@decocms/mesh 2.76.0 → 2.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-TbirTaeA.js → AlertCircle-BppvLQSd.js} +1 -1
- package/dist/client/assets/{ArrowUp-DVhz9MPT.js → ArrowUp-D26ZQKRa.js} +1 -1
- package/dist/client/assets/{Calendar-BhleOqT-.js → Calendar-DDieAsd2.js} +1 -1
- package/dist/client/assets/{Check-BIlnRzi6.js → Check-bgVFNRDs.js} +1 -1
- package/dist/client/assets/{CheckCircle-CSYoAEm3.js → CheckCircle-D5tJhsvc.js} +1 -1
- package/dist/client/assets/{CheckDone01-gZo2F6uL.js → CheckDone01-dY3WtOge.js} +1 -1
- package/dist/client/assets/{ChevronDown-jAfIG9nZ.js → ChevronDown-DY4fpd0G.js} +1 -1
- package/dist/client/assets/{ChevronRight-CNYkXy1u.js → ChevronRight-DMzFQQCc.js} +1 -1
- package/dist/client/assets/{Code01-DeVT5m93.js → Code01-7hV4ZDjZ.js} +1 -1
- package/dist/client/assets/{Copy01-BJPi2nBZ.js → Copy01-C35WeFYE.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-CZIcl0Ye.js → DotsHorizontal-LbVwX-Tq.js} +1 -1
- package/dist/client/assets/{DotsVertical-CPJps54j.js → DotsVertical-BNqPYTki.js} +1 -1
- package/dist/client/assets/{Download01-BVA62GFI.js → Download01-Cihql6Z7.js} +1 -1
- package/dist/client/assets/{Edit01-CLT1AKyh.js → Edit01-DDrpQJgk.js} +1 -1
- package/dist/client/assets/{File02-M7e4eeKQ.js → File02-GEmd_G7y.js} +1 -1
- package/dist/client/assets/{File06-BUOJeS0C.js → File06-888BgyfZ.js} +1 -1
- package/dist/client/assets/{FilterLines-CDkZPaiO.js → FilterLines-Bvkz4XO7.js} +1 -1
- package/dist/client/assets/{Globe02-CNtZ4Mz7.js → Globe02-DSX2gzp_.js} +1 -1
- package/dist/client/assets/{Grid01-BhCIE3UE.js → Grid01-CfSiTcO8.js} +1 -1
- package/dist/client/assets/{Home02-Zp_wVezk.js → Home02-PhQXF8P6.js} +1 -1
- package/dist/client/assets/{Image01-Bmljn0R6.js → Image01-BUR65REQ.js} +1 -1
- package/dist/client/assets/{Inbox01-Bz-1SNbb.js → Inbox01-Bhe6QhSW.js} +1 -1
- package/dist/client/assets/{InfoCircle-DutDNmXq.js → InfoCircle-5NZyA5WD.js} +1 -1
- package/dist/client/assets/{LinkExternal01-npl2D9IH.js → LinkExternal01-Cr89LzOE.js} +1 -1
- package/dist/client/assets/{List-B95opsr5.js → List-BBkbo-oe.js} +1 -1
- package/dist/client/assets/{Loading01-CudhqwtJ.js → Loading01-C2vqzEw-.js} +1 -1
- package/dist/client/assets/{Lock01-C3j5poil.js → Lock01-ClMI2bMm.js} +1 -1
- package/dist/client/assets/{Pin01-DpTwe7GO.js → Pin01-uiXGtZsb.js} +1 -1
- package/dist/client/assets/{Play-BxFFyAEF.js → Play-Bm8SKfhZ.js} +1 -1
- package/dist/client/assets/{Plus-BVPnBK8D.js → Plus-BMOTPGqH.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-Dzlid7sh.js → RefreshCcw01-B1tus5Lj.js} +1 -1
- package/dist/client/assets/{SearchMd-yRVgOeax.js → SearchMd-BqVXNd65.js} +1 -1
- package/dist/client/assets/{Settings01-DGIrqZBI.js → Settings01-CYRp4gjN.js} +1 -1
- package/dist/client/assets/{Settings02-CW4MK9LY.js → Settings02-BiTxgSpC.js} +1 -1
- package/dist/client/assets/{Share07-BKNvns4q.js → Share07-BZVoNuS6.js} +1 -1
- package/dist/client/assets/{Terminal-DV_yPRWa.js → Terminal-DRpoCIsG.js} +1 -1
- package/dist/client/assets/{Tool01-C0EKLKq5.js → Tool01-djk7g7Hv.js} +1 -1
- package/dist/client/assets/{Trash01-py7ft8Od.js → Trash01-d4v7i3Ze.js} +1 -1
- package/dist/client/assets/{Upload01-CCoXEdI4.js → Upload01-Ci_jklEk.js} +1 -1
- package/dist/client/assets/{Users03-D2F2bran.js → Users03-Bw7fWrTD.js} +1 -1
- package/dist/client/assets/{X-CixxHrye.js → X-CslJd5Ib.js} +1 -1
- package/dist/client/assets/{XClose-S1Me7eeg.js → XClose-CjpNuP8c.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-DZgc-mir.js → agent-connections-preview-qFrRTce9.js} +1 -1
- package/dist/client/assets/{agent-detail-DPLDxB9n.js → agent-detail-BqrAf6oD.js} +1 -1
- package/dist/client/assets/{agents-CynO2-IY.js → agents-DUQt1GSW.js} +1 -1
- package/dist/client/assets/{alert-dialog-B1nWkQHx.js → alert-dialog-DRso9X1m.js} +1 -1
- package/dist/client/assets/{auth-catchall-CJ49F7Eq.js → auth-catchall-CBFb2pC-.js} +1 -1
- package/dist/client/assets/{avatar-BbH9O0kN.js → avatar-kY9raA-l.js} +1 -1
- package/dist/client/assets/{badge-C898LHvV.js → badge-DBw6AEaX.js} +1 -1
- package/dist/client/assets/{binder-xcUkLvPC.js → binder-Jddq1y1v.js} +1 -1
- package/dist/client/assets/{breadcrumb-t_Ccp20G.js → breadcrumb-ChH6wfcA.js} +1 -1
- package/dist/client/assets/{button-C1iesapY.js → button-D_OpQIQm.js} +1 -1
- package/dist/client/assets/{card-DKzkS6ji.js → card-DAZxrY9k.js} +1 -1
- package/dist/client/assets/{checkbox-B82l7mBw.js → checkbox-C1Sx9y02.js} +1 -1
- package/dist/client/assets/{circle-alert-_5s_KbQk.js → circle-alert-DHI8xRUj.js} +1 -1
- package/dist/client/assets/{collection-detail-B-hnHfhu.js → collection-detail-mD5cqpxJ.js} +1 -1
- package/dist/client/assets/{collection-search-D3a5_1zR.js → collection-search-Bkd4qN8a.js} +1 -1
- package/dist/client/assets/{collection-tab-Y58MHDMK.js → collection-tab-Dw5b9EM9.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-B6XWzQ-4.js → collection-table-wrapper-DFTdnQhc.js} +1 -1
- package/dist/client/assets/{collection-tabs-BPHWDFL4.js → collection-tabs-N53MF1Jz.js} +1 -1
- package/dist/client/assets/{command-DepzRVHX.js → command-B5nNM5RC.js} +1 -1
- package/dist/client/assets/{connect-OP0J5SPJ.js → connect--hPmG576.js} +1 -1
- package/dist/client/assets/{connection-card-DkCny6Ez.js → connection-card-Ci3H_H7r.js} +1 -1
- package/dist/client/assets/{connection-detail-CdLleACg.js → connection-detail-8nT6j66Y.js} +1 -1
- package/dist/client/assets/{connections-BZUVvBGs.js → connections-ShazCLrP.js} +1 -1
- package/dist/client/assets/constants-1u4R2d-I.js +1 -0
- package/dist/client/assets/{constants-BEco_-y7.js → constants-DisdEZ3l.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-58b_GUv7.js → create-organization-dialog-Ca5pwwfH.js} +1 -1
- package/dist/client/assets/{create-project-dialog-C5GAJOOY.js → create-project-dialog-BDfz4rOz.js} +1 -1
- package/dist/client/assets/{dialog-CpkgwzHW.js → dialog-BPL7ZvPc.js} +1 -1
- package/dist/client/assets/{dropdown-menu-D6YYwFq7.js → dropdown-menu-BxLN4KkF.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-BMgNBEQS.js → dynamic-plugin-layout-D9dQ0ajA.js} +1 -1
- package/dist/client/assets/{empty-state-BQPtoYZe.js → empty-state-CbIU_RrP.js} +1 -1
- package/dist/client/assets/{empty-state-CH3e4Xzf.js → empty-state-DXJM9xrV.js} +1 -1
- package/dist/client/assets/{env-vars-editor-Vpi1vdW2.js → env-vars-editor-BbjrljLQ.js} +1 -1
- package/dist/client/assets/{error-boundary-BGFWaL1J.js → error-boundary-BMH0CjEH.js} +1 -1
- package/dist/client/assets/{extract-connection-data-CDmQ7rLP.js → extract-connection-data-wB5jtXsg.js} +1 -1
- package/dist/client/assets/{file-browser-DUDclrRh.js → file-browser-DBOCTon5.js} +2 -2
- package/dist/client/assets/{form-NA0-x5iN.js → form-BpiblhO1.js} +1 -1
- package/dist/client/assets/{grid-view-DbtTgaoS.js → grid-view-Bty4YwjE.js} +1 -1
- package/dist/client/assets/{home-DtmWz3MA.js → home-BIvstm5O.js} +1 -1
- package/dist/client/assets/{index-Kq8ytqk9.js → index--vZ0X2xS.js} +1 -1
- package/dist/client/assets/{index-wUnd_o-U.js → index-B9-4goiW.js} +1 -1
- package/dist/client/assets/{index-HxeE9C0A.js → index-BKpxPW_G.js} +2 -2
- package/dist/client/assets/{index-GRocoNYa.js → index-BV_k_ZyP.js} +1 -1
- package/dist/client/assets/{index-C9Dn0opW.js → index-B_142IPp.js} +1 -1
- package/dist/client/assets/{index-DlY6KFzI.js → index-CnNzyZrg.js} +1 -1
- package/dist/client/assets/{index-43_iGxlN.js → index-D-_nr7La.js} +1 -1
- package/dist/client/assets/{index-Dv4saiJc.js → index-D0nVkmnC.js} +1 -1
- package/dist/client/assets/{index-ByJoFAq_.js → index-fVGDVKMq.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-CSOdbqFL.js → infiniteQueryObserver-B8M15Jhm.js} +1 -1
- package/dist/client/assets/{input-DBGu1Yhi.js → input-lpAGMNlp.js} +1 -1
- package/dist/client/assets/{integration-icon-CmJggqPx.js → integration-icon-DFSc5_D8.js} +1 -1
- package/dist/client/assets/{label-11d5Pe_w.js → label-h0it3r-G.js} +1 -1
- package/dist/client/assets/{layout-BQSZy0Ao.js → layout-DaBTH10o.js} +1 -1
- package/dist/client/assets/{localstorage-keys-BxVB7BFB.js → localstorage-keys-CrJngaoW.js} +1 -1
- package/dist/client/assets/{login-CMpn2tdR.js → login-DX4NlTrd.js} +1 -1
- package/dist/client/assets/{mcp-oauth-JrpxCLx4.js → mcp-oauth-DQYLB8aB.js} +1 -1
- package/dist/client/assets/{mcp-server-card-8DET7nVd.js → mcp-server-card-fBAhOAUG.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-CMrzxsYv.js → mcp-server-detail-BZkrf0kt.js} +2 -2
- package/dist/client/assets/{members-CUWgr5ku.js → members-BigA6ZKR.js} +1 -1
- package/dist/client/assets/{monaco-editor-DvJ6AQm-.js → monaco-editor-DZSx9WV6.js} +1 -1
- package/dist/client/assets/{monitoring-Db1K0NxK.js → monitoring-cMb0Xapp.js} +1 -1
- package/dist/client/assets/{oauth-callback-Bh-LWKIz.js → oauth-callback-CjSC6FG1.js} +1 -1
- package/dist/client/assets/{page-Bx3m0Nlj.js → page-BDwNfQ-N.js} +1 -1
- package/dist/client/assets/{page-79TZOOqo.js → page-jq7pkske.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-34Wj3C93.js → plugin-empty-state-CIjn_En1.js} +1 -1
- package/dist/client/assets/{plugin-header-KrvIXXbF.js → plugin-header-DxKd-JRE.js} +1 -1
- package/dist/client/assets/{popover-BbAo_V3q.js → popover-ESVk6nXT.js} +1 -1
- package/dist/client/assets/{project-layout-QE2hcM6x.js → project-layout-DOGEQwDl.js} +1 -1
- package/dist/client/assets/{project-settings-2bxHgR8P.js → project-settings-DPjoRdOS.js} +1 -1
- package/dist/client/assets/{projects-list-CSrfAb2G.js → projects-list-BSPk4OqL.js} +1 -1
- package/dist/client/assets/{registry-utils-CLfG2KJO.js → registry-utils-yxVJe3X4.js} +1 -1
- package/dist/client/assets/{resizable-D5fgPQWp.js → resizable-fcBWjaSA.js} +1 -1
- package/dist/client/assets/{select-CnIfeZ9k.js → select-BbzYJ4VF.js} +1 -1
- package/dist/client/assets/{shell-layout-DIuzNmm5.js → shell-layout-DlF3XvPK.js} +1 -1
- package/dist/client/assets/{spinner-BbdUl9_5.js → spinner-Lv2khbLw.js} +1 -1
- package/dist/client/assets/{store-invite-eQ6O_LcC.js → store-invite-Bg3OdZwq.js} +1 -1
- package/dist/client/assets/{switch-7wa9WQCt.js → switch-sdaV-SJo.js} +1 -1
- package/dist/client/assets/{table-F_F9uG31.js → table-BxUix49E.js} +1 -1
- package/dist/client/assets/{tasks-Bo849zPQ.js → tasks-Bl2i_lGW.js} +1 -1
- package/dist/client/assets/{textarea-CX1AXmSo.js → textarea-BRJpMcB0.js} +1 -1
- package/dist/client/assets/{tools-list-CeBZ5K9_.js → tools-list-Cmzz8Wet.js} +1 -1
- package/dist/client/assets/{topbar-portal-DTnSGvrH.js → topbar-portal-bqTUj07t.js} +1 -1
- package/dist/client/assets/{typewriter-title-CydscG0b.js → typewriter-title-BPMIdq0b.js} +1 -1
- package/dist/client/assets/{use-binding-BIvDtNoa.js → use-binding-DMsO_03X.js} +1 -1
- package/dist/client/assets/{use-connection-DWpxH8iy.js → use-connection-B0740Saa.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-CMegJpH_.js → use-create-virtual-mcp-lh01_aoW.js} +1 -1
- package/dist/client/assets/{use-deco-chat-open-DeBMXnMx.js → use-deco-chat-open-B2KYtTue.js} +2 -2
- package/dist/client/assets/{use-install-from-registry-CNdLBCwL.js → use-install-from-registry-BjKzt3Pz.js} +1 -1
- package/dist/client/assets/{use-list-state-CqdwrHCA.js → use-list-state-DNfSCsX5.js} +1 -1
- package/dist/client/assets/{use-llm-B2BVGott.js → use-llm-D28vq8-j.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-CUow6VVK.js → use-mcp-prompts-FoVTG9k7.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DO_-llbI.js → use-mcp-tools-DF65_5AL.js} +1 -1
- package/dist/client/assets/{use-mobile-CqANtQ4e.js → use-mobile-Cu9U-yCu.js} +1 -1
- package/dist/client/assets/{use-organization-settings-ANLw4ex1.js → use-organization-settings-CPNBbiln.js} +1 -1
- package/dist/client/assets/{use-project-C1G7xlcy.js → use-project-CuNldV92.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DaI2d98r.js → use-virtual-mcp-BUCuQhrG.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-CsMrU_k5.js +1 -0
- package/dist/client/assets/{useMutation-M3-wug2Q.js → useMutation-Bnsod7M-.js} +1 -1
- package/dist/client/assets/useQuery-Bo6lCSyK.js +1 -0
- package/dist/client/assets/utils-Ckp7rFN8.js +1 -0
- package/dist/client/assets/{view-mode-toggle-JVmuLwXe.js → view-mode-toggle-4jMhv4Z3.js} +1 -1
- package/dist/client/assets/{workflow-BKKAfuJP.js → workflow-BrBoF9SG.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +152 -149
- package/dist/server/server.js +127 -124
- package/package.json +1 -1
- package/dist/client/assets/constants-gwxE8_b0.js +0 -1
- package/dist/client/assets/useInfiniteQuery-CL3o6Gdm.js +0 -1
- package/dist/client/assets/useQuery-jRtVXI31.js +0 -1
- package/dist/client/assets/utils-D1Qd9-I_.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as D,c as re,j as s,p as Xt,u as je,g as me,K as ue,o as Et,aj as We,s as Ce,b9 as yt,bf as St,z as Me,k as zt,h as Wt,t as le,y as es}from"./index-HxeE9C0A.js";import{C as ts,a as ss}from"./collection-table-wrapper-B6XWzQ-4.js";import{C as De}from"./collection-search-D3a5_1zR.js";import{P as Ee}from"./index-wUnd_o-U.js";import{B as ns,a as rs,b as os,c as is}from"./breadcrumb-t_Ccp20G.js";import{I as Ut,c as ye,b as Se,T as Ie,a as Oe}from"./integration-icon-CmJggqPx.js";import{C as ze}from"./checkbox-B82l7mBw.js";import{B as ie}from"./button-C1iesapY.js";import{c as q}from"./utils-D1Qd9-I_.js";import{h as Vt}from"./use-connection-DWpxH8iy.js";import{u as bt,C as ct,a as dt,b as It,c as ls,d as as,e as cs,f as ds}from"./command-DepzRVHX.js";import{u as it}from"./useQuery-jRtVXI31.js";import{u as Ne}from"./useMutation-M3-wug2Q.js";import{u as ms,a as us}from"./use-llm-B2BVGott.js";import{A as Pe}from"./avatar-BbH9O0kN.js";import{B as we}from"./badge-C898LHvV.js";import{f as Ue,a as Ve,b as Be,c as Ge,d as $e,e as Fe,A as Ke,g as Qe}from"./alert-dialog-B1nWkQHx.js";import{D as Bt,f as Gt,a as $t,b as fs,c as hs,e as gs}from"./dialog-CpkgwzHW.js";import{D as Ct,a as jt,b as Tt,c as nt,d as xs,e as ps,f as bs,g as Cs}from"./dropdown-menu-D6YYwFq7.js";import{i as js}from"./DotsHorizontal-CZIcl0Ye.js";import{i as qe}from"./Loading01-CudhqwtJ.js";import{i as Ts}from"./Lock01-C3j5poil.js";import{s as rt}from"./Plus-BVPnBK8D.js";import{s as Ft}from"./Trash01-py7ft8Od.js";import{i as Ot}from"./X-CixxHrye.js";import{I as vs}from"./input-DBGu1Yhi.js";import{S as ve}from"./switch-7wa9WQCt.js";import{E as mt}from"./empty-state-CH3e4Xzf.js";import{E as Ns}from"./error-boundary-BGFWaL1J.js";import{a as Es,F as wt,b as At,c as ys,d as _t,f as Lt}from"./form-NA0-x5iN.js";import{S as ft,a as ht,b as gt,c as xt,d as pt}from"./select-CnIfeZ9k.js";import{T as Ss}from"./textarea-CX1AXmSo.js";import{a as He,u as Ze}from"./constants-BEco_-y7.js";import{C as Rt}from"./card-DKzkS6ji.js";import{i as Kt}from"./DotsVertical-CPJps54j.js";import{i as Is}from"./index-DlY6KFzI.js";import{s as Qt}from"./XClose-S1Me7eeg.js";import{a as Os,b as ws,P as As}from"./popover-BbAo_V3q.js";import{t as _s}from"./ChevronDown-jAfIG9nZ.js";import"./ArrowUp-DVhz9MPT.js";import"./Check-BIlnRzi6.js";import"./Grid01-BhCIE3UE.js";import"./List-B95opsr5.js";import"./view-mode-toggle-JVmuLwXe.js";import"./table-F_F9uG31.js";import"./SearchMd-yRVgOeax.js";import"./ChevronRight-CNYkXy1u.js";import"./index-ByJoFAq_.js";import"./use-binding-BIvDtNoa.js";import"./binder-xcUkLvPC.js";import"./label-11d5Pe_w.js";const qt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M19 12H5m0 0 7 7m-7-7 7-7"}));qt.displayName="ArrowLeft";const vt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M11.302 21.615c.221.129.332.194.488.227.122.026.298.026.42 0 .156-.034.267-.098.488-.227C14.646 20.478 20 16.908 20 12V7.217c0-.799 0-1.199-.13-1.542a2 2 0 0 0-.548-.79c-.275-.243-.65-.383-1.398-.664l-5.362-2.01c-.208-.078-.312-.117-.419-.133a1 1 0 0 0-.286 0c-.107.016-.21.055-.419.133L6.076 4.22c-.748.28-1.122.421-1.398.664a2 2 0 0 0-.547.79C4 6.018 4 6.418 4 7.217V12c0 4.908 5.354 8.478 7.302 9.615Z"}));vt.displayName="Shield01";const Ht=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M20 17H4m0 0 4-4m-4 4 4 4M4 7h16m0 0-4-4m4 4-4 4"}));Ht.displayName="SwitchHorizontal01";const Zt=[{name:"ORGANIZATION_CREATE",description:"Create a new organization",category:"Organizations"},{name:"ORGANIZATION_LIST",description:"List organizations",category:"Organizations"},{name:"ORGANIZATION_GET",description:"View organization details",category:"Organizations"},{name:"ORGANIZATION_UPDATE",description:"Update organization",category:"Organizations"},{name:"ORGANIZATION_DELETE",description:"Delete organization",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_SETTINGS_GET",description:"View organization settings",category:"Organizations"},{name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization settings",category:"Organizations"},{name:"ORGANIZATION_MEMBER_ADD",description:"Add members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove members",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_MEMBER_LIST",description:"List members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update member roles",category:"Organizations"},{name:"COLLECTION_CONNECTIONS_CREATE",description:"Create connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_LIST",description:"List connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_GET",description:"View connection details",category:"Connections"},{name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete connections",category:"Connections",dangerous:!0},{name:"CONNECTION_TEST",description:"Test connections",category:"Connections"},{name:"DATABASES_RUN_SQL",description:"Run SQL queries",category:"Connections",dangerous:!0},{name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_GET",description:"View virtual MCP details",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete virtual MCPs",category:"Virtual MCPs",dangerous:!0},{name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create virtual tools on Virtual MCPs",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List virtual tools",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"View virtual tool details",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update virtual tools",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete virtual tools",category:"Virtual Tools",dangerous:!0},{name:"MONITORING_LOGS_LIST",description:"List monitoring logs",category:"Monitoring"},{name:"MONITORING_STATS",description:"View monitoring statistics",category:"Monitoring"},{name:"API_KEY_CREATE",description:"Create API key",category:"API Keys"},{name:"API_KEY_LIST",description:"List API keys",category:"API Keys"},{name:"API_KEY_UPDATE",description:"Update API key",category:"API Keys"},{name:"API_KEY_DELETE",description:"Delete API key",category:"API Keys",dangerous:!0},{name:"EVENT_PUBLISH",description:"Publish events",category:"Event Bus"},{name:"EVENT_SUBSCRIBE",description:"Subscribe to events",category:"Event Bus"},{name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events",category:"Event Bus"},{name:"EVENT_CANCEL",description:"Cancel recurring events",category:"Event Bus"},{name:"EVENT_ACK",description:"Acknowledge event delivery",category:"Event Bus"},{name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions",category:"Event Bus"},{name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state",category:"Event Bus"},{name:"USER_GET",description:"Get a user by id",category:"Users"},{name:"CODE_EXECUTION_SEARCH_TOOLS",description:"Search available tools by name or description",category:"Code Execution"},{name:"CODE_EXECUTION_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools",category:"Code Execution"},{name:"CODE_EXECUTION_RUN_CODE",description:"Run JavaScript code in a sandbox with tool access",category:"Code Execution",dangerous:!0},{name:"COLLECTION_THREADS_CREATE",description:"Create threads",category:"Threads"},{name:"COLLECTION_THREADS_LIST",description:"List threads",category:"Threads"},{name:"COLLECTION_THREADS_GET",description:"View thread details",category:"Threads"},{name:"COLLECTION_THREADS_UPDATE",description:"Update threads",category:"Threads"},{name:"COLLECTION_THREADS_DELETE",description:"Delete threads",category:"Threads",dangerous:!0},{name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List thread messages",category:"Threads"},{name:"TAGS_LIST",description:"List organization tags",category:"Tags"},{name:"TAGS_CREATE",description:"Create organization tag",category:"Tags"},{name:"TAGS_DELETE",description:"Delete organization tag",category:"Tags",dangerous:!0},{name:"MEMBER_TAGS_GET",description:"Get member tags",category:"Tags"},{name:"MEMBER_TAGS_SET",description:"Set member tags",category:"Tags"},{name:"PROJECT_LIST",description:"List projects in organization",category:"Projects"},{name:"PROJECT_GET",description:"View project details",category:"Projects"},{name:"PROJECT_CREATE",description:"Create new project",category:"Projects"},{name:"PROJECT_UPDATE",description:"Update project",category:"Projects"},{name:"PROJECT_DELETE",description:"Delete project",category:"Projects",dangerous:!0},{name:"PROJECT_PLUGIN_CONFIG_GET",description:"View project plugin configuration",category:"Projects"},{name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update project plugin configuration",category:"Projects"}],Ls={ORGANIZATION_CREATE:"Create organization",ORGANIZATION_LIST:"List organizations",ORGANIZATION_GET:"View organization details",ORGANIZATION_UPDATE:"Update organization",ORGANIZATION_DELETE:"Delete organization",ORGANIZATION_SETTINGS_GET:"View organization settings",ORGANIZATION_SETTINGS_UPDATE:"Update organization settings",ORGANIZATION_MEMBER_LIST:"List members",ORGANIZATION_MEMBER_ADD:"Add members",ORGANIZATION_MEMBER_REMOVE:"Remove members",ORGANIZATION_MEMBER_UPDATE_ROLE:"Update member roles",COLLECTION_CONNECTIONS_LIST:"List connections",COLLECTION_CONNECTIONS_GET:"View connection details",COLLECTION_CONNECTIONS_CREATE:"Create connections",COLLECTION_CONNECTIONS_UPDATE:"Update connections",COLLECTION_CONNECTIONS_DELETE:"Delete connections",CONNECTION_TEST:"Test connections",DATABASES_RUN_SQL:"Run SQL queries",COLLECTION_VIRTUAL_MCP_CREATE:"Create virtual MCPs",COLLECTION_VIRTUAL_MCP_LIST:"List virtual MCPs",COLLECTION_VIRTUAL_MCP_GET:"View virtual MCP details",COLLECTION_VIRTUAL_MCP_UPDATE:"Update virtual MCPs",COLLECTION_VIRTUAL_MCP_DELETE:"Delete virtual MCPs",COLLECTION_VIRTUAL_TOOLS_CREATE:"Create virtual tools",COLLECTION_VIRTUAL_TOOLS_LIST:"List virtual tools",COLLECTION_VIRTUAL_TOOLS_GET:"View virtual tool details",COLLECTION_VIRTUAL_TOOLS_UPDATE:"Update virtual tools",COLLECTION_VIRTUAL_TOOLS_DELETE:"Delete virtual tools",MONITORING_LOGS_LIST:"List monitoring logs",MONITORING_STATS:"View monitoring statistics",API_KEY_CREATE:"Create API key",API_KEY_LIST:"List API keys",API_KEY_UPDATE:"Update API key",API_KEY_DELETE:"Delete API key",EVENT_PUBLISH:"Publish events",EVENT_SUBSCRIBE:"Subscribe to events",EVENT_UNSUBSCRIBE:"Unsubscribe from events",EVENT_CANCEL:"Cancel recurring events",EVENT_ACK:"Acknowledge event delivery",EVENT_SUBSCRIPTION_LIST:"List event subscriptions",EVENT_SYNC_SUBSCRIPTIONS:"Sync subscriptions to desired state",USER_GET:"Get user by id",CODE_EXECUTION_SEARCH_TOOLS:"Search tools",CODE_EXECUTION_DESCRIBE_TOOLS:"Describe tools",CODE_EXECUTION_RUN_CODE:"Run code",COLLECTION_THREADS_CREATE:"Create threads",COLLECTION_THREADS_LIST:"List threads",COLLECTION_THREADS_GET:"View thread details",COLLECTION_THREADS_UPDATE:"Update threads",COLLECTION_THREADS_DELETE:"Delete threads",COLLECTION_THREAD_MESSAGES_LIST:"List thread messages",TAGS_LIST:"List organization tags",TAGS_CREATE:"Create organization tag",TAGS_DELETE:"Delete organization tag",MEMBER_TAGS_GET:"Get member tags",MEMBER_TAGS_SET:"Set member tags",PROJECT_LIST:"List projects",PROJECT_GET:"View project details",PROJECT_CREATE:"Create project",PROJECT_UPDATE:"Update project",PROJECT_DELETE:"Delete project",PROJECT_PLUGIN_CONFIG_GET:"View plugin config",PROJECT_PLUGIN_CONFIG_UPDATE:"Update plugin config"};function Rs(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],"Virtual Tools":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],"Code Execution":[],Tags:[],Projects:[]};for(const e of Zt)t[e.category]?.push(e);return t}function Ps(){return Zt.map(t=>({value:t.name,label:Ls[t.name],dangerous:t.dangerous}))}const Ms=D.memo(function(e){const n=re.c(21),{connection:r,isSelected:l,hasToolsEnabled:o,activeToolsCount:d,totalToolsCount:i,onSelect:f,onToggle:x}=e,m=l?"bg-accent/50":"hover:bg-muted/50";let b;n[0]!==m?(b=q("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",m),n[0]=m,n[1]=b):b=n[1];let a;n[2]!==r.icon||n[3]!==r.title?(a=s.jsx(Ut,{icon:r.icon,name:r.title,size:"xs"}),n[2]=r.icon,n[3]=r.title,n[4]=a):a=n[4];let T;n[5]!==r.title?(T=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:r.title})}),n[5]=r.title,n[6]=T):T=n[6];let h;n[7]!==f||n[8]!==a||n[9]!==T?(h=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:f,children:[a,T]}),n[7]=f,n[8]=a,n[9]=T,n[10]=h):h=n[10];let N;n[11]!==d||n[12]!==r.tools||n[13]!==o||n[14]!==x||n[15]!==i?(N=r.tools&&r.tools.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[d,"/",i]}),s.jsx(ze,{checked:o,onCheckedChange:x,onClick:zs})]}),n[11]=d,n[12]=r.tools,n[13]=o,n[14]=x,n[15]=i,n[16]=N):N=n[16];let p;return n[17]!==b||n[18]!==h||n[19]!==N?(p=s.jsxs("div",{className:b,children:[h,N]}),n[17]=b,n[18]=h,n[19]=N,n[20]=p):p=n[20],p}),Ds=D.memo(function(e){const n=re.c(18),{connectionId:r,tool:l,isSelected:o,onToggle:d}=e,i=`tool-${r}-${l.name}`,f=o?"text-foreground":"text-muted-foreground";let x;n[0]!==f?(x=q("text-sm font-medium",f),n[0]=f,n[1]=x):x=n[1];let m;n[2]!==x||n[3]!==l.name?(m=s.jsx("div",{className:"flex items-center gap-2 mb-1",children:s.jsx("span",{className:x,children:l.name})}),n[2]=x,n[3]=l.name,n[4]=m):m=n[4];let b;n[5]!==l.description?(b=l.description&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l.description}),n[5]=l.description,n[6]=b):b=n[6];let a;n[7]!==m||n[8]!==b?(a=s.jsxs("div",{className:"flex-1 min-w-0",children:[m,b]}),n[7]=m,n[8]=b,n[9]=a):a=n[9];const T=`tool-${r}-${l.name}`;let h;n[10]!==o||n[11]!==d||n[12]!==T?(h=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(ze,{id:T,checked:o,onCheckedChange:d,onClick:Us})}),n[10]=o,n[11]=d,n[12]=T,n[13]=h):h=n[13];let N;return n[14]!==i||n[15]!==a||n[16]!==h?(N=s.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:i,children:[a,h]}),n[14]=i,n[15]=a,n[16]=h,n[17]=N):N=n[17],N});function ks({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n}){const[r,l]=D.useState(""),o=D.useDeferredValue(r),[d,i]=D.useState("all"),[f,x]=D.useState(!1),m=D.useRef(new Set(Object.keys(t))),b=Vt({searchTerm:o.trim()||void 0}),a=n?b.filter(g=>g.connection_type!=="VIRTUAL"?!0:Xt(g.connection_url)!==n):b,T=m.current,h=[...T.values()].map(g=>a.find(A=>A.id===g)).filter(g=>g!==void 0),N=a.filter(g=>!T.has(g.id)),p=[...h,...N],E=g=>{const A=t[g];return A!==void 0&&A.length>0},j=p.filter(g=>{if(d==="all")return!0;const A=E(g.id);return d==="selected"?A:d==="unselected"?!A:!0}),[u,y]=D.useState(p[0]?.id??null),v=u?p.find(g=>g.id===u)??null:null,P=v?.tools??[],I=(g,A)=>t[g]?.includes(A)??!1,w=(g,A)=>{const S=t[g]??[],C=S.includes(A),M={...t};if(C){const z=S.filter(B=>B!==A);z.length===0?delete M[g]:M[g]=z}else M[g]=[...S,A];e(M)},L=g=>{const A=p.find(B=>B.id===g);if(!A?.tools)return;const S=t[g]??[],C=A.tools.map(B=>B.name),M=S.length>0&&C.every(B=>S.includes(B)),z={...t};M?delete z[g]:(z[g]=C,y(g)),e(z)},O=g=>{y(g),x(!0)},R=()=>{x(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:q("w-full md:w-80 border-r border-border flex flex-col",f&&"hidden md:flex"),children:[s.jsx(De,{value:r,onChange:l,placeholder:"Search MCP Servers..."}),s.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[s.jsx("button",{onClick:()=>i("all"),className:q("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),s.jsx("button",{onClick:()=>i("selected"),className:q("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),s.jsx("button",{onClick:()=>i("unselected"),className:q("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:j.length===0?s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:r?"No connections found":d==="selected"?"No servers selected":d==="unselected"?"No unselected servers":"No connections available"}):s.jsx("div",{className:"p-2 space-y-1",children:j.map(g=>{const A=g.tools?.length??0,S=t[g.id]?.length??0;return s.jsx(Ms,{connection:g,isSelected:u===g.id,hasToolsEnabled:E(g.id),activeToolsCount:S,totalToolsCount:A,onSelect:()=>O(g.id),onToggle:()=>L(g.id)},g.id)})})})]}),s.jsx("div",{className:q("flex-1 flex-col",f?"flex":"hidden md:flex"),children:v?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[s.jsx(ie,{variant:"ghost",size:"sm",onClick:R,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(qt,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(Ut,{icon:v.icon,name:v.title,size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:v.title}),v.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:v.description})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:P.length===0?s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):s.jsx("div",{className:"space-y-2",children:P.map(g=>s.jsx(Ds,{connectionId:v.id,tool:g,isSelected:I(v.id,g.name),onToggle:()=>w(v.id,g.name)},g.name))})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function zs(t){return t.stopPropagation()}function Us(t){return t.stopPropagation()}const Pt=[{value:"owner",label:"Owner",isBuiltin:!0},{value:"admin",label:"Admin",isBuiltin:!0},{value:"user",label:"User",isBuiltin:!0}];function Vs(t){return t.replace(/-/g," ")}function Bs(t){if(!t)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1,modelCount:0,allowsAllModels:!1};const e=[];let n=!1;const r=[];let l=!1;const o=new Set;let d=!1,i=0,f=!1;for(const[x,m]of Object.entries(t)){if(x==="self"){m.includes("*")?n=!0:e.push(...m);continue}if(x==="models"){m.includes("*:*")?f=!0:i=m.length;continue}if(x==="*"){if(l=!0,m.includes("*"))d=!0;else for(const b of m)o.add(b);continue}if(r.push(x),m.includes("*"))d=!0;else for(const b of m)o.add(b)}return{staticPermissions:e,allowsAllStaticPermissions:n,connectionIds:r,allowsAllConnections:l,toolNames:Array.from(o),allowsAllTools:d,modelCount:i,allowsAllModels:f}}function Nt(){const{locator:t}=je(),{data:e,isLoading:n,error:r,refetch:l}=it({queryKey:ue.organizationRoles(t),queryFn:async()=>{try{const i=await me.organization.listRoles();return i?.error?(console.error("[useOrganizationRoles] API error:",i.error),[]):i?.data??[]}catch(i){return console.error("[useOrganizationRoles] Fetch error:",i),[]}},staleTime:3e4}),o=Pt.map(i=>({role:i.value,label:i.label,isBuiltin:i.isBuiltin}));if(e&&Array.isArray(e))for(const i of e){const f=i.role;if(!f||Pt.some(E=>E.value===f))continue;const{staticPermissions:x,allowsAllStaticPermissions:m,connectionIds:b,allowsAllConnections:a,toolNames:T,allowsAllTools:h,modelCount:N,allowsAllModels:p}=Bs(i.permission);o.push({id:i.id,role:f,label:Vs(f),isBuiltin:!1,permission:i.permission??void 0,staticPermissionCount:m?-1:x.length,allowsAllStaticPermissions:m,connectionCount:a?-1:b.length,allowsAllConnections:a,toolCount:h?-1:T.length,allowsAllTools:h,modelCount:p?-1:N,allowsAllModels:p})}const d=o.filter(i=>!i.isBuiltin);return{roles:o,customRoles:d,builtinRoles:o.filter(i=>i.isBuiltin),isLoading:n,error:r,refetch:l}}const Gs=Et({role:Et({id:Ce().optional(),slug:Ce().optional(),label:Ce()}),allowAllStaticPermissions:St(),staticPermissions:We(Ce()),toolSet:yt(Ce(),We(Ce())),allowAllModels:St(),modelSet:yt(Ce(),We(Ce())),memberIds:We(Ce())});function Jt(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}const $s=[{role:"owner",label:"Owner",color:"bg-red-500"},{role:"admin",label:"Admin",color:"bg-blue-500"},{role:"user",label:"User",color:"bg-green-500"}],ut=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"];function Fs(t){if(!t)return"bg-neutral-400";let e=0;for(let r=0;r<t.length;r++){const l=t.charCodeAt(r);e=(e<<5)-e+l,e=e&e}const n=Math.abs(e)%ut.length;return ut[n]??ut[0]}function et(){return{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:[]}}function Ks(t){const e=re.c(39),{allowAllStaticPermissions:n,staticPermissions:r,onAllowAllChange:l,onPermissionsChange:o,readOnly:d}=t,i=d===void 0?!1:d,[f,x]=D.useState(""),m=D.useDeferredValue(f);let b,a,T,h,N;if(e[0]!==n||e[1]!==m||e[2]!==l||e[3]!==o||e[4]!==i||e[5]!==f||e[6]!==r){const j=Rs(),u=Ps(),y=u.filter(R=>R.label.toLowerCase().includes(m.toLowerCase())),v=R=>{if(r.includes(R))o(r.filter(g=>g!==R));else{const g=[...r,R];g.length===u.length?(l(!0),o([])):o(g)}};T="flex flex-col h-full",e[12]!==f?(h=s.jsx("div",{className:"border-b border-border",children:s.jsx(De,{value:f,onChange:x,placeholder:"Search permissions...",className:"border-b-0"})}),e[12]=f,e[13]=h):h=e[13];const P=!i&&"hover:bg-muted/50 cursor-pointer";let I;e[14]!==P?(I=q("flex items-center justify-between px-4 py-3 rounded-lg",P),e[14]=P,e[15]=I):I=e[15];let w;e[16]!==n||e[17]!==l||e[18]!==o||e[19]!==i?(w=()=>{if(i)return;l(!n),o([])},e[16]=n,e[17]=l,e[18]=o,e[19]=i,e[20]=w):w=e[20];let L;e[21]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[21]=L):L=e[21];let O;e[22]!==n||e[23]!==l||e[24]!==o||e[25]!==i?(O=s.jsx("div",{onClick:Js,children:i?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:n,disabled:i,onCheckedChange:R=>{i||(l(R),o([]))}})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:n,disabled:i,onCheckedChange:R=>{i||(l(R),o([]))}})}),e[22]=n,e[23]=l,e[24]=o,e[25]=i,e[26]=O):O=e[26],e[27]!==O||e[28]!==I||e[29]!==w?(N=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:I,onClick:w,children:[L,O]})}),e[27]=O,e[28]=I,e[29]=w,e[30]=N):N=e[30],b="flex-1 overflow-auto",a=Object.entries(j).map(R=>{const[g,A]=R,S=y.filter(C=>A.some(M=>M.name===C.value));return S.length===0?null:s.jsxs("div",{className:"mb-6 last:mb-0",children:[s.jsx("h4",{className:"text-sm font-medium p-3 pb-1.5 text-muted-foreground/75",children:g}),s.jsx("div",{className:"space-y-1",children:S.map(C=>s.jsxs("div",{className:q("flex items-center justify-between gap-3 px-4 py-3",!i&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{if(!i)if(n){l(!1);const M=u.map(Zs);o(M.filter(z=>z!==C.value))}else v(C.value)},children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("span",{className:"text-sm",children:C.label})}),s.jsx("div",{onClick:Hs,children:i?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:n||r.includes(C.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const M=u.map(qs);o(M.filter(z=>z!==C.value))}else v(C.value)}})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:n||r.includes(C.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const M=u.map(Qs);o(M.filter(z=>z!==C.value))}else v(C.value)}})})]},C.value))})]},g)}),e[0]=n,e[1]=m,e[2]=l,e[3]=o,e[4]=i,e[5]=f,e[6]=r,e[7]=b,e[8]=a,e[9]=T,e[10]=h,e[11]=N}else b=e[7],a=e[8],T=e[9],h=e[10],N=e[11];let p;e[31]!==b||e[32]!==a?(p=s.jsx("div",{className:b,children:a}),e[31]=b,e[32]=a,e[33]=p):p=e[33];let E;return e[34]!==T||e[35]!==h||e[36]!==N||e[37]!==p?(E=s.jsxs("div",{className:T,children:[h,N,p]}),e[34]=T,e[35]=h,e[36]=N,e[37]=p,e[38]=E):E=e[38],E}function Qs(t){return t.value}function qs(t){return t.value}function Hs(t){return t.stopPropagation()}function Zs(t){return t.value}function Js(t){return t.stopPropagation()}function Ys(t){const e=re.c(45),{connection:n,selectedModels:r,allowAllModels:l,onToggleModel:o,onToggleConnectionAll:d,allConnectionModelsSelected:i,searchQuery:f,readOnly:x}=t;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={pageSize:999},e[0]=m):m=e[0];const b=us(n.id,m);let a;e[1]!==b||e[2]!==f?(a=f.trim()?b.filter(w=>w.title.toLowerCase().includes(f.toLowerCase())||w.id.toLowerCase().includes(f.toLowerCase())||w.provider?.toLowerCase().includes(f.toLowerCase())):b,e[1]=b,e[2]=f,e[3]=a):a=e[3];const T=a;if(T.length===0)return null;let h;e[4]!==i||e[5]!==l||e[6]!==T||e[7]!==r?(h=l||i||r.includes("*")&&!l||T.every(w=>r.includes(w.id)||r.includes("*")),e[4]=i,e[5]=l,e[6]=T,e[7]=r,e[8]=h):h=e[8];const N=h;let p;e[9]!==n.icon||e[10]!==n.title?(p=n.icon?s.jsx("img",{src:n.icon,alt:n.title,className:"w-4 h-4 rounded"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:n.title.slice(0,1).toUpperCase()}),e[9]=n.icon,e[10]=n.title,e[11]=p):p=e[11];let E;e[12]!==n.title?(E=s.jsx("h4",{className:"text-sm font-medium text-muted-foreground/75",children:n.title}),e[12]=n.title,e[13]=E):E=e[13];let j;e[14]!==p||e[15]!==E?(j=s.jsxs("div",{className:"flex items-center gap-2",children:[p,E]}),e[14]=p,e[15]=E,e[16]=j):j=e[16];let u;e[17]!==N||e[18]!==l||e[19]!==n.id||e[20]!==b||e[21]!==d||e[22]!==x?(u=!x&&!l&&s.jsx(ve,{checked:N,onCheckedChange:()=>d(n.id,b)}),e[17]=N,e[18]=l,e[19]=n.id,e[20]=b,e[21]=d,e[22]=x,e[23]=u):u=e[23];let y;e[24]!==j||e[25]!==u?(y=s.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[j,u]}),e[24]=j,e[25]=u,e[26]=y):y=e[26];let v;if(e[27]!==l||e[28]!==n.id||e[29]!==T||e[30]!==o||e[31]!==x||e[32]!==r){let w;e[34]!==l||e[35]!==n.id||e[36]!==o||e[37]!==x||e[38]!==r?(w=L=>{const O=l||r.includes("*")||r.includes(L.id);return s.jsxs("div",{className:q("flex items-center justify-between gap-3 px-4 py-3",!x&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{x||l||o(n.id,L.id)},children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[L.logo&&s.jsx("img",{src:L.logo,className:"w-4 h-4 shrink-0 rounded-sm",alt:L.title}),s.jsx("span",{className:"text-sm truncate",children:L.title})]}),s.jsx("div",{onClick:Xs,children:x?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:O,disabled:!0})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:O,disabled:x||l,onCheckedChange:()=>{x||l||o(n.id,L.id)}})})]},L.id)},e[34]=l,e[35]=n.id,e[36]=o,e[37]=x,e[38]=r,e[39]=w):w=e[39],v=T.map(w),e[27]=l,e[28]=n.id,e[29]=T,e[30]=o,e[31]=x,e[32]=r,e[33]=v}else v=e[33];let P;e[40]!==v?(P=s.jsx("div",{className:"space-y-1",children:v}),e[40]=v,e[41]=P):P=e[41];let I;return e[42]!==P||e[43]!==y?(I=s.jsxs("div",{className:"mb-6 last:mb-0",children:[y,P]}),e[42]=P,e[43]=y,e[44]=I):I=e[44],I}function Xs(t){return t.stopPropagation()}function Ws(){const t=re.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(qe,{className:"size-4 animate-spin"}),"Loading models..."]}),t[0]=e):e=t[0],e}function en(t){const e=re.c(39),{allowAllModels:n,modelSet:r,onAllowAllChange:l,onModelSetChange:o,readOnly:d}=t,i=d===void 0?!1:d,[f,x]=D.useState(""),m=D.useDeferredValue(f),b=ms();let a;e[0]!==r||e[1]!==o?(a=(O,R)=>{const g=r[O]??[],A={...r};if(g.includes(R)){const S=g.filter(C=>C!==R);S.length===0?delete A[O]:A[O]=S}else A[O]=[...g,R];o(A)},e[0]=r,e[1]=o,e[2]=a):a=e[2];const T=a;let h;e[3]!==r||e[4]!==o?(h=(O,R)=>{const g=r[O]??[],A=R.map(sn),S=g.includes("*")||A.every(M=>g.includes(M)),C={...r};S?delete C[O]:C[O]=A,o(C)},e[3]=r,e[4]=o,e[5]=h):h=e[5];const N=h;let p;e[6]!==f?(p=s.jsx("div",{className:"border-b border-border",children:s.jsx(De,{value:f,onChange:x,placeholder:"Search models...",className:"border-b-0"})}),e[6]=f,e[7]=p):p=e[7];const E=!i&&"hover:bg-muted/50 cursor-pointer";let j;e[8]!==E?(j=q("flex items-center justify-between px-4 py-3 rounded-lg",E),e[8]=E,e[9]=j):j=e[9];let u;e[10]!==n||e[11]!==l||e[12]!==o||e[13]!==i?(u=()=>{if(i)return;const O=!n;l(O),O&&o({})},e[10]=n,e[11]=l,e[12]=o,e[13]=i,e[14]=u):u=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("span",{className:"text-sm font-medium",children:"All models"}),e[15]=y):y=e[15];let v;e[16]!==n||e[17]!==l||e[18]!==o||e[19]!==i?(v=s.jsx("div",{onClick:tn,children:i?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:n,disabled:!0})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:n,onCheckedChange:O=>{i||(l(O),O&&o({}))}})}),e[16]=n,e[17]=l,e[18]=o,e[19]=i,e[20]=v):v=e[20];let P;e[21]!==j||e[22]!==u||e[23]!==v?(P=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:j,onClick:u,children:[y,v]})}),e[21]=j,e[22]=u,e[23]=v,e[24]=P):P=e[24];let I;e[25]!==n||e[26]!==m||e[27]!==b||e[28]!==r||e[29]!==i||e[30]!==N||e[31]!==T?(I=b.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No LLM connections configured"}):b.map(O=>s.jsx(D.Suspense,{fallback:s.jsx(Ws,{}),children:s.jsx(Ys,{connection:O,selectedModels:r[O.id]??[],allowAllModels:n,onToggleModel:T,onToggleConnectionAll:N,allConnectionModelsSelected:(r[O.id]??[]).includes("*"),searchQuery:m,readOnly:i})},O.id)),e[25]=n,e[26]=m,e[27]=b,e[28]=r,e[29]=i,e[30]=N,e[31]=T,e[32]=I):I=e[32];let w;e[33]!==I?(w=s.jsx("div",{className:"flex-1 overflow-auto",children:I}),e[33]=I,e[34]=w):w=e[34];let L;return e[35]!==P||e[36]!==w||e[37]!==p?(L=s.jsxs("div",{className:"flex flex-col h-full",children:[p,P,w]}),e[35]=P,e[36]=w,e[37]=p,e[38]=L):L=e[38],L}function tn(t){return t.stopPropagation()}function sn(t){return t.id}function nn(t){const e=re.c(56),{open:n,onOpenChange:r,selectedMemberIds:l,onAddMembers:o}=t,[d,i]=D.useState(""),f=D.useDeferredValue(d);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0];const[m,b]=D.useState(x),{data:a}=bt();let T,h,N,p,E,j,u,y,v,P,I;if(e[1]!==a?.data?.members||e[2]!==f||e[3]!==o||e[4]!==r||e[5]!==n||e[6]!==m||e[7]!==d||e[8]!==l){const M=a?.data?.members??[];let z;e[20]!==f?(z=U=>{const c=f.toLowerCase();return U.user?.name?.toLowerCase().includes(c)||U.user?.email?.toLowerCase().includes(c)},e[20]=f,e[21]=z):z=e[21];const B=M.filter(z),K=rn;let X;e[22]!==l?(X=U=>l.includes(U),e[22]=l,e[23]=X):X=e[23];const W=X;let ee;e[24]!==m?(ee=U=>{m.includes(U)?b(m.filter(c=>c!==U)):b([...m,U])},e[24]=m,e[25]=ee):ee=e[25];const oe=ee;let te;e[26]!==o||e[27]!==r||e[28]!==m?(te=()=>{o(m),b([]),r(!1)},e[26]=o,e[27]=r,e[28]=m,e[29]=te):te=e[29],N=te,h=Ue,P=n,I=r,T=Ve,y="sm:max-w-md p-0 overflow-hidden",e[30]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsxs(Be,{className:"px-6 pt-6",children:[s.jsx(Ge,{children:"Add Members to Role"}),s.jsx($e,{children:"Select members to add to this role."})]}),e[30]=v):v=e[30],j="flex flex-col h-80",e[31]!==d?(u=s.jsx(De,{value:d,onChange:i,placeholder:"Search members...",className:"border-b border-t-0 border-x-0 rounded-none"}),e[31]=d,e[32]=u):u=e[32],p="flex-1 overflow-auto",E=B.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:d?"No members found":"No members available"})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:B.map(U=>{const c=K(U),_=W(U.id),V=m.includes(U.id);return s.jsxs("label",{className:q("flex items-center gap-3 p-2 rounded-lg",!c||_?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(ze,{checked:V||_,onCheckedChange:()=>{c&&!_&&oe(U.id)},disabled:!c||_}),s.jsx(Pe,{url:U.user?.image??void 0,fallback:Jt(U.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:U.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.user?.email})]}),!c&&s.jsx(we,{variant:"secondary",className:"shrink-0",children:"Owner"}),_&&c&&s.jsx(we,{variant:"outline",className:"shrink-0",children:"Added"})]},U.id)})}),e[1]=a?.data?.members,e[2]=f,e[3]=o,e[4]=r,e[5]=n,e[6]=m,e[7]=d,e[8]=l,e[9]=T,e[10]=h,e[11]=N,e[12]=p,e[13]=E,e[14]=j,e[15]=u,e[16]=y,e[17]=v,e[18]=P,e[19]=I}else T=e[9],h=e[10],N=e[11],p=e[12],E=e[13],j=e[14],u=e[15],y=e[16],v=e[17],P=e[18],I=e[19];let w;e[33]!==p||e[34]!==E?(w=s.jsx("div",{className:p,children:E}),e[33]=p,e[34]=E,e[35]=w):w=e[35];let L;e[36]!==w||e[37]!==j||e[38]!==u?(L=s.jsxs("div",{className:j,children:[u,w]}),e[36]=w,e[37]=j,e[38]=u,e[39]=L):L=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Ke,{children:"Cancel"}),e[40]=O):O=e[40];const R=m.length===0,g=m.length>0&&`(${m.length})`;let A;e[41]!==N||e[42]!==R||e[43]!==g?(A=s.jsxs(Fe,{className:"px-6 pb-6",children:[O,s.jsxs(Qe,{onClick:N,disabled:R,children:["Add ",g]})]}),e[41]=N,e[42]=R,e[43]=g,e[44]=A):A=e[44];let S;e[45]!==T||e[46]!==L||e[47]!==A||e[48]!==y||e[49]!==v?(S=s.jsxs(T,{className:y,children:[v,L,A]}),e[45]=T,e[46]=L,e[47]=A,e[48]=y,e[49]=v,e[50]=S):S=e[50];let C;return e[51]!==h||e[52]!==S||e[53]!==P||e[54]!==I?(C=s.jsx(h,{open:P,onOpenChange:I,children:S}),e[51]=h,e[52]=S,e[53]=P,e[54]=I,e[55]=C):C=e[55],C}function rn(t){return t.role!=="owner"}function on(t){const e=re.c(40),{memberIds:n,onMemberIdsChange:r,readOnly:l}=t,o=l===void 0?!1:l,[d,i]=D.useState(""),f=D.useDeferredValue(d),[x,m]=D.useState(!1),{data:b}=bt();let a,T,h,N,p;if(e[0]!==b?.data?.members||e[1]!==f||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==d){const y=b?.data?.members??[];let v;e[11]!==n?(v=S=>n.includes(S.id),e[11]=n,e[12]=v):v=e[12];const P=y.filter(v);let I;e[13]!==f?(I=S=>{const C=f.toLowerCase();return S.user?.name?.toLowerCase().includes(C)||S.user?.email?.toLowerCase().includes(C)},e[13]=f,e[14]=I):I=e[14];const w=P.filter(I);let L;e[15]!==n||e[16]!==r?(L=S=>{r(n.filter(C=>C!==S))},e[15]=n,e[16]=r,e[17]=L):L=e[17];const O=L;let R;e[18]!==n||e[19]!==r?(R=S=>{r([...n,...S])},e[18]=n,e[19]=r,e[20]=R):R=e[20],a=R,N="flex flex-col h-full";let g;e[21]!==d?(g=s.jsx(De,{value:d,onChange:i,placeholder:"Search members...",className:"flex-1 border-b-0"}),e[21]=d,e[22]=g):g=e[22];let A;e[23]!==o?(A=o?s.jsx("div",{className:"pr-4",children:s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(rt,{size:16}),"Add Member"]})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})})}):s.jsx("div",{className:"pr-4",children:s.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[s.jsx(rt,{size:16}),"Add Member"]})}),e[23]=o,e[24]=A):A=e[24],e[25]!==g||e[26]!==A?(p=s.jsxs("div",{className:"flex items-center border-b border-border",children:[g,A]}),e[25]=g,e[26]=A,e[27]=p):p=e[27],T="flex-1 overflow-auto",h=P.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No members"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Add members to this role to grant them the configured permissions."})]})}):w.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("p",{className:"text-sm text-muted-foreground",children:['No members match "',d,'"']})}):s.jsx("div",{className:"p-4 space-y-2",children:w.map(S=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(Pe,{url:S.user?.image??void 0,fallback:Jt(S.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:S.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:S.user?.email})]}),o?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ie,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(Ot,{size:16})})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>O(S.id),children:s.jsx(Ot,{size:16})})]},S.id))}),e[0]=b?.data?.members,e[1]=f,e[2]=n,e[3]=r,e[4]=o,e[5]=d,e[6]=a,e[7]=T,e[8]=h,e[9]=N,e[10]=p}else a=e[6],T=e[7],h=e[8],N=e[9],p=e[10];let E;e[28]!==T||e[29]!==h?(E=s.jsx("div",{className:T,children:h}),e[28]=T,e[29]=h,e[30]=E):E=e[30];let j;e[31]!==x||e[32]!==a||e[33]!==n?(j=s.jsx(nn,{open:x,onOpenChange:m,selectedMemberIds:n,onAddMembers:a}),e[31]=x,e[32]=a,e[33]=n,e[34]=j):j=e[34];let u;return e[35]!==N||e[36]!==p||e[37]!==E||e[38]!==j?(u=s.jsxs("div",{className:N,children:[p,E,j]}),e[35]=N,e[36]=p,e[37]=E,e[38]=j,e[39]=u):u=e[39],u}function ln(t){const e=re.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(qe,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let r;return e[1]!==t?(r=s.jsx(D.Suspense,{fallback:n,children:s.jsx(on,{...t})}),e[1]=t,e[2]=r):r=e[2],r}const an={owner:[],admin:[],user:[]};function tt(t,e){const n=t==="owner"||t==="admin",r=e.filter(l=>l.role===t);return{role:{slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:n,staticPermissions:an[t],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:r.map(l=>l.id)}}function cn({trigger:t,onSuccess:e}){const[n,r]=D.useState(!1),[l,o]=D.useState("mcp"),{locator:d}=je(),i=Me(),f=Vt()??[],{customRoles:x,refetch:m}=Nt(),{data:b}=it({queryKey:ue.members(d),queryFn:()=>me.organization.listMembers()}),a=zt({resolver:Wt(Gs),defaultValues:et()}),T=a.formState.isValid,h=a.formState.isDirty,[N,p]=D.useState(null),[E,j]=D.useState(null),u=!a.watch("role.id")&&!a.watch("role.slug")&&!E,[y,v]=D.useState(null),[P,I]=D.useState(!1),[w,L]=D.useState(null),O=c=>{const _=c.permission||{},V=_.self||[],fe=V.includes("*"),J=fe?[]:V.filter(G=>G!=="*"),Y={};for(const[G,se]of Object.entries(_))if(!(G==="self"||G==="models"))if(G==="*")for(const ne of f)se.includes("*")?Y[ne.id]=ne.tools?.map(ae=>ae.name)??[]:Y[ne.id]=se;else{const ne=f.find(ae=>ae.id===G);ne&&(se.includes("*")?Y[G]=ne.tools?.map(ae=>ae.name)??[]:Y[G]=se)}const H=_.models||[],he=H.length===0||H.includes("*:*"),Z={};if(!he)for(const G of H){const se=G.indexOf(":");if(se===-1)continue;const ne=G.slice(0,se),ae=G.slice(se+1);Z[ne]||(Z[ne]=[]),Z[ne].push(ae)}const ce=(b?.data?.members??[]).filter(G=>G.role===c.role).map(G=>G.id);return{role:{id:c.id,slug:c.role,label:c.label},allowAllStaticPermissions:fe,staticPermissions:J,toolSet:Y,allowAllModels:he,modelSet:Z,memberIds:ce}},R=c=>{const _=O(c);a.reset(_),p(c.id??null),j(null)},g=()=>{a.reset(et()),p(null),j(null),o("mcp")},A=c=>{h&&T?(L(()=>()=>R(c)),I(!0)):R(c)},S=async()=>{h&&T&&await ee(),g()},C=c=>{if(h&&T)L(()=>()=>{const _=tt(c,b?.data?.members??[]);a.reset(_),j(c),p(null),o("org")}),I(!0);else{const _=tt(c,b?.data?.members??[]);a.reset(_),j(c),p(null),o("org")}},M=c=>{if(!c&&a.formState.isDirty&&T){L(()=>()=>{r(!1),a.reset(et()),j(null)}),I(!0);return}if(r(c),!c)a.reset(et()),j(null),p(null);else{const _=x[0];if(_)R(_);else{const V=tt("user",b?.data?.members??[]);a.reset(V),j("user"),p(null),o("org")}}},z=()=>{I(!1),w&&(w(),L(null))},B=c=>{const _={};c.allowAllStaticPermissions?_.self=["*"]:c.staticPermissions.length>0&&(_.self=c.staticPermissions);for(const[V,fe]of Object.entries(c.toolSet))if(fe.length>0){const Y=f.find(H=>H.id===V)?.tools?.map(H=>H.name)??[];Y.length>0&&Y.every(H=>fe.includes(H))?_[V]=["*"]:_[V]=fe}if(c.allowAllModels)_.models=["*:*"];else{const V=[];for(const[fe,J]of Object.entries(c.modelSet))if(J.length>0)for(const Y of J)V.push(`${fe}:${Y}`);_.models=V}return _},K=Ne({mutationFn:async c=>{const _=B(c),V=c.role.slug||c.role.label.toLowerCase().replace(/\s+/g,"-");if(c.role.slug&&!c.role.id){const Y=(b?.data?.members??[]).filter(Z=>Z.role===c.role.slug).map(Z=>Z.id),H=c.memberIds.filter(Z=>!Y.includes(Z)),he=Y.filter(Z=>!c.memberIds.includes(Z));for(const Z of H){const Q=await me.organization.updateMemberRole({memberId:Z,role:[c.role.slug]});if(Q?.error)throw new Error(Q.error.message)}for(const Z of he){const Q=await me.organization.updateMemberRole({memberId:Z,role:["user"]});if(Q?.error)throw new Error(Q.error.message)}return c}else if(c.role.id){const J=await me.organization.updateRole({roleId:c.role.id,data:{permission:_}});if(J?.error)throw new Error(J.error.message);const H=(b?.data?.members??[]).filter(Q=>Q.role===c.role.slug).map(Q=>Q.id),he=c.memberIds.filter(Q=>!H.includes(Q)),Z=H.filter(Q=>!c.memberIds.includes(Q));for(const Q of he){const ce=await me.organization.updateMemberRole({memberId:Q,role:[c.role.slug]});if(ce?.error)throw new Error(ce.error.message)}for(const Q of Z){const ce=await me.organization.updateMemberRole({memberId:Q,role:["user"]});if(ce?.error)throw new Error(ce.error.message)}return c}else{const J=await me.organization.createRole({role:V,permission:_});if(J?.error)throw new Error(J.error.message);for(const Y of c.memberIds){const H=await me.organization.updateMemberRole({memberId:Y,role:[V]});if(H?.error)throw new Error(H.error.message)}return{...c,role:{...c.role,id:J.data?.roleData?.id,slug:V}}}},onSuccess:(c,_)=>{i.invalidateQueries({queryKey:ue.members(d)}),i.invalidateQueries({queryKey:ue.organizationRoles(d)});const V=!_.role.id&&!_.role.slug,fe=_.role.slug&&!_.role.id;le.success(fe?"Members updated successfully!":V?"Role created successfully!":"Role updated successfully!"),m(),a.reset(c),c.role.id&&p(c.role.id),e?.()},onError:c=>{le.error(c instanceof Error?c.message:"Failed to save role")}}),X=Ne({mutationFn:async c=>{const _=await me.organization.deleteRole({roleId:c});if(_?.error)throw new Error(_.error.message);return _?.data},onSuccess:()=>{if(i.invalidateQueries({queryKey:ue.members(d)}),i.invalidateQueries({queryKey:ue.organizationRoles(d)}),le.success("Role deleted successfully!"),m(),y?.id===N){const c=x.filter(_=>_.id!==y?.id);if(c[0])R(c[0]);else{const _=tt("user",b?.data?.members??[]);a.reset(_),j("user"),p(null),o("org")}}},onError:c=>{le.error(c instanceof Error?c.message:"Failed to delete role")}}),W=K.isPending||X.isPending,ee=async()=>{const c=a.getValues();if(!c.role.label.trim()){le.error("Role name is required"),a.setFocus("role.label");return}await K.mutateAsync(c)},oe=a.handleSubmit(c=>{if(!c.role.label.trim()){le.error("Role name is required"),a.setFocus("role.label");return}K.mutate(c)}),te=c=>{c.id&&v({id:c.id,label:c.label})},U=()=>{y?.id&&X.mutate(y.id),v(null)};return s.jsxs(Bt,{open:n,onOpenChange:M,children:[s.jsx(Gt,{asChild:!0,children:t}),s.jsx($t,{className:"sm:max-w-5xl h-[80vh] max-h-[80vh] flex flex-col p-0 overflow-hidden w-[95vw]",children:s.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 flex-col sm:flex-row",children:[s.jsxs("div",{className:"w-full sm:w-64 sm:border-r border-b sm:border-b-0 border-border flex flex-col bg-background sm:h-full max-h-[40vh] sm:max-h-full",children:[s.jsx("div",{className:"flex-1 overflow-auto px-3.5 py-3.5 pt-3.5",children:s.jsxs("div",{className:"flex flex-col gap-1",children:[$s.map(c=>{const _=E===c.role;return s.jsxs("div",{className:q("flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden cursor-pointer transition-colors",_?"bg-accent":"hover:bg-muted/50"),onClick:()=>C(c.role),children:[s.jsx("div",{className:q("shrink-0 size-3 rounded-full",c.color)}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:c.label}),s.jsx(Ts,{size:14,className:"text-muted-foreground shrink-0"})]},c.role)}),x.map(c=>{const _=N===c.id;return s.jsxs("div",{className:q("group flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden transition-colors cursor-pointer",_?"bg-accent":"hover:bg-muted/50"),onClick:()=>A(c),children:[s.jsx("div",{className:q("shrink-0 size-3 rounded-full",Fs(c.label))}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:c.label}),s.jsxs(Ct,{children:[s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"icon",className:q("size-5 shrink-0 transition-opacity opacity-0 pointer-events-none","group-hover:opacity-100 group-hover:pointer-events-auto",_&&"opacity-100 pointer-events-auto"),onClick:V=>V.stopPropagation(),children:s.jsx(js,{size:14})})}),s.jsx(Tt,{align:"end",children:s.jsxs(nt,{className:"text-destructive",onClick:V=>{V.stopPropagation(),te(c)},children:[s.jsx(Ft,{size:16}),"Delete"]})})]})]},c.id)}),u&&s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden bg-accent",children:[s.jsx("div",{className:"shrink-0 size-3 rounded-full bg-neutral-400"}),s.jsx(vs,{...a.register("role.label"),placeholder:"Enter role name",className:"flex-1 text-sm font-medium border-0 shadow-none h-auto px-0 py-0 focus-visible:ring-0 bg-transparent",autoFocus:!0}),s.jsx(we,{variant:"secondary",className:"shrink-0 text-xs px-1.5 py-0",children:"New"})]})]})}),s.jsx("div",{className:"px-3.5 pb-3.5",children:s.jsxs(ie,{variant:"outline",size:"default",onClick:S,disabled:W||h,className:"w-full h-10",children:[s.jsx(rt,{size:16}),"Create new role"]})})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.jsxs("div",{className:"h-12 border-b border-border px-4 py-3.5 flex items-center gap-2 shrink-0",children:[!E&&s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("mcp"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="mcp"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"MCP Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("org"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="org"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Organization Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("models"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="models"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Models"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("members"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="members"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Members"})]}),s.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[l==="mcp"&&!E&&s.jsx(ks,{toolSet:a.watch("toolSet"),onToolSetChange:c=>a.setValue("toolSet",c,{shouldDirty:!0})}),l==="org"&&s.jsx(Ks,{allowAllStaticPermissions:a.watch("allowAllStaticPermissions"),staticPermissions:a.watch("staticPermissions"),onAllowAllChange:c=>a.setValue("allowAllStaticPermissions",c,{shouldDirty:!0}),onPermissionsChange:c=>a.setValue("staticPermissions",c,{shouldDirty:!0}),readOnly:!!E}),l==="models"&&s.jsx(en,{allowAllModels:a.watch("allowAllModels"),modelSet:a.watch("modelSet"),onAllowAllChange:c=>a.setValue("allowAllModels",c,{shouldDirty:!0}),onModelSetChange:c=>a.setValue("modelSet",c,{shouldDirty:!0}),readOnly:!!E}),l==="members"&&s.jsx(ln,{memberIds:a.watch("memberIds"),onMemberIdsChange:c=>a.setValue("memberIds",c,{shouldDirty:!0}),readOnly:E==="owner"})]}),(!E||E!=="owner")&&s.jsxs("div",{className:"border-t border-border px-5 py-5 flex items-center justify-end gap-2.5 shrink-0",children:[s.jsx(ie,{variant:"outline",onClick:()=>M(!1),disabled:W,className:"h-10",children:"Cancel"}),s.jsx(ie,{onClick:oe,disabled:W||!T||!a.formState.isDirty,className:"h-10",children:K.isPending?"Saving...":u?"Create Role":"Save Changes"})]})]})]})}),s.jsx(Ue,{open:y!==null,onOpenChange:c=>!c&&v(null),children:s.jsxs(Ve,{children:[s.jsxs(Be,{children:[s.jsx(Ge,{children:"Delete Role"}),s.jsxs($e,{children:['Are you sure you want to delete the "',y?.label,'" role? This action cannot be undone.']})]}),s.jsxs(Fe,{children:[s.jsx(Ke,{children:"Cancel"}),s.jsx(Qe,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s.jsx(Ue,{open:P,onOpenChange:I,children:s.jsxs(Ve,{children:[s.jsxs(Be,{children:[s.jsx(Ge,{children:"Discard Changes"}),s.jsx($e,{children:"You have unsaved changes. Are you sure you want to discard them?"})]}),s.jsxs(Fe,{children:[s.jsx(Ke,{onClick:()=>L(null),children:"Keep Editing"}),s.jsx(Qe,{onClick:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Discard"})]})]})})]})}const dn=Ce().email("Invalid email address");function mn(t){if(!t.trim())return[];const e=t.split(/[,;\n]/).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(e))}function un({trigger:t}){const[e,n]=D.useState(!1),{locator:r}=je(),l=Me(),{data:o}=me.useSession(),d=o?.user?.email,{roles:i,isLoading:f}=Nt(),x=i.filter(j=>j.role!=="owner"),m=zt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),b=m.watch("emailsText"),a=m.watch("role"),h=mn(b).filter(j=>{const u=dn.safeParse(j).success,y=!d||j!==d.toLowerCase();return u&&y}),N=Ne({mutationFn:async({emails:j,role:u})=>{if(!u)throw new Error("Please select a role");const y=await Promise.allSettled(j.map(async P=>{const I=await me.organization.inviteMember({email:P,role:u});if(I.error)throw new Error(I.error.message);return I.data})),v=y.filter(P=>P.status==="rejected");if(v.length>0)throw new Error(`Failed to invite ${v.length} member${v.length>1?"s":""}`);return y},onSuccess:(j,{emails:u})=>{l.invalidateQueries({queryKey:ue.members(r)}),l.invalidateQueries({queryKey:ue.invitations(r)}),le.success(u.length===1?"Member invited successfully!":`${u.length} members invited successfully!`),m.reset({emailsText:"",role:"user"}),n(!1)},onError:j=>{le.error(j instanceof Error?j.message:"Failed to invite members")}}),p=j=>{if(h.length===0){le.error("Please enter at least one valid email address");return}if(!j.role){le.error("Please select a role");return}N.mutate({emails:h,role:j.role})},E=h.length>0&&!!a;return s.jsxs(Bt,{open:e,onOpenChange:n,children:[s.jsx(Gt,{asChild:!0,children:t}),s.jsxs($t,{className:"sm:max-w-lg",children:[s.jsx(fs,{children:s.jsx(hs,{children:"Invite members"})}),s.jsx(Es,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(p),className:"space-y-4",children:[s.jsx(wt,{control:m.control,name:"emailsText",render:({field:j})=>s.jsxs(At,{children:[s.jsx(ys,{children:"Email addresses"}),s.jsx(_t,{children:s.jsx(Ss,{...j,disabled:N.isPending,placeholder:`Enter email addresses separated by commas or new lines
|
|
1
|
+
import{r as D,c as re,j as s,p as Xt,u as je,g as me,K as ue,o as Et,aj as We,s as Ce,b9 as yt,bf as St,z as Me,k as zt,h as Wt,t as le,y as es}from"./index-BKpxPW_G.js";import{C as ts,a as ss}from"./collection-table-wrapper-DFTdnQhc.js";import{C as De}from"./collection-search-Bkd4qN8a.js";import{P as Ee}from"./index-B9-4goiW.js";import{B as ns,a as rs,b as os,c as is}from"./breadcrumb-ChH6wfcA.js";import{I as Ut,c as ye,b as Se,T as Ie,a as Oe}from"./integration-icon-DFSc5_D8.js";import{C as ze}from"./checkbox-C1Sx9y02.js";import{B as ie}from"./button-D_OpQIQm.js";import{c as q}from"./utils-Ckp7rFN8.js";import{h as Vt}from"./use-connection-B0740Saa.js";import{u as bt,C as ct,a as dt,b as It,c as ls,d as as,e as cs,f as ds}from"./command-B5nNM5RC.js";import{u as it}from"./useQuery-Bo6lCSyK.js";import{u as Ne}from"./useMutation-Bnsod7M-.js";import{u as ms,a as us}from"./use-llm-D28vq8-j.js";import{A as Pe}from"./avatar-kY9raA-l.js";import{B as we}from"./badge-DBw6AEaX.js";import{f as Ue,a as Ve,b as Be,c as Ge,d as $e,e as Fe,A as Ke,g as Qe}from"./alert-dialog-DRso9X1m.js";import{D as Bt,f as Gt,a as $t,b as fs,c as hs,e as gs}from"./dialog-BPL7ZvPc.js";import{D as Ct,a as jt,b as Tt,c as nt,d as xs,e as ps,f as bs,g as Cs}from"./dropdown-menu-BxLN4KkF.js";import{i as js}from"./DotsHorizontal-LbVwX-Tq.js";import{i as qe}from"./Loading01-C2vqzEw-.js";import{i as Ts}from"./Lock01-ClMI2bMm.js";import{s as rt}from"./Plus-BMOTPGqH.js";import{s as Ft}from"./Trash01-d4v7i3Ze.js";import{i as Ot}from"./X-CslJd5Ib.js";import{I as vs}from"./input-lpAGMNlp.js";import{S as ve}from"./switch-sdaV-SJo.js";import{E as mt}from"./empty-state-DXJM9xrV.js";import{E as Ns}from"./error-boundary-BMH0CjEH.js";import{a as Es,F as wt,b as At,c as ys,d as _t,f as Lt}from"./form-BpiblhO1.js";import{S as ft,a as ht,b as gt,c as xt,d as pt}from"./select-BbzYJ4VF.js";import{T as Ss}from"./textarea-BRJpMcB0.js";import{a as He,u as Ze}from"./constants-DisdEZ3l.js";import{C as Rt}from"./card-DAZxrY9k.js";import{i as Kt}from"./DotsVertical-BNqPYTki.js";import{i as Is}from"./index-CnNzyZrg.js";import{s as Qt}from"./XClose-CjpNuP8c.js";import{a as Os,b as ws,P as As}from"./popover-ESVk6nXT.js";import{t as _s}from"./ChevronDown-DY4fpd0G.js";import"./ArrowUp-D26ZQKRa.js";import"./Check-bgVFNRDs.js";import"./Grid01-CfSiTcO8.js";import"./List-BBkbo-oe.js";import"./view-mode-toggle-4jMhv4Z3.js";import"./table-BxUix49E.js";import"./SearchMd-BqVXNd65.js";import"./ChevronRight-DMzFQQCc.js";import"./index-fVGDVKMq.js";import"./use-binding-DMsO_03X.js";import"./binder-Jddq1y1v.js";import"./label-h0it3r-G.js";const qt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M19 12H5m0 0 7 7m-7-7 7-7"}));qt.displayName="ArrowLeft";const vt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M11.302 21.615c.221.129.332.194.488.227.122.026.298.026.42 0 .156-.034.267-.098.488-.227C14.646 20.478 20 16.908 20 12V7.217c0-.799 0-1.199-.13-1.542a2 2 0 0 0-.548-.79c-.275-.243-.65-.383-1.398-.664l-5.362-2.01c-.208-.078-.312-.117-.419-.133a1 1 0 0 0-.286 0c-.107.016-.21.055-.419.133L6.076 4.22c-.748.28-1.122.421-1.398.664a2 2 0 0 0-.547.79C4 6.018 4 6.418 4 7.217V12c0 4.908 5.354 8.478 7.302 9.615Z"}));vt.displayName="Shield01";const Ht=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M20 17H4m0 0 4-4m-4 4 4 4M4 7h16m0 0-4-4m4 4-4 4"}));Ht.displayName="SwitchHorizontal01";const Zt=[{name:"ORGANIZATION_CREATE",description:"Create a new organization",category:"Organizations"},{name:"ORGANIZATION_LIST",description:"List organizations",category:"Organizations"},{name:"ORGANIZATION_GET",description:"View organization details",category:"Organizations"},{name:"ORGANIZATION_UPDATE",description:"Update organization",category:"Organizations"},{name:"ORGANIZATION_DELETE",description:"Delete organization",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_SETTINGS_GET",description:"View organization settings",category:"Organizations"},{name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization settings",category:"Organizations"},{name:"ORGANIZATION_MEMBER_ADD",description:"Add members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove members",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_MEMBER_LIST",description:"List members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update member roles",category:"Organizations"},{name:"COLLECTION_CONNECTIONS_CREATE",description:"Create connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_LIST",description:"List connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_GET",description:"View connection details",category:"Connections"},{name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete connections",category:"Connections",dangerous:!0},{name:"CONNECTION_TEST",description:"Test connections",category:"Connections"},{name:"DATABASES_RUN_SQL",description:"Run SQL queries",category:"Connections",dangerous:!0},{name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_GET",description:"View virtual MCP details",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete virtual MCPs",category:"Virtual MCPs",dangerous:!0},{name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create virtual tools on Virtual MCPs",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List virtual tools",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"View virtual tool details",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update virtual tools",category:"Virtual Tools"},{name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete virtual tools",category:"Virtual Tools",dangerous:!0},{name:"MONITORING_LOGS_LIST",description:"List monitoring logs",category:"Monitoring"},{name:"MONITORING_STATS",description:"View monitoring statistics",category:"Monitoring"},{name:"API_KEY_CREATE",description:"Create API key",category:"API Keys"},{name:"API_KEY_LIST",description:"List API keys",category:"API Keys"},{name:"API_KEY_UPDATE",description:"Update API key",category:"API Keys"},{name:"API_KEY_DELETE",description:"Delete API key",category:"API Keys",dangerous:!0},{name:"EVENT_PUBLISH",description:"Publish events",category:"Event Bus"},{name:"EVENT_SUBSCRIBE",description:"Subscribe to events",category:"Event Bus"},{name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events",category:"Event Bus"},{name:"EVENT_CANCEL",description:"Cancel recurring events",category:"Event Bus"},{name:"EVENT_ACK",description:"Acknowledge event delivery",category:"Event Bus"},{name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions",category:"Event Bus"},{name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state",category:"Event Bus"},{name:"USER_GET",description:"Get a user by id",category:"Users"},{name:"CODE_EXECUTION_SEARCH_TOOLS",description:"Search available tools by name or description",category:"Code Execution"},{name:"CODE_EXECUTION_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools",category:"Code Execution"},{name:"CODE_EXECUTION_RUN_CODE",description:"Run JavaScript code in a sandbox with tool access",category:"Code Execution",dangerous:!0},{name:"COLLECTION_THREADS_CREATE",description:"Create threads",category:"Threads"},{name:"COLLECTION_THREADS_LIST",description:"List threads",category:"Threads"},{name:"COLLECTION_THREADS_GET",description:"View thread details",category:"Threads"},{name:"COLLECTION_THREADS_UPDATE",description:"Update threads",category:"Threads"},{name:"COLLECTION_THREADS_DELETE",description:"Delete threads",category:"Threads",dangerous:!0},{name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List thread messages",category:"Threads"},{name:"TAGS_LIST",description:"List organization tags",category:"Tags"},{name:"TAGS_CREATE",description:"Create organization tag",category:"Tags"},{name:"TAGS_DELETE",description:"Delete organization tag",category:"Tags",dangerous:!0},{name:"MEMBER_TAGS_GET",description:"Get member tags",category:"Tags"},{name:"MEMBER_TAGS_SET",description:"Set member tags",category:"Tags"},{name:"PROJECT_LIST",description:"List projects in organization",category:"Projects"},{name:"PROJECT_GET",description:"View project details",category:"Projects"},{name:"PROJECT_CREATE",description:"Create new project",category:"Projects"},{name:"PROJECT_UPDATE",description:"Update project",category:"Projects"},{name:"PROJECT_DELETE",description:"Delete project",category:"Projects",dangerous:!0},{name:"PROJECT_PLUGIN_CONFIG_GET",description:"View project plugin configuration",category:"Projects"},{name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update project plugin configuration",category:"Projects"}],Ls={ORGANIZATION_CREATE:"Create organization",ORGANIZATION_LIST:"List organizations",ORGANIZATION_GET:"View organization details",ORGANIZATION_UPDATE:"Update organization",ORGANIZATION_DELETE:"Delete organization",ORGANIZATION_SETTINGS_GET:"View organization settings",ORGANIZATION_SETTINGS_UPDATE:"Update organization settings",ORGANIZATION_MEMBER_LIST:"List members",ORGANIZATION_MEMBER_ADD:"Add members",ORGANIZATION_MEMBER_REMOVE:"Remove members",ORGANIZATION_MEMBER_UPDATE_ROLE:"Update member roles",COLLECTION_CONNECTIONS_LIST:"List connections",COLLECTION_CONNECTIONS_GET:"View connection details",COLLECTION_CONNECTIONS_CREATE:"Create connections",COLLECTION_CONNECTIONS_UPDATE:"Update connections",COLLECTION_CONNECTIONS_DELETE:"Delete connections",CONNECTION_TEST:"Test connections",DATABASES_RUN_SQL:"Run SQL queries",COLLECTION_VIRTUAL_MCP_CREATE:"Create virtual MCPs",COLLECTION_VIRTUAL_MCP_LIST:"List virtual MCPs",COLLECTION_VIRTUAL_MCP_GET:"View virtual MCP details",COLLECTION_VIRTUAL_MCP_UPDATE:"Update virtual MCPs",COLLECTION_VIRTUAL_MCP_DELETE:"Delete virtual MCPs",COLLECTION_VIRTUAL_TOOLS_CREATE:"Create virtual tools",COLLECTION_VIRTUAL_TOOLS_LIST:"List virtual tools",COLLECTION_VIRTUAL_TOOLS_GET:"View virtual tool details",COLLECTION_VIRTUAL_TOOLS_UPDATE:"Update virtual tools",COLLECTION_VIRTUAL_TOOLS_DELETE:"Delete virtual tools",MONITORING_LOGS_LIST:"List monitoring logs",MONITORING_STATS:"View monitoring statistics",API_KEY_CREATE:"Create API key",API_KEY_LIST:"List API keys",API_KEY_UPDATE:"Update API key",API_KEY_DELETE:"Delete API key",EVENT_PUBLISH:"Publish events",EVENT_SUBSCRIBE:"Subscribe to events",EVENT_UNSUBSCRIBE:"Unsubscribe from events",EVENT_CANCEL:"Cancel recurring events",EVENT_ACK:"Acknowledge event delivery",EVENT_SUBSCRIPTION_LIST:"List event subscriptions",EVENT_SYNC_SUBSCRIPTIONS:"Sync subscriptions to desired state",USER_GET:"Get user by id",CODE_EXECUTION_SEARCH_TOOLS:"Search tools",CODE_EXECUTION_DESCRIBE_TOOLS:"Describe tools",CODE_EXECUTION_RUN_CODE:"Run code",COLLECTION_THREADS_CREATE:"Create threads",COLLECTION_THREADS_LIST:"List threads",COLLECTION_THREADS_GET:"View thread details",COLLECTION_THREADS_UPDATE:"Update threads",COLLECTION_THREADS_DELETE:"Delete threads",COLLECTION_THREAD_MESSAGES_LIST:"List thread messages",TAGS_LIST:"List organization tags",TAGS_CREATE:"Create organization tag",TAGS_DELETE:"Delete organization tag",MEMBER_TAGS_GET:"Get member tags",MEMBER_TAGS_SET:"Set member tags",PROJECT_LIST:"List projects",PROJECT_GET:"View project details",PROJECT_CREATE:"Create project",PROJECT_UPDATE:"Update project",PROJECT_DELETE:"Delete project",PROJECT_PLUGIN_CONFIG_GET:"View plugin config",PROJECT_PLUGIN_CONFIG_UPDATE:"Update plugin config"};function Rs(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],"Virtual Tools":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],"Code Execution":[],Tags:[],Projects:[]};for(const e of Zt)t[e.category]?.push(e);return t}function Ps(){return Zt.map(t=>({value:t.name,label:Ls[t.name],dangerous:t.dangerous}))}const Ms=D.memo(function(e){const n=re.c(21),{connection:r,isSelected:l,hasToolsEnabled:o,activeToolsCount:d,totalToolsCount:i,onSelect:f,onToggle:x}=e,m=l?"bg-accent/50":"hover:bg-muted/50";let b;n[0]!==m?(b=q("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",m),n[0]=m,n[1]=b):b=n[1];let a;n[2]!==r.icon||n[3]!==r.title?(a=s.jsx(Ut,{icon:r.icon,name:r.title,size:"xs"}),n[2]=r.icon,n[3]=r.title,n[4]=a):a=n[4];let T;n[5]!==r.title?(T=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:r.title})}),n[5]=r.title,n[6]=T):T=n[6];let h;n[7]!==f||n[8]!==a||n[9]!==T?(h=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:f,children:[a,T]}),n[7]=f,n[8]=a,n[9]=T,n[10]=h):h=n[10];let N;n[11]!==d||n[12]!==r.tools||n[13]!==o||n[14]!==x||n[15]!==i?(N=r.tools&&r.tools.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[d,"/",i]}),s.jsx(ze,{checked:o,onCheckedChange:x,onClick:zs})]}),n[11]=d,n[12]=r.tools,n[13]=o,n[14]=x,n[15]=i,n[16]=N):N=n[16];let p;return n[17]!==b||n[18]!==h||n[19]!==N?(p=s.jsxs("div",{className:b,children:[h,N]}),n[17]=b,n[18]=h,n[19]=N,n[20]=p):p=n[20],p}),Ds=D.memo(function(e){const n=re.c(18),{connectionId:r,tool:l,isSelected:o,onToggle:d}=e,i=`tool-${r}-${l.name}`,f=o?"text-foreground":"text-muted-foreground";let x;n[0]!==f?(x=q("text-sm font-medium",f),n[0]=f,n[1]=x):x=n[1];let m;n[2]!==x||n[3]!==l.name?(m=s.jsx("div",{className:"flex items-center gap-2 mb-1",children:s.jsx("span",{className:x,children:l.name})}),n[2]=x,n[3]=l.name,n[4]=m):m=n[4];let b;n[5]!==l.description?(b=l.description&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l.description}),n[5]=l.description,n[6]=b):b=n[6];let a;n[7]!==m||n[8]!==b?(a=s.jsxs("div",{className:"flex-1 min-w-0",children:[m,b]}),n[7]=m,n[8]=b,n[9]=a):a=n[9];const T=`tool-${r}-${l.name}`;let h;n[10]!==o||n[11]!==d||n[12]!==T?(h=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(ze,{id:T,checked:o,onCheckedChange:d,onClick:Us})}),n[10]=o,n[11]=d,n[12]=T,n[13]=h):h=n[13];let N;return n[14]!==i||n[15]!==a||n[16]!==h?(N=s.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:i,children:[a,h]}),n[14]=i,n[15]=a,n[16]=h,n[17]=N):N=n[17],N});function ks({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n}){const[r,l]=D.useState(""),o=D.useDeferredValue(r),[d,i]=D.useState("all"),[f,x]=D.useState(!1),m=D.useRef(new Set(Object.keys(t))),b=Vt({searchTerm:o.trim()||void 0}),a=n?b.filter(g=>g.connection_type!=="VIRTUAL"?!0:Xt(g.connection_url)!==n):b,T=m.current,h=[...T.values()].map(g=>a.find(A=>A.id===g)).filter(g=>g!==void 0),N=a.filter(g=>!T.has(g.id)),p=[...h,...N],E=g=>{const A=t[g];return A!==void 0&&A.length>0},j=p.filter(g=>{if(d==="all")return!0;const A=E(g.id);return d==="selected"?A:d==="unselected"?!A:!0}),[u,y]=D.useState(p[0]?.id??null),v=u?p.find(g=>g.id===u)??null:null,P=v?.tools??[],I=(g,A)=>t[g]?.includes(A)??!1,w=(g,A)=>{const S=t[g]??[],C=S.includes(A),M={...t};if(C){const z=S.filter(B=>B!==A);z.length===0?delete M[g]:M[g]=z}else M[g]=[...S,A];e(M)},L=g=>{const A=p.find(B=>B.id===g);if(!A?.tools)return;const S=t[g]??[],C=A.tools.map(B=>B.name),M=S.length>0&&C.every(B=>S.includes(B)),z={...t};M?delete z[g]:(z[g]=C,y(g)),e(z)},O=g=>{y(g),x(!0)},R=()=>{x(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:q("w-full md:w-80 border-r border-border flex flex-col",f&&"hidden md:flex"),children:[s.jsx(De,{value:r,onChange:l,placeholder:"Search MCP Servers..."}),s.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[s.jsx("button",{onClick:()=>i("all"),className:q("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),s.jsx("button",{onClick:()=>i("selected"),className:q("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),s.jsx("button",{onClick:()=>i("unselected"),className:q("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:j.length===0?s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:r?"No connections found":d==="selected"?"No servers selected":d==="unselected"?"No unselected servers":"No connections available"}):s.jsx("div",{className:"p-2 space-y-1",children:j.map(g=>{const A=g.tools?.length??0,S=t[g.id]?.length??0;return s.jsx(Ms,{connection:g,isSelected:u===g.id,hasToolsEnabled:E(g.id),activeToolsCount:S,totalToolsCount:A,onSelect:()=>O(g.id),onToggle:()=>L(g.id)},g.id)})})})]}),s.jsx("div",{className:q("flex-1 flex-col",f?"flex":"hidden md:flex"),children:v?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[s.jsx(ie,{variant:"ghost",size:"sm",onClick:R,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(qt,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(Ut,{icon:v.icon,name:v.title,size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:v.title}),v.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:v.description})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:P.length===0?s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):s.jsx("div",{className:"space-y-2",children:P.map(g=>s.jsx(Ds,{connectionId:v.id,tool:g,isSelected:I(v.id,g.name),onToggle:()=>w(v.id,g.name)},g.name))})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function zs(t){return t.stopPropagation()}function Us(t){return t.stopPropagation()}const Pt=[{value:"owner",label:"Owner",isBuiltin:!0},{value:"admin",label:"Admin",isBuiltin:!0},{value:"user",label:"User",isBuiltin:!0}];function Vs(t){return t.replace(/-/g," ")}function Bs(t){if(!t)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1,modelCount:0,allowsAllModels:!1};const e=[];let n=!1;const r=[];let l=!1;const o=new Set;let d=!1,i=0,f=!1;for(const[x,m]of Object.entries(t)){if(x==="self"){m.includes("*")?n=!0:e.push(...m);continue}if(x==="models"){m.includes("*:*")?f=!0:i=m.length;continue}if(x==="*"){if(l=!0,m.includes("*"))d=!0;else for(const b of m)o.add(b);continue}if(r.push(x),m.includes("*"))d=!0;else for(const b of m)o.add(b)}return{staticPermissions:e,allowsAllStaticPermissions:n,connectionIds:r,allowsAllConnections:l,toolNames:Array.from(o),allowsAllTools:d,modelCount:i,allowsAllModels:f}}function Nt(){const{locator:t}=je(),{data:e,isLoading:n,error:r,refetch:l}=it({queryKey:ue.organizationRoles(t),queryFn:async()=>{try{const i=await me.organization.listRoles();return i?.error?(console.error("[useOrganizationRoles] API error:",i.error),[]):i?.data??[]}catch(i){return console.error("[useOrganizationRoles] Fetch error:",i),[]}},staleTime:3e4}),o=Pt.map(i=>({role:i.value,label:i.label,isBuiltin:i.isBuiltin}));if(e&&Array.isArray(e))for(const i of e){const f=i.role;if(!f||Pt.some(E=>E.value===f))continue;const{staticPermissions:x,allowsAllStaticPermissions:m,connectionIds:b,allowsAllConnections:a,toolNames:T,allowsAllTools:h,modelCount:N,allowsAllModels:p}=Bs(i.permission);o.push({id:i.id,role:f,label:Vs(f),isBuiltin:!1,permission:i.permission??void 0,staticPermissionCount:m?-1:x.length,allowsAllStaticPermissions:m,connectionCount:a?-1:b.length,allowsAllConnections:a,toolCount:h?-1:T.length,allowsAllTools:h,modelCount:p?-1:N,allowsAllModels:p})}const d=o.filter(i=>!i.isBuiltin);return{roles:o,customRoles:d,builtinRoles:o.filter(i=>i.isBuiltin),isLoading:n,error:r,refetch:l}}const Gs=Et({role:Et({id:Ce().optional(),slug:Ce().optional(),label:Ce()}),allowAllStaticPermissions:St(),staticPermissions:We(Ce()),toolSet:yt(Ce(),We(Ce())),allowAllModels:St(),modelSet:yt(Ce(),We(Ce())),memberIds:We(Ce())});function Jt(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}const $s=[{role:"owner",label:"Owner",color:"bg-red-500"},{role:"admin",label:"Admin",color:"bg-blue-500"},{role:"user",label:"User",color:"bg-green-500"}],ut=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"];function Fs(t){if(!t)return"bg-neutral-400";let e=0;for(let r=0;r<t.length;r++){const l=t.charCodeAt(r);e=(e<<5)-e+l,e=e&e}const n=Math.abs(e)%ut.length;return ut[n]??ut[0]}function et(){return{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:[]}}function Ks(t){const e=re.c(39),{allowAllStaticPermissions:n,staticPermissions:r,onAllowAllChange:l,onPermissionsChange:o,readOnly:d}=t,i=d===void 0?!1:d,[f,x]=D.useState(""),m=D.useDeferredValue(f);let b,a,T,h,N;if(e[0]!==n||e[1]!==m||e[2]!==l||e[3]!==o||e[4]!==i||e[5]!==f||e[6]!==r){const j=Rs(),u=Ps(),y=u.filter(R=>R.label.toLowerCase().includes(m.toLowerCase())),v=R=>{if(r.includes(R))o(r.filter(g=>g!==R));else{const g=[...r,R];g.length===u.length?(l(!0),o([])):o(g)}};T="flex flex-col h-full",e[12]!==f?(h=s.jsx("div",{className:"border-b border-border",children:s.jsx(De,{value:f,onChange:x,placeholder:"Search permissions...",className:"border-b-0"})}),e[12]=f,e[13]=h):h=e[13];const P=!i&&"hover:bg-muted/50 cursor-pointer";let I;e[14]!==P?(I=q("flex items-center justify-between px-4 py-3 rounded-lg",P),e[14]=P,e[15]=I):I=e[15];let w;e[16]!==n||e[17]!==l||e[18]!==o||e[19]!==i?(w=()=>{if(i)return;l(!n),o([])},e[16]=n,e[17]=l,e[18]=o,e[19]=i,e[20]=w):w=e[20];let L;e[21]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[21]=L):L=e[21];let O;e[22]!==n||e[23]!==l||e[24]!==o||e[25]!==i?(O=s.jsx("div",{onClick:Js,children:i?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:n,disabled:i,onCheckedChange:R=>{i||(l(R),o([]))}})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:n,disabled:i,onCheckedChange:R=>{i||(l(R),o([]))}})}),e[22]=n,e[23]=l,e[24]=o,e[25]=i,e[26]=O):O=e[26],e[27]!==O||e[28]!==I||e[29]!==w?(N=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:I,onClick:w,children:[L,O]})}),e[27]=O,e[28]=I,e[29]=w,e[30]=N):N=e[30],b="flex-1 overflow-auto",a=Object.entries(j).map(R=>{const[g,A]=R,S=y.filter(C=>A.some(M=>M.name===C.value));return S.length===0?null:s.jsxs("div",{className:"mb-6 last:mb-0",children:[s.jsx("h4",{className:"text-sm font-medium p-3 pb-1.5 text-muted-foreground/75",children:g}),s.jsx("div",{className:"space-y-1",children:S.map(C=>s.jsxs("div",{className:q("flex items-center justify-between gap-3 px-4 py-3",!i&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{if(!i)if(n){l(!1);const M=u.map(Zs);o(M.filter(z=>z!==C.value))}else v(C.value)},children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("span",{className:"text-sm",children:C.label})}),s.jsx("div",{onClick:Hs,children:i?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:n||r.includes(C.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const M=u.map(qs);o(M.filter(z=>z!==C.value))}else v(C.value)}})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:n||r.includes(C.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const M=u.map(Qs);o(M.filter(z=>z!==C.value))}else v(C.value)}})})]},C.value))})]},g)}),e[0]=n,e[1]=m,e[2]=l,e[3]=o,e[4]=i,e[5]=f,e[6]=r,e[7]=b,e[8]=a,e[9]=T,e[10]=h,e[11]=N}else b=e[7],a=e[8],T=e[9],h=e[10],N=e[11];let p;e[31]!==b||e[32]!==a?(p=s.jsx("div",{className:b,children:a}),e[31]=b,e[32]=a,e[33]=p):p=e[33];let E;return e[34]!==T||e[35]!==h||e[36]!==N||e[37]!==p?(E=s.jsxs("div",{className:T,children:[h,N,p]}),e[34]=T,e[35]=h,e[36]=N,e[37]=p,e[38]=E):E=e[38],E}function Qs(t){return t.value}function qs(t){return t.value}function Hs(t){return t.stopPropagation()}function Zs(t){return t.value}function Js(t){return t.stopPropagation()}function Ys(t){const e=re.c(45),{connection:n,selectedModels:r,allowAllModels:l,onToggleModel:o,onToggleConnectionAll:d,allConnectionModelsSelected:i,searchQuery:f,readOnly:x}=t;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={pageSize:999},e[0]=m):m=e[0];const b=us(n.id,m);let a;e[1]!==b||e[2]!==f?(a=f.trim()?b.filter(w=>w.title.toLowerCase().includes(f.toLowerCase())||w.id.toLowerCase().includes(f.toLowerCase())||w.provider?.toLowerCase().includes(f.toLowerCase())):b,e[1]=b,e[2]=f,e[3]=a):a=e[3];const T=a;if(T.length===0)return null;let h;e[4]!==i||e[5]!==l||e[6]!==T||e[7]!==r?(h=l||i||r.includes("*")&&!l||T.every(w=>r.includes(w.id)||r.includes("*")),e[4]=i,e[5]=l,e[6]=T,e[7]=r,e[8]=h):h=e[8];const N=h;let p;e[9]!==n.icon||e[10]!==n.title?(p=n.icon?s.jsx("img",{src:n.icon,alt:n.title,className:"w-4 h-4 rounded"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:n.title.slice(0,1).toUpperCase()}),e[9]=n.icon,e[10]=n.title,e[11]=p):p=e[11];let E;e[12]!==n.title?(E=s.jsx("h4",{className:"text-sm font-medium text-muted-foreground/75",children:n.title}),e[12]=n.title,e[13]=E):E=e[13];let j;e[14]!==p||e[15]!==E?(j=s.jsxs("div",{className:"flex items-center gap-2",children:[p,E]}),e[14]=p,e[15]=E,e[16]=j):j=e[16];let u;e[17]!==N||e[18]!==l||e[19]!==n.id||e[20]!==b||e[21]!==d||e[22]!==x?(u=!x&&!l&&s.jsx(ve,{checked:N,onCheckedChange:()=>d(n.id,b)}),e[17]=N,e[18]=l,e[19]=n.id,e[20]=b,e[21]=d,e[22]=x,e[23]=u):u=e[23];let y;e[24]!==j||e[25]!==u?(y=s.jsxs("div",{className:"flex items-center justify-between px-4 py-2",children:[j,u]}),e[24]=j,e[25]=u,e[26]=y):y=e[26];let v;if(e[27]!==l||e[28]!==n.id||e[29]!==T||e[30]!==o||e[31]!==x||e[32]!==r){let w;e[34]!==l||e[35]!==n.id||e[36]!==o||e[37]!==x||e[38]!==r?(w=L=>{const O=l||r.includes("*")||r.includes(L.id);return s.jsxs("div",{className:q("flex items-center justify-between gap-3 px-4 py-3",!x&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{x||l||o(n.id,L.id)},children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[L.logo&&s.jsx("img",{src:L.logo,className:"w-4 h-4 shrink-0 rounded-sm",alt:L.title}),s.jsx("span",{className:"text-sm truncate",children:L.title})]}),s.jsx("div",{onClick:Xs,children:x?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:O,disabled:!0})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:O,disabled:x||l,onCheckedChange:()=>{x||l||o(n.id,L.id)}})})]},L.id)},e[34]=l,e[35]=n.id,e[36]=o,e[37]=x,e[38]=r,e[39]=w):w=e[39],v=T.map(w),e[27]=l,e[28]=n.id,e[29]=T,e[30]=o,e[31]=x,e[32]=r,e[33]=v}else v=e[33];let P;e[40]!==v?(P=s.jsx("div",{className:"space-y-1",children:v}),e[40]=v,e[41]=P):P=e[41];let I;return e[42]!==P||e[43]!==y?(I=s.jsxs("div",{className:"mb-6 last:mb-0",children:[y,P]}),e[42]=P,e[43]=y,e[44]=I):I=e[44],I}function Xs(t){return t.stopPropagation()}function Ws(){const t=re.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(qe,{className:"size-4 animate-spin"}),"Loading models..."]}),t[0]=e):e=t[0],e}function en(t){const e=re.c(39),{allowAllModels:n,modelSet:r,onAllowAllChange:l,onModelSetChange:o,readOnly:d}=t,i=d===void 0?!1:d,[f,x]=D.useState(""),m=D.useDeferredValue(f),b=ms();let a;e[0]!==r||e[1]!==o?(a=(O,R)=>{const g=r[O]??[],A={...r};if(g.includes(R)){const S=g.filter(C=>C!==R);S.length===0?delete A[O]:A[O]=S}else A[O]=[...g,R];o(A)},e[0]=r,e[1]=o,e[2]=a):a=e[2];const T=a;let h;e[3]!==r||e[4]!==o?(h=(O,R)=>{const g=r[O]??[],A=R.map(sn),S=g.includes("*")||A.every(M=>g.includes(M)),C={...r};S?delete C[O]:C[O]=A,o(C)},e[3]=r,e[4]=o,e[5]=h):h=e[5];const N=h;let p;e[6]!==f?(p=s.jsx("div",{className:"border-b border-border",children:s.jsx(De,{value:f,onChange:x,placeholder:"Search models...",className:"border-b-0"})}),e[6]=f,e[7]=p):p=e[7];const E=!i&&"hover:bg-muted/50 cursor-pointer";let j;e[8]!==E?(j=q("flex items-center justify-between px-4 py-3 rounded-lg",E),e[8]=E,e[9]=j):j=e[9];let u;e[10]!==n||e[11]!==l||e[12]!==o||e[13]!==i?(u=()=>{if(i)return;const O=!n;l(O),O&&o({})},e[10]=n,e[11]=l,e[12]=o,e[13]=i,e[14]=u):u=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("span",{className:"text-sm font-medium",children:"All models"}),e[15]=y):y=e[15];let v;e[16]!==n||e[17]!==l||e[18]!==o||e[19]!==i?(v=s.jsx("div",{onClick:tn,children:i?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ve,{checked:n,disabled:!0})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(ve,{checked:n,onCheckedChange:O=>{i||(l(O),O&&o({}))}})}),e[16]=n,e[17]=l,e[18]=o,e[19]=i,e[20]=v):v=e[20];let P;e[21]!==j||e[22]!==u||e[23]!==v?(P=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:j,onClick:u,children:[y,v]})}),e[21]=j,e[22]=u,e[23]=v,e[24]=P):P=e[24];let I;e[25]!==n||e[26]!==m||e[27]!==b||e[28]!==r||e[29]!==i||e[30]!==N||e[31]!==T?(I=b.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No LLM connections configured"}):b.map(O=>s.jsx(D.Suspense,{fallback:s.jsx(Ws,{}),children:s.jsx(Ys,{connection:O,selectedModels:r[O.id]??[],allowAllModels:n,onToggleModel:T,onToggleConnectionAll:N,allConnectionModelsSelected:(r[O.id]??[]).includes("*"),searchQuery:m,readOnly:i})},O.id)),e[25]=n,e[26]=m,e[27]=b,e[28]=r,e[29]=i,e[30]=N,e[31]=T,e[32]=I):I=e[32];let w;e[33]!==I?(w=s.jsx("div",{className:"flex-1 overflow-auto",children:I}),e[33]=I,e[34]=w):w=e[34];let L;return e[35]!==P||e[36]!==w||e[37]!==p?(L=s.jsxs("div",{className:"flex flex-col h-full",children:[p,P,w]}),e[35]=P,e[36]=w,e[37]=p,e[38]=L):L=e[38],L}function tn(t){return t.stopPropagation()}function sn(t){return t.id}function nn(t){const e=re.c(56),{open:n,onOpenChange:r,selectedMemberIds:l,onAddMembers:o}=t,[d,i]=D.useState(""),f=D.useDeferredValue(d);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0];const[m,b]=D.useState(x),{data:a}=bt();let T,h,N,p,E,j,u,y,v,P,I;if(e[1]!==a?.data?.members||e[2]!==f||e[3]!==o||e[4]!==r||e[5]!==n||e[6]!==m||e[7]!==d||e[8]!==l){const M=a?.data?.members??[];let z;e[20]!==f?(z=U=>{const c=f.toLowerCase();return U.user?.name?.toLowerCase().includes(c)||U.user?.email?.toLowerCase().includes(c)},e[20]=f,e[21]=z):z=e[21];const B=M.filter(z),K=rn;let X;e[22]!==l?(X=U=>l.includes(U),e[22]=l,e[23]=X):X=e[23];const W=X;let ee;e[24]!==m?(ee=U=>{m.includes(U)?b(m.filter(c=>c!==U)):b([...m,U])},e[24]=m,e[25]=ee):ee=e[25];const oe=ee;let te;e[26]!==o||e[27]!==r||e[28]!==m?(te=()=>{o(m),b([]),r(!1)},e[26]=o,e[27]=r,e[28]=m,e[29]=te):te=e[29],N=te,h=Ue,P=n,I=r,T=Ve,y="sm:max-w-md p-0 overflow-hidden",e[30]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsxs(Be,{className:"px-6 pt-6",children:[s.jsx(Ge,{children:"Add Members to Role"}),s.jsx($e,{children:"Select members to add to this role."})]}),e[30]=v):v=e[30],j="flex flex-col h-80",e[31]!==d?(u=s.jsx(De,{value:d,onChange:i,placeholder:"Search members...",className:"border-b border-t-0 border-x-0 rounded-none"}),e[31]=d,e[32]=u):u=e[32],p="flex-1 overflow-auto",E=B.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:d?"No members found":"No members available"})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:B.map(U=>{const c=K(U),_=W(U.id),V=m.includes(U.id);return s.jsxs("label",{className:q("flex items-center gap-3 p-2 rounded-lg",!c||_?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(ze,{checked:V||_,onCheckedChange:()=>{c&&!_&&oe(U.id)},disabled:!c||_}),s.jsx(Pe,{url:U.user?.image??void 0,fallback:Jt(U.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:U.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.user?.email})]}),!c&&s.jsx(we,{variant:"secondary",className:"shrink-0",children:"Owner"}),_&&c&&s.jsx(we,{variant:"outline",className:"shrink-0",children:"Added"})]},U.id)})}),e[1]=a?.data?.members,e[2]=f,e[3]=o,e[4]=r,e[5]=n,e[6]=m,e[7]=d,e[8]=l,e[9]=T,e[10]=h,e[11]=N,e[12]=p,e[13]=E,e[14]=j,e[15]=u,e[16]=y,e[17]=v,e[18]=P,e[19]=I}else T=e[9],h=e[10],N=e[11],p=e[12],E=e[13],j=e[14],u=e[15],y=e[16],v=e[17],P=e[18],I=e[19];let w;e[33]!==p||e[34]!==E?(w=s.jsx("div",{className:p,children:E}),e[33]=p,e[34]=E,e[35]=w):w=e[35];let L;e[36]!==w||e[37]!==j||e[38]!==u?(L=s.jsxs("div",{className:j,children:[u,w]}),e[36]=w,e[37]=j,e[38]=u,e[39]=L):L=e[39];let O;e[40]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Ke,{children:"Cancel"}),e[40]=O):O=e[40];const R=m.length===0,g=m.length>0&&`(${m.length})`;let A;e[41]!==N||e[42]!==R||e[43]!==g?(A=s.jsxs(Fe,{className:"px-6 pb-6",children:[O,s.jsxs(Qe,{onClick:N,disabled:R,children:["Add ",g]})]}),e[41]=N,e[42]=R,e[43]=g,e[44]=A):A=e[44];let S;e[45]!==T||e[46]!==L||e[47]!==A||e[48]!==y||e[49]!==v?(S=s.jsxs(T,{className:y,children:[v,L,A]}),e[45]=T,e[46]=L,e[47]=A,e[48]=y,e[49]=v,e[50]=S):S=e[50];let C;return e[51]!==h||e[52]!==S||e[53]!==P||e[54]!==I?(C=s.jsx(h,{open:P,onOpenChange:I,children:S}),e[51]=h,e[52]=S,e[53]=P,e[54]=I,e[55]=C):C=e[55],C}function rn(t){return t.role!=="owner"}function on(t){const e=re.c(40),{memberIds:n,onMemberIdsChange:r,readOnly:l}=t,o=l===void 0?!1:l,[d,i]=D.useState(""),f=D.useDeferredValue(d),[x,m]=D.useState(!1),{data:b}=bt();let a,T,h,N,p;if(e[0]!==b?.data?.members||e[1]!==f||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==d){const y=b?.data?.members??[];let v;e[11]!==n?(v=S=>n.includes(S.id),e[11]=n,e[12]=v):v=e[12];const P=y.filter(v);let I;e[13]!==f?(I=S=>{const C=f.toLowerCase();return S.user?.name?.toLowerCase().includes(C)||S.user?.email?.toLowerCase().includes(C)},e[13]=f,e[14]=I):I=e[14];const w=P.filter(I);let L;e[15]!==n||e[16]!==r?(L=S=>{r(n.filter(C=>C!==S))},e[15]=n,e[16]=r,e[17]=L):L=e[17];const O=L;let R;e[18]!==n||e[19]!==r?(R=S=>{r([...n,...S])},e[18]=n,e[19]=r,e[20]=R):R=e[20],a=R,N="flex flex-col h-full";let g;e[21]!==d?(g=s.jsx(De,{value:d,onChange:i,placeholder:"Search members...",className:"flex-1 border-b-0"}),e[21]=d,e[22]=g):g=e[22];let A;e[23]!==o?(A=o?s.jsx("div",{className:"pr-4",children:s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(rt,{size:16}),"Add Member"]})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})})}):s.jsx("div",{className:"pr-4",children:s.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[s.jsx(rt,{size:16}),"Add Member"]})}),e[23]=o,e[24]=A):A=e[24],e[25]!==g||e[26]!==A?(p=s.jsxs("div",{className:"flex items-center border-b border-border",children:[g,A]}),e[25]=g,e[26]=A,e[27]=p):p=e[27],T="flex-1 overflow-auto",h=P.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No members"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Add members to this role to grant them the configured permissions."})]})}):w.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("p",{className:"text-sm text-muted-foreground",children:['No members match "',d,'"']})}):s.jsx("div",{className:"p-4 space-y-2",children:w.map(S=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(Pe,{url:S.user?.image??void 0,fallback:Jt(S.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:S.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:S.user?.email})]}),o?s.jsx(ye,{children:s.jsxs(Se,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ie,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(Ot,{size:16})})})}),s.jsx(Oe,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>O(S.id),children:s.jsx(Ot,{size:16})})]},S.id))}),e[0]=b?.data?.members,e[1]=f,e[2]=n,e[3]=r,e[4]=o,e[5]=d,e[6]=a,e[7]=T,e[8]=h,e[9]=N,e[10]=p}else a=e[6],T=e[7],h=e[8],N=e[9],p=e[10];let E;e[28]!==T||e[29]!==h?(E=s.jsx("div",{className:T,children:h}),e[28]=T,e[29]=h,e[30]=E):E=e[30];let j;e[31]!==x||e[32]!==a||e[33]!==n?(j=s.jsx(nn,{open:x,onOpenChange:m,selectedMemberIds:n,onAddMembers:a}),e[31]=x,e[32]=a,e[33]=n,e[34]=j):j=e[34];let u;return e[35]!==N||e[36]!==p||e[37]!==E||e[38]!==j?(u=s.jsxs("div",{className:N,children:[p,E,j]}),e[35]=N,e[36]=p,e[37]=E,e[38]=j,e[39]=u):u=e[39],u}function ln(t){const e=re.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(qe,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let r;return e[1]!==t?(r=s.jsx(D.Suspense,{fallback:n,children:s.jsx(on,{...t})}),e[1]=t,e[2]=r):r=e[2],r}const an={owner:[],admin:[],user:[]};function tt(t,e){const n=t==="owner"||t==="admin",r=e.filter(l=>l.role===t);return{role:{slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:n,staticPermissions:an[t],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:r.map(l=>l.id)}}function cn({trigger:t,onSuccess:e}){const[n,r]=D.useState(!1),[l,o]=D.useState("mcp"),{locator:d}=je(),i=Me(),f=Vt()??[],{customRoles:x,refetch:m}=Nt(),{data:b}=it({queryKey:ue.members(d),queryFn:()=>me.organization.listMembers()}),a=zt({resolver:Wt(Gs),defaultValues:et()}),T=a.formState.isValid,h=a.formState.isDirty,[N,p]=D.useState(null),[E,j]=D.useState(null),u=!a.watch("role.id")&&!a.watch("role.slug")&&!E,[y,v]=D.useState(null),[P,I]=D.useState(!1),[w,L]=D.useState(null),O=c=>{const _=c.permission||{},V=_.self||[],fe=V.includes("*"),J=fe?[]:V.filter(G=>G!=="*"),Y={};for(const[G,se]of Object.entries(_))if(!(G==="self"||G==="models"))if(G==="*")for(const ne of f)se.includes("*")?Y[ne.id]=ne.tools?.map(ae=>ae.name)??[]:Y[ne.id]=se;else{const ne=f.find(ae=>ae.id===G);ne&&(se.includes("*")?Y[G]=ne.tools?.map(ae=>ae.name)??[]:Y[G]=se)}const H=_.models||[],he=H.length===0||H.includes("*:*"),Z={};if(!he)for(const G of H){const se=G.indexOf(":");if(se===-1)continue;const ne=G.slice(0,se),ae=G.slice(se+1);Z[ne]||(Z[ne]=[]),Z[ne].push(ae)}const ce=(b?.data?.members??[]).filter(G=>G.role===c.role).map(G=>G.id);return{role:{id:c.id,slug:c.role,label:c.label},allowAllStaticPermissions:fe,staticPermissions:J,toolSet:Y,allowAllModels:he,modelSet:Z,memberIds:ce}},R=c=>{const _=O(c);a.reset(_),p(c.id??null),j(null)},g=()=>{a.reset(et()),p(null),j(null),o("mcp")},A=c=>{h&&T?(L(()=>()=>R(c)),I(!0)):R(c)},S=async()=>{h&&T&&await ee(),g()},C=c=>{if(h&&T)L(()=>()=>{const _=tt(c,b?.data?.members??[]);a.reset(_),j(c),p(null),o("org")}),I(!0);else{const _=tt(c,b?.data?.members??[]);a.reset(_),j(c),p(null),o("org")}},M=c=>{if(!c&&a.formState.isDirty&&T){L(()=>()=>{r(!1),a.reset(et()),j(null)}),I(!0);return}if(r(c),!c)a.reset(et()),j(null),p(null);else{const _=x[0];if(_)R(_);else{const V=tt("user",b?.data?.members??[]);a.reset(V),j("user"),p(null),o("org")}}},z=()=>{I(!1),w&&(w(),L(null))},B=c=>{const _={};c.allowAllStaticPermissions?_.self=["*"]:c.staticPermissions.length>0&&(_.self=c.staticPermissions);for(const[V,fe]of Object.entries(c.toolSet))if(fe.length>0){const Y=f.find(H=>H.id===V)?.tools?.map(H=>H.name)??[];Y.length>0&&Y.every(H=>fe.includes(H))?_[V]=["*"]:_[V]=fe}if(c.allowAllModels)_.models=["*:*"];else{const V=[];for(const[fe,J]of Object.entries(c.modelSet))if(J.length>0)for(const Y of J)V.push(`${fe}:${Y}`);_.models=V}return _},K=Ne({mutationFn:async c=>{const _=B(c),V=c.role.slug||c.role.label.toLowerCase().replace(/\s+/g,"-");if(c.role.slug&&!c.role.id){const Y=(b?.data?.members??[]).filter(Z=>Z.role===c.role.slug).map(Z=>Z.id),H=c.memberIds.filter(Z=>!Y.includes(Z)),he=Y.filter(Z=>!c.memberIds.includes(Z));for(const Z of H){const Q=await me.organization.updateMemberRole({memberId:Z,role:[c.role.slug]});if(Q?.error)throw new Error(Q.error.message)}for(const Z of he){const Q=await me.organization.updateMemberRole({memberId:Z,role:["user"]});if(Q?.error)throw new Error(Q.error.message)}return c}else if(c.role.id){const J=await me.organization.updateRole({roleId:c.role.id,data:{permission:_}});if(J?.error)throw new Error(J.error.message);const H=(b?.data?.members??[]).filter(Q=>Q.role===c.role.slug).map(Q=>Q.id),he=c.memberIds.filter(Q=>!H.includes(Q)),Z=H.filter(Q=>!c.memberIds.includes(Q));for(const Q of he){const ce=await me.organization.updateMemberRole({memberId:Q,role:[c.role.slug]});if(ce?.error)throw new Error(ce.error.message)}for(const Q of Z){const ce=await me.organization.updateMemberRole({memberId:Q,role:["user"]});if(ce?.error)throw new Error(ce.error.message)}return c}else{const J=await me.organization.createRole({role:V,permission:_});if(J?.error)throw new Error(J.error.message);for(const Y of c.memberIds){const H=await me.organization.updateMemberRole({memberId:Y,role:[V]});if(H?.error)throw new Error(H.error.message)}return{...c,role:{...c.role,id:J.data?.roleData?.id,slug:V}}}},onSuccess:(c,_)=>{i.invalidateQueries({queryKey:ue.members(d)}),i.invalidateQueries({queryKey:ue.organizationRoles(d)});const V=!_.role.id&&!_.role.slug,fe=_.role.slug&&!_.role.id;le.success(fe?"Members updated successfully!":V?"Role created successfully!":"Role updated successfully!"),m(),a.reset(c),c.role.id&&p(c.role.id),e?.()},onError:c=>{le.error(c instanceof Error?c.message:"Failed to save role")}}),X=Ne({mutationFn:async c=>{const _=await me.organization.deleteRole({roleId:c});if(_?.error)throw new Error(_.error.message);return _?.data},onSuccess:()=>{if(i.invalidateQueries({queryKey:ue.members(d)}),i.invalidateQueries({queryKey:ue.organizationRoles(d)}),le.success("Role deleted successfully!"),m(),y?.id===N){const c=x.filter(_=>_.id!==y?.id);if(c[0])R(c[0]);else{const _=tt("user",b?.data?.members??[]);a.reset(_),j("user"),p(null),o("org")}}},onError:c=>{le.error(c instanceof Error?c.message:"Failed to delete role")}}),W=K.isPending||X.isPending,ee=async()=>{const c=a.getValues();if(!c.role.label.trim()){le.error("Role name is required"),a.setFocus("role.label");return}await K.mutateAsync(c)},oe=a.handleSubmit(c=>{if(!c.role.label.trim()){le.error("Role name is required"),a.setFocus("role.label");return}K.mutate(c)}),te=c=>{c.id&&v({id:c.id,label:c.label})},U=()=>{y?.id&&X.mutate(y.id),v(null)};return s.jsxs(Bt,{open:n,onOpenChange:M,children:[s.jsx(Gt,{asChild:!0,children:t}),s.jsx($t,{className:"sm:max-w-5xl h-[80vh] max-h-[80vh] flex flex-col p-0 overflow-hidden w-[95vw]",children:s.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 flex-col sm:flex-row",children:[s.jsxs("div",{className:"w-full sm:w-64 sm:border-r border-b sm:border-b-0 border-border flex flex-col bg-background sm:h-full max-h-[40vh] sm:max-h-full",children:[s.jsx("div",{className:"flex-1 overflow-auto px-3.5 py-3.5 pt-3.5",children:s.jsxs("div",{className:"flex flex-col gap-1",children:[$s.map(c=>{const _=E===c.role;return s.jsxs("div",{className:q("flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden cursor-pointer transition-colors",_?"bg-accent":"hover:bg-muted/50"),onClick:()=>C(c.role),children:[s.jsx("div",{className:q("shrink-0 size-3 rounded-full",c.color)}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:c.label}),s.jsx(Ts,{size:14,className:"text-muted-foreground shrink-0"})]},c.role)}),x.map(c=>{const _=N===c.id;return s.jsxs("div",{className:q("group flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden transition-colors cursor-pointer",_?"bg-accent":"hover:bg-muted/50"),onClick:()=>A(c),children:[s.jsx("div",{className:q("shrink-0 size-3 rounded-full",Fs(c.label))}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:c.label}),s.jsxs(Ct,{children:[s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"icon",className:q("size-5 shrink-0 transition-opacity opacity-0 pointer-events-none","group-hover:opacity-100 group-hover:pointer-events-auto",_&&"opacity-100 pointer-events-auto"),onClick:V=>V.stopPropagation(),children:s.jsx(js,{size:14})})}),s.jsx(Tt,{align:"end",children:s.jsxs(nt,{className:"text-destructive",onClick:V=>{V.stopPropagation(),te(c)},children:[s.jsx(Ft,{size:16}),"Delete"]})})]})]},c.id)}),u&&s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden bg-accent",children:[s.jsx("div",{className:"shrink-0 size-3 rounded-full bg-neutral-400"}),s.jsx(vs,{...a.register("role.label"),placeholder:"Enter role name",className:"flex-1 text-sm font-medium border-0 shadow-none h-auto px-0 py-0 focus-visible:ring-0 bg-transparent",autoFocus:!0}),s.jsx(we,{variant:"secondary",className:"shrink-0 text-xs px-1.5 py-0",children:"New"})]})]})}),s.jsx("div",{className:"px-3.5 pb-3.5",children:s.jsxs(ie,{variant:"outline",size:"default",onClick:S,disabled:W||h,className:"w-full h-10",children:[s.jsx(rt,{size:16}),"Create new role"]})})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.jsxs("div",{className:"h-12 border-b border-border px-4 py-3.5 flex items-center gap-2 shrink-0",children:[!E&&s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("mcp"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="mcp"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"MCP Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("org"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="org"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Organization Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("models"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="models"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Models"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("members"),className:q("h-7 rounded-lg px-2 border border-input transition-colors",l==="members"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Members"})]}),s.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[l==="mcp"&&!E&&s.jsx(ks,{toolSet:a.watch("toolSet"),onToolSetChange:c=>a.setValue("toolSet",c,{shouldDirty:!0})}),l==="org"&&s.jsx(Ks,{allowAllStaticPermissions:a.watch("allowAllStaticPermissions"),staticPermissions:a.watch("staticPermissions"),onAllowAllChange:c=>a.setValue("allowAllStaticPermissions",c,{shouldDirty:!0}),onPermissionsChange:c=>a.setValue("staticPermissions",c,{shouldDirty:!0}),readOnly:!!E}),l==="models"&&s.jsx(en,{allowAllModels:a.watch("allowAllModels"),modelSet:a.watch("modelSet"),onAllowAllChange:c=>a.setValue("allowAllModels",c,{shouldDirty:!0}),onModelSetChange:c=>a.setValue("modelSet",c,{shouldDirty:!0}),readOnly:!!E}),l==="members"&&s.jsx(ln,{memberIds:a.watch("memberIds"),onMemberIdsChange:c=>a.setValue("memberIds",c,{shouldDirty:!0}),readOnly:E==="owner"})]}),(!E||E!=="owner")&&s.jsxs("div",{className:"border-t border-border px-5 py-5 flex items-center justify-end gap-2.5 shrink-0",children:[s.jsx(ie,{variant:"outline",onClick:()=>M(!1),disabled:W,className:"h-10",children:"Cancel"}),s.jsx(ie,{onClick:oe,disabled:W||!T||!a.formState.isDirty,className:"h-10",children:K.isPending?"Saving...":u?"Create Role":"Save Changes"})]})]})]})}),s.jsx(Ue,{open:y!==null,onOpenChange:c=>!c&&v(null),children:s.jsxs(Ve,{children:[s.jsxs(Be,{children:[s.jsx(Ge,{children:"Delete Role"}),s.jsxs($e,{children:['Are you sure you want to delete the "',y?.label,'" role? This action cannot be undone.']})]}),s.jsxs(Fe,{children:[s.jsx(Ke,{children:"Cancel"}),s.jsx(Qe,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s.jsx(Ue,{open:P,onOpenChange:I,children:s.jsxs(Ve,{children:[s.jsxs(Be,{children:[s.jsx(Ge,{children:"Discard Changes"}),s.jsx($e,{children:"You have unsaved changes. Are you sure you want to discard them?"})]}),s.jsxs(Fe,{children:[s.jsx(Ke,{onClick:()=>L(null),children:"Keep Editing"}),s.jsx(Qe,{onClick:z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Discard"})]})]})})]})}const dn=Ce().email("Invalid email address");function mn(t){if(!t.trim())return[];const e=t.split(/[,;\n]/).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(e))}function un({trigger:t}){const[e,n]=D.useState(!1),{locator:r}=je(),l=Me(),{data:o}=me.useSession(),d=o?.user?.email,{roles:i,isLoading:f}=Nt(),x=i.filter(j=>j.role!=="owner"),m=zt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),b=m.watch("emailsText"),a=m.watch("role"),h=mn(b).filter(j=>{const u=dn.safeParse(j).success,y=!d||j!==d.toLowerCase();return u&&y}),N=Ne({mutationFn:async({emails:j,role:u})=>{if(!u)throw new Error("Please select a role");const y=await Promise.allSettled(j.map(async P=>{const I=await me.organization.inviteMember({email:P,role:u});if(I.error)throw new Error(I.error.message);return I.data})),v=y.filter(P=>P.status==="rejected");if(v.length>0)throw new Error(`Failed to invite ${v.length} member${v.length>1?"s":""}`);return y},onSuccess:(j,{emails:u})=>{l.invalidateQueries({queryKey:ue.members(r)}),l.invalidateQueries({queryKey:ue.invitations(r)}),le.success(u.length===1?"Member invited successfully!":`${u.length} members invited successfully!`),m.reset({emailsText:"",role:"user"}),n(!1)},onError:j=>{le.error(j instanceof Error?j.message:"Failed to invite members")}}),p=j=>{if(h.length===0){le.error("Please enter at least one valid email address");return}if(!j.role){le.error("Please select a role");return}N.mutate({emails:h,role:j.role})},E=h.length>0&&!!a;return s.jsxs(Bt,{open:e,onOpenChange:n,children:[s.jsx(Gt,{asChild:!0,children:t}),s.jsxs($t,{className:"sm:max-w-lg",children:[s.jsx(fs,{children:s.jsx(hs,{children:"Invite members"})}),s.jsx(Es,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(p),className:"space-y-4",children:[s.jsx(wt,{control:m.control,name:"emailsText",render:({field:j})=>s.jsxs(At,{children:[s.jsx(ys,{children:"Email addresses"}),s.jsx(_t,{children:s.jsx(Ss,{...j,disabled:N.isPending,placeholder:`Enter email addresses separated by commas or new lines
|
|
2
2
|
e.g. user1@example.com, user2@example.com
|
|
3
3
|
or one per line`,className:"min-h-[120px] resize-none"})}),s.jsx(Lt,{})]})}),s.jsx(wt,{control:m.control,name:"role",render:({field:j})=>s.jsxs(At,{children:[s.jsx(_t,{children:s.jsxs(ft,{value:j.value,onValueChange:j.onChange,disabled:N.isPending||f,children:[s.jsx(ht,{className:"w-full",children:s.jsx(gt,{placeholder:"Select a role"})}),s.jsx(xt,{children:x.map(u=>{const y=[];return u.isBuiltin||(u.allowsAllStaticPermissions?y.push("Full org access"):u.staticPermissionCount&&u.staticPermissionCount>0&&y.push(`${u.staticPermissionCount} org perm${u.staticPermissionCount!==1?"s":""}`),u.allowsAllConnections?y.push("All connections"):u.connectionCount&&u.connectionCount>0&&y.push(`${u.connectionCount} connection${u.connectionCount!==1?"s":""}`),(u.connectionCount!==0||u.allowsAllConnections)&&(u.allowsAllTools?y.push("all tools"):u.toolCount&&u.toolCount>0&&y.push(`${u.toolCount} tool${u.toolCount!==1?"s":""}`))),s.jsx(pt,{value:u.role,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:u.label}),!u.isBuiltin&&y.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:y.join(", ")})]})},u.role)})})]})}),s.jsx(Lt,{})]})}),s.jsxs(gs,{children:[s.jsx(ie,{variant:"outline",onClick:()=>{m.reset({emailsText:"",role:"user"}),n(!1)},type:"button",disabled:N.isPending,children:"Cancel"}),s.jsx(ie,{type:"submit",disabled:N.isPending||!E,children:N.isPending?"Inviting...":`Invite ${h.length||0} Member${h.length!==1?"s":""}`})]})]})})]})]})}function fn(){const t=re.c(9),{org:e,locator:n}=je();let r;t[0]!==e.id?(r={connectionId:He,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const l=Ze(r);let o;t[2]!==n?(o=ue.invitations(n),t[2]=n,t[3]=o):o=t[3];let d;t[4]!==l?(d=async()=>{const f=await l.callTool({name:"ORGANIZATION_GET",arguments:{}});return(f.structuredContent??f)?.invitations??[]},t[4]=l,t[5]=d):d=t[5];let i;return t[6]!==o||t[7]!==d?(i={queryKey:o,queryFn:d},t[6]=o,t[7]=d,t[8]=i):i=t[8],es(i)}function hn(){const t=re.c(5),{locator:e}=je(),n=Me();let r;t[0]!==e||t[1]!==n?(r={mutationFn:xn,onSuccess:()=>{n.invalidateQueries({queryKey:ue.invitations(e)}),le.success("Invitation cancelled")},onError:gn},t[0]=e,t[1]=n,t[2]=r):r=t[2];const l=Ne(r);let o;return t[3]!==l?(o={cancel:l},t[3]=l,t[4]=o):o=t[4],o}function gn(t){le.error(t instanceof Error?t.message:"Failed to cancel invitation")}async function xn(t){const e=await me.organization.cancelInvitation({invitationId:t});if(e?.error)throw new Error(e.error.message);return e.data}function pn(){const t=re.c(9),{org:e,locator:n}=je();let r;t[0]!==e.id?(r={connectionId:He,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const l=Ze(r);let o;t[2]!==n?(o=ue.tags(n),t[2]=n,t[3]=o):o=t[3];let d;t[4]!==l?(d=async()=>{const f=await l.callTool({name:"TAGS_LIST",arguments:{}});return(f.structuredContent??f).tags},t[4]=l,t[5]=d):d=t[5];let i;return t[6]!==o||t[7]!==d?(i={queryKey:o,queryFn:d,staleTime:3e4},t[6]=o,t[7]=d,t[8]=i):i=t[8],it(i)}function bn(){const t=re.c(10),e=Me(),{org:n,locator:r}=je();let l;t[0]!==n.id?(l={connectionId:He,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const o=Ze(l);let d;t[2]!==o?(d=async x=>{const m=await o.callTool({name:"TAGS_CREATE",arguments:{name:x}});return(m.structuredContent??m).tag},t[2]=o,t[3]=d):d=t[3];let i;t[4]!==r||t[5]!==e?(i=()=>{e.invalidateQueries({queryKey:ue.tags(r)})},t[4]=r,t[5]=e,t[6]=i):i=t[6];let f;return t[7]!==d||t[8]!==i?(f={mutationFn:d,onSuccess:i,onError:Cn},t[7]=d,t[8]=i,t[9]=f):f=t[9],Ne(f)}function Cn(t){le.error(t instanceof Error?t.message:"Failed to create tag")}function jn(t){const e=re.c(12),{org:n,locator:r}=je();let l;e[0]!==n.id?(l={connectionId:He,orgId:n.id},e[0]=n.id,e[1]=l):l=e[1];const o=Ze(l);let d;e[2]!==r||e[3]!==t?(d=ue.memberTags(r,t),e[2]=r,e[3]=t,e[4]=d):d=e[4];let i;e[5]!==o||e[6]!==t?(i=async()=>{const m=await o.callTool({name:"MEMBER_TAGS_GET",arguments:{memberId:t}});return(m.structuredContent??m).tags},e[5]=o,e[6]=t,e[7]=i):i=e[7];const f=!!t;let x;return e[8]!==d||e[9]!==i||e[10]!==f?(x={queryKey:d,queryFn:i,staleTime:3e4,enabled:f},e[8]=d,e[9]=i,e[10]=f,e[11]=x):x=e[11],it(x)}function Tn(){const t=re.c(10),e=Me(),{org:n,locator:r}=je();let l;t[0]!==n.id?(l={connectionId:He,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const o=Ze(l);let d;t[2]!==o?(d=async x=>{const{memberId:m,tagIds:b}=x,a=await o.callTool({name:"MEMBER_TAGS_SET",arguments:{memberId:m,tagIds:b}});return a.structuredContent??a},t[2]=o,t[3]=d):d=t[3];let i;t[4]!==r||t[5]!==e?(i=(x,m)=>{e.invalidateQueries({queryKey:ue.memberTags(r,m.memberId)})},t[4]=r,t[5]=e,t[6]=i):i=t[6];let f;return t[7]!==d||t[8]!==i?(f={mutationFn:d,onSuccess:i,onError:vn},t[7]=d,t[8]=i,t[9]=f):f=t[9],Ne(f)}function vn(t){le.error(t instanceof Error?t.message:"Failed to update member tags")}function Yt(t){const e=re.c(44),{memberId:n,className:r,disabled:l,placeholder:o,maxDisplay:d}=t,i=l===void 0?!1:l,f=o===void 0?"Add tags...":o,x=d===void 0?2:d,[m,b]=D.useState(!1),[a,T]=D.useState(""),{data:h,isLoading:N}=pn(),p=h===void 0?[]:h,{data:E,isLoading:j}=jn(n),u=E===void 0?[]:E,y=bn(),v=Tn(),P=N||j,I=u.map(En);let w;e[0]!==a?(w=F=>F.name.toLowerCase().includes(a.toLowerCase()),e[0]=a,e[1]=w):w=e[1];const L=p.filter(w);let O;e[2]!==a?(O=F=>F.name.toLowerCase()===a.toLowerCase(),e[2]=a,e[3]=O):O=e[3];const R=p.find(O),g=a.trim()&&!R,A=async F=>{const be=I.includes(F.id)?I.filter(Ae=>Ae!==F.id):[...I,F.id];await v.mutateAsync({memberId:n,tagIds:be})},S=async()=>{if(!a.trim())return;const F=await y.mutateAsync(a.trim());await v.mutateAsync({memberId:n,tagIds:[...I,F.id]}),T("")},C=async F=>{const xe=I.filter(be=>be!==F);await v.mutateAsync({memberId:n,tagIds:xe})},M=y.isPending||v.isPending,z=ws;let B;e[4]!==m?(B=()=>b(!m),e[4]=m,e[5]=B):B=e[5];let K;e[6]!==r?(K=q("h-auto min-h-8 px-2 py-1 justify-start font-normal","hover:bg-accent/50",r),e[6]=r,e[7]=K):K=e[7];const X=i||P,W=P?s.jsx(qe,{size:14,className:"animate-spin text-muted-foreground"}):u.length>0?s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[u.slice(0,x).map(Nn),u.length>x&&s.jsxs(we,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:["+",u.length-x]})]}):s.jsx("span",{className:"text-muted-foreground text-xs",children:f});let ee;e[8]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(_s,{size:14,className:"ml-1 shrink-0 opacity-50"}),e[8]=ee):ee=e[8];let oe;e[9]!==X||e[10]!==W||e[11]!==B||e[12]!==K?(oe=s.jsx(As,{asChild:!0,children:s.jsxs(ie,{variant:"ghost",size:"sm",onClick:B,className:K,disabled:X,children:[W,ee]})}),e[9]=X,e[10]=W,e[11]=B,e[12]=K,e[13]=oe):oe=e[13];const te=Os,U="w-56 p-0",c="start";let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=()=>b(!1),e[14]=_):_=e[14];const V=cs,fe=!1;let J;e[15]!==a?(J=s.jsx(ds,{placeholder:"Search or create...",value:a,onValueChange:T,className:"h-9"}),e[15]=a,e[16]=J):J=e[16];const Y=as,H=u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{heading:"Selected",children:u.map(F=>s.jsx(dt,{onSelect:()=>A(F),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ze,{checked:!0,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:F.name})]}),s.jsx("button",{onClick:xe=>{xe.stopPropagation(),C(F.id)},className:"opacity-50 hover:opacity-100",disabled:M,children:s.jsx(Qt,{size:14})})]})},F.id))}),s.jsx(It,{})]}),he=ct,Z="Available",Q=L.length===0&&!g&&s.jsx(ls,{children:"No tags found."}),ce=L.filter(F=>!I.includes(F.id)).map(F=>s.jsx(dt,{onSelect:()=>A(F),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ze,{checked:!1,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:F.name})]})},F.id));let G;e[17]!==he||e[18]!==Q||e[19]!==ce?(G=s.jsxs(he,{heading:Z,children:[Q,ce]}),e[17]=he,e[18]=Q,e[19]=ce,e[20]=G):G=e[20];let se;e[21]!==S||e[22]!==M||e[23]!==a||e[24]!==g?(se=g&&s.jsxs(s.Fragment,{children:[s.jsx(It,{}),s.jsx(ct,{children:s.jsx(dt,{onSelect:S,className:"cursor-pointer",disabled:M,children:s.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[M?s.jsx(qe,{size:14,className:"animate-spin"}):s.jsx(rt,{size:14}),s.jsxs("span",{children:['Create "',a.trim(),'"']})]})})})]}),e[21]=S,e[22]=M,e[23]=a,e[24]=g,e[25]=se):se=e[25];let ne;e[26]!==Y||e[27]!==H||e[28]!==G||e[29]!==se?(ne=s.jsxs(Y,{children:[H,G,se]}),e[26]=Y,e[27]=H,e[28]=G,e[29]=se,e[30]=ne):ne=e[30];let ae;e[31]!==V||e[32]!==J||e[33]!==ne?(ae=s.jsxs(V,{shouldFilter:fe,children:[J,ne]}),e[31]=V,e[32]=J,e[33]=ne,e[34]=ae):ae=e[34];let ge;e[35]!==te||e[36]!==_||e[37]!==ae?(ge=s.jsx(te,{className:U,align:c,onEscapeKeyDown:_,children:ae}),e[35]=te,e[36]=_,e[37]=ae,e[38]=ge):ge=e[38];let Te;return e[39]!==z||e[40]!==m||e[41]!==oe||e[42]!==ge?(Te=s.jsxs(z,{open:m,onOpenChange:b,children:[oe,ge]}),e[39]=z,e[40]=m,e[41]=oe,e[42]=ge,e[43]=Te):Te=e[43],Te}function Nn(t){return s.jsx(we,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:t.name},t.id)}function En(t){return t.id}const Mt=["bg-neutral-400","bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500","bg-slate-500"],yn={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function ot(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function Sn(t){const e=new Map;for(const[n,r]of Object.entries(yn))e.set(n,r);for(let n=0;n<t.length;n++){const r=t[n];r&&!e.has(r.role)&&e.set(r.role,Mt[n%Mt.length]??"bg-neutral-400")}return e}function In(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function st(t){const e=re.c(79),{role:n,memberId:r,isOwner:l,roleColorMap:o,selectableRoles:d,onRoleChange:i,size:f,className:x}=t,m=f===void 0?"xs":f;let b,a,T,h,N,p,E,j,u,y,v;if(e[0]!==x||e[1]!==l||e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==d||e[7]!==m){v=Symbol.for("react.early_return_sentinel");e:{const S=o.get(n)??"bg-neutral-400";if(l){let C;e[19]!==r||e[20]!==i?(C=U=>i(r,U),e[19]=r,e[20]=i,e[21]=C):C=e[21];let M;e[22]!==n?(M=s.jsx("span",{className:"capitalize truncate",children:n}),e[22]=n,e[23]=M):M=e[23];const z=s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:q("size-2 rounded-full shrink-0",S)}),M]});let B;e[24]!==z?(B=s.jsx(gt,{children:z}),e[24]=z,e[25]=B):B=e[25];let K;e[26]!==x||e[27]!==m||e[28]!==B?(K=s.jsx(ht,{size:m,className:x,children:B}),e[26]=x,e[27]=m,e[28]=B,e[29]=K):K=e[29];let X;if(e[30]!==o||e[31]!==d){let U;e[33]!==o?(U=c=>{const _=o.get(c.role)??"bg-neutral-400";return s.jsx(pt,{value:c.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:q("size-3 rounded-full",_)}),s.jsx("span",{className:"capitalize",children:c.label})]})},c.role)},e[33]=o,e[34]=U):U=e[34],X=d.map(U),e[30]=o,e[31]=d,e[32]=X}else X=e[32];let W;e[35]!==X?(W=s.jsx(xt,{children:X}),e[35]=X,e[36]=W):W=e[36];let ee;e[37]!==l||e[38]!==n||e[39]!==C||e[40]!==K||e[41]!==W?(ee=s.jsx(Ie,{asChild:!0,children:s.jsx("div",{className:"w-fit",children:s.jsxs(ft,{value:n,onValueChange:C,disabled:l,children:[K,W]})})}),e[37]=l,e[38]=n,e[39]=C,e[40]=K,e[41]=W,e[42]=ee):ee=e[42];let oe;e[43]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(Oe,{children:s.jsx("p",{children:"The owner role cannot be changed"})}),e[43]=oe):oe=e[43];let te;e[44]!==ee?(te=s.jsx(ye,{children:s.jsxs(Se,{children:[ee,oe]})}),e[44]=ee,e[45]=te):te=e[45],v=te;break e}T=ft,j=n,e[46]!==r||e[47]!==i?(u=C=>i(r,C),e[46]=r,e[47]=i,e[48]=u):u=e[48],y=l,a=ht,p=m,E=x,b=gt,N="flex items-center gap-2 min-w-0",h=q("size-2 rounded-full shrink-0",S)}e[0]=x,e[1]=l,e[2]=r,e[3]=i,e[4]=n,e[5]=o,e[6]=d,e[7]=m,e[8]=b,e[9]=a,e[10]=T,e[11]=h,e[12]=N,e[13]=p,e[14]=E,e[15]=j,e[16]=u,e[17]=y,e[18]=v}else b=e[8],a=e[9],T=e[10],h=e[11],N=e[12],p=e[13],E=e[14],j=e[15],u=e[16],y=e[17],v=e[18];if(v!==Symbol.for("react.early_return_sentinel"))return v;let P;e[49]!==h?(P=s.jsx("div",{className:h}),e[49]=h,e[50]=P):P=e[50];let I;e[51]!==n?(I=s.jsx("span",{className:"capitalize truncate",children:n}),e[51]=n,e[52]=I):I=e[52];let w;e[53]!==P||e[54]!==I||e[55]!==N?(w=s.jsxs("div",{className:N,children:[P,I]}),e[53]=P,e[54]=I,e[55]=N,e[56]=w):w=e[56];let L;e[57]!==b||e[58]!==w?(L=s.jsx(b,{children:w}),e[57]=b,e[58]=w,e[59]=L):L=e[59];let O;e[60]!==a||e[61]!==L||e[62]!==p||e[63]!==E?(O=s.jsx(a,{size:p,className:E,children:L}),e[60]=a,e[61]=L,e[62]=p,e[63]=E,e[64]=O):O=e[64];let R;if(e[65]!==o||e[66]!==d){let S;e[68]!==o?(S=C=>{const M=o.get(C.role)??"bg-neutral-400";return s.jsx(pt,{value:C.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:q("size-3 rounded-full",M)}),s.jsx("span",{className:"capitalize",children:C.label})]})},C.role)},e[68]=o,e[69]=S):S=e[69],R=d.map(S),e[65]=o,e[66]=d,e[67]=R}else R=e[67];let g;e[70]!==R?(g=s.jsx(xt,{children:R}),e[70]=R,e[71]=g):g=e[71];let A;return e[72]!==T||e[73]!==O||e[74]!==g||e[75]!==j||e[76]!==u||e[77]!==y?(A=s.jsxs(T,{value:j,onValueChange:u,disabled:y,children:[O,g]}),e[72]=T,e[73]=O,e[74]=g,e[75]=j,e[76]=u,e[77]=y,e[78]=A):A=e[78],A}function Dt(t){const e=re.c(51),{member:n,roles:r,onChangeRole:l,onRemove:o,isUpdating:d}=t,i=d===void 0?!1:d,f=n.role==="owner";let x,m,b,a,T,h,N,p,E;if(e[0]!==f||e[1]!==i||e[2]!==n.id||e[3]!==n.role||e[4]!==l||e[5]!==r){let O;e[15]!==n.role?(O=C=>C.role!==n.role&&C.role!=="owner",e[15]=n.role,e[16]=O):O=e[16];const R=r.filter(O);a=Ct;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(Kt,{size:20}),e[17]=g):g=e[17],e[18]!==f?(E=s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:f,onClick:wn,children:g})}),e[18]=f,e[19]=E):E=e[19],b=Tt,N="end",p=On,m=xs;let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(Ht,{size:16}),e[20]=A):A=e[20],e[21]!==i?(h=s.jsxs(ps,{disabled:i,children:[A,"Change Role"]}),e[21]=i,e[22]=h):h=e[22],x=bs;let S;e[23]!==i||e[24]!==n.id||e[25]!==l?(S=C=>{const M=[];return C.isBuiltin||(C.allowsAllStaticPermissions?M.push("Full org access"):C.staticPermissionCount&&C.staticPermissionCount>0&&M.push(`${C.staticPermissionCount} org perm${C.staticPermissionCount!==1?"s":""}`),C.allowsAllConnections?M.push("All connections"):C.connectionCount&&C.connectionCount>0&&M.push(`${C.connectionCount} connection${C.connectionCount!==1?"s":""}`),(C.connectionCount!==0||C.allowsAllConnections)&&(C.allowsAllTools?M.push("all tools"):C.toolCount&&C.toolCount>0&&M.push(`${C.toolCount} tool${C.toolCount!==1?"s":""}`))),s.jsxs(nt,{onClick:z=>{z.stopPropagation(),l(n.id,C.role)},disabled:i,children:[C.isBuiltin?s.jsx(vt,{size:16}):s.jsx(Is,{size:16}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:C.label}),!C.isBuiltin&&M.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:M.join(", ")})]})]},C.role)},e[23]=i,e[24]=n.id,e[25]=l,e[26]=S):S=e[26],T=R.map(S),e[0]=f,e[1]=i,e[2]=n.id,e[3]=n.role,e[4]=l,e[5]=r,e[6]=x,e[7]=m,e[8]=b,e[9]=a,e[10]=T,e[11]=h,e[12]=N,e[13]=p,e[14]=E}else x=e[6],m=e[7],b=e[8],a=e[9],T=e[10],h=e[11],N=e[12],p=e[13],E=e[14];let j;e[27]!==x||e[28]!==T?(j=s.jsx(x,{children:T}),e[27]=x,e[28]=T,e[29]=j):j=e[29];let u;e[30]!==m||e[31]!==h||e[32]!==j?(u=s.jsxs(m,{children:[h,j]}),e[30]=m,e[31]=h,e[32]=j,e[33]=u):u=e[33];let y;e[34]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Cs,{}),e[34]=y):y=e[34];let v;e[35]!==n.id||e[36]!==o?(v=O=>{O.stopPropagation(),o(n.id)},e[35]=n.id,e[36]=o,e[37]=v):v=e[37];let P;e[38]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(Ft,{size:16}),e[38]=P):P=e[38];let I;e[39]!==v?(I=s.jsxs(nt,{variant:"destructive",onClick:v,children:[P,"Remove Member"]}),e[39]=v,e[40]=I):I=e[40];let w;e[41]!==b||e[42]!==I||e[43]!==N||e[44]!==p||e[45]!==u?(w=s.jsxs(b,{align:N,onClick:p,children:[u,y,I]}),e[41]=b,e[42]=I,e[43]=N,e[44]=p,e[45]=u,e[46]=w):w=e[46];let L;return e[47]!==a||e[48]!==w||e[49]!==E?(L=s.jsxs(a,{children:[E,w]}),e[47]=a,e[48]=w,e[49]=E,e[50]=L):L=e[50],L}function On(t){return t.stopPropagation()}function wn(t){return t.stopPropagation()}function kt(t){const e=re.c(8),{invitationId:n,onCancel:r,isCancelling:l}=t,o=l===void 0?!1:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:_n,children:s.jsx(Kt,{size:20})})}),e[0]=d):d=e[0];let i;e[1]!==n||e[2]!==r?(i=m=>{m.stopPropagation(),r(n)},e[1]=n,e[2]=r,e[3]=i):i=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(Qt,{size:16}),e[4]=f):f=e[4];let x;return e[5]!==o||e[6]!==i?(x=s.jsxs(Ct,{children:[d,s.jsx(Tt,{align:"end",onClick:An,children:s.jsxs(nt,{variant:"destructive",onClick:i,disabled:o,children:[f,"Cancel Invitation"]})})]}),e[5]=o,e[6]=i,e[7]=x):x=e[7],x}function An(t){return t.stopPropagation()}function _n(t){return t.stopPropagation()}function Ln(){const t=re.c(79),{data:e}=bt(),{data:n}=fn(),r=hn(),l=Me(),{locator:o}=je(),[d,i]=D.useState(null),[f,x]=D.useState(null),[m,b]=D.useState(""),[a,T]=D.useState("table"),[h,N]=D.useState("member"),[p,E]=D.useState("asc"),j=e?.data?.members;let u;t[0]!==h?(u=k=>{h===k?E(Qn):(N(k),E("asc"))},t[0]=h,t[1]=u):u=t[1];const y=u;let v=j??[],P=n??[];if(m){const k=m.toLowerCase();v=v.filter($=>$.user?.name?.toLowerCase().includes(k)||$.user?.email?.toLowerCase().includes(k)||$.role?.toLowerCase().includes(k)),P=P.filter($=>$.email?.toLowerCase().includes(k)||$.role?.toLowerCase().includes(k))}if(h&&p){let k;t[2]!==p||t[3]!==h?(k=($,de)=>{let pe,ke;e:switch(h){case"member":{pe=$.user?.name||"",ke=de.user?.name||"";break e}case"role":{pe=$.role||"",ke=de.role||"";break e}case"joined":{pe=$.createdAt?typeof $.createdAt=="string"?$.createdAt:$.createdAt.toISOString():"",ke=de.createdAt?typeof de.createdAt=="string"?de.createdAt:de.createdAt.toISOString():"";break e}default:return 0}return p==="asc"?pe.localeCompare(ke):ke.localeCompare(pe)},t[2]=p,t[3]=h,t[4]=k):k=t[4],v=[...v].sort(k)}const I=v;let w;t[5]!==o||t[6]!==l?(w={mutationFn:Kn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.members(o)}),le.success("Member has been removed from the organization"),i(null)},onError:Fn},t[5]=o,t[6]=l,t[7]=w):w=t[7];const L=Ne(w);let O;t[8]!==o||t[9]!==l?(O={mutationFn:$n,onSuccess:()=>{l.invalidateQueries({queryKey:ue.members(o)}),le.success("Member's role has been updated")},onError:Gn},t[8]=o,t[9]=l,t[10]=O):O=t[10];const R=Ne(O);let g;t[11]!==o||t[12]!==l?(g={mutationFn:Bn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.invitations(o)}),le.success("Invitation role has been updated")},onError:Vn},t[11]=o,t[12]=l,t[13]=g):g=t[13];const A=Ne(g),{roles:S,customRoles:C}=Nt();let M;t[14]!==C?(M=Sn(C),t[14]=C,t[15]=M):M=t[15];const z=M;let B;t[16]!==S?(B=S.filter(Un),t[16]=S,t[17]=B):B=t[17];const K=B;let X;t[18]===Symbol.for("react.memo_cache_sentinel")?(X={id:"member",header:"Member",render:zn,cellClassName:"flex-1 min-w-0",sortable:!0},t[18]=X):X=t[18];let W;t[19]!==z||t[20]!==K||t[21]!==A||t[22]!==R?(W={id:"role",header:"Role",render:k=>k.type==="member"?s.jsx(st,{role:k.data.role,memberId:k.data.id,isOwner:k.data.role==="owner",roleColorMap:z,selectableRoles:K,onRoleChange:($,de)=>R.mutate({memberId:$,role:de}),className:"w-36"}):s.jsx(st,{role:k.data.role,memberId:k.data.id,isOwner:!1,roleColorMap:z,selectableRoles:K,onRoleChange:($,de)=>A.mutate({invitationId:$,role:de,email:k.data.email}),className:"w-36"}),cellClassName:"w-36 shrink-0",sortable:!0},t[19]=z,t[20]=K,t[21]=A,t[22]=R,t[23]=W):W=t[23];let ee,oe;t[24]===Symbol.for("react.memo_cache_sentinel")?(ee={id:"tags",header:"Tags",render:kn,cellClassName:"w-40 shrink-0"},oe={id:"joined",header:"Joined",render:Dn,cellClassName:"w-48 shrink-0",sortable:!0},t[24]=ee,t[25]=oe):(ee=t[24],oe=t[25]);let te;t[26]!==r.cancel.isPending||t[27]!==S||t[28]!==R?(te={id:"actions",header:"",render:k=>k.type==="member"?s.jsx(Dt,{member:k.data,roles:S,onChangeRole:($,de)=>R.mutate({memberId:$,role:de}),onRemove:i,isUpdating:R.isPending}):s.jsx(kt,{invitationId:k.data.id,onCancel:x,isCancelling:r.cancel.isPending}),cellClassName:"w-12 shrink-0"},t[26]=r.cancel.isPending,t[27]=S,t[28]=R,t[29]=te):te=t[29];let U;t[30]!==te||t[31]!==W?(U=[X,W,ee,oe,te],t[30]=te,t[31]=W,t[32]=U):U=t[32];const c=U;let _;t[33]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(cn,{trigger:s.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:[s.jsx(vt,{size:16}),"Manage Roles"]})}),t[33]=_):_=t[33];let V;t[34]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsxs("div",{className:"flex items-center gap-2",children:[_,s.jsx(un,{trigger:s.jsx(ie,{size:"sm",children:"Invite Member"})})]}),t[34]=V):V=t[34];const fe=V,J=[...I.map(Mn),...P.filter(Pn).map(Rn)],Y=Ee,H=!!f;let he;t[35]===Symbol.for("react.memo_cache_sentinel")?(he=()=>x(null),t[35]=he):he=t[35];let Z;t[36]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsxs(Be,{children:[s.jsx(Ge,{children:"Cancel Invitation"}),s.jsx($e,{children:"Are you sure you want to cancel this invitation? The invitee will no longer be able to join the organization with this invitation."})]}),t[36]=Z):Z=t[36];let Q;t[37]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(Ke,{children:"Keep Invitation"}),t[37]=Q):Q=t[37];let ce;t[38]!==r.cancel||t[39]!==f?(ce=()=>{f&&(r.cancel.mutate(f),x(null))},t[38]=r.cancel,t[39]=f,t[40]=ce):ce=t[40];let G;t[41]!==r.cancel.isPending||t[42]!==ce?(G=s.jsxs(Ve,{children:[Z,s.jsxs(Fe,{children:[Q,s.jsx(Qe,{onClick:ce,disabled:r.cancel.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Invitation"})]})]}),t[41]=r.cancel.isPending,t[42]=ce,t[43]=G):G=t[43];let se;t[44]!==H||t[45]!==G?(se=s.jsx(Ue,{open:H,onOpenChange:he,children:G}),t[44]=H,t[45]=G,t[46]=se):se=t[46];const ne=!!d;let ae;t[47]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>i(null),t[47]=ae):ae=t[47];let ge;t[48]===Symbol.for("react.memo_cache_sentinel")?(ge=s.jsxs(Be,{children:[s.jsx(Ge,{children:"Remove Member"}),s.jsx($e,{children:"Are you sure you want to remove this member from the organization? This action cannot be undone."})]}),t[48]=ge):ge=t[48];let Te;t[49]===Symbol.for("react.memo_cache_sentinel")?(Te=s.jsx(Ke,{children:"Cancel"}),t[49]=Te):Te=t[49];let F;t[50]!==d||t[51]!==L?(F=()=>d&&L.mutate(d),t[50]=d,t[51]=L,t[52]=F):F=t[52];let xe;t[53]!==L.isPending||t[54]!==F?(xe=s.jsxs(Ve,{children:[ge,s.jsxs(Fe,{children:[Te,s.jsx(Qe,{onClick:F,disabled:L.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),t[53]=L.isPending,t[54]=F,t[55]=xe):xe=t[55];let be;t[56]!==ne||t[57]!==xe?(be=s.jsx(Ue,{open:ne,onOpenChange:ae,children:xe}),t[56]=ne,t[57]=xe,t[58]=be):be=t[58];let Ae;t[59]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(Ee.Header.Left,{children:s.jsx(ns,{children:s.jsx(rs,{children:s.jsx(os,{children:s.jsx(is,{children:"Members"})})})})}),t[59]=Ae):Ae=t[59];let Je;t[60]===Symbol.for("react.memo_cache_sentinel")?(Je=[{id:"member",label:"Name"},{id:"role",label:"Role"},{id:"joined",label:"Joined"}],t[60]=Je):Je=t[60];let _e;t[61]!==y||t[62]!==p||t[63]!==h||t[64]!==a?(_e=s.jsxs(Ee.Header,{children:[Ae,s.jsxs(Ee.Header.Right,{children:[s.jsx(ts,{viewMode:a,onViewModeChange:T,sortKey:h,sortDirection:p,onSort:y,sortOptions:Je}),fe]})]}),t[61]=y,t[62]=p,t[63]=h,t[64]=a,t[65]=_e):_e=t[65];let Ye;t[66]===Symbol.for("react.memo_cache_sentinel")?(Ye=k=>{k.key==="Escape"&&(b(""),k.target.blur())},t[66]=Ye):Ye=t[66];let Le;t[67]!==m?(Le=s.jsx(De,{value:m,onChange:b,placeholder:"Search members...",onKeyDown:Ye}),t[67]=m,t[68]=Le):Le=t[68];const lt=Ee,at=a==="cards"?s.jsx("div",{className:"flex-1 overflow-auto p-5",children:J.length===0?s.jsx(mt,{title:"No members found",description:m?`No members match "${m}"`:"Invite members to get started."}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:J.map(k=>{if(k.type==="invitation")return s.jsxs(Rt,{className:"transition-colors relative opacity-75",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(kt,{invitationId:k.data.id,onCancel:x,isCancelling:r.cancel.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Pe,{fallback:ot(k.data.email),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:k.data.email}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(we,{variant:"outline",className:"w-fit text-amber-600 border-amber-400",children:"Pending"})}),s.jsx(st,{role:k.data.role,memberId:k.data.id,isOwner:!1,roleColorMap:z,selectableRoles:K,onRoleChange:(de,pe)=>A.mutate({invitationId:de,role:pe,email:k.data.email}),className:"w-fit"})]})]})]},`inv-${k.data.id}`);const $=k.data;return s.jsxs(Rt,{className:"transition-colors relative",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Dt,{member:$,roles:S,onChangeRole:(de,pe)=>R.mutate({memberId:de,role:pe}),onRemove:i,isUpdating:R.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Pe,{url:$.user?.image??void 0,fallback:ot($.user?.name),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:$.user?.name||"Unknown"}),s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:$.user?.email}),s.jsx(st,{role:$.role,memberId:$.id,isOwner:$.role==="owner",roleColorMap:z,selectableRoles:K,onRoleChange:(de,pe)=>R.mutate({memberId:de,role:pe}),className:"w-fit"}),s.jsx(Yt,{memberId:$.id,maxDisplay:3})]})]})]},$.id)})})}):s.jsx(ss,{columns:c,data:J,isLoading:!1,sortKey:h,sortDirection:p,onSort:y,emptyState:m?s.jsx(mt,{title:"No members found",description:`No members match "${m}"`}):s.jsx(mt,{title:"No members found",description:"Invite members to get started."})});let Re;t[69]!==lt.Content||t[70]!==at?(Re=s.jsx(lt.Content,{children:at}),t[69]=lt.Content,t[70]=at,t[71]=Re):Re=t[71];let Xe;return t[72]!==Y||t[73]!==se||t[74]!==be||t[75]!==_e||t[76]!==Le||t[77]!==Re?(Xe=s.jsxs(Y,{children:[se,be,_e,Le,Re]}),t[72]=Y,t[73]=se,t[74]=be,t[75]=_e,t[76]=Le,t[77]=Re,t[78]=Xe):Xe=t[78],Xe}function Rn(t){return{type:"invitation",data:t}}function Pn(t){return t.status==="pending"}function Mn(t){return{type:"member",data:t}}function Dn(t){return t.type==="member"?s.jsx("span",{className:"text-sm text-foreground",children:t.data.createdAt?In(t.data.createdAt):"N/A"}):s.jsx(we,{variant:"outline",children:"Pending"})}function kn(t){return t.type==="member"?s.jsx(Yt,{memberId:t.data.id,maxDisplay:2}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}function zn(t){return t.type==="member"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Pe,{url:t.data.user?.image??void 0,fallback:ot(t.data.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.user?.name||"Unknown"}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.data.user?.email})]})]}):s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Pe,{fallback:ot(t.data.email),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.email}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:"Invitation sent"})]})]})}function Un(t){return t.role!=="owner"}function Vn(t){le.error(t instanceof Error?t.message:"Failed to update invitation role")}async function Bn(t){const{invitationId:e,role:n,email:r}=t,l=await me.organization.cancelInvitation({invitationId:e});if(l?.error)throw new Error(l.error.message);const o=await me.organization.inviteMember({email:r,role:n});if(o?.error)throw new Error(o.error.message)}function Gn(t){le.error(t instanceof Error?t.message:"Failed to update role")}async function $n(t){const{memberId:e,role:n}=t,r=await me.organization.updateMemberRole({memberId:e,role:[n]});if(r?.error)throw new Error(r.error.message)}function Fn(t){le.error(t instanceof Error?t.message:"Failed to remove member")}async function Kn(t){const e=await me.organization.removeMember({memberIdOrEmail:t});if(e?.error)throw new Error(e.error.message)}function Qn(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Fr(){const t=re.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Ee,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:"Failed to load members"})})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Ns,{fallback:e,children:s.jsx(D.Suspense,{fallback:s.jsx(Ee,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(qe,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(Ln,{})})}),t[1]=n):n=t[1],n}export{Fr as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as a,bt as N,j as _,c as Me,bm as te}from"./index-
|
|
1
|
+
import{r as a,bt as N,j as _,c as Me,bm as te}from"./index-BKpxPW_G.js";import{S as me}from"./spinner-Lv2khbLw.js";const Pe=({size:e=24,color:t="currentColor",...r})=>a.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},a.createElement("path",{d:"M12 6v6l4 2m6-2c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));Pe.displayName="Clock";function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Re(e){if(Array.isArray(e))return e}function Se(e,t,r){return(t=Ve(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,u,l=[],c=!0,g=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(O){g=!0,o=O}finally{try{if(!c&&r.return!=null&&(u=r.return(),Object(u)!==u))return}finally{if(g)throw o}}return l}}function Te(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ce(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function se(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ce(Object(r),!0).forEach(function(n){Se(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ce(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function _e(e,t){if(e==null)return{};var r,n,o=Ce(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Ce(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Ie(e,t){return Re(e)||xe(e,t)||Ae(e,t)||Te()}function Le(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ve(e){var t=Le(e,"string");return typeof t=="symbol"?t:t+""}function Ae(e,t){if(e){if(typeof e=="string")return ue(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ue(e,t):void 0}}function $e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function le(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function fe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?le(Object(r),!0).forEach(function(n){$e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ne(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,i){return i(o)},n)}}function k(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,l=new Array(u),c=0;c<u;c++)l[c]=arguments[c];return t.apply(r,[].concat(o,l))}}}function Q(e){return{}.toString.call(e).includes("Object")}function De(e){return!Object.keys(e).length}function W(e){return typeof e=="function"}function ze(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ke(e,t){return Q(t)||T("changeType"),Object.keys(t).some(function(r){return!ze(e,r)})&&T("changeField"),t}function Ke(e){W(e)||T("selectorType")}function We(e){W(e)||Q(e)||T("handlerType"),Q(e)&&Object.values(e).some(function(t){return!W(t)})&&T("handlersType")}function qe(e){e||T("initialIsRequired"),Q(e)||T("initialType"),De(e)&&T("initialContent")}function Fe(e,t){throw new Error(e[t]||e.default)}var Ue={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},T=k(Fe)(Ue),B={changes:ke,selector:Ke,handler:We,initial:qe};function Be(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};B.initial(e),B.handler(t);var r={current:e},n=k(Qe)(r,t),o=k(He)(r),i=k(B.changes)(e),u=k(Je)(r);function l(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(O){return O};return B.selector(g),g(r.current)}function c(g){Ne(n,o,i,u)(g)}return[l,c]}function Je(e,t){return W(t)?t(e.current):t}function He(e,t){return e.current=fe(fe({},e.current),t),t}function Qe(e,t,r){return W(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var Ge={create:Be},Ye={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Ze(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,l=new Array(u),c=0;c<u;c++)l[c]=arguments[c];return t.apply(r,[].concat(o,l))}}}function Xe(e){return{}.toString.call(e).includes("Object")}function et(e){return e||de("configIsRequired"),Xe(e)||de("configType"),e.urls?(tt(),{paths:{vs:e.urls.monacoBase}}):e}function tt(){console.warn(he.deprecation)}function rt(e,t){throw new Error(e[t]||e.default)}var he={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
3
|
You are using deprecated way of configuration.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as g,c as me,m as ja,u as on,j as v,O as jr,t as br,bX as ni,b4 as rt,ad as Ie,bt as fe,bY as RC,a2 as LC,aW as $C,bZ as qC,b_ as FC,al as In,a_ as y1,a3 as Ar,aq as b1,av as Ko,an as Pr,b1 as Ur,a$ as BC,am as Yd,b6 as zC,b7 as x1,b5 as WC,x as UC,f as KC,K as HC}from"./index-
|
|
1
|
+
import{r as g,c as me,m as ja,u as on,j as v,O as jr,t as br,bX as ni,b4 as rt,ad as Ie,bt as fe,bY as RC,a2 as LC,aW as $C,bZ as qC,b_ as FC,al as In,a_ as y1,a3 as Ar,aq as b1,av as Ko,an as Pr,b1 as Ur,a$ as BC,am as Yd,b6 as zC,b7 as x1,b5 as WC,x as UC,f as KC,K as HC}from"./index-BKpxPW_G.js";import{C as YC}from"./collection-search-Bkd4qN8a.js";import{P as qt}from"./index-B9-4goiW.js";import{B as GC,a as VC,b as XC,c as ZC}from"./breadcrumb-ChH6wfcA.js";import{E as w1}from"./empty-state-DXJM9xrV.js";import{E as Oi}from"./error-boundary-BMH0CjEH.js";import{b as Ci,T as ji,a as Ai,I as oa,n as Vf}from"./integration-icon-DFSc5_D8.js";import{B as sa}from"./badge-DBw6AEaX.js";import{c as de}from"./utils-Ckp7rFN8.js";import{t as $i}from"./ChevronDown-DY4fpd0G.js";import{i as _1}from"./ChevronRight-DMzFQQCc.js";import{B as Ne,b as Kv}from"./button-D_OpQIQm.js";import{b as Aa,P as Na,a as Ma}from"./popover-ESVk6nXT.js";import{i as Ws}from"./Check-bgVFNRDs.js";import{a as ai}from"./Copy01-C35WeFYE.js";import{n as Hv}from"./Download01-Cihql6Z7.js";import{i as S1}from"./FilterLines-Bvkz4XO7.js";import{i as QC}from"./index-CnNzyZrg.js";import{i as JC}from"./Play-Bm8SKfhZ.js";import{M as Yv,s as ej}from"./monaco-editor-DZSx9WV6.js";import{c as It,b as Xf,d as tj,e as rj,a as nj,T as Qt}from"./table-BxUix49E.js";import{r as aj}from"./index--vZ0X2xS.js";import{f as ij,c as oj,a as Gv,d as sj,C as lj,e as uj,u as cj}from"./command-B5nNM5RC.js";import{i as fj,u as dj}from"./Code01-7hV4ZDjZ.js";import{h as Gd}from"./use-connection-B0740Saa.js";import{a as P1,u as O1,W as hj}from"./constants-DisdEZ3l.js";import{b as C1}from"./use-virtual-mcp-BUCuQhrG.js";import{c as vj}from"./Grid01-CfSiTcO8.js";import{s as mj}from"./Plus-BMOTPGqH.js";import{s as pj}from"./Trash01-d4v7i3Ze.js";import{I as ia}from"./input-lpAGMNlp.js";import{C as Vv}from"./checkbox-C1Sx9y02.js";import{e as gj,S as Xv,a as Zv,b as Qv,c as Jv,d as ii}from"./select-BbzYJ4VF.js";import{n as yj}from"./Calendar-DDieAsd2.js";import{T as bj}from"./textarea-BRJpMcB0.js";import{C as xj}from"./collection-tabs-N53MF1Jz.js";import{S as wj}from"./switch-sdaV-SJo.js";import{L as _j}from"./label-h0it3r-G.js";import{u as Sj}from"./use-mcp-tools-DF65_5AL.js";import{t as Pj}from"./Users03-Bw7fWrTD.js";import"./Loading01-C2vqzEw-.js";import"./SearchMd-BqVXNd65.js";import"./index-fVGDVKMq.js";import"./spinner-Lv2khbLw.js";import"./infiniteQueryObserver-B8M15Jhm.js";import"./useMutation-Bnsod7M-.js";import"./useQuery-Bo6lCSyK.js";const j1=({size:e=24,color:t="currentColor",...r})=>g.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},g.createElement("path",{d:"m15 18-6-6 6-6"}));j1.displayName="ChevronLeft";const A1=({size:e=24,color:t="currentColor",...r})=>g.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},g.createElement("path",{d:"M9.5 15V9m5 6V9m7.5 3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));A1.displayName="PauseCircle";const N1=({size:e=24,color:t="currentColor",...r})=>g.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},g.createElement("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Z"}),g.createElement("path",{d:"M9.5 8.965c0-.477 0-.716.1-.849a.5.5 0 0 1 .364-.199c.166-.012.367.117.769.375l4.72 3.035c.349.224.523.336.583.478a.5.5 0 0 1 0 .39c-.06.142-.234.254-.583.478l-4.72 3.035c-.402.258-.603.387-.769.375a.5.5 0 0 1-.364-.2c-.1-.132-.1-.371-.1-.848v-6.07Z"}));N1.displayName="PlayCircle";const M1=({size:e=24,color:t="currentColor",...r})=>g.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},g.createElement("path",{d:"M4 7c0-.932 0-1.398.152-1.765a2 2 0 0 1 1.083-1.083C5.602 4 6.068 4 7 4h10c.932 0 1.398 0 1.765.152a2 2 0 0 1 1.083 1.083C20 5.602 20 6.068 20 7M9 20h6M12 4v16"}));M1.displayName="Type01";const Zf={maxJsonRenderSize:5e4,pageSize:50,streamingRefetchInterval:3e3};function qr(e){return e.filter(t=>t.key.trim()).map(t=>{const r=encodeURIComponent(t.key.trim()),n=encodeURIComponent(t.value||"");return`${r}:${t.operator}:${n}`}).join(",")}function Oj(e){return e?e.split(",").map(t=>{const[r,n,...a]=t.split(":");return{key:decodeURIComponent(r||""),operator:n||"eq",value:decodeURIComponent(a.join(":")||"")}}):[]}function oi(e){return e.filter(t=>t.key.trim()).map(t=>{switch(t.operator){case"eq":return`${t.key}=${t.value}`;case"contains":return`${t.key}~${t.value}`;case"exists":return`${t.key}?`;case"in":return`${t.key}@${t.value}`}}).join(`
|
|
2
2
|
`)}function em(e){return e.trim()?e.split(`
|
|
3
3
|
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{if(t.endsWith("?"))return{key:t.slice(0,-1),operator:"exists",value:""};if(t.includes("=")){const[r,...n]=t.split("=");return{key:r||"",operator:"eq",value:n.join("=")}}if(t.includes("~")){const[r,...n]=t.split("~");return{key:r||"",operator:"contains",value:n.join("~")}}if(t.includes("@")){const[r,...n]=t.split("@");return{key:r||"",operator:"in",value:n.join("@")}}return{key:t,operator:"exists",value:""}}):[]}function Cj(e){const t={},r={},n=[],a={};for(const i of e)if(i.key.trim())switch(i.operator){case"eq":i.value&&(t[i.key]=i.value);break;case"contains":i.value&&(r[i.key]=`%${i.value}%`);break;case"exists":n.push(i.key);break;case"in":i.value&&(a[i.key]=i.value);break}return{properties:Object.keys(t).length>0?t:void 0,propertyPatterns:Object.keys(r).length>0?r:void 0,propertyKeys:n.length>0?n:void 0,propertyInValues:Object.keys(a).length>0?a:void 0}}function tm(e){if(!e)return{content:"null",isTruncated:!1,originalSize:4};const t=JSON.stringify(e,null,2),r=t.length;return r<=Zf.maxJsonRenderSize?{content:t,isTruncated:!1,originalSize:r}:{content:t.slice(0,Zf.maxJsonRenderSize)+`
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,j as e}from"./index-
|
|
1
|
+
import{r as i,j as e}from"./index-BKpxPW_G.js";import{i as n}from"./Loading01-C2vqzEw-.js";import{h as l}from"./mcp-oauth-DQYLB8aB.js";function h(){const[s,c]=i.useState(null),[r,a]=i.useState(!1);return i.useEffect(()=>{(async()=>{try{const t=await l();if(!t.success){c(t.error||"MCP authentication failed"),setTimeout(()=>{window.close()},3e3);return}a(!0),setTimeout(()=>{window.close()},1500)}catch(t){c(t instanceof Error?t.message:String(t)),setTimeout(()=>{window.close()},3e3)}})()},[]),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-8 bg-background",children:e.jsxs("div",{className:"w-full max-w-md flex flex-col items-center justify-center gap-8",children:[r&&e.jsx("img",{src:"/empty-state-success.svg",alt:"",width:220,height:200,"aria-hidden":"true"}),!r&&!s&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(n,{size:32,className:"animate-spin text-primary"})}),s&&e.jsx("img",{src:"/empty-state-error.svg",alt:"",width:220,height:200,"aria-hidden":"true"}),e.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[e.jsx("h2",{className:"text-lg font-medium text-foreground",children:s?"Authentication Failed":r?"Authentication Successful":"Authentication in progress..."}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-2",children:"An error occurred during authentication:"}),e.jsx("p",{className:"text-destructive",children:s}),e.jsxs("p",{className:"mt-2",children:[e.jsx("br",{}),"This window will close automatically."]})]}):r?e.jsxs("p",{children:["Authentication complete.",e.jsx("br",{}),"This window will close automatically."]}):e.jsx("p",{children:"Processing authentication..."})})]})]})})}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as G,r as D,u as X,y as ue,K as le,bq as xe,j as s,m as oe,O as ie,g as ge,br as pe,l as he}from"./index-HxeE9C0A.js";import{P as U}from"./index-wUnd_o-U.js";import{B as je,a as ve,b as ye,c as be}from"./breadcrumb-t_Ccp20G.js";import{i as ae}from"./FilterLines-CDkZPaiO.js";import{n as Ne}from"./Inbox01-Bz-1SNbb.js";import{i as Z}from"./Loading01-CudhqwtJ.js";import{i as ce}from"./SearchMd-yRVgOeax.js";import{u as Ce}from"./useInfiniteQuery-CL3o6Gdm.js";import{a as Se,f as we,b as Te}from"./registry-utils-CLfG2KJO.js";import{u as Ie,h as Re,b as Pe}from"./constants-BEco_-y7.js";import{f as $e,g as me,h as ke}from"./use-connection-DWpxH8iy.js";import{s as Le}from"./slugify-CEUa2lfQ.js";import{C as ze}from"./collection-search-D3a5_1zR.js";import{M as re}from"./mcp-server-card-8DET7nVd.js";import{B as J}from"./button-C1iesapY.js";import{I as Fe}from"./input-DBGu1Yhi.js";import{c as de}from"./utils-D1Qd9-I_.js";import{b as Ke,P as Ae,a as Ee}from"./popover-BbAo_V3q.js";import{i as Be}from"./Check-BIlnRzi6.js";import{t as De}from"./ChevronDown-jAfIG9nZ.js";import{s as Y}from"./XClose-S1Me7eeg.js";import{d as Me,a as Oe,b as Ve,c as _e,S as We}from"./select-CnIfeZ9k.js";import{s as qe}from"./Plus-BVPnBK8D.js";import{E as Ge}from"./empty-state-CH3e4Xzf.js";import{u as He}from"./use-binding-BIvDtNoa.js";import{L as Ue,u as Je}from"./localstorage-keys-BxVB7BFB.js";import"./ChevronRight-CNYkXy1u.js";import"./infiniteQueryObserver-CSOdbqFL.js";import"./useMutation-M3-wug2Q.js";import"./integration-icon-CmJggqPx.js";import"./index-ByJoFAq_.js";import"./Globe02-CNtZ4Mz7.js";import"./Lock01-C3j5poil.js";import"./Terminal-DV_yPRWa.js";import"./card-DKzkS6ji.js";import"./github-icon-Dp3wHhYE.js";import"./binder-xcUkLvPC.js";import"./useQuery-jRtVXI31.js";function Qe(t,e){const l=G.c(4),[n,c]=D.useState(t),r=D.useRef(null),a=D.useRef(!0);let i,m;return l[0]!==e||l[1]!==t?(i=()=>{if(a.current){a.current=!1;return}return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{c(t)},e),()=>{r.current&&clearTimeout(r.current)}},m=[t,e],l[0]=e,l[1]=t,l[2]=i,l[3]=m):(i=l[2],m=l[3]),D.useEffect(i,m),n}function Ye(t){const e=G.c(14),l=D.useRef(null),n=`scroll-position:${t}`,c=D.useRef(null);let r;e[0]!==n?(r=()=>{l.current&&sessionStorage.setItem(n,String(l.current.scrollTop))},e[0]=n,e[1]=r):r=e[1];const a=r;let i;e[2]!==n?(i=()=>{if(c.current===n)return;const d=sessionStorage.getItem(n);if(d&&l.current){const j=Number.parseInt(d,10);l.current.scrollTop=j}c.current=n},e[2]=n,e[3]=i):i=e[3];const m=i;let y;e[4]!==m||e[5]!==n?(y=()=>{c.current!==n&&m()},e[4]=m,e[5]=n,e[6]=y):y=e[6];const p=y;let o;e[7]!==m||e[8]!==n?(o=d=>{l.current=d,d&&c.current!==n&&requestAnimationFrame(()=>{m()})},e[7]=m,e[8]=n,e[9]=o):o=e[9];const b=o;let u;return e[10]!==p||e[11]!==a||e[12]!==b?(u={scrollRef:b,saveScrollPosition:a,handleScroll:p},e[10]=p,e[11]=a,e[12]=b,e[13]=u):u=e[13],u}const Ze=24;function Xe(t){const e=G.c(53),{registryId:l,listToolName:n,filtersToolName:c,search:r}=t,{org:a}=X();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[m,y]=D.useState(i);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[1]=p):p=e[1];const[o,b]=D.useState(p),u=l||null;let d;e[2]!==a.id||e[3]!==u?(d={connectionId:u,orgId:a.id},e[2]=a.id,e[3]=u,e[4]=d):d=e[4];const j=Ie(d),I=!!c;let N;e[5]!==c||e[6]!==l?(N=le.toolCall(l,c||"no-filters","{}"),e[5]=c,e[6]=l,e[7]=N):N=e[7];let C;e[8]!==j||e[9]!==c?(C=async()=>{if(!c)return{tags:[],categories:[]};const B=await j.callTool({name:c,arguments:{}});return B.structuredContent??B},e[8]=j,e[9]=c,e[10]=C):C=e[10];let L;e[11]!==N||e[12]!==C?(L={queryKey:N,queryFn:C,staleTime:36e5},e[11]=N,e[12]=C,e[13]=L):L=e[13];const{data:$}=ue(L);let v,S,w;if(e[14]!==n||e[15]!==l||e[16]!==r||e[17]!==o||e[18]!==m){const B=r?.trim()?{operator:"or",conditions:[{field:["name"],operator:"contains",value:r},{field:["title"],operator:"contains",value:r},{field:["description"],operator:"contains",value:r}]}:void 0;v={limit:Ze,...m.length>0&&{tags:m},...o.length>0&&{categories:o},...B&&{where:B}},w=Ce,S=le.toolCall(l,n,JSON.stringify(v)),e[14]=n,e[15]=l,e[16]=r,e[17]=o,e[18]=m,e[19]=v,e[20]=S,e[21]=w}else v=e[19],S=e[20],w=e[21];let T;e[22]!==j||e[23]!==v||e[24]!==n?(T=async B=>{const{pageParam:te}=B,fe=te?{...v,cursor:te}:v,se=await j.callTool({name:n,arguments:fe});return se.structuredContent??se},e[22]=j,e[23]=v,e[24]=n,e[25]=T):T=e[25];let z;e[26]!==T||e[27]!==S?(z={queryKey:S,queryFn:T,initialPageParam:void 0,getNextPageParam:et,staleTime:36e5,placeholderData:xe},e[26]=T,e[27]=S,e[28]=z):z=e[28];const{data:A,fetchNextPage:k,hasNextPage:f,isFetchingNextPage:x,isFetching:g,isLoading:R}=w(z);let P;e:{if(!A?.pages||A.pages.length===0){P=null;break e}const B=A.pages[0];if(typeof B=="object"&&B!==null&&"totalCount"in B&&typeof B.totalCount=="number"){P=B.totalCount;break e}P=null}const K=P,h=A?.pages;let F;e[29]!==h?(F=Se(h),e[29]=h,e[30]=F):F=e[30];const E=F;let O;e[31]!==r||e[32]!==o.length||e[33]!==m.length?(O=m.length>0||o.length>0||!!r?.trim(),e[31]=r,e[32]=o.length,e[33]=m.length,e[34]=O):O=e[34];const V=O,W=g&&!x&&!R&&V;let q;e[35]!==k||e[36]!==f||e[37]!==x?(q=()=>{f&&!x&&k()},e[35]=k,e[36]=f,e[37]=x,e[38]=q):q=e[38];const M=q,_=f??!1,H=I?$?.tags:void 0,ee=I?$?.categories:void 0;let Q;return e[39]!==V||e[40]!==g||e[41]!==x||e[42]!==W||e[43]!==R||e[44]!==E||e[45]!==M||e[46]!==o||e[47]!==m||e[48]!==_||e[49]!==H||e[50]!==ee||e[51]!==K?(Q={items:E,totalCount:K,hasMore:_,isLoadingMore:x,isFiltering:W,isInitialLoading:R,isFetching:g,loadMore:M,availableTags:H,availableCategories:ee,selectedTags:m,selectedCategories:o,setSelectedTags:y,setSelectedCategories:b,hasActiveFilters:V},e[39]=V,e[40]=g,e[41]=x,e[42]=W,e[43]=R,e[44]=E,e[45]=M,e[46]=o,e[47]=m,e[48]=_,e[49]=H,e[50]=ee,e[51]=K,e[52]=Q):Q=e[52],Q}function et(t){if(typeof t=="object"&&t!==null){const e=t.nextCursor||t.cursor;if(e)return e}}function tt(t,e){return[...t].sort((l,n)=>n.count-l.count).slice(0,e)}function ne(t){const e=G.c(52),{label:l,items:n,selectedItems:c,onToggle:r,onClear:a}=t,[i,m]=D.useState(""),[y,p]=D.useState(!1);let o,b,u,d,j,I,N,C,L,$,v;if(e[0]!==n||e[1]!==l||e[2]!==r||e[3]!==y||e[4]!==i||e[5]!==c){const k=[...i?n.filter(F=>F.value.toLowerCase().includes(i.toLowerCase())):n].sort(st);u=c.length,b=Ke,L=y,$=p;let f;e[17]!==l?(f=s.jsx("span",{children:l}),e[17]=l,e[18]=f):f=e[18];let x;e[19]!==u?(x=u>0&&s.jsx("span",{className:"ml-1 rounded-full bg-primary text-primary-foreground px-1.5 py-0.5 text-[10px] font-medium",children:u}),e[19]=u,e[20]=x):x=e[20];let g;e[21]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(De,{size:14,className:"opacity-50"}),e[21]=g):g=e[21],e[22]!==x||e[23]!==f?(v=s.jsx(Ae,{asChild:!0,children:s.jsxs(J,{variant:"outline",size:"sm",className:"h-7 px-3 gap-1.5 text-xs font-normal flex-1",children:[f,x,g]})}),e[22]=x,e[23]=f,e[24]=v):v=e[24],o=Ee,I="w-64 p-0",N="start";let R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(ce,{size:16,className:"text-muted-foreground shrink-0"}),e[25]=R):R=e[25];let P;e[26]!==l?(P=l.toLowerCase(),e[26]=l,e[27]=P):P=e[27];const K=`Search ${P}...`;let h;e[28]===Symbol.for("react.memo_cache_sentinel")?(h=F=>m(F.target.value),e[28]=h):h=e[28],e[29]!==i||e[30]!==K?(C=s.jsx("div",{className:"shrink-0 w-full border-b border-border h-10",children:s.jsxs("label",{className:"flex items-center gap-2.5 h-10 px-4 cursor-text",children:[R,s.jsx(Fe,{type:"text",placeholder:K,value:i,onChange:h,className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[29]=i,e[30]=K,e[31]=C):C=e[31],d="max-h-64 overflow-y-auto p-1 flex flex-col gap-1",j=k.length===0?s.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground text-center",children:"No results found"}):k.map(F=>{const E=c.includes(F.value);return s.jsxs("button",{onClick:()=>r(F.value),className:de("w-full flex items-center justify-between px-2 py-1.5 text-sm rounded cursor-pointer transition-colors",E?"bg-accent/50 text-foreground":"hover:bg-muted text-foreground"),children:[s.jsxs("span",{className:"truncate flex items-center gap-2",children:[E&&s.jsx(Be,{size:16,className:"text-muted-foreground shrink-0"}),F.value]}),s.jsx("span",{className:"text-xs text-muted-foreground ml-2 shrink-0",children:F.count})]},F.value)}),e[0]=n,e[1]=l,e[2]=r,e[3]=y,e[4]=i,e[5]=c,e[6]=o,e[7]=b,e[8]=u,e[9]=d,e[10]=j,e[11]=I,e[12]=N,e[13]=C,e[14]=L,e[15]=$,e[16]=v}else o=e[6],b=e[7],u=e[8],d=e[9],j=e[10],I=e[11],N=e[12],C=e[13],L=e[14],$=e[15],v=e[16];let S;e[32]!==d||e[33]!==j?(S=s.jsx("div",{className:d,children:j}),e[32]=d,e[33]=j,e[34]=S):S=e[34];let w;e[35]!==l||e[36]!==a||e[37]!==u?(w=u>0&&s.jsx("div",{className:"p-2 border-t border-border",children:s.jsxs(J,{variant:"ghost",size:"sm",onClick:a,className:"w-full text-xs text-muted-foreground hover:text-foreground",children:["Clear ",l.toLowerCase()]})}),e[35]=l,e[36]=a,e[37]=u,e[38]=w):w=e[38];let T;e[39]!==o||e[40]!==w||e[41]!==I||e[42]!==N||e[43]!==C||e[44]!==S?(T=s.jsxs(o,{className:I,align:N,children:[C,S,w]}),e[39]=o,e[40]=w,e[41]=I,e[42]=N,e[43]=C,e[44]=S,e[45]=T):T=e[45];let z;return e[46]!==b||e[47]!==T||e[48]!==L||e[49]!==$||e[50]!==v?(z=s.jsxs(b,{open:L,onOpenChange:$,children:[v,T]}),e[46]=b,e[47]=T,e[48]=L,e[49]=$,e[50]=v,e[51]=z):z=e[51],z}function st(t,e){return e.count-t.count}function lt(t){const e=G.c(67),{availableTags:l,availableCategories:n,selectedTags:c,selectedCategories:r,onTagChange:a,onCategoryChange:i}=t,m=l&&l.length>0||n&&n.length>0,y=c.length>0||r.length>0;if(!m)return null;let p;e[0]!==a||e[1]!==c?(p=f=>{c.includes(f)?a(c.filter(x=>x!==f)):a([...c,f])},e[0]=a,e[1]=c,e[2]=p):p=e[2];const o=p;let b;e[3]!==i||e[4]!==r?(b=f=>{r.includes(f)?i(r.filter(x=>x!==f)):i([...r,f])},e[3]=i,e[4]=r,e[5]=b):b=e[5];const u=b;let d;e[6]!==i||e[7]!==a?(d=()=>{a([]),i([])},e[6]=i,e[7]=a,e[8]=d):d=e[8];const j=d;let I,N,C,L,$,v,S;if(e[9]!==n||e[10]!==l||e[11]!==i||e[12]!==a||e[13]!==r||e[14]!==c||e[15]!==u||e[16]!==o){const f=n?tt(n,6):[];I=r,N=c,S=new Set(f.map(rt)),$="flex items-center border-b border-border";let x;e[24]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:s.jsx(ae,{size:16})}),e[24]=x):x=e[24];let g;e[25]!==n||e[26]!==i||e[27]!==r||e[28]!==u?(g=n&&n.length>0&&s.jsx(ne,{label:"Categories",items:n,selectedItems:r,onToggle:u,onClear:()=>i([])}),e[25]=n,e[26]=i,e[27]=r,e[28]=u,e[29]=g):g=e[29];let R;e[30]!==l||e[31]!==a||e[32]!==c||e[33]!==o?(R=l&&l.length>0&&s.jsx(ne,{label:"Tags",items:l,selectedItems:c,onToggle:o,onClear:()=>a([])}),e[30]=l,e[31]=a,e[32]=c,e[33]=o,e[34]=R):R=e[34],e[35]!==R||e[36]!==g?(v=s.jsxs("div",{className:"flex items-center gap-3 flex-wrap px-5 py-3 border-r border-border",children:[x,g,R]}),e[35]=R,e[36]=g,e[37]=v):v=e[37],C="flex items-center gap-3 flex-wrap px-5 py-3";let P;e[38]!==r||e[39]!==u?(P=K=>{const h=r.includes(K.value);return s.jsxs("div",{onClick:()=>u(K.value),className:de("inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-full transition-colors cursor-pointer",h?"bg-primary text-primary-foreground hover:bg-primary/80":"bg-muted hover:bg-accent text-muted-foreground"),children:[s.jsx("span",{children:K.value}),h&&s.jsx("span",{onClick:F=>{F.stopPropagation(),u(K.value)},className:"hover:bg-primary/20 rounded-full p-0.5 -mr-1 cursor-pointer flex items-center",children:s.jsx(Y,{size:12})})]},K.value)},e[38]=r,e[39]=u,e[40]=P):P=e[40],L=f.map(P),e[9]=n,e[10]=l,e[11]=i,e[12]=a,e[13]=r,e[14]=c,e[15]=u,e[16]=o,e[17]=I,e[18]=N,e[19]=C,e[20]=L,e[21]=$,e[22]=v,e[23]=S}else I=e[17],N=e[18],C=e[19],L=e[20],$=e[21],v=e[22],S=e[23];let w;if(e[41]!==I||e[42]!==u||e[43]!==S){let f;e[45]!==S?(f=g=>!S.has(g),e[45]=S,e[46]=f):f=e[46];let x;e[47]!==u?(x=g=>s.jsxs("div",{onClick:()=>u(g),className:"inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-full transition-colors cursor-pointer bg-primary text-primary-foreground hover:bg-accent/50",children:[s.jsx("span",{children:g}),s.jsx("span",{onClick:R=>{R.stopPropagation(),u(g)},className:"hover:bg-primary/20 rounded-full p-0.5 -mr-1 cursor-pointer flex items-center",children:s.jsx(Y,{size:12})})]},`cat-${g}`),e[47]=u,e[48]=x):x=e[48],w=I.filter(f).map(x),e[41]=I,e[42]=u,e[43]=S,e[44]=w}else w=e[44];let T;if(e[49]!==N||e[50]!==o){let f;e[52]!==o?(f=x=>s.jsxs("div",{onClick:()=>o(x),className:"inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-full transition-colors cursor-pointer bg-primary text-primary-foreground hover:bg-accent/50",children:[s.jsx("span",{children:x}),s.jsx("span",{onClick:g=>{g.stopPropagation(),o(x)},className:"hover:bg-primary/20 rounded-full p-0.5 -mr-1 cursor-pointer flex items-center",children:s.jsx(Y,{size:12})})]},`tag-${x}`),e[52]=o,e[53]=f):f=e[53],T=N.map(f),e[49]=N,e[50]=o,e[51]=T}else T=e[51];let z;e[54]!==j||e[55]!==y?(z=y&&s.jsxs(J,{variant:"ghost",size:"sm",onClick:j,className:"h-7 text-xs text-muted-foreground hover:text-foreground gap-1 px-2",children:[s.jsx(Y,{size:14}),"Clear all"]}),e[54]=j,e[55]=y,e[56]=z):z=e[56];let A;e[57]!==z||e[58]!==C||e[59]!==L||e[60]!==w||e[61]!==T?(A=s.jsxs("div",{className:C,children:[L,w,T,z]}),e[57]=z,e[58]=C,e[59]=L,e[60]=w,e[61]=T,e[62]=A):A=e[62];let k;return e[63]!==A||e[64]!==$||e[65]!==v?(k=s.jsxs("div",{className:$,children:[v,A]}),e[63]=A,e[64]=$,e[65]=v,e[66]=k):k=e[66],k}function rt(t){return t.value}function nt(t,e){if(!e)return t;const l=e.toLowerCase();return t.filter(n=>(n.name||n.title||"").toLowerCase().includes(l)||(n.description||n.server.description||"").toLowerCase().includes(l))}function ot(t){return t.verified===!0||t._meta?.["mcp.mesh"]?.verified===!0}function it(t){const e=G.c(54),{registryId:l,listToolName:n,filtersToolName:c}=t,[r,a]=D.useState(""),i=Qe(r,300),m=oe(),{org:y}=X(),{scrollRef:p,saveScrollPosition:o,handleScroll:b}=Ye(`store-discovery:${l}`);let u;e[0]!==i||e[1]!==c||e[2]!==n||e[3]!==l?(u={registryId:l,listToolName:n,filtersToolName:c,search:i},e[0]=i,e[1]=c,e[2]=n,e[3]=l,e[4]=u):u=e[4];const{items:d,hasMore:j,isLoadingMore:I,isInitialLoading:N,isFetching:C,loadMore:L,availableTags:$,availableCategories:v,selectedTags:S,selectedCategories:w,setSelectedTags:T,setSelectedCategories:z,hasActiveFilters:A}=Xe(u);let k,f,x,g;e[5]!==i||e[6]!==C||e[7]!==N||e[8]!==d||e[9]!==r?(k=r?nt(d,r):d,f=(r!==i||C)&&!N&&!!r,g=k.filter(ot),x=k.filter(M=>!g.find(_=>_.id===M.id)),e[5]=i,e[6]=C,e[7]=N,e[8]=d,e[9]=r,e[10]=k,e[11]=f,e[12]=x,e[13]=g):(k=e[10],f=e[11],x=e[12],g=e[13]);const R=x;let P;e[14]!==m||e[15]!==y.slug||e[16]!==l||e[17]!==o?(P=M=>{o();const _=Le(M.name||M.title||M.server.title||""),H=M.server.name;m({to:"/$org/$project/store/$appName",params:{org:y.slug,project:ie,appName:_},search:{registryId:l,serverName:H}})},e[14]=m,e[15]=y.slug,e[16]=l,e[17]=o,e[18]=P):P=e[18];const K=P;let h;e[19]!==b||e[20]!==j||e[21]!==I||e[22]!==L?(h=M=>{if(b(),!j||I)return;const _=M.currentTarget;_.scrollHeight-_.scrollTop-_.clientHeight<200&&L()},e[19]=b,e[20]=j,e[21]=I,e[22]=L,e[23]=h):h=e[23];const F=h;let E;e[24]!==f||e[25]!==r?(E=s.jsx(ze,{value:r,onChange:a,placeholder:"Search for an MCP Server...",isSearching:f}),e[24]=f,e[25]=r,e[26]=E):E=e[26];let O;e[27]!==v||e[28]!==$||e[29]!==w||e[30]!==S||e[31]!==z||e[32]!==T?(O=s.jsx(lt,{availableTags:$,availableCategories:v,selectedTags:S,selectedCategories:w,onTagChange:T,onCategoryChange:z}),e[27]=v,e[28]=$,e[29]=w,e[30]=S,e[31]=z,e[32]=T,e[33]=O):O=e[33];let V;e[34]!==R||e[35]!==k||e[36]!==K||e[37]!==A||e[38]!==j||e[39]!==N||e[40]!==I||e[41]!==f||e[42]!==d||e[43]!==r||e[44]!==g?(V=s.jsx("div",{className:"p-5",children:s.jsx("div",{children:N?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(Z,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading items..."})]}):d.length===0&&!A?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(Ne,{size:48,className:"text-muted-foreground mb-4"}),s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No items available"}),s.jsx("p",{className:"text-muted-foreground",children:"This store doesn't have any available items yet."})]}):d.length===0&&A&&!r?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(ae,{size:48,className:"text-muted-foreground mb-4"}),s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No matching items"}),s.jsx("p",{className:"text-muted-foreground",children:"Try adjusting your filters to find more results."})]}):r&&k.length===0&&!f?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(ce,{size:48,className:"text-muted-foreground mb-4"}),s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No results found"}),s.jsx("p",{className:"text-muted-foreground",children:"Try adjusting your search terms."})]}):s.jsxs("div",{className:"flex flex-col gap-8",children:[f&&k.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(Z,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Searching..."})]}),g.length>0&&s.jsx(re,{items:g,title:"Verified",onItemClick:K}),R.length>0&&s.jsx(re,{items:R,title:g.length>0?"All":"",onItemClick:K}),j&&I&&s.jsx("div",{className:"flex justify-center py-8",children:s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(Z,{size:20,className:"animate-spin"}),s.jsx("span",{className:"text-sm",children:"Loading more items..."})]})})]})})}),e[34]=R,e[35]=k,e[36]=K,e[37]=A,e[38]=j,e[39]=N,e[40]=I,e[41]=f,e[42]=d,e[43]=r,e[44]=g,e[45]=V):V=e[45];let W;e[46]!==F||e[47]!==p||e[48]!==V?(W=s.jsx("div",{ref:p,className:"flex-1 overflow-y-auto",onScroll:F,children:V}),e[46]=F,e[47]=p,e[48]=V,e[49]=W):W=e[49];let q;return e[50]!==E||e[51]!==O||e[52]!==W?(q=s.jsxs("div",{className:"flex flex-col h-full",children:[E,O,W]}),e[50]=E,e[51]=O,e[52]=W,e[53]=q):q=e[53],q}function at(t){const e=G.c(8),{registryId:l}=t,n=$e(l),c=n?.tools;let r;e[0]!==c?(r=we(c),e[0]=c,e[1]=r):r=e[1];const a=r;if(!a)throw new Error("This registry does not support listing store items.");const i=n?.tools;let m;e[2]!==i?(m=Te(i),e[2]=i,e[3]=m):m=e[3];const p=m||void 0;let o;return e[4]!==a||e[5]!==l||e[6]!==p?(o=s.jsx(it,{registryId:l,listToolName:a,filtersToolName:p}),e[4]=a,e[5]=l,e[6]=p,e[7]=o):o=e[7],o}function ct(t){const e=G.c(15),{registries:l,value:n,onValueChange:c,onAddWellKnown:r,wellKnownRegistries:a,placeholder:i}=t,m=i===void 0?"Select a registry...":i;let y;e[0]!==m?(y=s.jsx(Oe,{size:"sm",className:"w-auto min-w-[160px]",children:s.jsx(Ve,{placeholder:m})}),e[0]=m,e[1]=y):y=e[1];let p;e[2]!==l?(p=l.map(mt),e[2]=l,e[3]=p):p=e[3];let o;e[4]!==r||e[5]!==a?(o=a.length>0&&s.jsxs("div",{className:"border-t border-border pt-1",children:[s.jsx("p",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Other known registries"}),a.map(d=>s.jsxs("button",{onClick:j=>{j.preventDefault(),j.stopPropagation(),r(d)},className:"relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-1.5 pr-8 pl-2 text-sm outline-hidden select-none hover:bg-accent hover:text-accent-foreground",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[d.icon?s.jsx("img",{src:d.icon,alt:d.title,className:"w-4 h-4 rounded"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:d.title.slice(0,1).toUpperCase()}),s.jsx("span",{className:"flex-1",children:d.title})]}),s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center text-muted-foreground",children:s.jsx(qe,{size:16})})]},d.id??d.title))]}),e[4]=r,e[5]=a,e[6]=o):o=e[6];let b;e[7]!==p||e[8]!==o?(b=s.jsxs(_e,{children:[p,o]}),e[7]=p,e[8]=o,e[9]=b):b=e[9];let u;return e[10]!==c||e[11]!==y||e[12]!==b||e[13]!==n?(u=s.jsxs(We,{value:n,onValueChange:c,children:[y,b]}),e[10]=c,e[11]=y,e[12]=b,e[13]=n,e[14]=u):u=e[14],u}function mt(t){return s.jsx(Me,{className:"cursor-pointer",value:t.id??t.name,children:s.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?s.jsx("img",{src:t.icon,alt:t.name,className:"w-4 h-4 rounded"}):s.jsx("div",{className:"w-4 h-4 rounded from-primary/20 to-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:t.name.slice(0,1).toUpperCase()}),s.jsx("span",{children:t.name})]})},t.id??t.name)}function dt({registries:t,onConnected:e}){const l=me(),{org:{slug:n}}=X(),{data:c}=ge.useSession(),r=oe(),[a,i]=D.useState(!1),m=t[0],y=async()=>{if(!(!m||!c?.user?.id)){i(!0);try{const o=await l.create.mutateAsync(m);e?.(o.id)}finally{i(!1)}}},p=()=>{r({to:"/$org/$project/mcps",params:{org:n,project:ie},search:{action:"create"}})};return s.jsx(Ge,{image:s.jsx("img",{src:"/store-empty-state.svg",alt:"No store connected",width:336,height:320,className:"max-w-full h-auto"}),title:"Connect to registry",description:"Connect to discover and use Connections from the community.",actions:s.jsxs(s.Fragment,{children:[s.jsxs(J,{variant:"outline",onClick:y,disabled:a||!m,children:[m?.icon&&s.jsx("img",{src:m.icon,alt:"",className:"size-4"}),a?"Installing...":"Install Registry"]}),s.jsx(J,{variant:"outline",onClick:p,children:"Custom Connection"})]})})}function Xt(){const t=G.c(42),{org:e}=X(),l=ke(),n=me(),c=pe(),r=c.location.pathname.includes("/store/")&&c.location.pathname.split("/").length>3,a=He(l);let i;t[0]!==a?(i=a.map(xt),t[0]=a,t[1]=i):i=t[1];const m=i;let y;t[2]!==e.slug?(y=Ue.selectedRegistry(e.slug),t[2]=e.slug,t[3]=y):y=t[3];const[p,o]=Je(y,ut);let b;if(t[4]!==a||t[5]!==p){let h;t[7]!==p?(h=F=>F.id===p,t[7]=p,t[8]=h):h=t[8],b=a.find(h),t[4]=a,t[5]=p,t[6]=b}else b=t[6];const d=b?.id||a[0]?.id||"";let j;t[9]!==e.id?(j=Re(e.id),t[9]=e.id,t[10]=j):j=t[10];let I;t[11]!==j?(I=[j],t[11]=j,t[12]=I):I=t[12];const N=I;let C;t[13]===Symbol.for("react.memo_cache_sentinel")?(C=[Pe()],t[13]=C):C=t[13];const L=C;let $;t[14]!==n.create||t[15]!==o?($=async h=>{const F=await n.create.mutateAsync(h);o(F.id)},t[14]=n.create,t[15]=o,t[16]=$):$=t[16];const v=$;let S;t[17]!==a?(S=new Set(a.map(ft)),t[17]=a,t[18]=S):S=t[18];const w=S;let T;t[19]!==w||t[20]!==N?(T=N.filter(h=>h.id&&!w.has(h.id)),t[19]=w,t[20]=N,t[21]=T):T=t[21];const z=T;let A;t[22]!==w?(A=L.filter(h=>h.id&&!w.has(h.id)),t[22]=w,t[23]=A):A=t[23];const k=A;if(r){let h;return t[24]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(he,{}),t[24]=h):h=t[24],h}let f;t[25]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(U.Header.Left,{children:s.jsx(je,{children:s.jsx(ve,{children:s.jsx(ye,{children:s.jsx(be,{children:"Store"})})})})}),t[25]=f):f=t[25];let x;t[26]!==v?(x=async h=>v(h),t[26]=v,t[27]=x):x=t[27];let g;t[28]!==z||t[29]!==d||t[30]!==m||t[31]!==o||t[32]!==x?(g=s.jsxs(U.Header,{children:[f,s.jsx(U.Header.Right,{children:s.jsx(ct,{wellKnownRegistries:z,registries:m,value:d,onValueChange:o,onAddWellKnown:x,placeholder:"Select store..."})})]}),t[28]=z,t[29]=d,t[30]=m,t[31]=o,t[32]=x,t[33]=g):g=t[33];let R;t[34]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[s.jsx(Z,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading store items..."})]}),t[34]=R):R=t[34];let P;t[35]!==k||t[36]!==d||t[37]!==o?(P=s.jsx(U.Content,{children:s.jsx(D.Suspense,{fallback:R,children:d?s.jsx(at,{registryId:d}):s.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:s.jsx(dt,{registries:k,onConnected:h=>{o(h)}})})})}),t[35]=k,t[36]=d,t[37]=o,t[38]=P):P=t[38];let K;return t[39]!==g||t[40]!==P?(K=s.jsxs(U,{children:[g,P]}),t[39]=g,t[40]=P,t[41]=K):K=t[41],K}function ft(t){return t.id}function ut(t){return t??""}function xt(t){return{id:t.id,name:t.title,icon:t.icon||void 0}}export{Xt as default};
|
|
1
|
+
import{c as G,r as D,u as X,y as ue,K as le,bq as xe,j as s,m as oe,O as ie,g as ge,br as pe,l as he}from"./index-BKpxPW_G.js";import{P as U}from"./index-B9-4goiW.js";import{B as je,a as ve,b as ye,c as be}from"./breadcrumb-ChH6wfcA.js";import{i as ae}from"./FilterLines-Bvkz4XO7.js";import{n as Ne}from"./Inbox01-Bhe6QhSW.js";import{i as Z}from"./Loading01-C2vqzEw-.js";import{i as ce}from"./SearchMd-BqVXNd65.js";import{u as Ce}from"./useInfiniteQuery-CsMrU_k5.js";import{a as Se,f as we,b as Te}from"./registry-utils-yxVJe3X4.js";import{u as Ie,h as Re,b as Pe}from"./constants-DisdEZ3l.js";import{f as $e,g as me,h as ke}from"./use-connection-B0740Saa.js";import{s as Le}from"./slugify-CEUa2lfQ.js";import{C as ze}from"./collection-search-Bkd4qN8a.js";import{M as re}from"./mcp-server-card-fBAhOAUG.js";import{B as J}from"./button-D_OpQIQm.js";import{I as Fe}from"./input-lpAGMNlp.js";import{c as de}from"./utils-Ckp7rFN8.js";import{b as Ke,P as Ae,a as Ee}from"./popover-ESVk6nXT.js";import{i as Be}from"./Check-bgVFNRDs.js";import{t as De}from"./ChevronDown-DY4fpd0G.js";import{s as Y}from"./XClose-CjpNuP8c.js";import{d as Me,a as Oe,b as Ve,c as _e,S as We}from"./select-BbzYJ4VF.js";import{s as qe}from"./Plus-BMOTPGqH.js";import{E as Ge}from"./empty-state-DXJM9xrV.js";import{u as He}from"./use-binding-DMsO_03X.js";import{L as Ue,u as Je}from"./localstorage-keys-CrJngaoW.js";import"./ChevronRight-DMzFQQCc.js";import"./infiniteQueryObserver-B8M15Jhm.js";import"./useMutation-Bnsod7M-.js";import"./integration-icon-DFSc5_D8.js";import"./index-fVGDVKMq.js";import"./Globe02-DSX2gzp_.js";import"./Lock01-ClMI2bMm.js";import"./Terminal-DRpoCIsG.js";import"./card-DAZxrY9k.js";import"./github-icon-Dp3wHhYE.js";import"./binder-Jddq1y1v.js";import"./useQuery-Bo6lCSyK.js";function Qe(t,e){const l=G.c(4),[n,c]=D.useState(t),r=D.useRef(null),a=D.useRef(!0);let i,m;return l[0]!==e||l[1]!==t?(i=()=>{if(a.current){a.current=!1;return}return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{c(t)},e),()=>{r.current&&clearTimeout(r.current)}},m=[t,e],l[0]=e,l[1]=t,l[2]=i,l[3]=m):(i=l[2],m=l[3]),D.useEffect(i,m),n}function Ye(t){const e=G.c(14),l=D.useRef(null),n=`scroll-position:${t}`,c=D.useRef(null);let r;e[0]!==n?(r=()=>{l.current&&sessionStorage.setItem(n,String(l.current.scrollTop))},e[0]=n,e[1]=r):r=e[1];const a=r;let i;e[2]!==n?(i=()=>{if(c.current===n)return;const d=sessionStorage.getItem(n);if(d&&l.current){const j=Number.parseInt(d,10);l.current.scrollTop=j}c.current=n},e[2]=n,e[3]=i):i=e[3];const m=i;let y;e[4]!==m||e[5]!==n?(y=()=>{c.current!==n&&m()},e[4]=m,e[5]=n,e[6]=y):y=e[6];const p=y;let o;e[7]!==m||e[8]!==n?(o=d=>{l.current=d,d&&c.current!==n&&requestAnimationFrame(()=>{m()})},e[7]=m,e[8]=n,e[9]=o):o=e[9];const b=o;let u;return e[10]!==p||e[11]!==a||e[12]!==b?(u={scrollRef:b,saveScrollPosition:a,handleScroll:p},e[10]=p,e[11]=a,e[12]=b,e[13]=u):u=e[13],u}const Ze=24;function Xe(t){const e=G.c(53),{registryId:l,listToolName:n,filtersToolName:c,search:r}=t,{org:a}=X();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[m,y]=D.useState(i);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[1]=p):p=e[1];const[o,b]=D.useState(p),u=l||null;let d;e[2]!==a.id||e[3]!==u?(d={connectionId:u,orgId:a.id},e[2]=a.id,e[3]=u,e[4]=d):d=e[4];const j=Ie(d),I=!!c;let N;e[5]!==c||e[6]!==l?(N=le.toolCall(l,c||"no-filters","{}"),e[5]=c,e[6]=l,e[7]=N):N=e[7];let C;e[8]!==j||e[9]!==c?(C=async()=>{if(!c)return{tags:[],categories:[]};const B=await j.callTool({name:c,arguments:{}});return B.structuredContent??B},e[8]=j,e[9]=c,e[10]=C):C=e[10];let L;e[11]!==N||e[12]!==C?(L={queryKey:N,queryFn:C,staleTime:36e5},e[11]=N,e[12]=C,e[13]=L):L=e[13];const{data:$}=ue(L);let v,S,w;if(e[14]!==n||e[15]!==l||e[16]!==r||e[17]!==o||e[18]!==m){const B=r?.trim()?{operator:"or",conditions:[{field:["name"],operator:"contains",value:r},{field:["title"],operator:"contains",value:r},{field:["description"],operator:"contains",value:r}]}:void 0;v={limit:Ze,...m.length>0&&{tags:m},...o.length>0&&{categories:o},...B&&{where:B}},w=Ce,S=le.toolCall(l,n,JSON.stringify(v)),e[14]=n,e[15]=l,e[16]=r,e[17]=o,e[18]=m,e[19]=v,e[20]=S,e[21]=w}else v=e[19],S=e[20],w=e[21];let T;e[22]!==j||e[23]!==v||e[24]!==n?(T=async B=>{const{pageParam:te}=B,fe=te?{...v,cursor:te}:v,se=await j.callTool({name:n,arguments:fe});return se.structuredContent??se},e[22]=j,e[23]=v,e[24]=n,e[25]=T):T=e[25];let z;e[26]!==T||e[27]!==S?(z={queryKey:S,queryFn:T,initialPageParam:void 0,getNextPageParam:et,staleTime:36e5,placeholderData:xe},e[26]=T,e[27]=S,e[28]=z):z=e[28];const{data:A,fetchNextPage:k,hasNextPage:f,isFetchingNextPage:x,isFetching:g,isLoading:R}=w(z);let P;e:{if(!A?.pages||A.pages.length===0){P=null;break e}const B=A.pages[0];if(typeof B=="object"&&B!==null&&"totalCount"in B&&typeof B.totalCount=="number"){P=B.totalCount;break e}P=null}const K=P,h=A?.pages;let F;e[29]!==h?(F=Se(h),e[29]=h,e[30]=F):F=e[30];const E=F;let O;e[31]!==r||e[32]!==o.length||e[33]!==m.length?(O=m.length>0||o.length>0||!!r?.trim(),e[31]=r,e[32]=o.length,e[33]=m.length,e[34]=O):O=e[34];const V=O,W=g&&!x&&!R&&V;let q;e[35]!==k||e[36]!==f||e[37]!==x?(q=()=>{f&&!x&&k()},e[35]=k,e[36]=f,e[37]=x,e[38]=q):q=e[38];const M=q,_=f??!1,H=I?$?.tags:void 0,ee=I?$?.categories:void 0;let Q;return e[39]!==V||e[40]!==g||e[41]!==x||e[42]!==W||e[43]!==R||e[44]!==E||e[45]!==M||e[46]!==o||e[47]!==m||e[48]!==_||e[49]!==H||e[50]!==ee||e[51]!==K?(Q={items:E,totalCount:K,hasMore:_,isLoadingMore:x,isFiltering:W,isInitialLoading:R,isFetching:g,loadMore:M,availableTags:H,availableCategories:ee,selectedTags:m,selectedCategories:o,setSelectedTags:y,setSelectedCategories:b,hasActiveFilters:V},e[39]=V,e[40]=g,e[41]=x,e[42]=W,e[43]=R,e[44]=E,e[45]=M,e[46]=o,e[47]=m,e[48]=_,e[49]=H,e[50]=ee,e[51]=K,e[52]=Q):Q=e[52],Q}function et(t){if(typeof t=="object"&&t!==null){const e=t.nextCursor||t.cursor;if(e)return e}}function tt(t,e){return[...t].sort((l,n)=>n.count-l.count).slice(0,e)}function ne(t){const e=G.c(52),{label:l,items:n,selectedItems:c,onToggle:r,onClear:a}=t,[i,m]=D.useState(""),[y,p]=D.useState(!1);let o,b,u,d,j,I,N,C,L,$,v;if(e[0]!==n||e[1]!==l||e[2]!==r||e[3]!==y||e[4]!==i||e[5]!==c){const k=[...i?n.filter(F=>F.value.toLowerCase().includes(i.toLowerCase())):n].sort(st);u=c.length,b=Ke,L=y,$=p;let f;e[17]!==l?(f=s.jsx("span",{children:l}),e[17]=l,e[18]=f):f=e[18];let x;e[19]!==u?(x=u>0&&s.jsx("span",{className:"ml-1 rounded-full bg-primary text-primary-foreground px-1.5 py-0.5 text-[10px] font-medium",children:u}),e[19]=u,e[20]=x):x=e[20];let g;e[21]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(De,{size:14,className:"opacity-50"}),e[21]=g):g=e[21],e[22]!==x||e[23]!==f?(v=s.jsx(Ae,{asChild:!0,children:s.jsxs(J,{variant:"outline",size:"sm",className:"h-7 px-3 gap-1.5 text-xs font-normal flex-1",children:[f,x,g]})}),e[22]=x,e[23]=f,e[24]=v):v=e[24],o=Ee,I="w-64 p-0",N="start";let R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(ce,{size:16,className:"text-muted-foreground shrink-0"}),e[25]=R):R=e[25];let P;e[26]!==l?(P=l.toLowerCase(),e[26]=l,e[27]=P):P=e[27];const K=`Search ${P}...`;let h;e[28]===Symbol.for("react.memo_cache_sentinel")?(h=F=>m(F.target.value),e[28]=h):h=e[28],e[29]!==i||e[30]!==K?(C=s.jsx("div",{className:"shrink-0 w-full border-b border-border h-10",children:s.jsxs("label",{className:"flex items-center gap-2.5 h-10 px-4 cursor-text",children:[R,s.jsx(Fe,{type:"text",placeholder:K,value:i,onChange:h,className:"flex-1 border-0 shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[29]=i,e[30]=K,e[31]=C):C=e[31],d="max-h-64 overflow-y-auto p-1 flex flex-col gap-1",j=k.length===0?s.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground text-center",children:"No results found"}):k.map(F=>{const E=c.includes(F.value);return s.jsxs("button",{onClick:()=>r(F.value),className:de("w-full flex items-center justify-between px-2 py-1.5 text-sm rounded cursor-pointer transition-colors",E?"bg-accent/50 text-foreground":"hover:bg-muted text-foreground"),children:[s.jsxs("span",{className:"truncate flex items-center gap-2",children:[E&&s.jsx(Be,{size:16,className:"text-muted-foreground shrink-0"}),F.value]}),s.jsx("span",{className:"text-xs text-muted-foreground ml-2 shrink-0",children:F.count})]},F.value)}),e[0]=n,e[1]=l,e[2]=r,e[3]=y,e[4]=i,e[5]=c,e[6]=o,e[7]=b,e[8]=u,e[9]=d,e[10]=j,e[11]=I,e[12]=N,e[13]=C,e[14]=L,e[15]=$,e[16]=v}else o=e[6],b=e[7],u=e[8],d=e[9],j=e[10],I=e[11],N=e[12],C=e[13],L=e[14],$=e[15],v=e[16];let S;e[32]!==d||e[33]!==j?(S=s.jsx("div",{className:d,children:j}),e[32]=d,e[33]=j,e[34]=S):S=e[34];let w;e[35]!==l||e[36]!==a||e[37]!==u?(w=u>0&&s.jsx("div",{className:"p-2 border-t border-border",children:s.jsxs(J,{variant:"ghost",size:"sm",onClick:a,className:"w-full text-xs text-muted-foreground hover:text-foreground",children:["Clear ",l.toLowerCase()]})}),e[35]=l,e[36]=a,e[37]=u,e[38]=w):w=e[38];let T;e[39]!==o||e[40]!==w||e[41]!==I||e[42]!==N||e[43]!==C||e[44]!==S?(T=s.jsxs(o,{className:I,align:N,children:[C,S,w]}),e[39]=o,e[40]=w,e[41]=I,e[42]=N,e[43]=C,e[44]=S,e[45]=T):T=e[45];let z;return e[46]!==b||e[47]!==T||e[48]!==L||e[49]!==$||e[50]!==v?(z=s.jsxs(b,{open:L,onOpenChange:$,children:[v,T]}),e[46]=b,e[47]=T,e[48]=L,e[49]=$,e[50]=v,e[51]=z):z=e[51],z}function st(t,e){return e.count-t.count}function lt(t){const e=G.c(67),{availableTags:l,availableCategories:n,selectedTags:c,selectedCategories:r,onTagChange:a,onCategoryChange:i}=t,m=l&&l.length>0||n&&n.length>0,y=c.length>0||r.length>0;if(!m)return null;let p;e[0]!==a||e[1]!==c?(p=f=>{c.includes(f)?a(c.filter(x=>x!==f)):a([...c,f])},e[0]=a,e[1]=c,e[2]=p):p=e[2];const o=p;let b;e[3]!==i||e[4]!==r?(b=f=>{r.includes(f)?i(r.filter(x=>x!==f)):i([...r,f])},e[3]=i,e[4]=r,e[5]=b):b=e[5];const u=b;let d;e[6]!==i||e[7]!==a?(d=()=>{a([]),i([])},e[6]=i,e[7]=a,e[8]=d):d=e[8];const j=d;let I,N,C,L,$,v,S;if(e[9]!==n||e[10]!==l||e[11]!==i||e[12]!==a||e[13]!==r||e[14]!==c||e[15]!==u||e[16]!==o){const f=n?tt(n,6):[];I=r,N=c,S=new Set(f.map(rt)),$="flex items-center border-b border-border";let x;e[24]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:s.jsx(ae,{size:16})}),e[24]=x):x=e[24];let g;e[25]!==n||e[26]!==i||e[27]!==r||e[28]!==u?(g=n&&n.length>0&&s.jsx(ne,{label:"Categories",items:n,selectedItems:r,onToggle:u,onClear:()=>i([])}),e[25]=n,e[26]=i,e[27]=r,e[28]=u,e[29]=g):g=e[29];let R;e[30]!==l||e[31]!==a||e[32]!==c||e[33]!==o?(R=l&&l.length>0&&s.jsx(ne,{label:"Tags",items:l,selectedItems:c,onToggle:o,onClear:()=>a([])}),e[30]=l,e[31]=a,e[32]=c,e[33]=o,e[34]=R):R=e[34],e[35]!==R||e[36]!==g?(v=s.jsxs("div",{className:"flex items-center gap-3 flex-wrap px-5 py-3 border-r border-border",children:[x,g,R]}),e[35]=R,e[36]=g,e[37]=v):v=e[37],C="flex items-center gap-3 flex-wrap px-5 py-3";let P;e[38]!==r||e[39]!==u?(P=K=>{const h=r.includes(K.value);return s.jsxs("div",{onClick:()=>u(K.value),className:de("inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-full transition-colors cursor-pointer",h?"bg-primary text-primary-foreground hover:bg-primary/80":"bg-muted hover:bg-accent text-muted-foreground"),children:[s.jsx("span",{children:K.value}),h&&s.jsx("span",{onClick:F=>{F.stopPropagation(),u(K.value)},className:"hover:bg-primary/20 rounded-full p-0.5 -mr-1 cursor-pointer flex items-center",children:s.jsx(Y,{size:12})})]},K.value)},e[38]=r,e[39]=u,e[40]=P):P=e[40],L=f.map(P),e[9]=n,e[10]=l,e[11]=i,e[12]=a,e[13]=r,e[14]=c,e[15]=u,e[16]=o,e[17]=I,e[18]=N,e[19]=C,e[20]=L,e[21]=$,e[22]=v,e[23]=S}else I=e[17],N=e[18],C=e[19],L=e[20],$=e[21],v=e[22],S=e[23];let w;if(e[41]!==I||e[42]!==u||e[43]!==S){let f;e[45]!==S?(f=g=>!S.has(g),e[45]=S,e[46]=f):f=e[46];let x;e[47]!==u?(x=g=>s.jsxs("div",{onClick:()=>u(g),className:"inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-full transition-colors cursor-pointer bg-primary text-primary-foreground hover:bg-accent/50",children:[s.jsx("span",{children:g}),s.jsx("span",{onClick:R=>{R.stopPropagation(),u(g)},className:"hover:bg-primary/20 rounded-full p-0.5 -mr-1 cursor-pointer flex items-center",children:s.jsx(Y,{size:12})})]},`cat-${g}`),e[47]=u,e[48]=x):x=e[48],w=I.filter(f).map(x),e[41]=I,e[42]=u,e[43]=S,e[44]=w}else w=e[44];let T;if(e[49]!==N||e[50]!==o){let f;e[52]!==o?(f=x=>s.jsxs("div",{onClick:()=>o(x),className:"inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-full transition-colors cursor-pointer bg-primary text-primary-foreground hover:bg-accent/50",children:[s.jsx("span",{children:x}),s.jsx("span",{onClick:g=>{g.stopPropagation(),o(x)},className:"hover:bg-primary/20 rounded-full p-0.5 -mr-1 cursor-pointer flex items-center",children:s.jsx(Y,{size:12})})]},`tag-${x}`),e[52]=o,e[53]=f):f=e[53],T=N.map(f),e[49]=N,e[50]=o,e[51]=T}else T=e[51];let z;e[54]!==j||e[55]!==y?(z=y&&s.jsxs(J,{variant:"ghost",size:"sm",onClick:j,className:"h-7 text-xs text-muted-foreground hover:text-foreground gap-1 px-2",children:[s.jsx(Y,{size:14}),"Clear all"]}),e[54]=j,e[55]=y,e[56]=z):z=e[56];let A;e[57]!==z||e[58]!==C||e[59]!==L||e[60]!==w||e[61]!==T?(A=s.jsxs("div",{className:C,children:[L,w,T,z]}),e[57]=z,e[58]=C,e[59]=L,e[60]=w,e[61]=T,e[62]=A):A=e[62];let k;return e[63]!==A||e[64]!==$||e[65]!==v?(k=s.jsxs("div",{className:$,children:[v,A]}),e[63]=A,e[64]=$,e[65]=v,e[66]=k):k=e[66],k}function rt(t){return t.value}function nt(t,e){if(!e)return t;const l=e.toLowerCase();return t.filter(n=>(n.name||n.title||"").toLowerCase().includes(l)||(n.description||n.server.description||"").toLowerCase().includes(l))}function ot(t){return t.verified===!0||t._meta?.["mcp.mesh"]?.verified===!0}function it(t){const e=G.c(54),{registryId:l,listToolName:n,filtersToolName:c}=t,[r,a]=D.useState(""),i=Qe(r,300),m=oe(),{org:y}=X(),{scrollRef:p,saveScrollPosition:o,handleScroll:b}=Ye(`store-discovery:${l}`);let u;e[0]!==i||e[1]!==c||e[2]!==n||e[3]!==l?(u={registryId:l,listToolName:n,filtersToolName:c,search:i},e[0]=i,e[1]=c,e[2]=n,e[3]=l,e[4]=u):u=e[4];const{items:d,hasMore:j,isLoadingMore:I,isInitialLoading:N,isFetching:C,loadMore:L,availableTags:$,availableCategories:v,selectedTags:S,selectedCategories:w,setSelectedTags:T,setSelectedCategories:z,hasActiveFilters:A}=Xe(u);let k,f,x,g;e[5]!==i||e[6]!==C||e[7]!==N||e[8]!==d||e[9]!==r?(k=r?nt(d,r):d,f=(r!==i||C)&&!N&&!!r,g=k.filter(ot),x=k.filter(M=>!g.find(_=>_.id===M.id)),e[5]=i,e[6]=C,e[7]=N,e[8]=d,e[9]=r,e[10]=k,e[11]=f,e[12]=x,e[13]=g):(k=e[10],f=e[11],x=e[12],g=e[13]);const R=x;let P;e[14]!==m||e[15]!==y.slug||e[16]!==l||e[17]!==o?(P=M=>{o();const _=Le(M.name||M.title||M.server.title||""),H=M.server.name;m({to:"/$org/$project/store/$appName",params:{org:y.slug,project:ie,appName:_},search:{registryId:l,serverName:H}})},e[14]=m,e[15]=y.slug,e[16]=l,e[17]=o,e[18]=P):P=e[18];const K=P;let h;e[19]!==b||e[20]!==j||e[21]!==I||e[22]!==L?(h=M=>{if(b(),!j||I)return;const _=M.currentTarget;_.scrollHeight-_.scrollTop-_.clientHeight<200&&L()},e[19]=b,e[20]=j,e[21]=I,e[22]=L,e[23]=h):h=e[23];const F=h;let E;e[24]!==f||e[25]!==r?(E=s.jsx(ze,{value:r,onChange:a,placeholder:"Search for an MCP Server...",isSearching:f}),e[24]=f,e[25]=r,e[26]=E):E=e[26];let O;e[27]!==v||e[28]!==$||e[29]!==w||e[30]!==S||e[31]!==z||e[32]!==T?(O=s.jsx(lt,{availableTags:$,availableCategories:v,selectedTags:S,selectedCategories:w,onTagChange:T,onCategoryChange:z}),e[27]=v,e[28]=$,e[29]=w,e[30]=S,e[31]=z,e[32]=T,e[33]=O):O=e[33];let V;e[34]!==R||e[35]!==k||e[36]!==K||e[37]!==A||e[38]!==j||e[39]!==N||e[40]!==I||e[41]!==f||e[42]!==d||e[43]!==r||e[44]!==g?(V=s.jsx("div",{className:"p-5",children:s.jsx("div",{children:N?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(Z,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading items..."})]}):d.length===0&&!A?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(Ne,{size:48,className:"text-muted-foreground mb-4"}),s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No items available"}),s.jsx("p",{className:"text-muted-foreground",children:"This store doesn't have any available items yet."})]}):d.length===0&&A&&!r?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(ae,{size:48,className:"text-muted-foreground mb-4"}),s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No matching items"}),s.jsx("p",{className:"text-muted-foreground",children:"Try adjusting your filters to find more results."})]}):r&&k.length===0&&!f?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(ce,{size:48,className:"text-muted-foreground mb-4"}),s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No results found"}),s.jsx("p",{className:"text-muted-foreground",children:"Try adjusting your search terms."})]}):s.jsxs("div",{className:"flex flex-col gap-8",children:[f&&k.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx(Z,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Searching..."})]}),g.length>0&&s.jsx(re,{items:g,title:"Verified",onItemClick:K}),R.length>0&&s.jsx(re,{items:R,title:g.length>0?"All":"",onItemClick:K}),j&&I&&s.jsx("div",{className:"flex justify-center py-8",children:s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(Z,{size:20,className:"animate-spin"}),s.jsx("span",{className:"text-sm",children:"Loading more items..."})]})})]})})}),e[34]=R,e[35]=k,e[36]=K,e[37]=A,e[38]=j,e[39]=N,e[40]=I,e[41]=f,e[42]=d,e[43]=r,e[44]=g,e[45]=V):V=e[45];let W;e[46]!==F||e[47]!==p||e[48]!==V?(W=s.jsx("div",{ref:p,className:"flex-1 overflow-y-auto",onScroll:F,children:V}),e[46]=F,e[47]=p,e[48]=V,e[49]=W):W=e[49];let q;return e[50]!==E||e[51]!==O||e[52]!==W?(q=s.jsxs("div",{className:"flex flex-col h-full",children:[E,O,W]}),e[50]=E,e[51]=O,e[52]=W,e[53]=q):q=e[53],q}function at(t){const e=G.c(8),{registryId:l}=t,n=$e(l),c=n?.tools;let r;e[0]!==c?(r=we(c),e[0]=c,e[1]=r):r=e[1];const a=r;if(!a)throw new Error("This registry does not support listing store items.");const i=n?.tools;let m;e[2]!==i?(m=Te(i),e[2]=i,e[3]=m):m=e[3];const p=m||void 0;let o;return e[4]!==a||e[5]!==l||e[6]!==p?(o=s.jsx(it,{registryId:l,listToolName:a,filtersToolName:p}),e[4]=a,e[5]=l,e[6]=p,e[7]=o):o=e[7],o}function ct(t){const e=G.c(15),{registries:l,value:n,onValueChange:c,onAddWellKnown:r,wellKnownRegistries:a,placeholder:i}=t,m=i===void 0?"Select a registry...":i;let y;e[0]!==m?(y=s.jsx(Oe,{size:"sm",className:"w-auto min-w-[160px]",children:s.jsx(Ve,{placeholder:m})}),e[0]=m,e[1]=y):y=e[1];let p;e[2]!==l?(p=l.map(mt),e[2]=l,e[3]=p):p=e[3];let o;e[4]!==r||e[5]!==a?(o=a.length>0&&s.jsxs("div",{className:"border-t border-border pt-1",children:[s.jsx("p",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",children:"Other known registries"}),a.map(d=>s.jsxs("button",{onClick:j=>{j.preventDefault(),j.stopPropagation(),r(d)},className:"relative flex w-full cursor-pointer items-center gap-2 rounded-lg py-1.5 pr-8 pl-2 text-sm outline-hidden select-none hover:bg-accent hover:text-accent-foreground",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[d.icon?s.jsx("img",{src:d.icon,alt:d.title,className:"w-4 h-4 rounded"}):s.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:d.title.slice(0,1).toUpperCase()}),s.jsx("span",{className:"flex-1",children:d.title})]}),s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center text-muted-foreground",children:s.jsx(qe,{size:16})})]},d.id??d.title))]}),e[4]=r,e[5]=a,e[6]=o):o=e[6];let b;e[7]!==p||e[8]!==o?(b=s.jsxs(_e,{children:[p,o]}),e[7]=p,e[8]=o,e[9]=b):b=e[9];let u;return e[10]!==c||e[11]!==y||e[12]!==b||e[13]!==n?(u=s.jsxs(We,{value:n,onValueChange:c,children:[y,b]}),e[10]=c,e[11]=y,e[12]=b,e[13]=n,e[14]=u):u=e[14],u}function mt(t){return s.jsx(Me,{className:"cursor-pointer",value:t.id??t.name,children:s.jsxs("div",{className:"flex items-center gap-2",children:[t.icon?s.jsx("img",{src:t.icon,alt:t.name,className:"w-4 h-4 rounded"}):s.jsx("div",{className:"w-4 h-4 rounded from-primary/20 to-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:t.name.slice(0,1).toUpperCase()}),s.jsx("span",{children:t.name})]})},t.id??t.name)}function dt({registries:t,onConnected:e}){const l=me(),{org:{slug:n}}=X(),{data:c}=ge.useSession(),r=oe(),[a,i]=D.useState(!1),m=t[0],y=async()=>{if(!(!m||!c?.user?.id)){i(!0);try{const o=await l.create.mutateAsync(m);e?.(o.id)}finally{i(!1)}}},p=()=>{r({to:"/$org/$project/mcps",params:{org:n,project:ie},search:{action:"create"}})};return s.jsx(Ge,{image:s.jsx("img",{src:"/store-empty-state.svg",alt:"No store connected",width:336,height:320,className:"max-w-full h-auto"}),title:"Connect to registry",description:"Connect to discover and use Connections from the community.",actions:s.jsxs(s.Fragment,{children:[s.jsxs(J,{variant:"outline",onClick:y,disabled:a||!m,children:[m?.icon&&s.jsx("img",{src:m.icon,alt:"",className:"size-4"}),a?"Installing...":"Install Registry"]}),s.jsx(J,{variant:"outline",onClick:p,children:"Custom Connection"})]})})}function Xt(){const t=G.c(42),{org:e}=X(),l=ke(),n=me(),c=pe(),r=c.location.pathname.includes("/store/")&&c.location.pathname.split("/").length>3,a=He(l);let i;t[0]!==a?(i=a.map(xt),t[0]=a,t[1]=i):i=t[1];const m=i;let y;t[2]!==e.slug?(y=Ue.selectedRegistry(e.slug),t[2]=e.slug,t[3]=y):y=t[3];const[p,o]=Je(y,ut);let b;if(t[4]!==a||t[5]!==p){let h;t[7]!==p?(h=F=>F.id===p,t[7]=p,t[8]=h):h=t[8],b=a.find(h),t[4]=a,t[5]=p,t[6]=b}else b=t[6];const d=b?.id||a[0]?.id||"";let j;t[9]!==e.id?(j=Re(e.id),t[9]=e.id,t[10]=j):j=t[10];let I;t[11]!==j?(I=[j],t[11]=j,t[12]=I):I=t[12];const N=I;let C;t[13]===Symbol.for("react.memo_cache_sentinel")?(C=[Pe()],t[13]=C):C=t[13];const L=C;let $;t[14]!==n.create||t[15]!==o?($=async h=>{const F=await n.create.mutateAsync(h);o(F.id)},t[14]=n.create,t[15]=o,t[16]=$):$=t[16];const v=$;let S;t[17]!==a?(S=new Set(a.map(ft)),t[17]=a,t[18]=S):S=t[18];const w=S;let T;t[19]!==w||t[20]!==N?(T=N.filter(h=>h.id&&!w.has(h.id)),t[19]=w,t[20]=N,t[21]=T):T=t[21];const z=T;let A;t[22]!==w?(A=L.filter(h=>h.id&&!w.has(h.id)),t[22]=w,t[23]=A):A=t[23];const k=A;if(r){let h;return t[24]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(he,{}),t[24]=h):h=t[24],h}let f;t[25]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(U.Header.Left,{children:s.jsx(je,{children:s.jsx(ve,{children:s.jsx(ye,{children:s.jsx(be,{children:"Store"})})})})}),t[25]=f):f=t[25];let x;t[26]!==v?(x=async h=>v(h),t[26]=v,t[27]=x):x=t[27];let g;t[28]!==z||t[29]!==d||t[30]!==m||t[31]!==o||t[32]!==x?(g=s.jsxs(U.Header,{children:[f,s.jsx(U.Header.Right,{children:s.jsx(ct,{wellKnownRegistries:z,registries:m,value:d,onValueChange:o,onAddWellKnown:x,placeholder:"Select store..."})})]}),t[28]=z,t[29]=d,t[30]=m,t[31]=o,t[32]=x,t[33]=g):g=t[33];let R;t[34]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[s.jsx(Z,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading store items..."})]}),t[34]=R):R=t[34];let P;t[35]!==k||t[36]!==d||t[37]!==o?(P=s.jsx(U.Content,{children:s.jsx(D.Suspense,{fallback:R,children:d?s.jsx(at,{registryId:d}):s.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:s.jsx(dt,{registries:k,onConnected:h=>{o(h)}})})})}),t[35]=k,t[36]=d,t[37]=o,t[38]=P):P=t[38];let K;return t[39]!==g||t[40]!==P?(K=s.jsxs(U,{children:[g,P]}),t[39]=g,t[40]=P,t[41]=K):K=t[41],K}function ft(t){return t.id}function ut(t){return t??""}function xt(t){return{id:t.id,name:t.title,icon:t.icon||void 0}}export{Xt as default};
|