@samanhappy/mcphub 1.1.14 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.fr.md +1 -1
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/dist/betterAuth.js +3 -3
- package/dist/betterAuth.js.map +1 -1
- package/dist/cli/commands/keys.js +22 -3
- package/dist/cli/commands/keys.js.map +1 -1
- package/dist/clients/mcpSdkClient.js +2667 -1448
- package/dist/clients/mcpSdkClient.js.map +4 -4
- package/dist/controllers/bearerKeyController.js +49 -3
- package/dist/controllers/bearerKeyController.js.map +1 -1
- package/dist/controllers/credentialBindingController.js +1 -1
- package/dist/controllers/credentialBindingController.js.map +1 -1
- package/dist/controllers/groupController.js +12 -5
- package/dist/controllers/groupController.js.map +1 -1
- package/dist/controllers/oauthRelayController.js +65 -0
- package/dist/controllers/oauthRelayController.js.map +1 -0
- package/dist/controllers/personalOAuthController.js +10 -1
- package/dist/controllers/personalOAuthController.js.map +1 -1
- package/dist/controllers/serverController.js +23 -14
- package/dist/controllers/serverController.js.map +1 -1
- package/dist/controllers/userController.js +11 -1
- package/dist/controllers/userController.js.map +1 -1
- package/dist/dao/BearerKeyDao.js +10 -5
- package/dist/dao/BearerKeyDao.js.map +1 -1
- package/dist/dao/BearerKeyDaoDbImpl.js +16 -5
- package/dist/dao/BearerKeyDaoDbImpl.js.map +1 -1
- package/dist/dao/GroupDaoDbImpl.js +11 -0
- package/dist/dao/GroupDaoDbImpl.js.map +1 -1
- package/dist/dao/ServerDao.js +5 -1
- package/dist/dao/ServerDao.js.map +1 -1
- package/dist/dao/ServerDaoDbImpl.js +3 -0
- package/dist/dao/ServerDaoDbImpl.js.map +1 -1
- package/dist/dao/UserDaoDbImpl.js +4 -0
- package/dist/dao/UserDaoDbImpl.js.map +1 -1
- package/dist/db/entities/BearerKey.js +8 -0
- package/dist/db/entities/BearerKey.js.map +1 -1
- package/dist/db/entities/Group.js +4 -0
- package/dist/db/entities/Group.js.map +1 -1
- package/dist/db/entities/Server.js +4 -0
- package/dist/db/entities/Server.js.map +1 -1
- package/dist/db/entities/User.js +4 -0
- package/dist/db/entities/User.js.map +1 -1
- package/dist/db/repositories/ServerRepository.js +1 -0
- package/dist/db/repositories/ServerRepository.js.map +1 -1
- package/dist/middlewares/auth.js +7 -1
- package/dist/middlewares/auth.js.map +1 -1
- package/dist/routes/index.js +2 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/services/authorizationService.js.map +1 -1
- package/dist/services/capabilitySnapshotService.js +2 -1
- package/dist/services/capabilitySnapshotService.js.map +1 -1
- package/dist/services/credentialBindingService.js +9 -1
- package/dist/services/credentialBindingService.js.map +1 -1
- package/dist/services/dataService.js +4 -2
- package/dist/services/dataService.js.map +1 -1
- package/dist/services/groupService.js +15 -7
- package/dist/services/groupService.js.map +1 -1
- package/dist/services/mcpEventBus.js +6 -0
- package/dist/services/mcpEventBus.js.map +1 -0
- package/dist/services/mcpService.js +26 -2
- package/dist/services/mcpService.js.map +1 -1
- package/dist/services/personalOAuthService.js +2 -0
- package/dist/services/personalOAuthService.js.map +1 -1
- package/dist/services/requestContextService.js +15 -0
- package/dist/services/requestContextService.js.map +1 -1
- package/dist/services/serverConfigEnvironment.js +2 -1
- package/dist/services/serverConfigEnvironment.js.map +1 -1
- package/dist/services/sseService.js +58 -6
- package/dist/services/sseService.js.map +1 -1
- package/dist/services/templateService.js +11 -5
- package/dist/services/templateService.js.map +1 -1
- package/dist/services/userService.js +5 -1
- package/dist/services/userService.js.map +1 -1
- package/dist/utils/groupAccess.js +6 -4
- package/dist/utils/groupAccess.js.map +1 -1
- package/dist/utils/groupKeyScope.js +11 -5
- package/dist/utils/groupKeyScope.js.map +1 -1
- package/dist/utils/migration.js +5 -0
- package/dist/utils/migration.js.map +1 -1
- package/dist/utils/oauthBearer.js +1 -0
- package/dist/utils/oauthBearer.js.map +1 -1
- package/dist/utils/oauthServerMetadata.js +21 -0
- package/dist/utils/oauthServerMetadata.js.map +1 -1
- package/dist/utils/serverConfigPersistence.js +16 -1
- package/dist/utils/serverConfigPersistence.js.map +1 -1
- package/dist/utils/serverConfigValidation.js +1 -0
- package/dist/utils/serverConfigValidation.js.map +1 -1
- package/dist/utils/settingsSync.js +3 -0
- package/dist/utils/settingsSync.js.map +1 -1
- package/frontend/dist/assets/{ActivityPage-C8Zj4FeE.js → ActivityPage-Bi-TjKez.js} +2 -2
- package/frontend/dist/assets/{ActivityPage-C8Zj4FeE.js.map → ActivityPage-Bi-TjKez.js.map} +1 -1
- package/frontend/dist/assets/{ConfirmDialog-BYdfb115.js → ConfirmDialog-BJpzQmMw.js} +2 -2
- package/frontend/dist/assets/{ConfirmDialog-BYdfb115.js.map → ConfirmDialog-BJpzQmMw.js.map} +1 -1
- package/frontend/dist/assets/CredentialsPage-C4Ucer3d.js +2 -0
- package/frontend/dist/assets/CredentialsPage-C4Ucer3d.js.map +1 -0
- package/frontend/dist/assets/{Dashboard-CCiZcGi4.js → Dashboard-C_2KkuoD.js} +2 -2
- package/frontend/dist/assets/{Dashboard-CCiZcGi4.js.map → Dashboard-C_2KkuoD.js.map} +1 -1
- package/frontend/dist/assets/{DeleteDialog-BaCsEkJA.js → DeleteDialog-BoMYLx3J.js} +2 -2
- package/frontend/dist/assets/{DeleteDialog-BaCsEkJA.js.map → DeleteDialog-BoMYLx3J.js.map} +1 -1
- package/frontend/dist/assets/{EndpointCopy-CmKx4RVL.js → EndpointCopy-DITVC2YQ.js} +2 -2
- package/frontend/dist/assets/{EndpointCopy-CmKx4RVL.js.map → EndpointCopy-DITVC2YQ.js.map} +1 -1
- package/frontend/dist/assets/GroupsPage-sE6YJyuK.js +33 -0
- package/frontend/dist/assets/GroupsPage-sE6YJyuK.js.map +1 -0
- package/frontend/dist/assets/{LoginPage-Hn1uu0vB.js → LoginPage-CFsd_nY-.js} +2 -2
- package/frontend/dist/assets/{LoginPage-Hn1uu0vB.js.map → LoginPage-CFsd_nY-.js.map} +1 -1
- package/frontend/dist/assets/{LogsPage-JMCtTjCv.js → LogsPage-BxZuGDuc.js} +2 -2
- package/frontend/dist/assets/{LogsPage-JMCtTjCv.js.map → LogsPage-BxZuGDuc.js.map} +1 -1
- package/frontend/dist/assets/MarketPage-CDBs4vMb.js +2 -0
- package/frontend/dist/assets/{MarketPage-Bvi1KESo.js.map → MarketPage-CDBs4vMb.js.map} +1 -1
- package/frontend/dist/assets/{OAuthConsentPage-DofQEZAU.js → OAuthConsentPage-BN_ucViM.js} +2 -2
- package/frontend/dist/assets/{OAuthConsentPage-DofQEZAU.js.map → OAuthConsentPage-BN_ucViM.js.map} +1 -1
- package/frontend/dist/assets/{Pagination-D99WHhBx.js → Pagination-S-7lzy59.js} +2 -2
- package/frontend/dist/assets/{Pagination-D99WHhBx.js.map → Pagination-S-7lzy59.js.map} +1 -1
- package/frontend/dist/assets/{PromptsPage-B-8vczAR.js → PromptsPage-Bl3ySXGK.js} +2 -2
- package/frontend/dist/assets/{PromptsPage-B-8vczAR.js.map → PromptsPage-Bl3ySXGK.js.map} +1 -1
- package/frontend/dist/assets/{ResourcesPage-DLAIatoG.js → ResourcesPage-BOzQkQ92.js} +2 -2
- package/frontend/dist/assets/{ResourcesPage-DLAIatoG.js.map → ResourcesPage-BOzQkQ92.js.map} +1 -1
- package/frontend/dist/assets/{ServersPage-wVLsTL_f.js → ServersPage-DHYwQ5AM.js} +5 -5
- package/frontend/dist/assets/{ServersPage-wVLsTL_f.js.map → ServersPage-DHYwQ5AM.js.map} +1 -1
- package/frontend/dist/assets/SettingsPage-CSJ35jlM.js +14 -0
- package/frontend/dist/assets/SettingsPage-CSJ35jlM.js.map +1 -0
- package/frontend/dist/assets/{StatusDot-00-sTQKv.js → StatusDot-NSjojGCy.js} +2 -2
- package/frontend/dist/assets/{StatusDot-00-sTQKv.js.map → StatusDot-NSjojGCy.js.map} +1 -1
- package/frontend/dist/assets/{ToggleGroup-CtWBng3r.js → ToggleGroup-BIZWpNzm.js} +2 -2
- package/frontend/dist/assets/{ToggleGroup-CtWBng3r.js.map → ToggleGroup-BIZWpNzm.js.map} +1 -1
- package/frontend/dist/assets/UserGroupSelection-CN0weGXJ.js +2 -0
- package/frontend/dist/assets/UserGroupSelection-CN0weGXJ.js.map +1 -0
- package/frontend/dist/assets/UsersPage-DC51v2b8.js +2 -0
- package/frontend/dist/assets/UsersPage-DC51v2b8.js.map +1 -0
- package/frontend/dist/assets/{clipboard-2RRFM-q8.js → clipboard-ik5YV95M.js} +2 -2
- package/frontend/dist/assets/{clipboard-2RRFM-q8.js.map → clipboard-ik5YV95M.js.map} +1 -1
- package/frontend/dist/assets/{costRevision-Ntl7VtWo.js → costRevision-Bxov9_vH.js} +2 -2
- package/frontend/dist/assets/{costRevision-Ntl7VtWo.js.map → costRevision-Bxov9_vH.js.map} +1 -1
- package/frontend/dist/assets/framework-vendor-D0S_ys6r.js +61 -0
- package/frontend/dist/assets/framework-vendor-D0S_ys6r.js.map +1 -0
- package/frontend/dist/assets/{i18n-vendor-DVmjrzgW.js → i18n-vendor-COTriSc6.js} +2 -2
- package/frontend/dist/assets/{i18n-vendor-DVmjrzgW.js.map → i18n-vendor-COTriSc6.js.map} +1 -1
- package/frontend/dist/assets/{icons-vendor-CyAS6fj0.js → icons-vendor-DZjjGrOu.js} +2 -2
- package/frontend/dist/assets/{icons-vendor-CyAS6fj0.js.map → icons-vendor-DZjjGrOu.js.map} +1 -1
- package/frontend/dist/assets/index-6AyPtx0A.js +3 -0
- package/frontend/dist/assets/index-6AyPtx0A.js.map +1 -0
- package/frontend/dist/assets/{resourceService-BB4UM6IQ.js → resourceService-DMzCAZ0B.js} +2 -2
- package/frontend/dist/assets/{resourceService-BB4UM6IQ.js.map → resourceService-DMzCAZ0B.js.map} +1 -1
- package/frontend/dist/assets/{useCostData-C3XnQyUj.js → useCostData-CcFSYViI.js} +2 -2
- package/frontend/dist/assets/{useCostData-C3XnQyUj.js.map → useCostData-CcFSYViI.js.map} +1 -1
- package/frontend/dist/assets/variableDetection-CbYSa1ka.js +80 -0
- package/frontend/dist/assets/variableDetection-CbYSa1ka.js.map +1 -0
- package/frontend/dist/index.html +4 -4
- package/package.json +2 -2
- package/frontend/dist/assets/CredentialsPage-BnzqPYjg.js +0 -2
- package/frontend/dist/assets/CredentialsPage-BnzqPYjg.js.map +0 -1
- package/frontend/dist/assets/GroupsPage-DHgQeVHy.js +0 -33
- package/frontend/dist/assets/GroupsPage-DHgQeVHy.js.map +0 -1
- package/frontend/dist/assets/MarketPage-Bvi1KESo.js +0 -2
- package/frontend/dist/assets/SettingsPage-DkfXDE5_.js +0 -14
- package/frontend/dist/assets/SettingsPage-DkfXDE5_.js.map +0 -1
- package/frontend/dist/assets/UsersPage-BtdFWcVD.js +0 -2
- package/frontend/dist/assets/UsersPage-BtdFWcVD.js.map +0 -1
- package/frontend/dist/assets/framework-vendor-CQFm9vKd.js +0 -61
- package/frontend/dist/assets/framework-vendor-CQFm9vKd.js.map +0 -1
- package/frontend/dist/assets/index-CkSmxNPW.js +0 -3
- package/frontend/dist/assets/index-CkSmxNPW.js.map +0 -1
- package/frontend/dist/assets/variableDetection-BUXwrSop.js +0 -18
- package/frontend/dist/assets/variableDetection-BUXwrSop.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as c,l as t,j as n}from"./index-
|
|
2
|
-
//# sourceMappingURL=resourceService-
|
|
1
|
+
import{i as c,l as t,j as n}from"./index-6AyPtx0A.js";import"./framework-vendor-D0S_ys6r.js";import"./i18n-vendor-COTriSc6.js";import"./icons-vendor-DZjjGrOu.js";const d=async(r,o,s)=>{try{const e=await t(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/toggle`,{enabled:s},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message}}catch(e){return console.error("Error toggling resource",{serverName:r,resourceUri:o,enabled:s,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}},g=async(r,o,s)=>{try{const e=await n(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/description`,{description:s},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message}}catch(e){return console.error("Error updating resource description",{serverName:r,resourceUri:o,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}},m=async(r,o)=>{var s;try{const e=await c(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message,description:(s=e.data)==null?void 0:s.description}}catch(e){return console.error("Error resetting resource description",{serverName:r,resourceUri:o,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}};export{m as resetResourceDescription,d as toggleResource,g as updateResourceDescription};
|
|
2
|
+
//# sourceMappingURL=resourceService-DMzCAZ0B.js.map
|
package/frontend/dist/assets/{resourceService-BB4UM6IQ.js.map → resourceService-DMzCAZ0B.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceService-
|
|
1
|
+
{"version":3,"file":"resourceService-DMzCAZ0B.js","sources":["../../src/services/resourceService.ts"],"sourcesContent":["import { apiDelete, apiPost, apiPut } from '../utils/fetchInterceptor';\n\n/**\n * Toggle a resource's enabled state for a specific server\n */\nexport const toggleResource = async (\n serverName: string,\n resourceUri: string,\n enabled: boolean,\n): Promise<{ success: boolean; error?: string }> => {\n try {\n const response = await apiPost<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/toggle`,\n { enabled },\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n };\n } catch (error) {\n console.error('Error toggling resource', { serverName, resourceUri, enabled, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n\n/**\n * Update a resource's description for a specific server\n */\nexport const updateResourceDescription = async (\n serverName: string,\n resourceUri: string,\n description: string,\n): Promise<{ success: boolean; error?: string }> => {\n try {\n const response = await apiPut<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/description`,\n { description },\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n };\n } catch (error) {\n console.error('Error updating resource description', { serverName, resourceUri, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n\nexport const resetResourceDescription = async (\n serverName: string,\n resourceUri: string,\n): Promise<{ success: boolean; error?: string; description?: string }> => {\n try {\n const response = await apiDelete<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/description`,\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n description: response.data?.description,\n };\n } catch (error) {\n console.error('Error resetting resource description', { serverName, resourceUri, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n"],"names":["toggleResource","serverName","resourceUri","enabled","response","apiPost","error","updateResourceDescription","description","apiPut","resetResourceDescription","apiDelete","_a"],"mappings":"kKAKO,MAAMA,EAAiB,MAC5BC,EACAC,EACAC,IACkD,CAClD,GAAI,CACF,MAAMC,EAAW,MAAMC,EACrB,YAAY,mBAAmBJ,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,UACvF,CAAE,QAAAC,CAAA,EACF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASC,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,OAAA,CAEnD,OAASE,EAAO,CACd,eAAQ,MAAM,0BAA2B,CAAE,WAAAL,EAAY,YAAAC,EAAa,QAAAC,EAAS,MAAAG,EAAO,EAC7E,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF,EAKaC,EAA4B,MACvCN,EACAC,EACAM,IACkD,CAClD,GAAI,CACF,MAAMJ,EAAW,MAAMK,EACrB,YAAY,mBAAmBR,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,eACvF,CAAE,YAAAM,CAAA,EACF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASJ,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,OAAA,CAEnD,OAASE,EAAO,CACd,eAAQ,MAAM,sCAAuC,CAAE,WAAAL,EAAY,YAAAC,EAAa,MAAAI,EAAO,EAChF,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF,EAEaI,EAA2B,MACtCT,EACAC,IACwE,OACxE,GAAI,CACF,MAAME,EAAW,MAAMO,EACrB,YAAY,mBAAmBV,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,eACvF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASE,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,QAC/C,aAAaQ,EAAAR,EAAS,OAAT,YAAAQ,EAAe,WAAA,CAEhC,OAASN,EAAO,CACd,eAAQ,MAAM,uCAAwC,CAAE,WAAAL,EAAY,YAAAC,EAAa,MAAAI,EAAO,EACjF,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as v,h as d}from"./index-
|
|
2
|
-
//# sourceMappingURL=useCostData-
|
|
1
|
+
import{p as v,h as d}from"./index-6AyPtx0A.js";import{r as s}from"./framework-vendor-D0S_ys6r.js";const w=r=>{const c=v(),{refreshIfNeeded:u}=c;return s.useEffect(()=>{r!=null&&r.refreshOnMount&&u()},[r==null?void 0:r.refreshOnMount,u]),c},E=(r="")=>{const[c,u]=s.useState([]),[h,C]=s.useState([]),[m,o]=s.useState(!0),a=s.useRef(null),f=s.useCallback(async()=>{try{o(!0);const[e,t]=await Promise.all([d("/cost/servers"),d("/cost/groups")]);return e!=null&&e.success&&Array.isArray(e.data)&&u(e.data),t!=null&&t.success&&Array.isArray(t.data)&&C(t.data),!!(e!=null&&e.success&&Array.isArray(e.data)&&(t!=null&&t.success)&&Array.isArray(t.data))}catch(e){return console.error("Error fetching context footprint:",e),!1}finally{o(!1)}},[]),n=s.useCallback(()=>(a.current||(a.current=f().finally(()=>{a.current=null})),a.current),[f]);return s.useEffect(()=>{let e=!0,t,i=0;const l=async()=>{const A=await n();e&&!A&&i<3&&(t=setTimeout(()=>void l(),2e3*2**i++))},y=a.current;return(async()=>(y&&await y,e&&await l()))(),()=>{e=!1,clearTimeout(t)}},[n,r]),{serverCosts:c,groupCosts:h,loading:m,refetch:n}};export{E as a,w as u};
|
|
2
|
+
//# sourceMappingURL=useCostData-CcFSYViI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCostData-
|
|
1
|
+
{"version":3,"file":"useCostData-CcFSYViI.js","sources":["../../src/hooks/useServerData.ts","../../src/hooks/useCostData.ts"],"sourcesContent":["// This hook now delegates to the ServerContext to avoid duplicate requests\n// All components will share the same server data and polling mechanism\nimport { useServerContext } from '@/contexts/ServerContext';\nimport { useEffect } from 'react';\n\nexport const useServerData = (options?: { refreshOnMount?: boolean }) => {\n const context = useServerContext();\n const { refreshIfNeeded } = context;\n\n // Optionally refresh on mount for pages that need fresh data\n useEffect(() => {\n if (options?.refreshOnMount) {\n refreshIfNeeded();\n }\n }, [options?.refreshOnMount, refreshIfNeeded]);\n\n return context;\n};\n\n","import { useCallback, useEffect, useRef, useState } from 'react';\nimport { apiGet } from '../utils/fetchInterceptor';\nimport type { ApiResponse, ServerCost, GroupCost } from '@/types';\n\nexport const useCostData = (revision = '') => {\n const [serverCosts, setServerCosts] = useState<ServerCost[]>([]);\n const [groupCosts, setGroupCosts] = useState<GroupCost[]>([]);\n const [loading, setLoading] = useState(true);\n\n const inFlight = useRef<Promise<boolean> | null>(null);\n\n const loadCosts = useCallback(async () => {\n try {\n setLoading(true);\n const [servers, groups] = await Promise.all([\n apiGet('/cost/servers') as Promise<ApiResponse<ServerCost[]>>,\n apiGet('/cost/groups') as Promise<ApiResponse<GroupCost[]>>,\n ]);\n if (servers?.success && Array.isArray(servers.data)) setServerCosts(servers.data);\n if (groups?.success && Array.isArray(groups.data)) setGroupCosts(groups.data);\n return Boolean(\n servers?.success &&\n Array.isArray(servers.data) &&\n groups?.success &&\n Array.isArray(groups.data),\n );\n } catch (err) {\n console.error('Error fetching context footprint:', err);\n return false;\n } finally {\n setLoading(false);\n }\n }, []);\n\n const fetchCosts = useCallback(() => {\n if (!inFlight.current) {\n inFlight.current = loadCosts().finally(() => {\n inFlight.current = null;\n });\n }\n return inFlight.current;\n }, [loadCosts]);\n\n useEffect(() => {\n // A revision change during an active request must still fetch the new state.\n let active = true;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let retries = 0;\n const refresh = async () => {\n const success = await fetchCosts();\n if (active && !success && retries < 3) {\n // Retry transient failures even when catalog revisions stay unchanged.\n timer = setTimeout(() => void refresh(), 2000 * 2 ** retries++);\n }\n };\n const previous = inFlight.current;\n void (async () => {\n if (previous) await previous;\n if (active) await refresh();\n })();\n return () => {\n active = false;\n clearTimeout(timer);\n };\n }, [fetchCosts, revision]);\n\n return { serverCosts, groupCosts, loading, refetch: fetchCosts };\n};\n"],"names":["useServerData","options","context","useServerContext","refreshIfNeeded","useEffect","useCostData","revision","serverCosts","setServerCosts","useState","groupCosts","setGroupCosts","loading","setLoading","inFlight","useRef","loadCosts","useCallback","servers","groups","apiGet","err","fetchCosts","active","timer","retries","refresh","success","previous"],"mappings":"kGAKO,MAAMA,EAAiBC,GAA2C,CACvE,MAAMC,EAAUC,EAAA,EACV,CAAE,gBAAAC,GAAoBF,EAG5BG,OAAAA,EAAAA,UAAU,IAAM,CACVJ,GAAA,MAAAA,EAAS,gBACXG,EAAA,CAEJ,EAAG,CAACH,GAAA,YAAAA,EAAS,eAAgBG,CAAe,CAAC,EAEtCF,CACT,ECbaI,EAAc,CAACC,EAAW,KAAO,CAC5C,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAAuB,CAAA,CAAE,EACzD,CAACC,EAAYC,CAAa,EAAIF,EAAAA,SAAsB,CAAA,CAAE,EACtD,CAACG,EAASC,CAAU,EAAIJ,EAAAA,SAAS,EAAI,EAErCK,EAAWC,EAAAA,OAAgC,IAAI,EAE/CC,EAAYC,EAAAA,YAAY,SAAY,CACxC,GAAI,CACFJ,EAAW,EAAI,EACf,KAAM,CAACK,EAASC,CAAM,EAAI,MAAM,QAAQ,IAAI,CAC1CC,EAAO,eAAe,EACtBA,EAAO,cAAc,CAAA,CACtB,EACD,OAAIF,GAAA,MAAAA,EAAS,SAAW,MAAM,QAAQA,EAAQ,IAAI,GAAGV,EAAeU,EAAQ,IAAI,EAC5EC,GAAA,MAAAA,EAAQ,SAAW,MAAM,QAAQA,EAAO,IAAI,GAAGR,EAAcQ,EAAO,IAAI,EACrE,GACLD,GAAA,MAAAA,EAAS,SACP,MAAM,QAAQA,EAAQ,IAAI,IAC1BC,GAAA,MAAAA,EAAQ,UACR,MAAM,QAAQA,EAAO,IAAI,EAE/B,OAASE,EAAK,CACZ,eAAQ,MAAM,oCAAqCA,CAAG,EAC/C,EACT,QAAA,CACER,EAAW,EAAK,CAClB,CACF,EAAG,CAAA,CAAE,EAECS,EAAaL,EAAAA,YAAY,KACxBH,EAAS,UACZA,EAAS,QAAUE,EAAA,EAAY,QAAQ,IAAM,CAC3CF,EAAS,QAAU,IACrB,CAAC,GAEIA,EAAS,SACf,CAACE,CAAS,CAAC,EAEdZ,OAAAA,EAAAA,UAAU,IAAM,CAEd,IAAImB,EAAS,GACTC,EACAC,EAAU,EACd,MAAMC,EAAU,SAAY,CAC1B,MAAMC,EAAU,MAAML,EAAA,EAClBC,GAAU,CAACI,GAAWF,EAAU,IAElCD,EAAQ,WAAW,IAAM,KAAKE,IAAW,IAAO,GAAKD,GAAS,EAElE,EACMG,EAAWd,EAAS,QAC1B,OAAM,UACAc,GAAU,MAAMA,EAChBL,SAAcG,EAAA,MAEb,IAAM,CACXH,EAAS,GACT,aAAaC,CAAK,CACpB,CACF,EAAG,CAACF,EAAYhB,CAAQ,CAAC,EAElB,CAAE,YAAAC,EAAa,WAAAG,EAAY,QAAAE,EAAS,QAASU,CAAA,CACtD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import{r as O,j as i}from"./framework-vendor-D0S_ys6r.js";import{U as pi}from"./UserGroupSelection-CN0weGXJ.js";import{a as fi,h as hi,l as mi}from"./index-6AyPtx0A.js";import{f as gi,a as yi,O as vi}from"./contextCost-CilWqGWT.js";import{u as bi}from"./i18n-vendor-COTriSc6.js";import{X as pt}from"./icons-vendor-DZjjGrOu.js";const tp=(e,t)=>t?t.isAdmin?!0:!!(e.owner&&e.owner===t.username):!1,xi=(e,t)=>{var n,r,s,o;return t===!0?null:(n=e.oauth)!=null&&n.authorizationRelay?"server.oauth.relayRequiresAdmin":((r=e.oauth)==null?void 0:r.allowInsecureTokenEndpoint)===!0?"server.httpOAuthRequiresAdmin":e.type==="stdio"||e.command||Array.isArray(e.args)&&e.args.length>0||!e.url&&!((s=e.openapi)!=null&&s.url)&&!((o=e.openapi)!=null&&o.schema)?"server.localExecutionRequiresAdmin":null};function xt(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function xs(e,t="|"){return e.map(n=>io(n)).join(t)}function kt(e,t){return typeof t=="bigint"?t.toString():t}class ki{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function $t(e){return new ki(e)}function _i(e){return e==null}function Tt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function ce(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function to(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t!=null&&t.get?t.get.raw:t==null?void 0:t.value}function Q(e){return to(e._zod.def)??e._zod.def.shape}function no(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return ce(this,t,r),r},enumerable:!0,configurable:!0})}function ro(e,t,n){t in e?ce(e,t,n):e[t]=n}function ae(e,t,n,r){const s=Q(t);for(const o of n){const c=Object.getOwnPropertyDescriptor(s,o);c.enumerable&&(c.get?no(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):ro(e,o,r?r(c.value,o):c.value))}}function wi(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?no(e,n,()=>t[n]):ro(e,n,r.value))}}function J(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ji(e){return JSON.stringify(e)}function Si(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const so="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ni=$t(()=>{var e;if(W.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Se(e){if(He(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(He(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function oo(e){return Se(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const zi=new Set(["string","number","symbol"]);function Xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function se(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function w(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function io(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Oi(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const $i={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ti={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ci(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o={};return ae(o,e,Ye(e,t)),se(e,J(n,{shape:o,checks:[]}))}function Ye(e,t){var s;const n=Q(e),r=[];for(const o of Reflect.ownKeys(t)){if(!((s=Object.getOwnPropertyDescriptor(n,o))!=null&&s.enumerable))throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function Ai(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=new Set(Ye(e,t)),c={};return ae(c,e,Reflect.ownKeys(Q(e)).filter(a=>!o.has(a))),se(e,J(n,{shape:c,checks:[]}))}function Ii(e,t){if(!Se(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=Q(e);for(const o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return se(e,J(e._zod.def,{shape:ao(e,t)}))}function ao(e,t){const n={};return ae(n,e,Reflect.ownKeys(Q(e))),wi(n,t),n}function Ei(e,t){if(!Se(t))throw new Error("Invalid input to safeExtend: expected a plain object");return se(e,J(e._zod.def,{shape:ao(e,t)}))}function Pi(e,t){var s,o;if(!((s=t==null?void 0:t._zod)!=null&&s.def))throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if((o=e._zod.def.checks)!=null&&o.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};ae(n,e,Reflect.ownKeys(Q(e))),ae(n,t,Reflect.ownKeys(Q(t)));const r=J(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return se(e,r)}function ks(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Ye(t,n)):void 0,l={};return ae(l,t,Reflect.ownKeys(Q(t)),e&&((g,f)=>a&&!a.has(f)?g:new e({type:"optional",innerType:g}))),se(t,J(t._zod.def,{shape:l,checks:[]}))}function Zi(e,t,n){const r=n?new Set(Ye(t,n)):void 0,s={};return ae(s,t,Reflect.ownKeys(Q(t)),(o,c)=>r&&!r.has(c)?o:new e({type:"nonoptional",innerType:o})),se(t,J(t._zod.def,{shape:s}))}function Y(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function Ri(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function co(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function be(e){return typeof e=="string"?e:e==null?void 0:e.message}function _s(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const s=r.maximum??r.length??r.size;s>=0&&t.push([s,n])}return t}function _t(e,t,n){var r;for(let s=t;s<e.length;s++)(r=e[s]).schema??(r.schema=n)}function fe(e,t,n){var l,g,f,m,v,h,k,p,b,_;var r;const s=(g=(l=e.inst)==null?void 0:l._zod)==null?void 0:g.traits;s!=null&&s.has("$ZodType")&&(s.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?(m=(f=e.schema)==null?void 0:f._zod.def)==null?void 0:m.error:void 0,c=e.message?e.message:be((k=(h=(v=e.inst)==null?void 0:v._zod.def)==null?void 0:h.error)==null?void 0:k.call(h,e))??be(o==null?void 0:o(e))??be((p=t==null?void 0:t.error)==null?void 0:p.call(t,e))??be((b=n.customError)==null?void 0:b.call(n,e))??be((_=n.localeError)==null?void 0:_.call(n,e))??"Invalid input",a={};for(const j of Object.keys(e))j==="inst"||j==="schema"||j==="continue"||j==="input"||j==="__proto__"||(a[j]=e[j]);return a.path??(a.path=[]),a.message=c,t!=null&&t.reportInput&&(a.input=e.input),a}const Ui=/[\uD800-\uDBFF]/;function Ct(e){const t=e.length;if(!Ui.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function At(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fi(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Ne(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Ki(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Li(e,n,r.value)}}function re(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function uo(e,t,n){return re(e,t,n,!1)}function Mi(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return re(this,n,r(this))},set(s){re(this,n,s)}})}return t}function Li(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:re(this,t,n.bind(this))},set(r){re(this,t,r)}})}function Ji(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let ft,ne=!1;const Vi={configurable:!0,get(){ne=!0}};function $(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&ft!==e._zod){ft=void 0;return}ft=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Vi);const s=ne;ne=!1;try{const o=n(this);return ne?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),ne=ne||s,o}catch(o){throw delete this[t],ne=ne||s,o}},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s})}})}function Hi(e,t,n,r){const s=Ji(e,t);s&&Object.defineProperty(s,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}const Bi="~constantCatch";function Wi(e){const t=()=>e;return t[Bi]=!0,t}var ws;const ht={value:void 0,enumerable:!1};let js="captureStackTrace"in Error?Error:null;function qi(e){const t=js;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return js=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function x(e,t,n,r){const s={};function o(v){this.def=v,this.constr=m,this.traits=new Set}o.prototype=s;const c=n,a=c&&new WeakSet;function l(v,h){if(v._zod){if(v._zod.traits.has(e))return}else{ht.value=new o(h);try{Object.defineProperty(v,"_zod",ht)}finally{ht.value=void 0}}if(v._zod.traits.add(e),t(v,h),a){const p=Object.getPrototypeOf(v),b=v._zod.constr.prototype;let _=p;for(;_&&_!==b;)_=Object.getPrototypeOf(_);const j=_??p;a.has(j)||(a.add(j),Ki(j,c))}const k=m.prototype;for(const p in k)Object.prototype.hasOwnProperty.call(k,p)&&(p in v||(v[p]=k[p].bind(v)))}const g=(r==null?void 0:r.Parent)??Object;class f extends g{}Object.defineProperty(f,"name",{value:e});function m(v){var b;const h=r!=null&&r.Parent?qi(f):this;l(h,v);const k=h._zod.deferred;if(k){for(const _ of k)_();h._zod.deferred=void 0}const p=(b=globalThis.__zod_globalConfig)==null?void 0:b.postProcessor;return p&&p(h),h}return Object.defineProperty(m,"init",{value:l}),Object.defineProperty(m,Symbol.hasInstance,{value:v=>{var h,k;return r!=null&&r.Parent&&v instanceof r.Parent?!0:(k=(h=v==null?void 0:v._zod)==null?void 0:h.traits)==null?void 0:k.has(e)}}),Object.defineProperty(m,"name",{value:e}),m}class ie extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ws=globalThis).__zod_globalConfig??(ws.__zod_globalConfig={});const W=globalThis.__zod_globalConfig;function oe(e){return e&&Object.assign(W,e),W}function Gi(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,kt,2)),e.message}function Xi(e){this._zod.message=e}const Yi={get:Gi,set:Xi,enumerable:!0,configurable:!0},mt={value:void 0,enumerable:!1},Ss=new WeakSet([Object.prototype,Error.prototype]),Qi=(e,t)=>{e.name="$ZodError",mt.value=t,Object.defineProperty(e,"issues",mt),mt.value=void 0,Object.defineProperty(e,"message",Yi);const n=Object.getPrototypeOf(e);Ss.has(n)||(Ss.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Di=x("$ZodError",Qi);function ea(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ta(e,t=n=>n.message){const n={},r=[];for(const s of e.issues)s.path.length>0?ea(n,s.path[0],()=>[]).push(t(s)):r.push(t(s));return{formErrors:r,fieldErrors:n}}function na(e,t=n=>n.message){const n={_errors:[]},r=(s,o=[])=>{for(const c of s.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(a=>r({issues:a},[...o,...c.path]));else if(c.code==="invalid_key")r({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")r({issues:c.issues},[...o,...c.path]);else{const a=[...o,...c.path];if(a.length===0)n._errors.push(t(c));else{let l=n,g=0;for(;g<a.length;){const f=a[g],m=g===a.length-1;if(f==="_errors"){m&&l._errors.push(t(c)),g++;continue}Object.prototype.hasOwnProperty.call(l,f)||Object.defineProperty(l,f,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const v=l[f];m&&v._errors.push(t(c)),l=v,g++}}}};return r(e),n}function Qe(e,t){return{callee:(t==null?void 0:t.callee)??e,Err:t==null?void 0:t.Err}}const It=e=>{const t=(n,r,s,o)=>{const c=s?{...s,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},c);if(a instanceof Promise)throw new ie;if(a.issues.length){const l=new((o==null?void 0:o.Err)??e)(a.issues.map(g=>fe(g,c,oe())));throw so(l,(o==null?void 0:o.callee)??t),l}return a.value};return t},Et=e=>{const t=async(n,r,s,o)=>{const c=s?{...s,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},c);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new((o==null?void 0:o.Err)??e)(a.issues.map(g=>fe(g,c,oe())));throw so(l,(o==null?void 0:o.callee)??t),l}return a.value};return t},Pt=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ie;return o.issues.length?po(e,o.issues,s):{success:!0,data:o.value}};function po(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(s=>fe(s,n,oe()))),t=void 0,n=void 0),r},set error(s){r=s,t=void 0,n=void 0}}}const Zt=e=>async(t,n,r)=>{const s=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?po(e,o.issues,s):{success:!0,data:o.value}},ra=Symbol.for("zod.compile.invalid"),sa=Symbol.for("zod.compile.fallback"),oa=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ra)return!0;if(r.definite===!0&&n===void 0)return!1}return ia(e,t,n)});function ia(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},s=e._zod.bag.fallbackRun;let o;if(s?(r[sa]=!0,o=s({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new ie;return o.issues.length===0}const aa=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let s=e._zod.run({value:t,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length===0},ca=e=>{const t=It(e),n=(r,s,o,c)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,s,a,Qe(n,c))};return n},ua=e=>{const t=It(e),n=(r,s,o,c)=>t(r,s,o,Qe(n,c));return n},la=e=>{const t=Et(e),n=async(r,s,o,c)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,s,a,Qe(n,c))};return n},da=e=>{const t=Et(e),n=async(r,s,o,c)=>await t(r,s,o,Qe(n,c));return n},pa=e=>(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return Pt(e)(t,n,s)},fa=e=>(t,n,r)=>Pt(e)(t,n,r),ha=e=>async(t,n,r)=>{const s=r?{...r,direction:"backward"}:{direction:"backward"};return Zt(e)(t,n,s)},ma=e=>async(t,n,r)=>Zt(e)(t,n,r),ga=/^[cC][0-9a-z]{6,}$/,ya=/^[0-9a-z]+$/,va=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ba=/^[0-9a-vA-V]{20}$/,xa=/^[A-Za-z0-9]{27}$/,ka=/^[a-zA-Z0-9_-]{21}$/;function _a(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const wa=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ja=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ns=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Sa=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Na="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function za(){return new RegExp(Na,"u")}const Oa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$a=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ta=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ca=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Aa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ia=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ea=/^https?$/,Pa=/^\+[1-9]\d{6,14}$/,fo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Za(e){return new RegExp(`^${e}$`)}const Ra=Za(fo);function wt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ua(e){return new RegExp(`^${wt(e)}$`)}function Fa(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${wt({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${wt({precision:e.precision})}`:n;return new RegExp(`^${fo}T(?:${r})$`)}const Ka=/^[\s\S]{0,}$/,Ma=/^[^A-Z]*$/,La=/^[^a-z]*$/,q=x("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Rt=e=>{const t=e.value;return!_i(t)&&t.length!==void 0},Ja=x("$ZodCheckMaxLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=Rt),e._zod.check=r=>{const s=r.value,o=s.length;if((typeof s=="string"&&o>t.maximum?Ct(s):o)<=t.maximum)return;const a=At(s);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Va=x("$ZodCheckMinLength",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=Rt),e._zod.check=r=>{const s=r.value,o=s.length;if((typeof s=="string"&&o>=t.minimum&&o<t.minimum*2?Ct(s):o)>=t.minimum)return;const a=At(s);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Ha=x("$ZodCheckLengthEquals",(e,t)=>{var n;q.init(e,t),(n=e._zod.def).when??(n.when=Rt),e._zod.check=r=>{const s=r.value,o=s.length,c=typeof s=="string"&&o>=t.length&&o<=t.length*2?Ct(s):o;if(c===t.length)return;const a=At(s),l=c>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),De=x("$ZodCheckStringFormat",(e,t)=>{var n,r;q.init(e,t),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ba=x("$ZodCheckRegex",(e,t)=>{De.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Wa=x("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ma),De.init(e,t)}),qa=x("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=La),De.init(e,t)}),Ga=x("$ZodCheckIncludes",(e,t)=>{q.init(e,t);const n=Xe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),Xa=x("$ZodCheckStartsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`^${Xe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ya=x("$ZodCheckEndsWith",(e,t)=>{q.init(e,t);const n=new RegExp(`.*${Xe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Qa=x("$ZodCheckOverwrite",(e,t)=>{q.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Da{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
|
+
`).filter(c=>c),s=Math.min(...r.map(c=>c.length-c.trimStart().length)),o=r.map(c=>c.slice(s)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=(this==null?void 0:this.content)??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
3
|
+
${n.join(`
|
|
4
|
+
`)}
|
|
5
|
+
};`)(...Object.values(this.closed))}}const ec={major:4,minor:6,patch:6},P=x("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ec;const r=e._zod.def.checks,s=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r!=null&&r.length?[...r]:[];for(const c of s)for(const a of c._zod.onattach)a(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const c=(l,g,f)=>{if(l.memo)return l;let m=Y(l),v;for(const h of g){if(h._zod.def.when){if(Ri(l)||!h._zod.def.when(l))continue}else if(m)continue;const k=l.issues.length,p=h._zod.check(l);if(p instanceof Promise&&(f==null?void 0:f.async)===!1)throw new ie;if(v||p instanceof Promise)v=(v??Promise.resolve()).then(async()=>{await p,l.issues.length!==k&&(_t(l.issues,k,e),m||(m=Y(l,k)))});else{if(l.issues.length===k)continue;_t(l.issues,k,e),m||(m=Y(l,k))}}return v?v.then(()=>l):l},a=(l,g,f)=>{if(Y(l))return l.aborted=!0,l;const m=c(g,s,f);if(m instanceof Promise){if(f.async===!1)throw new ie;return m.then(v=>e._zod.parse(v,f))}return e._zod.parse(m,f)};e._zod.run=(l,g)=>{if(g.skipChecks)return e._zod.parse(l,g);if(g.direction==="backward"){const m=e._zod.parse({value:l.value,issues:[]},{...g,skipChecks:!0});return m instanceof Promise?m.then(v=>a(v,l,g)):a(m,l,g)}const f=e._zod.parse(l,g);if(f instanceof Promise){if(g.async===!1)throw new ie;return f.then(m=>c(m,s,g))}return c(f,s,g)}}},{get"~standard"(){return uo(this,"~standard",mo(this))},set"~standard"(e){re(this,"~standard",e)}}),ho=(e,t)=>e.issues.length?{issues:e.issues.map(n=>fe(n,t,oe()))}:{value:e.value};async function tc(e,t){const n={async:!0};return ho(await e._zod.run({value:t,issues:[]},n),n)}function mo(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return ho(r,n)}catch{}return tc(e,t)},vendor:"zod",version:1}}const Ut=x("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=t.pattern??Ka,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),C=x("$ZodStringFormat",(e,t)=>{De.init(e,t),Ut.init(e,t)}),nc=x("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ja),C.init(e,t)}),rc=x("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ns(r))}else t.pattern??(t.pattern=Ns());C.init(e,t)}),sc=x("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Sa),C.init(e,t)}),go=1,Be=2;function yo(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function oc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?yo(e)||Be:ic(e,t)}function ic(e,t){var n;if(!t.normalize&&((n=t.protocol)==null?void 0:n.source)===Ea.source&&!/^https?:\/\//i.test(e))return go;try{if(typeof URL<"u"){const r=URL;if(typeof r.parse=="function")return r.parse(e)??Be}return new URL(e)}catch{return Be}}const ac=/[\t\n\r]/g;function zs(e){return e.replace(ac,"")}function cc(e,t){return t.lastIndex=0,t.test(e.hostname)}function uc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const lc=x("$ZodURL",(e,t)=>{C.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),s=oc(r,t);if(s===go){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(s===Be){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(s===!0){n.value=zs(r);return}t.hostname&&!cc(s,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!uc(s,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?s.href:zs(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),dc=x("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=za()),C.init(e,t)}),pc=x("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?ka:_a(t.length)),C.init(e,t)}),fc=x("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ga),C.init(e,t)}),hc=x("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ya),C.init(e,t)}),mc=x("$ZodULID",(e,t)=>{t.pattern??(t.pattern=va),C.init(e,t)}),gc=x("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ba),C.init(e,t)}),yc=x("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xa),C.init(e,t)}),vc=x("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Fa(t)),C.init(e,t)}),bc=x("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ra),C.init(e,t)}),xc=x("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ua(t)),C.init(e,t)}),kc=x("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wa),C.init(e,t)}),_c=x("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Oa),C.init(e,t)}),wc=/^[0-9a-fA-F:.]+$/;function vo(e){return wc.test(e)?yo(`http://[${e}]`):!1}const jc=x("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=$a),C.init(e,t),e._zod.check=n=>{vo(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Sc=x("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ta),C.init(e,t)});function Nc(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const s=Number(r);return`${s}`!==r||s<0||s>128?!1:vo(n)}const zc=x("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ca),C.init(e,t),e._zod.check=n=>{Nc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function bo(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const xo=/^[0-9a-zA-Z+/]*={0,2}$/,Oc=x("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xo),C.init(e,t),e._zod.check=n=>{bo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ft=/^[A-Za-z0-9_-]*$/;function $c(e){if(!Ft.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return bo(n)}const Tc=x("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ft),C.init(e,t),e._zod.check=n=>{$c(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Cc=x("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Pa),C.init(e,t)});function Ac(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const s=JSON.parse(atob(r));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Ic=x("$ZodJWT",(e,t)=>{C.init(e,t),e._zod.check=n=>{Ac(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ec=x("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=n=>n}),Pc=x("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Zc(e,t){const n=_s(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(o=>o[0])),s=e._zod.parse;e._zod.parse=(o,c)=>{const a=t(o.value);if(a>r&&!(c!=null&&c.skipChecks)&&(c==null?void 0:c.direction)!=="backward"){for(const[l,g]of _s(e._zod.def.checks))if(a>l&&g._zod.def.when(o)){const f=o.issues.length;return g._zod.check(o),o.issues[f].continue=!1,_t(o.issues,f,e),o}}return s(o,c)}}const Rc=e=>Array.isArray(e)?e.length:-1;function Os(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}const Uc=x("$ZodArray",(e,t)=>{P.init(e,t);const n=W.memoizer;n==null||n.attach(e),e._zod.parse=(r,s)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),s):Array(o.length);const c=[],a=s==null?void 0:s.abortEarly;for(let l=0;l<o.length;l++){const g=o[l],f=t.element._zod.run({value:g,issues:[]},s);if(f instanceof Promise)c.push(f.then(m=>Os(m,r,l)));else if(Os(f,r,l),a&&f.issues.length!==0&&Y(f))break}return c.length?Promise.all(c).then(()=>r):r},Zc(e,Rc)});function We(e,t,n,r,s,o){const c=n in r,a=o==="optional";if(!(!c&&a&&s==="optional")){if(e.issues.length){if(s!==void 0&&a&&!c)return;t.issues.push(...co(n,e.issues))}if(!c&&s===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(c||s==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const Fc=[];function ko(e){var c,a,l,g;const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Fc,s=r.length?[...t,...r]:t;for(const f of s)if(!((g=(l=(a=(c=e.shape)==null?void 0:c[f])==null?void 0:a._zod)==null?void 0:l.traits)!=null&&g.has("$ZodType")))throw new Error(`Invalid element at key "${String(f)}": expected a Zod schema`);const o=Oi(e.shape);return{...e,allKeys:s,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function _o(e,t,n,r,s,o,c){const a=[],l=s.keySet,g=s.catchall._zod,f=g.def.type,m=g.optin,v=g.optout;let h=0;for(const k in t){if(c&&n.issues.length!==h){if(Y(n,h))break;h=n.issues.length}if(l.has(k))continue;if(k==="__proto__"){f==="never"&&a.push(k);continue}if(f==="never"){a.push(k);continue}const p=g.run({value:t[k],issues:[]},r);p instanceof Promise?e.push(p.then(b=>We(b,n,k,t,m,v))):We(p,n,k,t,m,v)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Kc=x("$ZodObject",(e,t)=>{P.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n!=null&&n.get?n.get.raw:t.shape??{};if(r){const g=()=>{const f={...r};return Object.defineProperty(t,"shape",{value:f}),g.raw=f,f};g.raw=r,Object.defineProperty(t,"shape",{get:g})}const s=$t(()=>ko(t));$(e,"propValues",g=>{const f=g.def.shape,m={};for(const v in f){const h=f[v]._zod;if(h.values){Object.prototype.hasOwnProperty.call(m,v)||ce(m,v,new Set);for(const k of h.values)m[v].add(k);h.optin!==void 0&&m[v].add(void 0)}}return m});const o=He,c=t.catchall;let a;const l=W.memoizer;l==null||l.attach(e),e._zod.parse=(g,f)=>{a??(a=s.value);const m=g.value;if(!o(m))return g.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),g;g.value=l?l.alloc(e,g,{},f):{};const v=[],h=a.shape,k=f==null?void 0:f.abortEarly;let p=g.issues.length;for(const b of a.allKeys){if(k&&g.issues.length!==p){if(Y(g,p))break;p=g.issues.length}if(b==="__proto__")continue;const _=h[b],j=_._zod.optin,R=_._zod.optout,I=_._zod.run({value:m[b],issues:[]},f);I instanceof Promise?v.push(I.then(H=>We(H,g,b,m,j,R))):We(I,g,b,m,j,R)}return c?_o(v,m,g,f,s.value,e,k===!0):v.length?Promise.all(v).then(()=>g):g}}),Mc=x("$ZodObjectJIT",(e,t)=>{Kc.init(e,t);const n=e._zod.parse,r=$t(()=>ko(t)),s=W.memoizer,o=h=>{var H,D;const k=r.value,p=k.symbolKeys,b=new Da(["payload","ctx"],{shape:h,inst:e,memo:s,syms:p}),_=T=>`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`,j=(T,z)=>`
|
|
6
|
+
let ${T}_ab = false;
|
|
7
|
+
for (let i = 0; i < ${T}.issues.length; i++) {
|
|
8
|
+
const iss = ${T}.issues[i];
|
|
9
|
+
iss.path = iss.path ? [${z}, ...iss.path] : [${z}];
|
|
10
|
+
payload.issues.push(iss);
|
|
11
|
+
if (iss.continue !== true) ${T}_ab = true;
|
|
12
|
+
}
|
|
13
|
+
if (${T}_ab && ctx && ctx.abortEarly) {
|
|
14
|
+
payload.value = newResult;
|
|
15
|
+
return payload;
|
|
16
|
+
}`;b.write("const input = payload.value;");const R=Object.create(null);let I=0;for(const T of k.allKeys)R[T]=`key_${I++}`;b.write(s?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const T of k.allKeys){if(T==="__proto__")continue;const z=R[T],F=typeof T=="symbol"?`syms[${p.indexOf(T)}]`:ji(T),ee=`${F} in input`,L=h[T],B=(H=L==null?void 0:L._zod)==null?void 0:H.optin,M=B!==void 0,me=((D=L==null?void 0:L._zod)==null?void 0:D.optout)==="optional";if(b.write(`const ${z} = ${_(F)};`),M&&me){const et=B==="optional"?`${z}_present`:`${z}.value !== undefined || ${z}_present`;b.write(`
|
|
17
|
+
const ${z}_present = ${ee};
|
|
18
|
+
if (!${z}.issues.length || ${z}_present) {
|
|
19
|
+
if (${z}.issues.length) {${j(z,F)}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (${et}) {
|
|
23
|
+
newResult[${F}] = ${z}.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
`)}else M?(b.write(`
|
|
28
|
+
if (${z}.issues.length) {${j(z,F)}
|
|
29
|
+
}
|
|
30
|
+
`),B==="defaulted"?b.write(`newResult[${F}] = ${z}.value;`):b.write(`
|
|
31
|
+
if (${z}.value !== undefined || ${ee}) {
|
|
32
|
+
newResult[${F}] = ${z}.value;
|
|
33
|
+
}
|
|
34
|
+
`)):b.write(`
|
|
35
|
+
const ${z}_present = ${ee};
|
|
36
|
+
if (${z}.issues.length) {${j(z,F)}
|
|
37
|
+
}
|
|
38
|
+
if (!${z}_present && !${z}.issues.length) {
|
|
39
|
+
payload.issues.push({
|
|
40
|
+
code: "invalid_type",
|
|
41
|
+
expected: "nonoptional",
|
|
42
|
+
input: undefined,
|
|
43
|
+
path: [${F}]
|
|
44
|
+
});
|
|
45
|
+
if (ctx && ctx.abortEarly) {
|
|
46
|
+
payload.value = newResult;
|
|
47
|
+
return payload;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (${z}_present) {
|
|
52
|
+
newResult[${F}] = ${z}.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
`)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()};let c;const a=He,l=!W.jitless,f=l&&Ni.value,m=t.catchall;let v;e._zod.parse=(h,k)=>{v??(v=r.value);const p=h.value;return a(p)?l&&f&&(k==null?void 0:k.async)===!1&&k.jitless!==!0?(c||(c=o(t.shape)),h=c(h,k),m?_o([],p,h,k,v,e,(k==null?void 0:k.abortEarly)===!0):h):n(h,k):(h.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),h)}});function $s(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const s=e.filter(o=>!Y(o));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>fe(c,r,oe())))}),t)}const Lc=x("$ZodUnion",(e,t)=>{P.init(e,t),$(e,"optin",r=>r.def.options.some(s=>s._zod.optin==="defaulted")?"defaulted":r.def.options.some(s=>s._zod.optin!==void 0)?"optional":void 0),$(e,"optout",r=>r.def.options.some(s=>s._zod.optout==="optional")?"optional":void 0),$(e,"values",r=>{if(r.def.options.every(s=>s._zod.values))return new Set(r.def.options.flatMap(s=>Array.from(s._zod.values)))}),$(e,"pattern",r=>{if(r.def.options.every(s=>s._zod.pattern)){const s=r.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${s.map(o=>Tt(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,s)=>{if(n)return n(r,s);let o=!1;const c=[];for(const a of t.options){const l=a._zod.run({value:r.value,issues:[]},s);if(l instanceof Promise)c.push(l),o=!0;else{if(l.issues.length===0)return l;c.push(l)}}return o?Promise.all(c).then(a=>$s(a,r,e,s)):$s(c,r,e,s)}}),Jc=x("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(n,r)=>{const s=n.value,o=t.left._zod.run({value:s,issues:[]},r),c=t.right._zod.run({value:s,issues:[]},r);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([l,g])=>Ts(n,l,g)):Ts(n,o,c)}});function jt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Se(e)&&Se(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),s={...e,...t};Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__;for(const o of r){if(o==="__proto__")continue;const c=jt(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};s[o]=c.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const s=e[r],o=t[r],c=jt(s,o);if(!c.valid)return{valid:!1,mergeErrorPath:[r,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ts(e,t,n){const r=new Map;let s;const o=new Map,c=(g,f)=>{var v,h;let m;if(g.code==="unrecognized_keys"&&!((v=g.path)!=null&&v.length))s??(s=g),m=g.keys;else if(g.code==="invalid_key"&&g.origin==="record"&&((h=g.path)==null?void 0:h.length)===1){const k=String(g.path[0]);o.has(k)||o.set(k,g),m=[k]}else return!1;for(const k of m)r.has(k)||r.set(k,{}),r.get(k)[f]=!0;return!0};for(const g of t.issues)c(g,"l")||e.issues.push(g);for(const g of n.issues)c(g,"r")||e.issues.push(g);const a=[...r].filter(([,g])=>g.l&&g.r).map(([g])=>g);if(a.length){const g=s?a.filter(f=>s.keys.includes(f)):[];g.length&&e.issues.push({...s,keys:g});for(const f of a)!g.includes(f)&&o.has(f)&&e.issues.push(o.get(f))}const l=jt(t.value,n.value);if(!l.valid){if(Y(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`)}return e.value=l.data,e}const Vc=x("$ZodEnum",(e,t)=>{P.init(e,t);const n=xt(t.entries),r=new Set(n);e._zod.values=r,$(e,"pattern",s=>{const o=xt(s.def.entries).filter(c=>zi.has(typeof c));return new RegExp(o.length?`^(${o.map(c=>Xe(c.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(s,o)=>{const c=s.value;return r.has(c)||s.issues.push({code:"invalid_value",values:n,input:c,inst:e}),s}}),Hc=x("$ZodTransform",(e,t)=>{var n;P.init(e,t),e._zod.optin="optional",(n=W.memoizer)==null||n.guard(e),e._zod.parse=(r,s)=>{if(s.direction==="backward")throw new lo(e.constructor.name);const o=t.transform(r.value,r);if(s.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new ie;return r.value=o,r}});function Cs(e,t){return e.value=t.issues.length?void 0:t.value,e}const wo=x("$ZodOptional",(e,t)=>{P.init(e,t),$(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",$(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),$(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Tt(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const s=t.innerType._zod.run({value:n.value,issues:[]},r);return s instanceof Promise?s.then(o=>Cs(n,o)):Cs(n,s)}return t.innerType._zod.run(n,r)}}),Bc=x("$ZodExactOptional",(e,t)=>{wo.init(e,t),$(e,"values",n=>n.def.innerType._zod.values),$(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Wc=x("$ZodNullable",(e,t)=>{P.init(e,t),$(e,"optin",n=>n.def.innerType._zod.optin),$(e,"optout",n=>n.def.innerType._zod.optout),$(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Tt(r.source)}|null)$`):void 0}),$(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),qc=x("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="defaulted",$(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(o=>As(o,t)):As(s,t)}});function As(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gc=x("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="defaulted",$(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Xc=x("$ZodNonOptional",(e,t)=>{P.init(e,t),$(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,r)=>{const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(o=>Is(o,e)):Is(s,e)}});function Is(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Es(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(s=>fe(s,r,oe()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Yc=x("$ZodCatch",(e,t)=>{P.init(e,t),$(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),$(e,"optout",n=>n.def.innerType._zod.optout),$(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run({value:n.value,issues:[]},r);return s instanceof Promise?s.then(o=>Es(n,o,t,r)):Es(n,s,t,r)}}),Qc=x("$ZodPipe",(e,t)=>{P.init(e,t),$(e,"values",n=>n.def.in._zod.values),$(e,"optin",n=>n.def.in._zod.optin),$(e,"optout",n=>n.def.out._zod.optout),$(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(c=>Ue(c,t.in,r)):Ue(o,t.in,r)}const s=t.in._zod.run(n,r);return s instanceof Promise?s.then(o=>Ue(o,t.out,r)):Ue(s,t.out,r)}});function Ue(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Dc=x("$ZodReadonly",(e,t)=>{P.init(e,t),$(e,"propValues",n=>n.def.innerType._zod.propValues),$(e,"values",n=>n.def.innerType._zod.values),$(e,"optin",n=>{var r,s;return(s=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:s.optin}),$(e,"optout",n=>{var r,s;return(s=(r=n.def.innerType)==null?void 0:r._zod)==null?void 0:s.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(Ps):Ps(s)}});function Ps(e){return e.memo||(e.value=Object.freeze(e.value)),e}const eu=x("$ZodCustom",(e,t)=>{q.init(e,t),P.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(o=>Zs(o,n,r,e));Zs(s,n,r,e)}});function Zs(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(Ne(s))}}class tu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const St="~memo",Rs=[];function jo(e){return e!==null&&typeof e=="object"}function gt(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const So=new WeakMap,xe=0,Je=1,_e=2;function Ve(e,t,n){const r=So.get(e);if(r!==void 0)return r?_e:xe;if(t.has(e))return _e;t.add(e);let s=xe;const o=f=>{if(s!==_e&&(f!=null&&f._zod)){const m=Ve(f,t);m>s&&(s=m)}},c=(f,m)=>{var h;let v=xe;for(const k of Reflect.ownKeys(f)){const p=Object.getOwnPropertyDescriptor(f,k);if(!p.enumerable)continue;const b=p.get?Je:(h=p.value)!=null&&h._zod?Ve(p.value,t):xe;b>v&&(v=b)}return v},a=f=>{f>s&&(s=f)},l=e._zod.def;switch(l.type){case"object":{const f=to(l);a(f?c(f):Je),o(l.catchall);break}case"array":o(l.element);break;case"tuple":for(const f of l.items)o(f);o(l.rest);break;case"record":case"map":o(l.keyType),o(l.valueType);break;case"set":o(l.valueType);break;case"union":for(const f of l.options)o(f);break;case"intersection":o(l.left),o(l.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(l.innerType);break;case"pipe":o(l.in),o(l.out);break;case"function":o(l.input),o(l.output);break;case"lazy":{const f=l._cachedInner??void 0;a(f?Ve(f,t):Je);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const f in l){const m=Object.getOwnPropertyDescriptor(l,f);if(!m||m.get)continue;const v=m.value;if(!(!v||typeof v!="object")){if(v._zod)o(v);else if(Array.isArray(v))for(const h of v)o(h)}}}return t.delete(e),nu(e,s)}function nu(e,t){return t!==Je&&So.set(e,t===_e),t}function ru(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let Fe;const Ke=[],su={alloc(e,t,n){const r=Fe;if(!r)return n;Fe=void 0;const s={value:n,issues:null};return r.set(t.value,s),Ke.push(s),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(s,o)=>{if(o.direction!=="backward"&&iu(o,s.value))throw new tu;return n(s,o)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,s,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const c=e._zod.parse,a=(l,g)=>{if(n===void 0){const _=Ve(e,new Set);if(_===xe)return e._zod.parse=c,e._zod.run===a&&(e._zod.run=c),c(l,g);_===_e||r?n=!0:r=!0}const f=l.value;if(!jo(f))return c(l,g);let m=g[St];m||(m={buckets:new WeakMap,backEdges:void 0},g[St]=m);let v;s===g?v=o:(v=ru(m,e),s=g,o=v);const h=v.get(f);if(h)return l.value=h.value,h.issues?h.issues.length&&l.issues.push(...gt(h.issues)):(l.memo=!0,m.backEdges??(m.backEdges=new WeakSet),m.backEdges.add(h.value)),l;Fe=v;const k=Ke.length,p=c(l,g);Fe=void 0;const b=Ke.length>k?Ke.pop():void 0;return p instanceof Promise?p.then(_=>(b&&(b.issues=_.issues.length?gt(_.issues):Rs),_)):(b&&(b.issues=p.issues.length?gt(p.issues):Rs),p)};e._zod.parse=a,e._zod.run===c&&(e._zod.run=a)})}};function ou(){return su}function iu(e,t){var r;const n=(r=e[St])==null?void 0:r.backEdges;return n!==void 0&&jo(t)&&n.has(t)}const au=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function s(o,c){return o==="number"&&typeof c=="number"&&!Number.isFinite(c)?String(c):r[o]??o}return o=>{switch(o.code){case"invalid_type":{const c=s(o.expected),a=Fi(o.input),l=s(a,o.input);return`Invalid input: expected ${c}, received ${l}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${io(o.values[0])}`:`Invalid option: expected one of ${xs(o.values,"|")}`;case"too_big":{const c=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${c}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${c}${o.maximum.toString()}`}case"too_small":{const c=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${c}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${c}${o.minimum.toString()}`}case"invalid_format":{const c=o;return c.format==="starts_with"?`Invalid string: must start with "${c.prefix}"`:c.format==="ends_with"?`Invalid string: must end with "${c.suffix}"`:c.format==="includes"?`Invalid string: must include "${c.includes}"`:c.format==="regex"?`Invalid string: must match pattern ${c.pattern}`:`Invalid ${n[c.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${xs(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(a=>`'${a}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function cu(){return{localeError:au()}}var Us;class uu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const s={...r,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function lu(){return new uu}(Us=globalThis).__zod_globalRegistry??(Us.__zod_globalRegistry=lu());const ke=globalThis.__zod_globalRegistry;function du(e){return e.checks&&(e.checks=[...e.checks]),e}function pu(e,t){return new e(du({type:"string",...w(t)}))}function fu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function hu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function mu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function gu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function yu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function vu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function No(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function bu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function xu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function ku(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function _u(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function wu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function ju(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function Su(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Nu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function zu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Ou(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function $u(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Tu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Cu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function Au(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Iu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Eu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Pu(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function Zu(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function Ru(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function Uu(e){return new e({type:"unknown"})}function Fu(e,t){return new e({type:"never",...w(t)})}function zo(e,t){return new Ja({check:"max_length",...w(t),maximum:e})}function qe(e,t){return new Va({check:"min_length",...w(t),minimum:e})}function Oo(e,t){return new Ha({check:"length_equals",...w(t),length:e})}function Ku(e,t){return new Ba({check:"string_format",format:"regex",...w(t),pattern:e})}function Mu(e){return new Wa({check:"string_format",format:"lowercase",...w(e)})}function Lu(e){return new qa({check:"string_format",format:"uppercase",...w(e)})}function Ju(e,t){return new Ga({check:"string_format",format:"includes",...w(t),includes:e})}function Vu(e,t){return new Xa({check:"string_format",format:"starts_with",...w(t),prefix:e})}function Hu(e,t){return new Ya({check:"string_format",format:"ends_with",...w(t),suffix:e})}function he(e){return new Qa({check:"overwrite",tx:e})}function Bu(e){return he(t=>t.normalize(e))}function Wu(){return he(e=>e.trim())}function qu(){return he(e=>e.toLowerCase())}function Gu(){return he(e=>e.toUpperCase())}function Xu(){return he(e=>Si(e))}function Yu(e,t,n){return new e({type:"array",element:t,...w(n)})}function Qu(e,t,n){return new e({type:"custom",check:"custom",fn:t,...w(n)})}function Du(e,t){const n=el(r=>(r.addIssue=s=>{if(typeof s=="string")r.issues.push(Ne(s,r.value,n._zod.def));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(Ne(o))}},e(r.value,r)),t);return n}function el(e,t){const n=new q({check:"custom",...w(t)});return n._zod.check=e,n}function we(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&ce(e,r,n[r]);return e}function $o(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??ke,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",intersections:[],deferred:[],external:(e==null?void 0:e.external)??void 0}}function ze(e,t,n,r,s){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:s}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(s);return Object.assign(n,o),!0}function U(e,t,n={path:[],schemaPath:[]}){var f,m;var r;const s=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=(m=(f=e._zod).toJSONSchema)==null?void 0:m.call(f);if(a)c.schema=a;else{const v={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,v);else{const k=c.schema,p=t.processors[s.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);p(e,t,k,v)}const h=e._zod.parent;h&&(c.ref||(c.ref=h),U(h,t,v),t.seen.get(h).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&we(c.schema,l),t.io==="input"&&K(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((r=c.schema).default??(r.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function Fs(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function To(e,t){var c,a,l,g;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const f of e.seen.entries()){const m=(c=e.metadataRegistry.get(f[0]))==null?void 0:c.id;if(m){const v=r.get(m);if(v&&v!==f[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,f[0])}}const s=f=>{var p;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const b=(p=e.external.registry.get(f[0]))==null?void 0:p.id,_=e.external.uri??(R=>R);if(b)return{ref:_(b)};const j=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=j,{defId:j,ref:`${_("__shared")}#/${m}/${Fs(j)}`}}const v="#",h=`${v}/${m}/`;if(f[1]===n&&!f[1].schema.id)return{ref:v};const k=f[1].schema.id??`__schema${e.counter++}`;return{defId:k,ref:h+Fs(k)}},o=f=>{if(f[1].schema.$ref)return;const m=f[1],{ref:v,defId:h}=s(f);m.def={...m.schema},h&&(m.defId=h);const k=m.schema;for(const p in k)delete k[p];k.$ref=v};if(e.cycles==="throw")for(const f of e.seen.entries()){const m=f[1];if(m.cycle)throw new Error(`Cycle detected: #/${(a=m.cycle)==null?void 0:a.join("/")}/<root>
|
|
56
|
+
|
|
57
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const m=f[1];if(t===f[0]){o(f);continue}if(e.external){const h=(l=e.external.registry.get(f[0]))==null?void 0:l.id;if(t!==f[0]&&h){o(f);continue}}if((g=e.metadataRegistry.get(f[0]))==null?void 0:g.id){o(f);continue}if(m.cycle){o(f);continue}m.count>1&&e.reused==="ref"&&o(f)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Co(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;Co(r);const s=Object.keys(r);if(s.length!==1||s[0]!=="type")return;const o=r.type;for(const c of Array.isArray(o)?o:[o]){if(typeof c!="string")return;n.includes(c)||n.push(c)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Ao=new Set(["type","properties","required","additionalProperties"]),Ks=["oneOf","anyOf"];function Ms(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Nt(e){var o;const t=[];for(const c of e){if(typeof c!="object"||c.type!=="object")return null;for(const a in c)if(!Ao.has(a))return null;t.push(c)}const n={},r=new Set;for(const c of t){for(const a in c.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;const l=[];for(const f of t){const m=((o=f.properties)==null?void 0:o[a])??Ms(f);m!=null&&(l.some(v=>JSON.stringify(v)===JSON.stringify(m))||l.push(m))}const g=l.length===1?l[0]:Nt(l)??{allOf:l};ce(n,a,g)}for(const a of c.required??[])r.add(a)}const s={type:"object",properties:n};if(r.size&&(s.required=[...r]),t.every(c=>c.additionalProperties===!1))s.additionalProperties=!1;else{const c=[];for(const a of t){const l=Ms(a);l&&!c.some(g=>JSON.stringify(g)===JSON.stringify(l))&&c.push(l)}c.length===1?s.additionalProperties=c[0]:c.length>1&&(s.additionalProperties={allOf:c})}return s}function tl(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const s of Ao)if(s in e)return;const n=t.filter(s=>Ks.some(o=>Array.isArray(s[o])));let r=null;if(!n.length)r=Nt(t);else{const s=n[0],o=Ks.find(l=>Array.isArray(s[l]));if(Object.keys(s).length!==1)return;const c=t.filter(l=>l!==s),a=s[o].map(l=>Nt([...c,l]));if(a.some(l=>!l))return;r={[o]:a}}r&&(delete e.allOf,we(e,r))}function Io(e,t){var a,l,g,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const v=e.seen.get(m);if(v.ref===null)return;const h=v.def??v.schema,k={...h},p=v.ref;if(v.ref=null,p){r(p);const _=e.seen.get(p),j=_.schema;if(j.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(h.allOf=h.allOf??[],h.allOf.push(j)):we(h,j),we(h,k),m._zod.parent===p)for(const I in h)I==="$ref"||I==="allOf"||I in k||delete h[I];if(j.$ref&&_.def)for(const I in h)I==="$ref"||I==="allOf"||I in _.def&&JSON.stringify(h[I])===JSON.stringify(_.def[I])&&delete h[I]}const b=m._zod.parent;if(b&&b!==p){r(b);const _=e.seen.get(b);if(_!=null&&_.schema.$ref&&(h.$ref=_.schema.$ref,_.def))for(const j in h)j==="$ref"||j==="allOf"||j in _.def&&JSON.stringify(h[j])===JSON.stringify(_.def[j])&&delete h[j]}e.override({zodSchema:m,jsonSchema:h,path:v.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const m of[...e.seen.entries()].reverse())r(m[0]);if(e.target!=="openapi-3.0")for(const m of e.seen.entries())Co(m[1].def??m[1].schema);for(const m of e.deferred)m();if(e.intersections.length){const m=new Map;for(const v of e.seen.values())for(const h of[v.schema,v.def]){const k=h==null?void 0:h.allOf;if(!Array.isArray(k))continue;const p=m.get(k);p?p.push(h):m.set(k,[h])}for(const v of e.intersections)for(const h of m.get(v)??[])tl(h)}}const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,(a=e.external)!=null&&a.uri){const m=(l=e.external.registry.get(t))==null?void 0:l.id;if(!m)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(m)}we(s,n.defId?n.schema:n.def??n.schema);const o=(g=e.metadataRegistry.get(t))==null?void 0:g.id;o!==void 0&&s.id===o&&delete s.id;const c=((f=e.external)==null?void 0:f.defs)??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const m of e.seen.entries()){const v=m[1];v.def&&v.defId&&(v.def.id===v.defId&&delete v.def.id,ce(c,v.defId,v.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?s.$defs=c:s.definitions=c);try{const m=JSON.parse(JSON.stringify(s));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ge(t,"input",e.processors),output:Ge(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function K(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return K(r.element,n);if(r.type==="set")return K(r.valueType,n);if(r.type==="lazy")return K(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return K(r.innerType,n);if(r.type==="intersection")return K(r.left,n)||K(r.right,n);if(r.type==="record"||r.type==="map")return K(r.keyType,n)||K(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:K(r.in,n)||K(r.out,n);if(r.type==="object"){for(const s in r.shape)if(K(r.shape[s],n))return!0;return!1}if(r.type==="union"){for(const s of r.options)if(K(s,n))return!0;return!1}if(r.type==="tuple"){for(const s of r.items)if(K(s,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const nl=(e,t={})=>n=>{const r=$o({...n,processors:t});return U(e,r),To(r,e),Io(r,e)},Ge=(e,t,n={})=>r=>{const{libraryOptions:s,target:o}=r??{},c=$o({...s??{},target:o,io:t,processors:n});return U(e,c),To(c,e),Io(c,e)},de=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},pe=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ls=(e,t)=>{de(e,"minimum",t),pe(e,"maximum",t)},Eo=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Po=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Zo=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Ro=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Js=(e,t)=>de(e,"minimum",t.minimum),Vs=(e,t)=>pe(e,"maximum",t.maximum),Hs=e=>(t,n)=>{Ro(t,n.format);const[r,s]=e[n.format];de(t,"minimum",r),pe(t,"maximum",s)},yt={greater_than:(e,t)=>de(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>pe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Eo(e,t.value),number_format:Hs($i),bigint_format:Hs(Ti),min_length:Js,max_length:Vs,length_equals:(e,t)=>Ls(e,t.length),min_size:Js,max_size:Vs,size_equals:(e,t)=>Ls(e,t.size),string_format:(e,t)=>{Ro(e,t.format),t.pattern&&Po(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Zo(e,t.mime)};function je(e){var o;const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const c of r)(o=yt[c._zod.def.check])==null||o.call(yt,t,c._zod.def);const s=e._zod.bag;s.minimum!==void 0&&de(t,"minimum",s.minimum),s.exclusiveMinimum!==void 0&&de(t,"exclusiveMinimum",s.exclusiveMinimum),s.maximum!==void 0&&pe(t,"maximum",s.maximum),s.exclusiveMaximum!==void 0&&pe(t,"exclusiveMaximum",s.exclusiveMaximum),s.multipleOf!==void 0&&Eo(t,s.multipleOf),s.format!==void 0&&(t.format??(t.format=s.format),s.format.includes("int")&&(t.isInt=!0)),s.mime&&Zo(t,s.mime);for(const c of s.patterns??[])Po(t,c);return t}const rl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sl=new Map([[xo,Aa],[Ft,Ia]]),ol=e=>sl.get(e)??e,il=(e,t,n,r)=>{const s=n;s.type="string";const{minimum:o,maximum:c,format:a,patterns:l,contentEncoding:g,laxFormat:f}=je(e);if(typeof o=="number"&&(s.minLength=o),typeof c=="number"&&(s.maxLength=c),a&&(s.format=rl[a]??a,s.format===""&&delete s.format,(a==="time"||f)&&delete s.format),g&&(s.contentEncoding=g),l&&l.size>0){const m=[...l].map(ol);m.length===1?s.pattern=m[0].source:m.length>1&&(s.allOf=[...m.map(v=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:v.source}))])}},al=(e,t,n,r)=>{n.not={}},cl=(e,t,n,r)=>{},ul=(e,t,n,r)=>{const s=e._zod.def,o=xt(s.entries);if(o.length===0){n.not={};return}o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},ll=(e,t,n,r)=>{ze(e,t,n,r,"Custom types cannot be represented in JSON Schema")},dl=(e,t,n,r)=>{ze(e,t,n,r,"Transforms cannot be represented in JSON Schema")},pl=(e,t,n,r)=>{const s=n,o=e._zod.def,{minimum:c,maximum:a}=je(e);typeof c=="number"&&(s.minItems=c),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=U(o.element,t,{...r,path:[...r.path,"items"]})};function zt(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?zt(t.out):t.type==="catch"?zt(t.innerType):e._zod.optin}const fl=(e,t,n,r)=>{var g;const s=n,o=e._zod.def,c=o.shape;if(Object.getOwnPropertySymbols(c).length&&ze(e,t,s,r,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(const f in c)ce(s.properties,f,U(c[f],t,{...r,path:[...r.path,"properties",f]}));const l=[];for(const f of Object.keys(c)){const m=o.shape[f];(t.io==="input"?zt(m)===void 0:m._zod.optout===void 0)&&l.push(f)}l.length>0&&(s.required=l),((g=o.catchall)==null?void 0:g._zod.def.type)==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=U(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},hl=(e,t,n,r)=>{const s=e._zod.def,o=s.inclusive===!1,c=s.options.map((a,l)=>U(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",l]}));o?n.oneOf=c:n.anyOf=c},ml=(e,t,n,r)=>{const s=e._zod.def,o=U(s.left,t,{...r,path:[...r.path,"allOf",0]}),c=U(s.right,t,{...r,path:[...r.path,"allOf",1]}),a=g=>"allOf"in g&&Object.keys(g).length===1,l=[...a(o)?o.allOf:[o],...a(c)?c.allOf:[c]];n.allOf=l,t.intersections.push(l)},gl=(e,t,n,r)=>{const s=e._zod.def,o=U(s.innerType,t,r),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=s.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},yl=(e,t,n,r)=>{const s=e._zod.def;U(s.innerType,t,r);const o=t.seen.get(e);o.ref=s.innerType},Kt=Symbol();function Uo(e,t,n,r,s){let o=!1;const c=JSON.stringify(e,(a,l)=>typeof l!="bigint"?l:(o=!0,null));return o?(ze(t,n,r,s,"BigInt defaults cannot be represented in JSON Schema"),Kt):JSON.parse(c)}const vl=(e,t,n,r)=>{const s=e._zod.def;U(s.innerType,t,r);const o=t.seen.get(e);o.ref=s.innerType;const c=Uo(s.defaultValue,e,t,n,r);c!==Kt&&(n.default=c)},bl=(e,t,n,r)=>{const s=e._zod.def;U(s.innerType,t,r);const o=t.seen.get(e);if(o.ref=s.innerType,t.io!=="input")return;const c=Uo(s.defaultValue,e,t,n,r);c!==Kt&&(n._prefault=c)},xl=(e,t,n,r)=>{const s=e._zod.def;U(s.innerType,t,r);const o=t.seen.get(e);o.ref=s.innerType;let c;try{c=s.catchValue(void 0)}catch{ze(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=c},kl=(e,t,n,r)=>{const s=e._zod.def,o=s.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?o?s.out:s.in:s.out;U(c,t,r);const a=t.seen.get(e);a.ref=c},_l=(e,t,n,r)=>{const s=e._zod.def;U(s.innerType,t,r);const o=t.seen.get(e);o.ref=s.innerType,n.readOnly=!0},Fo=(e,t,n,r)=>{const s=e._zod.def;U(s.innerType,t,r);const o=t.seen.get(e);o.ref=s.innerType},Bs=new WeakSet([Object.prototype,Error.prototype]);function Me(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const wl=(e,t)=>{Di.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Bs.has(n)||(Bs.add(n),Me(n,"format",r=>s=>na(r,s)),Me(n,"flatten",r=>s=>ta(r,s)),Me(n,"addIssue",r=>s=>{r.issues.push(s),r.message=JSON.stringify(r.issues,kt,2)}),Me(n,"addIssues",r=>s=>{r.issues.push(...s),r.message=JSON.stringify(r.issues,kt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},V=x("ZodError",wl,void 0,{Parent:Error}),jl=It(V),Sl=Et(V),Nl=Pt(V),zl=Zt(V),Ol=ca(V),$l=ua(V),Tl=la(V),Cl=da(V),Al=pa(V),Il=fa(V),El=ha(V),Pl=ma(V);function Zl(){W.localeError||oe(cu())}function Mt(){W.memoizer||oe({memoizer:ou()})}const Z=x("ZodType",(e,t)=>(Zl(),P.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(J(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return se(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Id(e,t))},superRefine(e,t){return this.check(Ed(e,t))},overwrite(e){return this.check(he(e))},optional(){return qs(this)},exactOptional(){return xd(this)},nullable(){return Gs(this)},nullish(){return qs(Gs(this))},nonoptional(e){return Nd(this,e)},array(){return Lo(this)},or(e){return hd([this,e])},and(e){return gd(this,e)},transform(e){return Xs(this,bd(e))},default(e){return wd(this,e)},prefault(e){return Sd(this,e)},catch(e){return Od(this,e)},pipe(e){return Xs(this,e)},readonly(){return Cd(this)},describe(e){const t=this.clone();return ke.add(t,{description:e}),t},meta(...e){if(e.length===0)return ke.get(this);const t=this.clone();return ke.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return uo(this,"~standard",{...mo(this),jsonSchema:{input:Ge(this,"input"),output:Ge(this,"output")}})},set"~standard"(e){re(this,"~standard",e)},parse:function e(t,n){return jl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Sl(this,t,n,{callee:e})},safeParse(e,t){return Nl(this,e,t)},async safeParseAsync(e,t){return zl(this,e,t)},get spa(){return this==null?void 0:this.safeParseAsync},set spa(e){re(this,"spa",e)},validate(e,t){return oa(this,e,t)},validateAsync(e,t){return aa(this,e,t)},encode:function e(t,n){return Ol(this,t,n,{callee:e})},decode:function e(t,n){return $l(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Tl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Cl(this,t,n,{callee:e})},safeEncode(e,t){return Al(this,e,t)},safeDecode(e,t){return Il(this,e,t)},async safeEncodeAsync(e,t){return El(this,e,t)},async safeDecodeAsync(e,t){return Pl(this,e,t)},toJSONSchema(e){return nl(this,{})(e)},get description(){var e;return(e=ke.get(this))==null?void 0:e.description},get _def(){return this._zod.def}}),Ko=x("_ZodString",(e,t)=>{Ut.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>il(e,n,r)},Mi({format:e=>je(e).format??null,minLength:e=>je(e).minimum??null,maxLength:e=>je(e).maximum??null},{regex(...e){return this.check(Ku(...e))},includes(...e){return this.check(Ju(...e))},startsWith(...e){return this.check(Vu(...e))},endsWith(...e){return this.check(Hu(...e))},min(...e){return this.check(qe(...e))},max(...e){return this.check(zo(...e))},length(...e){return this.check(Oo(...e))},nonempty(...e){return this.check(qe(1,...e))},lowercase(e){return this.check(Mu(e))},uppercase(e){return this.check(Lu(e))},trim(){return this.check(Wu())},normalize(...e){return this.check(Bu(...e))},toLowerCase(){return this.check(qu())},toUpperCase(){return this.check(Gu())},slugify(){return this.check(Xu())}})),Rl=x("ZodString",(e,t)=>{Ut.init(e,t),Ko.init(e,t)},{email(e){return this.check(fu(Jl,e))},url(e){return this.check(No(Mo,e))},jwt(e){return this.check(Iu(id,e))},emoji(e){return this.check(bu(Bl,e))},guid(e){return this.check(hu(Vl,e))},uuid(e){return this.check(mu(Le,e))},uuidv4(e){return this.check(gu(Le,e))},uuidv6(e){return this.check(yu(Le,e))},uuidv7(e){return this.check(vu(Le,e))},nanoid(e){return this.check(xu(Wl,e))},cuid(e){return this.check(ku(ql,e))},cuid2(e){return this.check(_u(Gl,e))},ulid(e){return this.check(wu(Xl,e))},base64(e){return this.check(Tu(rd,e))},base64url(e){return this.check(Cu(sd,e))},xid(e){return this.check(ju(Yl,e))},ksuid(e){return this.check(Su(Ql,e))},ipv4(e){return this.check(Nu(Dl,e))},ipv6(e){return this.check(zu(ed,e))},cidrv4(e){return this.check(Ou(td,e))},cidrv6(e){return this.check($u(nd,e))},e164(e){return this.check(Au(od,e))},datetime(e){return this.check(Eu(Fl,e))},date(e){return this.check(Pu(Kl,e))},time(e){return this.check(Zu(Ml,e))},duration(e){return this.check(Ru(Ll,e))}});function Ul(e){return pu(Rl,e)}const A=x("ZodStringFormat",(e,t)=>{C.init(e,t),Ko.init(e,t)}),Fl=x("ZodISODateTime",(e,t)=>{vc.init(e,t),A.init(e,t)}),Kl=x("ZodISODate",(e,t)=>{bc.init(e,t),A.init(e,t)}),Ml=x("ZodISOTime",(e,t)=>{xc.init(e,t),A.init(e,t)}),Ll=x("ZodISODuration",(e,t)=>{kc.init(e,t),A.init(e,t)}),Jl=x("ZodEmail",(e,t)=>{sc.init(e,t),A.init(e,t)}),Vl=x("ZodGUID",(e,t)=>{nc.init(e,t),A.init(e,t)}),Le=x("ZodUUID",(e,t)=>{rc.init(e,t),A.init(e,t)}),Mo=x("ZodURL",(e,t)=>{lc.init(e,t),A.init(e,t)});function Hl(e){return No(Mo,e)}const Bl=x("ZodEmoji",(e,t)=>{dc.init(e,t),A.init(e,t)}),Wl=x("ZodNanoID",(e,t)=>{pc.init(e,t),A.init(e,t)}),ql=x("ZodCUID",(e,t)=>{fc.init(e,t),A.init(e,t)}),Gl=x("ZodCUID2",(e,t)=>{hc.init(e,t),A.init(e,t)}),Xl=x("ZodULID",(e,t)=>{mc.init(e,t),A.init(e,t)}),Yl=x("ZodXID",(e,t)=>{gc.init(e,t),A.init(e,t)}),Ql=x("ZodKSUID",(e,t)=>{yc.init(e,t),A.init(e,t)}),Dl=x("ZodIPv4",(e,t)=>{_c.init(e,t),A.init(e,t)}),ed=x("ZodIPv6",(e,t)=>{jc.init(e,t),A.init(e,t)}),td=x("ZodCIDRv4",(e,t)=>{Sc.init(e,t),A.init(e,t)}),nd=x("ZodCIDRv6",(e,t)=>{zc.init(e,t),A.init(e,t)}),rd=x("ZodBase64",(e,t)=>{Oc.init(e,t),A.init(e,t)}),sd=x("ZodBase64URL",(e,t)=>{Tc.init(e,t),A.init(e,t)}),od=x("ZodE164",(e,t)=>{Cc.init(e,t),A.init(e,t)}),id=x("ZodJWT",(e,t)=>{Ic.init(e,t),A.init(e,t)}),ad=x("ZodUnknown",(e,t)=>{Ec.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>cl()});function Ws(){return Uu(ad)}const cd=x("ZodNever",(e,t)=>{Pc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>al(e,n,r)});function ud(e){return Fu(cd,e)}const ld=x("ZodArray",(e,t)=>{Mt(),Uc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>pl(e,n,r,s),e.element=t.element},{min(e,t){return this.check(qe(e,t))},nonempty(e){return this.check(qe(1,e))},max(e,t){return this.check(zo(e,t))},length(e,t){return this.check(Oo(e,t))},unwrap(){return this.element}});function Lo(e,t){return Yu(ld,e,t)}const dd=x("ZodObject",(e,t)=>{Mt(),Mc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>fl(e,n,r,s),Hi(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return yd(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(J(this._zod.def,{catchall:e}))},passthrough(){return this.clone(J(this._zod.def,{catchall:Ws()}))},loose(){return this.clone(J(this._zod.def,{catchall:Ws()}))},strict(){return this.clone(J(this._zod.def,{catchall:ud()}))},strip(){return this.clone(J(this._zod.def,{catchall:void 0}))},extend(e){return Ii(this,e)},safeExtend(e){return Ei(this,e)},merge(e){return Pi(this,e)},pick(e){return Ci(this,e)},omit(e){return Ai(this,e)},partial(...e){return ks(Jo,this,e[0])},exactPartial(...e){return ks(Vo,this,e[0],"exactPartial")},required(...e){return Zi(Ho,this,e[0])}});function pd(e,t){const n={type:"object",shape:e??{},...w(t)};return new dd(n)}const fd=x("ZodUnion",(e,t)=>{Lc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>hl(e,n,r,s),e.options=t.options});function hd(e,t){return new fd({type:"union",options:e,...w(t)})}const md=x("ZodIntersection",(e,t)=>{Jc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>ml(e,n,r,s)});function gd(e,t){return new md({type:"intersection",left:e,right:t})}const Ot=x("ZodEnum",(e,t)=>{Vc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(r,s,o)=>ul(e,r,s),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,s)=>{const o={};for(const c of r)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new Ot({...t,checks:[],...w(s),entries:o})},e.exclude=(r,s)=>{const o={...t.entries};for(const c of r)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new Ot({...t,checks:[],...w(s),entries:o})}});function yd(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Ot({type:"enum",entries:n,...w(t)})}const vd=x("ZodTransform",(e,t)=>{Mt(),Hc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>dl(e,n,r,s),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new lo(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ne(o,n.value,t));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),"input"in c||(c.input=n.value),c.inst??(c.inst=e),n.issues.push(Ne(c))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(o=>(n.value=o,n)):(n.value=s,n)}});function bd(e){return new vd({type:"transform",transform:e})}const Jo=x("ZodOptional",(e,t)=>{wo.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Fo(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function qs(e){return new Jo({type:"optional",innerType:e})}const Vo=x("ZodExactOptional",(e,t)=>{Bc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>Fo(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function xd(e){return new Vo({type:"optional",innerType:e})}const kd=x("ZodNullable",(e,t)=>{Wc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>gl(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new kd({type:"nullable",innerType:e})}const _d=x("ZodDefault",(e,t)=>{qc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>vl(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function wd(e,t){return new _d({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():oo(t)}})}const jd=x("ZodPrefault",(e,t)=>{Gc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>bl(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function Sd(e,t){return new jd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():oo(t)}})}const Ho=x("ZodNonOptional",(e,t)=>{Xc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>yl(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function Nd(e,t){return new Ho({type:"nonoptional",innerType:e,...w(t)})}const zd=x("ZodCatch",(e,t)=>{Yc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>xl(e,n,r,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Od(e,t){return new zd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Wi(t)})}const $d=x("ZodPipe",(e,t)=>{Qc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>kl(e,n,r,s),e.in=t.in,e.out=t.out});function Xs(e,t){return new $d({type:"pipe",in:e,out:t})}const Td=x("ZodReadonly",(e,t)=>{Dc.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>_l(e,n,r,s),e.unwrap=()=>e._zod.def.innerType});function Cd(e){return new Td({type:"readonly",innerType:e})}const Ad=x("ZodCustom",(e,t)=>{eu.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,r,s)=>ll(e,n,r,s)});function Id(e,t={}){return Qu(Ad,e,t)}function Ed(e,t){return Du(e,t)}const vt=Hl().refine(e=>{const t=new URL(e);return["http:","https:"].includes(t.protocol)&&!t.username&&!t.password&&!t.hash}),Pd=pd({issuer:vt.refine(e=>!new URL(e).search),authorization_endpoint:vt.refine(e=>!new URL(e).search),token_endpoint:vt,response_types_supported:Lo(Ul()).min(1)}).passthrough(),Zd=(e,t)=>{const n=[...new Set(e.split(/\s+/).filter(Boolean))];if(!n.length||n.length>16||n.some(s=>{try{const o=new URL(s);return o.protocol!=="https:"||o.origin!==s}catch{return!0}}))throw new Error("server.oauth.relayOriginsInvalid");let r;try{r=Pd.parse(JSON.parse(t))}catch{throw new Error("server.oauth.relayMetadataInvalid")}return{authorizationRelay:{allowedRedirectOrigins:n},authorizationServerMetadata:r}},Ys=e=>{const t={};return e.forEach(({key:n,value:r})=>{const s=n.trim();s&&(t[s]=r)}),t},Bo=e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0):[],Qs=e=>Array.from(new Set((e||[]).map(t=>t.trim()).filter(t=>t.length>0))),Rd=e=>{const t={};if(typeof(e==null?void 0:e.timeout)=="number"&&!Number.isNaN(e.timeout)&&(t.timeout=e.timeout),typeof(e==null?void 0:e.resetTimeoutOnProgress)=="boolean"&&(t.resetTimeoutOnProgress=e.resetTimeoutOnProgress),e!=null&&e.maxTotalTimeout&&(t.maxTotalTimeout=e.maxTotalTimeout),(e==null?void 0:e.maxBufferSize)!==void 0){if(!Number.isSafeInteger(e.maxBufferSize)||e.maxBufferSize<=0)throw new Error("options.maxBufferSize must be a positive safe integer in bytes");t.maxBufferSize=e.maxBufferSize}return t},Ud=e=>{var f,m,v,h,k,p,b,_;if(!e)return{};const t={};e.identityMode&&(t.identityMode=e.identityMode),e.allowInsecureTokenEndpoint!==void 0&&(t.allowInsecureTokenEndpoint=e.allowInsecureTokenEndpoint);const n=(f=e.clientId)==null?void 0:f.trim(),r=(m=e.clientSecret)==null?void 0:m.trim(),s=(v=e.scopes)==null?void 0:v.trim(),o=(h=e.accessToken)==null?void 0:h.trim(),c=(k=e.refreshToken)==null?void 0:k.trim(),a=(p=e.authorizationEndpoint)==null?void 0:p.trim(),l=(b=e.tokenEndpoint)==null?void 0:b.trim(),g=(_=e.resource)==null?void 0:_.trim();if(n&&(t.clientId=n),r&&(t.clientSecret=r),s){const j=s.split(/[\s,]+/).map(R=>R.trim()).filter(R=>R.length>0);j.length>0&&(t.scopes=j)}return o&&e.identityMode!=="personal"&&(t.accessToken=o),c&&e.identityMode!=="personal"&&(t.refreshToken=c),a&&(t.authorizationEndpoint=a),l&&(t.tokenEndpoint=l),g&&(t.resource=g),e.authorizationRelay&&(t.authorizationRelay=e.authorizationRelay),e.authorizationServerMetadata&&(t.authorizationServerMetadata=e.authorizationServerMetadata),e.dynamicRegistration&&(t.dynamicRegistration=e.dynamicRegistration),e.revocationEndpoint&&(t.revocationEndpoint=e.revocationEndpoint),e.redirectUri&&(t.redirectUri=e.redirectUri),t.identityMode==="shared"&&Object.keys(t).length===1&&delete t.identityMode,t},Fd=e=>{var a,l,g,f,m,v,h,k,p,b,_,j,R,I,H,D,T,z,F,ee,L,B,M;const t={version:((a=e.openapi)==null?void 0:a.version)||"3.1.0",passthroughHeaders:Bo((l=e.openapi)==null?void 0:l.passthroughHeaders),cookieSession:((g=e.openapi)==null?void 0:g.cookieSession)===!0?!0:void 0},n=(m=(f=e.openapi)==null?void 0:f.oauth2TokenUrl)==null?void 0:m.trim(),r=(h=(v=e.openapi)==null?void 0:v.oauth2ClientId)==null?void 0:h.trim(),s=(p=(k=e.openapi)==null?void 0:k.oauth2ClientSecret)==null?void 0:p.trim(),o=(_=(b=e.openapi)==null?void 0:b.oauth2Token)==null?void 0:_.trim();if(((j=e.openapi)==null?void 0:j.inputMode)==="url")t.url=((R=e.openapi)==null?void 0:R.url)||"";else if(((I=e.openapi)==null?void 0:I.inputMode)==="schema"&&((H=e.openapi)!=null&&H.schema))try{t.schema=JSON.parse(e.openapi.schema)}catch{throw new Error("Invalid JSON schema format")}(D=e.openapi)!=null&&D.securityType&&e.openapi.securityType!=="none"&&(t.security={type:e.openapi.securityType,...e.openapi.securityType==="apiKey"&&{apiKey:{name:e.openapi.apiKeyName||"",in:e.openapi.apiKeyIn||"header",value:e.openapi.apiKeyValue||""}},...e.openapi.securityType==="http"&&{http:{scheme:e.openapi.httpScheme||"bearer",credentials:e.openapi.httpCredentials||""}},...e.openapi.securityType==="oauth2"&&{oauth2:{...n&&{tokenUrl:n},...r&&{clientId:r},...s&&{clientSecret:s},...o&&{token:o}}},...e.openapi.securityType==="openIdConnect"&&{openIdConnect:{url:e.openapi.openIdConnectUrl||"",token:e.openapi.openIdConnectToken||""}}});const c=(T=e.openapi)==null?void 0:T.specSecurityType;return c&&c!=="none"&&(t.specSecurity={type:c,...c==="apiKey"&&{apiKey:{name:((z=e.openapi)==null?void 0:z.specApiKeyName)||"",in:((F=e.openapi)==null?void 0:F.specApiKeyIn)||"header",value:((ee=e.openapi)==null?void 0:ee.specApiKeyValue)||""}},...c==="http"&&{http:{scheme:((L=e.openapi)==null?void 0:L.specHttpScheme)||"basic",credentials:((B=e.openapi)==null?void 0:B.specHttpCredentials)||""}},...c==="oauth2"&&{oauth2:{token:((M=e.openapi)==null?void 0:M.specOauth2Token)||""}}}),t},bt=({formData:e,serverType:t,envVars:n,headerVars:r})=>{var g,f,m,v,h;const s=Ys(n),o=Ys(r),c=Rd(e.options),a=((g=e.description)==null?void 0:g.trim())||"",l={type:t,description:a,options:c,visibility:e.visibility??"private",sharedWithUserGroups:e.visibility==="group"?Qs(e.sharedWithUserGroups):void 0,sharedWithUsers:e.visibility==="group"?Qs(e.sharedWithUsers):void 0,credentialTemplate:(f=e.credentialTemplate)==null?void 0:f.map(k=>({...k,target:t==="stdio"?k.target==="args"?"args":"env":k.target==="url"?"url":"headers"})),perSessionClient:e.perSessionClient===!0?!0:void 0,startOnDemand:e.startOnDemand===!0?!0:void 0,idleTimeoutMs:e.startOnDemand===!0||(m=e.credentialTemplate)!=null&&m.length?e.idleTimeoutMs??3e5:void 0,proxy:e.proxy};if(t==="openapi")l.headers=o,l.openapi=Fd(e);else if(t==="sse"||t==="streamable-http"){const k=((v=e.keepAlive)==null?void 0:v.enabled)===!0;l.protocolNegotiation=t==="streamable-http"?e.protocolNegotiation:void 0,l.url=e.url.trim(),l.env=s,l.headers=o,l.passthroughHeaders=Bo(e.passthroughHeaders),l.oauth=Ud(e.oauth),l.enableKeepAlive=k,l.keepAliveInterval=k?((h=e.keepAlive)==null?void 0:h.interval)||6e4:void 0}else l.command=e.command.trim(),l.args=e.args,l.env=s;return{name:e.name.trim(),config:l}},Kd=(e=[],t=[])=>Array.from(new Set([...e,...t])).sort((n,r)=>n.localeCompare(r)),Md=(e,t)=>{const n=t.trim().toLowerCase();return n?e.filter(r=>r.toLowerCase().includes(n)):[...e]},Ld=(e,t)=>Array.from(new Set([...e,...t])),Jd=(e,t)=>{const n=new Set(t);return e.filter(r=>!n.has(r))};function Wo(e,t=!1){if(t)return!1;const n=e.openapi;return n&&n.securityType&&n.securityType!=="none"?!1:!(n!=null&&n.apiKeyValue)&&!(n!=null&&n.httpCredentials)&&!(n!=null&&n.oauth2TokenUrl)&&!(n!=null&&n.oauth2ClientId)&&!(n!=null&&n.oauth2ClientSecret)&&!(n!=null&&n.oauth2Token)&&!(n!=null&&n.openIdConnectUrl)&&!(n!=null&&n.openIdConnectToken)}function Vd(e,t,n=!1){var s,o,c,a,l;if(!t.declared||!t.supported||!t.prefill||!Wo(e,n))return e;const r=t.prefill;return{...e,openapi:{...e.openapi,securityType:r.type,apiKeyName:((s=r.apiKey)==null?void 0:s.name)||"",apiKeyIn:((o=r.apiKey)==null?void 0:o.in)||"header",apiKeyValue:"",httpScheme:((c=r.http)==null?void 0:c.scheme)||"bearer",httpCredentials:"",oauth2TokenUrl:((a=r.oauth2)==null?void 0:a.tokenUrl)||"",oauth2ClientId:"",oauth2ClientSecret:"",oauth2Token:"",openIdConnectUrl:((l=r.openIdConnect)==null?void 0:l.url)||"",openIdConnectToken:""}}}function Hd(e,t){var r,s,o;if(!t.prefill)return!1;const n=e.openapi;if((n==null?void 0:n.securityType)!==t.prefill.type)return!0;switch(n==null?void 0:n.securityType){case"apiKey":return n.apiKeyName!==((r=t.prefill.apiKey)==null?void 0:r.name)||n.apiKeyIn!==((s=t.prefill.apiKey)==null?void 0:s.in);case"http":return n.httpScheme!==((o=t.prefill.http)==null?void 0:o.scheme);default:return!1}}function Bd(e){const t=e.openapi,n=t==null?void 0:t.securityType;if(!n||n==="none")return null;switch(n){case"apiKey":return`API key in ${(t==null?void 0:t.apiKeyIn)||"header"} '${(t==null?void 0:t.apiKeyName)||""}'`;case"http":return`HTTP ${(t==null?void 0:t.httpScheme)||"bearer"}`;case"oauth2":return"OAuth2";case"openIdConnect":return"OpenID Connect";default:return null}}function Wd(e,t,n={}){return t!=null&&t.declared?!Wo(e,n.securityTouched)&&Hd(e,t)?{kind:"warning",messageKey:"securityMismatchWarning",values:{summary:t.summary,configured:Bd(e)||"none"}}:t.supported?{kind:"info",messageKey:"securityPrefillNotice",values:{summary:t.summary}}:{kind:"warning",messageKey:"securityUnsupportedNotice",values:{summary:t.summary,reason:t.unsupportedReason||""}}:n.includeNotDeclared?{kind:"info",messageKey:"securityNotDeclared",values:{}}:null}function Ds(e){var r,s,o,c;const t=((r=e.openapi)==null?void 0:r.inputMode)==="schema"?"schema":"url",n=((c=t==="schema"?(s=e.openapi)==null?void 0:s.schema:(o=e.openapi)==null?void 0:o.url)==null?void 0:c.trim())||"";return{mode:t,value:n,key:n?`${t}:${n}`:""}}function qo(e){if(!e.value)return!1;if(e.mode==="schema")try{const t=JSON.parse(e.value);return t!==null&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}try{const t=new URL(e.value);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function qd(e){return!e.isEdit&&e.serverType==="openapi"&&qo(e.source)&&e.source.key!==e.analyzedSourceKey}const Go=/^[A-Za-z0-9._-]+$/,Lt=128,eo=e=>{const t=e.trim();return t.length>0&&t.length<=Lt&&Go.test(t)&&!t.includes("..")},np=e=>e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/\.{2,}/g,".").replace(/^-+|-+$/g,"").slice(0,Lt)||"server",rp=({onSubmit:e,onCancel:t,initialData:n=null,modalTitle:r,formError:s=null,mode:o,shareCandidatesFrom:c=null})=>{var on,an,cn,un,ln,dn,pn,fn,hn,mn,gn,yn,vn,bn,xn,kn,_n,wn,jn,Sn,Nn,zn,On,$n,Tn,Cn,An,In,En,Pn,Zn,Rn,Un,Fn,Kn,Mn,Ln,Jn,Vn,Hn,Bn,Wn,qn,Gn,Xn,Yn,Qn,Dn,er,tr,nr,rr,sr,or,ir,ar,cr,ur,lr,dr,pr,fr,hr,mr,gr,yr,vr,br,xr,kr,_r,wr,jr,Sr,Nr,zr,Or,$r,Tr,Cr,Ar,Ir,Er,Pr,Zr,Rr,Ur,Fr,Kr,Mr,Lr,Jr,Vr,Hr,Br,Wr,qr,Gr,Xr,Yr,Qr,Dr,es,ts,ns,rs,ss,os,is,as,cs,us,ls,ds,ps,fs,hs,ms,gs,ys,vs,bs;const{t:a}=bi(),{auth:l}=fi(),g=!(n!=null&&n.name)||eo(n.name),f=()=>!n||!n.config?"stdio":n.config.type?n.config.type:n.config.url?"sse":"stdio",m=d=>!d||!d.config||!d.config.env?[]:Object.entries(d.config.env).map(([u,y])=>({key:u,value:y,description:""})),v=d=>{var y;const u=(y=d==null?void 0:d.config)==null?void 0:y.oauth;return{identityMode:(u==null?void 0:u.identityMode)||"shared",clientId:(u==null?void 0:u.clientId)||"",...(u==null?void 0:u.allowInsecureTokenEndpoint)!==void 0&&{allowInsecureTokenEndpoint:u.allowInsecureTokenEndpoint},clientSecret:(u==null?void 0:u.clientSecret)||"",scopes:u!=null&&u.scopes?u.scopes.join(" "):"",accessToken:(u==null?void 0:u.accessToken)||"",refreshToken:(u==null?void 0:u.refreshToken)||"",authorizationEndpoint:(u==null?void 0:u.authorizationEndpoint)||"",tokenEndpoint:(u==null?void 0:u.tokenEndpoint)||"",resource:(u==null?void 0:u.resource)||"",...(u==null?void 0:u.authorizationRelay)&&{authorizationRelay:u.authorizationRelay},...(u==null?void 0:u.authorizationServerMetadata)&&{authorizationServerMetadata:u.authorizationServerMetadata},...(u==null?void 0:u.dynamicRegistration)&&{dynamicRegistration:u.dynamicRegistration},...(u==null?void 0:u.revocationEndpoint)&&{revocationEndpoint:u.revocationEndpoint},...(u==null?void 0:u.redirectUri)&&{redirectUri:u.redirectUri}}},[h,k]=O.useState(f()),[p,b]=O.useState({name:n&&n.name||"",description:n&&n.config&&n.config.description||"",url:n&&n.config&&n.config.url||"",command:n&&n.config&&n.config.command||"",arguments:"",args:n&&n.config&&n.config.args||[],type:f(),env:m(n),headers:[],passthroughHeaders:((an=(on=n==null?void 0:n.config)==null?void 0:on.passthroughHeaders)==null?void 0:an.join(", "))||"",visibility:((cn=n==null?void 0:n.config)==null?void 0:cn.visibility)??"private",sharedWithUsers:((un=n==null?void 0:n.config)==null?void 0:un.sharedWithUsers)||[],sharedWithUserGroups:((ln=n==null?void 0:n.config)==null?void 0:ln.sharedWithUserGroups)||[],options:{maxBufferSize:(pn=(dn=n==null?void 0:n.config)==null?void 0:dn.options)==null?void 0:pn.maxBufferSize,timeout:n&&n.config&&n.config.options&&n.config.options.timeout||6e4,resetTimeoutOnProgress:((hn=(fn=n==null?void 0:n.config)==null?void 0:fn.options)==null?void 0:hn.resetTimeoutOnProgress)??!0,maxTotalTimeout:n&&n.config&&n.config.options&&n.config.options.maxTotalTimeout||void 0},oauth:v(n),keepAlive:{enabled:((mn=n==null?void 0:n.config)==null?void 0:mn.enableKeepAlive)===!0,interval:((gn=n==null?void 0:n.config)==null?void 0:gn.keepAliveInterval)||6e4},perSessionClient:((yn=n==null?void 0:n.config)==null?void 0:yn.perSessionClient)===!0,protocolNegotiation:(vn=n==null?void 0:n.config)==null?void 0:vn.protocolNegotiation,credentialTemplate:((bn=n==null?void 0:n.config)==null?void 0:bn.credentialTemplate)||[],proxy:(xn=n==null?void 0:n.config)==null?void 0:xn.proxy,startOnDemand:((kn=n==null?void 0:n.config)==null?void 0:kn.startOnDemand)===!0,idleTimeoutMs:((_n=n==null?void 0:n.config)==null?void 0:_n.idleTimeoutMs)??3e5,openapi:n&&n.config&&n.config.openapi?{url:n.config.openapi.url||"",schema:n.config.openapi.schema?JSON.stringify(n.config.openapi.schema,null,2):"",inputMode:n.config.openapi.url?"url":n.config.openapi.schema?"schema":"url",version:n.config.openapi.version||"3.1.0",securityType:((wn=n.config.openapi.security)==null?void 0:wn.type)||"none",apiKeyName:((Sn=(jn=n.config.openapi.security)==null?void 0:jn.apiKey)==null?void 0:Sn.name)||"",apiKeyIn:((zn=(Nn=n.config.openapi.security)==null?void 0:Nn.apiKey)==null?void 0:zn.in)||"header",apiKeyValue:(($n=(On=n.config.openapi.security)==null?void 0:On.apiKey)==null?void 0:$n.value)||"",httpScheme:((Cn=(Tn=n.config.openapi.security)==null?void 0:Tn.http)==null?void 0:Cn.scheme)||"bearer",httpCredentials:((In=(An=n.config.openapi.security)==null?void 0:An.http)==null?void 0:In.credentials)||"",oauth2TokenUrl:((Pn=(En=n.config.openapi.security)==null?void 0:En.oauth2)==null?void 0:Pn.tokenUrl)||"",oauth2ClientId:((Rn=(Zn=n.config.openapi.security)==null?void 0:Zn.oauth2)==null?void 0:Rn.clientId)||"",oauth2ClientSecret:((Fn=(Un=n.config.openapi.security)==null?void 0:Un.oauth2)==null?void 0:Fn.clientSecret)||"",oauth2Token:((Mn=(Kn=n.config.openapi.security)==null?void 0:Kn.oauth2)==null?void 0:Mn.token)||"",openIdConnectUrl:((Jn=(Ln=n.config.openapi.security)==null?void 0:Ln.openIdConnect)==null?void 0:Jn.url)||"",openIdConnectToken:((Hn=(Vn=n.config.openapi.security)==null?void 0:Vn.openIdConnect)==null?void 0:Hn.token)||"",specSecurityType:["apiKey","http","oauth2"].includes((Bn=n.config.openapi.specSecurity)==null?void 0:Bn.type)?n.config.openapi.specSecurity.type:"none",specApiKeyName:((qn=(Wn=n.config.openapi.specSecurity)==null?void 0:Wn.apiKey)==null?void 0:qn.name)||"",specApiKeyIn:((Xn=(Gn=n.config.openapi.specSecurity)==null?void 0:Gn.apiKey)==null?void 0:Xn.in)||"header",specApiKeyValue:((Qn=(Yn=n.config.openapi.specSecurity)==null?void 0:Yn.apiKey)==null?void 0:Qn.value)||"",specHttpScheme:((er=(Dn=n.config.openapi.specSecurity)==null?void 0:Dn.http)==null?void 0:er.scheme)==="bearer"?"bearer":"basic",specHttpCredentials:((nr=(tr=n.config.openapi.specSecurity)==null?void 0:tr.http)==null?void 0:nr.credentials)||"",specOauth2Token:((sr=(rr=n.config.openapi.specSecurity)==null?void 0:rr.oauth2)==null?void 0:sr.token)||"",passthroughHeaders:n.config.openapi.passthroughHeaders?n.config.openapi.passthroughHeaders.join(", "):"",cookieSession:n.config.openapi.cookieSession===!0}:{inputMode:"url",url:"",schema:"",version:"3.1.0",securityType:"none",specSecurityType:"none",passthroughHeaders:"",cookieSession:!1}}),[_,j]=O.useState([]),[R,I]=O.useState([]),[H,D]=O.useState(!1),[T,z]=O.useState(!1),[F,ee]=O.useState(""),L=c||(n==null?void 0:n.name);O.useEffect(()=>{if(p.visibility!=="group"||!L)return;let d=!1;return D(!0),z(!1),hi(`/servers/${encodeURIComponent(L)}/share-candidates`).then(u=>{d||(u.success&&Array.isArray(u.data)?(j(u.data),I(u.userGroups||[])):z(!0))}).catch(()=>{d||z(!0)}).finally(()=>{d||D(!1)}),()=>{d=!0}},[p.visibility,L]);const B=Kd(p.sharedWithUsers||[],_),M=Md(B,F),me=new Set(p.sharedWithUsers||[]),et=M.length>0&&M.every(d=>me.has(d)),Xo=M.length===0||M.every(d=>!me.has(d)),Yo=d=>{b(u=>{const y=new Set(u.sharedWithUsers||[]);return y.has(d)?y.delete(d):y.add(d),{...u,sharedWithUsers:Array.from(y)}})},Qo=()=>{b(d=>({...d,sharedWithUsers:Ld(d.sharedWithUsers||[],M)}))},Do=()=>{b(d=>({...d,sharedWithUsers:Jd(d.sharedWithUsers||[],M)}))},[G,tt]=O.useState(n&&n.config&&n.config.env?Object.entries(n.config.env).map(([d,u])=>({key:d,value:u})):[]),[X,nt]=O.useState(n&&n.config&&n.config.headers?Object.entries(n.config.headers).map(([d,u])=>({key:d,value:u})):[]),[ge,Jt]=O.useState(null),[rt,ye]=O.useState(!1),[ei,st]=O.useState(!1),ot=O.useRef(0),Vt=O.useRef(null),Ht=O.useRef(!1),it=O.useRef(!!n),Oe=O.useRef(p);Oe.current=p;const Bt=O.useRef(G);Bt.current=G;const Wt=O.useRef(X);Wt.current=X;const[$e,Te]=O.useState(null),[qt,Gt]=O.useState(!1),[at,ti]=O.useState(!1),[ct,ni]=O.useState(!1),[Xt,ri]=O.useState(((ar=(ir=(or=n==null?void 0:n.config)==null?void 0:or.oauth)==null?void 0:ir.authorizationRelay)==null?void 0:ar.allowedRedirectOrigins.join(`
|
|
58
|
+
`))||""),[Yt,si]=O.useState((ur=(cr=n==null?void 0:n.config)==null?void 0:cr.oauth)!=null&&ur.authorizationServerMetadata?JSON.stringify(n.config.oauth.authorizationServerMetadata,null,2):""),[ut,oi]=O.useState(!1),[lt,ii]=O.useState(!1),[Qt,Ce]=O.useState(null),ue=o?o==="edit":!!n,ai=()=>{it.current=!0,Te(null)},Ae=d=>{const{name:u,value:y}=d.target;b({...p,[u]:y})},Ie=d=>{k(d),b(u=>({...u,type:d}))},Ee=(d,u,y)=>{const S=[...G];S[d][u]=y,tt(S)},Dt=()=>{tt([...G,{key:"",value:""}])},en=d=>{const u=[...G];u.splice(d,1),tt(u)},Pe=(d,u,y)=>{const S=[...X];S[d][u]=y,nt(S)},tn=()=>{nt([...X,{key:"",value:""}])},nn=d=>{const u=[...X];u.splice(d,1),nt(u)},le=(d,u)=>{b(y=>({...y,oauth:{...y.oauth||{},[d]:u}}))},Ze=(d,u)=>{b(y=>({...y,options:{...y.options,[d]:u}}))},ci=async d=>{try{const u=await mi("/servers/openapi/tool-stats",{config:d.config},{signal:AbortSignal.timeout(6e4)});return u.success&&u.data?u.data:null}catch{return null}},rn=async(d,u,y)=>{const S=++ot.current;ye(!0),st(!1);const N=await ci(d);if(ot.current!==S)return;if(!N){st(!0),ye(!1);return}Vt.current=u,Jt(N);const E=Oe.current,ve=it.current,te=N.declaredSecurity,di=y.allowSecurityPrefill&&!ve&&!ue&&!Ht.current;y.consumeAutomaticAnalysis&&(Ht.current=!0);const dt=te!=null&&te.declared&&te.supported&&di?Vd(E,te,ve):E;dt!==E&&(Oe.current=dt,b(dt)),Te(Wd(E,te,{includeNotDeclared:!0,securityTouched:ve})),ye(!1)},ui=async()=>{Gt(!0);try{const d=bt({formData:p,serverType:h,envVars:G,headerVars:X});await rn(d,Ds(p).key,{allowSecurityPrefill:!ue&&!it.current,consumeAutomaticAnalysis:!1})}catch{}finally{Gt(!1)}},Re=Ds(p),sn=h==="openapi"&&qo(Re);O.useEffect(()=>{if(ot.current+=1,Jt(null),st(!1),ye(!1),Te(null),!qd({isEdit:ue,serverType:h,source:Re,analyzedSourceKey:Vt.current}))return;ye(!0);const d=window.setTimeout(()=>{const u=bt({formData:Oe.current,serverType:h,envVars:Bt.current,headerVars:Wt.current});rn(u,Re.key,{allowSecurityPrefill:!0,consumeAutomaticAnalysis:!0})},600);return()=>{window.clearTimeout(d)}},[ue,Re.key,h]);const li=async d=>{var y,S;if(d.preventDefault(),Ce(null),(!(n!=null&&n.name)||p.name!==n.name)&&!eo(p.name)){Ce(a("server.nameInvalid"));return}try{const N=bt({formData:(y=p.oauth)!=null&&y.authorizationRelay?{...p,oauth:{...p.oauth,...Zd(Xt,Yt)}}:p,serverType:h,envVars:G,headerVars:X}),E=xi(N.config,(S=l.user)==null?void 0:S.isAdmin);if(E){Ce(a(E));return}e(N)}catch(N){Ce(N instanceof Error&&N.message.startsWith("server.oauth.relay")?a(N.message):`Error: ${N instanceof Error?N.message:String(N)}`)}};return i.jsxs("div",{className:"hub-card p-6 w-full max-w-3xl max-h-screen overflow-y-auto",children:[i.jsxs("div",{className:"flex justify-between items-center mb-5",children:[i.jsx("h2",{className:"text-lg font-semibold text-[var(--hub-ink)]",children:r}),i.jsx("button",{onClick:t,className:"hub-icon-btn","aria-label":"Close",children:i.jsx(pt,{size:16})})]}),(Qt||s)&&i.jsx("div",{role:"alert",className:"bg-red-50 text-red-700 p-3 rounded mb-4",children:s||Qt}),i.jsxs("form",{onSubmit:li,children:[i.jsxs("div",{className:"mb-5",children:[i.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)] mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:a("server.sectionBasicInfo","Basic Info")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[i.jsxs("div",{className:"md:col-span-1",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"name",children:a("server.name")}),i.jsx("input",{type:"text",name:"name",id:"name",value:p.name,onChange:Ae,className:"w-full py-2 px-3 form-input",placeholder:"e.g.: time-mcp",pattern:g?Go.source:void 0,maxLength:g?Lt:void 0,title:a("server.nameInvalid"),required:!0})]}),i.jsxs("div",{className:"md:col-span-2",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"description",children:a("server.description")}),i.jsx("input",{type:"text",name:"description",id:"description",value:p.description||"",onChange:Ae,className:"w-full py-2 px-3 form-input",placeholder:a("server.descriptionPlaceholder")})]})]})]}),i.jsxs("div",{className:"mb-5",children:[i.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)] mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:a("server.sectionConnection","Connection")}),((lr=l.user)==null?void 0:lr.isAdmin)!==!0&&i.jsx("p",{id:"local-execution-permission",className:"text-sm text-amber-700 dark:text-amber-300 mb-3",children:a("server.localExecutionRequiresAdmin")}),i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:a("server.type")}),i.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2",children:[i.jsxs("div",{children:[i.jsx("input",{type:"radio",id:"command",name:"serverType",value:"command",disabled:((dr=l.user)==null?void 0:dr.isAdmin)!==!0,"aria-describedby":(pr=l.user)!=null&&pr.isAdmin?void 0:"local-execution-permission",checked:h==="stdio",onChange:()=>Ie("stdio"),className:"mr-1"}),i.jsx("label",{htmlFor:"command",className:"text-[var(--hub-ink)]",children:a("server.typeStdio")})]}),i.jsxs("div",{children:[i.jsx("input",{type:"radio",id:"url",name:"serverType",value:"url",checked:h==="sse",onChange:()=>Ie("sse"),className:"mr-1"}),i.jsx("label",{htmlFor:"url",className:"text-[var(--hub-ink)]",children:a("server.typeSse")})]}),i.jsxs("div",{children:[i.jsx("input",{type:"radio",id:"streamable-http",name:"serverType",value:"streamable-http",checked:h==="streamable-http",onChange:()=>Ie("streamable-http"),className:"mr-1"}),i.jsx("label",{htmlFor:"streamable-http",className:"text-[var(--hub-ink)]",children:a("server.typeStreamableHttp")})]}),i.jsxs("div",{children:[i.jsx("input",{type:"radio",id:"openapi",name:"serverType",value:"openapi",checked:h==="openapi",onChange:()=>Ie("openapi"),className:"mr-1"}),i.jsx("label",{htmlFor:"openapi",className:"text-[var(--hub-ink)]",children:a("server.typeOpenapi")})]})]})]}),i.jsx("div",{className:"pl-4 border-l-2 border-gray-200 dark:border-gray-700 ml-2",children:h==="openapi"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:a("server.openapi.inputMode")}),i.jsxs("div",{className:"flex space-x-4",children:[i.jsxs("div",{children:[i.jsx("input",{type:"radio",id:"input-mode-url",name:"inputMode",value:"url",checked:((fr=p.openapi)==null?void 0:fr.inputMode)==="url",onChange:()=>b(d=>({...d,openapi:{...d.openapi,inputMode:"url"}})),className:"mr-1"}),i.jsx("label",{htmlFor:"input-mode-url",children:a("server.openapi.inputModeUrl")})]}),i.jsxs("div",{children:[i.jsx("input",{type:"radio",id:"input-mode-schema",name:"inputMode",value:"schema",checked:((hr=p.openapi)==null?void 0:hr.inputMode)==="schema",onChange:()=>b(d=>({...d,openapi:{...d.openapi,inputMode:"schema"}})),className:"mr-1"}),i.jsx("label",{htmlFor:"input-mode-schema",children:a("server.openapi.inputModeSchema")})]})]})]}),((mr=p.openapi)==null?void 0:mr.inputMode)==="url"&&i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"openapi-url",children:a("server.openapi.specUrl")}),i.jsx("input",{type:"url",name:"openapi-url",id:"openapi-url",value:((gr=p.openapi)==null?void 0:gr.url)||"",onChange:d=>b(u=>({...u,openapi:{...u.openapi,url:d.target.value}})),className:"w-full py-2 px-3 form-input",placeholder:"e.g.: https://api.example.com/openapi.json",required:h==="openapi"&&((yr=p.openapi)==null?void 0:yr.inputMode)==="url"})]}),((vr=p.openapi)==null?void 0:vr.inputMode)==="schema"&&i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"openapi-schema",children:a("server.openapi.schema")}),i.jsx("textarea",{name:"openapi-schema",id:"openapi-schema",rows:10,value:((br=p.openapi)==null?void 0:br.schema)||"",onChange:d=>b(u=>({...u,openapi:{...u.openapi,schema:d.target.value}})),className:"w-full py-2 px-3 form-input font-mono text-sm",placeholder:`{
|
|
59
|
+
"openapi": "3.1.0",
|
|
60
|
+
"info": {
|
|
61
|
+
"title": "API",
|
|
62
|
+
"version": "1.0.0"
|
|
63
|
+
},
|
|
64
|
+
"servers": [
|
|
65
|
+
{
|
|
66
|
+
"url": "https://api.example.com"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"paths": {
|
|
70
|
+
...
|
|
71
|
+
}
|
|
72
|
+
}`,required:h==="openapi"&&((xr=p.openapi)==null?void 0:xr.inputMode)==="schema"}),i.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:a("server.openapi.schemaHelp")})]}),!ue&&sn&&i.jsx("div",{className:"mb-4 rounded border border-blue-200 bg-blue-50 p-3 text-sm dark:border-blue-900 dark:bg-blue-950/30","aria-live":"polite",children:rt?i.jsx("p",{className:"text-blue-700 dark:text-blue-300",children:a("server.openapi.statsMeasuring")}):ge?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100",children:a("server.openapi.statsSummary",{toolCount:ge.toolCount,bytes:yi(ge.definitionsBytes),tokens:gi(ge.estimatedTokens)})}),ge.estimatedTokens>=vi&&i.jsx("p",{className:"mt-1 text-yellow-700 dark:text-yellow-300",children:a("server.openapi.statsWarning")})]}):ei?i.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:a("server.openapi.statsUnavailable")}):null}),i.jsxs("div",{className:"mb-4",onChange:ai,children:[i.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[i.jsx("label",{className:"block text-sm font-medium text-[var(--hub-ink-2)]",children:a("server.openapi.security")}),i.jsx("button",{type:"button",onClick:()=>void ui(),disabled:qt||rt||!sn,className:"hub-btn text-xs !h-7 !px-2",children:a(qt||rt?"server.openapi.securityDetecting":"server.openapi.securityDetect")})]}),i.jsxs("select",{value:((kr=p.openapi)==null?void 0:kr.securityType)||"none",onChange:d=>b(u=>{var y;return Te(null),{...u,openapi:{...u.openapi,securityType:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full py-2 px-3 form-input",children:[i.jsx("option",{value:"none",children:a("server.openapi.securityNone")}),i.jsx("option",{value:"apiKey",children:a("server.openapi.securityApiKey")}),i.jsx("option",{value:"http",children:a("server.openapi.securityHttp")}),i.jsx("option",{value:"oauth2",children:a("server.openapi.securityOAuth2")}),i.jsx("option",{value:"openIdConnect",children:a("server.openapi.securityOpenIdConnect")})]}),$e&&i.jsx("p",{className:`mt-2 text-xs ${$e.kind==="warning"?"text-yellow-700 dark:text-yellow-300":"text-blue-700 dark:text-blue-300"}`,children:a(`server.openapi.${$e.messageKey}`,$e.values)})]}),((_r=p.openapi)==null?void 0:_r.securityType)==="apiKey"&&i.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--hub-ink-2)]",children:a("server.openapi.apiKeyConfig")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-[var(--hub-ink-2)] mb-1",children:a("server.openapi.apiKeyName")}),i.jsx("input",{type:"text",value:((wr=p.openapi)==null?void 0:wr.apiKeyName)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,apiKeyName:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm form-input focus:outline-none",placeholder:"Authorization"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-[var(--hub-ink-2)] mb-1",children:a("server.openapi.apiKeyIn")}),i.jsxs("select",{value:((jr=p.openapi)==null?void 0:jr.apiKeyIn)||"header",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,apiKeyIn:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[i.jsx("option",{value:"header",children:a("server.openapi.apiKeyInHeader")}),i.jsx("option",{value:"query",children:a("server.openapi.apiKeyInQuery")}),i.jsx("option",{value:"cookie",children:a("server.openapi.apiKeyInCookie")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.apiKeyValue")}),i.jsx("input",{type:"password",value:((Sr=p.openapi)==null?void 0:Sr.apiKeyValue)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,apiKeyValue:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"your-api-key"})]})]})]}),((Nr=p.openapi)==null?void 0:Nr.securityType)==="http"&&i.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-gray-700 dark:text-gray-300",children:a("server.openapi.httpAuthConfig")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.httpScheme")}),i.jsxs("select",{value:((zr=p.openapi)==null?void 0:zr.httpScheme)||"bearer",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,httpScheme:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[i.jsx("option",{value:"basic",children:a("server.openapi.httpSchemeBasic")}),i.jsx("option",{value:"bearer",children:a("server.openapi.httpSchemeBearer")}),i.jsx("option",{value:"digest",children:a("server.openapi.httpSchemeDigest")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.httpCredentials")}),i.jsx("input",{type:"password",value:((Or=p.openapi)==null?void 0:Or.httpCredentials)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,httpCredentials:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:(($r=p.openapi)==null?void 0:$r.httpScheme)==="basic"?"user:password or base64":"bearer-token"}),((Tr=p.openapi)==null?void 0:Tr.httpScheme)==="basic"&&i.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:a("server.openapi.httpCredentialsBasicHint")})]})]})]}),((Cr=p.openapi)==null?void 0:Cr.securityType)==="openIdConnect"&&i.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-gray-700 dark:text-gray-300",children:a("server.openapi.openIdConnectConfig")}),i.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.openIdConnectUrl")}),i.jsx("input",{type:"url",value:((Ar=p.openapi)==null?void 0:Ar.openIdConnectUrl)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,openIdConnectUrl:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"https://example.com/.well-known/openid_configuration"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.openIdConnectToken")}),i.jsx("input",{type:"password",value:((Ir=p.openapi)==null?void 0:Ir.openIdConnectToken)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,openIdConnectToken:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"id-token"})]})]})]}),((Er=p.openapi)==null?void 0:Er.securityType)==="oauth2"&&i.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-gray-700 dark:text-gray-300",children:a("server.openapi.oauth2Config")}),i.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.oauth.tokenEndpoint")}),i.jsx("input",{type:"url",value:((Pr=p.openapi)==null?void 0:Pr.oauth2TokenUrl)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,oauth2TokenUrl:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"https://example.com/oauth/token"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.oauth.clientId")}),i.jsx("input",{type:"text",value:((Zr=p.openapi)==null?void 0:Zr.oauth2ClientId)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,oauth2ClientId:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"client-id"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.oauth.clientSecret")}),i.jsx("input",{type:"password",value:((Rr=p.openapi)==null?void 0:Rr.oauth2ClientSecret)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,oauth2ClientSecret:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"client-secret"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.oauth2Token")}),i.jsx("input",{type:"password",value:((Ur=p.openapi)==null?void 0:Ur.oauth2Token)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,oauth2Token:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"access-token"})]})]})]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center mb-1",children:[i.jsx("input",{type:"checkbox",id:"openapiSpecSecurity",checked:(((Fr=p.openapi)==null?void 0:Fr.specSecurityType)||"none")!=="none",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specSecurityType:d.target.checked?"http":"none"}}}),className:"mr-2"}),i.jsx("label",{htmlFor:"openapiSpecSecurity",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:a("server.openapi.specSecurityToggle")})]}),i.jsx("p",{className:"text-xs text-gray-500 ml-6",children:a("server.openapi.specSecurityHelp")}),(((Kr=p.openapi)==null?void 0:Kr.specSecurityType)||"none")!=="none"&&i.jsxs("div",{className:"mt-2 ml-6 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.security")}),i.jsxs("select",{value:((Mr=p.openapi)==null?void 0:Mr.specSecurityType)||"http",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specSecurityType:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[i.jsx("option",{value:"http",children:a("server.openapi.securityHttp")}),i.jsx("option",{value:"apiKey",children:a("server.openapi.securityApiKey")}),i.jsx("option",{value:"oauth2",children:a("server.openapi.securityOAuth2")})]})]}),((Lr=p.openapi)==null?void 0:Lr.specSecurityType)==="http"&&i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.httpScheme")}),i.jsxs("select",{value:((Jr=p.openapi)==null?void 0:Jr.specHttpScheme)||"basic",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specHttpScheme:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[i.jsx("option",{value:"basic",children:a("server.openapi.httpSchemeBasic")}),i.jsx("option",{value:"bearer",children:a("server.openapi.httpSchemeBearer")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.httpCredentials")}),i.jsx("input",{type:"password",value:((Vr=p.openapi)==null?void 0:Vr.specHttpCredentials)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specHttpCredentials:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:((Hr=p.openapi)==null?void 0:Hr.specHttpScheme)==="basic"?"user:password or base64":"bearer-token"})]})]}),((Br=p.openapi)==null?void 0:Br.specSecurityType)==="apiKey"&&i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.apiKeyName")}),i.jsx("input",{type:"text",value:((Wr=p.openapi)==null?void 0:Wr.specApiKeyName)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specApiKeyName:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"X-API-Key"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.apiKeyIn")}),i.jsxs("select",{value:((qr=p.openapi)==null?void 0:qr.specApiKeyIn)||"header",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specApiKeyIn:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[i.jsx("option",{value:"header",children:a("server.openapi.apiKeyInHeader")}),i.jsx("option",{value:"query",children:a("server.openapi.apiKeyInQuery")}),i.jsx("option",{value:"cookie",children:a("server.openapi.apiKeyInCookie")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.apiKeyValue")}),i.jsx("input",{type:"password",value:((Gr=p.openapi)==null?void 0:Gr.specApiKeyValue)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specApiKeyValue:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input"})]})]}),((Xr=p.openapi)==null?void 0:Xr.specSecurityType)==="oauth2"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.openapi.oauth2Token")}),i.jsx("input",{type:"password",value:((Yr=p.openapi)==null?void 0:Yr.specOauth2Token)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,url:((y=u.openapi)==null?void 0:y.url)||"",specOauth2Token:d.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"access-token"})]})]})]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center mb-1",children:[i.jsx("input",{type:"checkbox",id:"openapiCookieSession",checked:((Qr=p.openapi)==null?void 0:Qr.cookieSession)||!1,onChange:d=>b(u=>{var y,S;return{...u,openapi:{...u.openapi,passthroughHeaders:((y=u.openapi)==null?void 0:y.passthroughHeaders)||"",url:((S=u.openapi)==null?void 0:S.url)||"",cookieSession:d.target.checked}}}),className:"mr-2"}),i.jsx("label",{htmlFor:"openapiCookieSession",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:a("server.openapi.cookieSession","Cookie Session Handling")})]}),i.jsx("p",{className:"text-xs text-gray-500 ml-6",children:a("server.openapi.cookieSessionHelp","Capture Set-Cookie from upstream login responses and replay them on later calls within the same downstream session. Isolated per MCP session; not persisted.")})]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.headers")}),i.jsx("button",{type:"button",onClick:tn,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),X.map((d,u)=>i.jsxs("div",{className:"flex items-center mb-2",children:[i.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[i.jsx("input",{type:"text",value:d.key,onChange:y=>Pe(u,"key",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Authorization"}),i.jsx("span",{className:"flex items-center",children:":"}),i.jsx("input",{type:"text",value:d.value,onChange:y=>Pe(u,"value",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Bearer token..."})]}),i.jsx("button",{type:"button",onClick:()=>nn(u),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},u))]})]}):h==="sse"||h==="streamable-http"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-gray-700 dark:text-gray-300",htmlFor:"url",children:a("server.url")}),i.jsx("input",{type:"url",name:"url",id:"url",value:p.url,onChange:Ae,className:"w-full py-2 px-3 form-input",placeholder:h==="streamable-http"?"e.g.: http://localhost:3000/mcp":"e.g.: http://localhost:3000/sse",required:h==="sse"||h==="streamable-http"})]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.headers")}),i.jsx("button",{type:"button",onClick:tn,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),X.map((d,u)=>i.jsxs("div",{className:"flex items-center mb-2",children:[i.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[i.jsx("input",{type:"text",value:d.key,onChange:y=>Pe(u,"key",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Authorization"}),i.jsx("span",{className:"flex items-center",children:":"}),i.jsx("input",{type:"text",value:d.value,onChange:y=>Pe(u,"value",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Bearer token..."})]}),i.jsx("button",{type:"button",onClick:()=>nn(u),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},u))]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.envVars")}),i.jsx("button",{type:"button",onClick:Dt,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),G.map((d,u)=>i.jsxs("div",{className:"flex items-center mb-2",children:[i.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[i.jsx("input",{type:"text",value:d.key,onChange:y=>Ee(u,"key",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:a("server.key")}),i.jsx("span",{className:"flex items-center",children:":"}),i.jsx("input",{type:"text",value:d.value,onChange:y=>Ee(u,"value",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:a("server.value")})]}),i.jsx("button",{type:"button",onClick:()=>en(u),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},u))]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-gray-700 dark:text-gray-300",htmlFor:"command",children:a("server.command")}),i.jsx("input",{type:"text",name:"command",id:"command",value:p.command,onChange:Ae,className:"w-full py-2 px-3 form-input",placeholder:"e.g.: npx",required:h==="stdio"})]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.arguments")}),i.jsx("button",{type:"button",className:"text-sm text-blue-600 dark:text-blue-400",onClick:()=>b(d=>({...d,args:[...d.args||[],""]})),children:a("server.addArgument")})]}),i.jsx("p",{className:"text-xs text-gray-500 mb-2",children:a("server.argumentsHint")}),(p.args||[]).map((d,u)=>i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("input",{type:"text","aria-label":a("server.argumentLabel",{index:u+1}),value:d,onChange:y=>{const S=y.target.value;b(N=>{var E;return{...N,args:(E=N.args)==null?void 0:E.map((ve,te)=>te===u?S:ve)}})},className:"w-full py-2 px-3 form-input"}),i.jsx("button",{type:"button","aria-label":a("server.removeArgument",{index:u+1}),onClick:()=>b(y=>{var S;return{...y,args:(S=y.args)==null?void 0:S.filter((N,E)=>E!==u)}}),className:"text-gray-500 hover:text-red-600",children:i.jsx(pt,{size:16})})]},u))]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.envVars")}),i.jsx("button",{type:"button",onClick:Dt,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),G.map((d,u)=>i.jsxs("div",{className:"flex items-center mb-2",children:[i.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[i.jsx("input",{type:"text",value:d.key,onChange:y=>Ee(u,"key",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:a("server.key")}),i.jsx("span",{className:"flex items-center",children:":"}),i.jsx("input",{type:"text",value:d.value,onChange:y=>Ee(u,"value",y.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:a("server.value")})]}),i.jsx("button",{type:"button",onClick:()=>en(u),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},u))]})]})})]}),i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>ii(!lt),children:[i.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)]",children:a("server.sectionAdvanced","Advanced Options")}),i.jsx("span",{className:"text-gray-500 text-sm",children:lt?"▼":"▶"})]}),lt&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-white dark:bg-gray-900 border-t-0 space-y-4",children:[i.jsxs("fieldset",{className:"space-y-3 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[i.jsx("legend",{className:"px-1 font-medium",children:a("credentials.slots")}),i.jsx("p",{className:"text-sm text-gray-500",children:a("credentials.slotsHint")}),h==="stdio"&&i.jsx("p",{className:"text-sm text-gray-500",children:a("credentials.argsHint",{placeholder:"{{args.API_KEY}}"})}),(h==="sse"||h==="streamable-http")&&i.jsx("p",{className:"text-sm text-gray-500",children:a("credentials.urlHint",{placeholder:"{{url.region}}"})}),(p.credentialTemplate||[]).map((d,u)=>i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h==="stdio"?i.jsxs("select",{"aria-label":a("credentials.target"),value:d.target==="args"?"args":"env",className:"py-2 px-3 form-input",onChange:y=>{var S;return b({...p,credentialTemplate:(S=p.credentialTemplate)==null?void 0:S.map((N,E)=>E===u?{...N,target:y.target.value}:N)})},children:[i.jsx("option",{value:"env",children:a("server.envVars")}),i.jsx("option",{value:"args",children:a("server.arguments")})]}):i.jsxs("select",{"aria-label":a("credentials.target"),value:d.target==="url"?"url":"headers",className:"py-2 px-3 form-input",onChange:y=>{var S;return b({...p,credentialTemplate:(S=p.credentialTemplate)==null?void 0:S.map((N,E)=>E===u?{...N,target:y.target.value,allowed:y.target.value==="url"?[]:void 0}:N)})},children:[i.jsx("option",{value:"headers",children:a("server.headers")}),(h==="sse"||h==="streamable-http")&&i.jsx("option",{value:"url",children:"URL"})]}),i.jsx("input",{required:!0,maxLength:128,"aria-label":a("credentials.fieldName"),placeholder:a("credentials.fieldName"),value:d.name,className:"min-w-0 flex-1 py-2 px-3 form-input",onChange:y=>{var S;return b({...p,credentialTemplate:(S=p.credentialTemplate)==null?void 0:S.map((N,E)=>E===u?{...N,name:y.target.value}:N)})}}),i.jsx("input",{maxLength:200,"aria-label":a("credentials.label"),placeholder:a("credentials.label"),value:d.label||"",className:"min-w-0 flex-1 py-2 px-3 form-input",onChange:y=>{var S;return b({...p,credentialTemplate:(S=p.credentialTemplate)==null?void 0:S.map((N,E)=>E===u?{...N,label:y.target.value}:N)})}}),d.target==="url"&&i.jsx("textarea",{required:!0,"aria-label":a("credentials.allowed"),placeholder:a("credentials.allowed"),value:(d.allowed||[]).join(`
|
|
73
|
+
`),className:"w-full py-2 px-3 form-input",onChange:y=>{var S;return b({...p,credentialTemplate:(S=p.credentialTemplate)==null?void 0:S.map((N,E)=>E===u?{...N,allowed:y.target.value.split(`
|
|
74
|
+
`)}:N)})}}),i.jsx("button",{type:"button","aria-label":a("credentials.removeSlot"),onClick:()=>{var y;return b({...p,credentialTemplate:(y=p.credentialTemplate)==null?void 0:y.filter((S,N)=>N!==u)})},children:i.jsx(pt,{size:18})})]},u)),i.jsx("button",{type:"button",className:"text-sm text-blue-600",disabled:(((Dr=p.credentialTemplate)==null?void 0:Dr.length)||0)>=32,onClick:()=>b({...p,credentialTemplate:[...p.credentialTemplate||[],{target:h==="stdio"?"env":"headers",name:""}]}),children:a("credentials.addSlot")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"visibility",children:a("server.visibility","Visibility")}),i.jsxs("select",{id:"visibility",name:"visibility",value:p.visibility||"private",onChange:d=>b(u=>({...u,visibility:d.target.value})),className:"w-full py-2 px-3 form-input",children:[i.jsx("option",{value:"private",children:a("server.visibilityPrivate","Private — only the owner and admins")}),i.jsx("option",{value:"group",children:a("server.visibilityGroup","Shared — selected users only")}),i.jsx("option",{value:"public",children:a("server.visibilityPublic","Public — every authenticated user")})]}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.visibilityDescription","Controls which non-admin users can discover and call this server. Admins always have access.")}),p.visibility==="group"&&i.jsxs("div",{className:"mt-4 rounded border border-gray-200 dark:border-gray-700 p-3",children:[i.jsx(pi,{options:R,selected:p.sharedWithUserGroups||[],disabled:H||T||!(n!=null&&n.name),onChange:d=>b(u=>({...u,sharedWithUserGroups:d}))}),i.jsx("div",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:a("server.shareWithUsers","Share with users")}),i.jsx("p",{className:"text-xs text-gray-500 mt-1 mb-3",children:a("server.shareWithUsersDescription","Selected users can discover and call this server, but cannot manage its configuration.")}),n!=null&&n.name?i.jsxs(i.Fragment,{children:[H&&i.jsx("p",{className:"text-sm text-gray-500",children:a("server.shareCandidatesLoading","Loading users...")}),T&&i.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:a("server.shareCandidatesError","Failed to load users.")}),!H&&!T&&B.length===0&&i.jsx("p",{className:"text-sm text-gray-500",children:a("server.noShareCandidates","No other users are available.")}),B.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-3 space-y-2",children:[i.jsx("label",{htmlFor:"share-user-search",className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:a("server.shareUserSearchLabel","Search users")}),i.jsx("input",{id:"share-user-search",type:"search",value:F,onChange:d=>ee(d.target.value),placeholder:a("server.shareUserSearchPlaceholder","Search usernames..."),className:"w-full py-2 px-3 form-input text-sm"}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsx("button",{type:"button",onClick:Qo,disabled:et,className:"hub-btn text-sm",children:a("server.selectAllShareUsers","Select all")}),i.jsx("button",{type:"button",onClick:Do,disabled:Xo,className:"hub-btn text-sm",children:a("server.deselectAllShareUsers","Deselect all")})]})]}),M.length===0?i.jsx("p",{className:"text-sm text-gray-500",children:a("server.noMatchingShareUsers","No users match your search.")}):i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:M.map(d=>i.jsxs("label",{className:"flex items-center gap-2 rounded border border-gray-200 dark:border-gray-700 px-3 py-2 text-sm text-[var(--hub-ink-2)]",children:[i.jsx("input",{type:"checkbox",checked:me.has(d),onChange:()=>Yo(d)}),i.jsx("span",{children:d})]},d))})]})]}):i.jsx("p",{className:"text-sm text-gray-500",children:a("server.shareAfterCreate","Save the server before selecting users.")})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:a("server.openapi.passthroughHeaders")}),h==="openapi"?i.jsx(i.Fragment,{children:i.jsx("input",{type:"text",value:((es=p.openapi)==null?void 0:es.passthroughHeaders)||"",onChange:d=>b(u=>{var y;return{...u,openapi:{...u.openapi,passthroughHeaders:d.target.value,url:((y=u.openapi)==null?void 0:y.url)||""}}}),className:"w-full py-2 px-3 form-input",placeholder:"Authorization, X-API-Key, X-Custom-Header"})}):i.jsx("input",{type:"text",value:p.passthroughHeaders||"",onChange:d=>b(u=>({...u,passthroughHeaders:d.target.value})),className:"w-full py-2 px-3 form-input",placeholder:"Authorization, X-Custom-User-Id"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.openapi.passthroughHeadersHelp")})]}),h!=="openapi"&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>ni(!ct),children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.oauth.sectionTitle")}),i.jsx("span",{className:"text-gray-500 text-sm",children:ct?"▼":"▶"})]}),ct&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-gray-50 dark:bg-gray-800 border-t-0",children:[i.jsx("p",{className:"text-xs text-gray-500 mb-3",children:a("server.oauth.sectionDescription")}),(h==="sse"||h==="streamable-http")&&i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{htmlFor:"oauthIdentityMode",className:"block text-xs text-gray-600 mb-1",children:a("server.oauth.identityMode")}),i.jsxs("select",{id:"oauthIdentityMode",className:"w-full py-2 px-3 form-input",value:((ts=p.oauth)==null?void 0:ts.identityMode)||"shared",onChange:d=>{le("identityMode",d.target.value),d.target.value!=="personal"&&le("authorizationRelay",void 0)},children:[i.jsx("option",{value:"shared",children:a("server.oauth.sharedIdentity")}),i.jsx("option",{value:"personal",children:a("server.oauth.personalIdentity")})]}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.oauth.personalIdentityHelp")})]}),(h==="sse"||h==="streamable-http")&&(((ns=l.user)==null?void 0:ns.isAdmin)||((rs=p.oauth)==null?void 0:rs.allowInsecureTokenEndpoint))&&i.jsxs("div",{className:"mb-3",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:((ss=p.oauth)==null?void 0:ss.allowInsecureTokenEndpoint)===!0,disabled:!((os=l.user)!=null&&os.isAdmin),onChange:d=>le("allowInsecureTokenEndpoint",d.target.checked)}),a("server.oauth.allowInsecureTokenEndpoint")]}),i.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400 mt-1",children:a("server.oauth.allowInsecureTokenEndpointHelp")})]}),(h==="sse"||h==="streamable-http")&&((is=p.oauth)==null?void 0:is.identityMode)==="personal"&&(((as=l.user)==null?void 0:as.isAdmin)||p.oauth.authorizationRelay)&&i.jsxs("details",{className:"mb-4 rounded border border-gray-200 dark:border-gray-700 p-3",children:[i.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:a("server.oauth.advancedSettings")}),i.jsxs("div",{className:"mt-3 space-y-3",children:[i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",id:"oauthAuthorizationRelay",checked:!!p.oauth.authorizationRelay,disabled:!((cs=l.user)!=null&&cs.isAdmin),onChange:d=>le("authorizationRelay",d.target.checked?{allowedRedirectOrigins:[]}:void 0)}),a("server.oauth.relayEnabled")]}),i.jsx("p",{className:"text-xs text-gray-500",children:a("server.oauth.relayHelp")}),p.oauth.authorizationRelay&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"oauthRelayOrigins",className:"block text-xs mb-1",children:a("server.oauth.relayOrigins")}),i.jsx("textarea",{id:"oauthRelayOrigins",rows:2,required:!0,disabled:!((us=l.user)!=null&&us.isAdmin),value:Xt,onChange:d=>ri(d.target.value),placeholder:"https://login.microsoftonline.com",className:"w-full py-2 px-3 form-input font-mono text-xs"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.oauth.relayOriginsHelp")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"oauthRelayMetadata",className:"block text-xs mb-1",children:a("server.oauth.relayMetadata")}),i.jsx("textarea",{id:"oauthRelayMetadata",rows:8,wrap:"off",required:!0,disabled:!((ls=l.user)!=null&&ls.isAdmin),value:Yt,onChange:d=>si(d.target.value),placeholder:`{
|
|
75
|
+
"issuer": "http://broker.internal:3000",
|
|
76
|
+
"authorization_endpoint": "http://broker.internal:3000/authorize",
|
|
77
|
+
"token_endpoint": "http://broker.internal:3000/token",
|
|
78
|
+
"response_types_supported": ["code"]
|
|
79
|
+
}`,className:"w-full py-2 px-3 form-input font-mono text-xs"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.oauth.relayMetadataHelp")})]})]})]})]}),i.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.oauth.clientId")}),i.jsx("input",{type:"text",value:((ds=p.oauth)==null?void 0:ds.clientId)||"",onChange:d=>le("clientId",d.target.value),className:"w-full py-2 px-3 form-input",placeholder:"client id",autoComplete:"off"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:a("server.oauth.clientSecret")}),i.jsx("input",{type:"password",value:((ps=p.oauth)==null?void 0:ps.clientSecret)||"",onChange:d=>le("clientSecret",d.target.value),className:"w-full py-2 px-3 form-input",placeholder:"client secret",autoComplete:"off"})]})]})]})]}),h!=="openapi"&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>ti(!at),children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.requestOptions")}),i.jsx("span",{className:"text-gray-500 text-sm",children:at?"▼":"▶"})]}),at&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-gray-50 dark:bg-gray-800 border-t-0",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h==="stdio"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"maxBufferSize",children:a("server.maxBufferSize")}),i.jsx("input",{type:"number",id:"maxBufferSize",value:((fs=p.options)==null?void 0:fs.maxBufferSize)??"",onChange:d=>Ze("maxBufferSize",d.target.value===""?void 0:Number(d.target.value)),className:"w-full py-2 px-3 form-input",placeholder:"10485760",min:"1",step:"1"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.maxBufferSizeDescription")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"timeout",children:a("server.timeout")}),i.jsx("input",{type:"number",id:"timeout",value:((hs=p.options)==null?void 0:hs.timeout)||6e4,onChange:d=>Ze("timeout",parseInt(d.target.value)||6e4),className:"w-full py-2 px-3 form-input",placeholder:"30000",min:"1000",max:"300000"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.timeoutDescription")})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"maxTotalTimeout",children:a("server.maxTotalTimeout")}),i.jsx("input",{type:"number",id:"maxTotalTimeout",value:((ms=p.options)==null?void 0:ms.maxTotalTimeout)||"",onChange:d=>Ze("maxTotalTimeout",d.target.value?parseInt(d.target.value):void 0),className:"w-full py-2 px-3 form-input",placeholder:"Optional",min:"1000"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.maxTotalTimeoutDescription")})]})]}),i.jsxs("div",{className:"mt-3",children:[i.jsxs("label",{className:"flex items-center",children:[i.jsx("input",{type:"checkbox",checked:((gs=p.options)==null?void 0:gs.resetTimeoutOnProgress)??!0,onChange:d=>Ze("resetTimeoutOnProgress",d.target.checked),className:"mr-2"}),i.jsx("span",{className:"text-gray-600 text-sm",children:a("server.resetTimeoutOnProgress")})]}),i.jsx("p",{className:"text-xs text-gray-500 mt-1 ml-6",children:a("server.resetTimeoutOnProgressDescription")})]})]})]}),(h==="sse"||h==="streamable-http")&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>oi(!ut),children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a("server.keepAlive","Connection Health")}),i.jsx("span",{className:"text-gray-500 text-sm",children:ut?"▼":"▶"})]}),ut&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-gray-50 dark:bg-gray-800 border-t-0",children:[i.jsxs("div",{className:"flex items-center mb-3",children:[i.jsx("input",{type:"checkbox",id:"enableKeepAlive",checked:((ys=p.keepAlive)==null?void 0:ys.enabled)||!1,onChange:d=>b(u=>({...u,keepAlive:{...u.keepAlive,enabled:d.target.checked}})),className:"mr-2"}),i.jsx("label",{htmlFor:"enableKeepAlive",className:"text-gray-600 text-sm",children:a("server.enableKeepAlive","Enable Health Checks")})]}),i.jsx("p",{className:"text-xs text-gray-500 mb-3",children:a("server.keepAliveDescription","Run periodic health checks. Disconnected remote servers always reconnect automatically with backoff.")}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"keepAliveInterval",children:a("server.keepAliveInterval","Check interval (ms)")}),i.jsx("input",{type:"number",id:"keepAliveInterval",value:((vs=p.keepAlive)==null?void 0:vs.interval)||6e4,onChange:d=>b(u=>({...u,keepAlive:{...u.keepAlive,interval:parseInt(d.target.value)||6e4}})),className:"w-full py-2 px-3 form-input",placeholder:"60000",min:"5000",max:"300000"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.keepAliveIntervalDescription","Time between health checks in milliseconds (default: 60000ms = 1 minute)")})]})]})]}),h!=="openapi"&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center mb-1",children:[i.jsx("input",{type:"checkbox",id:"perSessionClient",checked:p.perSessionClient||!1,onChange:d=>b(u=>({...u,perSessionClient:d.target.checked})),className:"mr-2"}),i.jsx("label",{htmlFor:"perSessionClient",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:a("server.perSessionClient","Per-Session Client Isolation")})]}),i.jsx("p",{className:"text-xs text-gray-500 ml-6",children:a("server.perSessionClientDescription","Create a dedicated upstream connection per session instead of sharing one across all sessions. Enable for stateful servers like Playwright. Increases upstream connections with concurrent sessions.")})]}),h==="stdio"&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center mb-1",children:[i.jsx("input",{type:"checkbox",id:"startOnDemand",checked:p.startOnDemand||!1,onChange:d=>b(u=>({...u,startOnDemand:d.target.checked})),className:"mr-2"}),i.jsx("label",{htmlFor:"startOnDemand",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:a("server.startOnDemand","Start On Demand")})]}),i.jsx("p",{className:"text-xs text-gray-500 ml-6",children:a("server.startOnDemandDescription","Skip startup connect and spawn this server only when a tool call arrives. The process is shut down automatically after the idle timeout, then restarted on the next call. Reduces persistent memory usage for rarely-used servers.")}),(p.startOnDemand||!!((bs=p.credentialTemplate)!=null&&bs.length))&&i.jsxs("div",{className:"ml-6 mt-2",children:[i.jsx("label",{htmlFor:"idleTimeoutMs",className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:a("server.idleTimeoutMs","Idle shutdown timeout (ms)")}),i.jsx("input",{type:"number",id:"idleTimeoutMs",min:1e4,step:1e3,value:p.idleTimeoutMs??3e5,onChange:d=>b(u=>({...u,idleTimeoutMs:Number(d.target.value)})),className:"hub-input w-40 text-sm"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:a("server.idleTimeoutMsDescription","Shut down the process after this many milliseconds with no tool calls. Default: 300000 (5 minutes).")})]})]})]})]}),i.jsxs("div",{className:"flex justify-end mt-6",children:[i.jsx("button",{type:"button",onClick:t,className:"hub-btn mr-2",children:a("server.cancel")}),i.jsx("button",{type:"submit",className:"hub-btn primary",children:a(ue?"server.save":"server.add")})]})]})]})},sp=e=>{const t=new Set,n=/\$\{([^}]+)\}/g,r=o=>{let c;for(;(c=n.exec(o))!==null;)t.add(c[1])},s=(o,c="")=>{typeof o=="string"?r(o):Array.isArray(o)?o.forEach((a,l)=>s(a,`${c}[${l}]`)):o&&typeof o=="object"&&Object.entries(o).forEach(([a,l])=>{s(l,c?`${c}.${a}`:a)})};return s(e),Array.from(t)};export{Lt as S,rp as a,tp as c,sp as d,xi as g,np as s};
|
|
80
|
+
//# sourceMappingURL=variableDetection-CbYSa1ka.js.map
|