@decocms/mesh 1.0.0-alpha.1 → 1.0.0-alpha.12

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.
Files changed (103) hide show
  1. package/dist/README.md +288 -0
  2. package/dist/client/assets/{alert-dialog-DsYjmjQa.js → alert-dialog-Hgs2tcw0.js} +3 -3
  3. package/dist/client/assets/{auth-dQSMuI_r.js → auth-Dfo88onv.js} +1 -1
  4. package/dist/client/assets/{auth-catchall-vTieIyKZ.js → auth-catchall-pzDMkYZ_.js} +1 -1
  5. package/dist/client/assets/{avatar-DFNVHH7B.js → avatar-Dw1KHXJf.js} +1 -1
  6. package/dist/client/assets/{badge-D0svJbIE.js → badge-C29ypR-2.js} +1 -1
  7. package/dist/client/assets/{button-CB7Gt-Ba.js → button-Cv1rgJOF.js} +1 -1
  8. package/dist/client/assets/{card-BZePxfHz.js → card-BggFBtGd.js} +1 -1
  9. package/dist/client/assets/{checkbox-CJwRElzS.js → checkbox-Ay9B68Cb.js} +1 -1
  10. package/dist/client/assets/{circle-alert-FONBIc_T.js → circle-alert-C3-3ZyHM.js} +1 -1
  11. package/dist/client/assets/collection-detail-BihTkJuQ.js +1 -0
  12. package/dist/client/assets/{collection-display-button-Ccjj22Xn.js → collection-display-button-grM851Xd.js} +1 -1
  13. package/dist/client/assets/{collection-header-C3vTyWNy.js → collection-header-DsMf-88h.js} +1 -1
  14. package/dist/client/assets/{collection-page-BplXISpO.js → collection-page-C6Lt30BH.js} +1 -1
  15. package/dist/client/assets/{collection-search-BpPEPb0j.js → collection-search-CXcLRFBk.js} +1 -1
  16. package/dist/client/assets/{collection-table-wrapper-CJdrG443.js → collection-table-wrapper-DIAaiM6K.js} +1 -1
  17. package/dist/client/assets/{connection-card-B7VMSnFz.js → connection-card-BSv7-QCW.js} +1 -1
  18. package/dist/client/assets/connection-detail-B1R8nv6U.js +1 -0
  19. package/dist/client/assets/connections-hz-ahAKO.js +1 -0
  20. package/dist/client/assets/{create-organization-dialog-Mq1L8DSD.js → create-organization-dialog-Bvkdjwsj.js} +1 -1
  21. package/dist/client/assets/dialog-rRH3MQkl.js +1 -0
  22. package/dist/client/assets/{dropdown-menu-zoKN8fKM.js → dropdown-menu-dUgjswGX.js} +1 -1
  23. package/dist/client/assets/{empty-state-BCgOYCyG.js → empty-state-CCq1QaCi.js} +1 -1
  24. package/dist/client/assets/{error-boundary-L4NxoU-J.js → error-boundary-COxhsLlB.js} +1 -1
  25. package/dist/client/assets/{extract-connection-data-mJfi2GDs.js → extract-connection-data-DyKjnzFA.js} +1 -1
  26. package/dist/client/assets/{form-BmhZau8F.js → form-xpLXXjk9.js} +1 -1
  27. package/dist/client/assets/gateway-detail-DIqZF9Yz.js +1 -0
  28. package/dist/client/assets/gateways-BEpD9ssC.js +1 -0
  29. package/dist/client/assets/{home-RT_Ssleq.js → home-BP87nVNG.js} +1 -1
  30. package/dist/client/assets/{icon-Zm7eEeKG.js → icon-KZI-tyY2.js} +1 -1
  31. package/dist/client/assets/{index-CBL6DTCM.js → index-3kbMatbv.js} +15 -15
  32. package/dist/client/assets/{index-CoeZDSQf.js → index-B6JW-QRO.js} +1 -1
  33. package/dist/client/assets/{index-BAut7b_p.js → index-C3w_QZu6.js} +1 -1
  34. package/dist/client/assets/index-CMNfZDn2.css +1 -0
  35. package/dist/client/assets/index-kuMaGV9U.js +118 -0
  36. package/dist/client/assets/{input-DWY0hRYC.js → input-C0U94pom.js} +1 -1
  37. package/dist/client/assets/integration-icon-Dv-2D552.js +2 -0
  38. package/dist/client/assets/{layout-C75gYFRR.js → layout-B4csW0zk.js} +1 -1
  39. package/dist/client/assets/{lazy-highlighter-V_ETf5s5.js → lazy-highlighter-BeM-KnKF.js} +1 -1
  40. package/dist/client/assets/{localstorage-keys-CdMYd__a.js → localstorage-keys-BY-fTuiw.js} +1 -1
  41. package/dist/client/assets/login-Dl_POp8A.js +1 -0
  42. package/dist/client/assets/mcp-oauth-C8lkjJJ-.js +1 -0
  43. package/dist/client/assets/members-sRtGjt4B.js +1 -0
  44. package/dist/client/assets/{monitoring-stats-row-DiSEgwHP.js → monitoring-stats-row-Bmw8lKAo.js} +9 -9
  45. package/dist/client/assets/monitoring-wqV_ck_J.js +1 -0
  46. package/dist/client/assets/oauth-callback-D4bjzxVG.js +1 -0
  47. package/dist/client/assets/page-Dm4c28Rt.js +1 -0
  48. package/dist/client/assets/{popover-B7GJHYd2.js → popover-BLX5hifQ.js} +1 -1
  49. package/dist/client/assets/{prism-BsII3tZL.js → prism-a2E9dRRh.js} +1 -1
  50. package/dist/client/assets/{resource-tabs-Djqhz6PB.js → resource-tabs-C2-m37Rp.js} +1 -1
  51. package/dist/client/assets/{schema-CJRWBwzd.js → schema-DLIeWQJ0.js} +1 -1
  52. package/dist/client/assets/{select-CrueAR2N.js → select-BFyzpZOm.js} +1 -1
  53. package/dist/client/assets/settings-KJAP4FWc.js +1 -0
  54. package/dist/client/assets/{shell-layout-CwcEMEv3.js → shell-layout-DqWy6R9v.js} +4 -4
  55. package/dist/client/assets/{spinner-R42f7AVH.js → spinner-CYHX4tj_.js} +1 -1
  56. package/dist/client/assets/store-DoIp_x0L.js +1 -0
  57. package/dist/client/assets/store-app-detail-CkhxmJHm.js +1 -0
  58. package/dist/client/assets/switch-B0GAK0hk.js +1 -0
  59. package/dist/client/assets/{textarea-CAmjTm6l.js → textarea-7TwZjOJN.js} +1 -1
  60. package/dist/client/assets/tool-set-selector-BxJYXzYX.js +1 -0
  61. package/dist/client/assets/{tooltip-BLbXpJcn.js → tooltip-CyTpNpEt.js} +1 -1
  62. package/dist/client/assets/{upload-CG7PZ6WF.js → upload-CedwcKCT.js} +1 -1
  63. package/dist/client/assets/{use-binding-CeSgmpzj.js → use-binding-Dlf98XSv.js} +2 -2
  64. package/dist/client/assets/use-gateway-C6ADI4VP.js +1 -0
  65. package/dist/client/assets/{use-list-state-BTIryg2o.js → use-list-state-Cu8fsSjR.js} +1 -1
  66. package/dist/client/assets/use-mcp-Z1amXXTK.js +1 -0
  67. package/dist/client/assets/use-members-dDzJ30ii.js +1 -0
  68. package/dist/client/assets/{use-mobile-BPQzOCZP.js → use-mobile-Ct-F04sM.js} +1 -1
  69. package/dist/client/assets/use-organization-settings-D7E3skEu.js +1 -0
  70. package/dist/client/assets/{use-tool-call-BsMTRGjQ.js → use-tool-call-DSlbFKjt.js} +1 -1
  71. package/dist/client/assets/useQuery-DJ7WNdWe.js +1 -0
  72. package/dist/client/assets/utils-dJ2GyoL3.js +1 -0
  73. package/dist/client/index.html +2 -2
  74. package/dist/server/cli.js +169 -169
  75. package/dist/server/migrate.js +204 -204
  76. package/dist/server/server.js +232 -232
  77. package/package.json +18 -19
  78. package/dist/client/assets/chunk-2RRQPJJO-DGhxLrrR.js +0 -1
  79. package/dist/client/assets/collection-detail-CFf2hZjF.js +0 -1
  80. package/dist/client/assets/connection-detail-DGFMHZQW.js +0 -1
  81. package/dist/client/assets/connections-BFxMYtuo.js +0 -1
  82. package/dist/client/assets/dialog-DhrfZsqb.js +0 -1
  83. package/dist/client/assets/gateway-detail-BEN_sL0j.js +0 -1
  84. package/dist/client/assets/gateways-DPfP8fjF.js +0 -1
  85. package/dist/client/assets/index-CfNAXm02.js +0 -1
  86. package/dist/client/assets/index-VCe1FY3E.js +0 -118
  87. package/dist/client/assets/index-feMggVqN.css +0 -1
  88. package/dist/client/assets/integration-icon-Dgf9Pzxc.js +0 -1
  89. package/dist/client/assets/login-CaI2gNh0.js +0 -1
  90. package/dist/client/assets/members-BD990Z5F.js +0 -1
  91. package/dist/client/assets/monitoring-s9rrPP3V.js +0 -1
  92. package/dist/client/assets/oauth-callback-ChC_4XSg.js +0 -10
  93. package/dist/client/assets/page-BauA0SPJ.js +0 -1
  94. package/dist/client/assets/settings-85tu13fN.js +0 -1
  95. package/dist/client/assets/store-app-detail-D89e4NIX.js +0 -1
  96. package/dist/client/assets/store-zixro3Vs.js +0 -1
  97. package/dist/client/assets/tool-set-selector-BfScgRcK.js +0 -1
  98. package/dist/client/assets/use-connection-D5nZyekX.js +0 -2
  99. package/dist/client/assets/use-gateway-pRk3-ua4.js +0 -1
  100. package/dist/client/assets/use-members-OyBpbFn0.js +0 -1
  101. package/dist/client/assets/use-organization-settings-CMP1q4u_.js +0 -1
  102. package/dist/client/assets/useQuery-DEUZMq4A.js +0 -1
  103. package/dist/client/assets/utils-B-QWwgyW.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/mesh",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.12",
4
4
  "description": "MCP Mesh - Self-hostable MCP Gateway for managing AI connections and tools",
5
5
  "license": "MIT",
6
6
  "author": "Deco team",
@@ -35,6 +35,10 @@
35
35
  "prepublishOnly": "bun run build:client && bun run build:server"
36
36
  },
37
37
  "dependencies": {
38
+ "kysely": "^0.28.8",
39
+ "kysely-bun-worker": "^0.6.0"
40
+ },
41
+ "devDependencies": {
38
42
  "@ai-sdk/provider": "^2.0.0",
39
43
  "@ai-sdk/react": "^2.0.59",
40
44
  "@better-auth/sso": "1.4.1",
@@ -64,13 +68,23 @@
64
68
  "@rjsf/shadcn": "^6.1.2",
65
69
  "@rjsf/utils": "^6.1.2",
66
70
  "@rjsf/validator-ajv8": "^6.1.2",
71
+ "@tailwindcss/vite": "^4.1.17",
67
72
  "@tanstack/react-query": "^5.90.11",
68
73
  "@tanstack/react-router": "^1.139.7",
69
74
  "@tanstack/react-router-devtools": "^1.139.7",
75
+ "@types/bun": "^1.3.1",
76
+ "@types/pg": "^8.15.6",
77
+ "@types/react": "^19.2.2",
78
+ "@types/react-dom": "^19.2.2",
79
+ "@types/react-syntax-highlighter": "^15.5.13",
80
+ "@vercel/nft": "^1.1.1",
81
+ "@vitejs/plugin-react": "^5.1.0",
70
82
  "ai": "^5.0.101",
83
+ "babel-plugin-react-compiler": "^1.0.0",
71
84
  "better-auth": "1.4.5",
72
85
  "class-variance-authority": "^0.7.1",
73
86
  "clsx": "^2.1.1",
87
+ "concurrently": "^9.2.1",
74
88
  "croner": "^9.1.0",
75
89
  "date-fns": "^4.1.0",
76
90
  "fetch-to-node": "^2.1.0",
@@ -79,8 +93,6 @@
79
93
  "idb-keyval": "^6.2.2",
80
94
  "input-otp": "^1.4.2",
81
95
  "jose": "^6.0.11",
82
- "kysely": "^0.28.8",
83
- "kysely-bun-worker": "^0.6.0",
84
96
  "lucide-react": "^0.552.0",
85
97
  "nanoid": "^5.1.6",
86
98
  "pg": "^8.16.3",
@@ -92,26 +104,13 @@
92
104
  "sonner": "^2.0.7",
93
105
  "tailwind-merge": "^3.3.1",
94
106
  "tailwindcss": "^4.1.17",
95
- "use-mcp": "^0.0.21",
107
+ "typescript": "^5.9.3",
108
+ "vite": "^7.2.1",
109
+ "vite-tsconfig-paths": "^5.1.4",
96
110
  "zod": "^3.25.76",
97
111
  "zod-from-json-schema": "0.0.5",
98
112
  "zod-to-json-schema": "3.25.0"
99
113
  },
100
- "devDependencies": {
101
- "@tailwindcss/vite": "^4.1.17",
102
- "@types/bun": "^1.3.1",
103
- "@types/pg": "^8.15.6",
104
- "@types/react": "^19.2.2",
105
- "@types/react-syntax-highlighter": "^15.5.13",
106
- "@types/react-dom": "^19.2.2",
107
- "@vercel/nft": "^1.1.1",
108
- "@vitejs/plugin-react": "^5.1.0",
109
- "babel-plugin-react-compiler": "^1.0.0",
110
- "concurrently": "^9.2.1",
111
- "typescript": "^5.9.3",
112
- "vite": "^7.2.1",
113
- "vite-tsconfig-paths": "^5.1.4"
114
- },
115
114
  "module": "src/index.ts",
