@powerhousedao/connect 6.0.0-dev.53 → 6.0.0-dev.54
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/dist/assets/AddDriveModal-CUlc2LVq.js +2 -0
- package/dist/assets/AddDriveModal-CUlc2LVq.js.map +1 -0
- package/dist/assets/AnalyticsSubscriptionManager-B5G_L5RP.js +3 -0
- package/dist/assets/AnalyticsSubscriptionManager-B5G_L5RP.js.map +1 -0
- package/dist/assets/ClearStorageModal-xiZInXK_.js +2 -0
- package/dist/assets/ClearStorageModal-xiZInXK_.js.map +1 -0
- package/dist/assets/CookiesPolicyModal-DVXJp787.js +2 -0
- package/dist/assets/CookiesPolicyModal-DVXJp787.js.map +1 -0
- package/dist/assets/CreateDocumentModal-Cjpq1PBD.js +2 -0
- package/dist/assets/CreateDocumentModal-Cjpq1PBD.js.map +1 -0
- package/dist/assets/DebugSettingsModal-BvEPWw2E.js +7 -0
- package/dist/assets/DebugSettingsModal-BvEPWw2E.js.map +1 -0
- package/dist/assets/DeleteDriveModal-BEq8v3-E.js +2 -0
- package/dist/assets/DeleteDriveModal-BEq8v3-E.js.map +1 -0
- package/dist/assets/DeleteItemModal-B3ziER8J.js +2 -0
- package/dist/assets/DeleteItemModal-B3ziER8J.js.map +1 -0
- package/dist/assets/DisclaimerModal-CFnBcICu.js +2 -0
- package/dist/assets/DisclaimerModal-CFnBcICu.js.map +1 -0
- package/dist/assets/DriveSettingsModal-BOdnkWJn.js +2 -0
- package/dist/assets/DriveSettingsModal-BOdnkWJn.js.map +1 -0
- package/dist/assets/ExportDocumentWithErrorsModal--uHwELhU.js +2 -0
- package/dist/assets/ExportDocumentWithErrorsModal--uHwELhU.js.map +1 -0
- package/dist/assets/SettingsModal-BntFjuQb.js +2 -0
- package/dist/assets/SettingsModal-BntFjuQb.js.map +1 -0
- package/dist/assets/UpgradeDriveModal-DmbwNsbG.js +2 -0
- package/dist/assets/UpgradeDriveModal-DmbwNsbG.js.map +1 -0
- package/dist/assets/__vite-browser-external-D7Ct-6yo.js +2 -0
- package/dist/assets/__vite-browser-external-D7Ct-6yo.js.map +1 -0
- package/dist/assets/_virtual_ph_external-packages-CM1tCR4L.js +1 -0
- package/dist/assets/_virtual_ph_external-packages-CM1tCR4L.js.map +1 -0
- package/dist/assets/analytics-2CJbiDed.js +3 -0
- package/dist/assets/analytics-2CJbiDed.js.map +1 -0
- package/dist/assets/ccip-BEAjQRKG.js +2 -0
- package/dist/assets/ccip-BEAjQRKG.js.map +1 -0
- package/dist/assets/confirmation-modal-BOwR5ZQq.js +2 -0
- package/dist/assets/confirmation-modal-BOwR5ZQq.js.map +1 -0
- package/dist/assets/core-BmuZEe8D.js +2 -0
- package/dist/assets/core-BmuZEe8D.js.map +1 -0
- package/dist/assets/disclosure-BhnV_XS1.js +2 -0
- package/dist/assets/disclosure-BhnV_XS1.js.map +1 -0
- package/dist/assets/drive-by-id-DvdlB_kB.js +2 -0
- package/dist/assets/drive-by-id-DvdlB_kB.js.map +1 -0
- package/dist/assets/drives-DjHuIXXn.js +2 -0
- package/dist/assets/drives-DjHuIXXn.js.map +1 -0
- package/dist/assets/dropdown-menu-BzZBDp_E.js +2 -0
- package/dist/assets/dropdown-menu-BzZBDp_E.js.map +1 -0
- package/dist/assets/editor-DBekHIfI.js +2 -0
- package/dist/assets/editor-DBekHIfI.js.map +1 -0
- package/dist/assets/editor-DV2TvDV5.js +46 -0
- package/dist/assets/editor-DV2TvDV5.js.map +1 -0
- package/dist/assets/exports-CQVZRuji.js +3 -0
- package/dist/assets/exports-CQVZRuji.js.map +1 -0
- package/dist/assets/form-input-CPs_z-6y.js +2 -0
- package/dist/assets/form-input-CPs_z-6y.js.map +1 -0
- package/dist/assets/graphql-editor-CcDLLpoK.js +74 -0
- package/dist/assets/graphql-editor-CcDLLpoK.js.map +1 -0
- package/dist/assets/hmr-BfH10IPs.js +2 -0
- package/dist/assets/hmr-BfH10IPs.js.map +1 -0
- package/dist/assets/hmr-LMNkvzP7.js +1 -0
- package/dist/assets/hmr-LMNkvzP7.js.map +1 -0
- package/dist/assets/{hooks-53pCkdY-.js → hooks--iZen3H-.js} +13 -12
- package/dist/assets/hooks--iZen3H-.js.map +1 -0
- package/dist/assets/index-BDI8rK1R.js +2 -0
- package/dist/assets/index-BDI8rK1R.js.map +1 -0
- package/dist/assets/index-BWgPOeS2.js +500 -0
- package/dist/assets/index-BWgPOeS2.js.map +1 -0
- package/dist/assets/index-BeyYTlkr.js +2 -0
- package/dist/assets/index-BeyYTlkr.js.map +1 -0
- package/dist/assets/index-CUlo2oTb.js +199 -0
- package/dist/assets/index-CUlo2oTb.js.map +1 -0
- package/dist/assets/index-DN20Z-2K.js +222 -0
- package/dist/assets/index-DN20Z-2K.js.map +1 -0
- package/dist/assets/index-DPCEN2cB.js +2 -0
- package/dist/assets/index-DPCEN2cB.js.map +1 -0
- package/dist/assets/index-DcvFnjR9.css +1 -0
- package/dist/assets/index-RTtoSfzq.js +2 -0
- package/dist/assets/index-RTtoSfzq.js.map +1 -0
- package/dist/assets/index-WdPlK4TH.js +32 -0
- package/dist/assets/index-WdPlK4TH.js.map +1 -0
- package/dist/assets/index.esm-BeYGM8vk.js +2 -0
- package/dist/assets/index.esm-BeYGM8vk.js.map +1 -0
- package/dist/assets/index.modern-BKQ3hpRq.js +2 -0
- package/dist/assets/index.modern-BKQ3hpRq.js.map +1 -0
- package/dist/assets/json-editor-CfHUc1UK.js +2 -0
- package/dist/assets/json-editor-CfHUc1UK.js.map +1 -0
- package/dist/assets/load-D23NmM_n.js +4 -0
- package/dist/assets/load-D23NmM_n.js.map +1 -0
- package/dist/assets/location-info-N8RPWokW.js +2 -0
- package/dist/assets/location-info-N8RPWokW.js.map +1 -0
- package/dist/assets/message-list-0i5gk_8j.js +2 -0
- package/dist/assets/message-list-0i5gk_8j.js.map +1 -0
- package/dist/assets/migrator-CmQyl4ZK.js +78 -0
- package/dist/assets/migrator-CmQyl4ZK.js.map +1 -0
- package/dist/assets/node-input-DnUl9CxT.js +2 -0
- package/dist/assets/node-input-DnUl9CxT.js.map +1 -0
- package/dist/assets/nodefs-BP-sxN1O.js +2 -0
- package/dist/assets/nodefs-BP-sxN1O.js.map +1 -0
- package/dist/assets/nodefs-_NvywCGz.js +1 -0
- package/dist/assets/nodefs-_NvywCGz.js.map +1 -0
- package/dist/assets/opfs-ahp-DN9nZuJs.js +1 -0
- package/dist/assets/opfs-ahp-DN9nZuJs.js.map +1 -0
- package/dist/assets/opfs-ahp-DtmzPaVs.js +4 -0
- package/dist/assets/opfs-ahp-DtmzPaVs.js.map +1 -0
- package/dist/assets/options-CBc6-sTL.js +2 -0
- package/dist/assets/options-CBc6-sTL.js.map +1 -0
- package/dist/assets/pglite.db-B2bT8QML.js +133 -0
- package/dist/assets/pglite.db-B2bT8QML.js.map +1 -0
- package/dist/assets/pglite.worker-Ca6pWokV.js +1 -0
- package/dist/assets/pglite.worker-Ca6pWokV.js.map +1 -0
- package/dist/assets/processor-host-module-B89Dt9nZ.js +3 -0
- package/dist/assets/processor-host-module-B89Dt9nZ.js.map +1 -0
- package/dist/assets/queue-CxFgA-r3.js +2 -0
- package/dist/assets/queue-CxFgA-r3.js.map +1 -0
- package/dist/assets/reactor-7tK-WVaY.js +16 -0
- package/dist/assets/reactor-7tK-WVaY.js.map +1 -0
- package/dist/assets/reactor-Bsjwm88i.js +193 -0
- package/dist/assets/reactor-Bsjwm88i.js.map +1 -0
- package/dist/assets/reactor-CRqBKYEo.css +1 -0
- package/dist/assets/read-required-modal-BKEkfucI.js +2 -0
- package/dist/assets/read-required-modal-BKEkfucI.js.map +1 -0
- package/dist/assets/renown-CgfQ6oBU.js +2 -0
- package/dist/assets/renown-CgfQ6oBU.js.map +1 -0
- package/dist/assets/state-schemas-DK8TnzfC.js +3 -0
- package/dist/assets/state-schemas-DK8TnzfC.js.map +1 -0
- package/dist/assets/tabs-DY_DEdtI.js +2 -0
- package/dist/assets/tabs-DY_DEdtI.js.map +1 -0
- package/dist/assets/use-get-switchboard-link-B47eB8lt.js +12 -0
- package/dist/assets/use-get-switchboard-link-B47eB8lt.js.map +1 -0
- package/dist/assets/user-permissions-BJ8c2UOP.js +2 -0
- package/dist/assets/user-permissions-BJ8c2UOP.js.map +1 -0
- package/dist/assets/vetra-Bu3fuZWc.js +221 -0
- package/dist/assets/vetra-Bu3fuZWc.js.map +1 -0
- package/dist/index.html +2 -20
- package/lib/package.copy.json +3 -4
- package/lib/src/components/app-loader.d.ts.map +1 -1
- package/lib/src/components/app-loader.js +5 -16
- package/lib/src/components/app-loader.js.map +1 -1
- package/lib/src/components/index.d.ts +0 -1
- package/lib/src/components/index.d.ts.map +1 -1
- package/lib/src/components/index.js +0 -1
- package/lib/src/components/index.js.map +1 -1
- package/lib/src/components/load.d.ts +8 -0
- package/lib/src/components/load.d.ts.map +1 -0
- package/lib/src/components/load.js +17 -0
- package/lib/src/components/load.js.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.js +2 -1
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.js.map +1 -1
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.d.ts +1 -0
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.d.ts.map +1 -1
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.js +2 -0
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.js.map +1 -1
- package/lib/src/components/modal/modals/SettingsModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/SettingsModal.js +4 -1
- package/lib/src/components/modal/modals/SettingsModal.js.map +1 -1
- package/lib/src/components/modal/modals-container.d.ts +1 -1
- package/lib/src/components/modal/modals-container.d.ts.map +1 -1
- package/lib/src/components/modal/modals-container.js +12 -8
- package/lib/src/components/modal/modals-container.js.map +1 -1
- package/lib/src/main.js +3 -0
- package/lib/src/main.js.map +1 -1
- package/lib/src/services/storage/base-storage.d.ts.map +1 -1
- package/lib/src/services/storage/base-storage.js.map +1 -1
- package/lib/src/store/processor-host-module.d.ts.map +1 -1
- package/lib/src/store/processor-host-module.js +2 -2
- package/lib/src/store/processor-host-module.js.map +1 -1
- package/lib/src/store/reactor.d.ts.map +1 -1
- package/lib/src/store/reactor.js +1 -1
- package/lib/src/store/reactor.js.map +1 -1
- package/lib/style.css +15 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/vite.config.d.ts.map +1 -1
- package/lib/vite.config.js +1 -29
- package/lib/vite.config.js.map +1 -1
- package/package.copy.json +3 -4
- package/package.json +12 -13
- package/dist/assets/AddDriveModal-BZ11MHBB.js +0 -1
- package/dist/assets/ClearStorageModal-BC3gq6BT.js +0 -1
- package/dist/assets/CookiesPolicyModal-Bdf-jIqf.js +0 -1
- package/dist/assets/CreateDocumentModal-CExWso4S.js +0 -1
- package/dist/assets/DebugSettingsModal-MIi3iDrt.js +0 -1
- package/dist/assets/DeleteDriveModal-Cj_y-Bmk.js +0 -1
- package/dist/assets/DeleteItemModal-DLPEfn21.js +0 -1
- package/dist/assets/DisclaimerModal-uqaE0dfB.js +0 -1
- package/dist/assets/DriveSettingsModal-0o6Em8ZV.js +0 -1
- package/dist/assets/ExportDocumentWithErrorsModal-BWd92B7i.js +0 -1
- package/dist/assets/SettingsModal-Ca4V2Rxs.js +0 -1
- package/dist/assets/UpgradeDriveModal-ByNuxxET.js +0 -1
- package/dist/assets/config-0mYxXHFp.js +0 -1
- package/dist/assets/design_system-Q9KmzSmh.js +0 -45
- package/dist/assets/design_system_connect-MVhUhmHT.js +0 -47
- package/dist/assets/design_system_ui-BQ-CYVFb.js +0 -1
- package/dist/assets/document_drive-DiwReQ7A.js +0 -154
- package/dist/assets/document_engineering-BMBT2RYA.js +0 -1
- package/dist/assets/document_model-ly1Z8uco.js +0 -241
- package/dist/assets/document_model_editor-D_cNq26d.js +0 -25
- package/dist/assets/drive_explorer-508O2XxT.js +0 -2
- package/dist/assets/editor-DAyyI5MD.js +0 -1
- package/dist/assets/graphql-BXSeDpaV.js +0 -75
- package/dist/assets/graphql-editor-Buhxp36K.js +0 -73
- package/dist/assets/graphql_request-BHyPFzlZ.js +0 -3
- package/dist/assets/index-B6A7sjLB.css +0 -1
- package/dist/assets/index-D0gnc_IY.js +0 -208
- package/dist/assets/index-DQyPoyxC.js +0 -149
- package/dist/assets/index-DnR9iRBe.js +0 -29
- package/dist/assets/json-editor-dXLfmMol.js +0 -1
- package/dist/assets/nodefs-2HQmaeC9.js +0 -1
- package/dist/assets/nodefs-DzAAA-1u.js +0 -1
- package/dist/assets/opfs-ahp-CwNbpJAw.js +0 -3
- package/dist/assets/opfs-ahp-xYZANhiQ.js +0 -3
- package/dist/assets/postgres-CkP7QCDB.data +0 -0
- package/dist/assets/postgres-CyuUVpXN.wasm +0 -0
- package/dist/assets/react/jsx-runtime-DldvXD6N.js +0 -1
- package/dist/assets/react-D_vzfE_e.js +0 -1
- package/dist/assets/react-dom/client-SoBEzBdt.js +0 -9
- package/dist/assets/react-dom-Cz_KAjfm.js +0 -1
- package/dist/assets/reactor_browser-D2taHyRs.js +0 -136
- package/dist/assets/sentry_browser-TIBDlywD.js +0 -498
- package/dist/assets/sentry_react-CVx4Qq7f.js +0 -3
- package/dist/assets/state-schemas-C876MuV7.js +0 -2
- package/dist/assets/tailwind_merge-CXl88Wxt.js +0 -1
- package/dist/assets/zod-Cc38s6JG.js +0 -39
- package/lib/src/components/modal/index.d.ts +0 -18
- package/lib/src/components/modal/index.d.ts.map +0 -1
- package/lib/src/components/modal/index.js +0 -18
- package/lib/src/components/modal/index.js.map +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{d as u}from"./reactor-Bsjwm88i.js";import{u as l}from"./hmr-BfH10IPs.js";import{aI as d,aK as o,aJ as r,bF as a,aR as m,b6 as p,bh as f}from"./index-DN20Z-2K.js";import{s as g}from"./exports-CQVZRuji.js";import"./vetra-Bu3fuZWc.js";import"./renown-CgfQ6oBU.js";import"./reactor-7tK-WVaY.js";import"./migrator-CmQyl4ZK.js";import"./queue-CxFgA-r3.js";import"./drives-DjHuIXXn.js";const h=()=>{const{t}=d();return o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:t("notifications.reloadApp")}),o.jsxs("button",{onClick:()=>location.reload(),className:"underline decoration-solid underline-offset-2",children:[t("common.reloadConnect")," 🔄"]})]})},b=()=>{async function t(){const e=await k();if(e!==null){if(e.isLatest||e.currentVersion.includes("-"))return!0;a.studioMode||!a.warnOutdatedApp?m.warn(`Connect is outdated:
|
|
2
|
+
Current: @currentVersion
|
|
3
|
+
Latest: @latestVersion`,e.currentVersion,e.latestVersion):p(r.createElement(h),{type:"connect-warning",toastId:"outdated-app",autoClose:!1})}}r.useEffect(()=>{t().catch(console.error)},[])};window.navigator.appVersion.includes("Mac");const i={"staging/makerdao":"deployments/staging/makerdao","staging/arbitrum":"arb-ltip","staging/powerhouse":"staging",makerdao:"deployments/makerdao",arbitrum:"deployments/arbitrum",arbgrants:"deployments/arbitrum",localhost:"develop"},w=()=>{const t="https://raw.githubusercontent.com/powerhouse-inc/connect",e=window.location.href,s=Object.keys(i).find(c=>e.includes(c)),n=s?i[s]:void 0;if(n)return`${t}/${n}/package.json`},V=async()=>{const t=w();if(!t)return;const s=await(await fetch(t)).json(),{version:n}=s;return n},k=async()=>{const t=a.appVersion,e=await V();return e?{isLatest:e===t,currentVersion:t,latestVersion:e}:null};function y(){const t=f();r.useEffect(()=>{let e=null;if(t){const{credential:s,...n}=t;e={id:n.did,username:n.ens?.name,...n}}g(e)},[t])}async function T(){return await u(),{default:({children:t})=>(l(),y(),b(),t)}}export{T as loadComponent};
|
|
4
|
+
//# sourceMappingURL=load-D23NmM_n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-D23NmM_n.js","sources":["../../src/components/reload-connect-toast.tsx","../../src/hooks/useCheckLatestVersion.ts","../../src/hooks/utils.ts","../../src/store/user.ts","../../src/components/load.tsx"],"sourcesContent":["import { useTranslation } from \"react-i18next\";\n\nexport const ReloadConnectToast = () => {\n const { t } = useTranslation();\n\n return (\n <div>\n <p className=\"font-medium\">{t(\"notifications.reloadApp\")}</p>\n <button\n onClick={() => location.reload()}\n className=\"underline decoration-solid underline-offset-2\"\n >\n {t(\"common.reloadConnect\")} 🔄\n </button>\n </div>\n );\n};\n","import { connectConfig } from \"@powerhousedao/connect/config\";\nimport { isLatestVersion } from \"@powerhousedao/connect/hooks\";\nimport { toast } from \"@powerhousedao/connect/services\";\nimport { logger } from \"document-drive\";\nimport { createElement, useEffect } from \"react\";\nimport { ReloadConnectToast } from \"../components/reload-connect-toast.js\";\n\nexport const useCheckLatestVersion = () => {\n async function checkLatestVersion() {\n const result = await isLatestVersion();\n if (result === null) return;\n // ignore dev/staging versions\n if (result.isLatest || result.currentVersion.includes(\"-\")) {\n return true;\n }\n\n if (\n import.meta.env.MODE === \"development\" ||\n connectConfig.studioMode ||\n !connectConfig.warnOutdatedApp\n ) {\n logger.warn(\n \"Connect is outdated: \\nCurrent: @currentVersion\\nLatest: @latestVersion\",\n result.currentVersion,\n result.latestVersion,\n );\n } else {\n toast(createElement(ReloadConnectToast), {\n type: \"connect-warning\",\n toastId: \"outdated-app\",\n autoClose: false,\n });\n }\n }\n\n useEffect(() => {\n checkLatestVersion().catch(console.error);\n }, []);\n};\n","import { connectConfig } from \"@powerhousedao/connect/config\";\n\nexport const isMac = window.navigator.appVersion.includes(\"Mac\");\n\nconst urlBranchMap: Record<string, string> = {\n \"staging/makerdao\": \"deployments/staging/makerdao\",\n \"staging/arbitrum\": \"arb-ltip\",\n \"staging/powerhouse\": \"staging\",\n makerdao: \"deployments/makerdao\",\n arbitrum: \"deployments/arbitrum\",\n arbgrants: \"deployments/arbitrum\",\n localhost: \"develop\",\n};\n\nconst getGithubLinkFromUrl = () => {\n const githubLink = \"https://raw.githubusercontent.com/powerhouse-inc/connect\";\n const url = window.location.href;\n\n const env = Object.keys(urlBranchMap).find((env) => url.includes(env));\n const value = env ? urlBranchMap[env] : undefined;\n if (!value) {\n return undefined;\n } else {\n return `${githubLink}/${value}/package.json`;\n }\n};\n\nconst fetchLatestVersion = async () => {\n const link = getGithubLinkFromUrl();\n if (!link) {\n return undefined;\n }\n const result = await fetch(link);\n const data = (await result.json()) as { version: string };\n const { version } = data;\n return version;\n};\n\nexport const isLatestVersion = async () => {\n const currentVersion = connectConfig.appVersion;\n const deployed = await fetchLatestVersion();\n\n if (deployed) {\n return {\n isLatest: deployed === currentVersion,\n currentVersion,\n latestVersion: deployed,\n };\n }\n\n return null;\n};\n","import { useUser } from \"@powerhousedao/reactor-browser/connect\";\nimport type { User as SentryUser } from \"@sentry/react\";\nimport { setUser as setSentryUser } from \"@sentry/react\";\nimport { useEffect } from \"react\";\n\nexport function useSetSentryUser() {\n const user = useUser();\n useEffect(() => {\n let sentryUser: SentryUser | null = null;\n if (user) {\n // saves the user info except the credential\n const { credential, ...rest } = user;\n sentryUser = { id: rest.did, username: rest.ens?.name, ...rest };\n }\n setSentryUser(sentryUser);\n }, [user]);\n}\n","import { useCheckLatestVersion } from \"@powerhousedao/connect/hooks\";\nimport \"@powerhousedao/connect/i18n\";\nimport { useSubscribeToVetraPackages } from \"@powerhousedao/connect/services\";\nimport { createReactor, useSetSentryUser } from \"@powerhousedao/connect/store\";\nimport { type ReactNode } from \"react\";\n\nexport async function loadComponent() {\n await createReactor();\n return {\n default: ({ children }: { children?: ReactNode }) => {\n useSubscribeToVetraPackages();\n useSetSentryUser();\n useCheckLatestVersion();\n return children;\n },\n };\n}\n"],"names":["ReloadConnectToast","useTranslation","jsx","jsxs","useCheckLatestVersion","checkLatestVersion","result","isLatestVersion","connectConfig","logger","toast","createElement","useEffect","urlBranchMap","getGithubLinkFromUrl","githubLink","url","env","value","fetchLatestVersion","link","data","version","currentVersion","deployed","useSetSentryUser","user","useUser","sentryUser","credential","rest","setSentryUser","loadComponent","createReactor","children","useSubscribeToVetraPackages"],"mappings":"kYAEO,MAAMA,EAAqB,IAAM,CACtC,KAAM,CAAE,CAAA,EAAMC,EAAA,EAEd,cACG,MAAA,CACC,SAAA,CAAAC,MAAC,IAAA,CAAE,UAAU,cAAe,SAAA,EAAE,yBAAyB,EAAE,EACzDC,EAAAA,KAAC,SAAA,CACC,QAAS,IAAM,SAAS,OAAA,EACxB,UAAU,gDAET,SAAA,CAAA,EAAE,sBAAsB,EAAE,KAAA,CAAA,CAAA,CAC7B,EACF,CAEJ,ECTaC,EAAwB,IAAM,CACzC,eAAeC,GAAqB,CAClC,MAAMC,EAAS,MAAMC,EAAA,EACrB,GAAID,IAAW,KAEf,IAAIA,EAAO,UAAYA,EAAO,eAAe,SAAS,GAAG,EACvD,MAAO,GAKPE,EAAc,YACd,CAACA,EAAc,gBAEfC,EAAO,KACL;AAAA;AAAA,wBACAH,EAAO,eACPA,EAAO,aAAA,EAGTI,EAAMC,EAAAA,cAAcX,CAAkB,EAAG,CACvC,KAAM,kBACN,QAAS,eACT,UAAW,EAAA,CACZ,EAEL,CAEAY,EAAAA,UAAU,IAAM,CACdP,IAAqB,MAAM,QAAQ,KAAK,CAC1C,EAAG,CAAA,CAAE,CACP,ECpCqB,OAAO,UAAU,WAAW,SAAS,KAAK,EAE/D,MAAMQ,EAAuC,CAC3C,mBAAoB,+BACpB,mBAAoB,WACpB,qBAAsB,UACtB,SAAU,uBACV,SAAU,uBACV,UAAW,uBACX,UAAW,SACb,EAEMC,EAAuB,IAAM,CACjC,MAAMC,EAAa,2DACbC,EAAM,OAAO,SAAS,KAEtBC,EAAM,OAAO,KAAKJ,CAAY,EAAE,KAAMI,GAAQD,EAAI,SAASC,CAAG,CAAC,EAC/DC,EAAQD,EAAMJ,EAAaI,CAAG,EAAI,OACxC,GAAKC,EAGH,MAAO,GAAGH,CAAU,IAAIG,CAAK,eAEjC,EAEMC,EAAqB,SAAY,CACrC,MAAMC,EAAON,EAAA,EACb,GAAI,CAACM,EACH,OAGF,MAAMC,EAAQ,MADC,MAAM,MAAMD,CAAI,GACJ,KAAA,EACrB,CAAE,QAAAE,GAAYD,EACpB,OAAOC,CACT,EAEaf,EAAkB,SAAY,CACzC,MAAMgB,EAAiBf,EAAc,WAC/BgB,EAAW,MAAML,EAAA,EAEvB,OAAIK,EACK,CACL,SAAUA,IAAaD,EACvB,eAAAA,EACA,cAAeC,CAAA,EAIZ,IACT,EC9CO,SAASC,GAAmB,CACjC,MAAMC,EAAOC,EAAA,EACbf,EAAAA,UAAU,IAAM,CACd,IAAIgB,EAAgC,KACpC,GAAIF,EAAM,CAER,KAAM,CAAE,WAAAG,EAAY,GAAGC,CAAA,EAASJ,EAChCE,EAAa,CAAE,GAAIE,EAAK,IAAK,SAAUA,EAAK,KAAK,KAAM,GAAGA,CAAA,CAC5D,CACAC,EAAcH,CAAU,CAC1B,EAAG,CAACF,CAAI,CAAC,CACX,CCVA,eAAsBM,GAAgB,CACpC,aAAMC,EAAA,EACC,CACL,QAAS,CAAC,CAAE,SAAAC,MACVC,EAAA,EACAV,EAAA,EACArB,EAAA,EACO8B,EACT,CAEJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{aK as e,aO as n,aJ as o,bV as i}from"./index-DN20Z-2K.js";import{C as c}from"./index.esm-BeYGM8vk.js";import{s as d,l as f}from"./options-CBc6-sTL.js";function u(a){return e.jsx("div",{...a,className:n("h-px bg-gray-200",a.className)})}const x=o.forwardRef(function(r,s){return e.jsxs("label",{className:"relative cursor-pointer items-center",htmlFor:r.id,children:[e.jsx("input",{className:"peer sr-only",ref:s,type:"checkbox",value:"",...r}),e.jsx("div",{className:"peer h-6 w-11 rounded-full bg-gray-500 after:absolute after:start-0.5 after:top-0.5 after:size-5 after:rounded-full after:border after:border-none after:bg-gray-50 after:transition-all peer-checked:bg-blue-900 peer-checked:after:translate-x-full peer-focus:outline-none"})]})}),b=o.forwardRef(function(r,s){return e.jsxs("div",{className:"flex items-center rounded-md border border-gray-200 bg-gray-50 p-3 text-gray-900",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"font-medium text-gray-900",htmlFor:"availableOffline",children:"Make available offline"}),e.jsxs("p",{className:"text-xs text-gray-600",children:["Check this options if you keep a local backup",e.jsx("br",{}),"available at all times."]})]}),e.jsx(x,{id:"availableOffline",ref:s,...r})]})});function h(a){const{children:r,className:s,...t}=a;return e.jsx("label",{...t,className:n("block font-semibold text-gray-500",s),children:r})}function y(a){const{control:r,...s}=a;return e.jsx(c,{control:r,name:"sharingType",render:({field:t})=>e.jsx(i,{...s,...t,id:"sharingType",items:d})})}function j(a){const{location:r,className:s,...t}=a,l=f[r];return e.jsxs("div",{...t,className:n("my-3 flex items-center gap-2 rounded-xl border border-gray-100 p-3 text-gray-800 shadow",s),children:[l.icon,e.jsxs("div",{children:[e.jsx("p",{children:l.title}),e.jsx("p",{className:"text-xs text-slate-200",children:l.description})]})]})}export{b as A,u as D,h as L,y as S,j as a};
|
|
2
|
+
//# sourceMappingURL=location-info-N8RPWokW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location-info-N8RPWokW.js","sources":["../../../../packages/design-system/dist/src/connect/components/divider/divider.js","../../../../packages/design-system/dist/src/connect/components/toggle/toggle.js","../../../../packages/design-system/dist/src/connect/components/form/inputs/available-offline-toggle.js","../../../../packages/design-system/dist/src/connect/components/form/inputs/label.js","../../../../packages/design-system/dist/src/connect/components/form/inputs/sharing-type-form-input.js","../../../../packages/design-system/dist/src/connect/components/form/inputs/location-info.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { twMerge } from \"tailwind-merge\";\nexport function Divider(props) {\n return (_jsx(\"div\", { ...props, className: twMerge(\"h-px bg-gray-200\", props.className) }));\n}\n//# sourceMappingURL=divider.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { forwardRef } from \"react\";\nexport const Toggle = forwardRef(function Toggle(props, ref) {\n return (_jsxs(\"label\", { className: \"relative cursor-pointer items-center\", htmlFor: props.id, children: [_jsx(\"input\", { className: \"peer sr-only\", ref: ref, type: \"checkbox\", value: \"\", ...props }), _jsx(\"div\", { className: \"peer h-6 w-11 rounded-full bg-gray-500 after:absolute after:start-0.5 after:top-0.5 after:size-5 after:rounded-full after:border after:border-none after:bg-gray-50 after:transition-all peer-checked:bg-blue-900 peer-checked:after:translate-x-full peer-focus:outline-none\" })] }));\n});\n//# sourceMappingURL=toggle.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { forwardRef } from \"react\";\nimport { Toggle } from \"../../toggle/toggle.js\";\nexport const AvailableOfflineToggle = forwardRef(function AvailableOfflineToggle(props, ref) {\n return (_jsxs(\"div\", { className: \"flex items-center rounded-md border border-gray-200 bg-gray-50 p-3 text-gray-900\", children: [_jsxs(\"div\", { className: \"flex-1\", children: [_jsx(\"label\", { className: \"font-medium text-gray-900\", htmlFor: \"availableOffline\", children: \"Make available offline\" }), _jsxs(\"p\", { className: \"text-xs text-gray-600\", children: [\"Check this options if you keep a local backup\", _jsx(\"br\", {}), \"available at all times.\"] })] }), _jsx(Toggle, { id: \"availableOffline\", ref: ref, ...props })] }));\n});\n//# sourceMappingURL=available-offline-toggle.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { twMerge } from \"tailwind-merge\";\nexport function Label(props) {\n const { children, className, ...labelProps } = props;\n return (_jsx(\"label\", { ...labelProps, className: twMerge(\"block font-semibold text-gray-500\", className), children: children }));\n}\n//# sourceMappingURL=label.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { Controller } from \"react-hook-form\";\nimport { ConnectSelect } from \"../../select/select.js\";\nimport { sharingTypeOptions } from \"../../../constants/options.js\";\nexport function SharingTypeFormInput(props) {\n const { control, ...delegatedProps } = props;\n return (_jsx(Controller, { control: control, name: \"sharingType\", render: ({ field }) => (_jsx(ConnectSelect, { ...delegatedProps, ...field, id: \"sharingType\", items: sharingTypeOptions })) }));\n}\n//# sourceMappingURL=sharing-type-form-input.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { twMerge } from \"tailwind-merge\";\nimport { locationInfoByLocation } from \"../../../constants/options.js\";\nexport function LocationInfo(props) {\n const { location, className, ...divProps } = props;\n const locationInfo = locationInfoByLocation[location];\n return (_jsxs(\"div\", { ...divProps, className: twMerge(\"my-3 flex items-center gap-2 rounded-xl border border-gray-100 p-3 text-gray-800 shadow\", className), children: [locationInfo.icon, _jsxs(\"div\", { children: [_jsx(\"p\", { children: locationInfo.title }), _jsx(\"p\", { className: \"text-xs text-slate-200\", children: locationInfo.description })] })] }));\n}\n//# sourceMappingURL=location-info.js.map"],"names":["Divider","props","_jsx","twMerge","Toggle","forwardRef","ref","_jsxs","AvailableOfflineToggle","Label","children","className","labelProps","SharingTypeFormInput","control","delegatedProps","Controller","field","ConnectSelect","sharingTypeOptions","LocationInfo","location","divProps","locationInfo","locationInfoByLocation"],"mappings":"8JAEO,SAASA,EAAQC,EAAO,CAC3B,OAAQC,MAAK,MAAO,CAAE,GAAGD,EAAO,UAAWE,EAAQ,mBAAoBF,EAAM,SAAS,EAAG,CAC7F,CCFO,MAAMG,EAASC,EAAAA,WAAW,SAAgBJ,EAAOK,EAAK,CACzD,OAAQC,EAAAA,KAAM,QAAS,CAAE,UAAW,uCAAwC,QAASN,EAAM,GAAI,SAAU,CAACC,EAAAA,IAAK,QAAS,CAAE,UAAW,eAAgB,IAAKI,EAAK,KAAM,WAAY,MAAO,GAAI,GAAGL,CAAK,CAAE,EAAGC,EAAAA,IAAK,MAAO,CAAE,UAAW,+QAA+Q,CAAE,CAAC,CAAC,CAAE,CAC3f,CAAC,ECDYM,EAAyBH,EAAAA,WAAW,SAAgCJ,EAAOK,EAAK,CACzF,OAAQC,OAAM,MAAO,CAAE,UAAW,mFAAoF,SAAU,CAACA,OAAM,MAAO,CAAE,UAAW,SAAU,SAAU,CAACL,MAAK,QAAS,CAAE,UAAW,4BAA6B,QAAS,mBAAoB,SAAU,wBAAwB,CAAE,EAAGK,EAAAA,KAAM,IAAK,CAAE,UAAW,wBAAyB,SAAU,CAAC,gDAAiDL,MAAK,KAAM,CAAA,CAAE,EAAG,yBAAyB,EAAG,CAAC,EAAG,EAAGA,MAAKE,EAAQ,CAAE,GAAI,mBAAoB,IAAKE,EAAK,GAAGL,EAAO,CAAC,EAAG,CAC/gB,CAAC,ECHM,SAASQ,EAAMR,EAAO,CACzB,KAAM,CAAE,SAAAS,EAAU,UAAAC,EAAW,GAAGC,CAAU,EAAKX,EAC/C,OAAQC,MAAK,QAAS,CAAE,GAAGU,EAAY,UAAWT,EAAQ,oCAAqCQ,CAAS,EAAG,SAAUD,CAAQ,CAAE,CACnI,CCDO,SAASG,EAAqBZ,EAAO,CACxC,KAAM,CAAE,QAAAa,EAAS,GAAGC,CAAc,EAAKd,EACvC,OAAQC,EAAAA,IAAKc,EAAY,CAAE,QAASF,EAAS,KAAM,cAAe,OAAQ,CAAC,CAAE,MAAAG,CAAK,IAAQf,MAAKgB,EAAe,CAAE,GAAGH,EAAgB,GAAGE,EAAO,GAAI,cAAe,MAAOE,EAAoB,EAAI,CACnM,CCJO,SAASC,EAAanB,EAAO,CAChC,KAAM,CAAE,SAAAoB,EAAU,UAAAV,EAAW,GAAGW,CAAQ,EAAKrB,EACvCsB,EAAeC,EAAuBH,CAAQ,EACpD,OAAQd,EAAAA,KAAM,MAAO,CAAE,GAAGe,EAAU,UAAWnB,EAAQ,0FAA2FQ,CAAS,EAAG,SAAU,CAACY,EAAa,KAAMhB,EAAAA,KAAM,MAAO,CAAE,SAAU,CAACL,EAAAA,IAAK,IAAK,CAAE,SAAUqB,EAAa,KAAK,CAAE,EAAGrB,EAAAA,IAAK,IAAK,CAAE,UAAW,yBAA0B,SAAUqB,EAAa,WAAW,CAAE,CAAC,CAAC,CAAE,CAAC,EAAG,CACpW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{aK as t,bz as g,bA as m,bB as u,aJ as b,bC as p,bD as d,bE as h,aT as y}from"./index-DN20Z-2K.js";const k=b.forwardRef(({children:r,className:a,...o},s)=>t.jsx(p,{ref:s,...o,className:d("z-50 overflow-hidden rounded-md text-sm","border border-gray-200 bg-white text-gray-900 dark:border-gray-900 dark:bg-slate-900 dark:text-gray-200","px-3 py-1.5 shadow-md","data-[state=open]:animate-fade-in data-[state=open]:animate-zoom-in","data-[state=closed]:animate-fade-out data-[state=closed]:animate-zoom-out","data-[side=bottom]:animate-slide-in-from-top","data-[side=left]:animate-slide-in-from-right","data-[side=right]:animate-slide-in-from-left","data-[side=top]:animate-slide-in-from-bottom",a),children:r})),j=({content:r,children:a,triggerAsChild:o=!1,delayDuration:s=0,...n})=>{const{open:e,defaultOpen:x,onOpenChange:l,...i}=n;return t.jsxs(g,{defaultOpen:x,delayDuration:s,onOpenChange:l,open:e,children:[t.jsx(m,{asChild:o,type:o?void 0:"button",children:a}),t.jsx(u,{children:t.jsx(k,{sideOffset:3,...i,children:r})})]})},w=({children:r,required:a,disabled:o,description:s,hasError:n,inline:e,className:x,...l})=>{const i=d("inline-flex items-center text-sm font-medium",e?"leading-[22px]":"leading-4",`text-gray-900 ${e?"dark:text-gray-400":"dark:text-gray-50"}`,n&&"group-hover:!text-red-900 dark:group-hover:!text-red-900",n&&e&&"text-red-800 dark:text-red-800",n&&!e&&"text-red-900 dark:text-red-900",o&&`cursor-not-allowed text-gray-700 ${e?"dark:text-gray-600":"dark:text-gray-300"}`,e?!o&&"group-hover:text-gray-900 dark:group-hover:text-slate-50":"mb-[3px]",x);if(!r)return null;const c={...l};return t.jsxs("label",{className:i,...c,children:[r,a&&t.jsx("span",{className:d("ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50",n&&`${e?"!text-red-800":"!text-red-900"} group-hover:!text-red-900`),children:"*"}),s&&t.jsx(h,{children:t.jsx(j,{content:s,children:t.jsx(y,{name:"CircleInfo",size:16,className:d("ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500",o&&"text-gray-500")})})})]})},v="p",f=({children:r,type:a="info",as:o,className:s,...n})=>{const e=o||v,l=d("mb-0 inline-flex items-center text-xs font-medium",{error:"text-red-900 dark:text-red-900",info:"text-blue-900 dark:text-blue-900",warning:"text-yellow-900 dark:text-yellow-900"}[a],s);return t.jsx(e,{"data-type":a,className:l,...n,children:r})},N=({messages:r,type:a="info",className:o,...s})=>{if(r.length===0)return null;if(r.length===1)return t.jsx(f,{type:a,...s,children:r[0]});const n={error:"before:bg-red-900 dark:before:bg-red-900",info:"before:bg-blue-900 dark:before:bg-blue-900",warning:"before:bg-orange-900 dark:before:bg-orange-900"};return t.jsx("ul",{className:d("flex flex-col gap-1",o),...s,children:r.map(e=>t.jsx(f,{as:"li",type:a,className:d("relative pl-4","before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full",n[a]),children:e},e))})};export{w as F,j as T,N as a};
|
|
2
|
+
//# sourceMappingURL=message-list-0i5gk_8j.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-list-0i5gk_8j.js","sources":["../../../../packages/design-system/dist/src/ui/components/tooltip/tooltip.js","../../../../packages/design-system/dist/src/ui/components/form-label/form-label.js","../../../../packages/design-system/dist/src/ui/components/form-message/form-message.js","../../../../packages/design-system/dist/src/ui/components/form-message/message-list.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { cn } from \"@powerhousedao/design-system\";\nimport { Content, Portal, Provider, Root, Trigger, } from \"@radix-ui/react-tooltip\";\nimport { forwardRef } from \"react\";\nconst TooltipContent = forwardRef(({ children, className, ...props }, ref) => {\n return (_jsx(Content, { ref: ref, ...props, className: cn(\n // Base styles\n \"z-50 overflow-hidden rounded-md text-sm\", \n // Colors & Border\n \"border border-gray-200 bg-white text-gray-900 dark:border-gray-900 dark:bg-slate-900 dark:text-gray-200\", \n // Padding & Shadow\n \"px-3 py-1.5 shadow-md\", \n // Animations\n \"data-[state=open]:animate-fade-in data-[state=open]:animate-zoom-in\", \"data-[state=closed]:animate-fade-out data-[state=closed]:animate-zoom-out\", \n // Slide animations based on position\n \"data-[side=bottom]:animate-slide-in-from-top\", \"data-[side=left]:animate-slide-in-from-right\", \"data-[side=right]:animate-slide-in-from-left\", \"data-[side=top]:animate-slide-in-from-bottom\", className), children: children }));\n});\nconst Tooltip = ({ content, children, triggerAsChild = false, delayDuration = 0, ...props }) => {\n const { open, defaultOpen, onOpenChange, ...rest } = props;\n return (_jsxs(Root, { defaultOpen: defaultOpen, delayDuration: delayDuration, onOpenChange: onOpenChange, open: open, children: [_jsx(Trigger, { asChild: triggerAsChild, type: triggerAsChild ? undefined : \"button\", children: children }), _jsx(Portal, { children: _jsx(TooltipContent, { sideOffset: 3, ...rest, children: content }) })] }));\n};\nexport { Tooltip, TooltipContent, Provider as TooltipProvider, Root as TooltipRoot, Trigger as TooltipTrigger, };\n//# sourceMappingURL=tooltip.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { cn, Icon } from \"@powerhousedao/design-system\";\nimport { Tooltip, TooltipProvider } from \"../tooltip/tooltip.js\";\nexport const FormLabel = ({ children, required, disabled, description, hasError, inline, className, ...htmlLabelProps }) => {\n const classes = cn(\"inline-flex items-center text-sm font-medium\", inline ? \"leading-[22px]\" : \"leading-4\", `text-gray-900 ${inline ? \"dark:text-gray-400\" : \"dark:text-gray-50\"}`, hasError && \"group-hover:!text-red-900 dark:group-hover:!text-red-900\", hasError && inline && \"text-red-800 dark:text-red-800\", hasError && !inline && \"text-red-900 dark:text-red-900\", disabled &&\n `cursor-not-allowed text-gray-700 ${inline ? \"dark:text-gray-600\" : \"dark:text-gray-300\"}`, inline\n ? !disabled && \"group-hover:text-gray-900 dark:group-hover:text-slate-50\"\n : \"mb-[3px]\", className);\n if (!children) {\n // no label provided\n return null;\n }\n const extraProps = {\n ...htmlLabelProps,\n };\n return (_jsxs(\"label\", { className: classes, ...extraProps, children: [children, required && (_jsx(\"span\", { className: cn(\"ml-1 text-gray-800 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-slate-50\", hasError &&\n `${inline ? \"!text-red-800\" : \"!text-red-900\"} group-hover:!text-red-900`), children: \"*\" })), description && (_jsx(TooltipProvider, { children: _jsx(Tooltip, { content: description, children: _jsx(Icon, { name: \"CircleInfo\", size: 16, className: cn(\"ml-1 cursor-pointer text-gray-600 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-500\", disabled && \"text-gray-500\") }) }) }))] }));\n};\n//# sourceMappingURL=form-label.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { cn } from \"@powerhousedao/design-system\";\nconst defaultElement = \"p\";\nexport const FormMessage = ({ children, type = \"info\", as, className, ...props }) => {\n const Component = as || defaultElement;\n const typeClasses = {\n error: \"text-red-900 dark:text-red-900\",\n info: \"text-blue-900 dark:text-blue-900\",\n warning: \"text-yellow-900 dark:text-yellow-900\",\n };\n const classes = cn(\"mb-0 inline-flex items-center text-xs font-medium\", typeClasses[type], className);\n // TODO: add icon\n return (_jsx(Component, { \"data-type\": type, className: classes, ...props, children: children }));\n};\n//# sourceMappingURL=form-message.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { cn } from \"@powerhousedao/design-system\";\nimport { FormMessage } from \"./form-message.js\";\nexport const FormMessageList = ({ messages, type = \"info\", className, ...props }) => {\n if (messages.length === 0) {\n return null;\n }\n if (messages.length === 1) {\n return (_jsx(FormMessage, { type: type, ...props, children: messages[0] }));\n }\n const typeClasses = {\n error: \"before:bg-red-900 dark:before:bg-red-900\",\n info: \"before:bg-blue-900 dark:before:bg-blue-900\",\n warning: \"before:bg-orange-900 dark:before:bg-orange-900\",\n };\n return (_jsx(\"ul\", { className: cn(\"flex flex-col gap-1\", className), ...props, children: messages.map((message) => (_jsx(FormMessage, { as: \"li\", type: type, className: cn(\n // Layout\n \"relative pl-4\", \n // Visual styles\n \"before:absolute before:left-0 before:top-[0.4em] before:size-2 before:rounded-full\", typeClasses[type]), children: message }, message))) }));\n};\n//# sourceMappingURL=message-list.js.map"],"names":["TooltipContent","forwardRef","children","className","props","ref","_jsx","Content","cn","Tooltip","content","triggerAsChild","delayDuration","open","defaultOpen","onOpenChange","rest","_jsxs","Root","Trigger","Portal","FormLabel","required","disabled","description","hasError","inline","htmlLabelProps","classes","extraProps","TooltipProvider","Icon","defaultElement","FormMessage","type","as","Component","FormMessageList","messages","typeClasses","message"],"mappings":"yGAIA,MAAMA,EAAiBC,EAAAA,WAAW,CAAC,CAAE,SAAAC,EAAU,UAAAC,EAAW,GAAGC,CAAK,EAAIC,IAC1DC,EAAAA,IAAKC,EAAS,CAAE,IAAKF,EAAK,GAAGD,EAAO,UAAWI,EAEnD,0CAEA,0GAEA,wBAEA,sEAAuE,4EAEvE,+CAAgD,+CAAgD,+CAAgD,+CAAgDL,CAAS,EAAG,SAAUD,EAAU,CACvO,EACKO,EAAU,CAAC,CAAE,QAAAC,EAAS,SAAAR,EAAU,eAAAS,EAAiB,GAAO,cAAAC,EAAgB,EAAG,GAAGR,KAAY,CAC5F,KAAM,CAAE,KAAAS,EAAM,YAAAC,EAAa,aAAAC,EAAc,GAAGC,CAAI,EAAKZ,EACrD,OAAQa,EAAAA,KAAMC,EAAM,CAAE,YAAaJ,EAAa,cAAeF,EAAe,aAAcG,EAAc,KAAMF,EAAM,SAAU,CAACP,MAAKa,EAAS,CAAE,QAASR,EAAgB,KAAMA,EAAiB,OAAY,SAAU,SAAUT,EAAU,EAAGI,EAAAA,IAAKc,EAAQ,CAAE,SAAUd,MAAKN,EAAgB,CAAE,WAAY,EAAG,GAAGgB,EAAM,SAAUN,EAAS,CAAC,CAAE,CAAC,EAAG,CACpV,ECjBaW,EAAY,CAAC,CAAE,SAAAnB,EAAU,SAAAoB,EAAU,SAAAC,EAAU,YAAAC,EAAa,SAAAC,EAAU,OAAAC,EAAQ,UAAAvB,EAAW,GAAGwB,CAAc,IAAO,CACxH,MAAMC,EAAUpB,EAAG,+CAAgDkB,EAAS,iBAAmB,YAAa,iBAAiBA,EAAS,qBAAuB,mBAAmB,GAAID,GAAY,2DAA4DA,GAAYC,GAAU,iCAAkCD,GAAY,CAACC,GAAU,iCAAkCH,GACzW,oCAAoCG,EAAS,qBAAuB,oBAAoB,GAAIA,EAC1F,CAACH,GAAY,2DACb,WAAYpB,CAAS,EAC3B,GAAI,CAACD,EAED,OAAO,KAEX,MAAM2B,EAAa,CACf,GAAGF,CACX,EACI,OAAQV,EAAAA,KAAM,QAAS,CAAE,UAAWW,EAAS,GAAGC,EAAY,SAAU,CAAC3B,EAAUoB,GAAahB,EAAAA,IAAK,OAAQ,CAAE,UAAWE,EAAG,iGAAkGiB,GAC7M,GAAGC,EAAS,gBAAkB,eAAe,4BAA4B,EAAG,SAAU,GAAG,CAAE,EAAIF,GAAgBlB,EAAAA,IAAKwB,EAAiB,CAAE,SAAUxB,EAAAA,IAAKG,EAAS,CAAE,QAASe,EAAa,SAAUlB,EAAAA,IAAKyB,EAAM,CAAE,KAAM,aAAc,KAAM,GAAI,UAAWvB,EAAG,oGAAqGe,GAAY,eAAe,CAAC,CAAE,CAAC,CAAE,CAAC,CAAE,CAAE,EAAG,CAC5Z,ECfMS,EAAiB,IACVC,EAAc,CAAC,CAAE,SAAA/B,EAAU,KAAAgC,EAAO,OAAQ,GAAAC,EAAI,UAAAhC,EAAW,GAAGC,KAAY,CACjF,MAAMgC,EAAYD,GAAMH,EAMlBJ,EAAUpB,EAAG,oDALC,CAChB,MAAO,iCACP,KAAM,mCACN,QAAS,sCACjB,EACwF0B,CAAI,EAAG/B,CAAS,EAEpG,OAAQG,MAAK8B,EAAW,CAAE,YAAaF,EAAM,UAAWN,EAAS,GAAGxB,EAAO,SAAUF,CAAQ,CAAE,CACnG,ECVamC,EAAkB,CAAC,CAAE,SAAAC,EAAU,KAAAJ,EAAO,OAAQ,UAAA/B,EAAW,GAAGC,KAAY,CACjF,GAAIkC,EAAS,SAAW,EACpB,OAAO,KAEX,GAAIA,EAAS,SAAW,EACpB,OAAQhC,MAAK2B,EAAa,CAAE,KAAMC,EAAM,GAAG9B,EAAO,SAAUkC,EAAS,CAAC,EAAG,EAE7E,MAAMC,EAAc,CAChB,MAAO,2CACP,KAAM,6CACN,QAAS,gDACjB,EACI,OAAQjC,EAAAA,IAAK,KAAM,CAAE,UAAWE,EAAG,sBAAuBL,CAAS,EAAG,GAAGC,EAAO,SAAUkC,EAAS,IAAKE,GAAalC,EAAAA,IAAK2B,EAAa,CAAE,GAAI,KAAM,KAAMC,EAAM,UAAW1B,EAElK,gBAEA,qFAAsF+B,EAAYL,CAAI,CAAC,EAAG,SAAUM,GAAWA,CAAO,CAAE,EAAG,CACvJ"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import{bH as lr}from"./index-DN20Z-2K.js";function re(t){return typeof t>"u"||t===void 0}function v(t){return typeof t=="string"}function st(t){return typeof t=="number"}function jt(t){return typeof t=="boolean"}function Jt(t){return t===null}function Ri(t){return t instanceof Date}function Bt(t){return typeof t=="bigint"}function $(t){return typeof t=="function"}function me(t){return typeof t=="object"&&t!==null}function mr(t){return t[t.length-1]}function n(t){return Object.freeze(t)}function De(t){return z(t)?t:[t]}function z(t){return Array.isArray(t)}function Ai(t){return t}const k=n({is(t){return t.kind==="IdentifierNode"},create(t){return n({kind:"IdentifierNode",name:t})}}),et=n({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return n({kind:"SchemableIdentifierNode",identifier:k.create(t)})},createWithSchema(t,e){return n({kind:"SchemableIdentifierNode",schema:k.create(t),identifier:k.create(e)})}}),G=n({is(t){return t.kind==="AliasNode"},create(t,e){return n({kind:"AliasNode",node:t,alias:e})}}),D=n({is(t){return t.kind==="TableNode"},create(t){return n({kind:"TableNode",table:et.create(t)})},createWithSchema(t,e){return n({kind:"TableNode",table:et.createWithSchema(t,e)})}});function S(t){return me(t)&&$(t.toOperationNode)}function Vt(t){return me(t)&&"expressionType"in t&&S(t)}function fr(t){return me(t)&&"expression"in t&&v(t.alias)&&S(t)}const j=n({is(t){return t.kind==="SelectModifierNode"},create(t,e){return n({kind:"SelectModifierNode",modifier:t,of:e})},createWithExpression(t){return n({kind:"SelectModifierNode",rawModifier:t})}}),X=n({is(t){return t.kind==="AndNode"},create(t,e){return n({kind:"AndNode",left:t,right:e})}}),fe=n({is(t){return t.kind==="OrNode"},create(t,e){return n({kind:"OrNode",left:t,right:e})}}),He=n({is(t){return t.kind==="OnNode"},create(t){return n({kind:"OnNode",on:t})},cloneWithOperation(t,e,r){return n({...t,on:e==="And"?X.create(t.on,r):fe.create(t.on,r)})}}),ne=n({is(t){return t.kind==="JoinNode"},create(t,e){return n({kind:"JoinNode",joinType:t,table:e,on:void 0})},createWithOn(t,e,r){return n({kind:"JoinNode",joinType:t,table:e,on:He.create(r)})},cloneWithOn(t,e){return n({...t,on:t.on?He.cloneWithOperation(t.on,"And",e):He.create(e)})}}),he=n({is(t){return t.kind==="BinaryOperationNode"},create(t,e,r){return n({kind:"BinaryOperationNode",leftOperand:t,operator:e,rightOperand:r})}}),pr=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],Nr=["+","-","*","/","%","^","&","|","#","<<",">>"],zt=["->","->>"],wr=[...pr,...Nr,"&&","||"],yr=["exists","not exists"],gr=["not","-",...yr],xr=[...wr,...zt,...gr,"between","between symmetric"],ie=n({is(t){return t.kind==="OperatorNode"},create(t){return n({kind:"OperatorNode",operator:t})}});function wt(t){return v(t)&&zt.includes(t)}const _=n({is(t){return t.kind==="ColumnNode"},create(t){return n({kind:"ColumnNode",column:k.create(t)})}}),Gt=n({is(t){return t.kind==="SelectAllNode"},create(){return n({kind:"SelectAllNode"})}}),Ve=n({is(t){return t.kind==="ReferenceNode"},create(t,e){return n({kind:"ReferenceNode",table:e,column:t})},createSelectAll(t){return n({kind:"ReferenceNode",table:t,column:Gt.create()})}});class Mi{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return Zt(this.#e)}}function Kt(t){return me(t)&&S(t)&&v(t.dynamicReference)}const B=n({is(t){return t.kind==="OrderByItemNode"},create(t,e){return n({kind:"OrderByItemNode",orderBy:t,direction:e})},cloneWith(t,e){return n({...t,...e})}}),O=n({is(t){return t.kind==="RawNode"},create(t,e){return n({kind:"RawNode",sqlFragments:n(t),parameters:n(e)})},createWithSql(t){return O.create([t],[])},createWithChild(t){return O.create(["",""],[t])},createWithChildren(t){return O.create(new Array(t.length+1).fill(""),t)}}),Or=n({is(t){return t.kind==="CollateNode"},create(t){return n({kind:"CollateNode",collation:k.create(t)})}});class ee{#e;constructor(e){this.#e=n(e)}desc(){return new ee({node:B.cloneWith(this.#e.node,{direction:O.createWithSql("desc")})})}asc(){return new ee({node:B.cloneWith(this.#e.node,{direction:O.createWithSql("asc")})})}nullsLast(){return new ee({node:B.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new ee({node:B.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new ee({node:B.cloneWith(this.#e.node,{collation:Or.create(e)})})}toOperationNode(){return this.#e.node}}const yt=new Set;function ze(t){yt.has(t)||(yt.add(t),console.log(t))}function Ht(t){return t==="asc"||t==="desc"}function oe(t){if(t.length===2)return[Ye(t[0],t[1])];if(t.length===1){const[e]=t;return Array.isArray(e)?(ze("orderBy(array) is deprecated, use multiple orderBy calls instead."),e.map(r=>Ye(r))):[Ye(e)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${t.length}`)}function Ye(t,e){const r=br(t);if(B.is(r)){if(e)throw new Error("Cannot specify direction twice!");return r}return Yt(r,e)}function br(t){if(Ie(t))return Le(t);if(Kt(t))return t.toOperationNode();const[e,r]=t.split(" ");return r?(ze("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),Yt(Z(e),r)):Z(t)}function Yt(t,e){if(typeof e=="string"){if(!Ht(e))throw new Error(`Invalid order by direction: ${e}`);return B.create(t,O.createWithSql(e))}if(Vt(e))return ze("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),B.create(t,e.toOperationNode());const r=B.create(t);return e?e(new ee({node:r})).toOperationNode():r}const Fe=n({is(t){return t.kind==="JSONReferenceNode"},create(t,e){return n({kind:"JSONReferenceNode",reference:t,traversal:e})},cloneWithTraversal(t,e){return n({...t,traversal:e})}}),Xt=n({is(t){return t.kind==="JSONOperatorChainNode"},create(t){return n({kind:"JSONOperatorChainNode",operator:t,values:n([])})},cloneWithValue(t,e){return n({...t,values:n([...t.values,e])})}}),ye=n({is(t){return t.kind==="JSONPathNode"},create(t){return n({kind:"JSONPathNode",inOperator:t,pathLegs:n([])})},cloneWithLeg(t,e){return n({...t,pathLegs:n([...t.pathLegs,e])})}});function Zt(t){return v(t)?Z(t):t.toOperationNode()}function Ee(t){return z(t)?t.map(e=>M(e)):[M(t)]}function M(t){return Ie(t)?Le(t):Zt(t)}function kr(t,e){const r=Z(t);if(wt(e))return Fe.create(r,Xt.create(ie.create(e)));const i=e.slice(0,-1);if(wt(i))return Fe.create(r,ye.create(ie.create(i)));throw new Error(`Invalid JSON operator: ${e}`)}function Z(t){if(!t.includes("."))return Ve.create(_.create(t));const r=t.split(".").map(at);if(r.length===3)return Wr(r);if(r.length===2)return Er(r);throw new Error(`invalid column reference ${t}`)}function Cr(t){const e=" as ";if(t.includes(e)){const[r,i]=t.split(e).map(at);return G.create(Z(r),k.create(i))}else return Z(t)}function Tr(t){return _.create(t)}function vi(t){if(t.includes(" ")){const[r,i]=t.split(" ").map(at);if(!Ht(i))throw new Error(`invalid order direction "${i}" next to "${r}"`);return oe([r,i])[0]}else return Tr(t)}function Wr(t){const[e,r,i]=t;return Ve.create(_.create(i),D.createWithSchema(e,r))}function Er(t){const[e,r]=t;return Ve.create(_.create(r),D.create(e))}function at(t){return t.trim()}const Qt=n({is(t){return t.kind==="PrimitiveValueListNode"},create(t){return n({kind:"PrimitiveValueListNode",values:n([...t])})}}),er=n({is(t){return t.kind==="ValueListNode"},create(t){return n({kind:"ValueListNode",values:n(t)})}}),Q=n({is(t){return t.kind==="ValueNode"},create(t){return n({kind:"ValueNode",value:t})},createImmediate(t){return n({kind:"ValueNode",value:t,immediate:!0})}});function Sr(t){return z(t)?Rr(t):w(t)}function w(t){return Ie(t)?Le(t):Q.create(t)}function ut(t){return st(t)||jt(t)||Jt(t)}function ct(t){if(!ut(t))throw new Error(`unsafe immediate value ${JSON.stringify(t)}`);return Q.createImmediate(t)}function Rr(t){return t.some(Ie)?er.create(t.map(e=>w(e))):Qt.create(t)}const Se=n({is(t){return t.kind==="ParensNode"},create(t){return n({kind:"ParensNode",node:t})}});function C(t){if(t.length===3)return dt(t[0],t[1],t[2]);if(t.length===1)return w(t[0]);throw new Error(`invalid arguments: ${JSON.stringify(t)}`)}function dt(t,e,r){return Ar(e)&&tr(r)?he.create(M(t),tt(e),Q.createImmediate(r)):he.create(M(t),tt(e),Sr(r))}function U(t,e,r){return he.create(M(t),tt(e),M(r))}function gt(t,e){return _e(Object.entries(t).filter(([,r])=>!re(r)).map(([r,i])=>dt(r,tr(i)?"is":"=",i)),e)}function _e(t,e,r=!0){const i=e==="and"?X.create:fe.create;if(t.length===0)return he.create(Q.createImmediate(1),ie.create("="),Q.createImmediate(e==="and"?1:0));let o=xt(t[0]);for(let s=1;s<t.length;++s)o=i(o,xt(t[s]));return t.length>1&&r?Se.create(o):o}function Ar(t){return t==="is"||t==="is not"}function tr(t){return Jt(t)||jt(t)}function tt(t){if(v(t)&&xr.includes(t))return ie.create(t);if(S(t))return t.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(t)}`)}function xt(t){return S(t)?t.toOperationNode():t}const le=n({is(t){return t.kind==="OrderByNode"},create(t){return n({kind:"OrderByNode",items:n([...t])})},cloneWithItems(t,e){return n({...t,items:n([...t.items,...e])})}}),Ot=n({is(t){return t.kind==="PartitionByNode"},create(t){return n({kind:"PartitionByNode",items:n(t)})},cloneWithItems(t,e){return n({...t,items:n([...t.items,...e])})}}),rt=n({is(t){return t.kind==="OverNode"},create(){return n({kind:"OverNode"})},cloneWithOrderByItems(t,e){return n({...t,orderBy:t.orderBy?le.cloneWithItems(t.orderBy,e):le.create(e)})},cloneWithPartitionByItems(t,e){return n({...t,partitionBy:t.partitionBy?Ot.cloneWithItems(t.partitionBy,e):Ot.create(e)})}}),Ue=n({is(t){return t.kind==="FromNode"},create(t){return n({kind:"FromNode",froms:n(t)})},cloneWithFroms(t,e){return n({...t,froms:n([...t.froms,...e])})}}),bt=n({is(t){return t.kind==="GroupByNode"},create(t){return n({kind:"GroupByNode",items:n(t)})},cloneWithItems(t,e){return n({...t,items:n([...t.items,...e])})}}),kt=n({is(t){return t.kind==="HavingNode"},create(t){return n({kind:"HavingNode",having:t})},cloneWithOperation(t,e,r){return n({...t,having:e==="And"?X.create(t.having,r):fe.create(t.having,r)})}}),g=n({is(t){return t.kind==="InsertQueryNode"},create(t,e,r){return n({kind:"InsertQueryNode",into:t,...e&&{with:e},replace:r})},createWithoutInto(){return n({kind:"InsertQueryNode"})},cloneWith(t,e){return n({...t,...e})}}),rr=n({is(t){return t.kind==="ListNode"},create(t){return n({kind:"ListNode",items:n(t)})}}),ce=n({is(t){return t.kind==="UpdateQueryNode"},create(t,e){return n({kind:"UpdateQueryNode",table:t.length===1?t[0]:rr.create(t),...e&&{with:e}})},createWithoutTable(){return n({kind:"UpdateQueryNode"})},cloneWithFromItems(t,e){return n({...t,from:t.from?Ue.cloneWithFroms(t.from,e):Ue.create(e)})},cloneWithUpdates(t,e){return n({...t,updates:t.updates?n([...t.updates,...e]):e})},cloneWithLimit(t,e){return n({...t,limit:e})}}),nt=n({is(t){return t.kind==="UsingNode"},create(t){return n({kind:"UsingNode",tables:n(t)})},cloneWithTables(t,e){return n({...t,tables:n([...t.tables,...e])})}}),ge=n({is(t){return t.kind==="DeleteQueryNode"},create(t,e){return n({kind:"DeleteQueryNode",from:Ue.create(t),...e&&{with:e}})},cloneWithOrderByItems:(t,e)=>u.cloneWithOrderByItems(t,e),cloneWithoutOrderBy:t=>u.cloneWithoutOrderBy(t),cloneWithLimit(t,e){return n({...t,limit:e})},cloneWithoutLimit(t){return n({...t,limit:void 0})},cloneWithUsing(t,e){return n({...t,using:t.using!==void 0?nt.cloneWithTables(t.using,e):nt.create(e)})}}),T=n({is(t){return t.kind==="WhereNode"},create(t){return n({kind:"WhereNode",where:t})},cloneWithOperation(t,e,r){return n({...t,where:e==="And"?X.create(t.where,r):fe.create(t.where,r)})}}),Ct=n({is(t){return t.kind==="ReturningNode"},create(t){return n({kind:"ReturningNode",selections:n(t)})},cloneWithSelections(t,e){return n({...t,selections:t.selections?n([...t.selections,...e]):n(e)})}}),Mr=n({is(t){return t.kind==="ExplainNode"},create(t,e){return n({kind:"ExplainNode",format:t,options:e})}}),Me=n({is(t){return t.kind==="WhenNode"},create(t){return n({kind:"WhenNode",condition:t})},cloneWithResult(t,e){return n({...t,result:e})}}),F=n({is(t){return t.kind==="MergeQueryNode"},create(t,e){return n({kind:"MergeQueryNode",into:t,...e&&{with:e}})},cloneWithUsing(t,e){return n({...t,using:e})},cloneWithWhen(t,e){return n({...t,whens:t.whens?n([...t.whens,e]):n([e])})},cloneWithThen(t,e){return n({...t,whens:t.whens?n([...t.whens.slice(0,-1),Me.cloneWithResult(t.whens[t.whens.length-1],e)]):void 0})}}),Tt=n({is(t){return t.kind==="OutputNode"},create(t){return n({kind:"OutputNode",selections:n(t)})},cloneWithSelections(t,e){return n({...t,selections:t.selections?n([...t.selections,...e]):n(e)})}}),u=n({is(t){return f.is(t)||g.is(t)||ce.is(t)||ge.is(t)||F.is(t)},cloneWithEndModifier(t,e){return n({...t,endModifiers:t.endModifiers?n([...t.endModifiers,e]):n([e])})},cloneWithWhere(t,e){return n({...t,where:t.where?T.cloneWithOperation(t.where,"And",e):T.create(e)})},cloneWithJoin(t,e){return n({...t,joins:t.joins?n([...t.joins,e]):n([e])})},cloneWithReturning(t,e){return n({...t,returning:t.returning?Ct.cloneWithSelections(t.returning,e):Ct.create(e)})},cloneWithoutReturning(t){return n({...t,returning:void 0})},cloneWithoutWhere(t){return n({...t,where:void 0})},cloneWithExplain(t,e,r){return n({...t,explain:Mr.create(e,r?.toOperationNode())})},cloneWithTop(t,e){return n({...t,top:e})},cloneWithOutput(t,e){return n({...t,output:t.output?Tt.cloneWithSelections(t.output,e):Tt.create(e)})},cloneWithOrderByItems(t,e){return n({...t,orderBy:t.orderBy?le.cloneWithItems(t.orderBy,e):le.create(e)})},cloneWithoutOrderBy(t){return n({...t,orderBy:void 0})}}),f=n({is(t){return t.kind==="SelectQueryNode"},create(t){return n({kind:"SelectQueryNode",...t&&{with:t}})},createFrom(t,e){return n({kind:"SelectQueryNode",from:Ue.create(t),...e&&{with:e}})},cloneWithSelections(t,e){return n({...t,selections:t.selections?n([...t.selections,...e]):n(e)})},cloneWithDistinctOn(t,e){return n({...t,distinctOn:t.distinctOn?n([...t.distinctOn,...e]):n(e)})},cloneWithFrontModifier(t,e){return n({...t,frontModifiers:t.frontModifiers?n([...t.frontModifiers,e]):n([e])})},cloneWithOrderByItems:(t,e)=>u.cloneWithOrderByItems(t,e),cloneWithGroupByItems(t,e){return n({...t,groupBy:t.groupBy?bt.cloneWithItems(t.groupBy,e):bt.create(e)})},cloneWithLimit(t,e){return n({...t,limit:e})},cloneWithOffset(t,e){return n({...t,offset:e})},cloneWithFetch(t,e){return n({...t,fetch:e})},cloneWithHaving(t,e){return n({...t,having:t.having?kt.cloneWithOperation(t.having,"And",e):kt.create(e)})},cloneWithSetOperations(t,e){return n({...t,setOperations:t.setOperations?n([...t.setOperations,...e]):n([...e])})},cloneWithoutSelections(t){return n({...t,selections:[]})},cloneWithoutLimit(t){return n({...t,limit:void 0})},cloneWithoutOffset(t){return n({...t,offset:void 0})},cloneWithoutOrderBy:t=>u.cloneWithoutOrderBy(t),cloneWithoutGroupBy(t){return n({...t,groupBy:void 0})}});class xe{#e;constructor(e){this.#e=n(e)}on(...e){return new xe({...this.#e,joinNode:ne.cloneWithOn(this.#e.joinNode,C(e))})}onRef(e,r,i){return new xe({...this.#e,joinNode:ne.cloneWithOn(this.#e.joinNode,U(e,r,i))})}onTrue(){return new xe({...this.#e,joinNode:ne.cloneWithOn(this.#e.joinNode,O.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}const vr=n({is(t){return t.kind==="PartitionByItemNode"},create(t){return n({kind:"PartitionByItemNode",partitionBy:t})}});function qr(t){return Ee(t).map(vr.create)}class Oe{#e;constructor(e){this.#e=n(e)}orderBy(...e){return new Oe({overNode:rt.cloneWithOrderByItems(this.#e.overNode,oe(e))})}clearOrderBy(){return new Oe({overNode:u.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new Oe({overNode:rt.cloneWithPartitionByItems(this.#e.overNode,qr(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}const be=n({is(t){return t.kind==="SelectionNode"},create(t){return n({kind:"SelectionNode",selection:t})},createSelectAll(){return n({kind:"SelectionNode",selection:Gt.create()})},createSelectAllFromTable(t){return n({kind:"SelectionNode",selection:Ve.createSelectAll(t)})}});function q(t){return $(t)?q(t(Ne())):z(t)?t.map(e=>Wt(e)):[Wt(t)]}function Wt(t){return v(t)?be.create(Cr(t)):Kt(t)?be.create(t.toOperationNode()):be.create(ar(t))}function L(t){return t?Array.isArray(t)?t.map(Et):[Et(t)]:[be.createSelectAll()]}function Et(t){if(v(t))return be.createSelectAllFromTable(E(t));throw new Error(`invalid value selectAll expression: ${JSON.stringify(t)}`)}const Lr=n({is(t){return t.kind==="ValuesNode"},create(t){return n({kind:"ValuesNode",values:n(t)})}}),Ir=n({is(t){return t.kind==="DefaultInsertValueNode"},create(){return n({kind:"DefaultInsertValueNode"})}});function nr(t){const e=$(t)?t(Ne()):t,r=z(e)?e:n([e]);return Dr(r)}function Dr(t){const e=Pr(t);return[n([...e.keys()].map(_.create)),Lr.create(t.map(r=>Fr(r,e)))]}function Pr(t){const e=new Map;for(const r of t){const i=Object.keys(r);for(const o of i)!e.has(o)&&r[o]!==void 0&&e.set(o,e.size)}return e}function Fr(t,e){const r=Object.keys(t),i=Array.from({length:e.size});let o=!1,s=r.length;for(const c of r){const h=e.get(c);if(re(h)){s--;continue}const x=t[c];(re(x)||Ie(x))&&(o=!0),i[h]=x}if(s<e.size||o){const c=Ir.create();return er.create(i.map(h=>re(h)?c:w(h)))}return Qt.create(i)}const ir=n({is(t){return t.kind==="ColumnUpdateNode"},create(t,e){return n({kind:"ColumnUpdateNode",column:t,value:e})}});function _r(...t){return t.length===2?[ir.create(M(t[0]),w(t[1]))]:ht(t[0])}function ht(t){const e=$(t)?t(Ne()):t;return Object.entries(e).filter(([r,i])=>i!==void 0).map(([r,i])=>ir.create(_.create(r),w(i)))}const Ur=n({is(t){return t.kind==="OnDuplicateKeyNode"},create(t){return n({kind:"OnDuplicateKeyNode",updates:t})}});class $r{insertId;numInsertedOrUpdatedRows;constructor(e,r){this.insertId=e,this.numInsertedOrUpdatedRows=r}}class ve extends Error{node;constructor(e){super("no result"),this.node=e}}function qe(t){return Object.prototype.hasOwnProperty.call(t,"prototype")}const R=n({is(t){return t.kind==="OnConflictNode"},create(){return n({kind:"OnConflictNode"})},cloneWith(t,e){return n({...t,...e})},cloneWithIndexWhere(t,e){return n({...t,indexWhere:t.indexWhere?T.cloneWithOperation(t.indexWhere,"And",e):T.create(e)})},cloneWithIndexOrWhere(t,e){return n({...t,indexWhere:t.indexWhere?T.cloneWithOperation(t.indexWhere,"Or",e):T.create(e)})},cloneWithUpdateWhere(t,e){return n({...t,updateWhere:t.updateWhere?T.cloneWithOperation(t.updateWhere,"And",e):T.create(e)})},cloneWithUpdateOrWhere(t,e){return n({...t,updateWhere:t.updateWhere?T.cloneWithOperation(t.updateWhere,"Or",e):T.create(e)})},cloneWithoutIndexWhere(t){return n({...t,indexWhere:void 0})},cloneWithoutUpdateWhere(t){return n({...t,updateWhere:void 0})}});class J{#e;constructor(e){this.#e=n(e)}column(e){const r=_.create(e);return new J({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?n([...this.#e.onConflictNode.columns,r]):n([r])})})}columns(e){const r=e.map(_.create);return new J({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?n([...this.#e.onConflictNode.columns,...r]):n(r)})})}constraint(e){return new J({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{constraint:k.create(e)})})}expression(e){return new J({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new J({...this.#e,onConflictNode:R.cloneWithIndexWhere(this.#e.onConflictNode,C(e))})}whereRef(e,r,i){return new J({...this.#e,onConflictNode:R.cloneWithIndexWhere(this.#e.onConflictNode,U(e,r,i))})}clearWhere(){return new J({...this.#e,onConflictNode:R.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new jr({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new ke({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{updates:ht(e)})})}$call(e){return e(this)}}class jr{#e;constructor(e){this.#e=n(e)}toOperationNode(){return this.#e.onConflictNode}}class ke{#e;constructor(e){this.#e=n(e)}where(...e){return new ke({...this.#e,onConflictNode:R.cloneWithUpdateWhere(this.#e.onConflictNode,C(e))})}whereRef(e,r,i){return new ke({...this.#e,onConflictNode:R.cloneWithUpdateWhere(this.#e.onConflictNode,U(e,r,i))})}clearWhere(){return new ke({...this.#e,onConflictNode:R.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}const Jr=n({is(t){return t.kind==="TopNode"},create(t,e){return n({kind:"TopNode",expression:t,modifiers:e})}});function pe(t,e){if(!st(t)&&!Bt(t))throw new Error(`Invalid top expression: ${t}`);if(!re(e)&&!Br(e))throw new Error(`Invalid top modifiers: ${e}`);return Jr.create(t,e)}function Br(t){return t==="percent"||t==="with ties"||t==="percent with ties"}const se=n({is(t){return t.kind==="OrActionNode"},create(t){return n({kind:"OrActionNode",action:t})}});class l{#e;constructor(e){this.#e=n(e)}values(e){const[r,i]=nr(e);return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{columns:r,values:i})})}columns(e){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{columns:n(e.map(_.create))})})}expression(e){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{values:Le(e)})})}defaultValues(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new l({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{orAction:se.create("ignore")})})}orIgnore(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{orAction:se.create("ignore")})})}orAbort(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{orAction:se.create("abort")})})}orFail(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{orAction:se.create("fail")})})}orReplace(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{orAction:se.create("replace")})})}orRollback(){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{orAction:se.create("rollback")})})}top(e,r){return new l({...this.#e,queryNode:u.cloneWithTop(this.#e.queryNode,pe(e,r))})}onConflict(e){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{onConflict:e(new J({onConflictNode:R.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new l({...this.#e,queryNode:g.cloneWith(this.#e.queryNode,{onDuplicateKey:Ur.create(ht(e))})})}returning(e){return new l({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,q(e))})}returningAll(){return new l({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,L())})}output(e){return new l({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,q(e))})}outputAll(e){return new l({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,L(e))})}clearReturning(){return new l({...this.#e,queryNode:u.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new l({...this.#e})}$castTo(){return new l(this.#e)}$narrowType(){return new l(this.#e)}$assertType(){return new l(this.#e)}withPlugin(e){return new l({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:i}=this.#e.executor,o=e.query;return o.returning&&i.supportsReturning||o.output&&i.supportsOutput?r.rows:[new $r(r.insertId,r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=ve){const r=await this.executeTakeFirst();if(r===void 0)throw qe(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),i=this.#e.executor.stream(r,e);for await(const o of i)yield*o.rows}async explain(e,r){return await new l({...this.#e,queryNode:u.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}class Vr{numDeletedRows;constructor(e){this.numDeletedRows=e}}const lt=n({is(t){return t.kind==="LimitNode"},create(t){return n({kind:"LimitNode",limit:t})}});class N{#e;constructor(e){this.#e=n(e)}where(...e){return new N({...this.#e,queryNode:u.cloneWithWhere(this.#e.queryNode,C(e))})}whereRef(e,r,i){return new N({...this.#e,queryNode:u.cloneWithWhere(this.#e.queryNode,U(e,r,i))})}clearWhere(){return new N({...this.#e,queryNode:u.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new N({...this.#e,queryNode:u.cloneWithTop(this.#e.queryNode,pe(e,r))})}using(e){return new N({...this.#e,queryNode:ge.cloneWithUsing(this.#e.queryNode,de(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,r){return new N({...this.#e,queryNode:u.cloneWithJoin(this.#e.queryNode,Ke(e,r))})}returning(e){return new N({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,q(e))})}returningAll(e){return new N({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,L(e))})}output(e){return new N({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,q(e))})}outputAll(e){return new N({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,L(e))})}clearReturning(){return new N({...this.#e,queryNode:u.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new N({...this.#e,queryNode:ge.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new N({...this.#e,queryNode:u.cloneWithOrderByItems(this.#e.queryNode,oe(e))})}clearOrderBy(){return new N({...this.#e,queryNode:u.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new N({...this.#e,queryNode:ge.cloneWithLimit(this.#e.queryNode,lt.create(w(e)))})}modifyEnd(e){return new N({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,r){return e?r(this):new N({...this.#e})}$castTo(){return new N(this.#e)}$narrowType(){return new N(this.#e)}$assertType(){return new N(this.#e)}withPlugin(e){return new N({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:i}=this.#e.executor,o=e.query;return o.returning&&i.supportsReturning||o.output&&i.supportsOutput?r.rows:[new Vr(r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=ve){const r=await this.executeTakeFirst();if(r===void 0)throw qe(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),i=this.#e.executor.stream(r,e);for await(const o of i)yield*o.rows}async explain(e,r){return await new N({...this.#e,queryNode:u.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}class zr{numUpdatedRows;numChangedRows;constructor(e,r){this.numUpdatedRows=e,this.numChangedRows=r}}class p{#e;constructor(e){this.#e=n(e)}where(...e){return new p({...this.#e,queryNode:u.cloneWithWhere(this.#e.queryNode,C(e))})}whereRef(e,r,i){return new p({...this.#e,queryNode:u.cloneWithWhere(this.#e.queryNode,U(e,r,i))})}clearWhere(){return new p({...this.#e,queryNode:u.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new p({...this.#e,queryNode:u.cloneWithTop(this.#e.queryNode,pe(e,r))})}from(e){return new p({...this.#e,queryNode:ce.cloneWithFromItems(this.#e.queryNode,de(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}#t(e,r){return new p({...this.#e,queryNode:u.cloneWithJoin(this.#e.queryNode,Ke(e,r))})}orderBy(...e){return new p({...this.#e,queryNode:u.cloneWithOrderByItems(this.#e.queryNode,oe(e))})}clearOrderBy(){return new p({...this.#e,queryNode:u.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new p({...this.#e,queryNode:ce.cloneWithLimit(this.#e.queryNode,lt.create(w(e)))})}set(...e){return new p({...this.#e,queryNode:ce.cloneWithUpdates(this.#e.queryNode,_r(...e))})}returning(e){return new p({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,q(e))})}returningAll(e){return new p({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,L(e))})}output(e){return new p({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,q(e))})}outputAll(e){return new p({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,L(e))})}modifyEnd(e){return new p({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new p({...this.#e,queryNode:u.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new p({...this.#e})}$castTo(){return new p(this.#e)}$narrowType(){return new p(this.#e)}$assertType(){return new p(this.#e)}withPlugin(e){return new p({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:i}=this.#e.executor,o=e.query;return o.returning&&i.supportsReturning||o.output&&i.supportsOutput?r.rows:[new zr(r.numAffectedRows??BigInt(0),r.numChangedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=ve){const r=await this.executeTakeFirst();if(r===void 0)throw qe(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),i=this.#e.executor.stream(r,e);for await(const o of i)yield*o.rows}async explain(e,r){return await new p({...this.#e,queryNode:u.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}const St=n({is(t){return t.kind==="CommonTableExpressionNameNode"},create(t,e){return n({kind:"CommonTableExpressionNameNode",table:D.create(t),columns:e?n(e.map(_.create)):void 0})}}),$e=n({is(t){return t.kind==="CommonTableExpressionNode"},create(t,e){return n({kind:"CommonTableExpressionNode",name:t,expression:e})},cloneWith(t,e){return n({...t,...e})}});class je{#e;constructor(e){this.#e=n(e)}materialized(){return new je({...this.#e,node:$e.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new je({...this.#e,node:$e.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function Rt(t,e){const r=e(un()).toOperationNode();return $(t)?t(Gr(r)).toOperationNode():$e.create(or(t),r)}function Gr(t){return e=>new je({node:$e.create(or(e),t)})}function or(t){if(t.includes("(")){const e=t.split(/[\(\)]/),r=e[0],i=e[1].split(",").map(o=>o.trim());return St.create(r,i)}else return St.create(t)}const Pe=n({is(t){return t.kind==="WithNode"},create(t,e){return n({kind:"WithNode",expressions:n([t]),...e})},cloneWithExpression(t,e){return n({...t,expressions:n([...t.expressions,e])})}}),At=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Kr(t){let e="";for(let r=0;r<t;++r)e+=Hr();return e}function Hr(){return At[~~(Math.random()*At.length)]}function b(){return new Yr}class Yr{#e;get queryId(){return this.#e===void 0&&(this.#e=Kr(8)),this.#e}}class Xr{nodeStack=[];#e=n({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,r){if(!e)return e;this.nodeStack.push(e);const i=this.transformNodeImpl(e,r);return this.nodeStack.pop(),n(i)}transformNodeImpl(e,r){return this.#e[e.kind](e,r)}transformNodeList(e,r){return e&&n(e.map(i=>this.transformNode(i,r)))}transformSelectQuery(e,r){return{kind:"SelectQueryNode",from:this.transformNode(e.from,r),selections:this.transformNodeList(e.selections,r),distinctOn:this.transformNodeList(e.distinctOn,r),joins:this.transformNodeList(e.joins,r),groupBy:this.transformNode(e.groupBy,r),orderBy:this.transformNode(e.orderBy,r),where:this.transformNode(e.where,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),limit:this.transformNode(e.limit,r),offset:this.transformNode(e.offset,r),with:this.transformNode(e.with,r),having:this.transformNode(e.having,r),explain:this.transformNode(e.explain,r),setOperations:this.transformNodeList(e.setOperations,r),fetch:this.transformNode(e.fetch,r),top:this.transformNode(e.top,r)}}transformSelection(e,r){return{kind:"SelectionNode",selection:this.transformNode(e.selection,r)}}transformColumn(e,r){return{kind:"ColumnNode",column:this.transformNode(e.column,r)}}transformAlias(e,r){return{kind:"AliasNode",node:this.transformNode(e.node,r),alias:this.transformNode(e.alias,r)}}transformTable(e,r){return{kind:"TableNode",table:this.transformNode(e.table,r)}}transformFrom(e,r){return{kind:"FromNode",froms:this.transformNodeList(e.froms,r)}}transformReference(e,r){return{kind:"ReferenceNode",column:this.transformNode(e.column,r),table:this.transformNode(e.table,r)}}transformAnd(e,r){return{kind:"AndNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)}}transformOr(e,r){return{kind:"OrNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)}}transformValueList(e,r){return{kind:"ValueListNode",values:this.transformNodeList(e.values,r)}}transformParens(e,r){return{kind:"ParensNode",node:this.transformNode(e.node,r)}}transformJoin(e,r){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,r),on:this.transformNode(e.on,r)}}transformRaw(e,r){return{kind:"RawNode",sqlFragments:n([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,r)}}transformWhere(e,r){return{kind:"WhereNode",where:this.transformNode(e.where,r)}}transformInsertQuery(e,r){return{kind:"InsertQueryNode",into:this.transformNode(e.into,r),columns:this.transformNodeList(e.columns,r),values:this.transformNode(e.values,r),returning:this.transformNode(e.returning,r),onConflict:this.transformNode(e.onConflict,r),onDuplicateKey:this.transformNode(e.onDuplicateKey,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),ignore:e.ignore,orAction:this.transformNode(e.orAction,r),replace:e.replace,explain:this.transformNode(e.explain,r),defaultValues:e.defaultValues,top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)}}transformValues(e,r){return{kind:"ValuesNode",values:this.transformNodeList(e.values,r)}}transformDeleteQuery(e,r){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,r),using:this.transformNode(e.using,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orderBy:this.transformNode(e.orderBy,r),limit:this.transformNode(e.limit,r),explain:this.transformNode(e.explain,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)}}transformReturning(e,r){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,r)}}transformCreateTable(e,r){return{kind:"CreateTableNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),constraints:this.transformNodeList(e.constraints,r),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),selectQuery:this.transformNode(e.selectQuery,r)}}transformColumnDefinition(e,r){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),references:this.transformNode(e.references,r),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,r),check:this.transformNode(e.check,r),generated:this.transformNode(e.generated,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,r){return{kind:"AddColumnNode",column:this.transformNode(e.column,r)}}transformDropTable(e,r){return{kind:"DropTableNode",table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,r){return{kind:"OrderByNode",items:this.transformNodeList(e.items,r)}}transformOrderByItem(e,r){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,r),direction:this.transformNode(e.direction,r),collation:this.transformNode(e.collation,r),nulls:e.nulls}}transformGroupBy(e,r){return{kind:"GroupByNode",items:this.transformNodeList(e.items,r)}}transformGroupByItem(e,r){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,r)}}transformUpdateQuery(e,r){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,r),from:this.transformNode(e.from,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),updates:this.transformNodeList(e.updates,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),explain:this.transformNode(e.explain,r),limit:this.transformNode(e.limit,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r),orderBy:this.transformNode(e.orderBy,r)}}transformColumnUpdate(e,r){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,r),value:this.transformNode(e.value,r)}}transformLimit(e,r){return{kind:"LimitNode",limit:this.transformNode(e.limit,r)}}transformOffset(e,r){return{kind:"OffsetNode",offset:this.transformNode(e.offset,r)}}transformOnConflict(e,r){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,r),constraint:this.transformNode(e.constraint,r),indexExpression:this.transformNode(e.indexExpression,r),indexWhere:this.transformNode(e.indexWhere,r),updates:this.transformNodeList(e.updates,r),updateWhere:this.transformNode(e.updateWhere,r),doNothing:e.doNothing}}transformOnDuplicateKey(e,r){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,r)}}transformCreateIndex(e,r){return{kind:"CreateIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,r),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,r){return{kind:"ListNode",items:this.transformNodeList(e.items,r)}}transformDropIndex(e,r){return{kind:"DropIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,r){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,r){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,r){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,r),references:this.transformNode(e.references,r),name:this.transformNode(e.name,r),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,r){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,r),all:e.all}}transformReferences(e,r){return{kind:"ReferencesNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,r){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,r),name:this.transformNode(e.name,r)}}transformWith(e,r){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,r),recursive:e.recursive}}transformCommonTableExpression(e,r){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,r),materialized:e.materialized,expression:this.transformNode(e.expression,r)}}transformCommonTableExpressionName(e,r){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r)}}transformHaving(e,r){return{kind:"HavingNode",having:this.transformNode(e.having,r)}}transformCreateSchema(e,r){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,r),ifNotExists:e.ifNotExists}}transformDropSchema(e,r){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,r),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,r){return{kind:"AlterTableNode",table:this.transformNode(e.table,r),renameTo:this.transformNode(e.renameTo,r),setSchema:this.transformNode(e.setSchema,r),columnAlterations:this.transformNodeList(e.columnAlterations,r),addConstraint:this.transformNode(e.addConstraint,r),dropConstraint:this.transformNode(e.dropConstraint,r),renameConstraint:this.transformNode(e.renameConstraint,r),addIndex:this.transformNode(e.addIndex,r),dropIndex:this.transformNode(e.dropIndex,r)}}transformDropColumn(e,r){return{kind:"DropColumnNode",column:this.transformNode(e.column,r)}}transformRenameColumn(e,r){return{kind:"RenameColumnNode",column:this.transformNode(e.column,r),renameTo:this.transformNode(e.renameTo,r)}}transformAlterColumn(e,r){return{kind:"AlterColumnNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),dataTypeExpression:this.transformNode(e.dataTypeExpression,r),setDefault:this.transformNode(e.setDefault,r),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,r){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,r)}}transformAddConstraint(e,r){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,r)}}transformDropConstraint(e,r){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,r),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,r){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,r),newName:this.transformNode(e.newName,r)}}transformCreateView(e,r){return{kind:"CreateViewNode",name:this.transformNode(e.name,r),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,r),as:this.transformNode(e.as,r)}}transformRefreshMaterializedView(e,r){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,r),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,r){return{kind:"DropViewNode",name:this.transformNode(e.name,r),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,r){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,r)}}transformDefaultValue(e,r){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,r)}}transformOn(e,r){return{kind:"OnNode",on:this.transformNode(e.on,r)}}transformSelectModifier(e,r){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,r),of:this.transformNodeList(e.of,r)}}transformCreateType(e,r){return{kind:"CreateTypeNode",name:this.transformNode(e.name,r),enum:this.transformNode(e.enum,r)}}transformDropType(e,r){return{kind:"DropTypeNode",name:this.transformNode(e.name,r),ifExists:e.ifExists}}transformExplain(e,r){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,r)}}transformSchemableIdentifier(e,r){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,r),identifier:this.transformNode(e.identifier,r)}}transformAggregateFunction(e,r){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,r),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,r),withinGroup:this.transformNode(e.withinGroup,r),filter:this.transformNode(e.filter,r),over:this.transformNode(e.over,r)}}transformOver(e,r){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,r),partitionBy:this.transformNode(e.partitionBy,r)}}transformPartitionBy(e,r){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,r)}}transformPartitionByItem(e,r){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,r)}}transformBinaryOperation(e,r){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,r),operator:this.transformNode(e.operator,r),rightOperand:this.transformNode(e.rightOperand,r)}}transformUnaryOperation(e,r){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,r),operand:this.transformNode(e.operand,r)}}transformUsing(e,r){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,r)}}transformFunction(e,r){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,r)}}transformCase(e,r){return{kind:"CaseNode",value:this.transformNode(e.value,r),when:this.transformNodeList(e.when,r),else:this.transformNode(e.else,r),isStatement:e.isStatement}}transformWhen(e,r){return{kind:"WhenNode",condition:this.transformNode(e.condition,r),result:this.transformNode(e.result,r)}}transformJSONReference(e,r){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,r),traversal:this.transformNode(e.traversal,r)}}transformJSONPath(e,r){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,r),pathLegs:this.transformNodeList(e.pathLegs,r)}}transformJSONPathLeg(e,r){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,r){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,r),values:this.transformNodeList(e.values,r)}}transformTuple(e,r){return{kind:"TupleNode",values:this.transformNodeList(e.values,r)}}transformMergeQuery(e,r){return{kind:"MergeQueryNode",into:this.transformNode(e.into,r),using:this.transformNode(e.using,r),whens:this.transformNodeList(e.whens,r),with:this.transformNode(e.with,r),top:this.transformNode(e.top,r),endModifiers:this.transformNodeList(e.endModifiers,r),output:this.transformNode(e.output,r),returning:this.transformNode(e.returning,r)}}transformMatched(e,r){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,r){return{kind:"AddIndexNode",name:this.transformNode(e.name,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists}}transformCast(e,r){return{kind:"CastNode",expression:this.transformNode(e.expression,r),dataType:this.transformNode(e.dataType,r)}}transformFetch(e,r){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,r),modifier:e.modifier}}transformTop(e,r){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,r){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,r)}}transformDataType(e,r){return e}transformSelectAll(e,r){return e}transformIdentifier(e,r){return e}transformValue(e,r){return e}transformPrimitiveValueList(e,r){return e}transformOperator(e,r){return e}transformDefaultInsertValue(e,r){return e}transformOrAction(e,r){return e}transformCollate(e,r){return e}}const Zr=n({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),Qr={json_agg:!0,to_json:!0};class en extends Xr{#e;#t=new Set;#r=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,r){if(!this.#s(e))return super.transformNodeImpl(e,r);const i=this.#i(e);for(const a of i)this.#r.add(a);const o=this.#c(e);for(const a of o)this.#t.add(a);const s=super.transformNodeImpl(e,r);for(const a of o)this.#t.delete(a);for(const a of i)this.#r.delete(a);return s}transformSchemableIdentifier(e,r){const i=super.transformSchemableIdentifier(e,r);return i.schema||!this.#t.has(e.identifier.name)?i:{...i,schema:k.create(this.#e)}}transformReferences(e,r){const i=super.transformReferences(e,r);return i.table.table.schema?i:{...i,table:D.createWithSchema(this.#e,i.table.table.identifier.name)}}transformAggregateFunction(e,r){return{...super.transformAggregateFunction({...e,aggregated:[]},r),aggregated:this.#n(e,r,"aggregated")}}transformFunction(e,r){return{...super.transformFunction({...e,arguments:[]},r),arguments:this.#n(e,r,"arguments")}}transformSelectModifier(e,r){return{...super.transformSelectModifier({...e,of:void 0},r),of:e.of?.map(i=>D.is(i)&&!i.table.schema?{...i,table:this.transformIdentifier(i.table.identifier,r)}:this.transformNode(i,r))}}#n(e,r,i){return Qr[e.func]?e[i].map(o=>!D.is(o)||o.table.schema?this.transformNode(o,r):{...o,table:this.transformIdentifier(o.table.identifier,r)}):this.transformNodeList(e[i],r)}#s(e){return e.kind in Zr}#c(e){const r=new Set;if("name"in e&&e.name&&et.is(e.name)&&this.#a(e.name,r),"from"in e&&e.from)for(const i of e.from.froms)this.#o(i,r);if("into"in e&&e.into&&this.#o(e.into,r),"table"in e&&e.table&&this.#o(e.table,r),"joins"in e&&e.joins)for(const i of e.joins)this.#o(i.table,r);return"using"in e&&e.using&&(ne.is(e.using)?this.#o(e.using.table,r):this.#o(e.using,r)),r}#i(e){const r=new Set;return"with"in e&&e.with&&this.#d(e.with,r),r}#o(e,r){if(D.is(e))return this.#a(e.table,r);if(G.is(e)&&D.is(e.node))return this.#a(e.node.table,r);if(rr.is(e)){for(const i of e.items)this.#o(i,r);return}if(nt.is(e)){for(const i of e.tables)this.#o(i,r);return}}#a(e,r){const i=e.identifier.name;!this.#t.has(i)&&!this.#r.has(i)&&r.add(i)}#d(e,r){for(const i of e.expressions){const o=i.name.table.table.identifier.name;this.#r.has(o)||r.add(o)}}}class mt{#e;constructor(e){this.#e=new en(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}const tn=n({is(t){return t.kind==="MatchedNode"},create(t,e=!1){return n({kind:"MatchedNode",not:t,bySource:e})}});function Mt(t,e,r){return Me.create(_e([tn.create(!t.isMatched,t.bySource),...e&&e.length>0?[e.length===3&&r?U(e[0],e[1],e[2]):C(e)]:[]],"and",!1))}function Ce(t){return v(t)?O.create([t],[]):S(t)?t.toOperationNode():t}class vt{#e;#t;#r;constructor(){this.#e=new Promise((e,r)=>{this.#r=r,this.#t=e})}get promise(){return this.#e}resolve=e=>{this.#t&&this.#t(e)};reject=e=>{this.#r&&this.#r(e)}}async function rn(t){const e=new vt,r=new vt;return t.provideConnection(async i=>(e.resolve(i),await r.promise)).catch(i=>e.reject(i)),n({connection:await e.promise,release:r.resolve})}const nn=n([]);class on{#e;constructor(e=nn){this.#e=e}get plugins(){return this.#e}transformQuery(e,r){for(const i of this.#e){const o=i.transformQuery({node:e,queryId:r});if(o.kind===e.kind)e=o;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${o.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async r=>{const i=await r.executeQuery(e);return"numUpdatedOrDeletedRows"in i&&ze("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#t(i,e.queryId)})}async*stream(e,r){const{connection:i,release:o}=await rn(this);try{for await(const s of i.streamQuery(e,r))yield await this.#t(s,e.queryId)}finally{o()}}async#t(e,r){for(const i of this.#e)e=await i.transformResult({result:e,queryId:r});return e}}class ue extends on{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new ue([...this.plugins,e])}withPlugins(e){return new ue([...this.plugins,...e])}withPluginAtFront(e){return new ue([e,...this.plugins])}withoutPlugins(){return new ue([])}}const Ge=new ue;class sn{numChangedRows;constructor(e){this.numChangedRows=e}}class H{#e;constructor(e){this.#e=n(e)}modifyEnd(e){return new H({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new H({...this.#e,queryNode:u.cloneWithTop(this.#e.queryNode,pe(e,r))})}using(...e){return new W({...this.#e,queryNode:F.cloneWithUsing(this.#e.queryNode,Ke("Using",e))})}returning(e){return new H({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,q(e))})}returningAll(e){return new H({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,L(e))})}output(e){return new H({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,q(e))})}outputAll(e){return new H({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,L(e))})}}class W{#e;constructor(e){this.#e=n(e)}modifyEnd(e){return new W({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new W({...this.#e,queryNode:u.cloneWithTop(this.#e.queryNode,pe(e,r))})}whenMatched(){return this.#t([])}whenMatchedAnd(...e){return this.#t(e)}whenMatchedAndRef(e,r,i){return this.#t([e,r,i],!0)}#t(e,r){return new qt({...this.#e,queryNode:F.cloneWithWhen(this.#e.queryNode,Mt({isMatched:!0},e,r))})}whenNotMatched(){return this.#r([])}whenNotMatchedAnd(...e){return this.#r(e)}whenNotMatchedAndRef(e,r,i){return this.#r([e,r,i],!0)}whenNotMatchedBySource(){return this.#r([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#r(e,!1,!0)}whenNotMatchedBySourceAndRef(e,r,i){return this.#r([e,r,i],!0,!0)}returning(e){return new W({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,q(e))})}returningAll(e){return new W({...this.#e,queryNode:u.cloneWithReturning(this.#e.queryNode,L(e))})}output(e){return new W({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,q(e))})}outputAll(e){return new W({...this.#e,queryNode:u.cloneWithOutput(this.#e.queryNode,L(e))})}#r(e,r=!1,i=!1){const o={...this.#e,queryNode:F.cloneWithWhen(this.#e.queryNode,Mt({isMatched:!1,bySource:i},e,r))},s=i?qt:an;return new s(o)}$call(e){return e(this)}$if(e,r){return e?r(this):new W({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile(),r=await this.#e.executor.executeQuery(e),{adapter:i}=this.#e.executor,o=e.query;return o.returning&&i.supportsReturning||o.output&&i.supportsOutput?r.rows:[new sn(r.numAffectedRows)]}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=ve){const r=await this.executeTakeFirst();if(r===void 0)throw qe(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}}class qt{#e;constructor(e){this.#e=n(e)}thenDelete(){return new W({...this.#e,queryNode:F.cloneWithThen(this.#e.queryNode,Ce("delete"))})}thenDoNothing(){return new W({...this.#e,queryNode:F.cloneWithThen(this.#e.queryNode,Ce("do nothing"))})}thenUpdate(e){return new W({...this.#e,queryNode:F.cloneWithThen(this.#e.queryNode,Ce(e(new p({queryId:this.#e.queryId,executor:Ge,queryNode:ce.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(r=>r.set(...e))}}class an{#e;constructor(e){this.#e=n(e)}thenDoNothing(){return new W({...this.#e,queryNode:F.cloneWithThen(this.#e.queryNode,Ce("do nothing"))})}thenInsertValues(e){const[r,i]=nr(e);return new W({...this.#e,queryNode:F.cloneWithThen(this.#e.queryNode,Ce(g.cloneWith(g.createWithoutInto(),{columns:r,values:i})))})}}class te{#e;constructor(e){this.#e=n(e)}selectFrom(e){return it({queryId:b(),executor:this.#e.executor,queryNode:f.createFrom(de(e),this.#e.withNode)})}selectNoFrom(e){return it({queryId:b(),executor:this.#e.executor,queryNode:f.cloneWithSelections(f.create(this.#e.withNode),q(e))})}insertInto(e){return new l({queryId:b(),executor:this.#e.executor,queryNode:g.create(E(e),this.#e.withNode)})}replaceInto(e){return new l({queryId:b(),executor:this.#e.executor,queryNode:g.create(E(e),this.#e.withNode,!0)})}deleteFrom(e){return new N({queryId:b(),executor:this.#e.executor,queryNode:ge.create(de(e),this.#e.withNode)})}updateTable(e){return new p({queryId:b(),executor:this.#e.executor,queryNode:ce.create(de(e),this.#e.withNode)})}mergeInto(e){return new H({queryId:b(),executor:this.#e.executor,queryNode:F.create(ur(e),this.#e.withNode)})}with(e,r){const i=Rt(e,r);return new te({...this.#e,withNode:this.#e.withNode?Pe.cloneWithExpression(this.#e.withNode,i):Pe.create(i)})}withRecursive(e,r){const i=Rt(e,r);return new te({...this.#e,withNode:this.#e.withNode?Pe.cloneWithExpression(this.#e.withNode,i):Pe.create(i,{recursive:!0})})}withPlugin(e){return new te({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new te({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new te({...this.#e,executor:this.#e.executor.withPluginAtFront(new mt(e))})}}function un(){return new te({executor:Ge})}function cn(t,e){return new xe({joinNode:ne.create(t,Ae(e))})}function dn(){return new Oe({overNode:rt.create()})}function Ke(t,e){if(e.length===3)return ln(t,e[0],e[1],e[2]);if(e.length===2)return hn(t,e[0],e[1]);if(e.length===1)return mn(t,e[0]);throw new Error("not implemented")}function hn(t,e,r){return r(cn(t,e)).toOperationNode()}function ln(t,e,r,i){return ne.createWithOn(t,Ae(e),U(r,"=",i))}function mn(t,e){return ne.create(t,Ae(e))}const fn=n({is(t){return t.kind==="OffsetNode"},create(t){return n({kind:"OffsetNode",offset:t})}}),pn=n({is(t){return t.kind==="GroupByItemNode"},create(t){return n({kind:"GroupByItemNode",groupBy:t})}});function Nn(t){return t=$(t)?t(Ne()):t,Ee(t).map(pn.create)}const wn=n({is(t){return t.kind==="SetOperationNode"},create(t,e,r){return n({kind:"SetOperationNode",operator:t,expression:e,all:r})}});function ae(t,e,r){return $(e)&&(e=e(pt())),z(e)||(e=[e]),e.map(i=>wn.create(t,Le(i),r))}class m{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new ft(this,e)}or(...e){return new Je(fe.create(this.#e,C(e)))}and(...e){return new Be(X.create(this.#e,C(e)))}$castTo(){return new m(this.#e)}$notNull(){return new m(this.#e)}toOperationNode(){return this.#e}}class ft{#e;#t;constructor(e,r){this.#e=e,this.#t=r}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return G.create(this.#e.toOperationNode(),S(this.#t)?this.#t.toOperationNode():k.create(this.#t))}}class Je{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new ft(this,e)}or(...e){return new Je(fe.create(this.#e,C(e)))}$castTo(){return new Je(this.#e)}toOperationNode(){return Se.create(this.#e)}}class Be{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new ft(this,e)}and(...e){return new Be(X.create(this.#e,C(e)))}$castTo(){return new Be(this.#e)}toOperationNode(){return Se.create(this.#e)}}const yn=n({is(t){return t.kind==="FetchNode"},create(t,e){return{kind:"FetchNode",rowCount:Q.create(t),modifier:e}}});function gn(t,e){if(!st(t)&&!Bt(t))throw new Error(`Invalid fetch row count: ${t}`);if(!xn(e))throw new Error(`Invalid fetch modifier: ${e}`);return yn.create(t,e)}function xn(t){return t==="only"||t==="with ties"}class d{#e;constructor(e){this.#e=n(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new d({...this.#e,queryNode:u.cloneWithWhere(this.#e.queryNode,C(e))})}whereRef(e,r,i){return new d({...this.#e,queryNode:u.cloneWithWhere(this.#e.queryNode,U(e,r,i))})}having(...e){return new d({...this.#e,queryNode:f.cloneWithHaving(this.#e.queryNode,C(e))})}havingRef(e,r,i){return new d({...this.#e,queryNode:f.cloneWithHaving(this.#e.queryNode,U(e,r,i))})}select(e){return new d({...this.#e,queryNode:f.cloneWithSelections(this.#e.queryNode,q(e))})}distinctOn(e){return new d({...this.#e,queryNode:f.cloneWithDistinctOn(this.#e.queryNode,Ee(e))})}modifyFront(e){return new d({...this.#e,queryNode:f.cloneWithFrontModifier(this.#e.queryNode,j.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.createWithExpression(e.toOperationNode()))})}distinct(){return new d({...this.#e,queryNode:f.cloneWithFrontModifier(this.#e.queryNode,j.create("Distinct"))})}forUpdate(e){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.create("ForUpdate",e?De(e).map(E):void 0))})}forShare(e){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.create("ForShare",e?De(e).map(E):void 0))})}forKeyShare(e){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.create("ForKeyShare",e?De(e).map(E):void 0))})}forNoKeyUpdate(e){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.create("ForNoKeyUpdate",e?De(e).map(E):void 0))})}skipLocked(){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.create("SkipLocked"))})}noWait(){return new d({...this.#e,queryNode:u.cloneWithEndModifier(this.#e.queryNode,j.create("NoWait"))})}selectAll(e){return new d({...this.#e,queryNode:f.cloneWithSelections(this.#e.queryNode,L(e))})}innerJoin(...e){return this.#t("InnerJoin",e)}leftJoin(...e){return this.#t("LeftJoin",e)}rightJoin(...e){return this.#t("RightJoin",e)}fullJoin(...e){return this.#t("FullJoin",e)}crossJoin(...e){return this.#t("CrossJoin",e)}innerJoinLateral(...e){return this.#t("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#t("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#t("LateralCrossJoin",e)}crossApply(...e){return this.#t("CrossApply",e)}outerApply(...e){return this.#t("OuterApply",e)}#t(e,r){return new d({...this.#e,queryNode:u.cloneWithJoin(this.#e.queryNode,Ke(e,r))})}orderBy(...e){return new d({...this.#e,queryNode:u.cloneWithOrderByItems(this.#e.queryNode,oe(e))})}groupBy(e){return new d({...this.#e,queryNode:f.cloneWithGroupByItems(this.#e.queryNode,Nn(e))})}limit(e){return new d({...this.#e,queryNode:f.cloneWithLimit(this.#e.queryNode,lt.create(w(e)))})}offset(e){return new d({...this.#e,queryNode:f.cloneWithOffset(this.#e.queryNode,fn.create(w(e)))})}fetch(e,r="only"){return new d({...this.#e,queryNode:f.cloneWithFetch(this.#e.queryNode,gn(e,r))})}top(e,r){return new d({...this.#e,queryNode:u.cloneWithTop(this.#e.queryNode,pe(e,r))})}union(e){return new d({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,ae("union",e,!1))})}unionAll(e){return new d({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,ae("union",e,!0))})}intersect(e){return new d({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,ae("intersect",e,!1))})}intersectAll(e){return new d({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,ae("intersect",e,!0))})}except(e){return new d({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,ae("except",e,!1))})}exceptAll(e){return new d({...this.#e,queryNode:f.cloneWithSetOperations(this.#e.queryNode,ae("except",e,!0))})}as(e){return new On(this,e)}clearSelect(){return new d({...this.#e,queryNode:f.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new d({...this.#e,queryNode:u.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new d({...this.#e,queryNode:f.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new d({...this.#e,queryNode:f.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new d({...this.#e,queryNode:u.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new d({...this.#e,queryNode:f.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){return e?r(this):new d({...this.#e})}$castTo(){return new d(this.#e)}$narrowType(){return new d(this.#e)}$assertType(){return new d(this.#e)}$asTuple(){return new m(this.toOperationNode())}$asScalar(){return new m(this.toOperationNode())}withPlugin(e){return new d({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){const e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){const[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=ve){const r=await this.executeTakeFirst();if(r===void 0)throw qe(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){const r=this.compile(),i=this.#e.executor.stream(r,e);for await(const o of i)yield*o.rows}async explain(e,r){return await new d({...this.#e,queryNode:u.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}function it(t){return new d(t)}class On{#e;#t;constructor(e,r){this.#e=e,this.#t=r}get expression(){return this.#e}get alias(){return this.#t}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return G.create(this.#e.toOperationNode(),k.create(this.#t))}}const Y=n({is(t){return t.kind==="AggregateFunctionNode"},create(t,e=[]){return n({kind:"AggregateFunctionNode",func:t,aggregated:e})},cloneWithDistinct(t){return n({...t,distinct:!0})},cloneWithOrderBy(t,e,r=!1){const i=r?"withinGroup":"orderBy";return n({...t,[i]:t[i]?le.cloneWithItems(t[i],e):le.create(e)})},cloneWithFilter(t,e){return n({...t,filter:t.filter?T.cloneWithOperation(t.filter,"And",e):T.create(e)})},cloneWithOrFilter(t,e){return n({...t,filter:t.filter?T.cloneWithOperation(t.filter,"Or",e):T.create(e)})},cloneWithOver(t,e){return n({...t,over:e})}}),Lt=n({is(t){return t.kind==="FunctionNode"},create(t,e){return n({kind:"FunctionNode",func:t,arguments:e})}});class A{#e;constructor(e){this.#e=n(e)}get expressionType(){}as(e){return new bn(this,e)}distinct(){return new A({...this.#e,aggregateFunctionNode:Y.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new A({...this.#e,aggregateFunctionNode:u.cloneWithOrderByItems(this.#e.aggregateFunctionNode,oe(e))})}clearOrderBy(){return new A({...this.#e,aggregateFunctionNode:u.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new A({...this.#e,aggregateFunctionNode:Y.cloneWithOrderBy(this.#e.aggregateFunctionNode,oe(e),!0)})}filterWhere(...e){return new A({...this.#e,aggregateFunctionNode:Y.cloneWithFilter(this.#e.aggregateFunctionNode,C(e))})}filterWhereRef(e,r,i){return new A({...this.#e,aggregateFunctionNode:Y.cloneWithFilter(this.#e.aggregateFunctionNode,U(e,r,i))})}over(e){const r=dn();return new A({...this.#e,aggregateFunctionNode:Y.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}$castTo(){return new A(this.#e)}$notNull(){return new A(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class bn{#e;#t;constructor(e,r){this.#e=e,this.#t=r}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return G.create(this.#e.toOperationNode(),k.create(this.#t))}}function kn(){const t=(r,i)=>new m(Lt.create(r,Ee(i??[]))),e=(r,i)=>new A({aggregateFunctionNode:Y.create(r,i?Ee(i):void 0)});return Object.assign(t,{agg:e,avg(r){return e("avg",[r])},coalesce(...r){return t("coalesce",r)},count(r){return e("count",[r])},countAll(r){return new A({aggregateFunctionNode:Y.create("count",L(r))})},max(r){return e("max",[r])},min(r){return e("min",[r])},sum(r){return e("sum",[r])},any(r){return t("any",[r])},jsonAgg(r){return new A({aggregateFunctionNode:Y.create("json_agg",[v(r)?E(r):r.toOperationNode()])})},toJson(r){return new m(Lt.create("to_json",[v(r)?E(r):r.toOperationNode()]))}})}const Cn=n({is(t){return t.kind==="UnaryOperationNode"},create(t,e){return n({kind:"UnaryOperationNode",operator:t,operand:e})}});function Tn(t,e){return Cn.create(ie.create(t),M(e))}const V=n({is(t){return t.kind==="CaseNode"},create(t){return n({kind:"CaseNode",value:t})},cloneWithWhen(t,e){return n({...t,when:n(t.when?[...t.when,e]:[e])})},cloneWithThen(t,e){return n({...t,when:t.when?n([...t.when.slice(0,-1),Me.cloneWithResult(t.when[t.when.length-1],e)]):void 0})},cloneWith(t,e){return n({...t,...e})}});class Wn{#e;constructor(e){this.#e=n(e)}when(...e){return new sr({...this.#e,node:V.cloneWithWhen(this.#e.node,Me.create(C(e)))})}}class sr{#e;constructor(e){this.#e=n(e)}then(e){return new En({...this.#e,node:V.cloneWithThen(this.#e.node,ut(e)?ct(e):w(e))})}}class En{#e;constructor(e){this.#e=n(e)}when(...e){return new sr({...this.#e,node:V.cloneWithWhen(this.#e.node,Me.create(C(e)))})}else(e){return new Sn({...this.#e,node:V.cloneWith(this.#e.node,{else:ut(e)?ct(e):w(e)})})}end(){return new m(V.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new m(V.cloneWith(this.#e.node,{isStatement:!0}))}}class Sn{#e;constructor(e){this.#e=n(e)}end(){return new m(V.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new m(V.cloneWith(this.#e.node,{isStatement:!0}))}}const It=n({is(t){return t.kind==="JSONPathLegNode"},create(t,e){return n({kind:"JSONPathLegNode",type:t,value:e})}});class ot{#e;constructor(e){this.#e=e}at(e){return this.#t("ArrayLocation",e)}key(e){return this.#t("Member",e)}#t(e,r){return Fe.is(this.#e)?new Re(Fe.cloneWithTraversal(this.#e,ye.is(this.#e.traversal)?ye.cloneWithLeg(this.#e.traversal,It.create(e,r)):Xt.cloneWithValue(this.#e.traversal,Q.createImmediate(r)))):new Re(ye.cloneWithLeg(this.#e,It.create(e,r)))}}class Re extends ot{#e;constructor(e){super(e),this.#e=e}get expressionType(){}as(e){return new Rn(this,e)}$castTo(){return new Re(this.#e)}$notNull(){return new Re(this.#e)}toOperationNode(){return this.#e}}class Rn{#e;#t;constructor(e,r){this.#e=e,this.#t=r}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return G.create(this.#e.toOperationNode(),S(this.#t)?this.#t.toOperationNode():k.create(this.#t))}}const Dt=n({is(t){return t.kind==="TupleNode"},create(t){return n({kind:"TupleNode",values:n(t)})}}),An=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],Mn=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],vn=n({is(t){return t.kind==="DataTypeNode"},create(t){return n({kind:"DataTypeNode",dataType:t})}});function qn(t){return!!(An.includes(t)||Mn.some(e=>e.test(t)))}function Ln(t){if(S(t))return t.toOperationNode();if(qn(t))return vn.create(t);throw new Error(`invalid column data type ${JSON.stringify(t)}`)}const In=n({is(t){return t.kind==="CastNode"},create(t,e){return n({kind:"CastNode",expression:t,dataType:e})}});function pt(t=Ge){function e(o,s,a){return new m(dt(o,s,a))}function r(o,s){return new m(Tn(o,s))}const i=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(o){return it({queryId:b(),executor:t,queryNode:f.createFrom(de(o))})},case(o){return new Wn({node:V.create(re(o)?void 0:M(o))})},ref(o,s){return re(s)?new m(Z(o)):new ot(kr(o,s))},jsonPath(){return new ot(ye.create())},table(o){return new m(E(o))},val(o){return new m(w(o))},refTuple(...o){return new m(Dt.create(o.map(M)))},tuple(...o){return new m(Dt.create(o.map(w)))},lit(o){return new m(ct(o))},unary:r,not(o){return r("not",o)},exists(o){return r("exists",o)},neg(o){return r("-",o)},between(o,s,a){return new m(he.create(M(o),ie.create("between"),X.create(w(s),w(a))))},betweenSymmetric(o,s,a){return new m(he.create(M(o),ie.create("between symmetric"),X.create(w(s),w(a))))},and(o){return z(o)?new m(_e(o,"and")):new m(gt(o,"and"))},or(o){return z(o)?new m(_e(o,"or")):new m(gt(o,"or"))},parens(...o){const s=C(o);return Se.is(s)?new m(s):new m(Se.create(s))},cast(o,s){return new m(In.create(M(o),Ln(s)))},withSchema(o){return pt(t.withPluginAtFront(new mt(o)))}});return i.fn=kn(),i.eb=i,i}function Ne(t){return pt()}function Le(t){if(S(t))return t.toOperationNode();if($(t))return t(Ne()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(t)}`)}function ar(t){if(S(t))return t.toOperationNode();if($(t))return t(Ne()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(t)}`)}function Ie(t){return Vt(t)||fr(t)||$(t)}class qi{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Dn(this.#e,e)}}class Dn{#e;#t;get table(){return this.#e}get alias(){return this.#t}constructor(e,r){this.#e=e,this.#t=r}toOperationNode(){return G.create(E(this.#e),k.create(this.#t))}}function Pn(t){return me(t)&&S(t)&&v(t.table)&&v(t.alias)}function de(t){return z(t)?t.map(e=>Ae(e)):[Ae(t)]}function Ae(t){return v(t)?ur(t):Pn(t)?t.toOperationNode():ar(t)}function ur(t){const e=" as ";if(t.includes(e)){const[r,i]=t.split(e).map(cr);return G.create(E(r),k.create(i))}else return E(t)}function E(t){if(t.includes(".")){const[r,i]=t.split(".").map(cr);return D.createWithSchema(r,i)}else return D.create(t)}function cr(t){return t.trim()}class Te{#e;constructor(e){this.#e=n(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new Fn(this,e)}$castTo(){return new Te({...this.#e})}$notNull(){return new Te(this.#e)}withPlugin(e){return new Te({...this.#e,plugins:this.#e.plugins!==void 0?n([...this.#e.plugins,e]):n([e])})}toOperationNode(){return this.#r(this.#t())}compile(e){return this.#n(this.#t(e))}async execute(e){const r=this.#t(e);return r.executeQuery(this.#n(r))}#t(e){const r=e!==void 0?e.getExecutor():Ge;return this.#e.plugins!==void 0?r.withPlugins(this.#e.plugins):r}#r(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#n(e){return e.compileQuery(this.#r(e),this.#e.queryId)}}function K(t){return new Te(t)}class Fn{#e;#t;constructor(e,r){this.#e=e,this.#t=r}get expression(){return this.#e}get alias(){return this.#t}get rawBuilder(){return this.#e}toOperationNode(){return G.create(this.#e.toOperationNode(),S(this.#t)?this.#t.toOperationNode():k.create(this.#t))}}const y=Object.assign((t,...e)=>K({queryId:b(),rawNode:O.create(t,e?.map(Pt)??[])}),{ref(t){return K({queryId:b(),rawNode:O.createWithChild(Z(t))})},val(t){return K({queryId:b(),rawNode:O.createWithChild(w(t))})},value(t){return this.val(t)},table(t){return K({queryId:b(),rawNode:O.createWithChild(E(t))})},id(...t){const e=new Array(t.length+1).fill(".");return e[0]="",e[e.length-1]="",K({queryId:b(),rawNode:O.create(e,t.map(k.create))})},lit(t){return K({queryId:b(),rawNode:O.createWithChild(Q.createImmediate(t))})},literal(t){return this.lit(t)},raw(t){return K({queryId:b(),rawNode:O.createWithSql(t)})},join(t,e=y`, `){const r=new Array(Math.max(2*t.length-1,0)),i=e.toOperationNode();for(let o=0;o<t.length;++o)r[2*o]=Pt(t[o]),o!==t.length-1&&(r[2*o+1]=i);return K({queryId:b(),rawNode:O.createWithChildren(r)})}});function Pt(t){return S(t)?t.toOperationNode():w(t)}class _n{transformQuery(e){return e.node}async transformResult(e){return e.result}}const Un="kysely_migration",Ft="kysely_migration_lock",$n=!1,Xe="migration_lock";n({__noMigrations__:!0});class jn{#e;constructor(e){this.#e=n(e)}async getMigrations(){const r=await this.#u(this.#n)?await this.#e.db.withPlugin(this.#i).selectFrom(this.#n).select(["name","timestamp"]).$narrowType().execute():[];return(await this.#f()).map(({name:o,...s})=>{const a=r.find(c=>c.name===o);return{name:o,migration:s,executedAt:a?new Date(a.timestamp):void 0}})}async migrateToLatest(){return this.#t(()=>({direction:"Up",step:1/0}))}async migrateTo(e){return this.#t(({migrations:r,executedMigrations:i,pendingMigrations:o})=>{if(me(e)&&e.__noMigrations__===!0)return{direction:"Down",step:1/0};if(!r.find(c=>c.name===e))throw new Error(`migration "${e}" doesn't exist`);const s=i.indexOf(e),a=o.findIndex(c=>c.name===e);if(s!==-1)return{direction:"Down",step:i.length-s-1};if(a!==-1)return{direction:"Up",step:a+1};throw new Error(`migration "${e}" isn't executed or pending`)})}async migrateUp(){return this.#t(()=>({direction:"Up",step:1}))}async migrateDown(){return this.#t(()=>({direction:"Down",step:1}))}async#t(e){try{return await this.#o(),await this.#a(),await this.#d(),await this.#p(),await this.#N(e)}catch(r){return r instanceof Ze?r.resultSet:{error:r}}}get#r(){return this.#e.migrationTableSchema}get#n(){return this.#e.migrationTableName??Un}get#s(){return this.#e.migrationLockTableName??Ft}get#c(){return this.#e.allowUnorderedMigrations??$n}get#i(){return this.#r?new mt(this.#r):new _n}async#o(){if(!(!this.#r||await this.#l()))try{await this.#h(this.#e.db.schema.createSchema(this.#r))}catch(r){if(!await this.#l())throw r}}async#a(){if(!await this.#u(this.#n))try{await this.#h(this.#e.db.schema.withPlugin(this.#i).createTable(this.#n).addColumn("name","varchar(255)",r=>r.notNull().primaryKey()).addColumn("timestamp","varchar(255)",r=>r.notNull()))}catch(r){if(!await this.#u(this.#n))throw r}}async#d(){if(!await this.#u(this.#s))try{await this.#h(this.#e.db.schema.withPlugin(this.#i).createTable(this.#s).addColumn("id","varchar(255)",r=>r.notNull().primaryKey()).addColumn("is_locked","integer",r=>r.notNull().defaultTo(0)))}catch(r){if(!await this.#u(this.#s))throw r}}async#p(){if(!await this.#m())try{await this.#e.db.withPlugin(this.#i).insertInto(this.#s).values({id:Xe,is_locked:0}).execute()}catch(r){if(!await this.#m())throw r}}async#l(){return(await this.#e.db.introspection.getSchemas()).some(r=>r.name===this.#r)}async#u(e){const r=this.#r;return(await this.#e.db.introspection.getTables({withInternalKyselyTables:!0})).some(o=>o.name===e&&(!r||o.schema===r))}async#m(){return!!await this.#e.db.withPlugin(this.#i).selectFrom(this.#s).where("id","=",Xe).select("id").executeTakeFirst()}async#N(e){const r=this.#e.db.getExecutor().adapter,i=n({lockTable:this.#e.migrationLockTableName??Ft,lockRowId:Xe,lockTableSchema:this.#e.migrationTableSchema}),o=async s=>{try{await r.acquireMigrationLock(s,i);const a=await this.#w(s);if(a.migrations.length===0)return{results:[]};const{direction:c,step:h}=e(a);return h<=0?{results:[]}:c==="Down"?await this.#b(s,a,h):c==="Up"?await this.#k(s,a,h):{results:[]}}finally{await r.releaseMigrationLock(s,i)}};return r.supportsTransactionalDdl&&!this.#e.disableTransactions?this.#e.db.transaction().execute(o):this.#e.db.connection().execute(o)}async#w(e){const r=await this.#f(),i=await this.#g(e);this.#x(r,i),this.#c||this.#O(r,i);const o=this.#y(r,i);return n({migrations:r,executedMigrations:i,lastMigration:mr(i),pendingMigrations:o})}#y(e,r){return e.filter(i=>!r.includes(i.name))}async#f(){const e=await this.#e.provider.getMigrations();return Object.keys(e).sort().map(r=>({...e[r],name:r}))}async#g(e){const r=await e.withPlugin(this.#i).selectFrom(this.#n).select(["name","timestamp"]).$narrowType().execute(),i=this.#e.nameComparator||((o,s)=>o.localeCompare(s));return r.sort((o,s)=>o.timestamp===s.timestamp?i(o.name,s.name):new Date(o.timestamp).getTime()-new Date(s.timestamp).getTime()).map(o=>o.name)}#x(e,r){for(const i of r)if(!e.some(o=>o.name===i))throw new Error(`corrupted migrations: previously executed migration ${i} is missing`)}#O(e,r){for(let i=0;i<r.length;++i)if(e[i].name!==r[i])throw new Error(`corrupted migrations: expected previously executed migration ${r[i]} to be at index ${i} but ${e[i].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)}async#b(e,r,i){const o=r.executedMigrations.slice().reverse().slice(0,i).map(a=>r.migrations.find(c=>c.name===a)),s=o.map(a=>({migrationName:a.name,direction:"Down",status:"NotExecuted"}));for(let a=0;a<s.length;++a){const c=o[a];try{c.down&&(await c.down(e),await e.withPlugin(this.#i).deleteFrom(this.#n).where("name","=",c.name).execute(),s[a]={migrationName:c.name,direction:"Down",status:"Success"})}catch(h){throw s[a]={migrationName:c.name,direction:"Down",status:"Error"},new Ze({error:h,results:s})}}return{results:s}}async#k(e,r,i){const s=r.pendingMigrations.slice(0,i).map(a=>({migrationName:a.name,direction:"Up",status:"NotExecuted"}));for(let a=0;a<s.length;a++){const c=r.pendingMigrations[a];try{await c.up(e),await e.withPlugin(this.#i).insertInto(this.#n).values({name:c.name,timestamp:new Date().toISOString()}).execute(),s[a]={migrationName:c.name,direction:"Up",status:"Success"}}catch(h){throw s[a]={migrationName:c.name,direction:"Up",status:"Error"},new Ze({error:h,results:s})}}return{results:s}}async#h(e){this.#e.db.getExecutor().adapter.supportsCreateIfNotExists&&(e=e.ifNotExists()),await e.execute()}}class Ze extends Error{#e;constructor(e){super(),this.#e=e}get resultSet(){return this.#e}}var _t;(function(t){t.CONNECT="connect",t.SWITCHBOARD="switchboard"})(_t||(_t={}));var P;(function(t){t[t.Unknown=-1]="Unknown",t[t.TransportPending=0]="TransportPending",t[t.ExecutionPending=1]="ExecutionPending",t[t.Applied=2]="Applied",t[t.Error=3]="Error"})(P||(P={}));var We;(function(t){t.None="none",t.Channel="channel",t.Inbox="inbox",t.Outbox="outbox"})(We||(We={}));const Li={SYNC_SUCCEEDED:20002,SYNC_FAILED:20003};class we extends Error{errors;constructor(e){const r=e.map(i=>i.message).join("; ");super(`Mailbox callback failed with ${e.length} error(s): ${r}`),this.name="MailboxAggregateError",this.errors=e}}class Ut{itemsMap=new Map;addedCallbacks=[];removedCallbacks=[];paused=!1;addedBuffer=[];removedBuffer=[];_ack=0;_latestOrdinal=0;init(e){this._ack=this._latestOrdinal=e}get items(){return Array.from(this.itemsMap.values())}get ackOrdinal(){return this._ack}get latestOrdinal(){return this._latestOrdinal}get(e){return this.itemsMap.get(e)}add(...e){for(const o of e){this.itemsMap.set(o.id,o);for(const s of o.operations)this._latestOrdinal=Math.max(this._latestOrdinal,s.context.ordinal);o.on((s,a,c)=>{if(c===P.Applied)for(const h of s.operations)this._ack=Math.max(this._ack,h.context.ordinal)})}if(this.paused){this.addedBuffer.push(...e);return}const r=[...this.addedCallbacks],i=[];for(const o of r)try{o(e)}catch(s){i.push(s instanceof Error?s:new Error(String(s)))}if(i.length>0)throw new we(i)}remove(...e){for(const o of e)this.itemsMap.delete(o.id);if(this.paused){this.removedBuffer.push(...e);return}const r=[...this.removedCallbacks],i=[];for(const o of r)try{o(e)}catch(s){i.push(s instanceof Error?s:new Error(String(s)))}if(i.length>0)throw new we(i)}onAdded(e){this.addedCallbacks.push(e)}onRemoved(e){this.removedCallbacks.push(e)}pause(){this.paused=!0}resume(){this.paused=!1,this.flush()}flush(){if(this.addedBuffer.length>0){const e=this.addedBuffer.splice(0),r=[...this.addedCallbacks],i=[];for(const o of r)try{o(e)}catch(s){i.push(s instanceof Error?s:new Error(String(s)))}if(i.length>0)throw new we(i)}if(this.removedBuffer.length>0){const e=this.removedBuffer.splice(0),r=[...this.removedCallbacks],i=[];for(const o of r)try{o(e)}catch(s){i.push(s instanceof Error?s:new Error(String(s)))}if(i.length>0)throw new we(i)}}isPaused(){return this.paused}}class Jn{itemsMap=new Map;addedCallbacks=[];removedCallbacks=[];addedBuffer=[];removedBuffer=[];addedTimer=null;removedTimer=null;milliseconds;maxQueued;paused=!1;_ack=0;_latestOrdinal=0;constructor(e,r){this.milliseconds=e,this.maxQueued=r}init(e){this._ack=this._latestOrdinal=e}get items(){return Array.from(this.itemsMap.values())}get ackOrdinal(){return this._ack}get latestOrdinal(){return this._latestOrdinal}get(e){return this.itemsMap.get(e)}add(...e){for(const r of e){this.itemsMap.set(r.id,r);for(const i of r.operations)this._latestOrdinal=Math.max(this._latestOrdinal,i.context.ordinal);r.on((i,o,s)=>{if(s===P.Applied)for(const a of i.operations)this._ack=Math.max(this._ack,a.context.ordinal)})}this.addedBuffer.push(...e),!this.paused&&(this.addedBuffer.length>=this.maxQueued?this.flushAdded():this.scheduleAddedFlush())}remove(...e){for(const r of e)this.itemsMap.delete(r.id);this.removedBuffer.push(...e),!this.paused&&(this.removedBuffer.length>=this.maxQueued?this.flushRemoved():this.scheduleRemovedFlush())}onAdded(e){this.addedCallbacks.push(e)}onRemoved(e){this.removedCallbacks.push(e)}pause(){this.paused=!0,this.addedTimer!==null&&(clearTimeout(this.addedTimer),this.addedTimer=null),this.removedTimer!==null&&(clearTimeout(this.removedTimer),this.removedTimer=null)}resume(){this.paused=!1,this.addedBuffer.length>0&&this.scheduleAddedFlush(),this.removedBuffer.length>0&&this.scheduleRemovedFlush()}isPaused(){return this.paused}flush(){this.flushAdded(),this.flushRemoved()}scheduleAddedFlush(){this.addedTimer!==null&&clearTimeout(this.addedTimer),this.addedTimer=setTimeout(()=>{this.flushAdded()},this.milliseconds)}scheduleRemovedFlush(){this.removedTimer!==null&&clearTimeout(this.removedTimer),this.removedTimer=setTimeout(()=>{this.flushRemoved()},this.milliseconds)}flushAdded(){this.addedTimer!==null&&(clearTimeout(this.addedTimer),this.addedTimer=null);const e=this.addedBuffer;this.addedBuffer=[],e.length>0&&this.invokeCallbacks(this.addedCallbacks,e)}flushRemoved(){this.removedTimer!==null&&(clearTimeout(this.removedTimer),this.removedTimer=null);const e=this.removedBuffer;this.removedBuffer=[],e.length>0&&this.invokeCallbacks(this.removedCallbacks,e)}invokeCallbacks(e,r){const i=[...e],o=[];for(const s of i)try{s(r)}catch(a){o.push(a instanceof Error?a:new Error(String(a)))}if(o.length>0)throw new we(o)}}class Qe extends Error{source;error;constructor(e,r){super(`ChannelError[${e}]: ${r.message}`),this.name="ChannelError",this.source=e,this.error=r}}class Bn extends Error{errors;constructor(e){const r=e.map(i=>i.message).join("; ");super(`SyncOperation callback failed with ${e.length} error(s): ${r}`),this.name="SyncOperationAggregateError",this.errors=e}}class dr{id;jobId;jobDependencies;remoteName;documentId;scopes;branch;operations;status;error;callbacks=[];constructor(e,r,i,o,s,a,c,h){this.id=e,this.jobId=r,this.jobDependencies=i,this.remoteName=o,this.documentId=s,this.scopes=a,this.branch=c,this.operations=h,this.status=P.Unknown}on(e){this.callbacks.push(e)}started(){this.transition(P.TransportPending)}transported(){this.transition(P.ExecutionPending)}executed(){this.transition(P.Applied)}failed(e){this.error=e,this.transition(P.Error)}transition(e){const r=this.status;if(e<=r)return;this.status=e;const i=[];for(const o of this.callbacks)try{o(this,r,e)}catch(s){i.push(s instanceof Error?s:new Error(String(s)))}if(i.length>0)throw new Bn(i)}}function Ii(t,e){const r=[];for(const i of e.entries)for(const o of t.items)if(i.event.jobId===o.jobId){r.push(o);break}if(r.length>0){for(const i of r)i.executed();t.remove(...r)}}function Vn(t,e){const r=[];for(const i of t.items){let o=0;for(const s of i.operations)o=Math.max(o,s.context.ordinal);o<=e&&r.push(i)}if(r.length>0){for(const i of r)i.executed();t.remove(...r)}}function Di(t,e){return t.filter(r=>!(e.branch&&r.context.branch!==e.branch||e.documentId.length>0&&!e.documentId.includes(r.context.documentId)||e.scope.length>0&&!e.scope.includes(r.context.scope)))}function Pi(){return{state:"idle",failureCount:0}}function zn(t){return t.slice().sort((e,r)=>{const i=e.operations?.[0]?.operation.timestampUtcMs,o=r.operations?.[0]?.operation.timestampUtcMs;return!i&&!o?0:i?o?new Date(i).getTime()-new Date(o).getTime():-1:1})}function Gn(t){const e=[];let r=null,i=null,o=[];const s=()=>{o.length===0||r===null||i===null||(e.push({documentId:r,branch:o[0].context.branch,scope:i,operations:o}),o=[])};for(const a of t){const c=a.context.documentId,h=a.context.scope;(c!==r||h!==i)&&(s(),r=c,i=h),o.push(a)}return s(),e}function Fi(t){return{operation:{id:t.id,index:t.index,skip:t.skip,hash:t.hash,timestampUtcMs:t.timestampUtcMs,action:t.action},context:{documentId:t.documentId,documentType:t.documentType,scope:t.scope,branch:t.branch,ordinal:t.ordinal??0}}}function _i(t){const e={};for(const r of t){if(r.collectionMemberships)for(const[i,o]of Object.entries(r.collectionMemberships)){i in e||(e[i]=[]);for(const s of o)e[i].includes(s)||e[i].push(s)}for(const i of r.operations){const o=i.operation.action;if(o.type!=="ADD_RELATIONSHIP")continue;const s=o.input;if(!s?.sourceId||!s.targetId)continue;const a=lr(i.context.branch,s.sourceId);s.targetId in e||(e[s.targetId]=[]),e[s.targetId].includes(a)||e[s.targetId].push(a)}}return e}const Kn={intervalMs:2e3,maxQueueDepth:100,backpressureCheckIntervalMs:500,retryBaseDelayMs:1e3,retryMaxDelayMs:3e5};function hr(t,e,r,i){const o=Math.min(r,e*Math.pow(2,t-1));return o/2+i*(o/2)}class Ui{delegate;timer;running;paused;consecutiveFailures;queue;config;constructor(e,r={}){this.queue=e,this.config={...Kn,...r},this.running=!1,this.paused=!1,this.consecutiveFailures=0}setDelegate(e){this.delegate=e}start(){this.running=!0,this.consecutiveFailures=0,this.tick()}stop(){this.running=!1,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}tick(){if(!this.delegate||!this.running)return;const e=this.delegate;this.queue.totalSize().then(r=>{this.running&&(r>this.config.maxQueueDepth?this.scheduleBackpressureRecheck():e().then(()=>{this.consecutiveFailures=0,this.scheduleNext()}).catch(()=>{this.consecutiveFailures++,this.scheduleRetry()}))}).catch(()=>{this.scheduleNext()})}scheduleNext(){!this.running||this.paused||(this.timer=setTimeout(()=>this.tick(),this.config.intervalMs))}scheduleRetry(){if(!this.running||this.paused)return;const e=hr(this.consecutiveFailures,this.config.retryBaseDelayMs,this.config.retryMaxDelayMs,Math.random());this.timer=setTimeout(()=>this.tick(),e)}scheduleBackpressureRecheck(){!this.running||this.paused||(this.timer=setTimeout(()=>this.tick(),this.config.backpressureCheckIntervalMs))}pause(){this.paused=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}resume(){this.paused=!1,this.running&&this.scheduleNext()}triggerNow(){this.running&&this.delegate&&this.tick()}isPaused(){return this.paused}isRunning(){return this.running}getIntervalMs(){return this.config.intervalMs}setIntervalMs(e){this.config.intervalMs=e}}let Hn=0;function Yn(t){const e=t.context?.signer;return e?.signatures?{...t,context:{...t.context,signer:{...e,signatures:e.signatures.map(r=>Array.isArray(r)?r.join(", "):r)}}}:t}function Xn(t){return{type:t.type.toUpperCase(),channelMeta:t.channelMeta,operations:t.operations?.map(e=>({operation:{index:e.operation.index,timestampUtcMs:e.operation.timestampUtcMs,hash:e.operation.hash,skip:e.operation.skip,error:e.operation.error,id:e.operation.id,action:Yn(e.operation.action)},context:{documentId:e.context.documentId,documentType:e.context.documentType,scope:e.context.scope,branch:e.context.branch,ordinal:e.context.ordinal}})),cursor:t.cursor,key:t.key,dependsOn:t.dependsOn}}function Zn(t){return Array.isArray(t)?t:t.split(", ")}function Qn(t){const e=t.operation.action.context?.signer;if(!e?.signatures||e.signatures.length===0)return t;const r=e.signatures.map(Zn),i={...t.operation,action:{...t.operation.action,context:{...t.operation.action.context,signer:{...e,signatures:r}}}};return{...t,operation:i}}function ei(t,e){if(!t.operations||t.operations.length===0)return[];const r=t.operations.map(Qn);return Gn(r).map(o=>{const s=`syncop-${t.channelMeta.id}-${Date.now()}-${Hn++}`;return new dr(s,t.key??"",(t.dependsOn??[]).filter(Boolean),e,o.documentId,[o.scope],o.branch,o.operations)})}const $t=t=>{let e=0;for(const r of t)if(r.status===P.Applied)for(const i of r.operations)e=Math.max(e,i.context.ordinal);return e};class $i{logger;inbox;outbox;deadLetter;config;bufferedOutbox;channelId;remoteName;cursorStorage;operationIndex;pollTimer;isShutdown;failureCount;lastSuccessUtcMs;lastFailureUtcMs;lastPersistedInboxOrdinal=0;lastPersistedOutboxOrdinal=0;pushFailureCount=0;pushRetryTimer=null;pushBlocked=!1;constructor(e,r,i,o,s,a,c){this.logger=e,this.channelId=r,this.remoteName=i,this.cursorStorage=o,this.operationIndex=a,this.pollTimer=c,this.config={url:s.url,jwtHandler:s.jwtHandler,fetchFn:s.fetchFn,collectionId:s.collectionId,filter:s.filter,retryBaseDelayMs:s.retryBaseDelayMs,retryMaxDelayMs:s.retryMaxDelayMs},this.isShutdown=!1,this.failureCount=0,this.inbox=new Ut,this.bufferedOutbox=new Jn(500,25),this.outbox=this.bufferedOutbox,this.deadLetter=new Ut,this.deadLetter.onAdded(()=>{this.pollTimer.stop(),this.pushRetryTimer&&(clearTimeout(this.pushRetryTimer),this.pushRetryTimer=null)}),this.outbox.onAdded(h=>{this.isShutdown||this.pushBlocked||this.deadLetter.items.length>0||this.attemptPush(h)}),this.outbox.onRemoved(h=>{const x=$t(h);x>this.lastPersistedOutboxOrdinal&&(this.lastPersistedOutboxOrdinal=x,this.cursorStorage.upsert({remoteName:this.remoteName,cursorType:"outbox",cursorOrdinal:x,lastSyncedAtUtcMs:Date.now()}).catch(I=>{this.logger.error("Failed to update outbox cursor for @ChannelId! This means that future application runs may resend duplicate operations. This is recoverable (with deduplication protection), but not-optimal: @Error",this.channelId,I)}))}),this.inbox.onRemoved(h=>{const x=$t(h);x>this.lastPersistedInboxOrdinal&&(this.lastPersistedInboxOrdinal=x,this.cursorStorage.upsert({remoteName:this.remoteName,cursorType:"inbox",cursorOrdinal:x,lastSyncedAtUtcMs:Date.now()}).catch(I=>{this.logger.error("Failed to update inbox cursor for @ChannelId! This is unlikely to cause a problem, but not-optimal: @Error",this.channelId,I)}))})}shutdown(){return this.bufferedOutbox.flush(),this.isShutdown=!0,this.pollTimer.stop(),this.pushRetryTimer&&(clearTimeout(this.pushRetryTimer),this.pushRetryTimer=null),Promise.resolve()}async init(){await this.touchRemoteChannel();const e=await this.cursorStorage.list(this.remoteName),r=e.find(o=>o.cursorType==="inbox")?.cursorOrdinal??0,i=e.find(o=>o.cursorType==="outbox")?.cursorOrdinal??0;this.inbox.init(r),this.outbox.init(i),this.lastPersistedInboxOrdinal=r,this.lastPersistedOutboxOrdinal=i,this.pollTimer.setDelegate(()=>this.poll()),this.pollTimer.start()}async poll(){if(this.isShutdown)return;let e;try{e=await this.pollSyncEnvelopes(this.inbox.ackOrdinal,this.inbox.latestOrdinal)}catch(c){if(!this.handlePollError(c))throw c;return}const{envelopes:r,ackOrdinal:i,deadLetters:o}=e;i>0&&Vn(this.outbox,i);const s=zn(r),a=[];for(const c of s)if(c.type.toLowerCase()==="operations"&&c.operations){const h=ei(c,this.remoteName);for(const x of h)x.transported();a.push(...h)}a.length>0&&this.inbox.add(...a),o.length>0&&this.handleRemoteDeadLetters(o),this.lastSuccessUtcMs=Date.now(),this.failureCount=0}handleRemoteDeadLetters(e){for(const i of e)this.logger.error("Remote dead letter on @ChannelId: document @DocumentId failed with: @Error",this.channelId,i.documentId,i.error);const r=[];for(const i of e){const o=new dr(crypto.randomUUID(),"",[],this.remoteName,i.documentId,[],"",[]);o.failed(new Qe(We.Outbox,new Error(i.error))),r.push(o)}this.deadLetter.add(...r)}handlePollError(e){const r=e instanceof Error?e:new Error(String(e));if(r.message.includes("Channel not found"))return this.recoverFromChannelNotFound(),!0;this.failureCount++,this.lastFailureUtcMs=Date.now();const i=new Qe(We.Inbox,r);return this.logger.error("GqlChannel poll error (@FailureCount): @Error",this.failureCount,i),!1}recoverFromChannelNotFound(){this.logger.info("GqlChannel @ChannelId not found on remote, re-registering...",this.channelId),this.pollTimer.stop(),this.touchRemoteChannel().then(()=>{this.logger.info("GqlChannel @ChannelId re-registered successfully",this.channelId),this.failureCount=0,this.pollTimer.start()}).catch(e=>{this.logger.error("GqlChannel @ChannelId failed to re-register: @Error",this.channelId,e),this.failureCount++,this.lastFailureUtcMs=Date.now(),this.pollTimer.start()})}async pollSyncEnvelopes(e,r){const i=`
|
|
2
|
+
query PollSyncEnvelopes($channelId: String!, $outboxAck: Int!, $outboxLatest: Int!) {
|
|
3
|
+
pollSyncEnvelopes(channelId: $channelId, outboxAck: $outboxAck, outboxLatest: $outboxLatest) {
|
|
4
|
+
envelopes {
|
|
5
|
+
type
|
|
6
|
+
channelMeta {
|
|
7
|
+
id
|
|
8
|
+
}
|
|
9
|
+
operations {
|
|
10
|
+
operation {
|
|
11
|
+
index
|
|
12
|
+
timestampUtcMs
|
|
13
|
+
hash
|
|
14
|
+
skip
|
|
15
|
+
error
|
|
16
|
+
id
|
|
17
|
+
action {
|
|
18
|
+
id
|
|
19
|
+
type
|
|
20
|
+
timestampUtcMs
|
|
21
|
+
input
|
|
22
|
+
scope
|
|
23
|
+
attachments {
|
|
24
|
+
data
|
|
25
|
+
mimeType
|
|
26
|
+
hash
|
|
27
|
+
extension
|
|
28
|
+
fileName
|
|
29
|
+
}
|
|
30
|
+
context {
|
|
31
|
+
signer {
|
|
32
|
+
user {
|
|
33
|
+
address
|
|
34
|
+
networkId
|
|
35
|
+
chainId
|
|
36
|
+
}
|
|
37
|
+
app {
|
|
38
|
+
name
|
|
39
|
+
key
|
|
40
|
+
}
|
|
41
|
+
signatures
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
context {
|
|
47
|
+
documentId
|
|
48
|
+
documentType
|
|
49
|
+
scope
|
|
50
|
+
branch
|
|
51
|
+
ordinal
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
cursor {
|
|
55
|
+
remoteName
|
|
56
|
+
cursorOrdinal
|
|
57
|
+
lastSyncedAtUtcMs
|
|
58
|
+
}
|
|
59
|
+
key
|
|
60
|
+
dependsOn
|
|
61
|
+
}
|
|
62
|
+
ackOrdinal
|
|
63
|
+
deadLetters {
|
|
64
|
+
documentId
|
|
65
|
+
error
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`,o={channelId:this.channelId,outboxAck:e,outboxLatest:r},s=await this.executeGraphQL(i,o);return{envelopes:s.pollSyncEnvelopes.envelopes,ackOrdinal:s.pollSyncEnvelopes.ackOrdinal,deadLetters:s.pollSyncEnvelopes.deadLetters??[]}}async touchRemoteChannel(){let e="0";try{const o=await this.operationIndex.getLatestTimestampForCollection(this.config.collectionId);o&&(e=o)}catch{}const r=`
|
|
70
|
+
mutation TouchChannel($input: TouchChannelInput!) {
|
|
71
|
+
touchChannel(input: $input)
|
|
72
|
+
}
|
|
73
|
+
`,i={input:{id:this.channelId,name:this.channelId,collectionId:this.config.collectionId,filter:{documentId:this.config.filter.documentId,scope:this.config.filter.scope,branch:this.config.filter.branch},sinceTimestampUtcMs:e}};await this.executeGraphQL(r,i)}attemptPush(e){this.pushSyncOperations(e).then(()=>{this.pushBlocked=!1,this.pushFailureCount=0}).catch(r=>{const i=r instanceof Error?r:new Error(String(r));if(this.isRecoverablePushError(i))this.pushFailureCount++,this.pushBlocked=!0,this.logger.error("GqlChannel push failed (attempt @FailureCount), will retry: @Error",this.pushFailureCount,i),this.schedulePushRetry();else{const o=new Qe(We.Outbox,i);for(const s of e)s.failed(o);this.deadLetter.add(...e),this.outbox.remove(...e)}})}schedulePushRetry(){if(this.pushRetryTimer)return;const e=hr(this.pushFailureCount,this.config.retryBaseDelayMs,this.config.retryMaxDelayMs,Math.random());this.pushRetryTimer=setTimeout(()=>{if(this.pushRetryTimer=null,this.isShutdown)return;const r=this.outbox.items;if(r.length===0){this.pushBlocked=!1,this.pushFailureCount=0;return}this.attemptPush([...r])},e)}isRecoverablePushError(e){return!(e.message.startsWith("GraphQL errors:")||e.message==="GraphQL response missing data field")}async pushSyncOperations(e){for(const a of e)a.started();const r=new Map,i=[];for(let a=0;a<e.length;a++){const c=e[a],h=String(a);c.jobId&&(r.has(c.jobId)||r.set(c.jobId,[]),r.get(c.jobId).push(h));const x=[];for(const I of c.jobDependencies){const Nt=r.get(I);Nt&&x.push(...Nt)}this.logger.debug("[PUSH]: @Operations",c.operations.map(I=>`(${I.context.documentId}, ${I.context.branch}, ${I.context.scope}, ${I.operation.index})`)),i.push({type:"operations",channelMeta:{id:this.channelId},operations:c.operations,key:h,dependsOn:x})}const o=`
|
|
74
|
+
mutation PushSyncEnvelopes($envelopes: [SyncEnvelopeInput!]!) {
|
|
75
|
+
pushSyncEnvelopes(envelopes: $envelopes)
|
|
76
|
+
}
|
|
77
|
+
`,s={envelopes:i.map(a=>Xn(a))};await this.executeGraphQL(o,s)}async getAuthorizationHeader(){if(this.config.jwtHandler)try{const e=await this.config.jwtHandler(this.config.url);if(e)return`Bearer ${e}`}catch(e){this.logger.error("JWT handler failed: @Error",e)}}async executeGraphQL(e,r){const i={"Content-Type":"application/json"},o=await this.getAuthorizationHeader();o&&(i.Authorization=o);const s=this.config.fetchFn??fetch;let a;try{a=await s(this.config.url,{method:"POST",headers:i,body:JSON.stringify({query:e,variables:r})})}catch(h){throw new Error(`GraphQL request failed: ${h instanceof Error?h.message:String(h)}`)}if(!a.ok)throw new Error(`GraphQL request failed: ${a.status} ${a.statusText}`);let c;try{c=await a.json()}catch(h){throw new Error(`Failed to parse GraphQL response: ${h instanceof Error?h.message:String(h)}`)}if(c.errors)throw new Error(`GraphQL errors: ${JSON.stringify(c.errors,null,2)}`);if(!c.data)throw new Error("GraphQL response missing data field");return c.data}getHealth(){return{state:this.failureCount>0?"error":"idle",lastSuccessUtcMs:this.lastSuccessUtcMs,lastFailureUtcMs:this.lastFailureUtcMs,failureCount:this.failureCount}}get poller(){return this.pollTimer}}async function ti(t){await t.schema.createTable("Operation").addColumn("id","serial",e=>e.primaryKey()).addColumn("jobId","text",e=>e.notNull()).addColumn("opId","text",e=>e.notNull()).addColumn("prevOpId","text",e=>e.notNull()).addColumn("writeTimestampUtcMs","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("documentId","text",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("timestampUtcMs","timestamptz",e=>e.notNull()).addColumn("index","integer",e=>e.notNull()).addColumn("action","jsonb",e=>e.notNull()).addColumn("skip","integer",e=>e.notNull()).addColumn("error","text").addColumn("hash","text",e=>e.notNull()).addUniqueConstraint("unique_revision",["documentId","scope","branch","index"]).addUniqueConstraint("unique_operation_instance",["opId","index","skip"]).execute(),await t.schema.createIndex("streamOperations").on("Operation").columns(["documentId","scope","branch","id"]).execute(),await t.schema.createIndex("branchlessStreamOperations").on("Operation").columns(["documentId","scope","id"]).execute()}const ri=Object.freeze(Object.defineProperty({__proto__:null,up:ti},Symbol.toStringTag,{value:"Module"}));async function ni(t){await t.schema.createTable("Keyframe").addColumn("id","serial",e=>e.primaryKey()).addColumn("documentId","text",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("revision","integer",e=>e.notNull()).addColumn("document","jsonb",e=>e.notNull()).addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addUniqueConstraint("unique_keyframe",["documentId","scope","branch","revision"]).execute(),await t.schema.createIndex("keyframe_lookup").on("Keyframe").columns(["documentId","scope","branch","revision"]).execute()}const ii=Object.freeze(Object.defineProperty({__proto__:null,up:ni},Symbol.toStringTag,{value:"Module"}));async function oi(t){await t.schema.createTable("Document").addColumn("id","text",e=>e.primaryKey()).addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("updatedAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).execute()}const si=Object.freeze(Object.defineProperty({__proto__:null,up:oi},Symbol.toStringTag,{value:"Module"}));async function ai(t){await t.schema.createTable("DocumentRelationship").addColumn("id","text",e=>e.primaryKey()).addColumn("sourceId","text",e=>e.notNull().references("Document.id").onDelete("cascade")).addColumn("targetId","text",e=>e.notNull().references("Document.id").onDelete("cascade")).addColumn("relationshipType","text",e=>e.notNull()).addColumn("metadata","jsonb").addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("updatedAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addUniqueConstraint("unique_source_target_type",["sourceId","targetId","relationshipType"]).execute(),await t.schema.createIndex("idx_relationship_source").on("DocumentRelationship").column("sourceId").execute(),await t.schema.createIndex("idx_relationship_target").on("DocumentRelationship").column("targetId").execute(),await t.schema.createIndex("idx_relationship_type").on("DocumentRelationship").column("relationshipType").execute()}const ui=Object.freeze(Object.defineProperty({__proto__:null,up:ai},Symbol.toStringTag,{value:"Module"}));async function ci(t){await t.schema.createTable("IndexerState").addColumn("id","integer",e=>e.primaryKey().generatedAlwaysAsIdentity()).addColumn("lastOperationId","integer",e=>e.notNull()).addColumn("lastOperationTimestamp","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).execute()}const di=Object.freeze(Object.defineProperty({__proto__:null,up:ci},Symbol.toStringTag,{value:"Module"}));async function hi(t){await t.schema.createTable("DocumentSnapshot").addColumn("id","text",e=>e.primaryKey()).addColumn("documentId","text",e=>e.notNull()).addColumn("slug","text").addColumn("name","text").addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("content","jsonb",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("lastOperationIndex","integer",e=>e.notNull()).addColumn("lastOperationHash","text",e=>e.notNull()).addColumn("lastUpdatedAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("snapshotVersion","integer",e=>e.notNull().defaultTo(1)).addColumn("identifiers","jsonb").addColumn("metadata","jsonb").addColumn("isDeleted","boolean",e=>e.notNull().defaultTo(!1)).addColumn("deletedAt","timestamptz").addUniqueConstraint("unique_doc_scope_branch",["documentId","scope","branch"]).execute(),await t.schema.createIndex("idx_slug_scope_branch").on("DocumentSnapshot").columns(["slug","scope","branch"]).execute(),await t.schema.createIndex("idx_doctype_scope_branch").on("DocumentSnapshot").columns(["documentType","scope","branch"]).execute(),await t.schema.createIndex("idx_last_updated").on("DocumentSnapshot").column("lastUpdatedAt").execute(),await t.schema.createIndex("idx_is_deleted").on("DocumentSnapshot").column("isDeleted").execute()}const li=Object.freeze(Object.defineProperty({__proto__:null,up:hi},Symbol.toStringTag,{value:"Module"}));async function mi(t){await t.schema.createTable("SlugMapping").addColumn("slug","text",e=>e.primaryKey()).addColumn("documentId","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("createdAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("updatedAt","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addUniqueConstraint("unique_docid_scope_branch",["documentId","scope","branch"]).execute(),await t.schema.createIndex("idx_slug_documentid").on("SlugMapping").column("documentId").execute()}const fi=Object.freeze(Object.defineProperty({__proto__:null,up:mi},Symbol.toStringTag,{value:"Module"}));async function pi(t){await t.schema.createTable("ViewState").addColumn("readModelId","text",e=>e.primaryKey()).addColumn("lastOrdinal","integer",e=>e.notNull().defaultTo(0)).addColumn("lastOperationTimestamp","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).execute()}const Ni=Object.freeze(Object.defineProperty({__proto__:null,up:pi},Symbol.toStringTag,{value:"Module"}));async function wi(t){await t.schema.createTable("document_collections").addColumn("documentId","text",e=>e.notNull()).addColumn("collectionId","text",e=>e.notNull()).addColumn("joinedOrdinal","bigint",e=>e.notNull().defaultTo(0)).addColumn("leftOrdinal","bigint").addPrimaryKeyConstraint("document_collections_pkey",["documentId","collectionId"]).execute(),await t.schema.createIndex("idx_document_collections_collectionId").on("document_collections").column("collectionId").execute(),await t.schema.createIndex("idx_doc_collections_collection_range").on("document_collections").columns(["collectionId","joinedOrdinal"]).execute(),await t.schema.createTable("operation_index_operations").addColumn("ordinal","serial",e=>e.primaryKey()).addColumn("opId","text",e=>e.notNull()).addColumn("documentId","text",e=>e.notNull()).addColumn("documentType","text",e=>e.notNull()).addColumn("scope","text",e=>e.notNull()).addColumn("branch","text",e=>e.notNull()).addColumn("timestampUtcMs","text",e=>e.notNull()).addColumn("writeTimestampUtcMs","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("index","integer",e=>e.notNull()).addColumn("skip","integer",e=>e.notNull()).addColumn("hash","text",e=>e.notNull()).addColumn("action","jsonb",e=>e.notNull()).execute(),await t.schema.createIndex("idx_operation_index_operations_document").on("operation_index_operations").columns(["documentId","branch","scope"]).execute(),await t.schema.createIndex("idx_operation_index_operations_ordinal").on("operation_index_operations").column("ordinal").execute()}const yi=Object.freeze(Object.defineProperty({__proto__:null,up:wi},Symbol.toStringTag,{value:"Module"}));async function gi(t){await t.schema.createTable("sync_remotes").addColumn("name","text",e=>e.primaryKey()).addColumn("collection_id","text",e=>e.notNull()).addColumn("channel_type","text",e=>e.notNull()).addColumn("channel_id","text",e=>e.notNull().defaultTo("")).addColumn("remote_name","text",e=>e.notNull().defaultTo("")).addColumn("channel_parameters","jsonb",e=>e.notNull().defaultTo(y`'{}'::jsonb`)).addColumn("filter_document_ids","jsonb").addColumn("filter_scopes","jsonb").addColumn("filter_branch","text",e=>e.notNull().defaultTo("main")).addColumn("push_state","text",e=>e.notNull().defaultTo("idle")).addColumn("push_last_success_utc_ms","text").addColumn("push_last_failure_utc_ms","text").addColumn("push_failure_count","integer",e=>e.notNull().defaultTo(0)).addColumn("pull_state","text",e=>e.notNull().defaultTo("idle")).addColumn("pull_last_success_utc_ms","text").addColumn("pull_last_failure_utc_ms","text").addColumn("pull_failure_count","integer",e=>e.notNull().defaultTo(0)).addColumn("created_at","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addColumn("updated_at","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).execute(),await t.schema.createIndex("idx_sync_remotes_collection").on("sync_remotes").column("collection_id").execute(),await t.schema.createTable("sync_cursors").addColumn("remote_name","text",e=>e.primaryKey().references("sync_remotes.name").onDelete("cascade")).addColumn("cursor_ordinal","bigint",e=>e.notNull().defaultTo(0)).addColumn("last_synced_at_utc_ms","text").addColumn("updated_at","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).execute(),await t.schema.createIndex("idx_sync_cursors_ordinal").on("sync_cursors").column("cursor_ordinal").execute()}const xi=Object.freeze(Object.defineProperty({__proto__:null,up:gi},Symbol.toStringTag,{value:"Module"}));async function Oi(t){await t.deleteFrom("sync_cursors").where("remote_name","like","outbox::%").execute(),await t.deleteFrom("sync_remotes").where("name","like","outbox::%").execute(),await t.schema.dropTable("sync_cursors").execute(),await t.schema.createTable("sync_cursors").addColumn("remote_name","text",e=>e.notNull()).addColumn("cursor_type","text",e=>e.notNull().defaultTo("inbox")).addColumn("cursor_ordinal","bigint",e=>e.notNull().defaultTo(0)).addColumn("last_synced_at_utc_ms","text").addColumn("updated_at","timestamptz",e=>e.notNull().defaultTo(y`NOW()`)).addPrimaryKeyConstraint("sync_cursors_pk",["remote_name","cursor_type"]).execute(),await t.schema.createIndex("idx_sync_cursors_ordinal").on("sync_cursors").column("cursor_ordinal").execute()}const bi=Object.freeze(Object.defineProperty({__proto__:null,up:Oi},Symbol.toStringTag,{value:"Module"}));async function ki(t){await t.schema.alterTable("operation_index_operations").addColumn("sourceRemote","text",e=>e.notNull().defaultTo("")).execute()}const Ci=Object.freeze(Object.defineProperty({__proto__:null,up:ki},Symbol.toStringTag,{value:"Module"})),Ti="reactor",Wi={"001_create_operation_table":ri,"002_create_keyframe_table":ii,"003_create_document_table":si,"004_create_document_relationship_table":ui,"005_create_indexer_state_table":di,"006_create_document_snapshot_table":li,"007_create_slug_mapping_table":fi,"008_create_view_state_table":Ni,"009_create_operation_index_tables":yi,"010_create_sync_tables":xi,"011_add_cursor_type_column":bi,"012_add_source_remote_column":Ci};class Ei{getMigrations(){return Promise.resolve(Wi)}}async function ji(t,e=Ti){try{await y`CREATE SCHEMA IF NOT EXISTS ${y.id(e)}`.execute(t)}catch(a){return{success:!1,migrationsExecuted:[],error:a instanceof Error?a:new Error("Failed to create schema")}}const r=new jn({db:t.withSchema(e),provider:new Ei,migrationTableSchema:e});let i,o;try{const a=await r.migrateToLatest();i=a.error,o=a.results}catch(a){i=a,o=[]}const s=o?.map(a=>a.migrationName)??[];return i?{success:!1,migrationsExecuted:s,error:i instanceof Error?i:new Error("Unknown migration error")}:{success:!0,migrationsExecuted:s}}export{_i as $,ze as A,rn as B,_ as C,Mi as D,g as E,wn as F,$i as G,Me as H,Ui as I,v as J,jt as K,ie as L,st as M,Bt as N,Xr as O,Se as P,u as Q,Ti as R,P as S,Jt as T,Ri as U,Q as V,mt as W,Un as X,Ft as Y,Ut as Z,$t as _,k as a,Li as a0,Pi as a1,Ii as a2,Qe as a3,We as a4,Gn as a5,dr as a6,Fi as a7,Di as a8,ji as a9,_t as aa,et as b,Gt as c,Ln as d,vi as e,n as f,O as g,E as h,S as i,er as j,C as k,Le as l,Tr as m,Ai as n,b as o,Z as p,qi as q,on as r,y as s,$ as t,me as u,te as v,Wn as w,V as x,re as y,kn as z};
|
|
78
|
+
//# sourceMappingURL=migrator-CmQyl4ZK.js.map
|