@afbin/cli 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/afbin.mjs +33 -12
- package/dist/index.mjs +11 -1
- package/dist/runtime/dist/web/.vite/manifest.json +216 -216
- package/dist/runtime/dist/web/assets/{Account-CvOF6jpD.js → Account-qnxwLep7.js} +1 -1
- package/dist/runtime/dist/web/assets/Account-qnxwLep7.js.br +0 -0
- package/dist/runtime/dist/web/assets/Account-qnxwLep7.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ArtifactAddress-DORDne01.js → ArtifactAddress-1ftOG9A5.js} +2 -2
- package/dist/runtime/dist/web/assets/ArtifactAddress-1ftOG9A5.js.br +0 -0
- package/dist/runtime/dist/web/assets/ArtifactAddress-1ftOG9A5.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ArtifactData-BdL9R2dA.js → ArtifactData-CZq-MLWc.js} +1 -1
- package/dist/runtime/dist/web/assets/ArtifactData-CZq-MLWc.js.br +0 -0
- package/dist/runtime/dist/web/assets/ArtifactData-CZq-MLWc.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ArtifactEditor-BZXbOk_F.js → ArtifactEditor-Cd_-Z6DK.js} +1 -1
- package/dist/runtime/dist/web/assets/ArtifactEditor-Cd_-Z6DK.js.br +0 -0
- package/dist/runtime/dist/web/assets/ArtifactEditor-Cd_-Z6DK.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{AssetPageHeader-DX2RcYTv.js → AssetPageHeader-BqdRtu9K.js} +1 -1
- package/dist/runtime/dist/web/assets/AssetPageHeader-BqdRtu9K.js.br +0 -0
- package/dist/runtime/dist/web/assets/AssetPageHeader-BqdRtu9K.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Assets-dgdXIgAW.js → Assets-D6htDZnu.js} +1 -1
- package/dist/runtime/dist/web/assets/Assets-D6htDZnu.js.br +0 -0
- package/dist/runtime/dist/web/assets/Assets-D6htDZnu.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{AvatarCircle-MNnIhRvg.js → AvatarCircle-CBpOuCGy.js} +1 -1
- package/dist/runtime/dist/web/assets/AvatarCircle-CBpOuCGy.js.br +0 -0
- package/dist/runtime/dist/web/assets/AvatarCircle-CBpOuCGy.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Chat-V1ku1-60.js → Chat-DueKnMAf.js} +1 -1
- package/dist/runtime/dist/web/assets/Chat-DueKnMAf.js.br +0 -0
- package/dist/runtime/dist/web/assets/Chat-DueKnMAf.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ConfirmDialog-Ph1VDgNN.js → ConfirmDialog-hdkXS1mg.js} +1 -1
- package/dist/runtime/dist/web/assets/ConfirmDialog-hdkXS1mg.js.br +0 -0
- package/dist/runtime/dist/web/assets/ConfirmDialog-hdkXS1mg.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{DatasetCatalogView-DBJEPKFI.js → DatasetCatalogView-DKNdjYA_.js} +1 -1
- package/dist/runtime/dist/web/assets/DatasetCatalogView-DKNdjYA_.js.br +0 -0
- package/dist/runtime/dist/web/assets/DatasetCatalogView-DKNdjYA_.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{DatasetEditor-CMqN1duq.js → DatasetEditor-C22-4oJL.js} +1 -1
- package/dist/runtime/dist/web/assets/DatasetEditor-C22-4oJL.js.br +0 -0
- package/dist/runtime/dist/web/assets/DatasetEditor-C22-4oJL.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Docs-DVoW7b7v.js → Docs-B80IZLN8.js} +1 -1
- package/dist/runtime/dist/web/assets/Docs-B80IZLN8.js.br +0 -0
- package/dist/runtime/dist/web/assets/Docs-B80IZLN8.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Document-udhy5mlX.js → Document-C6-E9V3_.js} +4 -4
- package/dist/runtime/dist/web/assets/Document-C6-E9V3_.js.br +0 -0
- package/dist/runtime/dist/web/assets/Document-C6-E9V3_.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{DocumentChrome-EUbW_JvA.js → DocumentChrome-Bw4_z5yQ.js} +1 -1
- package/dist/runtime/dist/web/assets/DocumentChrome-Bw4_z5yQ.js.br +0 -0
- package/dist/runtime/dist/web/assets/DocumentChrome-Bw4_z5yQ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{DocumentSharing-BuTXuflA.js → DocumentSharing-BiTakFtn.js} +1 -1
- package/dist/runtime/dist/web/assets/DocumentSharing-BiTakFtn.js.br +0 -0
- package/dist/runtime/dist/web/assets/DocumentSharing-BiTakFtn.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{FileUpload-D6RTOrHD.js → FileUpload-B-da-wki.js} +1 -1
- package/dist/runtime/dist/web/assets/FileUpload-B-da-wki.js.br +0 -0
- package/dist/runtime/dist/web/assets/FileUpload-B-da-wki.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Folder-DoNsFB2I.js → Folder-B-OlCz39.js} +1 -1
- package/dist/runtime/dist/web/assets/Folder-B-OlCz39.js.br +0 -0
- package/dist/runtime/dist/web/assets/Folder-B-OlCz39.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ForkArtifact-DDmXl1BZ.js → ForkArtifact-DXYU1-qL.js} +1 -1
- package/dist/runtime/dist/web/assets/ForkArtifact-DXYU1-qL.js.br +0 -0
- package/dist/runtime/dist/web/assets/ForkArtifact-DXYU1-qL.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{GetStarted-YjltMEeN.js → GetStarted-CFsSvXR0.js} +1 -1
- package/dist/runtime/dist/web/assets/GetStarted-CFsSvXR0.js.br +0 -0
- package/dist/runtime/dist/web/assets/GetStarted-CFsSvXR0.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Home-DijnltFZ.js → Home-BSO7YYXA.js} +1 -1
- package/dist/runtime/dist/web/assets/Home-BSO7YYXA.js.br +0 -0
- package/dist/runtime/dist/web/assets/Home-BSO7YYXA.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Login-DLwn4aUr.js → Login-CszZ8VGu.js} +1 -1
- package/dist/runtime/dist/web/assets/Login-CszZ8VGu.js.br +0 -0
- package/dist/runtime/dist/web/assets/Login-CszZ8VGu.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{NotFound-svz4wCeL.js → NotFound-D2MOGkIO.js} +1 -1
- package/dist/runtime/dist/web/assets/NotFound-D2MOGkIO.js.br +0 -0
- package/dist/runtime/dist/web/assets/NotFound-D2MOGkIO.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Notifications-BGeJKv2W.js → Notifications-M7BiDhSo.js} +1 -1
- package/dist/runtime/dist/web/assets/Notifications-M7BiDhSo.js.br +0 -0
- package/dist/runtime/dist/web/assets/Notifications-M7BiDhSo.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Profile-B38GeCbR.js → Profile-DqV5PMEi.js} +2 -2
- package/dist/runtime/dist/web/assets/Profile-DqV5PMEi.js.br +0 -0
- package/dist/runtime/dist/web/assets/Profile-DqV5PMEi.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Program-D3-Gfvjo.js → Program-CdwfK2zE.js} +1 -1
- package/dist/runtime/dist/web/assets/Program-CdwfK2zE.js.br +0 -0
- package/dist/runtime/dist/web/assets/Program-CdwfK2zE.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{RowMenu-J4Gbci3B.js → RowMenu-B2c9LyOb.js} +1 -1
- package/dist/runtime/dist/web/assets/RowMenu-B2c9LyOb.js.br +0 -0
- package/dist/runtime/dist/web/assets/RowMenu-B2c9LyOb.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Schedules-D05tndQ1.js +1 -0
- package/dist/runtime/dist/web/assets/Schedules-D05tndQ1.js.br +0 -0
- package/dist/runtime/dist/web/assets/Schedules-D05tndQ1.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ScreenshotEditor-CUmN5F2q.js → ScreenshotEditor-B8g3LiBx.js} +1 -1
- package/dist/runtime/dist/web/assets/ScreenshotEditor-B8g3LiBx.js.br +0 -0
- package/dist/runtime/dist/web/assets/ScreenshotEditor-B8g3LiBx.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{ShareLink-n8KhtnaI.js → ShareLink-qbYss_Eh.js} +1 -1
- package/dist/runtime/dist/web/assets/ShareLink-qbYss_Eh.js.br +0 -0
- package/dist/runtime/dist/web/assets/ShareLink-qbYss_Eh.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Shelf-BgwHOaeW.js → Shelf-anhc5No9.js} +1 -1
- package/dist/runtime/dist/web/assets/Shelf-anhc5No9.js.br +0 -0
- package/dist/runtime/dist/web/assets/Shelf-anhc5No9.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{SocialPreviewEditor-DwHHRW29.js → SocialPreviewEditor-B4nUY6FA.js} +1 -1
- package/dist/runtime/dist/web/assets/SocialPreviewEditor-B4nUY6FA.js.br +0 -0
- package/dist/runtime/dist/web/assets/SocialPreviewEditor-B4nUY6FA.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Starter-I01MNooi.js → Starter-DrID859q.js} +1 -1
- package/dist/runtime/dist/web/assets/Starter-DrID859q.js.br +0 -0
- package/dist/runtime/dist/web/assets/Starter-DrID859q.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Trash-Cu0KXeW7.js → Trash-DoKID_ux.js} +1 -1
- package/dist/runtime/dist/web/assets/Trash-DoKID_ux.js.br +0 -0
- package/dist/runtime/dist/web/assets/Trash-DoKID_ux.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{Welcome-B8iPt_Nh.js → Welcome-Ct29u9Y9.js} +1 -1
- package/dist/runtime/dist/web/assets/Welcome-Ct29u9Y9.js.br +0 -0
- package/dist/runtime/dist/web/assets/Welcome-Ct29u9Y9.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{WorkspaceLayout-fF_ot7EK.js → WorkspaceLayout-Qf3x5yOM.js} +1 -1
- package/dist/runtime/dist/web/assets/WorkspaceLayout-Qf3x5yOM.js.br +0 -0
- package/dist/runtime/dist/web/assets/WorkspaceLayout-Qf3x5yOM.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{browser-artifact-write-ZsGe-hXr.js → browser-artifact-write-CG72iseh.js} +1 -1
- package/dist/runtime/dist/web/assets/browser-artifact-write-CG72iseh.js.br +0 -0
- package/dist/runtime/dist/web/assets/browser-artifact-write-CG72iseh.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{chevron-down-COGO5cmx.js → chevron-down-M1fHuk7u.js} +1 -1
- package/dist/runtime/dist/web/assets/{chevron-left-BJZiR3W-.js → chevron-left-NHmvDJpN.js} +1 -1
- package/dist/runtime/dist/web/assets/{copy-PNNAtmJH.js → copy-v5iTV3kk.js} +1 -1
- package/dist/runtime/dist/web/assets/copy-v5iTV3kk.js.br +0 -0
- package/dist/runtime/dist/web/assets/copy-v5iTV3kk.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{database-CKOnpvwb.js → database-BbH2eTSj.js} +1 -1
- package/dist/runtime/dist/web/assets/database-BbH2eTSj.js.br +2 -0
- package/dist/runtime/dist/web/assets/database-BbH2eTSj.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{document-update-client-DUF0zs2Z.js → document-update-client-td73lQ81.js} +1 -1
- package/dist/runtime/dist/web/assets/document-update-client-td73lQ81.js.br +0 -0
- package/dist/runtime/dist/web/assets/document-update-client-td73lQ81.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{dom-mounter-64phOf1s.js → dom-mounter-BSxIt5bC.js} +1 -1
- package/dist/runtime/dist/web/assets/dom-mounter-BSxIt5bC.js.br +0 -0
- package/dist/runtime/dist/web/assets/dom-mounter-BSxIt5bC.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{download-j-nqks7p.js → download-Dk3mxCBK.js} +1 -1
- package/dist/runtime/dist/web/assets/download-Dk3mxCBK.js.br +0 -0
- package/dist/runtime/dist/web/assets/download-Dk3mxCBK.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{eye-BNpzRKAK.js → eye-DEiYMLrO.js} +1 -1
- package/dist/runtime/dist/web/assets/eye-DEiYMLrO.js.br +0 -0
- package/dist/runtime/dist/web/assets/eye-DEiYMLrO.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{file-up-DH-HiKEX.js → file-up-GoLKOXxO.js} +1 -1
- package/dist/runtime/dist/web/assets/file-up-GoLKOXxO.js.br +1 -0
- package/dist/runtime/dist/web/assets/file-up-GoLKOXxO.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{git-fork-PQOXxmWW.js → git-fork-CN41g1lF.js} +1 -1
- package/dist/runtime/dist/web/assets/git-fork-CN41g1lF.js.br +0 -0
- package/dist/runtime/dist/web/assets/git-fork-CN41g1lF.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{http-C2exCIpl.js → http-DEdzW08u.js} +1 -1
- package/dist/runtime/dist/web/assets/http-DEdzW08u.js.br +0 -0
- package/dist/runtime/dist/web/assets/http-DEdzW08u.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{list-Dj3WErnh.js → list-CA_o21oZ.js} +1 -1
- package/dist/runtime/dist/web/assets/list-CA_o21oZ.js.br +0 -0
- package/dist/runtime/dist/web/assets/list-CA_o21oZ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{loader-circle-BXxJOPx-.js → loader-circle-2p_rsu6P.js} +1 -1
- package/dist/runtime/dist/web/assets/{lock-B1nhk71f.js → lock-BRsIxNP2.js} +1 -1
- package/dist/runtime/dist/web/assets/lock-BRsIxNP2.js.br +0 -0
- package/dist/runtime/dist/web/assets/lock-BRsIxNP2.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{person-mentions-BEjAedYZ.js → person-mentions-C7vQd7Vr.js} +1 -1
- package/dist/runtime/dist/web/assets/person-mentions-C7vQd7Vr.js.br +0 -0
- package/dist/runtime/dist/web/assets/person-mentions-C7vQd7Vr.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{plus-BtWrAD8F.js → plus-BNzHjmEg.js} +1 -1
- package/dist/runtime/dist/web/assets/{rotate-ccw-CSJ78xUE.js → rotate-ccw-CIMUmeuJ.js} +1 -1
- package/dist/runtime/dist/web/assets/rotate-ccw-CIMUmeuJ.js.br +0 -0
- package/dist/runtime/dist/web/assets/rotate-ccw-CIMUmeuJ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{search-agWZofH1.js → search-CmIkt7xE.js} +1 -1
- package/dist/runtime/dist/web/assets/{session-D__Apnw9.js → session-BsshdoaV.js} +1 -1
- package/dist/runtime/dist/web/assets/session-BsshdoaV.js.br +0 -0
- package/dist/runtime/dist/web/assets/session-BsshdoaV.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{shelf-CeaX4iBg.js → shelf-DUXW45ap.js} +1 -1
- package/dist/runtime/dist/web/assets/shelf-DUXW45ap.js.br +0 -0
- package/dist/runtime/dist/web/assets/shelf-DUXW45ap.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{solid-app-BtmRR9Ax.js → solid-app-BNcsMwv4.js} +2 -2
- package/dist/runtime/dist/web/assets/solid-app-BNcsMwv4.js.br +0 -0
- package/dist/runtime/dist/web/assets/solid-app-BNcsMwv4.js.gz +0 -0
- package/dist/runtime/dist/web/assets/solid-app-DRAhiXqs.css +2 -0
- package/dist/runtime/dist/web/assets/solid-app-DRAhiXqs.css.br +0 -0
- package/dist/runtime/dist/web/assets/solid-app-DRAhiXqs.css.gz +0 -0
- package/dist/runtime/dist/web/assets/{undo-2-Di8QrlfX.js → undo-2--XbU60MY.js} +1 -1
- package/dist/runtime/dist/web/assets/undo-2--XbU60MY.js.br +0 -0
- package/dist/runtime/dist/web/assets/undo-2--XbU60MY.js.gz +0 -0
- package/dist/runtime/dist/web/assets/{users-BJrdLUkX.js → users-Bm0xpNrq.js} +1 -1
- package/dist/runtime/dist/web/assets/users-Bm0xpNrq.js.br +0 -0
- package/dist/runtime/dist/web/assets/users-Bm0xpNrq.js.gz +0 -0
- package/dist/runtime/dist/web/solid-app.html +2 -2
- package/dist/runtime/draft-compile-worker.mjs +10 -0
- package/dist/runtime/host.mjs +12 -2
- package/dist/runtime/lambda-page-runtime.js +1 -1
- package/dist/runtime/lib/build-assets/.server-reader-cache.json +1 -1
- package/dist/runtime/lib/build-assets/offline/.build-cache.json +10 -7
- package/dist/runtime/lib/build-assets/offline/manifest.json +4 -4
- package/dist/runtime/lib/build-assets/offline/solid.js.gz +0 -0
- package/dist/runtime/lib/build-assets/prepared-sources.sha256 +1 -1
- package/dist/runtime/pool-worker.mjs +3 -0
- package/dist/runtime/preview/{ScreenshotEditor-R3UODF65.js → ScreenshotEditor-LHC3JZSA.js} +1 -1
- package/dist/runtime/preview/{annotate-U27XXRZK.js → annotate-THM7GL72.js} +1 -1
- package/dist/runtime/preview/chrome.css +1 -1
- package/dist/runtime/preview/{chunk-7RMKAFBO.js → chunk-4O7LVK2Q.js} +1 -1
- package/dist/runtime/preview/chunk-7T3V6PAW.js +1 -0
- package/dist/runtime/preview/{chunk-3KKU74WM.js → chunk-RDT3C3F6.js} +1 -1
- package/dist/runtime/preview/client.js +13 -13
- package/dist/runtime/preview/connect.js +1 -0
- package/dist/runtime/preview/{dom-mounter-3OQN7G4J.js → dom-mounter-2URPGP2F.js} +1 -1
- package/dist/runtime/preview/{engine-I6R47UTB.js → engine-5UO3LPN5.js} +1 -1
- package/dist/runtime/preview/{selection-actions-426G2H4N.js → selection-actions-LBFPODLD.js} +1 -1
- package/dist/runtime/preview/{session-UFN5GQK2.js → session-A2Z3M7QD.js} +1 -1
- package/dist/runtime/preview/update-parts-ZLXTYSVY.js +1 -0
- package/dist/runtime/preview.mjs +74496 -74135
- package/dist/runtime/public/chat/install.ps1 +1 -1
- package/dist/runtime/public/chat/install.sh +1 -1
- package/dist/runtime/public/chat/release.json +1 -1
- package/dist/runtime/public/islands/{boot-74e9143aa374c62b.js → boot-281adc05179334e6.js} +1 -1
- package/dist/runtime/public/islands/boot-281adc05179334e6.js.br +0 -0
- package/dist/runtime/public/islands/boot-281adc05179334e6.js.gz +0 -0
- package/dist/runtime/public/islands/{chunk-51a4b62dc42f3594.js → chunk-1af2f1c5f3e99805.js} +1 -1
- package/dist/runtime/public/islands/chunk-1af2f1c5f3e99805.js.br +0 -0
- package/dist/runtime/public/islands/chunk-1af2f1c5f3e99805.js.gz +0 -0
- package/dist/runtime/public/islands/{chunk-f451297257164687.js → chunk-2f5d885a7394f865.js} +1 -1
- package/dist/runtime/public/islands/chunk-2f5d885a7394f865.js.br +0 -0
- package/dist/runtime/public/islands/{chunk-f451297257164687.js.gz → chunk-2f5d885a7394f865.js.gz} +0 -0
- package/dist/runtime/public/islands/{chunk-68a083200dbd5bf7.js → chunk-3cb86bf7badbd2c3.js} +1 -1
- package/dist/runtime/public/islands/chunk-3cb86bf7badbd2c3.js.br +0 -0
- package/dist/runtime/public/islands/chunk-3cb86bf7badbd2c3.js.gz +0 -0
- package/dist/runtime/public/islands/{chunk-adcd632c8be50ba7.js → chunk-5e05b99cb275660b.js} +1 -1
- package/dist/runtime/public/islands/chunk-5e05b99cb275660b.js.br +0 -0
- package/dist/runtime/public/islands/{chunk-adcd632c8be50ba7.js.gz → chunk-5e05b99cb275660b.js.gz} +0 -0
- package/dist/runtime/public/islands/{chunk-e817ee4addba2d95.js → chunk-d924d4620b11b893.js} +1 -1
- package/dist/runtime/public/islands/chunk-d924d4620b11b893.js.br +0 -0
- package/dist/runtime/public/islands/chunk-d924d4620b11b893.js.gz +0 -0
- package/dist/runtime/public/islands/{chunk-1fa28532f51beb9c.js → chunk-dfe07cc2b19c50cc.js} +1 -1
- package/dist/runtime/public/islands/{frame-editor-6b8a50886fff8604.js → frame-editor-66b0c0d98283e912.js} +1 -1
- package/dist/runtime/public/islands/frame-editor-66b0c0d98283e912.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-66b0c0d98283e912.js.gz +0 -0
- package/dist/runtime/public/islands/{frame-editor-chunk-87b0311faf57261c.js → frame-editor-chunk-091e41cba1670be1.js} +1 -1
- package/dist/runtime/public/islands/frame-editor-chunk-091e41cba1670be1.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-091e41cba1670be1.js.gz +0 -0
- package/dist/runtime/public/islands/{frame-editor-chunk-69c553d9c4562981.js → frame-editor-chunk-5ea52db3a6d93294.js} +1 -1
- package/dist/runtime/public/islands/frame-editor-chunk-5ea52db3a6d93294.js.br +2 -0
- package/dist/runtime/public/islands/frame-editor-chunk-5ea52db3a6d93294.js.gz +0 -0
- package/dist/runtime/public/islands/{frame-editor-chunk-c2b9018371100824.js → frame-editor-chunk-a6db6db210776f5c.js} +1 -1
- package/dist/runtime/public/islands/frame-editor-chunk-a6db6db210776f5c.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-a6db6db210776f5c.js.gz +0 -0
- package/dist/runtime/public/islands/{frame-editor-chunk-a13dce46b9b8401f.js → frame-editor-chunk-c9facbfeee3c9bed.js} +1 -1
- package/dist/runtime/public/islands/frame-editor-chunk-c9facbfeee3c9bed.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-c9facbfeee3c9bed.js.gz +0 -0
- package/dist/runtime/public/islands/{frame-editor-chunk-b06f17fc7dae17e8.js → frame-editor-chunk-d6c77179f72db0ab.js} +1 -1
- package/dist/runtime/public/islands/frame-editor-chunk-d6c77179f72db0ab.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-d6c77179f72db0ab.js.gz +0 -0
- package/dist/runtime/public/islands/{image-map-a9f95f7e8d0712c1.js → image-map-7419ab54ff59434a.js} +1 -1
- package/dist/runtime/public/islands/image-map-7419ab54ff59434a.js.br +0 -0
- package/dist/runtime/public/islands/image-map-7419ab54ff59434a.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-basic-cbabcc4b41d6132a.js → kit-basic-c22b54dcd2ea6161.js} +1 -1
- package/dist/runtime/public/islands/kit-basic-c22b54dcd2ea6161.js.br +2 -0
- package/dist/runtime/public/islands/kit-basic-c22b54dcd2ea6161.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-cells-cefbceccdfd0dbe0.js → kit-cells-55ade213f1751716.js} +1 -1
- package/dist/runtime/public/islands/kit-cells-55ade213f1751716.js.br +0 -0
- package/dist/runtime/public/islands/kit-cells-55ade213f1751716.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-controls-81d17a10f9d457f2.js → kit-controls-4f1b98d7d87c4b21.js} +1 -1
- package/dist/runtime/public/islands/kit-controls-4f1b98d7d87c4b21.js.br +0 -0
- package/dist/runtime/public/islands/kit-controls-4f1b98d7d87c4b21.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-data-43947f36f1c501aa.js → kit-data-e1012fd12092b177.js} +1 -1
- package/dist/runtime/public/islands/kit-data-e1012fd12092b177.js.br +0 -0
- package/dist/runtime/public/islands/kit-data-e1012fd12092b177.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-dialog-eedc51ce82feec4b.js → kit-dialog-1e427336472b2906.js} +1 -1
- package/dist/runtime/public/islands/kit-dialog-1e427336472b2906.js.br +0 -0
- package/dist/runtime/public/islands/kit-dialog-1e427336472b2906.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-embed-3c8886cbfa06f74d.js → kit-embed-c7019820c5200806.js} +1 -1
- package/dist/runtime/public/islands/kit-embed-c7019820c5200806.js.br +0 -0
- package/dist/runtime/public/islands/kit-embed-c7019820c5200806.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-files-b7a2cb758f00a68b.js → kit-files-dc0b71ca71f2151c.js} +1 -1
- package/dist/runtime/public/islands/kit-files-dc0b71ca71f2151c.js.br +0 -0
- package/dist/runtime/public/islands/kit-files-dc0b71ca71f2151c.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-image-126e12fcae4215c1.js → kit-image-b31acf4d31a4eeaf.js} +1 -1
- package/dist/runtime/public/islands/kit-image-b31acf4d31a4eeaf.js.br +0 -0
- package/dist/runtime/public/islands/kit-image-b31acf4d31a4eeaf.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-people-5b6f5dd4aa82b657.js → kit-people-6feb1b730c5fd37f.js} +1 -1
- package/dist/runtime/public/islands/kit-people-6feb1b730c5fd37f.js.br +0 -0
- package/dist/runtime/public/islands/kit-people-6feb1b730c5fd37f.js.gz +0 -0
- package/dist/runtime/public/islands/{kit-static-28174bd8f593f8c0.js → kit-static-853aed2cd04c1b4a.js} +1 -1
- package/dist/runtime/public/islands/kit-static-853aed2cd04c1b4a.js.br +0 -0
- package/dist/runtime/public/islands/kit-static-853aed2cd04c1b4a.js.gz +0 -0
- package/dist/runtime/public/islands/manifest.json +211 -211
- package/dist/runtime/public/islands/manifest.json.br +0 -0
- package/dist/runtime/public/islands/manifest.json.gz +0 -0
- package/dist/runtime/public/islands/{morph-engine-4e664485be475dbf.js → morph-engine-c61693caf767d9bd.js} +1 -1
- package/dist/runtime/public/islands/morph-engine-c61693caf767d9bd.js.br +0 -0
- package/dist/runtime/public/islands/morph-engine-c61693caf767d9bd.js.gz +0 -0
- package/dist/runtime/public/islands/offline-ba3717e06bc69a4e.json.gzip +0 -0
- package/dist/runtime/public/islands/{page-5f87c34c7c181387.js → page-c3ae4acf0988c2b6.js} +1 -1
- package/dist/runtime/public/islands/page-c3ae4acf0988c2b6.js.br +0 -0
- package/dist/runtime/public/islands/page-c3ae4acf0988c2b6.js.gz +0 -0
- package/dist/runtime/public/islands/{rt-30ff0d94ee3732a1.js → rt-2ab0fed85481c574.js} +1 -1
- package/dist/runtime/public/islands/rt-2ab0fed85481c574.js.br +0 -0
- package/dist/runtime/public/islands/rt-2ab0fed85481c574.js.gz +0 -0
- package/dist/runtime/public/islands/{sqlite-engine-9fc56fea8b1e2aaf.js → sqlite-engine-f3956693df7cfa5c.js} +8 -8
- package/dist/runtime/public/islands/sqlite-engine-f3956693df7cfa5c.js.br +0 -0
- package/dist/runtime/public/islands/sqlite-engine-f3956693df7cfa5c.js.gz +0 -0
- package/dist/runtime/public/islands/{ssr-456cabbcb26f723d.js → ssr-ce6931fb7bda9b08.js} +3 -0
- package/dist/runtime/public/islands/ssr-ce6931fb7bda9b08.js.br +0 -0
- package/dist/runtime/public/islands/ssr-ce6931fb7bda9b08.js.gz +0 -0
- package/dist/runtime/public/islands/{url-sync-74b5212f7b3417d7.js → url-sync-b179b054c9d958a7.js} +1 -1
- package/dist/runtime/public/islands/url-sync-b179b054c9d958a7.js.br +0 -0
- package/dist/runtime/public/islands/url-sync-b179b054c9d958a7.js.gz +0 -0
- package/dist/share/man/man1/afbin.1 +6 -4
- package/dist/skills/artifactbin/references/commands.md +4 -2
- package/dist/skills/artifactbin/references/publishing.md +5 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/runtime/dist/web/assets/Account-CvOF6jpD.js.br +0 -0
- package/dist/runtime/dist/web/assets/Account-CvOF6jpD.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ArtifactAddress-DORDne01.js.br +0 -0
- package/dist/runtime/dist/web/assets/ArtifactAddress-DORDne01.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ArtifactData-BdL9R2dA.js.br +0 -0
- package/dist/runtime/dist/web/assets/ArtifactData-BdL9R2dA.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ArtifactEditor-BZXbOk_F.js.br +0 -0
- package/dist/runtime/dist/web/assets/ArtifactEditor-BZXbOk_F.js.gz +0 -0
- package/dist/runtime/dist/web/assets/AssetPageHeader-DX2RcYTv.js.br +0 -0
- package/dist/runtime/dist/web/assets/AssetPageHeader-DX2RcYTv.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Assets-dgdXIgAW.js.br +0 -0
- package/dist/runtime/dist/web/assets/Assets-dgdXIgAW.js.gz +0 -0
- package/dist/runtime/dist/web/assets/AvatarCircle-MNnIhRvg.js.br +0 -0
- package/dist/runtime/dist/web/assets/AvatarCircle-MNnIhRvg.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Chat-V1ku1-60.js.br +0 -0
- package/dist/runtime/dist/web/assets/Chat-V1ku1-60.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ConfirmDialog-Ph1VDgNN.js.br +0 -0
- package/dist/runtime/dist/web/assets/ConfirmDialog-Ph1VDgNN.js.gz +0 -0
- package/dist/runtime/dist/web/assets/DatasetCatalogView-DBJEPKFI.js.br +0 -0
- package/dist/runtime/dist/web/assets/DatasetCatalogView-DBJEPKFI.js.gz +0 -0
- package/dist/runtime/dist/web/assets/DatasetEditor-CMqN1duq.js.br +0 -0
- package/dist/runtime/dist/web/assets/DatasetEditor-CMqN1duq.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Docs-DVoW7b7v.js.br +0 -0
- package/dist/runtime/dist/web/assets/Docs-DVoW7b7v.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Document-udhy5mlX.js.br +0 -0
- package/dist/runtime/dist/web/assets/Document-udhy5mlX.js.gz +0 -0
- package/dist/runtime/dist/web/assets/DocumentChrome-EUbW_JvA.js.br +0 -0
- package/dist/runtime/dist/web/assets/DocumentChrome-EUbW_JvA.js.gz +0 -0
- package/dist/runtime/dist/web/assets/DocumentSharing-BuTXuflA.js.br +0 -0
- package/dist/runtime/dist/web/assets/DocumentSharing-BuTXuflA.js.gz +0 -0
- package/dist/runtime/dist/web/assets/FileUpload-D6RTOrHD.js.br +0 -0
- package/dist/runtime/dist/web/assets/FileUpload-D6RTOrHD.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Folder-DoNsFB2I.js.br +0 -0
- package/dist/runtime/dist/web/assets/Folder-DoNsFB2I.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ForkArtifact-DDmXl1BZ.js.br +0 -0
- package/dist/runtime/dist/web/assets/ForkArtifact-DDmXl1BZ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/GetStarted-YjltMEeN.js.br +0 -0
- package/dist/runtime/dist/web/assets/GetStarted-YjltMEeN.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Home-DijnltFZ.js.br +0 -0
- package/dist/runtime/dist/web/assets/Home-DijnltFZ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Login-DLwn4aUr.js.br +0 -0
- package/dist/runtime/dist/web/assets/Login-DLwn4aUr.js.gz +0 -0
- package/dist/runtime/dist/web/assets/NotFound-svz4wCeL.js.br +0 -0
- package/dist/runtime/dist/web/assets/NotFound-svz4wCeL.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Notifications-BGeJKv2W.js.br +0 -0
- package/dist/runtime/dist/web/assets/Notifications-BGeJKv2W.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Profile-B38GeCbR.js.br +0 -0
- package/dist/runtime/dist/web/assets/Profile-B38GeCbR.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Program-D3-Gfvjo.js.br +0 -0
- package/dist/runtime/dist/web/assets/Program-D3-Gfvjo.js.gz +0 -0
- package/dist/runtime/dist/web/assets/RowMenu-J4Gbci3B.js.br +0 -0
- package/dist/runtime/dist/web/assets/RowMenu-J4Gbci3B.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Schedules-DK3-YUvJ.js +0 -1
- package/dist/runtime/dist/web/assets/Schedules-DK3-YUvJ.js.br +0 -0
- package/dist/runtime/dist/web/assets/Schedules-DK3-YUvJ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ScreenshotEditor-CUmN5F2q.js.br +0 -0
- package/dist/runtime/dist/web/assets/ScreenshotEditor-CUmN5F2q.js.gz +0 -0
- package/dist/runtime/dist/web/assets/ShareLink-n8KhtnaI.js.br +0 -0
- package/dist/runtime/dist/web/assets/ShareLink-n8KhtnaI.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Shelf-BgwHOaeW.js.br +0 -0
- package/dist/runtime/dist/web/assets/Shelf-BgwHOaeW.js.gz +0 -0
- package/dist/runtime/dist/web/assets/SocialPreviewEditor-DwHHRW29.js.br +0 -0
- package/dist/runtime/dist/web/assets/SocialPreviewEditor-DwHHRW29.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Starter-I01MNooi.js.br +0 -0
- package/dist/runtime/dist/web/assets/Starter-I01MNooi.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Trash-Cu0KXeW7.js.br +0 -0
- package/dist/runtime/dist/web/assets/Trash-Cu0KXeW7.js.gz +0 -0
- package/dist/runtime/dist/web/assets/Welcome-B8iPt_Nh.js.br +0 -0
- package/dist/runtime/dist/web/assets/Welcome-B8iPt_Nh.js.gz +0 -0
- package/dist/runtime/dist/web/assets/WorkspaceLayout-fF_ot7EK.js.br +0 -0
- package/dist/runtime/dist/web/assets/WorkspaceLayout-fF_ot7EK.js.gz +0 -0
- package/dist/runtime/dist/web/assets/browser-artifact-write-ZsGe-hXr.js.br +0 -0
- package/dist/runtime/dist/web/assets/browser-artifact-write-ZsGe-hXr.js.gz +0 -0
- package/dist/runtime/dist/web/assets/copy-PNNAtmJH.js.br +0 -0
- package/dist/runtime/dist/web/assets/copy-PNNAtmJH.js.gz +0 -0
- package/dist/runtime/dist/web/assets/database-CKOnpvwb.js.br +0 -3
- package/dist/runtime/dist/web/assets/database-CKOnpvwb.js.gz +0 -0
- package/dist/runtime/dist/web/assets/document-update-client-DUF0zs2Z.js.br +0 -0
- package/dist/runtime/dist/web/assets/document-update-client-DUF0zs2Z.js.gz +0 -0
- package/dist/runtime/dist/web/assets/dom-mounter-64phOf1s.js.br +0 -0
- package/dist/runtime/dist/web/assets/dom-mounter-64phOf1s.js.gz +0 -0
- package/dist/runtime/dist/web/assets/download-j-nqks7p.js.br +0 -0
- package/dist/runtime/dist/web/assets/download-j-nqks7p.js.gz +0 -0
- package/dist/runtime/dist/web/assets/eye-BNpzRKAK.js.br +0 -0
- package/dist/runtime/dist/web/assets/eye-BNpzRKAK.js.gz +0 -0
- package/dist/runtime/dist/web/assets/file-up-DH-HiKEX.js.br +0 -0
- package/dist/runtime/dist/web/assets/file-up-DH-HiKEX.js.gz +0 -0
- package/dist/runtime/dist/web/assets/git-fork-PQOXxmWW.js.br +0 -0
- package/dist/runtime/dist/web/assets/git-fork-PQOXxmWW.js.gz +0 -0
- package/dist/runtime/dist/web/assets/http-C2exCIpl.js.br +0 -0
- package/dist/runtime/dist/web/assets/http-C2exCIpl.js.gz +0 -0
- package/dist/runtime/dist/web/assets/list-Dj3WErnh.js.br +0 -0
- package/dist/runtime/dist/web/assets/list-Dj3WErnh.js.gz +0 -0
- package/dist/runtime/dist/web/assets/lock-B1nhk71f.js.br +0 -0
- package/dist/runtime/dist/web/assets/lock-B1nhk71f.js.gz +0 -0
- package/dist/runtime/dist/web/assets/person-mentions-BEjAedYZ.js.br +0 -0
- package/dist/runtime/dist/web/assets/person-mentions-BEjAedYZ.js.gz +0 -0
- package/dist/runtime/dist/web/assets/rotate-ccw-CSJ78xUE.js.br +0 -0
- package/dist/runtime/dist/web/assets/rotate-ccw-CSJ78xUE.js.gz +0 -0
- package/dist/runtime/dist/web/assets/session-D__Apnw9.js.br +0 -0
- package/dist/runtime/dist/web/assets/session-D__Apnw9.js.gz +0 -0
- package/dist/runtime/dist/web/assets/shelf-CeaX4iBg.js.br +0 -0
- package/dist/runtime/dist/web/assets/shelf-CeaX4iBg.js.gz +0 -0
- package/dist/runtime/dist/web/assets/solid-app-BmdFnFpX.css +0 -2
- package/dist/runtime/dist/web/assets/solid-app-BmdFnFpX.css.br +0 -0
- package/dist/runtime/dist/web/assets/solid-app-BmdFnFpX.css.gz +0 -0
- package/dist/runtime/dist/web/assets/solid-app-BtmRR9Ax.js.br +0 -0
- package/dist/runtime/dist/web/assets/solid-app-BtmRR9Ax.js.gz +0 -0
- package/dist/runtime/dist/web/assets/undo-2-Di8QrlfX.js.br +0 -0
- package/dist/runtime/dist/web/assets/undo-2-Di8QrlfX.js.gz +0 -0
- package/dist/runtime/dist/web/assets/users-BJrdLUkX.js.br +0 -0
- package/dist/runtime/dist/web/assets/users-BJrdLUkX.js.gz +0 -0
- package/dist/runtime/preview/update-parts-OJC3ZSRW.js +0 -1
- package/dist/runtime/public/islands/boot-74e9143aa374c62b.js.br +0 -0
- package/dist/runtime/public/islands/boot-74e9143aa374c62b.js.gz +0 -0
- package/dist/runtime/public/islands/chunk-51a4b62dc42f3594.js.br +0 -0
- package/dist/runtime/public/islands/chunk-51a4b62dc42f3594.js.gz +0 -0
- package/dist/runtime/public/islands/chunk-68a083200dbd5bf7.js.br +0 -0
- package/dist/runtime/public/islands/chunk-68a083200dbd5bf7.js.gz +0 -0
- package/dist/runtime/public/islands/chunk-adcd632c8be50ba7.js.br +0 -0
- package/dist/runtime/public/islands/chunk-e817ee4addba2d95.js.br +0 -0
- package/dist/runtime/public/islands/chunk-e817ee4addba2d95.js.gz +0 -0
- package/dist/runtime/public/islands/chunk-f451297257164687.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-6b8a50886fff8604.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-6b8a50886fff8604.js.gz +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-69c553d9c4562981.js.br +0 -1
- package/dist/runtime/public/islands/frame-editor-chunk-69c553d9c4562981.js.gz +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-87b0311faf57261c.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-87b0311faf57261c.js.gz +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-a13dce46b9b8401f.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-a13dce46b9b8401f.js.gz +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-b06f17fc7dae17e8.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-b06f17fc7dae17e8.js.gz +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-c2b9018371100824.js.br +0 -0
- package/dist/runtime/public/islands/frame-editor-chunk-c2b9018371100824.js.gz +0 -0
- package/dist/runtime/public/islands/image-map-a9f95f7e8d0712c1.js.br +0 -0
- package/dist/runtime/public/islands/image-map-a9f95f7e8d0712c1.js.gz +0 -0
- package/dist/runtime/public/islands/kit-basic-cbabcc4b41d6132a.js.br +0 -0
- package/dist/runtime/public/islands/kit-basic-cbabcc4b41d6132a.js.gz +0 -0
- package/dist/runtime/public/islands/kit-cells-cefbceccdfd0dbe0.js.br +0 -0
- package/dist/runtime/public/islands/kit-cells-cefbceccdfd0dbe0.js.gz +0 -0
- package/dist/runtime/public/islands/kit-controls-81d17a10f9d457f2.js.br +0 -0
- package/dist/runtime/public/islands/kit-controls-81d17a10f9d457f2.js.gz +0 -0
- package/dist/runtime/public/islands/kit-data-43947f36f1c501aa.js.br +0 -0
- package/dist/runtime/public/islands/kit-data-43947f36f1c501aa.js.gz +0 -0
- package/dist/runtime/public/islands/kit-dialog-eedc51ce82feec4b.js.br +0 -0
- package/dist/runtime/public/islands/kit-dialog-eedc51ce82feec4b.js.gz +0 -0
- package/dist/runtime/public/islands/kit-embed-3c8886cbfa06f74d.js.br +0 -0
- package/dist/runtime/public/islands/kit-embed-3c8886cbfa06f74d.js.gz +0 -0
- package/dist/runtime/public/islands/kit-files-b7a2cb758f00a68b.js.br +0 -0
- package/dist/runtime/public/islands/kit-files-b7a2cb758f00a68b.js.gz +0 -0
- package/dist/runtime/public/islands/kit-image-126e12fcae4215c1.js.br +0 -0
- package/dist/runtime/public/islands/kit-image-126e12fcae4215c1.js.gz +0 -0
- package/dist/runtime/public/islands/kit-people-5b6f5dd4aa82b657.js.br +0 -0
- package/dist/runtime/public/islands/kit-people-5b6f5dd4aa82b657.js.gz +0 -0
- package/dist/runtime/public/islands/kit-static-28174bd8f593f8c0.js.br +0 -0
- package/dist/runtime/public/islands/kit-static-28174bd8f593f8c0.js.gz +0 -0
- package/dist/runtime/public/islands/morph-engine-4e664485be475dbf.js.br +0 -0
- package/dist/runtime/public/islands/morph-engine-4e664485be475dbf.js.gz +0 -0
- package/dist/runtime/public/islands/offline-4446a94ed9f706c3.json.gzip +0 -0
- package/dist/runtime/public/islands/page-5f87c34c7c181387.js.br +0 -0
- package/dist/runtime/public/islands/page-5f87c34c7c181387.js.gz +0 -0
- package/dist/runtime/public/islands/rt-30ff0d94ee3732a1.js.br +0 -0
- package/dist/runtime/public/islands/rt-30ff0d94ee3732a1.js.gz +0 -0
- package/dist/runtime/public/islands/sqlite-engine-9fc56fea8b1e2aaf.js.br +0 -0
- package/dist/runtime/public/islands/sqlite-engine-9fc56fea8b1e2aaf.js.gz +0 -0
- package/dist/runtime/public/islands/ssr-456cabbcb26f723d.js.br +0 -0
- package/dist/runtime/public/islands/ssr-456cabbcb26f723d.js.gz +0 -0
- package/dist/runtime/public/islands/url-sync-74b5212f7b3417d7.js.br +0 -0
- package/dist/runtime/public/islands/url-sync-74b5212f7b3417d7.js.gz +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var qo=Object.defineProperty;var Oe=(l,i,t)=>()=>{if(t)throw t[0];try{return l&&(i=l(l=0)),i}catch(p){throw t=[p],p}};var To=(l,i)=>{for(var t in i)qo(l,t,{get:i[t],enumerable:!0})};var Mr=Oe(()=>{"use strict"});var bt,At,Fr=Oe(()=>{"use strict";bt=l=>"error"in l,At=1e3});var Bn,Lr=Oe(()=>{"use strict";Bn=l=>l.replace(".","__")});var zn,jr,$r=Oe(()=>{"use strict";zn=[{name:"dayname",arity:[1],kind:"scalar",signature:"dayname(date) \u2192 text",summary:"Weekday name: Wednesday."},{name:"monthname",arity:[1],kind:"scalar",signature:"monthname(date) \u2192 text",summary:"Month name: September."},{name:"dayofweek",arity:[1],kind:"scalar",signature:"dayofweek(date) \u2192 integer",summary:"0 = Sunday \u2026 6 = Saturday."},{name:"date_trunc",arity:[2],kind:"scalar",signature:"date_trunc('day'|'week'|'month'|'quarter'|'year', date) \u2192 date",summary:"Start of the period; weeks start on Monday."},{name:"date_add",arity:[3],kind:"scalar",signature:"date_add(date, n, 'day'|'week'|'month'|'year'|'hour'|'minute') \u2192 date or timestamp",summary:"Adds n units; the result keeps the input kind."},{name:"date_diff",arity:[3],kind:"scalar",signature:"date_diff('day'|'week'|'month'|'year'|'hour'|'minute', start, end) \u2192 integer",summary:"Whole units from start to end."},{name:"date_part",arity:[2],kind:"scalar",signature:"date_part('year'|'quarter'|'month'|'week'|'day'|'hour'|'minute', date) \u2192 integer",summary:"One component; week is the ISO week."},{name:"date_format",arity:[2,3],kind:"scalar",signature:"date_format(date, pattern[, tz]) \u2192 text",summary:"Formats with strftime patterns (%a %A %b %B %d %e %H %M %Y \u2026), in tz when given."},{name:"date_parse",arity:[2],kind:"scalar",signature:"date_parse(text, pattern) \u2192 timestamp",summary:"Parses text with a strftime pattern; null when it does not match."},{name:"date_series",arity:[2,3],kind:"scalar",signature:"date_series(start, end[, 'day'|'week'|'month']) \u2192 list",summary:"Every date from start to end inclusive, as a JSON list; read it with json_each."},{name:"to_timezone",arity:[2],kind:"scalar",signature:"to_timezone(timestamp, tz) \u2192 text",summary:"The local wall-clock time in tz, as ISO text without offset."},{name:"make_date",arity:[3],kind:"scalar",signature:"make_date(year, month, day) \u2192 date",summary:"The date with these parts; fails on one the calendar does not have."},{name:"to_date",arity:[1],kind:"scalar",signature:"to_date(text) \u2192 date",summary:"The calendar day a date or timestamp names (2026-9-30, 2026/09/30, 2026-09-30T10:00Z); fails on text that names none."},{name:"try_to_date",arity:[1],kind:"scalar",signature:"try_to_date(text) \u2192 date",summary:"The calendar day, as to_date reads it; null when the text names none."},{name:"median",arity:[1],kind:"aggregate",signature:"median(x) \u2192 real",summary:"Middle value, averaging the two middle values."},{name:"quantile",arity:[2],kind:"aggregate",signature:"quantile(x, q) \u2192 real",summary:"Continuous quantile, q between 0 and 1."},{name:"stddev",arity:[1],kind:"aggregate",signature:"stddev(x) \u2192 real",summary:"Sample standard deviation."},{name:"stddev_pop",arity:[1],kind:"aggregate",signature:"stddev_pop(x) \u2192 real",summary:"Population standard deviation."},{name:"regr_slope",arity:[2],kind:"aggregate",signature:"regr_slope(y, x) \u2192 real",summary:"Least-squares slope of y against x, over rows with both."},{name:"regr_intercept",arity:[2],kind:"aggregate",signature:"regr_intercept(y, x) \u2192 real",summary:"Where the least-squares line of y against x crosses x = 0."},{name:"corr",arity:[2],kind:"aggregate",signature:"corr(y, x) \u2192 real",summary:"Pearson correlation of y and x, over rows with both."},{name:"arg_min",arity:[2],kind:"aggregate",signature:"arg_min(arg, value) \u2192 any",summary:"arg from the row with the least value (the first on a tie), over rows with both."},{name:"arg_max",arity:[2],kind:"aggregate",signature:"arg_max(arg, value) \u2192 any",summary:"arg from the row with the greatest value (the first on a tie), over rows with both."},{name:"round",arity:[1,2],kind:"scalar",signature:"round(x[, digits]) \u2192 number",summary:"Rounds half away from zero at the digits as written: round(13.975, 2) = 13.98."},{name:"to_number",arity:[1],kind:"scalar",signature:"to_number(text) \u2192 real",summary:"The number text names ('1.5', ' 2 ', '1e3'); null when it names none."},{name:"string_split",arity:[2],kind:"scalar",signature:"string_split(text, separator) \u2192 list",summary:"The parts between separators, as a JSON list; '' splits into characters."},{name:"split_part",arity:[3],kind:"scalar",signature:"split_part(text, separator, n) \u2192 text",summary:"The nth part (1-based; negative counts from the end), '' when there is none."},{name:"regexp_matches",arity:[2],kind:"scalar",signature:"regexp_matches(text, pattern) \u2192 boolean",summary:"JavaScript regular expression syntax."},{name:"regexp_replace",arity:[3],kind:"scalar",signature:"regexp_replace(text, pattern, replacement) \u2192 text",summary:"Replaces every match."},{name:"regexp_extract",arity:[2,3],kind:"scalar",signature:"regexp_extract(text, pattern[, group]) \u2192 text",summary:"The first match, or one of its groups."},{name:"list_contains",arity:[2],kind:"scalar",signature:"list_contains(list, value) \u2192 boolean",summary:"Whether a JSON list holds the value."},{name:"list_has_any",arity:[2],kind:"scalar",signature:"list_has_any(list, list) \u2192 boolean",summary:"Whether two JSON lists share a value."},{name:"to_list",arity:[1],kind:"scalar",signature:"to_list(text) \u2192 list",summary:`The list text names (["a","b"], [a, b], ['a', 'b']) as a JSON list of text, a bare null as null; fails on text that names none.`},{name:"try_to_list",arity:[1],kind:"scalar",signature:"try_to_list(text) \u2192 list",summary:"The list, as to_list reads it; null when the text names none."},{name:"list_value",arity:[0,1,2,3,4,5,6,7,8],kind:"scalar",signature:"list_value(a, b, \u2026) \u2192 list",summary:"Builds a JSON list."},{name:"uuid",arity:[0],kind:"scalar",signature:"uuid() \u2192 text",summary:"A random UUID; the one non-deterministic function, allowed only in mutations."}],jr=new Set(["uuid","random","randomblob"])});var Ur=Oe(()=>{"use strict"});var Br=Oe(()=>{"use strict"});var zr=Oe(()=>{"use strict"});var Qr=Oe(()=>{"use strict"});var Vr=Oe(()=>{"use strict"});var Wr=Oe(()=>{"use strict"});var Hr=Oe(()=>{"use strict"});var Gr=Oe(()=>{"use strict"});var Jr,Sa,va,Kr=Oe(()=>{"use strict";Jr="/api/internal",Sa=`${Jr}/tokens`,va=`${Jr}/artifact-approval`});var Yr=Oe(()=>{"use strict"});var Xr=Oe(()=>{"use strict"});var Zr=Oe(()=>{"use strict"});var ei=Oe(()=>{"use strict"});var ti=Oe(()=>{"use strict"});var ni=Oe(()=>{"use strict"});var ri=Oe(()=>{"use strict"});var ii=Oe(()=>{"use strict"});var si=Oe(()=>{"use strict"});var oi=Oe(()=>{"use strict"});var ai=Oe(()=>{"use strict"});var gn,li=Oe(()=>{"use strict";gn=[{name:"user_id",type:"user"},{name:"joined_at",type:"timestamp"}]});var ci=Oe(()=>{"use strict"});var ui=Oe(()=>{"use strict"});var fi=Oe(()=>{"use strict"});var di=Oe(()=>{"use strict"});var mi=Oe(()=>{"use strict"});var ht=Oe(()=>{"use strict";Mr();Fr();Lr();$r();Ur();Br();zr();Qr();Vr();Wr();Hr();Gr();Kr();Yr();Xr();Zr();ei();ti();ni();ri();ii();si();oi();ai();li();ci();ui();fi();di();mi()});function xt(l,i="timestamp"){let t=()=>{throw new Error(`${i}: invalid timestamp; use an ISO date/datetime (UTC when omitted), an explicit offset, or epoch milliseconds`)};if(typeof l=="number"){if(!Number.isFinite(l))return t();let ne=new Date(l);return Number.isNaN(ne.getTime())?t():ne.toISOString()}if(l instanceof Date)return Number.isNaN(l.getTime())?t():l.toISOString();if(typeof l!="string")return t();let p=/^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/i.exec(l.trim());if(!p)return t();let g=p[1],T=new Date(`${g}T00:00:00.000Z`);if(Number.isNaN(T.getTime())||T.toISOString().slice(0,10)!==g)return t();let I=p[2]??"00",j=p[3]??"00",H=p[4]??"00";if(+I>23||+j>59||+H>59)return t();let se=(p[5]??"").padEnd(3,"0").slice(0,3),ue=(p[6]??"Z").toUpperCase();/^[+-]\d{2}$/.test(ue)&&(ue+=":00"),/^[+-]\d{4}$/.test(ue)&&(ue=`${ue.slice(0,3)}:${ue.slice(3)}`);let Y=new Date(`${g}T${I}:${j}:${H}.${se}${ue}`);return Number.isNaN(Y.getTime())?t():Y.toISOString()}function Wt(l){try{return xt(l),!0}catch{return!1}}var Wn=Oe(()=>{"use strict"});function ko(l){return l==null?null:typeof l=="number"?"number":typeof l=="boolean"?"boolean":typeof l=="string"?xo.test(l)?"date":/^[0-9]{4}-/.test(l)&&Wt(l)?"timestamp":"string":null}function Ht(l){let i=[],t=new Map;for(let p of l)for(let[g,T]of Object.entries(p)){!t.has(g)&&!i.includes(g)&&i.push(g);let I=ko(T);if(I===null)continue;let j=t.get(g);j===void 0?t.set(g,I):j!==I&&t.set(g,"string")}return i.map(p=>({name:p,type:t.get(p)??"string"}))}var xo,kt=Oe(()=>{"use strict";Wn();Wn();xo=/^\d{4}-\d{2}-\d{2}$/});function Ge(l,i){throw new Error(`${l}: ${i}`)}function Yt(l){let i=Mi.exec(l);if(!i)return null;let t=Number(i[1]),p=Number(i[2]),g=Number(i[3]),T=t%4===0&&(t%100!==0||t%400===0),I=p===2?T?29:28:[4,6,9,11].includes(p)?30:31;return p>=1&&p<=12&&g>=1&&g<=I?new Date(0).setUTCFullYear(t,p-1,g):null}function pt(l,i){typeof i!="string"&&Ge(l,"expected ISO date or timestamp text");let t=Yt(i);return t!==null?{kind:"date",ms:t}:(Mi.test(i)&&Ge(l,`${i} is not a calendar date`),{kind:"timestamp",ms:Date.parse(xt(i,l))})}function Kn(l,i){let t=new Date(l),p=t.getUTCFullYear(),g=t.getUTCMonth()+i,T=new Date(Date.UTC(p,g+1,0)).getUTCDate();return Date.UTC(p,g,Math.min(t.getUTCDate(),T),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}function Fi(l){let i=new Date(l),t=Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()-(i.getUTCDay()+6)%7+3),p=new Date(t).getUTCFullYear();return{week:1+Math.floor((t-Date.UTC(p,0,1))/(7*Mt)),year:p}}function Li(l,i,t){if(t===void 0){let T=new Date(i);return{year:T.getUTCFullYear(),month:T.getUTCMonth()+1,day:T.getUTCDate(),hour:T.getUTCHours(),minute:T.getUTCMinutes(),second:T.getUTCSeconds(),ms:T.getUTCMilliseconds()}}let p=Ai.get(t);if(!p){try{p=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{Ge(l,`unknown time zone ${t}`)}Ai.set(t,p)}let g=Object.fromEntries(p.formatToParts(new Date(i)).map(T=>[T.type,T.value]));return{year:Number(g.year),month:Number(g.month),day:Number(g.day),hour:Number(g.hour),minute:Number(g.minute),second:Number(g.second),ms:(i%1e3+1e3)%1e3}}function Co(l,i,t,p){let g=Li(l,i.ms,i.kind==="date"?void 0:p),T=Date.UTC(g.year,g.month-1,g.day),I=new Date(T).getUTCDay(),j=g.hour%12||12,H=Fi(T);return t.replace(/%(-?)([a-zA-Z%])/g,(se,ue,Y)=>{let ne=(_e,Te=2)=>ue?String(_e):Ye(_e,Te);switch(Y){case"a":return rr[I].slice(0,3);case"A":return rr[I];case"b":return An[g.month-1].slice(0,3);case"B":return An[g.month-1];case"d":return ne(g.day);case"e":return ue?String(g.day):Ye(g.day,2," ");case"m":return ne(g.month);case"y":return ne(g.year%100);case"Y":return String(g.year);case"H":return ne(g.hour);case"I":return ne(j);case"p":return g.hour<12?"AM":"PM";case"M":return ne(g.minute);case"S":return ne(g.second);case"j":return ne(Math.round((T-Date.UTC(g.year,0,1))/Mt)+1,3);case"u":return String(I||7);case"w":return String(I);case"V":return ne(H.week);case"G":return String(H.year);case"F":return`${g.year}-${Ye(g.month)}-${Ye(g.day)}`;case"T":return`${Ye(g.hour)}:${Ye(g.minute)}:${Ye(g.second)}`;case"%":return"%";default:return Ge(l,`unsupported pattern ${se}`)}})}function Mo(l,i,t){let p=[],g="",T=(Y,ne)=>{g+=`(${Y})`,p.push(ne)},I=Y=>(ne,_e)=>(_e[Y]=Number(ne.trim()),!0);for(let Y=0;Y<t.length;Y++){if(t[Y]!=="%"){g+=Do(t[Y]);continue}let ne=t[++Y];switch(ne==="-"&&(ne=t[++Y]),ne){case"Y":T("\\d{4}",I("year"));break;case"y":T("\\d{2}",(_e,Te)=>(Te.year=2e3+Number(_e),!0));break;case"m":T("\\d{1,2}",I("month"));break;case"d":case"e":T(" ?\\d{1,2}",I("day"));break;case"H":case"I":T("\\d{1,2}",I("hour"));break;case"M":T("\\d{1,2}",I("minute"));break;case"S":T("\\d{1,2}",I("second"));break;case"p":T("[AaPp][Mm]",(_e,Te)=>(Te.pm=_e.toLowerCase()==="pm",!0));break;case"b":case"B":T("[A-Za-z]{3,9}",(_e,Te)=>{let Ce=No(_e);return Te.month=Ce+1,Ce>=0});break;case"a":case"A":T("[A-Za-z]{3,9}",()=>!0);break;case"%":g+="%";break;default:Ge(l,`unsupported pattern %${ne??""}`)}}let j=new RegExp(`^${g}$`).exec(i);if(!j)return null;let H={year:1970,month:1,day:1,hour:0,minute:0,second:0,ms:0};if(!p.every((Y,ne)=>Y(j[ne+1],H)))return null;H.pm!==void 0&&(H.hour=H.hour%12+(H.pm?12:0));let se=Date.UTC(H.year,H.month-1,H.day,H.hour,H.minute,H.second),ue=new Date(se);return ue.getUTCFullYear()!==H.year||ue.getUTCMonth()!==H.month-1||ue.getUTCDate()!==H.day||H.hour>23||H.minute>59||H.second>59?null:ue.toISOString()}function Yn(l,i,t=""){typeof i!="string"&&Ge(l,"expected a pattern");let p=`${t}/${i}`,g=qn.get(p);if(!g){try{g=new RegExp(i,t)}catch(T){Ge(l,`invalid regular expression: ${T.message}`)}qn.size>500&&qn.clear(),qn.set(p,g)}return g.lastIndex=0,g}function Xn(l,i){let t;try{t=JSON.parse(String(i))}catch{t=void 0}return Array.isArray(t)||Ge(l,"expected a JSON list"),t.map(p=>typeof p=="boolean"?Number(p):p)}function ki(l){return[...l].sort((i,t)=>i-t)}function Ii(l,i){if(l.length<(i?2:1))return null;let t=l.reduce((p,g)=>p+g,0)/l.length;return Math.sqrt(l.reduce((p,g)=>p+(g-t)**2,0)/(l.length-(i?1:0)))}function er(l){let i=Fo(l,2);if(!i.length)return null;let t=i.reduce((j,[H])=>j+H,0)/i.length,p=i.reduce((j,[,H])=>j+H,0)/i.length,g=i.reduce((j,[,H])=>j+(H-p)**2,0),T=i.reduce((j,[H])=>j+(H-t)**2,0),I=i.reduce((j,[H,se])=>j+(se-p)*(H-t),0);return g===0?null:{slope:I/g,intercept:t-I/g*p,r:T===0?null:I/Math.sqrt(g*T)}}function Lo(l,i){let t=Kt(l),p=Kt(i),g=typeof l!="string",T=typeof i!="string";return g&&T?t-p:g!==T?g?-1:1:l<i?-1:l>i?1:0}function Oi(l){let i=typeof l=="string"?$o.exec(l):null;if(!i||/\(BC\)/i.test(i[5]))return null;let t=`${Ye(Number(i[1]),4)}-${Ye(Number(i[3]))}-${Ye(Number(i[4]))}`;return Yt(t)===null?null:t}function Uo(l,i){for(let t=i+1;t<l.length;t++)if(l[t]==="\\")t++;else if(l[t]===l[i])return t;return-1}function Bo(l){let i=0,t=()=>{for(;i<l.length&&nr.has(l[i]);)i++};if(t(),l[i++]!=="[")return null;t();let p=[];if(l[i]==="]")i++;else for(;;){let g=[],T=!1,I=[];for(let ue=l[i];I.length||ue!==","&&ue!=="]";ue=l[i]){if(ue===void 0)return null;if(Pi.has(ue)){let Y=Uo(l,i);if(Y<0)return null;if(I.length)g.push(...[...l.slice(i,Y+1)].map(ne=>({c:ne,kept:!1})));else{T=!0;for(let ne=i+1;ne<Y;ne++)g.push({c:l[l[ne]==="\\"?++ne:ne],kept:!0})}i=Y+1;continue}if(ue==="\\"&&!I.length&&Pi.has(l[i+1]??"")){g.push({c:l[i+1],kept:!0}),i+=2;continue}if(Ci[ue])I.push(Ci[ue]);else if(I.length&&")]}".includes(ue)&&I.pop()!==ue)return null;g.push({c:ue,kept:!1}),i++}let j=0,H=g.length;for(;j<H&&!g[j].kept&&nr.has(g[j].c);)j++;for(;H>j&&!g[H-1].kept&&nr.has(g[H-1].c);)H--;let se=g.slice(j,H).map(ue=>ue.c).join("");if(p.push(!T&&se.toLowerCase()==="null"?null:se),l[i++]==="]")break}return t(),i===l.length?p:null}function Ni(l,i){if(!l.length)return null;let t=i*(l.length-1),p=Math.floor(t),g=Math.ceil(t);return l[p]+(l[g]-l[p])*(t-p)}function ji(l,i,t){for(let{name:p,arity:g,kind:T}of Qo){let I=zo[p];if(!I||I.kind!==T)throw new Error(`sql library: ${p} is not implemented as a ${T}`);let j=p!=="uuid";if(I.kind==="scalar"){l.createFunction({name:p,arity:g,deterministic:j,innocuous:j,xFunc:(ue,...Y)=>{let ne=I.nullable!==!1&&Y.some(_e=>_e===null)?null:I.call(Y);if(!I.real||typeof ne!="number")return ne;t(ue,ne)}});continue}let H=new Map,se=ue=>{let Y=i(ue,0);return Y?H.get(Y):void 0};l.createFunction({name:p,arity:g,deterministic:j,innocuous:!0,xStep:(ue,...Y)=>{let ne=i(ue,8),_e=H.get(ne);_e?_e.push(Y):H.set(ne,[Y])},xInverse:ue=>{se(ue)?.shift()},xValue:ue=>I.final(se(ue)??[]),xFinal:ue=>{let Y=i(ue,0),ne=Y?H.get(Y):void 0;return Y&&H.delete(Y),I.final(ne??[])}})}}var Mt,Mi,rr,An,Ti,Nt,Po,rn,En,Ai,Ye,xi,Do,No,qn,Zn,Kt,Tn,Fo,Ri,tr,jo,$o,nr,Pi,Ci,Di,zo,Qo,ir,$i=Oe(()=>{"use strict";ht();kt();Mt=864e5,Mi=/^(\d{4})-(\d{2})-(\d{2})$/,rr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],An=["January","February","March","April","May","June","July","August","September","October","November","December"],Ti=1e5;Nt=l=>new Date(l).toISOString().slice(0,10),Po=l=>l.kind==="date"?Nt(l.ms):new Date(l.ms).toISOString(),rn=(l,i,t)=>{let p=typeof i=="string"?i.toLowerCase():"";return t.includes(p)||Ge(l,`unit must be one of ${t.join(", ")} (got ${String(i)})`),p},En=(l,i)=>{let t=Number(i);return Number.isFinite(t)||Ge(l,"expected a number"),Math.trunc(t)};Ai=new Map;Ye=(l,i=2,t="0")=>String(l).padStart(i,t);xi=(l,i)=>i===""?[...l]:l.split(i),Do=l=>l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),No=l=>An.findIndex(i=>i.toLowerCase().startsWith(l.toLowerCase())&&(l.length===3||i.toLowerCase()===l.toLowerCase()));qn=new Map;Zn=l=>l?1:0,Kt=l=>typeof l=="bigint"?Number(l):typeof l=="number"?l:typeof l=="string"&&l.trim()!==""?Number(l):NaN,Tn=(l,i=0)=>l.map(t=>Kt(t[i])).filter(Number.isFinite),Fo=(l,i)=>l.map(t=>t.slice(0,i).map(Kt)).filter(t=>t.every(Number.isFinite));Ri=l=>i=>{let t=null;for(let p of i)p[0]!==null&&p[1]!==null&&(!t||l*Lo(p[1],t[1])<0)&&(t=p);return t?t[0]:null},tr=(l,i)=>{let t=Kt(i);return Number.isInteger(t)||Ge(l,"expected whole numbers"),t},jo=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i,$o=/^\s*(\d{1,4})([-/])(\d{1,2})\2(\d{1,2})(?!\d)(.*)$/s;nr=new Set([" "," ",`
|
|
2
|
-
`,"\v","\f","\r"]),Pi=new Set(['"',"'"]),Ci={"[":"]","(":")","{":"}"};Di=l=>{let i=Bo(String(l));return i&&JSON.stringify(i)};zo={dayname:{kind:"scalar",call:([l])=>rr[new Date(pt("dayname",l).ms).getUTCDay()]},monthname:{kind:"scalar",call:([l])=>An[new Date(pt("monthname",l).ms).getUTCMonth()]},dayofweek:{kind:"scalar",call:([l])=>new Date(pt("dayofweek",l).ms).getUTCDay()},date_trunc:{kind:"scalar",call:([l,i])=>{let t=rn("date_trunc",l,["day","week","month","quarter","year"]),p=new Date(pt("date_trunc",i).ms),g=p.getUTCFullYear(),T=p.getUTCMonth(),I=p.getUTCDate();return Nt(t==="day"?Date.UTC(g,T,I):t==="week"?Date.UTC(g,T,I-(p.getUTCDay()+6)%7):t==="month"?Date.UTC(g,T,1):t==="quarter"?Date.UTC(g,T-T%3,1):Date.UTC(g,0,1))}},date_add:{kind:"scalar",call:([l,i,t])=>{let p=pt("date_add",l),g=En("date_add",i),T=rn("date_add",t,["day","week","month","year","hour","minute"]);(T==="hour"||T==="minute")&&p.kind==="date"&&Ge("date_add",`adding ${T}s needs a timestamp, not a date`);let I=T==="month"?Kn(p.ms,g):T==="year"?Kn(p.ms,12*g):p.ms+g*{day:Mt,week:7*Mt,hour:36e5,minute:6e4}[T];return Po({kind:p.kind,ms:I})}},date_diff:{kind:"scalar",call:([l,i,t])=>{let p=rn("date_diff",l,["day","week","month","year","hour","minute"]),g=pt("date_diff",i).ms,T=pt("date_diff",t).ms;if(p!=="month"&&p!=="year")return Math.trunc((T-g)/{day:Mt,week:7*Mt,hour:36e5,minute:6e4}[p]);let I=new Date(g),j=new Date(T),H=(j.getUTCFullYear()-I.getUTCFullYear())*12+(j.getUTCMonth()-I.getUTCMonth()),se=ue=>ue.getTime()-Date.UTC(ue.getUTCFullYear(),ue.getUTCMonth(),1);return H>0&&se(j)<se(I)&&H--,H<0&&se(j)>se(I)&&H++,p==="month"?H:Math.trunc(H/12)}},date_part:{kind:"scalar",call:([l,i])=>{let t=rn("date_part",l,["year","quarter","month","week","day","hour","minute"]),p=new Date(pt("date_part",i).ms);switch(t){case"year":return p.getUTCFullYear();case"quarter":return Math.floor(p.getUTCMonth()/3)+1;case"month":return p.getUTCMonth()+1;case"week":return Fi(p.getTime()).week;case"day":return p.getUTCDate();case"hour":return p.getUTCHours();default:return p.getUTCMinutes()}}},date_format:{kind:"scalar",call:([l,i,t])=>(typeof i!="string"&&Ge("date_format","expected a pattern"),t!==void 0&&typeof t!="string"&&Ge("date_format","expected a time zone name"),Co("date_format",pt("date_format",l),i,t))},date_parse:{kind:"scalar",call:([l,i])=>(typeof i!="string"&&Ge("date_parse","expected a pattern"),Mo("date_parse",String(l),i))},date_series:{kind:"scalar",call:([l,i,t])=>{let p=t===void 0?"day":rn("date_series",t,["day","week","month"]),g=pt("date_series",l).ms,T=pt("date_series",i).ms,I=[];for(let j=0;;j++){let H=p==="month"?Kn(g,j):g+j*(p==="week"?7:1)*Mt;if(H>T)break;I.length>=Ti&&Ge("date_series",`more than ${Ti} dates`),I.push(Nt(H))}return JSON.stringify(I)}},to_timezone:{kind:"scalar",call:([l,i])=>{typeof i!="string"&&Ge("to_timezone","expected a time zone name");let t=Li("to_timezone",pt("to_timezone",l).ms,i);return`${Ye(t.year,4)}-${Ye(t.month)}-${Ye(t.day)}T${Ye(t.hour)}:${Ye(t.minute)}:${Ye(t.second)}.${Ye(t.ms,3)}`}},make_date:{kind:"scalar",call:([l,i,t])=>{let p=`${Ye(tr("make_date",l),4)}-${Ye(tr("make_date",i))}-${Ye(tr("make_date",t))}`;return Yt(p)===null&&Ge("make_date",`${p} is not a calendar date`),p}},to_date:{kind:"scalar",call:([l])=>Oi(l)??Ge("to_date",`${String(l).trim()} is not a date`)},try_to_date:{kind:"scalar",call:([l])=>Oi(l)},median:{kind:"aggregate",final:l=>Ni(ki(Tn(l)),.5)},quantile:{kind:"aggregate",final:l=>{let i=l[0]?.[1],t=Number(i);return i!=null&&!(t>=0&&t<=1)&&Ge("quantile","q must be between 0 and 1"),i==null?null:Ni(ki(Tn(l)),t)}},stddev:{kind:"aggregate",final:l=>Ii(Tn(l),!0)},stddev_pop:{kind:"aggregate",final:l=>Ii(Tn(l),!1)},regr_slope:{kind:"aggregate",final:l=>er(l)?.slope??null},regr_intercept:{kind:"aggregate",final:l=>er(l)?.intercept??null},corr:{kind:"aggregate",final:l=>er(l)?.r??null},arg_min:{kind:"aggregate",final:Ri(1)},arg_max:{kind:"aggregate",final:Ri(-1)},round:{kind:"scalar",real:!0,call:([l,i])=>{let t=Kt(l);Number.isNaN(t)&&Ge("round","expected a number");let p=i===void 0?0:En("round",i);if(Number.isInteger(t)&&p>=0)return t;let g=10**Math.abs(p),T=Math.sign(t)*(p>=0?Math.round(Math.abs(t)*g)/g:Math.round(Math.abs(t)/g)*g);return Number.isFinite(T)?T:t}},to_number:{kind:"scalar",call:([l])=>{if(typeof l=="number"||typeof l=="bigint")return Number(l);let i=String(l).trim();return jo.test(i)?Number(i):null}},string_split:{kind:"scalar",call:([l,i])=>JSON.stringify(xi(String(l),String(i)))},split_part:{kind:"scalar",call:([l,i,t])=>{let p=xi(String(l),String(i)),g=En("split_part",t);return(g>0?p[g-1]:g<0?p[p.length+g]:void 0)??""}},regexp_matches:{kind:"scalar",call:([l,i])=>Zn(Yn("regexp_matches",i).test(String(l)))},regexp_replace:{kind:"scalar",call:([l,i,t])=>String(l).replace(Yn("regexp_replace",i,"g"),String(t))},regexp_extract:{kind:"scalar",call:([l,i,t])=>{let p=Yn("regexp_extract",i).exec(String(l));return p?p[t===void 0?0:En("regexp_extract",t)]??null:null}},list_contains:{kind:"scalar",call:([l,i])=>Zn(Xn("list_contains",l).includes(i))},list_has_any:{kind:"scalar",call:([l,i])=>{let t=Xn("list_has_any",l);return Zn(Xn("list_has_any",i).some(p=>t.includes(p)))}},to_list:{kind:"scalar",call:([l])=>Di(l)??Ge("to_list",`${String(l)} is not a list`)},try_to_list:{kind:"scalar",call:([l])=>Di(l)},list_value:{kind:"scalar",nullable:!1,call:l=>JSON.stringify(l.map(i=>(i!==null&&typeof i=="object"&&Ge("list_value","lists hold text, numbers and null"),typeof i=="bigint"?Number(i):i)))},uuid:{kind:"scalar",nullable:!1,call:()=>globalThis.crypto.randomUUID()}},Qo=zn.flatMap(l=>l.arity.map(i=>({name:l.name,arity:i,kind:l.kind}))),ir=new Set(zn.map(l=>l.name))});function Wo(l){let i=ut(l.name),t=l.type==="boolean"?[`${i} IN (0, 1)`,"true or false"]:l.type==="date"?[`date(${i}) IS ${i}`,"a date (YYYY-MM-DD)"]:l.type==="timestamp"?[`strftime('%Y-%m-%dT%H:%M:%fZ', ${i}) IS ${i}`,"a UTC timestamp (YYYY-MM-DDTHH:MM:SS.sssZ)"]:null;return t?` CONSTRAINT ${ut(`${l.name} must be ${t[1]}`)} CHECK (${t[0]})`:""}function sn(l,i,t){if(i==null)return null;if(l==="date"){if(typeof i!="string"||Yt(i)===null)throw new Error(`${t} is not a date the dataset can hold (expected YYYY-MM-DD)`);return i}if(l==="timestamp")return xt(i,t);if(typeof i=="boolean")return i?1:0;if(l==="boolean"&&i!==0&&i!==1)throw new Error(`${t} must be true or false`);return typeof i=="number"||typeof i=="string"?i:typeof i=="bigint"?Number(i):JSON.stringify(i)}function Go(l,i){return l==null?null:(typeof l=="bigint"&&(l=Number(l)),l instanceof Uint8Array?Array.from(l,t=>t.toString(16).padStart(2,"0")).join(""):i==="boolean"?l!==0:l)}var nt,St,Vo,ut,_t,sr,xn,Ho,Jo,or,ar,st,Ko,on=Oe(()=>{"use strict";ht();kt();$i();nt=class extends Error{},St=class extends Error{},Vo={string:"TEXT",number:"REAL",boolean:"INTEGER",date:"TEXT",timestamp:"TEXT",user:"TEXT"},ut=l=>`"${l.replaceAll('"','""')}"`,_t=(l,i)=>`${l.toLowerCase()}\0${i.toLowerCase()}`,sr=new Set(["json_each","json_tree"]),xn=new Set(["->","->>","abs","acos","acosh","asin","asinh","atan","atan2","atanh","avg","ceil","ceiling","char","coalesce","concat","concat_ws","cos","cosh","count","cume_dist","current_date","current_time","current_timestamp","date","datetime","degrees","dense_rank","exp","first_value","floor","format","glob","group_concat","hex","if","ifnull","iif","instr","json","json_array","json_array_insert","json_array_length","json_error_position","json_extract","json_group_array","json_group_object","json_insert","json_object","json_patch","json_pretty","json_quote","json_remove","json_replace","json_set","json_type","json_valid","julianday","lag","last_value","lead","length","like","likelihood","likely","ln","log","log10","log2","lower","ltrim","max","min","mod","nth_value","ntile","nullif","octet_length","percent_rank","percentile","percentile_cont","percentile_disc","pi","pow","power","printf","quote","radians","random","randomblob","rank","replace","round","row_number","rtrim","sign","sin","sinh","sqrt","strftime","string_agg","substr","substring","sum","tan","tanh","time","timediff","total","trim","trunc","typeof","unhex","unicode","unistr","unistr_quote","unixepoch","unlikely","upper","zeroblob"]);Ho=(l,i)=>l==="date"&&typeof i=="string"&&/^\d{4}-\d{2}-\d{2}[T ]/.test(i)?i.slice(0,10):i;Jo=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,or=l=>(l instanceof Error?l.message:String(l)).replace(/^SQLITE_[A-Z_]+: sqlite3 result code \d+: /,""),ar=class{constructor(i,t,p){this.owner=i;this.stmt=t;this.analysis=p}owner;stmt;analysis;get text(){return this.owner.sqlite3.capi.sqlite3_sql(this.stmt.pointer).replace(/;$/,"")}bind(i,t={}){let{capi:p}=this.owner.sqlite3;for(let g=1;g<=this.stmt.parameterCount;g++){let T=p.sqlite3_bind_parameter_name(this.stmt.pointer,g).slice(1),I=sn(Object.hasOwn(t,T)?t[T]:void 0,Object.hasOwn(i,T)?i[T]:null,`parameter $${T}`);typeof I=="number"?p.sqlite3_bind_double(this.stmt.pointer,g,I):this.stmt.bind(g,I)}return this}rows(i,t){let p=[],g=!1;this.owner.within(t,()=>{for(;this.stmt.step();){if(p.length===i){g=!0;break}p.push(Array.from({length:this.stmt.columnCount},(j,H)=>this.stmt.get(H)))}});let T=this.analysis.columns.map((j,H)=>this.owner.resultColumn(this.stmt,H,j,p));return{rows:p.map(j=>Object.fromEntries(T.map((H,se)=>[H.name,Go(j[se],H.type)]))),columns:T,more:g}}run(i){this.owner.within(i,()=>{for(;this.stmt.step(););})}finalize(){this.stmt.finalize()}},st=class{constructor(i){this.sqlite3=i;let{capi:t}=i;this.#e=new i.oo1.DB(":memory:");try{ji(this.#e,(p,g)=>t.sqlite3_js_aggregate_context(p,g),(p,g)=>t.sqlite3_result_double(p,g)),this.#u=new Set(this.trusted(()=>this.#e.exec({sql:"SELECT name FROM pragma_module_list",returnValue:"resultRows"}).map(p=>String(p[0]).toLowerCase()))),this.trusted(()=>this.#e.exec("PRAGMA recursive_triggers = ON")),t.sqlite3_limit(this.#e,t.SQLITE_LIMIT_LENGTH,32*1024*1024),t.sqlite3_limit(this.#e,t.SQLITE_LIMIT_SQL_LENGTH,1e6),t.sqlite3_set_authorizer(this.#e,(p,g,T,I,j,H)=>this.#y({code:g,object:T||null,column:I===0?null:I,db:j||null,source:H||null}),0),t.sqlite3_progress_handler(this.#e,1e3,()=>performance.now()<=this.#d?0:(this.#m=!0,1),0)}catch(p){throw this.#e.close(),p}}sqlite3;#e;#t=new Map;#s=["temp","main"];#n=new Set;#r=new Set;#a=new Set;#u;#i=0;#f="read";#o=null;#l=null;#c=null;#d=1/0;#m=!1;close(){this.#e.close()}trusted(i){this.#i++;try{return i()}finally{this.#i--}}exec(i,t){return this.trusted(()=>this.#e.exec({sql:i,bind:t,rowMode:"object",returnValue:"resultRows"}))}internalFunction(i,t){let p=this.internalName();return this.#e.createFunction({name:p,arity:t,xFunc:(g,...T)=>i(...T)}),p}extensionFunction(i,t,p){let g=i.toLowerCase();if(!/^[a-z_][a-z0-9_]*$/.test(g)||xn.has(g)||ir.has(g))throw new Error(`invalid extension function name ${i}`);this.#e.createFunction({name:g,arity:p,xFunc:(T,...I)=>t(...I)}),this.#a.add(g)}internalName(){let i=globalThis.crypto.getRandomValues(new Uint8Array(12)),t=`__engine_${Array.from(i,p=>p.toString(16).padStart(2,"0")).join("")}`;return this.#r.add(t),t}attach(i){if(!i||i.length>255||i.includes("\0")||/^temp$|^sqlite_/i.test(i))throw new Error(`invalid schema name ${i}`);this.#s.some(t=>t.toLowerCase()===i.toLowerCase())||(this.exec(`ATTACH ':memory:' AS ${ut(i)}`),this.#s.push(i))}createTable(i,t){let p=i.columns.length?i.columns:[{name:"_empty",type:"string"}];i.schema!=="main"&&this.attach(i.schema);let g=p.map((T,I)=>`${ut(T.name)} ${Vo[T.type]}${t?` DEFAULT (${t(I)})`:""}${Wo(T)}`).join(", ");this.exec(`CREATE TABLE ${ut(i.schema)}.${ut(i.table)} (${g}) STRICT`),this.#p(i.schema,i.table,i.columns)}insertRows(i,t){if(!t.length||!i.columns.length)return;let p=JSON.stringify(t.map((T,I)=>i.columns.map(j=>sn(j.type,Ho(j.type,T[j.name]),`${i.table}.${j.name} (row ${I+1})`)))),g=i.columns.map(T=>ut(T.name)).join(", ");try{this.exec(`INSERT INTO ${ut(i.schema)}.${ut(i.table)} (${g}) SELECT ${i.columns.map((T,I)=>`value ->> ${I}`).join(", ")} FROM json_each(?) ORDER BY key`,[p])}catch(T){throw new Error(or(T))}}load(i){let t={...i,columns:i.columns.length?i.columns:Ht(i.rows)};this.createTable(t),this.insertRows(t,i.rows)}drop(i,t){this.exec(`DROP TABLE IF EXISTS ${ut(i)}.${ut(t)}`),this.#t.delete(_t(i,t))}scratch(i){let t=new Map(this.#t),p=new Set(this.#n);this.exec("BEGIN");try{return i()}finally{this.sqlite3.capi.sqlite3_get_autocommit(this.#e.pointer)||this.exec("ROLLBACK"),this.#t.clear();for(let[g,T]of t)this.#t.set(g,T);this.#n.clear();for(let g of p)this.#n.add(g)}}createView(i){let t=this.prepare(i.sql,"read"),p;try{if(t.stmt.parameterCount)throw new nt("a stored model cannot bind reader parameters");p=t.text}finally{t.finalize()}i.schema!=="main"&&this.attach(i.schema);let g=i.columns.length?i.columns.map(T=>ut(T.name)).join(", "):"*";this.exec(`CREATE VIEW ${ut(i.schema)}.${ut(i.table)} AS SELECT ${g} FROM (
|
|
1
|
+
var To=Object.defineProperty;var Oe=(l,i,t)=>()=>{if(t)throw t[0];try{return l&&(i=l(l=0)),i}catch(p){throw t=[p],p}};var Ao=(l,i)=>{for(var t in i)To(l,t,{get:i[t],enumerable:!0})};var Mr=Oe(()=>{"use strict"});var bt,At,Lr=Oe(()=>{"use strict";bt=l=>"error"in l,At=1e3});var Bn,Fr=Oe(()=>{"use strict";Bn=l=>l.replace(".","__")});var zn,jr,$r=Oe(()=>{"use strict";zn=[{name:"dayname",arity:[1],kind:"scalar",signature:"dayname(date) \u2192 text",summary:"Weekday name: Wednesday."},{name:"monthname",arity:[1],kind:"scalar",signature:"monthname(date) \u2192 text",summary:"Month name: September."},{name:"dayofweek",arity:[1],kind:"scalar",signature:"dayofweek(date) \u2192 integer",summary:"0 = Sunday \u2026 6 = Saturday."},{name:"date_trunc",arity:[2],kind:"scalar",signature:"date_trunc('day'|'week'|'month'|'quarter'|'year', date) \u2192 date",summary:"Start of the period; weeks start on Monday."},{name:"date_add",arity:[3],kind:"scalar",signature:"date_add(date, n, 'day'|'week'|'month'|'year'|'hour'|'minute') \u2192 date or timestamp",summary:"Adds n units; the result keeps the input kind."},{name:"date_diff",arity:[3],kind:"scalar",signature:"date_diff('day'|'week'|'month'|'year'|'hour'|'minute', start, end) \u2192 integer",summary:"Whole units from start to end."},{name:"date_part",arity:[2],kind:"scalar",signature:"date_part('year'|'quarter'|'month'|'week'|'day'|'hour'|'minute', date) \u2192 integer",summary:"One component; week is the ISO week."},{name:"date_format",arity:[2,3],kind:"scalar",signature:"date_format(date, pattern[, tz]) \u2192 text",summary:"Formats with strftime patterns (%a %A %b %B %d %e %H %M %Y \u2026), in tz when given."},{name:"date_parse",arity:[2],kind:"scalar",signature:"date_parse(text, pattern) \u2192 timestamp",summary:"Parses text with a strftime pattern; null when it does not match."},{name:"date_series",arity:[2,3],kind:"scalar",signature:"date_series(start, end[, 'day'|'week'|'month']) \u2192 list",summary:"Every date from start to end inclusive, as a JSON list; read it with json_each."},{name:"to_timezone",arity:[2],kind:"scalar",signature:"to_timezone(timestamp, tz) \u2192 text",summary:"The local wall-clock time in tz, as ISO text without offset."},{name:"make_date",arity:[3],kind:"scalar",signature:"make_date(year, month, day) \u2192 date",summary:"The date with these parts; fails on one the calendar does not have."},{name:"to_date",arity:[1],kind:"scalar",signature:"to_date(text) \u2192 date",summary:"The calendar day a date or timestamp names (2026-9-30, 2026/09/30, 2026-09-30T10:00Z); fails on text that names none."},{name:"try_to_date",arity:[1],kind:"scalar",signature:"try_to_date(text) \u2192 date",summary:"The calendar day, as to_date reads it; null when the text names none."},{name:"median",arity:[1],kind:"aggregate",signature:"median(x) \u2192 real",summary:"Middle value, averaging the two middle values."},{name:"quantile",arity:[2],kind:"aggregate",signature:"quantile(x, q) \u2192 real",summary:"Continuous quantile, q between 0 and 1."},{name:"stddev",arity:[1],kind:"aggregate",signature:"stddev(x) \u2192 real",summary:"Sample standard deviation."},{name:"stddev_pop",arity:[1],kind:"aggregate",signature:"stddev_pop(x) \u2192 real",summary:"Population standard deviation."},{name:"regr_slope",arity:[2],kind:"aggregate",signature:"regr_slope(y, x) \u2192 real",summary:"Least-squares slope of y against x, over rows with both."},{name:"regr_intercept",arity:[2],kind:"aggregate",signature:"regr_intercept(y, x) \u2192 real",summary:"Where the least-squares line of y against x crosses x = 0."},{name:"corr",arity:[2],kind:"aggregate",signature:"corr(y, x) \u2192 real",summary:"Pearson correlation of y and x, over rows with both."},{name:"arg_min",arity:[2],kind:"aggregate",signature:"arg_min(arg, value) \u2192 any",summary:"arg from the row with the least value (the first on a tie), over rows with both."},{name:"arg_max",arity:[2],kind:"aggregate",signature:"arg_max(arg, value) \u2192 any",summary:"arg from the row with the greatest value (the first on a tie), over rows with both."},{name:"round",arity:[1,2],kind:"scalar",signature:"round(x[, digits]) \u2192 number",summary:"Rounds half away from zero at the digits as written: round(13.975, 2) = 13.98."},{name:"to_number",arity:[1],kind:"scalar",signature:"to_number(text) \u2192 real",summary:"The number text names ('1.5', ' 2 ', '1e3'); null when it names none."},{name:"string_split",arity:[2],kind:"scalar",signature:"string_split(text, separator) \u2192 list",summary:"The parts between separators, as a JSON list; '' splits into characters."},{name:"split_part",arity:[3],kind:"scalar",signature:"split_part(text, separator, n) \u2192 text",summary:"The nth part (1-based; negative counts from the end), '' when there is none."},{name:"regexp_matches",arity:[2],kind:"scalar",signature:"regexp_matches(text, pattern) \u2192 boolean",summary:"JavaScript regular expression syntax."},{name:"regexp_replace",arity:[3],kind:"scalar",signature:"regexp_replace(text, pattern, replacement) \u2192 text",summary:"Replaces every match."},{name:"regexp_extract",arity:[2,3],kind:"scalar",signature:"regexp_extract(text, pattern[, group]) \u2192 text",summary:"The first match, or one of its groups."},{name:"list_contains",arity:[2],kind:"scalar",signature:"list_contains(list, value) \u2192 boolean",summary:"Whether a JSON list holds the value."},{name:"list_has_any",arity:[2],kind:"scalar",signature:"list_has_any(list, list) \u2192 boolean",summary:"Whether two JSON lists share a value."},{name:"to_list",arity:[1],kind:"scalar",signature:"to_list(text) \u2192 list",summary:`The list text names (["a","b"], [a, b], ['a', 'b']) as a JSON list of text, a bare null as null; fails on text that names none.`},{name:"try_to_list",arity:[1],kind:"scalar",signature:"try_to_list(text) \u2192 list",summary:"The list, as to_list reads it; null when the text names none."},{name:"list_value",arity:[0,1,2,3,4,5,6,7,8],kind:"scalar",signature:"list_value(a, b, \u2026) \u2192 list",summary:"Builds a JSON list."},{name:"uuid",arity:[0],kind:"scalar",signature:"uuid() \u2192 text",summary:"A random UUID; the one non-deterministic function, allowed only in mutations."}],jr=new Set(["uuid","random","randomblob"])});var Ur=Oe(()=>{"use strict"});var Br=Oe(()=>{"use strict"});var zr=Oe(()=>{"use strict"});var Qr=Oe(()=>{"use strict"});var Vr=Oe(()=>{"use strict"});var Wr=Oe(()=>{"use strict"});var Hr=Oe(()=>{"use strict"});var Gr=Oe(()=>{"use strict"});var Jr,va,Ea,Kr=Oe(()=>{"use strict";Jr="/api/internal",va=`${Jr}/tokens`,Ea=`${Jr}/artifact-approval`});var Yr=Oe(()=>{"use strict"});var Xr=Oe(()=>{"use strict"});var Zr=Oe(()=>{"use strict"});var ei=Oe(()=>{"use strict"});var ti=Oe(()=>{"use strict"});var ni=Oe(()=>{"use strict"});var ri=Oe(()=>{"use strict"});var ii=Oe(()=>{"use strict"});var si=Oe(()=>{"use strict"});var oi=Oe(()=>{"use strict"});var ai=Oe(()=>{"use strict"});var gn,li=Oe(()=>{"use strict";gn=[{name:"user_id",type:"user"},{name:"joined_at",type:"timestamp"}]});var ci=Oe(()=>{"use strict"});var ui=Oe(()=>{"use strict"});var fi=Oe(()=>{"use strict"});var di=Oe(()=>{"use strict"});var mi=Oe(()=>{"use strict"});var pi=Oe(()=>{"use strict"});var ht=Oe(()=>{"use strict";Mr();Lr();Fr();$r();Ur();Br();zr();Qr();Vr();Wr();Hr();Gr();Kr();Yr();Xr();Zr();ei();ti();ni();ri();ii();si();oi();ai();li();ci();ui();fi();di();mi();pi()});function xt(l,i="timestamp"){let t=()=>{throw new Error(`${i}: invalid timestamp; use an ISO date/datetime (UTC when omitted), an explicit offset, or epoch milliseconds`)};if(typeof l=="number"){if(!Number.isFinite(l))return t();let ne=new Date(l);return Number.isNaN(ne.getTime())?t():ne.toISOString()}if(l instanceof Date)return Number.isNaN(l.getTime())?t():l.toISOString();if(typeof l!="string")return t();let p=/^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/i.exec(l.trim());if(!p)return t();let g=p[1],T=new Date(`${g}T00:00:00.000Z`);if(Number.isNaN(T.getTime())||T.toISOString().slice(0,10)!==g)return t();let I=p[2]??"00",j=p[3]??"00",H=p[4]??"00";if(+I>23||+j>59||+H>59)return t();let se=(p[5]??"").padEnd(3,"0").slice(0,3),ue=(p[6]??"Z").toUpperCase();/^[+-]\d{2}$/.test(ue)&&(ue+=":00"),/^[+-]\d{4}$/.test(ue)&&(ue=`${ue.slice(0,3)}:${ue.slice(3)}`);let Y=new Date(`${g}T${I}:${j}:${H}.${se}${ue}`);return Number.isNaN(Y.getTime())?t():Y.toISOString()}function Wt(l){try{return xt(l),!0}catch{return!1}}var Wn=Oe(()=>{"use strict"});function ko(l){return l==null?null:typeof l=="number"?"number":typeof l=="boolean"?"boolean":typeof l=="string"?Io.test(l)?"date":/^[0-9]{4}-/.test(l)&&Wt(l)?"timestamp":"string":null}function Ht(l){let i=[],t=new Map;for(let p of l)for(let[g,T]of Object.entries(p)){!t.has(g)&&!i.includes(g)&&i.push(g);let I=ko(T);if(I===null)continue;let j=t.get(g);j===void 0?t.set(g,I):j!==I&&t.set(g,"string")}return i.map(p=>({name:p,type:t.get(p)??"string"}))}var Io,It=Oe(()=>{"use strict";Wn();Wn();Io=/^\d{4}-\d{2}-\d{2}$/});function Ge(l,i){throw new Error(`${l}: ${i}`)}function Yt(l){let i=Li.exec(l);if(!i)return null;let t=Number(i[1]),p=Number(i[2]),g=Number(i[3]),T=t%4===0&&(t%100!==0||t%400===0),I=p===2?T?29:28:[4,6,9,11].includes(p)?30:31;return p>=1&&p<=12&&g>=1&&g<=I?new Date(0).setUTCFullYear(t,p-1,g):null}function pt(l,i){typeof i!="string"&&Ge(l,"expected ISO date or timestamp text");let t=Yt(i);return t!==null?{kind:"date",ms:t}:(Li.test(i)&&Ge(l,`${i} is not a calendar date`),{kind:"timestamp",ms:Date.parse(xt(i,l))})}function Kn(l,i){let t=new Date(l),p=t.getUTCFullYear(),g=t.getUTCMonth()+i,T=new Date(Date.UTC(p,g+1,0)).getUTCDate();return Date.UTC(p,g,Math.min(t.getUTCDate(),T),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())}function Fi(l){let i=new Date(l),t=Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()-(i.getUTCDay()+6)%7+3),p=new Date(t).getUTCFullYear();return{week:1+Math.floor((t-Date.UTC(p,0,1))/(7*Mt)),year:p}}function ji(l,i,t){if(t===void 0){let T=new Date(i);return{year:T.getUTCFullYear(),month:T.getUTCMonth()+1,day:T.getUTCDate(),hour:T.getUTCHours(),minute:T.getUTCMinutes(),second:T.getUTCSeconds(),ms:T.getUTCMilliseconds()}}let p=xi.get(t);if(!p){try{p=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{Ge(l,`unknown time zone ${t}`)}xi.set(t,p)}let g=Object.fromEntries(p.formatToParts(new Date(i)).map(T=>[T.type,T.value]));return{year:Number(g.year),month:Number(g.month),day:Number(g.day),hour:Number(g.hour),minute:Number(g.minute),second:Number(g.second),ms:(i%1e3+1e3)%1e3}}function Do(l,i,t,p){let g=ji(l,i.ms,i.kind==="date"?void 0:p),T=Date.UTC(g.year,g.month-1,g.day),I=new Date(T).getUTCDay(),j=g.hour%12||12,H=Fi(T);return t.replace(/%(-?)([a-zA-Z%])/g,(se,ue,Y)=>{let ne=(_e,Te=2)=>ue?String(_e):Ye(_e,Te);switch(Y){case"a":return rr[I].slice(0,3);case"A":return rr[I];case"b":return An[g.month-1].slice(0,3);case"B":return An[g.month-1];case"d":return ne(g.day);case"e":return ue?String(g.day):Ye(g.day,2," ");case"m":return ne(g.month);case"y":return ne(g.year%100);case"Y":return String(g.year);case"H":return ne(g.hour);case"I":return ne(j);case"p":return g.hour<12?"AM":"PM";case"M":return ne(g.minute);case"S":return ne(g.second);case"j":return ne(Math.round((T-Date.UTC(g.year,0,1))/Mt)+1,3);case"u":return String(I||7);case"w":return String(I);case"V":return ne(H.week);case"G":return String(H.year);case"F":return`${g.year}-${Ye(g.month)}-${Ye(g.day)}`;case"T":return`${Ye(g.hour)}:${Ye(g.minute)}:${Ye(g.second)}`;case"%":return"%";default:return Ge(l,`unsupported pattern ${se}`)}})}function Lo(l,i,t){let p=[],g="",T=(Y,ne)=>{g+=`(${Y})`,p.push(ne)},I=Y=>(ne,_e)=>(_e[Y]=Number(ne.trim()),!0);for(let Y=0;Y<t.length;Y++){if(t[Y]!=="%"){g+=No(t[Y]);continue}let ne=t[++Y];switch(ne==="-"&&(ne=t[++Y]),ne){case"Y":T("\\d{4}",I("year"));break;case"y":T("\\d{2}",(_e,Te)=>(Te.year=2e3+Number(_e),!0));break;case"m":T("\\d{1,2}",I("month"));break;case"d":case"e":T(" ?\\d{1,2}",I("day"));break;case"H":case"I":T("\\d{1,2}",I("hour"));break;case"M":T("\\d{1,2}",I("minute"));break;case"S":T("\\d{1,2}",I("second"));break;case"p":T("[AaPp][Mm]",(_e,Te)=>(Te.pm=_e.toLowerCase()==="pm",!0));break;case"b":case"B":T("[A-Za-z]{3,9}",(_e,Te)=>{let Ce=Mo(_e);return Te.month=Ce+1,Ce>=0});break;case"a":case"A":T("[A-Za-z]{3,9}",()=>!0);break;case"%":g+="%";break;default:Ge(l,`unsupported pattern %${ne??""}`)}}let j=new RegExp(`^${g}$`).exec(i);if(!j)return null;let H={year:1970,month:1,day:1,hour:0,minute:0,second:0,ms:0};if(!p.every((Y,ne)=>Y(j[ne+1],H)))return null;H.pm!==void 0&&(H.hour=H.hour%12+(H.pm?12:0));let se=Date.UTC(H.year,H.month-1,H.day,H.hour,H.minute,H.second),ue=new Date(se);return ue.getUTCFullYear()!==H.year||ue.getUTCMonth()!==H.month-1||ue.getUTCDate()!==H.day||H.hour>23||H.minute>59||H.second>59?null:ue.toISOString()}function Yn(l,i,t=""){typeof i!="string"&&Ge(l,"expected a pattern");let p=`${t}/${i}`,g=qn.get(p);if(!g){try{g=new RegExp(i,t)}catch(T){Ge(l,`invalid regular expression: ${T.message}`)}qn.size>500&&qn.clear(),qn.set(p,g)}return g.lastIndex=0,g}function Xn(l,i){let t;try{t=JSON.parse(String(i))}catch{t=void 0}return Array.isArray(t)||Ge(l,"expected a JSON list"),t.map(p=>typeof p=="boolean"?Number(p):p)}function ki(l){return[...l].sort((i,t)=>i-t)}function Ri(l,i){if(l.length<(i?2:1))return null;let t=l.reduce((p,g)=>p+g,0)/l.length;return Math.sqrt(l.reduce((p,g)=>p+(g-t)**2,0)/(l.length-(i?1:0)))}function er(l){let i=Fo(l,2);if(!i.length)return null;let t=i.reduce((j,[H])=>j+H,0)/i.length,p=i.reduce((j,[,H])=>j+H,0)/i.length,g=i.reduce((j,[,H])=>j+(H-p)**2,0),T=i.reduce((j,[H])=>j+(H-t)**2,0),I=i.reduce((j,[H,se])=>j+(se-p)*(H-t),0);return g===0?null:{slope:I/g,intercept:t-I/g*p,r:T===0?null:I/Math.sqrt(g*T)}}function jo(l,i){let t=Kt(l),p=Kt(i),g=typeof l!="string",T=typeof i!="string";return g&&T?t-p:g!==T?g?-1:1:l<i?-1:l>i?1:0}function Pi(l){let i=typeof l=="string"?Uo.exec(l):null;if(!i||/\(BC\)/i.test(i[5]))return null;let t=`${Ye(Number(i[1]),4)}-${Ye(Number(i[3]))}-${Ye(Number(i[4]))}`;return Yt(t)===null?null:t}function Bo(l,i){for(let t=i+1;t<l.length;t++)if(l[t]==="\\")t++;else if(l[t]===l[i])return t;return-1}function zo(l){let i=0,t=()=>{for(;i<l.length&&nr.has(l[i]);)i++};if(t(),l[i++]!=="[")return null;t();let p=[];if(l[i]==="]")i++;else for(;;){let g=[],T=!1,I=[];for(let ue=l[i];I.length||ue!==","&&ue!=="]";ue=l[i]){if(ue===void 0)return null;if(Ci.has(ue)){let Y=Bo(l,i);if(Y<0)return null;if(I.length)g.push(...[...l.slice(i,Y+1)].map(ne=>({c:ne,kept:!1})));else{T=!0;for(let ne=i+1;ne<Y;ne++)g.push({c:l[l[ne]==="\\"?++ne:ne],kept:!0})}i=Y+1;continue}if(ue==="\\"&&!I.length&&Ci.has(l[i+1]??"")){g.push({c:l[i+1],kept:!0}),i+=2;continue}if(Di[ue])I.push(Di[ue]);else if(I.length&&")]}".includes(ue)&&I.pop()!==ue)return null;g.push({c:ue,kept:!1}),i++}let j=0,H=g.length;for(;j<H&&!g[j].kept&&nr.has(g[j].c);)j++;for(;H>j&&!g[H-1].kept&&nr.has(g[H-1].c);)H--;let se=g.slice(j,H).map(ue=>ue.c).join("");if(p.push(!T&&se.toLowerCase()==="null"?null:se),l[i++]==="]")break}return t(),i===l.length?p:null}function Mi(l,i){if(!l.length)return null;let t=i*(l.length-1),p=Math.floor(t),g=Math.ceil(t);return l[p]+(l[g]-l[p])*(t-p)}function $i(l,i,t){for(let{name:p,arity:g,kind:T}of Vo){let I=Qo[p];if(!I||I.kind!==T)throw new Error(`sql library: ${p} is not implemented as a ${T}`);let j=p!=="uuid";if(I.kind==="scalar"){l.createFunction({name:p,arity:g,deterministic:j,innocuous:j,xFunc:(ue,...Y)=>{let ne=I.nullable!==!1&&Y.some(_e=>_e===null)?null:I.call(Y);if(!I.real||typeof ne!="number")return ne;t(ue,ne)}});continue}let H=new Map,se=ue=>{let Y=i(ue,0);return Y?H.get(Y):void 0};l.createFunction({name:p,arity:g,deterministic:j,innocuous:!0,xStep:(ue,...Y)=>{let ne=i(ue,8),_e=H.get(ne);_e?_e.push(Y):H.set(ne,[Y])},xInverse:ue=>{se(ue)?.shift()},xValue:ue=>I.final(se(ue)??[]),xFinal:ue=>{let Y=i(ue,0),ne=Y?H.get(Y):void 0;return Y&&H.delete(Y),I.final(ne??[])}})}}var Mt,Li,rr,An,Ai,Nt,Co,rn,En,xi,Ye,Ii,No,Mo,qn,Zn,Kt,Tn,Fo,Oi,tr,$o,Uo,nr,Ci,Di,Ni,Qo,Vo,ir,Ui=Oe(()=>{"use strict";ht();It();Mt=864e5,Li=/^(\d{4})-(\d{2})-(\d{2})$/,rr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],An=["January","February","March","April","May","June","July","August","September","October","November","December"],Ai=1e5;Nt=l=>new Date(l).toISOString().slice(0,10),Co=l=>l.kind==="date"?Nt(l.ms):new Date(l.ms).toISOString(),rn=(l,i,t)=>{let p=typeof i=="string"?i.toLowerCase():"";return t.includes(p)||Ge(l,`unit must be one of ${t.join(", ")} (got ${String(i)})`),p},En=(l,i)=>{let t=Number(i);return Number.isFinite(t)||Ge(l,"expected a number"),Math.trunc(t)};xi=new Map;Ye=(l,i=2,t="0")=>String(l).padStart(i,t);Ii=(l,i)=>i===""?[...l]:l.split(i),No=l=>l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Mo=l=>An.findIndex(i=>i.toLowerCase().startsWith(l.toLowerCase())&&(l.length===3||i.toLowerCase()===l.toLowerCase()));qn=new Map;Zn=l=>l?1:0,Kt=l=>typeof l=="bigint"?Number(l):typeof l=="number"?l:typeof l=="string"&&l.trim()!==""?Number(l):NaN,Tn=(l,i=0)=>l.map(t=>Kt(t[i])).filter(Number.isFinite),Fo=(l,i)=>l.map(t=>t.slice(0,i).map(Kt)).filter(t=>t.every(Number.isFinite));Oi=l=>i=>{let t=null;for(let p of i)p[0]!==null&&p[1]!==null&&(!t||l*jo(p[1],t[1])<0)&&(t=p);return t?t[0]:null},tr=(l,i)=>{let t=Kt(i);return Number.isInteger(t)||Ge(l,"expected whole numbers"),t},$o=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i,Uo=/^\s*(\d{1,4})([-/])(\d{1,2})\2(\d{1,2})(?!\d)(.*)$/s;nr=new Set([" "," ",`
|
|
2
|
+
`,"\v","\f","\r"]),Ci=new Set(['"',"'"]),Di={"[":"]","(":")","{":"}"};Ni=l=>{let i=zo(String(l));return i&&JSON.stringify(i)};Qo={dayname:{kind:"scalar",call:([l])=>rr[new Date(pt("dayname",l).ms).getUTCDay()]},monthname:{kind:"scalar",call:([l])=>An[new Date(pt("monthname",l).ms).getUTCMonth()]},dayofweek:{kind:"scalar",call:([l])=>new Date(pt("dayofweek",l).ms).getUTCDay()},date_trunc:{kind:"scalar",call:([l,i])=>{let t=rn("date_trunc",l,["day","week","month","quarter","year"]),p=new Date(pt("date_trunc",i).ms),g=p.getUTCFullYear(),T=p.getUTCMonth(),I=p.getUTCDate();return Nt(t==="day"?Date.UTC(g,T,I):t==="week"?Date.UTC(g,T,I-(p.getUTCDay()+6)%7):t==="month"?Date.UTC(g,T,1):t==="quarter"?Date.UTC(g,T-T%3,1):Date.UTC(g,0,1))}},date_add:{kind:"scalar",call:([l,i,t])=>{let p=pt("date_add",l),g=En("date_add",i),T=rn("date_add",t,["day","week","month","year","hour","minute"]);(T==="hour"||T==="minute")&&p.kind==="date"&&Ge("date_add",`adding ${T}s needs a timestamp, not a date`);let I=T==="month"?Kn(p.ms,g):T==="year"?Kn(p.ms,12*g):p.ms+g*{day:Mt,week:7*Mt,hour:36e5,minute:6e4}[T];return Co({kind:p.kind,ms:I})}},date_diff:{kind:"scalar",call:([l,i,t])=>{let p=rn("date_diff",l,["day","week","month","year","hour","minute"]),g=pt("date_diff",i).ms,T=pt("date_diff",t).ms;if(p!=="month"&&p!=="year")return Math.trunc((T-g)/{day:Mt,week:7*Mt,hour:36e5,minute:6e4}[p]);let I=new Date(g),j=new Date(T),H=(j.getUTCFullYear()-I.getUTCFullYear())*12+(j.getUTCMonth()-I.getUTCMonth()),se=ue=>ue.getTime()-Date.UTC(ue.getUTCFullYear(),ue.getUTCMonth(),1);return H>0&&se(j)<se(I)&&H--,H<0&&se(j)>se(I)&&H++,p==="month"?H:Math.trunc(H/12)}},date_part:{kind:"scalar",call:([l,i])=>{let t=rn("date_part",l,["year","quarter","month","week","day","hour","minute"]),p=new Date(pt("date_part",i).ms);switch(t){case"year":return p.getUTCFullYear();case"quarter":return Math.floor(p.getUTCMonth()/3)+1;case"month":return p.getUTCMonth()+1;case"week":return Fi(p.getTime()).week;case"day":return p.getUTCDate();case"hour":return p.getUTCHours();default:return p.getUTCMinutes()}}},date_format:{kind:"scalar",call:([l,i,t])=>(typeof i!="string"&&Ge("date_format","expected a pattern"),t!==void 0&&typeof t!="string"&&Ge("date_format","expected a time zone name"),Do("date_format",pt("date_format",l),i,t))},date_parse:{kind:"scalar",call:([l,i])=>(typeof i!="string"&&Ge("date_parse","expected a pattern"),Lo("date_parse",String(l),i))},date_series:{kind:"scalar",call:([l,i,t])=>{let p=t===void 0?"day":rn("date_series",t,["day","week","month"]),g=pt("date_series",l).ms,T=pt("date_series",i).ms,I=[];for(let j=0;;j++){let H=p==="month"?Kn(g,j):g+j*(p==="week"?7:1)*Mt;if(H>T)break;I.length>=Ai&&Ge("date_series",`more than ${Ai} dates`),I.push(Nt(H))}return JSON.stringify(I)}},to_timezone:{kind:"scalar",call:([l,i])=>{typeof i!="string"&&Ge("to_timezone","expected a time zone name");let t=ji("to_timezone",pt("to_timezone",l).ms,i);return`${Ye(t.year,4)}-${Ye(t.month)}-${Ye(t.day)}T${Ye(t.hour)}:${Ye(t.minute)}:${Ye(t.second)}.${Ye(t.ms,3)}`}},make_date:{kind:"scalar",call:([l,i,t])=>{let p=`${Ye(tr("make_date",l),4)}-${Ye(tr("make_date",i))}-${Ye(tr("make_date",t))}`;return Yt(p)===null&&Ge("make_date",`${p} is not a calendar date`),p}},to_date:{kind:"scalar",call:([l])=>Pi(l)??Ge("to_date",`${String(l).trim()} is not a date`)},try_to_date:{kind:"scalar",call:([l])=>Pi(l)},median:{kind:"aggregate",final:l=>Mi(ki(Tn(l)),.5)},quantile:{kind:"aggregate",final:l=>{let i=l[0]?.[1],t=Number(i);return i!=null&&!(t>=0&&t<=1)&&Ge("quantile","q must be between 0 and 1"),i==null?null:Mi(ki(Tn(l)),t)}},stddev:{kind:"aggregate",final:l=>Ri(Tn(l),!0)},stddev_pop:{kind:"aggregate",final:l=>Ri(Tn(l),!1)},regr_slope:{kind:"aggregate",final:l=>er(l)?.slope??null},regr_intercept:{kind:"aggregate",final:l=>er(l)?.intercept??null},corr:{kind:"aggregate",final:l=>er(l)?.r??null},arg_min:{kind:"aggregate",final:Oi(1)},arg_max:{kind:"aggregate",final:Oi(-1)},round:{kind:"scalar",real:!0,call:([l,i])=>{let t=Kt(l);Number.isNaN(t)&&Ge("round","expected a number");let p=i===void 0?0:En("round",i);if(Number.isInteger(t)&&p>=0)return t;let g=10**Math.abs(p),T=Math.sign(t)*(p>=0?Math.round(Math.abs(t)*g)/g:Math.round(Math.abs(t)/g)*g);return Number.isFinite(T)?T:t}},to_number:{kind:"scalar",call:([l])=>{if(typeof l=="number"||typeof l=="bigint")return Number(l);let i=String(l).trim();return $o.test(i)?Number(i):null}},string_split:{kind:"scalar",call:([l,i])=>JSON.stringify(Ii(String(l),String(i)))},split_part:{kind:"scalar",call:([l,i,t])=>{let p=Ii(String(l),String(i)),g=En("split_part",t);return(g>0?p[g-1]:g<0?p[p.length+g]:void 0)??""}},regexp_matches:{kind:"scalar",call:([l,i])=>Zn(Yn("regexp_matches",i).test(String(l)))},regexp_replace:{kind:"scalar",call:([l,i,t])=>String(l).replace(Yn("regexp_replace",i,"g"),String(t))},regexp_extract:{kind:"scalar",call:([l,i,t])=>{let p=Yn("regexp_extract",i).exec(String(l));return p?p[t===void 0?0:En("regexp_extract",t)]??null:null}},list_contains:{kind:"scalar",call:([l,i])=>Zn(Xn("list_contains",l).includes(i))},list_has_any:{kind:"scalar",call:([l,i])=>{let t=Xn("list_has_any",l);return Zn(Xn("list_has_any",i).some(p=>t.includes(p)))}},to_list:{kind:"scalar",call:([l])=>Ni(l)??Ge("to_list",`${String(l)} is not a list`)},try_to_list:{kind:"scalar",call:([l])=>Ni(l)},list_value:{kind:"scalar",nullable:!1,call:l=>JSON.stringify(l.map(i=>(i!==null&&typeof i=="object"&&Ge("list_value","lists hold text, numbers and null"),typeof i=="bigint"?Number(i):i)))},uuid:{kind:"scalar",nullable:!1,call:()=>globalThis.crypto.randomUUID()}},Vo=zn.flatMap(l=>l.arity.map(i=>({name:l.name,arity:i,kind:l.kind}))),ir=new Set(zn.map(l=>l.name))});function Ho(l){let i=ut(l.name),t=l.type==="boolean"?[`${i} IN (0, 1)`,"true or false"]:l.type==="date"?[`date(${i}) IS ${i}`,"a date (YYYY-MM-DD)"]:l.type==="timestamp"?[`strftime('%Y-%m-%dT%H:%M:%fZ', ${i}) IS ${i}`,"a UTC timestamp (YYYY-MM-DDTHH:MM:SS.sssZ)"]:null;return t?` CONSTRAINT ${ut(`${l.name} must be ${t[1]}`)} CHECK (${t[0]})`:""}function sn(l,i,t){if(i==null)return null;if(l==="date"){if(typeof i!="string"||Yt(i)===null)throw new Error(`${t} is not a date the dataset can hold (expected YYYY-MM-DD)`);return i}if(l==="timestamp")return xt(i,t);if(typeof i=="boolean")return i?1:0;if(l==="boolean"&&i!==0&&i!==1)throw new Error(`${t} must be true or false`);return typeof i=="number"||typeof i=="string"?i:typeof i=="bigint"?Number(i):JSON.stringify(i)}function Jo(l,i){return l==null?null:(typeof l=="bigint"&&(l=Number(l)),l instanceof Uint8Array?Array.from(l,t=>t.toString(16).padStart(2,"0")).join(""):i==="boolean"?l!==0:l)}var nt,St,Wo,ut,_t,sr,xn,Go,Ko,or,ar,st,Yo,on=Oe(()=>{"use strict";ht();It();Ui();nt=class extends Error{},St=class extends Error{},Wo={string:"TEXT",number:"REAL",boolean:"INTEGER",date:"TEXT",timestamp:"TEXT",user:"TEXT"},ut=l=>`"${l.replaceAll('"','""')}"`,_t=(l,i)=>`${l.toLowerCase()}\0${i.toLowerCase()}`,sr=new Set(["json_each","json_tree"]),xn=new Set(["->","->>","abs","acos","acosh","asin","asinh","atan","atan2","atanh","avg","ceil","ceiling","char","coalesce","concat","concat_ws","cos","cosh","count","cume_dist","current_date","current_time","current_timestamp","date","datetime","degrees","dense_rank","exp","first_value","floor","format","glob","group_concat","hex","if","ifnull","iif","instr","json","json_array","json_array_insert","json_array_length","json_error_position","json_extract","json_group_array","json_group_object","json_insert","json_object","json_patch","json_pretty","json_quote","json_remove","json_replace","json_set","json_type","json_valid","julianday","lag","last_value","lead","length","like","likelihood","likely","ln","log","log10","log2","lower","ltrim","max","min","mod","nth_value","ntile","nullif","octet_length","percent_rank","percentile","percentile_cont","percentile_disc","pi","pow","power","printf","quote","radians","random","randomblob","rank","replace","round","row_number","rtrim","sign","sin","sinh","sqrt","strftime","string_agg","substr","substring","sum","tan","tanh","time","timediff","total","trim","trunc","typeof","unhex","unicode","unistr","unistr_quote","unixepoch","unlikely","upper","zeroblob"]);Go=(l,i)=>l==="date"&&typeof i=="string"&&/^\d{4}-\d{2}-\d{2}[T ]/.test(i)?i.slice(0,10):i;Ko=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,or=l=>(l instanceof Error?l.message:String(l)).replace(/^SQLITE_[A-Z_]+: sqlite3 result code \d+: /,""),ar=class{constructor(i,t,p){this.owner=i;this.stmt=t;this.analysis=p}owner;stmt;analysis;get text(){return this.owner.sqlite3.capi.sqlite3_sql(this.stmt.pointer).replace(/;$/,"")}bind(i,t={}){let{capi:p}=this.owner.sqlite3;for(let g=1;g<=this.stmt.parameterCount;g++){let T=p.sqlite3_bind_parameter_name(this.stmt.pointer,g).slice(1),I=sn(Object.hasOwn(t,T)?t[T]:void 0,Object.hasOwn(i,T)?i[T]:null,`parameter $${T}`);typeof I=="number"?p.sqlite3_bind_double(this.stmt.pointer,g,I):this.stmt.bind(g,I)}return this}rows(i,t){let p=[],g=!1;this.owner.within(t,()=>{for(;this.stmt.step();){if(p.length===i){g=!0;break}p.push(Array.from({length:this.stmt.columnCount},(j,H)=>this.stmt.get(H)))}});let T=this.analysis.columns.map((j,H)=>this.owner.resultColumn(this.stmt,H,j,p));return{rows:p.map(j=>Object.fromEntries(T.map((H,se)=>[H.name,Jo(j[se],H.type)]))),columns:T,more:g}}run(i){this.owner.within(i,()=>{for(;this.stmt.step(););})}finalize(){this.stmt.finalize()}},st=class{constructor(i){this.sqlite3=i;let{capi:t}=i;this.#e=new i.oo1.DB(":memory:");try{$i(this.#e,(p,g)=>t.sqlite3_js_aggregate_context(p,g),(p,g)=>t.sqlite3_result_double(p,g)),this.#u=new Set(this.trusted(()=>this.#e.exec({sql:"SELECT name FROM pragma_module_list",returnValue:"resultRows"}).map(p=>String(p[0]).toLowerCase()))),this.trusted(()=>this.#e.exec("PRAGMA recursive_triggers = ON")),t.sqlite3_limit(this.#e,t.SQLITE_LIMIT_LENGTH,32*1024*1024),t.sqlite3_limit(this.#e,t.SQLITE_LIMIT_SQL_LENGTH,1e6),t.sqlite3_set_authorizer(this.#e,(p,g,T,I,j,H)=>this.#y({code:g,object:T||null,column:I===0?null:I,db:j||null,source:H||null}),0),t.sqlite3_progress_handler(this.#e,1e3,()=>performance.now()<=this.#d?0:(this.#m=!0,1),0)}catch(p){throw this.#e.close(),p}}sqlite3;#e;#t=new Map;#s=["temp","main"];#n=new Set;#r=new Set;#a=new Set;#u;#i=0;#f="read";#o=null;#l=null;#c=null;#d=1/0;#m=!1;close(){this.#e.close()}trusted(i){this.#i++;try{return i()}finally{this.#i--}}exec(i,t){return this.trusted(()=>this.#e.exec({sql:i,bind:t,rowMode:"object",returnValue:"resultRows"}))}internalFunction(i,t){let p=this.internalName();return this.#e.createFunction({name:p,arity:t,xFunc:(g,...T)=>i(...T)}),p}extensionFunction(i,t,p){let g=i.toLowerCase();if(!/^[a-z_][a-z0-9_]*$/.test(g)||xn.has(g)||ir.has(g))throw new Error(`invalid extension function name ${i}`);this.#e.createFunction({name:g,arity:p,xFunc:(T,...I)=>t(...I)}),this.#a.add(g)}internalName(){let i=globalThis.crypto.getRandomValues(new Uint8Array(12)),t=`__engine_${Array.from(i,p=>p.toString(16).padStart(2,"0")).join("")}`;return this.#r.add(t),t}attach(i){if(!i||i.length>255||i.includes("\0")||/^temp$|^sqlite_/i.test(i))throw new Error(`invalid schema name ${i}`);this.#s.some(t=>t.toLowerCase()===i.toLowerCase())||(this.exec(`ATTACH ':memory:' AS ${ut(i)}`),this.#s.push(i))}createTable(i,t){let p=i.columns.length?i.columns:[{name:"_empty",type:"string"}];i.schema!=="main"&&this.attach(i.schema);let g=p.map((T,I)=>`${ut(T.name)} ${Wo[T.type]}${t?` DEFAULT (${t(I)})`:""}${Ho(T)}`).join(", ");this.exec(`CREATE TABLE ${ut(i.schema)}.${ut(i.table)} (${g}) STRICT`),this.#p(i.schema,i.table,i.columns)}insertRows(i,t){if(!t.length||!i.columns.length)return;let p=JSON.stringify(t.map((T,I)=>i.columns.map(j=>sn(j.type,Go(j.type,T[j.name]),`${i.table}.${j.name} (row ${I+1})`)))),g=i.columns.map(T=>ut(T.name)).join(", ");try{this.exec(`INSERT INTO ${ut(i.schema)}.${ut(i.table)} (${g}) SELECT ${i.columns.map((T,I)=>`value ->> ${I}`).join(", ")} FROM json_each(?) ORDER BY key`,[p])}catch(T){throw new Error(or(T))}}load(i){let t={...i,columns:i.columns.length?i.columns:Ht(i.rows)};this.createTable(t),this.insertRows(t,i.rows)}drop(i,t){this.exec(`DROP TABLE IF EXISTS ${ut(i)}.${ut(t)}`),this.#t.delete(_t(i,t))}scratch(i){let t=new Map(this.#t),p=new Set(this.#n);this.exec("BEGIN");try{return i()}finally{this.sqlite3.capi.sqlite3_get_autocommit(this.#e.pointer)||this.exec("ROLLBACK"),this.#t.clear();for(let[g,T]of t)this.#t.set(g,T);this.#n.clear();for(let g of p)this.#n.add(g)}}createView(i){let t=this.prepare(i.sql,"read"),p;try{if(t.stmt.parameterCount)throw new nt("a stored model cannot bind reader parameters");p=t.text}finally{t.finalize()}i.schema!=="main"&&this.attach(i.schema);let g=i.columns.length?i.columns.map(T=>ut(T.name)).join(", "):"*";this.exec(`CREATE VIEW ${ut(i.schema)}.${ut(i.table)} AS SELECT ${g} FROM (
|
|
3
3
|
${p}
|
|
4
|
-
) AS _model`),this.#n.add(i.table.toLowerCase()),this.#p(i.schema,i.table,i.columns)}createViews(i){let t=i;for(;t.length;){let p=t.filter(g=>{try{return this.createView(g),!1}catch{return!0}});if(p.length===t.length)return;t=p}}registeredFunctions(){return this.exec("SELECT name, narg, type FROM pragma_function_list WHERE builtin = 0").map(i=>({name:String(i.name),arity:Number(i.narg),kind:i.type==="a"?"aggregate":i.type==="w"?"window":"scalar"}))}#p(i,t,p){this.#t.set(_t(i,t),new Map(p.map(g=>[g.name.toLowerCase(),g])))}prepare(i,t,p){let g=t==="write"?"Mutation":"Query";this.#f=t,this.#o=p??null,this.#l=[],this.#c=null;let T,I=this.#l;try{T=this.#e.prepare(i)}catch(j){throw this.#c?new nt(this.#c):new Error(or(j))}finally{this.#l=null}try{let j=this.sqlite3.capi.sqlite3_sql(T.pointer);if(!i.startsWith(j)||!this.#h(i.slice(j.length)))throw new nt(`a <${g}> holds exactly one statement \u2014 split it into separate <${g}> declarations`);let H=this.#w(T,I);return this.#S(T,H,t,g),new ar(this,T,H)}catch(j){throw T.finalize(),j}}#h(i){if(!i.trim())return!0;let{capi:t,wasm:p}=this.sqlite3,[g,T]=p.allocCString(i,!0),I=p.pstack.pointer,j=this.#l;this.#l=null;try{let H=p.pstack.allocPtr(),se=p.pstack.allocPtr(),ue=g+T;for(let Y=g;Y<ue;){let ne=t.sqlite3_prepare_v3(this.#e.pointer,Y,ue-Y,0,H,se),_e=p.peekPtr(H);if(_e)return t.sqlite3_finalize(_e),!1;if(ne!==t.SQLITE_OK)return!1;let Te=p.peekPtr(se);if(Te<=Y)return!1;Y=Te}return!0}finally{this.#l=j,p.pstack.restore(I),p.dealloc(g)}}#y(i){let{capi:t}=this.sqlite3;if(this.#i||(this.#l?.push(i),i.source&&this.#r.has(i.source)))return t.SQLITE_OK;let p=this.#b(i);return p===null?t.SQLITE_OK:(this.#c??=p,t.SQLITE_DENY)}#b(i){let{capi:t}=this.sqlite3,p=i.object?.toLowerCase()??"";switch(i.code){case t.SQLITE_SELECT:case t.SQLITE_RECURSIVE:return null;case t.SQLITE_READ:return this.#_(p)?`${i.object} is not data a statement may read (system and virtual tables are refused)`:i.db&&!sr.has(p)&&!this.#t.has(_t(i.db,p))?`${i.db}.${i.object} is not a table this statement may read`:null;case t.SQLITE_FUNCTION:{let g=(i.column??"").toLowerCase();return xn.has(g)||ir.has(g)||this.#a.has(g)?null:`function ${g}() is not available`}case t.SQLITE_INSERT:case t.SQLITE_UPDATE:case t.SQLITE_DELETE:return this.#f==="read"?"a <Query> may only SELECT \u2014 a document reads its data, it never writes it; a write is a <Mutation>":this.#_(p)||!i.db||!this.#t.has(_t(i.db,p))||this.#n.has(p)?`${i.object} is not a table a <Mutation> may write`:this.#o&&_t(i.db,p)!==_t(this.#o.schema,this.#o.table)?`a <Mutation> writes only its own table ${this.#o.table}, not ${i.object}`:null;default:return`${
|
|
5
|
-
`,Te=ne;if(T){try{Te=l.prepare(lr({name:i,sql:_e},T).sql,"read")}catch(ge){if(!T.sort||ge instanceof nt)throw ge;Te=l.prepare(lr({name:i,sql:_e},{...T,sort:void 0}).sql,"read")}Y.push(Te)}if(H){let{rows:ge,columns:Pe}=Te.bind(p,g).rows(Number.POSITIVE_INFINITY,ue());return ge.length<=I?{rows:ge,columns:Pe}:{rows:ge.slice(0,I),columns:Pe,truncated:!0,totalRows:ge.length,all:ge}}let{rows:Ce,columns:be,more:re}=Te.bind(p,g).rows(I,ue());if(!re&&!T)return{rows:Ce,columns:be};let ye=l.prepare(`SELECT count(*) AS n FROM (${_e}) AS _q`,"read");Y.push(ye);let Ae=Number(ye.bind(p,g).rows(1,ue()).rows[0]?.n);return{rows:Ce,columns:be,...Ae>Ce.length?{truncated:!0}:{},totalRows:Ae}}catch(ne){return ne instanceof St?{error:`<Query name="${i}"> ran too long and was stopped (limit ${j}ms) \u2014 narrow it (filter, aggregate, or LIMIT)`,timedOut:!0}:{error:an(ne)}}finally{for(let ne of Y)ne.finalize()}}function
|
|
6
|
-
`).slice(0,3).join(" ").trim();
|
|
7
|
-
`).slice(0,3).join(" ").trim(),dr=class{constructor(i,t,p){this.db=i;this.target=t;this.#t=Array.from({length:p},()=>0),this.unset=i.internalFunction(g=>(this.#e&&this.#t[Number(g)]++,null),1)}db;target;inserted=[];updated=[];deleted=[];moved=!1;visible=null;#e=!0;#t;unset;install(){let i=this.db.internalFunction(g=>this.#e&&this.visible&&!this.visible.has(Number(g))?1:0,1),t=this.db.internalFunction((g,T,I)=>(this.#e&&(g==="i"?this.inserted.push(Number(I)):g==="d"?this.deleted.push(Number(T)):(this.updated.push(Number(T)),T!==I&&(this.moved=!0))),null),3),p=this.target;for(let g of[`BEFORE UPDATE ON ${p} WHEN ${i}(OLD.rowid) BEGIN SELECT RAISE(IGNORE); END`,`BEFORE DELETE ON ${p} WHEN ${i}(OLD.rowid) BEGIN SELECT RAISE(IGNORE); END`,`AFTER INSERT ON ${p} BEGIN SELECT ${t}('i', NULL, NEW.rowid); END`,`AFTER UPDATE ON ${p} BEGIN SELECT ${t}('u', OLD.rowid, NEW.rowid); END`,`AFTER DELETE ON ${p} BEGIN SELECT ${t}('d', OLD.rowid, NULL); END`])this.db.exec(`CREATE TEMP TRIGGER ${this.db.internalName()} ${g}`)}stop(){this.#e=!1}named(i){return this.inserted.length?i.filter((t,p)=>this.#t[p]<this.inserted.length):[]}within(i){return i==="insert"?!this.updated.length&&!this.deleted.length:i==="update"?!this.inserted.length&&!this.deleted.length&&!this.moved:!this.inserted.length&&!this.updated.length}},
|
|
8
|
-
`)),!e)return null;Fn=Ln(e,!0)}return Fn.shift()},qt={ttys:[],init(){},shutdown(){},register(e,n){qt.ttys[e]={input:[],output:[],ops:n},f.registerDevice(e,qt.stream_ops)},stream_ops:{open(e){var n=qt.ttys[e.node.rdev];if(!n)throw new f.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,c,o,r){if(!e.tty||!e.tty.ops.get_char)throw new f.ErrnoError(60);for(var s=0,a=0;a<o;a++){var m;try{m=e.tty.ops.get_char(e.tty)}catch{throw new f.ErrnoError(29)}if(m===void 0&&s===0)throw new f.ErrnoError(6);if(m==null)break;s++,n[c+a]=m}return s&&(e.node.atime=Date.now()),s},write(e,n,c,o,r){if(!e.tty||!e.tty.ops.put_char)throw new f.ErrnoError(60);try{for(var s=0;s<o;s++)e.tty.ops.put_char(e.tty,n[c+s])}catch{throw new f.ErrnoError(29)}return o&&(e.node.mtime=e.node.ctime=Date.now()),s}},default_tty_ops:{get_char(e){return ys()},put_char(e,n){n===null||n===10?(Y(Xt(e.output)),e.output=[]):n!=0&&e.output.push(n)},fsync(e){e.output?.length>0&&(Y(Xt(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,c){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,n){n===null||n===10?(ne(Xt(e.output)),e.output=[]):n!=0&&e.output.push(n)},fsync(e){e.output?.length>0&&(ne(Xt(e.output)),e.output=[])}}},bs=(e,n)=>Rt.fill(0,e,e+n),vr=(e,n)=>Math.ceil(e/n)*n,Er=e=>{e=vr(e,65536);var n=Or(65536,e);return n&&bs(n,e),n},Re={ops_table:null,mount(e){return Re.createNode(null,"/",16895,0)},createNode(e,n,c,o){if(f.isBlkdev(c)||f.isFIFO(c))throw new f.ErrnoError(63);Re.ops_table||={dir:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr,lookup:Re.node_ops.lookup,mknod:Re.node_ops.mknod,rename:Re.node_ops.rename,unlink:Re.node_ops.unlink,rmdir:Re.node_ops.rmdir,readdir:Re.node_ops.readdir,symlink:Re.node_ops.symlink},stream:{llseek:Re.stream_ops.llseek}},file:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr},stream:{llseek:Re.stream_ops.llseek,read:Re.stream_ops.read,write:Re.stream_ops.write,mmap:Re.stream_ops.mmap,msync:Re.stream_ops.msync}},link:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr,readlink:Re.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr},stream:f.chrdev_stream_ops}};var r=f.createNode(e,n,c,o);return f.isDir(r.mode)?(r.node_ops=Re.ops_table.dir.node,r.stream_ops=Re.ops_table.dir.stream,r.contents={}):f.isFile(r.mode)?(r.node_ops=Re.ops_table.file.node,r.stream_ops=Re.ops_table.file.stream,r.usedBytes=0,r.contents=Re.emptyFileContents??=new Uint8Array(0)):f.isLink(r.mode)?(r.node_ops=Re.ops_table.link.node,r.stream_ops=Re.ops_table.link.stream):f.isChrdev(r.mode)&&(r.node_ops=Re.ops_table.chrdev.node,r.stream_ops=Re.ops_table.chrdev.stream),r.atime=r.mtime=r.ctime=Date.now(),e&&(e.contents[n]=r,e.atime=e.mtime=e.ctime=r.atime),r},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,n){var c=e.contents.length;if(!(c>=n)){n=Math.max(n,c*(c<1048576?2:1.125)>>>0),c&&(n=Math.max(n,256));var o=Re.getFileDataAsTypedArray(e);e.contents=new Uint8Array(n),e.contents.set(o)}},resizeFileStorage(e,n){if(e.usedBytes!=n){var c=e.contents;e.contents=new Uint8Array(n),e.contents.set(c.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n}},node_ops:{getattr(e){var n={};return n.dev=f.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,f.isDir(e.mode)?n.size=4096:f.isFile(e.mode)?n.size=e.usedBytes:f.isLink(e.mode)?n.size=e.link.length:n.size=0,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 c of["mode","atime","mtime","ctime"])n[c]!=null&&(e[c]=n[c]);n.size!==void 0&&Re.resizeFileStorage(e,n.size)},lookup(e,n){throw Re.doesNotExistError||(Re.doesNotExistError=new f.ErrnoError(44),Re.doesNotExistError.stack="<generic error, no stack>"),Re.doesNotExistError},mknod(e,n,c,o){return Re.createNode(e,n,c,o)},rename(e,n,c){var o;try{o=f.lookupNode(n,c)}catch{}if(o){if(f.isDir(e.mode))for(var r in o.contents)throw new f.ErrnoError(55);f.hashRemoveNode(o)}delete e.parent.contents[e.name],n.contents[c]=e,e.name=c,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){for(var c in f.lookupNode(e,n).contents)throw new f.ErrnoError(55);delete e.contents[n],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,n,c){var o=Re.createNode(e,n,41471,0);return o.link=c,o},readlink(e){if(!f.isLink(e.mode))throw new f.ErrnoError(28);return e.link}},stream_ops:{read(e,n,c,o,r){var s=e.node.contents;if(r>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-r,o);return n.set(s.subarray(r,r+a),c),a},write(e,n,c,o,r,s){if(n.buffer===ot.buffer&&(s=!1),!o)return 0;var a=e.node;return a.mtime=a.ctime=Date.now(),s?(a.contents=n.subarray(c,c+o),a.usedBytes=o):a.usedBytes===0&&r===0?(a.contents=n.slice(c,c+o),a.usedBytes=o):(Re.expandFileStorage(a,r+o),a.contents.set(n.subarray(c,c+o),r),a.usedBytes=Math.max(a.usedBytes,r+o)),o},llseek(e,n,c){var o=n;if(c===1?o+=e.position:c===2&&f.isFile(e.node.mode)&&(o+=e.node.usedBytes),o<0)throw new f.ErrnoError(28);return o},mmap(e,n,c,o,r){if(!f.isFile(e.node.mode))throw new f.ErrnoError(43);var s,a,m=e.node.contents;if(!(r&2)&&m.buffer===ot.buffer)a=!1,s=m.byteOffset;else{if(a=!0,s=Er(n),!s)throw new f.ErrnoError(48);m&&((c>0||c+n<m.length)&&(m.subarray?m=m.subarray(c,c+n):m=Array.prototype.slice.call(m,c,c+n)),ot.set(m,s))}return{ptr:s,allocated:a}},msync(e,n,c,o,r){return Re.stream_ops.write(e,n,0,o,c,!1),0}}},ws=e=>{if(typeof e!="string")return e;var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(typeof n>"u")throw new Error(`Unknown file open mode: ${e}`);return n},qr=e=>(typeof e=="string"&&(e=Ln(e,!0)),e.subarray||(e=new Uint8Array(e)),e),jn=(e,n)=>{var c=0;return e&&(c|=365),n&&(c|=146),c},Ss=async e=>{var n=await se(e);return new Uint8Array(n)},vs=(...e)=>f.createDataFile(...e),Es=e=>e,Ot=0,Zt=null,qs=e=>{if(Ot--,t.monitorRunDependencies?.(Ot),Ot==0&&Zt){var n=Zt;Zt=null,n()}},Ts=e=>{Ot++,t.monitorRunDependencies?.(Ot)},Tr=[],As=async(e,n)=>{typeof Browser<"u"&&Browser.init();for(var c of Tr)if(c.canHandle(n))return c.handle(e,n);return e},Ar=async(e,n,c,o,r,s,a,m)=>{var d=n?jt.resolve(Ve.join2(e,n)):e,q=Es(`cp ${d}`);Ts(q);try{var V=c;typeof c=="string"&&(V=await Ss(c)),V=await As(V,d),m?.(),s||vs(e,n,V,o,r,a)}finally{qs(q)}},xs=(e,n,c,o,r,s,a,m,d,q)=>{Ar(e,n,c,o,r,m,d,q).then(s).catch(a)},f={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,c,o){e||(e=this),this.parent=e,this.mount=e.mount,this.id=f.nextInode++,this.name=n,this.mode=c,this.rdev=o,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 f.isDir(this.mode)}get isDevice(){return f.isChrdev(this.mode)}},lookupPath(e,n={}){if(!e)throw new f.ErrnoError(44);n.follow_mount??=!0,Ve.isAbs(e)||(e=f.cwd()+"/"+e);e:for(var c=0;c<40;c++){for(var o=e.split("/").filter(q=>!!q),r=f.root,s="/",a=0;a<o.length;a++){var m=a===o.length-1;if(m&&n.parent)break;if(o[a]!=="."){if(o[a]===".."){if(s=Ve.dirname(s),f.isRoot(r)){e=s+"/"+o.slice(a+1).join("/"),c--;continue e}else r=r.parent;continue}s=Ve.join2(s,o[a]);try{r=f.lookupNode(r,o[a])}catch(q){if(q?.errno===44&&m&&n.noent_okay)return{path:s};throw q}if(f.isMountpoint(r)&&(!m||n.follow_mount)&&(r=r.mounted.root),f.isLink(r.mode)&&(!m||n.follow)){if(!r.node_ops.readlink)throw new f.ErrnoError(52);var d=r.node_ops.readlink(r);Ve.isAbs(d)||(d=Ve.dirname(s)+"/"+d),e=d+"/"+o.slice(a+1).join("/");continue e}}}return{path:s,node:r}}throw new f.ErrnoError(32)},getPath(e){for(var n;;){if(f.isRoot(e)){var c=e.mount.mountpoint;return n?c[c.length-1]!=="/"?`${c}/${n}`:c+n:c}n=n?`${e.name}/${n}`:e.name,e=e.parent}},hashName(e,n){for(var c=0,o=0;o<n.length;o++)c=(c<<5)-c+n.charCodeAt(o)|0;return(e+c>>>0)%f.nameTable.length},hashAddNode(e){var n=f.hashName(e.parent.id,e.name);e.name_next=f.nameTable[n],f.nameTable[n]=e},hashRemoveNode(e){var n=f.hashName(e.parent.id,e.name);if(f.nameTable[n]===e)f.nameTable[n]=e.name_next;else for(var c=f.nameTable[n];c;){if(c.name_next===e){c.name_next=e.name_next;break}c=c.name_next}},lookupNode(e,n){var c=f.mayLookup(e);if(c)throw new f.ErrnoError(c);for(var o=f.hashName(e.id,n),r=f.nameTable[o];r;r=r.name_next){var s=r.name;if(r.parent.id===e.id&&s===n)return r}return f.lookup(e,n)},createNode(e,n,c,o){var r=new f.FSNode(e,n,c,o);return f.hashAddNode(r),r},destroyNode(e){f.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];return e&512&&(n+="w"),n},nodePermissions(e,n){return f.ignorePermissions?0:n.includes("r")&&!(e.mode&292)||n.includes("w")&&!(e.mode&146)||n.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!f.isDir(e.mode))return 54;var n=f.nodePermissions(e,"x");return n||(e.node_ops.lookup?0:2)},mayCreate(e,n){if(!f.isDir(e.mode))return 54;try{return f.lookupNode(e,n),20}catch{}return f.nodePermissions(e,"wx")},mayDelete(e,n,c){var o;try{o=f.lookupNode(e,n)}catch(s){return s.errno}var r=f.nodePermissions(e,"wx");if(r)return r;if(c){if(!f.isDir(o.mode))return 54;if(f.isRoot(o)||f.getPath(o)===f.cwd())return 10}else if(f.isDir(o.mode))return 31;return 0},mayOpen(e,n){if(!e)return 44;if(f.isLink(e.mode))return 32;var c=f.flagsToPermissionString(n);return f.isDir(e.mode)&&(c!=="r"||n&576)?31:f.nodePermissions(e,c)},checkOpExists(e,n){if(!e)throw new f.ErrnoError(n);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=f.MAX_OPEN_FDS;e++)if(!f.streams[e])return e;throw new f.ErrnoError(33)},getStreamChecked(e){var n=f.getStream(e);if(!n)throw new f.ErrnoError(8);return n},getStream:e=>f.streams[e],createStream(e,n=-1){return e=Object.assign(new f.FSStream,e),n==-1&&(n=f.nextfd()),e.fd=n,f.streams[n]=e,e},closeStream(e){f.streams[e]=null},dupStream(e,n=-1){var c=f.createStream(e,n);return c.stream_ops?.dup?.(c),c},doSetAttr(e,n,c){var o=e?.stream_ops.setattr,r=o?e:n;o??=n.node_ops.setattr,f.checkOpExists(o,63),o(r,c)},chrdev_stream_ops:{open(e){e.stream_ops=f.getDevice(e.node.rdev).stream_ops,e.stream_ops.open?.(e)},llseek(){throw new f.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,n)=>e<<8|n,registerDevice(e,n){f.devices[e]={stream_ops:n}},getDevice:e=>f.devices[e],getMounts(e){for(var n=[],c=[e];c.length;){var o=c.pop();n.push(o),c.push(...o.mounts)}return n},syncfs(e,n){typeof e=="function"&&(n=e,e=!1),f.syncFSRequests++,f.syncFSRequests>1&&ne(`warning: ${f.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var c=f.getMounts(f.root.mount),o=0;function r(m){return f.syncFSRequests--,n(m)}function s(m){if(m)return s.errored?void 0:(s.errored=!0,r(m));++o>=c.length&&r(null)}for(var a of c)a.type.syncfs?a.type.syncfs(a,e,s):s(null)},mount(e,n,c){var o=c==="/",r=!c,s;if(o&&f.root)throw new f.ErrnoError(10);if(!o&&!r){var a=f.lookupPath(c,{follow_mount:!1});if(c=a.path,s=a.node,f.isMountpoint(s))throw new f.ErrnoError(10);if(!f.isDir(s.mode))throw new f.ErrnoError(54)}var m={type:e,opts:n,mountpoint:c,mounts:[]},d=e.mount(m);return d.mount=m,m.root=d,o?f.root=d:s&&(s.mounted=m,s.mount&&s.mount.mounts.push(m)),d},unmount(e){var n=f.lookupPath(e,{follow_mount:!1});if(!f.isMountpoint(n.node))throw new f.ErrnoError(28);var c=n.node,o=c.mounted,r=f.getMounts(o);for(var[s,a]of Object.entries(f.nameTable))for(;a;){var m=a.name_next;r.includes(a.mount)&&f.destroyNode(a),a=m}c.mounted=null;var d=c.mount.mounts.indexOf(o);c.mount.mounts.splice(d,1)},lookup(e,n){return e.node_ops.lookup(e,n)},mknod(e,n,c){var o=f.lookupPath(e,{parent:!0}).node,r=Ve.basename(e);if(!r)throw new f.ErrnoError(28);if(r==="."||r==="..")throw new f.ErrnoError(20);var s=f.mayCreate(o,r);if(s)throw new f.ErrnoError(s);if(!o.node_ops.mknod)throw new f.ErrnoError(63);return o.node_ops.mknod(o,r,n,c)},statfs(e){return f.statfsNode(f.lookupPath(e,{follow:!0}).node)},statfsStream(e){return f.statfsNode(e.node)},statfsNode(e){var n={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:f.nextInode,ffree:f.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(n,e.node_ops.statfs(e.mount.opts.root)),n},create(e,n=438){return n&=4095,n|=32768,f.mknod(e,n,0)},mkdir(e,n=511){return n&=1023,n|=16384,f.mknod(e,n,0)},mkdirTree(e,n){var c=e.split("/"),o="";for(var r of c)if(r){(o||Ve.isAbs(e))&&(o+="/"),o+=r;try{f.mkdir(o,n)}catch(s){if(s.errno!=20)throw s}}},mkdev(e,n,c){return typeof c>"u"&&(c=n,n=438),n|=8192,f.mknod(e,n,c)},symlink(e,n){if(!jt.resolve(e))throw new f.ErrnoError(44);var c=f.lookupPath(n,{parent:!0}).node;if(!c)throw new f.ErrnoError(44);var o=Ve.basename(n),r=f.mayCreate(c,o);if(r)throw new f.ErrnoError(r);if(!c.node_ops.symlink)throw new f.ErrnoError(63);return c.node_ops.symlink(c,o,e)},rename(e,n){var c=Ve.dirname(e),o=Ve.dirname(n),r=Ve.basename(e),s=Ve.basename(n),a=f.lookupPath(e,{parent:!0}),m=a.node,d;if(a=f.lookupPath(n,{parent:!0}),d=a.node,!m||!d)throw new f.ErrnoError(44);if(m.mount!==d.mount)throw new f.ErrnoError(75);var q=f.lookupNode(m,r),V=jt.relative(e,o);if(V.charAt(0)!==".")throw new f.ErrnoError(28);if(V=jt.relative(n,c),V.charAt(0)!==".")throw new f.ErrnoError(55);var N;try{N=f.lookupNode(d,s)}catch{}if(q!==N){var x=f.isDir(q.mode),R=f.mayDelete(m,r,x);if(R)throw new f.ErrnoError(R);if(R=N?f.mayDelete(d,s,x):f.mayCreate(d,s),R)throw new f.ErrnoError(R);if(!m.node_ops.rename)throw new f.ErrnoError(63);if(f.isMountpoint(q)||N&&f.isMountpoint(N))throw new f.ErrnoError(10);if(d!==m&&(R=f.nodePermissions(m,"w"),R))throw new f.ErrnoError(R);f.hashRemoveNode(q);try{m.node_ops.rename(q,d,s),q.parent=d}catch($){throw $}finally{f.hashAddNode(q)}}},rmdir(e){var n=f.lookupPath(e,{parent:!0}).node,c=Ve.basename(e),o=f.lookupNode(n,c),r=f.mayDelete(n,c,!0);if(r)throw new f.ErrnoError(r);if(!n.node_ops.rmdir)throw new f.ErrnoError(63);if(f.isMountpoint(o))throw new f.ErrnoError(10);n.node_ops.rmdir(n,c),f.destroyNode(o)},readdir(e){var n=f.lookupPath(e,{follow:!0}).node;return f.checkOpExists(n.node_ops.readdir,54)(n)},unlink(e){var n=f.lookupPath(e,{parent:!0}).node;if(!n)throw new f.ErrnoError(44);var c=Ve.basename(e),o=f.lookupNode(n,c),r=f.mayDelete(n,c,!1);if(r)throw new f.ErrnoError(r);if(!n.node_ops.unlink)throw new f.ErrnoError(63);if(f.isMountpoint(o))throw new f.ErrnoError(10);n.node_ops.unlink(n,c),f.destroyNode(o)},readlink(e){var n=f.lookupPath(e).node;if(!n)throw new f.ErrnoError(44);if(!n.node_ops.readlink)throw new f.ErrnoError(28);return n.node_ops.readlink(n)},stat(e,n){var c=f.lookupPath(e,{follow:!n}).node;return f.checkOpExists(c.node_ops.getattr,63)(c)},fstat(e){var n=f.getStreamChecked(e),c=n.node,o=n.stream_ops.getattr,r=o?n:c;return o??=c.node_ops.getattr,f.checkOpExists(o,63),o(r)},lstat(e){return f.stat(e,!0)},doChmod(e,n,c,o){f.doSetAttr(e,n,{mode:c&4095|n.mode&-4096,ctime:Date.now(),dontFollow:o})},chmod(e,n,c){var o;typeof e=="string"?o=f.lookupPath(e,{follow:!c}).node:o=e,f.doChmod(null,o,n,c)},lchmod(e,n){f.chmod(e,n,!0)},fchmod(e,n){var c=f.getStreamChecked(e);f.doChmod(c,c.node,n,!1)},doChown(e,n,c){f.doSetAttr(e,n,{timestamp:Date.now(),dontFollow:c})},chown(e,n,c,o){var r;typeof e=="string"?r=f.lookupPath(e,{follow:!o}).node:r=e,f.doChown(null,r,o)},lchown(e,n,c){f.chown(e,n,c,!0)},fchown(e,n,c){var o=f.getStreamChecked(e);f.doChown(o,o.node,!1)},doTruncate(e,n,c){if(f.isDir(n.mode))throw new f.ErrnoError(31);if(!f.isFile(n.mode))throw new f.ErrnoError(28);var o=f.nodePermissions(n,"w");if(o)throw new f.ErrnoError(o);f.doSetAttr(e,n,{size:c,timestamp:Date.now()})},truncate(e,n){if(n<0)throw new f.ErrnoError(28);var c;typeof e=="string"?c=f.lookupPath(e,{follow:!0}).node:c=e,f.doTruncate(null,c,n)},ftruncate(e,n){var c=f.getStreamChecked(e);if(n<0||(c.flags&2097155)===0)throw new f.ErrnoError(28);f.doTruncate(c,c.node,n)},utime(e,n,c){var o=f.lookupPath(e,{follow:!0}).node;f.checkOpExists(o.node_ops.setattr,63)(o,{atime:n,mtime:c})},open(e,n,c=438){if(e==="")throw new f.ErrnoError(44);n=ws(n),n&64?c=c&4095|32768:c=0;var o,r;if(typeof e=="object")o=e;else{r=e.endsWith("/");var s=f.lookupPath(e,{follow:!(n&131072),noent_okay:!0});o=s.node,e=s.path}var a=!1;if(n&64)if(o){if(n&128)throw new f.ErrnoError(20)}else{if(r)throw new f.ErrnoError(31);o=f.mknod(e,c|511,0),a=!0}if(!o)throw new f.ErrnoError(44);if(f.isChrdev(o.mode)&&(n&=-513),n&65536&&!f.isDir(o.mode))throw new f.ErrnoError(54);if(!a){var m=f.mayOpen(o,n);if(m)throw new f.ErrnoError(m)}n&512&&!a&&f.truncate(o,0),n&=-131713;var d=f.createStream({node:o,path:f.getPath(o),flags:n,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),a&&f.chmod(o,c&511),d},close(e){if(f.isClosed(e))throw new f.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(n){throw n}finally{f.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,n,c){if(f.isClosed(e))throw new f.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new f.ErrnoError(70);if(c!=0&&c!=1&&c!=2)throw new f.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,c),e.ungotten=[],e.position},read(e,n,c,o,r){if(o<0||r<0)throw new f.ErrnoError(28);if(f.isClosed(e))throw new f.ErrnoError(8);if((e.flags&2097155)===1)throw new f.ErrnoError(8);if(f.isDir(e.node.mode))throw new f.ErrnoError(31);if(!e.stream_ops.read)throw new f.ErrnoError(28);var s=typeof r<"u";if(!s)r=e.position;else if(!e.seekable)throw new f.ErrnoError(70);var a=e.stream_ops.read(e,n,c,o,r);return s||(e.position+=a),a},write(e,n,c,o,r,s){if(o<0||r<0)throw new f.ErrnoError(28);if(f.isClosed(e))throw new f.ErrnoError(8);if((e.flags&2097155)===0)throw new f.ErrnoError(8);if(f.isDir(e.node.mode))throw new f.ErrnoError(31);if(!e.stream_ops.write)throw new f.ErrnoError(28);e.seekable&&e.flags&1024&&f.llseek(e,0,2);var a=typeof r<"u";if(!a)r=e.position;else if(!e.seekable)throw new f.ErrnoError(70);var m=e.stream_ops.write(e,n,c,o,r,s);return a||(e.position+=m),m},mmap(e,n,c,o,r){if((o&2)!==0&&(r&2)===0&&(e.flags&2097155)!==2)throw new f.ErrnoError(2);if((e.flags&2097155)===1)throw new f.ErrnoError(2);if(!e.stream_ops.mmap)throw new f.ErrnoError(43);if(!n)throw new f.ErrnoError(28);return e.stream_ops.mmap(e,n,c,o,r)},msync(e,n,c,o,r){return e.stream_ops.msync?e.stream_ops.msync(e,n,c,o,r):0},ioctl(e,n,c){if(!e.stream_ops.ioctl)throw new f.ErrnoError(59);return e.stream_ops.ioctl(e,n,c)},readFile(e,n={}){n.flags=n.flags||0,n.encoding=n.encoding||"binary",n.encoding!=="utf8"&&n.encoding!=="binary"&&Ne(`Invalid encoding type "${n.encoding}"`);var c=f.open(e,n.flags),o=f.stat(e).size,r=new Uint8Array(o);return f.read(c,r,0,o,0),n.encoding==="utf8"&&(r=Xt(r)),f.close(c),r},writeFile(e,n,c={}){c.flags=c.flags||577;var o=f.open(e,c.flags,c.mode);n=qr(n),f.write(o,n,0,n.byteLength,void 0,c.canOwn),f.close(o)},cwd:()=>f.currentPath,chdir(e){var n=f.lookupPath(e,{follow:!0});if(n.node===null)throw new f.ErrnoError(44);if(!f.isDir(n.node.mode))throw new f.ErrnoError(54);var c=f.nodePermissions(n.node,"x");if(c)throw new f.ErrnoError(c);f.currentPath=n.path},createDefaultDirectories(){f.mkdir("/tmp"),f.mkdir("/home"),f.mkdir("/home/web_user")},createDefaultDevices(){f.mkdir("/dev"),f.registerDevice(f.makedev(1,3),{read:()=>0,write:(o,r,s,a,m)=>a,llseek:()=>0}),f.mkdev("/dev/null",f.makedev(1,3)),qt.register(f.makedev(5,0),qt.default_tty_ops),qt.register(f.makedev(6,0),qt.default_tty1_ops),f.mkdev("/dev/tty",f.makedev(5,0)),f.mkdev("/dev/tty1",f.makedev(6,0));var e=new Uint8Array(1024),n=0,c=()=>(n===0&&(yr(e),n=e.byteLength),e[--n]);f.createDevice("/dev","random",c),f.createDevice("/dev","urandom",c),f.mkdir("/dev/shm"),f.mkdir("/dev/shm/tmp")},createSpecialDirectories(){f.mkdir("/proc");var e=f.mkdir("/proc/self");f.mkdir("/proc/self/fd"),f.mount({mount(){var n=f.createNode(e,"fd",16895,73);return n.stream_ops={llseek:Re.stream_ops.llseek},n.node_ops={lookup(c,o){var r=+o,s=f.getStreamChecked(r),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>s.path},id:r+1};return a.parent=a,a},readdir(){return Array.from(f.streams.entries()).filter(([c,o])=>o).map(([c,o])=>c.toString())}},n}},{},"/proc/self/fd")},createStandardStreams(e,n,c){e?f.createDevice("/dev","stdin",e):f.symlink("/dev/tty","/dev/stdin"),n?f.createDevice("/dev","stdout",null,n):f.symlink("/dev/tty","/dev/stdout"),c?f.createDevice("/dev","stderr",null,c):f.symlink("/dev/tty1","/dev/stderr"),f.open("/dev/stdin",0),f.open("/dev/stdout",1),f.open("/dev/stderr",1)},staticInit(){f.nameTable=new Array(4096),f.mount(Re,{},"/"),f.createDefaultDirectories(),f.createDefaultDevices(),f.createSpecialDirectories(),f.filesystems={MEMFS:Re}},init(e,n,c){f.initialized=!0,e??=t.stdin,n??=t.stdout,c??=t.stderr,f.createStandardStreams(e,n,c)},quit(){f.initialized=!1;for(var e of f.streams)e&&f.close(e)},findObject(e,n){var c=f.analyzePath(e,n);return c.exists?c.object:null},analyzePath(e,n){try{var c=f.lookupPath(e,{follow:!n});e=c.path}catch{}var o={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var c=f.lookupPath(e,{parent:!0});o.parentExists=!0,o.parentPath=c.path,o.parentObject=c.node,o.name=Ve.basename(e),c=f.lookupPath(e,{follow:!n}),o.exists=!0,o.path=c.path,o.object=c.node,o.name=c.node.name,o.isRoot=c.path==="/"}catch(r){o.error=r.errno}return o},createPath(e,n,c,o){e=typeof e=="string"?e:f.getPath(e);for(var r=n.split("/").reverse();r.length;){var s=r.pop();if(s){var a=Ve.join2(e,s);try{f.mkdir(a)}catch(m){if(m.errno!=20)throw m}e=a}}return a},createFile(e,n,c,o,r){var s=Ve.join2(typeof e=="string"?e:f.getPath(e),n),a=jn(o,r);return f.create(s,a)},createDataFile(e,n,c,o,r,s){var a=n;e&&(e=typeof e=="string"?e:f.getPath(e),a=n?Ve.join2(e,n):e);var m=jn(o,r),d=f.create(a,m);if(c){c=qr(c),f.chmod(d,m|146);var q=f.open(d,577);f.write(q,c,0,c.length,0,s),f.close(q),f.chmod(d,m)}},createDevice(e,n,c,o){var r=Ve.join2(typeof e=="string"?e:f.getPath(e),n),s=jn(!!c,!!o);f.createDevice.major??=64;var a=f.makedev(f.createDevice.major++,0);return f.registerDevice(a,{open(m){m.seekable=!1},close(m){o?.buffer?.length&&o(10)},read(m,d,q,V,N){for(var x=0,R=0;R<V;R++){var $;try{$=c()}catch{throw new f.ErrnoError(29)}if($===void 0&&x===0)throw new f.ErrnoError(6);if($==null)break;x++,d[q+R]=$}return x&&(m.node.atime=Date.now()),x},write(m,d,q,V,N){for(var x=0;x<V;x++)try{o(d[q+x])}catch{throw new f.ErrnoError(29)}return V&&(m.node.mtime=m.node.ctime=Date.now()),x}}),f.mkdev(r,s,a)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Ne("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=ue(e.url)}catch{throw new f.ErrnoError(29)}},createLazyFile(e,n,c,o,r){class s{lengthKnown=!1;chunks=[];get(N){if(!(N>this.length-1||N<0)){var x=N%this.chunkSize,R=N/this.chunkSize|0;return this.getter(R)[x]}}setDataGetter(N){this.getter=N}cacheLength(){var N=new XMLHttpRequest;N.open("HEAD",c,!1),N.send(null),N.status>=200&&N.status<300||N.status===304||Ne("Couldn't load "+c+". Status: "+N.status);var x=Number(N.getResponseHeader("Content-length")),R,$=(R=N.getResponseHeader("Accept-Ranges"))&&R==="bytes",B=(R=N.getResponseHeader("Content-Encoding"))&&R==="gzip",J=1048576;$||(J=x);var E=(W,ee)=>{W>ee&&Ne("invalid range ("+W+", "+ee+") or no bytes requested!"),ee>x-1&&Ne("only "+x+" bytes available! programmer error!");var O=new XMLHttpRequest;return O.open("GET",c,!1),x!==J&&O.setRequestHeader("Range","bytes="+W+"-"+ee),O.responseType="arraybuffer",O.overrideMimeType&&O.overrideMimeType("text/plain; charset=x-user-defined"),O.send(null),O.status>=200&&O.status<300||O.status===304||Ne("Couldn't load "+c+". Status: "+O.status),O.response!==void 0?new Uint8Array(O.response||[]):Ln(O.responseText||"",!0)},w=this;w.setDataGetter(W=>{var ee=W*J,O=(W+1)*J-1;return O=Math.min(O,x-1),typeof w.chunks[W]>"u"&&(w.chunks[W]=E(ee,O)),typeof w.chunks[W]>"u"&&Ne("doXHR failed!"),w.chunks[W]}),(B||!x)&&(J=x=1,x=this.getter(0).length,J=x,Y("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=x,this._chunkSize=J,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){g||Ne("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var a={isDevice:!1,contents:new s}}else var a={isDevice:!1,url:c};var m=f.createFile(e,n,a,o,r);a.contents?m.contents=a.contents:a.url&&(m.contents=null,m.url=a.url),Object.defineProperties(m,{usedBytes:{get:function(){return this.contents.length}}});var d={};for(let[V,N]of Object.entries(m.stream_ops))d[V]=(...x)=>(f.forceLoadFile(m),N(...x));function q(V,N,x,R,$){var B=V.node.contents;if($>=B.length)return 0;var J=Math.min(B.length-$,R);if(B.slice)for(var E=0;E<J;E++)N[x+E]=B[$+E];else for(var E=0;E<J;E++)N[x+E]=B.get($+E);return J}return d.read=(V,N,x,R,$)=>(f.forceLoadFile(m),q(V,N,x,R,$)),d.mmap=(V,N,x,R,$)=>{f.forceLoadFile(m);var B=Er(N);if(!B)throw new f.ErrnoError(48);return q(V,ot,B,N,x),{ptr:B,allocated:!0}},m.stream_ops=d,m}},ks=(e,n,c)=>{if(!e)return"";var o=wr(Rt,e,n,c);return br.decode(Rt.subarray(e,o))},De={calculateAt(e,n,c){if(Ve.isAbs(n))return n;var o;if(e===-100?o=f.cwd():o=De.getStreamFromFD(e).path,n.length==0){if(!c)throw new f.ErrnoError(44);return o}return o+"/"+n},writeStat(e,n){We[e>>2]=n.dev,We[e+4>>2]=n.mode,We[e+8>>2]=n.nlink,We[e+12>>2]=n.uid,We[e+16>>2]=n.gid,We[e+20>>2]=n.rdev,Xe[e+24>>3]=BigInt(n.size),je[e+32>>2]=4096,je[e+36>>2]=n.blocks;var c=n.atime.getTime(),o=n.mtime.getTime(),r=n.ctime.getTime();return Xe[e+40>>3]=BigInt(Math.floor(c/1e3)),We[e+48>>2]=c%1e3*1e3*1e3,Xe[e+56>>3]=BigInt(Math.floor(o/1e3)),We[e+64>>2]=o%1e3*1e3*1e3,Xe[e+72>>3]=BigInt(Math.floor(r/1e3)),We[e+80>>2]=r%1e3*1e3*1e3,Xe[e+88>>3]=BigInt(n.ino),0},writeStatFs(e,n){We[e+4>>2]=n.bsize,We[e+60>>2]=n.bsize,Xe[e+8>>3]=BigInt(n.blocks),Xe[e+16>>3]=BigInt(n.bfree),Xe[e+24>>3]=BigInt(n.bavail),Xe[e+32>>3]=BigInt(n.files),Xe[e+40>>3]=BigInt(n.ffree),We[e+48>>2]=n.fsid,We[e+64>>2]=n.flags,We[e+56>>2]=n.namelen},doMsync(e,n,c,o,r){if(!f.isFile(n.node.mode))throw new f.ErrnoError(43);if(o&2)return 0;var s=Rt.slice(e,e+c);f.msync(n,s,r,c,o)},getStreamFromFD(e){return f.getStreamChecked(e)},varargs:void 0,getStr(e){return ks(e)}};function Is(e,n){try{return e=De.getStr(e),f.chmod(e,n),0}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Rs(e,n,c,o){try{if(n=De.getStr(n),n=De.calculateAt(e,n),c&-8)return-28;var r=f.lookupPath(n,{follow:!0}).node;if(!r)return-44;var s="";return c&4&&(s+="r"),c&2&&(s+="w"),c&1&&(s+="x"),s&&f.nodePermissions(r,s)?-2:0}catch(a){if(typeof f>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Os(e,n){try{return f.fchmod(e,n),0}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Ps(e,n,c){try{return f.fchown(e,n,c),0}catch(o){if(typeof f>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var dn=()=>{var e=je[+De.varargs>>2];return De.varargs+=4,e},$t=dn;function Cs(e,n,c){De.varargs=c;try{var o=De.getStreamFromFD(e);switch(n){case 0:var r=dn();if(r<0)return-28;for(;f.streams[r];)r++;return f.dupStream(o,r).fd;case 1:case 2:return 0;case 3:return o.flags;case 4:var r=dn();return o.flags|=r,0;case 12:var r=$t(),s=0;return Le[r+s>>1]=2,0;case 13:case 14:return 0}return-28}catch(a){if(typeof f>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Ds(e,n){try{return De.writeStat(n,f.fstat(e))}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}var Ns=9007199254740992,Ms=-9007199254740992,Ut=e=>e<Ms||e>Ns?NaN:Number(e);function Fs(e,n){n=Ut(n);try{return isNaN(n)?-61:(f.ftruncate(e,n),0)}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}var Pt=(e,n,c)=>Sr(e,Rt,n,c);function Ls(e,n){try{if(n===0)return-28;var c=f.cwd(),o=fn(c)+1;return n<o?-68:(Pt(c,e,n),o)}catch(r){if(typeof f>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function js(e,n,c){De.varargs=c;try{var o=De.getStreamFromFD(e);switch(n){case 21509:return o.tty?0:-59;case 21505:if(!o.tty)return-59;if(o.tty.ops.ioctl_tcgets){var r=o.tty.ops.ioctl_tcgets(o),N=$t();je[N>>2]=r.c_iflag||0,je[N+4>>2]=r.c_oflag||0,je[N+8>>2]=r.c_cflag||0,je[N+12>>2]=r.c_lflag||0;for(var s=0;s<32;s++)ot[N+s+17]=r.c_cc[s]||0;return 0}return 0;case 21510:case 21511:case 21512:return o.tty?0:-59;case 21506:case 21507:case 21508:if(!o.tty)return-59;if(o.tty.ops.ioctl_tcsets){for(var N=$t(),a=je[N>>2],m=je[N+4>>2],d=je[N+8>>2],q=je[N+12>>2],V=[],s=0;s<32;s++)V.push(ot[N+s+17]);return o.tty.ops.ioctl_tcsets(o.tty,n,{c_iflag:a,c_oflag:m,c_cflag:d,c_lflag:q,c_cc:V})}return 0;case 21519:if(!o.tty)return-59;var N=$t();return je[N>>2]=0,0;case 21520:return o.tty?-28:-59;case 21537:case 21531:var N=$t();return f.ioctl(o,n,N);case 21523:if(!o.tty)return-59;if(o.tty.ops.ioctl_tiocgwinsz){var x=o.tty.ops.ioctl_tiocgwinsz(o.tty),N=$t();Le[N>>1]=x[0],Le[N+2>>1]=x[1]}return 0;case 21524:return o.tty?0:-59;case 21515:return o.tty?0:-59;default:return-28}}catch(R){if(typeof f>"u"||R.name!=="ErrnoError")throw R;return-R.errno}}function $s(e,n){try{return e=De.getStr(e),De.writeStat(n,f.lstat(e))}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Us(e,n,c){try{return n=De.getStr(n),n=De.calculateAt(e,n),f.mkdir(n,c,0),0}catch(o){if(typeof f>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Bs(e,n,c,o){try{n=De.getStr(n);var r=o&256,s=o&4096;return o=o&-6401,n=De.calculateAt(e,n,s),De.writeStat(c,r?f.lstat(n):f.stat(n))}catch(a){if(typeof f>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function zs(e,n,c,o){De.varargs=o;try{n=De.getStr(n),n=De.calculateAt(e,n);var r=o?dn():0;return f.open(n,c,r).fd}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function Qs(e,n,c,o){try{if(n=De.getStr(n),n=De.calculateAt(e,n),o<=0)return-28;var r=f.readlink(n),s=Math.min(o,fn(r)),a=ot[c+s];return Pt(r,c,o+1),ot[c+s]=a,s}catch(m){if(typeof f>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}function Vs(e){try{return e=De.getStr(e),f.rmdir(e),0}catch(n){if(typeof f>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Ws(e,n){try{return e=De.getStr(e),De.writeStat(n,f.stat(e))}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Hs(e,n,c){try{if(n=De.getStr(n),n=De.calculateAt(e,n),!c)f.unlink(n);else if(c===512)f.rmdir(n);else return-28;return 0}catch(o){if(typeof f>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var xr=e=>We[e>>2]+je[e+4>>2]*4294967296;function Gs(e,n,c,o){try{n=De.getStr(n),n=De.calculateAt(e,n,!0);var r=Date.now(),s,a;if(!c)s=r,a=r;else{var m=xr(c),d=je[c+8>>2];d==1073741823?s=r:d==1073741822?s=null:s=m*1e3+d/1e6,c+=16,m=xr(c),d=je[c+8>>2],d==1073741823?a=r:d==1073741822?a=null:a=m*1e3+d/1e6}return(a??s)!==null&&f.utime(n,s,a),0}catch(q){if(typeof f>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}var Js=e=>e%4===0&&(e%100!==0||e%400===0),Ks=[0,31,60,91,121,152,182,213,244,274,305,335],Ys=[0,31,59,90,120,151,181,212,243,273,304,334],Xs=e=>(Js(e.getFullYear())?Ks:Ys)[e.getMonth()]+e.getDate()-1;function Zs(e,n){e=Ut(e);var c=new Date(e*1e3);je[n>>2]=c.getSeconds(),je[n+4>>2]=c.getMinutes(),je[n+8>>2]=c.getHours(),je[n+12>>2]=c.getDate(),je[n+16>>2]=c.getMonth(),je[n+20>>2]=c.getFullYear()-1900,je[n+24>>2]=c.getDay();var o=Xs(c)|0;je[n+28>>2]=o,je[n+36>>2]=-(c.getTimezoneOffset()*60);var r=new Date(c.getFullYear(),0,1),s=new Date(c.getFullYear(),6,1).getTimezoneOffset(),a=r.getTimezoneOffset(),m=(s!=a&&c.getTimezoneOffset()==Math.min(a,s))|0;je[n+32>>2]=m}function eo(e,n,c,o,r,s,a){r=Ut(r);try{var m=De.getStreamFromFD(o),d=f.mmap(m,e,r,n,c),q=d.ptr;return je[s>>2]=d.allocated,We[a>>2]=q,0}catch(V){if(typeof f>"u"||V.name!=="ErrnoError")throw V;return-V.errno}}function to(e,n,c,o,r,s){s=Ut(s);try{var a=De.getStreamFromFD(r);c&2&&De.doMsync(e,a,n,o,s)}catch(m){if(typeof f>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}var no=(e,n,c,o)=>{var r=new Date().getFullYear(),s=new Date(r,0,1),a=new Date(r,6,1),m=s.getTimezoneOffset(),d=a.getTimezoneOffset(),q=Math.max(m,d);We[e>>2]=q*60,je[n>>2]=+(m!=d);var V=R=>{var $=R>=0?"-":"+",B=Math.abs(R);return`UTC${$}${String(Math.floor(B/60)).padStart(2,"0")}${String(B%60).padStart(2,"0")}`},N=V(m),x=V(d);d<m?(Pt(N,c,17),Pt(x,o,17)):(Pt(N,o,17),Pt(x,c,17))},kr=()=>performance.now(),Ir=()=>Date.now(),ro=1,io=e=>e>=0&&e<=3;function so(e,n,c){if(n=Ut(n),!io(e))return 28;var o;if(e===0)o=Ir();else if(ro)o=kr();else return 52;var r=Math.round(o*1e3*1e3);return Xe[c>>3]=BigInt(r),0}var Rr=()=>2147483648,oo=()=>Rr(),ao=e=>{var n=(e-yt.buffer.byteLength+65535)/65536|0;try{return yt.grow(n),ye(),1}catch{}},lo=e=>{var n=Rt.length;e>>>=0;var c=Rr();if(e>c)return!1;for(var o=1;o<=4;o*=2){var r=n*(1+.2/o);if(r=Math.min(r,e+100663296),ao(Math.min(c,vr(Math.max(e,r),65536))))return!0}return!1},$n={},co=()=>T||"./this.program",en=()=>{if(!en.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:co()};for(var n in $n)$n[n]===void 0?delete e[n]:e[n]=$n[n];var c=[];for(var n in e)c.push(`${n}=${e[n]}`);en.strings=c}return en.strings},uo=(e,n)=>{var c=0,o=0;for(var r of en()){var s=n+c;We[e+o>>2]=s,c+=Pt(r,s,1/0)+1,o+=4}return 0},fo=(e,n)=>{var c=en();We[e>>2]=c.length;var o=0;for(var r of c)o+=fn(r)+1;return We[n>>2]=o,0};function mo(e){try{var n=De.getStreamFromFD(e);return f.close(n),0}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return c.errno}}function po(e,n){try{var c=0,o=0,r=0,s=De.getStreamFromFD(e),a=s.tty?2:f.isDir(s.mode)?3:f.isLink(s.mode)?7:4;return ot[n]=a,Le[n+2>>1]=r,Xe[n+8>>3]=BigInt(c),Xe[n+16>>3]=BigInt(o),0}catch(m){if(typeof f>"u"||m.name!=="ErrnoError")throw m;return m.errno}}var _o=(e,n,c,o)=>{for(var r=0,s=0;s<c;s++){var a=We[n>>2],m=We[n+4>>2];n+=8;var d=f.read(e,ot,a,m,o);if(d<0)return-1;if(r+=d,d<m)break;typeof o<"u"&&(o+=d)}return r};function go(e,n,c,o){try{var r=_o(De.getStreamFromFD(e),n,c);return We[o>>2]=r,0}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function ho(e,n,c,o){n=Ut(n);try{if(isNaN(n))return 61;var r=De.getStreamFromFD(e);return f.llseek(r,n,c),Xe[o>>3]=BigInt(r.position),r.getdents&&n===0&&c===0&&(r.getdents=null),0}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function yo(e){try{var n=De.getStreamFromFD(e);return n.stream_ops?.fsync?.(n)}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return c.errno}}var bo=(e,n,c,o)=>{for(var r=0,s=0;s<c;s++){var a=We[n>>2],m=We[n+4>>2];n+=8;var d=f.write(e,ot,a,m,o);if(d<0)return-1;if(r+=d,d<m)break;typeof o<"u"&&(o+=d)}return r};function wo(e,n,c,o){try{var r=bo(De.getStreamFromFD(e),n,c);return We[o>>2]=r,0}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return s.errno}}if(f.createPreloadedFile=xs,f.preloadFile=Ar,f.staticInit(),Ae(),t.noExitRuntime&&t.noExitRuntime,t.preloadPlugins&&(Tr=t.preloadPlugins),t.print&&(Y=t.print),t.printErr&&(ne=t.printErr),t.wasmBinary&&(_e=t.wasmBinary),t.arguments&&t.arguments,t.thisProgram&&(T=t.thisProgram),t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.shift()();t.wasmMemory=yt;var Or;function So(e){t._sqlite3_status64=e.sqlite3_status64,t._sqlite3_status=e.sqlite3_status,t._sqlite3_db_status64=e.sqlite3_db_status64,t._sqlite3_msize=e.sqlite3_msize,t._sqlite3_db_status=e.sqlite3_db_status,t._sqlite3_vfs_find=e.sqlite3_vfs_find,t._sqlite3_initialize=e.sqlite3_initialize,t._sqlite3_malloc=e.sqlite3_malloc,t._sqlite3_free=e.sqlite3_free,t._sqlite3_vfs_register=e.sqlite3_vfs_register,t._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,t._sqlite3_malloc64=e.sqlite3_malloc64,t._sqlite3_realloc=e.sqlite3_realloc,t._sqlite3_realloc64=e.sqlite3_realloc64,t._sqlite3_value_text=e.sqlite3_value_text,t._sqlite3_randomness=e.sqlite3_randomness,t._sqlite3_stricmp=e.sqlite3_stricmp,t._sqlite3_strnicmp=e.sqlite3_strnicmp,t._sqlite3_uri_parameter=e.sqlite3_uri_parameter,t._sqlite3_uri_boolean=e.sqlite3_uri_boolean,t._sqlite3_serialize=e.sqlite3_serialize,t._sqlite3_prepare_v2=e.sqlite3_prepare_v2,t._sqlite3_step=e.sqlite3_step,t._sqlite3_column_int64=e.sqlite3_column_int64,t._sqlite3_reset=e.sqlite3_reset,t._sqlite3_exec=e.sqlite3_exec,t._sqlite3_column_int=e.sqlite3_column_int,t._sqlite3_finalize=e.sqlite3_finalize,t._sqlite3_file_control=e.sqlite3_file_control,t._sqlite3_column_name=e.sqlite3_column_name,t._sqlite3_column_text=e.sqlite3_column_text,t._sqlite3_column_type=e.sqlite3_column_type,t._sqlite3_errmsg=e.sqlite3_errmsg,t._sqlite3_deserialize=e.sqlite3_deserialize,t._sqlite3_clear_bindings=e.sqlite3_clear_bindings,t._sqlite3_value_blob=e.sqlite3_value_blob,t._sqlite3_value_bytes=e.sqlite3_value_bytes,t._sqlite3_value_double=e.sqlite3_value_double,t._sqlite3_value_int=e.sqlite3_value_int,t._sqlite3_value_int64=e.sqlite3_value_int64,t._sqlite3_value_subtype=e.sqlite3_value_subtype,t._sqlite3_value_pointer=e.sqlite3_value_pointer,t._sqlite3_value_type=e.sqlite3_value_type,t._sqlite3_value_nochange=e.sqlite3_value_nochange,t._sqlite3_value_frombind=e.sqlite3_value_frombind,t._sqlite3_value_dup=e.sqlite3_value_dup,t._sqlite3_value_free=e.sqlite3_value_free,t._sqlite3_result_blob=e.sqlite3_result_blob,t._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,t._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,t._sqlite3_result_double=e.sqlite3_result_double,t._sqlite3_result_error=e.sqlite3_result_error,t._sqlite3_result_int=e.sqlite3_result_int,t._sqlite3_result_int64=e.sqlite3_result_int64,t._sqlite3_result_null=e.sqlite3_result_null,t._sqlite3_result_pointer=e.sqlite3_result_pointer,t._sqlite3_result_subtype=e.sqlite3_result_subtype,t._sqlite3_result_text=e.sqlite3_result_text,t._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,t._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,t._sqlite3_result_error_code=e.sqlite3_result_error_code,t._sqlite3_user_data=e.sqlite3_user_data,t._sqlite3_context_db_handle=e.sqlite3_context_db_handle,t._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,t._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,t._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,t._sqlite3_aggregate_context=e.sqlite3_aggregate_context,t._sqlite3_get_auxdata=e.sqlite3_get_auxdata,t._sqlite3_set_auxdata=e.sqlite3_set_auxdata,t._sqlite3_column_count=e.sqlite3_column_count,t._sqlite3_data_count=e.sqlite3_data_count,t._sqlite3_column_blob=e.sqlite3_column_blob,t._sqlite3_column_bytes=e.sqlite3_column_bytes,t._sqlite3_column_double=e.sqlite3_column_double,t._sqlite3_column_value=e.sqlite3_column_value,t._sqlite3_column_decltype=e.sqlite3_column_decltype,t._sqlite3_column_database_name=e.sqlite3_column_database_name,t._sqlite3_column_table_name=e.sqlite3_column_table_name,t._sqlite3_column_origin_name=e.sqlite3_column_origin_name,t._sqlite3_bind_blob=e.sqlite3_bind_blob,t._sqlite3_bind_double=e.sqlite3_bind_double,t._sqlite3_bind_int=e.sqlite3_bind_int,t._sqlite3_bind_int64=e.sqlite3_bind_int64,t._sqlite3_bind_null=e.sqlite3_bind_null,t._sqlite3_bind_pointer=e.sqlite3_bind_pointer,t._sqlite3_bind_text=e.sqlite3_bind_text,t._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,t._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,t._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,t._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,t._sqlite3_db_handle=e.sqlite3_db_handle,t._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,t._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,t._sqlite3_stmt_explain=e.sqlite3_stmt_explain,t._sqlite3_stmt_busy=e.sqlite3_stmt_busy,t._sqlite3_next_stmt=e.sqlite3_next_stmt,t._sqlite3_stmt_status=e.sqlite3_stmt_status,t._sqlite3_sql=e.sqlite3_sql,t._sqlite3_expanded_sql=e.sqlite3_expanded_sql,t._sqlite3_preupdate_old=e.sqlite3_preupdate_old,t._sqlite3_preupdate_count=e.sqlite3_preupdate_count,t._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,t._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,t._sqlite3_preupdate_new=e.sqlite3_preupdate_new,t._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,t._sqlite3_set_authorizer=e.sqlite3_set_authorizer,t._sqlite3_strglob=e.sqlite3_strglob,t._sqlite3_strlike=e.sqlite3_strlike,t._sqlite3_auto_extension=e.sqlite3_auto_extension,t._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,t._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,t._sqlite3_prepare_v3=e.sqlite3_prepare_v3,t._sqlite3_create_module=e.sqlite3_create_module,t._sqlite3_create_module_v2=e.sqlite3_create_module_v2,t._sqlite3_drop_modules=e.sqlite3_drop_modules,t._sqlite3_declare_vtab=e.sqlite3_declare_vtab,t._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,t._sqlite3_vtab_collation=e.sqlite3_vtab_collation,t._sqlite3_vtab_in=e.sqlite3_vtab_in,t._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,t._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,t._sqlite3_keyword_name=e.sqlite3_keyword_name,t._sqlite3_keyword_count=e.sqlite3_keyword_count,t._sqlite3_keyword_check=e.sqlite3_keyword_check,t._sqlite3_complete=e.sqlite3_complete,t._sqlite3_libversion=e.sqlite3_libversion,t._sqlite3_libversion_number=e.sqlite3_libversion_number,t._sqlite3_shutdown=e.sqlite3_shutdown,t._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,t._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,t._sqlite3_changes64=e.sqlite3_changes64,t._sqlite3_changes=e.sqlite3_changes,t._sqlite3_total_changes64=e.sqlite3_total_changes64,t._sqlite3_total_changes=e.sqlite3_total_changes,t._sqlite3_txn_state=e.sqlite3_txn_state,t._sqlite3_close_v2=e.sqlite3_close_v2,t._sqlite3_busy_handler=e.sqlite3_busy_handler,t._sqlite3_progress_handler=e.sqlite3_progress_handler,t._sqlite3_busy_timeout=e.sqlite3_busy_timeout,t._sqlite3_interrupt=e.sqlite3_interrupt,t._sqlite3_is_interrupted=e.sqlite3_is_interrupted,t._sqlite3_create_function=e.sqlite3_create_function,t._sqlite3_create_function_v2=e.sqlite3_create_function_v2,t._sqlite3_create_window_function=e.sqlite3_create_window_function,t._sqlite3_overload_function=e.sqlite3_overload_function,t._sqlite3_trace_v2=e.sqlite3_trace_v2,t._sqlite3_commit_hook=e.sqlite3_commit_hook,t._sqlite3_update_hook=e.sqlite3_update_hook,t._sqlite3_rollback_hook=e.sqlite3_rollback_hook,t._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,t._sqlite3_set_errmsg=e.sqlite3_set_errmsg,t._sqlite3_error_offset=e.sqlite3_error_offset,t._sqlite3_errcode=e.sqlite3_errcode,t._sqlite3_extended_errcode=e.sqlite3_extended_errcode,t._sqlite3_errstr=e.sqlite3_errstr,t._sqlite3_limit=e.sqlite3_limit,t._sqlite3_open=e.sqlite3_open,t._sqlite3_open_v2=e.sqlite3_open_v2,t._sqlite3_create_collation=e.sqlite3_create_collation,t._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,t._sqlite3_collation_needed=e.sqlite3_collation_needed,t._sqlite3_get_autocommit=e.sqlite3_get_autocommit,t._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,t._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,t._sqlite3_uri_key=e.sqlite3_uri_key,t._sqlite3_uri_int64=e.sqlite3_uri_int64,t._sqlite3_db_name=e.sqlite3_db_name,t._sqlite3_db_filename=e.sqlite3_db_filename,t._sqlite3_db_readonly=e.sqlite3_db_readonly,t._sqlite3_compileoption_used=e.sqlite3_compileoption_used,t._sqlite3_compileoption_get=e.sqlite3_compileoption_get,t._sqlite3session_diff=e.sqlite3session_diff,t._sqlite3session_attach=e.sqlite3session_attach,t._sqlite3session_create=e.sqlite3session_create,t._sqlite3session_delete=e.sqlite3session_delete,t._sqlite3session_table_filter=e.sqlite3session_table_filter,t._sqlite3session_changeset=e.sqlite3session_changeset,t._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,t._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,t._sqlite3session_patchset=e.sqlite3session_patchset,t._sqlite3session_enable=e.sqlite3session_enable,t._sqlite3session_indirect=e.sqlite3session_indirect,t._sqlite3session_isempty=e.sqlite3session_isempty,t._sqlite3session_memory_used=e.sqlite3session_memory_used,t._sqlite3session_object_config=e.sqlite3session_object_config,t._sqlite3session_changeset_size=e.sqlite3session_changeset_size,t._sqlite3changeset_start=e.sqlite3changeset_start,t._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,t._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,t._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,t._sqlite3changeset_next=e.sqlite3changeset_next,t._sqlite3changeset_op=e.sqlite3changeset_op,t._sqlite3changeset_pk=e.sqlite3changeset_pk,t._sqlite3changeset_old=e.sqlite3changeset_old,t._sqlite3changeset_new=e.sqlite3changeset_new,t._sqlite3changeset_conflict=e.sqlite3changeset_conflict,t._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,t._sqlite3changeset_finalize=e.sqlite3changeset_finalize,t._sqlite3changeset_invert=e.sqlite3changeset_invert,t._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,t._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,t._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,t._sqlite3changeset_apply=e.sqlite3changeset_apply,t._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,t._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,t._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,t._sqlite3changegroup_new=e.sqlite3changegroup_new,t._sqlite3changegroup_add=e.sqlite3changegroup_add,t._sqlite3changegroup_output=e.sqlite3changegroup_output,t._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,t._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,t._sqlite3changegroup_delete=e.sqlite3changegroup_delete,t._sqlite3changeset_concat=e.sqlite3changeset_concat,t._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,t._sqlite3session_config=e.sqlite3session_config,t._sqlite3_sourceid=e.sqlite3_sourceid,t._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,t._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,t._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,t._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,t._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,t._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,t._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,t._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,t._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,t._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,t._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,t._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,t._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,t._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,t._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,t._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,t._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,t._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,t._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,t._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,t._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,t._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,t._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,t._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,t._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,t._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,t._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,t._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,t._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,t._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,t._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,t._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,t._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,t._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,t._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,t._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,t._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,t._malloc=e.malloc,t._free=e.free,t._realloc=e.realloc,Or=e.emscripten_builtin_memalign,e._emscripten_stack_restore,e._emscripten_stack_alloc,e.emscripten_stack_get_current,e.__indirect_function_table}var Pr={__syscall_chmod:Is,__syscall_faccessat:Rs,__syscall_fchmod:Os,__syscall_fchown32:Ps,__syscall_fcntl64:Cs,__syscall_fstat64:Ds,__syscall_ftruncate64:Fs,__syscall_getcwd:Ls,__syscall_ioctl:js,__syscall_lstat64:$s,__syscall_mkdirat:Us,__syscall_newfstatat:Bs,__syscall_openat:zs,__syscall_readlinkat:Qs,__syscall_rmdir:Vs,__syscall_stat64:Ws,__syscall_unlinkat:Hs,__syscall_utimensat:Gs,_localtime_js:Zs,_mmap_js:eo,_munmap_js:to,_tzset_js:no,clock_time_get:so,emscripten_date_now:Ir,emscripten_get_heap_max:oo,emscripten_get_now:kr,emscripten_resize_heap:lo,environ_get:uo,environ_sizes_get:fo,fd_close:mo,fd_fdstat_get:po,fd_read:go,fd_seek:ho,fd_sync:yo,fd_write:wo,memory:yt};function Un(){if(Ot>0){Zt=Un;return}if(ge(),Ot>0){Zt=Un;return}function e(){t.calledRun=!0,!Te&&(Pe(),Ce?.(t),t.onRuntimeInitialized?.(),Fe())}t.setStatus?(t.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>t.setStatus(""),1),e()},1)):e()}var Bt=await Dn();return Un(),t.runSQLite3PostLoadInit=async function(e,n,c){"use strict";delete n.runSQLite3PostLoadInit;globalThis.sqlite3ApiBootstrap=async function o(r=globalThis.sqlite3ApiConfig||o.defaultConfig){if(o.sqlite3)return(o.sqlite3.config||console).warn("sqlite3ApiBootstrap() called multiple times.","Config and external initializers are ignored on calls after the first."),o.sqlite3;let s=(...h)=>Object.assign(Object.create(null),...h),a=s({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},r);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(h=>{typeof a[h]=="function"&&(a[h]=a[h]())});let m=s(),d=s(),q=h=>m.sqlite3_js_rc_str&&m.sqlite3_js_rc_str(h)||"Unknown result code #"+h,V=h=>typeof h=="number"&&h===(h|0)&&h<=2147483647&&h>=-2147483648;class N extends Error{constructor(...A){let U;if(A.length)if(V(A[0]))if(U=A[0],A.length===1)super(q(A[0]));else{let X=q(U);typeof A[1]=="object"?super(X,A[1]):(A[0]=X+":",super(A.join(" ")))}else A.length===2&&typeof A[1]=="object"?super(...A):super(A.join(" "));this.resultCode=U||m.SQLITE_ERROR,this.name="SQLite3Error"}}N.toss=(...h)=>{throw new N(...h)};let x=N.toss;a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir)&&x("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");let R=function h(A){return h._max||(h._max=BigInt("0x7fffffffffffffff"),h._min=~h._max),A>=h._min&&A<=h._max},$=h=>h>=-2147483647n-1n&&h<=2147483647n,B=function h(A){return h._min||(h._min=Number.MIN_SAFE_INTEGER,h._max=Number.MAX_SAFE_INTEGER),A>=h._min&&A<=h._max},J=h=>h&&h.constructor&&V(h.constructor.BYTES_PER_ELEMENT)?h:!1,E=h=>h&&(h instanceof Uint8Array||h instanceof Int8Array||h instanceof ArrayBuffer),w=h=>h&&(h instanceof Uint8Array||h instanceof Int8Array||h instanceof ArrayBuffer),W=h=>E(h)||x("Value is not of a supported TypedArray type."),ee=function(h){return w(h)?d.typedArrayToString(h instanceof ArrayBuffer?new Uint8Array(h):h,0,h.length):Array.isArray(h)?h.join(""):(d.isPtr(h)&&(h=d.cstrToJs(h)),h)};class O extends Error{constructor(...A){A.length===2&&typeof A[1]=="object"?super(...A):A.length?super(A.join(" ")):super("Allocation failed."),this.resultCode=m.SQLITE_NOMEM,this.name="WasmAllocError"}}O.toss=(...h)=>{throw new O(...h)},Object.assign(m,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(h,A,U,X,L,fe,de,me,S)=>{},sqlite3_create_function:(h,A,U,X,L,fe,de,me)=>{},sqlite3_create_window_function:(h,A,U,X,L,fe,de,me,S,C)=>{},sqlite3_prepare_v3:(h,A,U,X,L,fe)=>{},sqlite3_prepare_v2:(h,A,U,X,L)=>{},sqlite3_exec:(h,A,U,X,L)=>{},sqlite3_randomness:(h,A)=>{}});let z={affirmBindableTypedArray:W,flexibleString:ee,bigIntFits32:$,bigIntFits64:R,bigIntFitsDouble:B,isBindableTypedArray:E,isInt32:V,isSQLableTypedArray:w,isTypedArray:J,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...h){throw new Error(h.join(" "))},toss3:x,typedArrayPart:d.typedArrayPart,nu:s,assert:function(h,A){h||z.toss("Assertion failed:",A)},affirmDbHeader:function(h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));let A="SQLite format 3";15>h.byteLength&&x("Input does not contain an SQLite3 database header.");for(let U=0;U<15;++U)A.charCodeAt(U)!==h[U]&&x("Input does not contain an SQLite3 database header.")},affirmIsDb:function(h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));let A=h.byteLength;(A<512||A%512!==0)&&x("Byte array size",A,"is invalid for an SQLite3 db."),z.affirmDbHeader(h)}};Object.assign(d,{exports:a.exports||x("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||x("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}),d.allocFromTypedArray=function(h){h instanceof ArrayBuffer&&(h=new Uint8Array(h)),W(h);let A=d.alloc(h.byteLength||1);return d.heapForSize(h.constructor).set(h.byteLength?h:[0],Number(A)),A};{let h=a.allocExportName,A=a.deallocExportName,U=a.reallocExportName;for(let X of[h,A,U])d.exports[X]instanceof Function||x("Missing required exports[",X,"] function.");d.alloc=function X(L){return X.impl(L)||O.toss("Failed to allocate",L," bytes.")},d.alloc.impl=d.exports[h],d.realloc=function X(L,fe){let de=X.impl(d.ptr.coerce(L),fe);return fe?de||O.toss("Failed to reallocate",fe," bytes."):d.ptr.null},d.realloc.impl=d.exports[U],d.dealloc=function X(L){X.impl(d.ptr.coerce(L))},d.dealloc.impl=d.exports[A]}d.compileOptionUsed=function h(A){if(arguments.length){if(Array.isArray(A)){let U=s();return A.forEach(X=>{U[X]=m.sqlite3_compileoption_used(X)}),U}else if(typeof A=="object")return Object.keys(A).forEach(U=>{A[U]=m.sqlite3_compileoption_used(U)}),A}else{if(h._result)return h._result;h._opt||(h._rx=/^([^=]+)=(.+)/,h._rxInt=/^-?\d+$/,h._opt=function(de,me){let S=h._rx.exec(de);me[0]=S?S[1]:de,me[1]=S?h._rxInt.test(S[2])?+S[2]:S[2]:!0});let U=s(),X=[0,0],L=0,fe;for(;fe=m.sqlite3_compileoption_get(L++);)h._opt(fe,X),U[X[0]]=X[1];return h._result=U}return typeof A=="string"?!!m.sqlite3_compileoption_used(A):!1},d.pstack=s({restore:d.exports.sqlite3__wasm_pstack_restore,alloc:function(h){return typeof h=="string"&&!(h=d.sizeofIR(h))&&O.toss("Invalid value for pstack.alloc(",arguments[0],")"),d.exports.sqlite3__wasm_pstack_alloc(h)||O.toss("Could not allocate",h,"bytes from the pstack.")},allocChunks:function(h,A){typeof A=="string"&&!(A=d.sizeofIR(A))&&O.toss("Invalid size value for allocChunks(",arguments[1],")");let U=d.pstack.alloc(h*A),X=[U],L=1,fe=A;for(;L<h;++L,fe+=A)X.push(d.ptr.add(U,fe));return X},allocPtr:(h=1,A=!0)=>h===1?d.pstack.alloc(A?8:d.ptr.size):d.pstack.allocChunks(h,A?8:d.ptr.size),call:function(h){let A=d.pstack.pointer;try{return h(le)}finally{d.pstack.restore(A)}}}),Object.defineProperties(d.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3__wasm_pstack_remaining}}),m.sqlite3_randomness=(...h)=>{if(h.length===1&&z.isTypedArray(h[0])&&h[0].BYTES_PER_ELEMENT===1){let A=h[0];if(A.byteLength===0)return d.exports.sqlite3_randomness(0,d.ptr.null),A;let U=d.pstack.pointer;try{let X=A.byteLength,L=0,fe=d.exports.sqlite3_randomness,de=d.heap8u(),me=X<512?X:512,S=d.pstack.alloc(me);do{let C=X>me?me:X;fe(C,S),A.set(d.typedArrayPart(de,S,d.ptr.add(S,C)),L),X-=C,L+=C}while(X>0)}catch(X){a.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",X)}finally{d.pstack.restore(U)}return A}d.exports.sqlite3_randomness(...h)},m.sqlite3_wasmfs_opfs_dir=function(){if(this.dir!==void 0)return this.dir;let h=a.wasmfsOpfsDir;if(!h||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!d.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{return h&&d.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],h)===0?this.dir=h:this.dir=""}catch{return this.dir=""}}.bind(s()),m.sqlite3_wasmfs_filename_is_persistent=function(h){let A=m.sqlite3_wasmfs_opfs_dir();return A&&h?h.startsWith(A+"/"):!1},m.sqlite3_js_db_uses_vfs=function(h,A,U=0){try{let X=m.sqlite3_vfs_find(A);return X?h?X===m.sqlite3_js_db_vfs(h,U)?X:!1:X===m.sqlite3_vfs_find(0)?X:!1:!1}catch{return!1}},m.sqlite3_js_vfs_list=function(){let h=[],A=m.sqlite3_vfs_find(d.ptr.null);for(;A;){let U=new m.sqlite3_vfs(A);h.push(d.cstrToJs(U.$zName)),A=U.$pNext,U.dispose()}return h},m.sqlite3_js_db_export=function(h,A=0){h=d.xWrap.testConvertArg("sqlite3*",h),h||x("Invalid sqlite3* argument."),d.bigIntEnabled||x("BigInt support is not enabled.");let U=d.scopedAllocPush(),X;try{let L=d.scopedAlloc(8+d.ptr.size),fe=d.ptr.add(L,8),de=A?d.isPtr(A)?A:d.scopedAllocCString(""+A):d.ptr.null,me=d.exports.sqlite3__wasm_db_serialize(h,de,fe,L,0);me&&x("Database serialization failed with code",le.capi.sqlite3_js_rc_str(me)),X=d.peekPtr(fe);let S=d.peek(L,"i64");return me=S?d.heap8u().slice(Number(X),Number(X)+Number(S)):new Uint8Array,me}finally{X&&d.exports.sqlite3_free(X),d.scopedAllocPop(U)}},m.sqlite3_js_db_vfs=(h,A=d.ptr.null)=>z.sqlite3__wasm_db_vfs(h,A),m.sqlite3_js_aggregate_context=(h,A)=>m.sqlite3_aggregate_context(h,A)||(A?O.toss("Cannot allocate",A,"bytes for sqlite3_aggregate_context()"):0),m.sqlite3_js_posix_create_file=function(h,A,U){let X;A&&d.isPtr(A)?X=A:A instanceof ArrayBuffer||A instanceof Uint8Array?(X=d.allocFromTypedArray(A),(arguments.length<3||!z.isInt32(U)||U<0)&&(U=A.byteLength)):N.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{(!z.isInt32(U)||U<0)&&N.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");let L=z.sqlite3__wasm_posix_create_file(h,X,U);L&&N.toss("Creation of file failed with sqlite3 result code",m.sqlite3_js_rc_str(L))}finally{X&&X!==A&&d.dealloc(X)}},m.sqlite3_js_vfs_create_file=function(h,A,U,X){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 L;U?d.isPtr(U)?L=U:(U instanceof ArrayBuffer&&(U=new Uint8Array(U)),U instanceof Uint8Array?(L=d.allocFromTypedArray(U),(arguments.length<4||!z.isInt32(X)||X<0)&&(X=U.byteLength)):N.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):L=0,(!z.isInt32(X)||X<0)&&(L&&L!==U&&d.dealloc(L),N.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{let fe=z.sqlite3__wasm_vfs_create_file(h,A,L,X);fe&&N.toss("Creation of file failed with sqlite3 result code",m.sqlite3_js_rc_str(fe))}finally{L&&L!==U&&d.dealloc(L)}},m.sqlite3_js_sql_to_string=h=>{if(typeof h=="string")return h;let A=ee(v);return A===v?void 0:A},m.sqlite3_db_config=function(h,A,...U){switch(A){case m.SQLITE_DBCONFIG_ENABLE_FKEY:case m.SQLITE_DBCONFIG_ENABLE_TRIGGER:case m.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case m.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case m.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case m.SQLITE_DBCONFIG_ENABLE_QPSG:case m.SQLITE_DBCONFIG_TRIGGER_EQP:case m.SQLITE_DBCONFIG_RESET_DATABASE:case m.SQLITE_DBCONFIG_DEFENSIVE:case m.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case m.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case m.SQLITE_DBCONFIG_DQS_DML:case m.SQLITE_DBCONFIG_DQS_DDL:case m.SQLITE_DBCONFIG_ENABLE_VIEW:case m.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case m.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case m.SQLITE_DBCONFIG_STMT_SCANSTATUS:case m.SQLITE_DBCONFIG_REVERSE_SCANORDER:case m.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE:case m.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE:case m.SQLITE_DBCONFIG_ENABLE_COMMENTS:case m.SQLITE_DBCONFIG_FP_DIGITS:return this.ip||(this.ip=d.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"])),this.ip(h,A,U[0],U[1]||0);case m.SQLITE_DBCONFIG_LOOKASIDE:return this.pii||(this.pii=d.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"])),this.pii(h,A,U[0],U[1],U[2]);case m.SQLITE_DBCONFIG_MAINDBNAME:return this.s||(this.s=d.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"])),this.s(h,A,U[0]);default:return m.SQLITE_MISUSE}}.bind(s()),m.sqlite3_value_to_js=function(h,A=!0){let U,X=m.sqlite3_value_type(h);switch(X){case m.SQLITE_INTEGER:d.bigIntEnabled?(U=m.sqlite3_value_int64(h),z.bigIntFitsDouble(U)&&(U=Number(U))):U=m.sqlite3_value_double(h);break;case m.SQLITE_FLOAT:U=m.sqlite3_value_double(h);break;case m.SQLITE_TEXT:U=m.sqlite3_value_text(h);break;case m.SQLITE_BLOB:{let L=m.sqlite3_value_bytes(h),fe=m.sqlite3_value_blob(h);L&&!fe&&le.WasmAllocError.toss("Cannot allocate memory for blob argument of",L,"byte(s)"),U=L?d.heap8u().slice(Number(fe),Number(fe)+Number(L)):null;break}case m.SQLITE_NULL:U=null;break;default:A&&x(m.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",X),U=void 0}return U},m.sqlite3_values_to_js=function(h,A,U=!0){let X,L=[];for(X=0;X<h;++X)L.push(m.sqlite3_value_to_js(d.peekPtr(d.ptr.add(A,d.ptr.size*X)),U));return L},m.sqlite3_result_error_js=function(h,A){A instanceof O?m.sqlite3_result_error_nomem(h):m.sqlite3_result_error(h,""+A,-1)},m.sqlite3_result_js=function(h,A){if(A instanceof Error){m.sqlite3_result_error_js(h,A);return}try{switch(typeof A){case"undefined":break;case"boolean":m.sqlite3_result_int(h,A?1:0);break;case"bigint":z.bigIntFits32(A)?m.sqlite3_result_int(h,Number(A)):z.bigIntFitsDouble(A)?m.sqlite3_result_double(h,Number(A)):d.bigIntEnabled?z.bigIntFits64(A)?m.sqlite3_result_int64(h,A):x("BigInt value",A.toString(),"is too BigInt for int64."):x("BigInt value",A.toString(),"is too BigInt.");break;case"number":{let U;z.isInt32(A)?U=m.sqlite3_result_int:d.bigIntEnabled&&Number.isInteger(A)&&z.bigIntFits64(BigInt(A))?U=m.sqlite3_result_int64:U=m.sqlite3_result_double,U(h,A);break}case"string":{let[U,X]=d.allocCString(A,!0);m.sqlite3_result_text(h,U,X,m.SQLITE_WASM_DEALLOC);break}case"object":if(A===null){m.sqlite3_result_null(h);break}else if(z.isBindableTypedArray(A)){let U=d.allocFromTypedArray(A);m.sqlite3_result_blob(h,U,A.byteLength,m.SQLITE_WASM_DEALLOC);break}default:x("Don't not how to handle this UDF result value:",typeof A,A)}}catch(U){m.sqlite3_result_error_js(h,U)}},m.sqlite3_column_js=function(h,A,U=!0){let X=m.sqlite3_column_value(h,A);return X===0?void 0:m.sqlite3_value_to_js(X,U)};{let h=function(A,U,X){X=m[X],this.ptr?d.pokePtr(this.ptr,0):this.ptr=d.allocPtr();let L=X(A,U,this.ptr);if(L)return N.toss(L,arguments[2]+"() failed with code "+L);let fe=d.peekPtr(this.ptr);return fe?m.sqlite3_value_to_js(fe,!0):void 0}.bind(s());m.sqlite3_preupdate_new_js=(A,U)=>h(A,U,"sqlite3_preupdate_new"),m.sqlite3_preupdate_old_js=(A,U)=>h(A,U,"sqlite3_preupdate_old"),m.sqlite3changeset_new_js=(A,U)=>h(A,U,"sqlite3changeset_new"),m.sqlite3changeset_old_js=(A,U)=>h(A,U,"sqlite3changeset_old")}m.sqlite3_js_retry_busy=function(h,A,U){for(let X=1;X<=h;++X)try{U&&X>1&&U(X);let L=A();if(m.SQLITE_BUSY===L){if(X===h)throw new N(L,["sqlite3_js_retry_busy() max retry attempts (",h,") reached."].join(""));continue}return L}catch(L){if(X<h&&L instanceof N&&L.resultCode===m.SQLITE_BUSY)continue;throw L}};let le={WasmAllocError:O,SQLite3Error:N,capi:m,util:z,wasm:d,config:a,version:s(),client:void 0,asyncPostInit:async function h(){if(h.isReady instanceof Promise)return h.isReady;let A=this.initializersAsync;delete this.initializersAsync;let U=async()=>(le.__isUnderTest||(delete le.util,delete le.StructBinder,delete le.opfs),le),X=fe=>{throw a.error("an async sqlite3 initializer failed:",fe),fe};if(!A||!A.length)return h.isReady=U().catch(X);A=A.map(fe=>fe instanceof Function?async de=>fe(le):fe),A.push(U);let L=Promise.resolve(le);for(;A.length;)L=L.then(A.shift());return h.isReady=L.catch(X)}.bind(o),scriptInfo:void 0};typeof c<"u"&&(le.__isUnderTest=!!c);try{o.initializers.forEach(h=>{h(le)})}catch(h){throw console.error("sqlite3 bootstrap initializer threw:",h),h}if(delete o.initializers,o.sqlite3=le,typeof e<"u"&&(e.debugModule("sqlite3ApiBootstrap() complete",le),le.scriptInfo=e),le.__isUnderTest){typeof n<"u"&&(le.config.emscripten=n);let h=le.scriptInfo?.instantiateWasm;h&&(le.wasm.module=h.module,le.wasm.instance=h.instance,le.wasm.imports=h.imports)}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete o.defaultConfig,le.asyncPostInit().then(h=>(typeof e<"u"&&e.debugModule("sqlite3.asyncPostInit() complete",h),delete h.asyncPostInit,delete h.scriptInfo,delete h.emscripten,h))},globalThis.sqlite3ApiBootstrap.initializers=[],globalThis.sqlite3ApiBootstrap.initializersAsync=[],globalThis.sqlite3ApiBootstrap.defaultConfig=Object.create(null),globalThis.sqlite3ApiBootstrap.sqlite3=void 0,globalThis.sqlite3ApiBootstrap.initializers.push(function(o){o.version={libVersion:"3.53.4",libVersionNumber:3053004,sourceId:"2026-07-24 19:02:57 bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc",downloadVersion:3530400,scm:{"sha3-256":"bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc",branch:"branch-3.53",tags:"release version-3.53.4",datetime:"2026-07-24T19:02:57.525Z"}}}),globalThis.WhWasmUtilInstaller=function(r){"use strict";r.bigIntEnabled===void 0&&(r.bigIntEnabled=!!globalThis.BigInt64Array);let s=(...u)=>{throw new Error(u.join(" "))};if(!r.pointerSize&&!r.pointerIR&&r.alloc&&r.dealloc){let u=r.alloc(1);r.pointerSize=typeof u=="bigint"?8:4,r.dealloc(u)}r.pointerSize&&!r.pointerIR&&(r.pointerIR=r.pointerSize===4?"i32":"i64");let a=r.pointerIR??="i32",m=r.pointerSize??=a==="i32"?4:a==="i64"?8:0;delete r.pointerSize,delete r.pointerIR,a!=="i32"&&a!=="i64"?s("Invalid pointerIR:",a):m!==8&&m!==4&&s("Invalid pointerSize:",m);let d=r.bigIntEnabled?u=>BigInt(u||0):u=>s("BigInt support is disabled in this build."),V=m===4?u=>Number(u||0):d,N=V(0),x=function(...u){let _=V(0);for(let y of u)_+=V(y);return _};{let u=Object.create(null);Object.defineProperty(r,"ptr",{enumerable:!0,get:()=>u,set:()=>s("The ptr property is read-only.")}),(function _(y,Q){return Object.defineProperty(u,y,{enumerable:!0,get:()=>Q,set:()=>s("ptr["+y+"] is read-only.")}),_})("null",N)("size",m)("ir",a)("coerce",V)("add",x)("addn",a===4?x:(..._)=>Number(x(..._)))}r.exports||Object.defineProperty(r,"exports",{enumerable:!0,configurable:!0,get:()=>r.instance?.exports});let R=Object.create(null);R.heapSize=0,R.memory=null,R.freeFuncIndexes=[],R.scopedAlloc=[],R.scopedAlloc.pushPtr=u=>(R.scopedAlloc[R.scopedAlloc.length-1].push(u),u),R.utf8Decoder=new TextDecoder,R.utf8Encoder=new TextEncoder("utf-8"),r.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 m;default:return(""+u).endsWith("*")?m:void 0}};let $=function(){if(!R.memory)R.memory=r.memory instanceof WebAssembly.Memory?r.memory:r.exports.memory;else if(R.heapSize===R.memory.buffer.byteLength)return R;let u=R.memory.buffer;return R.HEAP8=new Int8Array(u),R.HEAP8U=new Uint8Array(u),R.HEAP16=new Int16Array(u),R.HEAP16U=new Uint16Array(u),R.HEAP32=new Int32Array(u),R.HEAP32U=new Uint32Array(u),R.HEAP32F=new Float32Array(u),R.HEAP64F=new Float64Array(u),r.bigIntEnabled&&(typeof BigInt64Array<"u"?(R.HEAP64=new BigInt64Array(u),R.HEAP64U=new BigUint64Array(u)):s("BigInt support is enabled, but the BigInt64Array type is missing.")),R.heapSize=u.byteLength,R};r.heap8=()=>$().HEAP8,r.heap8u=()=>$().HEAP8U,r.heap16=()=>$().HEAP16,r.heap16u=()=>$().HEAP16U,r.heap32=()=>$().HEAP32,r.heap32u=()=>$().HEAP32U,r.heapForSize=function(u,_=!0){let y=R.memory&&R.heapSize===R.memory.buffer.byteLength?R:$();switch(u){case Int8Array:return y.HEAP8;case Uint8Array:return y.HEAP8U;case Int16Array:return y.HEAP16;case Uint16Array:return y.HEAP16U;case Int32Array:return y.HEAP32;case Uint32Array:return y.HEAP32U;case 8:return _?y.HEAP8U:y.HEAP8;case 16:return _?y.HEAP16U:y.HEAP16;case 32:return _?y.HEAP32U:y.HEAP32;case 64:if(y.HEAP64)return _?y.HEAP64U:y.HEAP64;break;default:if(r.bigIntEnabled){if(u===globalThis.BigUint64Array)return y.HEAP64U;if(u===globalThis.BigInt64Array)return y.HEAP64;break}}s("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};let B=r.functionTable;delete r.functionTable,r.functionTable=B?()=>B:()=>r.exports.__indirect_function_table,r.functionEntry=function(u){let _=r.functionTable();return u<_.length?_.get(V(u)):void 0},r.jsFuncToWasm=function u(_,y){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,D,te)=>{te<128?b[D](te):b[D](te%128|128,te>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:b=>{let D=u._.rxJSig.exec(b);return D?D[2]:b.substr(1)},letterType:b=>u._.sigTypes[b]||s("Invalid signature letter:",b),pushSigType:(b,D)=>b.push(u._.typeCodes[u._.letterType(D)])}),typeof _=="string"){let b=y;y=_,_=b}let Q=u._,K=Q.sigParams(y),M=[1,96];Q.uleb128Encode(M,"push",K.length);for(let b of K)Q.pushSigType(M,b);return y[0]==="v"?M.push(0):(M.push(1),Q.pushSigType(M,y[0])),Q.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:_}}).exports.f};let J=function(_,y,Q){if(Q&&!R.scopedAlloc.length&&s("No scopedAllocPush() scope is active."),typeof _=="string"){let D=y;y=_,_=D}(typeof y!="string"||!(_ instanceof Function))&&s("Invalid arguments: expecting (function,signature) or (signature,function).");let K=r.functionTable(),M=V(K.length),b;for(;(b=R.freeFuncIndexes.pop())&&K.get(b);){b=null;continue}b||(b=V(M),K.grow(V(1)));try{return K.set(b,_),Q&&R.scopedAlloc.pushPtr(b),b}catch(D){if(!(D instanceof TypeError))throw b===M&&R.freeFuncIndexes.push(M),D}try{let D=r.jsFuncToWasm(_,y);K.set(b,D),Q&&R.scopedAlloc.pushPtr(b)}catch(D){throw b===M&&R.freeFuncIndexes.push(M),D}return b};r.installFunction=(u,_)=>J(u,_,!1),r.scopedInstallFunction=(u,_)=>J(u,_,!0),r.uninstallFunction=function(u){if(!u&&N!==u)return;let _=r.functionTable();R.freeFuncIndexes.push(u);let y=_.get(u);return _.set(u,null),y},r.peek=function(_,y="i8"){y.endsWith("*")&&(y=a);let Q=R.memory&&R.heapSize===R.memory.buffer.byteLength?R:$(),K=Array.isArray(_)?[]:void 0,M;do{switch(K&&(_=arguments[0].shift()),y){case"i1":case"i8":M=Q.HEAP8[Number(_)>>0];break;case"i16":M=Q.HEAP16[Number(_)>>1];break;case"i32":M=Q.HEAP32[Number(_)>>2];break;case"float":case"f32":M=Q.HEAP32F[Number(_)>>2];break;case"double":case"f64":M=Number(Q.HEAP64F[Number(_)>>3]);break;case"i64":if(Q.HEAP64){M=d(Q.HEAP64[Number(_)>>3]);break}default:s("Invalid type for peek():",y)}K&&K.push(M)}while(K&&arguments[0].length);return K||M},r.poke=function(u,_,y="i8"){y.endsWith("*")&&(y=a);let Q=R.memory&&R.heapSize===R.memory.buffer.byteLength?R:$();for(let K of Array.isArray(u)?u:[u])switch(y){case"i1":case"i8":Q.HEAP8[Number(K)>>0]=_;continue;case"i16":Q.HEAP16[Number(K)>>1]=_;continue;case"i32":Q.HEAP32[Number(K)>>2]=_;continue;case"float":case"f32":Q.HEAP32F[Number(K)>>2]=_;continue;case"double":case"f64":Q.HEAP64F[Number(K)>>3]=_;continue;case"i64":if(Q.HEAP64){Q.HEAP64[Number(K)>>3]=d(_);continue}default:s("Invalid type for poke(): "+y)}return this},r.peekPtr=(...u)=>r.peek(u.length===1?u[0]:u,a),r.pokePtr=(u,_=0)=>r.poke(u,_,a),r.peek8=(...u)=>r.peek(u.length===1?u[0]:u,"i8"),r.poke8=(u,_)=>r.poke(u,_,"i8"),r.peek16=(...u)=>r.peek(u.length===1?u[0]:u,"i16"),r.poke16=(u,_)=>r.poke(u,_,"i16"),r.peek32=(...u)=>r.peek(u.length===1?u[0]:u,"i32"),r.poke32=(u,_)=>r.poke(u,_,"i32"),r.peek64=(...u)=>r.peek(u.length===1?u[0]:u,"i64"),r.poke64=(u,_)=>r.poke(u,_,"i64"),r.peek32f=(...u)=>r.peek(u.length===1?u[0]:u,"f32"),r.poke32f=(u,_)=>r.poke(u,_,"f32"),r.peek64f=(...u)=>r.peek(u.length===1?u[0]:u,"f64"),r.poke64f=(u,_)=>r.poke(u,_,"f64"),r.getMemValue=r.peek,r.getPtrValue=r.peekPtr,r.setMemValue=r.poke,r.setPtrValue=r.pokePtr,r.isPtr32=u=>typeof u=="number"&&u>=0&&u===(u|0),r.isPtr64=u=>typeof u=="bigint"?u>=0:r.isPtr32(u),r.isPtr=m===4?r.isPtr32:r.isPtr64,r.cstrlen=function(u){if(!u||!r.isPtr(u))return null;u=Number(u);let _=$().HEAP8U,y=u;for(;_[y]!==0;++y);return y-u};let E=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,w=u=>u.buffer instanceof E;r.isSharedTypedArray=w;let W=(u,_,y)=>(m===8&&(typeof _=="bigint"&&(_=Number(_)),typeof y=="bigint"&&(y=Number(y))),w(u)?u.slice(_,y):u.subarray(_,y));r.typedArrayPart=W;let ee=(u,_,y)=>R.utf8Decoder.decode(W(u,_,y));r.typedArrayToString=ee,r.cstrToJs=function(u){let _=r.cstrlen(u);return _?ee($().HEAP8U,Number(u),Number(u)+_):_===null?_:""},r.jstrlen=function(u){if(typeof u!="string")return null;let _=u.length,y=0;for(let Q=0;Q<_;++Q){let K=u.charCodeAt(Q);K>=55296&&K<=57343&&(K=65536+((K&1023)<<10)|u.charCodeAt(++Q)&1023),K<=127?++y:K<=2047?y+=2:K<=65535?y+=3:y+=4}return y},r.jstrcpy=function(u,_,y=0,Q=-1,K=!0){if((!_||!(_ instanceof Int8Array)&&!(_ instanceof Uint8Array))&&s("jstrcpy() target must be an Int8Array or Uint8Array."),Q=Number(Q),y=Number(y),Q<0&&(Q=_.length-y),!(Q>0)||!(y>=0))return 0;let M=0,b=u.length,D=y,te=y+Q-(K?1:0);for(;M<b&&y<te;++M){let Z=u.charCodeAt(M);if(Z>=55296&&Z<=57343&&(Z=65536+((Z&1023)<<10)|u.charCodeAt(++M)&1023),Z<=127){if(y>=te)break;_[y++]=Z}else if(Z<=2047){if(y+1>=te)break;_[y++]=192|Z>>6,_[y++]=128|Z&63}else if(Z<=65535){if(y+2>=te)break;_[y++]=224|Z>>12,_[y++]=128|Z>>6&63,_[y++]=128|Z&63}else{if(y+3>=te)break;_[y++]=240|Z>>18,_[y++]=128|Z>>12&63,_[y++]=128|Z>>6&63,_[y++]=128|Z&63}}return K&&(_[y++]=0),y-D},r.cstrncpy=function(u,_,y){if((!u||!_)&&s("cstrncpy() does not accept NULL strings."),y<0)y=r.cstrlen(strPtr)+1;else if(!(y>0))return 0;let Q=r.heap8u(),K=0,M,b=Number(u),D=Number(_);for(;K<y&&(M=Q[D+K]);++K)Q[b+K]=M;return K<y&&(Q[b+K++]=0),K},r.jstrToUintArray=(u,_=!1)=>R.utf8Encoder.encode(_?u+"\0":u);let O=(u,_)=>{(!(u.alloc instanceof Function)||!(u.dealloc instanceof Function))&&s("Object is missing alloc() and/or dealloc() function(s)","required by",_+"().")},z=function(u,_,y,Q){if(O(r,Q),typeof u!="string")return null;let K=R.utf8Encoder.encode(u),M=y(K.length+1),b=M;try{let D=$().HEAP8U;return D.set(K,Number(M)),D[x(M,K.length)]=0,b=N,_?[M,K.length]:M}finally{b&&r.dealloc(b)}};r.allocCString=(u,_=!1)=>z(u,_,r.alloc,"allocCString()"),r.scopedAllocPush=function(){O(r,"scopedAllocPush");let u=[];return R.scopedAlloc.push(u),u},r.scopedAllocPop=function(u){O(r,"scopedAllocPop");let _=arguments.length?R.scopedAlloc.indexOf(u):R.scopedAlloc.length-1;_<0&&s("Invalid state object for scopedAllocPop()."),arguments.length===0&&(u=R.scopedAlloc[_]),R.scopedAlloc.splice(_,1);for(let y;y=u.pop();)r.functionEntry(y)?r.uninstallFunction(y):r.dealloc(y)},r.scopedAlloc=function(u){R.scopedAlloc.length||s("No scopedAllocPush() scope is active.");let _=V(r.alloc(u));return R.scopedAlloc.pushPtr(_)},Object.defineProperty(r.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>R.scopedAlloc.length,set:()=>s("The 'active' property is read-only.")}),r.scopedAllocCString=(u,_=!1)=>z(u,_,r.scopedAlloc,"scopedAllocCString()");let le=function(u,_){let y=r[u?"scopedAlloc":"alloc"]((_.length+1)*r.ptr.size),Q=0;return _.forEach(K=>{r.pokePtr(x(y,r.ptr.size*Q++),r[u?"scopedAllocCString":"allocCString"](""+K))}),r.pokePtr(x(y,r.ptr.size*Q),0),y};r.scopedAllocMainArgv=u=>le(!0,u),r.allocMainArgv=u=>le(!1,u),r.cArgvToJs=(u,_)=>{let y=[];for(let Q=0;Q<u;++Q){let K=r.peekPtr(x(_,r.ptr.size*Q));y.push(K?r.cstrToJs(K):null)}return y},r.scopedAllocCall=function(u){r.scopedAllocPush();try{return u()}finally{r.scopedAllocPop()}};let h=function(u,_,y){O(r,y);let Q=_?"i64":a,K=r[y](u*(_?8:m));if(r.poke(K,0,Q),u===1)return K;let M=[K];for(let b=1;b<u;++b)K=x(K,_?8:m),M[b]=K,r.poke(K,0,Q);return M};r.allocPtr=(u=1,_=!0)=>h(u,_,"alloc"),r.scopedAllocPtr=(u=1,_=!0)=>h(u,_,"scopedAlloc"),r.xGet=function(u){return r.exports[u]||s("Cannot find exported symbol:",u)};let A=(u,_)=>s(u+"() requires",_,"argument(s).");r.xCall=function(u,..._){let y=u instanceof Function?u:r.xGet(u);return y instanceof Function||s("Exported symbol",u,"is not a function."),y.length!==_.length&&A(y===u?y.name:u,y.length),arguments.length===2&&Array.isArray(arguments[1])?y.apply(null,arguments[1]):y.apply(null,_)},R.xWrap=Object.create(null),R.xWrap.convert=Object.create(null),R.xWrap.convert.arg=new Map,R.xWrap.convert.result=new Map;let U=R.xWrap.convert.arg,X=R.xWrap.convert.result,L=V;U.set("i64",d).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",U.get("f32")).set("f64",U.get("f32")).set("double",U.get("f64")).set("int",U.get("i32")).set("null",u=>u).set(null,U.get("null")).set("**",L).set("*",L),X.set("*",L).set("pointer",L).set("number",u=>Number(u)).set("void",u=>{}).set(void 0,X.get("void")).set("null",u=>u).set(null,X.get("null"));for(let u of["i8","i16","i32","i64","int","f32","float","f64","double"])U.set(u+"*",L),X.set(u+"*",L),X.set(u,U.get(u)||s("Maintenance required: missing arg converter for",u));let fe=u=>typeof u=="string"?r.scopedAllocCString(u):V(u);U.set("string",fe).set("utf8",fe),X.set("string",u=>r.cstrToJs(u)).set("utf8",X.get("string")).set("string:dealloc",u=>{try{return u?r.cstrToJs(u):null}finally{r.dealloc(u)}}).set("utf8:dealloc",X.get("string:dealloc")).set("json",u=>JSON.parse(r.cstrToJs(u))).set("json:dealloc",u=>{try{return u?JSON.parse(r.cstrToJs(u)):null}finally{r.dealloc(u)}});let de=class{constructor(u){this.name=u.name||"unnamed adapter"}convertArg(u,_,y){s("AbstractArgAdapter must be subclassed.")}};U.FuncPtrAdapter=class vt extends de{constructor(_){super(_),U.FuncPtrAdapter.warnOnUse&&console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",_),this.name=_.name||"unnamed",this.signature=_.signature,_.contextKey instanceof Function&&(this.contextKey=_.contextKey,_.bindScope||(_.bindScope="context")),this.bindScope=_.bindScope||s("FuncPtrAdapter options requires a bindScope (explicit or implied)."),vt.bindScopes.indexOf(_.bindScope)<0&&s("Invalid options.bindScope ("+_.bindMod+") for FuncPtrAdapter. Expecting one of: ("+vt.bindScopes.join(", ")+")"),this.isTransient=this.bindScope==="transient",this.isContext=this.bindScope==="context",this.isPermanent=this.bindScope==="permanent",this.singleton=this.bindScope==="singleton"?[]:void 0,this.callProxy=_.callProxy instanceof Function?_.callProxy:void 0}contextKey(_,y){return this}contextMap(_){let y=this.__cmap||(this.__cmap=new Map),Q=y.get(_);return Q===void 0&&y.set(_,Q=[]),Q}convertArg(_,y,Q){let K=this.singleton;if(!K&&this.isContext&&(K=this.contextMap(this.contextKey(y,Q))),K&&K.length===2&&K[0]===_)return K[1];if(_ instanceof Function){this.callProxy&&(_=this.callProxy(_));let M=J(_,this.signature,this.isTransient);if(vt.debugFuncInstall&&vt.debugOut("FuncPtrAdapter installed",this,this.contextKey(y,Q),"@"+M,_),K){if(K[1]){vt.debugFuncInstall&&vt.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(y,Q),"@"+K[1],_);try{R.scopedAlloc.pushPtr(K[1])}catch{}}K[0]=arguments[0]||N,K[1]=M}return M}else if(r.isPtr(_)||_===null||_===void 0){if(K&&K[1]&&K[1]!==_){vt.debugFuncInstall&&vt.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(y,Q),"@"+K[1],_);try{R.scopedAlloc.pushPtr(K[1])}catch{}K[0]=K[1]=_||N}return _||N}else throw new TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},U.FuncPtrAdapter.warnOnUse=!1,U.FuncPtrAdapter.debugFuncInstall=!1,U.FuncPtrAdapter.debugOut=console.debug.bind(console),U.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];let me=u=>U.get(u)||s("Argument adapter not found:",u),S=u=>X.get(u)||s("Result adapter not found:",u);R.xWrap.convertArg=(u,..._)=>me(u)(..._),R.xWrap.convertArgNoCheck=(u,..._)=>U.get(u)(..._),R.xWrap.convertResult=(u,_)=>u===null?_:u?S(u)(_):void 0,R.xWrap.convertResultNoCheck=(u,_)=>u===null?_:u?X.get(u)(_):void 0,r.xWrap=function u(_,y,...Q){arguments.length===3&&Array.isArray(arguments[2])&&(Q=arguments[2]),r.isPtr(_)&&(_=r.functionEntry(_)||s("Function pointer not found in WASM function table."));let K=_ instanceof Function,M=K?_:r.xGet(_);if(K&&(_=M.name||"unnamed function"),Q.length!==M.length&&A(_,M.length),M.length===0&&(y===null||y==="null"))return M;S(y);for(let D of Q)D instanceof de?U.set(D,(...te)=>D.convertArg(...te)):me(D);let b=R.xWrap;return M.length===0?(...D)=>D.length?A(_,M.length):b.convertResult(y,M.call(null)):function(...D){D.length!==M.length&&A(_,M.length);let te=r.scopedAllocPush();try{let Z=0;for(u.debug&&console.debug("xWrap() preparing: resultType ",y,"xf",M,"argTypes",Q,"args",D);Z<D.length;++Z)D[Z]=b.convertArgNoCheck(Q[Z],D[Z],D,Z);return u.debug&&console.debug("xWrap() calling: resultType ",y,"xf",M,"argTypes",Q,"args",D),b.convertResultNoCheck(y,M.apply(null,D))}finally{r.scopedAllocPop(te)}}};let C=function(u,_,y,Q,K,M){if(typeof y=="string"){if(_===1)return M.get(y);if(_===2){if(Q)Q instanceof Function||s(K,"requires a function argument.");else return M.delete(y),u;return M.set(y,Q),u}}s("Invalid arguments to",K)};return r.xWrap.resultAdapter=function u(_,y){return C(u,arguments.length,_,y,"resultAdapter()",X)},r.xWrap.argAdapter=function u(_,y){return C(u,arguments.length,_,y,"argAdapter()",U)},r.xWrap.FuncPtrAdapter=U.FuncPtrAdapter,r.xCallWrapped=function(u,_,y,...Q){return Array.isArray(arguments[3])&&(Q=arguments[3]),r.xWrap(u,_,y||[]).apply(null,Q||[])},r.xWrap.testConvertArg=R.xWrap.convertArg,r.xWrap.testConvertResult=R.xWrap.convertResult,r},globalThis.WhWasmUtilInstaller.yawl=function(r){"use strict";let s=()=>fetch(r.uri,{credentials:"same-origin"}),a=this,m=function(d){if(r.wasmUtilTarget){let q=(...N)=>{throw new Error(N.join(" "))},V=r.wasmUtilTarget;if(V.module=d.module,V.instance=d.instance,V.instance.exports.memory||(V.memory=r?.imports?.env?.memory||q("Missing 'memory' object!")),!V.alloc&&d.instance.exports.malloc){let N=d.instance.exports;V.alloc=function(x){return N.malloc(x)||q("Allocation of",x,"bytes failed.")},V.dealloc=function(x){x&&N.free(x)}}a(V)}return d.config=r,r.onload&&r.onload(d),d};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(s(),r.imports||{}).then(m):()=>s().then(d=>d.arrayBuffer()).then(d=>WebAssembly.instantiate(d,r.imports||{})).then(m)}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function o(r){"use strict";let s=(...P)=>{throw new Error(P.join(" "))};{let P=r.heap;P instanceof WebAssembly.Memory?P=function(){return new Uint8Array(this.buffer)}.bind(P):P instanceof Function||s("config.heap must be WebAssembly.Memory instance or","a function which returns one."),r.heap=P}["alloc","dealloc"].forEach(function(P){r[P]instanceof Function||s("Config option '"+P+"' must be a function.")});let a=o,m=r.heap,d=r.alloc,q=r.dealloc;r.realloc;let V=r.log||console.debug.bind(console),N=r.memberPrefix||"",x=r.memberSuffix||"",R=globalThis.BigInt,$=globalThis.BigInt64Array,B=r.bigIntEnabled??!!$,J,E=r.pointerSize||r.ptrSize||(typeof(J=d(1))=="bigint"?8:4),w=r.pointerIR||r.ptrIR||(E===4?"i32":"i64");J&&(q(J),J=void 0),E!==4&&E!==8&&s("Invalid pointer size:",E),w!=="i32"&&w!=="i64"&&s("Invalid pointer representation:",w);let W=B&&R?P=>R(P||0):P=>s("BigInt support is disabled in this build."),ee=w=="i32"?Number:W,O=ee(0),z=function(...P){let ie=O;for(let ce=0;ce<P.length;++ce)ie+=ee(P[ce]);return ie},le=function(...P){return z(this.pointer,...P)};a.debugFlags||(a.__makeDebugFlags=function(P=null){P&&P.__flags&&(P=P.__flags);let ie=function ce(pe){return arguments.length===0?ce.__flags:(pe<0?(delete ce.__flags.getter,delete ce.__flags.setter,delete ce.__flags.alloc,delete ce.__flags.dealloc):(ce.__flags.getter=(1&pe)!==0,ce.__flags.setter=(2&pe)!==0,ce.__flags.alloc=(4&pe)!==0,ce.__flags.dealloc=(8&pe)!==0),ce._flags)};return Object.defineProperty(ie,"__flags",{iterable:!1,writable:!1,value:Object.create(P)}),P||ie(0),ie},a.debugFlags=a.__makeDebugFlags());let h=!0,A=P=>P[1]==="(",U=P=>P==="p"||P==="P"||P==="s",X=P=>P==="P",L=P=>P?A(P)?"p":P[0]:void 0,fe=function(P){switch(L(P)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return w;case"j":return"i64";case"f":return"float";case"d":return"double"}s("Unhandled signature IR:",P)},de=function(P){switch(L(P)){case"c":case"C":return 1;case"i":return 4;case"p":case"P":case"s":return E;case"j":return 8;case"f":return 4;case"d":return 8}s("Unhandled signature sizeof:",P)},me=$?()=>!0:()=>s("BigInt64Array is not available."),S=function(P){switch(L(P)){case"p":case"P":case"s":switch(E){case 4:return"getInt32";case 8:return me()&&"getBigInt64"}break;case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return me()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}s("Unhandled DataView getter for signature:",P)},C=function(P){switch(L(P)){case"p":case"P":case"s":switch(E){case 4:return"setInt32";case 8:return me()&&"setBigInt64"}break;case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return me()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}s("Unhandled DataView setter for signature:",P)},u=function(P){switch(L(P)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return W;case"p":case"P":case"s":switch(E){case 4:return Number;case 8:return W}}s("Unhandled DataView set wrapper for signature:",P)},_=(P,ie)=>P+"::"+ie,y=function(P,ie){return()=>s(_(P,ie),"is read-only.")},Q=function P(ie,ce=!0){let pe=P.map.get(ie);return!pe&&ce&&P.map.set(ie,pe=P.create(ie)),pe};Q.map=new WeakMap,Q.create=P=>Object.assign(Object.create(null),{o:P,p:void 0,ownsPointer:!1,zod:!1,xb:0});let K=P=>Q.map.delete(P),M=P=>typeof P=="number"&&P===(P|0)&&P>=0,D=E===4?M:P=>typeof P=="bigint"&&P>=0||M(P),te=P=>D(P)&&P>0,Z=function(P,ie,ce){let pe=Q(ie,!1);if(pe){if(K(ie),!ce&&!(ce=pe.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(ie.ondispose)){let xe;for(;xe=ie.ondispose.pop();)try{xe instanceof Function?xe.call(ie):xe instanceof lt?xe.dispose():D(xe)&&q(xe)}catch(Qe){console.warn("ondispose() for",P.structName,"@",ce,"threw. NOT propagating it.",Qe)}}else if(ie.ondispose instanceof Function)try{ie.ondispose()}catch(xe){console.warn("ondispose() for",P.structName,"@",ce,"threw. NOT propagating it.",xe)}delete ie.ondispose,P.debugFlags.__flags.dealloc&&V("debug.dealloc:",pe.ownsPointer?"":"EXTERNAL",P.structName,"instance:",P.structInfo.sizeof,"bytes @"+ce),pe.ownsPointer&&((pe.zod||P.structInfo.zeroOnDispose)&&m().fill(0,Number(ce),Number(ce)+P.structInfo.sizeof+pe.xb),q(ce))}},we=()=>({configurable:!1,writable:!1,iterable:!1}),he=P=>({...we(),value:P}),ke=function(ie,ce,pe){let xe,Qe=ze=>{te(ze)||s("Invalid pointer value",arguments[0],"for",ie.structName,"constructor.")};arguments.length>=3?pe&&typeof pe=="object"?(xe=pe,pe=xe?.wrap):(Qe(pe),xe={wrap:pe}):xe={};let et=!pe,it=0,ct=!1;if(pe)Qe(pe),ct=!!xe?.takeOwnership;else{let ze=xe?.extraBytes??0;(ze<0||ze!==(ze|0))&&s("Invalid extraBytes value:",xe?.extraBytes),it=ie.structInfo.sizeof+ze,pe=d(it)||s("Allocation of",ie.structName,"structure failed."),ct=!0}try{xe?.debugFlags&&ce.debugFlags(xe.debugFlags),ie.debugFlags.__flags.alloc&&V("debug.alloc:",et?"":"EXTERNAL",ie.structName,"instance:",ie.structInfo.sizeof,"bytes @"+pe),et&&m().fill(0,Number(pe),Number(pe)+it);let ze=Q(ce);ze.p=pe,ze.ownsPointer=ct,ze.xb=it?it-ie.structInfo.sizeof:0,ze.zod=!!xe?.zeroOnDispose,xe?.ondispose&&xe.ondispose!==pe&&ce.addOnDispose(xe.ondispose)}catch(ze){throw Z(ie,ce,pe),ze}},Be=function P(ie){return P.rxSig1??=/^[ipPsjfdcC]$/,P.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,P.rxSig1.test(ie)||P.rxSig2.test(ie)},Ze=function(P){let ie=this.get(P);return ie||(ie=[Object.create(null),Object.create(null),Object.create(null)],this.set(P,ie)),ie}.bind(new WeakMap),at=function(P,ie,ce,pe){let xe=Ze(P)[ie];return arguments.length===3?xe[ce]:pe?xe[ce]=pe:delete xe[ce]},Ct=function(P,...ie){return at(this,0,P,...ie)},mn=function(P,ie){Be(ie)&&s(P,"(",ie,") collides with a data type signature.")},F=function(P,...ie){return mn("Setter adaptor",P),at(this,1,P,...ie)},G=function(P,...ie){return mn("Struct adaptor",P),at(this,2,P,...ie)},oe=function(P,ie){let ce=typeof ie=="string"?at(P,2,ie):ie;return typeof ce!="object"&&s("Invalid struct mapping object. Arg =",ie,JSON.stringify(ce)),ce},Se=he(P=>N+P+x),ve=function(P,ie,ce=!0){let pe=P.members[ie];if(!pe&&(N||x)){for(let xe of Object.values(P.members))if(xe.key===ie){pe=xe;break}!pe&&ce&&s(_(P.name||P.structName,ie),"is not a mapped struct member.")}return pe},Ee=function P(ie,ce,pe=!1){P._||(P._=Qe=>Qe.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));let xe=ve(ie.structInfo,ce,!0);return pe?P._(xe.signature):xe.signature},qe=he(function(){let P=[];for(let ie of Object.keys(this.structInfo.members))P.push(this.memberKey(ie));return P}),Me=new TextDecoder("utf-8"),He=new TextEncoder,$e=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Ue=function(P,ie,ce){return E===8&&(ie=Number(ie),ce=Number(ce)),Me.decode(P.buffer instanceof $e?P.slice(ie,ce):P.subarray(ie,ce))},Ke=function(P,ie,ce=!1){let pe=ve(P.structInfo,ie,ce);return pe&&pe.signature.length===1&&pe.signature[0]==="s"?pe:!1},gt=function(P){P.signature!=="s"&&s("Invalid member type signature for C-string value:",JSON.stringify(P))},Tt=function(ie,ce){let pe=ve(ie.structInfo,ce,!0);gt(pe);let xe=ie[pe.key];if(!xe)return null;let Qe=xe,et=m();for(;et[Qe]!==0;++Qe);return xe===Qe?"":Ue(et,xe,Qe)},zt=function(P,...ie){P.ondispose?Array.isArray(P.ondispose)||(P.ondispose=[P.ondispose]):P.ondispose=[],P.ondispose.push(...ie)},Dt=function(P){let ie=He.encode(P),ce=d(ie.length+1);ce||s("Allocation error while duplicating string:",P);let pe=m();return pe.set(ie,Number(ce)),pe[z(ce,ie.length)]=0,ce},tn=function(P,ie,ce){let pe=ve(P.structInfo,ie,!0);gt(pe);let xe=Dt(ce);return P[pe.key]=xe,zt(P,xe),P},lt=function(ie,ce){arguments[2]!==he&&s("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:he(ie),structInfo:he(ce)})};lt.prototype=Object.create(null,{dispose:he(function(){Z(this.constructor,this)}),lookupMember:he(function(P,ie=!0){return ve(this.structInfo,P,ie)}),memberToJsString:he(function(P){return Tt(this,P)}),memberIsString:he(function(P,ie=!0){return Ke(this,P,ie)}),memberKey:Se,memberKeys:qe,memberSignature:he(function(P,ie=!1){return Ee(this,P,ie)}),memoryDump:he(function(){let P=this.pointer;return P?new Uint8Array(m().slice(Number(P),Number(P)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return Q(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return Q(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return Q(this,!1)?.p},set:()=>s("Cannot assign the 'pointer' property of a struct.")},setMemberCString:he(function(P,ie){return tn(this,P,ie)})}),Object.assign(lt.prototype,{addOnDispose:function(...P){return zt(this,...P),this}}),Object.defineProperties(lt,{allocCString:he(Dt),isA:he(P=>P instanceof lt),hasExternalPointer:he(P=>{let ie=Q(P,!1);return!!(ie?.p&&!ie?.ownsPointer)}),memberKey:Se});let pn=function(P){return P.get||(P.adaptGet?dt.adaptGet(P.adaptGet):void 0)},Cr=function(P){return P.set||(P.adaptSet?dt.adaptSet(P.adaptSet):void 0)},vo=function P(ie,ce,pe){let xe=P.innerStructs??=new Map,Qe=ie.memberKey(ce);pe.signature!==void 0&&s("'signature' cannot be used on an embedded struct (",ie.structName,".",Qe,")."),Cr(pe)&&s("'set' and 'adaptSet' are not permitted for nested struct members."),pe.structName??=ie.structName+"::"+ce,pe.key=Qe,pe.name=ce,pe.constructor=this.call(this,pe.structName,pe);let et=pn(pe),it=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:y(ie.structName,Qe),get:function(){let ct=this.debugFlags.__flags,ze=this.pointer,tt=ze+"."+Qe,Ie=xe.get(tt);return ct.getter&&V("debug.getter: k =",tt),Ie||(Ie=new pe.constructor(z(ze,pe.offset)),xe.set(tt,Ie),this.addOnDispose(()=>Ie.dispose()),Ie.addOnDispose(()=>xe.delete(tt))),et&&(Ie=et.apply(this,[Ie,Qe])),ct.getter&&V("debug.getter: result =",Ie),Ie}});Object.defineProperty(ie.prototype,Qe,it)},Eo=function P(ie,ce,pe){if(pe=oe(this,pe),pe.members)return vo.call(this,ie,ce,pe);if(!P.cache){P.cache={getters:{},setters:{},sw:{}};let tt=["i","c","C","p","P","s","f","d","v()"];B&&tt.push("j"),tt.forEach(function(Ie){P.cache.getters[Ie]=S(Ie),P.cache.setters[Ie]=C(Ie),P.cache.sw[Ie]=u(Ie)}),P.sigCheck=function(Ie,Je,_n,Nr){Object.prototype.hasOwnProperty.call(Ie,_n)&&s(Ie.structName,"already has a property named",_n+"."),Be(Nr)||s("Malformed signature for",_(Ie.structName,Je)+":",Nr)}}let xe=ie.memberKey(ce);P.sigCheck(ie.prototype,ce,xe,pe.signature),pe.key=xe,pe.name=ce;let Qe=L(pe.signature),et=_(ie.structName,xe),it=ie.debugFlags.__flags,ct=pn(pe),ze=Object.create(null);if(ze.configurable=!1,ze.enumerable=!1,ze.get=function(){it.getter&&V("debug.getter:",P.cache.getters[Qe],"for",fe(Qe),et,"@",this.pointer,"+",pe.offset,"sz",pe.sizeof);let tt=new DataView(m().buffer,Number(this.pointer)+pe.offset,pe.sizeof)[P.cache.getters[Qe]](0,h);return ct&&(tt=ct.apply(this,[xe,tt])),it.getter&&V("debug.getter:",et,"result =",tt),tt},pe.readOnly)ze.set=y(ie.prototype.structName,xe);else{let tt=Cr(pe);ze.set=function(Ie){it.setter&&V("debug.setter:",P.cache.setters[Qe],"for",fe(Qe),et,"@",this.pointer,"+",pe.offset,"sz",pe.sizeof,Ie),this.pointer||s("Cannot set native property on a disposed",this.structName,"instance."),tt&&(Ie=tt.apply(this,[xe,Ie])),Ie==null?Ie=O:U(pe.signature)&&!D(Ie)&&(X(pe.signature)&&Ie instanceof lt?(Ie=Ie.pointer||O,it.setter&&V("debug.setter:",et,"resolved to",Ie)):s("Invalid value for pointer-type",et+".")),new DataView(m().buffer,Number(this.pointer)+pe.offset,pe.sizeof)[P.cache.setters[Qe]](0,P.cache.sw[Qe](Ie),h)}}Object.defineProperty(ie.prototype,xe,ze)},Dr=function P(ie,ce,pe=Object.create(null)){let xe=function Ie(Je){this instanceof Ie||s("The",ie,"constructor may only be called via 'new'."),ke(Ie,this,...arguments)},Qe=this,et=Ie=>typeof Ie=="string"&&Be(Ie)?{signature:Ie}:oe(Qe,Ie);arguments.length===1?(ce=et(ie),ie=ce.structName||ce.name):arguments.length===2?(ce=et(ce),ce.name??=ie):ce=et(ce),ie??=ce.structName,ie??=pe.structName,ie||s("One of 'name' or 'structName' are required."),ce.adapt&&(Object.keys(ce.adapt.struct||{}).forEach(Ie=>{G.call(P,Ie,ce.adapt.struct[Ie])}),Object.keys(ce.adapt.set||{}).forEach(Ie=>{F.call(P,Ie,ce.adapt.set[Ie])}),Object.keys(ce.adapt.get||{}).forEach(Ie=>{Ct.call(P,Ie,ce.adapt.get[Ie])})),!ce.members&&!ce.sizeof&&(ce.sizeof=de(ce.signature));let it=he(a.__makeDebugFlags(dt.debugFlags));Object.defineProperties(xe,{debugFlags:it,isA:he(Ie=>Ie instanceof xe),memberKey:Se,memberKeys:qe,structInfo:he(ce),structName:he(ie),ptrAdd:he(z)}),xe.prototype=new lt(ie,ce,he),Object.defineProperties(xe.prototype,{debugFlags:it,constructor:he(xe),ptrAdd:he(le)});let ct=!1,ze=0,tt=!!ce.autoCalcSizeOffset;return tt||ce.sizeof||s(ie,"description is missing its sizeof property."),ce.offset??=0,Object.keys(ce.members||{}).forEach(Ie=>{let Je=et(ce.members[Ie]);!Je.members&&!Je.sizeof&&(Je.sizeof=de(Je.signature),Je.sizeof||s(_(ie,Ie),"is missing a sizeof property.",Je)),Je.offset===void 0&&(tt?Je.offset=ze:s(_(ie,Ie),"is missing its offset.",JSON.stringify(Je))),ce.members[Ie]=Je,(!ct||ct.offset<Je.offset)&&(ct=Je);let _n=!!Je.autoCalc;tt&&(Je.autoCalcSizeOffset=!0),Eo.call(Qe,xe,Ie,Je),_n?Je.autoCalcSizeOffset=!0:delete Je.autoCalcSizeOffset,ze+=Je.sizeof}),ct||s("No member property descriptions found."),ce.sizeof||(ce.sizeof=ze),ce.sizeof===1?ce.signature==="c"||ce.signature==="C"||s("Unexpected sizeof==1 member",_(ie,k),"with signature",ce.signature):(ce.sizeof%4!==0&&(console.warn("Invalid struct member description",ce),s(ie,"sizeof is not aligned. sizeof="+ce.sizeof)),ce.offset%4!==0&&(console.warn("Invalid struct member description",ce),s(ie,"offset is not aligned. offset="+ce.offset))),ce.sizeof<ze&&(console.warn("Suspect struct description:",ce,"offset =",ze),s("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",ze,"but got",ce.sizeof,"for",ce)),delete ce.autoCalcSizeOffset,xe},dt=function P(ie,ce){return arguments.length==1?Dr.call(P,ie):Dr.call(P,ie,ce)};return dt.StructType=lt,dt.config=r,dt.allocCString=Dt,dt.adaptGet=Ct,dt.adaptSet=F,dt.adaptStruct=G,dt.ptrAdd=z,dt.debugFlags||(dt.debugFlags=a.__makeDebugFlags(a.debugFlags)),dt},globalThis.sqlite3ApiBootstrap.initializers.push(function(o){"use strict";let r=(...E)=>{throw new Error(E.join(" "))},s=o.capi,a=o.wasm,m=o.util;globalThis.WhWasmUtilInstaller(a),delete globalThis.WhWasmUtilInstaller;let d={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_bind_double","int","sqlite3_stmt*","int","f64"],["sqlite3_bind_int","int","sqlite3_stmt*","int","int"],["sqlite3_bind_null",void 0,"sqlite3_stmt*","int"],["sqlite3_bind_parameter_count","int","sqlite3_stmt*"],["sqlite3_bind_parameter_index","int","sqlite3_stmt*","string"],["sqlite3_bind_parameter_name","string","sqlite3_stmt*","int"],["sqlite3_bind_pointer","int","sqlite3_stmt*","int","*","string:static","*"],["sqlite3_bind_zeroblob","int","sqlite3_stmt*","int","int"],["sqlite3_busy_handler","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(E,w)=>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 w;return(W,ee,O,z)=>{try{let le=a.cArgvToJs(ee,O);return w||(w=a.cArgvToJs(ee,z)),E(le,w)|0}catch(le){return le.resultCode||s.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,w)=>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=>(w,W,ee,O,z)=>{E(w,W,a.cstrToJs(ee),a.cstrToJs(O),z)}}),"*"]],["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&&d.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new a.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(E,w)=>E[0]}),"*"]]),a.exports.sqlite3_stmt_explain&&d.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]),a.exports.sqlite3_set_authorizer&&d.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(E,w)=>E[0],callProxy:E=>(w,W,ee,O,z,le)=>{try{return ee=ee&&a.cstrToJs(ee),O=O&&a.cstrToJs(O),z=z&&a.cstrToJs(z),le=le&&a.cstrToJs(le),E(w,W,ee,O,z,le)|0}catch(h){return h.resultCode||s.SQLITE_ERROR}}}),"*"]]),a.exports.sqlite3_column_origin_name&&d.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"]),a.bigIntEnabled&&a.exports.sqlite3_declare_vtab&&d.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","**"]),a.bigIntEnabled&&a.exports.sqlite3_preupdate_hook&&d.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=>(w,W,ee,O,z,le,h)=>{E(w,W,ee,a.cstrToJs(O),a.cstrToJs(z),le,h)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]),a.bigIntEnabled&&a.exports.sqlite3changegroup_add&&a.exports.sqlite3session_create&&a.exports.sqlite3_preupdate_hook){let E={signature:"i(ps)",callProxy:w=>(W,ee)=>{try{return w(W,a.cstrToJs(ee))|0}catch(O){return O.resultCode||s.SQLITE_ERROR}}};d.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:(w,W)=>w[0]}),"*"]])}o.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",O=>E(m.flexibleString(O))),a.xWrap.argAdapter("string:static",function(O){return a.isPtr(O)?O:(O=""+O,this[O]||(this[O]=a.allocCString(O)))}.bind(Object.create(null)));let w=a.xWrap.argAdapter("*"),W=function(){};a.xWrap.argAdapter("sqlite3_filename",w)("sqlite3_context*",w)("sqlite3_value*",w)("void*",w)("sqlite3_changegroup*",w)("sqlite3_changeset_iter*",w)("sqlite3_session*",w)("sqlite3_stmt*",O=>w(O instanceof(o?.oo1?.Stmt||W)?O.pointer:O))("sqlite3*",O=>w(O instanceof(o?.oo1?.DB||W)?O.pointer:O))("sqlite3_vfs*",O=>typeof O=="string"?s.sqlite3_vfs_find(O)||o.SQLite3Error.toss(s.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",O):w(O instanceof(s.sqlite3_vfs||W)?O.pointer:O)),a.exports.sqlite3_declare_vtab&&a.xWrap.argAdapter("sqlite3_index_info*",O=>w(O instanceof(s.sqlite3_index_info||W)?O.pointer:O))("sqlite3_module*",O=>w(O instanceof(s.sqlite3_module||W)?O.pointer:O));let ee=a.xWrap.resultAdapter("*");a.xWrap.resultAdapter("sqlite3*",ee)("sqlite3_context*",ee)("sqlite3_stmt*",ee)("sqlite3_value*",ee)("sqlite3_vfs*",ee)("void*",ee);for(let O of d.core)s[O[0]]=a.xWrap.apply(null,O);for(let O of d.wasmInternal)m[O[0]]=a.xWrap.apply(null,O);for(let O of d.int64)s[O[0]]=a.bigIntEnabled?a.xWrap.apply(null,O):()=>r(O[0]+"() is unavailable due to lack","of BigInt support in this build.");delete d.core,delete d.int64,delete d.wasmInternal,m.sqlite3__wasm_db_error=function(O,z,le){return O?(z instanceof o.WasmAllocError?(z=s.SQLITE_NOMEM,le=0):z instanceof Error&&(le=le||""+z,z=z.resultCode||s.SQLITE_ERROR),s.sqlite3_set_errmsg(O,z,le)||z):s.SQLITE_MISUSE}}{let E=a.xCall("sqlite3__wasm_enum_json");E||r("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!"),a.ctype=JSON.parse(a.cstrToJs(E));let w=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];a.bigIntEnabled&&w.push("serialize","session","vtab");for(let O of w)for(let z of Object.entries(a.ctype[O]))s[z[0]]=z[1];a.functionEntry(s.SQLITE_WASM_DEALLOC)||r("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+s.SQLITE_WASM_DEALLOC+").");let W=Object.create(null);for(let O of Object.entries(a.ctype.resultCodes))W[O[1]]=O[0];s.sqlite3_js_rc_str=O=>W[O];let ee=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 O of a.ctype.structs)ee[O.name]||(s[O.name]=o.StructBinder(O));if(s.sqlite3_index_info){for(let O of["sqlite3_index_constraint","sqlite3_index_orderby","sqlite3_index_constraint_usage"])s.sqlite3_index_info[O]=s[O],delete s[O];s.sqlite3_vtab_config=a.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}let q=(E,w,W)=>m.sqlite3__wasm_db_error(E,s.SQLITE_MISUSE,w+"() requires "+W+" argument"+(W===1?"":"s")+"."),V=E=>m.sqlite3__wasm_db_error(E,s.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),N=E=>a.xWrap.argAdapter("sqlite3*")(E),x=E=>a.isPtr(E)?a.cstrToJs(E):E,R=function(E,w){E=N(E);let W=this.dbMap.get(E);if(w)!W&&w>0&&this.dbMap.set(E,W=Object.create(null));else return this.dbMap.delete(E),W;return W}.bind(Object.assign(Object.create(null),{dbMap:new Map}));R.addCollation=function(E,w){let W=R(E,1);W.collation||(W.collation=new Set),W.collation.add(x(w).toLowerCase())},R._addUDF=function(E,w,W,ee){w=x(w).toLowerCase();let O=ee.get(w);O||ee.set(w,O=new Set),O.add(W<0?-1:W)},R.addFunction=function(E,w,W){let ee=R(E,1);ee.udf||(ee.udf=new Map),this._addUDF(E,w,W,ee.udf)},a.exports.sqlite3_create_window_function&&(R.addWindowFunc=function(E,w,W){let ee=R(E,1);ee.wudf||(ee.wudf=new Map),this._addUDF(E,w,W,ee.wudf)}),R.cleanup=function(E){E=N(E);for(let ee 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[O,z]=ee;if(!a.exports[O])continue;let le=[E];le.length=z;try{s[O](...le)}catch(h){o.config.warn("close-time call of",O+"(",le,") threw:",h)}}let w=R(E,0);if(!w)return;if(w.collation){for(let ee of w.collation)try{s.sqlite3_create_collation_v2(E,ee,s.SQLITE_UTF8,0,0,0)}catch{}delete w.collation}let W=0;for(;W<2;++W){let ee=W?w.wudf:w.udf;if(!ee)continue;let O=W?s.sqlite3_create_window_function:s.sqlite3_create_function_v2;for(let z of ee){let le=z[0],h=z[1],A=[E,le,0,s.SQLITE_UTF8,0,0,0,0,0];W&&A.push(0);for(let U of h)try{A[2]=U,O.apply(null,A)}catch{}h.clear()}ee.clear()}delete w.udf,delete w.wudf};{let E=a.xWrap("sqlite3_close_v2","int","sqlite3*");s.sqlite3_close_v2=function(w){if(arguments.length!==1)return q(w,"sqlite3_close_v2",1);if(w)try{R.cleanup(w)}catch{}return E(w)}}if(s.sqlite3session_create){let E=a.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);s.sqlite3session_delete=function(w){if(arguments.length!==1)return q(pDb,"sqlite3session_delete",1);w&&s.sqlite3session_table_filter(w,0,0),E(w)}}{let E=(W,ee)=>"argv["+ee+"]:"+W[0]+":"+a.cstrToJs(W[1]).toLowerCase(),w=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})]);s.sqlite3_create_collation_v2=function(W,ee,O,z,le,h){if(arguments.length!==6)return q(W,"sqlite3_create_collation_v2",6);if((O&15)===0)O|=s.SQLITE_UTF8;else if(s.SQLITE_UTF8!==(O&15))return V(W);try{let A=w(W,ee,O,z,le,h);return A===0&&le instanceof Function&&R.addCollation(W,ee),A}catch(A){return m.sqlite3__wasm_db_error(W,A)}},s.sqlite3_create_collation=(W,ee,O,z,le)=>arguments.length===5?s.sqlite3_create_collation_v2(W,ee,O,z,le,0):q(W,"sqlite3_create_collation",5)}{let E=function(O,z){return O[0]+":"+(O[2]<0?-1:O[2])+":"+z+":"+a.cstrToJs(O[1]).toLowerCase()},w=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:E,callProxy:O=>(z,le,h)=>{try{O(z,...s.sqlite3_values_to_js(le,h))}catch(A){s.sqlite3_result_error_js(z,A)}}},xFinalAndValue:{signature:"v(p)",contextKey:E,callProxy:O=>z=>{try{s.sqlite3_result_js(z,O(z))}catch(le){s.sqlite3_result_error_js(z,le)}}},xFunc:{signature:"v(pip)",contextKey:E,callProxy:O=>(z,le,h)=>{try{s.sqlite3_result_js(z,O(z,...s.sqlite3_values_to_js(le,h)))}catch(A){s.sqlite3_result_error_js(z,A)}}},xDestroy:{signature:"v(p)",contextKey:E,callProxy:O=>z=>{try{O(z)}catch(le){console.error("UDF xDestroy method threw:",le)}}}}),W=a.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xFunc",...w.xFunc}),new a.xWrap.FuncPtrAdapter({name:"xStep",...w.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...w.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...w.xDestroy})]),ee=a.exports.sqlite3_create_window_function?a.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xStep",...w.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...w.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xValue",...w.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xInverse",...w.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...w.xDestroy})]):void 0;s.sqlite3_create_function_v2=function O(z,le,h,A,U,X,L,fe,de){if(O.length!==arguments.length)return q(z,"sqlite3_create_function_v2",O.length);if((A&15)===0)A|=s.SQLITE_UTF8;else if(s.SQLITE_UTF8!==(A&15))return V(z);try{let me=W(z,le,h,A,U,X,L,fe,de);return me===0&&(X instanceof Function||L instanceof Function||fe instanceof Function||de instanceof Function)&&R.addFunction(z,le,h),me}catch(me){return console.error("sqlite3_create_function_v2() setup threw:",me),m.sqlite3__wasm_db_error(z,me,"Creation of UDF threw: "+me)}},s.sqlite3_create_function=function O(z,le,h,A,U,X,L,fe){return O.length===arguments.length?s.sqlite3_create_function_v2(z,le,h,A,U,X,L,fe,0):q(z,"sqlite3_create_function",O.length)},ee?s.sqlite3_create_window_function=function O(z,le,h,A,U,X,L,fe,de,me){if(O.length!==arguments.length)return q(z,"sqlite3_create_window_function",O.length);if((A&15)===0)A|=s.SQLITE_UTF8;else if(s.SQLITE_UTF8!==(A&15))return V(z);try{let S=ee(z,le,h,A,U,X,L,fe,de,me);return S===0&&(X instanceof Function||L instanceof Function||fe instanceof Function||de instanceof Function||me instanceof Function)&&R.addWindowFunc(z,le,h),S}catch(S){return console.error("sqlite3_create_window_function() setup threw:",S),m.sqlite3__wasm_db_error(z,S,"Creation of UDF threw: "+S)}}:delete s.sqlite3_create_window_function,s.sqlite3_create_function_v2.udfSetResult=s.sqlite3_create_function.udfSetResult=s.sqlite3_result_js,s.sqlite3_create_window_function&&(s.sqlite3_create_window_function.udfSetResult=s.sqlite3_result_js),s.sqlite3_create_function_v2.udfConvertArgs=s.sqlite3_create_function.udfConvertArgs=s.sqlite3_values_to_js,s.sqlite3_create_window_function&&(s.sqlite3_create_window_function.udfConvertArgs=s.sqlite3_values_to_js),s.sqlite3_create_function_v2.udfSetError=s.sqlite3_create_function.udfSetError=s.sqlite3_result_error_js,s.sqlite3_create_window_function&&(s.sqlite3_create_window_function.udfSetError=s.sqlite3_result_error_js)}{let E=(W,ee)=>(typeof W=="string"?ee=-1:m.isSQLableTypedArray(W)?(ee=W.byteLength,W=a.typedArrayToString(W instanceof ArrayBuffer?new Uint8Array(W):W)):Array.isArray(W)&&(W=W.join(""),ee=-1),[W,ee]),w={basic:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};s.sqlite3_prepare_v3=function W(ee,O,z,le,h,A){if(W.length!==arguments.length)return q(ee,"sqlite3_prepare_v3",W.length);let[U,X]=E(O,Number(z));switch(typeof U){case"string":return w.basic(ee,U,X,le,h,null);case typeof a.ptr.null:return w.full(ee,a.ptr.coerce(U),X,le,h,A);default:return m.sqlite3__wasm_db_error(ee,s.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof U)}},s.sqlite3_prepare_v2=function W(ee,O,z,le,h){return W.length===arguments.length?s.sqlite3_prepare_v3(ee,O,z,0,le,h):q(ee,"sqlite3_prepare_v2",W.length)}}{let E=a.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),w=a.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);s.sqlite3_bind_text=function W(ee,O,z,le,h){if(W.length!==arguments.length)return q(s.sqlite3_db_handle(ee),"sqlite3_bind_text",W.length);if(a.isPtr(z)||z===null)return E(ee,O,z,le,h);z instanceof ArrayBuffer?z=new Uint8Array(z):Array.isArray(pMem)&&(z=pMem.join(""));let A,U;try{if(m.isSQLableTypedArray(z))A=a.allocFromTypedArray(z),U=z.byteLength;else if(typeof z=="string")[A,U]=a.allocCString(z);else return m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),s.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return E(ee,O,A,U,s.SQLITE_WASM_DEALLOC)}catch(X){return a.dealloc(A),m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),X)}},s.sqlite3_bind_blob=function W(ee,O,z,le,h){if(W.length!==arguments.length)return q(s.sqlite3_db_handle(ee),"sqlite3_bind_blob",W.length);if(a.isPtr(z)||z===null)return w(ee,O,z,le,h);z instanceof ArrayBuffer?z=new Uint8Array(z):Array.isArray(z)&&(z=z.join(""));let A,U;try{if(m.isBindableTypedArray(z))A=a.allocFromTypedArray(z),U=le>=0?le:z.byteLength;else if(typeof z=="string")[A,U]=a.allocCString(z);else return m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),s.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return w(ee,O,A,U,s.SQLITE_WASM_DEALLOC)}catch(X){return a.dealloc(A),m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),X)}}}if(!s.sqlite3_column_text){let E=a.xWrap.argAdapter("sqlite3_stmt*"),w=a.xWrap.argAdapter("int"),W=a.xWrap.argAdapter("sqlite3_value*"),ee=(O,z)=>a.typedArrayToString(a.heap8u(),Number(O),Number(O)+z);s.sqlite3_column_text=function(O,z){let le=E(O),h=w(z),A=a.exports.sqlite3_column_text(le,h);return A?ee(A,a.exports.sqlite3_column_bytes(le,h)):null},s.sqlite3_value_text=function(O){let z=W(O),le=a.exports.sqlite3_value_text(z);return le?ee(le,a.exports.sqlite3_value_bytes(z)):null}}s.sqlite3_config=function(E,...w){if(arguments.length<2)return s.SQLITE_MISUSE;switch(E){case s.SQLITE_CONFIG_COVERING_INDEX_SCAN:case s.SQLITE_CONFIG_MEMSTATUS:case s.SQLITE_CONFIG_SMALL_MALLOC:case s.SQLITE_CONFIG_SORTERREF_SIZE:case s.SQLITE_CONFIG_STMTJRNL_SPILL:case s.SQLITE_CONFIG_URI:return a.exports.sqlite3__wasm_config_i(E,w[0]);case s.SQLITE_CONFIG_LOOKASIDE:return a.exports.sqlite3__wasm_config_ii(E,w[0],w[1]);case s.SQLITE_CONFIG_MEMDB_MAXSIZE:return a.exports.sqlite3__wasm_config_j(E,w[0]);case s.SQLITE_CONFIG_GETMALLOC:case s.SQLITE_CONFIG_GETMUTEX:case s.SQLITE_CONFIG_GETPCACHE2:case s.SQLITE_CONFIG_GETPCACHE:case s.SQLITE_CONFIG_HEAP:case s.SQLITE_CONFIG_LOG:case s.SQLITE_CONFIG_MALLOC:case s.SQLITE_CONFIG_MMAP_SIZE:case s.SQLITE_CONFIG_MULTITHREAD:case s.SQLITE_CONFIG_MUTEX:case s.SQLITE_CONFIG_PAGECACHE:case s.SQLITE_CONFIG_PCACHE2:case s.SQLITE_CONFIG_PCACHE:case s.SQLITE_CONFIG_PCACHE_HDRSZ:case s.SQLITE_CONFIG_PMASZ:case s.SQLITE_CONFIG_SERIALIZED:case s.SQLITE_CONFIG_SINGLETHREAD:case s.SQLITE_CONFIG_SQLLOG:case s.SQLITE_CONFIG_WIN32_HEAPSIZE:default:return s.SQLITE_NOTFOUND}};{let E=new Set;s.sqlite3_auto_extension=function(w){if(w instanceof Function)w=a.installFunction("i(ppp)",w);else if(arguments.length!==1||!a.isPtr(w))return s.SQLITE_MISUSE;let W=a.exports.sqlite3_auto_extension(w);return w!==arguments[0]&&(W===0?E.add(w):a.uninstallFunction(w)),W},s.sqlite3_cancel_auto_extension=function(w){return!w||arguments.length!==1||!a.isPtr(w)?0:a.exports.sqlite3_cancel_auto_extension(w)},s.sqlite3_reset_auto_extension=function(){a.exports.sqlite3_reset_auto_extension();for(let w of E)a.uninstallFunction(w);E.clear()}}a.xWrap.FuncPtrAdapter.warnOnUse=!0;let $=o.StructBinder,B=function E(w,W,ee,O=E.installMethodArgcCheck){if(w instanceof $.StructType?!(ee instanceof Function)&&!a.isPtr(ee)&&r("Usage error: expecting a Function or WASM pointer to one."):r("Usage error: target object is-not-a StructType."),arguments.length===1)return(A,U)=>E(w,A,U,O);E.argcProxy||(E.argcProxy=function(A,U,X,L){return function(...fe){return X.length!==arguments.length&&r("Argument mismatch for",A.structInfo.name+"::"+U+": Native signature is:",L),X.apply(this,fe)}},E.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((A,U)=>{if(a.isPtr(A))try{a.uninstallFunction(A)}catch{}}),delete this.ondispose.__removeFuncList)});let z=w.memberSignature(W);z.length<2&&r("Member",W,"does not have a function pointer signature:",z);let le=w.memberKey(W),h=O&&!a.isPtr(ee)?E.argcProxy(w,le,ee,z):ee;if(a.isPtr(h))h&&!a.functionEntry(h)&&r("Pointer",h,"is not a WASM function table entry."),w[le]=h;else{let A=a.installFunction(h,z);w[le]=A,(!w.ondispose||!w.ondispose.__removeFuncList)&&(w.addOnDispose("ondispose.__removeFuncList handler",E.removeFuncList),w.ondispose.__removeFuncList=[]),w.ondispose.__removeFuncList.push(le,A)}return(A,U)=>E(w,A,U,O)};B.installMethodArgcCheck=!1;let J=function(E,w,W=B.installMethodArgcCheck){let ee=new Map;for(let O of Object.keys(w)){let z=w[O],le=ee.get(z);if(le){let h=E.memberKey(O);E[h]=E[E.memberKey(le)]}else B(E,O,z,W),ee.set(z,O)}return E};$.StructType.prototype.installMethod=function(w,W,ee=B.installMethodArgcCheck){return arguments.length<3&&w&&typeof w=="object"?J(this,...arguments):B(this,...arguments)},$.StructType.prototype.installMethods=function(E,w=B.installMethodArgcCheck){return J(this,E,w)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){let r=(...S)=>{throw new o.SQLite3Error(...S)},s=o.capi,a=o.wasm,m=o.util;o.__isUnderTest?console.debug.bind(console):o.config.debug,o.__isUnderTest?console.warn.bind(console):o.config.warn,o.__isUnderTest?console.error.bind(console):o.config.error;let d=new WeakMap,q=new Set,V=new WeakMap,N=(S,C,u)=>{let _=Object.getOwnPropertyDescriptor(S,C);return _?_.value:u},x=function(S,C){return C&&(S instanceof J&&(S=S.pointer),r(C,"sqlite3 result code",C+":",S?s.sqlite3_errmsg(S):s.sqlite3_errstr(C))),arguments[0]},R=a.installFunction("i(ippp)",function(S,C,u,_){s.SQLITE_TRACE_STMT===S&&console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+C+"["+s.sqlite3_db_filename(C,null)+"]",a.cstrToJs(_))}.bind({counter:0})),$=Object.create(null),B=function S(...C){let u=S.normalizeArgs(...C),_;if(_=u["sqlite3*"])u["sqlite3*:takeOwnership"]||q.add(this),this.filename=s.sqlite3_db_filename(_,"main");else{let y=u.filename,Q=u.vfs,K=u.flags;(typeof y!="string"&&!a.isPtr(y)||typeof K!="string"||Q&&typeof Q!="string"&&!a.isPtr(Q))&&(o.config.error("Invalid DB ctor args",u,arguments),r("Invalid arguments for DB constructor:",arguments,"opts:",u));let M=0;K.indexOf("c")>=0&&(M|=s.SQLITE_OPEN_CREATE|s.SQLITE_OPEN_READWRITE),K.indexOf("w")>=0&&(M|=s.SQLITE_OPEN_READWRITE),M===0&&(M|=s.SQLITE_OPEN_READONLY),M|=s.SQLITE_OPEN_EXRESCODE;let b=a.pstack.pointer;try{let D=a.pstack.allocPtr(),te=s.sqlite3_open_v2(y,D,M,Q||a.ptr.null);_=a.peekPtr(D),x(_,te),s.sqlite3_extended_result_codes(_,1),K.indexOf("t")>=0&&s.sqlite3_trace_v2(_,s.SQLITE_TRACE_STMT,R,_)}catch(D){throw _&&s.sqlite3_close_v2(_),D}finally{a.pstack.restore(b)}this.filename=a.isPtr(y)?a.cstrToJs(y):y}if(d.set(this,_),V.set(this,Object.create(null)),!u["sqlite3*"])try{let y=s.sqlite3_js_db_vfs(_)||r("Internal error: cannot get VFS for new db handle."),Q=$[y];Q&&(Q instanceof Function?Q(this,o):x(_,s.sqlite3_exec(_,Q,0,0,0)))}catch(y){throw this.close(),y}};B.setVfsPostOpenCallback=function(S,C){C instanceof Function||r("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments),$[S]=C},B.normalizeArgs=function(S=":memory:",C="c",u=null){let _={};return arguments.length===1&&arguments[0]&&typeof arguments[0]=="object"?(Object.assign(_,arguments[0]),_.flags===void 0&&(_.flags="c"),_.vfs===void 0&&(_.vfs=null),_.filename===void 0&&(_.filename=":memory:")):(_.filename=S,_.flags=C,_.vfs=u),_};let J=function(...S){B.apply(this,S)};J.dbCtorHelper=B;let E={null:1,number:2,string:3,boolean:4,blob:5};a.bigIntEnabled&&(E.bigint=E.number);let w=function(){E!==arguments[2]&&r(s.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare()."),this.db=arguments[0],d.set(this,arguments[1]),arguments.length>3&&!arguments[3]&&q.add(this)},W=function(S){return S.pointer||r("DB has been closed."),S},ee=function(S,C){return(C!==(C|0)||C<0||C>=S.columnCount)&&r("Column index",C,"is out of range."),S},O=function(S,C){let u=Object.create(null);switch(u.opt=Object.create(null),C.length){case 1:typeof C[0]=="string"||m.isSQLableTypedArray(C[0])||Array.isArray(C[0])?u.sql=C[0]:C[0]&&typeof C[0]=="object"&&(u.opt=C[0],u.sql=u.opt.sql);break;case 2:u.sql=C[0],u.opt=C[1];break;default:r("Invalid argument count for exec().")}u.sql=m.flexibleString(u.sql),typeof u.sql!="string"&&r("Missing SQL argument or unsupported SQL value type.");let _=u.opt;switch(_.returnValue){case"resultRows":_.resultRows||(_.resultRows=[]),u.returnVal=()=>_.resultRows;break;case"saveSql":_.saveSql||(_.saveSql=[]),u.returnVal=()=>_.saveSql;break;case void 0:case"this":u.returnVal=()=>S;break;default:r("Invalid returnValue value:",_.returnValue)}if(!_.callback&&!_.returnValue&&_.rowMode!==void 0&&(_.resultRows||(_.resultRows=[]),u.returnVal=()=>_.resultRows),_.callback||_.resultRows)switch(_.rowMode===void 0?"array":_.rowMode){case"object":u.cbArg=(y,Q)=>{Q.columnNames||(Q.columnNames=y.getColumnNames([]));let K=y.get([]),M=Object.create(null);for(let b in Q.columnNames)M[Q.columnNames[b]]=K[b];return M};break;case"array":u.cbArg=y=>y.get([]);break;case"stmt":Array.isArray(_.resultRows)&&r("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference."),u.cbArg=y=>y;break;default:if(m.isInt32(_.rowMode)){u.cbArg=y=>y.get(_.rowMode);break}else if(typeof _.rowMode=="string"&&_.rowMode.length>1&&_.rowMode[0]==="$"){let y=_.rowMode.substr(1);u.cbArg=Q=>{let K=Q.get(Object.create(null))[y];return K===void 0?r(s.SQLITE_NOTFOUND,"exec(): unknown result column:",y):K};break}r("Invalid rowMode:",_.rowMode)}return u},z=(S,C,u,..._)=>{let y=S.prepare(C);try{let Q=y.bind(u).step()?y.get(..._):void 0;return y.reset(),Q}finally{y.finalize()}},le=(S,C,u,_)=>S.exec({sql:C,bind:u,rowMode:_,returnValue:"resultRows"});J.checkRc=(S,C)=>x(S,C),J.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return W(this)},close:function(){let S=this.pointer;if(S){if(this.onclose&&this.onclose.before instanceof Function)try{this.onclose.before(this)}catch{}if(Object.keys(V.get(this)).forEach((C,u)=>{if(u&&u.pointer)try{u.finalize()}catch{}}),d.delete(this),V.delete(this),q.delete(this)||s.sqlite3_close_v2(S),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(S=!1,C=!1){let u=W(this).pointer;return S?C?s.sqlite3_total_changes64(u):s.sqlite3_total_changes(u):C?s.sqlite3_changes64(u):s.sqlite3_changes(u)},dbFilename:function(S="main"){return s.sqlite3_db_filename(W(this).pointer,S)},dbName:function(S=0){return s.sqlite3_db_name(W(this).pointer,S)},dbVfsName:function(S=0){let C,u=s.sqlite3_js_db_vfs(W(this).pointer,S);if(u){let _=new s.sqlite3_vfs(u);try{C=a.cstrToJs(_.$zName)}finally{_.dispose()}}return C},prepare:function(S){W(this);let C=a.pstack.pointer,u,_;try{u=a.pstack.alloc(8),J.checkRc(this,s.sqlite3_prepare_v2(this.pointer,S,-1,u,null)),_=a.peekPtr(u)}finally{a.pstack.restore(C)}_||r("Cannot prepare empty SQL.");let y=new w(this,_,E);return V.get(this)[_]=y,y},exec:function(){W(this);let S=O(this,arguments);if(!S.sql)return r("exec() requires an SQL string.");let C=S.opt,u=C.callback,_=Array.isArray(C.resultRows)?C.resultRows:void 0,y,Q=C.bind,K=!!(S.cbArg||C.columnNames||_),M=a.scopedAllocPush(),b=Array.isArray(C.saveSql)?C.saveSql:void 0;try{let D=m.isSQLableTypedArray(S.sql),te=D?S.sql.byteLength:a.jstrlen(S.sql),Z=a.scopedAlloc(2*a.ptr.size+(te+1)),we=a.ptr.add(Z,a.ptr.size),he=a.ptr.add(we,a.ptr.size),ke=a.ptr.add(he,te);for(D?a.heap8().set(S.sql,he):a.jstrcpy(S.sql,a.heap8(),he,te,!1),a.poke8(a.ptr.add(he,te),0);he&&a.peek8(he);){a.pokePtr([Z,we],0),J.checkRc(this,s.sqlite3_prepare_v3(this.pointer,he,te,0,Z,we));let Be=a.peekPtr(Z);if(he=a.peekPtr(we),te=Number(a.ptr.add(ke,-he)),!!Be){if(b&&b.push(s.sqlite3_sql(Be).trim()),y=new w(this,Be,E),Q&&y.parameterCount&&(y.bind(Q),Q=null),K&&y.columnCount){let Ze=Array.isArray(C.columnNames)?0:1;if(K=!1,S.cbArg||_){let at=Object.create(null);for(;y.step();L.delete(y)){Ze++===0&&y.getColumnNames(at.columnNames=C.columnNames||[]),L.add(y);let Ct=S.cbArg(y,at);if(_&&_.push(Ct),u&&u.call(C,Ct,y)===!1)break}L.delete(y)}Ze===0&&y.getColumnNames(C.columnNames)}else y.step();y.reset().finalize(),y=null}}}finally{y&&(L.delete(y),y.finalize()),a.scopedAllocPop(M)}return S.returnVal()},createFunction:function(C,u,_){let y=at=>at instanceof Function;switch(arguments.length){case 1:_=C,C=_.name,u=_.xFunc||0;break;case 2:y(u)||(_=u,u=_.xFunc||0)}_||(_={}),typeof C!="string"&&r("Invalid arguments: missing function name.");let Q=_.xStep||0,K=_.xFinal||0,M=_.xValue||0,b=_.xInverse||0,D;y(u)?(D=!1,(y(Q)||y(K))&&r("Ambiguous arguments: scalar or aggregate?"),Q=K=null):y(Q)?(y(K)||r("Missing xFinal() callback for aggregate or window UDF."),u=null):y(K)?r("Missing xStep() callback for aggregate or window UDF."):r("Missing function-type properties."),D===!1?(y(M)||y(b))&&r("xValue and xInverse are not permitted for non-window UDFs."):y(M)?(y(b)||r("xInverse must be provided if xValue is."),D=!0):y(b)&&r("xValue must be provided if xInverse is.");let te=_.pApp;te!=null&&!a.isPtr(te)&&r("Invalid value for pApp property. Must be a legal WASM pointer value.");let Z=_.xDestroy||0;Z&&!y(Z)&&r("xDestroy property must be a function.");let we=0;N(_,"deterministic")&&(we|=s.SQLITE_DETERMINISTIC),N(_,"directOnly")&&(we|=s.SQLITE_DIRECTONLY),N(_,"innocuous")&&(we|=s.SQLITE_INNOCUOUS),C=C.toLowerCase();let he=u||Q,ke=N(_,"arity"),Be=typeof ke=="number"?ke:he.length?he.length-1:0,Ze;return D?Ze=s.sqlite3_create_window_function(this.pointer,C,Be,s.SQLITE_UTF8|we,te||0,Q,K,M,b,Z):Ze=s.sqlite3_create_function_v2(this.pointer,C,Be,s.SQLITE_UTF8|we,te||0,u,Q,K,Z),J.checkRc(this,Ze),this},selectValue:function(S,C,u){return z(this,S,C,0,u)},selectValues:function(S,C,u){let _=this.prepare(S),y=[];try{for(_.bind(C);_.step();)y.push(_.get(0,u));_.reset()}finally{_.finalize()}return y},selectArray:function(S,C){return z(this,S,C,[])},selectObject:function(S,C){return z(this,S,C,{})},selectArrays:function(S,C){return le(this,S,C,"array")},selectObjects:function(S,C){return le(this,S,C,"object")},openStatementCount:function(){return this.pointer?Object.keys(V.get(this)).length:0},transaction:function(S){let C="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&r(s.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),C+=" "+arguments[0],S=arguments[1]),W(this).exec(C);try{let u=S(this);return this.exec("COMMIT"),u}catch(u){throw this.exec("ROLLBACK"),u}},savepoint:function(S){W(this).exec("SAVEPOINT oo1");try{let C=S(this);return this.exec("RELEASE oo1"),C}catch(C){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),C}},checkRc:function(S){return x(this,S)}},J.wrapHandle=function(S,C=!1){if(!S||!a.isPtr(S))throw new o.SQLite3Error(s.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new J({"sqlite3*":S,"sqlite3*:takeOwnership":!!C})};let h=function(S){return S.pointer||r("Stmt has been closed."),S},A=function(S){let C=E[S==null?"null":typeof S];switch(C){case E.boolean:case E.null:case E.number:case E.string:return C;case E.bigint:return a.bigIntEnabled?C:void 0;default:return m.isBindableTypedArray(S)?E.blob:void 0}},U=function(S){return A(S)||r("Unsupported bind() argument type:",typeof S)},X=function(S,C){let u=typeof C=="number"?C:s.sqlite3_bind_parameter_index(S.pointer,C);return u===0||!m.isInt32(u)?r("Invalid bind() parameter name: "+C):(u<1||u>S.parameterCount)&&r("Bind index",C,"is out of range."),u},L=new Set,fe=new Set,de=function(S,C){return L.has(S)&&r("Operation is illegal when statement is locked:",C),S},me=function S(C,u,_,y){de(h(C),"bind()"),S._||(S._tooBigInt=K=>r("BigInt value is too big to store without precision loss:",K),S._={string:function(K,M,b,D){let[te,Z]=a.allocCString(b,!0);return(D?s.sqlite3_bind_blob:s.sqlite3_bind_text)(K.pointer,M,te,Z,s.SQLITE_WASM_DEALLOC)}}),U(y),u=X(C,u);let Q=0;switch(y==null?E.null:_){case E.null:Q=s.sqlite3_bind_null(C.pointer,u);break;case E.string:Q=S._.string(C,u,y,!1);break;case E.number:{let K;m.isInt32(y)?K=s.sqlite3_bind_int:typeof y=="bigint"?m.bigIntFits64(y)?a.bigIntEnabled?K=s.sqlite3_bind_int64:m.bigIntFitsDouble(y)?(y=Number(y),K=s.sqlite3_bind_double):S._tooBigInt(y):S._tooBigInt(y):(y=Number(y),a.bigIntEnabled&&Number.isInteger(y)?K=s.sqlite3_bind_int64:K=s.sqlite3_bind_double),Q=K(C.pointer,u,y);break}case E.boolean:Q=s.sqlite3_bind_int(C.pointer,u,y?1:0);break;case E.blob:{if(typeof y=="string"){Q=S._.string(C,u,y,!0);break}else y instanceof ArrayBuffer?y=new Uint8Array(y):m.isBindableTypedArray(y)||r("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");let K=a.alloc(y.byteLength||1);a.heap8().set(y.byteLength?y:[0],Number(K)),Q=s.sqlite3_bind_blob(C.pointer,u,K,y.byteLength,s.SQLITE_WASM_DEALLOC);break}default:o.config.warn("Unsupported bind() argument type:",y),r("Unsupported bind() argument type: "+typeof y)}return Q&&J.checkRc(C.db.pointer,Q),C};w.prototype={finalize:function(){let S=this.pointer;if(S){de(this,"finalize()");let C=q.delete(this)?0:s.sqlite3_finalize(S);return delete V.get(this.db)[S],d.delete(this),L.delete(this),fe.delete(this),delete this.parameterCount,delete this.db,C}},clearBindings:function(){return de(h(this),"clearBindings()"),s.sqlite3_clear_bindings(this.pointer),fe.delete(this),this},reset:function(S){de(this,"reset()"),S&&this.clearBindings();let C=s.sqlite3_reset(h(this).pointer);return fe.delete(this),x(this.db,C),this},bind:function(){h(this);let S,C;switch(arguments.length){case 1:S=1,C=arguments[0];break;case 2:S=arguments[0],C=arguments[1];break;default:r("Invalid bind() arguments.")}return C===void 0?this:(this.parameterCount||r("This statement has no bindable parameters."),fe.delete(this),C===null?me(this,S,E.null,C):Array.isArray(C)?(arguments.length!==1&&r("When binding an array, an index argument is not permitted."),C.forEach((u,_)=>me(this,_+1,U(u),u)),this):(C instanceof ArrayBuffer&&(C=new Uint8Array(C)),typeof C=="object"&&!m.isBindableTypedArray(C)?(arguments.length!==1&&r("When binding an object, an index argument is not permitted."),Object.keys(C).forEach(u=>me(this,u,U(C[u]),C[u])),this):me(this,S,U(C),C)))},bindAsBlob:function(S,C){h(this),arguments.length===1&&(C=S,S=1);let u=U(C);return E.string!==u&&E.blob!==u&&E.null!==u&&r("Invalid value type for bindAsBlob()"),me(this,S,E.blob,C)},step:function(){de(this,"step()");let S=s.sqlite3_step(h(this).pointer);switch(S){case s.SQLITE_DONE:return fe.delete(this),!1;case s.SQLITE_ROW:return fe.add(this),!0;default:fe.delete(this),o.config.warn("sqlite3_step() rc=",S,s.sqlite3_js_rc_str(S),"SQL =",s.sqlite3_sql(this.pointer)),J.checkRc(this.db.pointer,S)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{let S=this.step();return this.reset(),S}finally{try{this.finalize()}catch{}}},get:function(S,C){if(fe.has(h(this))||r("Stmt.step() has not (recently) returned true."),Array.isArray(S)){let u=0,_=this.columnCount;for(;u<_;)S[u]=this.get(u++);return S}else if(S&&typeof S=="object"){let u=0,_=this.columnCount;for(;u<_;)S[s.sqlite3_column_name(this.pointer,u)]=this.get(u++);return S}switch(ee(this,S),C===void 0?s.sqlite3_column_type(this.pointer,S):C){case s.SQLITE_NULL:return null;case s.SQLITE_INTEGER:if(a.bigIntEnabled){let u=s.sqlite3_column_int64(this.pointer,S);return u>=Number.MIN_SAFE_INTEGER&&u<=Number.MAX_SAFE_INTEGER?Number(u).valueOf():u}else{let u=s.sqlite3_column_double(this.pointer,S);return(u>Number.MAX_SAFE_INTEGER||u<Number.MIN_SAFE_INTEGER)&&r("Integer is out of range for JS integer range: "+u),m.isInt32(u)?u|0:u}case s.SQLITE_FLOAT:return s.sqlite3_column_double(this.pointer,S);case s.SQLITE_TEXT:return s.sqlite3_column_text(this.pointer,S);case s.SQLITE_BLOB:{let u=s.sqlite3_column_bytes(this.pointer,S),_=s.sqlite3_column_blob(this.pointer,S),y=new Uint8Array(u);return u&&(y.set(a.heap8u().slice(Number(_),Number(_)+u),0),this.db._blobXfer instanceof Array&&this.db._blobXfer.push(y.buffer)),y}default:r("Don't know how to translate","type of result column #"+S+".")}r("Not reached.")},getInt:function(S){return this.get(S,s.SQLITE_INTEGER)},getFloat:function(S){return this.get(S,s.SQLITE_FLOAT)},getString:function(S){return this.get(S,s.SQLITE_TEXT)},getBlob:function(S){return this.get(S,s.SQLITE_BLOB)},getJSON:function(S){let C=this.get(S,s.SQLITE_STRING);return C===null?C:JSON.parse(C)},getColumnName:function(S){return s.sqlite3_column_name(ee(h(this),S).pointer,S)},getColumnNames:function(S=[]){ee(h(this),0);let C=this.columnCount;for(let u=0;u<C;++u)S.push(s.sqlite3_column_name(this.pointer,u));return S},getParamIndex:function(S){return h(this).parameterCount?s.sqlite3_bind_parameter_index(this.pointer,S):void 0},getParamName:function(S){return h(this).parameterCount?s.sqlite3_bind_parameter_name(this.pointer,S):void 0},isBusy:function(){return s.sqlite3_stmt_busy(h(this))!==0},isReadOnly:function(){return s.sqlite3_stmt_readonly(h(this))!==0}};{let S={enumerable:!0,get:function(){return d.get(this)},set:()=>r("The pointer property is read-only.")};Object.defineProperty(w.prototype,"pointer",S),Object.defineProperty(J.prototype,"pointer",S)}Object.defineProperty(w.prototype,"columnCount",{enumerable:!1,get:function(){return s.sqlite3_column_count(this.pointer)},set:()=>r("The columnCount property is read-only.")}),Object.defineProperty(w.prototype,"parameterCount",{enumerable:!1,get:function(){return s.sqlite3_bind_parameter_count(this.pointer)},set:()=>r("The parameterCount property is read-only.")}),w.wrapHandle=function(S,C,u=!1){if(!(S instanceof J)||!S.pointer)throw new o.SQLite3Error(o.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!C||!a.isPtr(C))throw new o.SQLite3Error(o.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new w(S,C,E,!!u)},o.oo1={DB:J,Stmt:w}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){let r=o.util;o.initWorker1API=function(){"use strict";let s=(...$)=>{throw new Error($.join(" "))};globalThis.WorkerGlobalScope instanceof Function||s("initWorker1API() must be run from a Worker thread.");let a=this.sqlite3||s("Missing this.sqlite3 object."),m=a.oo1.DB,d=function($){let B=q.idMap.get($);return B||(B="db#"+ ++q.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),q.idMap.set($,B),B)},q={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function($){let B=new m($);return this.dbs[d(B)]=B,this.dbList.indexOf(B)<0&&this.dbList.push(B),B},close:function($,B){if($){delete this.dbs[d($)];let J=$.filename,E=r.sqlite3__wasm_db_vfs($.pointer,0);$.close();let w=this.dbList.indexOf($);w>=0&&this.dbList.splice(w,1),B&&J&&E&&r.sqlite3__wasm_vfs_unlink(E,J)}},post:function($,B){B&&B.length?(globalThis.postMessage($,Array.from(B)),B.length=0):globalThis.postMessage($)},dbs:Object.create(null),getDb:function($,B=!0){return this.dbs[$]||(B?s("Unknown (or closed) DB ID:",$):void 0)}},V=function($=q.dbList[0]){return $&&$.pointer?$:s("DB is not opened.")},N=function($,B=!0){let J=q.getDb($.dbId,!1)||q.dbList[0];return B?V(J):J},x=function(){return q.dbList[0]&&d(q.dbList[0])},R={open:function($){let B=Object.create(null),J=$.args||Object.create(null);J.simulateError&&s("Throwing because of simulateError flag.");let E=Object.create(null);B.vfs=J.vfs,B.filename=J.filename||"";let w=q.open(B);return E.filename=w.filename,E.persistent=!!a.capi.sqlite3_js_db_uses_vfs(w.pointer,"opfs"),E.dbId=d(w),E.vfs=w.dbVfsName(),E},close:function($){let B=N($,!1),J={filename:B&&B.filename};if(B){let E=$.args&&typeof $.args=="object"?!!$.args.unlink:!1;q.close(B,E)}return J},exec:function($){let B=typeof $.args=="string"?{sql:$.args}:$.args||Object.create(null);B.rowMode==="stmt"?s("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API."):B.sql||s("'exec' requires input SQL.");let J=N($);(B.callback||Array.isArray(B.resultRows))&&(J._blobXfer=q.xfer);let E=B.callback,w=0,W=!!B.columnNames;typeof E=="string"&&(W||(B.columnNames=[]),B.callback=function(ee,O){q.post({type:E,columnNames:B.columnNames,rowNumber:++w,row:ee},q.xfer)});try{let ee=B.countChanges?J.changes(!0,B.countChanges===64):void 0;J.exec(B),ee!==void 0&&(B.changeCount=J.changes(!0,B.countChanges===64)-ee);let O=B.lastInsertRowId?a.capi.sqlite3_last_insert_rowid(J):void 0;O!==void 0&&(B.lastInsertRowId=O),B.callback instanceof Function&&(B.callback=E,q.post({type:E,columnNames:B.columnNames,rowNumber:null,row:void 0}))}finally{delete J._blobXfer,B.callback&&(B.callback=E)}return B},"config-get":function(){let $=Object.create(null),B=a.config;return["bigIntEnabled"].forEach(function(J){Object.getOwnPropertyDescriptor(B,J)&&($[J]=B[J])}),$.version=a.version,$.vfsList=a.capi.sqlite3_js_vfs_list(),$},export:function($){let B=N($),J={byteArray:a.capi.sqlite3_js_db_export(B.pointer),filename:B.filename,mimetype:"application/x-sqlite3"};return q.xfer.push(J.byteArray.buffer),J},toss:function($){s("Testing worker exception")}};globalThis.onmessage=async function($){$=$.data;let B,J=$.dbId,E=$.type,w=performance.now();try{R.hasOwnProperty(E)&&R[E]instanceof Function?B=await R[E]($):s("Unknown db worker message type:",$.type)}catch(W){E="error",B={operation:$.type,message:W.message,errorClass:W.name,input:$},W.stack&&(B.stack=typeof W.stack=="string"?W.stack.split(/\n\s*/):W.stack)}J||(J=B.dbId||x()),q.post({type:E,dbId:J,messageId:$.messageId,workerReceivedTime:w,workerRespondTime:performance.now(),departureTime:$.departureTime,result:B},q.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:o})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){let r=o.wasm,s=o.capi,a=o.util.toss3,m=Object.create(null);o.vfs=m,s.sqlite3_vfs.prototype.registerVfs=function(d=!1){this instanceof o.capi.sqlite3_vfs||a("Expecting a sqlite3_vfs-type argument.");let q=s.sqlite3_vfs_register(this,d?1:0);return q&&a("sqlite3_vfs_register(",this,") failed with rc",q),this.pointer!==s.sqlite3_vfs_find(this.$zName)&&a("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this),this},m.installVfs=function(d){let q=0,V=["io","vfs"];for(let N of V){let x=d[N];x&&(++q,x.struct.installMethods(x.methods,!!x.applyArgcCheck),N==="vfs"&&(!x.struct.$zName&&typeof x.name=="string"&&x.struct.addOnDispose(x.struct.$zName=r.allocCString(x.name)),x.struct.registerVfs(!!x.asDefault)))}return q||a("Misuse: installVfs() options object requires at least","one of:",V),this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(!o.wasm.exports.sqlite3_declare_vtab)return;let r=o.wasm,s=o.capi,a=o.util.toss3,m=Object.create(null);o.vtab=m;let d=s.sqlite3_index_info;d.prototype.nthConstraint=function(N,x=!1){if(N<0||N>=this.$nConstraint)return!1;let R=r.ptr.add(this.$aConstraint,d.sqlite3_index_constraint.structInfo.sizeof*N);return x?R:new d.sqlite3_index_constraint(R)},d.prototype.nthConstraintUsage=function(N,x=!1){if(N<0||N>=this.$nConstraint)return!1;let R=r.ptr.add(this.$aConstraintUsage,d.sqlite3_index_constraint_usage.structInfo.sizeof*N);return x?R:new d.sqlite3_index_constraint_usage(R)},d.prototype.nthOrderBy=function(N,x=!1){if(N<0||N>=this.$nOrderBy)return!1;let R=r.ptr.add(this.$aOrderBy,d.sqlite3_index_orderby.structInfo.sizeof*N);return x?R:new d.sqlite3_index_orderby(R)};let q=function(N,x){return function(R,$=!1){if(arguments.length===0&&(R=new x),R instanceof x)return this.set(R.pointer,R),R;r.isPtr(R)||o.SQLite3Error.toss("Invalid argument to",N+"()");let B=this.get(R);return $&&this.delete(R),B}.bind(new Map)},V=function(N,x){let R=q(N,x);return Object.assign(Object.create(null),{StructType:x,create:$=>{let B=R();return r.pokePtr($,B.pointer),B},get:$=>R($),unget:$=>R($,!0),dispose:$=>R($,!0)?.dispose?.()})};m.xVtab=V("xVtab",s.sqlite3_vtab),m.xCursor=V("xCursor",s.sqlite3_vtab_cursor),m.xIndexInfo=N=>new s.sqlite3_index_info(N),m.xError=function N(x,R,$){if(N.errorReporter instanceof Function)try{N.errorReporter("sqlite3_module::"+x+"(): "+R.message)}catch{}let B;return R instanceof o.WasmAllocError?B=s.SQLITE_NOMEM:arguments.length>2?B=$:R instanceof o.SQLite3Error&&(B=R.resultCode),B||s.SQLITE_ERROR},m.xError.errorReporter=o.config.error.bind(o.config),m.xRowid=(N,x)=>r.poke(N,x,"i64"),m.setupModule=function(N){let x=!1,R=this instanceof s.sqlite3_module?this:N.struct||(x=new s.sqlite3_module);try{let $=N.methods||a("Missing 'methods' object.");for(let B of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){let J=B[0],E=B[1];$[J]===!0?$[J]=$[E]:$[E]===!0&&($[E]=$[J])}if(N.catchExceptions){let B=function(w,W){return["xConnect","xCreate"].indexOf(w)>=0?function(ee,O,z,le,h,A){try{return W(...arguments)||0}catch(U){return U instanceof o.WasmAllocError||(r.dealloc(r.peekPtr(A)),r.pokePtr(A,r.allocCString(U.message))),m.xError(w,U)}}:function(...ee){try{return W(...ee)||0}catch(O){return m.xError(w,O)}}},J=["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 w of J){let W=$[w];if(W instanceof Function)w==="xConnect"&&$.xCreate===W?E[w]=$.xCreate:w==="xCreate"&&$.xConnect===W?E[w]=$.xConnect:E[w]=B(w,W);else continue}R.installMethods(E,!1)}else R.installMethods($,!!N.applyArgcCheck);if(R.$iVersion===0){let B;typeof N.iVersion=="number"?B=N.iVersion:R.$xIntegrity?B=4:R.$xShadowName?B=3:R.$xSavePoint||R.$xRelease||R.$xRollbackTo?B=2:B=1,R.$iVersion=B}}catch($){throw x&&x.dispose(),$}return R},s.sqlite3_module.prototype.setupModule=function(N){return m.setupModule.call(this,N)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(o.config.disable?.vfs?.kvvfs)return;let r=o.capi,s=r.sqlite3_kvvfs_methods,a=r.KVVfsFile,m=o.capi.sqlite3_vfs_find("kvvfs");if(delete r.sqlite3_kvvfs_methods,delete r.KVVfsFile,!m)return;let d=o.util,q=o.wasm,V=d.toss3,N=new s(q.exports.sqlite3__wasm_kvvfs_methods());d.assert(32<=N.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+N.$nKeySize);let x=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:q.allocCString("jrnl"),zKeySz:q.allocCString("sz"),keySize:N.$nKeySize,buffer:Object.assign(Object.create(null),{n:N.$nBufferSize,pool:Object.create(null)})});x.memBuffer=(F=0)=>x.buffer.pool[F]??=q.alloc(x.buffer.n),x.memBufferFree=F=>{let G=x.buffer.pool[F];G&&(q.dealloc(G),delete x.buffer.pool[F])};let R=()=>{},$=o.__isUnderTest?(...F)=>o.config.debug?.("kvvfs:",...F):R,B=(...F)=>o.config.warn?.("kvvfs:",...F),J=(...F)=>o.config.error?.("kvvfs:",...F);class E{#e=Object.create(null);#t=null;#s=0;constructor(){this.clear()}#n(){return this.#t??=Object.keys(this.#e)}key(G){return G<0||G>=this.#s?null:this.#n()[G]}getItem(G){return this.#e[G]??null}setItem(G,oe){G in this.#e||(++this.#s,this.#t=null),this.#e[G]=""+oe}removeItem(G){G in this.#e&&(delete this.#e[G],--this.#s,this.#t=null)}clear(){this.#e=Object.create(null),this.#t=null,this.#s=0}get length(){return this.#s}}let w=F=>F==="local"||F==="session",W=F=>w(F)?"kvvfs-"+F+"-":"",ee=function(F,G=!1){if(w(F))return;let oe=new Blob([F]).size;oe||V(r.SQLITE_MISUSE,"Empty name is not permitted.");let ae=x.keySize-1;x.rxJournalSuffix.test(F)?G||V(r.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix."):["-wal","-shm"].filter(ve=>F.endsWith(ve)).length?V(r.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix."):ae-=8,oe>ae&&V(r.SQLITE_RANGE,"Storage name is too long. Limit =",ae);let Se=0;for(;Se<oe;++Se){let ve=F.codePointAt(Se);ve<32&&V(r.SQLITE_RANGE,"Illegal character ("+ve+"d) in storage name:",F)}},O=(F,G=void 0)=>Object.assign(Object.create(null),{jzClass:F,refc:1,deleteAtRefc0:!1,storage:G||new E,keyPrefix:W(F),files:[],listeners:void 0}),z=o.kvvfs=Object.create(null);o.__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 le=function(F){let G=x.rxJournalSuffix.test(F.jzClass)?F.jzClass.replace(x.rxJournalSuffix,""):F.jzClass+"-journal";z?.log?.xClose&&$("cleaning up storage handles [",F.jzClass,G,"]",F),delete x.storagePool[F.jzClass],delete x.storagePool[G],o.__isUnderTest||(delete F.storage,delete F.refc)},h=F=>x.storagePool[F.jzClass]=x.storagePool[F.jzClass+"-journal"]=F,A=".";x.storagePool=Object.assign(Object.create(null),{[A]:O(A)}),globalThis.Storage&&(globalThis.localStorage instanceof globalThis.Storage&&(x.storagePool.local=O("local",globalThis.localStorage)),globalThis.sessionStorage instanceof globalThis.Storage&&(x.storagePool.session=O("session",globalThis.sessionStorage))),x.builtinStorageNames=Object.keys(x.storagePool);let U=F=>x.builtinStorageNames.indexOf(F)>-1;for(let F of Object.keys(x.storagePool)){let G=x.storagePool[F];x.storagePool[F+"-journal"]=G}x.setError=(F=void 0,G=r.SQLITE_ERROR)=>F?(x.lastError=F,F.resultCode|0||G):(delete x.lastError,0),x.popError=()=>{let F=x.lastError;return delete x.lastError,F};let X=F=>{B("kvvfs.listener handler threw:",F)},L=q.exports.sqlite3__wasm_kvvfs_decode,fe=q.exports.sqlite3__wasm_kvvfs_encode,de=async function(F,G,...oe){try{G.keyPrefix&&oe[0]&&(oe[0]=oe[0].replace(G.keyPrefix,""));let ae,Se,ve,Ee;for(let qe of G.listeners){let Me=Object.create(null);Me.storageName=G.jzClass,Me.type=F,qe.decodePages;let He=qe.events[F];if(He){if(!qe.includeJournal&&oe[0]==="jrnl")continue;if(F==="write"&&qe.decodePages&&+oe[0]>0){if(Me.data=[oe[0]],Ee?.[oe[0]]){Me.data[1]=Ee[oe[0]];continue}ae??=new TextEncoder("utf-8"),Se??=x.memBuffer(10),ve??=x.memBuffer(11);let $e=ae.encode(oe[1]),Ue=q.heap8u();Ue.set($e,Number(Se)),Ue[q.ptr.addn(Se,$e.length)]=0;let Ke=L(Se,ve,x.buffer.n);if(Ke>0)Ee??=Object.create(null),Ee[oe[0]]=Me.data[1]=Ue.slice(Number(ve),q.ptr.addn(ve,Ke));else continue}else Me.data=oe.length?oe.length===1?oe[0]:oe:void 0;try{He(Me)?.catch?.(X)}catch($e){B("notifyListeners [",G.jzClass,"]",F,$e)}}}}catch(ae){X(ae)}},me=F=>typeof F=="string"?x.storagePool[F]:x.storagePool[q.cstrToJs(F)],S=q.exports.sqlite3__wasm_kvvfsMakeKey,C=(F,G,oe)=>G&&F.keyPrefix?S(G,oe):oe,u=(F,G,oe)=>q.cstrToJs(C(F,G,oe)),_=F=>+F.storage.getItem(F.keyPrefix+"sz"),y=new Map,Q={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},K=new r.sqlite3_vfs(N.$pVfs),M=new r.sqlite3_io_methods(N.$pIoDb),b=new r.sqlite3_io_methods(N.$pIoJrnl),D=Object.create(null),te=Object.assign(Object.create(null),{pFileHandles:y,cache:x,storageForZClass:me,KVVfsStorage:E,disablePageSizeChange:!0});z.log&&(z.internal=te);let Z={recordHandler:{xRcrdRead:(F,G,oe,ae)=>{try{let Se=q.cstrToJs(F),ve=me(Se);if(!ve)return-1;let Ee=u(ve,F,G);z?.log?.xRcrdRead&&B("xRcrdRead",Se,Ee,ae,ve);let qe=ve.storage.getItem(Ee);if(qe===null)return-1;let Me=qe.length;if(ae<=0)return Me;if(ae===1)return q.poke(oe,0),Me;ae+1<Me&&V(r.SQLITE_RANGE,"xRcrdRead()",Se,Ee,"input buffer is too small: need",Me,"but have",ae);let He=x.memBuffer(0),$e=q.heap8(),Ue=0;for(;Ue<Me;++Ue)$e[q.ptr.add(He,Ue)]=qe.codePointAt(Ue)&255;return $e.copyWithin(Number(oe),Number(He),q.ptr.addn(He,Ue)),$e[q.ptr.add(oe,Me)]=0,ae}catch(Se){return J("kvrecordRead()",Se),x.setError(Se),-2}},xRcrdWrite:(F,G,oe)=>{try{let ae=me(F),Se=u(ae,F,G),ve=q.cstrToJs(oe);return z?.log?.xRcrdWrite&&B("xRcrdWrite",Se,ae),ae.storage.setItem(Se,ve),ae.listeners&&de("write",ae,Se,ve),0}catch(ae){return J("kvrecordWrite()",ae),x.setError(ae,r.SQLITE_IOERR)}},xRcrdDelete:(F,G)=>{try{let oe=me(F),ae=u(oe,F,G);return z?.log?.xRcrdDelete&&B("xRcrdDelete",ae,oe),oe.storage.removeItem(ae),oe.listeners&&de("delete",oe,ae),0}catch(oe){return J("kvrecordDelete()",oe),x.setError(oe,r.SQLITE_IOERR)}}},vfs:{xOpen:function(F,G,oe,ae,Se){x.popError();let ve;try{G||(ve=q.allocCString(""+oe+"."+(Math.random()*1e5|0)),G=ve);let Ee=q.cstrToJs(G);z?.log?.xOpen&&$("xOpen",Ee,"flags =",ae),ee(Ee,!0),ae&(r.SQLITE_OPEN_MAIN_DB|r.SQLITE_OPEN_TEMP_DB|r.SQLITE_OPEN_TRANSIENT_DB)&&x.rxJournalSuffix.test(Ee)&&V(r.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let qe=me(Ee);!qe&&!(ae&r.SQLITE_OPEN_CREATE)&&V(r.SQLITE_ERROR,"Storage not found:",Ee);let Me=Q.vfs.xOpen(F,G,oe,ae,Se);if(Me)return Me;let He=!!(r.SQLITE_OPEN_DELETEONCLOSE&ae);q.isPtr(arguments[1])&&r.sqlite3_uri_boolean(G,"delete-on-close",0)&&(He=!0);let $e=new a(oe);if(d.assert($e.$zClass,"Missing f.$zClass"),$e.addOnDispose(ve),ve=void 0,qe)++qe.refc,qe.files.push($e),q.poke32(Se,ae);else{q.poke32(Se,ae|r.SQLITE_OPEN_CREATE),d.assert(!$e.$isJournal,"Opening a journal before its db? "+Ee);let Ue=Ee.replace(x.rxJournalSuffix,"");qe=O(Ue),h(qe),qe.files.push($e),qe.deleteAtRefc0=He,z?.log?.xOpen&&$("xOpen installed storage handle [",Ue,Ue+"-journal","]",qe)}return y.set(oe,{store:qe,file:$e,jzClass:Ee}),qe.listeners&&de("open",qe,qe.files.length),0}catch(Ee){return B("xOpen:",Ee),x.setError(Ee)}finally{ve&&q.dealloc(ve)}},xDelete:function(F,G,oe){x.popError();try{let ae=q.cstrToJs(G);return x.rxJournalSuffix.test(ae)&&D.xRcrdDelete(G,x.zKeyJrnl),0}catch(ae){return B("xDelete",ae),x.setError(ae)}},xAccess:function(F,G,oe,ae){x.popError();try{let Se=me(G),ve=Se?.jzClass||q.cstrToJs(G);if(z?.log?.xAccess&&$("xAccess",ve,"flags =",oe,"*pResOut =",q.peek32(ae),"store =",Se),!Se)try{ee(ve)}catch{return q.poke32(ae,0),0}if(Se){let Ee=Se.keyPrefix+(x.rxJournalSuffix.test(ve)?"jrnl":"1"),qe=Se.storage.getItem(Ee)?0:1;q.poke32(ae,qe)}else q.poke32(ae,0);return 0}catch(Se){return J("xAccess",Se),x.setError(Se)}},xRandomness:function(F,G,oe){let ae=q.heap8u(),Se=0,ve=Number(oe);for(;Se<G;++Se)ae[ve+Se]=Math.random()*255e3&255;return G},xGetLastError:function(F,G,oe){let ae=x.popError();if($("xGetLastError",ae),ae){let Se=q.scopedAllocPush();try{let[ve,Ee]=q.scopedAllocCString(ae.message,!0);return q.cstrncpy(oe,ve,G),Ee>G&&q.poke8(q.ptr.add(oe,G,-1),0),$("set xGetLastError",ae.message),ae.resultCode|0||r.SQLITE_IOERR}catch{return r.SQLITE_NOMEM}finally{q.scopedAllocPop(Se)}}return 0}},ioDb:{xClose:function(F){x.popError();try{let G=y.get(F);if(z?.log?.xClose&&$("xClose",F,G),G){y.delete(F);let oe=G.store;oe.files=oe.files.filter(ae=>ae!==G.file),--oe.refc<=0&&oe.deleteAtRefc0&&le(oe),Q.ioDb.xClose(F),G.file.dispose(),oe.listeners&&de("close",oe,oe.files.length)}return 0}catch(G){return J("xClose",G),x.setError(G)}},xFileControl:function(F,G,oe){x.popError();try{let ae=y.get(F);if(d.assert(ae,"Missing KVVfsFile handle"),z?.log?.xFileControl&&$("xFileControl",ae,"op =",G),G===r.SQLITE_FCNTL_PRAGMA&&te.disablePageSizeChange){let ve=q.peekPtr(q.ptr.add(oe,q.ptr.size));if(q.cstrToJs(ve)==="page_size"){z?.log?.xFileControl&&$("xFileControl pragma",q.cstrToJs(ve));let Ee=q.peekPtr(q.ptr.add(oe,2*q.ptr.size));if(Ee)return z?.log?.xFileControl&&B("xFileControl pragma",ae,"NOT setting page size to",q.cstrToJs(Ee)),ae.file.$szPage=-1,0;if(ae.file.$szPage>0)return z?.log?.xFileControl&&B("xFileControl",ae,"getting page size",ae.file.$szPage),q.pokePtr(oe,q.allocCString(""+ae.file.$szPage)),0}}let Se=Q.ioDb.xFileControl(F,G,oe);return Se==0&&r.SQLITE_FCNTL_SYNC===G&&ae.store.listeners&&de("sync",ae.store,!1),Se}catch(ae){return J("xFileControl",ae),x.setError(ae)}},xSync:function(F,G){x.popError();try{let oe=y.get(F);z?.log?.xSync&&$("xSync",oe),d.assert(oe,"Missing KVVfsFile handle");let ae=Q.ioDb.xSync(F,G);return ae==0&&oe.store.listeners&&de("sync",oe.store,!0),ae}catch(oe){return J("xSync",oe),x.setError(oe)}}},ioJrnl:{xClose:!0}};try{d.assert(x.buffer.n>132096,"Heap buffer is not large enough");for(let F of Object.entries(Z.recordHandler)){let G=F[0],oe=F[1];D[G]=oe,N[N.memberKey(G)]=q.installFunction(N.memberSignature(G),oe)}for(let F of Object.entries(Z.vfs)){let G=F[0],oe=F[1],ae=K.memberKey(G),Se=K.structInfo.members[G]||d.toss("Missing pVfs.structInfo[",G,"]");Q.vfs[G]=q.functionEntry(K[ae]),K[ae]=q.installFunction(Se.signature,oe)}for(let F of Object.entries(Z.ioDb)){let G=F[0],oe=F[1],ae=M.memberKey(G);Q.ioDb[G]=q.functionEntry(M[ae])||d.toss("Missing native pIoDb[",ae,"]"),M[ae]=q.installFunction(M.memberSignature(G),oe)}for(let F of Object.entries(Z.ioJrnl)){let G=F[0],oe=F[1],ae=b.memberKey(G);Q.ioJrnl[G]=q.functionEntry(b[ae])||d.toss("Missing native pIoJrnl[",ae,"]"),oe===!0?b[ae]=M[ae]||d.toss("Missing copied pIoDb[",ae,"]"):b[ae]=q.installFunction(b.memberSignature(G),oe)}}finally{N.dispose(),K.dispose(),M.dispose(),b.dispose()}let we=function F(G){if(G==="")return F("local")+F("session");let oe=me(G);if(!oe)return 0;oe.files.length&&(globalThis.localStorage===oe.storage||globalThis.sessionStorage===oe.storage||V(r.SQLITE_ACCESS,"Cannot clear in-use database storage."));let ae=oe.storage,Se=[],ve,Ee=ae.length;for(ve=0;ve<Ee;++ve){let qe=ae.key(ve);(!oe.keyPrefix||qe.startsWith(oe.keyPrefix))&&Se.push(qe)}return Se.forEach(qe=>ae.removeItem(qe)),Se.length},he=function F(G){if(G==="")return F("local")+F("session");let oe=me(G);if(!oe)return 0;let ae=oe.storage,Se,ve=0;for(Se=0;Se<ae.length;++Se){let Ee=ae.key(Se);(!oe.keyPrefix||Ee.startsWith(oe.keyPrefix))&&(ve+=Ee.length,ve+=ae.getItem(Ee).length)}return ve*2},ke=function(...G){let oe;G.length===1&&typeof G[0]=="object"?oe=G[0]:G.length&&(oe=Object.assign(Object.create(null),{name:G[0]}));let ae=oe?me(oe.name):null;ae||V(r.SQLITE_NOTFOUND,"There is no kvvfs storage named",oe?.name);let Se=ae.storage,ve=Object.assign(Object.create(null),{name:ae.jzClass,timestamp:Date.now(),pages:[]}),Ee=Object.create(null),qe=ae.keyPrefix,Me=qe?/^kvvfs-[^-]+-(\w+)/:void 0,He=0,$e=Se.length;for(;He<$e;++He){let Ue=Se.key(He);if(!qe||Ue.startsWith(qe)){let Ke=(qe?Me.exec(Ue):void 0)?.[1]??Ue;switch(Ke){case"jrnl":oe.includeJournal&&(ve.journal=Se.getItem(Ue));break;case"sz":ve.size=+Se.getItem(Ue);break;default:if(Ke=+Ke,(!d.isInt32(Ke)||Ke<=0)&&V(r.SQLITE_RANGE,"Malformed kvvfs key: "+Ue),oe.decodePages){let gt=Se.getItem(Ue),Tt=gt.length,zt=x.memBuffer(0),Dt=x.memBuffer(1),tn=q.heap8u(),lt=0;for(;lt<Tt;++lt)tn[q.ptr.add(zt,lt)]=gt.codePointAt(lt)&255;tn[q.ptr.add(zt,lt)]=0;let pn=L(zt,Dt,x.buffer.n);Ee[Ke]=tn.slice(Number(Dt),q.ptr.addn(Dt,pn))}else Ee[Ke]=Se.getItem(Ue)}}}return oe.decodePages&&x.memBufferFree(1),Object.keys(Ee).map(Ue=>+Ue).sort().forEach(Ue=>ve.pages.push(Ee[Ue])),ve},Be=function(F,G=!1){!F?.timestamp||!F.name||F.size===void 0||!Array.isArray(F.pages)?V(r.SQLITE_MISUSE,"Malformed export object."):(!F.size||F.size!==(F.size|0)||F.size>=2147483647)&&V(r.SQLITE_RANGE,"Invalid db size: "+F.size),ee(F.name);let oe=me(F.name),ae=!oe;oe?(G?!oe.files||!oe.jzClass?V(r.SQLITE_ERROR,"Internal storage object",F.name,"seems to be malformed."):oe.files.length&&V(r.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use."):V(r.SQLITE_ACCESS,"Storage '"+F.name+"' already exists and","overwrite was not specified."),we(F.name)):oe=O(F.name);let Se=W(F.name),ve;try{let Ee=oe.storage;Ee.setItem(Se+"sz",F.size),F.journal&&Ee.setItem(Se+"jrnl",F.journal),F.pages[0]instanceof Uint8Array?F.pages.forEach((qe,Me)=>{let He=qe.length;ve??=x.memBuffer(1);let $e=x.memBuffer(0),Ue=q.heap8u();Ue.set(qe,Number($e)),Ue[q.ptr.addn($e,He)]=0;let Ke=fe($e,He,ve);d.assert(Ke<x.buffer.n,"Impossibly long output - possibly smashed the heap"),d.assert(q.peek8(q.ptr.add(ve,Ke))===0,"Expecting NUL-terminated encoded output");let gt=q.cstrToJs(ve);Ee.setItem(Se+(Me+1),gt)}):F.pages[0]&&F.pages.forEach((qe,Me)=>Ee.setItem(Se+(Me+1),qe)),ae&&h(oe)}catch{if(!ae)try{we(F.name)}catch{}}finally{ve&&x.memBufferFree(1)}return this},Ze=function(F){let G=me(F);if(G){++G.refc;return}ee(F),h(O(F))},at=function(F){let G=me(F);return!G||w(G.jzClass)||U(G.jzClass)||x.rxJournalSuffix.test(F)?!1:G.refc>G.files.length||G.files.length===0?(--G.refc<=0&&le(G),!0):!1},Ct=function(F){(!F||typeof F!="object")&&V(r.SQLITE_MISUSE,"Expecting a listener object.");let G=me(F.storage);G||(F.storage&&F.reserve?(Ze(F.storage),G=me(F.storage),d.assert(G,"Unexpectedly cannot fetch reserved storage "+F.storage)):V(r.SQLITE_NOTFOUND,"No such storage:",F.storage)),F.events&&(G.listeners??=[]).push(F)},mn=function(F){let G=me(F?.storage);if(G?.listeners&&F.events){let oe=G.listeners.length;G.listeners=G.listeners.filter(Se=>Se!==F);let ae=oe>G.listeners.length;return G.listeners.length||(G.listeners=void 0),ae}return!1};if(o.kvvfs.reserve=Ze,o.kvvfs.import=Be,o.kvvfs.export=ke,o.kvvfs.unlink=at,o.kvvfs.listen=Ct,o.kvvfs.unlisten=mn,o.kvvfs.exists=F=>!!me(F),o.kvvfs.estimateSize=he,o.kvvfs.clear=we,globalThis.Storage&&(r.sqlite3_js_kvvfs_size=(F="")=>he(F),r.sqlite3_js_kvvfs_clear=(F="")=>we(F)),o.oo1?.DB){let F=o.oo1.DB;o.oo1.JsStorageDb=function(oe=o.oo1.JsStorageDb.defaultStorageName){let ae=F.dbCtorHelper.normalizeArgs(...arguments);switch(ae.vfs="kvvfs",ae.filename){case":sessionStorage:":ae.filename="session";break;case":localStorage:":ae.filename="local"}let Se=/(file:(\/\/)?)([^?]+)/.exec(ae.filename);ee(Se?Se[3]:ae.filename),F.dbCtorHelper.call(this,ae)},o.oo1.JsStorageDb.defaultStorageName=x.storagePool.session?"session":A;let G=o.oo1.JsStorageDb;G.prototype=Object.create(F.prototype),G.clearStorage=we,G.prototype.clearStorage=function(){return G.clearStorage(this.affirmOpen().dbFilename(),!0)},G.storageSize=he,G.prototype.storageSize=function(){return G.storageSize(this.affirmOpen().dbFilename(),!0)}}if(o.__isUnderTest&&o.vtab){let F=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(F).forEach((ve,Ee)=>F[ve].colId=Ee);let G=o.vtab,oe=Object.assign(Object.create(null),{row:function(){return x.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(oe),{rowid:0,names:Object.keys(x.storagePool).filter(ve=>!x.rxJournalSuffix.test(ve))});let ae=function(ve,Ee){let qe=ve instanceof r.sqlite3_vtab_cursor?ve:G.xCursor.get(ve);return(Ee||!qe.vTabState)&&(qe.vTabState=Object.assign(Object.create(oe),{rowid:0,names:Object.keys(x.storagePool).filter(Me=>!x.rxJournalSuffix.test(Me))})),qe.vTabState},Se=function ve(){return ve.mod??=new o.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(Ee,qe,Me,He,$e,Ue){try{let Ke=[];Object.keys(F).forEach(Tt=>{Ke.push(Tt+" "+F[Tt].type)});let gt=r.sqlite3_declare_vtab(Ee,"CREATE TABLE ignored("+Ke.join(",")+")");if(gt===0){let Tt=G.xVtab.create($e);d.assert(Tt===G.xVtab.get(q.peekPtr($e)),"output pointer check failed")}return gt}catch(Ke){return G.xError("xConnect",Ke,r.SQLITE_ERROR)}},xCreate:q.ptr.null,xDisconnect:function(Ee){return G.xVtab.dispose(Ee),0},xOpen:function(Ee,qe){return G.xCursor.create(qe),0},xClose:function(Ee){let qe=G.xCursor.unget(Ee);return delete qe.vTabState,qe.dispose(),0},xNext:function(Ee){let qe=G.xCursor.get(Ee);return++ae(qe).rowid,0},xColumn:function(Ee,qe,Me){let He=ae(Ee),$e=He.row();switch(d.assert($e,"Unexpected xColumn call"),Me){case F.rowid.colId:r.sqlite3_result_int(qe,He.rowid);break;case F.name.colId:r.sqlite3_result_text(qe,$e.jzClass,-1,r.SQLITE_TRANSIENT);break;case F.nRef.colId:r.sqlite3_result_int(qe,$e.refc);break;case F.nOpen.colId:r.sqlite3_result_int(qe,$e.files.length);break;case F.isTransient.colId:r.sqlite3_result_int(qe,!!$e.deleteAtRefc0);break;case F.dbSize.colId:r.sqlite3_result_int(qe,_($e));break;default:return r.sqlite3_result_error(qe,"Invalid column id: "+Me),r.SQLITE_RANGE}return 0},xRowid:function(Ee,qe){let Me=ae(Ee);return G.xRowid(qe,Me.rowid),0},xEof:function(Ee){let qe=ae(Ee);return""+!qe.row(),!qe.row()},xFilter:function(Ee,qe,Me,He,$e){return ae(Ee,!0),0},xBestIndex:function(Ee,qe){let Me=new r.sqlite3_index_info(qe);return Me.$estimatedRows=x.storagePool.size,Me.$estimatedCost=1,Me.dispose(),0}}})};o.kvvfs.create_module=function(ve,Ee="sqlite_kvvfs"){return r.sqlite3_create_module(ve,Ee,Se(),q.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){"use strict";if(o.config.disable?.vfs?.opfs&&o.config.disable.vfs["opfs-vfs"])return;let r=o.util.toss;o.capi;let s=o.util;o.wasm;let a=o.opfs=Object.create(null);a.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,a.getRootDir=async function d(){return d.promise??=navigator.storage.getDirectory().then(q=>(a.rootDirectory=q,q)).catch(q=>{throw delete d.promise,q})},a.getResolvedPath=function(d,q){let V=new URL(d,"file://irrelevant").pathname;return q?V.split("/").filter(N=>!!N):V},a.getDirForFilename=async function(q,V=!1){let N=a.getResolvedPath(q,!0),x=N.pop(),R=await a.getRootDir();for(let $ of N)$&&(R=await R.getDirectoryHandle($,{create:!!V}));return[R,x]},a.mkdir=async function(d){try{return await a.getDirForFilename(d+"/filepart",!0),!0}catch{return!1}},a.entryExists=async function(d){try{let[q,V]=await a.getDirForFilename(d);return await q.getFileHandle(V),!0}catch{return!1}},a.randomFilename=function d(q=16){d._chars||(d._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",d._n=d._chars.length);let V=[],N=0;for(;N<q;++N){let x=Math.random()*(d._n*64)%d._n|0;V[N]=d._chars[x]}return V.join("")},a.treeList=async function(){let d=async function V(N,x){x.name=N.name,x.dirs=[],x.files=[];for await(let R of N.values())if(R.kind==="directory"){let $=Object.create(null);x.dirs.push($),await V(R,$)}else x.files.push(R.name)},q=Object.create(null);return await d(await a.getRootDir(),q),q},a.rmfr=async function(){let d=await a.getRootDir(),q={recurse:!0};for await(let V of d.values())d.removeEntry(V.name,q)},a.unlink=async function(d,q=!1,V=!1){try{let[N,x]=await a.getDirForFilename(d,!1);return await N.removeEntry(x,{recursive:q}),!0}catch(N){if(V)throw new Error("unlink(",arguments[0],") failed: "+N.message,{cause:N});return!1}},a.traverse=async function(d){let q={recursive:!0,directory:await a.getRootDir()};typeof d=="function"&&(d={callback:d}),d=Object.assign(q,d||{}),(async function V(N,x){for await(let R of N.values()){if(d.callback(R,N,x)===!1)return!1;if(d.recursive&&R.kind==="directory"&&await V(R,x+1)===!1)break}})(d.directory,0)};let m=async function(d,q){let[V,N]=await a.getDirForFilename(d,!0),x=await(await V.getFileHandle(N,{create:!0})).createSyncAccessHandle(),R=0,$,B=!1;try{for(x.truncate(0);($=await q())!==void 0;)$ instanceof ArrayBuffer&&($=new Uint8Array($)),!B&&R===0&&$.byteLength>=15&&(s.affirmDbHeader($),B=!0),x.write($,{at:R}),R+=$.byteLength;if((R<512||R%512!==0)&&r("Input size",R,"is not correct for an SQLite database."),!B){let J=new Uint8Array(20);x.read(J,{at:0}),s.affirmDbHeader(J)}return x.write(new Uint8Array([1,1]),{at:18}),R}catch(J){throw await x.close(),x=void 0,await V.removeEntry(N).catch(()=>{}),J}finally{x&&await x.close()}};a.importDb=async function(d,q){if(q instanceof Function)return m(d,q);q instanceof ArrayBuffer&&(q=new Uint8Array(q)),s.affirmIsDb(q);let V=q.byteLength,[N,x]=await a.getDirForFilename(d,!0),R,$=0;try{return R=await(await N.getFileHandle(x,{create:!0})).createSyncAccessHandle(),R.truncate(0),$=R.write(q,{at:0}),$!=V&&r("Expected to write "+V+" bytes but wrote "+$+"."),R.write(new Uint8Array([1,1]),{at:18}),$}catch(B){throw R&&(await R.close(),R=void 0),await N.removeEntry(x).catch(()=>{}),B}finally{R&&await R.close()}},a.vfsInstallationFeatureCheck=function(d){!globalThis.SharedArrayBuffer||!globalThis.Atomics?r("Cannot install OPFS: Missing SharedArrayBuffer and/or Atomics.","The server must emit the COOP/COEP response headers to enable those.","See https://sqlite.org/wasm/doc/trunk/persistence.md#coop-coep"):typeof WorkerGlobalScope>"u"?r("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait()."):!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory?r("Missing required OPFS APIs."):d==="opfs-wl"&&!globalThis.Atomics.waitAsync&&r("The",d,"VFS requires Atomics.waitAsync(), which is not available.")},a.initOptions=function(q,V){let N=new URL(globalThis.location.href).searchParams;if(!N.has(q+"-disable")){try{a.vfsInstallationFeatureCheck(q)}catch{return}return V=s.nu(V),V.vfsName=q,V.verbose??=N.has("opfs-verbose")?+N.get("opfs-verbose"):1,V.sanityChecks??=N.has("opfs-sanity-check"),a.proxyUri||(a.proxyUri="sqlite3-opfs-async-proxy.js",o.scriptInfo?.sqlite3Dir&&(a.proxyUri=o.scriptInfo.sqlite3Dir+a.proxyUri)),V.proxyUri??=a.proxyUri,typeof V.proxyUri=="function"&&(V.proxyUri=V.proxyUri()),a.options=V}},a.createVfsState=function(){let d=s.nu(),q=a.options;d.verbose=q.verbose;let V=[o.config.error,o.config.warn,o.config.log],N=q.vfsName||r("Maintenance required: missing VFS name"),x=(L,...fe)=>{d.verbose>L&&V[L](N+":",...fe)},R=(...L)=>x(2,...L),$=(...L)=>x(1,...L),B=(...L)=>x(0,...L),J=o.capi,E=o.wasm,w=d.vfs=new J.sqlite3_vfs,W=w.ioMethods=new J.sqlite3_io_methods;W.$iVersion=1,w.$iVersion=2,w.$szOsFile=J.sqlite3_file.structInfo.sizeof,w.$mxPathname=1024,w.$zName=E.allocCString(N),w.addOnDispose("$zName",w.$zName,W),w.metrics=s.nu({counters:s.nu(),dump:function(){let L,fe=0,de=0,me=0;for(L in d.opIds){let S=ee[L];fe+=S.count,de+=S.time,me+=S.wait,S.avgTime=S.count&&S.time?S.time/S.count:0,S.avgWait=S.count&&S.wait?S.wait/S.count:0}o.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",ee,`
|
|
9
|
-
Total of`,fe,"op(s) for",de,"ms (incl. "+me+" ms of waiting on the async side)"),o.config.log("Serialization metrics:",w.metrics.counters.s11n),w.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let L,fe=S=>S.count=S.time=S.wait=0,de=w.metrics.counters;for(L in d.opIds)fe(de[L]=Object.create(null));let me=de.s11n=Object.create(null);me=me.serialize=Object.create(null),me.count=me.time=0,me=de.s11n.deserialize=Object.create(null),me.count=me.time=0}}),d.asyncIdleWaitTime=150,d.asyncS11nExceptions=1,d.fileBufferSize=65536,d.sabS11nOffset=d.fileBufferSize,d.sabS11nSize=w.$mxPathname*2,d.sabIO=new SharedArrayBuffer(d.fileBufferSize+d.sabS11nSize),d.opIds=Object.create(null);{let L=0;d.opIds.whichOp=L++,d.opIds.rc=L++,d.opIds.xAccess=L++,d.opIds.xClose=L++,d.opIds.xDelete=L++,d.opIds.xDeleteNoWait=L++,d.opIds.xFileSize=L++,d.opIds.xLock=L++,d.opIds.xOpen=L++,d.opIds.xRead=L++,d.opIds.xSleep=L++,d.opIds.xSync=L++,d.opIds.xTruncate=L++,d.opIds.xUnlock=L++,d.opIds.xWrite=L++,d.opIds.mkdir=L++,d.opIds["opfs-async-metrics"]=L++,d.opIds["opfs-async-shutdown"]=L++,d.opIds.retry=L++,d.sabOP=new SharedArrayBuffer(L*4)}d.sq3Codes=Object.create(null);for(let L 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"])d.sq3Codes[L]=J[L]??r("Maintenance required: not found:",L);d.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),w.metrics.reset();let ee=w.metrics.counters,O=w.opRun=(L,...fe)=>{let de=d.opIds[L]||r(w.vfsName+": Invalid op ID:",L);d.s11n.serialize(...fe),Atomics.store(d.sabOPView,d.opIds.rc,-1),Atomics.store(d.sabOPView,d.opIds.whichOp,de),Atomics.notify(d.sabOPView,d.opIds.whichOp);let me=performance.now();for(;Atomics.wait(d.sabOPView,d.opIds.rc,-1)!=="not-equal";);let S=Atomics.load(d.sabOPView,d.opIds.rc);if(ee[L].wait+=performance.now()-me,S&&d.asyncS11nExceptions){let C=d.s11n.deserialize();C&&B(L+"() async error:",...C)}return S},z=Object.create(null);z.op=void 0,z.start=void 0;let le=w.mTimeStart=L=>{z.start=performance.now(),z.op=L,++ee[L].count},h=w.mTimeEnd=()=>ee[z.op].time+=performance.now()-z.start,A=w.__openFiles=Object.create(null);w.ioSyncWrappers=s.nu({xCheckReservedLock:function(L,fe){return E.poke(fe,0,"i32"),0},xClose:function(L){le("xClose");let fe=0,de=A[L];return de&&(delete A[L],fe=O("xClose",L),de.sq3File&&de.sq3File.dispose()),h(),fe},xDeviceCharacteristics:function(L){return J.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(L,fe,de){return J.SQLITE_NOTFOUND},xFileSize:function(L,fe){le("xFileSize");let de=O("xFileSize",L);if(de==0)try{let me=d.s11n.deserialize()[0];E.poke(fe,me,"i64")}catch(me){B("Unexpected error reading xFileSize() result:",me),de=d.sq3Codes.SQLITE_IOERR}return h(),de},xRead:function(L,fe,de,me){le("xRead");let S=A[L],C;try{C=O("xRead",L,de,Number(me)),(C===0||J.SQLITE_IOERR_SHORT_READ===C)&&E.heap8u().set(S.sabView.subarray(0,de),Number(fe))}catch(u){B("xRead(",arguments,") failed:",u,S),C=J.SQLITE_IOERR_READ}return h(),C},xSync:function(L,fe){le("xSync");let de=O("xSync",L,fe);return h(),de},xTruncate:function(L,fe){le("xTruncate");let de=O("xTruncate",L,Number(fe));return h(),de},xWrite:function(L,fe,de,me){le("xWrite");let S=A[L],C;try{S.sabView.set(E.heap8u().subarray(Number(fe),Number(fe)+de)),C=O("xWrite",L,de,Number(me))}catch(u){B("xWrite(",arguments,") failed:",u,S),C=J.SQLITE_IOERR_WRITE}return h(),C}}),w.vfsSyncWrappers={xAccess:function(L,fe,de,me){le("xAccess");let S=O("xAccess",E.cstrToJs(fe));return E.poke(me,S?0:1,"i32"),h(),0},xCurrentTime:function(L,fe){return E.poke(fe,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(L,fe){return E.poke(fe,21086676e7+new Date().getTime(),"i64"),0},xDelete:function(L,fe,de){le("xDelete");let me=O("xDelete",E.cstrToJs(fe),de,!1);return h(),me},xFullPathname:function(L,fe,de,me){return E.cstrncpy(me,fe,de)<de?0:J.SQLITE_CANTOPEN},xGetLastError:function(L,fe,de){return o.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(fe,de,me,S,C){le("xOpen");let u=0,_,y;if(!de)_=a.randomFilename(),de=y=E.allocCString(_);else if(E.isPtr(de))J.sqlite3_uri_boolean(de,"opfs-unlock-asap",0)&&(u|=d.opfsFlags.OPFS_UNLOCK_ASAP),J.sqlite3_uri_boolean(de,"delete-before-open",0)&&(u|=d.opfsFlags.OPFS_UNLINK_BEFORE_OPEN),_=E.cstrToJs(de);else return o.config.error("Impossible zName value in xOpen?",de),J.SQLITE_CANTOPEN;let Q=s.nu({fid:me,filename:_,sab:new SharedArrayBuffer(d.fileBufferSize),flags:S,readOnly:!(J.SQLITE_OPEN_CREATE&S)&&!!(S&J.SQLITE_OPEN_READONLY)}),K=O("xOpen",me,_,S,u);return K?y&&E.dealloc(y):(Q.readOnly&&E.poke(C,J.SQLITE_OPEN_READONLY,"i32"),A[me]=Q,Q.sabView=d.sabFileBufView,Q.sq3File=new J.sqlite3_file(me),y&&Q.sq3File.addOnDispose(y),Q.sq3File.$pMethods=W.pointer,Q.lockType=J.SQLITE_LOCK_NONE),h(),K}};let U=J.sqlite3_vfs_find(null);if(U){let L=new J.sqlite3_vfs(U);w.$xRandomness=L.$xRandomness,w.$xSleep=L.$xSleep,L.dispose()}w.$xRandomness||(w.vfsSyncWrappers.xRandomness=function(L,fe,de){let me=E.heap8u(),S=0,C=Number(de);for(;S<fe;++S)me[C+S]=Math.random()*255e3&255;return S}),w.$xSleep||(w.vfsSyncWrappers.xSleep=function(L,fe){return le("xSleep"),Atomics.wait(d.sabOPView,d.opIds.xSleep,0,fe),h(),0});let X=function(){if(d.s11n)return d.s11n;let L=new TextDecoder,fe=new TextEncoder("utf-8"),de=new Uint8Array(d.sabIO,d.sabS11nOffset,d.sabS11nSize),me=new DataView(d.sabIO,d.sabS11nOffset,d.sabS11nSize);d.s11n=Object.create(null);let S=Object.create(null);S.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},S.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},S.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},S.string={id:4};let C=_=>S[typeof _]||r("Maintenance required: this value type cannot be serialized.",_),u=_=>{switch(_){case S.number.id:return S.number;case S.bigint.id:return S.bigint;case S.boolean.id:return S.boolean;case S.string.id:return S.string;default:r("Invalid type ID:",_)}};return d.s11n.deserialize=function(_=!1){performance.now();let y=de[0],Q=y?[]:null;if(y){let K=[],M=1,b,D,te;for(b=0;b<y;++b,++M)K.push(u(de[M]));for(b=0;b<y;++b){let Z=K[b];Z.getter?(te=me[Z.getter](M,d.littleEndian),M+=Z.size):(D=me.getInt32(M,d.littleEndian),M+=4,te=L.decode(de.slice(M,M+D)),M+=D),Q.push(te)}}return _&&(de[0]=0),Q},d.s11n.serialize=function(..._){if(performance.now(),_.length){let y=[],Q=0,K=1;for(de[0]=_.length&255;Q<_.length;++Q,++K)y.push(C(_[Q])),de[K]=y[Q].id;for(Q=0;Q<_.length;++Q){let M=y[Q];if(M.setter)me[M.setter](K,_[Q],d.littleEndian),K+=M.size;else{let b=fe.encode(_[Q]);me.setInt32(K,b.byteLength,d.littleEndian),K+=4,de.set(b,K),K+=b.byteLength}}}else de[0]=0},d.s11n};return w.initS11n=X,w.bindVfs=function(L,fe){return Object.assign(w.ioSyncWrappers,L),new Promise(function(de,me){let S,C=M=>(S=!0,w.dispose(),me(M)),u=()=>{try{fe(o,w)}catch(M){return C(M)}return S=!1,de(o)},_=a.options,y=w.worker=(()=>{let M=new URL("sqlite3-opfs-async-proxy.js",import.meta.url);return M.searchParams.set("vfs",N),new Worker(M.toString())})(),Q=setTimeout(()=>{S===void 0&&C(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3);y._originalOnError=y.onerror,y.onerror=function(M){B("Error initializing OPFS asyncer:",M),C(new Error("Loading OPFS async Worker failed for unknown reasons."))},w.opRun;let K=function(){let M=E.scopedAllocPush(),b=new J.sqlite3_file;try{let D=b.pointer,te=J.SQLITE_OPEN_CREATE|J.SQLITE_OPEN_READWRITE|J.SQLITE_OPEN_MAIN_DB,Z=E.scopedAlloc(8),we="/sanity/check/file"+randomFilename(8),he=E.scopedAllocCString(we),ke;if(d.s11n.serialize("This is \xE4 string."),ke=d.s11n.deserialize(),R("deserialize() says:",ke),ke[0]!=="This is \xE4 string."&&r("String d13n error."),w.vfsSyncWrappers.xAccess(w.pointer,he,0,Z),ke=E.peek(Z,"i32"),R("xAccess(",we,") exists ?=",ke),ke=w.vfsSyncWrappers.xOpen(w.pointer,he,D,te,Z),R("open rc =",ke,"state.sabOPView[xOpen] =",d.sabOPView[d.opIds.xOpen]),ke!==0){B("open failed with code",ke);return}w.vfsSyncWrappers.xAccess(w.pointer,he,0,Z),ke=E.peek(Z,"i32"),ke||r("xAccess() failed to detect file."),ke=w.ioSyncWrappers.xSync(b.pointer,0),ke&&r("sync failed w/ rc",ke),ke=w.ioSyncWrappers.xTruncate(b.pointer,1024),ke&&r("truncate failed w/ rc",ke),E.poke(Z,0,"i64"),ke=w.ioSyncWrappers.xFileSize(b.pointer,Z),ke&&r("xFileSize failed w/ rc",ke),R("xFileSize says:",E.peek(Z,"i64")),ke=w.ioSyncWrappers.xWrite(b.pointer,he,10,1),ke&&r("xWrite() failed!");let Be=E.scopedAlloc(16);ke=w.ioSyncWrappers.xRead(b.pointer,Be,6,2),E.poke(Be+6,0);let Ze=E.cstrToJs(Be);R("xRead() got:",Ze),Ze!=="sanity"&&r("Unexpected xRead() value."),w.vfsSyncWrappers.xSleep&&(R("xSleep()ing before close()ing..."),w.vfsSyncWrappers.xSleep(w.pointer,2e3),R("waking up from xSleep()")),ke=w.ioSyncWrappers.xClose(D),R("xClose rc =",ke,"sabOPView =",d.sabOPView),R("Deleting file:",we),w.vfsSyncWrappers.xDelete(w.pointer,he,4660),w.vfsSyncWrappers.xAccess(w.pointer,he,0,Z),ke=E.peek(Z,"i32"),ke&&r("Expecting 0 from xAccess(",we,") after xDelete()."),$("End of OPFS sanity checks.")}finally{b.dispose(),E.scopedAllocPop(M)}};y.onmessage=function({data:M}){switch(M.type){case"opfs-unavailable":C(new Error(M.payload.join(" ")));break;case"opfs-async-loaded":delete d.vfs,y.postMessage({type:"opfs-async-init",args:s.nu(d)});break;case"opfs-async-inited":if(S===!0)break;clearTimeout(Q),Q=null;try{o.vfs.installVfs({io:{struct:w.ioMethods,methods:w.ioSyncWrappers},vfs:{struct:w,methods:w.vfsSyncWrappers}}),d.sabOPView=new Int32Array(d.sabOP),d.sabFileBufView=new Uint8Array(d.sabIO,0,d.fileBufferSize),d.sabS11nView=new Uint8Array(d.sabIO,d.sabS11nOffset,d.sabS11nSize),w.initS11n(),delete w.initS11n,_.sanityChecks&&($("Running sanity checks because of opfs-sanity-check URL arg..."),K()),a.thisThreadHasOPFS()?a.getRootDir().then(b=>{y.onerror=y._originalOnError,delete y._originalOnError,R("End of OPFS sqlite3_vfs setup.",w),u()}).catch(C):u()}catch(b){B(b),C(b)}break;case"debug":$("debug message from worker:",M);break;default:{let b="Unexpected message from the OPFS async worker: "+JSON.stringify(M);B(b),C(new Error(b));break}}}})},d}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(!o.opfs||o.config.disable?.vfs?.opfs)return;let r=o.util,s=o.opfs||o.util.toss("Missing sqlite3.opfs"),a=async function(m){if(m=s.initOptions("opfs",m),!m)return o;let d=o.capi,q=s.createVfsState().vfs,V=q.metrics.counters,N=q.mTimeStart,x=q.mTimeEnd,R=q.opRun,$=q.__openFiles;return q.bindVfs(r.nu({xLock:function(B,J){N("xLock"),++V.xLock.count;let E=$[B],w=0;return E.lockType?E.lockType=J:(w=R("xLock",B,J),w===0&&(E.lockType=J)),x(),w},xUnlock:function(B,J){N("xUnlock"),++V.xUnlock.count;let E=$[B],w=0;return d.SQLITE_LOCK_NONE===J&&E.lockType&&(w=R("xUnlock",B,J)),w===0&&(E.lockType=J),x(),w}}),function(B,J){if(B.oo1){let E=function(...w){let W=B.oo1.DB.dbCtorHelper.normalizeArgs(...w);W.vfs=J.$zName,B.oo1.DB.dbCtorHelper.call(this,W)};E.prototype=Object.create(B.oo1.DB.prototype),B.oo1.OpfsDb=E,E.importDb=s.importDb,B.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(q.pointer,function(w,W){W.capi.sqlite3_busy_timeout(w,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async m=>a().catch(d=>{m.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",d)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){"use strict";if(o.config.disable?.vfs?.["opfs-sahpool"])return;let r=o.util.toss,s=o.util.toss3,a=Object.create(null),m=o.capi,d=o.util,q=o.wasm,V=4096,N=512,x=8,R=516,$=N,B=R,J=V,E=m.SQLITE_OPEN_MAIN_DB|m.SQLITE_OPEN_MAIN_JOURNAL|m.SQLITE_OPEN_SUPER_JOURNAL|m.SQLITE_OPEN_WAL,w=m.SQLITE_OPEN_MEMORY,W=".opaque",ee=()=>Math.random().toString(36).slice(2),O=new TextDecoder,z=new TextEncoder,le=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1}),h=[o.config.error,o.config.warn,o.config.log];o.config.log;let A=o.config.warn;o.config.error;let U=new Map,X=M=>U.get(M),L=(M,b)=>{b?U.set(M,b):U.delete(M)},fe=new Map,de=M=>fe.get(M),me=(M,b)=>{b?fe.set(M,b):fe.delete(M)},S={xCheckReservedLock:function(M,b){let D=de(M);return D.log("xCheckReservedLock"),D.storeErr(),q.poke32(b,1),0},xClose:function(M){let b=de(M);b.storeErr();let D=b.getOFileForS3File(M);if(D)try{b.log(`xClose ${D.path}`),b.mapS3FileToOFile(M,!1),D.sah.flush(),D.flags&m.SQLITE_OPEN_DELETEONCLOSE&&b.deletePath(D.path)}catch(te){return b.storeErr(te,m.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(M){return m.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(M,b,D){return m.SQLITE_NOTFOUND},xFileSize:function(M,b){let D=de(M);D.log("xFileSize");let te=D.getOFileForS3File(M).sah.getSize()-J;return q.poke64(b,BigInt(te)),0},xLock:function(M,b){let D=de(M);D.log(`xLock ${b}`),D.storeErr();let te=D.getOFileForS3File(M);return te.lockType=b,0},xRead:function(M,b,D,te){let Z=de(M);Z.storeErr();let we=Z.getOFileForS3File(M);Z.log(`xRead ${we.path} ${D} @ ${te}`);try{let he=we.sah.read(q.heap8u().subarray(Number(b),Number(b)+D),{at:J+Number(te)});return he<D?(q.heap8u().fill(0,Number(b)+he,Number(b)+D),m.SQLITE_IOERR_SHORT_READ):0}catch(he){return Z.storeErr(he,m.SQLITE_IOERR)}},xSectorSize:function(M){return V},xSync:function(M,b){let D=de(M);D.log(`xSync ${b}`),D.storeErr();let te=D.getOFileForS3File(M);try{return te.sah.flush(),0}catch(Z){return D.storeErr(Z,m.SQLITE_IOERR)}},xTruncate:function(M,b){let D=de(M);D.log(`xTruncate ${b}`),D.storeErr();let te=D.getOFileForS3File(M);try{return te.sah.truncate(J+Number(b)),0}catch(Z){return D.storeErr(Z,m.SQLITE_IOERR)}},xUnlock:function(M,b){let D=de(M);D.log("xUnlock");let te=D.getOFileForS3File(M);return te.lockType=b,0},xWrite:function(M,b,D,te){let Z=de(M);Z.storeErr();let we=Z.getOFileForS3File(M);Z.log(`xWrite ${we.path} ${D} ${te}`);try{return D===we.sah.write(q.heap8u().subarray(Number(b),Number(b)+D),{at:J+Number(te)})?0:r("Unknown write() failure.")}catch(he){return Z.storeErr(he,m.SQLITE_IOERR)}}},C=new m.sqlite3_io_methods;C.$iVersion=1,o.vfs.installVfs({io:{struct:C,methods:S}});let u={xAccess:function(M,b,D,te){let Z=X(M);Z.storeErr();try{let we=Z.getPath(b);q.poke32(te,Z.hasFilename(we)?1:0)}catch{q.poke32(te,0)}return 0},xCurrentTime:function(M,b){return q.poke(b,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(M,b){return q.poke(b,21086676e7+new Date().getTime(),"i64"),0},xDelete:function(M,b,D){let te=X(M);te.log(`xDelete ${q.cstrToJs(b)}`),te.storeErr();try{return te.deletePath(te.getPath(b)),0}catch(Z){return te.storeErr(Z),m.SQLITE_IOERR_DELETE}},xFullPathname:function(M,b,D,te){return q.cstrncpy(te,b,D)<D?0:m.SQLITE_CANTOPEN},xGetLastError:function(M,b,D){let te=X(M),Z=te.popErr();if(te.log(`xGetLastError ${b} e =`,Z),Z){let we=q.scopedAllocPush();try{let[he,ke]=q.scopedAllocCString(Z.message,!0);q.cstrncpy(D,he,b),ke>b&&q.poke8(q.ptr.add(D,b,-1),0)}catch{return m.SQLITE_NOMEM}finally{q.scopedAllocPop(we)}}return Z?Z.sqlite3Rc||m.SQLITE_IOERR:0},xOpen:function(b,D,te,Z,we){let he=X(b);try{Z&=~w,he.log(`xOpen ${q.cstrToJs(D)} ${Z}`);let ke=D&&q.peek8(D)?he.getPath(D):ee(),Be=he.getSAHForPath(ke);!Be&&Z&m.SQLITE_OPEN_CREATE&&(he.getFileCount()<he.getCapacity()?(Be=he.nextAvailableSAH(),he.setAssociatedPath(Be,ke,Z)):r("SAH pool is full. Cannot create file",ke)),Be||r("file not found:",ke);let Ze={path:ke,flags:Z,sah:Be};he.mapS3FileToOFile(te,Ze),Ze.lockType=m.SQLITE_LOCK_NONE;let at=new m.sqlite3_file(te);return at.$pMethods=C.pointer,at.dispose(),q.poke32(we,Z),0}catch(ke){return he.storeErr(ke),m.SQLITE_CANTOPEN}}},_=function(M){o.capi.sqlite3_vfs_find(M)&&s("VFS name is already registered:",M);let b=new m.sqlite3_vfs,D=m.sqlite3_vfs_find(null),te=D?new m.sqlite3_vfs(D):null;return b.$iVersion=2,b.$szOsFile=m.sqlite3_file.structInfo.sizeof,b.$mxPathname=N,b.addOnDispose(b.$zName=q.allocCString(M),()=>L(b.pointer,0)),te&&(b.$xRandomness=te.$xRandomness,b.$xSleep=te.$xSleep,te.dispose()),!b.$xRandomness&&!u.xRandomness&&(u.xRandomness=function(Z,we,he){let ke=q.heap8u(),Be=0,Ze=Number(he);for(;Be<we;++Be)ke[Ze+Be]=Math.random()*255e3&255;return Be}),!b.$xSleep&&!u.xSleep&&(u.xSleep=(Z,we)=>0),o.vfs.installVfs({vfs:{struct:b,methods:u}}),b};class y{vfsDir;#e;#t;#s;#n=new Map;#r=new Map;#a=new Set;#u=new Map;#i=new Uint8Array(R);#f;#o;#l;constructor(b=Object.create(null)){this.#l=b.verbosity??le.verbosity,this.vfsName=b.name||le.name,this.#o=_(this.vfsName),L(this.#o.pointer,this),this.vfsDir=b.directory||"."+this.vfsName,this.#f=new DataView(this.#i.buffer,this.#i.byteOffset),this.isReady=this.reset(!!(b.clearOnInit??le.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(b.initialCapacity||le.initialCapacity)})}#c(b,...D){this.#l>b&&h[b](this.vfsName+":",...D)}log(...b){this.#c(2,...b)}warn(...b){this.#c(1,...b)}error(...b){this.#c(0,...b)}getVfs(){return this.#o}getCapacity(){return this.#n.size}getFileCount(){return this.#r.size}getFileNames(){let b=[];for(let D of this.#r.keys())b.push(D);return b}async addCapacity(b){for(let D=0;D<b;++D){let te=ee(),Z=await(await this.#t.getFileHandle(te,{create:!0})).createSyncAccessHandle();this.#n.set(Z,te),this.setAssociatedPath(Z,"",0)}return this.getCapacity()}async reduceCapacity(b){let D=0;for(let te of Array.from(this.#a)){if(D===b||this.getFileCount()===this.getCapacity())break;let Z=this.#n.get(te);te.close(),await this.#t.removeEntry(Z),this.#n.delete(te),this.#a.delete(te),++D}return D}releaseAccessHandles(){for(let b of this.#n.keys())b.close();this.#n.clear(),this.#r.clear(),this.#a.clear()}async acquireAccessHandles(b=!1){let D=[];for await(let[te,Z]of this.#t)Z.kind==="file"&&D.push([te,Z]);return Promise.all(D.map(async([te,Z])=>{try{let we=await Z.createSyncAccessHandle();if(this.#n.set(we,te),b)we.truncate(J),this.setAssociatedPath(we,"",0);else{let he=this.getAssociatedPath(we);he?this.#r.set(he,we):this.#a.add(we)}}catch(we){throw this.storeErr(we),this.releaseAccessHandles(),we}}))}getAssociatedPath(b){b.read(this.#i,{at:0});let D=this.#f.getUint32($);if(this.#i[0]&&(D&m.SQLITE_OPEN_DELETEONCLOSE||(D&E)===0))return A(`Removing file with unexpected flags ${D.toString(16)}`,this.#i),this.setAssociatedPath(b,"",0),"";let te=new Uint32Array(x/4);b.read(te,{at:B});let Z=this.computeDigest(this.#i,D);if(te.every((we,he)=>we===Z[he])){let we=this.#i.findIndex(he=>he===0);return we===0&&b.truncate(J),we?O.decode(this.#i.subarray(0,we)):""}else return A("Disassociating file with bad digest."),this.setAssociatedPath(b,"",0),""}setAssociatedPath(b,D,te){let Z=z.encodeInto(D,this.#i);N<=Z.written+1&&r("Path too long:",D),D&&te&&(te|=w),this.#i.fill(0,Z.written,N),this.#f.setUint32($,te);let we=this.computeDigest(this.#i,te);b.write(this.#i,{at:0}),b.write(we,{at:B}),b.flush(),D?(this.#r.set(D,b),this.#a.delete(b)):(b.truncate(J),this.#a.add(b))}computeDigest(b,D){if(D&w){let te=3735928559,Z=1103547991;for(let we of b)te=Math.imul(te^we,2654435761),Z=Math.imul(Z^we,104729);return new Uint32Array([te>>>0,Z>>>0])}else return new Uint32Array([0,0])}async reset(b){await this.isReady;let D=await navigator.storage.getDirectory(),te;for(let Z of this.vfsDir.split("/"))Z&&(te=D,D=await D.getDirectoryHandle(Z,{create:!0}));return this.#e=D,this.#s=te,this.#t=await this.#e.getDirectoryHandle(W,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(b)}getPath(b){return q.isPtr(b)&&(b=q.cstrToJs(b)),(b instanceof URL?b:new URL(b,"file://localhost/")).pathname}deletePath(b){let D=this.#r.get(b);return D&&(this.#r.delete(b),this.setAssociatedPath(D,"",0)),!!D}storeErr(b,D){return b&&(b.sqlite3Rc=D||m.SQLITE_IOERR,this.error(b)),this.$error=b,D}popErr(){let b=this.$error;return this.$error=void 0,b}nextAvailableSAH(){let[b]=this.#a.keys();return b}getOFileForS3File(b){return this.#u.get(b)}mapS3FileToOFile(b,D){D?(this.#u.set(b,D),me(b,this)):(this.#u.delete(b),me(b,!1))}hasFilename(b){return this.#r.has(b)}getSAHForPath(b){return this.#r.get(b)}async removeVfs(){if(!this.#o.pointer||!this.#t)return!1;m.sqlite3_vfs_unregister(this.#o.pointer),this.#o.dispose(),delete a[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(W,{recursive:!0}),this.#t=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(b){o.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",b)}return!0}pauseVfs(){return this.#u.size>0&&o.SQLite3Error.toss(m.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files."),this.#n.size>0&&(m.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles()),this}isPaused(){return this.#n.size===0}async unpauseVfs(){return this.#n.size===0?this.acquireAccessHandles(!1).then(()=>m.sqlite3_vfs_register(this.#o,0),this):this}exportFile(b){let D=this.#r.get(b)||r("File not found:",b),te=D.getSize()-J,Z=new Uint8Array(te>0?te:0);if(te>0){let we=D.read(Z,{at:J});we!=te&&r("Expected to read "+te+" bytes but read "+we+".")}return Z}async importDbChunked(b,D){let te=this.#r.get(b)||this.nextAvailableSAH()||r("No available handles to import to.");te.truncate(0);let Z=0,we,he=!1;try{for(;(we=await D())!==void 0;)we instanceof ArrayBuffer&&(we=new Uint8Array(we)),!he&&Z===0&&we.byteLength>=15&&(d.affirmDbHeader(we),he=!0),te.write(we,{at:J+Z}),Z+=we.byteLength;if((Z<512||Z%512!==0)&&r("Input size",Z,"is not correct for an SQLite database."),!he){let ke=new Uint8Array(20);te.read(ke,{at:0}),d.affirmDbHeader(ke)}te.write(new Uint8Array([1,1]),{at:4114})}catch(ke){throw this.setAssociatedPath(te,"",0),ke}return this.setAssociatedPath(te,b,m.SQLITE_OPEN_MAIN_DB),Z}importDb(b,D){if(D instanceof ArrayBuffer)D=new Uint8Array(D);else if(D instanceof Function)return this.importDbChunked(b,D);let te=this.#r.get(b)||this.nextAvailableSAH()||r("No available handles to import to."),Z=D.byteLength;(Z<512||Z%512!=0)&&r("Byte array size is invalid for an SQLite db.");let we="SQLite format 3";for(let ke=0;ke<15;++ke)we.charCodeAt(ke)!==D[ke]&&r("Input does not contain an SQLite database header.");let he=te.write(D,{at:J});return he!=Z?(this.setAssociatedPath(te,"",0),r("Expected to write "+Z+" bytes but wrote "+he+".")):(te.write(new Uint8Array([1,1]),{at:4114}),this.setAssociatedPath(te,b,m.SQLITE_OPEN_MAIN_DB)),he}}class Q{#e;constructor(b){this.#e=b,this.vfsName=b.vfsName}async addCapacity(b){return this.#e.addCapacity(b)}async reduceCapacity(b){return this.#e.reduceCapacity(b)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(b){let D=this.#e.getCapacity();return D<b?this.#e.addCapacity(b-D):D}exportFile(b){return this.#e.exportFile(b)}importDb(b,D){return this.#e.importDb(b,D)}async wipeFiles(){return this.#e.reset(!0)}unlink(b){return this.#e.deletePath(b)}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 K=async()=>{let M=await navigator.storage.getDirectory(),b=".opfs-sahpool-sync-check-"+ee(),D=(await(await M.getFileHandle(b,{create:!0})).createSyncAccessHandle()).close();return await D,await M.removeEntry(b),D?.then&&r("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method."),!0};o.installOpfsSAHPoolVfs=async function(M=Object.create(null)){M=Object.assign(Object.create(null),le,M||{});let b=M.name;if(M.$testThrowPhase1)throw M.$testThrowPhase1;if(a[b])try{return await a[b]}catch(D){if(M.forceReinitIfPreviouslyFailed)delete a[b];else throw D}return!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory?a[b]=Promise.reject(new Error("Missing required OPFS APIs.")):a[b]=K().then(async function(){if(M.$testThrowPhase2)throw M.$testThrowPhase2;let D=new y(M);return D.isReady.then(async()=>{let te=new Q(D);if(o.oo1){let Z=o.oo1,we=D.getVfs(),he=function(...ke){let Be=Z.DB.dbCtorHelper.normalizeArgs(...ke);Be.vfs=we.$zName,Z.DB.dbCtorHelper.call(this,Be)};he.prototype=Object.create(Z.DB.prototype),te.OpfsSAHPoolDb=he}return D.log("VFS initialized."),te}).catch(async te=>{throw await D.removeVfs().catch(()=>{}),te})}).catch(D=>a[b]=Promise.reject(D))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(!o.opfs||o.config.disable?.vfs?.["opfs-wl"])return;let r=o.util;o.util.toss;let s=o.opfs,a="opfs-wl",m=async function(d){if(d=s.initOptions(a,d),!d)return o;o.capi;let q=s.createVfsState().vfs;q.metrics.counters;let V=q.mTimeStart,N=q.mTimeEnd,x=q.opRun,R=q.__openFiles;return q.bindVfs(r.nu({xLock:function($,B){V("xLock");let J=R[$],E=x("xLock",$,B);return E||(J.lockType=B),N(),E},xUnlock:function($,B){V("xUnlock");let J=R[$],E=x("xUnlock",$,B);return E||(J.lockType=B),N(),E}}),function($,B){if($.oo1){let J=function(...E){let w=$.oo1.DB.dbCtorHelper.normalizeArgs(...E);w.vfs=B.$zName,$.oo1.DB.dbCtorHelper.call(this,w)};J.prototype=Object.create($.oo1.DB.prototype),$.oo1.OpfsWlDb=J,J.importDb=s.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async d=>m().catch(q=>{d.config.warn("Ignoring inability to install the",a,"sqlite3_vfs:",q)}))});try{let o=Object.assign(Object.create(null),{memory:typeof yt<"u"?yt:n.wasmMemory,exports:typeof Bt<"u"?Bt:Object.prototype.hasOwnProperty.call(n,"wasmExports")?n.wasmExports:n.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",o);let r=globalThis.sqlite3ApiBootstrap(o);return delete globalThis.sqlite3ApiBootstrap,r}catch(o){throw console.error("sqlite3ApiBootstrap() error:",o),o}},re?i=t:i=new Promise((e,n)=>{Ce=e,be=n}),i}var ia,cu,is,ss=Oe(()=>{mr=(function(){let l=mr;if(!l)throw new Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");let i=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(i.debugModule=i.urlParams.has("sqlite3.debugModule")?(...p)=>console.warn("sqlite3.debugModule:",...p):()=>{},i.urlParams.has("sqlite3.dir"))i.sqlite3Dir=i.urlParams.get("sqlite3.dir")+"/";else if(i.moduleScript){let p=i.moduleScript.src.split("/");p.pop(),i.sqlite3Dir=p.join("/")+"/"}let t=globalThis.sqlite3InitModule=function p(...g){return i.emscriptenLocateFile=g[0]?.locateFile,i.emscriptenInstantiateWasm=g[0]?.instantiateWasm,l(...g).then(T=>{i.debugModule("sqlite3InitModule() sIMS =",i),i.debugModule("sqlite3InitModule() EmscriptenModule =",T);let I=T.runSQLite3PostLoadInit(i,T,!!p.__isUnderTest);return i.debugModule("sqlite3InitModule() sqlite3 =",I),I}).catch(T=>{throw console.error("Exception loading sqlite3 module:",T),T})};if(t.ready=l.ready,i.moduleScript){let p=i.moduleScript.src.split("/");p.pop(),i.scriptDir=p.join("/")+"/"}return i.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",i),t})();ia=mr;globalThis.sqlite3Worker1Promiser=function l(i=l.defaultConfig){if(arguments.length===1&&typeof arguments[0]=="function"){let Y=i;i=Object.assign(Object.create(null),l.defaultConfig),i.onready=Y}else i=Object.assign(Object.create(null),l.defaultConfig,i);let t=Object.create(null),p=function(){},g=i.onerror||p,T=i.debug||p,I=i.generateMessageId?void 0:Object.create(null),j=i.generateMessageId||function(Y){return Y.type+"#"+(I[Y.type]=(I[Y.type]||0)+1)},H=(...Y)=>{throw new Error(Y.join(" "))};i.worker||(i.worker=l.defaultConfig.worker),typeof i.worker=="function"&&(i.worker=i.worker());let se,ue;return i.worker.onmessage=function(Y){Y=Y.data,T("worker1.onmessage",Y);let ne=t[Y.messageId];if(!ne){if(Y&&Y.type==="sqlite3-api"&&Y.result==="worker1-ready"){i.onready&&i.onready(ue);return}if(ne=t[Y.type],ne&&ne.onrow){ne.onrow(Y);return}i.onunhandled?i.onunhandled(arguments[0]):g("sqlite3Worker1Promiser() unhandled worker message:",Y);return}switch(delete t[Y.messageId],Y.type){case"error":ne.reject(Y);return;case"open":se||(se=Y.dbId);break;case"close":Y.dbId===se&&(se=void 0)}try{ne.resolve(Y)}catch(_e){ne.reject(_e)}},ue=function(){let Y;arguments.length===1?Y=arguments[0]:arguments.length===2?(Y=Object.create(null),Y.type=arguments[0],Y.args=arguments[1],Y.dbId=Y.args.dbId):H("Invalid arguments for sqlite3Worker1Promiser()-created factory."),!Y.dbId&&Y.type!=="open"&&(Y.dbId=se),Y.messageId=j(Y),Y.departureTime=performance.now();let ne=Object.create(null);ne.message=Y;let _e;Y.type==="exec"&&Y.args&&(typeof Y.args.callback=="function"?(_e=Y.messageId+":row",ne.onrow=Y.args.callback,Y.args.callback=_e,t[_e]=ne):typeof Y.args.callback=="string"&&H("exec callback may not be a string when using the Promise interface."));let Te=new Promise(function(Ce,be){ne.resolve=Ce,ne.reject=be,t[Y.messageId]=ne,T("Posting",Y.type,"message to Worker dbId="+(se||"default")+":",Y),i.worker.postMessage(Y)});return _e&&(Te=Te.finally(()=>delete t[_e])),Te}};globalThis.sqlite3Worker1Promiser.defaultConfig={worker:function(){return new Worker(new URL("sqlite3-worker1.mjs",import.meta.url),{type:"module"})},onerror:(...l)=>console.error("sqlite3Worker1Promiser():",...l)};globalThis.sqlite3Worker1Promiser.v2=function l(i=l.defaultConfig){let t;typeof i=="function"?(t=i,i={}):typeof i?.onready=="function"&&(t=i.onready,delete i.onready);let p=Object.create(null);i=Object.assign(i||Object.create(null),{onready:async function(T){try{t&&await t(T),p.resolve(T)}catch(I){p.reject(I)}}});let g=new Promise(function(T,I){p.resolve=T,p.reject=I});try{this.original(i)}catch(T){p.reject(T)}return g}.bind({original:sqlite3Worker1Promiser});globalThis.sqlite3Worker1Promiser.v2.defaultConfig=globalThis.sqlite3Worker1Promiser.defaultConfig;cu=sqlite3Worker1Promiser.v2;delete globalThis.sqlite3Worker1Promiser;is=ia});function cs(l){ls=l}async function oa(l){let i=["localStorage","sessionStorage"].filter(t=>{try{return globalThis[t],!1}catch{}return Object.defineProperty(globalThis,t,{value:void 0,configurable:!0}),!0});try{return await l()}finally{for(let t of i)delete globalThis[t]}}async function as(l){let i=await oa(()=>sa(l?{wasmBinary:l,locateFile:t=>t}:void 0));return i.config.warn=()=>{},i}function us(l){return l?as(l):os??=as(ls??void 0).catch(i=>{throw os=null,i})}var sa,os,ls,pr=Oe(()=>{"use strict";ss();sa=is,os=null,ls=null});var fs={};To(fs,{CORE_FUNCTIONS:()=>xn,DEFAULT_CAPS:()=>Ft,Refused:()=>nt,SqliteDatabase:()=>st,TimedOut:()=>St,loadSqlite:()=>la,provideSqliteWasm:()=>cs});function aa(l){let i=t=>{let p=new st(l);try{return t(p)}finally{p.close()}};return{analyze:(t,p,g)=>i(T=>{g?.mode==="write"&&g.extensions?.setupMutation?.(T,{dryRun:!0});for(let j of p)j.sql===void 0&&T.createTable(j);T.createViews(p.flatMap(j=>j.sql===void 0?[]:[{...j,sql:j.sql}]));let I=T.prepare(t,"any");return I.finalize(),I.analysis}),run:(t,p)=>Bi(l,t,p),runMany:(t,p)=>zi(l,t,p),held:t=>Qi(l,t),mutate:(t,p,g)=>ts(l,t,p,g),dryRun:t=>Wi(l,t),dryRunMutations:(t,p)=>ns(l,t,p),open:()=>new st(l),libraryFunctions:()=>i(t=>t.registeredFunctions())}}async function la(l){return aa(await us(l))}var ds=Oe(()=>{"use strict";on();Hi();rs();pr();pr();kn();on()});ht();ht();ht();var Ao=[{name:"_me.id",type:"user",source:"platform",readOnly:!0,query:!0,markup:!0,summary:"The reader's account id; null for a guest."},{name:"_now",type:"timestamp",source:"platform",readOnly:!0,query:!0,markup:!1,summary:"The current instant, UTC ISO; the same on the server and in the browser."},{name:"_tz",type:"string",source:"platform",readOnly:!0,query:!0,markup:!1,summary:"The reader's IANA time zone (UTC when unknown)."},{name:"_row",type:null,source:"control",readOnly:!0,query:!1,markup:!1,summary:"A field of the row the control sits in: $_row.<column>."},{name:"_value",type:null,source:"control",readOnly:!0,query:!1,markup:!1,summary:"The new value an editing cell holds."}],nn={_me:{columns:[{name:"id",type:"user"}],summary:"The reader as a one-row table (id null for a guest)."},_members:{columns:gn,summary:"The artifact's accepted members."}},pi=/^_row\.([A-Za-z_]\w*)$/;function hn(l){let i=pi.test(l)?"_row":l;return Ao.find(t=>t.name===i)??null}var Qn=l=>pi.exec(l)?.[1]??null,_i=l=>hn(l)!==null;var yn=l=>({"_me.id":l.userId,_now:l.now,_tz:l.tz});ht();function bn(l){return Object.fromEntries(l.values.flatMap(i=>i.kind==="scalar"?[[i.name,i.default]]:[]))}function gi(l){return Object.fromEntries(l.values.flatMap(i=>i.kind==="scalar"&&i.type!=="table"?[[i.name,i.type]]:[]))}function hi(l,i={}){let t=i.page?[i.page.name]:i.only?[...i.only]:null;if(!t)return l.queries;let p=new Map(l.queries.map(I=>[I.name,I])),g=new Set,T=I=>{let j=p.get(I);if(!(!j||g.has(I))){g.add(I);for(let H of j.reads.queries)T(H)}};for(let I of t)T(I);return l.queries.filter(I=>g.has(I.name))}var wn=(l,i)=>l.imports.find(t=>t.name===i)?.ref;function Qt(l,i){return Object.fromEntries(l.map(t=>[Bn(t),i[t]??null]))}function Vt(l,i){let t={};for(let p of l){let g=i[p]??hn(p)?.type??null;g&&(t[Bn(p)]=g)}return t}function Sn(l,i){let t=new Map(l.flatMap(I=>I.type?[[I.name,I.type]]:[]));if(!t.size)return i;let p=i.columns.map(I=>{let j=t.get(I.name);return j&&j!==I.type?{...I,type:j}:I}),g=p.filter(I=>I.type==="boolean").map(I=>I.name),T=g.length?i.rows.map(I=>{let j={...I};for(let H of g)typeof j[H]=="number"&&(j[H]=j[H]!==0);return j}):i.rows;return{...i,columns:p,rows:T}}var yi=l=>[...l.args.map(i=>i.name),...l.reads.builtins.filter(_i)];function Vn(l,i,t){let p=[],g=(T,I)=>"import"in i.target?i.target.import===T&&i.target.table===I:T==="main"&&i.target.local===I;for(let T of i.reads.imports){let I=l.imports.find(j=>j.name===T);for(let j of I?.tables??[])g(T,j.name)||p.push({schema:T,table:j.name,rows:t.imports?.[T]?.[j.name]?.rows??[],columns:j.columns})}for(let T of i.reads.values){let I=l.values.find(j=>j.name===T&&j.kind==="table");I&&!g("main",I.name)&&p.push({schema:"main",table:I.name,rows:t.tables?.[I.name]?.rows??I.rows??[],columns:I.columns??[]})}return i.reads.builtins.includes("_me")&&p.push({schema:"main",table:"_me",rows:[{id:t.userId??null}],columns:nn._me.columns}),i.reads.builtins.includes("_members")&&p.push({schema:"main",table:"_members",rows:t.members??[],columns:nn._members.columns}),p}kt();kt();kt();ht();var bi=["Dialog","DialogTrigger","DialogContent","DialogClose","Mermaid","DeckGL","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","CardAction","Badge","Button","Alert","AlertTitle","AlertDescription","Table","TableHeader","TableBody","TableFooter","TableRow","TableHead","TableCell","TableCaption","Separator","Skeleton","Progress","Breadcrumb","BreadcrumbList","BreadcrumbItem","BreadcrumbLink","BreadcrumbPage","BreadcrumbSeparator","BreadcrumbEllipsis","Avatar","AvatarImage","AvatarFallback","AvatarBadge","AvatarGroup","AvatarGroupCount","Tabs","TabsList","TabsTrigger","TabsContent","Accordion","AccordionItem","AccordionTrigger","AccordionContent","Collapsible","CollapsibleTrigger","CollapsibleContent","Tooltip","TooltipTrigger","TooltipContent","TooltipProvider","Popover","PopoverTrigger","PopoverContent","PopoverAnchor","PopoverHeader","PopoverTitle","PopoverDescription","Grid","GridItem","Input","Textarea","Select","Slider","DatePicker","Segmented","Switch","SlideDeck","Slide","File","Icon","User","UserImage","UserHandle","SignIn","DataTable","Column","For","Files"];var Io=["svg","g","defs","path","line","polyline","polygon","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath","title","desc"],Ql=["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","a","strong","em","b","i","u","s","code","pre","kbd","samp","var","blockquote","cite","q","abbr","mark","small","sub","sup","del","ins","img","figure","figcaption","picture","source","video","audio","track","iframe","section","article","aside","header","footer","main","nav","address","hr","br","wbr","time","data","details","summary","button","input","label","select","option","optgroup","textarea","fieldset","legend","output","meter","progress","datalist","canvas","dialog","template",...Io];var wi=["Question","Number",...bi];kt();var Ro=/^\d{4}-\d{2}-\d{2}([T ].*)?$/;var Gt=(l,i)=>{if(l===null)return!0;switch(i){case"number":return typeof l=="number"&&Number.isFinite(l);case"boolean":return typeof l=="boolean";case"timestamp":return Wt(l);case"date":return typeof l=="string"&&Ro.test(l);case"user":case"string":return typeof l=="string"}};var dc=new Set(wi);var Jt=class extends Error{};function Hn(l,i){if(!Array.isArray(l)||l.length>1e4)throw new Jt("Local table must contain at most 10000 rows");return l.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(p=>!i.some(g=>g.name===p)))throw new Jt("Local row has undeclared fields");return Object.fromEntries(i.map(p=>{let g=Object.hasOwn(t,p.name)?t[p.name]:null;if(!Gt(g,p.type))throw new Jt(`Local field "${p.name}" has an invalid type`);return[p.name,g]}))})}function vn(l,i={}){return Object.fromEntries(Object.entries(i).map(([t,p])=>{let g=l.values.find(I=>I.kind==="table"&&I.name===t);if(!g||g.kind!=="table")throw new Jt(`"${t}" is not a declared inline table`);let T=g.columns??[];return[t,{columns:T,rows:Hn(p,T)}]}))}var wt=class extends Error{constructor(t){super(`Document query ${t}: complete results required`);this.reason=t}reason};async function Si(l,i,t,p={}){let g=await Oo(l,i,t,p);return"state"in g?g.state:g.finish(await l.run({...g.run,imports:g.imports,page:p.page}))}async function Oo(l,i,t,p){let g=bn(i);for(let[re,ye]of Object.entries(p.values??{}))Object.hasOwn(g,re)&&(g[re]=ye);let T={...g,...p.bindings?.values,...yn({userId:p.userId??null,now:p.now??new Date().toISOString(),tz:p.tz??"UTC"})},I={...gi(i),...p.bindings?.types},j={},H={},se={_me:{columns:nn._me.columns,rows:[{id:p.userId??null}]},_members:{columns:gn,rows:p.members??[]}},ue=vn(i,p.localTables);for(let re of i.values)re.kind==="table"&&(se[re.name]=ue[re.name]??{rows:re.rows??[],columns:re.columns??[]},j[re.name]=se[re.name]);let Y=hi(i,p);if(Y.length===0)return{state:{values:g,tables:j,errors:H}};if(p.completeResults){let re=performance.now(),ye=0;for(let Ae of Y){let ge=p.timeoutMs===void 0?void 0:Math.floor(p.timeoutMs-(performance.now()-re));if(ge!==void 0&&ge<1)throw new wt("timeout");let Pe=Qt(Ae.params,T),Fe=Vt(Ae.params,I),Ne;if(Ae.source){if(!p.sourceQuery)throw new wt("query");Ne=await p.sourceQuery(Ae,Pe,Fe,{limit:p.limit??At,offset:0},ge)}else{if(Ae.reads.imports.some(Et=>!t[Et]))throw new wt("query");let rt=(await l.run({tables:se,imports:Object.fromEntries(Ae.reads.imports.map(Et=>[Et,t[Et]])),queries:[{name:Ae.name,sql:Ae.sql}],params:Pe,paramTypes:Fe,limit:p.limit??At,timeoutMs:ge}))[Ae.name];if(!rt||bt(rt))throw new wt(rt&&"timedOut"in rt&&rt.timedOut?"timeout":"query");Ne=rt}if(p.timeoutMs!==void 0&&performance.now()-re>p.timeoutMs)throw new wt("timeout");if(Ne.truncated||Ne.rows.length>(p.limit??At)||Ne.totalRows!==void 0&&Ne.totalRows>Ne.rows.length)throw new wt("capacity");if(ye+=new TextEncoder().encode(JSON.stringify(Ne.rows)).byteLength,p.resultBytes!==void 0&&ye>p.resultBytes)throw new wt("capacity");j[Ae.name]=se[Ae.name]=Sn(Ae.columns,Ne)}return{state:{values:g,tables:j,errors:H}}}await Promise.all(Y.filter(re=>!!re.source).map(async re=>{try{if(!p.sourceQuery)throw new Error(`the connected database ref:${re.source} is not reachable from here`);let ye=p.page?.name===re.name?p.page:void 0,Ae=Sn(re.columns,await p.sourceQuery(re,Qt(re.params,T),Vt(re.params,I),ye));se[re.name]=Ae,j[re.name]=Ae}catch(ye){H[re.name]=ye instanceof Error?ye.message:"Dataset query failed"}}));let ne=new Map(i.imports.filter(re=>!Object.hasOwn(t,re.name)).map(re=>[re.name,re.ref])),_e=Y.filter(re=>{if(re.source)return!1;let ye=re.reads.imports.find(Ae=>ne.has(Ae));return ye&&(H[re.name]=`<Query name="${re.name}"> reads ${ye} (ref:${ne.get(ye)}), which is unavailable \u2014 deleted, or no longer readable here`),!ye});if(!_e.length)return{state:{values:g,tables:j,errors:H}};let Te=new Set(_e.flatMap(re=>re.reads.imports)),Ce=Object.assign({},..._e.map(re=>Qt(re.params,T))),be=Object.assign({},..._e.map(re=>Vt(re.params,I)));return{run:{tables:se,queries:_e.map(re=>({name:re.name,sql:re.sql})),params:Ce,paramTypes:be,limit:p.limit??At,timeoutMs:p.timeoutMs},imports:Object.fromEntries(Object.entries(t).filter(([re])=>Te.has(re))),finish:re=>{for(let ye of _e){let Ae=re[ye.name];Ae&&(bt(Ae)?H[ye.name]=Ae.error:j[ye.name]=Sn(ye.columns,Ae))}return{values:g,tables:j,errors:H}}}}ht();async function vi(l,i,t,p,g){if(!("local"in i.target))throw new Error("Mutation must target a declared local table");let T=i.target.local,I=l.values.find(ue=>ue.kind==="table"&&ue.name===T);if(!I)throw new Error("Mutation must target a declared local table");let j=I.columns??[];if(!j.length)throw new Error("Local table needs declared columns");let H=Object.hasOwn(t.tables,T)?t.tables[T].rows:I.rows??[],se=await p.mutate({table:{name:T,columns:j,rows:Hn(H,j)},sql:i.sql,params:g.params,paramTypes:g.paramTypes,...g.reads?.length?{reads:g.reads}:{},...i.expectedAffected===void 0?{}:{expectedAffected:i.expectedAffected}});if(bt(se))throw new Error(se.error);return{target:T,table:{columns:se.columns,rows:se.rows},affected:se.affected}}function Gn(l,i,t,p){let g=ne=>({ok:!1,reason:"invalid_sql",detail:ne}),T=ne=>({ok:!1,reason:"invalid_row",detail:ne}),I=Object.keys(t.args).filter(ne=>!i.args.some(_e=>_e.name===ne));if(I.length)return g(`${i.name} takes no argument ${I.join(", ")}${i.args.length?` (it takes ${i.args.map(ne=>ne.name).join(", ")})`:""}`);let j={},H=bn(l);for(let ne of i.args){let _e=Object.hasOwn(t.args,ne.name)?t.args[ne.name]:H[ne.name]??null,Te=_e===""&&ne.type&&ne.type!=="string"?null:_e;if(ne.type&&!Gt(Te,ne.type))return g(`argument $${ne.name} does not match its declared type`);j[ne.name]=Te}let se=i.reads.builtins.flatMap(ne=>Qn(ne)??[]),ue=Object.fromEntries(i.args.map(ne=>[ne.name,ne.type]));if(se.length){let ne=se.filter(Te=>!t.row||!Object.hasOwn(t.row,Te));if(ne.length)return T(`this row mutation reads $_row.${ne.join(", $_row.")} \u2014 send the row its control sits in`);let _e=Object.keys(t.row).filter(Te=>!se.includes(Te));if(_e.length)return T(`the row carries ${_e.join(", ")}, which ${i.name} does not read \u2014 send only $_row.${se.join(", $_row.")}`);for(let Te of se){let Ce=i.rowTypes?.[Te]??null,be=t.row[Te];if(Ce&&!Gt(be,Ce))return T("row fields and scalar types must match the declared table result");j[`_row.${Te}`]=be,ue[`_row.${Te}`]=Ce}}else if(t.row!==void 0)return T("this mutation does not read a row");if(i.reads.builtins.includes("_value")){if(t.value===void 0)return T("cell mutations require value");let ne=i.valueType??null,_e=ne&&ne!=="string"&&t.value===""?null:t.value;if(ne&&!Gt(_e,ne))return T("parameter $_value does not match the edited column's type");j._value=_e,ue._value=ne}else if(t.value!==void 0)return T("this mutation does not accept a value");Object.assign(j,yn(p));let Y=yi(i);return{ok:!0,params:Qt(Y,j),paramTypes:Vt(Y,ue),bindings:{values:j,types:{...Object.fromEntries(Object.entries(ue).filter(ne=>ne[1]!==null)),"_me.id":"user",_now:"timestamp",_tz:"string"},...p}}}var Jn=5e3,Ei=1e4;function qi(l){let i=null,t=null,p=null,g=new Map,T=[],I=null,j=be=>{let re=be.generation;be.loading=re,l.fetch(be.name).then(ye=>{be.generation===re&&(be.base=ye,T=T.filter(Ae=>Ae.confirmedAt===void 0||Ae.confirmedAt>=re),I=null)},()=>{}).finally(()=>{be.loading===re&&delete be.loading})},H=(be,re)=>Object.fromEntries(be.imports.flatMap(ye=>re.has(ye.ref)?[[ye.name,re.get(ye.ref)]]:[])),se=()=>{if(I)return I;let be=new Map;for(let[re,ye]of g)ye.base&&be.set(re,ye.base);for(let re of T){let ye=re.m.target,Ae=be.get(re.ref)?.[ye.table],ge=re.flow.imports.find(Fe=>Fe.name===ye.import)?.tables.find(Fe=>Fe.name===ye.table);if(!i||!Ae||!ge)continue;let Pe=i.mutate({...re.input,table:{schema:ye.import,name:ye.table,rows:Ae.rows,columns:ge.columns},reads:Vn(re.flow,re.m,{imports:H(re.flow,be),userId:re.userId})},{limit:Ei,timeoutMs:Jn});bt(Pe)||be.set(re.ref,{...be.get(re.ref),[ye.table]:{rows:Pe.rows,columns:ge.columns}})}return I=be},ue=be=>H(be,se()),Y=!1,ne=()=>{if(Y)throw new Error("the page engine is closed");if(!i)throw new Error("the page engine is not loaded");return i},_e=be=>{let re=be.imports.map(Ae=>Ae.name),ye=JSON.stringify(re);return t?.schemas!==ye&&(t?.db.close(),t={schemas:ye,db:ne().held(re)}),t.db},Te=(be,re,ye)=>Si({run:async Ae=>_e(be).run(Ae,{limit:Ae.limit??At,pageLimit:Ae.page?.limit??Ae.limit??At,timeoutMs:Jn})},be,ue(be),{userId:re.userId,now:re.now,tz:re.tz,values:re.values,...ye.only?{only:ye.only}:{},...ye.page?{page:ye.page}:{},...re.localTables?{localTables:re.localTables}:{}}),Ce=(be,re,ye,Ae)=>{let ge=Gn(be,re,ye,Ae);if(!ge.ok)throw new Error(ge.detail);return ge};return{close(){Y=!0,t?.db.close(),t=null},prepare(be,re){if(!Y){p??=l.load().then(ye=>{i=ye,I=null},()=>{});for(let ye of re){let Ae=wn(be,ye);if(!Ae)continue;let ge=g.get(Ae);ge||g.set(Ae,ge={name:ye,generation:1}),!ge.base&&ge.loading===void 0&&j(ge)}}},ready(be,re){return!Y&&!!i&&re.every(ye=>{let Ae=wn(be,ye);return!!Ae&&!!g.get(Ae)?.base})},invalidate(be){for(let re of new Set(be)){let ye=g.get(re);ye&&(ye.generation++,delete ye.base,I=null,j(ye))}},async run(be,re,ye){let Ae=await Te(be,ye,{only:re});return{tables:Ae.tables,errors:Ae.errors}},async page(be,re,ye,Ae){let ge=await Te(be,Ae,{page:{name:re,...ye}}),Pe=ge.tables[re];if(!Pe)throw new Error(ge.errors[re]??`no rows for "${re}"`);return Pe},async write(be,re,ye,Ae){let{params:ge,paramTypes:Pe}=Ce(be,re,ye,Ae),Fe=vn(be,ye.localTables);return vi(be,re,{tables:Fe},{mutate:async Ne=>ne().mutate(Ne,{limit:Ei,timeoutMs:Jn})},{params:ge,paramTypes:Pe,reads:Vn(be,re,{imports:ue(be),tables:Fe,userId:Ae.userId})})},apply(be,re,ye,Ae){let ge="import"in re.target?wn(be,re.target.import):void 0;if(Y||!i||!ge)return null;let Pe=Gn(be,re,ye,Ae);if(!Pe.ok)return null;let Fe={flow:be,m:re,ref:ge,userId:Ae.userId,input:{sql:re.sql,params:Pe.params,paramTypes:Pe.paramTypes,...re.expectedAffected===void 0?{}:{expectedAffected:re.expectedAffected}}},Ne=se().get(ge);return T=[...T,Fe],I=null,se().get(ge)===Ne?(T=T.filter(ft=>ft!==Fe),I=null,null):{settle(ft){T.includes(Fe)&&(ft?Fe.confirmedAt=g.get(ge)?.generation??0:(T=T.filter(rt=>rt!==Fe),I=null))}}}}}function ms(l){let i=null,t=async()=>{if(typeof l!="string")return l();let p=await fetch(l,{credentials:"omit"});if(!p.ok)throw new Error(`the SQLite engine did not load (${p.status})`);return p.arrayBuffer()};return()=>i??=Promise.all([Promise.resolve().then(()=>(ds(),fs)),t()]).then(([p,g])=>p.loadSqlite(g))}function xu(l,i){return qi({load:ms(l),fetch:i})}export{xu as pageEngine};
|
|
4
|
+
) AS _model`),this.#n.add(i.table.toLowerCase()),this.#p(i.schema,i.table,i.columns)}createViews(i){let t=i;for(;t.length;){let p=t.filter(g=>{try{return this.createView(g),!1}catch{return!0}});if(p.length===t.length)return;t=p}}registeredFunctions(){return this.exec("SELECT name, narg, type FROM pragma_function_list WHERE builtin = 0").map(i=>({name:String(i.name),arity:Number(i.narg),kind:i.type==="a"?"aggregate":i.type==="w"?"window":"scalar"}))}#p(i,t,p){this.#t.set(_t(i,t),new Map(p.map(g=>[g.name.toLowerCase(),g])))}prepare(i,t,p){let g=t==="write"?"Mutation":"Query";this.#f=t,this.#o=p??null,this.#l=[],this.#c=null;let T,I=this.#l;try{T=this.#e.prepare(i)}catch(j){throw this.#c?new nt(this.#c):new Error(or(j))}finally{this.#l=null}try{let j=this.sqlite3.capi.sqlite3_sql(T.pointer);if(!i.startsWith(j)||!this.#h(i.slice(j.length)))throw new nt(`a <${g}> holds exactly one statement \u2014 split it into separate <${g}> declarations`);let H=this.#w(T,I);return this.#S(T,H,t,g),new ar(this,T,H)}catch(j){throw T.finalize(),j}}#h(i){if(!i.trim())return!0;let{capi:t,wasm:p}=this.sqlite3,[g,T]=p.allocCString(i,!0),I=p.pstack.pointer,j=this.#l;this.#l=null;try{let H=p.pstack.allocPtr(),se=p.pstack.allocPtr(),ue=g+T;for(let Y=g;Y<ue;){let ne=t.sqlite3_prepare_v3(this.#e.pointer,Y,ue-Y,0,H,se),_e=p.peekPtr(H);if(_e)return t.sqlite3_finalize(_e),!1;if(ne!==t.SQLITE_OK)return!1;let Te=p.peekPtr(se);if(Te<=Y)return!1;Y=Te}return!0}finally{this.#l=j,p.pstack.restore(I),p.dealloc(g)}}#y(i){let{capi:t}=this.sqlite3;if(this.#i||(this.#l?.push(i),i.source&&this.#r.has(i.source)))return t.SQLITE_OK;let p=this.#b(i);return p===null?t.SQLITE_OK:(this.#c??=p,t.SQLITE_DENY)}#b(i){let{capi:t}=this.sqlite3,p=i.object?.toLowerCase()??"";switch(i.code){case t.SQLITE_SELECT:case t.SQLITE_RECURSIVE:return null;case t.SQLITE_READ:return this.#_(p)?`${i.object} is not data a statement may read (system and virtual tables are refused)`:i.db&&!sr.has(p)&&!this.#t.has(_t(i.db,p))?`${i.db}.${i.object} is not a table this statement may read`:null;case t.SQLITE_FUNCTION:{let g=(i.column??"").toLowerCase();return xn.has(g)||ir.has(g)||this.#a.has(g)?null:`function ${g}() is not available`}case t.SQLITE_INSERT:case t.SQLITE_UPDATE:case t.SQLITE_DELETE:return this.#f==="read"?"a <Query> may only SELECT \u2014 a document reads its data, it never writes it; a write is a <Mutation>":this.#_(p)||!i.db||!this.#t.has(_t(i.db,p))||this.#n.has(p)?`${i.object} is not a table a <Mutation> may write`:this.#o&&_t(i.db,p)!==_t(this.#o.schema,this.#o.table)?`a <Mutation> writes only its own table ${this.#o.table}, not ${i.object}`:null;default:return`${Yo[i.code]??"this statement"} is not allowed \u2014 a <Query> is one SELECT, a <Mutation> one INSERT, UPDATE or DELETE`}}#_(i){return i.startsWith("sqlite_")||i.startsWith("pragma_")||this.#u.has(i)&&!sr.has(i)}#w(i,t){let{capi:p}=this.sqlite3,{SQLITE_READ:g,SQLITE_SELECT:T,SQLITE_RECURSIVE:I,SQLITE_FUNCTION:j,SQLITE_INSERT:H,SQLITE_UPDATE:se,SQLITE_DELETE:ue}=p,Y=t.filter(ge=>!(ge.source&&this.#r.has(ge.source))),ne=new Set(Y.filter(ge=>(ge.code===T||ge.code===I)&&ge.source).map(ge=>ge.source.toLowerCase()).filter(ge=>!this.#n.has(ge))),_e=[],Te=new Set;for(let ge of Y){if(ge.code!==g||!ge.object)continue;let Pe=ge.object;if(ge.source&&this.#n.has(ge.source.toLowerCase())||sr.has(Pe.toLowerCase()))continue;let Le=ge.db;if(!Le&&(ne.has(Pe.toLowerCase())||(Le=this.#s.find(rt=>this.#t.has(_t(rt,Pe)))??null,!Le)))continue;let Ne=(ge.column??"").toLowerCase()==="rowid"?"rowid":ge.column??"",ft=`${_t(Le,Pe)}\0${Ne.toLowerCase()}`;Te.has(ft)||(Te.add(ft),_e.push({schema:Le,table:Pe,column:Ne}))}let Ce=[];for(let ge of Y){let Pe=ge.code===H?"insert":ge.code===se?"update":ge.code===ue?"delete":null;if(!Pe||!ge.object||!ge.db)continue;let Le=Ce.find(Ne=>Ne.op===Pe&&_t(Ne.schema,Ne.table)===_t(ge.db,ge.object));Le||Ce.push(Le={schema:ge.db,table:ge.object,op:Pe,...Pe==="update"?{columns:[]}:{}}),Pe==="update"&&ge.column&&!Le.columns.includes(ge.column)&&Le.columns.push(ge.column)}let be=[...new Set(Y.filter(ge=>ge.code===j&&ge.column).map(ge=>ge.column.toLowerCase()))],re=[];for(let ge=1;ge<=i.parameterCount;ge++){let Pe=p.sqlite3_bind_parameter_name(i.pointer,ge);if(!Pe||Pe.startsWith("?"))throw new nt("parameters are named ($name); ? placeholders are not supported");re.push(Pe.slice(1))}let ye=Array.from({length:i.columnCount},(ge,Pe)=>{let Le=this.#g(i,Pe);return{name:i.getColumnName(Pe),declaredType:Le?.column.type??null,...Le?{origin:Le.at}:{}}});return{kind:Ce[0]?.op??"select",reads:_e,writes:Ce,functions:be,params:re,columns:ye}}#S(i,t,p,g){let{capi:T}=this.sqlite3;if(T.sqlite3_stmt_isexplain(i.pointer))throw new nt("EXPLAIN is not allowed");let I=T.sqlite3_stmt_readonly(i.pointer)!==0,j=t.kind==="select"&&I&&i.columnCount>0,H=t.kind!=="select"&&!I&&new Set(t.writes.map(ue=>`${ue.op}\0${_t(ue.schema,ue.table)}`)).size===1;if(t.kind!=="select"&&i.columnCount>0)throw new nt("a <Mutation> cannot use RETURNING \u2014 it answers the table's new rows, not a result");if(p==="read"&&!j)throw new nt("a <Query> may only SELECT \u2014 a document reads its data, it never writes it; a write is a <Mutation>");if(p==="write"&&!H)throw new nt("a <Mutation> is one INSERT, UPDATE or DELETE over its own table \u2014 nothing else; a read is a <Query>");if(p==="any"&&!j&&!H)throw new nt(`a <${g}> is one SELECT, or one INSERT, UPDATE or DELETE over one table`);let se=t.kind==="select"?t.functions.find(ue=>jr.has(ue)):void 0;if(se)throw new nt(`function ${se}() is allowed only in a <Mutation> \u2014 its result would differ between runs`)}#g(i,t){let{capi:p}=this.sqlite3,g=p.sqlite3_column_database_name(i.pointer,t),T=p.sqlite3_column_table_name(i.pointer,t),I=p.sqlite3_column_origin_name(i.pointer,t);if(!g||!T||!I)return null;let j=this.#t.get(_t(g,T))?.get(I.toLowerCase());return j?{column:j,at:{schema:g,table:T,column:I}}:null}#v(i,t){return this.#g(i,t)?.column??null}resultColumn(i,t,p,g){let T=this.#v(i,t);if(T)return T.type==="user"?{...T,name:p.name}:{name:p.name,type:T.type};let I=g.map(se=>se[t]).filter(se=>se!=null),j=se=>I.length>0&&I.every(se),H=j(se=>typeof se=="number"||typeof se=="bigint")?"number":j(se=>typeof se=="string"&&Yt(se)!==null)?"date":j(se=>typeof se=="string"&&Ko.test(se))?"timestamp":"string";return{name:p.name,type:H}}within(i,t){this.#d=performance.now()+i,this.#m=!1;try{t()}catch(p){throw this.#m?new St("interrupted"):new Error(or(p))}finally{this.#d=1/0}}},Yo={0:"COPY",1:"CREATE INDEX",2:"CREATE TABLE",3:"CREATE INDEX",4:"CREATE TABLE",5:"CREATE TRIGGER",6:"CREATE VIEW",7:"CREATE TRIGGER",8:"CREATE VIEW",10:"DROP INDEX",11:"DROP TABLE",12:"DROP INDEX",13:"DROP TABLE",14:"DROP TRIGGER",15:"DROP VIEW",16:"DROP TRIGGER",17:"DROP VIEW",19:"PRAGMA",22:"BEGIN/COMMIT/ROLLBACK",24:"ATTACH",25:"DETACH",26:"ALTER TABLE",27:"REINDEX",28:"ANALYZE",29:"CREATE VIRTUAL TABLE",30:"DROP VIRTUAL TABLE",32:"SAVEPOINT"}});var Lt,In=Oe(()=>{"use strict";Lt={maxRows:1e4,timeoutMs:5e3}});function lr(l,i){let t=i.sort?`${ta}${Xo(i.sort.col)} ${i.sort.dir==="desc"?"DESC":"ASC"} NULLS LAST`:"";return{...l,sql:`${Zo}${l.sql}${ea}${t} LIMIT ${Math.trunc(i.limit)} OFFSET ${Math.trunc(i.offset)}`}}var Xo,Zo,ea,ta,Bi=Oe(()=>{"use strict";Xo=l=>`"${l.replace(/"/g,'""')}"`,Zo="SELECT * FROM (",ea=") AS _q",ta=" ORDER BY "});function zi(l,i,t){let p=new st(l);try{return kn(p,i,t,()=>{for(let[g,T]of Object.entries(i.imports??{}))for(let[I,j]of Object.entries(T))p.load({schema:g,table:I,...j})})}finally{p.close()}}function Qi(l,i,t){let p=new st(l);try{let g={};try{for(let[T,I]of Object.entries(i.imports??{}))for(let[j,H]of Object.entries(I))p.load({schema:T,table:j,...H})}catch(T){return i.runs.map(I=>Wi({...I,queries:[...i.shared?.queries??[],...I.queries]},T))}return i.shared&&(g=kn(p,i.shared,t(i.shared,-1),()=>{},!0)),i.runs.map((T,I)=>({...g,...p.scratch(()=>kn(p,T,t(T,I),()=>{}))}))}finally{p.close()}}function Vi(l,i){let t=new st(l),p=new Map;try{for(let g of i)t.attach(g)}catch(g){throw t.close(),g}return{run(g,T){let I=()=>{for(let[j,H]of Object.entries(g.imports??{}))for(let[se,ue]of Object.entries(H)){let Y=JSON.stringify([j,se]);p.get(Y)!==ue.rows&&(p.delete(Y),t.drop(j,se),t.load({schema:j,table:se,...ue}),p.set(Y,ue.rows))}};try{I()}catch(j){return Wi(g,j)}return t.scratch(()=>kn(t,g,T,()=>{}))},close:()=>t.close()}}function kn(l,i,t,p,g=!1){let T={},I=i.paramTypes??i.catalog?.paramTypes??{};try{if(i.catalog)ra(l,i);else{for(let[j,H]of Object.entries(i.tables))l.load({schema:"main",table:j,...H});p()}for(let[j,H]of i.queries.entries()){let se=i.page?.name===H.name?i.page:null,ue=!se&&!i.catalog&&(g||j<i.queries.length-1),Y=na(l,H.name,H.sql,i.params,I,se,se?t.pageLimit:t.limit,t.timeoutMs,ue);if(bt(Y)){T[H.name]=Y;continue}let{all:ne,..._e}=Y;if(T[H.name]=_e,!i.catalog)try{l.load({schema:"main",table:H.name,rows:ne??_e.rows,columns:_e.columns})}catch(Te){T[H.name]={error:`result of <Query name="${H.name}"> could not be materialised: ${an(Te)}`}}}}catch(j){for(let H of i.queries)T[H.name]??={error:an(j)}}return T}function na(l,i,t,p,g,T,I,j,H=!1){let se=performance.now(),ue=()=>Math.max(0,j-(performance.now()-se)),Y=[];try{let ne=l.prepare(t,"read");Y.push(ne);let _e=`${ne.text}
|
|
5
|
+
`,Te=ne;if(T){try{Te=l.prepare(lr({name:i,sql:_e},T).sql,"read")}catch(ge){if(!T.sort||ge instanceof nt)throw ge;Te=l.prepare(lr({name:i,sql:_e},{...T,sort:void 0}).sql,"read")}Y.push(Te)}if(H){let{rows:ge,columns:Pe}=Te.bind(p,g).rows(Number.POSITIVE_INFINITY,ue());return ge.length<=I?{rows:ge,columns:Pe}:{rows:ge.slice(0,I),columns:Pe,truncated:!0,totalRows:ge.length,all:ge}}let{rows:Ce,columns:be,more:re}=Te.bind(p,g).rows(I,ue());if(!re&&!T)return{rows:Ce,columns:be};let ye=l.prepare(`SELECT count(*) AS n FROM (${_e}) AS _q`,"read");Y.push(ye);let Ae=Number(ye.bind(p,g).rows(1,ue()).rows[0]?.n);return{rows:Ce,columns:be,...Ae>Ce.length?{truncated:!0}:{},totalRows:Ae}}catch(ne){return ne instanceof St?{error:`<Query name="${i}"> ran too long and was stopped (limit ${j}ms) \u2014 narrow it (filter, aggregate, or LIMIT)`,timedOut:!0}:{error:an(ne)}}finally{for(let ne of Y)ne.finalize()}}function ra(l,i){let t=i.catalog;i.queries.length!==1&&Ft("a catalog read requires exactly one query"),t.tables.length>1e3&&Ft("catalog is too large");let p=new Set;for(let g of t.tables){(!g.name||g.name.length>255||g.name.includes("\0"))&&Ft("invalid catalog identifier");let T=JSON.stringify([g.schema.toLowerCase(),g.name.toLowerCase()]);p.has(T)&&Ft("duplicate catalog table"),p.add(T),typeof g.source=="string"==(typeof g.sql=="string")&&Ft("table requires exactly one source")}for(let g of new Set([t.defaultSchema,...t.tables.map(T=>T.schema)]))g!=="main"&&l.attach(g);for(let g of t.tables){if(g.source===void 0)continue;let T=Object.hasOwn(i.tables,g.source)?i.tables[g.source]:void 0;T||Ft("catalog table data is unavailable"),g.columns.some(I=>!T.columns.some(j=>j.name===I.name&&j.type===I.type))&&Ft("catalog column is unavailable"),l.load({schema:g.schema,table:g.name,columns:g.columns,rows:T.rows})}l.createViews(t.tables.flatMap(g=>g.sql===void 0?[]:[{schema:g.schema,table:g.name,columns:g.columns,sql:g.sql}]))}function Hi(l,i){let t=[],p={},g=new st(l),T=Object.fromEntries(i.paramNames.map(I=>[I,null]));try{for(let[I,j]of Object.entries(i.tables))g.load({schema:"main",table:I,columns:j.columns,rows:[]});for(let[I,j]of Object.entries(i.imports??{}))for(let[H,se]of Object.entries(j))g.load({schema:I,table:H,columns:se.columns,rows:[]});for(let I of i.queries){let j=null;try{j=g.prepare(I.sql,"read"),p[I.name]=j.bind(T,i.paramTypes).rows(Lt.maxRows,Lt.timeoutMs).columns,g.load({schema:"main",table:I.name,columns:p[I.name],rows:[]})}catch(H){delete p[I.name],t.push({name:I.name,error:an(H)})}finally{j?.finalize()}}}finally{g.close()}return{errors:t,columns:p}}var an,Wi,Ft,Gi=Oe(()=>{"use strict";ht();In();Bi();on();an=l=>(l instanceof Error?l.message:String(l)).split(`
|
|
6
|
+
`).slice(0,3).join(" ").trim();Wi=(l,i)=>Object.fromEntries(l.queries.map(t=>[t.name,{error:an(i)}]));Ft=l=>{throw new Error(`Dataset SQL: ${l}`)}});function mt(l,i){throw new Error(`${l}: ${i}`)}function Ji(l,i){return(!l||typeof l!="object"||Array.isArray(l))&&mt(i,"expected an object"),l}function Ki(l,i){l!==null&&!["string","number","boolean"].includes(typeof l)&&mt(i,"expected a scalar"),typeof l=="number"&&!Number.isFinite(l)&&mt(i,"expected a finite number")}function cr(l,i,t=0){t>12&&mt(i,"predicate nesting exceeds 12");let p=Ji(l,i);for(let[g,T]of Object.entries(p)){let I=`${i}.${g}`;if(g==="_and"||g==="_or")Array.isArray(T)||mt(I,"expected an array"),T.forEach((j,H)=>cr(j,`${I}[${H}]`,t+1));else if(g==="_not")cr(T,I,t+1);else{(g.startsWith("_")||!g||g.includes("\0"))&&mt(I,"unsupported predicate");let j=Ji(T,I);for(let[H,se]of Object.entries(j))H==="_is_null"?typeof se!="boolean"&&mt(I,"_is_null requires a boolean"):H==="_in"||H==="_nin"?(Array.isArray(se)||mt(I,"expected an array"),se.forEach(ue=>{Ki(ue,I),ue===null&&mt(I,"null comparisons require _is_null")})):Object.hasOwn(Yi,H)?(Ki(se,I),se===null&&mt(I,"null comparisons require _is_null")):mt(`${I}.${H}`,"unsupported operator")}}}function ur(l,i){if(typeof l=="string"&&/^x-hasura-/i.test(l)){let t=l.toLowerCase(),p=i[t];return(!Object.hasOwn(i,t)||p===void 0)&&mt(t,"required server session variable is unavailable"),p}return l}function fr(l,i,t,p="policy"){cr(l,"predicate");let g={},T=0,I=H=>{let se=`${p}_${T++}`;return g[se]=ur(H,t),`$${se}`},j=H=>{let se=Object.entries(H).map(([ue,Y])=>{if(ue==="_and"||ue==="_or"){let Te=Y.map(j);return Te.length?`(${Te.join(ue==="_and"?" AND ":" OR ")})`:ue==="_and"?"TRUE":"FALSE"}if(ue==="_not")return`(NOT ${j(Y)})`;i.includes(ue)||mt(ue,"unknown column");let ne=`"${ue.replaceAll('"','""')}"`,_e=Object.entries(Y).map(([Te,Ce])=>{if(Te==="_is_null")return`${ne} IS ${Ce?"":"NOT "}NULL`;if(Te==="_in"||Te==="_nin"){let be=Ce;return be.length?`${ne} ${Te==="_nin"?"NOT ":""}IN (${be.map(I).join(", ")})`:Te==="_in"?"FALSE":"TRUE"}return`${ne} ${Yi[Te]} ${I(Ce)}`});return _e.length?`(${_e.join(" AND ")})`:"TRUE"});return se.length?`(${se.join(" AND ")})`:"TRUE"};return{sql:j(l),params:g}}var Yi,Xi=Oe(()=>{"use strict";Yi={_eq:"=",_neq:"<>",_gt:">",_gte:">=",_lt:"<",_lte:"<="}});function ia(l,i,t,p,g){l.operations.includes(i)||kt("operation is not permitted");let I=l.table[`${i}_permissions`]?.find(se=>se.role===l.role)?.permission??kt("no matching role permission");(p.some(se=>se.toLowerCase().startsWith("__policy_"))||Object.keys(g).some(se=>se.toLowerCase().startsWith("__policy_")))&&kt("reserved policy identifier"),i==="update"&&ts(I,t.writes[0]?.columns??[]);let j=new Set((l.execution?.functions?.deny??[]).map(se=>se.toLowerCase())),H=l.execution?.functions?.allow?.map(se=>se.toLowerCase());for(let se of t.functions)(j.has(se)||H&&!H.includes(se))&&kt(`function ${se} is not permitted`);return I}function ts(l,i){"columns"in l&&l.columns!==void 0&&l.columns!=="*"&&i.some(t=>!l.columns.includes(t))&&kt("a written column is not permitted")}function ns(l,i,t,p={}){let g=performance.now(),T=()=>Math.max(0,t.timeoutMs-(performance.now()-g)),I=i.table.columns.length?i.table.columns:Ht(i.table.rows),j=I.map(_e=>_e.name),H={schema:i.table.schema??"main",table:i.table.name,columns:I},se=`${Rn(H.schema)}.${Rn(H.table)}`,ue=new st(l),Y=[],ne;try{if(j.some(Fe=>/^(rowid|oid|_rowid_)$/i.test(Fe)))throw new Error(`a column named ${j.find(Fe=>/^(rowid|oid|_rowid_)$/i.test(Fe))} cannot be written by a <Mutation>`);ne=p.setupMutation?.(ue,{input:i,dryRun:!1});let _e=new dr(ue,se,I.length);ue.createTable(H,Fe=>`${_e.unset}(${Fe})`),ue.insertRows(H,i.table.rows);for(let Fe of i.reads??[])ue.load(Fe);_e.install();let Te=ue.prepare(i.sql,"write",H);Y.push(Te);let Ce=Te.analysis.kind,be=i.policy,re=be?ia(be,Ce,Te.analysis,j,i.params):null;if(be&&re&&"filter"in re){let Fe=fr(re.filter,j,be.session,"__policy_filter");_e.visible=new Set(ue.exec(`SELECT rowid AS id FROM ${se} WHERE ${Fe.sql}`,Zi(Fe.params)).map(je=>Number(je.id)))}if(Te.bind(i.params,i.paramTypes).run(T()),_e.stop(),!_e.within(Ce)){let Fe=`the ${Ce.toUpperCase()} changed rows outside its own operation (a REPLACE, or a changed rowid) \u2014 not supported`;throw be&&kt(Fe),new Error(Fe)}let ye=Ce==="insert"?_e.named(j):Ce==="update"?Te.analysis.writes[0]?.columns??[]:[],Ae={operation:Ce,columns:ye,functions:Te.analysis.functions};if(be&&re&&Ce==="insert"&&ts(re,ye),be&&i.policyPreview)return{rows:i.table.rows,columns:I,affected:0,analysis:Ae};let ge=JSON.stringify(Ce==="insert"?_e.inserted:_e.updated),Pe="rowid IN (SELECT value FROM json_each($__policy_ids))",Le=be&&re&&"set"in re&&re.set?Object.entries(re.set):[];if(Le.length){let Fe={$__policy_ids:ge},je=Le.map(([Xe,ot],un)=>{let Nn=I.find(Mn=>Mn.name===Xe)??kt("unknown preset column");return Fe[`$__policy_set_${un}`]=sn(Nn.type,ur(ot,be.session),`preset ${Xe}`),`${Rn(Xe)} = $__policy_set_${un}`});ue.exec(`UPDATE ${se} SET ${je.join(", ")} WHERE ${Pe}`,Fe)}if(be&&re&&"check"in re&&re.check&&Ce!=="delete"){let Fe=fr(re.check,j,be.session,"__policy_check"),[je]=ue.exec(`SELECT count(*) AS n FROM ${se} WHERE ${Pe} AND (${Fe.sql}) IS NOT TRUE`,{...Zi(Fe.params),$__policy_ids:ge});Number(je?.n)&&kt("a resulting row failed its check")}let Ne=Ce==="insert"?_e.inserted.length:Ce==="update"?_e.updated.length:_e.deleted.length,ft=new Set([...ye,...Le.map(([Fe])=>Fe)]),rt=Ce==="delete"?[]:I.filter(Fe=>Fe.type==="user"&&ft.has(Fe.name)),Et=rt.length?ue.exec(`SELECT ${rt.map(Fe=>Rn(Fe.name)).join(", ")} FROM ${se} WHERE ${Pe}`,{$__policy_ids:ge}):[],Pn=be||I.some(Fe=>Fe.type==="user")?{affected:Ne,analysis:Ae,userWrites:Et}:{affected:Ne};if(i.expectedAffected!==void 0&&Ne!==i.expectedAffected)return Ne===0?{error:"the row changed since it was read",code:"row_changed"}:Ne>i.expectedAffected?{error:`the mutation matched ${Ne} rows; expected ${i.expectedAffected}`,code:"row_not_unique"}:{error:`the mutation changed ${Ne} rows; expected ${i.expectedAffected}`,code:"row_changed"};let ln=ne?.();if(ln)return{error:"Execution requires continuation",continuation:ln};let cn=ue.prepare(`SELECT * FROM ${se}`,"read");Y.push(cn);let{rows:Cn,more:Dn}=cn.rows(t.limit,T());if(Dn){let[Fe]=ue.exec(`SELECT count(*) AS n FROM ${se}`);return{error:`this write would leave ${Number(Fe?.n)} rows, over the dataset cap of ${t.limit} rows \u2014 delete rows first, or keep the dataset under the cap`,full:!0}}return{rows:Cn,columns:i.table.columns,...Pn}}catch(_e){if(_e instanceof St)return{error:`the mutation ran too long and was stopped (limit ${t.timeoutMs}ms)`,timedOut:!0};if(_e instanceof On)return{error:_e.message,code:"policy_denied"};let Te=ne?.();return Te?{error:"Execution requires continuation",continuation:Te}:{error:es(_e)}}finally{for(let _e of Y)_e.finalize();ue.close()}}function rs(l,i,t={}){let p=[],g=Object.fromEntries(i.paramNames.map(T=>[T,null]));for(let T of i.mutations){let I=new st(l),j=null;try{t.setupMutation?.(I,{dryRun:!0});let H=T.tableName??`ref_${T.target}`,se=i.tables[H];se&&I.createTable({schema:"main",table:H,columns:se.columns}),j=I.prepare(T.sql,"write",{schema:"main",table:H}),j.bind(g,{...i.paramTypes,...T.paramTypes}).run(Lt.timeoutMs)}catch(H){p.push({name:T.name,error:es(H)})}finally{j?.finalize(),I.close()}}return{errors:p}}var On,kt,Rn,es,dr,Zi,is=Oe(()=>{"use strict";Xi();It();In();on();On=class extends Error{},kt=l=>{throw new On(`Dataset policy: ${l}`)},Rn=l=>`"${l.replaceAll('"','""')}"`,es=l=>(l instanceof Error?l.message:String(l)).split(`
|
|
7
|
+
`).slice(0,3).join(" ").trim(),dr=class{constructor(i,t,p){this.db=i;this.target=t;this.#t=Array.from({length:p},()=>0),this.unset=i.internalFunction(g=>(this.#e&&this.#t[Number(g)]++,null),1)}db;target;inserted=[];updated=[];deleted=[];moved=!1;visible=null;#e=!0;#t;unset;install(){let i=this.db.internalFunction(g=>this.#e&&this.visible&&!this.visible.has(Number(g))?1:0,1),t=this.db.internalFunction((g,T,I)=>(this.#e&&(g==="i"?this.inserted.push(Number(I)):g==="d"?this.deleted.push(Number(T)):(this.updated.push(Number(T)),T!==I&&(this.moved=!0))),null),3),p=this.target;for(let g of[`BEFORE UPDATE ON ${p} WHEN ${i}(OLD.rowid) BEGIN SELECT RAISE(IGNORE); END`,`BEFORE DELETE ON ${p} WHEN ${i}(OLD.rowid) BEGIN SELECT RAISE(IGNORE); END`,`AFTER INSERT ON ${p} BEGIN SELECT ${t}('i', NULL, NEW.rowid); END`,`AFTER UPDATE ON ${p} BEGIN SELECT ${t}('u', OLD.rowid, NEW.rowid); END`,`AFTER DELETE ON ${p} BEGIN SELECT ${t}('d', OLD.rowid, NULL); END`])this.db.exec(`CREATE TEMP TRIGGER ${this.db.internalName()} ${g}`)}stop(){this.#e=!1}named(i){return this.inserted.length?i.filter((t,p)=>this.#t[p]<this.inserted.length):[]}within(i){return i==="insert"?!this.updated.length&&!this.deleted.length:i==="update"?!this.inserted.length&&!this.deleted.length&&!this.moved:!this.inserted.length&&!this.updated.length}},Zi=l=>Object.fromEntries(Object.entries(l).map(([i,t])=>[`$${i}`,sn(void 0,t,i)]))});async function mr(l={}){var i,t=l,p=!!globalThis.window,g=!!globalThis.WorkerGlobalScope;globalThis.process?.versions?.node&&globalThis.process?.type;var T="./this.program",I=import.meta.url,j="";function H(e){return t.locateFile?t.locateFile(e,j):j+e}var se,ue;if(p||g){try{j=new URL(".",I).href}catch{}g&&(ue=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),se=async e=>{var n=await fetch(e,{credentials:"same-origin"});if(n.ok)return n.arrayBuffer();throw new Error(n.status+" : "+n.url)}}var Y=console.log.bind(console),ne=console.error.bind(console),_e,Te=!1,Ce,be,re=!1;function ye(){var e=yt.buffer;ot=new Int8Array(e),Fe=new Int16Array(e),Rt=new Uint8Array(e),Mn=new Uint16Array(e),je=new Int32Array(e),We=new Uint32Array(e),un=new Float32Array(e),Nn=new Float64Array(e),Xe=new BigInt64Array(e),_s=new BigUint64Array(e)}function Ae(){if(t.wasmMemory)yt=t.wasmMemory;else{var e=t.INITIAL_MEMORY||8388608;yt=new WebAssembly.Memory({initial:e/65536,maximum:32768})}ye()}function ge(){if(t.preRun)for(typeof t.preRun=="function"&&(t.preRun=[t.preRun]);t.preRun.length;)hs(t.preRun.shift());_r(hr)}function Pe(){re=!0,!t.noFSInit&&!f.initialized&&f.init(),qt.init(),Bt.__wasm_call_ctors(),f.ignorePermissions=!1}function Le(){if(t.postRun)for(typeof t.postRun=="function"&&(t.postRun=[t.postRun]);t.postRun.length;)gs(t.postRun.shift());_r(gr)}function Ne(e){t.onAbort?.(e),e=`Aborted(${e})`,ne(e),Te=!0,e+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(e);throw be?.(n),n}var ft;function rt(){return t.locateFile?H("sqlite3.wasm"):new URL("sqlite3.wasm",import.meta.url).href}function Et(e){if(e==ft&&_e)return new Uint8Array(_e);if(ue)return ue(e);throw"both async and sync fetching of the wasm failed"}async function Pn(e){if(!_e)try{var n=await se(e);return new Uint8Array(n)}catch{}return Et(e)}async function ln(e,n){try{var c=await Pn(e);return await WebAssembly.instantiate(c,n)}catch(o){ne(`failed to asynchronously prepare wasm: ${o}`),Ne(o)}}async function cn(e,n,c){if(!e)try{var o=fetch(n,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(o,c)}catch(r){ne(`wasm streaming compile failed: ${r}`),ne("falling back to ArrayBuffer instantiation")}return ln(n,c)}function Cn(){return{env:Pr,wasi_snapshot_preview1:Pr}}async function Dn(){function e(o,r){return Bt=o.exports,vo(Bt),Bt}function n(o){return e(o.instance)}var c=Cn();return t.instantiateWasm?new Promise((o,r)=>{t.instantiateWasm(c,(s,a)=>{o(e(s,a))})}):(ft??=rt(),n(await cn(_e,ft,c)))}var Fe,je,Xe,ot,un,Nn,Mn,We,_s,Rt,_r=e=>{for(;e.length>0;)e.shift()(t)},gr=[],gs=e=>gr.push(e),hr=[],hs=e=>hr.push(e),yt,Ve={isAbs:e=>e.charAt(0)==="/",splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,n)=>{for(var c=0,o=e.length-1;o>=0;o--){var r=e[o];r==="."?e.splice(o,1):r===".."?(e.splice(o,1),c++):c&&(e.splice(o,1),c--)}if(n)for(;c;c--)e.unshift("..");return e},normalize:e=>{var n=Ve.isAbs(e),c=e.slice(-1)==="/";return e=Ve.normalizeArray(e.split("/").filter(o=>!!o),!n).join("/"),!e&&!n&&(e="."),e&&c&&(e+="/"),(n?"/":"")+e},dirname:e=>{var n=Ve.splitPath(e),c=n[0],o=n[1];return!c&&!o?".":(o&&(o=o.slice(0,-1)),c+o)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>Ve.normalize(e.join("/")),join2:(e,n)=>Ve.normalize(e+"/"+n)},ys=()=>e=>(crypto.getRandomValues(e),0),yr=e=>(yr=ys())(e),jt={resolve:(...e)=>{for(var n="",c=!1,o=e.length-1;o>=-1&&!c;o--){var r=o>=0?e[o]:f.cwd();if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)return"";n=r+"/"+n,c=Ve.isAbs(r)}return n=Ve.normalizeArray(n.split("/").filter(s=>!!s),!c).join("/"),(c?"/":"")+n||"."},relative:(e,n)=>{e=jt.resolve(e).slice(1),n=jt.resolve(n).slice(1);function c(q){for(var V=0;V<q.length&&q[V]==="";V++);for(var N=q.length-1;N>=0&&q[N]==="";N--);return V>N?[]:q.slice(V,N-V+1)}for(var o=c(e.split("/")),r=c(n.split("/")),s=Math.min(o.length,r.length),a=s,m=0;m<s;m++)if(o[m]!==r[m]){a=m;break}for(var d=[],m=a;m<o.length;m++)d.push("..");return d=d.concat(r.slice(a)),d.join("/")}},br=new TextDecoder,wr=(e,n,c,o)=>{var r=n+c;if(o)return r;for(;e[n]&&!(n>=r);)++n;return n},Xt=(e,n=0,c,o)=>{var r=wr(e,n,c,o);return br.decode(e.buffer?e.subarray(n,r):new Uint8Array(e.slice(n,r)))},Ln=[],fn=e=>{for(var n=0,c=0;c<e.length;++c){var o=e.charCodeAt(c);o<=127?n++:o<=2047?n+=2:o>=55296&&o<=57343?(n+=4,++c):n+=3}return n},Sr=(e,n,c,o)=>{if(!(o>0))return 0;for(var r=c,s=c+o-1,a=0;a<e.length;++a){var m=e.codePointAt(a);if(m<=127){if(c>=s)break;n[c++]=m}else if(m<=2047){if(c+1>=s)break;n[c++]=192|m>>6,n[c++]=128|m&63}else if(m<=65535){if(c+2>=s)break;n[c++]=224|m>>12,n[c++]=128|m>>6&63,n[c++]=128|m&63}else{if(c+3>=s)break;n[c++]=240|m>>18,n[c++]=128|m>>12&63,n[c++]=128|m>>6&63,n[c++]=128|m&63,a++}}return n[c]=0,c-r},Fn=(e,n,c)=>{var o=c>0?c:fn(e)+1,r=new Array(o),s=Sr(e,r,0,r.length);return n&&(r.length=s),r},bs=()=>{if(!Ln.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
8
|
+
`)),!e)return null;Ln=Fn(e,!0)}return Ln.shift()},qt={ttys:[],init(){},shutdown(){},register(e,n){qt.ttys[e]={input:[],output:[],ops:n},f.registerDevice(e,qt.stream_ops)},stream_ops:{open(e){var n=qt.ttys[e.node.rdev];if(!n)throw new f.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,c,o,r){if(!e.tty||!e.tty.ops.get_char)throw new f.ErrnoError(60);for(var s=0,a=0;a<o;a++){var m;try{m=e.tty.ops.get_char(e.tty)}catch{throw new f.ErrnoError(29)}if(m===void 0&&s===0)throw new f.ErrnoError(6);if(m==null)break;s++,n[c+a]=m}return s&&(e.node.atime=Date.now()),s},write(e,n,c,o,r){if(!e.tty||!e.tty.ops.put_char)throw new f.ErrnoError(60);try{for(var s=0;s<o;s++)e.tty.ops.put_char(e.tty,n[c+s])}catch{throw new f.ErrnoError(29)}return o&&(e.node.mtime=e.node.ctime=Date.now()),s}},default_tty_ops:{get_char(e){return bs()},put_char(e,n){n===null||n===10?(Y(Xt(e.output)),e.output=[]):n!=0&&e.output.push(n)},fsync(e){e.output?.length>0&&(Y(Xt(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,c){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,n){n===null||n===10?(ne(Xt(e.output)),e.output=[]):n!=0&&e.output.push(n)},fsync(e){e.output?.length>0&&(ne(Xt(e.output)),e.output=[])}}},ws=(e,n)=>Rt.fill(0,e,e+n),vr=(e,n)=>Math.ceil(e/n)*n,Er=e=>{e=vr(e,65536);var n=Or(65536,e);return n&&ws(n,e),n},Re={ops_table:null,mount(e){return Re.createNode(null,"/",16895,0)},createNode(e,n,c,o){if(f.isBlkdev(c)||f.isFIFO(c))throw new f.ErrnoError(63);Re.ops_table||={dir:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr,lookup:Re.node_ops.lookup,mknod:Re.node_ops.mknod,rename:Re.node_ops.rename,unlink:Re.node_ops.unlink,rmdir:Re.node_ops.rmdir,readdir:Re.node_ops.readdir,symlink:Re.node_ops.symlink},stream:{llseek:Re.stream_ops.llseek}},file:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr},stream:{llseek:Re.stream_ops.llseek,read:Re.stream_ops.read,write:Re.stream_ops.write,mmap:Re.stream_ops.mmap,msync:Re.stream_ops.msync}},link:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr,readlink:Re.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Re.node_ops.getattr,setattr:Re.node_ops.setattr},stream:f.chrdev_stream_ops}};var r=f.createNode(e,n,c,o);return f.isDir(r.mode)?(r.node_ops=Re.ops_table.dir.node,r.stream_ops=Re.ops_table.dir.stream,r.contents={}):f.isFile(r.mode)?(r.node_ops=Re.ops_table.file.node,r.stream_ops=Re.ops_table.file.stream,r.usedBytes=0,r.contents=Re.emptyFileContents??=new Uint8Array(0)):f.isLink(r.mode)?(r.node_ops=Re.ops_table.link.node,r.stream_ops=Re.ops_table.link.stream):f.isChrdev(r.mode)&&(r.node_ops=Re.ops_table.chrdev.node,r.stream_ops=Re.ops_table.chrdev.stream),r.atime=r.mtime=r.ctime=Date.now(),e&&(e.contents[n]=r,e.atime=e.mtime=e.ctime=r.atime),r},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,n){var c=e.contents.length;if(!(c>=n)){n=Math.max(n,c*(c<1048576?2:1.125)>>>0),c&&(n=Math.max(n,256));var o=Re.getFileDataAsTypedArray(e);e.contents=new Uint8Array(n),e.contents.set(o)}},resizeFileStorage(e,n){if(e.usedBytes!=n){var c=e.contents;e.contents=new Uint8Array(n),e.contents.set(c.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n}},node_ops:{getattr(e){var n={};return n.dev=f.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,f.isDir(e.mode)?n.size=4096:f.isFile(e.mode)?n.size=e.usedBytes:f.isLink(e.mode)?n.size=e.link.length:n.size=0,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 c of["mode","atime","mtime","ctime"])n[c]!=null&&(e[c]=n[c]);n.size!==void 0&&Re.resizeFileStorage(e,n.size)},lookup(e,n){throw Re.doesNotExistError||(Re.doesNotExistError=new f.ErrnoError(44),Re.doesNotExistError.stack="<generic error, no stack>"),Re.doesNotExistError},mknod(e,n,c,o){return Re.createNode(e,n,c,o)},rename(e,n,c){var o;try{o=f.lookupNode(n,c)}catch{}if(o){if(f.isDir(e.mode))for(var r in o.contents)throw new f.ErrnoError(55);f.hashRemoveNode(o)}delete e.parent.contents[e.name],n.contents[c]=e,e.name=c,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){for(var c in f.lookupNode(e,n).contents)throw new f.ErrnoError(55);delete e.contents[n],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,n,c){var o=Re.createNode(e,n,41471,0);return o.link=c,o},readlink(e){if(!f.isLink(e.mode))throw new f.ErrnoError(28);return e.link}},stream_ops:{read(e,n,c,o,r){var s=e.node.contents;if(r>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-r,o);return n.set(s.subarray(r,r+a),c),a},write(e,n,c,o,r,s){if(n.buffer===ot.buffer&&(s=!1),!o)return 0;var a=e.node;return a.mtime=a.ctime=Date.now(),s?(a.contents=n.subarray(c,c+o),a.usedBytes=o):a.usedBytes===0&&r===0?(a.contents=n.slice(c,c+o),a.usedBytes=o):(Re.expandFileStorage(a,r+o),a.contents.set(n.subarray(c,c+o),r),a.usedBytes=Math.max(a.usedBytes,r+o)),o},llseek(e,n,c){var o=n;if(c===1?o+=e.position:c===2&&f.isFile(e.node.mode)&&(o+=e.node.usedBytes),o<0)throw new f.ErrnoError(28);return o},mmap(e,n,c,o,r){if(!f.isFile(e.node.mode))throw new f.ErrnoError(43);var s,a,m=e.node.contents;if(!(r&2)&&m.buffer===ot.buffer)a=!1,s=m.byteOffset;else{if(a=!0,s=Er(n),!s)throw new f.ErrnoError(48);m&&((c>0||c+n<m.length)&&(m.subarray?m=m.subarray(c,c+n):m=Array.prototype.slice.call(m,c,c+n)),ot.set(m,s))}return{ptr:s,allocated:a}},msync(e,n,c,o,r){return Re.stream_ops.write(e,n,0,o,c,!1),0}}},Ss=e=>{if(typeof e!="string")return e;var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(typeof n>"u")throw new Error(`Unknown file open mode: ${e}`);return n},qr=e=>(typeof e=="string"&&(e=Fn(e,!0)),e.subarray||(e=new Uint8Array(e)),e),jn=(e,n)=>{var c=0;return e&&(c|=365),n&&(c|=146),c},vs=async e=>{var n=await se(e);return new Uint8Array(n)},Es=(...e)=>f.createDataFile(...e),qs=e=>e,Ot=0,Zt=null,Ts=e=>{if(Ot--,t.monitorRunDependencies?.(Ot),Ot==0&&Zt){var n=Zt;Zt=null,n()}},As=e=>{Ot++,t.monitorRunDependencies?.(Ot)},Tr=[],xs=async(e,n)=>{typeof Browser<"u"&&Browser.init();for(var c of Tr)if(c.canHandle(n))return c.handle(e,n);return e},Ar=async(e,n,c,o,r,s,a,m)=>{var d=n?jt.resolve(Ve.join2(e,n)):e,q=qs(`cp ${d}`);As(q);try{var V=c;typeof c=="string"&&(V=await vs(c)),V=await xs(V,d),m?.(),s||Es(e,n,V,o,r,a)}finally{Ts(q)}},Is=(e,n,c,o,r,s,a,m,d,q)=>{Ar(e,n,c,o,r,m,d,q).then(s).catch(a)},f={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,c,o){e||(e=this),this.parent=e,this.mount=e.mount,this.id=f.nextInode++,this.name=n,this.mode=c,this.rdev=o,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 f.isDir(this.mode)}get isDevice(){return f.isChrdev(this.mode)}},lookupPath(e,n={}){if(!e)throw new f.ErrnoError(44);n.follow_mount??=!0,Ve.isAbs(e)||(e=f.cwd()+"/"+e);e:for(var c=0;c<40;c++){for(var o=e.split("/").filter(q=>!!q),r=f.root,s="/",a=0;a<o.length;a++){var m=a===o.length-1;if(m&&n.parent)break;if(o[a]!=="."){if(o[a]===".."){if(s=Ve.dirname(s),f.isRoot(r)){e=s+"/"+o.slice(a+1).join("/"),c--;continue e}else r=r.parent;continue}s=Ve.join2(s,o[a]);try{r=f.lookupNode(r,o[a])}catch(q){if(q?.errno===44&&m&&n.noent_okay)return{path:s};throw q}if(f.isMountpoint(r)&&(!m||n.follow_mount)&&(r=r.mounted.root),f.isLink(r.mode)&&(!m||n.follow)){if(!r.node_ops.readlink)throw new f.ErrnoError(52);var d=r.node_ops.readlink(r);Ve.isAbs(d)||(d=Ve.dirname(s)+"/"+d),e=d+"/"+o.slice(a+1).join("/");continue e}}}return{path:s,node:r}}throw new f.ErrnoError(32)},getPath(e){for(var n;;){if(f.isRoot(e)){var c=e.mount.mountpoint;return n?c[c.length-1]!=="/"?`${c}/${n}`:c+n:c}n=n?`${e.name}/${n}`:e.name,e=e.parent}},hashName(e,n){for(var c=0,o=0;o<n.length;o++)c=(c<<5)-c+n.charCodeAt(o)|0;return(e+c>>>0)%f.nameTable.length},hashAddNode(e){var n=f.hashName(e.parent.id,e.name);e.name_next=f.nameTable[n],f.nameTable[n]=e},hashRemoveNode(e){var n=f.hashName(e.parent.id,e.name);if(f.nameTable[n]===e)f.nameTable[n]=e.name_next;else for(var c=f.nameTable[n];c;){if(c.name_next===e){c.name_next=e.name_next;break}c=c.name_next}},lookupNode(e,n){var c=f.mayLookup(e);if(c)throw new f.ErrnoError(c);for(var o=f.hashName(e.id,n),r=f.nameTable[o];r;r=r.name_next){var s=r.name;if(r.parent.id===e.id&&s===n)return r}return f.lookup(e,n)},createNode(e,n,c,o){var r=new f.FSNode(e,n,c,o);return f.hashAddNode(r),r},destroyNode(e){f.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];return e&512&&(n+="w"),n},nodePermissions(e,n){return f.ignorePermissions?0:n.includes("r")&&!(e.mode&292)||n.includes("w")&&!(e.mode&146)||n.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!f.isDir(e.mode))return 54;var n=f.nodePermissions(e,"x");return n||(e.node_ops.lookup?0:2)},mayCreate(e,n){if(!f.isDir(e.mode))return 54;try{return f.lookupNode(e,n),20}catch{}return f.nodePermissions(e,"wx")},mayDelete(e,n,c){var o;try{o=f.lookupNode(e,n)}catch(s){return s.errno}var r=f.nodePermissions(e,"wx");if(r)return r;if(c){if(!f.isDir(o.mode))return 54;if(f.isRoot(o)||f.getPath(o)===f.cwd())return 10}else if(f.isDir(o.mode))return 31;return 0},mayOpen(e,n){if(!e)return 44;if(f.isLink(e.mode))return 32;var c=f.flagsToPermissionString(n);return f.isDir(e.mode)&&(c!=="r"||n&576)?31:f.nodePermissions(e,c)},checkOpExists(e,n){if(!e)throw new f.ErrnoError(n);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=f.MAX_OPEN_FDS;e++)if(!f.streams[e])return e;throw new f.ErrnoError(33)},getStreamChecked(e){var n=f.getStream(e);if(!n)throw new f.ErrnoError(8);return n},getStream:e=>f.streams[e],createStream(e,n=-1){return e=Object.assign(new f.FSStream,e),n==-1&&(n=f.nextfd()),e.fd=n,f.streams[n]=e,e},closeStream(e){f.streams[e]=null},dupStream(e,n=-1){var c=f.createStream(e,n);return c.stream_ops?.dup?.(c),c},doSetAttr(e,n,c){var o=e?.stream_ops.setattr,r=o?e:n;o??=n.node_ops.setattr,f.checkOpExists(o,63),o(r,c)},chrdev_stream_ops:{open(e){e.stream_ops=f.getDevice(e.node.rdev).stream_ops,e.stream_ops.open?.(e)},llseek(){throw new f.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,n)=>e<<8|n,registerDevice(e,n){f.devices[e]={stream_ops:n}},getDevice:e=>f.devices[e],getMounts(e){for(var n=[],c=[e];c.length;){var o=c.pop();n.push(o),c.push(...o.mounts)}return n},syncfs(e,n){typeof e=="function"&&(n=e,e=!1),f.syncFSRequests++,f.syncFSRequests>1&&ne(`warning: ${f.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var c=f.getMounts(f.root.mount),o=0;function r(m){return f.syncFSRequests--,n(m)}function s(m){if(m)return s.errored?void 0:(s.errored=!0,r(m));++o>=c.length&&r(null)}for(var a of c)a.type.syncfs?a.type.syncfs(a,e,s):s(null)},mount(e,n,c){var o=c==="/",r=!c,s;if(o&&f.root)throw new f.ErrnoError(10);if(!o&&!r){var a=f.lookupPath(c,{follow_mount:!1});if(c=a.path,s=a.node,f.isMountpoint(s))throw new f.ErrnoError(10);if(!f.isDir(s.mode))throw new f.ErrnoError(54)}var m={type:e,opts:n,mountpoint:c,mounts:[]},d=e.mount(m);return d.mount=m,m.root=d,o?f.root=d:s&&(s.mounted=m,s.mount&&s.mount.mounts.push(m)),d},unmount(e){var n=f.lookupPath(e,{follow_mount:!1});if(!f.isMountpoint(n.node))throw new f.ErrnoError(28);var c=n.node,o=c.mounted,r=f.getMounts(o);for(var[s,a]of Object.entries(f.nameTable))for(;a;){var m=a.name_next;r.includes(a.mount)&&f.destroyNode(a),a=m}c.mounted=null;var d=c.mount.mounts.indexOf(o);c.mount.mounts.splice(d,1)},lookup(e,n){return e.node_ops.lookup(e,n)},mknod(e,n,c){var o=f.lookupPath(e,{parent:!0}).node,r=Ve.basename(e);if(!r)throw new f.ErrnoError(28);if(r==="."||r==="..")throw new f.ErrnoError(20);var s=f.mayCreate(o,r);if(s)throw new f.ErrnoError(s);if(!o.node_ops.mknod)throw new f.ErrnoError(63);return o.node_ops.mknod(o,r,n,c)},statfs(e){return f.statfsNode(f.lookupPath(e,{follow:!0}).node)},statfsStream(e){return f.statfsNode(e.node)},statfsNode(e){var n={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:f.nextInode,ffree:f.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(n,e.node_ops.statfs(e.mount.opts.root)),n},create(e,n=438){return n&=4095,n|=32768,f.mknod(e,n,0)},mkdir(e,n=511){return n&=1023,n|=16384,f.mknod(e,n,0)},mkdirTree(e,n){var c=e.split("/"),o="";for(var r of c)if(r){(o||Ve.isAbs(e))&&(o+="/"),o+=r;try{f.mkdir(o,n)}catch(s){if(s.errno!=20)throw s}}},mkdev(e,n,c){return typeof c>"u"&&(c=n,n=438),n|=8192,f.mknod(e,n,c)},symlink(e,n){if(!jt.resolve(e))throw new f.ErrnoError(44);var c=f.lookupPath(n,{parent:!0}).node;if(!c)throw new f.ErrnoError(44);var o=Ve.basename(n),r=f.mayCreate(c,o);if(r)throw new f.ErrnoError(r);if(!c.node_ops.symlink)throw new f.ErrnoError(63);return c.node_ops.symlink(c,o,e)},rename(e,n){var c=Ve.dirname(e),o=Ve.dirname(n),r=Ve.basename(e),s=Ve.basename(n),a=f.lookupPath(e,{parent:!0}),m=a.node,d;if(a=f.lookupPath(n,{parent:!0}),d=a.node,!m||!d)throw new f.ErrnoError(44);if(m.mount!==d.mount)throw new f.ErrnoError(75);var q=f.lookupNode(m,r),V=jt.relative(e,o);if(V.charAt(0)!==".")throw new f.ErrnoError(28);if(V=jt.relative(n,c),V.charAt(0)!==".")throw new f.ErrnoError(55);var N;try{N=f.lookupNode(d,s)}catch{}if(q!==N){var x=f.isDir(q.mode),R=f.mayDelete(m,r,x);if(R)throw new f.ErrnoError(R);if(R=N?f.mayDelete(d,s,x):f.mayCreate(d,s),R)throw new f.ErrnoError(R);if(!m.node_ops.rename)throw new f.ErrnoError(63);if(f.isMountpoint(q)||N&&f.isMountpoint(N))throw new f.ErrnoError(10);if(d!==m&&(R=f.nodePermissions(m,"w"),R))throw new f.ErrnoError(R);f.hashRemoveNode(q);try{m.node_ops.rename(q,d,s),q.parent=d}catch($){throw $}finally{f.hashAddNode(q)}}},rmdir(e){var n=f.lookupPath(e,{parent:!0}).node,c=Ve.basename(e),o=f.lookupNode(n,c),r=f.mayDelete(n,c,!0);if(r)throw new f.ErrnoError(r);if(!n.node_ops.rmdir)throw new f.ErrnoError(63);if(f.isMountpoint(o))throw new f.ErrnoError(10);n.node_ops.rmdir(n,c),f.destroyNode(o)},readdir(e){var n=f.lookupPath(e,{follow:!0}).node;return f.checkOpExists(n.node_ops.readdir,54)(n)},unlink(e){var n=f.lookupPath(e,{parent:!0}).node;if(!n)throw new f.ErrnoError(44);var c=Ve.basename(e),o=f.lookupNode(n,c),r=f.mayDelete(n,c,!1);if(r)throw new f.ErrnoError(r);if(!n.node_ops.unlink)throw new f.ErrnoError(63);if(f.isMountpoint(o))throw new f.ErrnoError(10);n.node_ops.unlink(n,c),f.destroyNode(o)},readlink(e){var n=f.lookupPath(e).node;if(!n)throw new f.ErrnoError(44);if(!n.node_ops.readlink)throw new f.ErrnoError(28);return n.node_ops.readlink(n)},stat(e,n){var c=f.lookupPath(e,{follow:!n}).node;return f.checkOpExists(c.node_ops.getattr,63)(c)},fstat(e){var n=f.getStreamChecked(e),c=n.node,o=n.stream_ops.getattr,r=o?n:c;return o??=c.node_ops.getattr,f.checkOpExists(o,63),o(r)},lstat(e){return f.stat(e,!0)},doChmod(e,n,c,o){f.doSetAttr(e,n,{mode:c&4095|n.mode&-4096,ctime:Date.now(),dontFollow:o})},chmod(e,n,c){var o;typeof e=="string"?o=f.lookupPath(e,{follow:!c}).node:o=e,f.doChmod(null,o,n,c)},lchmod(e,n){f.chmod(e,n,!0)},fchmod(e,n){var c=f.getStreamChecked(e);f.doChmod(c,c.node,n,!1)},doChown(e,n,c){f.doSetAttr(e,n,{timestamp:Date.now(),dontFollow:c})},chown(e,n,c,o){var r;typeof e=="string"?r=f.lookupPath(e,{follow:!o}).node:r=e,f.doChown(null,r,o)},lchown(e,n,c){f.chown(e,n,c,!0)},fchown(e,n,c){var o=f.getStreamChecked(e);f.doChown(o,o.node,!1)},doTruncate(e,n,c){if(f.isDir(n.mode))throw new f.ErrnoError(31);if(!f.isFile(n.mode))throw new f.ErrnoError(28);var o=f.nodePermissions(n,"w");if(o)throw new f.ErrnoError(o);f.doSetAttr(e,n,{size:c,timestamp:Date.now()})},truncate(e,n){if(n<0)throw new f.ErrnoError(28);var c;typeof e=="string"?c=f.lookupPath(e,{follow:!0}).node:c=e,f.doTruncate(null,c,n)},ftruncate(e,n){var c=f.getStreamChecked(e);if(n<0||(c.flags&2097155)===0)throw new f.ErrnoError(28);f.doTruncate(c,c.node,n)},utime(e,n,c){var o=f.lookupPath(e,{follow:!0}).node;f.checkOpExists(o.node_ops.setattr,63)(o,{atime:n,mtime:c})},open(e,n,c=438){if(e==="")throw new f.ErrnoError(44);n=Ss(n),n&64?c=c&4095|32768:c=0;var o,r;if(typeof e=="object")o=e;else{r=e.endsWith("/");var s=f.lookupPath(e,{follow:!(n&131072),noent_okay:!0});o=s.node,e=s.path}var a=!1;if(n&64)if(o){if(n&128)throw new f.ErrnoError(20)}else{if(r)throw new f.ErrnoError(31);o=f.mknod(e,c|511,0),a=!0}if(!o)throw new f.ErrnoError(44);if(f.isChrdev(o.mode)&&(n&=-513),n&65536&&!f.isDir(o.mode))throw new f.ErrnoError(54);if(!a){var m=f.mayOpen(o,n);if(m)throw new f.ErrnoError(m)}n&512&&!a&&f.truncate(o,0),n&=-131713;var d=f.createStream({node:o,path:f.getPath(o),flags:n,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),a&&f.chmod(o,c&511),d},close(e){if(f.isClosed(e))throw new f.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(n){throw n}finally{f.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,n,c){if(f.isClosed(e))throw new f.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new f.ErrnoError(70);if(c!=0&&c!=1&&c!=2)throw new f.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,c),e.ungotten=[],e.position},read(e,n,c,o,r){if(o<0||r<0)throw new f.ErrnoError(28);if(f.isClosed(e))throw new f.ErrnoError(8);if((e.flags&2097155)===1)throw new f.ErrnoError(8);if(f.isDir(e.node.mode))throw new f.ErrnoError(31);if(!e.stream_ops.read)throw new f.ErrnoError(28);var s=typeof r<"u";if(!s)r=e.position;else if(!e.seekable)throw new f.ErrnoError(70);var a=e.stream_ops.read(e,n,c,o,r);return s||(e.position+=a),a},write(e,n,c,o,r,s){if(o<0||r<0)throw new f.ErrnoError(28);if(f.isClosed(e))throw new f.ErrnoError(8);if((e.flags&2097155)===0)throw new f.ErrnoError(8);if(f.isDir(e.node.mode))throw new f.ErrnoError(31);if(!e.stream_ops.write)throw new f.ErrnoError(28);e.seekable&&e.flags&1024&&f.llseek(e,0,2);var a=typeof r<"u";if(!a)r=e.position;else if(!e.seekable)throw new f.ErrnoError(70);var m=e.stream_ops.write(e,n,c,o,r,s);return a||(e.position+=m),m},mmap(e,n,c,o,r){if((o&2)!==0&&(r&2)===0&&(e.flags&2097155)!==2)throw new f.ErrnoError(2);if((e.flags&2097155)===1)throw new f.ErrnoError(2);if(!e.stream_ops.mmap)throw new f.ErrnoError(43);if(!n)throw new f.ErrnoError(28);return e.stream_ops.mmap(e,n,c,o,r)},msync(e,n,c,o,r){return e.stream_ops.msync?e.stream_ops.msync(e,n,c,o,r):0},ioctl(e,n,c){if(!e.stream_ops.ioctl)throw new f.ErrnoError(59);return e.stream_ops.ioctl(e,n,c)},readFile(e,n={}){n.flags=n.flags||0,n.encoding=n.encoding||"binary",n.encoding!=="utf8"&&n.encoding!=="binary"&&Ne(`Invalid encoding type "${n.encoding}"`);var c=f.open(e,n.flags),o=f.stat(e).size,r=new Uint8Array(o);return f.read(c,r,0,o,0),n.encoding==="utf8"&&(r=Xt(r)),f.close(c),r},writeFile(e,n,c={}){c.flags=c.flags||577;var o=f.open(e,c.flags,c.mode);n=qr(n),f.write(o,n,0,n.byteLength,void 0,c.canOwn),f.close(o)},cwd:()=>f.currentPath,chdir(e){var n=f.lookupPath(e,{follow:!0});if(n.node===null)throw new f.ErrnoError(44);if(!f.isDir(n.node.mode))throw new f.ErrnoError(54);var c=f.nodePermissions(n.node,"x");if(c)throw new f.ErrnoError(c);f.currentPath=n.path},createDefaultDirectories(){f.mkdir("/tmp"),f.mkdir("/home"),f.mkdir("/home/web_user")},createDefaultDevices(){f.mkdir("/dev"),f.registerDevice(f.makedev(1,3),{read:()=>0,write:(o,r,s,a,m)=>a,llseek:()=>0}),f.mkdev("/dev/null",f.makedev(1,3)),qt.register(f.makedev(5,0),qt.default_tty_ops),qt.register(f.makedev(6,0),qt.default_tty1_ops),f.mkdev("/dev/tty",f.makedev(5,0)),f.mkdev("/dev/tty1",f.makedev(6,0));var e=new Uint8Array(1024),n=0,c=()=>(n===0&&(yr(e),n=e.byteLength),e[--n]);f.createDevice("/dev","random",c),f.createDevice("/dev","urandom",c),f.mkdir("/dev/shm"),f.mkdir("/dev/shm/tmp")},createSpecialDirectories(){f.mkdir("/proc");var e=f.mkdir("/proc/self");f.mkdir("/proc/self/fd"),f.mount({mount(){var n=f.createNode(e,"fd",16895,73);return n.stream_ops={llseek:Re.stream_ops.llseek},n.node_ops={lookup(c,o){var r=+o,s=f.getStreamChecked(r),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>s.path},id:r+1};return a.parent=a,a},readdir(){return Array.from(f.streams.entries()).filter(([c,o])=>o).map(([c,o])=>c.toString())}},n}},{},"/proc/self/fd")},createStandardStreams(e,n,c){e?f.createDevice("/dev","stdin",e):f.symlink("/dev/tty","/dev/stdin"),n?f.createDevice("/dev","stdout",null,n):f.symlink("/dev/tty","/dev/stdout"),c?f.createDevice("/dev","stderr",null,c):f.symlink("/dev/tty1","/dev/stderr"),f.open("/dev/stdin",0),f.open("/dev/stdout",1),f.open("/dev/stderr",1)},staticInit(){f.nameTable=new Array(4096),f.mount(Re,{},"/"),f.createDefaultDirectories(),f.createDefaultDevices(),f.createSpecialDirectories(),f.filesystems={MEMFS:Re}},init(e,n,c){f.initialized=!0,e??=t.stdin,n??=t.stdout,c??=t.stderr,f.createStandardStreams(e,n,c)},quit(){f.initialized=!1;for(var e of f.streams)e&&f.close(e)},findObject(e,n){var c=f.analyzePath(e,n);return c.exists?c.object:null},analyzePath(e,n){try{var c=f.lookupPath(e,{follow:!n});e=c.path}catch{}var o={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var c=f.lookupPath(e,{parent:!0});o.parentExists=!0,o.parentPath=c.path,o.parentObject=c.node,o.name=Ve.basename(e),c=f.lookupPath(e,{follow:!n}),o.exists=!0,o.path=c.path,o.object=c.node,o.name=c.node.name,o.isRoot=c.path==="/"}catch(r){o.error=r.errno}return o},createPath(e,n,c,o){e=typeof e=="string"?e:f.getPath(e);for(var r=n.split("/").reverse();r.length;){var s=r.pop();if(s){var a=Ve.join2(e,s);try{f.mkdir(a)}catch(m){if(m.errno!=20)throw m}e=a}}return a},createFile(e,n,c,o,r){var s=Ve.join2(typeof e=="string"?e:f.getPath(e),n),a=jn(o,r);return f.create(s,a)},createDataFile(e,n,c,o,r,s){var a=n;e&&(e=typeof e=="string"?e:f.getPath(e),a=n?Ve.join2(e,n):e);var m=jn(o,r),d=f.create(a,m);if(c){c=qr(c),f.chmod(d,m|146);var q=f.open(d,577);f.write(q,c,0,c.length,0,s),f.close(q),f.chmod(d,m)}},createDevice(e,n,c,o){var r=Ve.join2(typeof e=="string"?e:f.getPath(e),n),s=jn(!!c,!!o);f.createDevice.major??=64;var a=f.makedev(f.createDevice.major++,0);return f.registerDevice(a,{open(m){m.seekable=!1},close(m){o?.buffer?.length&&o(10)},read(m,d,q,V,N){for(var x=0,R=0;R<V;R++){var $;try{$=c()}catch{throw new f.ErrnoError(29)}if($===void 0&&x===0)throw new f.ErrnoError(6);if($==null)break;x++,d[q+R]=$}return x&&(m.node.atime=Date.now()),x},write(m,d,q,V,N){for(var x=0;x<V;x++)try{o(d[q+x])}catch{throw new f.ErrnoError(29)}return V&&(m.node.mtime=m.node.ctime=Date.now()),x}}),f.mkdev(r,s,a)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Ne("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=ue(e.url)}catch{throw new f.ErrnoError(29)}},createLazyFile(e,n,c,o,r){class s{lengthKnown=!1;chunks=[];get(N){if(!(N>this.length-1||N<0)){var x=N%this.chunkSize,R=N/this.chunkSize|0;return this.getter(R)[x]}}setDataGetter(N){this.getter=N}cacheLength(){var N=new XMLHttpRequest;N.open("HEAD",c,!1),N.send(null),N.status>=200&&N.status<300||N.status===304||Ne("Couldn't load "+c+". Status: "+N.status);var x=Number(N.getResponseHeader("Content-length")),R,$=(R=N.getResponseHeader("Accept-Ranges"))&&R==="bytes",B=(R=N.getResponseHeader("Content-Encoding"))&&R==="gzip",J=1048576;$||(J=x);var E=(W,ee)=>{W>ee&&Ne("invalid range ("+W+", "+ee+") or no bytes requested!"),ee>x-1&&Ne("only "+x+" bytes available! programmer error!");var O=new XMLHttpRequest;return O.open("GET",c,!1),x!==J&&O.setRequestHeader("Range","bytes="+W+"-"+ee),O.responseType="arraybuffer",O.overrideMimeType&&O.overrideMimeType("text/plain; charset=x-user-defined"),O.send(null),O.status>=200&&O.status<300||O.status===304||Ne("Couldn't load "+c+". Status: "+O.status),O.response!==void 0?new Uint8Array(O.response||[]):Fn(O.responseText||"",!0)},w=this;w.setDataGetter(W=>{var ee=W*J,O=(W+1)*J-1;return O=Math.min(O,x-1),typeof w.chunks[W]>"u"&&(w.chunks[W]=E(ee,O)),typeof w.chunks[W]>"u"&&Ne("doXHR failed!"),w.chunks[W]}),(B||!x)&&(J=x=1,x=this.getter(0).length,J=x,Y("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=x,this._chunkSize=J,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){g||Ne("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var a={isDevice:!1,contents:new s}}else var a={isDevice:!1,url:c};var m=f.createFile(e,n,a,o,r);a.contents?m.contents=a.contents:a.url&&(m.contents=null,m.url=a.url),Object.defineProperties(m,{usedBytes:{get:function(){return this.contents.length}}});var d={};for(let[V,N]of Object.entries(m.stream_ops))d[V]=(...x)=>(f.forceLoadFile(m),N(...x));function q(V,N,x,R,$){var B=V.node.contents;if($>=B.length)return 0;var J=Math.min(B.length-$,R);if(B.slice)for(var E=0;E<J;E++)N[x+E]=B[$+E];else for(var E=0;E<J;E++)N[x+E]=B.get($+E);return J}return d.read=(V,N,x,R,$)=>(f.forceLoadFile(m),q(V,N,x,R,$)),d.mmap=(V,N,x,R,$)=>{f.forceLoadFile(m);var B=Er(N);if(!B)throw new f.ErrnoError(48);return q(V,ot,B,N,x),{ptr:B,allocated:!0}},m.stream_ops=d,m}},ks=(e,n,c)=>{if(!e)return"";var o=wr(Rt,e,n,c);return br.decode(Rt.subarray(e,o))},De={calculateAt(e,n,c){if(Ve.isAbs(n))return n;var o;if(e===-100?o=f.cwd():o=De.getStreamFromFD(e).path,n.length==0){if(!c)throw new f.ErrnoError(44);return o}return o+"/"+n},writeStat(e,n){We[e>>2]=n.dev,We[e+4>>2]=n.mode,We[e+8>>2]=n.nlink,We[e+12>>2]=n.uid,We[e+16>>2]=n.gid,We[e+20>>2]=n.rdev,Xe[e+24>>3]=BigInt(n.size),je[e+32>>2]=4096,je[e+36>>2]=n.blocks;var c=n.atime.getTime(),o=n.mtime.getTime(),r=n.ctime.getTime();return Xe[e+40>>3]=BigInt(Math.floor(c/1e3)),We[e+48>>2]=c%1e3*1e3*1e3,Xe[e+56>>3]=BigInt(Math.floor(o/1e3)),We[e+64>>2]=o%1e3*1e3*1e3,Xe[e+72>>3]=BigInt(Math.floor(r/1e3)),We[e+80>>2]=r%1e3*1e3*1e3,Xe[e+88>>3]=BigInt(n.ino),0},writeStatFs(e,n){We[e+4>>2]=n.bsize,We[e+60>>2]=n.bsize,Xe[e+8>>3]=BigInt(n.blocks),Xe[e+16>>3]=BigInt(n.bfree),Xe[e+24>>3]=BigInt(n.bavail),Xe[e+32>>3]=BigInt(n.files),Xe[e+40>>3]=BigInt(n.ffree),We[e+48>>2]=n.fsid,We[e+64>>2]=n.flags,We[e+56>>2]=n.namelen},doMsync(e,n,c,o,r){if(!f.isFile(n.node.mode))throw new f.ErrnoError(43);if(o&2)return 0;var s=Rt.slice(e,e+c);f.msync(n,s,r,c,o)},getStreamFromFD(e){return f.getStreamChecked(e)},varargs:void 0,getStr(e){return ks(e)}};function Rs(e,n){try{return e=De.getStr(e),f.chmod(e,n),0}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Os(e,n,c,o){try{if(n=De.getStr(n),n=De.calculateAt(e,n),c&-8)return-28;var r=f.lookupPath(n,{follow:!0}).node;if(!r)return-44;var s="";return c&4&&(s+="r"),c&2&&(s+="w"),c&1&&(s+="x"),s&&f.nodePermissions(r,s)?-2:0}catch(a){if(typeof f>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Ps(e,n){try{return f.fchmod(e,n),0}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Cs(e,n,c){try{return f.fchown(e,n,c),0}catch(o){if(typeof f>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var dn=()=>{var e=je[+De.varargs>>2];return De.varargs+=4,e},$t=dn;function Ds(e,n,c){De.varargs=c;try{var o=De.getStreamFromFD(e);switch(n){case 0:var r=dn();if(r<0)return-28;for(;f.streams[r];)r++;return f.dupStream(o,r).fd;case 1:case 2:return 0;case 3:return o.flags;case 4:var r=dn();return o.flags|=r,0;case 12:var r=$t(),s=0;return Fe[r+s>>1]=2,0;case 13:case 14:return 0}return-28}catch(a){if(typeof f>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Ns(e,n){try{return De.writeStat(n,f.fstat(e))}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}var Ms=9007199254740992,Ls=-9007199254740992,Ut=e=>e<Ls||e>Ms?NaN:Number(e);function Fs(e,n){n=Ut(n);try{return isNaN(n)?-61:(f.ftruncate(e,n),0)}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}var Pt=(e,n,c)=>Sr(e,Rt,n,c);function js(e,n){try{if(n===0)return-28;var c=f.cwd(),o=fn(c)+1;return n<o?-68:(Pt(c,e,n),o)}catch(r){if(typeof f>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function $s(e,n,c){De.varargs=c;try{var o=De.getStreamFromFD(e);switch(n){case 21509:return o.tty?0:-59;case 21505:if(!o.tty)return-59;if(o.tty.ops.ioctl_tcgets){var r=o.tty.ops.ioctl_tcgets(o),N=$t();je[N>>2]=r.c_iflag||0,je[N+4>>2]=r.c_oflag||0,je[N+8>>2]=r.c_cflag||0,je[N+12>>2]=r.c_lflag||0;for(var s=0;s<32;s++)ot[N+s+17]=r.c_cc[s]||0;return 0}return 0;case 21510:case 21511:case 21512:return o.tty?0:-59;case 21506:case 21507:case 21508:if(!o.tty)return-59;if(o.tty.ops.ioctl_tcsets){for(var N=$t(),a=je[N>>2],m=je[N+4>>2],d=je[N+8>>2],q=je[N+12>>2],V=[],s=0;s<32;s++)V.push(ot[N+s+17]);return o.tty.ops.ioctl_tcsets(o.tty,n,{c_iflag:a,c_oflag:m,c_cflag:d,c_lflag:q,c_cc:V})}return 0;case 21519:if(!o.tty)return-59;var N=$t();return je[N>>2]=0,0;case 21520:return o.tty?-28:-59;case 21537:case 21531:var N=$t();return f.ioctl(o,n,N);case 21523:if(!o.tty)return-59;if(o.tty.ops.ioctl_tiocgwinsz){var x=o.tty.ops.ioctl_tiocgwinsz(o.tty),N=$t();Fe[N>>1]=x[0],Fe[N+2>>1]=x[1]}return 0;case 21524:return o.tty?0:-59;case 21515:return o.tty?0:-59;default:return-28}}catch(R){if(typeof f>"u"||R.name!=="ErrnoError")throw R;return-R.errno}}function Us(e,n){try{return e=De.getStr(e),De.writeStat(n,f.lstat(e))}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Bs(e,n,c){try{return n=De.getStr(n),n=De.calculateAt(e,n),f.mkdir(n,c,0),0}catch(o){if(typeof f>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function zs(e,n,c,o){try{n=De.getStr(n);var r=o&256,s=o&4096;return o=o&-6401,n=De.calculateAt(e,n,s),De.writeStat(c,r?f.lstat(n):f.stat(n))}catch(a){if(typeof f>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Qs(e,n,c,o){De.varargs=o;try{n=De.getStr(n),n=De.calculateAt(e,n);var r=o?dn():0;return f.open(n,c,r).fd}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function Vs(e,n,c,o){try{if(n=De.getStr(n),n=De.calculateAt(e,n),o<=0)return-28;var r=f.readlink(n),s=Math.min(o,fn(r)),a=ot[c+s];return Pt(r,c,o+1),ot[c+s]=a,s}catch(m){if(typeof f>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}function Ws(e){try{return e=De.getStr(e),f.rmdir(e),0}catch(n){if(typeof f>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Hs(e,n){try{return e=De.getStr(e),De.writeStat(n,f.stat(e))}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function Gs(e,n,c){try{if(n=De.getStr(n),n=De.calculateAt(e,n),!c)f.unlink(n);else if(c===512)f.rmdir(n);else return-28;return 0}catch(o){if(typeof f>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var xr=e=>We[e>>2]+je[e+4>>2]*4294967296;function Js(e,n,c,o){try{n=De.getStr(n),n=De.calculateAt(e,n,!0);var r=Date.now(),s,a;if(!c)s=r,a=r;else{var m=xr(c),d=je[c+8>>2];d==1073741823?s=r:d==1073741822?s=null:s=m*1e3+d/1e6,c+=16,m=xr(c),d=je[c+8>>2],d==1073741823?a=r:d==1073741822?a=null:a=m*1e3+d/1e6}return(a??s)!==null&&f.utime(n,s,a),0}catch(q){if(typeof f>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}var Ks=e=>e%4===0&&(e%100!==0||e%400===0),Ys=[0,31,60,91,121,152,182,213,244,274,305,335],Xs=[0,31,59,90,120,151,181,212,243,273,304,334],Zs=e=>(Ks(e.getFullYear())?Ys:Xs)[e.getMonth()]+e.getDate()-1;function eo(e,n){e=Ut(e);var c=new Date(e*1e3);je[n>>2]=c.getSeconds(),je[n+4>>2]=c.getMinutes(),je[n+8>>2]=c.getHours(),je[n+12>>2]=c.getDate(),je[n+16>>2]=c.getMonth(),je[n+20>>2]=c.getFullYear()-1900,je[n+24>>2]=c.getDay();var o=Zs(c)|0;je[n+28>>2]=o,je[n+36>>2]=-(c.getTimezoneOffset()*60);var r=new Date(c.getFullYear(),0,1),s=new Date(c.getFullYear(),6,1).getTimezoneOffset(),a=r.getTimezoneOffset(),m=(s!=a&&c.getTimezoneOffset()==Math.min(a,s))|0;je[n+32>>2]=m}function to(e,n,c,o,r,s,a){r=Ut(r);try{var m=De.getStreamFromFD(o),d=f.mmap(m,e,r,n,c),q=d.ptr;return je[s>>2]=d.allocated,We[a>>2]=q,0}catch(V){if(typeof f>"u"||V.name!=="ErrnoError")throw V;return-V.errno}}function no(e,n,c,o,r,s){s=Ut(s);try{var a=De.getStreamFromFD(r);c&2&&De.doMsync(e,a,n,o,s)}catch(m){if(typeof f>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}var ro=(e,n,c,o)=>{var r=new Date().getFullYear(),s=new Date(r,0,1),a=new Date(r,6,1),m=s.getTimezoneOffset(),d=a.getTimezoneOffset(),q=Math.max(m,d);We[e>>2]=q*60,je[n>>2]=+(m!=d);var V=R=>{var $=R>=0?"-":"+",B=Math.abs(R);return`UTC${$}${String(Math.floor(B/60)).padStart(2,"0")}${String(B%60).padStart(2,"0")}`},N=V(m),x=V(d);d<m?(Pt(N,c,17),Pt(x,o,17)):(Pt(N,o,17),Pt(x,c,17))},Ir=()=>performance.now(),kr=()=>Date.now(),io=1,so=e=>e>=0&&e<=3;function oo(e,n,c){if(n=Ut(n),!so(e))return 28;var o;if(e===0)o=kr();else if(io)o=Ir();else return 52;var r=Math.round(o*1e3*1e3);return Xe[c>>3]=BigInt(r),0}var Rr=()=>2147483648,ao=()=>Rr(),lo=e=>{var n=(e-yt.buffer.byteLength+65535)/65536|0;try{return yt.grow(n),ye(),1}catch{}},co=e=>{var n=Rt.length;e>>>=0;var c=Rr();if(e>c)return!1;for(var o=1;o<=4;o*=2){var r=n*(1+.2/o);if(r=Math.min(r,e+100663296),lo(Math.min(c,vr(Math.max(e,r),65536))))return!0}return!1},$n={},uo=()=>T||"./this.program",en=()=>{if(!en.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:uo()};for(var n in $n)$n[n]===void 0?delete e[n]:e[n]=$n[n];var c=[];for(var n in e)c.push(`${n}=${e[n]}`);en.strings=c}return en.strings},fo=(e,n)=>{var c=0,o=0;for(var r of en()){var s=n+c;We[e+o>>2]=s,c+=Pt(r,s,1/0)+1,o+=4}return 0},mo=(e,n)=>{var c=en();We[e>>2]=c.length;var o=0;for(var r of c)o+=fn(r)+1;return We[n>>2]=o,0};function po(e){try{var n=De.getStreamFromFD(e);return f.close(n),0}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return c.errno}}function _o(e,n){try{var c=0,o=0,r=0,s=De.getStreamFromFD(e),a=s.tty?2:f.isDir(s.mode)?3:f.isLink(s.mode)?7:4;return ot[n]=a,Fe[n+2>>1]=r,Xe[n+8>>3]=BigInt(c),Xe[n+16>>3]=BigInt(o),0}catch(m){if(typeof f>"u"||m.name!=="ErrnoError")throw m;return m.errno}}var go=(e,n,c,o)=>{for(var r=0,s=0;s<c;s++){var a=We[n>>2],m=We[n+4>>2];n+=8;var d=f.read(e,ot,a,m,o);if(d<0)return-1;if(r+=d,d<m)break;typeof o<"u"&&(o+=d)}return r};function ho(e,n,c,o){try{var r=go(De.getStreamFromFD(e),n,c);return We[o>>2]=r,0}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function yo(e,n,c,o){n=Ut(n);try{if(isNaN(n))return 61;var r=De.getStreamFromFD(e);return f.llseek(r,n,c),Xe[o>>3]=BigInt(r.position),r.getdents&&n===0&&c===0&&(r.getdents=null),0}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function bo(e){try{var n=De.getStreamFromFD(e);return n.stream_ops?.fsync?.(n)}catch(c){if(typeof f>"u"||c.name!=="ErrnoError")throw c;return c.errno}}var wo=(e,n,c,o)=>{for(var r=0,s=0;s<c;s++){var a=We[n>>2],m=We[n+4>>2];n+=8;var d=f.write(e,ot,a,m,o);if(d<0)return-1;if(r+=d,d<m)break;typeof o<"u"&&(o+=d)}return r};function So(e,n,c,o){try{var r=wo(De.getStreamFromFD(e),n,c);return We[o>>2]=r,0}catch(s){if(typeof f>"u"||s.name!=="ErrnoError")throw s;return s.errno}}if(f.createPreloadedFile=Is,f.preloadFile=Ar,f.staticInit(),Ae(),t.noExitRuntime&&t.noExitRuntime,t.preloadPlugins&&(Tr=t.preloadPlugins),t.print&&(Y=t.print),t.printErr&&(ne=t.printErr),t.wasmBinary&&(_e=t.wasmBinary),t.arguments&&t.arguments,t.thisProgram&&(T=t.thisProgram),t.preInit)for(typeof t.preInit=="function"&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.shift()();t.wasmMemory=yt;var Or;function vo(e){t._sqlite3_status64=e.sqlite3_status64,t._sqlite3_status=e.sqlite3_status,t._sqlite3_db_status64=e.sqlite3_db_status64,t._sqlite3_msize=e.sqlite3_msize,t._sqlite3_db_status=e.sqlite3_db_status,t._sqlite3_vfs_find=e.sqlite3_vfs_find,t._sqlite3_initialize=e.sqlite3_initialize,t._sqlite3_malloc=e.sqlite3_malloc,t._sqlite3_free=e.sqlite3_free,t._sqlite3_vfs_register=e.sqlite3_vfs_register,t._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,t._sqlite3_malloc64=e.sqlite3_malloc64,t._sqlite3_realloc=e.sqlite3_realloc,t._sqlite3_realloc64=e.sqlite3_realloc64,t._sqlite3_value_text=e.sqlite3_value_text,t._sqlite3_randomness=e.sqlite3_randomness,t._sqlite3_stricmp=e.sqlite3_stricmp,t._sqlite3_strnicmp=e.sqlite3_strnicmp,t._sqlite3_uri_parameter=e.sqlite3_uri_parameter,t._sqlite3_uri_boolean=e.sqlite3_uri_boolean,t._sqlite3_serialize=e.sqlite3_serialize,t._sqlite3_prepare_v2=e.sqlite3_prepare_v2,t._sqlite3_step=e.sqlite3_step,t._sqlite3_column_int64=e.sqlite3_column_int64,t._sqlite3_reset=e.sqlite3_reset,t._sqlite3_exec=e.sqlite3_exec,t._sqlite3_column_int=e.sqlite3_column_int,t._sqlite3_finalize=e.sqlite3_finalize,t._sqlite3_file_control=e.sqlite3_file_control,t._sqlite3_column_name=e.sqlite3_column_name,t._sqlite3_column_text=e.sqlite3_column_text,t._sqlite3_column_type=e.sqlite3_column_type,t._sqlite3_errmsg=e.sqlite3_errmsg,t._sqlite3_deserialize=e.sqlite3_deserialize,t._sqlite3_clear_bindings=e.sqlite3_clear_bindings,t._sqlite3_value_blob=e.sqlite3_value_blob,t._sqlite3_value_bytes=e.sqlite3_value_bytes,t._sqlite3_value_double=e.sqlite3_value_double,t._sqlite3_value_int=e.sqlite3_value_int,t._sqlite3_value_int64=e.sqlite3_value_int64,t._sqlite3_value_subtype=e.sqlite3_value_subtype,t._sqlite3_value_pointer=e.sqlite3_value_pointer,t._sqlite3_value_type=e.sqlite3_value_type,t._sqlite3_value_nochange=e.sqlite3_value_nochange,t._sqlite3_value_frombind=e.sqlite3_value_frombind,t._sqlite3_value_dup=e.sqlite3_value_dup,t._sqlite3_value_free=e.sqlite3_value_free,t._sqlite3_result_blob=e.sqlite3_result_blob,t._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,t._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,t._sqlite3_result_double=e.sqlite3_result_double,t._sqlite3_result_error=e.sqlite3_result_error,t._sqlite3_result_int=e.sqlite3_result_int,t._sqlite3_result_int64=e.sqlite3_result_int64,t._sqlite3_result_null=e.sqlite3_result_null,t._sqlite3_result_pointer=e.sqlite3_result_pointer,t._sqlite3_result_subtype=e.sqlite3_result_subtype,t._sqlite3_result_text=e.sqlite3_result_text,t._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,t._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,t._sqlite3_result_error_code=e.sqlite3_result_error_code,t._sqlite3_user_data=e.sqlite3_user_data,t._sqlite3_context_db_handle=e.sqlite3_context_db_handle,t._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,t._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,t._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,t._sqlite3_aggregate_context=e.sqlite3_aggregate_context,t._sqlite3_get_auxdata=e.sqlite3_get_auxdata,t._sqlite3_set_auxdata=e.sqlite3_set_auxdata,t._sqlite3_column_count=e.sqlite3_column_count,t._sqlite3_data_count=e.sqlite3_data_count,t._sqlite3_column_blob=e.sqlite3_column_blob,t._sqlite3_column_bytes=e.sqlite3_column_bytes,t._sqlite3_column_double=e.sqlite3_column_double,t._sqlite3_column_value=e.sqlite3_column_value,t._sqlite3_column_decltype=e.sqlite3_column_decltype,t._sqlite3_column_database_name=e.sqlite3_column_database_name,t._sqlite3_column_table_name=e.sqlite3_column_table_name,t._sqlite3_column_origin_name=e.sqlite3_column_origin_name,t._sqlite3_bind_blob=e.sqlite3_bind_blob,t._sqlite3_bind_double=e.sqlite3_bind_double,t._sqlite3_bind_int=e.sqlite3_bind_int,t._sqlite3_bind_int64=e.sqlite3_bind_int64,t._sqlite3_bind_null=e.sqlite3_bind_null,t._sqlite3_bind_pointer=e.sqlite3_bind_pointer,t._sqlite3_bind_text=e.sqlite3_bind_text,t._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,t._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,t._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,t._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,t._sqlite3_db_handle=e.sqlite3_db_handle,t._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,t._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,t._sqlite3_stmt_explain=e.sqlite3_stmt_explain,t._sqlite3_stmt_busy=e.sqlite3_stmt_busy,t._sqlite3_next_stmt=e.sqlite3_next_stmt,t._sqlite3_stmt_status=e.sqlite3_stmt_status,t._sqlite3_sql=e.sqlite3_sql,t._sqlite3_expanded_sql=e.sqlite3_expanded_sql,t._sqlite3_preupdate_old=e.sqlite3_preupdate_old,t._sqlite3_preupdate_count=e.sqlite3_preupdate_count,t._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,t._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,t._sqlite3_preupdate_new=e.sqlite3_preupdate_new,t._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,t._sqlite3_set_authorizer=e.sqlite3_set_authorizer,t._sqlite3_strglob=e.sqlite3_strglob,t._sqlite3_strlike=e.sqlite3_strlike,t._sqlite3_auto_extension=e.sqlite3_auto_extension,t._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,t._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,t._sqlite3_prepare_v3=e.sqlite3_prepare_v3,t._sqlite3_create_module=e.sqlite3_create_module,t._sqlite3_create_module_v2=e.sqlite3_create_module_v2,t._sqlite3_drop_modules=e.sqlite3_drop_modules,t._sqlite3_declare_vtab=e.sqlite3_declare_vtab,t._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,t._sqlite3_vtab_collation=e.sqlite3_vtab_collation,t._sqlite3_vtab_in=e.sqlite3_vtab_in,t._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,t._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,t._sqlite3_keyword_name=e.sqlite3_keyword_name,t._sqlite3_keyword_count=e.sqlite3_keyword_count,t._sqlite3_keyword_check=e.sqlite3_keyword_check,t._sqlite3_complete=e.sqlite3_complete,t._sqlite3_libversion=e.sqlite3_libversion,t._sqlite3_libversion_number=e.sqlite3_libversion_number,t._sqlite3_shutdown=e.sqlite3_shutdown,t._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,t._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,t._sqlite3_changes64=e.sqlite3_changes64,t._sqlite3_changes=e.sqlite3_changes,t._sqlite3_total_changes64=e.sqlite3_total_changes64,t._sqlite3_total_changes=e.sqlite3_total_changes,t._sqlite3_txn_state=e.sqlite3_txn_state,t._sqlite3_close_v2=e.sqlite3_close_v2,t._sqlite3_busy_handler=e.sqlite3_busy_handler,t._sqlite3_progress_handler=e.sqlite3_progress_handler,t._sqlite3_busy_timeout=e.sqlite3_busy_timeout,t._sqlite3_interrupt=e.sqlite3_interrupt,t._sqlite3_is_interrupted=e.sqlite3_is_interrupted,t._sqlite3_create_function=e.sqlite3_create_function,t._sqlite3_create_function_v2=e.sqlite3_create_function_v2,t._sqlite3_create_window_function=e.sqlite3_create_window_function,t._sqlite3_overload_function=e.sqlite3_overload_function,t._sqlite3_trace_v2=e.sqlite3_trace_v2,t._sqlite3_commit_hook=e.sqlite3_commit_hook,t._sqlite3_update_hook=e.sqlite3_update_hook,t._sqlite3_rollback_hook=e.sqlite3_rollback_hook,t._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,t._sqlite3_set_errmsg=e.sqlite3_set_errmsg,t._sqlite3_error_offset=e.sqlite3_error_offset,t._sqlite3_errcode=e.sqlite3_errcode,t._sqlite3_extended_errcode=e.sqlite3_extended_errcode,t._sqlite3_errstr=e.sqlite3_errstr,t._sqlite3_limit=e.sqlite3_limit,t._sqlite3_open=e.sqlite3_open,t._sqlite3_open_v2=e.sqlite3_open_v2,t._sqlite3_create_collation=e.sqlite3_create_collation,t._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,t._sqlite3_collation_needed=e.sqlite3_collation_needed,t._sqlite3_get_autocommit=e.sqlite3_get_autocommit,t._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,t._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,t._sqlite3_uri_key=e.sqlite3_uri_key,t._sqlite3_uri_int64=e.sqlite3_uri_int64,t._sqlite3_db_name=e.sqlite3_db_name,t._sqlite3_db_filename=e.sqlite3_db_filename,t._sqlite3_db_readonly=e.sqlite3_db_readonly,t._sqlite3_compileoption_used=e.sqlite3_compileoption_used,t._sqlite3_compileoption_get=e.sqlite3_compileoption_get,t._sqlite3session_diff=e.sqlite3session_diff,t._sqlite3session_attach=e.sqlite3session_attach,t._sqlite3session_create=e.sqlite3session_create,t._sqlite3session_delete=e.sqlite3session_delete,t._sqlite3session_table_filter=e.sqlite3session_table_filter,t._sqlite3session_changeset=e.sqlite3session_changeset,t._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,t._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,t._sqlite3session_patchset=e.sqlite3session_patchset,t._sqlite3session_enable=e.sqlite3session_enable,t._sqlite3session_indirect=e.sqlite3session_indirect,t._sqlite3session_isempty=e.sqlite3session_isempty,t._sqlite3session_memory_used=e.sqlite3session_memory_used,t._sqlite3session_object_config=e.sqlite3session_object_config,t._sqlite3session_changeset_size=e.sqlite3session_changeset_size,t._sqlite3changeset_start=e.sqlite3changeset_start,t._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,t._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,t._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,t._sqlite3changeset_next=e.sqlite3changeset_next,t._sqlite3changeset_op=e.sqlite3changeset_op,t._sqlite3changeset_pk=e.sqlite3changeset_pk,t._sqlite3changeset_old=e.sqlite3changeset_old,t._sqlite3changeset_new=e.sqlite3changeset_new,t._sqlite3changeset_conflict=e.sqlite3changeset_conflict,t._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,t._sqlite3changeset_finalize=e.sqlite3changeset_finalize,t._sqlite3changeset_invert=e.sqlite3changeset_invert,t._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,t._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,t._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,t._sqlite3changeset_apply=e.sqlite3changeset_apply,t._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,t._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,t._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,t._sqlite3changegroup_new=e.sqlite3changegroup_new,t._sqlite3changegroup_add=e.sqlite3changegroup_add,t._sqlite3changegroup_output=e.sqlite3changegroup_output,t._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,t._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,t._sqlite3changegroup_delete=e.sqlite3changegroup_delete,t._sqlite3changeset_concat=e.sqlite3changeset_concat,t._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,t._sqlite3session_config=e.sqlite3session_config,t._sqlite3_sourceid=e.sqlite3_sourceid,t._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,t._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,t._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,t._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,t._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,t._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,t._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,t._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,t._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,t._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,t._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,t._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,t._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,t._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,t._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,t._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,t._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,t._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,t._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,t._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,t._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,t._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,t._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,t._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,t._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,t._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,t._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,t._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,t._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,t._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,t._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,t._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,t._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,t._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,t._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,t._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,t._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,t._malloc=e.malloc,t._free=e.free,t._realloc=e.realloc,Or=e.emscripten_builtin_memalign,e._emscripten_stack_restore,e._emscripten_stack_alloc,e.emscripten_stack_get_current,e.__indirect_function_table}var Pr={__syscall_chmod:Rs,__syscall_faccessat:Os,__syscall_fchmod:Ps,__syscall_fchown32:Cs,__syscall_fcntl64:Ds,__syscall_fstat64:Ns,__syscall_ftruncate64:Fs,__syscall_getcwd:js,__syscall_ioctl:$s,__syscall_lstat64:Us,__syscall_mkdirat:Bs,__syscall_newfstatat:zs,__syscall_openat:Qs,__syscall_readlinkat:Vs,__syscall_rmdir:Ws,__syscall_stat64:Hs,__syscall_unlinkat:Gs,__syscall_utimensat:Js,_localtime_js:eo,_mmap_js:to,_munmap_js:no,_tzset_js:ro,clock_time_get:oo,emscripten_date_now:kr,emscripten_get_heap_max:ao,emscripten_get_now:Ir,emscripten_resize_heap:co,environ_get:fo,environ_sizes_get:mo,fd_close:po,fd_fdstat_get:_o,fd_read:ho,fd_seek:yo,fd_sync:bo,fd_write:So,memory:yt};function Un(){if(Ot>0){Zt=Un;return}if(ge(),Ot>0){Zt=Un;return}function e(){t.calledRun=!0,!Te&&(Pe(),Ce?.(t),t.onRuntimeInitialized?.(),Le())}t.setStatus?(t.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>t.setStatus(""),1),e()},1)):e()}var Bt=await Dn();return Un(),t.runSQLite3PostLoadInit=async function(e,n,c){"use strict";delete n.runSQLite3PostLoadInit;globalThis.sqlite3ApiBootstrap=async function o(r=globalThis.sqlite3ApiConfig||o.defaultConfig){if(o.sqlite3)return(o.sqlite3.config||console).warn("sqlite3ApiBootstrap() called multiple times.","Config and external initializers are ignored on calls after the first."),o.sqlite3;let s=(...h)=>Object.assign(Object.create(null),...h),a=s({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},r);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(h=>{typeof a[h]=="function"&&(a[h]=a[h]())});let m=s(),d=s(),q=h=>m.sqlite3_js_rc_str&&m.sqlite3_js_rc_str(h)||"Unknown result code #"+h,V=h=>typeof h=="number"&&h===(h|0)&&h<=2147483647&&h>=-2147483648;class N extends Error{constructor(...A){let U;if(A.length)if(V(A[0]))if(U=A[0],A.length===1)super(q(A[0]));else{let X=q(U);typeof A[1]=="object"?super(X,A[1]):(A[0]=X+":",super(A.join(" ")))}else A.length===2&&typeof A[1]=="object"?super(...A):super(A.join(" "));this.resultCode=U||m.SQLITE_ERROR,this.name="SQLite3Error"}}N.toss=(...h)=>{throw new N(...h)};let x=N.toss;a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir)&&x("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");let R=function h(A){return h._max||(h._max=BigInt("0x7fffffffffffffff"),h._min=~h._max),A>=h._min&&A<=h._max},$=h=>h>=-2147483647n-1n&&h<=2147483647n,B=function h(A){return h._min||(h._min=Number.MIN_SAFE_INTEGER,h._max=Number.MAX_SAFE_INTEGER),A>=h._min&&A<=h._max},J=h=>h&&h.constructor&&V(h.constructor.BYTES_PER_ELEMENT)?h:!1,E=h=>h&&(h instanceof Uint8Array||h instanceof Int8Array||h instanceof ArrayBuffer),w=h=>h&&(h instanceof Uint8Array||h instanceof Int8Array||h instanceof ArrayBuffer),W=h=>E(h)||x("Value is not of a supported TypedArray type."),ee=function(h){return w(h)?d.typedArrayToString(h instanceof ArrayBuffer?new Uint8Array(h):h,0,h.length):Array.isArray(h)?h.join(""):(d.isPtr(h)&&(h=d.cstrToJs(h)),h)};class O extends Error{constructor(...A){A.length===2&&typeof A[1]=="object"?super(...A):A.length?super(A.join(" ")):super("Allocation failed."),this.resultCode=m.SQLITE_NOMEM,this.name="WasmAllocError"}}O.toss=(...h)=>{throw new O(...h)},Object.assign(m,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(h,A,U,X,F,fe,de,me,S)=>{},sqlite3_create_function:(h,A,U,X,F,fe,de,me)=>{},sqlite3_create_window_function:(h,A,U,X,F,fe,de,me,S,C)=>{},sqlite3_prepare_v3:(h,A,U,X,F,fe)=>{},sqlite3_prepare_v2:(h,A,U,X,F)=>{},sqlite3_exec:(h,A,U,X,F)=>{},sqlite3_randomness:(h,A)=>{}});let z={affirmBindableTypedArray:W,flexibleString:ee,bigIntFits32:$,bigIntFits64:R,bigIntFitsDouble:B,isBindableTypedArray:E,isInt32:V,isSQLableTypedArray:w,isTypedArray:J,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...h){throw new Error(h.join(" "))},toss3:x,typedArrayPart:d.typedArrayPart,nu:s,assert:function(h,A){h||z.toss("Assertion failed:",A)},affirmDbHeader:function(h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));let A="SQLite format 3";15>h.byteLength&&x("Input does not contain an SQLite3 database header.");for(let U=0;U<15;++U)A.charCodeAt(U)!==h[U]&&x("Input does not contain an SQLite3 database header.")},affirmIsDb:function(h){h instanceof ArrayBuffer&&(h=new Uint8Array(h));let A=h.byteLength;(A<512||A%512!==0)&&x("Byte array size",A,"is invalid for an SQLite3 db."),z.affirmDbHeader(h)}};Object.assign(d,{exports:a.exports||x("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||x("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}),d.allocFromTypedArray=function(h){h instanceof ArrayBuffer&&(h=new Uint8Array(h)),W(h);let A=d.alloc(h.byteLength||1);return d.heapForSize(h.constructor).set(h.byteLength?h:[0],Number(A)),A};{let h=a.allocExportName,A=a.deallocExportName,U=a.reallocExportName;for(let X of[h,A,U])d.exports[X]instanceof Function||x("Missing required exports[",X,"] function.");d.alloc=function X(F){return X.impl(F)||O.toss("Failed to allocate",F," bytes.")},d.alloc.impl=d.exports[h],d.realloc=function X(F,fe){let de=X.impl(d.ptr.coerce(F),fe);return fe?de||O.toss("Failed to reallocate",fe," bytes."):d.ptr.null},d.realloc.impl=d.exports[U],d.dealloc=function X(F){X.impl(d.ptr.coerce(F))},d.dealloc.impl=d.exports[A]}d.compileOptionUsed=function h(A){if(arguments.length){if(Array.isArray(A)){let U=s();return A.forEach(X=>{U[X]=m.sqlite3_compileoption_used(X)}),U}else if(typeof A=="object")return Object.keys(A).forEach(U=>{A[U]=m.sqlite3_compileoption_used(U)}),A}else{if(h._result)return h._result;h._opt||(h._rx=/^([^=]+)=(.+)/,h._rxInt=/^-?\d+$/,h._opt=function(de,me){let S=h._rx.exec(de);me[0]=S?S[1]:de,me[1]=S?h._rxInt.test(S[2])?+S[2]:S[2]:!0});let U=s(),X=[0,0],F=0,fe;for(;fe=m.sqlite3_compileoption_get(F++);)h._opt(fe,X),U[X[0]]=X[1];return h._result=U}return typeof A=="string"?!!m.sqlite3_compileoption_used(A):!1},d.pstack=s({restore:d.exports.sqlite3__wasm_pstack_restore,alloc:function(h){return typeof h=="string"&&!(h=d.sizeofIR(h))&&O.toss("Invalid value for pstack.alloc(",arguments[0],")"),d.exports.sqlite3__wasm_pstack_alloc(h)||O.toss("Could not allocate",h,"bytes from the pstack.")},allocChunks:function(h,A){typeof A=="string"&&!(A=d.sizeofIR(A))&&O.toss("Invalid size value for allocChunks(",arguments[1],")");let U=d.pstack.alloc(h*A),X=[U],F=1,fe=A;for(;F<h;++F,fe+=A)X.push(d.ptr.add(U,fe));return X},allocPtr:(h=1,A=!0)=>h===1?d.pstack.alloc(A?8:d.ptr.size):d.pstack.allocChunks(h,A?8:d.ptr.size),call:function(h){let A=d.pstack.pointer;try{return h(le)}finally{d.pstack.restore(A)}}}),Object.defineProperties(d.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:d.exports.sqlite3__wasm_pstack_remaining}}),m.sqlite3_randomness=(...h)=>{if(h.length===1&&z.isTypedArray(h[0])&&h[0].BYTES_PER_ELEMENT===1){let A=h[0];if(A.byteLength===0)return d.exports.sqlite3_randomness(0,d.ptr.null),A;let U=d.pstack.pointer;try{let X=A.byteLength,F=0,fe=d.exports.sqlite3_randomness,de=d.heap8u(),me=X<512?X:512,S=d.pstack.alloc(me);do{let C=X>me?me:X;fe(C,S),A.set(d.typedArrayPart(de,S,d.ptr.add(S,C)),F),X-=C,F+=C}while(X>0)}catch(X){a.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",X)}finally{d.pstack.restore(U)}return A}d.exports.sqlite3_randomness(...h)},m.sqlite3_wasmfs_opfs_dir=function(){if(this.dir!==void 0)return this.dir;let h=a.wasmfsOpfsDir;if(!h||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!d.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{return h&&d.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],h)===0?this.dir=h:this.dir=""}catch{return this.dir=""}}.bind(s()),m.sqlite3_wasmfs_filename_is_persistent=function(h){let A=m.sqlite3_wasmfs_opfs_dir();return A&&h?h.startsWith(A+"/"):!1},m.sqlite3_js_db_uses_vfs=function(h,A,U=0){try{let X=m.sqlite3_vfs_find(A);return X?h?X===m.sqlite3_js_db_vfs(h,U)?X:!1:X===m.sqlite3_vfs_find(0)?X:!1:!1}catch{return!1}},m.sqlite3_js_vfs_list=function(){let h=[],A=m.sqlite3_vfs_find(d.ptr.null);for(;A;){let U=new m.sqlite3_vfs(A);h.push(d.cstrToJs(U.$zName)),A=U.$pNext,U.dispose()}return h},m.sqlite3_js_db_export=function(h,A=0){h=d.xWrap.testConvertArg("sqlite3*",h),h||x("Invalid sqlite3* argument."),d.bigIntEnabled||x("BigInt support is not enabled.");let U=d.scopedAllocPush(),X;try{let F=d.scopedAlloc(8+d.ptr.size),fe=d.ptr.add(F,8),de=A?d.isPtr(A)?A:d.scopedAllocCString(""+A):d.ptr.null,me=d.exports.sqlite3__wasm_db_serialize(h,de,fe,F,0);me&&x("Database serialization failed with code",le.capi.sqlite3_js_rc_str(me)),X=d.peekPtr(fe);let S=d.peek(F,"i64");return me=S?d.heap8u().slice(Number(X),Number(X)+Number(S)):new Uint8Array,me}finally{X&&d.exports.sqlite3_free(X),d.scopedAllocPop(U)}},m.sqlite3_js_db_vfs=(h,A=d.ptr.null)=>z.sqlite3__wasm_db_vfs(h,A),m.sqlite3_js_aggregate_context=(h,A)=>m.sqlite3_aggregate_context(h,A)||(A?O.toss("Cannot allocate",A,"bytes for sqlite3_aggregate_context()"):0),m.sqlite3_js_posix_create_file=function(h,A,U){let X;A&&d.isPtr(A)?X=A:A instanceof ArrayBuffer||A instanceof Uint8Array?(X=d.allocFromTypedArray(A),(arguments.length<3||!z.isInt32(U)||U<0)&&(U=A.byteLength)):N.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{(!z.isInt32(U)||U<0)&&N.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");let F=z.sqlite3__wasm_posix_create_file(h,X,U);F&&N.toss("Creation of file failed with sqlite3 result code",m.sqlite3_js_rc_str(F))}finally{X&&X!==A&&d.dealloc(X)}},m.sqlite3_js_vfs_create_file=function(h,A,U,X){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 F;U?d.isPtr(U)?F=U:(U instanceof ArrayBuffer&&(U=new Uint8Array(U)),U instanceof Uint8Array?(F=d.allocFromTypedArray(U),(arguments.length<4||!z.isInt32(X)||X<0)&&(X=U.byteLength)):N.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):F=0,(!z.isInt32(X)||X<0)&&(F&&F!==U&&d.dealloc(F),N.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{let fe=z.sqlite3__wasm_vfs_create_file(h,A,F,X);fe&&N.toss("Creation of file failed with sqlite3 result code",m.sqlite3_js_rc_str(fe))}finally{F&&F!==U&&d.dealloc(F)}},m.sqlite3_js_sql_to_string=h=>{if(typeof h=="string")return h;let A=ee(v);return A===v?void 0:A},m.sqlite3_db_config=function(h,A,...U){switch(A){case m.SQLITE_DBCONFIG_ENABLE_FKEY:case m.SQLITE_DBCONFIG_ENABLE_TRIGGER:case m.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case m.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case m.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case m.SQLITE_DBCONFIG_ENABLE_QPSG:case m.SQLITE_DBCONFIG_TRIGGER_EQP:case m.SQLITE_DBCONFIG_RESET_DATABASE:case m.SQLITE_DBCONFIG_DEFENSIVE:case m.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case m.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case m.SQLITE_DBCONFIG_DQS_DML:case m.SQLITE_DBCONFIG_DQS_DDL:case m.SQLITE_DBCONFIG_ENABLE_VIEW:case m.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case m.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case m.SQLITE_DBCONFIG_STMT_SCANSTATUS:case m.SQLITE_DBCONFIG_REVERSE_SCANORDER:case m.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE:case m.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE:case m.SQLITE_DBCONFIG_ENABLE_COMMENTS:case m.SQLITE_DBCONFIG_FP_DIGITS:return this.ip||(this.ip=d.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"])),this.ip(h,A,U[0],U[1]||0);case m.SQLITE_DBCONFIG_LOOKASIDE:return this.pii||(this.pii=d.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"])),this.pii(h,A,U[0],U[1],U[2]);case m.SQLITE_DBCONFIG_MAINDBNAME:return this.s||(this.s=d.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"])),this.s(h,A,U[0]);default:return m.SQLITE_MISUSE}}.bind(s()),m.sqlite3_value_to_js=function(h,A=!0){let U,X=m.sqlite3_value_type(h);switch(X){case m.SQLITE_INTEGER:d.bigIntEnabled?(U=m.sqlite3_value_int64(h),z.bigIntFitsDouble(U)&&(U=Number(U))):U=m.sqlite3_value_double(h);break;case m.SQLITE_FLOAT:U=m.sqlite3_value_double(h);break;case m.SQLITE_TEXT:U=m.sqlite3_value_text(h);break;case m.SQLITE_BLOB:{let F=m.sqlite3_value_bytes(h),fe=m.sqlite3_value_blob(h);F&&!fe&&le.WasmAllocError.toss("Cannot allocate memory for blob argument of",F,"byte(s)"),U=F?d.heap8u().slice(Number(fe),Number(fe)+Number(F)):null;break}case m.SQLITE_NULL:U=null;break;default:A&&x(m.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",X),U=void 0}return U},m.sqlite3_values_to_js=function(h,A,U=!0){let X,F=[];for(X=0;X<h;++X)F.push(m.sqlite3_value_to_js(d.peekPtr(d.ptr.add(A,d.ptr.size*X)),U));return F},m.sqlite3_result_error_js=function(h,A){A instanceof O?m.sqlite3_result_error_nomem(h):m.sqlite3_result_error(h,""+A,-1)},m.sqlite3_result_js=function(h,A){if(A instanceof Error){m.sqlite3_result_error_js(h,A);return}try{switch(typeof A){case"undefined":break;case"boolean":m.sqlite3_result_int(h,A?1:0);break;case"bigint":z.bigIntFits32(A)?m.sqlite3_result_int(h,Number(A)):z.bigIntFitsDouble(A)?m.sqlite3_result_double(h,Number(A)):d.bigIntEnabled?z.bigIntFits64(A)?m.sqlite3_result_int64(h,A):x("BigInt value",A.toString(),"is too BigInt for int64."):x("BigInt value",A.toString(),"is too BigInt.");break;case"number":{let U;z.isInt32(A)?U=m.sqlite3_result_int:d.bigIntEnabled&&Number.isInteger(A)&&z.bigIntFits64(BigInt(A))?U=m.sqlite3_result_int64:U=m.sqlite3_result_double,U(h,A);break}case"string":{let[U,X]=d.allocCString(A,!0);m.sqlite3_result_text(h,U,X,m.SQLITE_WASM_DEALLOC);break}case"object":if(A===null){m.sqlite3_result_null(h);break}else if(z.isBindableTypedArray(A)){let U=d.allocFromTypedArray(A);m.sqlite3_result_blob(h,U,A.byteLength,m.SQLITE_WASM_DEALLOC);break}default:x("Don't not how to handle this UDF result value:",typeof A,A)}}catch(U){m.sqlite3_result_error_js(h,U)}},m.sqlite3_column_js=function(h,A,U=!0){let X=m.sqlite3_column_value(h,A);return X===0?void 0:m.sqlite3_value_to_js(X,U)};{let h=function(A,U,X){X=m[X],this.ptr?d.pokePtr(this.ptr,0):this.ptr=d.allocPtr();let F=X(A,U,this.ptr);if(F)return N.toss(F,arguments[2]+"() failed with code "+F);let fe=d.peekPtr(this.ptr);return fe?m.sqlite3_value_to_js(fe,!0):void 0}.bind(s());m.sqlite3_preupdate_new_js=(A,U)=>h(A,U,"sqlite3_preupdate_new"),m.sqlite3_preupdate_old_js=(A,U)=>h(A,U,"sqlite3_preupdate_old"),m.sqlite3changeset_new_js=(A,U)=>h(A,U,"sqlite3changeset_new"),m.sqlite3changeset_old_js=(A,U)=>h(A,U,"sqlite3changeset_old")}m.sqlite3_js_retry_busy=function(h,A,U){for(let X=1;X<=h;++X)try{U&&X>1&&U(X);let F=A();if(m.SQLITE_BUSY===F){if(X===h)throw new N(F,["sqlite3_js_retry_busy() max retry attempts (",h,") reached."].join(""));continue}return F}catch(F){if(X<h&&F instanceof N&&F.resultCode===m.SQLITE_BUSY)continue;throw F}};let le={WasmAllocError:O,SQLite3Error:N,capi:m,util:z,wasm:d,config:a,version:s(),client:void 0,asyncPostInit:async function h(){if(h.isReady instanceof Promise)return h.isReady;let A=this.initializersAsync;delete this.initializersAsync;let U=async()=>(le.__isUnderTest||(delete le.util,delete le.StructBinder,delete le.opfs),le),X=fe=>{throw a.error("an async sqlite3 initializer failed:",fe),fe};if(!A||!A.length)return h.isReady=U().catch(X);A=A.map(fe=>fe instanceof Function?async de=>fe(le):fe),A.push(U);let F=Promise.resolve(le);for(;A.length;)F=F.then(A.shift());return h.isReady=F.catch(X)}.bind(o),scriptInfo:void 0};typeof c<"u"&&(le.__isUnderTest=!!c);try{o.initializers.forEach(h=>{h(le)})}catch(h){throw console.error("sqlite3 bootstrap initializer threw:",h),h}if(delete o.initializers,o.sqlite3=le,typeof e<"u"&&(e.debugModule("sqlite3ApiBootstrap() complete",le),le.scriptInfo=e),le.__isUnderTest){typeof n<"u"&&(le.config.emscripten=n);let h=le.scriptInfo?.instantiateWasm;h&&(le.wasm.module=h.module,le.wasm.instance=h.instance,le.wasm.imports=h.imports)}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete o.defaultConfig,le.asyncPostInit().then(h=>(typeof e<"u"&&e.debugModule("sqlite3.asyncPostInit() complete",h),delete h.asyncPostInit,delete h.scriptInfo,delete h.emscripten,h))},globalThis.sqlite3ApiBootstrap.initializers=[],globalThis.sqlite3ApiBootstrap.initializersAsync=[],globalThis.sqlite3ApiBootstrap.defaultConfig=Object.create(null),globalThis.sqlite3ApiBootstrap.sqlite3=void 0,globalThis.sqlite3ApiBootstrap.initializers.push(function(o){o.version={libVersion:"3.53.4",libVersionNumber:3053004,sourceId:"2026-07-24 19:02:57 bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc",downloadVersion:3530400,scm:{"sha3-256":"bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc",branch:"branch-3.53",tags:"release version-3.53.4",datetime:"2026-07-24T19:02:57.525Z"}}}),globalThis.WhWasmUtilInstaller=function(r){"use strict";r.bigIntEnabled===void 0&&(r.bigIntEnabled=!!globalThis.BigInt64Array);let s=(...u)=>{throw new Error(u.join(" "))};if(!r.pointerSize&&!r.pointerIR&&r.alloc&&r.dealloc){let u=r.alloc(1);r.pointerSize=typeof u=="bigint"?8:4,r.dealloc(u)}r.pointerSize&&!r.pointerIR&&(r.pointerIR=r.pointerSize===4?"i32":"i64");let a=r.pointerIR??="i32",m=r.pointerSize??=a==="i32"?4:a==="i64"?8:0;delete r.pointerSize,delete r.pointerIR,a!=="i32"&&a!=="i64"?s("Invalid pointerIR:",a):m!==8&&m!==4&&s("Invalid pointerSize:",m);let d=r.bigIntEnabled?u=>BigInt(u||0):u=>s("BigInt support is disabled in this build."),V=m===4?u=>Number(u||0):d,N=V(0),x=function(...u){let _=V(0);for(let y of u)_+=V(y);return _};{let u=Object.create(null);Object.defineProperty(r,"ptr",{enumerable:!0,get:()=>u,set:()=>s("The ptr property is read-only.")}),(function _(y,Q){return Object.defineProperty(u,y,{enumerable:!0,get:()=>Q,set:()=>s("ptr["+y+"] is read-only.")}),_})("null",N)("size",m)("ir",a)("coerce",V)("add",x)("addn",a===4?x:(..._)=>Number(x(..._)))}r.exports||Object.defineProperty(r,"exports",{enumerable:!0,configurable:!0,get:()=>r.instance?.exports});let R=Object.create(null);R.heapSize=0,R.memory=null,R.freeFuncIndexes=[],R.scopedAlloc=[],R.scopedAlloc.pushPtr=u=>(R.scopedAlloc[R.scopedAlloc.length-1].push(u),u),R.utf8Decoder=new TextDecoder,R.utf8Encoder=new TextEncoder("utf-8"),r.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 m;default:return(""+u).endsWith("*")?m:void 0}};let $=function(){if(!R.memory)R.memory=r.memory instanceof WebAssembly.Memory?r.memory:r.exports.memory;else if(R.heapSize===R.memory.buffer.byteLength)return R;let u=R.memory.buffer;return R.HEAP8=new Int8Array(u),R.HEAP8U=new Uint8Array(u),R.HEAP16=new Int16Array(u),R.HEAP16U=new Uint16Array(u),R.HEAP32=new Int32Array(u),R.HEAP32U=new Uint32Array(u),R.HEAP32F=new Float32Array(u),R.HEAP64F=new Float64Array(u),r.bigIntEnabled&&(typeof BigInt64Array<"u"?(R.HEAP64=new BigInt64Array(u),R.HEAP64U=new BigUint64Array(u)):s("BigInt support is enabled, but the BigInt64Array type is missing.")),R.heapSize=u.byteLength,R};r.heap8=()=>$().HEAP8,r.heap8u=()=>$().HEAP8U,r.heap16=()=>$().HEAP16,r.heap16u=()=>$().HEAP16U,r.heap32=()=>$().HEAP32,r.heap32u=()=>$().HEAP32U,r.heapForSize=function(u,_=!0){let y=R.memory&&R.heapSize===R.memory.buffer.byteLength?R:$();switch(u){case Int8Array:return y.HEAP8;case Uint8Array:return y.HEAP8U;case Int16Array:return y.HEAP16;case Uint16Array:return y.HEAP16U;case Int32Array:return y.HEAP32;case Uint32Array:return y.HEAP32U;case 8:return _?y.HEAP8U:y.HEAP8;case 16:return _?y.HEAP16U:y.HEAP16;case 32:return _?y.HEAP32U:y.HEAP32;case 64:if(y.HEAP64)return _?y.HEAP64U:y.HEAP64;break;default:if(r.bigIntEnabled){if(u===globalThis.BigUint64Array)return y.HEAP64U;if(u===globalThis.BigInt64Array)return y.HEAP64;break}}s("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};let B=r.functionTable;delete r.functionTable,r.functionTable=B?()=>B:()=>r.exports.__indirect_function_table,r.functionEntry=function(u){let _=r.functionTable();return u<_.length?_.get(V(u)):void 0},r.jsFuncToWasm=function u(_,y){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,D,te)=>{te<128?b[D](te):b[D](te%128|128,te>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:b=>{let D=u._.rxJSig.exec(b);return D?D[2]:b.substr(1)},letterType:b=>u._.sigTypes[b]||s("Invalid signature letter:",b),pushSigType:(b,D)=>b.push(u._.typeCodes[u._.letterType(D)])}),typeof _=="string"){let b=y;y=_,_=b}let Q=u._,K=Q.sigParams(y),M=[1,96];Q.uleb128Encode(M,"push",K.length);for(let b of K)Q.pushSigType(M,b);return y[0]==="v"?M.push(0):(M.push(1),Q.pushSigType(M,y[0])),Q.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:_}}).exports.f};let J=function(_,y,Q){if(Q&&!R.scopedAlloc.length&&s("No scopedAllocPush() scope is active."),typeof _=="string"){let D=y;y=_,_=D}(typeof y!="string"||!(_ instanceof Function))&&s("Invalid arguments: expecting (function,signature) or (signature,function).");let K=r.functionTable(),M=V(K.length),b;for(;(b=R.freeFuncIndexes.pop())&&K.get(b);){b=null;continue}b||(b=V(M),K.grow(V(1)));try{return K.set(b,_),Q&&R.scopedAlloc.pushPtr(b),b}catch(D){if(!(D instanceof TypeError))throw b===M&&R.freeFuncIndexes.push(M),D}try{let D=r.jsFuncToWasm(_,y);K.set(b,D),Q&&R.scopedAlloc.pushPtr(b)}catch(D){throw b===M&&R.freeFuncIndexes.push(M),D}return b};r.installFunction=(u,_)=>J(u,_,!1),r.scopedInstallFunction=(u,_)=>J(u,_,!0),r.uninstallFunction=function(u){if(!u&&N!==u)return;let _=r.functionTable();R.freeFuncIndexes.push(u);let y=_.get(u);return _.set(u,null),y},r.peek=function(_,y="i8"){y.endsWith("*")&&(y=a);let Q=R.memory&&R.heapSize===R.memory.buffer.byteLength?R:$(),K=Array.isArray(_)?[]:void 0,M;do{switch(K&&(_=arguments[0].shift()),y){case"i1":case"i8":M=Q.HEAP8[Number(_)>>0];break;case"i16":M=Q.HEAP16[Number(_)>>1];break;case"i32":M=Q.HEAP32[Number(_)>>2];break;case"float":case"f32":M=Q.HEAP32F[Number(_)>>2];break;case"double":case"f64":M=Number(Q.HEAP64F[Number(_)>>3]);break;case"i64":if(Q.HEAP64){M=d(Q.HEAP64[Number(_)>>3]);break}default:s("Invalid type for peek():",y)}K&&K.push(M)}while(K&&arguments[0].length);return K||M},r.poke=function(u,_,y="i8"){y.endsWith("*")&&(y=a);let Q=R.memory&&R.heapSize===R.memory.buffer.byteLength?R:$();for(let K of Array.isArray(u)?u:[u])switch(y){case"i1":case"i8":Q.HEAP8[Number(K)>>0]=_;continue;case"i16":Q.HEAP16[Number(K)>>1]=_;continue;case"i32":Q.HEAP32[Number(K)>>2]=_;continue;case"float":case"f32":Q.HEAP32F[Number(K)>>2]=_;continue;case"double":case"f64":Q.HEAP64F[Number(K)>>3]=_;continue;case"i64":if(Q.HEAP64){Q.HEAP64[Number(K)>>3]=d(_);continue}default:s("Invalid type for poke(): "+y)}return this},r.peekPtr=(...u)=>r.peek(u.length===1?u[0]:u,a),r.pokePtr=(u,_=0)=>r.poke(u,_,a),r.peek8=(...u)=>r.peek(u.length===1?u[0]:u,"i8"),r.poke8=(u,_)=>r.poke(u,_,"i8"),r.peek16=(...u)=>r.peek(u.length===1?u[0]:u,"i16"),r.poke16=(u,_)=>r.poke(u,_,"i16"),r.peek32=(...u)=>r.peek(u.length===1?u[0]:u,"i32"),r.poke32=(u,_)=>r.poke(u,_,"i32"),r.peek64=(...u)=>r.peek(u.length===1?u[0]:u,"i64"),r.poke64=(u,_)=>r.poke(u,_,"i64"),r.peek32f=(...u)=>r.peek(u.length===1?u[0]:u,"f32"),r.poke32f=(u,_)=>r.poke(u,_,"f32"),r.peek64f=(...u)=>r.peek(u.length===1?u[0]:u,"f64"),r.poke64f=(u,_)=>r.poke(u,_,"f64"),r.getMemValue=r.peek,r.getPtrValue=r.peekPtr,r.setMemValue=r.poke,r.setPtrValue=r.pokePtr,r.isPtr32=u=>typeof u=="number"&&u>=0&&u===(u|0),r.isPtr64=u=>typeof u=="bigint"?u>=0:r.isPtr32(u),r.isPtr=m===4?r.isPtr32:r.isPtr64,r.cstrlen=function(u){if(!u||!r.isPtr(u))return null;u=Number(u);let _=$().HEAP8U,y=u;for(;_[y]!==0;++y);return y-u};let E=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,w=u=>u.buffer instanceof E;r.isSharedTypedArray=w;let W=(u,_,y)=>(m===8&&(typeof _=="bigint"&&(_=Number(_)),typeof y=="bigint"&&(y=Number(y))),w(u)?u.slice(_,y):u.subarray(_,y));r.typedArrayPart=W;let ee=(u,_,y)=>R.utf8Decoder.decode(W(u,_,y));r.typedArrayToString=ee,r.cstrToJs=function(u){let _=r.cstrlen(u);return _?ee($().HEAP8U,Number(u),Number(u)+_):_===null?_:""},r.jstrlen=function(u){if(typeof u!="string")return null;let _=u.length,y=0;for(let Q=0;Q<_;++Q){let K=u.charCodeAt(Q);K>=55296&&K<=57343&&(K=65536+((K&1023)<<10)|u.charCodeAt(++Q)&1023),K<=127?++y:K<=2047?y+=2:K<=65535?y+=3:y+=4}return y},r.jstrcpy=function(u,_,y=0,Q=-1,K=!0){if((!_||!(_ instanceof Int8Array)&&!(_ instanceof Uint8Array))&&s("jstrcpy() target must be an Int8Array or Uint8Array."),Q=Number(Q),y=Number(y),Q<0&&(Q=_.length-y),!(Q>0)||!(y>=0))return 0;let M=0,b=u.length,D=y,te=y+Q-(K?1:0);for(;M<b&&y<te;++M){let Z=u.charCodeAt(M);if(Z>=55296&&Z<=57343&&(Z=65536+((Z&1023)<<10)|u.charCodeAt(++M)&1023),Z<=127){if(y>=te)break;_[y++]=Z}else if(Z<=2047){if(y+1>=te)break;_[y++]=192|Z>>6,_[y++]=128|Z&63}else if(Z<=65535){if(y+2>=te)break;_[y++]=224|Z>>12,_[y++]=128|Z>>6&63,_[y++]=128|Z&63}else{if(y+3>=te)break;_[y++]=240|Z>>18,_[y++]=128|Z>>12&63,_[y++]=128|Z>>6&63,_[y++]=128|Z&63}}return K&&(_[y++]=0),y-D},r.cstrncpy=function(u,_,y){if((!u||!_)&&s("cstrncpy() does not accept NULL strings."),y<0)y=r.cstrlen(strPtr)+1;else if(!(y>0))return 0;let Q=r.heap8u(),K=0,M,b=Number(u),D=Number(_);for(;K<y&&(M=Q[D+K]);++K)Q[b+K]=M;return K<y&&(Q[b+K++]=0),K},r.jstrToUintArray=(u,_=!1)=>R.utf8Encoder.encode(_?u+"\0":u);let O=(u,_)=>{(!(u.alloc instanceof Function)||!(u.dealloc instanceof Function))&&s("Object is missing alloc() and/or dealloc() function(s)","required by",_+"().")},z=function(u,_,y,Q){if(O(r,Q),typeof u!="string")return null;let K=R.utf8Encoder.encode(u),M=y(K.length+1),b=M;try{let D=$().HEAP8U;return D.set(K,Number(M)),D[x(M,K.length)]=0,b=N,_?[M,K.length]:M}finally{b&&r.dealloc(b)}};r.allocCString=(u,_=!1)=>z(u,_,r.alloc,"allocCString()"),r.scopedAllocPush=function(){O(r,"scopedAllocPush");let u=[];return R.scopedAlloc.push(u),u},r.scopedAllocPop=function(u){O(r,"scopedAllocPop");let _=arguments.length?R.scopedAlloc.indexOf(u):R.scopedAlloc.length-1;_<0&&s("Invalid state object for scopedAllocPop()."),arguments.length===0&&(u=R.scopedAlloc[_]),R.scopedAlloc.splice(_,1);for(let y;y=u.pop();)r.functionEntry(y)?r.uninstallFunction(y):r.dealloc(y)},r.scopedAlloc=function(u){R.scopedAlloc.length||s("No scopedAllocPush() scope is active.");let _=V(r.alloc(u));return R.scopedAlloc.pushPtr(_)},Object.defineProperty(r.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>R.scopedAlloc.length,set:()=>s("The 'active' property is read-only.")}),r.scopedAllocCString=(u,_=!1)=>z(u,_,r.scopedAlloc,"scopedAllocCString()");let le=function(u,_){let y=r[u?"scopedAlloc":"alloc"]((_.length+1)*r.ptr.size),Q=0;return _.forEach(K=>{r.pokePtr(x(y,r.ptr.size*Q++),r[u?"scopedAllocCString":"allocCString"](""+K))}),r.pokePtr(x(y,r.ptr.size*Q),0),y};r.scopedAllocMainArgv=u=>le(!0,u),r.allocMainArgv=u=>le(!1,u),r.cArgvToJs=(u,_)=>{let y=[];for(let Q=0;Q<u;++Q){let K=r.peekPtr(x(_,r.ptr.size*Q));y.push(K?r.cstrToJs(K):null)}return y},r.scopedAllocCall=function(u){r.scopedAllocPush();try{return u()}finally{r.scopedAllocPop()}};let h=function(u,_,y){O(r,y);let Q=_?"i64":a,K=r[y](u*(_?8:m));if(r.poke(K,0,Q),u===1)return K;let M=[K];for(let b=1;b<u;++b)K=x(K,_?8:m),M[b]=K,r.poke(K,0,Q);return M};r.allocPtr=(u=1,_=!0)=>h(u,_,"alloc"),r.scopedAllocPtr=(u=1,_=!0)=>h(u,_,"scopedAlloc"),r.xGet=function(u){return r.exports[u]||s("Cannot find exported symbol:",u)};let A=(u,_)=>s(u+"() requires",_,"argument(s).");r.xCall=function(u,..._){let y=u instanceof Function?u:r.xGet(u);return y instanceof Function||s("Exported symbol",u,"is not a function."),y.length!==_.length&&A(y===u?y.name:u,y.length),arguments.length===2&&Array.isArray(arguments[1])?y.apply(null,arguments[1]):y.apply(null,_)},R.xWrap=Object.create(null),R.xWrap.convert=Object.create(null),R.xWrap.convert.arg=new Map,R.xWrap.convert.result=new Map;let U=R.xWrap.convert.arg,X=R.xWrap.convert.result,F=V;U.set("i64",d).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",U.get("f32")).set("f64",U.get("f32")).set("double",U.get("f64")).set("int",U.get("i32")).set("null",u=>u).set(null,U.get("null")).set("**",F).set("*",F),X.set("*",F).set("pointer",F).set("number",u=>Number(u)).set("void",u=>{}).set(void 0,X.get("void")).set("null",u=>u).set(null,X.get("null"));for(let u of["i8","i16","i32","i64","int","f32","float","f64","double"])U.set(u+"*",F),X.set(u+"*",F),X.set(u,U.get(u)||s("Maintenance required: missing arg converter for",u));let fe=u=>typeof u=="string"?r.scopedAllocCString(u):V(u);U.set("string",fe).set("utf8",fe),X.set("string",u=>r.cstrToJs(u)).set("utf8",X.get("string")).set("string:dealloc",u=>{try{return u?r.cstrToJs(u):null}finally{r.dealloc(u)}}).set("utf8:dealloc",X.get("string:dealloc")).set("json",u=>JSON.parse(r.cstrToJs(u))).set("json:dealloc",u=>{try{return u?JSON.parse(r.cstrToJs(u)):null}finally{r.dealloc(u)}});let de=class{constructor(u){this.name=u.name||"unnamed adapter"}convertArg(u,_,y){s("AbstractArgAdapter must be subclassed.")}};U.FuncPtrAdapter=class vt extends de{constructor(_){super(_),U.FuncPtrAdapter.warnOnUse&&console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",_),this.name=_.name||"unnamed",this.signature=_.signature,_.contextKey instanceof Function&&(this.contextKey=_.contextKey,_.bindScope||(_.bindScope="context")),this.bindScope=_.bindScope||s("FuncPtrAdapter options requires a bindScope (explicit or implied)."),vt.bindScopes.indexOf(_.bindScope)<0&&s("Invalid options.bindScope ("+_.bindMod+") for FuncPtrAdapter. Expecting one of: ("+vt.bindScopes.join(", ")+")"),this.isTransient=this.bindScope==="transient",this.isContext=this.bindScope==="context",this.isPermanent=this.bindScope==="permanent",this.singleton=this.bindScope==="singleton"?[]:void 0,this.callProxy=_.callProxy instanceof Function?_.callProxy:void 0}contextKey(_,y){return this}contextMap(_){let y=this.__cmap||(this.__cmap=new Map),Q=y.get(_);return Q===void 0&&y.set(_,Q=[]),Q}convertArg(_,y,Q){let K=this.singleton;if(!K&&this.isContext&&(K=this.contextMap(this.contextKey(y,Q))),K&&K.length===2&&K[0]===_)return K[1];if(_ instanceof Function){this.callProxy&&(_=this.callProxy(_));let M=J(_,this.signature,this.isTransient);if(vt.debugFuncInstall&&vt.debugOut("FuncPtrAdapter installed",this,this.contextKey(y,Q),"@"+M,_),K){if(K[1]){vt.debugFuncInstall&&vt.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(y,Q),"@"+K[1],_);try{R.scopedAlloc.pushPtr(K[1])}catch{}}K[0]=arguments[0]||N,K[1]=M}return M}else if(r.isPtr(_)||_===null||_===void 0){if(K&&K[1]&&K[1]!==_){vt.debugFuncInstall&&vt.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(y,Q),"@"+K[1],_);try{R.scopedAlloc.pushPtr(K[1])}catch{}K[0]=K[1]=_||N}return _||N}else throw new TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},U.FuncPtrAdapter.warnOnUse=!1,U.FuncPtrAdapter.debugFuncInstall=!1,U.FuncPtrAdapter.debugOut=console.debug.bind(console),U.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];let me=u=>U.get(u)||s("Argument adapter not found:",u),S=u=>X.get(u)||s("Result adapter not found:",u);R.xWrap.convertArg=(u,..._)=>me(u)(..._),R.xWrap.convertArgNoCheck=(u,..._)=>U.get(u)(..._),R.xWrap.convertResult=(u,_)=>u===null?_:u?S(u)(_):void 0,R.xWrap.convertResultNoCheck=(u,_)=>u===null?_:u?X.get(u)(_):void 0,r.xWrap=function u(_,y,...Q){arguments.length===3&&Array.isArray(arguments[2])&&(Q=arguments[2]),r.isPtr(_)&&(_=r.functionEntry(_)||s("Function pointer not found in WASM function table."));let K=_ instanceof Function,M=K?_:r.xGet(_);if(K&&(_=M.name||"unnamed function"),Q.length!==M.length&&A(_,M.length),M.length===0&&(y===null||y==="null"))return M;S(y);for(let D of Q)D instanceof de?U.set(D,(...te)=>D.convertArg(...te)):me(D);let b=R.xWrap;return M.length===0?(...D)=>D.length?A(_,M.length):b.convertResult(y,M.call(null)):function(...D){D.length!==M.length&&A(_,M.length);let te=r.scopedAllocPush();try{let Z=0;for(u.debug&&console.debug("xWrap() preparing: resultType ",y,"xf",M,"argTypes",Q,"args",D);Z<D.length;++Z)D[Z]=b.convertArgNoCheck(Q[Z],D[Z],D,Z);return u.debug&&console.debug("xWrap() calling: resultType ",y,"xf",M,"argTypes",Q,"args",D),b.convertResultNoCheck(y,M.apply(null,D))}finally{r.scopedAllocPop(te)}}};let C=function(u,_,y,Q,K,M){if(typeof y=="string"){if(_===1)return M.get(y);if(_===2){if(Q)Q instanceof Function||s(K,"requires a function argument.");else return M.delete(y),u;return M.set(y,Q),u}}s("Invalid arguments to",K)};return r.xWrap.resultAdapter=function u(_,y){return C(u,arguments.length,_,y,"resultAdapter()",X)},r.xWrap.argAdapter=function u(_,y){return C(u,arguments.length,_,y,"argAdapter()",U)},r.xWrap.FuncPtrAdapter=U.FuncPtrAdapter,r.xCallWrapped=function(u,_,y,...Q){return Array.isArray(arguments[3])&&(Q=arguments[3]),r.xWrap(u,_,y||[]).apply(null,Q||[])},r.xWrap.testConvertArg=R.xWrap.convertArg,r.xWrap.testConvertResult=R.xWrap.convertResult,r},globalThis.WhWasmUtilInstaller.yawl=function(r){"use strict";let s=()=>fetch(r.uri,{credentials:"same-origin"}),a=this,m=function(d){if(r.wasmUtilTarget){let q=(...N)=>{throw new Error(N.join(" "))},V=r.wasmUtilTarget;if(V.module=d.module,V.instance=d.instance,V.instance.exports.memory||(V.memory=r?.imports?.env?.memory||q("Missing 'memory' object!")),!V.alloc&&d.instance.exports.malloc){let N=d.instance.exports;V.alloc=function(x){return N.malloc(x)||q("Allocation of",x,"bytes failed.")},V.dealloc=function(x){x&&N.free(x)}}a(V)}return d.config=r,r.onload&&r.onload(d),d};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(s(),r.imports||{}).then(m):()=>s().then(d=>d.arrayBuffer()).then(d=>WebAssembly.instantiate(d,r.imports||{})).then(m)}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function o(r){"use strict";let s=(...P)=>{throw new Error(P.join(" "))};{let P=r.heap;P instanceof WebAssembly.Memory?P=function(){return new Uint8Array(this.buffer)}.bind(P):P instanceof Function||s("config.heap must be WebAssembly.Memory instance or","a function which returns one."),r.heap=P}["alloc","dealloc"].forEach(function(P){r[P]instanceof Function||s("Config option '"+P+"' must be a function.")});let a=o,m=r.heap,d=r.alloc,q=r.dealloc;r.realloc;let V=r.log||console.debug.bind(console),N=r.memberPrefix||"",x=r.memberSuffix||"",R=globalThis.BigInt,$=globalThis.BigInt64Array,B=r.bigIntEnabled??!!$,J,E=r.pointerSize||r.ptrSize||(typeof(J=d(1))=="bigint"?8:4),w=r.pointerIR||r.ptrIR||(E===4?"i32":"i64");J&&(q(J),J=void 0),E!==4&&E!==8&&s("Invalid pointer size:",E),w!=="i32"&&w!=="i64"&&s("Invalid pointer representation:",w);let W=B&&R?P=>R(P||0):P=>s("BigInt support is disabled in this build."),ee=w=="i32"?Number:W,O=ee(0),z=function(...P){let ie=O;for(let ce=0;ce<P.length;++ce)ie+=ee(P[ce]);return ie},le=function(...P){return z(this.pointer,...P)};a.debugFlags||(a.__makeDebugFlags=function(P=null){P&&P.__flags&&(P=P.__flags);let ie=function ce(pe){return arguments.length===0?ce.__flags:(pe<0?(delete ce.__flags.getter,delete ce.__flags.setter,delete ce.__flags.alloc,delete ce.__flags.dealloc):(ce.__flags.getter=(1&pe)!==0,ce.__flags.setter=(2&pe)!==0,ce.__flags.alloc=(4&pe)!==0,ce.__flags.dealloc=(8&pe)!==0),ce._flags)};return Object.defineProperty(ie,"__flags",{iterable:!1,writable:!1,value:Object.create(P)}),P||ie(0),ie},a.debugFlags=a.__makeDebugFlags());let h=!0,A=P=>P[1]==="(",U=P=>P==="p"||P==="P"||P==="s",X=P=>P==="P",F=P=>P?A(P)?"p":P[0]:void 0,fe=function(P){switch(F(P)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return w;case"j":return"i64";case"f":return"float";case"d":return"double"}s("Unhandled signature IR:",P)},de=function(P){switch(F(P)){case"c":case"C":return 1;case"i":return 4;case"p":case"P":case"s":return E;case"j":return 8;case"f":return 4;case"d":return 8}s("Unhandled signature sizeof:",P)},me=$?()=>!0:()=>s("BigInt64Array is not available."),S=function(P){switch(F(P)){case"p":case"P":case"s":switch(E){case 4:return"getInt32";case 8:return me()&&"getBigInt64"}break;case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return me()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}s("Unhandled DataView getter for signature:",P)},C=function(P){switch(F(P)){case"p":case"P":case"s":switch(E){case 4:return"setInt32";case 8:return me()&&"setBigInt64"}break;case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return me()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}s("Unhandled DataView setter for signature:",P)},u=function(P){switch(F(P)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return W;case"p":case"P":case"s":switch(E){case 4:return Number;case 8:return W}}s("Unhandled DataView set wrapper for signature:",P)},_=(P,ie)=>P+"::"+ie,y=function(P,ie){return()=>s(_(P,ie),"is read-only.")},Q=function P(ie,ce=!0){let pe=P.map.get(ie);return!pe&&ce&&P.map.set(ie,pe=P.create(ie)),pe};Q.map=new WeakMap,Q.create=P=>Object.assign(Object.create(null),{o:P,p:void 0,ownsPointer:!1,zod:!1,xb:0});let K=P=>Q.map.delete(P),M=P=>typeof P=="number"&&P===(P|0)&&P>=0,D=E===4?M:P=>typeof P=="bigint"&&P>=0||M(P),te=P=>D(P)&&P>0,Z=function(P,ie,ce){let pe=Q(ie,!1);if(pe){if(K(ie),!ce&&!(ce=pe.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(ie.ondispose)){let xe;for(;xe=ie.ondispose.pop();)try{xe instanceof Function?xe.call(ie):xe instanceof lt?xe.dispose():D(xe)&&q(xe)}catch(Qe){console.warn("ondispose() for",P.structName,"@",ce,"threw. NOT propagating it.",Qe)}}else if(ie.ondispose instanceof Function)try{ie.ondispose()}catch(xe){console.warn("ondispose() for",P.structName,"@",ce,"threw. NOT propagating it.",xe)}delete ie.ondispose,P.debugFlags.__flags.dealloc&&V("debug.dealloc:",pe.ownsPointer?"":"EXTERNAL",P.structName,"instance:",P.structInfo.sizeof,"bytes @"+ce),pe.ownsPointer&&((pe.zod||P.structInfo.zeroOnDispose)&&m().fill(0,Number(ce),Number(ce)+P.structInfo.sizeof+pe.xb),q(ce))}},we=()=>({configurable:!1,writable:!1,iterable:!1}),he=P=>({...we(),value:P}),Ie=function(ie,ce,pe){let xe,Qe=ze=>{te(ze)||s("Invalid pointer value",arguments[0],"for",ie.structName,"constructor.")};arguments.length>=3?pe&&typeof pe=="object"?(xe=pe,pe=xe?.wrap):(Qe(pe),xe={wrap:pe}):xe={};let et=!pe,it=0,ct=!1;if(pe)Qe(pe),ct=!!xe?.takeOwnership;else{let ze=xe?.extraBytes??0;(ze<0||ze!==(ze|0))&&s("Invalid extraBytes value:",xe?.extraBytes),it=ie.structInfo.sizeof+ze,pe=d(it)||s("Allocation of",ie.structName,"structure failed."),ct=!0}try{xe?.debugFlags&&ce.debugFlags(xe.debugFlags),ie.debugFlags.__flags.alloc&&V("debug.alloc:",et?"":"EXTERNAL",ie.structName,"instance:",ie.structInfo.sizeof,"bytes @"+pe),et&&m().fill(0,Number(pe),Number(pe)+it);let ze=Q(ce);ze.p=pe,ze.ownsPointer=ct,ze.xb=it?it-ie.structInfo.sizeof:0,ze.zod=!!xe?.zeroOnDispose,xe?.ondispose&&xe.ondispose!==pe&&ce.addOnDispose(xe.ondispose)}catch(ze){throw Z(ie,ce,pe),ze}},Be=function P(ie){return P.rxSig1??=/^[ipPsjfdcC]$/,P.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,P.rxSig1.test(ie)||P.rxSig2.test(ie)},Ze=function(P){let ie=this.get(P);return ie||(ie=[Object.create(null),Object.create(null),Object.create(null)],this.set(P,ie)),ie}.bind(new WeakMap),at=function(P,ie,ce,pe){let xe=Ze(P)[ie];return arguments.length===3?xe[ce]:pe?xe[ce]=pe:delete xe[ce]},Ct=function(P,...ie){return at(this,0,P,...ie)},mn=function(P,ie){Be(ie)&&s(P,"(",ie,") collides with a data type signature.")},L=function(P,...ie){return mn("Setter adaptor",P),at(this,1,P,...ie)},G=function(P,...ie){return mn("Struct adaptor",P),at(this,2,P,...ie)},oe=function(P,ie){let ce=typeof ie=="string"?at(P,2,ie):ie;return typeof ce!="object"&&s("Invalid struct mapping object. Arg =",ie,JSON.stringify(ce)),ce},Se=he(P=>N+P+x),ve=function(P,ie,ce=!0){let pe=P.members[ie];if(!pe&&(N||x)){for(let xe of Object.values(P.members))if(xe.key===ie){pe=xe;break}!pe&&ce&&s(_(P.name||P.structName,ie),"is not a mapped struct member.")}return pe},Ee=function P(ie,ce,pe=!1){P._||(P._=Qe=>Qe.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));let xe=ve(ie.structInfo,ce,!0);return pe?P._(xe.signature):xe.signature},qe=he(function(){let P=[];for(let ie of Object.keys(this.structInfo.members))P.push(this.memberKey(ie));return P}),Me=new TextDecoder("utf-8"),He=new TextEncoder,$e=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Ue=function(P,ie,ce){return E===8&&(ie=Number(ie),ce=Number(ce)),Me.decode(P.buffer instanceof $e?P.slice(ie,ce):P.subarray(ie,ce))},Ke=function(P,ie,ce=!1){let pe=ve(P.structInfo,ie,ce);return pe&&pe.signature.length===1&&pe.signature[0]==="s"?pe:!1},gt=function(P){P.signature!=="s"&&s("Invalid member type signature for C-string value:",JSON.stringify(P))},Tt=function(ie,ce){let pe=ve(ie.structInfo,ce,!0);gt(pe);let xe=ie[pe.key];if(!xe)return null;let Qe=xe,et=m();for(;et[Qe]!==0;++Qe);return xe===Qe?"":Ue(et,xe,Qe)},zt=function(P,...ie){P.ondispose?Array.isArray(P.ondispose)||(P.ondispose=[P.ondispose]):P.ondispose=[],P.ondispose.push(...ie)},Dt=function(P){let ie=He.encode(P),ce=d(ie.length+1);ce||s("Allocation error while duplicating string:",P);let pe=m();return pe.set(ie,Number(ce)),pe[z(ce,ie.length)]=0,ce},tn=function(P,ie,ce){let pe=ve(P.structInfo,ie,!0);gt(pe);let xe=Dt(ce);return P[pe.key]=xe,zt(P,xe),P},lt=function(ie,ce){arguments[2]!==he&&s("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:he(ie),structInfo:he(ce)})};lt.prototype=Object.create(null,{dispose:he(function(){Z(this.constructor,this)}),lookupMember:he(function(P,ie=!0){return ve(this.structInfo,P,ie)}),memberToJsString:he(function(P){return Tt(this,P)}),memberIsString:he(function(P,ie=!0){return Ke(this,P,ie)}),memberKey:Se,memberKeys:qe,memberSignature:he(function(P,ie=!1){return Ee(this,P,ie)}),memoryDump:he(function(){let P=this.pointer;return P?new Uint8Array(m().slice(Number(P),Number(P)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return Q(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return Q(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return Q(this,!1)?.p},set:()=>s("Cannot assign the 'pointer' property of a struct.")},setMemberCString:he(function(P,ie){return tn(this,P,ie)})}),Object.assign(lt.prototype,{addOnDispose:function(...P){return zt(this,...P),this}}),Object.defineProperties(lt,{allocCString:he(Dt),isA:he(P=>P instanceof lt),hasExternalPointer:he(P=>{let ie=Q(P,!1);return!!(ie?.p&&!ie?.ownsPointer)}),memberKey:Se});let pn=function(P){return P.get||(P.adaptGet?dt.adaptGet(P.adaptGet):void 0)},Cr=function(P){return P.set||(P.adaptSet?dt.adaptSet(P.adaptSet):void 0)},Eo=function P(ie,ce,pe){let xe=P.innerStructs??=new Map,Qe=ie.memberKey(ce);pe.signature!==void 0&&s("'signature' cannot be used on an embedded struct (",ie.structName,".",Qe,")."),Cr(pe)&&s("'set' and 'adaptSet' are not permitted for nested struct members."),pe.structName??=ie.structName+"::"+ce,pe.key=Qe,pe.name=ce,pe.constructor=this.call(this,pe.structName,pe);let et=pn(pe),it=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:y(ie.structName,Qe),get:function(){let ct=this.debugFlags.__flags,ze=this.pointer,tt=ze+"."+Qe,ke=xe.get(tt);return ct.getter&&V("debug.getter: k =",tt),ke||(ke=new pe.constructor(z(ze,pe.offset)),xe.set(tt,ke),this.addOnDispose(()=>ke.dispose()),ke.addOnDispose(()=>xe.delete(tt))),et&&(ke=et.apply(this,[ke,Qe])),ct.getter&&V("debug.getter: result =",ke),ke}});Object.defineProperty(ie.prototype,Qe,it)},qo=function P(ie,ce,pe){if(pe=oe(this,pe),pe.members)return Eo.call(this,ie,ce,pe);if(!P.cache){P.cache={getters:{},setters:{},sw:{}};let tt=["i","c","C","p","P","s","f","d","v()"];B&&tt.push("j"),tt.forEach(function(ke){P.cache.getters[ke]=S(ke),P.cache.setters[ke]=C(ke),P.cache.sw[ke]=u(ke)}),P.sigCheck=function(ke,Je,_n,Nr){Object.prototype.hasOwnProperty.call(ke,_n)&&s(ke.structName,"already has a property named",_n+"."),Be(Nr)||s("Malformed signature for",_(ke.structName,Je)+":",Nr)}}let xe=ie.memberKey(ce);P.sigCheck(ie.prototype,ce,xe,pe.signature),pe.key=xe,pe.name=ce;let Qe=F(pe.signature),et=_(ie.structName,xe),it=ie.debugFlags.__flags,ct=pn(pe),ze=Object.create(null);if(ze.configurable=!1,ze.enumerable=!1,ze.get=function(){it.getter&&V("debug.getter:",P.cache.getters[Qe],"for",fe(Qe),et,"@",this.pointer,"+",pe.offset,"sz",pe.sizeof);let tt=new DataView(m().buffer,Number(this.pointer)+pe.offset,pe.sizeof)[P.cache.getters[Qe]](0,h);return ct&&(tt=ct.apply(this,[xe,tt])),it.getter&&V("debug.getter:",et,"result =",tt),tt},pe.readOnly)ze.set=y(ie.prototype.structName,xe);else{let tt=Cr(pe);ze.set=function(ke){it.setter&&V("debug.setter:",P.cache.setters[Qe],"for",fe(Qe),et,"@",this.pointer,"+",pe.offset,"sz",pe.sizeof,ke),this.pointer||s("Cannot set native property on a disposed",this.structName,"instance."),tt&&(ke=tt.apply(this,[xe,ke])),ke==null?ke=O:U(pe.signature)&&!D(ke)&&(X(pe.signature)&&ke instanceof lt?(ke=ke.pointer||O,it.setter&&V("debug.setter:",et,"resolved to",ke)):s("Invalid value for pointer-type",et+".")),new DataView(m().buffer,Number(this.pointer)+pe.offset,pe.sizeof)[P.cache.setters[Qe]](0,P.cache.sw[Qe](ke),h)}}Object.defineProperty(ie.prototype,xe,ze)},Dr=function P(ie,ce,pe=Object.create(null)){let xe=function ke(Je){this instanceof ke||s("The",ie,"constructor may only be called via 'new'."),Ie(ke,this,...arguments)},Qe=this,et=ke=>typeof ke=="string"&&Be(ke)?{signature:ke}:oe(Qe,ke);arguments.length===1?(ce=et(ie),ie=ce.structName||ce.name):arguments.length===2?(ce=et(ce),ce.name??=ie):ce=et(ce),ie??=ce.structName,ie??=pe.structName,ie||s("One of 'name' or 'structName' are required."),ce.adapt&&(Object.keys(ce.adapt.struct||{}).forEach(ke=>{G.call(P,ke,ce.adapt.struct[ke])}),Object.keys(ce.adapt.set||{}).forEach(ke=>{L.call(P,ke,ce.adapt.set[ke])}),Object.keys(ce.adapt.get||{}).forEach(ke=>{Ct.call(P,ke,ce.adapt.get[ke])})),!ce.members&&!ce.sizeof&&(ce.sizeof=de(ce.signature));let it=he(a.__makeDebugFlags(dt.debugFlags));Object.defineProperties(xe,{debugFlags:it,isA:he(ke=>ke instanceof xe),memberKey:Se,memberKeys:qe,structInfo:he(ce),structName:he(ie),ptrAdd:he(z)}),xe.prototype=new lt(ie,ce,he),Object.defineProperties(xe.prototype,{debugFlags:it,constructor:he(xe),ptrAdd:he(le)});let ct=!1,ze=0,tt=!!ce.autoCalcSizeOffset;return tt||ce.sizeof||s(ie,"description is missing its sizeof property."),ce.offset??=0,Object.keys(ce.members||{}).forEach(ke=>{let Je=et(ce.members[ke]);!Je.members&&!Je.sizeof&&(Je.sizeof=de(Je.signature),Je.sizeof||s(_(ie,ke),"is missing a sizeof property.",Je)),Je.offset===void 0&&(tt?Je.offset=ze:s(_(ie,ke),"is missing its offset.",JSON.stringify(Je))),ce.members[ke]=Je,(!ct||ct.offset<Je.offset)&&(ct=Je);let _n=!!Je.autoCalc;tt&&(Je.autoCalcSizeOffset=!0),qo.call(Qe,xe,ke,Je),_n?Je.autoCalcSizeOffset=!0:delete Je.autoCalcSizeOffset,ze+=Je.sizeof}),ct||s("No member property descriptions found."),ce.sizeof||(ce.sizeof=ze),ce.sizeof===1?ce.signature==="c"||ce.signature==="C"||s("Unexpected sizeof==1 member",_(ie,k),"with signature",ce.signature):(ce.sizeof%4!==0&&(console.warn("Invalid struct member description",ce),s(ie,"sizeof is not aligned. sizeof="+ce.sizeof)),ce.offset%4!==0&&(console.warn("Invalid struct member description",ce),s(ie,"offset is not aligned. offset="+ce.offset))),ce.sizeof<ze&&(console.warn("Suspect struct description:",ce,"offset =",ze),s("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",ze,"but got",ce.sizeof,"for",ce)),delete ce.autoCalcSizeOffset,xe},dt=function P(ie,ce){return arguments.length==1?Dr.call(P,ie):Dr.call(P,ie,ce)};return dt.StructType=lt,dt.config=r,dt.allocCString=Dt,dt.adaptGet=Ct,dt.adaptSet=L,dt.adaptStruct=G,dt.ptrAdd=z,dt.debugFlags||(dt.debugFlags=a.__makeDebugFlags(a.debugFlags)),dt},globalThis.sqlite3ApiBootstrap.initializers.push(function(o){"use strict";let r=(...E)=>{throw new Error(E.join(" "))},s=o.capi,a=o.wasm,m=o.util;globalThis.WhWasmUtilInstaller(a),delete globalThis.WhWasmUtilInstaller;let d={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_bind_double","int","sqlite3_stmt*","int","f64"],["sqlite3_bind_int","int","sqlite3_stmt*","int","int"],["sqlite3_bind_null",void 0,"sqlite3_stmt*","int"],["sqlite3_bind_parameter_count","int","sqlite3_stmt*"],["sqlite3_bind_parameter_index","int","sqlite3_stmt*","string"],["sqlite3_bind_parameter_name","string","sqlite3_stmt*","int"],["sqlite3_bind_pointer","int","sqlite3_stmt*","int","*","string:static","*"],["sqlite3_bind_zeroblob","int","sqlite3_stmt*","int","int"],["sqlite3_busy_handler","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(E,w)=>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 w;return(W,ee,O,z)=>{try{let le=a.cArgvToJs(ee,O);return w||(w=a.cArgvToJs(ee,z)),E(le,w)|0}catch(le){return le.resultCode||s.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,w)=>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=>(w,W,ee,O,z)=>{E(w,W,a.cstrToJs(ee),a.cstrToJs(O),z)}}),"*"]],["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&&d.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new a.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(E,w)=>E[0]}),"*"]]),a.exports.sqlite3_stmt_explain&&d.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]),a.exports.sqlite3_set_authorizer&&d.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(E,w)=>E[0],callProxy:E=>(w,W,ee,O,z,le)=>{try{return ee=ee&&a.cstrToJs(ee),O=O&&a.cstrToJs(O),z=z&&a.cstrToJs(z),le=le&&a.cstrToJs(le),E(w,W,ee,O,z,le)|0}catch(h){return h.resultCode||s.SQLITE_ERROR}}}),"*"]]),a.exports.sqlite3_column_origin_name&&d.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"]),a.bigIntEnabled&&a.exports.sqlite3_declare_vtab&&d.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","**"]),a.bigIntEnabled&&a.exports.sqlite3_preupdate_hook&&d.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=>(w,W,ee,O,z,le,h)=>{E(w,W,ee,a.cstrToJs(O),a.cstrToJs(z),le,h)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]),a.bigIntEnabled&&a.exports.sqlite3changegroup_add&&a.exports.sqlite3session_create&&a.exports.sqlite3_preupdate_hook){let E={signature:"i(ps)",callProxy:w=>(W,ee)=>{try{return w(W,a.cstrToJs(ee))|0}catch(O){return O.resultCode||s.SQLITE_ERROR}}};d.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:(w,W)=>w[0]}),"*"]])}o.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",O=>E(m.flexibleString(O))),a.xWrap.argAdapter("string:static",function(O){return a.isPtr(O)?O:(O=""+O,this[O]||(this[O]=a.allocCString(O)))}.bind(Object.create(null)));let w=a.xWrap.argAdapter("*"),W=function(){};a.xWrap.argAdapter("sqlite3_filename",w)("sqlite3_context*",w)("sqlite3_value*",w)("void*",w)("sqlite3_changegroup*",w)("sqlite3_changeset_iter*",w)("sqlite3_session*",w)("sqlite3_stmt*",O=>w(O instanceof(o?.oo1?.Stmt||W)?O.pointer:O))("sqlite3*",O=>w(O instanceof(o?.oo1?.DB||W)?O.pointer:O))("sqlite3_vfs*",O=>typeof O=="string"?s.sqlite3_vfs_find(O)||o.SQLite3Error.toss(s.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",O):w(O instanceof(s.sqlite3_vfs||W)?O.pointer:O)),a.exports.sqlite3_declare_vtab&&a.xWrap.argAdapter("sqlite3_index_info*",O=>w(O instanceof(s.sqlite3_index_info||W)?O.pointer:O))("sqlite3_module*",O=>w(O instanceof(s.sqlite3_module||W)?O.pointer:O));let ee=a.xWrap.resultAdapter("*");a.xWrap.resultAdapter("sqlite3*",ee)("sqlite3_context*",ee)("sqlite3_stmt*",ee)("sqlite3_value*",ee)("sqlite3_vfs*",ee)("void*",ee);for(let O of d.core)s[O[0]]=a.xWrap.apply(null,O);for(let O of d.wasmInternal)m[O[0]]=a.xWrap.apply(null,O);for(let O of d.int64)s[O[0]]=a.bigIntEnabled?a.xWrap.apply(null,O):()=>r(O[0]+"() is unavailable due to lack","of BigInt support in this build.");delete d.core,delete d.int64,delete d.wasmInternal,m.sqlite3__wasm_db_error=function(O,z,le){return O?(z instanceof o.WasmAllocError?(z=s.SQLITE_NOMEM,le=0):z instanceof Error&&(le=le||""+z,z=z.resultCode||s.SQLITE_ERROR),s.sqlite3_set_errmsg(O,z,le)||z):s.SQLITE_MISUSE}}{let E=a.xCall("sqlite3__wasm_enum_json");E||r("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!"),a.ctype=JSON.parse(a.cstrToJs(E));let w=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];a.bigIntEnabled&&w.push("serialize","session","vtab");for(let O of w)for(let z of Object.entries(a.ctype[O]))s[z[0]]=z[1];a.functionEntry(s.SQLITE_WASM_DEALLOC)||r("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+s.SQLITE_WASM_DEALLOC+").");let W=Object.create(null);for(let O of Object.entries(a.ctype.resultCodes))W[O[1]]=O[0];s.sqlite3_js_rc_str=O=>W[O];let ee=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 O of a.ctype.structs)ee[O.name]||(s[O.name]=o.StructBinder(O));if(s.sqlite3_index_info){for(let O of["sqlite3_index_constraint","sqlite3_index_orderby","sqlite3_index_constraint_usage"])s.sqlite3_index_info[O]=s[O],delete s[O];s.sqlite3_vtab_config=a.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}let q=(E,w,W)=>m.sqlite3__wasm_db_error(E,s.SQLITE_MISUSE,w+"() requires "+W+" argument"+(W===1?"":"s")+"."),V=E=>m.sqlite3__wasm_db_error(E,s.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),N=E=>a.xWrap.argAdapter("sqlite3*")(E),x=E=>a.isPtr(E)?a.cstrToJs(E):E,R=function(E,w){E=N(E);let W=this.dbMap.get(E);if(w)!W&&w>0&&this.dbMap.set(E,W=Object.create(null));else return this.dbMap.delete(E),W;return W}.bind(Object.assign(Object.create(null),{dbMap:new Map}));R.addCollation=function(E,w){let W=R(E,1);W.collation||(W.collation=new Set),W.collation.add(x(w).toLowerCase())},R._addUDF=function(E,w,W,ee){w=x(w).toLowerCase();let O=ee.get(w);O||ee.set(w,O=new Set),O.add(W<0?-1:W)},R.addFunction=function(E,w,W){let ee=R(E,1);ee.udf||(ee.udf=new Map),this._addUDF(E,w,W,ee.udf)},a.exports.sqlite3_create_window_function&&(R.addWindowFunc=function(E,w,W){let ee=R(E,1);ee.wudf||(ee.wudf=new Map),this._addUDF(E,w,W,ee.wudf)}),R.cleanup=function(E){E=N(E);for(let ee 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[O,z]=ee;if(!a.exports[O])continue;let le=[E];le.length=z;try{s[O](...le)}catch(h){o.config.warn("close-time call of",O+"(",le,") threw:",h)}}let w=R(E,0);if(!w)return;if(w.collation){for(let ee of w.collation)try{s.sqlite3_create_collation_v2(E,ee,s.SQLITE_UTF8,0,0,0)}catch{}delete w.collation}let W=0;for(;W<2;++W){let ee=W?w.wudf:w.udf;if(!ee)continue;let O=W?s.sqlite3_create_window_function:s.sqlite3_create_function_v2;for(let z of ee){let le=z[0],h=z[1],A=[E,le,0,s.SQLITE_UTF8,0,0,0,0,0];W&&A.push(0);for(let U of h)try{A[2]=U,O.apply(null,A)}catch{}h.clear()}ee.clear()}delete w.udf,delete w.wudf};{let E=a.xWrap("sqlite3_close_v2","int","sqlite3*");s.sqlite3_close_v2=function(w){if(arguments.length!==1)return q(w,"sqlite3_close_v2",1);if(w)try{R.cleanup(w)}catch{}return E(w)}}if(s.sqlite3session_create){let E=a.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);s.sqlite3session_delete=function(w){if(arguments.length!==1)return q(pDb,"sqlite3session_delete",1);w&&s.sqlite3session_table_filter(w,0,0),E(w)}}{let E=(W,ee)=>"argv["+ee+"]:"+W[0]+":"+a.cstrToJs(W[1]).toLowerCase(),w=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})]);s.sqlite3_create_collation_v2=function(W,ee,O,z,le,h){if(arguments.length!==6)return q(W,"sqlite3_create_collation_v2",6);if((O&15)===0)O|=s.SQLITE_UTF8;else if(s.SQLITE_UTF8!==(O&15))return V(W);try{let A=w(W,ee,O,z,le,h);return A===0&&le instanceof Function&&R.addCollation(W,ee),A}catch(A){return m.sqlite3__wasm_db_error(W,A)}},s.sqlite3_create_collation=(W,ee,O,z,le)=>arguments.length===5?s.sqlite3_create_collation_v2(W,ee,O,z,le,0):q(W,"sqlite3_create_collation",5)}{let E=function(O,z){return O[0]+":"+(O[2]<0?-1:O[2])+":"+z+":"+a.cstrToJs(O[1]).toLowerCase()},w=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:E,callProxy:O=>(z,le,h)=>{try{O(z,...s.sqlite3_values_to_js(le,h))}catch(A){s.sqlite3_result_error_js(z,A)}}},xFinalAndValue:{signature:"v(p)",contextKey:E,callProxy:O=>z=>{try{s.sqlite3_result_js(z,O(z))}catch(le){s.sqlite3_result_error_js(z,le)}}},xFunc:{signature:"v(pip)",contextKey:E,callProxy:O=>(z,le,h)=>{try{s.sqlite3_result_js(z,O(z,...s.sqlite3_values_to_js(le,h)))}catch(A){s.sqlite3_result_error_js(z,A)}}},xDestroy:{signature:"v(p)",contextKey:E,callProxy:O=>z=>{try{O(z)}catch(le){console.error("UDF xDestroy method threw:",le)}}}}),W=a.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xFunc",...w.xFunc}),new a.xWrap.FuncPtrAdapter({name:"xStep",...w.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...w.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...w.xDestroy})]),ee=a.exports.sqlite3_create_window_function?a.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xStep",...w.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...w.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xValue",...w.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xInverse",...w.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...w.xDestroy})]):void 0;s.sqlite3_create_function_v2=function O(z,le,h,A,U,X,F,fe,de){if(O.length!==arguments.length)return q(z,"sqlite3_create_function_v2",O.length);if((A&15)===0)A|=s.SQLITE_UTF8;else if(s.SQLITE_UTF8!==(A&15))return V(z);try{let me=W(z,le,h,A,U,X,F,fe,de);return me===0&&(X instanceof Function||F instanceof Function||fe instanceof Function||de instanceof Function)&&R.addFunction(z,le,h),me}catch(me){return console.error("sqlite3_create_function_v2() setup threw:",me),m.sqlite3__wasm_db_error(z,me,"Creation of UDF threw: "+me)}},s.sqlite3_create_function=function O(z,le,h,A,U,X,F,fe){return O.length===arguments.length?s.sqlite3_create_function_v2(z,le,h,A,U,X,F,fe,0):q(z,"sqlite3_create_function",O.length)},ee?s.sqlite3_create_window_function=function O(z,le,h,A,U,X,F,fe,de,me){if(O.length!==arguments.length)return q(z,"sqlite3_create_window_function",O.length);if((A&15)===0)A|=s.SQLITE_UTF8;else if(s.SQLITE_UTF8!==(A&15))return V(z);try{let S=ee(z,le,h,A,U,X,F,fe,de,me);return S===0&&(X instanceof Function||F instanceof Function||fe instanceof Function||de instanceof Function||me instanceof Function)&&R.addWindowFunc(z,le,h),S}catch(S){return console.error("sqlite3_create_window_function() setup threw:",S),m.sqlite3__wasm_db_error(z,S,"Creation of UDF threw: "+S)}}:delete s.sqlite3_create_window_function,s.sqlite3_create_function_v2.udfSetResult=s.sqlite3_create_function.udfSetResult=s.sqlite3_result_js,s.sqlite3_create_window_function&&(s.sqlite3_create_window_function.udfSetResult=s.sqlite3_result_js),s.sqlite3_create_function_v2.udfConvertArgs=s.sqlite3_create_function.udfConvertArgs=s.sqlite3_values_to_js,s.sqlite3_create_window_function&&(s.sqlite3_create_window_function.udfConvertArgs=s.sqlite3_values_to_js),s.sqlite3_create_function_v2.udfSetError=s.sqlite3_create_function.udfSetError=s.sqlite3_result_error_js,s.sqlite3_create_window_function&&(s.sqlite3_create_window_function.udfSetError=s.sqlite3_result_error_js)}{let E=(W,ee)=>(typeof W=="string"?ee=-1:m.isSQLableTypedArray(W)?(ee=W.byteLength,W=a.typedArrayToString(W instanceof ArrayBuffer?new Uint8Array(W):W)):Array.isArray(W)&&(W=W.join(""),ee=-1),[W,ee]),w={basic:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};s.sqlite3_prepare_v3=function W(ee,O,z,le,h,A){if(W.length!==arguments.length)return q(ee,"sqlite3_prepare_v3",W.length);let[U,X]=E(O,Number(z));switch(typeof U){case"string":return w.basic(ee,U,X,le,h,null);case typeof a.ptr.null:return w.full(ee,a.ptr.coerce(U),X,le,h,A);default:return m.sqlite3__wasm_db_error(ee,s.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof U)}},s.sqlite3_prepare_v2=function W(ee,O,z,le,h){return W.length===arguments.length?s.sqlite3_prepare_v3(ee,O,z,0,le,h):q(ee,"sqlite3_prepare_v2",W.length)}}{let E=a.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),w=a.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);s.sqlite3_bind_text=function W(ee,O,z,le,h){if(W.length!==arguments.length)return q(s.sqlite3_db_handle(ee),"sqlite3_bind_text",W.length);if(a.isPtr(z)||z===null)return E(ee,O,z,le,h);z instanceof ArrayBuffer?z=new Uint8Array(z):Array.isArray(pMem)&&(z=pMem.join(""));let A,U;try{if(m.isSQLableTypedArray(z))A=a.allocFromTypedArray(z),U=z.byteLength;else if(typeof z=="string")[A,U]=a.allocCString(z);else return m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),s.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return E(ee,O,A,U,s.SQLITE_WASM_DEALLOC)}catch(X){return a.dealloc(A),m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),X)}},s.sqlite3_bind_blob=function W(ee,O,z,le,h){if(W.length!==arguments.length)return q(s.sqlite3_db_handle(ee),"sqlite3_bind_blob",W.length);if(a.isPtr(z)||z===null)return w(ee,O,z,le,h);z instanceof ArrayBuffer?z=new Uint8Array(z):Array.isArray(z)&&(z=z.join(""));let A,U;try{if(m.isBindableTypedArray(z))A=a.allocFromTypedArray(z),U=le>=0?le:z.byteLength;else if(typeof z=="string")[A,U]=a.allocCString(z);else return m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),s.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return w(ee,O,A,U,s.SQLITE_WASM_DEALLOC)}catch(X){return a.dealloc(A),m.sqlite3__wasm_db_error(s.sqlite3_db_handle(ee),X)}}}if(!s.sqlite3_column_text){let E=a.xWrap.argAdapter("sqlite3_stmt*"),w=a.xWrap.argAdapter("int"),W=a.xWrap.argAdapter("sqlite3_value*"),ee=(O,z)=>a.typedArrayToString(a.heap8u(),Number(O),Number(O)+z);s.sqlite3_column_text=function(O,z){let le=E(O),h=w(z),A=a.exports.sqlite3_column_text(le,h);return A?ee(A,a.exports.sqlite3_column_bytes(le,h)):null},s.sqlite3_value_text=function(O){let z=W(O),le=a.exports.sqlite3_value_text(z);return le?ee(le,a.exports.sqlite3_value_bytes(z)):null}}s.sqlite3_config=function(E,...w){if(arguments.length<2)return s.SQLITE_MISUSE;switch(E){case s.SQLITE_CONFIG_COVERING_INDEX_SCAN:case s.SQLITE_CONFIG_MEMSTATUS:case s.SQLITE_CONFIG_SMALL_MALLOC:case s.SQLITE_CONFIG_SORTERREF_SIZE:case s.SQLITE_CONFIG_STMTJRNL_SPILL:case s.SQLITE_CONFIG_URI:return a.exports.sqlite3__wasm_config_i(E,w[0]);case s.SQLITE_CONFIG_LOOKASIDE:return a.exports.sqlite3__wasm_config_ii(E,w[0],w[1]);case s.SQLITE_CONFIG_MEMDB_MAXSIZE:return a.exports.sqlite3__wasm_config_j(E,w[0]);case s.SQLITE_CONFIG_GETMALLOC:case s.SQLITE_CONFIG_GETMUTEX:case s.SQLITE_CONFIG_GETPCACHE2:case s.SQLITE_CONFIG_GETPCACHE:case s.SQLITE_CONFIG_HEAP:case s.SQLITE_CONFIG_LOG:case s.SQLITE_CONFIG_MALLOC:case s.SQLITE_CONFIG_MMAP_SIZE:case s.SQLITE_CONFIG_MULTITHREAD:case s.SQLITE_CONFIG_MUTEX:case s.SQLITE_CONFIG_PAGECACHE:case s.SQLITE_CONFIG_PCACHE2:case s.SQLITE_CONFIG_PCACHE:case s.SQLITE_CONFIG_PCACHE_HDRSZ:case s.SQLITE_CONFIG_PMASZ:case s.SQLITE_CONFIG_SERIALIZED:case s.SQLITE_CONFIG_SINGLETHREAD:case s.SQLITE_CONFIG_SQLLOG:case s.SQLITE_CONFIG_WIN32_HEAPSIZE:default:return s.SQLITE_NOTFOUND}};{let E=new Set;s.sqlite3_auto_extension=function(w){if(w instanceof Function)w=a.installFunction("i(ppp)",w);else if(arguments.length!==1||!a.isPtr(w))return s.SQLITE_MISUSE;let W=a.exports.sqlite3_auto_extension(w);return w!==arguments[0]&&(W===0?E.add(w):a.uninstallFunction(w)),W},s.sqlite3_cancel_auto_extension=function(w){return!w||arguments.length!==1||!a.isPtr(w)?0:a.exports.sqlite3_cancel_auto_extension(w)},s.sqlite3_reset_auto_extension=function(){a.exports.sqlite3_reset_auto_extension();for(let w of E)a.uninstallFunction(w);E.clear()}}a.xWrap.FuncPtrAdapter.warnOnUse=!0;let $=o.StructBinder,B=function E(w,W,ee,O=E.installMethodArgcCheck){if(w instanceof $.StructType?!(ee instanceof Function)&&!a.isPtr(ee)&&r("Usage error: expecting a Function or WASM pointer to one."):r("Usage error: target object is-not-a StructType."),arguments.length===1)return(A,U)=>E(w,A,U,O);E.argcProxy||(E.argcProxy=function(A,U,X,F){return function(...fe){return X.length!==arguments.length&&r("Argument mismatch for",A.structInfo.name+"::"+U+": Native signature is:",F),X.apply(this,fe)}},E.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((A,U)=>{if(a.isPtr(A))try{a.uninstallFunction(A)}catch{}}),delete this.ondispose.__removeFuncList)});let z=w.memberSignature(W);z.length<2&&r("Member",W,"does not have a function pointer signature:",z);let le=w.memberKey(W),h=O&&!a.isPtr(ee)?E.argcProxy(w,le,ee,z):ee;if(a.isPtr(h))h&&!a.functionEntry(h)&&r("Pointer",h,"is not a WASM function table entry."),w[le]=h;else{let A=a.installFunction(h,z);w[le]=A,(!w.ondispose||!w.ondispose.__removeFuncList)&&(w.addOnDispose("ondispose.__removeFuncList handler",E.removeFuncList),w.ondispose.__removeFuncList=[]),w.ondispose.__removeFuncList.push(le,A)}return(A,U)=>E(w,A,U,O)};B.installMethodArgcCheck=!1;let J=function(E,w,W=B.installMethodArgcCheck){let ee=new Map;for(let O of Object.keys(w)){let z=w[O],le=ee.get(z);if(le){let h=E.memberKey(O);E[h]=E[E.memberKey(le)]}else B(E,O,z,W),ee.set(z,O)}return E};$.StructType.prototype.installMethod=function(w,W,ee=B.installMethodArgcCheck){return arguments.length<3&&w&&typeof w=="object"?J(this,...arguments):B(this,...arguments)},$.StructType.prototype.installMethods=function(E,w=B.installMethodArgcCheck){return J(this,E,w)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){let r=(...S)=>{throw new o.SQLite3Error(...S)},s=o.capi,a=o.wasm,m=o.util;o.__isUnderTest?console.debug.bind(console):o.config.debug,o.__isUnderTest?console.warn.bind(console):o.config.warn,o.__isUnderTest?console.error.bind(console):o.config.error;let d=new WeakMap,q=new Set,V=new WeakMap,N=(S,C,u)=>{let _=Object.getOwnPropertyDescriptor(S,C);return _?_.value:u},x=function(S,C){return C&&(S instanceof J&&(S=S.pointer),r(C,"sqlite3 result code",C+":",S?s.sqlite3_errmsg(S):s.sqlite3_errstr(C))),arguments[0]},R=a.installFunction("i(ippp)",function(S,C,u,_){s.SQLITE_TRACE_STMT===S&&console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+C+"["+s.sqlite3_db_filename(C,null)+"]",a.cstrToJs(_))}.bind({counter:0})),$=Object.create(null),B=function S(...C){let u=S.normalizeArgs(...C),_;if(_=u["sqlite3*"])u["sqlite3*:takeOwnership"]||q.add(this),this.filename=s.sqlite3_db_filename(_,"main");else{let y=u.filename,Q=u.vfs,K=u.flags;(typeof y!="string"&&!a.isPtr(y)||typeof K!="string"||Q&&typeof Q!="string"&&!a.isPtr(Q))&&(o.config.error("Invalid DB ctor args",u,arguments),r("Invalid arguments for DB constructor:",arguments,"opts:",u));let M=0;K.indexOf("c")>=0&&(M|=s.SQLITE_OPEN_CREATE|s.SQLITE_OPEN_READWRITE),K.indexOf("w")>=0&&(M|=s.SQLITE_OPEN_READWRITE),M===0&&(M|=s.SQLITE_OPEN_READONLY),M|=s.SQLITE_OPEN_EXRESCODE;let b=a.pstack.pointer;try{let D=a.pstack.allocPtr(),te=s.sqlite3_open_v2(y,D,M,Q||a.ptr.null);_=a.peekPtr(D),x(_,te),s.sqlite3_extended_result_codes(_,1),K.indexOf("t")>=0&&s.sqlite3_trace_v2(_,s.SQLITE_TRACE_STMT,R,_)}catch(D){throw _&&s.sqlite3_close_v2(_),D}finally{a.pstack.restore(b)}this.filename=a.isPtr(y)?a.cstrToJs(y):y}if(d.set(this,_),V.set(this,Object.create(null)),!u["sqlite3*"])try{let y=s.sqlite3_js_db_vfs(_)||r("Internal error: cannot get VFS for new db handle."),Q=$[y];Q&&(Q instanceof Function?Q(this,o):x(_,s.sqlite3_exec(_,Q,0,0,0)))}catch(y){throw this.close(),y}};B.setVfsPostOpenCallback=function(S,C){C instanceof Function||r("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments),$[S]=C},B.normalizeArgs=function(S=":memory:",C="c",u=null){let _={};return arguments.length===1&&arguments[0]&&typeof arguments[0]=="object"?(Object.assign(_,arguments[0]),_.flags===void 0&&(_.flags="c"),_.vfs===void 0&&(_.vfs=null),_.filename===void 0&&(_.filename=":memory:")):(_.filename=S,_.flags=C,_.vfs=u),_};let J=function(...S){B.apply(this,S)};J.dbCtorHelper=B;let E={null:1,number:2,string:3,boolean:4,blob:5};a.bigIntEnabled&&(E.bigint=E.number);let w=function(){E!==arguments[2]&&r(s.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare()."),this.db=arguments[0],d.set(this,arguments[1]),arguments.length>3&&!arguments[3]&&q.add(this)},W=function(S){return S.pointer||r("DB has been closed."),S},ee=function(S,C){return(C!==(C|0)||C<0||C>=S.columnCount)&&r("Column index",C,"is out of range."),S},O=function(S,C){let u=Object.create(null);switch(u.opt=Object.create(null),C.length){case 1:typeof C[0]=="string"||m.isSQLableTypedArray(C[0])||Array.isArray(C[0])?u.sql=C[0]:C[0]&&typeof C[0]=="object"&&(u.opt=C[0],u.sql=u.opt.sql);break;case 2:u.sql=C[0],u.opt=C[1];break;default:r("Invalid argument count for exec().")}u.sql=m.flexibleString(u.sql),typeof u.sql!="string"&&r("Missing SQL argument or unsupported SQL value type.");let _=u.opt;switch(_.returnValue){case"resultRows":_.resultRows||(_.resultRows=[]),u.returnVal=()=>_.resultRows;break;case"saveSql":_.saveSql||(_.saveSql=[]),u.returnVal=()=>_.saveSql;break;case void 0:case"this":u.returnVal=()=>S;break;default:r("Invalid returnValue value:",_.returnValue)}if(!_.callback&&!_.returnValue&&_.rowMode!==void 0&&(_.resultRows||(_.resultRows=[]),u.returnVal=()=>_.resultRows),_.callback||_.resultRows)switch(_.rowMode===void 0?"array":_.rowMode){case"object":u.cbArg=(y,Q)=>{Q.columnNames||(Q.columnNames=y.getColumnNames([]));let K=y.get([]),M=Object.create(null);for(let b in Q.columnNames)M[Q.columnNames[b]]=K[b];return M};break;case"array":u.cbArg=y=>y.get([]);break;case"stmt":Array.isArray(_.resultRows)&&r("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference."),u.cbArg=y=>y;break;default:if(m.isInt32(_.rowMode)){u.cbArg=y=>y.get(_.rowMode);break}else if(typeof _.rowMode=="string"&&_.rowMode.length>1&&_.rowMode[0]==="$"){let y=_.rowMode.substr(1);u.cbArg=Q=>{let K=Q.get(Object.create(null))[y];return K===void 0?r(s.SQLITE_NOTFOUND,"exec(): unknown result column:",y):K};break}r("Invalid rowMode:",_.rowMode)}return u},z=(S,C,u,..._)=>{let y=S.prepare(C);try{let Q=y.bind(u).step()?y.get(..._):void 0;return y.reset(),Q}finally{y.finalize()}},le=(S,C,u,_)=>S.exec({sql:C,bind:u,rowMode:_,returnValue:"resultRows"});J.checkRc=(S,C)=>x(S,C),J.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return W(this)},close:function(){let S=this.pointer;if(S){if(this.onclose&&this.onclose.before instanceof Function)try{this.onclose.before(this)}catch{}if(Object.keys(V.get(this)).forEach((C,u)=>{if(u&&u.pointer)try{u.finalize()}catch{}}),d.delete(this),V.delete(this),q.delete(this)||s.sqlite3_close_v2(S),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(S=!1,C=!1){let u=W(this).pointer;return S?C?s.sqlite3_total_changes64(u):s.sqlite3_total_changes(u):C?s.sqlite3_changes64(u):s.sqlite3_changes(u)},dbFilename:function(S="main"){return s.sqlite3_db_filename(W(this).pointer,S)},dbName:function(S=0){return s.sqlite3_db_name(W(this).pointer,S)},dbVfsName:function(S=0){let C,u=s.sqlite3_js_db_vfs(W(this).pointer,S);if(u){let _=new s.sqlite3_vfs(u);try{C=a.cstrToJs(_.$zName)}finally{_.dispose()}}return C},prepare:function(S){W(this);let C=a.pstack.pointer,u,_;try{u=a.pstack.alloc(8),J.checkRc(this,s.sqlite3_prepare_v2(this.pointer,S,-1,u,null)),_=a.peekPtr(u)}finally{a.pstack.restore(C)}_||r("Cannot prepare empty SQL.");let y=new w(this,_,E);return V.get(this)[_]=y,y},exec:function(){W(this);let S=O(this,arguments);if(!S.sql)return r("exec() requires an SQL string.");let C=S.opt,u=C.callback,_=Array.isArray(C.resultRows)?C.resultRows:void 0,y,Q=C.bind,K=!!(S.cbArg||C.columnNames||_),M=a.scopedAllocPush(),b=Array.isArray(C.saveSql)?C.saveSql:void 0;try{let D=m.isSQLableTypedArray(S.sql),te=D?S.sql.byteLength:a.jstrlen(S.sql),Z=a.scopedAlloc(2*a.ptr.size+(te+1)),we=a.ptr.add(Z,a.ptr.size),he=a.ptr.add(we,a.ptr.size),Ie=a.ptr.add(he,te);for(D?a.heap8().set(S.sql,he):a.jstrcpy(S.sql,a.heap8(),he,te,!1),a.poke8(a.ptr.add(he,te),0);he&&a.peek8(he);){a.pokePtr([Z,we],0),J.checkRc(this,s.sqlite3_prepare_v3(this.pointer,he,te,0,Z,we));let Be=a.peekPtr(Z);if(he=a.peekPtr(we),te=Number(a.ptr.add(Ie,-he)),!!Be){if(b&&b.push(s.sqlite3_sql(Be).trim()),y=new w(this,Be,E),Q&&y.parameterCount&&(y.bind(Q),Q=null),K&&y.columnCount){let Ze=Array.isArray(C.columnNames)?0:1;if(K=!1,S.cbArg||_){let at=Object.create(null);for(;y.step();F.delete(y)){Ze++===0&&y.getColumnNames(at.columnNames=C.columnNames||[]),F.add(y);let Ct=S.cbArg(y,at);if(_&&_.push(Ct),u&&u.call(C,Ct,y)===!1)break}F.delete(y)}Ze===0&&y.getColumnNames(C.columnNames)}else y.step();y.reset().finalize(),y=null}}}finally{y&&(F.delete(y),y.finalize()),a.scopedAllocPop(M)}return S.returnVal()},createFunction:function(C,u,_){let y=at=>at instanceof Function;switch(arguments.length){case 1:_=C,C=_.name,u=_.xFunc||0;break;case 2:y(u)||(_=u,u=_.xFunc||0)}_||(_={}),typeof C!="string"&&r("Invalid arguments: missing function name.");let Q=_.xStep||0,K=_.xFinal||0,M=_.xValue||0,b=_.xInverse||0,D;y(u)?(D=!1,(y(Q)||y(K))&&r("Ambiguous arguments: scalar or aggregate?"),Q=K=null):y(Q)?(y(K)||r("Missing xFinal() callback for aggregate or window UDF."),u=null):y(K)?r("Missing xStep() callback for aggregate or window UDF."):r("Missing function-type properties."),D===!1?(y(M)||y(b))&&r("xValue and xInverse are not permitted for non-window UDFs."):y(M)?(y(b)||r("xInverse must be provided if xValue is."),D=!0):y(b)&&r("xValue must be provided if xInverse is.");let te=_.pApp;te!=null&&!a.isPtr(te)&&r("Invalid value for pApp property. Must be a legal WASM pointer value.");let Z=_.xDestroy||0;Z&&!y(Z)&&r("xDestroy property must be a function.");let we=0;N(_,"deterministic")&&(we|=s.SQLITE_DETERMINISTIC),N(_,"directOnly")&&(we|=s.SQLITE_DIRECTONLY),N(_,"innocuous")&&(we|=s.SQLITE_INNOCUOUS),C=C.toLowerCase();let he=u||Q,Ie=N(_,"arity"),Be=typeof Ie=="number"?Ie:he.length?he.length-1:0,Ze;return D?Ze=s.sqlite3_create_window_function(this.pointer,C,Be,s.SQLITE_UTF8|we,te||0,Q,K,M,b,Z):Ze=s.sqlite3_create_function_v2(this.pointer,C,Be,s.SQLITE_UTF8|we,te||0,u,Q,K,Z),J.checkRc(this,Ze),this},selectValue:function(S,C,u){return z(this,S,C,0,u)},selectValues:function(S,C,u){let _=this.prepare(S),y=[];try{for(_.bind(C);_.step();)y.push(_.get(0,u));_.reset()}finally{_.finalize()}return y},selectArray:function(S,C){return z(this,S,C,[])},selectObject:function(S,C){return z(this,S,C,{})},selectArrays:function(S,C){return le(this,S,C,"array")},selectObjects:function(S,C){return le(this,S,C,"object")},openStatementCount:function(){return this.pointer?Object.keys(V.get(this)).length:0},transaction:function(S){let C="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&r(s.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),C+=" "+arguments[0],S=arguments[1]),W(this).exec(C);try{let u=S(this);return this.exec("COMMIT"),u}catch(u){throw this.exec("ROLLBACK"),u}},savepoint:function(S){W(this).exec("SAVEPOINT oo1");try{let C=S(this);return this.exec("RELEASE oo1"),C}catch(C){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),C}},checkRc:function(S){return x(this,S)}},J.wrapHandle=function(S,C=!1){if(!S||!a.isPtr(S))throw new o.SQLite3Error(s.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new J({"sqlite3*":S,"sqlite3*:takeOwnership":!!C})};let h=function(S){return S.pointer||r("Stmt has been closed."),S},A=function(S){let C=E[S==null?"null":typeof S];switch(C){case E.boolean:case E.null:case E.number:case E.string:return C;case E.bigint:return a.bigIntEnabled?C:void 0;default:return m.isBindableTypedArray(S)?E.blob:void 0}},U=function(S){return A(S)||r("Unsupported bind() argument type:",typeof S)},X=function(S,C){let u=typeof C=="number"?C:s.sqlite3_bind_parameter_index(S.pointer,C);return u===0||!m.isInt32(u)?r("Invalid bind() parameter name: "+C):(u<1||u>S.parameterCount)&&r("Bind index",C,"is out of range."),u},F=new Set,fe=new Set,de=function(S,C){return F.has(S)&&r("Operation is illegal when statement is locked:",C),S},me=function S(C,u,_,y){de(h(C),"bind()"),S._||(S._tooBigInt=K=>r("BigInt value is too big to store without precision loss:",K),S._={string:function(K,M,b,D){let[te,Z]=a.allocCString(b,!0);return(D?s.sqlite3_bind_blob:s.sqlite3_bind_text)(K.pointer,M,te,Z,s.SQLITE_WASM_DEALLOC)}}),U(y),u=X(C,u);let Q=0;switch(y==null?E.null:_){case E.null:Q=s.sqlite3_bind_null(C.pointer,u);break;case E.string:Q=S._.string(C,u,y,!1);break;case E.number:{let K;m.isInt32(y)?K=s.sqlite3_bind_int:typeof y=="bigint"?m.bigIntFits64(y)?a.bigIntEnabled?K=s.sqlite3_bind_int64:m.bigIntFitsDouble(y)?(y=Number(y),K=s.sqlite3_bind_double):S._tooBigInt(y):S._tooBigInt(y):(y=Number(y),a.bigIntEnabled&&Number.isInteger(y)?K=s.sqlite3_bind_int64:K=s.sqlite3_bind_double),Q=K(C.pointer,u,y);break}case E.boolean:Q=s.sqlite3_bind_int(C.pointer,u,y?1:0);break;case E.blob:{if(typeof y=="string"){Q=S._.string(C,u,y,!0);break}else y instanceof ArrayBuffer?y=new Uint8Array(y):m.isBindableTypedArray(y)||r("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");let K=a.alloc(y.byteLength||1);a.heap8().set(y.byteLength?y:[0],Number(K)),Q=s.sqlite3_bind_blob(C.pointer,u,K,y.byteLength,s.SQLITE_WASM_DEALLOC);break}default:o.config.warn("Unsupported bind() argument type:",y),r("Unsupported bind() argument type: "+typeof y)}return Q&&J.checkRc(C.db.pointer,Q),C};w.prototype={finalize:function(){let S=this.pointer;if(S){de(this,"finalize()");let C=q.delete(this)?0:s.sqlite3_finalize(S);return delete V.get(this.db)[S],d.delete(this),F.delete(this),fe.delete(this),delete this.parameterCount,delete this.db,C}},clearBindings:function(){return de(h(this),"clearBindings()"),s.sqlite3_clear_bindings(this.pointer),fe.delete(this),this},reset:function(S){de(this,"reset()"),S&&this.clearBindings();let C=s.sqlite3_reset(h(this).pointer);return fe.delete(this),x(this.db,C),this},bind:function(){h(this);let S,C;switch(arguments.length){case 1:S=1,C=arguments[0];break;case 2:S=arguments[0],C=arguments[1];break;default:r("Invalid bind() arguments.")}return C===void 0?this:(this.parameterCount||r("This statement has no bindable parameters."),fe.delete(this),C===null?me(this,S,E.null,C):Array.isArray(C)?(arguments.length!==1&&r("When binding an array, an index argument is not permitted."),C.forEach((u,_)=>me(this,_+1,U(u),u)),this):(C instanceof ArrayBuffer&&(C=new Uint8Array(C)),typeof C=="object"&&!m.isBindableTypedArray(C)?(arguments.length!==1&&r("When binding an object, an index argument is not permitted."),Object.keys(C).forEach(u=>me(this,u,U(C[u]),C[u])),this):me(this,S,U(C),C)))},bindAsBlob:function(S,C){h(this),arguments.length===1&&(C=S,S=1);let u=U(C);return E.string!==u&&E.blob!==u&&E.null!==u&&r("Invalid value type for bindAsBlob()"),me(this,S,E.blob,C)},step:function(){de(this,"step()");let S=s.sqlite3_step(h(this).pointer);switch(S){case s.SQLITE_DONE:return fe.delete(this),!1;case s.SQLITE_ROW:return fe.add(this),!0;default:fe.delete(this),o.config.warn("sqlite3_step() rc=",S,s.sqlite3_js_rc_str(S),"SQL =",s.sqlite3_sql(this.pointer)),J.checkRc(this.db.pointer,S)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{let S=this.step();return this.reset(),S}finally{try{this.finalize()}catch{}}},get:function(S,C){if(fe.has(h(this))||r("Stmt.step() has not (recently) returned true."),Array.isArray(S)){let u=0,_=this.columnCount;for(;u<_;)S[u]=this.get(u++);return S}else if(S&&typeof S=="object"){let u=0,_=this.columnCount;for(;u<_;)S[s.sqlite3_column_name(this.pointer,u)]=this.get(u++);return S}switch(ee(this,S),C===void 0?s.sqlite3_column_type(this.pointer,S):C){case s.SQLITE_NULL:return null;case s.SQLITE_INTEGER:if(a.bigIntEnabled){let u=s.sqlite3_column_int64(this.pointer,S);return u>=Number.MIN_SAFE_INTEGER&&u<=Number.MAX_SAFE_INTEGER?Number(u).valueOf():u}else{let u=s.sqlite3_column_double(this.pointer,S);return(u>Number.MAX_SAFE_INTEGER||u<Number.MIN_SAFE_INTEGER)&&r("Integer is out of range for JS integer range: "+u),m.isInt32(u)?u|0:u}case s.SQLITE_FLOAT:return s.sqlite3_column_double(this.pointer,S);case s.SQLITE_TEXT:return s.sqlite3_column_text(this.pointer,S);case s.SQLITE_BLOB:{let u=s.sqlite3_column_bytes(this.pointer,S),_=s.sqlite3_column_blob(this.pointer,S),y=new Uint8Array(u);return u&&(y.set(a.heap8u().slice(Number(_),Number(_)+u),0),this.db._blobXfer instanceof Array&&this.db._blobXfer.push(y.buffer)),y}default:r("Don't know how to translate","type of result column #"+S+".")}r("Not reached.")},getInt:function(S){return this.get(S,s.SQLITE_INTEGER)},getFloat:function(S){return this.get(S,s.SQLITE_FLOAT)},getString:function(S){return this.get(S,s.SQLITE_TEXT)},getBlob:function(S){return this.get(S,s.SQLITE_BLOB)},getJSON:function(S){let C=this.get(S,s.SQLITE_STRING);return C===null?C:JSON.parse(C)},getColumnName:function(S){return s.sqlite3_column_name(ee(h(this),S).pointer,S)},getColumnNames:function(S=[]){ee(h(this),0);let C=this.columnCount;for(let u=0;u<C;++u)S.push(s.sqlite3_column_name(this.pointer,u));return S},getParamIndex:function(S){return h(this).parameterCount?s.sqlite3_bind_parameter_index(this.pointer,S):void 0},getParamName:function(S){return h(this).parameterCount?s.sqlite3_bind_parameter_name(this.pointer,S):void 0},isBusy:function(){return s.sqlite3_stmt_busy(h(this))!==0},isReadOnly:function(){return s.sqlite3_stmt_readonly(h(this))!==0}};{let S={enumerable:!0,get:function(){return d.get(this)},set:()=>r("The pointer property is read-only.")};Object.defineProperty(w.prototype,"pointer",S),Object.defineProperty(J.prototype,"pointer",S)}Object.defineProperty(w.prototype,"columnCount",{enumerable:!1,get:function(){return s.sqlite3_column_count(this.pointer)},set:()=>r("The columnCount property is read-only.")}),Object.defineProperty(w.prototype,"parameterCount",{enumerable:!1,get:function(){return s.sqlite3_bind_parameter_count(this.pointer)},set:()=>r("The parameterCount property is read-only.")}),w.wrapHandle=function(S,C,u=!1){if(!(S instanceof J)||!S.pointer)throw new o.SQLite3Error(o.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!C||!a.isPtr(C))throw new o.SQLite3Error(o.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new w(S,C,E,!!u)},o.oo1={DB:J,Stmt:w}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){let r=o.util;o.initWorker1API=function(){"use strict";let s=(...$)=>{throw new Error($.join(" "))};globalThis.WorkerGlobalScope instanceof Function||s("initWorker1API() must be run from a Worker thread.");let a=this.sqlite3||s("Missing this.sqlite3 object."),m=a.oo1.DB,d=function($){let B=q.idMap.get($);return B||(B="db#"+ ++q.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),q.idMap.set($,B),B)},q={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function($){let B=new m($);return this.dbs[d(B)]=B,this.dbList.indexOf(B)<0&&this.dbList.push(B),B},close:function($,B){if($){delete this.dbs[d($)];let J=$.filename,E=r.sqlite3__wasm_db_vfs($.pointer,0);$.close();let w=this.dbList.indexOf($);w>=0&&this.dbList.splice(w,1),B&&J&&E&&r.sqlite3__wasm_vfs_unlink(E,J)}},post:function($,B){B&&B.length?(globalThis.postMessage($,Array.from(B)),B.length=0):globalThis.postMessage($)},dbs:Object.create(null),getDb:function($,B=!0){return this.dbs[$]||(B?s("Unknown (or closed) DB ID:",$):void 0)}},V=function($=q.dbList[0]){return $&&$.pointer?$:s("DB is not opened.")},N=function($,B=!0){let J=q.getDb($.dbId,!1)||q.dbList[0];return B?V(J):J},x=function(){return q.dbList[0]&&d(q.dbList[0])},R={open:function($){let B=Object.create(null),J=$.args||Object.create(null);J.simulateError&&s("Throwing because of simulateError flag.");let E=Object.create(null);B.vfs=J.vfs,B.filename=J.filename||"";let w=q.open(B);return E.filename=w.filename,E.persistent=!!a.capi.sqlite3_js_db_uses_vfs(w.pointer,"opfs"),E.dbId=d(w),E.vfs=w.dbVfsName(),E},close:function($){let B=N($,!1),J={filename:B&&B.filename};if(B){let E=$.args&&typeof $.args=="object"?!!$.args.unlink:!1;q.close(B,E)}return J},exec:function($){let B=typeof $.args=="string"?{sql:$.args}:$.args||Object.create(null);B.rowMode==="stmt"?s("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API."):B.sql||s("'exec' requires input SQL.");let J=N($);(B.callback||Array.isArray(B.resultRows))&&(J._blobXfer=q.xfer);let E=B.callback,w=0,W=!!B.columnNames;typeof E=="string"&&(W||(B.columnNames=[]),B.callback=function(ee,O){q.post({type:E,columnNames:B.columnNames,rowNumber:++w,row:ee},q.xfer)});try{let ee=B.countChanges?J.changes(!0,B.countChanges===64):void 0;J.exec(B),ee!==void 0&&(B.changeCount=J.changes(!0,B.countChanges===64)-ee);let O=B.lastInsertRowId?a.capi.sqlite3_last_insert_rowid(J):void 0;O!==void 0&&(B.lastInsertRowId=O),B.callback instanceof Function&&(B.callback=E,q.post({type:E,columnNames:B.columnNames,rowNumber:null,row:void 0}))}finally{delete J._blobXfer,B.callback&&(B.callback=E)}return B},"config-get":function(){let $=Object.create(null),B=a.config;return["bigIntEnabled"].forEach(function(J){Object.getOwnPropertyDescriptor(B,J)&&($[J]=B[J])}),$.version=a.version,$.vfsList=a.capi.sqlite3_js_vfs_list(),$},export:function($){let B=N($),J={byteArray:a.capi.sqlite3_js_db_export(B.pointer),filename:B.filename,mimetype:"application/x-sqlite3"};return q.xfer.push(J.byteArray.buffer),J},toss:function($){s("Testing worker exception")}};globalThis.onmessage=async function($){$=$.data;let B,J=$.dbId,E=$.type,w=performance.now();try{R.hasOwnProperty(E)&&R[E]instanceof Function?B=await R[E]($):s("Unknown db worker message type:",$.type)}catch(W){E="error",B={operation:$.type,message:W.message,errorClass:W.name,input:$},W.stack&&(B.stack=typeof W.stack=="string"?W.stack.split(/\n\s*/):W.stack)}J||(J=B.dbId||x()),q.post({type:E,dbId:J,messageId:$.messageId,workerReceivedTime:w,workerRespondTime:performance.now(),departureTime:$.departureTime,result:B},q.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:o})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){let r=o.wasm,s=o.capi,a=o.util.toss3,m=Object.create(null);o.vfs=m,s.sqlite3_vfs.prototype.registerVfs=function(d=!1){this instanceof o.capi.sqlite3_vfs||a("Expecting a sqlite3_vfs-type argument.");let q=s.sqlite3_vfs_register(this,d?1:0);return q&&a("sqlite3_vfs_register(",this,") failed with rc",q),this.pointer!==s.sqlite3_vfs_find(this.$zName)&&a("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this),this},m.installVfs=function(d){let q=0,V=["io","vfs"];for(let N of V){let x=d[N];x&&(++q,x.struct.installMethods(x.methods,!!x.applyArgcCheck),N==="vfs"&&(!x.struct.$zName&&typeof x.name=="string"&&x.struct.addOnDispose(x.struct.$zName=r.allocCString(x.name)),x.struct.registerVfs(!!x.asDefault)))}return q||a("Misuse: installVfs() options object requires at least","one of:",V),this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(!o.wasm.exports.sqlite3_declare_vtab)return;let r=o.wasm,s=o.capi,a=o.util.toss3,m=Object.create(null);o.vtab=m;let d=s.sqlite3_index_info;d.prototype.nthConstraint=function(N,x=!1){if(N<0||N>=this.$nConstraint)return!1;let R=r.ptr.add(this.$aConstraint,d.sqlite3_index_constraint.structInfo.sizeof*N);return x?R:new d.sqlite3_index_constraint(R)},d.prototype.nthConstraintUsage=function(N,x=!1){if(N<0||N>=this.$nConstraint)return!1;let R=r.ptr.add(this.$aConstraintUsage,d.sqlite3_index_constraint_usage.structInfo.sizeof*N);return x?R:new d.sqlite3_index_constraint_usage(R)},d.prototype.nthOrderBy=function(N,x=!1){if(N<0||N>=this.$nOrderBy)return!1;let R=r.ptr.add(this.$aOrderBy,d.sqlite3_index_orderby.structInfo.sizeof*N);return x?R:new d.sqlite3_index_orderby(R)};let q=function(N,x){return function(R,$=!1){if(arguments.length===0&&(R=new x),R instanceof x)return this.set(R.pointer,R),R;r.isPtr(R)||o.SQLite3Error.toss("Invalid argument to",N+"()");let B=this.get(R);return $&&this.delete(R),B}.bind(new Map)},V=function(N,x){let R=q(N,x);return Object.assign(Object.create(null),{StructType:x,create:$=>{let B=R();return r.pokePtr($,B.pointer),B},get:$=>R($),unget:$=>R($,!0),dispose:$=>R($,!0)?.dispose?.()})};m.xVtab=V("xVtab",s.sqlite3_vtab),m.xCursor=V("xCursor",s.sqlite3_vtab_cursor),m.xIndexInfo=N=>new s.sqlite3_index_info(N),m.xError=function N(x,R,$){if(N.errorReporter instanceof Function)try{N.errorReporter("sqlite3_module::"+x+"(): "+R.message)}catch{}let B;return R instanceof o.WasmAllocError?B=s.SQLITE_NOMEM:arguments.length>2?B=$:R instanceof o.SQLite3Error&&(B=R.resultCode),B||s.SQLITE_ERROR},m.xError.errorReporter=o.config.error.bind(o.config),m.xRowid=(N,x)=>r.poke(N,x,"i64"),m.setupModule=function(N){let x=!1,R=this instanceof s.sqlite3_module?this:N.struct||(x=new s.sqlite3_module);try{let $=N.methods||a("Missing 'methods' object.");for(let B of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){let J=B[0],E=B[1];$[J]===!0?$[J]=$[E]:$[E]===!0&&($[E]=$[J])}if(N.catchExceptions){let B=function(w,W){return["xConnect","xCreate"].indexOf(w)>=0?function(ee,O,z,le,h,A){try{return W(...arguments)||0}catch(U){return U instanceof o.WasmAllocError||(r.dealloc(r.peekPtr(A)),r.pokePtr(A,r.allocCString(U.message))),m.xError(w,U)}}:function(...ee){try{return W(...ee)||0}catch(O){return m.xError(w,O)}}},J=["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 w of J){let W=$[w];if(W instanceof Function)w==="xConnect"&&$.xCreate===W?E[w]=$.xCreate:w==="xCreate"&&$.xConnect===W?E[w]=$.xConnect:E[w]=B(w,W);else continue}R.installMethods(E,!1)}else R.installMethods($,!!N.applyArgcCheck);if(R.$iVersion===0){let B;typeof N.iVersion=="number"?B=N.iVersion:R.$xIntegrity?B=4:R.$xShadowName?B=3:R.$xSavePoint||R.$xRelease||R.$xRollbackTo?B=2:B=1,R.$iVersion=B}}catch($){throw x&&x.dispose(),$}return R},s.sqlite3_module.prototype.setupModule=function(N){return m.setupModule.call(this,N)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(o.config.disable?.vfs?.kvvfs)return;let r=o.capi,s=r.sqlite3_kvvfs_methods,a=r.KVVfsFile,m=o.capi.sqlite3_vfs_find("kvvfs");if(delete r.sqlite3_kvvfs_methods,delete r.KVVfsFile,!m)return;let d=o.util,q=o.wasm,V=d.toss3,N=new s(q.exports.sqlite3__wasm_kvvfs_methods());d.assert(32<=N.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+N.$nKeySize);let x=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:q.allocCString("jrnl"),zKeySz:q.allocCString("sz"),keySize:N.$nKeySize,buffer:Object.assign(Object.create(null),{n:N.$nBufferSize,pool:Object.create(null)})});x.memBuffer=(L=0)=>x.buffer.pool[L]??=q.alloc(x.buffer.n),x.memBufferFree=L=>{let G=x.buffer.pool[L];G&&(q.dealloc(G),delete x.buffer.pool[L])};let R=()=>{},$=o.__isUnderTest?(...L)=>o.config.debug?.("kvvfs:",...L):R,B=(...L)=>o.config.warn?.("kvvfs:",...L),J=(...L)=>o.config.error?.("kvvfs:",...L);class E{#e=Object.create(null);#t=null;#s=0;constructor(){this.clear()}#n(){return this.#t??=Object.keys(this.#e)}key(G){return G<0||G>=this.#s?null:this.#n()[G]}getItem(G){return this.#e[G]??null}setItem(G,oe){G in this.#e||(++this.#s,this.#t=null),this.#e[G]=""+oe}removeItem(G){G in this.#e&&(delete this.#e[G],--this.#s,this.#t=null)}clear(){this.#e=Object.create(null),this.#t=null,this.#s=0}get length(){return this.#s}}let w=L=>L==="local"||L==="session",W=L=>w(L)?"kvvfs-"+L+"-":"",ee=function(L,G=!1){if(w(L))return;let oe=new Blob([L]).size;oe||V(r.SQLITE_MISUSE,"Empty name is not permitted.");let ae=x.keySize-1;x.rxJournalSuffix.test(L)?G||V(r.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix."):["-wal","-shm"].filter(ve=>L.endsWith(ve)).length?V(r.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix."):ae-=8,oe>ae&&V(r.SQLITE_RANGE,"Storage name is too long. Limit =",ae);let Se=0;for(;Se<oe;++Se){let ve=L.codePointAt(Se);ve<32&&V(r.SQLITE_RANGE,"Illegal character ("+ve+"d) in storage name:",L)}},O=(L,G=void 0)=>Object.assign(Object.create(null),{jzClass:L,refc:1,deleteAtRefc0:!1,storage:G||new E,keyPrefix:W(L),files:[],listeners:void 0}),z=o.kvvfs=Object.create(null);o.__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 le=function(L){let G=x.rxJournalSuffix.test(L.jzClass)?L.jzClass.replace(x.rxJournalSuffix,""):L.jzClass+"-journal";z?.log?.xClose&&$("cleaning up storage handles [",L.jzClass,G,"]",L),delete x.storagePool[L.jzClass],delete x.storagePool[G],o.__isUnderTest||(delete L.storage,delete L.refc)},h=L=>x.storagePool[L.jzClass]=x.storagePool[L.jzClass+"-journal"]=L,A=".";x.storagePool=Object.assign(Object.create(null),{[A]:O(A)}),globalThis.Storage&&(globalThis.localStorage instanceof globalThis.Storage&&(x.storagePool.local=O("local",globalThis.localStorage)),globalThis.sessionStorage instanceof globalThis.Storage&&(x.storagePool.session=O("session",globalThis.sessionStorage))),x.builtinStorageNames=Object.keys(x.storagePool);let U=L=>x.builtinStorageNames.indexOf(L)>-1;for(let L of Object.keys(x.storagePool)){let G=x.storagePool[L];x.storagePool[L+"-journal"]=G}x.setError=(L=void 0,G=r.SQLITE_ERROR)=>L?(x.lastError=L,L.resultCode|0||G):(delete x.lastError,0),x.popError=()=>{let L=x.lastError;return delete x.lastError,L};let X=L=>{B("kvvfs.listener handler threw:",L)},F=q.exports.sqlite3__wasm_kvvfs_decode,fe=q.exports.sqlite3__wasm_kvvfs_encode,de=async function(L,G,...oe){try{G.keyPrefix&&oe[0]&&(oe[0]=oe[0].replace(G.keyPrefix,""));let ae,Se,ve,Ee;for(let qe of G.listeners){let Me=Object.create(null);Me.storageName=G.jzClass,Me.type=L,qe.decodePages;let He=qe.events[L];if(He){if(!qe.includeJournal&&oe[0]==="jrnl")continue;if(L==="write"&&qe.decodePages&&+oe[0]>0){if(Me.data=[oe[0]],Ee?.[oe[0]]){Me.data[1]=Ee[oe[0]];continue}ae??=new TextEncoder("utf-8"),Se??=x.memBuffer(10),ve??=x.memBuffer(11);let $e=ae.encode(oe[1]),Ue=q.heap8u();Ue.set($e,Number(Se)),Ue[q.ptr.addn(Se,$e.length)]=0;let Ke=F(Se,ve,x.buffer.n);if(Ke>0)Ee??=Object.create(null),Ee[oe[0]]=Me.data[1]=Ue.slice(Number(ve),q.ptr.addn(ve,Ke));else continue}else Me.data=oe.length?oe.length===1?oe[0]:oe:void 0;try{He(Me)?.catch?.(X)}catch($e){B("notifyListeners [",G.jzClass,"]",L,$e)}}}}catch(ae){X(ae)}},me=L=>typeof L=="string"?x.storagePool[L]:x.storagePool[q.cstrToJs(L)],S=q.exports.sqlite3__wasm_kvvfsMakeKey,C=(L,G,oe)=>G&&L.keyPrefix?S(G,oe):oe,u=(L,G,oe)=>q.cstrToJs(C(L,G,oe)),_=L=>+L.storage.getItem(L.keyPrefix+"sz"),y=new Map,Q={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},K=new r.sqlite3_vfs(N.$pVfs),M=new r.sqlite3_io_methods(N.$pIoDb),b=new r.sqlite3_io_methods(N.$pIoJrnl),D=Object.create(null),te=Object.assign(Object.create(null),{pFileHandles:y,cache:x,storageForZClass:me,KVVfsStorage:E,disablePageSizeChange:!0});z.log&&(z.internal=te);let Z={recordHandler:{xRcrdRead:(L,G,oe,ae)=>{try{let Se=q.cstrToJs(L),ve=me(Se);if(!ve)return-1;let Ee=u(ve,L,G);z?.log?.xRcrdRead&&B("xRcrdRead",Se,Ee,ae,ve);let qe=ve.storage.getItem(Ee);if(qe===null)return-1;let Me=qe.length;if(ae<=0)return Me;if(ae===1)return q.poke(oe,0),Me;ae+1<Me&&V(r.SQLITE_RANGE,"xRcrdRead()",Se,Ee,"input buffer is too small: need",Me,"but have",ae);let He=x.memBuffer(0),$e=q.heap8(),Ue=0;for(;Ue<Me;++Ue)$e[q.ptr.add(He,Ue)]=qe.codePointAt(Ue)&255;return $e.copyWithin(Number(oe),Number(He),q.ptr.addn(He,Ue)),$e[q.ptr.add(oe,Me)]=0,ae}catch(Se){return J("kvrecordRead()",Se),x.setError(Se),-2}},xRcrdWrite:(L,G,oe)=>{try{let ae=me(L),Se=u(ae,L,G),ve=q.cstrToJs(oe);return z?.log?.xRcrdWrite&&B("xRcrdWrite",Se,ae),ae.storage.setItem(Se,ve),ae.listeners&&de("write",ae,Se,ve),0}catch(ae){return J("kvrecordWrite()",ae),x.setError(ae,r.SQLITE_IOERR)}},xRcrdDelete:(L,G)=>{try{let oe=me(L),ae=u(oe,L,G);return z?.log?.xRcrdDelete&&B("xRcrdDelete",ae,oe),oe.storage.removeItem(ae),oe.listeners&&de("delete",oe,ae),0}catch(oe){return J("kvrecordDelete()",oe),x.setError(oe,r.SQLITE_IOERR)}}},vfs:{xOpen:function(L,G,oe,ae,Se){x.popError();let ve;try{G||(ve=q.allocCString(""+oe+"."+(Math.random()*1e5|0)),G=ve);let Ee=q.cstrToJs(G);z?.log?.xOpen&&$("xOpen",Ee,"flags =",ae),ee(Ee,!0),ae&(r.SQLITE_OPEN_MAIN_DB|r.SQLITE_OPEN_TEMP_DB|r.SQLITE_OPEN_TRANSIENT_DB)&&x.rxJournalSuffix.test(Ee)&&V(r.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let qe=me(Ee);!qe&&!(ae&r.SQLITE_OPEN_CREATE)&&V(r.SQLITE_ERROR,"Storage not found:",Ee);let Me=Q.vfs.xOpen(L,G,oe,ae,Se);if(Me)return Me;let He=!!(r.SQLITE_OPEN_DELETEONCLOSE&ae);q.isPtr(arguments[1])&&r.sqlite3_uri_boolean(G,"delete-on-close",0)&&(He=!0);let $e=new a(oe);if(d.assert($e.$zClass,"Missing f.$zClass"),$e.addOnDispose(ve),ve=void 0,qe)++qe.refc,qe.files.push($e),q.poke32(Se,ae);else{q.poke32(Se,ae|r.SQLITE_OPEN_CREATE),d.assert(!$e.$isJournal,"Opening a journal before its db? "+Ee);let Ue=Ee.replace(x.rxJournalSuffix,"");qe=O(Ue),h(qe),qe.files.push($e),qe.deleteAtRefc0=He,z?.log?.xOpen&&$("xOpen installed storage handle [",Ue,Ue+"-journal","]",qe)}return y.set(oe,{store:qe,file:$e,jzClass:Ee}),qe.listeners&&de("open",qe,qe.files.length),0}catch(Ee){return B("xOpen:",Ee),x.setError(Ee)}finally{ve&&q.dealloc(ve)}},xDelete:function(L,G,oe){x.popError();try{let ae=q.cstrToJs(G);return x.rxJournalSuffix.test(ae)&&D.xRcrdDelete(G,x.zKeyJrnl),0}catch(ae){return B("xDelete",ae),x.setError(ae)}},xAccess:function(L,G,oe,ae){x.popError();try{let Se=me(G),ve=Se?.jzClass||q.cstrToJs(G);if(z?.log?.xAccess&&$("xAccess",ve,"flags =",oe,"*pResOut =",q.peek32(ae),"store =",Se),!Se)try{ee(ve)}catch{return q.poke32(ae,0),0}if(Se){let Ee=Se.keyPrefix+(x.rxJournalSuffix.test(ve)?"jrnl":"1"),qe=Se.storage.getItem(Ee)?0:1;q.poke32(ae,qe)}else q.poke32(ae,0);return 0}catch(Se){return J("xAccess",Se),x.setError(Se)}},xRandomness:function(L,G,oe){let ae=q.heap8u(),Se=0,ve=Number(oe);for(;Se<G;++Se)ae[ve+Se]=Math.random()*255e3&255;return G},xGetLastError:function(L,G,oe){let ae=x.popError();if($("xGetLastError",ae),ae){let Se=q.scopedAllocPush();try{let[ve,Ee]=q.scopedAllocCString(ae.message,!0);return q.cstrncpy(oe,ve,G),Ee>G&&q.poke8(q.ptr.add(oe,G,-1),0),$("set xGetLastError",ae.message),ae.resultCode|0||r.SQLITE_IOERR}catch{return r.SQLITE_NOMEM}finally{q.scopedAllocPop(Se)}}return 0}},ioDb:{xClose:function(L){x.popError();try{let G=y.get(L);if(z?.log?.xClose&&$("xClose",L,G),G){y.delete(L);let oe=G.store;oe.files=oe.files.filter(ae=>ae!==G.file),--oe.refc<=0&&oe.deleteAtRefc0&&le(oe),Q.ioDb.xClose(L),G.file.dispose(),oe.listeners&&de("close",oe,oe.files.length)}return 0}catch(G){return J("xClose",G),x.setError(G)}},xFileControl:function(L,G,oe){x.popError();try{let ae=y.get(L);if(d.assert(ae,"Missing KVVfsFile handle"),z?.log?.xFileControl&&$("xFileControl",ae,"op =",G),G===r.SQLITE_FCNTL_PRAGMA&&te.disablePageSizeChange){let ve=q.peekPtr(q.ptr.add(oe,q.ptr.size));if(q.cstrToJs(ve)==="page_size"){z?.log?.xFileControl&&$("xFileControl pragma",q.cstrToJs(ve));let Ee=q.peekPtr(q.ptr.add(oe,2*q.ptr.size));if(Ee)return z?.log?.xFileControl&&B("xFileControl pragma",ae,"NOT setting page size to",q.cstrToJs(Ee)),ae.file.$szPage=-1,0;if(ae.file.$szPage>0)return z?.log?.xFileControl&&B("xFileControl",ae,"getting page size",ae.file.$szPage),q.pokePtr(oe,q.allocCString(""+ae.file.$szPage)),0}}let Se=Q.ioDb.xFileControl(L,G,oe);return Se==0&&r.SQLITE_FCNTL_SYNC===G&&ae.store.listeners&&de("sync",ae.store,!1),Se}catch(ae){return J("xFileControl",ae),x.setError(ae)}},xSync:function(L,G){x.popError();try{let oe=y.get(L);z?.log?.xSync&&$("xSync",oe),d.assert(oe,"Missing KVVfsFile handle");let ae=Q.ioDb.xSync(L,G);return ae==0&&oe.store.listeners&&de("sync",oe.store,!0),ae}catch(oe){return J("xSync",oe),x.setError(oe)}}},ioJrnl:{xClose:!0}};try{d.assert(x.buffer.n>132096,"Heap buffer is not large enough");for(let L of Object.entries(Z.recordHandler)){let G=L[0],oe=L[1];D[G]=oe,N[N.memberKey(G)]=q.installFunction(N.memberSignature(G),oe)}for(let L of Object.entries(Z.vfs)){let G=L[0],oe=L[1],ae=K.memberKey(G),Se=K.structInfo.members[G]||d.toss("Missing pVfs.structInfo[",G,"]");Q.vfs[G]=q.functionEntry(K[ae]),K[ae]=q.installFunction(Se.signature,oe)}for(let L of Object.entries(Z.ioDb)){let G=L[0],oe=L[1],ae=M.memberKey(G);Q.ioDb[G]=q.functionEntry(M[ae])||d.toss("Missing native pIoDb[",ae,"]"),M[ae]=q.installFunction(M.memberSignature(G),oe)}for(let L of Object.entries(Z.ioJrnl)){let G=L[0],oe=L[1],ae=b.memberKey(G);Q.ioJrnl[G]=q.functionEntry(b[ae])||d.toss("Missing native pIoJrnl[",ae,"]"),oe===!0?b[ae]=M[ae]||d.toss("Missing copied pIoDb[",ae,"]"):b[ae]=q.installFunction(b.memberSignature(G),oe)}}finally{N.dispose(),K.dispose(),M.dispose(),b.dispose()}let we=function L(G){if(G==="")return L("local")+L("session");let oe=me(G);if(!oe)return 0;oe.files.length&&(globalThis.localStorage===oe.storage||globalThis.sessionStorage===oe.storage||V(r.SQLITE_ACCESS,"Cannot clear in-use database storage."));let ae=oe.storage,Se=[],ve,Ee=ae.length;for(ve=0;ve<Ee;++ve){let qe=ae.key(ve);(!oe.keyPrefix||qe.startsWith(oe.keyPrefix))&&Se.push(qe)}return Se.forEach(qe=>ae.removeItem(qe)),Se.length},he=function L(G){if(G==="")return L("local")+L("session");let oe=me(G);if(!oe)return 0;let ae=oe.storage,Se,ve=0;for(Se=0;Se<ae.length;++Se){let Ee=ae.key(Se);(!oe.keyPrefix||Ee.startsWith(oe.keyPrefix))&&(ve+=Ee.length,ve+=ae.getItem(Ee).length)}return ve*2},Ie=function(...G){let oe;G.length===1&&typeof G[0]=="object"?oe=G[0]:G.length&&(oe=Object.assign(Object.create(null),{name:G[0]}));let ae=oe?me(oe.name):null;ae||V(r.SQLITE_NOTFOUND,"There is no kvvfs storage named",oe?.name);let Se=ae.storage,ve=Object.assign(Object.create(null),{name:ae.jzClass,timestamp:Date.now(),pages:[]}),Ee=Object.create(null),qe=ae.keyPrefix,Me=qe?/^kvvfs-[^-]+-(\w+)/:void 0,He=0,$e=Se.length;for(;He<$e;++He){let Ue=Se.key(He);if(!qe||Ue.startsWith(qe)){let Ke=(qe?Me.exec(Ue):void 0)?.[1]??Ue;switch(Ke){case"jrnl":oe.includeJournal&&(ve.journal=Se.getItem(Ue));break;case"sz":ve.size=+Se.getItem(Ue);break;default:if(Ke=+Ke,(!d.isInt32(Ke)||Ke<=0)&&V(r.SQLITE_RANGE,"Malformed kvvfs key: "+Ue),oe.decodePages){let gt=Se.getItem(Ue),Tt=gt.length,zt=x.memBuffer(0),Dt=x.memBuffer(1),tn=q.heap8u(),lt=0;for(;lt<Tt;++lt)tn[q.ptr.add(zt,lt)]=gt.codePointAt(lt)&255;tn[q.ptr.add(zt,lt)]=0;let pn=F(zt,Dt,x.buffer.n);Ee[Ke]=tn.slice(Number(Dt),q.ptr.addn(Dt,pn))}else Ee[Ke]=Se.getItem(Ue)}}}return oe.decodePages&&x.memBufferFree(1),Object.keys(Ee).map(Ue=>+Ue).sort().forEach(Ue=>ve.pages.push(Ee[Ue])),ve},Be=function(L,G=!1){!L?.timestamp||!L.name||L.size===void 0||!Array.isArray(L.pages)?V(r.SQLITE_MISUSE,"Malformed export object."):(!L.size||L.size!==(L.size|0)||L.size>=2147483647)&&V(r.SQLITE_RANGE,"Invalid db size: "+L.size),ee(L.name);let oe=me(L.name),ae=!oe;oe?(G?!oe.files||!oe.jzClass?V(r.SQLITE_ERROR,"Internal storage object",L.name,"seems to be malformed."):oe.files.length&&V(r.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use."):V(r.SQLITE_ACCESS,"Storage '"+L.name+"' already exists and","overwrite was not specified."),we(L.name)):oe=O(L.name);let Se=W(L.name),ve;try{let Ee=oe.storage;Ee.setItem(Se+"sz",L.size),L.journal&&Ee.setItem(Se+"jrnl",L.journal),L.pages[0]instanceof Uint8Array?L.pages.forEach((qe,Me)=>{let He=qe.length;ve??=x.memBuffer(1);let $e=x.memBuffer(0),Ue=q.heap8u();Ue.set(qe,Number($e)),Ue[q.ptr.addn($e,He)]=0;let Ke=fe($e,He,ve);d.assert(Ke<x.buffer.n,"Impossibly long output - possibly smashed the heap"),d.assert(q.peek8(q.ptr.add(ve,Ke))===0,"Expecting NUL-terminated encoded output");let gt=q.cstrToJs(ve);Ee.setItem(Se+(Me+1),gt)}):L.pages[0]&&L.pages.forEach((qe,Me)=>Ee.setItem(Se+(Me+1),qe)),ae&&h(oe)}catch{if(!ae)try{we(L.name)}catch{}}finally{ve&&x.memBufferFree(1)}return this},Ze=function(L){let G=me(L);if(G){++G.refc;return}ee(L),h(O(L))},at=function(L){let G=me(L);return!G||w(G.jzClass)||U(G.jzClass)||x.rxJournalSuffix.test(L)?!1:G.refc>G.files.length||G.files.length===0?(--G.refc<=0&&le(G),!0):!1},Ct=function(L){(!L||typeof L!="object")&&V(r.SQLITE_MISUSE,"Expecting a listener object.");let G=me(L.storage);G||(L.storage&&L.reserve?(Ze(L.storage),G=me(L.storage),d.assert(G,"Unexpectedly cannot fetch reserved storage "+L.storage)):V(r.SQLITE_NOTFOUND,"No such storage:",L.storage)),L.events&&(G.listeners??=[]).push(L)},mn=function(L){let G=me(L?.storage);if(G?.listeners&&L.events){let oe=G.listeners.length;G.listeners=G.listeners.filter(Se=>Se!==L);let ae=oe>G.listeners.length;return G.listeners.length||(G.listeners=void 0),ae}return!1};if(o.kvvfs.reserve=Ze,o.kvvfs.import=Be,o.kvvfs.export=Ie,o.kvvfs.unlink=at,o.kvvfs.listen=Ct,o.kvvfs.unlisten=mn,o.kvvfs.exists=L=>!!me(L),o.kvvfs.estimateSize=he,o.kvvfs.clear=we,globalThis.Storage&&(r.sqlite3_js_kvvfs_size=(L="")=>he(L),r.sqlite3_js_kvvfs_clear=(L="")=>we(L)),o.oo1?.DB){let L=o.oo1.DB;o.oo1.JsStorageDb=function(oe=o.oo1.JsStorageDb.defaultStorageName){let ae=L.dbCtorHelper.normalizeArgs(...arguments);switch(ae.vfs="kvvfs",ae.filename){case":sessionStorage:":ae.filename="session";break;case":localStorage:":ae.filename="local"}let Se=/(file:(\/\/)?)([^?]+)/.exec(ae.filename);ee(Se?Se[3]:ae.filename),L.dbCtorHelper.call(this,ae)},o.oo1.JsStorageDb.defaultStorageName=x.storagePool.session?"session":A;let G=o.oo1.JsStorageDb;G.prototype=Object.create(L.prototype),G.clearStorage=we,G.prototype.clearStorage=function(){return G.clearStorage(this.affirmOpen().dbFilename(),!0)},G.storageSize=he,G.prototype.storageSize=function(){return G.storageSize(this.affirmOpen().dbFilename(),!0)}}if(o.__isUnderTest&&o.vtab){let L=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(L).forEach((ve,Ee)=>L[ve].colId=Ee);let G=o.vtab,oe=Object.assign(Object.create(null),{row:function(){return x.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(oe),{rowid:0,names:Object.keys(x.storagePool).filter(ve=>!x.rxJournalSuffix.test(ve))});let ae=function(ve,Ee){let qe=ve instanceof r.sqlite3_vtab_cursor?ve:G.xCursor.get(ve);return(Ee||!qe.vTabState)&&(qe.vTabState=Object.assign(Object.create(oe),{rowid:0,names:Object.keys(x.storagePool).filter(Me=>!x.rxJournalSuffix.test(Me))})),qe.vTabState},Se=function ve(){return ve.mod??=new o.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(Ee,qe,Me,He,$e,Ue){try{let Ke=[];Object.keys(L).forEach(Tt=>{Ke.push(Tt+" "+L[Tt].type)});let gt=r.sqlite3_declare_vtab(Ee,"CREATE TABLE ignored("+Ke.join(",")+")");if(gt===0){let Tt=G.xVtab.create($e);d.assert(Tt===G.xVtab.get(q.peekPtr($e)),"output pointer check failed")}return gt}catch(Ke){return G.xError("xConnect",Ke,r.SQLITE_ERROR)}},xCreate:q.ptr.null,xDisconnect:function(Ee){return G.xVtab.dispose(Ee),0},xOpen:function(Ee,qe){return G.xCursor.create(qe),0},xClose:function(Ee){let qe=G.xCursor.unget(Ee);return delete qe.vTabState,qe.dispose(),0},xNext:function(Ee){let qe=G.xCursor.get(Ee);return++ae(qe).rowid,0},xColumn:function(Ee,qe,Me){let He=ae(Ee),$e=He.row();switch(d.assert($e,"Unexpected xColumn call"),Me){case L.rowid.colId:r.sqlite3_result_int(qe,He.rowid);break;case L.name.colId:r.sqlite3_result_text(qe,$e.jzClass,-1,r.SQLITE_TRANSIENT);break;case L.nRef.colId:r.sqlite3_result_int(qe,$e.refc);break;case L.nOpen.colId:r.sqlite3_result_int(qe,$e.files.length);break;case L.isTransient.colId:r.sqlite3_result_int(qe,!!$e.deleteAtRefc0);break;case L.dbSize.colId:r.sqlite3_result_int(qe,_($e));break;default:return r.sqlite3_result_error(qe,"Invalid column id: "+Me),r.SQLITE_RANGE}return 0},xRowid:function(Ee,qe){let Me=ae(Ee);return G.xRowid(qe,Me.rowid),0},xEof:function(Ee){let qe=ae(Ee);return""+!qe.row(),!qe.row()},xFilter:function(Ee,qe,Me,He,$e){return ae(Ee,!0),0},xBestIndex:function(Ee,qe){let Me=new r.sqlite3_index_info(qe);return Me.$estimatedRows=x.storagePool.size,Me.$estimatedCost=1,Me.dispose(),0}}})};o.kvvfs.create_module=function(ve,Ee="sqlite_kvvfs"){return r.sqlite3_create_module(ve,Ee,Se(),q.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){"use strict";if(o.config.disable?.vfs?.opfs&&o.config.disable.vfs["opfs-vfs"])return;let r=o.util.toss;o.capi;let s=o.util;o.wasm;let a=o.opfs=Object.create(null);a.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,a.getRootDir=async function d(){return d.promise??=navigator.storage.getDirectory().then(q=>(a.rootDirectory=q,q)).catch(q=>{throw delete d.promise,q})},a.getResolvedPath=function(d,q){let V=new URL(d,"file://irrelevant").pathname;return q?V.split("/").filter(N=>!!N):V},a.getDirForFilename=async function(q,V=!1){let N=a.getResolvedPath(q,!0),x=N.pop(),R=await a.getRootDir();for(let $ of N)$&&(R=await R.getDirectoryHandle($,{create:!!V}));return[R,x]},a.mkdir=async function(d){try{return await a.getDirForFilename(d+"/filepart",!0),!0}catch{return!1}},a.entryExists=async function(d){try{let[q,V]=await a.getDirForFilename(d);return await q.getFileHandle(V),!0}catch{return!1}},a.randomFilename=function d(q=16){d._chars||(d._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",d._n=d._chars.length);let V=[],N=0;for(;N<q;++N){let x=Math.random()*(d._n*64)%d._n|0;V[N]=d._chars[x]}return V.join("")},a.treeList=async function(){let d=async function V(N,x){x.name=N.name,x.dirs=[],x.files=[];for await(let R of N.values())if(R.kind==="directory"){let $=Object.create(null);x.dirs.push($),await V(R,$)}else x.files.push(R.name)},q=Object.create(null);return await d(await a.getRootDir(),q),q},a.rmfr=async function(){let d=await a.getRootDir(),q={recurse:!0};for await(let V of d.values())d.removeEntry(V.name,q)},a.unlink=async function(d,q=!1,V=!1){try{let[N,x]=await a.getDirForFilename(d,!1);return await N.removeEntry(x,{recursive:q}),!0}catch(N){if(V)throw new Error("unlink(",arguments[0],") failed: "+N.message,{cause:N});return!1}},a.traverse=async function(d){let q={recursive:!0,directory:await a.getRootDir()};typeof d=="function"&&(d={callback:d}),d=Object.assign(q,d||{}),(async function V(N,x){for await(let R of N.values()){if(d.callback(R,N,x)===!1)return!1;if(d.recursive&&R.kind==="directory"&&await V(R,x+1)===!1)break}})(d.directory,0)};let m=async function(d,q){let[V,N]=await a.getDirForFilename(d,!0),x=await(await V.getFileHandle(N,{create:!0})).createSyncAccessHandle(),R=0,$,B=!1;try{for(x.truncate(0);($=await q())!==void 0;)$ instanceof ArrayBuffer&&($=new Uint8Array($)),!B&&R===0&&$.byteLength>=15&&(s.affirmDbHeader($),B=!0),x.write($,{at:R}),R+=$.byteLength;if((R<512||R%512!==0)&&r("Input size",R,"is not correct for an SQLite database."),!B){let J=new Uint8Array(20);x.read(J,{at:0}),s.affirmDbHeader(J)}return x.write(new Uint8Array([1,1]),{at:18}),R}catch(J){throw await x.close(),x=void 0,await V.removeEntry(N).catch(()=>{}),J}finally{x&&await x.close()}};a.importDb=async function(d,q){if(q instanceof Function)return m(d,q);q instanceof ArrayBuffer&&(q=new Uint8Array(q)),s.affirmIsDb(q);let V=q.byteLength,[N,x]=await a.getDirForFilename(d,!0),R,$=0;try{return R=await(await N.getFileHandle(x,{create:!0})).createSyncAccessHandle(),R.truncate(0),$=R.write(q,{at:0}),$!=V&&r("Expected to write "+V+" bytes but wrote "+$+"."),R.write(new Uint8Array([1,1]),{at:18}),$}catch(B){throw R&&(await R.close(),R=void 0),await N.removeEntry(x).catch(()=>{}),B}finally{R&&await R.close()}},a.vfsInstallationFeatureCheck=function(d){!globalThis.SharedArrayBuffer||!globalThis.Atomics?r("Cannot install OPFS: Missing SharedArrayBuffer and/or Atomics.","The server must emit the COOP/COEP response headers to enable those.","See https://sqlite.org/wasm/doc/trunk/persistence.md#coop-coep"):typeof WorkerGlobalScope>"u"?r("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait()."):!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory?r("Missing required OPFS APIs."):d==="opfs-wl"&&!globalThis.Atomics.waitAsync&&r("The",d,"VFS requires Atomics.waitAsync(), which is not available.")},a.initOptions=function(q,V){let N=new URL(globalThis.location.href).searchParams;if(!N.has(q+"-disable")){try{a.vfsInstallationFeatureCheck(q)}catch{return}return V=s.nu(V),V.vfsName=q,V.verbose??=N.has("opfs-verbose")?+N.get("opfs-verbose"):1,V.sanityChecks??=N.has("opfs-sanity-check"),a.proxyUri||(a.proxyUri="sqlite3-opfs-async-proxy.js",o.scriptInfo?.sqlite3Dir&&(a.proxyUri=o.scriptInfo.sqlite3Dir+a.proxyUri)),V.proxyUri??=a.proxyUri,typeof V.proxyUri=="function"&&(V.proxyUri=V.proxyUri()),a.options=V}},a.createVfsState=function(){let d=s.nu(),q=a.options;d.verbose=q.verbose;let V=[o.config.error,o.config.warn,o.config.log],N=q.vfsName||r("Maintenance required: missing VFS name"),x=(F,...fe)=>{d.verbose>F&&V[F](N+":",...fe)},R=(...F)=>x(2,...F),$=(...F)=>x(1,...F),B=(...F)=>x(0,...F),J=o.capi,E=o.wasm,w=d.vfs=new J.sqlite3_vfs,W=w.ioMethods=new J.sqlite3_io_methods;W.$iVersion=1,w.$iVersion=2,w.$szOsFile=J.sqlite3_file.structInfo.sizeof,w.$mxPathname=1024,w.$zName=E.allocCString(N),w.addOnDispose("$zName",w.$zName,W),w.metrics=s.nu({counters:s.nu(),dump:function(){let F,fe=0,de=0,me=0;for(F in d.opIds){let S=ee[F];fe+=S.count,de+=S.time,me+=S.wait,S.avgTime=S.count&&S.time?S.time/S.count:0,S.avgWait=S.count&&S.wait?S.wait/S.count:0}o.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",ee,`
|
|
9
|
+
Total of`,fe,"op(s) for",de,"ms (incl. "+me+" ms of waiting on the async side)"),o.config.log("Serialization metrics:",w.metrics.counters.s11n),w.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let F,fe=S=>S.count=S.time=S.wait=0,de=w.metrics.counters;for(F in d.opIds)fe(de[F]=Object.create(null));let me=de.s11n=Object.create(null);me=me.serialize=Object.create(null),me.count=me.time=0,me=de.s11n.deserialize=Object.create(null),me.count=me.time=0}}),d.asyncIdleWaitTime=150,d.asyncS11nExceptions=1,d.fileBufferSize=65536,d.sabS11nOffset=d.fileBufferSize,d.sabS11nSize=w.$mxPathname*2,d.sabIO=new SharedArrayBuffer(d.fileBufferSize+d.sabS11nSize),d.opIds=Object.create(null);{let F=0;d.opIds.whichOp=F++,d.opIds.rc=F++,d.opIds.xAccess=F++,d.opIds.xClose=F++,d.opIds.xDelete=F++,d.opIds.xDeleteNoWait=F++,d.opIds.xFileSize=F++,d.opIds.xLock=F++,d.opIds.xOpen=F++,d.opIds.xRead=F++,d.opIds.xSleep=F++,d.opIds.xSync=F++,d.opIds.xTruncate=F++,d.opIds.xUnlock=F++,d.opIds.xWrite=F++,d.opIds.mkdir=F++,d.opIds["opfs-async-metrics"]=F++,d.opIds["opfs-async-shutdown"]=F++,d.opIds.retry=F++,d.sabOP=new SharedArrayBuffer(F*4)}d.sq3Codes=Object.create(null);for(let F of["SQLITE_ACCESS_EXISTS","SQLITE_ACCESS_READWRITE","SQLITE_BUSY","SQLITE_CANTOPEN","SQLITE_ERROR","SQLITE_IOERR","SQLITE_IOERR_ACCESS","SQLITE_IOERR_CLOSE","SQLITE_IOERR_DELETE","SQLITE_IOERR_FSYNC","SQLITE_IOERR_LOCK","SQLITE_IOERR_READ","SQLITE_IOERR_SHORT_READ","SQLITE_IOERR_TRUNCATE","SQLITE_IOERR_UNLOCK","SQLITE_IOERR_WRITE","SQLITE_LOCK_EXCLUSIVE","SQLITE_LOCK_NONE","SQLITE_LOCK_PENDING","SQLITE_LOCK_RESERVED","SQLITE_LOCK_SHARED","SQLITE_LOCKED","SQLITE_MISUSE","SQLITE_NOTFOUND","SQLITE_OPEN_CREATE","SQLITE_OPEN_DELETEONCLOSE","SQLITE_OPEN_MAIN_DB","SQLITE_OPEN_READONLY","SQLITE_LOCK_NONE","SQLITE_LOCK_SHARED","SQLITE_LOCK_RESERVED","SQLITE_LOCK_PENDING","SQLITE_LOCK_EXCLUSIVE"])d.sq3Codes[F]=J[F]??r("Maintenance required: not found:",F);d.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),w.metrics.reset();let ee=w.metrics.counters,O=w.opRun=(F,...fe)=>{let de=d.opIds[F]||r(w.vfsName+": Invalid op ID:",F);d.s11n.serialize(...fe),Atomics.store(d.sabOPView,d.opIds.rc,-1),Atomics.store(d.sabOPView,d.opIds.whichOp,de),Atomics.notify(d.sabOPView,d.opIds.whichOp);let me=performance.now();for(;Atomics.wait(d.sabOPView,d.opIds.rc,-1)!=="not-equal";);let S=Atomics.load(d.sabOPView,d.opIds.rc);if(ee[F].wait+=performance.now()-me,S&&d.asyncS11nExceptions){let C=d.s11n.deserialize();C&&B(F+"() async error:",...C)}return S},z=Object.create(null);z.op=void 0,z.start=void 0;let le=w.mTimeStart=F=>{z.start=performance.now(),z.op=F,++ee[F].count},h=w.mTimeEnd=()=>ee[z.op].time+=performance.now()-z.start,A=w.__openFiles=Object.create(null);w.ioSyncWrappers=s.nu({xCheckReservedLock:function(F,fe){return E.poke(fe,0,"i32"),0},xClose:function(F){le("xClose");let fe=0,de=A[F];return de&&(delete A[F],fe=O("xClose",F),de.sq3File&&de.sq3File.dispose()),h(),fe},xDeviceCharacteristics:function(F){return J.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(F,fe,de){return J.SQLITE_NOTFOUND},xFileSize:function(F,fe){le("xFileSize");let de=O("xFileSize",F);if(de==0)try{let me=d.s11n.deserialize()[0];E.poke(fe,me,"i64")}catch(me){B("Unexpected error reading xFileSize() result:",me),de=d.sq3Codes.SQLITE_IOERR}return h(),de},xRead:function(F,fe,de,me){le("xRead");let S=A[F],C;try{C=O("xRead",F,de,Number(me)),(C===0||J.SQLITE_IOERR_SHORT_READ===C)&&E.heap8u().set(S.sabView.subarray(0,de),Number(fe))}catch(u){B("xRead(",arguments,") failed:",u,S),C=J.SQLITE_IOERR_READ}return h(),C},xSync:function(F,fe){le("xSync");let de=O("xSync",F,fe);return h(),de},xTruncate:function(F,fe){le("xTruncate");let de=O("xTruncate",F,Number(fe));return h(),de},xWrite:function(F,fe,de,me){le("xWrite");let S=A[F],C;try{S.sabView.set(E.heap8u().subarray(Number(fe),Number(fe)+de)),C=O("xWrite",F,de,Number(me))}catch(u){B("xWrite(",arguments,") failed:",u,S),C=J.SQLITE_IOERR_WRITE}return h(),C}}),w.vfsSyncWrappers={xAccess:function(F,fe,de,me){le("xAccess");let S=O("xAccess",E.cstrToJs(fe));return E.poke(me,S?0:1,"i32"),h(),0},xCurrentTime:function(F,fe){return E.poke(fe,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(F,fe){return E.poke(fe,21086676e7+new Date().getTime(),"i64"),0},xDelete:function(F,fe,de){le("xDelete");let me=O("xDelete",E.cstrToJs(fe),de,!1);return h(),me},xFullPathname:function(F,fe,de,me){return E.cstrncpy(me,fe,de)<de?0:J.SQLITE_CANTOPEN},xGetLastError:function(F,fe,de){return o.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(fe,de,me,S,C){le("xOpen");let u=0,_,y;if(!de)_=a.randomFilename(),de=y=E.allocCString(_);else if(E.isPtr(de))J.sqlite3_uri_boolean(de,"opfs-unlock-asap",0)&&(u|=d.opfsFlags.OPFS_UNLOCK_ASAP),J.sqlite3_uri_boolean(de,"delete-before-open",0)&&(u|=d.opfsFlags.OPFS_UNLINK_BEFORE_OPEN),_=E.cstrToJs(de);else return o.config.error("Impossible zName value in xOpen?",de),J.SQLITE_CANTOPEN;let Q=s.nu({fid:me,filename:_,sab:new SharedArrayBuffer(d.fileBufferSize),flags:S,readOnly:!(J.SQLITE_OPEN_CREATE&S)&&!!(S&J.SQLITE_OPEN_READONLY)}),K=O("xOpen",me,_,S,u);return K?y&&E.dealloc(y):(Q.readOnly&&E.poke(C,J.SQLITE_OPEN_READONLY,"i32"),A[me]=Q,Q.sabView=d.sabFileBufView,Q.sq3File=new J.sqlite3_file(me),y&&Q.sq3File.addOnDispose(y),Q.sq3File.$pMethods=W.pointer,Q.lockType=J.SQLITE_LOCK_NONE),h(),K}};let U=J.sqlite3_vfs_find(null);if(U){let F=new J.sqlite3_vfs(U);w.$xRandomness=F.$xRandomness,w.$xSleep=F.$xSleep,F.dispose()}w.$xRandomness||(w.vfsSyncWrappers.xRandomness=function(F,fe,de){let me=E.heap8u(),S=0,C=Number(de);for(;S<fe;++S)me[C+S]=Math.random()*255e3&255;return S}),w.$xSleep||(w.vfsSyncWrappers.xSleep=function(F,fe){return le("xSleep"),Atomics.wait(d.sabOPView,d.opIds.xSleep,0,fe),h(),0});let X=function(){if(d.s11n)return d.s11n;let F=new TextDecoder,fe=new TextEncoder("utf-8"),de=new Uint8Array(d.sabIO,d.sabS11nOffset,d.sabS11nSize),me=new DataView(d.sabIO,d.sabS11nOffset,d.sabS11nSize);d.s11n=Object.create(null);let S=Object.create(null);S.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},S.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},S.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},S.string={id:4};let C=_=>S[typeof _]||r("Maintenance required: this value type cannot be serialized.",_),u=_=>{switch(_){case S.number.id:return S.number;case S.bigint.id:return S.bigint;case S.boolean.id:return S.boolean;case S.string.id:return S.string;default:r("Invalid type ID:",_)}};return d.s11n.deserialize=function(_=!1){performance.now();let y=de[0],Q=y?[]:null;if(y){let K=[],M=1,b,D,te;for(b=0;b<y;++b,++M)K.push(u(de[M]));for(b=0;b<y;++b){let Z=K[b];Z.getter?(te=me[Z.getter](M,d.littleEndian),M+=Z.size):(D=me.getInt32(M,d.littleEndian),M+=4,te=F.decode(de.slice(M,M+D)),M+=D),Q.push(te)}}return _&&(de[0]=0),Q},d.s11n.serialize=function(..._){if(performance.now(),_.length){let y=[],Q=0,K=1;for(de[0]=_.length&255;Q<_.length;++Q,++K)y.push(C(_[Q])),de[K]=y[Q].id;for(Q=0;Q<_.length;++Q){let M=y[Q];if(M.setter)me[M.setter](K,_[Q],d.littleEndian),K+=M.size;else{let b=fe.encode(_[Q]);me.setInt32(K,b.byteLength,d.littleEndian),K+=4,de.set(b,K),K+=b.byteLength}}}else de[0]=0},d.s11n};return w.initS11n=X,w.bindVfs=function(F,fe){return Object.assign(w.ioSyncWrappers,F),new Promise(function(de,me){let S,C=M=>(S=!0,w.dispose(),me(M)),u=()=>{try{fe(o,w)}catch(M){return C(M)}return S=!1,de(o)},_=a.options,y=w.worker=(()=>{let M=new URL("sqlite3-opfs-async-proxy.js",import.meta.url);return M.searchParams.set("vfs",N),new Worker(M.toString())})(),Q=setTimeout(()=>{S===void 0&&C(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3);y._originalOnError=y.onerror,y.onerror=function(M){B("Error initializing OPFS asyncer:",M),C(new Error("Loading OPFS async Worker failed for unknown reasons."))},w.opRun;let K=function(){let M=E.scopedAllocPush(),b=new J.sqlite3_file;try{let D=b.pointer,te=J.SQLITE_OPEN_CREATE|J.SQLITE_OPEN_READWRITE|J.SQLITE_OPEN_MAIN_DB,Z=E.scopedAlloc(8),we="/sanity/check/file"+randomFilename(8),he=E.scopedAllocCString(we),Ie;if(d.s11n.serialize("This is \xE4 string."),Ie=d.s11n.deserialize(),R("deserialize() says:",Ie),Ie[0]!=="This is \xE4 string."&&r("String d13n error."),w.vfsSyncWrappers.xAccess(w.pointer,he,0,Z),Ie=E.peek(Z,"i32"),R("xAccess(",we,") exists ?=",Ie),Ie=w.vfsSyncWrappers.xOpen(w.pointer,he,D,te,Z),R("open rc =",Ie,"state.sabOPView[xOpen] =",d.sabOPView[d.opIds.xOpen]),Ie!==0){B("open failed with code",Ie);return}w.vfsSyncWrappers.xAccess(w.pointer,he,0,Z),Ie=E.peek(Z,"i32"),Ie||r("xAccess() failed to detect file."),Ie=w.ioSyncWrappers.xSync(b.pointer,0),Ie&&r("sync failed w/ rc",Ie),Ie=w.ioSyncWrappers.xTruncate(b.pointer,1024),Ie&&r("truncate failed w/ rc",Ie),E.poke(Z,0,"i64"),Ie=w.ioSyncWrappers.xFileSize(b.pointer,Z),Ie&&r("xFileSize failed w/ rc",Ie),R("xFileSize says:",E.peek(Z,"i64")),Ie=w.ioSyncWrappers.xWrite(b.pointer,he,10,1),Ie&&r("xWrite() failed!");let Be=E.scopedAlloc(16);Ie=w.ioSyncWrappers.xRead(b.pointer,Be,6,2),E.poke(Be+6,0);let Ze=E.cstrToJs(Be);R("xRead() got:",Ze),Ze!=="sanity"&&r("Unexpected xRead() value."),w.vfsSyncWrappers.xSleep&&(R("xSleep()ing before close()ing..."),w.vfsSyncWrappers.xSleep(w.pointer,2e3),R("waking up from xSleep()")),Ie=w.ioSyncWrappers.xClose(D),R("xClose rc =",Ie,"sabOPView =",d.sabOPView),R("Deleting file:",we),w.vfsSyncWrappers.xDelete(w.pointer,he,4660),w.vfsSyncWrappers.xAccess(w.pointer,he,0,Z),Ie=E.peek(Z,"i32"),Ie&&r("Expecting 0 from xAccess(",we,") after xDelete()."),$("End of OPFS sanity checks.")}finally{b.dispose(),E.scopedAllocPop(M)}};y.onmessage=function({data:M}){switch(M.type){case"opfs-unavailable":C(new Error(M.payload.join(" ")));break;case"opfs-async-loaded":delete d.vfs,y.postMessage({type:"opfs-async-init",args:s.nu(d)});break;case"opfs-async-inited":if(S===!0)break;clearTimeout(Q),Q=null;try{o.vfs.installVfs({io:{struct:w.ioMethods,methods:w.ioSyncWrappers},vfs:{struct:w,methods:w.vfsSyncWrappers}}),d.sabOPView=new Int32Array(d.sabOP),d.sabFileBufView=new Uint8Array(d.sabIO,0,d.fileBufferSize),d.sabS11nView=new Uint8Array(d.sabIO,d.sabS11nOffset,d.sabS11nSize),w.initS11n(),delete w.initS11n,_.sanityChecks&&($("Running sanity checks because of opfs-sanity-check URL arg..."),K()),a.thisThreadHasOPFS()?a.getRootDir().then(b=>{y.onerror=y._originalOnError,delete y._originalOnError,R("End of OPFS sqlite3_vfs setup.",w),u()}).catch(C):u()}catch(b){B(b),C(b)}break;case"debug":$("debug message from worker:",M);break;default:{let b="Unexpected message from the OPFS async worker: "+JSON.stringify(M);B(b),C(new Error(b));break}}}})},d}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(!o.opfs||o.config.disable?.vfs?.opfs)return;let r=o.util,s=o.opfs||o.util.toss("Missing sqlite3.opfs"),a=async function(m){if(m=s.initOptions("opfs",m),!m)return o;let d=o.capi,q=s.createVfsState().vfs,V=q.metrics.counters,N=q.mTimeStart,x=q.mTimeEnd,R=q.opRun,$=q.__openFiles;return q.bindVfs(r.nu({xLock:function(B,J){N("xLock"),++V.xLock.count;let E=$[B],w=0;return E.lockType?E.lockType=J:(w=R("xLock",B,J),w===0&&(E.lockType=J)),x(),w},xUnlock:function(B,J){N("xUnlock"),++V.xUnlock.count;let E=$[B],w=0;return d.SQLITE_LOCK_NONE===J&&E.lockType&&(w=R("xUnlock",B,J)),w===0&&(E.lockType=J),x(),w}}),function(B,J){if(B.oo1){let E=function(...w){let W=B.oo1.DB.dbCtorHelper.normalizeArgs(...w);W.vfs=J.$zName,B.oo1.DB.dbCtorHelper.call(this,W)};E.prototype=Object.create(B.oo1.DB.prototype),B.oo1.OpfsDb=E,E.importDb=s.importDb,B.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(q.pointer,function(w,W){W.capi.sqlite3_busy_timeout(w,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async m=>a().catch(d=>{m.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",d)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){"use strict";if(o.config.disable?.vfs?.["opfs-sahpool"])return;let r=o.util.toss,s=o.util.toss3,a=Object.create(null),m=o.capi,d=o.util,q=o.wasm,V=4096,N=512,x=8,R=516,$=N,B=R,J=V,E=m.SQLITE_OPEN_MAIN_DB|m.SQLITE_OPEN_MAIN_JOURNAL|m.SQLITE_OPEN_SUPER_JOURNAL|m.SQLITE_OPEN_WAL,w=m.SQLITE_OPEN_MEMORY,W=".opaque",ee=()=>Math.random().toString(36).slice(2),O=new TextDecoder,z=new TextEncoder,le=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1}),h=[o.config.error,o.config.warn,o.config.log];o.config.log;let A=o.config.warn;o.config.error;let U=new Map,X=M=>U.get(M),F=(M,b)=>{b?U.set(M,b):U.delete(M)},fe=new Map,de=M=>fe.get(M),me=(M,b)=>{b?fe.set(M,b):fe.delete(M)},S={xCheckReservedLock:function(M,b){let D=de(M);return D.log("xCheckReservedLock"),D.storeErr(),q.poke32(b,1),0},xClose:function(M){let b=de(M);b.storeErr();let D=b.getOFileForS3File(M);if(D)try{b.log(`xClose ${D.path}`),b.mapS3FileToOFile(M,!1),D.sah.flush(),D.flags&m.SQLITE_OPEN_DELETEONCLOSE&&b.deletePath(D.path)}catch(te){return b.storeErr(te,m.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(M){return m.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(M,b,D){return m.SQLITE_NOTFOUND},xFileSize:function(M,b){let D=de(M);D.log("xFileSize");let te=D.getOFileForS3File(M).sah.getSize()-J;return q.poke64(b,BigInt(te)),0},xLock:function(M,b){let D=de(M);D.log(`xLock ${b}`),D.storeErr();let te=D.getOFileForS3File(M);return te.lockType=b,0},xRead:function(M,b,D,te){let Z=de(M);Z.storeErr();let we=Z.getOFileForS3File(M);Z.log(`xRead ${we.path} ${D} @ ${te}`);try{let he=we.sah.read(q.heap8u().subarray(Number(b),Number(b)+D),{at:J+Number(te)});return he<D?(q.heap8u().fill(0,Number(b)+he,Number(b)+D),m.SQLITE_IOERR_SHORT_READ):0}catch(he){return Z.storeErr(he,m.SQLITE_IOERR)}},xSectorSize:function(M){return V},xSync:function(M,b){let D=de(M);D.log(`xSync ${b}`),D.storeErr();let te=D.getOFileForS3File(M);try{return te.sah.flush(),0}catch(Z){return D.storeErr(Z,m.SQLITE_IOERR)}},xTruncate:function(M,b){let D=de(M);D.log(`xTruncate ${b}`),D.storeErr();let te=D.getOFileForS3File(M);try{return te.sah.truncate(J+Number(b)),0}catch(Z){return D.storeErr(Z,m.SQLITE_IOERR)}},xUnlock:function(M,b){let D=de(M);D.log("xUnlock");let te=D.getOFileForS3File(M);return te.lockType=b,0},xWrite:function(M,b,D,te){let Z=de(M);Z.storeErr();let we=Z.getOFileForS3File(M);Z.log(`xWrite ${we.path} ${D} ${te}`);try{return D===we.sah.write(q.heap8u().subarray(Number(b),Number(b)+D),{at:J+Number(te)})?0:r("Unknown write() failure.")}catch(he){return Z.storeErr(he,m.SQLITE_IOERR)}}},C=new m.sqlite3_io_methods;C.$iVersion=1,o.vfs.installVfs({io:{struct:C,methods:S}});let u={xAccess:function(M,b,D,te){let Z=X(M);Z.storeErr();try{let we=Z.getPath(b);q.poke32(te,Z.hasFilename(we)?1:0)}catch{q.poke32(te,0)}return 0},xCurrentTime:function(M,b){return q.poke(b,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(M,b){return q.poke(b,21086676e7+new Date().getTime(),"i64"),0},xDelete:function(M,b,D){let te=X(M);te.log(`xDelete ${q.cstrToJs(b)}`),te.storeErr();try{return te.deletePath(te.getPath(b)),0}catch(Z){return te.storeErr(Z),m.SQLITE_IOERR_DELETE}},xFullPathname:function(M,b,D,te){return q.cstrncpy(te,b,D)<D?0:m.SQLITE_CANTOPEN},xGetLastError:function(M,b,D){let te=X(M),Z=te.popErr();if(te.log(`xGetLastError ${b} e =`,Z),Z){let we=q.scopedAllocPush();try{let[he,Ie]=q.scopedAllocCString(Z.message,!0);q.cstrncpy(D,he,b),Ie>b&&q.poke8(q.ptr.add(D,b,-1),0)}catch{return m.SQLITE_NOMEM}finally{q.scopedAllocPop(we)}}return Z?Z.sqlite3Rc||m.SQLITE_IOERR:0},xOpen:function(b,D,te,Z,we){let he=X(b);try{Z&=~w,he.log(`xOpen ${q.cstrToJs(D)} ${Z}`);let Ie=D&&q.peek8(D)?he.getPath(D):ee(),Be=he.getSAHForPath(Ie);!Be&&Z&m.SQLITE_OPEN_CREATE&&(he.getFileCount()<he.getCapacity()?(Be=he.nextAvailableSAH(),he.setAssociatedPath(Be,Ie,Z)):r("SAH pool is full. Cannot create file",Ie)),Be||r("file not found:",Ie);let Ze={path:Ie,flags:Z,sah:Be};he.mapS3FileToOFile(te,Ze),Ze.lockType=m.SQLITE_LOCK_NONE;let at=new m.sqlite3_file(te);return at.$pMethods=C.pointer,at.dispose(),q.poke32(we,Z),0}catch(Ie){return he.storeErr(Ie),m.SQLITE_CANTOPEN}}},_=function(M){o.capi.sqlite3_vfs_find(M)&&s("VFS name is already registered:",M);let b=new m.sqlite3_vfs,D=m.sqlite3_vfs_find(null),te=D?new m.sqlite3_vfs(D):null;return b.$iVersion=2,b.$szOsFile=m.sqlite3_file.structInfo.sizeof,b.$mxPathname=N,b.addOnDispose(b.$zName=q.allocCString(M),()=>F(b.pointer,0)),te&&(b.$xRandomness=te.$xRandomness,b.$xSleep=te.$xSleep,te.dispose()),!b.$xRandomness&&!u.xRandomness&&(u.xRandomness=function(Z,we,he){let Ie=q.heap8u(),Be=0,Ze=Number(he);for(;Be<we;++Be)Ie[Ze+Be]=Math.random()*255e3&255;return Be}),!b.$xSleep&&!u.xSleep&&(u.xSleep=(Z,we)=>0),o.vfs.installVfs({vfs:{struct:b,methods:u}}),b};class y{vfsDir;#e;#t;#s;#n=new Map;#r=new Map;#a=new Set;#u=new Map;#i=new Uint8Array(R);#f;#o;#l;constructor(b=Object.create(null)){this.#l=b.verbosity??le.verbosity,this.vfsName=b.name||le.name,this.#o=_(this.vfsName),F(this.#o.pointer,this),this.vfsDir=b.directory||"."+this.vfsName,this.#f=new DataView(this.#i.buffer,this.#i.byteOffset),this.isReady=this.reset(!!(b.clearOnInit??le.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(b.initialCapacity||le.initialCapacity)})}#c(b,...D){this.#l>b&&h[b](this.vfsName+":",...D)}log(...b){this.#c(2,...b)}warn(...b){this.#c(1,...b)}error(...b){this.#c(0,...b)}getVfs(){return this.#o}getCapacity(){return this.#n.size}getFileCount(){return this.#r.size}getFileNames(){let b=[];for(let D of this.#r.keys())b.push(D);return b}async addCapacity(b){for(let D=0;D<b;++D){let te=ee(),Z=await(await this.#t.getFileHandle(te,{create:!0})).createSyncAccessHandle();this.#n.set(Z,te),this.setAssociatedPath(Z,"",0)}return this.getCapacity()}async reduceCapacity(b){let D=0;for(let te of Array.from(this.#a)){if(D===b||this.getFileCount()===this.getCapacity())break;let Z=this.#n.get(te);te.close(),await this.#t.removeEntry(Z),this.#n.delete(te),this.#a.delete(te),++D}return D}releaseAccessHandles(){for(let b of this.#n.keys())b.close();this.#n.clear(),this.#r.clear(),this.#a.clear()}async acquireAccessHandles(b=!1){let D=[];for await(let[te,Z]of this.#t)Z.kind==="file"&&D.push([te,Z]);return Promise.all(D.map(async([te,Z])=>{try{let we=await Z.createSyncAccessHandle();if(this.#n.set(we,te),b)we.truncate(J),this.setAssociatedPath(we,"",0);else{let he=this.getAssociatedPath(we);he?this.#r.set(he,we):this.#a.add(we)}}catch(we){throw this.storeErr(we),this.releaseAccessHandles(),we}}))}getAssociatedPath(b){b.read(this.#i,{at:0});let D=this.#f.getUint32($);if(this.#i[0]&&(D&m.SQLITE_OPEN_DELETEONCLOSE||(D&E)===0))return A(`Removing file with unexpected flags ${D.toString(16)}`,this.#i),this.setAssociatedPath(b,"",0),"";let te=new Uint32Array(x/4);b.read(te,{at:B});let Z=this.computeDigest(this.#i,D);if(te.every((we,he)=>we===Z[he])){let we=this.#i.findIndex(he=>he===0);return we===0&&b.truncate(J),we?O.decode(this.#i.subarray(0,we)):""}else return A("Disassociating file with bad digest."),this.setAssociatedPath(b,"",0),""}setAssociatedPath(b,D,te){let Z=z.encodeInto(D,this.#i);N<=Z.written+1&&r("Path too long:",D),D&&te&&(te|=w),this.#i.fill(0,Z.written,N),this.#f.setUint32($,te);let we=this.computeDigest(this.#i,te);b.write(this.#i,{at:0}),b.write(we,{at:B}),b.flush(),D?(this.#r.set(D,b),this.#a.delete(b)):(b.truncate(J),this.#a.add(b))}computeDigest(b,D){if(D&w){let te=3735928559,Z=1103547991;for(let we of b)te=Math.imul(te^we,2654435761),Z=Math.imul(Z^we,104729);return new Uint32Array([te>>>0,Z>>>0])}else return new Uint32Array([0,0])}async reset(b){await this.isReady;let D=await navigator.storage.getDirectory(),te;for(let Z of this.vfsDir.split("/"))Z&&(te=D,D=await D.getDirectoryHandle(Z,{create:!0}));return this.#e=D,this.#s=te,this.#t=await this.#e.getDirectoryHandle(W,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(b)}getPath(b){return q.isPtr(b)&&(b=q.cstrToJs(b)),(b instanceof URL?b:new URL(b,"file://localhost/")).pathname}deletePath(b){let D=this.#r.get(b);return D&&(this.#r.delete(b),this.setAssociatedPath(D,"",0)),!!D}storeErr(b,D){return b&&(b.sqlite3Rc=D||m.SQLITE_IOERR,this.error(b)),this.$error=b,D}popErr(){let b=this.$error;return this.$error=void 0,b}nextAvailableSAH(){let[b]=this.#a.keys();return b}getOFileForS3File(b){return this.#u.get(b)}mapS3FileToOFile(b,D){D?(this.#u.set(b,D),me(b,this)):(this.#u.delete(b),me(b,!1))}hasFilename(b){return this.#r.has(b)}getSAHForPath(b){return this.#r.get(b)}async removeVfs(){if(!this.#o.pointer||!this.#t)return!1;m.sqlite3_vfs_unregister(this.#o.pointer),this.#o.dispose(),delete a[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(W,{recursive:!0}),this.#t=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(b){o.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",b)}return!0}pauseVfs(){return this.#u.size>0&&o.SQLite3Error.toss(m.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files."),this.#n.size>0&&(m.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles()),this}isPaused(){return this.#n.size===0}async unpauseVfs(){return this.#n.size===0?this.acquireAccessHandles(!1).then(()=>m.sqlite3_vfs_register(this.#o,0),this):this}exportFile(b){let D=this.#r.get(b)||r("File not found:",b),te=D.getSize()-J,Z=new Uint8Array(te>0?te:0);if(te>0){let we=D.read(Z,{at:J});we!=te&&r("Expected to read "+te+" bytes but read "+we+".")}return Z}async importDbChunked(b,D){let te=this.#r.get(b)||this.nextAvailableSAH()||r("No available handles to import to.");te.truncate(0);let Z=0,we,he=!1;try{for(;(we=await D())!==void 0;)we instanceof ArrayBuffer&&(we=new Uint8Array(we)),!he&&Z===0&&we.byteLength>=15&&(d.affirmDbHeader(we),he=!0),te.write(we,{at:J+Z}),Z+=we.byteLength;if((Z<512||Z%512!==0)&&r("Input size",Z,"is not correct for an SQLite database."),!he){let Ie=new Uint8Array(20);te.read(Ie,{at:0}),d.affirmDbHeader(Ie)}te.write(new Uint8Array([1,1]),{at:4114})}catch(Ie){throw this.setAssociatedPath(te,"",0),Ie}return this.setAssociatedPath(te,b,m.SQLITE_OPEN_MAIN_DB),Z}importDb(b,D){if(D instanceof ArrayBuffer)D=new Uint8Array(D);else if(D instanceof Function)return this.importDbChunked(b,D);let te=this.#r.get(b)||this.nextAvailableSAH()||r("No available handles to import to."),Z=D.byteLength;(Z<512||Z%512!=0)&&r("Byte array size is invalid for an SQLite db.");let we="SQLite format 3";for(let Ie=0;Ie<15;++Ie)we.charCodeAt(Ie)!==D[Ie]&&r("Input does not contain an SQLite database header.");let he=te.write(D,{at:J});return he!=Z?(this.setAssociatedPath(te,"",0),r("Expected to write "+Z+" bytes but wrote "+he+".")):(te.write(new Uint8Array([1,1]),{at:4114}),this.setAssociatedPath(te,b,m.SQLITE_OPEN_MAIN_DB)),he}}class Q{#e;constructor(b){this.#e=b,this.vfsName=b.vfsName}async addCapacity(b){return this.#e.addCapacity(b)}async reduceCapacity(b){return this.#e.reduceCapacity(b)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(b){let D=this.#e.getCapacity();return D<b?this.#e.addCapacity(b-D):D}exportFile(b){return this.#e.exportFile(b)}importDb(b,D){return this.#e.importDb(b,D)}async wipeFiles(){return this.#e.reset(!0)}unlink(b){return this.#e.deletePath(b)}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 K=async()=>{let M=await navigator.storage.getDirectory(),b=".opfs-sahpool-sync-check-"+ee(),D=(await(await M.getFileHandle(b,{create:!0})).createSyncAccessHandle()).close();return await D,await M.removeEntry(b),D?.then&&r("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method."),!0};o.installOpfsSAHPoolVfs=async function(M=Object.create(null)){M=Object.assign(Object.create(null),le,M||{});let b=M.name;if(M.$testThrowPhase1)throw M.$testThrowPhase1;if(a[b])try{return await a[b]}catch(D){if(M.forceReinitIfPreviouslyFailed)delete a[b];else throw D}return!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory?a[b]=Promise.reject(new Error("Missing required OPFS APIs.")):a[b]=K().then(async function(){if(M.$testThrowPhase2)throw M.$testThrowPhase2;let D=new y(M);return D.isReady.then(async()=>{let te=new Q(D);if(o.oo1){let Z=o.oo1,we=D.getVfs(),he=function(...Ie){let Be=Z.DB.dbCtorHelper.normalizeArgs(...Ie);Be.vfs=we.$zName,Z.DB.dbCtorHelper.call(this,Be)};he.prototype=Object.create(Z.DB.prototype),te.OpfsSAHPoolDb=he}return D.log("VFS initialized."),te}).catch(async te=>{throw await D.removeVfs().catch(()=>{}),te})}).catch(D=>a[b]=Promise.reject(D))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(o){if(!o.opfs||o.config.disable?.vfs?.["opfs-wl"])return;let r=o.util;o.util.toss;let s=o.opfs,a="opfs-wl",m=async function(d){if(d=s.initOptions(a,d),!d)return o;o.capi;let q=s.createVfsState().vfs;q.metrics.counters;let V=q.mTimeStart,N=q.mTimeEnd,x=q.opRun,R=q.__openFiles;return q.bindVfs(r.nu({xLock:function($,B){V("xLock");let J=R[$],E=x("xLock",$,B);return E||(J.lockType=B),N(),E},xUnlock:function($,B){V("xUnlock");let J=R[$],E=x("xUnlock",$,B);return E||(J.lockType=B),N(),E}}),function($,B){if($.oo1){let J=function(...E){let w=$.oo1.DB.dbCtorHelper.normalizeArgs(...E);w.vfs=B.$zName,$.oo1.DB.dbCtorHelper.call(this,w)};J.prototype=Object.create($.oo1.DB.prototype),$.oo1.OpfsWlDb=J,J.importDb=s.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async d=>m().catch(q=>{d.config.warn("Ignoring inability to install the",a,"sqlite3_vfs:",q)}))});try{let o=Object.assign(Object.create(null),{memory:typeof yt<"u"?yt:n.wasmMemory,exports:typeof Bt<"u"?Bt:Object.prototype.hasOwnProperty.call(n,"wasmExports")?n.wasmExports:n.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",o);let r=globalThis.sqlite3ApiBootstrap(o);return delete globalThis.sqlite3ApiBootstrap,r}catch(o){throw console.error("sqlite3ApiBootstrap() error:",o),o}},re?i=t:i=new Promise((e,n)=>{Ce=e,be=n}),i}var sa,du,ss,os=Oe(()=>{mr=(function(){let l=mr;if(!l)throw new Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");let i=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(i.debugModule=i.urlParams.has("sqlite3.debugModule")?(...p)=>console.warn("sqlite3.debugModule:",...p):()=>{},i.urlParams.has("sqlite3.dir"))i.sqlite3Dir=i.urlParams.get("sqlite3.dir")+"/";else if(i.moduleScript){let p=i.moduleScript.src.split("/");p.pop(),i.sqlite3Dir=p.join("/")+"/"}let t=globalThis.sqlite3InitModule=function p(...g){return i.emscriptenLocateFile=g[0]?.locateFile,i.emscriptenInstantiateWasm=g[0]?.instantiateWasm,l(...g).then(T=>{i.debugModule("sqlite3InitModule() sIMS =",i),i.debugModule("sqlite3InitModule() EmscriptenModule =",T);let I=T.runSQLite3PostLoadInit(i,T,!!p.__isUnderTest);return i.debugModule("sqlite3InitModule() sqlite3 =",I),I}).catch(T=>{throw console.error("Exception loading sqlite3 module:",T),T})};if(t.ready=l.ready,i.moduleScript){let p=i.moduleScript.src.split("/");p.pop(),i.scriptDir=p.join("/")+"/"}return i.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",i),t})();sa=mr;globalThis.sqlite3Worker1Promiser=function l(i=l.defaultConfig){if(arguments.length===1&&typeof arguments[0]=="function"){let Y=i;i=Object.assign(Object.create(null),l.defaultConfig),i.onready=Y}else i=Object.assign(Object.create(null),l.defaultConfig,i);let t=Object.create(null),p=function(){},g=i.onerror||p,T=i.debug||p,I=i.generateMessageId?void 0:Object.create(null),j=i.generateMessageId||function(Y){return Y.type+"#"+(I[Y.type]=(I[Y.type]||0)+1)},H=(...Y)=>{throw new Error(Y.join(" "))};i.worker||(i.worker=l.defaultConfig.worker),typeof i.worker=="function"&&(i.worker=i.worker());let se,ue;return i.worker.onmessage=function(Y){Y=Y.data,T("worker1.onmessage",Y);let ne=t[Y.messageId];if(!ne){if(Y&&Y.type==="sqlite3-api"&&Y.result==="worker1-ready"){i.onready&&i.onready(ue);return}if(ne=t[Y.type],ne&&ne.onrow){ne.onrow(Y);return}i.onunhandled?i.onunhandled(arguments[0]):g("sqlite3Worker1Promiser() unhandled worker message:",Y);return}switch(delete t[Y.messageId],Y.type){case"error":ne.reject(Y);return;case"open":se||(se=Y.dbId);break;case"close":Y.dbId===se&&(se=void 0)}try{ne.resolve(Y)}catch(_e){ne.reject(_e)}},ue=function(){let Y;arguments.length===1?Y=arguments[0]:arguments.length===2?(Y=Object.create(null),Y.type=arguments[0],Y.args=arguments[1],Y.dbId=Y.args.dbId):H("Invalid arguments for sqlite3Worker1Promiser()-created factory."),!Y.dbId&&Y.type!=="open"&&(Y.dbId=se),Y.messageId=j(Y),Y.departureTime=performance.now();let ne=Object.create(null);ne.message=Y;let _e;Y.type==="exec"&&Y.args&&(typeof Y.args.callback=="function"?(_e=Y.messageId+":row",ne.onrow=Y.args.callback,Y.args.callback=_e,t[_e]=ne):typeof Y.args.callback=="string"&&H("exec callback may not be a string when using the Promise interface."));let Te=new Promise(function(Ce,be){ne.resolve=Ce,ne.reject=be,t[Y.messageId]=ne,T("Posting",Y.type,"message to Worker dbId="+(se||"default")+":",Y),i.worker.postMessage(Y)});return _e&&(Te=Te.finally(()=>delete t[_e])),Te}};globalThis.sqlite3Worker1Promiser.defaultConfig={worker:function(){return new Worker(new URL("sqlite3-worker1.mjs",import.meta.url),{type:"module"})},onerror:(...l)=>console.error("sqlite3Worker1Promiser():",...l)};globalThis.sqlite3Worker1Promiser.v2=function l(i=l.defaultConfig){let t;typeof i=="function"?(t=i,i={}):typeof i?.onready=="function"&&(t=i.onready,delete i.onready);let p=Object.create(null);i=Object.assign(i||Object.create(null),{onready:async function(T){try{t&&await t(T),p.resolve(T)}catch(I){p.reject(I)}}});let g=new Promise(function(T,I){p.resolve=T,p.reject=I});try{this.original(i)}catch(T){p.reject(T)}return g}.bind({original:sqlite3Worker1Promiser});globalThis.sqlite3Worker1Promiser.v2.defaultConfig=globalThis.sqlite3Worker1Promiser.defaultConfig;du=sqlite3Worker1Promiser.v2;delete globalThis.sqlite3Worker1Promiser;ss=sa});function us(l){cs=l}async function aa(l){let i=["localStorage","sessionStorage"].filter(t=>{try{return globalThis[t],!1}catch{}return Object.defineProperty(globalThis,t,{value:void 0,configurable:!0}),!0});try{return await l()}finally{for(let t of i)delete globalThis[t]}}async function ls(l){let i=await aa(()=>oa(l?{wasmBinary:l,locateFile:t=>t}:void 0));return i.config.warn=()=>{},i}function fs(l){return l?ls(l):as??=ls(cs??void 0).catch(i=>{throw as=null,i})}var oa,as,cs,pr=Oe(()=>{"use strict";os();oa=ss,as=null,cs=null});var ds={};Ao(ds,{CORE_FUNCTIONS:()=>xn,DEFAULT_CAPS:()=>Lt,Refused:()=>nt,SqliteDatabase:()=>st,TimedOut:()=>St,loadSqlite:()=>ca,provideSqliteWasm:()=>us});function la(l){let i=t=>{let p=new st(l);try{return t(p)}finally{p.close()}};return{analyze:(t,p,g)=>i(T=>{g?.mode==="write"&&g.extensions?.setupMutation?.(T,{dryRun:!0});for(let j of p)j.sql===void 0&&T.createTable(j);T.createViews(p.flatMap(j=>j.sql===void 0?[]:[{...j,sql:j.sql}]));let I=T.prepare(t,"any");return I.finalize(),I.analysis}),run:(t,p)=>zi(l,t,p),runMany:(t,p)=>Qi(l,t,p),held:t=>Vi(l,t),mutate:(t,p,g)=>ns(l,t,p,g),dryRun:t=>Hi(l,t),dryRunMutations:(t,p)=>rs(l,t,p),open:()=>new st(l),libraryFunctions:()=>i(t=>t.registeredFunctions())}}async function ca(l){return la(await fs(l))}var ms=Oe(()=>{"use strict";on();Gi();is();pr();pr();In();on()});ht();ht();ht();var xo=[{name:"_me.id",type:"user",source:"platform",readOnly:!0,query:!0,markup:!0,summary:"The reader's account id; null for a guest."},{name:"_now",type:"timestamp",source:"platform",readOnly:!0,query:!0,markup:!1,summary:"The current instant, UTC ISO; the same on the server and in the browser."},{name:"_tz",type:"string",source:"platform",readOnly:!0,query:!0,markup:!1,summary:"The reader's IANA time zone (UTC when unknown)."},{name:"_row",type:null,source:"control",readOnly:!0,query:!1,markup:!1,summary:"A field of the row the control sits in: $_row.<column>."},{name:"_value",type:null,source:"control",readOnly:!0,query:!1,markup:!1,summary:"The new value an editing cell holds."}],nn={_me:{columns:[{name:"id",type:"user"}],summary:"The reader as a one-row table (id null for a guest)."},_members:{columns:gn,summary:"The artifact's accepted members."}},_i=/^_row\.([A-Za-z_]\w*)$/;function hn(l){let i=_i.test(l)?"_row":l;return xo.find(t=>t.name===i)??null}var Qn=l=>_i.exec(l)?.[1]??null,gi=l=>hn(l)!==null;var yn=l=>({"_me.id":l.userId,_now:l.now,_tz:l.tz});ht();function bn(l){return Object.fromEntries(l.values.flatMap(i=>i.kind==="scalar"?[[i.name,i.default]]:[]))}function hi(l){return Object.fromEntries(l.values.flatMap(i=>i.kind==="scalar"&&i.type!=="table"?[[i.name,i.type]]:[]))}function yi(l,i={}){let t=i.page?[i.page.name]:i.only?[...i.only]:null;if(!t)return l.queries;let p=new Map(l.queries.map(I=>[I.name,I])),g=new Set,T=I=>{let j=p.get(I);if(!(!j||g.has(I))){g.add(I);for(let H of j.reads.queries)T(H)}};for(let I of t)T(I);return l.queries.filter(I=>g.has(I.name))}var wn=(l,i)=>l.imports.find(t=>t.name===i)?.ref;function Qt(l,i){return Object.fromEntries(l.map(t=>[Bn(t),i[t]??null]))}function Vt(l,i){let t={};for(let p of l){let g=i[p]??hn(p)?.type??null;g&&(t[Bn(p)]=g)}return t}function Sn(l,i){let t=new Map(l.flatMap(I=>I.type?[[I.name,I.type]]:[]));if(!t.size)return i;let p=i.columns.map(I=>{let j=t.get(I.name);return j&&j!==I.type?{...I,type:j}:I}),g=p.filter(I=>I.type==="boolean").map(I=>I.name),T=g.length?i.rows.map(I=>{let j={...I};for(let H of g)typeof j[H]=="number"&&(j[H]=j[H]!==0);return j}):i.rows;return{...i,columns:p,rows:T}}var bi=l=>[...l.args.map(i=>i.name),...l.reads.builtins.filter(gi)];function Vn(l,i,t){let p=[],g=(T,I)=>"import"in i.target?i.target.import===T&&i.target.table===I:T==="main"&&i.target.local===I;for(let T of i.reads.imports){let I=l.imports.find(j=>j.name===T);for(let j of I?.tables??[])g(T,j.name)||p.push({schema:T,table:j.name,rows:t.imports?.[T]?.[j.name]?.rows??[],columns:j.columns})}for(let T of i.reads.values){let I=l.values.find(j=>j.name===T&&j.kind==="table");I&&!g("main",I.name)&&p.push({schema:"main",table:I.name,rows:t.tables?.[I.name]?.rows??I.rows??[],columns:I.columns??[]})}return i.reads.builtins.includes("_me")&&p.push({schema:"main",table:"_me",rows:[{id:t.userId??null}],columns:nn._me.columns}),i.reads.builtins.includes("_members")&&p.push({schema:"main",table:"_members",rows:t.members??[],columns:nn._members.columns}),p}It();It();It();ht();var wi=["Dialog","DialogTrigger","DialogContent","DialogClose","Mermaid","DeckGL","Card","CardHeader","CardTitle","CardDescription","CardContent","CardFooter","CardAction","Badge","Button","Alert","AlertTitle","AlertDescription","Table","TableHeader","TableBody","TableFooter","TableRow","TableHead","TableCell","TableCaption","Separator","Skeleton","Progress","Breadcrumb","BreadcrumbList","BreadcrumbItem","BreadcrumbLink","BreadcrumbPage","BreadcrumbSeparator","BreadcrumbEllipsis","Avatar","AvatarImage","AvatarFallback","AvatarBadge","AvatarGroup","AvatarGroupCount","Tabs","TabsList","TabsTrigger","TabsContent","Accordion","AccordionItem","AccordionTrigger","AccordionContent","Collapsible","CollapsibleTrigger","CollapsibleContent","Tooltip","TooltipTrigger","TooltipContent","TooltipProvider","Popover","PopoverTrigger","PopoverContent","PopoverAnchor","PopoverHeader","PopoverTitle","PopoverDescription","Grid","GridItem","Input","Textarea","Select","Slider","DatePicker","Segmented","Switch","SlideDeck","Slide","File","Icon","User","UserImage","UserHandle","SignIn","DataTable","Column","For","Files"];var Ro=["svg","g","defs","path","line","polyline","polygon","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath","title","desc"],Hl=["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","a","strong","em","b","i","u","s","code","pre","kbd","samp","var","blockquote","cite","q","abbr","mark","small","sub","sup","del","ins","img","figure","figcaption","picture","source","video","audio","track","iframe","section","article","aside","header","footer","main","nav","address","hr","br","wbr","time","data","details","summary","button","input","label","select","option","optgroup","textarea","fieldset","legend","output","meter","progress","datalist","canvas","dialog","template",...Ro];var Si=["Question","Number",...wi];It();var Oo=/^\d{4}-\d{2}-\d{2}([T ].*)?$/;var Gt=(l,i)=>{if(l===null)return!0;switch(i){case"number":return typeof l=="number"&&Number.isFinite(l);case"boolean":return typeof l=="boolean";case"timestamp":return Wt(l);case"date":return typeof l=="string"&&Oo.test(l);case"user":case"string":return typeof l=="string"}};var _c=new Set(Si);var Jt=class extends Error{};function Hn(l,i){if(!Array.isArray(l)||l.length>1e4)throw new Jt("Local table must contain at most 10000 rows");return l.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(p=>!i.some(g=>g.name===p)))throw new Jt("Local row has undeclared fields");return Object.fromEntries(i.map(p=>{let g=Object.hasOwn(t,p.name)?t[p.name]:null;if(!Gt(g,p.type))throw new Jt(`Local field "${p.name}" has an invalid type`);return[p.name,g]}))})}function vn(l,i={}){return Object.fromEntries(Object.entries(i).map(([t,p])=>{let g=l.values.find(I=>I.kind==="table"&&I.name===t);if(!g||g.kind!=="table")throw new Jt(`"${t}" is not a declared inline table`);let T=g.columns??[];return[t,{columns:T,rows:Hn(p,T)}]}))}var wt=class extends Error{constructor(t){super(`Document query ${t}: complete results required`);this.reason=t}reason};async function vi(l,i,t,p={}){let g=await Po(l,i,t,p);return"state"in g?g.state:g.finish(await l.run({...g.run,imports:g.imports,page:p.page}))}async function Po(l,i,t,p){let g=bn(i);for(let[re,ye]of Object.entries(p.values??{}))Object.hasOwn(g,re)&&(g[re]=ye);let T={...g,...p.bindings?.values,...yn({userId:p.userId??null,now:p.now??new Date().toISOString(),tz:p.tz??"UTC"})},I={...hi(i),...p.bindings?.types},j={},H={},se={_me:{columns:nn._me.columns,rows:[{id:p.userId??null}]},_members:{columns:gn,rows:p.members??[]}},ue=vn(i,p.localTables);for(let re of i.values)re.kind==="table"&&(se[re.name]=ue[re.name]??{rows:re.rows??[],columns:re.columns??[]},j[re.name]=se[re.name]);let Y=yi(i,p);if(Y.length===0)return{state:{values:g,tables:j,errors:H}};if(p.completeResults){let re=performance.now(),ye=0;for(let Ae of Y){let ge=p.timeoutMs===void 0?void 0:Math.floor(p.timeoutMs-(performance.now()-re));if(ge!==void 0&&ge<1)throw new wt("timeout");let Pe=Qt(Ae.params,T),Le=Vt(Ae.params,I),Ne;if(Ae.source){if(!p.sourceQuery)throw new wt("query");Ne=await p.sourceQuery(Ae,Pe,Le,{limit:p.limit??At,offset:0},ge)}else{if(Ae.reads.imports.some(Et=>!t[Et]))throw new wt("query");let rt=(await l.run({tables:se,imports:Object.fromEntries(Ae.reads.imports.map(Et=>[Et,t[Et]])),queries:[{name:Ae.name,sql:Ae.sql}],params:Pe,paramTypes:Le,limit:p.limit??At,timeoutMs:ge}))[Ae.name];if(!rt||bt(rt))throw new wt(rt&&"timedOut"in rt&&rt.timedOut?"timeout":"query");Ne=rt}if(p.timeoutMs!==void 0&&performance.now()-re>p.timeoutMs)throw new wt("timeout");if(Ne.truncated||Ne.rows.length>(p.limit??At)||Ne.totalRows!==void 0&&Ne.totalRows>Ne.rows.length)throw new wt("capacity");if(ye+=new TextEncoder().encode(JSON.stringify(Ne.rows)).byteLength,p.resultBytes!==void 0&&ye>p.resultBytes)throw new wt("capacity");j[Ae.name]=se[Ae.name]=Sn(Ae.columns,Ne)}return{state:{values:g,tables:j,errors:H}}}await Promise.all(Y.filter(re=>!!re.source).map(async re=>{try{if(!p.sourceQuery)throw new Error(`the connected database ref:${re.source} is not reachable from here`);let ye=p.page?.name===re.name?p.page:void 0,Ae=Sn(re.columns,await p.sourceQuery(re,Qt(re.params,T),Vt(re.params,I),ye));se[re.name]=Ae,j[re.name]=Ae}catch(ye){H[re.name]=ye instanceof Error?ye.message:"Dataset query failed"}}));let ne=new Map(i.imports.filter(re=>!Object.hasOwn(t,re.name)).map(re=>[re.name,re.ref])),_e=Y.filter(re=>{if(re.source)return!1;let ye=re.reads.imports.find(Ae=>ne.has(Ae));return ye&&(H[re.name]=`<Query name="${re.name}"> reads ${ye} (ref:${ne.get(ye)}), which is unavailable \u2014 deleted, or no longer readable here`),!ye});if(!_e.length)return{state:{values:g,tables:j,errors:H}};let Te=new Set(_e.flatMap(re=>re.reads.imports)),Ce=Object.assign({},..._e.map(re=>Qt(re.params,T))),be=Object.assign({},..._e.map(re=>Vt(re.params,I)));return{run:{tables:se,queries:_e.map(re=>({name:re.name,sql:re.sql})),params:Ce,paramTypes:be,limit:p.limit??At,timeoutMs:p.timeoutMs},imports:Object.fromEntries(Object.entries(t).filter(([re])=>Te.has(re))),finish:re=>{for(let ye of _e){let Ae=re[ye.name];Ae&&(bt(Ae)?H[ye.name]=Ae.error:j[ye.name]=Sn(ye.columns,Ae))}return{values:g,tables:j,errors:H}}}}ht();async function Ei(l,i,t,p,g){if(!("local"in i.target))throw new Error("Mutation must target a declared local table");let T=i.target.local,I=l.values.find(ue=>ue.kind==="table"&&ue.name===T);if(!I)throw new Error("Mutation must target a declared local table");let j=I.columns??[];if(!j.length)throw new Error("Local table needs declared columns");let H=Object.hasOwn(t.tables,T)?t.tables[T].rows:I.rows??[],se=await p.mutate({table:{name:T,columns:j,rows:Hn(H,j)},sql:i.sql,params:g.params,paramTypes:g.paramTypes,...g.reads?.length?{reads:g.reads}:{},...i.expectedAffected===void 0?{}:{expectedAffected:i.expectedAffected}});if(bt(se))throw new Error(se.error);return{target:T,table:{columns:se.columns,rows:se.rows},affected:se.affected}}function Gn(l,i,t,p){let g=ne=>({ok:!1,reason:"invalid_sql",detail:ne}),T=ne=>({ok:!1,reason:"invalid_row",detail:ne}),I=Object.keys(t.args).filter(ne=>!i.args.some(_e=>_e.name===ne));if(I.length)return g(`${i.name} takes no argument ${I.join(", ")}${i.args.length?` (it takes ${i.args.map(ne=>ne.name).join(", ")})`:""}`);let j={},H=bn(l);for(let ne of i.args){let _e=Object.hasOwn(t.args,ne.name)?t.args[ne.name]:H[ne.name]??null,Te=_e===""&&ne.type&&ne.type!=="string"?null:_e;if(ne.type&&!Gt(Te,ne.type))return g(`argument $${ne.name} does not match its declared type`);j[ne.name]=Te}let se=i.reads.builtins.flatMap(ne=>Qn(ne)??[]),ue=Object.fromEntries(i.args.map(ne=>[ne.name,ne.type]));if(se.length){let ne=se.filter(Te=>!t.row||!Object.hasOwn(t.row,Te));if(ne.length)return T(`this row mutation reads $_row.${ne.join(", $_row.")} \u2014 send the row its control sits in`);let _e=Object.keys(t.row).filter(Te=>!se.includes(Te));if(_e.length)return T(`the row carries ${_e.join(", ")}, which ${i.name} does not read \u2014 send only $_row.${se.join(", $_row.")}`);for(let Te of se){let Ce=i.rowTypes?.[Te]??null,be=t.row[Te];if(Ce&&!Gt(be,Ce))return T("row fields and scalar types must match the declared table result");j[`_row.${Te}`]=be,ue[`_row.${Te}`]=Ce}}else if(t.row!==void 0)return T("this mutation does not read a row");if(i.reads.builtins.includes("_value")){if(t.value===void 0)return T("cell mutations require value");let ne=i.valueType??null,_e=ne&&ne!=="string"&&t.value===""?null:t.value;if(ne&&!Gt(_e,ne))return T("parameter $_value does not match the edited column's type");j._value=_e,ue._value=ne}else if(t.value!==void 0)return T("this mutation does not accept a value");Object.assign(j,yn(p));let Y=bi(i);return{ok:!0,params:Qt(Y,j),paramTypes:Vt(Y,ue),bindings:{values:j,types:{...Object.fromEntries(Object.entries(ue).filter(ne=>ne[1]!==null)),"_me.id":"user",_now:"timestamp",_tz:"string"},...p}}}var Jn=5e3,qi=1e4;function Ti(l){let i=null,t=null,p=null,g=new Map,T=[],I=null,j=be=>{let re=be.generation;be.loading=re,l.fetch(be.name).then(ye=>{be.generation===re&&(be.base=ye,T=T.filter(Ae=>Ae.confirmedAt===void 0||Ae.confirmedAt>=re),I=null)},()=>{}).finally(()=>{be.loading===re&&delete be.loading})},H=(be,re)=>Object.fromEntries(be.imports.flatMap(ye=>re.has(ye.ref)?[[ye.name,re.get(ye.ref)]]:[])),se=()=>{if(I)return I;let be=new Map;for(let[re,ye]of g)ye.base&&be.set(re,ye.base);for(let re of T){let ye=re.m.target,Ae=be.get(re.ref)?.[ye.table],ge=re.flow.imports.find(Le=>Le.name===ye.import)?.tables.find(Le=>Le.name===ye.table);if(!i||!Ae||!ge)continue;let Pe=i.mutate({...re.input,table:{schema:ye.import,name:ye.table,rows:Ae.rows,columns:ge.columns},reads:Vn(re.flow,re.m,{imports:H(re.flow,be),userId:re.userId})},{limit:qi,timeoutMs:Jn});bt(Pe)||be.set(re.ref,{...be.get(re.ref),[ye.table]:{rows:Pe.rows,columns:ge.columns}})}return I=be},ue=be=>H(be,se()),Y=!1,ne=()=>{if(Y)throw new Error("the page engine is closed");if(!i)throw new Error("the page engine is not loaded");return i},_e=be=>{let re=be.imports.map(Ae=>Ae.name),ye=JSON.stringify(re);return t?.schemas!==ye&&(t?.db.close(),t={schemas:ye,db:ne().held(re)}),t.db},Te=(be,re,ye)=>vi({run:async Ae=>_e(be).run(Ae,{limit:Ae.limit??At,pageLimit:Ae.page?.limit??Ae.limit??At,timeoutMs:Jn})},be,ue(be),{userId:re.userId,now:re.now,tz:re.tz,values:re.values,...ye.only?{only:ye.only}:{},...ye.page?{page:ye.page}:{},...re.localTables?{localTables:re.localTables}:{}}),Ce=(be,re,ye,Ae)=>{let ge=Gn(be,re,ye,Ae);if(!ge.ok)throw new Error(ge.detail);return ge};return{close(){Y=!0,t?.db.close(),t=null},prepare(be,re){if(!Y){p??=l.load().then(ye=>{i=ye,I=null},()=>{});for(let ye of re){let Ae=wn(be,ye);if(!Ae)continue;let ge=g.get(Ae);ge||g.set(Ae,ge={name:ye,generation:1}),!ge.base&&ge.loading===void 0&&j(ge)}}},ready(be,re){return!Y&&!!i&&re.every(ye=>{let Ae=wn(be,ye);return!!Ae&&!!g.get(Ae)?.base})},invalidate(be){for(let re of new Set(be)){let ye=g.get(re);ye&&(ye.generation++,delete ye.base,I=null,j(ye))}},async run(be,re,ye){let Ae=await Te(be,ye,{only:re});return{tables:Ae.tables,errors:Ae.errors}},async page(be,re,ye,Ae){let ge=await Te(be,Ae,{page:{name:re,...ye}}),Pe=ge.tables[re];if(!Pe)throw new Error(ge.errors[re]??`no rows for "${re}"`);return Pe},async write(be,re,ye,Ae){let{params:ge,paramTypes:Pe}=Ce(be,re,ye,Ae),Le=vn(be,ye.localTables);return Ei(be,re,{tables:Le},{mutate:async Ne=>ne().mutate(Ne,{limit:qi,timeoutMs:Jn})},{params:ge,paramTypes:Pe,reads:Vn(be,re,{imports:ue(be),tables:Le,userId:Ae.userId})})},apply(be,re,ye,Ae){let ge="import"in re.target?wn(be,re.target.import):void 0;if(Y||!i||!ge)return null;let Pe=Gn(be,re,ye,Ae);if(!Pe.ok)return null;let Le={flow:be,m:re,ref:ge,userId:Ae.userId,input:{sql:re.sql,params:Pe.params,paramTypes:Pe.paramTypes,...re.expectedAffected===void 0?{}:{expectedAffected:re.expectedAffected}}},Ne=se().get(ge);return T=[...T,Le],I=null,se().get(ge)===Ne?(T=T.filter(ft=>ft!==Le),I=null,null):{settle(ft){T.includes(Le)&&(ft?Le.confirmedAt=g.get(ge)?.generation??0:(T=T.filter(rt=>rt!==Le),I=null))}}}}}function ps(l){let i=null,t=async()=>{if(typeof l!="string")return l();let p=await fetch(l,{credentials:"omit"});if(!p.ok)throw new Error(`the SQLite engine did not load (${p.status})`);return p.arrayBuffer()};return()=>i??=Promise.all([Promise.resolve().then(()=>(ms(),ds)),t()]).then(([p,g])=>p.loadSqlite(g))}function Ru(l,i){return Ti({load:ps(l),fetch:i})}export{Ru as pageEngine};
|
|
10
10
|
/*! Bundled license information:
|
|
11
11
|
|
|
12
12
|
@sqlite.org/sqlite-wasm/dist/index.mjs:
|