decocms 2.138.0 → 2.158.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/README.md +417 -40
- package/dist/README.md +295 -0
- package/dist/client/assets/AlertCircle-DsQlVvig.js +1 -0
- package/dist/client/assets/AlignLeft-Cvo6EEA1.js +1 -0
- package/dist/client/assets/ArrowDown-KTP4HONB.js +1 -0
- package/dist/client/assets/ArrowLeft-CR3SWku2.js +1 -0
- package/dist/client/assets/ArrowUp-BfaawFDM.js +1 -0
- package/dist/client/assets/Check-OSWZCZf9.js +1 -0
- package/dist/client/assets/CheckCircle-B2wkNkz_.js +1 -0
- package/dist/client/assets/CheckDone01-j6DaSyTU.js +1 -0
- package/dist/client/assets/CheckVerified02-D6qy17me.js +1 -0
- package/dist/client/assets/ChevronDown-BR4cCk-W.js +1 -0
- package/dist/client/assets/ChevronLeft-D4Ua6sXw.js +1 -0
- package/dist/client/assets/ChevronRight-ByOuE_Vi.js +1 -0
- package/dist/client/assets/Clock-BEpmd0mM.js +1 -0
- package/dist/client/assets/Code01-BsBlwdG0.js +1 -0
- package/dist/client/assets/CommitMono-VariableFont-ytizKI8U.woff2 +0 -0
- package/dist/client/assets/Container-BVSlDn4p.js +1 -0
- package/dist/client/assets/Copy01-B595Thpy.js +1 -0
- package/dist/client/assets/Dataflow03-DW4Gd5sB.js +1 -0
- package/dist/client/assets/DotsHorizontal-0eyRqScK.js +1 -0
- package/dist/client/assets/DotsVertical-Cshw63SI.js +1 -0
- package/dist/client/assets/Download01-DFmX-SGA.js +1 -0
- package/dist/client/assets/Edit01-BzJXGmI-.js +1 -0
- package/dist/client/assets/Edit05-BKDqgNc4.js +1 -0
- package/dist/client/assets/Eye-CHYeRDXI.js +1 -0
- package/dist/client/assets/File02-ZK3-99s4.js +1 -0
- package/dist/client/assets/File06-B7IZdrgj.js +1 -0
- package/dist/client/assets/FilterLines-pJtef_Pv.js +1 -0
- package/dist/client/assets/Globe01-p5f8j_mm.js +1 -0
- package/dist/client/assets/Globe02-D7s1ULQJ.js +1 -0
- package/dist/client/assets/Grid01-DIGu5eh8.js +1 -0
- package/dist/client/assets/Hash02-CkWXLlvG.js +1 -0
- package/dist/client/assets/Home02-DiSPSdMx.js +1 -0
- package/dist/client/assets/Image01-4wUrHqw6.js +1 -0
- package/dist/client/assets/Inbox01-csEiEq63.js +1 -0
- package/dist/client/assets/InfoCircle-s0XyUQYC.js +1 -0
- package/dist/client/assets/InterVariable-DiVDrmQJ.woff2 +0 -0
- package/dist/client/assets/InterVariable-Italic-FCBEiFp6.woff2 +0 -0
- package/dist/client/assets/Key01-BP2mhRrj.js +1 -0
- package/dist/client/assets/LayersTwo01-C4CgBsBK.js +1 -0
- package/dist/client/assets/LayoutLeft-DzzE993C.js +1 -0
- package/dist/client/assets/Link01-CHaReCKl.js +1 -0
- package/dist/client/assets/LinkExternal01-Cj5yLC8K.js +1 -0
- package/dist/client/assets/List-BnvhY7Nh.js +1 -0
- package/dist/client/assets/Loading01-aMp99RZI.js +1 -0
- package/dist/client/assets/Lock01-STjQUMU6.js +1 -0
- package/dist/client/assets/Play-Dr8AlTmi.js +1 -0
- package/dist/client/assets/Plus-Dp8Rr75G.js +1 -0
- package/dist/client/assets/RefreshCcw01-DDGad8lb.js +1 -0
- package/dist/client/assets/Save01-36pjbcKA.js +1 -0
- package/dist/client/assets/SearchMd-r7i5BQk7.js +1 -0
- package/dist/client/assets/Settings01-DKTz1YSf.js +1 -0
- package/dist/client/assets/Shield01-J7QygUij.js +1 -0
- package/dist/client/assets/Terminal-CtjH6zFY.js +1 -0
- package/dist/client/assets/Trash01-DJTe1fKw.js +1 -0
- package/dist/client/assets/Upload01-BEhQSPeB.js +1 -0
- package/dist/client/assets/Users03-CG_islph.js +1 -0
- package/dist/client/assets/X-DjDetE_c.js +1 -0
- package/dist/client/assets/XCircle-CSLSI6pa.js +1 -0
- package/dist/client/assets/XClose-dSJ6zVxj.js +1 -0
- package/dist/client/assets/Zap-BdJ17pmL.js +1 -0
- package/dist/client/assets/agent-connections-preview-DB81vdUX.js +1 -0
- package/dist/client/assets/agent-detail-BAru2zv4.js +2 -0
- package/dist/client/assets/agents-DTLxCfRX.js +1 -0
- package/dist/client/assets/alert-dialog-Bbrwo05x.js +7 -0
- package/dist/client/assets/auth-catchall-BETKUynS.js +1 -0
- package/dist/client/assets/avatar-D94UEcg7.js +1 -0
- package/dist/client/assets/badge-DxYG_XB9.js +1 -0
- package/dist/client/assets/binder-wDmRPNL2.js +1 -0
- package/dist/client/assets/breadcrumb-BrsAPde7.js +1 -0
- package/dist/client/assets/card-CkYe6Ikt.js +1 -0
- package/dist/client/assets/chart-DnUFHI2d.js +15 -0
- package/dist/client/assets/checkbox-DhgSL5Cz.js +1 -0
- package/dist/client/assets/circle-alert-CgP-qNn-.js +1 -0
- package/dist/client/assets/collapsible-DYgsVB3N.js +1 -0
- package/dist/client/assets/collection-detail-D5XIUYKg.js +26 -0
- package/dist/client/assets/collection-display-button-DEx37m4V.js +1 -0
- package/dist/client/assets/collection-search-DXvW2iQG.js +1 -0
- package/dist/client/assets/collection-tab-CNXNROrc.js +1 -0
- package/dist/client/assets/collection-table-wrapper-xKuLiuQ5.js +1 -0
- package/dist/client/assets/collection-tabs-BEqvkJum.js +1 -0
- package/dist/client/assets/command-wAVHsF2T.js +1 -0
- package/dist/client/assets/connect-yoERnUTv.js +1 -0
- package/dist/client/assets/connection-card--y0YdfEA.js +1 -0
- package/dist/client/assets/connection-detail-1Ku6b0Wl.js +1 -0
- package/dist/client/assets/connection-status-Cq0AmCwK.js +1 -0
- package/dist/client/assets/connections-Cih6wM0L.js +1 -0
- package/dist/client/assets/constants-BBAQxhFl.js +1 -0
- package/dist/client/assets/constants-_xTq0aTt.js +1 -0
- package/dist/client/assets/context-Bk-UzwLO.js +29 -0
- package/dist/client/assets/create-organization-dialog-D50lIYTQ.js +1 -0
- package/dist/client/assets/create-project-dialog-B3BGNP1R.js +1 -0
- package/dist/client/assets/danger-DuT5kBaU.js +1 -0
- package/dist/client/assets/danger-zone-Cjq5A9rY.js +1 -0
- package/dist/client/assets/decopilot-events-BrbCILIn.js +1 -0
- package/dist/client/assets/dependencies-BXhkBUyi.js +1 -0
- package/dist/client/assets/dialog-B-Kp8Cuq.js +1 -0
- package/dist/client/assets/differenceInSeconds-NQ4PDo0z.js +1 -0
- package/dist/client/assets/dropdown-menu-DjhC4m2a.js +1 -0
- package/dist/client/assets/dynamic-plugin-layout-DRpqAaco.js +1 -0
- package/dist/client/assets/editable-task-title-CWlhOc5Q.js +16 -0
- package/dist/client/assets/empty-state-680W7nUY.js +1 -0
- package/dist/client/assets/env-vars-editor-BRxwCr-L.js +1 -0
- package/dist/client/assets/estree-CwOGYdhi.js +44 -0
- package/dist/client/assets/extract-connection-data-DUglufvW.js +1 -0
- package/dist/client/assets/file-browser-BLB4FkOU.js +2 -0
- package/dist/client/assets/form-DK8WrQI3.js +1 -0
- package/dist/client/assets/format-time-CMKyl-GC.js +1 -0
- package/dist/client/assets/formatDistanceToNow-Cb2QZZJn.js +1 -0
- package/dist/client/assets/general-DonW35nE.js +1 -0
- package/dist/client/assets/generate-id-Dyweu44Y.js +1 -0
- package/dist/client/assets/github-icon-Dp3wHhYE.js +1 -0
- package/dist/client/assets/grid-view-CqJSMZVQ.js +1 -0
- package/dist/client/assets/home-DIVCSvrl.js +1 -0
- package/dist/client/assets/icon-picker-DvkCVh_W.js +1 -0
- package/dist/client/assets/index-B84Dx7nI.js +218 -0
- package/dist/client/assets/index-BGwf3l_M.js +1 -0
- package/dist/client/assets/index-BPI27S5s.js +25 -0
- package/dist/client/assets/index-BmSASrPR.js +1 -0
- package/dist/client/assets/index-C8u6axf-.js +1 -0
- package/dist/client/assets/index-CcaZ2Rhp.css +1 -0
- package/dist/client/assets/index-CmH5OQnm.js +1 -0
- package/dist/client/assets/index-D9XxJ5Op.js +1 -0
- package/dist/client/assets/index-DA_JOtb0.js +1 -0
- package/dist/client/assets/index-SKwvOtlz.js +184 -0
- package/dist/client/assets/infiniteQueryObserver-DenS4T97.js +1 -0
- package/dist/client/assets/input-NIbTU7RU.js +1 -0
- package/dist/client/assets/integration-icon-DNJkhUIt.js +1 -0
- package/dist/client/assets/label-B6R7vHKQ.js +1 -0
- package/dist/client/assets/layout-CECSvrhq.js +1 -0
- package/dist/client/assets/layout-CMdmqG4j.js +1 -0
- package/dist/client/assets/localstorage-keys-BckSA5cs.js +1 -0
- package/dist/client/assets/login-BfEg3qXN.js +1 -0
- package/dist/client/assets/markdown-Cqv1T19z.js +29 -0
- package/dist/client/assets/marked.esm-BaswSlok.js +56 -0
- package/dist/client/assets/mcp-app-renderer-gG-wM7zZ.js +11 -0
- package/dist/client/assets/mcp-server-card-M7WdUx8I.js +1 -0
- package/dist/client/assets/mcp-server-detail-D73ue2Yz.js +2 -0
- package/dist/client/assets/members-Buq9RcXv.js +3 -0
- package/dist/client/assets/monaco-editor-BXv0Xqkq.js +19 -0
- package/dist/client/assets/monitoring-CEhjsxOM.js +31 -0
- package/dist/client/assets/monitoring-dashboard-edit-BntH-KiR.js +1 -0
- package/dist/client/assets/monitoring-dashboard-view-Bw3iwoxc.js +4 -0
- package/dist/client/assets/oauth-callback-D455SJn4.js +1 -0
- package/dist/client/assets/page-C-6ciKw-.js +1 -0
- package/dist/client/assets/page-DrITT5mj.js +1 -0
- package/dist/client/assets/plugin-empty-state-BLzOpmuv.js +1 -0
- package/dist/client/assets/plugin-empty-state-D73E0OXs.js +1 -0
- package/dist/client/assets/plugin-header-DkXBoQof.js +1 -0
- package/dist/client/assets/plugin-header-_N_-KJkN.js +1 -0
- package/dist/client/assets/plugins-D4w2xHCL.js +1 -0
- package/dist/client/assets/popover-D7xgfP4W.js +1 -0
- package/dist/client/assets/project-app-view-DWi5m8l8.js +1 -0
- package/dist/client/assets/project-layout-CWEThOiP.js +1 -0
- package/dist/client/assets/project-plugins-BKPLJXFp.js +1 -0
- package/dist/client/assets/projects-list-Y8k15POh.js +1 -0
- package/dist/client/assets/purify.es-C0_7NiBM.js +2 -0
- package/dist/client/assets/readme-viewer-DWnTz46N.css +1 -0
- package/dist/client/assets/readme-viewer-WWU4z7Xg.js +1 -0
- package/dist/client/assets/registry-layout-D_LH6ewr.js +5 -0
- package/dist/client/assets/registry-utils-CMqg9IHN.js +1 -0
- package/dist/client/assets/reports-layout-B3u5OkMC.js +3 -0
- package/dist/client/assets/reset-password-Cm7BWULq.js +1 -0
- package/dist/client/assets/resizable-pH8vbRAI.js +1 -0
- package/dist/client/assets/save-actions-CTDUNaiW.js +1 -0
- package/dist/client/assets/scroll-area-DOWQyO2m.js +1 -0
- package/dist/client/assets/select-1y3LRFgk.js +1 -0
- package/dist/client/assets/shell-layout-B6SbKq-6.js +3 -0
- package/dist/client/assets/sidebar-settings-BZx3Z8UA.js +1 -0
- package/dist/client/assets/skeleton-CMw17Qjd.js +1 -0
- package/dist/client/assets/slugify-CEUa2lfQ.js +1 -0
- package/dist/client/assets/spinner-DiXeE5Xk.js +1 -0
- package/dist/client/assets/standalone-DS4gw9AE.js +29 -0
- package/dist/client/assets/store-invite-BdRmGVAy.js +1 -0
- package/dist/client/assets/switch-BA80KxP2.js +1 -0
- package/dist/client/assets/table-vuF1fVQ6.js +1 -0
- package/dist/client/assets/tabs-D3RTRDyW.js +1 -0
- package/dist/client/assets/tasks-C_CW4iPq.js +1 -0
- package/dist/client/assets/tasks-panel-D3YXt5j8.js +1 -0
- package/dist/client/assets/textarea-BW2ziFqJ.js +1 -0
- package/dist/client/assets/time-range-picker-CZg_Yx1g.js +5 -0
- package/dist/client/assets/toggle-group-DO86EMeS.js +1 -0
- package/dist/client/assets/tools-list-BzLGkrz5.js +1 -0
- package/dist/client/assets/tooltip-CHJhCJL3.js +1 -0
- package/dist/client/assets/topbar-portal-BomQ7YMR.js +1 -0
- package/dist/client/assets/types-DibruoFW.js +155 -0
- package/dist/client/assets/typescript-Ca_eWjgL.js +21 -0
- package/dist/client/assets/unwrap-tool-result-BYXdCQMg.js +1 -0
- package/dist/client/assets/usage-B8eRkRZY.js +1 -0
- package/dist/client/assets/use-binding-Bdb-0lwc.js +1 -0
- package/dist/client/assets/use-collections-BoFyuDa6.js +1 -0
- package/dist/client/assets/use-connection-DSPQNIQD.js +1 -0
- package/dist/client/assets/use-copy-Ba97e-kV.js +1 -0
- package/dist/client/assets/use-create-virtual-mcp-Cf71AE6l.js +1 -0
- package/dist/client/assets/use-install-from-registry-B6NE77_0.js +1 -0
- package/dist/client/assets/use-list-state-kborONTL.js +1 -0
- package/dist/client/assets/use-llm-CKGJlXuC.js +1 -0
- package/dist/client/assets/use-mcp-prompts-C___IsDE.js +1 -0
- package/dist/client/assets/use-mcp-tools-K2l5CqFr.js +1 -0
- package/dist/client/assets/use-members-DajocvHM.js +1 -0
- package/dist/client/assets/use-mobile-DznYZ63b.js +1 -0
- package/dist/client/assets/use-preferences-BfaOwWT4.js +1 -0
- package/dist/client/assets/use-project-DZlIfmd3.js +1 -0
- package/dist/client/assets/use-settings-modal-C2h2dbTq.js +1 -0
- package/dist/client/assets/use-view-mode-3gfyljcZ.js +1 -0
- package/dist/client/assets/use-virtual-mcp-5EdNqvyH.js +1 -0
- package/dist/client/assets/useInfiniteQuery-CFRJ66U9.js +1 -0
- package/dist/client/assets/useMutation-Be5QSQym.js +1 -0
- package/dist/client/assets/useQuery-CIRdCYZz.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-CQgxvKZn.js +1 -0
- package/dist/client/assets/user-CY9QFLJr.js +1 -0
- package/dist/client/assets/workflow-Db4yuI9S.js +1 -0
- package/dist/client/empty-state-cards.png +0 -0
- package/dist/client/empty-state-error.svg +19 -0
- package/dist/client/empty-state-home.png +0 -0
- package/dist/client/empty-state-logs.svg +80 -0
- package/dist/client/empty-state-openrouter.svg +320 -0
- package/dist/client/empty-state-success-muted.svg +19 -0
- package/dist/client/empty-state-success.svg +19 -0
- package/dist/client/emptystate-mcp.svg +33 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/globe.svg +4 -0
- package/dist/client/icons/capy-0.png +0 -0
- package/dist/client/icons/capy-1.png +0 -0
- package/dist/client/icons/capy-10.png +0 -0
- package/dist/client/icons/capy-11.png +0 -0
- package/dist/client/icons/capy-12.png +0 -0
- package/dist/client/icons/capy-13.png +0 -0
- package/dist/client/icons/capy-14.png +0 -0
- package/dist/client/icons/capy-15.png +0 -0
- package/dist/client/icons/capy-16.png +0 -0
- package/dist/client/icons/capy-17.png +0 -0
- package/dist/client/icons/capy-18.png +0 -0
- package/dist/client/icons/capy-19.png +0 -0
- package/dist/client/icons/capy-2.png +0 -0
- package/dist/client/icons/capy-20.png +0 -0
- package/dist/client/icons/capy-21.png +0 -0
- package/dist/client/icons/capy-22.png +0 -0
- package/dist/client/icons/capy-23.png +0 -0
- package/dist/client/icons/capy-24.png +0 -0
- package/dist/client/icons/capy-25.png +0 -0
- package/dist/client/icons/capy-26.png +0 -0
- package/dist/client/icons/capy-27.png +0 -0
- package/dist/client/icons/capy-28.png +0 -0
- package/dist/client/icons/capy-29.png +0 -0
- package/dist/client/icons/capy-3.png +0 -0
- package/dist/client/icons/capy-30.png +0 -0
- package/dist/client/icons/capy-31.png +0 -0
- package/dist/client/icons/capy-32.png +0 -0
- package/dist/client/icons/capy-33.png +0 -0
- package/dist/client/icons/capy-34.png +0 -0
- package/dist/client/icons/capy-35.png +0 -0
- package/dist/client/icons/capy-36.png +0 -0
- package/dist/client/icons/capy-37.png +0 -0
- package/dist/client/icons/capy-38.png +0 -0
- package/dist/client/icons/capy-4.png +0 -0
- package/dist/client/icons/capy-5.png +0 -0
- package/dist/client/icons/capy-6.png +0 -0
- package/dist/client/icons/capy-7.png +0 -0
- package/dist/client/icons/capy-8.png +0 -0
- package/dist/client/icons/capy-9.png +0 -0
- package/dist/client/index.html +12 -0
- package/dist/client/logos/Claude Code.svg +3 -0
- package/dist/client/logos/Windsurf.svg +3 -0
- package/dist/client/logos/cursor.svg +3 -0
- package/dist/client/logos/deco logo.svg +4 -0
- package/dist/client/sounds/notification.mp3 +0 -0
- package/dist/client/store-empty-state.svg +109 -0
- package/dist/client/verified-badge.svg +4 -0
- package/dist/server/cli.js +2143 -0
- package/dist/server/migrate.js +2001 -0
- package/dist/server/server.js +1922 -0
- package/package.json +141 -24
- package/bin/deco.js +0 -33
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function O(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var S=O();function ie(n){S=n}var z={exec:()=>null};function u(n,e=""){let t=typeof n=="string"?n:n.source;const s={replace:(r,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(x.caret,"$1"),t=t.replace(r,l),s},getRegex:()=>new RegExp(t,e)};return s}var x={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i")},xe=/^(?:[ \t]*(?:\n|$))+/,be=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,me=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,_=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,we=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,N=/(?:[*+-]|\d{1,9}[.)])/,le=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ae=u(le).replace(/bull/g,N).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ye=u(le).replace(/bull/g,N).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),j=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Re=/^[^\n]+/,H=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se=u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",H).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$e=u(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,N).getRegex(),B="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Q=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Te=u("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Q).replace("tag",B).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),oe=u(j).replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",B).getRegex(),ve=u(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oe).getRegex(),F={blockquote:ve,code:be,def:Se,fences:me,heading:we,hr:_,html:Te,lheading:ae,list:$e,newline:xe,paragraph:oe,table:z,text:Re},ee=u("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",B).getRegex(),ze={...F,lheading:ye,table:ee,paragraph:u(j).replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ee).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",B).getRegex()},_e={...F,html:u(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Q).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:z,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:u(j).replace("hr",_).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",ae).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ae=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Le=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ce=/^( {2,}|\\)\n(?!\s*$)/,Ce=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,E=/[\p{P}\p{S}]/u,U=/[\s\p{P}\p{S}]/u,he=/[^\s\p{P}\p{S}]/u,Ie=u(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,U).getRegex(),pe=/(?!~)[\p{P}\p{S}]/u,Pe=/(?!~)[\s\p{P}\p{S}]/u,Be=/(?:[^\s\p{P}\p{S}]|~)/u,Ee=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ue=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,qe=u(ue,"u").replace(/punct/g,E).getRegex(),Ze=u(ue,"u").replace(/punct/g,pe).getRegex(),ge="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",De=u(ge,"gu").replace(/notPunctSpace/g,he).replace(/punctSpace/g,U).replace(/punct/g,E).getRegex(),Me=u(ge,"gu").replace(/notPunctSpace/g,Be).replace(/punctSpace/g,Pe).replace(/punct/g,pe).getRegex(),Ge=u("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,he).replace(/punctSpace/g,U).replace(/punct/g,E).getRegex(),Oe=u(/\\(punct)/,"gu").replace(/punct/g,E).getRegex(),Ne=u(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),je=u(Q).replace("(?:-->|$)","-->").getRegex(),He=u("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),C=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Qe=u(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",C).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),fe=u(/^!?\[(label)\]\[(ref)\]/).replace("label",C).replace("ref",H).getRegex(),ke=u(/^!?\[(ref)\](?:\[\])?/).replace("ref",H).getRegex(),Fe=u("reflink|nolink(?!\\()","g").replace("reflink",fe).replace("nolink",ke).getRegex(),X={_backpedal:z,anyPunctuation:Oe,autolink:Ne,blockSkip:Ee,br:ce,code:Le,del:z,emStrongLDelim:qe,emStrongRDelimAst:De,emStrongRDelimUnd:Ge,escape:Ae,link:Qe,nolink:ke,punctuation:Ie,reflink:fe,reflinkSearch:Fe,tag:He,text:Ce,url:z},Ue={...X,link:u(/^!?\[(label)\]\((.*?)\)/).replace("label",C).getRegex(),reflink:u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",C).getRegex()},D={...X,emStrongRDelimAst:Me,emStrongLDelim:Ze,url:u(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Xe={...D,br:u(ce).replace("{2,}","*").getRegex(),text:u(D.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},A={normal:F,gfm:ze,pedantic:_e},T={normal:X,gfm:D,breaks:Xe,pedantic:Ue},We={"&":"&","<":"<",">":">",'"':""","'":"'"},te=n=>We[n];function m(n,e){if(e){if(x.escapeTest.test(n))return n.replace(x.escapeReplace,te)}else if(x.escapeTestNoEncode.test(n))return n.replace(x.escapeReplaceNoEncode,te);return n}function ne(n){try{n=encodeURI(n).replace(x.percentDecode,"%")}catch{return null}return n}function re(n,e){const t=n.replace(x.findPipe,(i,l,a)=>{let c=!1,o=l;for(;--o>=0&&a[o]==="\\";)c=!c;return c?"|":" |"}),s=t.split(x.splitPipe);let r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(x.slashPipe,"|");return s}function v(n,e,t){const s=n.length;if(s===0)return"";let r=0;for(;r<s&&n.charAt(s-r-1)===e;)r++;return n.slice(0,s-r)}function Je(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])t++;else if(n[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function se(n,e,t,s,r){const i=e.href,l=e.title||null,a=n[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;const c={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:l,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,c}function Ke(n,e,t){const s=n.match(t.other.indentCodeCompensation);if(s===null)return e;const r=s[1];return e.split(`
|
|
3
|
+
`).map(i=>{const l=i.match(t.other.beginningSpace);if(l===null)return i;const[a]=l;return a.length>=r.length?i.slice(r.length):i}).join(`
|
|
4
|
+
`)}var I=class{options;rules;lexer;constructor(n){this.options=n||S}space(n){const e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){const e=this.rules.block.code.exec(n);if(e){const t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:v(t,`
|
|
5
|
+
`)}}}fences(n){const e=this.rules.block.fences.exec(n);if(e){const t=e[0],s=Ke(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){const e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){const s=v(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){const e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:v(e[0],`
|
|
6
|
+
`)}}blockquote(n){const e=this.rules.block.blockquote.exec(n);if(e){let t=v(e[0],`
|
|
7
|
+
`).split(`
|
|
8
|
+
`),s="",r="";const i=[];for(;t.length>0;){let l=!1;const a=[];let c;for(c=0;c<t.length;c++)if(this.rules.other.blockquoteStart.test(t[c]))a.push(t[c]),l=!0;else if(!l)a.push(t[c]);else break;t=t.slice(c);const o=a.join(`
|
|
9
|
+
`),h=o.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
11
|
+
${o}`:o,r=r?`${r}
|
|
12
|
+
${h}`:h;const k=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=k,t.length===0)break;const p=i.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){const d=p,f=d.raw+`
|
|
13
|
+
`+t.join(`
|
|
14
|
+
`),b=this.blockquote(f);i[i.length-1]=b,s=s.substring(0,s.length-d.raw.length)+b.raw,r=r.substring(0,r.length-d.text.length)+b.text;break}else if(p?.type==="list"){const d=p,f=d.raw+`
|
|
15
|
+
`+t.join(`
|
|
16
|
+
`),b=this.list(f);i[i.length-1]=b,s=s.substring(0,s.length-p.raw.length)+b.raw,r=r.substring(0,r.length-d.raw.length)+b.raw,t=f.substring(i.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim();const s=t.length>1,r={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");const i=this.rules.other.listItemRegex(t);let l=!1;for(;n;){let c=!1,o="",h="";if(!(e=i.exec(n))||this.rules.block.hr.test(n))break;o=e[0],n=n.substring(o.length);let k=e[2].split(`
|
|
18
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,q=>" ".repeat(3*q.length)),p=n.split(`
|
|
19
|
+
`,1)[0],d=!k.trim(),f=0;if(this.options.pedantic?(f=2,h=k.trimStart()):d?f=e[1].length+1:(f=e[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,h=k.slice(f),f+=e[1].length),d&&this.rules.other.blankLine.test(p)&&(o+=p+`
|
|
20
|
+
`,n=n.substring(p.length+1),c=!0),!c){const q=this.rules.other.nextBulletRegex(f),K=this.rules.other.hrRegex(f),V=this.rules.other.fencesBeginRegex(f),Y=this.rules.other.headingBeginRegex(f),de=this.rules.other.htmlBeginRegex(f);for(;n;){const Z=n.split(`
|
|
21
|
+
`,1)[0];let $;if(p=Z,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),$=p):$=p.replace(this.rules.other.tabCharGlobal," "),V.test(p)||Y.test(p)||de.test(p)||q.test(p)||K.test(p))break;if($.search(this.rules.other.nonSpaceChar)>=f||!p.trim())h+=`
|
|
22
|
+
`+$.slice(f);else{if(d||k.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||V.test(k)||Y.test(k)||K.test(k))break;h+=`
|
|
23
|
+
`+p}!d&&!p.trim()&&(d=!0),o+=Z+`
|
|
24
|
+
`,n=n.substring(Z.length+1),k=$.slice(f)}}r.loose||(l?r.loose=!0:this.rules.other.doubleBlankLine.test(o)&&(l=!0));let b=null,J;this.options.gfm&&(b=this.rules.other.listIsTask.exec(h),b&&(J=b[0]!=="[ ] ",h=h.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:o,task:!!b,checked:J,loose:!1,text:h,tokens:[]}),r.raw+=o}const a=r.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let c=0;c<r.items.length;c++)if(this.lexer.state.top=!1,r.items[c].tokens=this.lexer.blockTokens(r.items[c].text,[]),!r.loose){const o=r.items[c].tokens.filter(k=>k.type==="space"),h=o.length>0&&o.some(k=>this.rules.other.anyLine.test(k.raw));r.loose=h}if(r.loose)for(let c=0;c<r.items.length;c++)r.items[c].loose=!0;return r}}html(n){const e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){const e=this.rules.block.def.exec(n);if(e){const t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:s,title:r}}}table(n){const e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const t=re(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(const l of s)this.rules.other.tableAlignRight.test(l)?i.align.push("right"):this.rules.other.tableAlignCenter.test(l)?i.align.push("center"):this.rules.other.tableAlignLeft.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<t.length;l++)i.header.push({text:t[l],tokens:this.lexer.inline(t[l]),header:!0,align:i.align[l]});for(const l of r)i.rows.push(re(l,i.header.length).map((a,c)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:i.align[c]})));return i}}lheading(n){const e=this.rules.block.lheading.exec(n);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(n){const e=this.rules.block.paragraph.exec(n);if(e){const t=e[1].charAt(e[1].length-1)===`
|
|
26
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){const e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){const e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){const e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){const e=this.rules.inline.link.exec(n);if(e){const t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;const i=v(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{const i=Je(e[2],"()");if(i===-2)return;if(i>-1){const a=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),se(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){const s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){const i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return se(t,r,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!s||s[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!t||this.rules.inline.punctuation.exec(t)){const i=[...s[0]].length-1;let l,a,c=i,o=0;const h=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*n.length+i);(s=h.exec(e))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(a=[...l].length,s[3]||s[4]){c+=a;continue}else if((s[5]||s[6])&&i%3&&!((i+a)%3)){o+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+o);const k=[...s[0]][0].length,p=n.slice(0,i+s.index+k+a);if(Math.min(i,a)%2){const f=p.slice(1,-1);return{type:"em",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}const d=p.slice(2,-2);return{type:"strong",raw:p,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(n){const e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," ");const s=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){const e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n){const e=this.rules.inline.del.exec(n);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(n){const e=this.rules.inline.autolink.exec(n);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,s;if(e[2]==="@")t=e[0],s="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){const e=this.rules.inline.text.exec(n);if(e){const t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},w=class M{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||S,this.options.tokenizer=this.options.tokenizer||new I,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:x,block:A.normal,inline:T.normal};this.options.pedantic?(t.block=A.pedantic,t.inline=T.pedantic):this.options.gfm&&(t.block=A.gfm,this.options.breaks?t.inline=T.breaks:t.inline=T.gfm),this.tokenizer.rules=t}static get rules(){return{block:A,inline:T}}static lex(e,t){return new M(t).lex(e)}static lexInline(e,t){return new M(t).inlineTokens(e)}lex(e){e=e.replace(x.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(x.tabCharGlobal," ").replace(x.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(l=>(r=l.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);const l=t.at(-1);r.raw.length===1&&l!==void 0?l.raw+=`
|
|
28
|
+
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);const l=t.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=`
|
|
29
|
+
`+r.raw,l.text+=`
|
|
30
|
+
`+r.text,this.inlineQueue.at(-1).src=l.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);const l=t.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=`
|
|
31
|
+
`+r.raw,l.text+=`
|
|
32
|
+
`+r.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let l=1/0;const a=e.slice(1);let c;this.options.extensions.startBlock.forEach(o=>{c=o.call({lexer:this},a),typeof c=="number"&&c>=0&&(l=Math.min(l,c))}),l<1/0&&l>=0&&(i=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){const l=t.at(-1);s&&l?.type==="paragraph"?(l.raw+=`
|
|
33
|
+
`+r.raw,l.text+=`
|
|
34
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(r),s=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);const l=t.at(-1);l?.type==="text"?(l.raw+=`
|
|
35
|
+
`+r.raw,l.text+=`
|
|
36
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s=e,r=null;if(this.tokens.links){const a=Object.keys(this.tokens.links);if(a.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)a.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,l="";for(;e;){i||(l=""),i=!1;let a;if(this.options.extensions?.inline?.some(o=>(a=o.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);const o=t.at(-1);a.type==="text"&&o?.type==="text"?(o.raw+=a.raw,o.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,s,l)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if(this.options.extensions?.startInline){let o=1/0;const h=e.slice(1);let k;this.options.extensions.startInline.forEach(p=>{k=p.call({lexer:this},h),typeof k=="number"&&k>=0&&(o=Math.min(o,k))}),o<1/0&&o>=0&&(c=e.substring(0,o+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(l=a.raw.slice(-1)),i=!0;const o=t.at(-1);o?.type==="text"?(o.raw+=a.raw,o.text+=a.text):t.push(a);continue}if(e){const o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return t}},P=class{options;parser;constructor(n){this.options=n||S}space(n){return""}code({text:n,lang:e,escaped:t}){const s=(e||"").match(x.notSpaceStart)?.[0],r=n.replace(x.endingNewline,"")+`
|
|
37
|
+
`;return s?'<pre><code class="language-'+m(s)+'">'+(t?r:m(r,!0))+`</code></pre>
|
|
38
|
+
`:"<pre><code>"+(t?r:m(r,!0))+`</code></pre>
|
|
39
|
+
`}blockquote({tokens:n}){return`<blockquote>
|
|
40
|
+
${this.parser.parse(n)}</blockquote>
|
|
41
|
+
`}html({text:n}){return n}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
|
|
42
|
+
`}hr(n){return`<hr>
|
|
43
|
+
`}list(n){const e=n.ordered,t=n.start;let s="";for(let l=0;l<n.items.length;l++){const a=n.items[l];s+=this.listitem(a)}const r=e?"ol":"ul",i=e&&t!==1?' start="'+t+'"':"";return"<"+r+i+`>
|
|
44
|
+
`+s+"</"+r+`>
|
|
45
|
+
`}listitem(n){let e="";if(n.task){const t=this.checkbox({checked:!!n.checked});n.loose?n.tokens[0]?.type==="paragraph"?(n.tokens[0].text=t+" "+n.tokens[0].text,n.tokens[0].tokens&&n.tokens[0].tokens.length>0&&n.tokens[0].tokens[0].type==="text"&&(n.tokens[0].tokens[0].text=t+" "+m(n.tokens[0].tokens[0].text),n.tokens[0].tokens[0].escaped=!0)):n.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:!0}):e+=t+" "}return e+=this.parser.parse(n.tokens,!!n.loose),`<li>${e}</li>
|
|
46
|
+
`}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
|
|
47
|
+
`}table(n){let e="",t="";for(let r=0;r<n.header.length;r++)t+=this.tablecell(n.header[r]);e+=this.tablerow({text:t});let s="";for(let r=0;r<n.rows.length;r++){const i=n.rows[r];t="";for(let l=0;l<i.length;l++)t+=this.tablecell(i[l]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
48
|
+
<thead>
|
|
49
|
+
`+e+`</thead>
|
|
50
|
+
`+s+`</table>
|
|
51
|
+
`}tablerow({text:n}){return`<tr>
|
|
52
|
+
${n}</tr>
|
|
53
|
+
`}tablecell(n){const e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
|
|
54
|
+
`}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${m(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){const s=this.parser.parseInline(t),r=ne(n);if(r===null)return s;n=r;let i='<a href="'+n+'"';return e&&(i+=' title="'+m(e)+'"'),i+=">"+s+"</a>",i}image({href:n,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));const r=ne(n);if(r===null)return m(t);n=r;let i=`<img src="${n}" alt="${t}"`;return e&&(i+=` title="${m(e)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:m(n.text)}},W=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}},y=class G{options;renderer;textRenderer;constructor(e){this.options=e||S,this.options.renderer=this.options.renderer||new P,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new W}static parse(e,t){return new G(t).parse(e)}static parseInline(e,t){return new G(t).parseInline(e)}parse(e,t=!0){let s="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions?.renderers?.[i.type]){const a=i,c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(a.type)){s+=c||"";continue}}const l=i;switch(l.type){case"space":{s+=this.renderer.space(l);continue}case"hr":{s+=this.renderer.hr(l);continue}case"heading":{s+=this.renderer.heading(l);continue}case"code":{s+=this.renderer.code(l);continue}case"table":{s+=this.renderer.table(l);continue}case"blockquote":{s+=this.renderer.blockquote(l);continue}case"list":{s+=this.renderer.list(l);continue}case"html":{s+=this.renderer.html(l);continue}case"paragraph":{s+=this.renderer.paragraph(l);continue}case"text":{let a=l,c=this.renderer.text(a);for(;r+1<e.length&&e[r+1].type==="text";)a=e[++r],c+=`
|
|
55
|
+
`+this.renderer.text(a);t?s+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):s+=c;continue}default:{const a='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}parseInline(e,t=this.renderer){let s="";for(let r=0;r<e.length;r++){const i=e[r];if(this.options.extensions?.renderers?.[i.type]){const a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=a||"";continue}}const l=i;switch(l.type){case"escape":{s+=t.text(l);break}case"html":{s+=t.html(l);break}case"link":{s+=t.link(l);break}case"image":{s+=t.image(l);break}case"strong":{s+=t.strong(l);break}case"em":{s+=t.em(l);break}case"codespan":{s+=t.codespan(l);break}case"br":{s+=t.br(l);break}case"del":{s+=t.del(l);break}case"text":{s+=t.text(l);break}default:{const a='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}},L=class{options;block;constructor(n){this.options=n||S}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}provideLexer(){return this.block?w.lex:w.lexInline}provideParser(){return this.block?y.parse:y.parseInline}},Ve=class{defaults=O();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=y;Renderer=P;TextRenderer=W;Lexer=w;Tokenizer=I;Hooks=L;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(const s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{const r=s;for(const i of r.header)t=t.concat(this.walkTokens(i.tokens,e));for(const i of r.rows)for(const l of i)t=t.concat(this.walkTokens(l.tokens,e));break}case"list":{const r=s;t=t.concat(this.walkTokens(r.items,e));break}default:{const r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{const l=r[i].flat(1/0);t=t.concat(this.walkTokens(l,e))}):r.tokens&&(t=t.concat(this.walkTokens(r.tokens,e)))}}return t}use(...n){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{const s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){const i=e.renderers[r.name];i?e.renderers[r.name]=function(...l){let a=r.renderer.apply(this,l);return a===!1&&(a=i.apply(this,l)),a}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),t.renderer){const r=this.defaults.renderer||new P(this.defaults);for(const i in t.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const l=i,a=t.renderer[l],c=r[l];r[l]=(...o)=>{let h=a.apply(r,o);return h===!1&&(h=c.apply(r,o)),h||""}}s.renderer=r}if(t.tokenizer){const r=this.defaults.tokenizer||new I(this.defaults);for(const i in t.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const l=i,a=t.tokenizer[l],c=r[l];r[l]=(...o)=>{let h=a.apply(r,o);return h===!1&&(h=c.apply(r,o)),h}}s.tokenizer=r}if(t.hooks){const r=this.defaults.hooks||new L;for(const i in t.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const l=i,a=t.hooks[l],c=r[l];L.passThroughHooks.has(i)?r[l]=o=>{if(this.defaults.async)return Promise.resolve(a.call(r,o)).then(k=>c.call(r,k));const h=a.call(r,o);return c.call(r,h)}:r[l]=(...o)=>{let h=a.apply(r,o);return h===!1&&(h=c.apply(r,o)),h}}s.hooks=r}if(t.walkTokens){const r=this.defaults.walkTokens,i=t.walkTokens;s.walkTokens=function(l){let a=[];return a.push(i.call(this,l)),r&&(a=a.concat(r.call(this,l))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return w.lex(n,e??this.defaults)}parser(n,e){return y.parse(n,e??this.defaults)}parseMarkdown(n){return(t,s)=>{const r={...s},i={...this.defaults,...r},l=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return l(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));i.hooks&&(i.hooks.options=i,i.hooks.block=n);const a=i.hooks?i.hooks.provideLexer():n?w.lex:w.lexInline,c=i.hooks?i.hooks.provideParser():n?y.parse:y.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(o=>a(o,i)).then(o=>i.hooks?i.hooks.processAllTokens(o):o).then(o=>i.walkTokens?Promise.all(this.walkTokens(o,i.walkTokens)).then(()=>o):o).then(o=>c(o,i)).then(o=>i.hooks?i.hooks.postprocess(o):o).catch(l);try{i.hooks&&(t=i.hooks.preprocess(t));let o=a(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let h=c(o,i);return i.hooks&&(h=i.hooks.postprocess(h)),h}catch(o){return l(o)}}}onError(n,e){return t=>{if(t.message+=`
|
|
56
|
+
Please report this to https://github.com/markedjs/marked.`,n){const s="<p>An error occurred:</p><pre>"+m(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},R=new Ve;function g(n,e){return R.parse(n,e)}g.options=g.setOptions=function(n){return R.setOptions(n),g.defaults=R.defaults,ie(g.defaults),g};g.getDefaults=O;g.defaults=S;g.use=function(...n){return R.use(...n),g.defaults=R.defaults,ie(g.defaults),g};g.walkTokens=function(n,e){return R.walkTokens(n,e)};g.parseInline=R.parseInline;g.Parser=y;g.parser=y.parse;g.Renderer=P;g.TextRenderer=W;g.Lexer=w;g.lexer=w.lex;g.Tokenizer=I;g.Hooks=L;g.parse=g;g.options;g.setOptions;g.use;g.walkTokens;g.parseInline;y.parse;w.lex;export{g as m};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{r as _,c as V,z as O,j as d}from"./index-B84Dx7nI.js";import{u as q}from"./decopilot-events-BrbCILIn.js";import{K as Y,T as G,t as J}from"./types-DibruoFW.js";function N(o){return Math.ceil(o.length*3/4)}function be(o){const e=[];for(const t of o)switch(t.type){case"text":t.text?.trim()&&e.push({type:"paragraph",content:[{type:"text",text:t.text}]});break;case"image":case"audio":t.data&&t.mimeType&&e.push({type:"paragraph",content:[{type:"file",attrs:{id:crypto.randomUUID(),name:`${t.type}.${t.mimeType.split("/")[1]??"bin"}`,mimeType:t.mimeType,size:N(t.data),data:t.data}}]});break;case"resource":{const n=t.resource;"text"in n&&n.text?e.push({type:"paragraph",content:[{type:"text",text:n.text}]}):"blob"in n&&n.blob&&e.push({type:"paragraph",content:[{type:"file",attrs:{id:crypto.randomUUID(),name:String(n.uri),mimeType:n.mimeType??"application/octet-stream",size:N(n.blob),data:n.blob}}]});break}case"resource_link":e.push({type:"paragraph",content:[{type:"text",text:t.name??t.uri}]});break}return{type:"doc",content:e}}const z=["default-src 'none'","script-src 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval'","style-src 'unsafe-inline'","img-src * data: blob:","font-src data:","connect-src 'none'","frame-src 'none'","worker-src blob:","form-action 'none'","base-uri 'none'"].join("; ");function Q(o,e={}){const n=`<meta http-equiv="Content-Security-Policy" content="${ee(e)}">`,s=/<head(\s[^>]*)?>|<HEAD(\s[^>]*)?>/i,c=o.match(s);if(c){const i=(c.index??0)+c[0].length;return o.slice(0,i)+`
|
|
2
|
+
`+n+o.slice(i)}const a=/<html(\s[^>]*)?>|<HTML(\s[^>]*)?>/i,r=o.match(a);if(r){const i=(r.index??0)+r[0].length;return o.slice(0,i)+`
|
|
3
|
+
<head>
|
|
4
|
+
`+n+`
|
|
5
|
+
</head>`+o.slice(i)}const u=/<!DOCTYPE[^>]*>/i,l=o.match(u);if(l){const i=(l.index??0)+l[0].length;return o.slice(0,i)+`
|
|
6
|
+
<head>
|
|
7
|
+
`+n+`
|
|
8
|
+
</head>`+o.slice(i)}return`<head>
|
|
9
|
+
`+n+`
|
|
10
|
+
</head>
|
|
11
|
+
`+o}const X=/^https?:\/\/(\*\.)?[a-zA-Z0-9._-]+(:\d+)?\/?$/;function L(o){return!o||o.length===0?[]:o.filter(e=>X.test(e))}function ee(o){if(o.csp)return o.csp;const e=o.resourceCsp;if(!e)return z;const t=L(e.resourceDomains),n=L(e.connectDomains),s=L(e.frameDomains),c=L(e.baseUriDomains),a=t.length>0,r=n.length>0,u=s.length>0,l=c.length>0;if(!a&&!r&&!u&&!l)return z;const i=t.join(" ");return["default-src 'none'",a?`script-src 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' ${i}`:"script-src 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval'",a?`style-src 'unsafe-inline' ${i}`:"style-src 'unsafe-inline'",a?`img-src * data: blob: ${i}`:"img-src * data: blob:",a?`font-src data: ${i}`:"font-src data:",r?`connect-src ${n.join(" ")}`:"connect-src 'none'",u?`frame-src ${s.join(" ")}`:"frame-src 'none'","worker-src blob:","form-action 'none'",l?`base-uri ${c.join(" ")}`:"base-uri 'none'"].join("; ")}const te=[["--background","--color-background-primary"],["--muted","--color-background-secondary"],["--accent","--color-background-tertiary"],["--destructive","--color-background-danger"],["--success","--color-background-success"],["--warning","--color-background-warning"],["--foreground","--color-text-primary"],["--muted-foreground","--color-text-secondary"],["--accent-foreground","--color-text-tertiary"],["--destructive-foreground","--color-text-danger"],["--success-foreground","--color-text-success"],["--warning-foreground","--color-text-warning"],["--border","--color-border-primary"],["--input","--color-border-secondary"],["--ring","--color-ring-primary"],["--font-sans","--font-sans"],["--font-mono","--font-mono"],["--font-weight-normal","--font-weight-normal"],["--font-weight-medium","--font-weight-medium"],["--font-weight-semibold","--font-weight-semibold"],["--font-weight-bold","--font-weight-bold"],["--radius","--border-radius-md"],["--default-border-width","--border-width-regular"],["--shadow-sm","--shadow-sm"],["--shadow-md","--shadow-md"],["--shadow-lg","--shadow-lg"]];function ne(){if(typeof document>"u")return{};const o=getComputedStyle(document.documentElement),e={};for(const[t,n]of te){const s=o.getPropertyValue(t).trim();s&&(e[n]=s)}return{variables:e}}const oe={name:"MCP Mesh",version:"1.0.0"},se={openLinks:{},serverTools:{},serverResources:{},logging:{},message:{},downloadFile:{},updateModelContext:{text:{}}},re=15e3;function ie(){return typeof navigator>"u"?"en":navigator.language??"en"}function ae(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}function ce(){return typeof navigator>"u"?"web":/Mobi|Android/i.test(navigator.userAgent)?"mobile":"web"}function B(o,e,t){return{theme:J(),styles:ne(),displayMode:o,availableDisplayModes:["inline","fullscreen"],locale:ie(),timeZone:ae(),platform:ce(),...e!=null&&{toolInfo:e},...t!=null&&{containerDimensions:{maxHeight:t}}}}const $=new Set;let F=!1;function le(){if(F||typeof document>"u")return;F=!0;const o=()=>$.forEach(e=>e());new MutationObserver(o).observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"]}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",o)}function ue(o){return $.add(o),le(),()=>$.delete(o)}class de{bridge=null;timeout=null;disposed=!1;unsubTheme=null;snapshot;listeners=new Set;config;constructor(e){this.config=e,this.snapshot=Object.freeze({height:e.minHeight,isLoading:!0,error:null})}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getSnapshot=()=>this.snapshot;updateConfig(e){const t=this.config;this.config=e,!(!this.bridge||this.disposed)&&(e.toolInput!==t.toolInput&&e.toolInput!=null&&this.bridge.sendToolInput({arguments:e.toolInput}),e.toolResult!==t.toolResult&&e.toolResult!=null&&this.bridge.sendToolResult(e.toolResult))}pushHostContext(){if(!this.bridge||this.disposed)return;const{displayMode:e,maxHeight:t,toolInfo:n}=this.config;this.bridge.setHostContext(B(e,n,t))}set(e){const t=this.snapshot,n={...t,...e};if(!(n.height===t.height&&n.isLoading===t.isLoading&&n.error===t.error)){this.snapshot=Object.freeze(n);for(const s of this.listeners)s()}}teardown(){(this.bridge||this.timeout||this.unsubTheme)&&this.config.onTeardown?.(),this.disposed=!0,this.unsubTheme?.(),this.unsubTheme=null,this.bridge&&(this.bridge.teardownResource({}).catch(()=>{}),this.bridge.close(),this.bridge=null),this.timeout&&(clearTimeout(this.timeout),this.timeout=null)}attach=e=>{if(this.teardown(),this.disposed=!1,this.set({height:this.config.minHeight,isLoading:!0,error:null}),!!e){e.onerror=()=>{this.disposed||this.set({error:"Failed to load app",isLoading:!1})};try{const{client:t,displayMode:n,maxHeight:s,toolInfo:c}=this.config,a=B(n,c,s),r=new Y(t,oe,se,{hostContext:a});this.bridge=r,this.registerHandlers(r),this.startInitTimeout(),this.registerInitHandler(r),this.connectTransport(r,e),this.unsubTheme=ue(()=>this.pushHostContext())}catch(t){this.clearTimeout(),console.error("Failed to create AppBridge:",t),this.set({error:t instanceof Error?t.message:"Unknown error",isLoading:!1})}}};registerHandlers(e){e.onopenlink=async({url:t})=>{let n=null;try{n=new URL(t)}catch{}if(!n||!["http:","https:"].includes(n.protocol))throw new Error("Only http and https URLs are allowed");return window.open(t,"_blank","noopener,noreferrer"),{}},e.onmessage=async t=>(this.config.onMessage?.(t),{}),e.onupdatemodelcontext=async t=>(this.config.onUpdateModelContext?.(t),{}),e.onsizechange=({height:t})=>{if(!this.disposed&&t!=null){const{minHeight:n,maxHeight:s}=this.config;this.set({height:Math.max(n,Math.min(s,t))})}},e.onloggingmessage=({level:t,data:n})=>{console[t==="error"?"error":"debug"](`[MCP App ${this.config.toolInfo?.tool.name??"unknown"}]`,n)},e.ondownloadfile=async({contents:t})=>{for(const n of t)if(n.type==="resource"){const s=n.resource,c="blob"in s?new Blob([Uint8Array.from(atob(s.blob),u=>u.charCodeAt(0))],{type:s.mimeType}):new Blob([s.text??""],{type:s.mimeType}),a=URL.createObjectURL(c),r=document.createElement("a");r.href=a,r.download=s.uri.split("/").pop()??"download",r.click(),URL.revokeObjectURL(a)}else n.type==="resource_link"&&window.open(n.uri,"_blank");return{}}}registerInitHandler(e){e.oninitialized=()=>{if(this.disposed)return;this.clearTimeout(),this.set({isLoading:!1});const{toolInput:t,toolResult:n}=this.config;t!=null&&e.sendToolInput({arguments:t}),n!=null&&e.sendToolResult(n)}}startInitTimeout(){this.timeout=setTimeout(()=>{this.disposed||this.set({error:"App took too long to load",isLoading:!1})},re)}clearTimeout(){this.timeout&&(globalThis.clearTimeout(this.timeout),this.timeout=null)}connectTransport(e,t){if(!t.contentWindow){console.warn("iframe contentWindow not yet available");return}const n=new G(t.contentWindow,t.contentWindow);e.connect(n).catch(s=>{this.disposed||(this.clearTimeout(),console.error("AppBridge connect failed:",s),this.set({error:s instanceof Error?s.message:"Connection failed",isLoading:!1}))})}}function he(o){const e=_.useRef(new de(o));_.useEffect(()=>{e.current.updateConfig(o)},[o]);const{height:t,isLoading:n,error:s}=_.useSyncExternalStore(e.current.subscribe,e.current.getSnapshot);return{height:t,isLoading:n,error:s,iframeRef:e.current.attach}}function fe(o){const e=o?.contents?.[0];return!e||!("text"in e)||!e.text?null:Q(e.text,{resourceCsp:e._meta?.ui?.csp})}function ye(o){const e=V.c(39),{resourceURI:t,toolInfo:n,toolInput:s,toolResult:c,displayMode:a,minHeight:r,maxHeight:u,client:l,onMessage:i,onUpdateModelContext:x,onTeardown:D,className:h}=o,H=a===void 0?"inline":a,j=r===void 0?150:r,S=u===void 0?600:u;let T;e[0]!==l||e[1]!==t?(T={client:l,uri:t,staleTime:3e4},e[0]=l,e[1]=t,e[2]=T):T=e[2];const{data:W}=q(T),v=fe(W);let R;e[3]!==l||e[4]!==H||e[5]!==S||e[6]!==j||e[7]!==i||e[8]!==D||e[9]!==x||e[10]!==n||e[11]!==s||e[12]!==c?(R={client:l,displayMode:H,minHeight:j,maxHeight:S,toolInfo:n,toolInput:s,toolResult:c,onMessage:i,onUpdateModelContext:x,onTeardown:D},e[3]=l,e[4]=H,e[5]=S,e[6]=j,e[7]=i,e[8]=D,e[9]=x,e[10]=n,e[11]=s,e[12]=c,e[13]=R):R=e[13];const{height:Z,isLoading:M,error:C,iframeRef:P}=he(R);if(!v)return null;if(C){let y;e[14]!==h?(y=O("flex items-center justify-center p-4 text-destructive bg-destructive/10 rounded-lg",h),e[14]=h,e[15]=y):y=e[15];let w;e[16]!==C?(w=d.jsx("span",{className:"text-sm",children:C}),e[16]=C,e[17]=w):w=e[17];let I;return e[18]!==y||e[19]!==w?(I=d.jsx("div",{className:y,children:w}),e[18]=y,e[19]=w,e[20]=I):I=e[20],I}const K=n?.tool.name;let f;e[21]!==h?(f=O("relative w-full overflow-hidden rounded-lg",h),e[21]=h,e[22]=f):f=e[22];const U=`${Z}px`;let m;e[23]!==U?(m={height:U},e[23]=U,e[24]=m):m=e[24];let p;e[25]!==M?(p=M&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background z-10",children:d.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[d.jsx("div",{className:"size-4 border-2 border-current border-t-transparent rounded-full animate-spin"}),d.jsx("span",{className:"text-sm",children:"Loading app..."})]})}),e[25]=M,e[26]=p):p=e[26];const E=M&&"invisible";let g;e[27]!==E?(g=O("w-full h-full border-0",E),e[27]=E,e[28]=g):g=e[28];const A=`MCP App: ${K??t}`;let b;e[29]!==v||e[30]!==P||e[31]!==g||e[32]!==A?(b=d.jsx("iframe",{ref:P,srcDoc:v,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:g,title:A}),e[29]=v,e[30]=P,e[31]=g,e[32]=A,e[33]=b):b=e[33];let k;return e[34]!==b||e[35]!==f||e[36]!==m||e[37]!==p?(k=d.jsxs("div",{className:f,style:m,children:[p,b]}),e[34]=b,e[35]=f,e[36]=m,e[37]=p,e[38]=k):k=e[38],k}export{ye as M,be as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as Z,c as V,z as H,j as n,B as J}from"./index-B84Dx7nI.js";import{a as K,b as Q,T as X}from"./tooltip-CHJhCJL3.js";import{i as F}from"./CheckVerified02-D6qy17me.js";import{s as Y}from"./Globe02-D7s1ULQJ.js";import{i as ee}from"./Lock01-STjQUMU6.js";import{s as te}from"./Plus-Dp8Rr75G.js";import{i as se}from"./Terminal-CtjH6zFY.js";import{C as le}from"./card-CkYe6Ikt.js";import{I as ie}from"./integration-icon-DNJkhUIt.js";import{g as ne}from"./github-icon-Dp3wHhYE.js";const W=({size:s=24,color:e="currentColor",...i})=>Z.createElement("svg",{viewBox:"0 0 24 24",width:s,height:s,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...i},Z.createElement("path",{d:"M6 6h.01M6 18h.01m-.81-8h13.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C22 8.48 22 7.92 22 6.8V5.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C20.48 2 19.92 2 18.8 2H5.2c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C2 3.52 2 4.08 2 5.2v1.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C3.52 10 4.08 10 5.2 10Zm0 12h13.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C22 20.48 22 19.92 22 18.8v-1.6c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C20.48 14 19.92 14 18.8 14H5.2c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C2 15.52 2 16.08 2 17.2v1.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C3.52 22 4.08 22 5.2 22Z"}));W.displayName="Server01";function ae(s){if(!s.includes("/"))return s;const e=s.split("/"),i=e[0],l=e[1];if(!i||!l)return s;if(i.includes(".")){const a=i.split("."),r=a[a.length-1]||i,c=l.replace(/^mcp-?/,"").replace(/-?mcp$/,"").replace(/^server-?/,"").replace(/-?server$/,"");return!c||c.length<2?r:c}return l}function re(s){const e=V.c(2),{protocol:i,className:l}=s;let a;return e[0]!==l?(a={http:n.jsx(Y,{className:l}),sse:n.jsx(W,{className:l}),stdio:n.jsx(se,{className:l})},e[0]=l,e[1]=a):a=e[1],a[i]}function ce(s){switch(s){case"http":return"HTTP";case"sse":return"SSE";case"stdio":return"STDIO"}}function oe(s){const e=V.c(9),{protocol:i}=s;let l;e[0]!==i?(l=H("flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium shrink-0",{http:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",sse:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",stdio:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400"}[i]),e[0]=i,e[1]=l):l=e[1];let a,r;e[2]!==i?(a=n.jsx(re,{protocol:i,className:"w-3 h-3"}),r=ce(i),e[2]=i,e[3]=a,e[4]=r):(a=e[3],r=e[4]);let c;return e[5]!==l||e[6]!==a||e[7]!==r?(c=n.jsxs("div",{className:l,children:[a,r]}),e[5]=l,e[6]=a,e[7]=r,e[8]=c):c=e[8],c}function me(s){const e=V.c(73),{icon:i,displayName:l,description:a,onClick:r}=s,t=(s.variant??"store")==="server",m=t?s.hostname:null,f=t?s.protocol:null,p=t?s.isInstalling:!1,x=t?s.actionLabel:void 0,d=t?null:s.scopeName,o=t?!1:s.isVerified,u=t?!1:s.isOfficial,h=t?!0:s.canInstall,R=t?"p-4":"p-6";let g;e[0]!==R?(g=H("cursor-pointer hover:bg-muted/50 transition-colors",R),e[0]=R,e[1]=g):g=e[1];const A=t?"gap-3":"gap-4";let v;e[2]!==A?(v=H("flex flex-col h-full relative",A),e[2]=A,e[3]=v):v=e[3];const G=t?"sm":"md";let j;e[4]!==l||e[5]!==i||e[6]!==G?(j=n.jsx(ie,{icon:i,name:l,size:G,className:"shadow-sm shrink-0"}),e[4]=l,e[5]=i,e[6]=G,e[7]=j):j=e[7];const U=t?"text-sm":"text-base";let N;e[8]!==U?(N=H("flex items-center gap-2 font-medium min-w-0",U),e[8]=U,e[9]=N):N=e[9];let C;e[10]!==l?(C=n.jsx("span",{className:"truncate",children:l}),e[10]=l,e[11]=C):C=e[11];let b;e[12]!==u||e[13]!==t?(b=!t&&u&&n.jsx(F,{size:16,className:"text-primary shrink-0"}),e[12]=u,e[13]=t,e[14]=b):b=e[14];let k;e[15]!==u||e[16]!==t||e[17]!==o?(k=!t&&!u&&o&&n.jsx(F,{size:16,className:"text-success shrink-0"}),e[15]=u,e[16]=t,e[17]=o,e[18]=k):k=e[18];let y;e[19]!==h||e[20]!==t?(y=!t&&!h&&n.jsx(ee,{size:16,className:"text-muted-foreground shrink-0"}),e[19]=h,e[20]=t,e[21]=y):y=e[21];let I;e[22]!==t||e[23]!==f?(I=t&&f&&n.jsx(oe,{protocol:f}),e[22]=t,e[23]=f,e[24]=I):I=e[24];let w;e[25]!==k||e[26]!==y||e[27]!==I||e[28]!==N||e[29]!==C||e[30]!==b?(w=n.jsx(K,{asChild:!0,children:n.jsxs("div",{className:N,children:[C,b,k,y,I]})}),e[25]=k,e[26]=y,e[27]=I,e[28]=N,e[29]=C,e[30]=b,e[31]=w):w=e[31];let S;e[32]!==l?(S=n.jsx("p",{children:l}),e[32]=l,e[33]=S):S=e[33];let $;e[34]!==h||e[35]!==t?($=!t&&!h&&n.jsx("p",{className:"text-xs mt-1",children:"No connection available"}),e[34]=h,e[35]=t,e[36]=$):$=e[36];let P;e[37]!==S||e[38]!==$?(P=n.jsxs(Q,{children:[S,$]}),e[37]=S,e[38]=$,e[39]=P):P=e[39];let T;e[40]!==w||e[41]!==P?(T=n.jsxs(X,{children:[w,P]}),e[40]=w,e[41]=P,e[42]=T):T=e[42];let _;e[43]!==m||e[44]!==t||e[45]!==d?(_=(d||m)&&n.jsx("div",{className:H("text-muted-foreground truncate",t?"text-xs mt-0.5":"text-sm"),children:d||m}),e[43]=m,e[44]=t,e[45]=d,e[46]=_):_=e[46];let z;e[47]!==T||e[48]!==_?(z=n.jsx("div",{className:"flex gap-2 items-start min-w-0 flex-1",children:n.jsxs("div",{className:"min-w-0 flex-1",children:[T,_]})}),e[47]=T,e[48]=_,e[49]=z):z=e[49];let D;e[50]!==z||e[51]!==j?(D=n.jsxs("div",{className:"flex gap-3",children:[j,z]}),e[50]=z,e[51]=j,e[52]=D):D=e[52];let E;e[53]!==a?(E=a&&n.jsx("div",{className:"text-sm text-muted-foreground line-clamp-2",children:a}),e[53]=a,e[54]=E):E=e[54];let M;e[55]!==a||e[56]!==t?(M=!a&&!t&&n.jsx("div",{className:"text-sm text-muted-foreground line-clamp-2",children:"No description available"}),e[55]=a,e[56]=t,e[57]=M):M=e[57];let L;e[58]!==x||e[59]!==p||e[60]!==t||e[61]!==r?(L=t&&n.jsxs(J,{variant:"outline",size:"sm",onClick:q=>{q.stopPropagation(),r()},disabled:p,className:"w-full mt-auto cursor-pointer",children:[n.jsx(te,{size:16}),p?"Connecting...":x||"Connect"]}),e[58]=x,e[59]=p,e[60]=t,e[61]=r,e[62]=L):L=e[62];let B;e[63]!==D||e[64]!==E||e[65]!==M||e[66]!==L||e[67]!==v?(B=n.jsxs("div",{className:v,children:[D,E,M,L]}),e[63]=D,e[64]=E,e[65]=M,e[66]=L,e[67]=v,e[68]=B):B=e[68];let O;return e[69]!==r||e[70]!==g||e[71]!==B?(O=n.jsx(le,{className:g,onClick:r,children:B}),e[69]=r,e[70]=g,e[71]=B,e[72]=O):O=e[72],O}function de(s){const e=s.server,i=s._meta?.["mcp.mesh"],l=i?.friendly_name||s.name||e?.title||s.title||s.id||"Unnamed Item",a=i?.short_description||i?.mesh_description||e?.description||s.description||null,r=e?.icons?.[0]?.src||ne(e?.repository)||null,c=i?.verified??!1,t=i?.official??!1,m=(e?.remotes?.length??0)>0,f=(e?.packages?.length??0)>0,p=m||f;let x=l,d=null;if(l.includes("/")){const o=l.split("/");o.length>=2&&(d=o[0]||null,x=ae(l))}if(!d){const o=i?.scopeName,u=i?.appName;o&&u?d=`${o}/${u}`:o&&(d=o)}return!d&&s.id?.includes("/")&&(d=s.id),i?.friendly_name&&(x=i.friendly_name),{icon:r,scopeName:d,displayName:x,description:a,isVerified:c,isOfficial:t,canInstall:p}}function ke(s){const e=V.c(19),{items:i,title:l,onItemClick:a}=s;let r,c,t,m,f;if(e[0]!==i||e[1]!==a||e[2]!==l){f=Symbol.for("react.early_return_sentinel");e:{const d=i.filter(fe);if(d.length===0){f=null;break e}t="flex flex-col gap-4",e[8]!==l?(m=l&&n.jsx("div",{className:"flex items-center justify-between w-max gap-2",children:n.jsx("h2",{className:"text-lg font-medium",children:l})}),e[8]=l,e[9]=m):m=e[9],r="grid grid-cols-4 gap-4";let o;e[10]!==a?(o=u=>{const h=de(u);return n.jsx(me,{...h,onClick:()=>a(u)},u.id)},e[10]=a,e[11]=o):o=e[11],c=d.map(o)}e[0]=i,e[1]=a,e[2]=l,e[3]=r,e[4]=c,e[5]=t,e[6]=m,e[7]=f}else r=e[3],c=e[4],t=e[5],m=e[6],f=e[7];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;e[12]!==r||e[13]!==c?(p=n.jsx("div",{className:r,children:c}),e[12]=r,e[13]=c,e[14]=p):p=e[14];let x;return e[15]!==t||e[16]!==m||e[17]!==p?(x=n.jsxs("div",{className:t,children:[m,p]}),e[15]=t,e[16]=m,e[17]=p,e[18]=x):x=e[18],x}function fe(s){return s!=null}export{ke as M,me as a,W as b,ae as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B84Dx7nI.js","assets/index-CcaZ2Rhp.css","assets/index-D9XxJ5Op.js","assets/use-collections-BoFyuDa6.js","assets/useMutation-Be5QSQym.js","assets/constants-_xTq0aTt.js","assets/use-connection-DSPQNIQD.js","assets/use-mcp-tools-K2l5CqFr.js","assets/useQuery-CIRdCYZz.js","assets/decopilot-events-BrbCILIn.js","assets/use-mcp-prompts-C___IsDE.js","assets/use-virtual-mcp-5EdNqvyH.js","assets/usage-B8eRkRZY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as Y,c as G,j as t,B as se,x as me,z as ze,K as ue,bZ as fe,u as _e,e as Ie,O as ie,g as Fe,d as Oe,f as He,at as Ge}from"./index-B84Dx7nI.js";import{i as qe}from"./AlertCircle-DsQlVvig.js";import{i as ke}from"./Loading01-aMp99RZI.js";import{P as de}from"./index-CmH5OQnm.js";import{c as Ke,T as We,a as Qe,b as Ye}from"./tooltip-CHJhCJL3.js";import{i as Xe}from"./Check-OSWZCZf9.js";import{a as Ze}from"./Copy01-B595Thpy.js";import{I as Te}from"./integration-icon-DNJkhUIt.js";import{i as Je}from"./CheckCircle-B2wkNkz_.js";import{t as et}from"./ChevronDown-BR4cCk-W.js";import{s as ve}from"./Plus-Dp8Rr75G.js";import{a as tt,c as st,b as rt,D as ot}from"./dropdown-menu-DjhC4m2a.js";import{n as be}from"./LinkExternal01-Cj5yLC8K.js";import{E as nt}from"./collection-search-DXvW2iQG.js";import{R as ye}from"./readme-viewer-WWU4z7Xg.js";import{u as pe}from"./useQuery-CIRdCYZz.js";import{m as je}from"./marked.esm-BaswSlok.js";import{a as it}from"./tools-list-BzLGkrz5.js";import{C as lt}from"./collection-tabs-BEqvkJum.js";import{s as at}from"./Globe02-D7s1ULQJ.js";import{a as ct,b as dt,e as mt}from"./mcp-server-card-M7WdUx8I.js";import{i as ut}from"./Terminal-CtjH6zFY.js";import{B as ft,a as pt,b as Ne,d as xt,e as ht,c as gt}from"./breadcrumb-BrsAPde7.js";import{u as vt}from"./use-binding-Bdb-0lwc.js";import{a as bt,b as yt,u as jt}from"./use-connection-DSPQNIQD.js";import{u as Nt}from"./constants-_xTq0aTt.js";import{u as wt}from"./use-mcp-tools-K2l5CqFr.js";import{u as Ct,L as St}from"./localstorage-keys-BckSA5cs.js";import{e as _t}from"./extract-connection-data-DUglufvW.js";import{s as It}from"./slugify-CEUa2lfQ.js";import{e as kt,g as Tt}from"./github-icon-Dp3wHhYE.js";import{f as Lt,d as we,g as Pt,h as Mt}from"./registry-utils-CMqg9IHN.js";import{i as Rt}from"./InfoCircle-s0XyUQYC.js";import"./index-C8u6axf-.js";import"./Container-BVSlDn4p.js";import"./ChevronRight-ByOuE_Vi.js";import"./SearchMd-r7i5BQk7.js";import"./input-NIbTU7RU.js";import"./File06-B7IZdrgj.js";import"./collection-display-button-DEx37m4V.js";import"./ArrowDown-KTP4HONB.js";import"./ArrowUp-BfaawFDM.js";import"./Grid01-DIGu5eh8.js";import"./List-BnvhY7Nh.js";import"./badge-DxYG_XB9.js";import"./collection-table-wrapper-xKuLiuQ5.js";import"./table-vuF1fVQ6.js";import"./card-CkYe6Ikt.js";import"./types-DibruoFW.js";import"./Eye-CHYeRDXI.js";import"./LayersTwo01-C4CgBsBK.js";import"./layout-CMdmqG4j.js";import"./CheckVerified02-D6qy17me.js";import"./Lock01-STjQUMU6.js";import"./binder-wDmRPNL2.js";import"./use-collections-BoFyuDa6.js";import"./useMutation-Be5QSQym.js";import"./constants-BBAQxhFl.js";import"./generate-id-Dyweu44Y.js";const Le=({size:r=24,color:e="currentColor",...s})=>Y.createElement("svg",{viewBox:"0 0 24 24",width:r,height:r,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},Y.createElement("path",{d:"m21 21-3.5-3.5m2.5-6a8.5 8.5 0 1 1-17 0 8.5 8.5 0 0 1 17 0Z"}));Le.displayName="SearchLg";function Dt(r){const e=G.c(3),{message:s}=r,o=s===void 0?"Loading MCP Server details...":s;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(ke,{size:48,className:"animate-spin mb-4"}),e[0]=n):n=e[0];let l;return e[1]!==o?(l=t.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[n,t.jsx("p",{className:"text-sm text-muted-foreground",children:o})]}),e[1]=o,e[2]=l):l=e[2],l}function Et(r){const e=G.c(9),{error:s,onBack:o}=r,n=s instanceof Error?s.message:s;let l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(qe,{size:48,className:"text-destructive mb-4"}),c=t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Error loading MCP Server"}),e[0]=l,e[1]=c):(l=e[0],c=e[1]);let m;e[2]!==n?(m=t.jsx("p",{className:"text-muted-foreground max-w-md text-center",children:n}),e[2]=n,e[3]=m):m=e[3];let a;e[4]!==o?(a=t.jsx("button",{onClick:o,className:"mt-4 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:"Go Back"}),e[4]=o,e[5]=a):a=e[5];let d;return e[6]!==m||e[7]!==a?(d=t.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[l,c,m,a]}),e[6]=m,e[7]=a,e[8]=d):d=e[8],d}function Ut(r){const e=G.c(5),{onBack:s}=r;let o,n,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Le,{size:48,className:"text-muted-foreground mb-4"}),n=t.jsx("h3",{className:"text-lg font-medium mb-2",children:"MCP Server not found"}),l=t.jsx("p",{className:"text-muted-foreground max-w-md text-center",children:"The MCP Server you're looking for doesn't exist in this store."}),e[0]=o,e[1]=n,e[2]=l):(o=e[0],n=e[1],l=e[2]);let c;return e[3]!==s?(c=t.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o,n,l,t.jsx("button",{onClick:s,className:"mt-4 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:"Go Back to Store"})]}),e[3]=s,e[4]=c):c=e[4],c}function $t(r){const e=G.c(11),{breadcrumb:s,shareUrl:o}=r,[n,l]=Y.useState(!1);let c;e[0]!==o?(c=async()=>{o&&(await navigator.clipboard.writeText(o),l(!0),me.success("Share link copied to clipboard"),setTimeout(()=>l(!1),2e3))},e[0]=o,e[1]=c):c=e[1];const m=c;let a;e[2]!==s?(a=t.jsx(de.Header.Left,{children:s}),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==n||e[5]!==m||e[6]!==o?(d=o&&t.jsx(de.Header.Right,{children:t.jsx(Ke,{children:t.jsxs(We,{children:[t.jsx(Qe,{asChild:!0,children:t.jsxs(se,{variant:"outline",size:"sm",onClick:m,className:"gap-1.5 cursor-pointer",children:[n?t.jsx(Xe,{size:16,className:"text-green-600"}):t.jsx(Ze,{size:16}),t.jsx("span",{children:n?"Copied!":"Share"})]})}),t.jsx(Ye,{children:t.jsx("p",{children:"Copy a universal link anyone can use to find this MCP"})})]})})}),e[4]=n,e[5]=m,e[6]=o,e[7]=d):d=e[7];let w;return e[8]!==a||e[9]!==d?(w=t.jsxs(de.Header,{children:[a,d]}),e[8]=a,e[9]=d,e[10]=w):w=e[10],w}function Ce(r){const e=G.c(28),{versions:s,selectedIndex:o,onSelect:n,isInstalling:l,variant:c,showLabel:m}=r,a=l===void 0?!1:l,d=c===void 0?"default":c,w=m===void 0?!1:m,p=s[o],I=w?"sm":"default",f=d==="default"&&"rounded-l-none px-2 border-l-2 border-l-white/50";let v;e[0]!==f?(v=ze("shrink-0 cursor-pointer",f),e[0]=f,e[1]=v):v=e[1];let u;e[2]!==p?.server?.version||e[3]!==w?(u=w&&t.jsxs("span",{className:"mr-1",children:["v",p?.server?.version||"unknown"]}),e[2]=p?.server?.version,e[3]=w,e[4]=u):u=e[4];const N=w?14:20;let h;e[5]!==N?(h=t.jsx(et,{size:N}),e[5]=N,e[6]=h):h=e[6];let y;e[7]!==a||e[8]!==I||e[9]!==v||e[10]!==u||e[11]!==h||e[12]!==d?(y=t.jsx(tt,{asChild:!0,children:t.jsxs(se,{variant:d,disabled:a,size:I,className:v,children:[u,h]})}),e[7]=a,e[8]=I,e[9]=v,e[10]=u,e[11]=h,e[12]=d,e[13]=y):y=e[13];let j;if(e[14]!==a||e[15]!==n||e[16]!==o||e[17]!==s){let T;e[19]!==a||e[20]!==n||e[21]!==o?(T=(S,_)=>{const M=S._meta?.["io.modelcontextprotocol.registry/official"];return t.jsx(st,{onClick:()=>n(_),disabled:a,className:"cursor-pointer",children:t.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"font-medium text-sm",children:["v",S.server?.version||"unknown"]}),M?.isLatest&&t.jsx("div",{className:"text-xs text-muted-foreground/50 font-semibold",children:"LATEST"})]}),_===o&&t.jsx(Je,{size:16,className:"text-muted-foreground shrink-0"})]})},_)},e[19]=a,e[20]=n,e[21]=o,e[22]=T):T=e[22],j=s.map(T),e[14]=a,e[15]=n,e[16]=o,e[17]=s,e[18]=j}else j=e[18];let g;e[23]!==j?(g=t.jsx(rt,{align:"end",className:"w-56 max-h-[300px] overflow-y-auto",children:j}),e[23]=j,e[24]=g):g=e[24];let L;return e[25]!==y||e[26]!==g?(L=t.jsxs(ot,{children:[y,g]}),e[25]=y,e[26]=g,e[27]=L):L=e[27],L}function Vt(r){const e=G.c(46),{data:s,itemVersions:o,onInstall:n,canInstall:l,isInstalling:c,hideInstallControls:m,selectedVersionIndex:a,onVersionChange:d}=r,w=l===void 0?!0:l,p=c===void 0?!1:c,I=m===void 0?!1:m,[f,v]=Y.useState(0),u=a??f;let N;e[0]!==d?(N=U=>{v(U),d?.(U)},e[0]=d,e[1]=N):N=e[1];const h=N,y=o[u]||o[0];let j;e[2]!==y?.server?.remotes?(j=y?.server?.remotes??[],e[2]=y?.server?.remotes,e[3]=j):j=e[3];const g=j;let L;e[4]!==y?.server?.packages?(L=y?.server?.packages??[],e[4]=y?.server?.packages,e[5]=L):L=e[5];const S=L.length>0,_=g.length>0,M=g.findIndex(Bt),x=M>=0?M:0;let X;e[6]!==x||e[7]!==S||e[8]!==_||e[9]!==n||e[10]!==u?(X=()=>{_?n(u,x,void 0):S&&n(u,void 0,0)},e[6]=x,e[7]=S,e[8]=_,e[9]=n,e[10]=u,e[11]=X):X=e[11];const b=X;let R;e[12]!==o||e[13]!==n||e[14]!==h?(R=U=>{h(U);const O=o[U],W=O?.server?.remotes??[],q=O?.server?.packages??[];if(W.length>0){const oe=W.findIndex(At);n(U,oe>=0?oe:0,void 0)}else q.length>0&&n(U,void 0,0)},e[12]=o,e[13]=n,e[14]=h,e[15]=R):R=e[15];const A=R;let B;e[16]!==s.icon||e[17]!==s.name?(B=t.jsx(Te,{icon:s.icon,name:s.name,size:"lg",className:"shrink-0 shadow-sm"}),e[16]=s.icon,e[17]=s.name,e[18]=B):B=e[18];let K;e[19]!==s.name?(K=t.jsx("h1",{className:"text-3xl font-medium",children:s.name}),e[19]=s.name,e[20]=K):K=e[20];let F;e[21]!==s.verified?(F=s.verified&&t.jsx("img",{src:"/verified-badge.svg",alt:"Verified",className:"w-5 h-5 shrink-0"}),e[21]=s.verified,e[22]=F):F=e[22];let k;e[23]!==K||e[24]!==F?(k=t.jsxs("div",{className:"flex items-center gap-2",children:[K,F]}),e[23]=K,e[24]=F,e[25]=k):k=e[25];let C;e[26]!==s.shortDescription?(C=s.shortDescription&&t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.shortDescription}),e[26]=s.shortDescription,e[27]=C):C=e[27];let V;e[28]!==k||e[29]!==C?(V=t.jsxs("div",{className:"flex-1 min-w-0",children:[k,C]}),e[28]=k,e[29]=C,e[30]=V):V=e[30];let D;e[31]!==w||e[32]!==b||e[33]!==A||e[34]!==I||e[35]!==p||e[36]!==o||e[37]!==u||e[38]!==h?(D=w&&!I?t.jsx("div",{className:"shrink-0 flex items-center gap-2",children:o.length>1?t.jsxs("div",{className:"flex",children:[t.jsxs(se,{variant:"default",size:"sm",onClick:b,disabled:p,className:"shrink-0 rounded-r-none cursor-pointer",children:[t.jsx(ve,{size:20}),p?"Connecting...":"Connect"]}),t.jsx(Ce,{versions:o,selectedIndex:u,onSelect:A,isInstalling:p,variant:"outline"})]}):t.jsxs(se,{variant:"default",size:"sm",onClick:b,disabled:o.length===0||p,className:"shrink-0 cursor-pointer",children:[t.jsx(ve,{size:20}),p?"Connecting...":"Connect"]})}):I?o.length>1?t.jsx("div",{className:"shrink-0",children:t.jsx(Ce,{versions:o,selectedIndex:u,onSelect:h,isInstalling:p,variant:"outline",showLabel:!0})}):null:t.jsx("div",{className:"shrink-0 px-4 py-2 text-sm text-muted-foreground bg-muted rounded-lg",children:"Cannot be connected"}),e[31]=w,e[32]=b,e[33]=A,e[34]=I,e[35]=p,e[36]=o,e[37]=u,e[38]=h,e[39]=D):D=e[39];let E;e[40]!==V||e[41]!==D?(E=t.jsxs("div",{className:"flex-1 min-w-0 flex items-center justify-between",children:[V,D]}),e[40]=V,e[41]=D,e[42]=E):E=e[42];let z;return e[43]!==E||e[44]!==B?(z=t.jsxs("div",{className:"flex items-center gap-4 py-8 px-5 border-b border-border",children:[B,E]}),e[43]=E,e[44]=B,e[45]=z):z=e[45],z}function At(r){return r.type?.toLowerCase()==="http"||r.type?.toLowerCase()==="streamable-http"}function Bt(r){return r.type?.toLowerCase()==="http"||r.type?.toLowerCase()==="streamable-http"}function zt(r){if(!r)return"—";try{const e=new Date(r);return isNaN(e.getTime())?"—":e.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return"—"}}function Ft(r){const e=G.c(47),{data:s,publisherInfo:o,selectedItem:n}=r;let l;e[0]!==s.description?(l=s.description&&t.jsxs("div",{className:"px-5 pb-5 border-b border-border",children:[t.jsx("h2",{className:"text-base font-medium mb-3",children:"Overview"}),t.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:s.description})]}),e[0]=s.description,e[1]=l):l=e[1];const c=s.publisher==="io.modelcontextprotocol.registry/official"?"Official Registry":s.publisher;let m;e[2]!==o.logo||e[3]!==c?(m=t.jsx(Te,{icon:o.logo,name:c,size:"sm",className:"shrink-0 shadow-sm"}),e[2]=o.logo,e[3]=c,e[4]=m):m=e[4];let a;e[5]!==s.publisher?(a=s.publisher==="io.modelcontextprotocol.registry/official"?"Official Registry":s.publisher.charAt(0).toUpperCase()+s.publisher.slice(1),e[5]=s.publisher,e[6]=a):a=e[6];let d;e[7]!==a?(d=t.jsx("div",{className:"font-medium",children:a}),e[7]=a,e[8]=d):d=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("div",{className:"text-xs text-muted-foreground",children:"Publisher"}),e[9]=w):w=e[9];let p;e[10]!==d?(p=t.jsxs("div",{children:[d,w]}),e[10]=d,e[11]=p):p=e[11];let I;e[12]!==m||e[13]!==p?(I=t.jsx("div",{className:"px-5 border-b border-border",children:t.jsxs("div",{className:"flex items-center gap-3 py-5",children:[m,p]})}),e[12]=m,e[13]=p,e[14]=I):I=e[14];let f;e[15]!==s.version?(f=s.version&&t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Version"}),t.jsxs("span",{className:"text-muted-foreground uppercase text-xs",children:["v",s.version]})]}),e[15]=s.version,e[16]=f):f=e[16];let v;e[17]!==s.tags?(v=s.tags&&s.tags.length>0&&t.jsxs("div",{className:"flex justify-between items-start text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Tags"}),t.jsx("div",{className:"flex flex-wrap gap-1 justify-end max-w-[60%]",children:s.tags.map(Ht)})]}),e[17]=s.tags,e[18]=v):v=e[18];let u;e[19]!==s.categories?(u=s.categories&&s.categories.length>0&&t.jsxs("div",{className:"flex justify-between items-start text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Categories"}),t.jsx("div",{className:"flex flex-wrap gap-1 justify-end max-w-[60%]",children:s.categories.map(Ot)})]}),e[19]=s.categories,e[20]=u):u=e[20];let N;e[21]!==s.connectionType?(N=s.connectionType&&t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Connection Type"}),t.jsx("span",{className:"text-muted-foreground uppercase text-xs",children:s.connectionType})]}),e[21]=s.connectionType,e[22]=N):N=e[22];let h;e[23]!==s.schemaVersion?(h=s.schemaVersion&&t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Schema Version"}),t.jsx("span",{className:"text-muted-foreground text-xs",children:s.schemaVersion})]}),e[23]=s.schemaVersion,e[24]=h):h=e[24];let y;e[25]!==s.websiteUrl?(y=s.websiteUrl&&t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Website"}),t.jsxs("a",{href:s.websiteUrl,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:underline flex items-center gap-1 text-xs",children:[t.jsx("span",{children:"Visit"}),t.jsx(be,{size:14})]})]}),e[25]=s.websiteUrl,e[26]=y):y=e[26];let j;e[27]!==s.repository?(j=s.repository?.url&&t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-foreground text-sm",children:"Source"}),t.jsxs("a",{href:s.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:underline flex items-center gap-1 text-xs",children:[t.jsx("span",{children:"GitHub"}),t.jsx(be,{size:14})]})]}),e[27]=s.repository,e[28]=j):j=e[28];let g;e[29]!==v||e[30]!==u||e[31]!==N||e[32]!==h||e[33]!==y||e[34]!==j||e[35]!==f?(g=t.jsxs("div",{className:"px-5 py-5 border-b border-border space-y-4",children:[f,v,u,N,h,y,j]}),e[29]=v,e[30]=u,e[31]=N,e[32]=h,e[33]=y,e[34]=j,e[35]=f,e[36]=g):g=e[36];let L;e[37]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx("span",{className:"text-foreground text-sm",children:"Last Updated"}),e[37]=L):L=e[37];let T;e[38]!==n.updated_at?(T=zt(n.updated_at),e[38]=n.updated_at,e[39]=T):T=e[39];let S;e[40]!==T?(S=t.jsxs("div",{className:"px-5 py-5 text-sm flex justify-between items-center border-b border-border",children:[L,t.jsx("span",{className:"text-muted-foreground uppercase text-xs",children:T})]}),e[40]=T,e[41]=S):S=e[41];let _;return e[42]!==l||e[43]!==g||e[44]!==S||e[45]!==I?(_=t.jsxs("div",{className:"lg:col-span-1 flex flex-col pt-5",children:[l,I,g,S]}),e[42]=l,e[43]=g,e[44]=S,e[45]=I,e[46]=_):_=e[46],_}function Ot(r){return t.jsx("span",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:r},r)}function Ht(r){return t.jsx("span",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:r},r)}const Gt=[{value:"http",label:"HTTP"},{value:"sse",label:"SSE"},{value:"stdio",label:"STDIO"},{value:"all",label:"All"}],qt={docs:"Documentation",bindings:"Workers Bindings",builds:"Workers Builds",observability:"Observability",radar:"Radar",containers:"Containers",browser:"Browser Rendering",logs:"Logpush",autorag:"AutoRAG",auditlogs:"Audit Logs",graphql:"GraphQL",dex:"DEX Monitoring",casb:"CASB"};function Kt(r){if(!r)return"Local";try{return new URL(r).hostname}catch{return r}}function Wt(r){if(!r)return"local";try{const e=new URL(r).hostname;return e.split(".")[0]||e}catch{return"unknown"}}function Qt(r){const e=qt[r.toLowerCase()];return e||r.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Yt(r){if(!r)return"http";const e=r.toLowerCase();return e==="sse"?"sse":e==="stdio"?"stdio":"http"}function Xt(r){return r.map((e,s)=>{const o=Yt(e.type),n=Kt(e.url),l=Wt(e.url),c=e.title||e.name||Qt(l);return{index:s,protocol:o,url:e.url,hostname:n,serviceName:l,displayName:c,name:e.name,title:e.title,description:e.description,_type:e._type,_index:e._index}})}function Zt(r){const e=G.c(2),{protocol:s,className:o}=r;let n;return e[0]!==o?(n={http:t.jsx(at,{className:o}),sse:t.jsx(dt,{className:o}),stdio:t.jsx(ut,{className:o})},e[0]=o,e[1]=n):n=e[1],n[s]}function Jt(r){const e=G.c(10),{options:s,selected:o,onSelect:n}=r;if(s.length<=1)return null;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("span",{className:"text-sm text-muted-foreground",children:"Protocol:"}),e[0]=l):l=e[0];let c;if(e[1]!==n||e[2]!==s||e[3]!==o){let a;e[5]!==n||e[6]!==o?(a=d=>t.jsxs(se,{variant:o===d.value?"default":"outline",size:"sm",onClick:()=>n(d.value),className:"cursor-pointer",children:[t.jsx(Zt,{protocol:d.value==="all"?"http":d.value,className:"w-4 h-4 mr-1"}),d.label]},d.value),e[5]=n,e[6]=o,e[7]=a):a=e[7],c=s.map(a),e[1]=n,e[2]=s,e[3]=o,e[4]=c}else c=e[4];let m;return e[8]!==c?(m=t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l,t.jsx("div",{className:"flex gap-1",children:c})]}),e[8]=c,e[9]=m):m=e[9],m}function es(r){const e=G.c(11),{servers:s,onInstall:o,isInstalling:n,icon:l,mcpName:c,showStdio:m}=r,a=n===void 0?!1:n,d=m===void 0?!1:m,w=d?s:s.filter(os),p=Xt(w),I=p.length<13?"all":"http",[f,v]=Y.useState(I);let u;e:{if(f==="all"){u="all";break e}let x;if(e[0]!==f?(x=b=>b.protocol===f,e[0]=f,e[1]=x):x=e[1],p.some(x)){u=f;break e}if(p.length<13){u="all";break e}u=p[0]?.protocol??"http"}const N=u,h=N==="all"?p:p.filter(x=>x.protocol===N),y=new Set(p.map(rs));let j=Gt.filter(x=>x.value==="all"||y.has(x.value));d||(j=j.filter(ss));const g=y.size<=1?j.filter(ts):j,L="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4";let T;e[2]!==l||e[3]!==a||e[4]!==c||e[5]!==o?(T=x=>t.jsx(ct,{variant:"server",icon:l??null,displayName:x.displayName,description:x.description??null,hostname:x.hostname,protocol:x.protocol,isInstalling:a,onClick:()=>o({type:x.protocol,url:x.url,name:x.name,title:x.title,description:x.description,_type:x._type,_index:x._index})},`${x.hostname}-${x.protocol}-${x.index}`),e[2]=l,e[3]=a,e[4]=c,e[5]=o,e[6]=T):T=e[6];const S=h.map(T);let _;e[7]!==S?(_=t.jsx("div",{className:L,children:S}),e[7]=S,e[8]=_):_=e[8];let M;return e[9]!==h.length?(M=h.length===0&&t.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No servers match the selected filter."}),e[9]=h.length,e[10]=M):M=e[10],t.jsxs("div",{className:"p-5",children:[t.jsx(Jt,{options:g,selected:N,onSelect:v}),_,M]})}function ts(r){return r.value!=="all"}function ss(r){return r.value!=="stdio"}function rs(r){return r.protocol}function os(r){return r.type?.toLowerCase()!=="stdio"}async function Se(r){return(await fe(async()=>{const{default:s}=await import("./purify.es-C0_7NiBM.js");return{default:s}},[])).default.sanitize(r,{USE_PROFILES:{html:!0},FORBID_TAGS:["style","form"],FORBID_ATTR:["style"]})}function ns(r){const e=G.c(53),{data:s,availableTabs:o,effectiveActiveTabId:n,effectiveTools:l,isLoadingTools:c,onTabChange:m,servers:a,onInstallServer:d,isInstalling:w,mcpIcon:p,mcpName:I,showStdio:f}=r,v=c===void 0?!1:c;let u;e[0]!==a?(u=a===void 0?[]:a,e[0]=a,e[1]=u):u=e[1];const N=u,h=w===void 0?!1:w,y=f===void 0?!1:f;let j;e[2]!==s.readmeMarkdown?(j=s.readmeMarkdown?.trim(),e[2]=s.readmeMarkdown,e[3]=j):j=e[3];const g=!!j;let L;e[4]!==s.readmeUrl?(L=s.readmeUrl?.trim(),e[4]=s.readmeUrl,e[5]=L):L=e[5];const T=!!L;let S;e[6]!==s.readmeMarkdown?(S=ue.storeReadmeUrl(`embedded:${s.readmeMarkdown}`),e[6]=s.readmeMarkdown,e[7]=S):S=e[7];let _;e[8]!==s.readmeMarkdown?(_=async()=>{const q=je.parse(s.readmeMarkdown??"",{async:!1});return Se(q)},e[8]=s.readmeMarkdown,e[9]=_):_=e[9];let M;e[10]!==g||e[11]!==S||e[12]!==_?(M={queryKey:S,queryFn:_,enabled:g,staleTime:1/0},e[10]=g,e[11]=S,e[12]=_,e[13]=M):M=e[13];const{data:x,isLoading:X}=pe(M);let b;e[14]!==s.readmeUrl?(b=ue.storeReadmeUrl(s.readmeUrl),e[14]=s.readmeUrl,e[15]=b):b=e[15];let R;e[16]!==s.readmeUrl?(R=async()=>{if(!s.readmeUrl)return null;const q=await fetch(s.readmeUrl);if(!q.ok)throw new Error(`Failed to fetch README (${q.status})`);const re=await q.text();return Se(je.parse(re,{async:!1}))},e[16]=s.readmeUrl,e[17]=R):R=e[17];const A=T&&!g;let B;e[18]!==b||e[19]!==R||e[20]!==A?(B={queryKey:b,queryFn:R,enabled:A,staleTime:36e5,gcTime:864e5},e[18]=b,e[19]=R,e[20]=A,e[21]=B):B=e[21];const{data:K,isLoading:F}=pe(B),k=x??K??null,C=g&&X||!g&&F;let V;e[22]!==l?(V=l.map(is),e[22]=l,e[23]=V):V=e[23];const D=V;let E;e[24]!==o||e[25]!==n||e[26]!==m?(E=o.length>0&&t.jsx("div",{className:"px-4 py-2 border-b border-border bg-background",children:t.jsx(lt,{tabs:o,activeTab:n,onTabChange:m})}),e[24]=o,e[25]=n,e[26]=m,e[27]=E):E=e[27];let z;e[28]!==n||e[29]!==h||e[30]!==p||e[31]!==I||e[32]!==d||e[33]!==N||e[34]!==y?(z=n==="servers"&&N.length>0&&t.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:t.jsx(es,{servers:N,onInstall:q=>d?.(q),isInstalling:h,icon:p,mcpName:I,showStdio:y})}),e[28]=n,e[29]=h,e[30]=p,e[31]=I,e[32]=d,e[33]=N,e[34]=y,e[35]=z):z=e[35];let U;e[36]!==n||e[37]!==l.length||e[38]!==v||e[39]!==D?(U=n==="tools"&&t.jsx("div",{className:"flex flex-col flex-1",children:v?t.jsxs("div",{className:"flex items-center justify-center p-8",children:[t.jsx(ke,{size:24,className:"animate-spin"}),t.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Loading tools..."})]}):l.length>0?t.jsx(it,{tools:D,showToolbar:!1,emptyMessage:"This MCP Server doesn't have any tools."}):t.jsx(nt,{image:null,title:"No tools available",description:"This MCP Server doesn't have any tools."})}),e[36]=n,e[37]=l.length,e[38]=v,e[39]=D,e[40]=U):U=e[40];let O;e[41]!==k||e[42]!==C||e[43]!==s.repository||e[44]!==n||e[45]!==g||e[46]!==T?(O=n==="readme"&&t.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:g||T?t.jsx(ye,{html:k,isLoading:C}):t.jsx(ye,{repository:s?.repository})}),e[41]=k,e[42]=C,e[43]=s.repository,e[44]=n,e[45]=g,e[46]=T,e[47]=O):O=e[47];let W;return e[48]!==E||e[49]!==z||e[50]!==U||e[51]!==O?(W=t.jsxs("div",{className:"lg:col-span-2 flex flex-col border-l border-border",children:[E,z,U,O]}),e[48]=E,e[49]=z,e[50]=U,e[51]=O,e[52]=W):W=e[52],W}function is(r){const e=r;return{name:e.name||"",description:e.description||void 0}}function ls(r,e){if(!r||!e)return;const s=e.toLowerCase();return r.find(o=>o.app_name?.toLowerCase()===s||o.app_id?.toLowerCase()===s||o.title.toLowerCase()===s)||r.find(o=>o.title.toLowerCase().includes(s))}function as(r,e,s,o,n){if(!e||e==="Unknown")return{count:0};if(e==="io.modelcontextprotocol.registry/official")return{logo:o?.icon||void 0,count:n??r.length};const l=e.toLowerCase(),c=r.filter(a=>(a._meta?.["io.modelcontextprotocol.registry/official"]?"io.modelcontextprotocol.registry/official":a.publisher||a._meta?.["mcp.mesh"]?.scopeName||"Unknown").toLowerCase()===l);return{logo:s?.icon||c[0]?.publisher_logo||c[0]?.icon||void 0,count:c.length}}function cs(r){const e=r._meta?.["mcp.mesh"],s=r._meta?.["io.modelcontextprotocol.registry/official"],o=r.server??{},n=Pt(o?.remotes?.[0]?.type),l=Mt(o?.$schema),c=r.id?.includes("/")?r.id.split("/")[0]:void 0,m=s?"io.modelcontextprotocol.registry/official":r.publisher||e?.scopeName||c||"Unknown",a=Tt(o.repository),d=r.icon||r.image||r.logo||o.icons?.[0]?.src||a||null,w=r.name||r.title||r.server?.title||"Unnamed Item",p=mt(w),I=e?.friendly_name||p,f=e?.mesh_description||r.description||r.summary||o?.description||"",v=e?.short_description||null,u=typeof e?.readme=="string"?e.readme:null,N=typeof e?.readme_url=="string"?e.readme_url:null,h=e?.tags||[],y=e?.categories||[];return{name:I,description:f,shortDescription:v,readmeMarkdown:u,readmeUrl:N,icon:d,verified:r.verified||e?.verified,publisher:m,version:o.version||null,websiteUrl:o.websiteUrl||null,repository:o.repository||null,schemaVersion:l??null,connectionType:n,connectionUrl:o?.remotes?.[0]?.url||null,remoteUrl:o?.remotes?.[0]?.url||null,tags:h,categories:y,tools:r.tools||o.tools||e?.tools||[],models:r.models||o.models||e?.models||[],emails:r.emails||o.emails||e?.emails||[],analytics:r.analytics||o.analytics||e?.analytics,cdn:r.cdn||o.cdn||e?.cdn}}class ds extends Y.Component{state={hasError:!1,error:null};static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,s){console.error("Store MCP server detail error:",e,s)}render(){return this.state.hasError?t.jsx(Et,{error:this.state.error||new Error("Unknown error"),onBack:this.props.onBack}):this.props.children}}function ms(){const{org:r}=_e(),e=Ie(),{appName:s}=Fe({strict:!1}),{registryId:o,serverName:n,stdio:l}=Oe({strict:!1}),[c,m]=Ct(St.storeShowStdio(),()=>!1),a=l==="true"?!0:l==="false"?!1:c;l!==void 0&&l==="true"!==c&&m(l==="true");const[d,w]=Y.useState(null),[p,I]=Y.useState(null),[f,v]=Y.useState(null),u=bt(),N=yt(),{data:h}=He.useSession(),y=vt(N),j=o||y[0]?.id||"",g=jt(j),L=Lt(g?.tools),T=we(g?.tools??null,"_VERSIONS"),S=we(g?.tools??null,"_GET"),_=!!n;let M="",x={};_?(M=T||S,x={name:n}):(M=L,x={});const X=Nt({connectionId:j||null,orgId:r.id}),{data:b}=wt({client:X,toolName:M,toolArguments:x,select:i=>i.structuredContent??i});let R=[],A=[],B=null;if(b){if(Array.isArray(b))R=b;else if(typeof b=="object"&&b!==null)if("totalCount"in b&&typeof b.totalCount=="number"&&(B=b.totalCount),"item"in b&&b.item){const i=b.item;R=[{id:i.id||"",title:i.title,server:i.server,_meta:i._meta}]}else{let i;"versions"in b&&Array.isArray(b.versions)?i="versions":"servers"in b&&Array.isArray(b.servers)?i="servers":i=Object.keys(b).find(P=>Array.isArray(b[P])),i&&(R=b[i],(i==="versions"||M?.includes("VERSIONS"))&&(A=R))}}const K=(()=>{const i=A.findIndex(P=>P._meta?.["io.modelcontextprotocol.registry/official"]?.isLatest===!0);return i>=0?i:0})(),F=p??K;let k=R.find(i=>{const P=i.name||i.title||i.server?.title||"";return It(P)===s});!k&&n&&(k=R.find(i=>i.id===n||i.server?.name===n||i.name===n||i.title===n));const C=k?cs(k):null,V=(C?.tools?.length||0)>0,D=k?.server?.remotes?.[0]?.url||null,E=!V&&!!D,z=pe({queryKey:ue.remoteMcpTools(D),queryFn:async()=>{if(!D)return[];const{Client:i}=await fe(async()=>{const{Client:Z}=await import("./index-B84Dx7nI.js").then($=>$.cX);return{Client:Z}},__vite__mapDeps([0,1])),{StreamableHTTPClientTransport:P}=await fe(async()=>{const{StreamableHTTPClientTransport:Z}=await import("./index-D9XxJ5Op.js");return{StreamableHTTPClientTransport:Z}},__vite__mapDeps([2,0,1,3,4,5,6,7,8,9,10,11,12])),H=new i({name:"mesh-store",version:"1.0.0"}),Q=new P(new URL(D),{requestInit:{headers:{Accept:"application/json, text/event-stream","Content-Type":"application/json"}}});try{return await H.connect(Q),((await H.listTools()).tools||[]).map($=>({name:$.name,description:$.description}))}finally{await H.close().catch(console.error)}},enabled:E}),U=E&&z.isLoading,O=z.data??[],W=V?C?.tools||[]:O,q=ls(N,C?.publisher),re=C?as(R,C.publisher,q,g??null,B):{count:0},oe=C?.repository?kt(C.repository):null,Pe=k?.server?.remotes??[],Me=k?.server?.packages??[],le=[...Pe.map((i,P)=>({...i,_type:"remote",_index:P})),...Me.map((i,P)=>({type:"stdio",url:void 0,name:i.name||i.identifier,title:i.name||i.identifier?.replace(/^@[^/]+\//,""),description:i.environmentVariables?.length?`Requires ${i.environmentVariables.length} environment variable(s)`:void 0,_type:"package",_index:P}))],xe=a?le:le.filter(i=>i.type?.toLowerCase()!=="stdio"),he=xe.length>1,J=[{id:"servers",label:"Servers",count:xe.length,visible:he},{id:"readme",label:"README",visible:!!C?.readmeMarkdown||!!C?.readmeUrl||!!C?.repository&&!!oe},{id:"tools",label:"Tools",count:W.length,visible:V||O.length>0||!!D}].filter(i=>i.visible),Re=J.find(i=>i.id==="servers")?.id||J.find(i=>i.id==="readme")?.id||J[0]?.id||"overview",De=d&&J.find(i=>i.id===d)?d:Re,ae=async(i,P,H,Q)=>{const Z=A[i??0]||k;if(!Z||!r||!h?.user?.id)return;const $=_t(Z,r.id,h.user.id,{remoteIndex:H===void 0?P??0:void 0,packageIndex:H}),ee=$.connection_type==="STDIO",ne=!!$.connection_url,Be=ee&&$.connection_headers&&typeof $.connection_headers=="object"&&"command"in $.connection_headers;if(!ne&&!Be){me.error("This MCP Server cannot be connected: no connection method available");return}Q&&($.title=Q);try{const{id:te}=await u.create.mutateAsync($);e({to:"/$org/$project/mcps/$connectionId",params:{org:r.slug,project:ie,connectionId:te}})}catch(te){me.error(`Failed to connect MCP Server: ${te instanceof Error?te.message:String(te)}`)}},ce=async(i,P,H)=>{const Q=A[i??0]||k;if(!Q)return;const Z=Q.id??Q.title,$=N.filter(ee=>ee.app_name===Z||ee.title===Q.title);if($.length>0){const ne=`${Q.title||"MCP Server"} (${$.length+1})`;v({step:"warning",existing:$,pendingArgs:[i,P,H],suggestedName:ne,customName:ne});return}ae(i,P,H)},Ee=()=>{e({to:"/$org/$project/store",params:{org:r.slug,project:ie}})};if(!k)return t.jsx(Ut,{onBack:Ee});if(!C)return null;const Ue=(k?.server?.remotes?.length??0)>0,$e=(k?.server?.packages?.length??0)>0,ge=Ue||$e,Ve=t.jsx(ft,{children:t.jsxs(pt,{children:[t.jsx(Ne,{children:t.jsx(xt,{asChild:!0,children:t.jsx(Ge,{to:"/$org/$project/store",params:{org:r.slug,project:ie},children:"Store"})})}),t.jsx(ht,{}),t.jsx(Ne,{children:t.jsx(gt,{children:C.name})})]})}),Ae=(()=>{const i=new URL(`/store/${encodeURIComponent(s||"")}`,window.location.origin);return n&&i.searchParams.set("serverName",n),i.href})();return t.jsxs("div",{className:"flex flex-col h-full border-l border-border",children:[f&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>v(null),children:t.jsx("div",{className:"bg-background border rounded-lg shadow-lg p-6 max-w-md w-full mx-4",onClick:i=>i.stopPropagation(),children:f.step==="warning"?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"MCP Already Installed"}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["You already have"," ",t.jsx("strong",{children:f.existing.length})," instance",f.existing.length!==1?"s":""," of this MCP installed:"]}),t.jsx("ul",{className:"text-sm space-y-1 mb-4 max-h-32 overflow-auto",children:f.existing.map(i=>t.jsxs("li",{className:"flex items-center gap-2 text-muted-foreground",children:[t.jsx("span",{className:"font-medium text-foreground",children:i.title}),t.jsxs("span",{className:"text-xs",children:["(",i.created_at?new Date(i.created_at).toLocaleDateString():"—",")"]})]},i.id))}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm rounded-md border hover:bg-muted/50 transition-colors",onClick:()=>v(null),children:"Cancel"}),t.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",onClick:()=>v({...f,step:"rename"}),children:"Install Anyway"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Choose a name"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Give this instance a different name to distinguish it, or keep the suggested one."}),t.jsx("input",{type:"text",className:"w-full rounded-md border bg-transparent px-3 py-2 text-sm mb-4 focus:outline-none focus:ring-2 focus:ring-primary",value:f.customName,onChange:i=>v({...f,customName:i.target.value}),onKeyDown:i=>{if(i.key==="Enter"){const P=f.customName.trim()||f.suggestedName,H=f.pendingArgs;v(null),ae(...H,P)}},autoFocus:!0}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm rounded-md border hover:bg-muted/50 transition-colors",onClick:()=>v({...f,step:"warning"}),children:"Back"}),t.jsx("button",{type:"button",className:"px-3 py-1.5 text-sm rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",onClick:()=>{const i=f.customName.trim()||f.suggestedName,P=f.pendingArgs;v(null),ae(...P,i)},children:"Install"})]})]})})}),t.jsx($t,{breadcrumb:Ve,shareUrl:Ae}),t.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:t.jsx("div",{className:"h-full",children:t.jsxs("div",{className:"h-full",children:[!ge&&t.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-200 rounded-lg text-sm text-amber-900",children:[t.jsx(Rt,{size:16,className:"inline mr-2"}),"This MCP Server cannot be connected - no connection method available."]}),t.jsx(Vt,{data:C,itemVersions:A.length>0?A:[k],onInstall:ce,canInstall:ge,isInstalling:u.create.isPending,hideInstallControls:he,selectedVersionIndex:F,onVersionChange:I}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 min-h-[677px]",children:[t.jsx(Ft,{data:C,publisherInfo:re,selectedItem:k}),t.jsx(ns,{data:C,availableTabs:J,effectiveActiveTabId:De,effectiveTools:W,isLoadingTools:U,onTabChange:w,servers:le,onInstallServer:i=>{i._type==="remote"?ce(F,i._index,void 0):ce(F,void 0,i._index)},isInstalling:u.create.isPending,mcpIcon:C.icon,mcpName:C.name,showStdio:a})]})]})})})]})}function gr(){const r=G.c(6),{org:e}=_e(),s=Ie();let o;r[0]!==s||r[1]!==e.slug?(o=()=>{s({to:"/$org/$project/store",params:{org:e.slug,project:ie}})},r[0]=s,r[1]=e.slug,r[2]=o):o=r[2];const n=o;let l;r[3]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(Y.Suspense,{fallback:t.jsx(Dt,{}),children:t.jsx(ms,{})}),r[3]=l):l=r[3];let c;return r[4]!==n?(c=t.jsx(ds,{onBack:n,children:l}),r[4]=n,r[5]=c):c=r[5],c}export{gr as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as D,c as oe,z as H,j as s,p as Yt,B as ie,u as je,f as me,K as ue,o as Et,D as Xe,n as Ce,bK as vt,bQ as yt,w as Me,t as kt,q as Wt,x as le,v as Xt,E as es}from"./index-B84Dx7nI.js";import{C as ts}from"./collection-display-button-DEx37m4V.js";import{C as De,E as ct}from"./collection-search-DXvW2iQG.js";import{P as ve}from"./index-CmH5OQnm.js";import{B as ss,a as ns,b as os,c as rs}from"./breadcrumb-BrsAPde7.js";import{C as is}from"./collection-table-wrapper-xKuLiuQ5.js";import{I as zt}from"./integration-icon-DNJkhUIt.js";import{C as ze}from"./checkbox-DhgSL5Cz.js";import{i as ls}from"./ArrowLeft-CR3SWku2.js";import{b as Ut}from"./use-connection-DSPQNIQD.js";import{u as bt}from"./use-members-DajocvHM.js";import{u as it}from"./useQuery-CIRdCYZz.js";import{u as Ee}from"./useMutation-Be5QSQym.js";import{u as as,a as cs}from"./use-llm-CKGJlXuC.js";import{A as Pe}from"./avatar-D94UEcg7.js";import{B as ye}from"./badge-DxYG_XB9.js";import{f as Ue,a as Ve,b as Ge,c as Be,d as $e,e as Fe,A as Ke,h as Qe}from"./alert-dialog-Bbrwo05x.js";import{D as Vt,f as Gt,a as Bt,b as ds,c as ms,e as us}from"./dialog-B-Kp8Cuq.js";import{D as Ct,a as jt,b as Tt,c as nt,h as fs,j as hs,k as gs,e as xs}from"./dropdown-menu-DjhC4m2a.js";import{i as ps}from"./DotsHorizontal-0eyRqScK.js";import{i as He}from"./Loading01-aMp99RZI.js";import{i as bs}from"./Lock01-STjQUMU6.js";import{s as ot}from"./Plus-Dp8Rr75G.js";import{s as $t}from"./Trash01-DJTe1fKw.js";import{i as St}from"./X-DjDetE_c.js";import{I as Cs}from"./input-NIbTU7RU.js";import{S as Ne}from"./switch-BA80KxP2.js";import{c as Se,T as Oe,a as Ie,b as Ae}from"./tooltip-CHJhCJL3.js";import{a as js,F as Ot,b as It,c as Ts,d as At,f as _t}from"./form-DK8WrQI3.js";import{S as ft,a as ht,b as gt,c as xt,d as pt}from"./select-1y3LRFgk.js";import{T as Ns}from"./textarea-BW2ziFqJ.js";import{a as qe,u as Je}from"./constants-_xTq0aTt.js";import{C as wt}from"./card-CkYe6Ikt.js";import{i as Ft}from"./DotsVertical-Cshw63SI.js";import{i as Es}from"./Key01-BP2mhRrj.js";import{i as Kt}from"./Shield01-J7QygUij.js";import{s as Qt}from"./XClose-dSJ6zVxj.js";import{C as dt,e as mt,f as Rt,d as vs,a as ys,b as Ss,c as Os}from"./command-wAVHsF2T.js";import{P as Is,a as As,b as _s}from"./popover-D7xgfP4W.js";import{t as ws}from"./ChevronDown-BR4cCk-W.js";import"./ArrowDown-KTP4HONB.js";import"./ArrowUp-BfaawFDM.js";import"./Check-OSWZCZf9.js";import"./Grid01-DIGu5eh8.js";import"./List-BnvhY7Nh.js";import"./SearchMd-r7i5BQk7.js";import"./localstorage-keys-BckSA5cs.js";import"./ChevronRight-ByOuE_Vi.js";import"./table-vuF1fVQ6.js";import"./Container-BVSlDn4p.js";import"./use-collections-BoFyuDa6.js";import"./use-binding-Bdb-0lwc.js";import"./binder-wDmRPNL2.js";import"./index-C8u6axf-.js";import"./label-B6R7vHKQ.js";import"./index-BGwf3l_M.js";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 qt=[{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:"MONITORING_DASHBOARD_CREATE",description:"Create monitoring dashboards",category:"Monitoring"},{name:"MONITORING_DASHBOARD_GET",description:"View dashboard details",category:"Monitoring"},{name:"MONITORING_DASHBOARD_LIST",description:"List monitoring dashboards",category:"Monitoring"},{name:"MONITORING_DASHBOARD_UPDATE",description:"Update monitoring dashboards",category:"Monitoring"},{name:"MONITORING_DASHBOARD_DELETE",description:"Delete monitoring dashboards",category:"Monitoring",dangerous:!0},{name:"MONITORING_DASHBOARD_QUERY",description:"Query dashboard widget data",category:"Monitoring"},{name:"MONITORING_WIDGET_PREVIEW",description:"Preview widget aggregation",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"},{name:"PROJECT_CONNECTION_LIST",description:"List project connections",category:"Projects"},{name:"PROJECT_CONNECTION_ADD",description:"Add connection to project",category:"Projects"},{name:"PROJECT_CONNECTION_REMOVE",description:"Remove connection from project",category:"Projects"},{name:"PROJECT_PINNED_VIEWS_UPDATE",description:"Update project pinned sidebar views",category:"Projects"}],Rs={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",MONITORING_DASHBOARD_CREATE:"Create monitoring dashboards",MONITORING_DASHBOARD_GET:"View dashboard details",MONITORING_DASHBOARD_LIST:"List monitoring dashboards",MONITORING_DASHBOARD_UPDATE:"Update monitoring dashboards",MONITORING_DASHBOARD_DELETE:"Delete monitoring dashboards",MONITORING_DASHBOARD_QUERY:"Query dashboard widget data",MONITORING_WIDGET_PREVIEW:"Preview widget aggregation",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",PROJECT_CONNECTION_LIST:"List project connections",PROJECT_CONNECTION_ADD:"Add project connection",PROJECT_CONNECTION_REMOVE:"Remove project connection",PROJECT_PINNED_VIEWS_UPDATE:"Update pinned views"};function Ls(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],"Virtual Tools":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],"Code Execution":[],Tags:[],Projects:[]};for(const e of qt)t[e.category]?.push(e);return t}function Ps(){return qt.map(t=>({value:t.name,label:Rs[t.name],dangerous:t.dangerous}))}const Ms=D.memo(function(e){const n=oe.c(21),{connection:o,isSelected:l,hasToolsEnabled:r,activeToolsCount:d,totalToolsCount:i,onSelect:f,onToggle:x}=e,m=l?"bg-accent/50":"hover:bg-muted/50";let b;n[0]!==m?(b=H("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]!==o.icon||n[3]!==o.title?(a=s.jsx(zt,{icon:o.icon,name:o.title,size:"xs"}),n[2]=o.icon,n[3]=o.title,n[4]=a):a=n[4];let T;n[5]!==o.title?(T=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:o.title})}),n[5]=o.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 E;n[11]!==d||n[12]!==o.tools||n[13]!==r||n[14]!==x||n[15]!==i?(E=o.tools&&o.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:r,onCheckedChange:x,onClick:zs})]}),n[11]=d,n[12]=o.tools,n[13]=r,n[14]=x,n[15]=i,n[16]=E):E=n[16];let p;return n[17]!==b||n[18]!==h||n[19]!==E?(p=s.jsxs("div",{className:b,children:[h,E]}),n[17]=b,n[18]=h,n[19]=E,n[20]=p):p=n[20],p}),Ds=D.memo(function(e){const n=oe.c(18),{connectionId:o,tool:l,isSelected:r,onToggle:d}=e,i=`tool-${o}-${l.name}`,f=r?"text-foreground":"text-muted-foreground";let x;n[0]!==f?(x=H("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-${o}-${l.name}`;let h;n[10]!==r||n[11]!==d||n[12]!==T?(h=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(ze,{id:T,checked:r,onCheckedChange:d,onClick:Us})}),n[10]=r,n[11]=d,n[12]=T,n[13]=h):h=n[13];let E;return n[14]!==i||n[15]!==a||n[16]!==h?(E=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]=E):E=n[17],E});function ks({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n}){const[o,l]=D.useState(""),r=D.useDeferredValue(o),[d,i]=D.useState("all"),[f,x]=D.useState(!1),m=D.useRef(new Set(Object.keys(t))),b=Ut({searchTerm:r.trim()||void 0}),a=n?b.filter(g=>g.connection_type!=="VIRTUAL"?!0:Yt(g.connection_url)!==n):b,T=m.current,h=[...T.values()].map(g=>a.find(_=>_.id===g)).filter(g=>g!==void 0),E=a.filter(g=>!T.has(g.id)),p=[...h,...E],v=g=>{const _=t[g];return _!==void 0&&_.length>0},j=p.filter(g=>{if(d==="all")return!0;const _=v(g.id);return d==="selected"?_:d==="unselected"?!_:!0}),[u,y]=D.useState(p[0]?.id??null),N=u?p.find(g=>g.id===u)??null:null,P=N?.tools??[],O=(g,_)=>t[g]?.includes(_)??!1,A=(g,_)=>{const S=t[g]??[],C=S.includes(_),M={...t};if(C){const z=S.filter(G=>G!==_);z.length===0?delete M[g]:M[g]=z}else M[g]=[...S,_];e(M)},R=g=>{const _=p.find(G=>G.id===g);if(!_?.tools)return;const S=t[g]??[],C=_.tools.map(G=>G.name),M=S.length>0&&C.every(G=>S.includes(G)),z={...t};M?delete z[g]:(z[g]=C,y(g)),e(z)},I=g=>{y(g),x(!0)},L=()=>{x(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:H("w-full md:w-80 border-r border-border flex flex-col",f&&"hidden md:flex"),children:[s.jsx(De,{value:o,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:H("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:H("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:H("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:o?"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 _=g.tools?.length??0,S=t[g.id]?.length??0;return s.jsx(Ms,{connection:g,isSelected:u===g.id,hasToolsEnabled:v(g.id),activeToolsCount:S,totalToolsCount:_,onSelect:()=>I(g.id),onToggle:()=>R(g.id)},g.id)})})})]}),s.jsx("div",{className:H("flex-1 flex-col",f?"flex":"hidden md:flex"),children:N?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:L,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(ls,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(zt,{icon:N.icon,name:N.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:N.title}),N.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:N.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:N.id,tool:g,isSelected:O(N.id,g.name),onToggle:()=>A(N.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 Lt=[{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 Gs(t){if(!t)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1,modelCount:0,allowsAllModels:!1};const e=[];let n=!1;const o=[];let l=!1;const r=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)r.add(b);continue}if(o.push(x),m.includes("*"))d=!0;else for(const b of m)r.add(b)}return{staticPermissions:e,allowsAllStaticPermissions:n,connectionIds:o,allowsAllConnections:l,toolNames:Array.from(r),allowsAllTools:d,modelCount:i,allowsAllModels:f}}function Nt(){const{locator:t}=je(),{data:e,isLoading:n,error:o,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}),r=Lt.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||Lt.some(v=>v.value===f))continue;const{staticPermissions:x,allowsAllStaticPermissions:m,connectionIds:b,allowsAllConnections:a,toolNames:T,allowsAllTools:h,modelCount:E,allowsAllModels:p}=Gs(i.permission);r.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:E,allowsAllModels:p})}const d=r.filter(i=>!i.isBuiltin);return{roles:r,customRoles:d,builtinRoles:r.filter(i=>i.isBuiltin),isLoading:n,error:o,refetch:l}}const Bs=Et({role:Et({id:Ce().optional(),slug:Ce().optional(),label:Ce()}),allowAllStaticPermissions:yt(),staticPermissions:Xe(Ce()),toolSet:vt(Ce(),Xe(Ce())),allowAllModels:yt(),modelSet:vt(Ce(),Xe(Ce())),memberIds:Xe(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 o=0;o<t.length;o++){const l=t.charCodeAt(o);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=oe.c(39),{allowAllStaticPermissions:n,staticPermissions:o,onAllowAllChange:l,onPermissionsChange:r,readOnly:d}=t,i=d===void 0?!1:d,[f,x]=D.useState(""),m=D.useDeferredValue(f);let b,a,T,h,E;if(e[0]!==n||e[1]!==m||e[2]!==l||e[3]!==r||e[4]!==i||e[5]!==f||e[6]!==o){const j=Ls(),u=Ps(),y=u.filter(L=>L.label.toLowerCase().includes(m.toLowerCase())),N=L=>{if(o.includes(L))r(o.filter(g=>g!==L));else{const g=[...o,L];g.length===u.length?(l(!0),r([])):r(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 O;e[14]!==P?(O=H("flex items-center justify-between px-4 py-3 rounded-lg",P),e[14]=P,e[15]=O):O=e[15];let A;e[16]!==n||e[17]!==l||e[18]!==r||e[19]!==i?(A=()=>{if(i)return;l(!n),r([])},e[16]=n,e[17]=l,e[18]=r,e[19]=i,e[20]=A):A=e[20];let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[21]=R):R=e[21];let I;e[22]!==n||e[23]!==l||e[24]!==r||e[25]!==i?(I=s.jsx("div",{onClick:Zs,children:i?s.jsx(Se,{children:s.jsxs(Oe,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(Ne,{checked:n,disabled:i,onCheckedChange:L=>{i||(l(L),r([]))}})})}),s.jsx(Ae,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Ne,{checked:n,disabled:i,onCheckedChange:L=>{i||(l(L),r([]))}})}),e[22]=n,e[23]=l,e[24]=r,e[25]=i,e[26]=I):I=e[26],e[27]!==I||e[28]!==O||e[29]!==A?(E=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:O,onClick:A,children:[R,I]})}),e[27]=I,e[28]=O,e[29]=A,e[30]=E):E=e[30],b="flex-1 overflow-auto",a=Object.entries(j).map(L=>{const[g,_]=L,S=y.filter(C=>_.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:H("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(Js);r(M.filter(z=>z!==C.value))}else N(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:qs,children:i?s.jsx(Se,{children:s.jsxs(Oe,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(Ne,{checked:n||o.includes(C.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const M=u.map(Hs);r(M.filter(z=>z!==C.value))}else N(C.value)}})})}),s.jsx(Ae,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Ne,{checked:n||o.includes(C.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const M=u.map(Qs);r(M.filter(z=>z!==C.value))}else N(C.value)}})})]},C.value))})]},g)}),e[0]=n,e[1]=m,e[2]=l,e[3]=r,e[4]=i,e[5]=f,e[6]=o,e[7]=b,e[8]=a,e[9]=T,e[10]=h,e[11]=E}else b=e[7],a=e[8],T=e[9],h=e[10],E=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 v;return e[34]!==T||e[35]!==h||e[36]!==E||e[37]!==p?(v=s.jsxs("div",{className:T,children:[h,E,p]}),e[34]=T,e[35]=h,e[36]=E,e[37]=p,e[38]=v):v=e[38],v}function Qs(t){return t.value}function Hs(t){return t.value}function qs(t){return t.stopPropagation()}function Js(t){return t.value}function Zs(t){return t.stopPropagation()}function Ys(t){const e=oe.c(45),{connection:n,selectedModels:o,allowAllModels:l,onToggleModel:r,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=cs(n.id,m);let a;e[1]!==b||e[2]!==f?(a=f.trim()?b.filter(A=>A.title.toLowerCase().includes(f.toLowerCase())||A.id.toLowerCase().includes(f.toLowerCase())||A.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]!==o?(h=l||i||o.includes("*")&&!l||T.every(A=>o.includes(A.id)||o.includes("*")),e[4]=i,e[5]=l,e[6]=T,e[7]=o,e[8]=h):h=e[8];const E=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 v;e[12]!==n.title?(v=s.jsx("h4",{className:"text-sm font-medium text-muted-foreground/75",children:n.title}),e[12]=n.title,e[13]=v):v=e[13];let j;e[14]!==p||e[15]!==v?(j=s.jsxs("div",{className:"flex items-center gap-2",children:[p,v]}),e[14]=p,e[15]=v,e[16]=j):j=e[16];let u;e[17]!==E||e[18]!==l||e[19]!==n.id||e[20]!==b||e[21]!==d||e[22]!==x?(u=!x&&!l&&s.jsx(Ne,{checked:E,onCheckedChange:()=>d(n.id,b)}),e[17]=E,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 N;if(e[27]!==l||e[28]!==n.id||e[29]!==T||e[30]!==r||e[31]!==x||e[32]!==o){let A;e[34]!==l||e[35]!==n.id||e[36]!==r||e[37]!==x||e[38]!==o?(A=R=>{const I=l||o.includes("*")||o.includes(R.id);return s.jsxs("div",{className:H("flex items-center justify-between gap-3 px-4 py-3",!x&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{x||l||r(n.id,R.id)},children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[R.logo&&s.jsx("img",{src:R.logo,className:"w-4 h-4 shrink-0 rounded-sm",alt:R.title}),s.jsx("span",{className:"text-sm truncate",children:R.title})]}),s.jsx("div",{onClick:Ws,children:x?s.jsx(Se,{children:s.jsxs(Oe,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(Ne,{checked:I,disabled:!0})})}),s.jsx(Ae,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Ne,{checked:I,disabled:x||l,onCheckedChange:()=>{x||l||r(n.id,R.id)}})})]},R.id)},e[34]=l,e[35]=n.id,e[36]=r,e[37]=x,e[38]=o,e[39]=A):A=e[39],N=T.map(A),e[27]=l,e[28]=n.id,e[29]=T,e[30]=r,e[31]=x,e[32]=o,e[33]=N}else N=e[33];let P;e[40]!==N?(P=s.jsx("div",{className:"space-y-1",children:N}),e[40]=N,e[41]=P):P=e[41];let O;return e[42]!==P||e[43]!==y?(O=s.jsxs("div",{className:"mb-6 last:mb-0",children:[y,P]}),e[42]=P,e[43]=y,e[44]=O):O=e[44],O}function Ws(t){return t.stopPropagation()}function Xs(){const t=oe.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(He,{className:"size-4 animate-spin"}),"Loading models..."]}),t[0]=e):e=t[0],e}function en(t){const e=oe.c(39),{allowAllModels:n,modelSet:o,onAllowAllChange:l,onModelSetChange:r,readOnly:d}=t,i=d===void 0?!1:d,[f,x]=D.useState(""),m=D.useDeferredValue(f),b=as();let a;e[0]!==o||e[1]!==r?(a=(I,L)=>{const g=o[I]??[],_={...o};if(g.includes(L)){const S=g.filter(C=>C!==L);S.length===0?delete _[I]:_[I]=S}else _[I]=[...g,L];r(_)},e[0]=o,e[1]=r,e[2]=a):a=e[2];const T=a;let h;e[3]!==o||e[4]!==r?(h=(I,L)=>{const g=o[I]??[],_=L.map(sn),S=g.includes("*")||_.every(M=>g.includes(M)),C={...o};S?delete C[I]:C[I]=_,r(C)},e[3]=o,e[4]=r,e[5]=h):h=e[5];const E=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 v=!i&&"hover:bg-muted/50 cursor-pointer";let j;e[8]!==v?(j=H("flex items-center justify-between px-4 py-3 rounded-lg",v),e[8]=v,e[9]=j):j=e[9];let u;e[10]!==n||e[11]!==l||e[12]!==r||e[13]!==i?(u=()=>{if(i)return;const I=!n;l(I),I&&r({})},e[10]=n,e[11]=l,e[12]=r,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 N;e[16]!==n||e[17]!==l||e[18]!==r||e[19]!==i?(N=s.jsx("div",{onClick:tn,children:i?s.jsx(Se,{children:s.jsxs(Oe,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(Ne,{checked:n,disabled:!0})})}),s.jsx(Ae,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Ne,{checked:n,onCheckedChange:I=>{i||(l(I),I&&r({}))}})}),e[16]=n,e[17]=l,e[18]=r,e[19]=i,e[20]=N):N=e[20];let P;e[21]!==j||e[22]!==u||e[23]!==N?(P=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:j,onClick:u,children:[y,N]})}),e[21]=j,e[22]=u,e[23]=N,e[24]=P):P=e[24];let O;e[25]!==n||e[26]!==m||e[27]!==b||e[28]!==o||e[29]!==i||e[30]!==E||e[31]!==T?(O=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(I=>s.jsx(D.Suspense,{fallback:s.jsx(Xs,{}),children:s.jsx(Ys,{connection:I,selectedModels:o[I.id]??[],allowAllModels:n,onToggleModel:T,onToggleConnectionAll:E,allConnectionModelsSelected:(o[I.id]??[]).includes("*"),searchQuery:m,readOnly:i})},I.id)),e[25]=n,e[26]=m,e[27]=b,e[28]=o,e[29]=i,e[30]=E,e[31]=T,e[32]=O):O=e[32];let A;e[33]!==O?(A=s.jsx("div",{className:"flex-1 overflow-auto",children:O}),e[33]=O,e[34]=A):A=e[34];let R;return e[35]!==P||e[36]!==A||e[37]!==p?(R=s.jsxs("div",{className:"flex flex-col h-full",children:[p,P,A]}),e[35]=P,e[36]=A,e[37]=p,e[38]=R):R=e[38],R}function tn(t){return t.stopPropagation()}function sn(t){return t.id}function nn(t){const e=oe.c(56),{open:n,onOpenChange:o,selectedMemberIds:l,onAddMembers:r}=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,E,p,v,j,u,y,N,P,O;if(e[1]!==a?.data?.members||e[2]!==f||e[3]!==r||e[4]!==o||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 G=M.filter(z),K=on;let W;e[22]!==l?(W=U=>l.includes(U),e[22]=l,e[23]=W):W=e[23];const X=W;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 re=ee;let te;e[26]!==r||e[27]!==o||e[28]!==m?(te=()=>{r(m),b([]),o(!1)},e[26]=r,e[27]=o,e[28]=m,e[29]=te):te=e[29],E=te,h=Ue,P=n,O=o,T=Ve,y="sm:max-w-md p-0 overflow-hidden",e[30]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsxs(Ge,{className:"px-6 pt-6",children:[s.jsx(Be,{children:"Add Members to Role"}),s.jsx($e,{children:"Select members to add to this role."})]}),e[30]=N):N=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",v=G.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:G.map(U=>{const c=K(U),w=X(U.id),V=m.includes(U.id);return s.jsxs("label",{className:H("flex items-center gap-3 p-2 rounded-lg",!c||w?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(ze,{checked:V||w,onCheckedChange:()=>{c&&!w&&re(U.id)},disabled:!c||w}),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(ye,{variant:"secondary",className:"shrink-0",children:"Owner"}),w&&c&&s.jsx(ye,{variant:"outline",className:"shrink-0",children:"Added"})]},U.id)})}),e[1]=a?.data?.members,e[2]=f,e[3]=r,e[4]=o,e[5]=n,e[6]=m,e[7]=d,e[8]=l,e[9]=T,e[10]=h,e[11]=E,e[12]=p,e[13]=v,e[14]=j,e[15]=u,e[16]=y,e[17]=N,e[18]=P,e[19]=O}else T=e[9],h=e[10],E=e[11],p=e[12],v=e[13],j=e[14],u=e[15],y=e[16],N=e[17],P=e[18],O=e[19];let A;e[33]!==p||e[34]!==v?(A=s.jsx("div",{className:p,children:v}),e[33]=p,e[34]=v,e[35]=A):A=e[35];let R;e[36]!==A||e[37]!==j||e[38]!==u?(R=s.jsxs("div",{className:j,children:[u,A]}),e[36]=A,e[37]=j,e[38]=u,e[39]=R):R=e[39];let I;e[40]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(Ke,{children:"Cancel"}),e[40]=I):I=e[40];const L=m.length===0,g=m.length>0&&`(${m.length})`;let _;e[41]!==E||e[42]!==L||e[43]!==g?(_=s.jsxs(Fe,{className:"px-6 pb-6",children:[I,s.jsxs(Qe,{onClick:E,disabled:L,children:["Add ",g]})]}),e[41]=E,e[42]=L,e[43]=g,e[44]=_):_=e[44];let S;e[45]!==T||e[46]!==R||e[47]!==_||e[48]!==y||e[49]!==N?(S=s.jsxs(T,{className:y,children:[N,R,_]}),e[45]=T,e[46]=R,e[47]=_,e[48]=y,e[49]=N,e[50]=S):S=e[50];let C;return e[51]!==h||e[52]!==S||e[53]!==P||e[54]!==O?(C=s.jsx(h,{open:P,onOpenChange:O,children:S}),e[51]=h,e[52]=S,e[53]=P,e[54]=O,e[55]=C):C=e[55],C}function on(t){return t.role!=="owner"}function rn(t){const e=oe.c(40),{memberIds:n,onMemberIdsChange:o,readOnly:l}=t,r=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,E,p;if(e[0]!==b?.data?.members||e[1]!==f||e[2]!==n||e[3]!==o||e[4]!==r||e[5]!==d){const y=b?.data?.members??[];let N;e[11]!==n?(N=S=>n.includes(S.id),e[11]=n,e[12]=N):N=e[12];const P=y.filter(N);let O;e[13]!==f?(O=S=>{const C=f.toLowerCase();return S.user?.name?.toLowerCase().includes(C)||S.user?.email?.toLowerCase().includes(C)},e[13]=f,e[14]=O):O=e[14];const A=P.filter(O);let R;e[15]!==n||e[16]!==o?(R=S=>{o(n.filter(C=>C!==S))},e[15]=n,e[16]=o,e[17]=R):R=e[17];const I=R;let L;e[18]!==n||e[19]!==o?(L=S=>{o([...n,...S])},e[18]=n,e[19]=o,e[20]=L):L=e[20],a=L,E="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 _;e[23]!==r?(_=r?s.jsx("div",{className:"pr-4",children:s.jsx(Se,{children:s.jsxs(Oe,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(ot,{size:16}),"Add Member"]})})}),s.jsx(Ae,{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(ot,{size:16}),"Add Member"]})}),e[23]=r,e[24]=_):_=e[24],e[25]!==g||e[26]!==_?(p=s.jsxs("div",{className:"flex items-center border-b border-border",children:[g,_]}),e[25]=g,e[26]=_,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."})]})}):A.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:A.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})]}),r?s.jsx(Se,{children:s.jsxs(Oe,{children:[s.jsx(Ie,{asChild:!0,children:s.jsx("div",{children:s.jsx(ie,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(St,{size:16})})})}),s.jsx(Ae,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>I(S.id),children:s.jsx(St,{size:16})})]},S.id))}),e[0]=b?.data?.members,e[1]=f,e[2]=n,e[3]=o,e[4]=r,e[5]=d,e[6]=a,e[7]=T,e[8]=h,e[9]=E,e[10]=p}else a=e[6],T=e[7],h=e[8],E=e[9],p=e[10];let v;e[28]!==T||e[29]!==h?(v=s.jsx("div",{className:T,children:h}),e[28]=T,e[29]=h,e[30]=v):v=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]!==E||e[36]!==p||e[37]!==v||e[38]!==j?(u=s.jsxs("div",{className:E,children:[p,v,j]}),e[35]=E,e[36]=p,e[37]=v,e[38]=j,e[39]=u):u=e[39],u}function ln(t){const e=oe.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(He,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let o;return e[1]!==t?(o=s.jsx(D.Suspense,{fallback:n,children:s.jsx(rn,{...t})}),e[1]=t,e[2]=o):o=e[2],o}const an={owner:[],admin:[],user:[]};function tt(t,e){const n=t==="owner"||t==="admin",o=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:o.map(l=>l.id)}}function cn({trigger:t,onSuccess:e}){const[n,o]=D.useState(!1),[l,r]=D.useState("mcp"),{locator:d}=je(),i=Me(),f=Ut()??[],{customRoles:x,refetch:m}=Nt(),{data:b}=it({queryKey:ue.members(d),queryFn:()=>me.organization.listMembers()}),a=kt({resolver:Wt(Bs),defaultValues:et()}),T=a.formState.isValid,h=a.formState.isDirty,[E,p]=D.useState(null),[v,j]=D.useState(null),u=!a.watch("role.id")&&!a.watch("role.slug")&&!v,[y,N]=D.useState(null),[P,O]=D.useState(!1),[A,R]=D.useState(null),I=c=>{const w=c.permission||{},V=w.self||[],fe=V.includes("*"),Z=fe?[]:V.filter(B=>B!=="*"),Y={};for(const[B,se]of Object.entries(w))if(!(B==="self"||B==="models"))if(B==="*")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===B);ne&&(se.includes("*")?Y[B]=ne.tools?.map(ae=>ae.name)??[]:Y[B]=se)}const q=w.models||[],he=q.length===0||q.includes("*:*"),J={};if(!he)for(const B of q){const se=B.indexOf(":");if(se===-1)continue;const ne=B.slice(0,se),ae=B.slice(se+1);J[ne]||(J[ne]=[]),J[ne].push(ae)}const ce=(b?.data?.members??[]).filter(B=>B.role===c.role).map(B=>B.id);return{role:{id:c.id,slug:c.role,label:c.label},allowAllStaticPermissions:fe,staticPermissions:Z,toolSet:Y,allowAllModels:he,modelSet:J,memberIds:ce}},L=c=>{const w=I(c);a.reset(w),p(c.id??null),j(null)},g=()=>{a.reset(et()),p(null),j(null),r("mcp")},_=c=>{h&&T?(R(()=>()=>L(c)),O(!0)):L(c)},S=async()=>{h&&T&&await ee(),g()},C=c=>{if(h&&T)R(()=>()=>{const w=tt(c,b?.data?.members??[]);a.reset(w),j(c),p(null),r("org")}),O(!0);else{const w=tt(c,b?.data?.members??[]);a.reset(w),j(c),p(null),r("org")}},M=c=>{if(!c&&a.formState.isDirty&&T){R(()=>()=>{o(!1),a.reset(et()),j(null)}),O(!0);return}if(o(c),!c)a.reset(et()),j(null),p(null);else{const w=x[0];if(w)L(w);else{const V=tt("user",b?.data?.members??[]);a.reset(V),j("user"),p(null),r("org")}}},z=()=>{O(!1),A&&(A(),R(null))},G=c=>{const w={};c.allowAllStaticPermissions?w.self=["*"]:c.staticPermissions.length>0&&(w.self=c.staticPermissions);for(const[V,fe]of Object.entries(c.toolSet))if(fe.length>0){const Y=f.find(q=>q.id===V)?.tools?.map(q=>q.name)??[];Y.length>0&&Y.every(q=>fe.includes(q))?w[V]=["*"]:w[V]=fe}if(c.allowAllModels)w.models=["*:*"];else{const V=[];for(const[fe,Z]of Object.entries(c.modelSet))if(Z.length>0)for(const Y of Z)V.push(`${fe}:${Y}`);w.models=V}return w},K=Ee({mutationFn:async c=>{const w=G(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(J=>J.role===c.role.slug).map(J=>J.id),q=c.memberIds.filter(J=>!Y.includes(J)),he=Y.filter(J=>!c.memberIds.includes(J));for(const J of q){const Q=await me.organization.updateMemberRole({memberId:J,role:[c.role.slug]});if(Q?.error)throw new Error(Q.error.message)}for(const J of he){const Q=await me.organization.updateMemberRole({memberId:J,role:["user"]});if(Q?.error)throw new Error(Q.error.message)}return c}else if(c.role.id){const Z=await me.organization.updateRole({roleId:c.role.id,data:{permission:w}});if(Z?.error)throw new Error(Z.error.message);const q=(b?.data?.members??[]).filter(Q=>Q.role===c.role.slug).map(Q=>Q.id),he=c.memberIds.filter(Q=>!q.includes(Q)),J=q.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 J){const ce=await me.organization.updateMemberRole({memberId:Q,role:["user"]});if(ce?.error)throw new Error(ce.error.message)}return c}else{const Z=await me.organization.createRole({role:V,permission:w});if(Z?.error)throw new Error(Z.error.message);for(const Y of c.memberIds){const q=await me.organization.updateMemberRole({memberId:Y,role:[V]});if(q?.error)throw new Error(q.error.message)}return{...c,role:{...c.role,id:Z.data?.roleData?.id,slug:V}}}},onSuccess:(c,w)=>{i.invalidateQueries({queryKey:ue.members(d)}),i.invalidateQueries({queryKey:ue.organizationRoles(d)});const V=!w.role.id&&!w.role.slug,fe=w.role.slug&&!w.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")}}),W=Ee({mutationFn:async c=>{const w=await me.organization.deleteRole({roleId:c});if(w?.error)throw new Error(w.error.message);return w?.data},onSuccess:()=>{if(i.invalidateQueries({queryKey:ue.members(d)}),i.invalidateQueries({queryKey:ue.organizationRoles(d)}),le.success("Role deleted successfully!"),m(),y?.id===E){const c=x.filter(w=>w.id!==y?.id);if(c[0])L(c[0]);else{const w=tt("user",b?.data?.members??[]);a.reset(w),j("user"),p(null),r("org")}}},onError:c=>{le.error(c instanceof Error?c.message:"Failed to delete role")}}),X=K.isPending||W.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)},re=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&&N({id:c.id,label:c.label})},U=()=>{y?.id&&W.mutate(y.id),N(null)};return s.jsxs(Vt,{open:n,onOpenChange:M,children:[s.jsx(Gt,{asChild:!0,children:t}),s.jsx(Bt,{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 w=v===c.role;return s.jsxs("div",{className:H("flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden cursor-pointer transition-colors",w?"bg-accent":"hover:bg-muted/50"),onClick:()=>C(c.role),children:[s.jsx("div",{className:H("shrink-0 size-3 rounded-full",c.color)}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:c.label}),s.jsx(bs,{size:14,className:"text-muted-foreground shrink-0"})]},c.role)}),x.map(c=>{const w=E===c.id;return s.jsxs("div",{className:H("group flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden transition-colors cursor-pointer",w?"bg-accent":"hover:bg-muted/50"),onClick:()=>_(c),children:[s.jsx("div",{className:H("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:H("size-5 shrink-0 transition-opacity opacity-0 pointer-events-none","group-hover:opacity-100 group-hover:pointer-events-auto",w&&"opacity-100 pointer-events-auto"),onClick:V=>V.stopPropagation(),children:s.jsx(ps,{size:14})})}),s.jsx(Tt,{align:"end",children:s.jsxs(nt,{className:"text-destructive",onClick:V=>{V.stopPropagation(),te(c)},children:[s.jsx($t,{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(Cs,{...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(ye,{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:X||h,className:"w-full h-10",children:[s.jsx(ot,{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:[!v&&s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>r("mcp"),className:H("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:()=>r("org"),className:H("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:()=>r("models"),className:H("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:()=>r("members"),className:H("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"&&!v&&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:!!v}),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:!!v}),l==="members"&&s.jsx(ln,{memberIds:a.watch("memberIds"),onMemberIdsChange:c=>a.setValue("memberIds",c,{shouldDirty:!0}),readOnly:v==="owner"})]}),(!v||v!=="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:X,className:"h-10",children:"Cancel"}),s.jsx(ie,{onClick:re,disabled:X||!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&&N(null),children:s.jsxs(Ve,{children:[s.jsxs(Ge,{children:[s.jsx(Be,{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:O,children:s.jsxs(Ve,{children:[s.jsxs(Ge,{children:[s.jsx(Be,{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:()=>R(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:o}=je(),l=Me(),{data:r}=me.useSession(),d=r?.user?.email,{roles:i,isLoading:f}=Nt(),x=i.filter(j=>j.role!=="owner"),m=kt({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}),E=Ee({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 O=await me.organization.inviteMember({email:P,role:u});if(O.error)throw new Error(O.error.message);return O.data})),N=y.filter(P=>P.status==="rejected");if(N.length>0)throw new Error(`Failed to invite ${N.length} member${N.length>1?"s":""}`);return y},onSuccess:(j,{emails:u})=>{l.invalidateQueries({queryKey:ue.members(o)}),l.invalidateQueries({queryKey:ue.invitations(o)}),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}E.mutate({emails:h,role:j.role})},v=h.length>0&&!!a;return s.jsxs(Vt,{open:e,onOpenChange:n,children:[s.jsx(Gt,{asChild:!0,children:t}),s.jsxs(Bt,{className:"sm:max-w-lg",children:[s.jsx(ds,{children:s.jsx(ms,{children:"Invite members"})}),s.jsx(js,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(p),className:"space-y-4",children:[s.jsx(Ot,{control:m.control,name:"emailsText",render:({field:j})=>s.jsxs(It,{children:[s.jsx(Ts,{children:"Email addresses"}),s.jsx(At,{children:s.jsx(Ns,{...j,disabled:E.isPending,placeholder:`Enter email addresses separated by commas or new lines
|
|
2
|
+
e.g. user1@example.com, user2@example.com
|
|
3
|
+
or one per line`,className:"min-h-[120px] resize-none"})}),s.jsx(_t,{})]})}),s.jsx(Ot,{control:m.control,name:"role",render:({field:j})=>s.jsxs(It,{children:[s.jsx(At,{children:s.jsxs(ft,{value:j.value,onValueChange:j.onChange,disabled:E.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(_t,{})]})}),s.jsxs(us,{children:[s.jsx(ie,{variant:"outline",onClick:()=>{m.reset({emailsText:"",role:"user"}),n(!1)},type:"button",disabled:E.isPending,children:"Cancel"}),s.jsx(ie,{type:"submit",disabled:E.isPending||!v,children:E.isPending?"Inviting...":`Invite ${h.length||0} Member${h.length!==1?"s":""}`})]})]})})]})]})}function fn(){const t=oe.c(9),{org:e,locator:n}=je();let o;t[0]!==e.id?(o={connectionId:qe,orgId:e.id},t[0]=e.id,t[1]=o):o=t[1];const l=Je(o);let r;t[2]!==n?(r=ue.invitations(n),t[2]=n,t[3]=r):r=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]!==r||t[7]!==d?(i={queryKey:r,queryFn:d},t[6]=r,t[7]=d,t[8]=i):i=t[8],Xt(i)}function hn(){const t=oe.c(5),{locator:e}=je(),n=Me();let o;t[0]!==e||t[1]!==n?(o={mutationFn:xn,onSuccess:()=>{n.invalidateQueries({queryKey:ue.invitations(e)}),le.success("Invitation cancelled")},onError:gn},t[0]=e,t[1]=n,t[2]=o):o=t[2];const l=Ee(o);let r;return t[3]!==l?(r={cancel:l},t[3]=l,t[4]=r):r=t[4],r}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=oe.c(9),{org:e,locator:n}=je();let o;t[0]!==e.id?(o={connectionId:qe,orgId:e.id},t[0]=e.id,t[1]=o):o=t[1];const l=Je(o);let r;t[2]!==n?(r=ue.tags(n),t[2]=n,t[3]=r):r=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]!==r||t[7]!==d?(i={queryKey:r,queryFn:d,staleTime:3e4},t[6]=r,t[7]=d,t[8]=i):i=t[8],it(i)}function bn(){const t=oe.c(10),e=Me(),{org:n,locator:o}=je();let l;t[0]!==n.id?(l={connectionId:qe,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const r=Je(l);let d;t[2]!==r?(d=async x=>{const m=await r.callTool({name:"TAGS_CREATE",arguments:{name:x}});return(m.structuredContent??m).tag},t[2]=r,t[3]=d):d=t[3];let i;t[4]!==o||t[5]!==e?(i=()=>{e.invalidateQueries({queryKey:ue.tags(o)})},t[4]=o,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],Ee(f)}function Cn(t){le.error(t instanceof Error?t.message:"Failed to create tag")}function jn(t){const e=oe.c(12),{org:n,locator:o}=je();let l;e[0]!==n.id?(l={connectionId:qe,orgId:n.id},e[0]=n.id,e[1]=l):l=e[1];const r=Je(l);let d;e[2]!==o||e[3]!==t?(d=ue.memberTags(o,t),e[2]=o,e[3]=t,e[4]=d):d=e[4];let i;e[5]!==r||e[6]!==t?(i=async()=>{const m=await r.callTool({name:"MEMBER_TAGS_GET",arguments:{memberId:t}});return(m.structuredContent??m).tags},e[5]=r,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=oe.c(10),e=Me(),{org:n,locator:o}=je();let l;t[0]!==n.id?(l={connectionId:qe,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const r=Je(l);let d;t[2]!==r?(d=async x=>{const{memberId:m,tagIds:b}=x,a=await r.callTool({name:"MEMBER_TAGS_SET",arguments:{memberId:m,tagIds:b}});return a.structuredContent??a},t[2]=r,t[3]=d):d=t[3];let i;t[4]!==o||t[5]!==e?(i=(x,m)=>{e.invalidateQueries({queryKey:ue.memberTags(o,m.memberId)})},t[4]=o,t[5]=e,t[6]=i):i=t[6];let f;return t[7]!==d||t[8]!==i?(f={mutationFn:d,onSuccess:i,onError:Nn},t[7]=d,t[8]=i,t[9]=f):f=t[9],Ee(f)}function Nn(t){le.error(t instanceof Error?t.message:"Failed to update member tags")}function Zt(t){const e=oe.c(44),{memberId:n,className:o,disabled:l,placeholder:r,maxDisplay:d}=t,i=l===void 0?!1:l,f=r===void 0?"Add tags...":r,x=d===void 0?2:d,[m,b]=D.useState(!1),[a,T]=D.useState(""),{data:h,isLoading:E}=pn(),p=h===void 0?[]:h,{data:v,isLoading:j}=jn(n),u=v===void 0?[]:v,y=bn(),N=Tn(),P=E||j,O=u.map(vn);let A;e[0]!==a?(A=F=>F.name.toLowerCase().includes(a.toLowerCase()),e[0]=a,e[1]=A):A=e[1];const R=p.filter(A);let I;e[2]!==a?(I=F=>F.name.toLowerCase()===a.toLowerCase(),e[2]=a,e[3]=I):I=e[3];const L=p.find(I),g=a.trim()&&!L,_=async F=>{const be=O.includes(F.id)?O.filter(_e=>_e!==F.id):[...O,F.id];await N.mutateAsync({memberId:n,tagIds:be})},S=async()=>{if(!a.trim())return;const F=await y.mutateAsync(a.trim());await N.mutateAsync({memberId:n,tagIds:[...O,F.id]}),T("")},C=async F=>{const xe=O.filter(be=>be!==F);await N.mutateAsync({memberId:n,tagIds:xe})},M=y.isPending||N.isPending,z=As;let G;e[4]!==m?(G=()=>b(!m),e[4]=m,e[5]=G):G=e[5];let K;e[6]!==o?(K=H("h-auto min-h-8 px-2 py-1 justify-start font-normal","hover:bg-accent/50",o),e[6]=o,e[7]=K):K=e[7];const W=i||P,X=P?s.jsx(He,{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(En),u.length>x&&s.jsxs(ye,{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(ws,{size:14,className:"ml-1 shrink-0 opacity-50"}),e[8]=ee):ee=e[8];let re;e[9]!==W||e[10]!==X||e[11]!==G||e[12]!==K?(re=s.jsx(_s,{asChild:!0,children:s.jsxs(ie,{variant:"ghost",size:"sm",onClick:G,className:K,disabled:W,children:[X,ee]})}),e[9]=W,e[10]=X,e[11]=G,e[12]=K,e[13]=re):re=e[13];const te=Is,U="w-56 p-0",c="start";let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=()=>b(!1),e[14]=w):w=e[14];const V=Ss,fe=!1;let Z;e[15]!==a?(Z=s.jsx(Os,{placeholder:"Search or create...",value:a,onValueChange:T,className:"h-9"}),e[15]=a,e[16]=Z):Z=e[16];const Y=ys,q=u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{heading:"Selected",children:u.map(F=>s.jsx(mt,{onSelect:()=>_(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(Rt,{})]}),he=dt,J="Available",Q=R.length===0&&!g&&s.jsx(vs,{children:"No tags found."}),ce=R.filter(F=>!O.includes(F.id)).map(F=>s.jsx(mt,{onSelect:()=>_(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 B;e[17]!==he||e[18]!==Q||e[19]!==ce?(B=s.jsxs(he,{heading:J,children:[Q,ce]}),e[17]=he,e[18]=Q,e[19]=ce,e[20]=B):B=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(Rt,{}),s.jsx(dt,{children:s.jsx(mt,{onSelect:S,className:"cursor-pointer",disabled:M,children:s.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[M?s.jsx(He,{size:14,className:"animate-spin"}):s.jsx(ot,{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]!==q||e[28]!==B||e[29]!==se?(ne=s.jsxs(Y,{children:[q,B,se]}),e[26]=Y,e[27]=q,e[28]=B,e[29]=se,e[30]=ne):ne=e[30];let ae;e[31]!==V||e[32]!==Z||e[33]!==ne?(ae=s.jsxs(V,{shouldFilter:fe,children:[Z,ne]}),e[31]=V,e[32]=Z,e[33]=ne,e[34]=ae):ae=e[34];let ge;e[35]!==te||e[36]!==w||e[37]!==ae?(ge=s.jsx(te,{className:U,align:c,onEscapeKeyDown:w,children:ae}),e[35]=te,e[36]=w,e[37]=ae,e[38]=ge):ge=e[38];let Te;return e[39]!==z||e[40]!==m||e[41]!==re||e[42]!==ge?(Te=s.jsxs(z,{open:m,onOpenChange:b,children:[re,ge]}),e[39]=z,e[40]=m,e[41]=re,e[42]=ge,e[43]=Te):Te=e[43],Te}function En(t){return s.jsx(ye,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:t.name},t.id)}function vn(t){return t.id}const Pt=["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 rt(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function Sn(t){const e=new Map;for(const[n,o]of Object.entries(yn))e.set(n,o);for(let n=0;n<t.length;n++){const o=t[n];o&&!e.has(o.role)&&e.set(o.role,Pt[n%Pt.length]??"bg-neutral-400")}return e}function On(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function st(t){const e=oe.c(79),{role:n,memberId:o,isOwner:l,roleColorMap:r,selectableRoles:d,onRoleChange:i,size:f,className:x}=t,m=f===void 0?"xs":f;let b,a,T,h,E,p,v,j,u,y,N;if(e[0]!==x||e[1]!==l||e[2]!==o||e[3]!==i||e[4]!==n||e[5]!==r||e[6]!==d||e[7]!==m){N=Symbol.for("react.early_return_sentinel");e:{const S=r.get(n)??"bg-neutral-400";if(l){let C;e[19]!==o||e[20]!==i?(C=U=>i(o,U),e[19]=o,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:H("size-2 rounded-full shrink-0",S)}),M]});let G;e[24]!==z?(G=s.jsx(gt,{children:z}),e[24]=z,e[25]=G):G=e[25];let K;e[26]!==x||e[27]!==m||e[28]!==G?(K=s.jsx(ht,{size:m,className:x,children:G}),e[26]=x,e[27]=m,e[28]=G,e[29]=K):K=e[29];let W;if(e[30]!==r||e[31]!==d){let U;e[33]!==r?(U=c=>{const w=r.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:H("size-3 rounded-full",w)}),s.jsx("span",{className:"capitalize",children:c.label})]})},c.role)},e[33]=r,e[34]=U):U=e[34],W=d.map(U),e[30]=r,e[31]=d,e[32]=W}else W=e[32];let X;e[35]!==W?(X=s.jsx(xt,{children:W}),e[35]=W,e[36]=X):X=e[36];let ee;e[37]!==l||e[38]!==n||e[39]!==C||e[40]!==K||e[41]!==X?(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,X]})})}),e[37]=l,e[38]=n,e[39]=C,e[40]=K,e[41]=X,e[42]=ee):ee=e[42];let re;e[43]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(Ae,{children:s.jsx("p",{children:"The owner role cannot be changed"})}),e[43]=re):re=e[43];let te;e[44]!==ee?(te=s.jsx(Se,{children:s.jsxs(Oe,{children:[ee,re]})}),e[44]=ee,e[45]=te):te=e[45],N=te;break e}T=ft,j=n,e[46]!==o||e[47]!==i?(u=C=>i(o,C),e[46]=o,e[47]=i,e[48]=u):u=e[48],y=l,a=ht,p=m,v=x,b=gt,E="flex items-center gap-2 min-w-0",h=H("size-2 rounded-full shrink-0",S)}e[0]=x,e[1]=l,e[2]=o,e[3]=i,e[4]=n,e[5]=r,e[6]=d,e[7]=m,e[8]=b,e[9]=a,e[10]=T,e[11]=h,e[12]=E,e[13]=p,e[14]=v,e[15]=j,e[16]=u,e[17]=y,e[18]=N}else b=e[8],a=e[9],T=e[10],h=e[11],E=e[12],p=e[13],v=e[14],j=e[15],u=e[16],y=e[17],N=e[18];if(N!==Symbol.for("react.early_return_sentinel"))return N;let P;e[49]!==h?(P=s.jsx("div",{className:h}),e[49]=h,e[50]=P):P=e[50];let O;e[51]!==n?(O=s.jsx("span",{className:"capitalize truncate",children:n}),e[51]=n,e[52]=O):O=e[52];let A;e[53]!==P||e[54]!==O||e[55]!==E?(A=s.jsxs("div",{className:E,children:[P,O]}),e[53]=P,e[54]=O,e[55]=E,e[56]=A):A=e[56];let R;e[57]!==b||e[58]!==A?(R=s.jsx(b,{children:A}),e[57]=b,e[58]=A,e[59]=R):R=e[59];let I;e[60]!==a||e[61]!==R||e[62]!==p||e[63]!==v?(I=s.jsx(a,{size:p,className:v,children:R}),e[60]=a,e[61]=R,e[62]=p,e[63]=v,e[64]=I):I=e[64];let L;if(e[65]!==r||e[66]!==d){let S;e[68]!==r?(S=C=>{const M=r.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:H("size-3 rounded-full",M)}),s.jsx("span",{className:"capitalize",children:C.label})]})},C.role)},e[68]=r,e[69]=S):S=e[69],L=d.map(S),e[65]=r,e[66]=d,e[67]=L}else L=e[67];let g;e[70]!==L?(g=s.jsx(xt,{children:L}),e[70]=L,e[71]=g):g=e[71];let _;return e[72]!==T||e[73]!==I||e[74]!==g||e[75]!==j||e[76]!==u||e[77]!==y?(_=s.jsxs(T,{value:j,onValueChange:u,disabled:y,children:[I,g]}),e[72]=T,e[73]=I,e[74]=g,e[75]=j,e[76]=u,e[77]=y,e[78]=_):_=e[78],_}function Mt(t){const e=oe.c(51),{member:n,roles:o,onChangeRole:l,onRemove:r,isUpdating:d}=t,i=d===void 0?!1:d,f=n.role==="owner";let x,m,b,a,T,h,E,p,v;if(e[0]!==f||e[1]!==i||e[2]!==n.id||e[3]!==n.role||e[4]!==l||e[5]!==o){let I;e[15]!==n.role?(I=C=>C.role!==n.role&&C.role!=="owner",e[15]=n.role,e[16]=I):I=e[16];const L=o.filter(I);a=Ct;let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(Ft,{size:20}),e[17]=g):g=e[17],e[18]!==f?(v=s.jsx(jt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:f,onClick:An,children:g})}),e[18]=f,e[19]=v):v=e[19],b=Tt,E="end",p=In,m=fs;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx(Ht,{size:16}),e[20]=_):_=e[20],e[21]!==i?(h=s.jsxs(hs,{disabled:i,children:[_,"Change Role"]}),e[21]=i,e[22]=h):h=e[22],x=gs;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(Kt,{size:16}):s.jsx(Es,{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=L.map(S),e[0]=f,e[1]=i,e[2]=n.id,e[3]=n.role,e[4]=l,e[5]=o,e[6]=x,e[7]=m,e[8]=b,e[9]=a,e[10]=T,e[11]=h,e[12]=E,e[13]=p,e[14]=v}else x=e[6],m=e[7],b=e[8],a=e[9],T=e[10],h=e[11],E=e[12],p=e[13],v=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(xs,{}),e[34]=y):y=e[34];let N;e[35]!==n.id||e[36]!==r?(N=I=>{I.stopPropagation(),r(n.id)},e[35]=n.id,e[36]=r,e[37]=N):N=e[37];let P;e[38]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx($t,{size:16}),e[38]=P):P=e[38];let O;e[39]!==N?(O=s.jsxs(nt,{variant:"destructive",onClick:N,children:[P,"Remove Member"]}),e[39]=N,e[40]=O):O=e[40];let A;e[41]!==b||e[42]!==O||e[43]!==E||e[44]!==p||e[45]!==u?(A=s.jsxs(b,{align:E,onClick:p,children:[u,y,O]}),e[41]=b,e[42]=O,e[43]=E,e[44]=p,e[45]=u,e[46]=A):A=e[46];let R;return e[47]!==a||e[48]!==A||e[49]!==v?(R=s.jsxs(a,{children:[v,A]}),e[47]=a,e[48]=A,e[49]=v,e[50]=R):R=e[50],R}function In(t){return t.stopPropagation()}function An(t){return t.stopPropagation()}function Dt(t){const e=oe.c(8),{invitationId:n,onCancel:o,isCancelling:l}=t,r=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:wn,children:s.jsx(Ft,{size:20})})}),e[0]=d):d=e[0];let i;e[1]!==n||e[2]!==o?(i=m=>{m.stopPropagation(),o(n)},e[1]=n,e[2]=o,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]!==r||e[6]!==i?(x=s.jsxs(Ct,{children:[d,s.jsx(Tt,{align:"end",onClick:_n,children:s.jsxs(nt,{variant:"destructive",onClick:i,disabled:r,children:[f,"Cancel Invitation"]})})]}),e[5]=r,e[6]=i,e[7]=x):x=e[7],x}function _n(t){return t.stopPropagation()}function wn(t){return t.stopPropagation()}function Rn(){const t=oe.c(79),{data:e}=bt(),{data:n}=fn(),o=hn(),l=Me(),{locator:r}=je(),[d,i]=D.useState(null),[f,x]=D.useState(null),[m,b]=D.useState(""),[a,T]=D.useState("table"),[h,E]=D.useState("member"),[p,v]=D.useState("asc"),j=e?.data?.members;let u;t[0]!==h?(u=k=>{h===k?v(Qn):(E(k),v("asc"))},t[0]=h,t[1]=u):u=t[1];const y=u;let N=j??[],P=n??[];if(m){const k=m.toLowerCase();N=N.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],N=[...N].sort(k)}const O=N;let A;t[5]!==r||t[6]!==l?(A={mutationFn:Kn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.members(r)}),le.success("Member has been removed from the organization"),i(null)},onError:Fn},t[5]=r,t[6]=l,t[7]=A):A=t[7];const R=Ee(A);let I;t[8]!==r||t[9]!==l?(I={mutationFn:$n,onSuccess:()=>{l.invalidateQueries({queryKey:ue.members(r)}),le.success("Member's role has been updated")},onError:Bn},t[8]=r,t[9]=l,t[10]=I):I=t[10];const L=Ee(I);let g;t[11]!==r||t[12]!==l?(g={mutationFn:Gn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.invitations(r)}),le.success("Invitation role has been updated")},onError:Vn},t[11]=r,t[12]=l,t[13]=g):g=t[13];const _=Ee(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 G;t[16]!==S?(G=S.filter(Un),t[16]=S,t[17]=G):G=t[17];const K=G;let W;t[18]===Symbol.for("react.memo_cache_sentinel")?(W={id:"member",header:"Member",render:zn,cellClassName:"flex-1 min-w-0",sortable:!0},t[18]=W):W=t[18];let X;t[19]!==z||t[20]!==K||t[21]!==_||t[22]!==L?(X={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)=>L.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)=>_.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]=_,t[22]=L,t[23]=X):X=t[23];let ee,re;t[24]===Symbol.for("react.memo_cache_sentinel")?(ee={id:"tags",header:"Tags",render:kn,cellClassName:"w-40 shrink-0"},re={id:"joined",header:"Joined",render:Dn,cellClassName:"w-48 shrink-0",sortable:!0},t[24]=ee,t[25]=re):(ee=t[24],re=t[25]);let te;t[26]!==o.cancel.isPending||t[27]!==S||t[28]!==L?(te={id:"actions",header:"",render:k=>k.type==="member"?s.jsx(Mt,{member:k.data,roles:S,onChangeRole:($,de)=>L.mutate({memberId:$,role:de}),onRemove:i,isUpdating:L.isPending}):s.jsx(Dt,{invitationId:k.data.id,onCancel:x,isCancelling:o.cancel.isPending}),cellClassName:"w-12 shrink-0"},t[26]=o.cancel.isPending,t[27]=S,t[28]=L,t[29]=te):te=t[29];let U;t[30]!==te||t[31]!==X?(U=[W,X,ee,re,te],t[30]=te,t[31]=X,t[32]=U):U=t[32];const c=U;let w;t[33]===Symbol.for("react.memo_cache_sentinel")?(w=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(Kt,{size:16}),"Manage Roles"]})}),t[33]=w):w=t[33];let V;t[34]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsxs("div",{className:"flex items-center gap-2",children:[w,s.jsx(un,{trigger:s.jsx(ie,{size:"sm",children:"Invite Member"})})]}),t[34]=V):V=t[34];const fe=V,Z=[...O.map(Mn),...P.filter(Pn).map(Ln)],Y=ve,q=!!f;let he;t[35]===Symbol.for("react.memo_cache_sentinel")?(he=()=>x(null),t[35]=he):he=t[35];let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsxs(Ge,{children:[s.jsx(Be,{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]=J):J=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]!==o.cancel||t[39]!==f?(ce=()=>{f&&(o.cancel.mutate(f),x(null))},t[38]=o.cancel,t[39]=f,t[40]=ce):ce=t[40];let B;t[41]!==o.cancel.isPending||t[42]!==ce?(B=s.jsxs(Ve,{children:[J,s.jsxs(Fe,{children:[Q,s.jsx(Qe,{onClick:ce,disabled:o.cancel.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Invitation"})]})]}),t[41]=o.cancel.isPending,t[42]=ce,t[43]=B):B=t[43];let se;t[44]!==q||t[45]!==B?(se=s.jsx(Ue,{open:q,onOpenChange:he,children:B}),t[44]=q,t[45]=B,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(Ge,{children:[s.jsx(Be,{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]!==R?(F=()=>d&&R.mutate(d),t[50]=d,t[51]=R,t[52]=F):F=t[52];let xe;t[53]!==R.isPending||t[54]!==F?(xe=s.jsxs(Ve,{children:[ge,s.jsxs(Fe,{children:[Te,s.jsx(Qe,{onClick:F,disabled:R.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),t[53]=R.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 _e;t[59]===Symbol.for("react.memo_cache_sentinel")?(_e=s.jsx(ve.Header.Left,{children:s.jsx(ss,{children:s.jsx(ns,{children:s.jsx(os,{children:s.jsx(rs,{children:"Members"})})})})}),t[59]=_e):_e=t[59];let Ze;t[60]===Symbol.for("react.memo_cache_sentinel")?(Ze=[{id:"member",label:"Name"},{id:"role",label:"Role"},{id:"joined",label:"Joined"}],t[60]=Ze):Ze=t[60];let we;t[61]!==y||t[62]!==p||t[63]!==h||t[64]!==a?(we=s.jsxs(ve.Header,{children:[_e,s.jsxs(ve.Header.Right,{children:[s.jsx(ts,{viewMode:a,onViewModeChange:T,sortKey:h,sortDirection:p,onSort:y,sortOptions:Ze}),fe]})]}),t[61]=y,t[62]=p,t[63]=h,t[64]=a,t[65]=we):we=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 Re;t[67]!==m?(Re=s.jsx(De,{value:m,onChange:b,placeholder:"Search members...",onKeyDown:Ye}),t[67]=m,t[68]=Re):Re=t[68];const lt=ve,at=a==="cards"?s.jsx("div",{className:"flex-1 overflow-auto p-5",children:Z.length===0?s.jsx(ct,{title:"No members found",description:m?`No members match "${m}"`:"Invite members to get started."}):s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4",children:Z.map(k=>{if(k.type==="invitation")return s.jsxs(wt,{className:"transition-colors relative opacity-75",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Dt,{invitationId:k.data.id,onCancel:x,isCancelling:o.cancel.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Pe,{fallback:rt(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(ye,{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)=>_.mutate({invitationId:de,role:pe,email:k.data.email}),className:"w-fit"})]})]})]},`inv-${k.data.id}`);const $=k.data;return s.jsxs(wt,{className:"transition-colors relative",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Mt,{member:$,roles:S,onChangeRole:(de,pe)=>L.mutate({memberId:de,role:pe}),onRemove:i,isUpdating:L.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Pe,{url:$.user?.image??void 0,fallback:rt($.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)=>L.mutate({memberId:de,role:pe}),className:"w-fit"}),s.jsx(Zt,{memberId:$.id,maxDisplay:3})]})]})]},$.id)})})}):s.jsx(is,{columns:c,data:Z,isLoading:!1,sortKey:h,sortDirection:p,onSort:y,emptyState:m?s.jsx(ct,{title:"No members found",description:`No members match "${m}"`}):s.jsx(ct,{title:"No members found",description:"Invite members to get started."})});let Le;t[69]!==lt.Content||t[70]!==at?(Le=s.jsx(lt.Content,{children:at}),t[69]=lt.Content,t[70]=at,t[71]=Le):Le=t[71];let We;return t[72]!==Y||t[73]!==se||t[74]!==be||t[75]!==we||t[76]!==Re||t[77]!==Le?(We=s.jsxs(Y,{children:[se,be,we,Re,Le]}),t[72]=Y,t[73]=se,t[74]=be,t[75]=we,t[76]=Re,t[77]=Le,t[78]=We):We=t[78],We}function Ln(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?On(t.data.createdAt):"N/A"}):s.jsx(ye,{variant:"outline",children:"Pending"})}function kn(t){return t.type==="member"?s.jsx(Zt,{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:rt(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:rt(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 Gn(t){const{invitationId:e,role:n,email:o}=t,l=await me.organization.cancelInvitation({invitationId:e});if(l?.error)throw new Error(l.error.message);const r=await me.organization.inviteMember({email:o,role:n});if(r?.error)throw new Error(r.error.message)}function Bn(t){le.error(t instanceof Error?t.message:"Failed to update role")}async function $n(t){const{memberId:e,role:n}=t,o=await me.organization.updateMemberRole({memberId:e,role:[n]});if(o?.error)throw new Error(o.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 Zo(){const t=oe.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(ve,{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(es,{fallback:e,children:s.jsx(D.Suspense,{fallback:s.jsx(ve,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(He,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(Rn,{})})}),t[1]=n):n=t[1],n}export{Zo as default};
|