116
115
  "keywords": [
117
116
  "mcp",
@@ -1 +0,0 @@
1
- function n(r){const e=()=>{throw new Error(`Invalid url to pass to open(): ${r}`)};let t;try{t=new URL(r)}catch{e()}return t.protocol!=="https:"&&t.protocol!=="http:"&&e(),t.hostname!==encodeURIComponent(t.hostname)&&e(),t.username&&(t.username=encodeURIComponent(t.username)),t.password&&(t.password=encodeURIComponent(t.password)),t.pathname=t.pathname.slice(0,1)+encodeURIComponent(t.pathname.slice(1)).replace(/%2f/ig,"/"),t.search=t.search.slice(0,1)+Array.from(t.searchParams.entries()).map(l).join("&"),t.hash=t.hash.slice(0,1)+encodeURIComponent(t.hash.slice(1)),t.href}function l([r,e]){return`${encodeURIComponent(r)}${e.length>0?`=${encodeURIComponent(e)}`:""}`}var u=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;onPopupWindow;constructor(r,e={}){this.serverUrl=r,this.storageKeyPrefix=e.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(r),this.clientName=e.clientName||"MCP Browser Client",this.clientUri=e.clientUri||(typeof window<"u"?window.location.origin:""),this.callbackUrl=n(e.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=e.preventAutoAuth,this.onPopupWindow=e.onPopupWindow}get redirectUrl(){return n(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){const r=this.getKey("client_info"),e=localStorage.getItem(r);if(e)try{return JSON.parse(e)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(r);return}}async saveClientInformation(r){const e=this.getKey("client_info");localStorage.setItem(e,JSON.stringify(r))}async tokens(){const r=this.getKey("tokens"),e=localStorage.getItem(r);if(e)try{return JSON.parse(e)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(r);return}}async saveTokens(r){const e=this.getKey("tokens");localStorage.setItem(e,JSON.stringify(r)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(r){const e=this.getKey("code_verifier");localStorage.setItem(e,r)}async codeVerifier(){const r=this.getKey("code_verifier"),e=localStorage.getItem(r);if(!e)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${r}. Auth flow likely corrupted or timed out.`);return e}async prepareAuthorizationUrl(r){const e=crypto.randomUUID(),t=`${this.storageKeyPrefix}:state_${e}`,o={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl}};localStorage.setItem(t,JSON.stringify(o)),r.searchParams.set("state",e);const c=r.toString(),s=n(c);return localStorage.setItem(this.getKey("last_auth_url"),s),s}async redirectToAuthorization(r){if(this.preventAutoAuth)return;const e=await this.prepareAuthorizationUrl(r),t="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const o=window.open(e,`mcp_auth_${this.serverUrlHash}`,t);this.onPopupWindow&&this.onPopupWindow(e,t,o),!o||o.closed||typeof o.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(o.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(o){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,o)}}getLastAttemptedAuthUrl(){const r=localStorage.getItem(this.getKey("last_auth_url"));return r?n(r):null}clearStorage(){const r=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,e=`${this.storageKeyPrefix}:state_`,t=[];let o=0;for(let s=0;s<localStorage.length;s++){const i=localStorage.key(s);if(i){if(i.startsWith(r))t.push(i);else if(i.startsWith(e))try{const a=localStorage.getItem(i);a&&JSON.parse(a).serverUrlHash===this.serverUrlHash&&t.push(i)}catch(a){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,a)}}}return[...new Set(t)].forEach(s=>{localStorage.removeItem(s),o++}),o}hashString(r){let e=0;for(let t=0;t<r.length;t++){const o=r.charCodeAt(t);e=(e<<5)-e+o,e=e&e}return Math.abs(e).toString(16)}getKey(r){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${r}`}};export{u as B,n as s};
@@ -1 +0,0 @@
1
- import{b6 as _,r as y,d as R,as as ee,j as t,c as S,af as te,a6 as se,b5 as W}from"./index-VCe1FY3E.js";import{f as oe,c as D,U as B,a as ne,e as re}from"./use-connection-D5nZyekX.js";import{T as ae}from"./tool-set-selector-BfScgRcK.js";import{B as ie}from"./badge-D0svJbIE.js";import{B as I}from"./button-CB7Gt-Ba.js";import{I as z}from"./icon-Zm7eEeKG.js";import{I as V}from"./input-DWY0hRYC.js";import{S as ce}from"./spinner-R42f7AVH.js";import{T as q}from"./textarea-CAmjTm6l.js";import{c as k}from"./utils-B-QWwgyW.js";import{a as G,u as le,O as de,P as me,E as ue}from"./index-CBL6DTCM.js";import{b as Z,a as xe,V as H}from"./layout-C75gYFRR.js";import{U as fe}from"./upload-CG7PZ6WF.js";import{u as pe}from"./index-CfNAXm02.js";import{C as he}from"./circle-alert-FONBIc_T.js";import{E as ge}from"./error-boundary-L4NxoU-J.js";import"./tooltip-BLbXpJcn.js";import"./integration-icon-Dgf9Pzxc.js";import"./checkbox-CJwRElzS.js";import"./select-CrueAR2N.js";import"./collection-search-BpPEPb0j.js";import"./use-organization-settings-CMP1q4u_.js";import"./empty-state-BCgOYCyG.js";import"./use-binding-CeSgmpzj.js";import"./auth-dQSMuI_r.js";import"./use-tool-call-BsMTRGjQ.js";import"./chunk-2RRQPJJO-DGhxLrrR.js";import"./form-BmhZau8F.js";import"./use-gateway-pRk3-ua4.js";import"./formatDistanceToNow-Ctx6mZEP.js";import"./extract-connection-data-mJfi2GDs.js";import"./registry-utils-ulDDT0d8.js";import"./generate-id-Dyweu44Y.js";import"./index-CoeZDSQf.js";import"./index-BAut7b_p.js";import"./schema-CJRWBwzd.js";const be=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],je=_("box",be);const ve=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ne=_("clock",ve);const ye=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],we=_("code",ye);const Se=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ce=_("copy",Se);const ke=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],$e=_("database",ke);const Ie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],_e=_("info",Ie);const Te=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],K=_("play",Te);function Ee(s){const e=S.c(14),{value:n,onChange:a,alt:r}=s,o=y.useRef(null);let i;e[0]!==a?(i=p=>{const v=p.target.files?.[0];if(v){const w=new FileReader;w.onloadend=()=>{const j=w.result;a(j)},w.readAsDataURL(v)}},e[0]=a,e[1]=i):i=e[1];const m=i;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o.current?.click()},e[2]=l):l=e[2];const u=l;let c;e[3]!==m?(c=t.jsx("input",{type:"file",ref:o,className:"hidden",accept:"image/*",onChange:m}),e[3]=m,e[4]=c):c=e[4];let h;e[5]!==r||e[6]!==n?(h=n?t.jsx("img",{src:n,alt:r||"Avatar",className:"w-full h-full object-cover"}):t.jsx("div",{className:"w-full h-full flex items-center justify-center text-2xl",children:"🤖"}),e[5]=r,e[6]=n,e[7]=h):h=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center rounded-xl",children:t.jsx(fe,{className:"h-5 w-5 text-white"})}),e[8]=g):g=e[8];let b;e[9]!==h?(b=t.jsxs("div",{className:"h-full w-full rounded-xl border border-border bg-muted/20 overflow-hidden relative",children:[h,g]}),e[9]=h,e[10]=b):b=e[10];let f;return e[11]!==c||e[12]!==b?(f=t.jsxs("div",{className:"relative h-14 w-14 shrink-0 cursor-pointer group",onClick:u,children:[c,b]}),e[11]=c,e[12]=b,e[13]=f):f=e[13],f}function Ae({itemId:s,onBack:e,onUpdate:n}){const[a,r]=y.useState(!1),[o,i]=y.useState("profile"),{connectionId:m}=R({from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"}),l=m??B,u=D(l),c=oe(l,"AGENT",s,u),{register:h,handleSubmit:g,reset:b,setValue:f,watch:p,formState:{isDirty:v}}=ee({defaultValues:{title:"",description:"",instructions:"",avatar:"",tool_set:{}}}),w=p("avatar"),j=p("tool_set")??{};y.useEffect(()=>{c&&b({title:c.title??"",description:c.description??"",instructions:c.instructions??"",avatar:c.avatar??"",tool_set:c.tool_set??{}})},[c,b]);const x=async $=>{r(!0);try{await n($)}finally{r(!1)}},M=$=>{f("tool_set",$,{shouldDirty:!0})};return c?t.jsxs(Z,{onBack:e,children:[t.jsxs(xe,{children:[t.jsx(I,{variant:o==="profile"?"secondary":"ghost",size:"sm",className:k("h-7 font-normal",o==="profile"?"bg-muted text-foreground":"text-muted-foreground"),onClick:()=>i("profile"),children:"Profile"}),t.jsx(I,{variant:o==="tools"?"secondary":"ghost",size:"sm",className:k("h-7 font-normal",o==="tools"?"bg-muted text-foreground":"text-muted-foreground"),onClick:()=>i("tools"),children:"Tools"}),t.jsx(I,{variant:o==="triggers"?"secondary":"ghost",size:"sm",className:k("h-7 font-normal",o==="triggers"?"bg-muted text-foreground":"text-muted-foreground"),onClick:()=>i("triggers"),disabled:!0,children:"Triggers"}),t.jsx(I,{variant:o==="advanced"?"secondary":"ghost",size:"sm",className:k("h-7 font-normal",o==="advanced"?"bg-muted text-foreground":"text-muted-foreground"),onClick:()=>i("advanced"),disabled:!0,children:"Advanced"})]}),t.jsxs(H,{children:[t.jsx(G,{connectionId:m,title:c.title,icon:c.avatar??"smart_toy"}),t.jsx(I,{className:"bg-[#d0ec1a] text-[#07401a] hover:bg-[#d0ec1a]/90 h-7 text-xs font-medium",onClick:g(x),disabled:!v||a,children:a?t.jsxs(t.Fragment,{children:[t.jsx(z,{name:"progress_activity",size:12,className:"mr-2 animate-spin"}),"Saving..."]}):"Save changes"})]}),o==="profile"&&t.jsx("div",{className:"p-5",children:t.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[t.jsxs("div",{className:"flex gap-4 items-start",children:[t.jsx(Ee,{value:w,onChange:$=>f("avatar",$,{shouldDirty:!0}),alt:p("title")}),t.jsxs("div",{className:"space-y-3 pt-1 flex-1",children:[t.jsx(V,{...h("title"),className:"text-2xl font-medium text-foreground border-transparent hover:border-input focus:border-input px-0 h-auto bg-transparent shadow-none",placeholder:"Agent Name"}),t.jsx(V,{...h("description"),className:"text-sm text-muted-foreground border-transparent hover:border-input focus:border-input px-0 h-auto bg-transparent shadow-none",placeholder:"Brief description"})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs(ie,{variant:"secondary",className:"px-2 py-0.5 h-6 gap-1.5 bg-secondary/50 text-muted-foreground font-normal text-xs hover:bg-secondary/50",children:[t.jsx(_e,{className:"h-3.5 w-3.5"}),"Type @ to add tools and more"]}),t.jsx("div",{className:"relative",children:t.jsx(q,{...h("instructions"),className:"min-h-[400px] resize-none text-sm leading-relaxed font-normal border-0 focus-visible:ring-0 px-0 py-0 shadow-none",placeholder:"Enter agent instructions..."})})]})]})}),o==="tools"&&t.jsx(ae,{toolSet:j,onToolSetChange:M}),o==="triggers"&&t.jsx("div",{className:"p-5",children:t.jsx("div",{className:"text-sm text-muted-foreground",children:"Triggers tab coming soon"})}),o==="advanced"&&t.jsx("div",{className:"p-5",children:t.jsx("div",{className:"text-sm text-muted-foreground",children:"Advanced tab coming soon"})})]}):t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(ce,{})})}const ze=te("relative w-full rounded-lg border px-4 py-3 text-sm flex items-start gap-3 [&>svg]:size-4 [&>svg]:flex-shrink-0 [&>svg]:mt-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-destructive/10 text-destructive border-destructive [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-warning/10 text-warning-foreground border-warning [&>svg]:text-current *:data-[slot=alert-description]:text-warning-foreground/90",success:"bg-success/10 text-success-foreground border-success [&>svg]:text-current *:data-[slot=alert-description]:text-success-foreground/90",info:"bg-card text-card-foreground border-border [&>svg]:text-current *:data-[slot=alert-description]:text-muted-foreground/90"}},defaultVariants:{variant:"default"}});function Re(s){const e=S.c(10);let n,a,r;e[0]!==s?({className:n,variant:r,...a}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=r):(n=e[1],a=e[2],r=e[3]);let o;e[4]!==n||e[5]!==r?(o=k(ze({variant:r}),n),e[4]=n,e[5]=r,e[6]=o):o=e[6];let i;return e[7]!==a||e[8]!==o?(i=t.jsx("div",{"data-slot":"alert",role:"alert",className:o,...a}),e[7]=a,e[8]=o,e[9]=i):i=e[9],i}function Me(s){const e=S.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=k("line-clamp-1 min-h-4 font-medium tracking-tight",n),e[3]=n,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=t.jsx("div",{"data-slot":"alert-title",className:r,...a}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o}function Oe(s){const e=S.c(8);let n,a;e[0]!==s?({className:n,...a}=s,e[0]=s,e[1]=n,e[2]=a):(n=e[1],a=e[2]);let r;e[3]!==n?(r=k("text-muted-foreground leading-relaxed",n),e[3]=n,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=t.jsx("div",{"data-slot":"alert-description",className:r,...a}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o}function Pe(s){try{const e=new URL(s);return e.pathname=e.pathname.replace(/\/i:([a-f0-9-]+)/gi,"/$1"),e.toString()}catch{return s}}const Ue=s=>s.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function Ve(s){const e=S.c(15),{toolName:n,connectionId:a,connection:r,onBack:o}=s;let i;e[0]!==r.connection_url?(i=Pe(r.connection_url),e[0]=r.connection_url,e[1]=i):i=e[1];const m=i,l=`/mcp/${a}`;let u;e[2]!==l?(u=new URL(l,window.location.origin),e[2]=l,e[3]=u):u=e[3];const c=u,h=r.connection_token??null;let g;if(e[4]!==m||e[5]!==h?(g={url:m,token:h},e[4]=m,e[5]=h,e[6]=g):g=e[6],!le(g)){let v;return e[7]!==o?(v=t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(de,{onAuthenticate:()=>o(),buttonText:"Go back"})}),e[7]=o,e[8]=v):v=e[8],v}const f=`${a}:${n}`;let p;return e[9]!==a||e[10]!==c||e[11]!==o||e[12]!==f||e[13]!==n?(p=t.jsx(De,{toolName:n,connectionId:a,mcpProxyUrl:c,onBack:o},f),e[9]=a,e[10]=c,e[11]=o,e[12]=f,e[13]=n,e[14]=p):p=e[14],p}function De({toolName:s,connectionId:e,mcpProxyUrl:n,onBack:a}){const[r,o]=y.useState({}),[i,m]=y.useState("{}"),[l,u]=y.useState(null),[c,h]=y.useState(null),[g,b]=y.useState(!1),[f,p]=y.useState(null),[v,w]=y.useState("json"),j=pe({url:n.href,clientName:"MCP Tool Inspector",clientUri:window.location.origin,autoReconnect:!1});y.useEffect(()=>{j.error&&console.error("MCP Error:",j.error)},[j.error]);const x=j.tools?.find(d=>d.name===s),M=x?.inputSchema?.properties,$=M?Object.keys(M):[],A=$.length>0,O={};if(A&&x?.inputSchema?.properties)for(const d of $)O[d]=x.inputSchema.required?.includes(d)?"":void 0;const J=d=>Object.prototype.hasOwnProperty.call(r,d),Q=async()=>{b(!0),h(null),u(null),p(null);const d=performance.now(),C=D(e);try{const N=A?{...O,...r}:(()=>{const T=i.trim();if(!T)return{};const E=JSON.parse(T);if(E&&typeof E=="object")return E;throw new Error("Raw JSON input must be an object.")})();A&&x?.inputSchema?.properties&&Object.entries(x.inputSchema.properties).forEach(([T,E])=>{if((E.type==="object"||E.type==="array")&&typeof N[T]=="string")try{N[T]=JSON.parse(N[T])}catch{}});const P=await C(s,N),U=performance.now(),X=Math.round(U-d);u(P);const Y=JSON.stringify(P),F=new TextEncoder().encode(Y).length;p({duration:`${X}ms`,bytes:`${F} bytes`,tokens:`~${Math.ceil(F/4)} tokens`,cost:"$0.0000"})}catch(N){const P=N instanceof Error?N.message:String(N);h(P||"Unknown error occurred");const U=performance.now();p({duration:`${Math.round(U-d)}ms`})}finally{b(!1)}},L=(d,C)=>{o(N=>({...N,[d]:C}))};return t.jsxs(Z,{onBack:a,children:[t.jsx(H,{children:t.jsx(G,{connectionId:e,title:x?.title??Ue(s),icon:"build"})}),t.jsxs("div",{className:"flex flex-col items-center w-full max-w-[1500px] mx-auto p-10 gap-4",children:[t.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[t.jsx("h1",{className:"text-2xl font-medium text-foreground",children:s}),t.jsx("p",{className:"text-muted-foreground text-base",children:x?.description||"No description available"})]}),t.jsxs("div",{className:"flex items-center gap-4 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[j.state==="ready"?t.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 animate-pulse"}):j.state==="connecting"||j.state==="authenticating"?t.jsx(z,{name:"progress_activity",size:12,className:"animate-spin text-yellow-500"}):t.jsx("div",{className:"h-2 w-2 rounded-full bg-red-500"}),t.jsx("span",{className:"font-mono text-sm capitalize text-muted-foreground",children:j.state.replace("_"," ")})]}),t.jsx("div",{className:"w-px h-4 bg-border"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"font-mono text-sm",children:f?.duration||"-"})]}),t.jsx("div",{className:"w-px h-4 bg-border"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(je,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"font-mono text-sm",children:f?.tokens||"-"})]}),t.jsx("div",{className:"w-px h-4 bg-border"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($e,{className:"h-4 w-4 text-muted-foreground"}),t.jsx("span",{className:"font-mono text-sm",children:f?.bytes||"-"})]})]}),c&&t.jsxs(Re,{variant:"destructive",className:"max-w-[800px] w-full bg-red-50 dark:bg-red-900/10 border-red-200 dark:border-red-900",children:[t.jsx(he,{className:"h-4 w-4"}),t.jsx(Me,{children:"Execution Failed"}),t.jsx(Oe,{children:c})]}),t.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-[800px] items-center",children:[t.jsxs("div",{className:"w-full bg-card border border-border rounded-xl shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-4 w-4 rounded-sm bg-primary/10 flex items-center justify-center",children:t.jsx(K,{className:"h-3 w-3 text-primary"})}),t.jsx("span",{className:"font-medium text-sm",children:"Input"})]}),t.jsxs(I,{size:"sm",variant:"default",className:"h-8 gap-2",onClick:Q,disabled:g,children:[g?t.jsx(z,{name:"progress_activity",size:14,className:"animate-spin"}):t.jsx(K,{className:"h-3.5 w-3.5 fill-current"}),"Execute tool"]})]}),t.jsxs("div",{className:"p-4 space-y-4",children:[t.jsx("div",{className:"text-xs font-mono text-muted-foreground uppercase tracking-wider",children:"Arguments"}),A&&x?.inputSchema?.properties?Object.entries(x.inputSchema.properties).map(([d,C])=>t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),x.inputSchema?.required?.includes(d)&&t.jsx("span",{className:"text-red-500 text-xs",children:"*"}),t.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:C.type})]}),C.description&&t.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:C.description}),C.type==="object"||C.type==="array"?t.jsx(q,{className:"flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 font-mono",value:J(d)?r[d]??"":O[d]??"",onChange:N=>L(d,N.target.value),placeholder:`Enter ${d} as JSON...`}):t.jsx(V,{value:J(d)?r[d]??"":O[d]??"",onChange:N=>L(d,N.target.value),placeholder:`Enter ${d}...`})]},d)):t.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."}),x?.inputSchema&&!A&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),t.jsx("textarea",{className:"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",value:i,onChange:d=>m(d.target.value),placeholder:'e.g. { "foo": "bar" }'})]})]})]}),t.jsxs("div",{className:"w-full bg-card border border-border rounded-xl shadow-sm overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-muted/30",children:[t.jsx("span",{className:"text-xs font-mono text-muted-foreground uppercase tracking-wider",children:"Execution Result"}),t.jsxs("div",{className:"flex items-center bg-muted rounded-lg p-1 h-8",children:[t.jsx("button",{onClick:()=>w("json"),className:k("px-3 py-1 text-xs font-medium rounded-md transition-all",v==="json"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:"JSON"}),t.jsxs("button",{onClick:()=>w("view"),className:k("px-3 py-1 text-xs font-medium rounded-md transition-all flex items-center gap-1",v==="view"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),disabled:!0,title:"Coming soon",children:["Create view",t.jsx(me,{className:"h-3 w-3"})]})]})]}),t.jsxs("div",{className:"relative min-h-[200px] max-h-[500px] overflow-auto bg-zinc-950 text-zinc-50 p-4 font-mono text-xs",children:[l?t.jsx("pre",{className:"whitespace-pre-wrap break-all",children:JSON.stringify(l,null,2)}):t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-zinc-700",children:[t.jsx(we,{className:"h-8 w-8 mb-2 opacity-50"}),t.jsx("p",{children:"Run the tool to see results"})]}),l&&t.jsx("div",{className:"absolute top-4 right-4 flex gap-2",children:t.jsx(I,{size:"icon",variant:"secondary",className:"h-8 w-8 bg-zinc-800 text-zinc-400 hover:text-white hover:bg-zinc-700 border-zinc-700",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(l,null,2)),se.success("Copied to clipboard")},children:t.jsx(Ce,{className:"h-4 w-4"})})})]})]})]})]})]})}function Be(s){const e=S.c(8),{itemId:n,onBack:a}=s;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={strict:!1},e[0]=r):r=e[0];const i=R(r).connectionId??B,m=ne(i);if(!m){let c;return e[1]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=c):c=e[1],c}let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(z,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),e[2]=l):l=e[2];let u;return e[3]!==m||e[4]!==i||e[5]!==a||e[6]!==n?(u=t.jsx(y.Suspense,{fallback:l,children:t.jsx(Ve,{toolName:n,connectionId:i,connection:m,onBack:a})}),e[3]=m,e[4]=i,e[5]=a,e[6]=n,e[7]=u):u=e[7],u}const Je={agent:Ae};function Le(){const s=S.c(6),e=W();let n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},s[0]=n):n=s[0];const a=R(n),r=decodeURIComponent(a.itemId);let o;s[1]!==e.history?(o=()=>{e.history.back()},s[1]=e.history,s[2]=o):o=s[2];const i=o,m=Fe;let l;return s[3]!==i||s[4]!==r?(l=t.jsx(Be,{itemId:r,onBack:i,onUpdate:m}),s[3]=i,s[4]=r,s[5]=l):l=s[5],l}async function Fe(s){return Promise.resolve()}function Ke(){const s=S.c(17),e=W();let n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},s[0]=n):n=s[0];const a=R(n),r=a.connectionId,o=decodeURIComponent(a.collectionName),i=decodeURIComponent(a.itemId);let m;s[1]!==e.history?(m=()=>{e.history.back()},s[1]=e.history,s[2]=m):m=s[2];const l=m,u=r??B;let c;s[3]!==u?(c=D(u),s[3]=u,s[4]=c):c=s[4];const g=re(u,o,c);let b;s[5]!==g||s[6]!==i?(b=async x=>{i&&await g.update.mutateAsync({id:i,data:x})},s[5]=g,s[6]=i,s[7]=b):b=s[7];const f=b;let p;s[8]!==o?(p=o?.toLowerCase(),s[8]=o,s[9]=p):p=s[9];const v=p,w=v&&Je[v];if(w){let x;return s[10]!==w||s[11]!==l||s[12]!==f||s[13]!==i?(x=t.jsx(w,{itemId:i,onBack:l,onUpdate:f}),s[10]=w,s[11]=l,s[12]=f,s[13]=i,s[14]=x):x=s[14],x}let j;return s[15]!==l?(j=t.jsx(ue,{icon:"extension",title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:l,children:"Go back"}}),s[15]=l,s[16]=j):j=s[16],j}function We(){const s=S.c(3);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},s[0]=e):e=s[0];const n=R(e);if(decodeURIComponent(n.collectionName)==="tools"){let i;return s[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Le,{}),s[1]=i):i=s[1],i}let o;return s[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Ke,{}),s[2]=o):o=s[2],o}function _t(){const s=S.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(ge,{children:t.jsx(y.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(z,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(We,{})})}),s[0]=e):e=s[0],e}export{_t as default};
@@ -1 +0,0 @@
1
- import{c as V,j as o,a5 as Oe,a as Ye,r as ze,a6 as Ze,d as et,b as tt,b5 as ot}from"./index-VCe1FY3E.js";import{E as Ee}from"./empty-state-BCgOYCyG.js";import{E as Fe}from"./error-boundary-L4NxoU-J.js";import{a as Ke,e as st,u as nt,c as it,d as lt}from"./use-connection-D5nZyekX.js";import{b as at}from"./use-binding-CeSgmpzj.js";import{E as Ve,P as rt,a as ct,u as dt,S as mt}from"./index-CBL6DTCM.js";import{B as ge}from"./button-CB7Gt-Ba.js";import{I as M}from"./icon-Zm7eEeKG.js";import{a as ut,T as ft,R as pt}from"./resource-tabs-Djqhz6PB.js";import{V as ht,a as gt,b as xt}from"./layout-C75gYFRR.js";import{g as Be}from"./generate-id-Dyweu44Y.js";import{C as Le}from"./collection-display-button-Ccjj22Xn.js";import{C as jt}from"./collection-search-BpPEPb0j.js";import{C as bt}from"./card-BZePxfHz.js";import{I as Ct}from"./integration-icon-Dgf9Pzxc.js";import{b as We,D as qe,a as He,c as B}from"./dropdown-menu-zoKN8fKM.js";import{C as vt}from"./collection-table-wrapper-CJdrG443.js";import{u as yt}from"./use-list-state-BTIryg2o.js";import{B as _t}from"./extract-connection-data-mJfi2GDs.js";import{A as wt,g as St,c as Nt,b as It,d as Tt,e as Dt,a as $t,f as At}from"./alert-dialog-DsYjmjQa.js";import"./utils-B-QWwgyW.js";import"./tooltip-BLbXpJcn.js";import"./auth-dQSMuI_r.js";import"./use-organization-settings-CMP1q4u_.js";import"./use-tool-call-BsMTRGjQ.js";import"./chunk-2RRQPJJO-DGhxLrrR.js";import"./form-BmhZau8F.js";import"./input-DWY0hRYC.js";import"./select-CrueAR2N.js";import"./use-gateway-pRk3-ua4.js";import"./formatDistanceToNow-Ctx6mZEP.js";import"./registry-utils-ulDDT0d8.js";import"./index-CoeZDSQf.js";import"./index-BAut7b_p.js";import"./schema-CJRWBwzd.js";import"./useQuery-DEUZMq4A.js";import"./badge-D0svJbIE.js";import"./use-mobile-BPQzOCZP.js";function Pt(t,e){const s=t.properties||{};for(const i in s){const a=s[i];if(a&&a.type==="string"&&(a.format==="url"||a.format==="uri")&&e&&typeof e=="object"&&i in e&&e[i])return e[i]}const l=["image","img","avatar","icon","logo","thumbnail","cover"];for(const i of l)if(e&&typeof e=="object"&&i in e&&typeof e[i]=="string")return e[i]}function kt(t){const e=V.c(25),{item:s,schema:l,actions:i}=t;let a;e[0]!==s||e[1]!==l?(a=Pt(l,s),e[0]=s,e[1]=l,e[2]=a):a=e[2];const u=a,n=s&&typeof s=="object"&&"description"in s&&typeof s.description=="string"?s.description:void 0;let f;e[3]!==i?(f=i&&Object.keys(i).length>0,e[3]=i,e[4]=f):f=e[4];const g=f;let r;e[5]!==u||e[6]!==s.title?(r=o.jsx(Ct,{icon:u,name:s.title,size:"md",className:"shrink-0 shadow-sm"}),e[5]=u,e[6]=s.title,e[7]=r):r=e[7];let d;e[8]!==s.title?(d=o.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:s.title}),e[8]=s.title,e[9]=d):d=e[9];const x=n||"No description";let h;e[10]!==x?(h=o.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:x}),e[10]=x,e[11]=h):h=e[11];let j;e[12]!==d||e[13]!==h?(j=o.jsxs("div",{className:"flex flex-col gap-0 flex-1",children:[d,h]}),e[12]=d,e[13]=h,e[14]=j):j=e[14];let p;e[15]!==r||e[16]!==j?(p=o.jsxs("div",{className:"flex flex-col gap-4 p-6 flex-1",children:[r,j]}),e[15]=r,e[16]=j,e[17]=p):p=e[17];let c;e[18]!==i||e[19]!==g||e[20]!==s?(c=g&&o.jsx("div",{className:"absolute top-6 right-6 opacity-0 group-hover:opacity-100 transition-opacity",onClick:Mt,onMouseDown:Et,children:o.jsxs(We,{children:[o.jsx(qe,{asChild:!0,children:o.jsx(ge,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:zt,children:o.jsx(M,{name:"more_vert",size:20})})}),o.jsxs(He,{align:"end",onClick:Ot,children:[i.open&&o.jsxs(B,{onClick:C=>{C.stopPropagation(),i.open?.(s)},children:[o.jsx(M,{name:"visibility",size:16}),"Open"]}),i.edit&&o.jsxs(B,{onClick:C=>{C.stopPropagation(),i.edit?.(s)},children:[o.jsx(M,{name:"edit",size:16}),"Edit"]}),i.duplicate&&o.jsxs(B,{onClick:C=>{C.stopPropagation(),i.duplicate?.(s)},children:[o.jsx(M,{name:"content_copy",size:16}),"Duplicate"]}),i.delete&&o.jsxs(B,{variant:"destructive",onClick:C=>{C.stopPropagation(),i.delete?.(s)},children:[o.jsx(M,{name:"delete",size:16}),"Delete"]})]})]})}),e[18]=i,e[19]=g,e[20]=s,e[21]=c):c=e[21];let N;return e[22]!==p||e[23]!==c?(N=o.jsxs(bt,{className:"cursor-pointer transition-colors h-full flex flex-col group relative",children:[p,c]}),e[22]=p,e[23]=c,e[24]=N):N=e[24],N}function Ot(t){return t.stopPropagation()}function zt(t){return t.stopPropagation()}function Et(t){return t.stopPropagation()}function Mt(t){return t.stopPropagation()}function Je(t,e){return Object.keys(t.properties||{}).filter(s=>["id","created_at","updated_at","created_by","updated_by"].includes(s)?!1:e?e.includes(s):!0).map(s=>({id:s,label:s.charAt(0).toUpperCase()+s.slice(1).replace(/_/g," ")}))}function Ut(t){const e=V.c(32),{data:s,schema:l,viewMode:i,onViewModeChange:a,search:u,sortKey:n,sortDirection:f,onSort:g,actions:r,onItemClick:d,headerActions:x,emptyState:h,readOnly:j,columns:p,hideToolbar:c,sortableFields:N}=t,C=a===void 0?Kt:a,v=f===void 0?"asc":f,P=g===void 0?Ft:g;let m;e[0]!==r?(m=r===void 0?{}:r,e[0]=r,e[1]=m):m=e[1];const I=m,k=d===void 0?Rt:d,T=x===void 0?null:x,y=h===void 0?null:h,O=j===void 0?!1:j,_=p===void 0?void 0:p,z=c===void 0?!1:c,w=N===void 0?void 0:N;let D;e[2]!==_||e[3]!==l||e[4]!==w?(D=_?_.filter(Bt).filter(U=>!w||w.includes(U.id)).map(Vt):Je(l,w),e[2]=_,e[3]=l,e[4]=w,e[5]=D):D=e[5];const S=D;let $;e[6]!==T||e[7]!==z||e[8]!==P||e[9]!==C||e[10]!==v||e[11]!==n||e[12]!==S||e[13]!==i?($=!z&&o.jsx("div",{className:"shrink-0 w-full border-b border-border h-12",children:o.jsxs("div",{className:"flex items-center gap-3 h-12 px-4",children:[o.jsx("div",{className:"flex items-center gap-2 flex-1",children:T}),o.jsx("div",{className:"flex items-center gap-2 shrink-0",children:o.jsx(Le,{viewMode:i,onViewModeChange:C,sortKey:n,sortDirection:v,onSort:P,sortOptions:S})})]})}),e[6]=T,e[7]=z,e[8]=P,e[9]=C,e[10]=v,e[11]=n,e[12]=S,e[13]=i,e[14]=$):$=e[14];let b;e[15]!==I||e[16]!==_||e[17]!==s||e[18]!==y||e[19]!==k||e[20]!==P||e[21]!==O||e[22]!==l||e[23]!==u||e[24]!==v||e[25]!==n||e[26]!==w||e[27]!==i?(b=i==="cards"?o.jsx("div",{className:"flex-1 overflow-auto p-5",children:s.length===0?o.jsx("div",{className:"flex items-center justify-center h-full",children:y||o.jsx(Ve,{icon:"inbox",title:"No items found",description:u?"Try adjusting your search":"No items to display"})}):o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:s.map(U=>o.jsx("div",{onClick:()=>k?.(U),className:"cursor-pointer h-full",children:o.jsx(kt,{item:U,schema:l,readOnly:O,actions:I})},U.id))})}):o.jsx(vt,{columns:Ht(_,l,w,I),data:s,sortKey:n,sortDirection:v,onSort:P,onRowClick:k,emptyState:y||o.jsx(Ve,{icon:"inbox",title:"No items found",description:u?"Try adjusting your search":"No items to display"})}),e[15]=I,e[16]=_,e[17]=s,e[18]=y,e[19]=k,e[20]=P,e[21]=O,e[22]=l,e[23]=u,e[24]=v,e[25]=n,e[26]=w,e[27]=i,e[28]=b):b=e[28];let E;return e[29]!==$||e[30]!==b?(E=o.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[$,b]}),e[29]=$,e[30]=b,e[31]=E):E=e[31],E}function Vt(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Bt(t){return t.sortable!==!1}function Rt(){}function Ft(){}function Kt(){}function Lt(t){return{id:"actions",header:"",render:e=>o.jsxs(We,{children:[o.jsx(qe,{asChild:!0,children:o.jsx(ge,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:s=>s.stopPropagation(),children:o.jsx(M,{name:"more_vert",size:20})})}),o.jsxs(He,{align:"end",onClick:s=>s.stopPropagation(),children:[t.open&&o.jsxs(B,{onClick:s=>{s.stopPropagation(),t.open?.(e)},children:[o.jsx(M,{name:"visibility",size:16}),"Open"]}),t.edit&&o.jsxs(B,{onClick:s=>{s.stopPropagation(),t.edit?.(e)},children:[o.jsx(M,{name:"edit",size:16}),"Edit"]}),t.duplicate&&o.jsxs(B,{onClick:s=>{s.stopPropagation(),t.duplicate?.(e)},children:[o.jsx(M,{name:"content_copy",size:16}),"Duplicate"]}),t.delete&&o.jsxs(B,{variant:"destructive",onClick:s=>{s.stopPropagation(),t.delete?.(e)},children:[o.jsx(M,{name:"delete",size:16}),"Delete"]})]})]}),cellClassName:"w-[60px]",sortable:!1}}function Wt(t){const e=t.type;return e==="string"||e==="number"||e==="integer"||e==="boolean"}function Re(t){return t.type==="string"&&(t.format==="url"||t.format==="uri")}function qt(t,e){const s=t.properties||{},l=Object.keys(s).filter(n=>{const f=s[n];return f&&Wt(f)}),i=l.find(n=>{const f=s[n];return f&&Re(f)}),a=new Set;i&&a.add(i);const u=["title","description","updated_at","updated_by"];for(const n of u)l.includes(n)&&i!==n&&!a.has(n)&&a.add(n);for(const n of l)a.has(n)||a.add(n);return[...a.values()].map(n=>{const f=s[n];if(!f)return{id:n,header:n.charAt(0).toUpperCase()+n.slice(1).replace(/_/g," "),render:r=>{const d=r[n];return d==null?"—":o.jsx("span",{className:"block truncate max-w-full",children:String(d)})},sortable:e?e.includes(n):!["id"].includes(n),cellClassName:"max-w-[200px]"};const g=e?e.includes(n):!["id"].includes(n);return f.format==="date-time"||n.endsWith("_at")?{id:n,header:n.charAt(0).toUpperCase()+n.slice(1).replace(/_/g," "),render:r=>{const d=r[n];return d?o.jsx("span",{className:"block truncate max-w-full",children:new Date(d).toLocaleDateString()}):"—"},sortable:g,cellClassName:"max-w-[200px]"}:i===n&&Re(f)?{id:n,header:n.charAt(0).toUpperCase()+n.slice(1).replace(/_/g," "),render:r=>{const d=r[n];return d?o.jsx("img",{src:String(d),alt:n,className:"h-8 w-8 rounded object-cover"}):"—"},sortable:g,cellClassName:"max-w-[200px]"}:{id:n,header:n.charAt(0).toUpperCase()+n.slice(1).replace(/_/g," "),render:r=>{const d=r[n];return d==null?"—":o.jsx("span",{className:"block truncate max-w-full",children:String(d)})},sortable:g,cellClassName:"max-w-[100px]"}})}function Ht(t,e,s,l){const i=t||qt(e,s);return i.some(n=>n.id==="actions")?i:Object.keys(l).length>0?[...i,Lt(l)]:i}function Jt(t){const e=V.c(117),{connectionId:s,org:l,activeCollection:i}=t,a=i.name,u=i.schema??_t,n=i.hasCreateTool,f=i.hasUpdateTool,g=i.hasDeleteTool,r=Oe(),{data:d}=Ye.useSession(),x=d?.user?.id||"unknown",h=Ke(s);let j;e[0]!==s?(j=it(s),e[0]=s,e[1]=j):j=e[1];const p=j,c=st(s,a,p),N=`${s}-${a}`;let C;e[2]!==l||e[3]!==N?(C={namespace:l,resource:N,defaultSortKey:"updated_at"},e[2]=l,e[3]=N,e[4]=C):C=e[4];const{search:v,searchTerm:P,setSearch:m,viewMode:I,setViewMode:k,sortKey:T,sortDirection:y,handleSort:O}=yt(C);let _;e[5]!==P||e[6]!==y||e[7]!==T?(_={searchTerm:P,sortKey:T,sortDirection:y},e[5]=P,e[6]=y,e[7]=T,e[8]=_):_=e[8];const z=nt(s,a,p,_),w=!n&&!f&&!g;let D;e[9]!==a||e[10]!==s||e[11]!==r||e[12]!==l?(D=A=>{r({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:l,connectionId:s,collectionName:a,itemId:A.id}})},e[9]=a,e[10]=s,e[11]=r,e[12]=l,e[13]=D):D=e[13];const S=D;let $;e[14]!==c.create||e[15]!==x?($=async A=>{const he=new Date().toISOString();await c.create.mutateAsync({...A,id:Be("conn"),title:`${A.title} (Copy)`,created_at:he,updated_at:he,created_by:x,updated_by:x})},e[14]=c.create,e[15]=x,e[16]=$):$=e[16];const b=$,[E,U]=ze.useState(null);let le;e[17]===Symbol.for("react.memo_cache_sentinel")?(le=A=>{U(A)},e[17]=le):le=e[17];const Ge=le;let R;e[18]!==S||e[19]!==f?(R=f&&{edit:S},e[18]=S,e[19]=f,e[20]=R):R=e[20];let F;e[21]!==b||e[22]!==n?(F=n&&{duplicate:b},e[21]=b,e[22]=n,e[23]=F):F=e[23];let K;e[24]!==g?(K=g&&{delete:Ge},e[24]=g,e[25]=K):K=e[25];let ae;e[26]!==K||e[27]!==R||e[28]!==F?(ae={...R,...F,...K},e[26]=K,e[27]=R,e[28]=F,e[29]=ae):ae=e[29];const xe=ae;let re;e[30]!==c.delete||e[31]!==E?(re=async()=>{E&&(await c.delete.mutateAsync(E.id),U(null))},e[30]=c.delete,e[31]=E,e[32]=re):re=e[32];const je=re;let ce;e[33]!==c.create||e[34]!==a||e[35]!==s||e[36]!==n||e[37]!==r||e[38]!==l||e[39]!==x?(ce=async()=>{if(!n){Ze.error("Create operation is not available for this collection");return}const A=new Date().toISOString(),he={id:Be("conn"),title:"New Item",created_at:A,updated_at:A,created_by:x,updated_by:x};try{const ke=await c.create.mutateAsync(he);r({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:l,connectionId:s,collectionName:a,itemId:ke.id}})}catch(ke){console.error("Failed to create item:",ke)}},e[33]=c.create,e[34]=a,e[35]=s,e[36]=n,e[37]=r,e[38]=l,e[39]=x,e[40]=ce):ce=e[40];const be=ce;let de;e[41]!==u?(de=Je(u),e[41]=u,e[42]=de):de=e[42];const Ce=de,Me=(z?.length??0)>0,Qe=n&&Me,Xe=n&&!Me&&!v;let me;e[43]!==c.create||e[44]!==be||e[45]!==n?(me=n?o.jsxs(ge,{onClick:be,size:"sm",disabled:c.create.isPending,className:"h-7",children:[o.jsx(rt,{className:"mr-2 h-4 w-4"}),c.create.isPending?"Creating...":"Create"]}):null,e[43]=c.create,e[44]=be,e[45]=n,e[46]=me):me=e[46];const Ue=me,ve=T;let L;e[47]!==O||e[48]!==k||e[49]!==y||e[50]!==Ce||e[51]!==ve||e[52]!==I?(L=o.jsx(Le,{viewMode:I,onViewModeChange:k,sortKey:ve,sortDirection:y,onSort:O,sortOptions:Ce}),e[47]=O,e[48]=k,e[49]=y,e[50]=Ce,e[51]=ve,e[52]=I,e[53]=L):L=e[53];const ye=`${a}s`,_e=h?.icon??"grid_view";let W;e[54]!==s||e[55]!==ye||e[56]!==_e?(W=o.jsx(ct,{connectionId:s,title:ye,icon:_e}),e[54]=s,e[55]=ye,e[56]=_e,e[57]=W):W=e[57];const we=Qe&&Ue;let q;e[58]!==L||e[59]!==W||e[60]!==we?(q=o.jsxs(ht,{children:[L,W,we]}),e[58]=L,e[59]=W,e[60]=we,e[61]=q):q=e[61];const Se=`Search ${a}...`;let H;e[62]!==m?(H=A=>{A.key==="Escape"&&(m(""),A.target.blur())},e[62]=m,e[63]=H):H=e[63];let J;e[64]!==v||e[65]!==m||e[66]!==Se||e[67]!==H?(J=o.jsx(jt,{value:v,onChange:m,placeholder:Se,onKeyDown:H}),e[64]=v,e[65]=m,e[66]=Se,e[67]=H,e[68]=J):J=e[68];let G;e[69]!==z?(G=z??[],e[69]=z,e[70]=G):G=e[70];const Ne=T;let Q;e[71]!==S?(Q=A=>S(A),e[71]=S,e[72]=Q):Q=e[72];const Ie="No items found",Te=v?"Try adjusting your search terms":"This collection doesn't have any items yet.",De=Xe?Ue:void 0;let X;e[73]!==Ie||e[74]!==Te||e[75]!==De?(X=o.jsx(Ee,{image:null,title:Ie,description:Te,actions:De}),e[73]=Ie,e[74]=Te,e[75]=De,e[76]=X):X=e[76];let Y;e[77]!==O||e[78]!==w||e[79]!==xe||e[80]!==u||e[81]!==v||e[82]!==m||e[83]!==k||e[84]!==y||e[85]!==G||e[86]!==Ne||e[87]!==Q||e[88]!==X||e[89]!==I?(Y=o.jsx("div",{className:"flex-1 overflow-auto",children:o.jsx(Ut,{hideToolbar:!0,data:G,schema:u,viewMode:I,onViewModeChange:k,search:v,onSearchChange:m,sortKey:Ne,sortDirection:y,onSort:O,actions:xe,onItemClick:Q,readOnly:w,emptyState:X})}),e[77]=O,e[78]=w,e[79]=xe,e[80]=u,e[81]=v,e[82]=m,e[83]=k,e[84]=y,e[85]=G,e[86]=Ne,e[87]=Q,e[88]=X,e[89]=I,e[90]=Y):Y=e[90];let Z;e[91]!==J||e[92]!==Y?(Z=o.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[J,Y]}),e[91]=J,e[92]=Y,e[93]=Z):Z=e[93];const $e=!!E;let ue;e[94]===Symbol.for("react.memo_cache_sentinel")?(ue=A=>{A||U(null)},e[94]=ue):ue=e[94];let fe;e[95]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx(Nt,{children:"Delete item?"}),e[95]=fe):fe=e[95];const Ae=E?.title;let ee;e[96]!==Ae?(ee=o.jsxs(It,{children:[fe,o.jsxs(Tt,{children:['Are you sure you want to delete "',Ae,'"? This action cannot be undone.']})]}),e[96]=Ae,e[97]=ee):ee=e[97];let te;e[98]!==c.delete.isPending?(te=o.jsx(wt,{disabled:c.delete.isPending,children:"Cancel"}),e[98]=c.delete.isPending,e[99]=te):te=e[99];const Pe=c.delete.isPending?"Deleting...":"Delete";let oe;e[100]!==c.delete.isPending||e[101]!==je||e[102]!==Pe?(oe=o.jsx(St,{onClick:je,disabled:c.delete.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Pe}),e[100]=c.delete.isPending,e[101]=je,e[102]=Pe,e[103]=oe):oe=e[103];let se;e[104]!==te||e[105]!==oe?(se=o.jsxs(Dt,{children:[te,oe]}),e[104]=te,e[105]=oe,e[106]=se):se=e[106];let ne;e[107]!==ee||e[108]!==se?(ne=o.jsxs($t,{children:[ee,se]}),e[107]=ee,e[108]=se,e[109]=ne):ne=e[109];let ie;e[110]!==$e||e[111]!==ne?(ie=o.jsx(At,{open:$e,onOpenChange:ue,children:ne}),e[110]=$e,e[111]=ne,e[112]=ie):ie=e[112];let pe;return e[113]!==q||e[114]!==Z||e[115]!==ie?(pe=o.jsxs(o.Fragment,{children:[q,Z,ie]}),e[113]=q,e[114]=Z,e[115]=ie,e[116]=pe):pe=e[116],pe}function Gt(t){const e=V.c(2),{repository:s}=t;let l;return e[0]!==s?(l=o.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:o.jsx(ut,{repository:s})}),e[0]=s,e[1]=l):l=e[1],l}function Qt(t){const e=V.c(4),{tools:s,connectionId:l,org:i}=t;let a;return e[0]!==l||e[1]!==i||e[2]!==s?(a=o.jsx(ft,{tools:s,connectionId:l,org:i}),e[0]=l,e[1]=i,e[2]=s,e[3]=a):a=e[3],a}function Xt(t){const e=V.c(49),{connection:s,connectionId:l,org:i,requestedTabId:a,collections:u,onUpdate:n,isUpdating:f}=t,g=ot();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={from:"/$org/mcps/$connectionId"},e[0]=r):r=e[0];const d=Oe(r);let x;e[1]!==s.connection_token||e[2]!==s.connection_url?(x={url:s.connection_url,token:s.connection_token},e[1]=s.connection_token,e[2]=s.connection_url,e[3]=x):x=e[3];const h=dt(x),j=s?.metadata?.repository,p=!!j?.url,c=s?.tools?.length??0;let N;e[4]===Symbol.for("react.memo_cache_sentinel")?(N={id:"settings",label:"Settings"},e[4]=N):N=e[4];let C;e[5]!==h||e[6]!==c?(C=h&&c>0?[{id:"tools",label:"Tools",count:c}]:[],e[5]=h,e[6]=c,e[7]=C):C=e[7];let v;if(e[8]!==u||e[9]!==p||e[10]!==h||e[11]!==C){let b;e[13]!==p?(b=p?[{id:"readme",label:"README"}]:[],e[13]=p,e[14]=b):b=e[14],v=[N,...C,...h?(u||[]).map(Yt):[],...b],e[8]=u,e[9]=p,e[10]=h,e[11]=C,e[12]=v}else v=e[12];const P=v,m=P.some(b=>b.id===a)?a:"settings";let I;e[15]!==d?(I=b=>{d({search:E=>({...E,tab:b}),replace:!0})},e[15]=d,e[16]=I):I=e[16];const k=I;let T;e[17]!==u?(T=u||[],e[17]=u,e[18]=T):T=e[18];let y;if(e[19]!==m||e[20]!==T){let b;e[22]!==m?(b=E=>E.name===m,e[22]=m,e[23]=b):b=e[23],y=T.find(b),e[19]=m,e[20]=T,e[21]=y}else y=e[21];const O=y;let _;e[24]!==g.history?(_=()=>g.history.back(),e[24]=g.history,e[25]=_):_=e[25];let z;e[26]!==m||e[27]!==k||e[28]!==P?(z=o.jsx(gt,{children:o.jsx(pt,{tabs:P,activeTab:m,onTabChange:k})}),e[26]=m,e[27]=k,e[28]=P,e[29]=z):z=e[29];let w;e[30]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(M,{size:32,name:"progress_activity",className:"animate-spin text-muted-foreground"})}),e[30]=w):w=e[30];let D;e[31]!==O||e[32]!==m||e[33]!==s||e[34]!==l||e[35]!==p||e[36]!==h||e[37]!==f||e[38]!==n||e[39]!==i||e[40]!==j?(D=o.jsx(ze.Suspense,{fallback:w,children:m==="tools"?o.jsx(Qt,{tools:s.tools??void 0,connectionId:l,org:i}):m==="settings"?o.jsx(mt,{connection:s,onUpdate:n,isUpdating:f,isMCPAuthenticated:h}):m==="readme"&&p?o.jsx(Gt,{repository:j}):O&&h?o.jsx(Jt,{connectionId:l,org:i,activeCollection:O},m):o.jsx(Ee,{title:"Collection not found",description:"This collection may have been deleted or you may not have access."})}),e[31]=O,e[32]=m,e[33]=s,e[34]=l,e[35]=p,e[36]=h,e[37]=f,e[38]=n,e[39]=i,e[40]=j,e[41]=D):D=e[41];let S;e[42]!==m||e[43]!==D?(S=o.jsx("div",{className:"flex h-full w-full bg-background overflow-hidden",children:o.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-auto",children:o.jsx(Fe,{children:D},m)})}),e[42]=m,e[43]=D,e[44]=S):S=e[44];let $;return e[45]!==z||e[46]!==S||e[47]!==_?($=o.jsxs(xt,{onBack:_,children:[z,S]}),e[45]=z,e[46]=S,e[47]=_,e[48]=$):$=e[48],$}function Yt(t){return{id:t.name,label:t.displayName}}function Zt(){const t=V.c(17);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/mcps/$connectionId"},t[0]=e):e=t[0];const s=Oe(e);let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l={from:"/shell/$org/mcps/$connectionId"},t[1]=l):l=t[1];const{connectionId:i,org:a}=et(l);let u;t[2]===Symbol.for("react.memo_cache_sentinel")?(u={from:"/shell/$org/mcps/$connectionId"},t[2]=u):u=t[2];const f=tt(u).tab||"settings",g=Ke(i),r=lt(),d=at(g??void 0);let x;t[3]!==r.update||t[4]!==i?(x=async p=>{await r.update.mutateAsync({id:i,data:p})},t[3]=r.update,t[4]=i,t[5]=x):x=t[5];const h=x;if(!g){let p;return t[6]!==s||t[7]!==a?(p=o.jsx("div",{className:"flex h-full w-full bg-background",children:o.jsx(Ee,{title:"Connection not found",description:"This connection may have been deleted or you may not have access.",actions:o.jsx(ge,{variant:"outline",onClick:()=>s({to:"/$org/mcps",params:{org:a}}),children:"Back to connections"})})}),t[6]=s,t[7]=a,t[8]=p):p=t[8],p}let j;return t[9]!==r.update.isPending||t[10]!==d||t[11]!==g||t[12]!==i||t[13]!==h||t[14]!==a||t[15]!==f?(j=o.jsx(Xt,{org:a,connection:g,connectionId:i,requestedTabId:f,collections:d,onUpdate:h,isUpdating:r.update.isPending}),t[9]=r.update.isPending,t[10]=d,t[11]=g,t[12]=i,t[13]=h,t[14]=a,t[15]=f,t[16]=j):j=t[16],j}function eo(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Fe,{children:o.jsx(ze.Suspense,{fallback:o.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:o.jsx(M,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Zt,{})})}),t[0]=e):e=t[0],e}function Ro(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(eo,{}),t[0]=e):e=t[0],e}export{Ro as default};
@@ -1 +0,0 @@
1
- import{c as Ae,j as t,r as Ne,a5 as ze,b as Ee,a as Fe,ar as Ke,as as Be}from"./index-VCe1FY3E.js";import{C as He}from"./schema-CJRWBwzd.js";import{C as Oe}from"./collection-header-C3vTyWNy.js";import{C as Re}from"./collection-page-BplXISpO.js";import{C as Ve}from"./collection-search-BpPEPb0j.js";import{C as Le}from"./collection-table-wrapper-CJdrG443.js";import{C as Ue}from"./connection-card-B7VMSnFz.js";import{E as De}from"./empty-state-BCgOYCyG.js";import{E as We}from"./error-boundary-L4NxoU-J.js";import{I as qe}from"./integration-icon-Dgf9Pzxc.js";import{d as Ge,b as Je}from"./use-connection-D5nZyekX.js";import{u as Qe}from"./use-list-state-BTIryg2o.js";import{u as Xe}from"./tooltip-BLbXpJcn.js";import{c as Ye,b as Ze,d as et,A as tt,e as nt,g as ot,a as st,f as it}from"./alert-dialog-DsYjmjQa.js";import{B as rt}from"./badge-D0svJbIE.js";import{B as E}from"./button-CB7Gt-Ba.js";import{a as ct,b as lt,D as at,f as dt,c as mt,d as ut}from"./dialog-DhrfZsqb.js";import{b as Me,D as Pe,a as Te,c as pe}from"./dropdown-menu-zoKN8fKM.js";import{F,a as pt,b as K,c as B,d as H,f as O}from"./form-BmhZau8F.js";import{I as m}from"./icon-Zm7eEeKG.js";import{I as Ie}from"./input-DWY0hRYC.js";import{c as ht,a as ft,S as gt,b as xt,d as ke}from"./select-CrueAR2N.js";import{T as jt}from"./textarea-CAmjTm6l.js";import{g as _t}from"./generate-id-Dyweu44Y.js";import"./collection-display-button-Ccjj22Xn.js";import"./utils-B-QWwgyW.js";import"./card-BZePxfHz.js";import"./use-mobile-BPQzOCZP.js";const Ct=He.pick({title:!0,description:!0,connection_type:!0,connection_url:!0,connection_token:!0}).partial({description:!0,connection_token:!0});function St(e,n){switch(n.type){case"edit":return{mode:"editing",connection:n.connection};case"delete":return{mode:"deleting",connection:n.connection};case"close":return{mode:"idle"}}}function yt(){const e=Ae.c(120),{org:n}=Xe(),r=ze();let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={strict:!1},e[0]=R):R=e[0];const $e=Ee(R),{data:he}=Fe.useSession();let V;e[1]!==n.slug?(V={namespace:n.slug,resource:"connections"},e[1]=n.slug,e[2]=V):V=e[2];const o=Qe(V),d=Ge(),z=Je(o);let L;e[3]===Symbol.for("react.memo_cache_sentinel")?(L={mode:"idle"},e[3]=L):L=e[3];const[l,u]=Ne.useReducer(St,L),U=$e.action==="create";let W;e[4]!==r||e[5]!==n.slug?(W=()=>{r({to:"/$org/mcps",params:{org:n.slug},search:{action:"create"}})},e[4]=r,e[5]=n.slug,e[6]=W):W=e[6];const fe=W;let q;e[7]!==r||e[8]!==n.slug?(q=()=>{r({to:"/$org/mcps",params:{org:n.slug},search:{}})},e[7]=r,e[8]=n.slug,e[9]=q):q=e[9];const p=q;let G;e[10]===Symbol.for("react.memo_cache_sentinel")?(G={resolver:Ke(Ct),defaultValues:{title:"",description:null,connection_type:"HTTP",connection_url:"",connection_token:null}},e[10]=G):G=e[10];const i=Be(G),c=l.mode==="editing"?l.connection:null;let J,Q;e[11]!==c||e[12]!==i?(J=()=>{c?i.reset({title:c.title,description:c.description,connection_type:c.connection_type,connection_url:c.connection_url,connection_token:null}):i.reset({title:"",description:null,connection_type:"HTTP",connection_url:"",connection_token:null})},Q=[c,i],e[11]=c,e[12]=i,e[13]=J,e[14]=Q):(J=e[13],Q=e[14]),Ne.useEffect(J,Q);let X;e[15]!==d||e[16]!==l.connection||e[17]!==l.mode?(X=async()=>{if(l.mode!=="deleting")return;const s=l.connection.id;u({type:"close"});try{await d.delete.mutateAsync(s)}catch{}},e[15]=d,e[16]=l.connection,e[17]=l.mode,e[18]=X):X=e[18];const ge=X;let Y;e[19]!==d||e[20]!==p||e[21]!==c||e[22]!==i||e[23]!==r||e[24]!==n.id||e[25]!==n.slug||e[26]!==he?.user?.id?(Y=async s=>{if(c){await d.update.mutateAsync({id:c.id,data:{title:s.title,description:s.description||null,connection_type:s.connection_type,connection_url:s.connection_url,...s.connection_token&&{connection_token:s.connection_token}}}),u({type:"close"}),i.reset();return}const a=_t("conn");await d.create.mutateAsync({id:a,title:s.title,description:s.description||null,connection_type:s.connection_type,connection_url:s.connection_url,connection_token:s.connection_token||null,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:he?.user?.id||"system",organization_id:n.id,icon:null,app_name:null,app_id:null,connection_headers:null,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),p(),i.reset(),r({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:a}})},e[19]=d,e[20]=p,e[21]=c,e[22]=i,e[23]=r,e[24]=n.id,e[25]=n.slug,e[26]=he?.user?.id,e[27]=Y):Y=e[27];const xe=Y;let Z;e[28]!==p||e[29]!==i||e[30]!==U?(Z=s=>{s||(U?p():u({type:"close"}),i.reset())},e[28]=p,e[29]=i,e[30]=U,e[31]=Z):Z=e[31];const h=Z;let ee,te,ne,oe,se,ie;e[32]===Symbol.for("react.memo_cache_sentinel")?(ee={id:"icon",header:"",render:Ft,cellClassName:"w-16 shrink-0"},te={id:"title",header:"Name",render:Et,cellClassName:"w-48 min-w-0 shrink-0",sortable:!0},ne={id:"description",header:"Description",render:zt,cellClassName:"flex-1 min-w-0",wrap:!0,sortable:!0},oe={id:"connection_type",header:"Type",accessor:$t,cellClassName:"w-24 shrink-0",sortable:!0},se={id:"connection_url",header:"URL",render:At,wrap:!0,cellClassName:"w-48 min-w-0 shrink-0"},ie={id:"status",header:"Status",render:Tt,cellClassName:"w-24 shrink-0",sortable:!0},e[32]=ee,e[33]=te,e[34]=ne,e[35]=oe,e[36]=se,e[37]=ie):(ee=e[32],te=e[33],ne=e[34],oe=e[35],se=e[36],ie=e[37]);let re;e[38]!==r||e[39]!==n.slug?(re=[ee,te,ne,oe,se,ie,{id:"actions",header:"",render:s=>t.jsxs(Me,{children:[t.jsx(Pe,{asChild:!0,children:t.jsx(E,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Pt,children:t.jsx(m,{name:"more_vert",size:20})})}),t.jsxs(Te,{align:"end",onClick:Mt,children:[t.jsxs(pe,{onClick:a=>{a.stopPropagation(),r({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:s.id}})},children:[t.jsx(m,{name:"visibility",size:16}),"Inspect"]}),t.jsxs(pe,{variant:"destructive",onClick:a=>{a.stopPropagation(),u({type:"delete",connection:s})},children:[t.jsx(m,{name:"delete",size:16}),"Delete"]})]})]}),cellClassName:"w-12 shrink-0"}],e[38]=r,e[39]=n.slug,e[40]=re):re=e[40];const je=re;let ce;e[41]!==fe?(ce=t.jsx(E,{onClick:fe,size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:"Connect MCP Server"}),e[41]=fe,e[42]=ce):ce=e[42];const _e=ce,Ce=U||l.mode==="editing",Se=c?"Edit Connection":"Create New Connection";let f;e[43]!==Se?(f=t.jsx(ct,{children:Se}),e[43]=Se,e[44]=f):f=e[44];const ye=c?"Update the connection details below.":"Add a new connection to your organization. Fill in the details below.";let g;e[45]!==ye?(g=t.jsx(lt,{children:ye}),e[45]=ye,e[46]=g):g=e[46];let x;e[47]!==f||e[48]!==g?(x=t.jsxs(at,{children:[f,g]}),e[47]=f,e[48]=g,e[49]=x):x=e[49];let j;e[50]!==i||e[51]!==xe?(j=i.handleSubmit(xe),e[50]=i,e[51]=xe,e[52]=j):j=e[52];let _;e[53]!==i.control?(_=t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsx(F,{control:i.control,name:"title",render:It}),t.jsx(F,{control:i.control,name:"description",render:Nt}),t.jsx(F,{control:i.control,name:"connection_type",render:kt}),t.jsx(F,{control:i.control,name:"connection_url",render:Dt}),t.jsx(F,{control:i.control,name:"connection_token",render:wt})]}),e[53]=i.control,e[54]=_):_=e[54];let C;e[55]!==h?(C=t.jsx(E,{type:"button",variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e[55]=h,e[56]=C):C=e[56];const ve=i.formState.isSubmitting?"Saving...":c?"Update Connection":"Create Connection";let S;e[57]!==i.formState.isSubmitting||e[58]!==ve?(S=t.jsx(E,{type:"submit",disabled:i.formState.isSubmitting,className:"min-w-40",children:ve}),e[57]=i.formState.isSubmitting,e[58]=ve,e[59]=S):S=e[59];let y;e[60]!==C||e[61]!==S?(y=t.jsxs(dt,{children:[C,S]}),e[60]=C,e[61]=S,e[62]=y):y=e[62];let v;e[63]!==j||e[64]!==_||e[65]!==y?(v=t.jsxs("form",{onSubmit:j,children:[_,y]}),e[63]=j,e[64]=_,e[65]=y,e[66]=v):v=e[66];let b;e[67]!==i||e[68]!==v?(b=t.jsx(pt,{...i,children:v}),e[67]=i,e[68]=v,e[69]=b):b=e[69];let w;e[70]!==x||e[71]!==b?(w=t.jsxs(mt,{className:"sm:max-w-[525px]",children:[x,b]}),e[70]=x,e[71]=b,e[72]=w):w=e[72];let D;e[73]!==h||e[74]!==Ce||e[75]!==w?(D=t.jsx(ut,{open:Ce,onOpenChange:h,children:w}),e[73]=h,e[74]=Ce,e[75]=w,e[76]=D):D=e[76];const be=l.mode==="deleting";let le;e[77]===Symbol.for("react.memo_cache_sentinel")?(le=s=>!s&&u({type:"close"}),e[77]=le):le=e[77];let ae;e[78]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsx(Ye,{children:"Delete Connection?"}),e[78]=ae):ae=e[78];const we=l.mode==="deleting"&&l.connection.title;let k;e[79]!==we?(k=t.jsxs(Ze,{children:[ae,t.jsxs(et,{children:["This action cannot be undone. This will permanently delete"," ",t.jsx("span",{className:"font-medium text-foreground",children:we}),"."]})]}),e[79]=we,e[80]=k):k=e[80];let de;e[81]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsx(tt,{children:"Cancel"}),e[81]=de):de=e[81];let N;e[82]!==ge?(N=t.jsxs(nt,{children:[de,t.jsx(ot,{onClick:ge,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]}),e[82]=ge,e[83]=N):N=e[83];let I;e[84]!==k||e[85]!==N?(I=t.jsxs(st,{children:[k,N]}),e[84]=k,e[85]=N,e[86]=I):I=e[86];let M;e[87]!==be||e[88]!==I?(M=t.jsx(it,{open:be,onOpenChange:le,children:I}),e[87]=be,e[88]=I,e[89]=M):M=e[89];let me;e[90]===Symbol.for("react.memo_cache_sentinel")?(me=[{id:"title",label:"Name"},{id:"description",label:"Description"},{id:"connection_type",label:"Type"},{id:"status",label:"Status"}],e[90]=me):me=e[90];let P;e[91]!==_e||e[92]!==o.handleSort||e[93]!==o.setViewMode||e[94]!==o.sortDirection||e[95]!==o.sortKey||e[96]!==o.viewMode?(P=t.jsx(Oe,{title:"MCP Servers",viewMode:o.viewMode,onViewModeChange:o.setViewMode,sortKey:o.sortKey,sortDirection:o.sortDirection,onSort:o.handleSort,sortOptions:me,ctaButton:_e}),e[91]=_e,e[92]=o.handleSort,e[93]=o.setViewMode,e[94]=o.sortDirection,e[95]=o.sortKey,e[96]=o.viewMode,e[97]=P):P=e[97];let T;e[98]!==o?(T=s=>{s.key==="Escape"&&(o.setSearch(""),s.target.blur())},e[98]=o,e[99]=T):T=e[99];let A;e[100]!==o.search||e[101]!==o.setSearch||e[102]!==T?(A=t.jsx(Ve,{value:o.search,onChange:o.setSearch,placeholder:"Search for an MCP Server...",onKeyDown:T}),e[100]=o.search,e[101]=o.setSearch,e[102]=T,e[103]=A):A=e[103];let $;e[104]!==je||e[105]!==z||e[106]!==o.handleSort||e[107]!==o.search||e[108]!==o.sortDirection||e[109]!==o.sortKey||e[110]!==o.viewMode||e[111]!==r||e[112]!==n.slug?($=o.viewMode==="cards"?t.jsx("div",{className:"flex-1 overflow-auto p-5",children:z.length===0?t.jsx(De,{image:t.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:500,height:223,"aria-hidden":"true"}),title:(o.search,"No MCP Servers found"),description:o.search?`No MCP Servers match "${o.search}"`:"Create a connection to get started."}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:z.map(s=>t.jsx(Ue,{connection:s,fallbackIcon:"extension",onClick:()=>r({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:s.id}}),headerActions:t.jsxs(Me,{children:[t.jsx(Pe,{asChild:!0,children:t.jsx(E,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:bt,children:t.jsx(m,{name:"more_vert",size:20})})}),t.jsxs(Te,{align:"end",onClick:vt,children:[t.jsxs(pe,{onClick:a=>{a.stopPropagation(),r({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:s.id}})},children:[t.jsx(m,{name:"visibility",size:16}),"Inspect"]}),t.jsxs(pe,{variant:"destructive",onClick:a=>{a.stopPropagation(),u({type:"delete",connection:s})},children:[t.jsx(m,{name:"delete",size:16}),"Delete"]})]})]})},s.id))})}):t.jsx(Le,{columns:je,data:z,isLoading:!1,sortKey:o.sortKey,sortDirection:o.sortDirection,onSort:o.handleSort,onRowClick:s=>r({to:"/$org/mcps/$connectionId",params:{org:n.slug,connectionId:s.id}}),emptyState:o.search?t.jsx(De,{image:t.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:500,height:223,"aria-hidden":"true"}),title:"No MCP Servers found",description:`No MCP Servers match "${o.search}"`}):t.jsx(De,{image:t.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:500,height:223,"aria-hidden":"true"}),title:"No MCP Servers found",description:"Create a connection to get started."})}),e[104]=je,e[105]=z,e[106]=o.handleSort,e[107]=o.search,e[108]=o.sortDirection,e[109]=o.sortKey,e[110]=o.viewMode,e[111]=r,e[112]=n.slug,e[113]=$):$=e[113];let ue;return e[114]!==D||e[115]!==M||e[116]!==P||e[117]!==A||e[118]!==$?(ue=t.jsxs(Re,{children:[D,M,P,A,$]}),e[114]=D,e[115]=M,e[116]=P,e[117]=A,e[118]=$,e[119]=ue):ue=e[119],ue}function vt(e){return e.stopPropagation()}function bt(e){return e.stopPropagation()}function wt(e){const{field:n}=e;return t.jsxs(K,{children:[t.jsx(B,{children:"Token (optional)"}),t.jsx(H,{children:t.jsx(Ie,{type:"password",placeholder:"Bearer token or API key",...n,value:n.value??""})}),t.jsx(O,{})]})}function Dt(e){const{field:n}=e;return t.jsxs(K,{children:[t.jsx(B,{children:"URL *"}),t.jsx(H,{children:t.jsx(Ie,{placeholder:"https://example.com/mcp",...n})}),t.jsx(O,{})]})}function kt(e){const{field:n}=e;return t.jsxs(K,{children:[t.jsx(B,{children:"Type *"}),t.jsxs(ht,{value:n.value,onValueChange:n.onChange,children:[t.jsx(H,{children:t.jsx(ft,{children:t.jsx(gt,{})})}),t.jsxs(xt,{children:[t.jsx(ke,{value:"HTTP",children:"HTTP"}),t.jsx(ke,{value:"SSE",children:"SSE"}),t.jsx(ke,{value:"Websocket",children:"Websocket"})]})]}),t.jsx(O,{})]})}function Nt(e){const{field:n}=e;return t.jsxs(K,{children:[t.jsx(B,{children:"Description"}),t.jsx(H,{children:t.jsx(jt,{placeholder:"A brief description of this connection",rows:3,...n,value:n.value??""})}),t.jsx(O,{})]})}function It(e){const{field:n}=e;return t.jsxs(K,{children:[t.jsx(B,{children:"Name *"}),t.jsx(H,{children:t.jsx(Ie,{placeholder:"My Connection",...n})}),t.jsx(O,{})]})}function Mt(e){return e.stopPropagation()}function Pt(e){return e.stopPropagation()}function Tt(e){return t.jsx(rt,{variant:e.status==="active"?"default":"outline",children:e.status})}function At(e){return t.jsx("span",{className:"text-sm text-muted-foreground block truncate",children:e.connection_url})}function $t(e){return t.jsx("span",{className:"text-sm font-medium",children:e.connection_type})}function zt(e){return t.jsx("span",{className:"text-sm text-foreground line-clamp-2",children:e.description||"—"})}function Et(e){return t.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title})}function Ft(e){return t.jsx(qe,{icon:e.icon,name:e.title,size:"sm",className:"shrink-0 shadow-sm",fallbackIcon:"extension"})}function pn(){const e=Ae.c(1);let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(We,{children:t.jsx(Ne.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(m,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(yt,{})})}),e[0]=n):n=e[0],n}export{pn as default};
@@ -1 +0,0 @@
1
- import{c as n,j as i,a8 as m,ax as g,ab as u,a9 as x,aa as j,ac as N,ae as h,ad as b}from"./index-VCe1FY3E.js";import{c}from"./utils-B-QWwgyW.js";import{c as D}from"./tooltip-BLbXpJcn.js";const v=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],y=D("x",v);function T(l){const e=n.c(4);let t;e[0]!==l?({...t}=l,e[0]=l,e[1]=t):t=e[1];let s;return e[2]!==t?(s=i.jsx(m,{"data-slot":"dialog",...t}),e[2]=t,e[3]=s):s=e[3],s}function R(l){const e=n.c(4);let t;e[0]!==l?({...t}=l,e[0]=l,e[1]=t):t=e[1];let s;return e[2]!==t?(s=i.jsx(g,{"data-slot":"dialog-trigger",...t}),e[2]=t,e[3]=s):s=e[3],s}function $(l){const e=n.c(4);let t;e[0]!==l?({...t}=l,e[0]=l,e[1]=t):t=e[1];let s;return e[2]!==t?(s=i.jsx(N,{"data-slot":"dialog-portal",...t}),e[2]=t,e[3]=s):s=e[3],s}function _(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=c("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx(h,{"data-slot":"dialog-overlay",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}function k(l){const e=n.c(6),{className:t}=l;let s;e[0]!==t?(s=c("cursor-pointer ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground","absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2","focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),e[0]=t,e[1]=s):s=e[1];let a,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(y,{}),o=i.jsx("span",{className:"sr-only",children:"Close"}),e[2]=a,e[3]=o):(a=e[2],o=e[3]);let r;return e[4]!==s?(r=i.jsxs(b,{className:s,children:[a,o]}),e[4]=s,e[5]=r):r=e[5],r}function B(l){const e=n.c(15);let t,s,a,o;e[0]!==l?({className:s,children:t,closeButtonClassName:a,...o}=l,e[0]=l,e[1]=t,e[2]=s,e[3]=a,e[4]=o):(t=e[1],s=e[2],a=e[3],o=e[4]);let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(_,{}),e[5]=r):r=e[5];let d;e[6]!==s?(d=c("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-xl border p-6 shadow-lg duration-200 sm:max-w-lg",s),e[6]=s,e[7]=d):d=e[7];let f;e[8]!==a?(f=i.jsx(k,{className:a}),e[8]=a,e[9]=f):f=e[9];let p;return e[10]!==t||e[11]!==o||e[12]!==d||e[13]!==f?(p=i.jsxs($,{"data-slot":"dialog-portal",children:[r,i.jsxs(u,{"data-slot":"dialog-content",className:d,...o,children:[t,f]})]}),e[10]=t,e[11]=o,e[12]=d,e[13]=f,e[14]=p):p=e[14],p}function E(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=c("flex flex-col gap-2 text-center sm:text-left",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx("div",{"data-slot":"dialog-header",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}function O(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=c("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx("div",{"data-slot":"dialog-footer",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}function P(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=c("text-lg leading-none font-semibold",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx(x,{"data-slot":"dialog-title",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}function S(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=c("text-muted-foreground text-sm",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx(j,{"data-slot":"dialog-description",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}export{E as D,y as X,P as a,S as b,B as c,T as d,R as e,O as f};
@@ -1 +0,0 @@
1
- import{r as N,aB as Be,j as t,aC as je,az as be,aO as Fe,aE as Ge,bf as De,bg as Ue,c as O,a5 as Ve,d as Me,ap as Oe,bi as fe,aq as he,b5 as We,ar as Le,as as qe,a6 as xe}from"./index-VCe1FY3E.js";import{E as He}from"./empty-state-BCgOYCyG.js";import{E as ye}from"./error-boundary-L4NxoU-J.js";import{I as Je}from"./integration-icon-Dgf9Pzxc.js";import{T as Xe}from"./tool-set-selector-BfScgRcK.js";import{b as Ke,a as Qe}from"./use-gateway-pRk3-ua4.js";import{b as Ye}from"./use-connection-D5nZyekX.js";import{B as J}from"./button-CB7Gt-Ba.js";import{I as M}from"./icon-Zm7eEeKG.js";import{I as ve}from"./input-DWY0hRYC.js";import{c as pe}from"./utils-B-QWwgyW.js";import{F as Z,a as Ze,b as te,d as se,f as oe,c as _e}from"./form-BmhZau8F.js";import{c as we,a as Ce,S as Se,b as Ne,d as ee}from"./select-CrueAR2N.js";import{d as X,b as K,a as Q,T as Y}from"./tooltip-BLbXpJcn.js";import{V as et,b as tt}from"./layout-C75gYFRR.js";import{f as st}from"./formatDistanceToNow-Ctx6mZEP.js";import"./checkbox-CJwRElzS.js";import"./collection-search-BpPEPb0j.js";var me="Switch",[ot]=Be(me),[nt,lt]=ot(me),ke=N.forwardRef((o,e)=>{const{__scopeSwitch:s,name:n,checked:a,defaultChecked:r,required:i,disabled:c,value:l="on",onCheckedChange:m,form:d,...p}=o,[u,j]=N.useState(null),f=be(e,b=>j(b)),h=N.useRef(!1),g=u?d||!!u.closest("form"):!0,[A,D]=Fe({prop:a,defaultProp:r??!1,onChange:m,caller:me});return t.jsxs(nt,{scope:s,checked:A,disabled:c,children:[t.jsx(je.button,{type:"button",role:"switch","aria-checked":A,"aria-required":i,"data-state":$e(A),"data-disabled":c?"":void 0,disabled:c,value:l,...p,ref:f,onClick:Ge(o.onClick,b=>{D(y=>!y),g&&(h.current=b.isPropagationStopped(),h.current||b.stopPropagation())})}),g&&t.jsx(Ee,{control:u,bubbles:!h.current,name:n,value:l,checked:A,required:i,disabled:c,form:d,style:{transform:"translateX(-100%)"}})]})});ke.displayName=me;var Te="SwitchThumb",Ie=N.forwardRef((o,e)=>{const{__scopeSwitch:s,...n}=o,a=lt(Te,s);return t.jsx(je.span,{"data-state":$e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:e})});Ie.displayName=Te;var at="SwitchBubbleInput",Ee=N.forwardRef(({__scopeSwitch:o,control:e,checked:s,bubbles:n=!0,...a},r)=>{const i=N.useRef(null),c=be(i,r),l=De(s),m=Ue(e);return N.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==s&&j){const f=new Event("click",{bubbles:n});j.call(d,s),d.dispatchEvent(f)}},[l,s,n]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...a,tabIndex:-1,ref:c,style:{...a.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ee.displayName=at;function $e(o){return o?"checked":"unchecked"}var it=ke,rt=Ie;function ct(o){const e=O.c(9);let s,n;e[0]!==o?({className:s,...n}=o,e[0]=o,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let a;e[3]!==s?(a=pe("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),e[3]=s,e[4]=a):a=e[4];let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(rt,{"data-slot":"switch-thumb",className:pe("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")}),e[5]=r):r=e[5];let i;return e[6]!==n||e[7]!==a?(i=t.jsx(it,{"data-slot":"switch",className:a,...n,children:r}),e[6]=n,e[7]=a,e[8]=i):i=e[8],i}function ge(o){const s=new TextEncoder().encode(o),n=Array.from(s,a=>String.fromCharCode(a)).join("");return btoa(n)}function dt(o){const e=O.c(63),{serverName:s,gatewayUrl:n}=o,[a,r]=N.useState(!1),[i,c]=N.useState(null);let l,m,d,p,u;if(e[0]!==n||e[1]!==s){const re={type:"http",url:n},ce={[s]:re};l=JSON.stringify(ce,null,2);const ue=ze=>JSON.stringify({...re,headers:{"x-mesh-client":ze}},null,2),Pe=ge(ue("Cursor"));m=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(s)}&config=${encodeURIComponent(Pe)}`;const Re=ge(ue("Windsurf"));u=`windsurf://codeium.windsurf/mcp/install?name=${encodeURIComponent(s)}&config=${encodeURIComponent(Re)}`;const Ae=ue("Claude Code");d=s;let de;e[7]===Symbol.for("react.memo_cache_sentinel")?(de=/'/g,e[7]=de):de=e[7],p=Ae.replace(de,"'\\''"),e[0]=n,e[1]=s,e[2]=l,e[3]=m,e[4]=d,e[5]=p,e[6]=u}else l=e[2],m=e[3],d=e[4],p=e[5],u=e[6];const j=`claude mcp add "${d}" --config '${p}'`;let f;e[8]!==l?(f=async()=>{await navigator.clipboard.writeText(l),r(!0),xe.success("Configuration copied to clipboard"),setTimeout(()=>r(!1),2e3)},e[8]=l,e[9]=f):f=e[9];const h=f;let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=async(re,ce)=>{await navigator.clipboard.writeText(re),c(ce),xe.success(`${ce} command copied`),setTimeout(()=>c(null),2e3)},e[10]=g):g=e[10];const A=g,D=mt;let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("div",{children:t.jsx("h4",{className:"text-sm font-medium text-foreground mb-1",children:"Install in your IDE"})}),e[11]=b):b=e[11];const y=a?"check":"content_copy";let V;e[12]!==y?(V=t.jsx(M,{name:y,size:14}),e[12]=y,e[13]=V):V=e[13];let z;e[14]!==h||e[15]!==V?(z=t.jsx(Q,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:h,children:V})}),e[14]=h,e[15]=V,e[16]=z):z=e[16];let G;e[17]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsx(Y,{children:"Copy configuration"}),e[17]=G):G=e[17];let B;e[18]!==z?(B=t.jsx("div",{className:"absolute top-2 right-2",children:t.jsx(X,{children:t.jsxs(K,{children:[z,G]})})}),e[18]=z,e[19]=B):B=e[19];let v;e[20]!==l||e[21]!==h?(v=t.jsx("pre",{className:"text-xs font-mono text-foreground overflow-auto max-h-40 whitespace-pre-wrap wrap-break-word cursor-pointer",onClick:h,children:l}),e[20]=l,e[21]=h,e[22]=v):v=e[22];let _;e[23]!==B||e[24]!==v?(_=t.jsxs("div",{className:"relative flex flex-col gap-2 p-3 bg-muted/50 rounded-lg",children:[B,v]}),e[23]=B,e[24]=v,e[25]=_):_=e[25];let w;e[26]!==m?(w=()=>D(m),e[26]=m,e[27]=w):w=e[27];let k,T;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-6 w-6",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),T=t.jsx("span",{className:"text-sm font-medium",children:"Cursor"}),e[28]=k,e[29]=T):(k=e[28],T=e[29]);let F;e[30]!==w?(F=t.jsx(Q,{asChild:!0,children:t.jsxs(J,{variant:"outline",className:"h-auto py-3 px-4 justify-center gap-2 flex-1 min-w-fit",onClick:w,children:[k,T]})}),e[30]=w,e[31]=F):F=e[31];let I;e[32]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(Y,{children:"Add to Cursor"}),e[32]=I):I=e[32];let E;e[33]!==F?(E=t.jsx(X,{children:t.jsxs(K,{children:[F,I]})}),e[33]=F,e[34]=E):E=e[34];let C;e[35]!==j?(C=()=>A(j,"Claude"),e[35]=j,e[36]=C):C=e[36];let $,P;e[37]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-6 w-6",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),P=t.jsx("span",{className:"text-sm font-medium",children:"Claude Code"}),e[37]=$,e[38]=P):($=e[37],P=e[38]);let S;e[39]!==i?(S=i==="Claude"&&t.jsx(M,{name:"check",size:14,className:"ml-2 text-green-500"}),e[39]=i,e[40]=S):S=e[40];let R;e[41]!==C||e[42]!==S?(R=t.jsx(Q,{asChild:!0,children:t.jsxs(J,{variant:"outline",className:"h-auto py-3 px-4 justify-center gap-2 flex-1 min-w-fit",onClick:C,children:[$,P,S]})}),e[41]=C,e[42]=S,e[43]=R):R=e[43];let x;e[44]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(Y,{children:"Add to Claude Code"}),e[44]=x):x=e[44];let U;e[45]!==R?(U=t.jsx(X,{children:t.jsxs(K,{children:[R,x]})}),e[45]=R,e[46]=U):U=e[46];let W;e[47]!==u?(W=()=>D(u),e[47]=u,e[48]=W):W=e[48];let ne,le;e[49]===Symbol.for("react.memo_cache_sentinel")?(ne=t.jsx("img",{src:"/logos/Windsurf.svg",alt:"Windsurf",className:"h-6 w-6",style:{filter:"brightness(0) saturate(100%) invert(6%) sepia(68%) saturate(3620%) hue-rotate(204deg) brightness(92%) contrast(103%)"}}),le=t.jsx("span",{className:"text-sm font-medium",children:"Windsurf"}),e[49]=ne,e[50]=le):(ne=e[49],le=e[50]);let L;e[51]!==W?(L=t.jsx(Q,{asChild:!0,children:t.jsxs(J,{variant:"outline",className:"h-auto py-3 px-4 justify-center gap-2 flex-1 min-w-fit",onClick:W,children:[ne,le]})}),e[51]=W,e[52]=L):L=e[52];let ae;e[53]===Symbol.for("react.memo_cache_sentinel")?(ae=t.jsx(Y,{children:"Add to Windsurf"}),e[53]=ae):ae=e[53];let q;e[54]!==L?(q=t.jsx(X,{children:t.jsxs(K,{children:[L,ae]})}),e[54]=L,e[55]=q):q=e[55];let H;e[56]!==E||e[57]!==U||e[58]!==q?(H=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[E,U,q]}),e[56]=E,e[57]=U,e[58]=q,e[59]=H):H=e[59];let ie;return e[60]!==_||e[61]!==H?(ie=t.jsxs("div",{className:"flex flex-col gap-4",children:[b,_,H]}),e[60]=_,e[61]=H,e[62]=ie):ie=e[62],ie}function mt(o){window.open(o,"_blank")}const ut=Oe({title:he().min(1,"Name is required").max(255),description:he().nullable(),status:fe(["active","inactive"]),tool_selection_mode:fe(["inclusion","exclusion"]),tool_selection_strategy:fe(["passthrough","smart_tool_selection","code_execution"])});function ft(o,e){const s={};for(const n of o.connections)if(n.selected_tools===null){const a=e.get(n.connection_id)??[];a.length>0&&(s[n.connection_id]=a)}else n.selected_tools.length>0&&(s[n.connection_id]=n.selected_tools);return s}function ht(o,e){return Object.entries(o).map(([s,n])=>{const a=e.get(s)??[],r=a.length>0&&a.every(i=>n.includes(i));return{connection_id:s,selected_tools:r?null:n}})}function xt(o){const e=O.c(28),{form:s,toolSet:n,onToolSetChange:a,icon:r}=o;let i;e[0]!==s?(i=s.watch("title")||"Gateway",e[0]=s,e[1]=i):i=e[1];let c;e[2]!==r||e[3]!==i?(c=t.jsx(Je,{icon:r,name:i,size:"lg",className:"shrink-0 shadow-sm",fallbackIcon:"network_node"}),e[2]=r,e[3]=i,e[4]=c):c=e[4];let l;e[5]!==s.control?(l=t.jsx(Z,{control:s.control,name:"status",render:yt}),e[5]=s.control,e[6]=l):l=e[6];let m;e[7]!==c||e[8]!==l?(m=t.jsxs("div",{className:"flex items-start justify-between",children:[c,l]}),e[7]=c,e[8]=l,e[9]=m):m=e[9];let d;e[10]!==s.control?(d=t.jsxs("div",{className:"flex flex-col",children:[t.jsx(Z,{control:s.control,name:"title",render:bt}),t.jsx(Z,{control:s.control,name:"description",render:jt})]}),e[10]=s.control,e[11]=d):d=e[11];let p;e[12]!==m||e[13]!==d?(p=t.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[m,d]}),e[12]=m,e[13]=d,e[14]=p):p=e[14];let u;e[15]!==s.control?(u=t.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[t.jsx(Z,{control:s.control,name:"tool_selection_mode",render:gt}),t.jsx(Z,{control:s.control,name:"tool_selection_strategy",render:pt})]}),e[15]=s.control,e[16]=u):u=e[16];let j;e[17]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("div",{className:"flex-1 flex items-center justify-center p-5",children:t.jsx(M,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),e[17]=j):j=e[17];let f;e[18]!==a||e[19]!==n?(f=t.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:t.jsx(ye,{children:t.jsx(N.Suspense,{fallback:j,children:t.jsx(Xe,{toolSet:n,onToolSetChange:a})})})}),e[18]=a,e[19]=n,e[20]=f):f=e[20];let h;e[21]!==p||e[22]!==u||e[23]!==f?(h=t.jsxs("div",{className:"flex flex-col h-full",children:[p,u,f]}),e[21]=p,e[22]=u,e[23]=f,e[24]=h):h=e[24];let g;return e[25]!==s||e[26]!==h?(g=t.jsx(Ze,{...s,children:h}),e[25]=s,e[26]=h,e[27]=g):g=e[27],g}function pt(o){const{field:e}=o;return t.jsxs(te,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(_e,{className:"mb-0",children:"Gateway Strategy"}),t.jsx(X,{children:t.jsxs(K,{children:[t.jsx(Q,{asChild:!0,children:t.jsx("button",{type:"button",className:"cursor-help flex items-center",children:t.jsx(M,{name:"info",size:14,className:"text-muted-foreground"})})}),t.jsx(Y,{side:"right",className:"max-w-sm",children:t.jsxs("div",{className:"text-xs space-y-1",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Passthrough:"})," Pass tools through as-is (default)."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Smart Tool Selection:"})," Intelligent tool selection behavior."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Code Execution:"})," Code execution behavior."]})]})})]})})]}),t.jsxs(we,{value:e.value,onValueChange:e.onChange,children:[t.jsx(se,{children:t.jsx(Ce,{className:"w-[180px]",children:t.jsx(Se,{})})}),t.jsxs(Ne,{children:[t.jsx(ee,{value:"passthrough",children:"Passthrough"}),t.jsx(ee,{value:"smart_tool_selection",children:"Smart Tool Selection"}),t.jsx(ee,{value:"code_execution",children:"Code Execution"})]})]})]}),t.jsx(oe,{})]})}function gt(o){const{field:e}=o;return t.jsxs(te,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(_e,{className:"mb-0",children:"Tool Selection Mode"}),t.jsx(X,{children:t.jsxs(K,{children:[t.jsx(Q,{asChild:!0,children:t.jsx("button",{type:"button",className:"cursor-help flex items-center",children:t.jsx(M,{name:"info",size:14,className:"text-muted-foreground"})})}),t.jsx(Y,{side:"right",className:"max-w-sm",children:t.jsxs("div",{className:"text-xs space-y-1",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Include:"})," Only selected connections/tools are exposed."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Exclude:"})," All connections/tools except selected ones are exposed."]})]})})]})})]}),t.jsxs(we,{value:e.value,onValueChange:e.onChange,children:[t.jsx(se,{children:t.jsx(Ce,{className:"w-[180px]",children:t.jsx(Se,{})})}),t.jsxs(Ne,{children:[t.jsx(ee,{value:"inclusion",children:"Include Selected"}),t.jsx(ee,{value:"exclusion",children:"Exclude Selected"})]})]})]}),t.jsx(oe,{})]})}function jt(o){const{field:e}=o;return t.jsxs(te,{className:"w-full space-y-0",children:[t.jsx(se,{children:t.jsx(ve,{...e,value:e.value||"",className:"h-auto text-base text-muted-foreground leading-6 px-0 border-transparent hover:border-input focus:border-input bg-transparent transition-all",placeholder:"Add a description..."})}),t.jsx(oe,{})]})}function bt(o){const{field:e}=o;return t.jsxs(te,{className:"w-full space-y-0",children:[t.jsx(se,{children:t.jsx(ve,{...e,className:"h-auto text-lg! font-medium leading-7 px-0 border-transparent hover:border-input focus:border-input bg-transparent transition-all",placeholder:"Gateway Name"})}),t.jsx(oe,{})]})}function yt(o){const{field:e}=o;return t.jsxs(te,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:e.value==="active"?"Active":"Inactive"}),t.jsx(se,{children:t.jsx(ct,{checked:e.value==="active",onCheckedChange:s=>e.onChange(s?"active":"inactive")})})]}),t.jsx(oe,{})]})}function vt(o){const e=O.c(53),{gateway:s,gatewayId:n}=o,a=We(),r=Qe();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const c=Ye(i);let l;if(e[1]!==c){l=new Map;for(const x of c)x.tools&&x.tools.length>0&&l.set(x.id,x.tools.map(_t));e[1]=c,e[2]=l}else l=e[2];let m;e[3]!==l||e[4]!==s?(m=()=>ft(s,l),e[3]=l,e[4]=s,e[5]=m):m=e[5];const[d,p]=N.useState(m),[u,j]=N.useState(!1);let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=x=>{p(x),j(!0)},e[6]=f):f=e[6];const h=f;let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=Le(ut),e[7]=g):g=e[7];const A=s.tool_selection_mode??"inclusion",D=s.tool_selection_strategy??"passthrough";let b;e[8]!==s.description||e[9]!==s.status||e[10]!==s.title||e[11]!==A||e[12]!==D?(b={resolver:g,defaultValues:{title:s.title,description:s.description,status:s.status,tool_selection_mode:A,tool_selection_strategy:D}},e[8]=s.description,e[9]=s.status,e[10]=s.title,e[11]=A,e[12]=D,e[13]=b):b=e[13];const y=qe(b),z=y.formState.isDirty||u;let G;e[14]!==r.update||e[15]!==l||e[16]!==y||e[17]!==n||e[18]!==d?(G=async()=>{const x=y.getValues(),U=ht(d,l);await r.update.mutateAsync({id:n,data:{title:x.title,description:x.description,status:x.status,tool_selection_mode:x.tool_selection_mode,tool_selection_strategy:x.tool_selection_strategy,connections:U}}),y.reset(x),j(!1)},e[14]=r.update,e[15]=l,e[16]=y,e[17]=n,e[18]=d,e[19]=G):G=e[19];const B=G;let v;e[20]!==a.history?(v=()=>a.history.back(),e[20]=a.history,e[21]=v):v=e[21];let _;e[22]!==r.update.isPending||e[23]!==B||e[24]!==z?(_=z&&t.jsxs(J,{onClick:B,disabled:r.update.isPending,size:"sm",className:"h-7",children:[r.update.isPending&&t.jsx(M,{name:"progress_activity",size:16,className:"mr-2 animate-spin"}),"Save Changes"]}),e[22]=r.update.isPending,e[23]=B,e[24]=z,e[25]=_):_=e[25];let w;e[26]!==_?(w=t.jsx(et,{children:_}),e[26]=_,e[27]=w):w=e[27];let k;e[28]!==y||e[29]!==s.icon||e[30]!==d?(k=t.jsx("div",{className:"lg:border-r border-b lg:border-b-0 border-border overflow-auto",children:t.jsx(xt,{form:y,toolSet:d,onToolSetChange:h,icon:s.icon})}),e[28]=y,e[29]=s.icon,e[30]=d,e[31]=k):k=e[31];let T;e[32]!==s.id||e[33]!==s.title?(T=s.title||`gateway-${s.id.slice(0,8)}`,e[32]=s.id,e[33]=s.title,e[34]=T):T=e[34];const F=`${window.location.origin}/mcp/gateway/${s.id}`;let I;e[35]!==T||e[36]!==F?(I=t.jsx("div",{className:"p-5",children:t.jsx(dt,{serverName:T,gatewayUrl:F})}),e[35]=T,e[36]=F,e[37]=I):I=e[37];let E;e[38]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("span",{className:"flex-1 text-sm text-foreground",children:"Last Updated"}),e[38]=E):E=e[38];let C;e[39]!==s.updated_at?(C=s.updated_at?st(new Date(s.updated_at),{addSuffix:!1}):"Unknown",e[39]=s.updated_at,e[40]=C):C=e[40];let $;e[41]!==C?($=t.jsxs("div",{className:"flex items-center gap-4 p-5 border-t border-border",children:[E,t.jsx("span",{className:"font-mono text-sm uppercase text-muted-foreground",children:C})]}),e[41]=C,e[42]=$):$=e[42];let P;e[43]!==I||e[44]!==$?(P=t.jsxs("div",{className:"flex flex-col overflow-auto",children:[I,$]}),e[43]=I,e[44]=$,e[45]=P):P=e[45];let S;e[46]!==k||e[47]!==P?(S=t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] h-full",children:[k,P]}),e[46]=k,e[47]=P,e[48]=S):S=e[48];let R;return e[49]!==w||e[50]!==S||e[51]!==v?(R=t.jsxs(tt,{onBack:v,children:[w,S]}),e[49]=w,e[50]=S,e[51]=v,e[52]=R):R=e[52],R}function _t(o){return o.name}function wt(){const o=O.c(8);let e;o[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/gateways/$gatewayId"},o[0]=e):e=o[0];const s=Ve(e);let n;o[1]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/gateways/$gatewayId"},o[1]=n):n=o[1];const{gatewayId:a,org:r}=Me(n),i=Ke(a);if(!i){let l;return o[2]!==s||o[3]!==r?(l=t.jsx("div",{className:"flex h-full w-full bg-background",children:t.jsx(He,{title:"Gateway not found",description:"This gateway may have been deleted or you may not have access.",actions:t.jsx(J,{variant:"outline",onClick:()=>s({to:"/$org/gateways",params:{org:r}}),children:"Back to gateways"})})}),o[2]=s,o[3]=r,o[4]=l):l=o[4],l}let c;return o[5]!==i||o[6]!==a?(c=t.jsx(vt,{gateway:i,gatewayId:a}),o[5]=i,o[6]=a,o[7]=c):c=o[7],c}function Ct(){const o=O.c(1);let e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(ye,{children:t.jsx(N.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:t.jsx(M,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(wt,{})})}),o[0]=e):e=o[0],e}function Ot(){const o=O.c(1);let e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ct,{}),o[0]=e):e=o[0],e}export{Ot as default};
@@ -1 +0,0 @@
1
- import{c as Y,j as t,r as Z,a5 as te,a6 as se}from"./index-VCe1FY3E.js";import{C as oe}from"./collection-header-C3vTyWNy.js";import{C as ae}from"./collection-page-BplXISpO.js";import{C as ne}from"./collection-search-BpPEPb0j.js";import{C as re}from"./collection-table-wrapper-CJdrG443.js";import{C as ie}from"./connection-card-B7VMSnFz.js";import{E as q}from"./empty-state-BCgOYCyG.js";import{E as le}from"./error-boundary-L4NxoU-J.js";import{I as ce}from"./integration-icon-Dgf9Pzxc.js";import{a as de,u as me}from"./use-gateway-pRk3-ua4.js";import{b as ue}from"./use-connection-D5nZyekX.js";import{u as ge}from"./use-list-state-BTIryg2o.js";import{u as pe}from"./tooltip-BLbXpJcn.js";import{c as he,b as fe,d as xe,A as we,e as ye,g as je,a as Ce,f as Ne}from"./alert-dialog-DsYjmjQa.js";import{B as ee}from"./badge-D0svJbIE.js";import{B as J}from"./button-CB7Gt-Ba.js";import{b as Q,D as U,a as X,c as B}from"./dropdown-menu-zoKN8fKM.js";import{I as i}from"./icon-Zm7eEeKG.js";import"./collection-display-button-Ccjj22Xn.js";import"./utils-B-QWwgyW.js";import"./input-DWY0hRYC.js";import"./card-BZePxfHz.js";import"./use-mobile-BPQzOCZP.js";function ve(e,a){switch(a.type){case"delete":return{mode:"deleting",gateway:a.gateway};case"close":return{mode:"idle"}}}function De(){const e=Y.c(68),{org:a}=pe(),n=te();let y;e[0]!==a.slug?(y={namespace:a.slug,resource:"gateways"},e[0]=a.slug,e[1]=y):y=e[1];const s=ge(y),r=de(),w=me(s);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];const R=ue(j);let C;e[3]===Symbol.for("react.memo_cache_sentinel")?(C={mode:"idle"},e[3]=C):C=e[3];const[l,N]=Z.useReducer(ve,C);let v;e[4]!==r.create||e[5]!==R.length||e[6]!==n||e[7]!==a.slug?(v=async()=>{if(R.length===0){se.error("Create at least one MCP connection first");return}const o=await r.create.mutateAsync({title:"New Gateway",description:"Gateways let you securely expose integrated tools to the outside world.",status:"active",tool_selection_strategy:"passthrough",tool_selection_mode:"inclusion",connections:[]});n({to:"/$org/gateways/$gatewayId",params:{org:a.slug,gatewayId:o.id}})},e[4]=r.create,e[5]=R.length,e[6]=n,e[7]=a.slug,e[8]=v):v=e[8];const T=v;let D;e[9]!==r.delete||e[10]!==l.gateway||e[11]!==l.mode?(D=async()=>{if(l.mode!=="deleting")return;const o=l.gateway.id;N({type:"close"});try{await r.delete.mutateAsync(o)}catch{}},e[9]=r.delete,e[10]=l.gateway,e[11]=l.mode,e[12]=D):D=e[12];const O=D;let S,_,b,k,I,M;e[13]===Symbol.for("react.memo_cache_sentinel")?(_={id:"icon",header:"",render:$e,cellClassName:"w-16 shrink-0"},b={id:"title",header:"Name",render:Ae,cellClassName:"w-48 min-w-0 shrink-0",sortable:!0},k={id:"description",header:"Description",render:ze,cellClassName:"flex-1 min-w-0",wrap:!0,sortable:!0},I={id:"mode",header:"Mode",accessor:Pe,cellClassName:"w-[100px]"},M={id:"connections",header:"Connections",render:Me,cellClassName:"w-24 shrink-0"},S={id:"status",header:"Status",render:Ie,cellClassName:"w-24 shrink-0",sortable:!0},e[13]=S,e[14]=_,e[15]=b,e[16]=k,e[17]=I,e[18]=M):(S=e[13],_=e[14],b=e[15],k=e[16],I=e[17],M=e[18]);let P;e[19]!==n||e[20]!==a.slug?(P=[_,b,k,I,M,S,{id:"actions",header:"",render:o=>t.jsxs(Q,{children:[t.jsx(U,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:ke,children:t.jsx(i,{name:"more_vert",size:20})})}),t.jsxs(X,{align:"end",onClick:be,children:[t.jsxs(B,{onClick:c=>{c.stopPropagation(),n({to:"/$org/gateways/$gatewayId",params:{org:a.slug,gatewayId:o.id}})},children:[t.jsx(i,{name:"visibility",size:16}),"Inspect"]}),t.jsxs(B,{variant:"destructive",onClick:c=>{c.stopPropagation(),N({type:"delete",gateway:o})},children:[t.jsx(i,{name:"delete",size:16}),"Delete"]})]})]}),cellClassName:"w-12 shrink-0"}],e[19]=n,e[20]=a.slug,e[21]=P):P=e[21];const V=P,H=r.create.isPending?"Creating...":"Create MCP Gateway";let z;e[22]!==r.create.isPending||e[23]!==T||e[24]!==H?(z=t.jsx(J,{onClick:T,size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",disabled:r.create.isPending,children:H}),e[22]=r.create.isPending,e[23]=T,e[24]=H,e[25]=z):z=e[25];const L=z,F=l.mode==="deleting";let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=o=>!o&&N({type:"close"}),e[26]=A):A=e[26];let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(he,{children:"Delete Gateway?"}),e[27]=$):$=e[27];const W=l.mode==="deleting"&&l.gateway.title;let d;e[28]!==W?(d=t.jsxs(fe,{children:[$,t.jsxs(xe,{children:["This action cannot be undone. This will permanently delete"," ",t.jsx("span",{className:"font-medium text-foreground",children:W}),"."]})]}),e[28]=W,e[29]=d):d=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(we,{children:"Cancel"}),e[30]=E):E=e[30];let m;e[31]!==O?(m=t.jsxs(ye,{children:[E,t.jsx(je,{onClick:O,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]}),e[31]=O,e[32]=m):m=e[32];let u;e[33]!==d||e[34]!==m?(u=t.jsxs(Ce,{children:[d,m]}),e[33]=d,e[34]=m,e[35]=u):u=e[35];let g;e[36]!==F||e[37]!==u?(g=t.jsx(Ne,{open:F,onOpenChange:A,children:u}),e[36]=F,e[37]=u,e[38]=g):g=e[38];let G;e[39]===Symbol.for("react.memo_cache_sentinel")?(G=[{id:"title",label:"Name"},{id:"description",label:"Description"},{id:"status",label:"Status"}],e[39]=G):G=e[39];let p;e[40]!==L||e[41]!==s.handleSort||e[42]!==s.setViewMode||e[43]!==s.sortDirection||e[44]!==s.sortKey||e[45]!==s.viewMode?(p=t.jsx(oe,{title:"MCP Gateways",viewMode:s.viewMode,onViewModeChange:s.setViewMode,sortKey:s.sortKey,sortDirection:s.sortDirection,onSort:s.handleSort,sortOptions:G,ctaButton:L}),e[40]=L,e[41]=s.handleSort,e[42]=s.setViewMode,e[43]=s.sortDirection,e[44]=s.sortKey,e[45]=s.viewMode,e[46]=p):p=e[46];let h;e[47]!==s?(h=o=>{o.key==="Escape"&&(s.setSearch(""),o.target.blur())},e[47]=s,e[48]=h):h=e[48];let f;e[49]!==s.search||e[50]!==s.setSearch||e[51]!==h?(f=t.jsx(ne,{value:s.search,onChange:s.setSearch,placeholder:"Search for a gateway...",onKeyDown:h}),e[49]=s.search,e[50]=s.setSearch,e[51]=h,e[52]=f):f=e[52];let x;e[53]!==V||e[54]!==w||e[55]!==s.handleSort||e[56]!==s.search||e[57]!==s.sortDirection||e[58]!==s.sortKey||e[59]!==s.viewMode||e[60]!==n||e[61]!==a.slug?(x=s.viewMode==="cards"?t.jsx("div",{className:"flex-1 overflow-auto p-5",children:w.length===0?t.jsx(q,{image:t.jsx(i,{name:"network_node",size:48,className:"text-muted-foreground"}),title:s.search?"No gateways found":"No gateways yet",description:s.search?`No gateways match "${s.search}"`:"Create a gateway to aggregate tools from multiple MCP connections."}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:w.map(o=>t.jsx(ie,{connection:{id:o.id,title:o.title,description:o.description,icon:o.icon,status:o.status},fallbackIcon:"network_node",onClick:()=>n({to:"/$org/gateways/$gatewayId",params:{org:a.slug,gatewayId:o.id}}),footer:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[o.connections.length," connection",o.connections.length!==1?"s":""]}),t.jsx("span",{children:"•"}),t.jsx("span",{children:o.tool_selection_mode==="exclusion"?"Exclude":"Include"})]}),headerActions:t.jsxs(Q,{children:[t.jsx(U,{asChild:!0,children:t.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:_e,children:t.jsx(i,{name:"more_vert",size:20})})}),t.jsxs(X,{align:"end",onClick:Se,children:[t.jsxs(B,{onClick:c=>{c.stopPropagation(),n({to:"/$org/gateways/$gatewayId",params:{org:a.slug,gatewayId:o.id}})},children:[t.jsx(i,{name:"visibility",size:16}),"Inspect"]}),t.jsxs(B,{variant:"destructive",onClick:c=>{c.stopPropagation(),N({type:"delete",gateway:o})},children:[t.jsx(i,{name:"delete",size:16}),"Delete"]})]})]})},o.id))})}):t.jsx(re,{columns:V,data:w,isLoading:!1,sortKey:s.sortKey,sortDirection:s.sortDirection,onSort:s.handleSort,onRowClick:o=>n({to:"/$org/gateways/$gatewayId",params:{org:a.slug,gatewayId:o.id}}),emptyState:s.search?t.jsx(q,{image:t.jsx(i,{name:"network_node",size:48,className:"text-muted-foreground"}),title:"No gateways found",description:`No gateways match "${s.search}"`}):t.jsx(q,{image:t.jsx(i,{name:"network_node",size:48,className:"text-muted-foreground"}),title:"No gateways yet",description:"Create a gateway to aggregate tools from multiple MCP connections."})}),e[53]=V,e[54]=w,e[55]=s.handleSort,e[56]=s.search,e[57]=s.sortDirection,e[58]=s.sortKey,e[59]=s.viewMode,e[60]=n,e[61]=a.slug,e[62]=x):x=e[62];let K;return e[63]!==g||e[64]!==p||e[65]!==f||e[66]!==x?(K=t.jsxs(ae,{children:[g,p,f,x]}),e[63]=g,e[64]=p,e[65]=f,e[66]=x,e[67]=K):K=e[67],K}function Se(e){return e.stopPropagation()}function _e(e){return e.stopPropagation()}function be(e){return e.stopPropagation()}function ke(e){return e.stopPropagation()}function Ie(e){return t.jsx(ee,{variant:e.status==="active"?"default":"outline",children:e.status})}function Me(e){return t.jsx("span",{className:"text-sm text-muted-foreground",children:e.connections.length})}function Pe(e){return t.jsx(ee,{variant:"outline",className:"text-xs",children:e.tool_selection_mode==="exclusion"?"Exclude":"Include"})}function ze(e){return t.jsx("span",{className:"text-sm text-foreground line-clamp-2",children:e.description||"—"})}function Ae(e){return t.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.title})}function $e(e){return t.jsx(ce,{icon:e.icon,name:e.title,size:"sm",className:"shrink-0 shadow-sm",fallbackIcon:"network_node"})}function at(){const e=Y.c(1);let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(le,{children:t.jsx(Z.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(i,{name:"progress_activity",size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(De,{})})}),e[0]=a):a=e[0],a}export{at as default};
@@ -1 +0,0 @@
1
- import{s as Q,B as V}from"./chunk-2RRQPJJO-DGhxLrrR.js";import{a as H,C as be,U as X,L as ee,R as Ce,b as te,G as Ee,c as Te}from"./auth-dQSMuI_r.js";import{r as s}from"./index-VCe1FY3E.js";import{C as $e,S as ye,c as ve}from"./use-binding-CeSgmpzj.js";function U(q,g){if(!q)throw new Error(g)}var re=3e3,Se=5e3,j=300*1e3;function Me(q){const{url:g,clientName:k,clientUri:P,callbackUrl:L=typeof window<"u"?Q(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:M="mcp:auth",clientConfig:T={},customHeaders:G={},debug:Ae=!1,autoRetry:I=!1,autoReconnect:z=re,transportType:D="auto",preventAutoAuth:O=!1,onPopupWindow:Y}=q,[m,b]=s.useState("discovering"),[ne,Z]=s.useState([]),[oe,_]=s.useState([]),[se,N]=s.useState([]),[ae,x]=s.useState([]),[ce,F]=s.useState(void 0),[ie,ue]=s.useState([]),[B,v]=s.useState(void 0),l=s.useRef(null),$=s.useRef(null),f=s.useRef(null),C=s.useRef(!1),u=s.useRef(!0),S=s.useRef(0),a=s.useRef(null),p=s.useRef(m),J=s.useRef(z),W=s.useRef(null);s.useEffect(()=>{p.current=m,J.current=z},[m,z]);const e=s.useCallback((t,n,...o)=>{const d=o.length>0?`${n} ${o.map(r=>JSON.stringify(r)).join(" ")}`:n;console[t](`[useMcp] ${d}`),u.current&&ue(r=>[...r.slice(-100),{level:t,message:d,timestamp:Date.now()}])},[]),y=s.useCallback(async(t=!1)=>{t||e("info","Disconnecting..."),C.current=!1,a.current&&clearTimeout(a.current),a.current=null;const n=$.current;if(l.current=null,$.current=null,u.current&&!t&&(b("discovering"),Z([]),_([]),N([]),x([]),F(void 0),v(void 0)),n)try{await n.close(),t||e("debug","Transport closed")}catch(o){t||e("warn","Error closing transport:",o)}},[e]),w=s.useCallback((t,n)=>{if(e("error",t,n??""),u.current){b("failed"),F(t);const o=f.current?.getLastAttemptedAuthUrl();o&&(v(o),e("info","Manual authentication URL may be available.",o))}C.current=!1},[e]),R=s.useCallback(async()=>{if(C.current){e("debug","Connection attempt already in progress.");return}if(!u.current){e("debug","Connect called after unmount, aborting.");return}C.current=!0,S.current+=1,F(void 0),v(void 0),W.current=null,b("discovering"),e("info",`Connecting attempt #${S.current} to ${g}...`),f.current||(f.current=new V(g,{storageKeyPrefix:M,clientName:k,clientUri:P,callbackUrl:L,preventAutoAuth:O,onPopupWindow:Y}),e("debug","BrowserOAuthClientProvider initialized in connect.")),l.current||(l.current=new $e({name:T.name||"use-mcp-react-client",version:T.version||"0.1.0"},{capabilities:{}}),e("debug","MCP Client initialized in connect."));const t=async o=>{e("info",`Attempting connection with ${o.toUpperCase()} transport...`),p.current!=="authenticating"&&b("connecting");let d;try{U(f.current,"Auth Provider must be initialized"),U(l.current,"Client must be initialized"),$.current&&(await $.current.close().catch(h=>e("warn",`Error closing previous transport: ${h.message}`)),$.current=null);const r={authProvider:f.current,requestInit:{headers:{Accept:"application/json, text/event-stream",...G}}},i=Q(g),c=new URL(i);e("debug",`Creating ${o.toUpperCase()} transport for URL: ${c.toString()}`),e("debug","Transport options:",{authProvider:!!f.current,headers:G,url:c.toString()}),o==="http"?(e("debug","Creating StreamableHTTPClientTransport..."),d=new ye(c,r),e("debug","StreamableHTTPClientTransport created successfully")):(e("debug","Creating SSEClientTransport..."),d=new ve(c,r),e("debug","SSEClientTransport created successfully")),$.current=d,e("debug",`${o.toUpperCase()} transport created and assigned to ref.`)}catch(r){return w(`Failed to create ${o.toUpperCase()} transport: ${r instanceof Error?r.message:String(r)}`,r instanceof Error?r:void 0),"failed"}d.onmessage=r=>{e("debug",`[Transport] Received: ${JSON.stringify(r)}`),l.current?.handleMessage?.(r)},d.onerror=r=>{e("warn",`Transport error event (${o.toUpperCase()}):`,r),e("debug","Error details:",{message:r.message,stack:r.stack,name:r.name,cause:r.cause}),w(`Transport error (${o.toUpperCase()}): ${r.message}`,r)},d.onclose=()=>{if(!u.current||C.current)return;e("info",`Transport connection closed (${W.current||"unknown"} type).`);const r=p.current,i=J.current;if(r==="ready"&&i){const c=typeof i=="number"?i:re;e("info",`Attempting to reconnect in ${c}ms...`),b("connecting"),setTimeout(()=>{u.current&&R()},c)}else r!=="failed"&&r!=="authenticating"&&w("Connection closed unexpectedly.")};try{e("info",`Connecting client via ${o.toUpperCase()}...`),e("debug","About to call client.connect() with transport instance"),e("debug",`Transport instance type: ${d.constructor.name}`),await l.current.connect(d),e("info",`Client connected via ${o.toUpperCase()}. Loading tools, resources, and prompts...`),W.current=o,b("loading");const r=await l.current.request({method:"tools/list"},Te);let i={resources:[],resourceTemplates:[]};try{i=await l.current.request({method:"resources/list"},ee)}catch(h){e("debug","Server does not support resources/list method",h)}let c={prompts:[]};try{c=await l.current.request({method:"prompts/list"},te)}catch(h){e("debug","Server does not support prompts/list method",h)}if(u.current){Z(r.tools),_(i.resources),N(Array.isArray(i.resourceTemplates)?i.resourceTemplates:[]),x(c.prompts);const h=[`Loaded ${r.tools.length} tools`];return(i.resources.length>0||i.resourceTemplates&&i.resourceTemplates.length>0)&&(h.push(`${i.resources.length} resources`),Array.isArray(i.resourceTemplates)&&i.resourceTemplates.length>0&&h.push(`${i.resourceTemplates.length} resource templates`)),c.prompts.length>0&&h.push(`${c.prompts.length} prompts`),e("info",h.join(", ")+"."),b("ready"),S.current=0,"success"}else return"failed"}catch(r){e("debug",`Client connect error via ${o.toUpperCase()}:`,r),e("debug","Connect error details:",{message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:"N/A",name:r instanceof Error?r.name:"Unknown",cause:r instanceof Error?r.cause:void 0});const i=r instanceof Error?r:new Error(String(r)),c=i.message,h=c.includes("404")||c.includes("Not Found"),we=c.includes("405")||c.includes("Method Not Allowed"),K=c==="Failed to fetch"||c==="NetworkError when attempting to fetch resource."||c==="Load failed";if(o==="http"&&(h||we||K))return e("warn",`HTTP transport failed (${K?"CORS":h?"404":"405"}).`),"fallback";if(i instanceof X||c.includes("Unauthorized")||c.includes("401")){e("info","Authentication required."),U(f.current,"Auth Provider not available for auth flow");const Re=await f.current.tokens();if(O&&!Re)return e("info","Authentication required but auto-auth prevented. User action needed."),b("pending_auth"),"auth_redirect";p.current!=="authenticating"&&p.current!=="pending_auth"&&(b("authenticating"),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{},j));try{const E=await H(f.current,{serverUrl:g});if(!u.current)return"failed";if(E==="AUTHORIZED")return e("info","Authentication successful via existing token or refresh. Re-attempting connection..."),a.current&&clearTimeout(a.current),C.current=!1,R(),"failed";if(E==="REDIRECT")return e("info","Redirecting for authentication. Waiting for callback..."),"auth_redirect"}catch(E){return u.current&&(a.current&&clearTimeout(a.current),w(`Failed to initiate authentication: ${E instanceof Error?E.message:String(E)}`,E instanceof Error?E:void 0)),"failed"}}return w(`Failed to connect via ${o.toUpperCase()}: ${c}`,i),"failed"}};let n="failed";if(console.log({transportType:D}),D==="sse")e("debug","Using SSE-only transport mode"),n=await t("sse");else if(D==="http")e("debug","Using HTTP-only transport mode"),n=await t("http");else{e("debug","Using auto transport mode (HTTP with SSE fallback)");const o=await t("http");if(o==="fallback"&&u.current&&p.current!=="authenticating"){e("info","HTTP failed, attempting SSE fallback...");const d=await t("sse");n=d,d==="failed"&&u.current}else n=o}(n==="success"||n==="failed")&&(C.current=!1),e("debug",`Connection sequence finished with status: ${n}`)},[e,w,y,H,g,M,k,P,L,T.name,T.version]),le=s.useCallback(async(t,n)=>{if(p.current!=="ready"||!l.current)throw new Error(`MCP client is not ready (current state: ${m}). Cannot call tool "${t}".`);e("info",`Calling tool: ${t}`,n);try{const o=await l.current.request({method:"tools/call",params:{name:t,arguments:n}},be);return e("info",`Tool "${t}" call successful:`,o),o}catch(o){e("error",`Error calling tool "${t}": ${o instanceof Error?o.message:String(o)}`,o);const d=o instanceof Error?o:new Error(String(o));if(d instanceof X||d.message.includes("Unauthorized")||d.message.includes("401")){e("warn","Tool call unauthorized, attempting re-authentication..."),b("authenticating"),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{},j);try{U(f.current,"Auth Provider not available for tool re-auth");const r=await H(f.current,{serverUrl:g});if(!u.current)return;r==="AUTHORIZED"?(e("info","Re-authentication successful. Retrying tool call is recommended, or reconnecting."),a.current&&clearTimeout(a.current),C.current=!1,R()):r==="REDIRECT"&&e("info","Redirecting for re-authentication for tool call.")}catch(r){if(!u.current)return;a.current&&clearTimeout(a.current),w(`Re-authentication failed: ${r instanceof Error?r.message:String(r)}`,r instanceof Error?r:void 0)}}if(p.current!=="authenticating")throw o;return}},[m,g,e,w,R]),A=s.useCallback(()=>{p.current==="failed"?(e("info","Retry requested..."),R()):e("warn",`Retry called but state is not 'failed' (state: ${p.current}). Ignoring.`)},[e,R]),fe=s.useCallback(async()=>{e("info","Manual authentication requested...");const t=p.current;if(t==="failed")e("info","Attempting to reconnect and authenticate via retry..."),A();else if(t==="pending_auth"){e("info","Proceeding with authentication from pending state..."),b("authenticating"),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{},j);try{U(f.current,"Auth Provider not available for manual auth");const n=await H(f.current,{serverUrl:g});if(!u.current)return;n==="AUTHORIZED"?(e("info","Manual authentication successful. Re-attempting connection..."),a.current&&clearTimeout(a.current),C.current=!1,R()):n==="REDIRECT"&&e("info","Redirecting for manual authentication. Waiting for callback...")}catch(n){if(!u.current)return;a.current&&clearTimeout(a.current),w(`Manual authentication failed: ${n instanceof Error?n.message:String(n)}`,n instanceof Error?n:void 0)}}else if(t==="authenticating"){e("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const n=f.current?.getLastAttemptedAuthUrl();n&&!B&&(v(n),e("info","Manual authentication URL retrieved:",n))}else e("info",`Client not in a state requiring manual authentication trigger (state: ${t}). If needed, try disconnecting and reconnecting.`)},[e,A,B,g,w,R]),de=s.useCallback(()=>{if(f.current){const t=f.current.clearStorage();e("info",`Cleared ${t} item(s) from localStorage for ${g}.`),v(void 0),y()}else e("warn","Auth provider not initialized, cannot clear storage.")},[g,e,y]),ge=s.useCallback(async()=>{if(p.current!=="ready"||!l.current)throw new Error(`MCP client is not ready (current state: ${m}). Cannot list resources.`);e("info","Listing resources...");try{const t=await l.current.request({method:"resources/list"},ee);u.current&&(_(t.resources),N(Array.isArray(t.resourceTemplates)?t.resourceTemplates:[]),e("info",`Listed ${t.resources.length} resources, ${Array.isArray(t.resourceTemplates)?t.resourceTemplates.length:0} resource templates.`))}catch(t){throw e("error",`Error listing resources: ${t instanceof Error?t.message:String(t)}`,t),t}},[m,e]),me=s.useCallback(async t=>{if(p.current!=="ready"||!l.current)throw new Error(`MCP client is not ready (current state: ${m}). Cannot read resource "${t}".`);e("info",`Reading resource: ${t}`);try{const n=await l.current.request({method:"resources/read",params:{uri:t}},Ce);return e("info",`Resource "${t}" read successfully`),n}catch(n){throw e("error",`Error reading resource "${t}": ${n instanceof Error?n.message:String(n)}`,n),n}},[m,e]),pe=s.useCallback(async()=>{if(p.current!=="ready"||!l.current)throw new Error(`MCP client is not ready (current state: ${m}). Cannot list prompts.`);e("info","Listing prompts...");try{const t=await l.current.request({method:"prompts/list"},te);u.current&&(x(t.prompts),e("info",`Listed ${t.prompts.length} prompts.`))}catch(t){throw e("error",`Error listing prompts: ${t instanceof Error?t.message:String(t)}`,t),t}},[m,e]),he=s.useCallback(async(t,n)=>{if(p.current!=="ready"||!l.current)throw new Error(`MCP client is not ready (current state: ${m}). Cannot get prompt "${t}".`);e("info",`Getting prompt: ${t}`,n);try{const o=await l.current.request({method:"prompts/get",params:{name:t,arguments:n}},Ee);return e("info",`Prompt "${t}" retrieved successfully`),o}catch(o){throw e("error",`Error getting prompt "${t}": ${o instanceof Error?o.message:String(o)}`,o),o}},[m,e]);return s.useEffect(()=>{const t=n=>{n.origin===window.location.origin&&n.data?.type==="mcp_auth_callback"&&(e("info","Received auth callback message.",n.data),a.current&&clearTimeout(a.current),n.data.success?(e("info","Authentication successful via popup. Reconnecting client..."),C.current=!1,R()):w(`Authentication failed in callback: ${n.data.error||"Unknown reason."}`))};return window.addEventListener("message",t),e("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",t),e("debug","Auth callback message listener removed."),a.current&&clearTimeout(a.current)}},[e,w,R]),s.useEffect(()=>(u.current=!0,e("debug","useMcp mounted, initiating connection."),S.current=0,(!f.current||f.current.serverUrl!==g)&&(f.current=new V(g,{storageKeyPrefix:M,clientName:k,clientUri:P,callbackUrl:L,preventAutoAuth:O,onPopupWindow:Y}),e("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),R(),()=>{u.current=!1,e("debug","useMcp unmounting, disconnecting."),y(!0)}),[g,M,L,k,P,T.name,T.version,R,y]),s.useEffect(()=>{let t=null;if(m==="failed"&&I&&S.current>0){const n=typeof I=="number"?I:Se;e("info",`Connection failed, auto-retrying in ${n}ms...`),t=setTimeout(()=>{u.current&&p.current==="failed"&&A()},n)}return()=>{t&&clearTimeout(t)}},[m,I,A,e]),{state:m,tools:ne,resources:oe,resourceTemplates:se,prompts:ae,error:ce,log:ie,authUrl:B,callTool:le,listResources:ge,readResource:me,listPrompts:pe,getPrompt:he,retry:A,disconnect:y,authenticate:fe,clearStorage:de}}export{Me as u};