@tickernelz/wardmote-ui 2026.1114.2 → 2026.1114.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActiveAgentsPanel-Budj8e9v.js → ActiveAgentsPanel-CF0fwsze.js} +1 -1
- package/dist/assets/{AdapterManager-DhiW44Eo.js → AdapterManager-DUXWwNxv.js} +1 -1
- package/dist/assets/{AdvancedToolsRoute-CICI1XRd.js → AdvancedToolsRoute-BamlkE3p.js} +1 -1
- package/dist/assets/{AgentActionButtons-DIhpv51Y.js → AgentActionButtons-CPIhsP04.js} +1 -1
- package/dist/assets/{AgentBubbleActionRow-DIr3TdR9.js → AgentBubbleActionRow-BUAUmJKa.js} +1 -1
- package/dist/assets/{AgentChat-CeuGtMXr.js → AgentChat-BAn_ghsu.js} +1 -1
- package/dist/assets/{AgentChats-CmDtTrMa.js → AgentChats-f73hodzr.js} +1 -1
- package/dist/assets/{AgentDefaults-DpYaMGkf.js → AgentDefaults-BL1XYvEo.js} +1 -1
- package/dist/assets/{AgentDetail-DFTeFc4-.js → AgentDetail-DthxFfuB.js} +1 -1
- package/dist/assets/{AgentTodoCard-DRXZ7hmU.js → AgentTodoCard-BvgkWD0T.js} +1 -1
- package/dist/assets/{Agents-CClUUMUq.js → Agents-D5qI6yZZ.js} +3 -3
- package/dist/assets/{AppDetail-DfHLFOtj.js → AppDetail-B6PtMl8J.js} +1 -1
- package/dist/assets/{AppNotConnected-CcmXbFtD.js → AppNotConnected-C_tGn786.js} +1 -1
- package/dist/assets/{ApprovalCard-uT_9D_uH.js → ApprovalCard-DrfZAdGQ.js} +1 -1
- package/dist/assets/{ApprovalDetail-CE41WFbd.js → ApprovalDetail-sfPpfdXc.js} +1 -1
- package/dist/assets/{ApprovalPayload-_zU9bukt.js → ApprovalPayload-C4F3ItGH.js} +1 -1
- package/dist/assets/{Approvals-BXrjqpKc.js → Approvals-DZoMl7_m.js} +1 -1
- package/dist/assets/{AppsConnect-DH7aSjtS.js → AppsConnect-D8Gu187f.js} +1 -1
- package/dist/assets/{AppsReview-C0Y3SxmZ.js → AppsReview-DokFETm0.js} +1 -1
- package/dist/assets/{ArtifactCard-DKUUBZ0K.js → ArtifactCard-BTf2-JIV.js} +1 -1
- package/dist/assets/{Artifacts-Bsv5m0aU.js → Artifacts-CK8FaygC.js} +1 -1
- package/dist/assets/{AssistantConnection-Dm2PaSeU.js → AssistantConnection-BlKC7jk0.js} +1 -1
- package/dist/assets/{AttentionInteractionResolver-CBjNuhYo.js → AttentionInteractionResolver-C2iz6oqT.js} +1 -1
- package/dist/assets/{AuditHub-DbUni0O_.js → AuditHub-DMhunMn8.js} +1 -1
- package/dist/assets/{BoardChat-CgzCuFIL.js → BoardChat-C4W8JLKB.js} +1 -1
- package/dist/assets/{BootstrapSetupUxLab-D-niQCV5.js → BootstrapSetupUxLab-D58OwniR.js} +1 -1
- package/dist/assets/{Browse-0bmB5mqw.js → Browse-BDjohBak.js} +1 -1
- package/dist/assets/{BudgetPolicyCard-CqFUHqOj.js → BudgetPolicyCard-DfAAgk9Z.js} +1 -1
- package/dist/assets/{CaseDetail-DakrB2jI.js → CaseDetail-CL0FC5sG.js} +1 -1
- package/dist/assets/{Cases-DXbr4HJt.js → Cases-C-7dXrEt.js} +1 -1
- package/dist/assets/{ChatEndpointDetail-BdDKo-Gq.js → ChatEndpointDetail-C-IYAYG8.js} +1 -1
- package/dist/assets/{ChatEndpointSetup-BX3iDH7N.js → ChatEndpointSetup-CM3QixMj.js} +1 -1
- package/dist/assets/{ChoiceControls-Bu-fd6qI.js → ChoiceControls-3Qpci4yE.js} +1 -1
- package/dist/assets/{Companies-FcUNLIkt.js → Companies-97toQ8Cw.js} +1 -1
- package/dist/assets/{CompanyAccess-BUcTNg7_.js → CompanyAccess-CKhS1BaS.js} +1 -1
- package/dist/assets/{CompanyActivity-ScpRBz1G.js → CompanyActivity-DzNrAyAb.js} +1 -1
- package/dist/assets/{CompanyConnections-DMEwbZv7.js → CompanyConnections-ORCH4i3U.js} +1 -1
- package/dist/assets/{CompanyEnvironments-EqXhVruZ.js → CompanyEnvironments-DphURbtb.js} +1 -1
- package/dist/assets/{CompanyExport-DQ9ffuua.js → CompanyExport-XeVCUcK3.js} +1 -1
- package/dist/assets/{CompanyImport-BhuZu4oc.js → CompanyImport-DPKpUaRa.js} +1 -1
- package/dist/assets/{CompanySettings-BSkg4ahA.js → CompanySettings-4JQpzuS1.js} +1 -1
- package/dist/assets/{CompanySettingsPluginPage-BzZkZqh-.js → CompanySettingsPluginPage-cVvXh0_G.js} +1 -1
- package/dist/assets/{CompanySkills-BbA4RKIw.js → CompanySkills-BA_9Ztwj.js} +1 -1
- package/dist/assets/{ComposerAddMenu-D9z2INup.js → ComposerAddMenu-DNp4ecG8.js} +1 -1
- package/dist/assets/{ConfigureBuiltInAgentModal-BUJPbmWc.js → ConfigureBuiltInAgentModal-CQCHDkl4.js} +1 -1
- package/dist/assets/{ConnectionSetupFlow-DKjP5RBZ.js → ConnectionSetupFlow-BaarToKu.js} +1 -1
- package/dist/assets/{CopyableGatewayUrl-BZyE_jT9.js → CopyableGatewayUrl-DxQsV7Hr.js} +1 -1
- package/dist/assets/{Dashboard--lTwxjV-.js → Dashboard--iaPJqJp.js} +1 -1
- package/dist/assets/{DashboardLive-BYyTgF5d.js → DashboardLive-4rGeotay.js} +1 -1
- package/dist/assets/{DecisionDateChips-vXwAFdua.js → DecisionDateChips-CJOLtNrJ.js} +1 -1
- package/dist/assets/{DecisionModelSettings-NrNERkaW.js → DecisionModelSettings-D-OxKIGP.js} +1 -1
- package/dist/assets/{DecisionQueuePage-BaaKuZBi.js → DecisionQueuePage-D-kNFav_.js} +1 -1
- package/dist/assets/{DesignGuide-DS6MuXWY.js → DesignGuide-D7486q4b.js} +1 -1
- package/dist/assets/{DocumentFrameHeader-DTSqcw4Q.js → DocumentFrameHeader-B61HhahB.js} +1 -1
- package/dist/assets/{EmailEndpointSetup-CJFYu2G0.js → EmailEndpointSetup-6OHb9B4q.js} +1 -1
- package/dist/assets/{ExecutionWorkspaceDetail-CuD5xWOB.js → ExecutionWorkspaceDetail-BGV-9D5Y.js} +1 -1
- package/dist/assets/{FolderControls-B7TWghGc.js → FolderControls-L2RzbfdQ.js} +1 -1
- package/dist/assets/{GatewayDetail-xNVOxSIs.js → GatewayDetail-CdXNQ9gD.js} +1 -1
- package/dist/assets/{GatewaysList-DsSKLm1h.js → GatewaysList-B0Jq1IRC.js} +1 -1
- package/dist/assets/{GoalDetail-oN5pyUUY.js → GoalDetail-D2VhPtvw.js} +1 -1
- package/dist/assets/{GoalTree-DaFizciF.js → GoalTree-kFpgH4dA.js} +1 -1
- package/dist/assets/{Goals-xgGKfQZi.js → Goals-B-_gq_Qu.js} +1 -1
- package/dist/assets/{ImageGalleryModal-CjHED0Lb.js → ImageGalleryModal-DzKBMOnu.js} +1 -1
- package/dist/assets/{Inbox-wHhHozfr.js → Inbox-zllmqRcB.js} +1 -1
- package/dist/assets/{InstanceAdvanced-Bdf2a4c_.js → InstanceAdvanced-B7tDfjwG.js} +1 -1
- package/dist/assets/{InviteLanding-McBYpNeW.js → InviteLanding-brwa_8NC.js} +1 -1
- package/dist/assets/{IssueChatLongThreadPerf-DD3RLbBo.js → IssueChatLongThreadPerf-D0HJe6IV.js} +1 -1
- package/dist/assets/{IssueChatThread-BN-_8hT8.js → IssueChatThread-CMXzuvrF.js} +1 -1
- package/dist/assets/{IssueDetail-CsaD311l.js → IssueDetail-DGdg-mB8.js} +1 -1
- package/dist/assets/{IssueDocumentAnnotations-BVdH4RTa.js → IssueDocumentAnnotations-BK-LgExc.js} +1 -1
- package/dist/assets/{IssueOutputSection-CDIMRaF0.js → IssueOutputSection-aSyiE1pg.js} +1 -1
- package/dist/assets/{IssueRecoveryActionCard-C9qJAHes.js → IssueRecoveryActionCard-vAuL_OEC.js} +1 -1
- package/dist/assets/{IssueThreadInteractionCard-BbigJB2U.js → IssueThreadInteractionCard-wFidFTIh.js} +1 -1
- package/dist/assets/{Issues-BWoc80Y9.js → Issues-CsmM33z_.js} +1 -1
- package/dist/assets/{LiveNowTodoLine-B9oTH2L0.js → LiveNowTodoLine-CP32NNp_.js} +1 -1
- package/dist/assets/{ManagedAiConnectionDetails-B0aWUPkf.js → ManagedAiConnectionDetails-Ba0awZ-O.js} +1 -1
- package/dist/assets/{McpConnect-Dzf7W2K6.js → McpConnect-CYLP1yLX.js} +1 -1
- package/dist/assets/{MembershipAction-oiLtxQm3.js → MembershipAction-CKs7Ua9x.js} +1 -1
- package/dist/assets/{ModelsAndProviders-BEb4Z38S.js → ModelsAndProviders-gaR7HDQm.js} +1 -1
- package/dist/assets/{NewAgent-C3MxIRJj.js → NewAgent-DBQzvxIr.js} +1 -1
- package/dist/assets/{OmpAllSettings-DBtL1qDL.js → OmpAllSettings-B_Knr51Z.js} +1 -1
- package/dist/assets/{PipelineSettings-BcAtsehE.js → PipelineSettings-Dl-94FB5.js} +1 -1
- package/dist/assets/{Pipelines-CkiYUQS-.js → Pipelines-CY9hGe0h.js} +1 -1
- package/dist/assets/{PixelsOffice-BSlctoug.js → PixelsOffice-BgyGZsiV.js} +1 -1
- package/dist/assets/{PluginPage-C6Qnf9ka.js → PluginPage-CMA4Ei50.js} +1 -1
- package/dist/assets/{PluginSettings-Do37r6Zu.js → PluginSettings-Cm4H1JRT.js} +1 -1
- package/dist/assets/{ProfileDetailRoute-DRFQNId6.js → ProfileDetailRoute-BEBctbC6.js} +1 -1
- package/dist/assets/{ProfileSettings-BMwLBQDB.js → ProfileSettings-Djo7BLIj.js} +1 -1
- package/dist/assets/{ProfileWizardRoute-XnnvzH9S.js → ProfileWizardRoute-DxLujEtD.js} +1 -1
- package/dist/assets/{ProjectDetail-BW6Lr4Iq.js → ProjectDetail-CmmdvUHn.js} +1 -1
- package/dist/assets/{ProjectWorkspaceDetail-DR4JCa1b.js → ProjectWorkspaceDetail-BsA0hJ-k.js} +1 -1
- package/dist/assets/{ProjectWorkspacesContent-CadPZn0k.js → ProjectWorkspacesContent-BNNI_WAk.js} +1 -1
- package/dist/assets/{Projects-DLBFbxcj.js → Projects-BTAauZr0.js} +1 -1
- package/dist/assets/{PublicIssueSharePage-C9yRZOdP.js → PublicIssueSharePage-DdPjfmD9.js} +1 -1
- package/dist/assets/{ReviewQueueCard-CIkiY-Lm.js → ReviewQueueCard-BC6VY8Bc.js} +1 -1
- package/dist/assets/{RichWorkProductCard-JGHGU_RI.js → RichWorkProductCard-ClpMt_Bh.js} +1 -1
- package/dist/assets/{RoutineDetail-izWzADvA.js → RoutineDetail-BT6_GKnC.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-DiT_o5Dm.js → RoutineRunVariablesDialog-D_Mls1sV.js} +1 -1
- package/dist/assets/{Routines-CHtabiYj.js → Routines-4LevOfvV.js} +1 -1
- package/dist/assets/{ScrollToBottom-pyHLjOjY.js → ScrollToBottom-jItsgDR8.js} +1 -1
- package/dist/assets/{Search-yNNB6kys.js → Search-bmcm0_m_.js} +1 -1
- package/dist/assets/{Secrets-BOyOk5BF.js → Secrets-DfR1fBAZ.js} +1 -1
- package/dist/assets/{SkillSourceTree-M58QwBFF.js → SkillSourceTree--FWKWyF3.js} +1 -1
- package/dist/assets/{SkillSources-Cw4PU-Bz.js → SkillSources-jUDjqy5i.js} +1 -1
- package/dist/assets/{SkillStudio-Cj_M3ZJa.js → SkillStudio-BsqtUnzF.js} +1 -1
- package/dist/assets/{SourceTrustBadge-BZBQe5No.js → SourceTrustBadge-CfBrvKL3.js} +1 -1
- package/dist/assets/{StatusCards-DaJdQUN5.js → StatusCards-Dt3zorUZ.js} +1 -1
- package/dist/assets/{SummarySlotCard-DlSmN6PL.js → SummarySlotCard-D1C0qH2L.js} +1 -1
- package/dist/assets/{TaskChatLab-CU5eA7nX.js → TaskChatLab-B0coUvdp.js} +1 -1
- package/dist/assets/{TaskChatMarker-wBVUFL3u.js → TaskChatMarker-C40twVjh.js} +1 -1
- package/dist/assets/{TaskChatProtocolCard-D-Dwy2EL.js → TaskChatProtocolCard--bi_tc6i.js} +1 -1
- package/dist/assets/{TaskChatThreadView-Crlf9I05.js → TaskChatThreadView-DkzFDrLW.js} +1 -1
- package/dist/assets/{TaskDetailRelationsPanel-CkktN1EC.js → TaskDetailRelationsPanel-DZGkinoJ.js} +1 -1
- package/dist/assets/{TaskTreeControls-B_ulMOi1.js → TaskTreeControls-DznugVpi.js} +1 -1
- package/dist/assets/Terminal-NjEb5-2b.js +1 -0
- package/dist/assets/TerminalView-DZxK2Ei5.js +58 -0
- package/dist/assets/{TrustPresetSection-DTc1Rj4q.js → TrustPresetSection-CjNwNBo3.js} +1 -1
- package/dist/assets/{UserProfile-C6q55R0Q.js → UserProfile-Dujv3qdz.js} +1 -1
- package/dist/assets/{WhatNeedsMe-1igJA4gL.js → WhatNeedsMe-C9P2EsqQ.js} +1 -1
- package/dist/assets/{Workspaces-rtQKliW0.js → Workspaces-BTgSx9nA.js} +1 -1
- package/dist/assets/{connection-owner-CZwxTEuM.js → connection-owner-DL4yKhSt.js} +1 -1
- package/dist/assets/dist-ypeTPGg_.js +1 -0
- package/dist/assets/dropdown-menu-DEO3mF_E.js +1 -0
- package/dist/assets/{environment-variables-editor-CCxeFKKk.js → environment-variables-editor-0qgSPgNN.js} +1 -1
- package/dist/assets/{index-DDoARkPG.js → index-3AxqhPET.js} +4 -4
- package/dist/assets/index-B5bd7Tk6.css +2 -0
- package/dist/assets/{issue-properties-lmRBaUTG.js → issue-properties-B1cYnBDU.js} +1 -1
- package/dist/assets/{issue-workspace-selection-4JI2Uh9p.js → issue-workspace-selection-S8UgGgK1.js} +1 -1
- package/dist/assets/{pipeline-stage-presentation-BSuBql6K.js → pipeline-stage-presentation-5UBw7nsb.js} +1 -1
- package/dist/assets/{shared-DDwmHbeD.js → shared-4LF6wQ38.js} +1 -1
- package/dist/assets/{tool-taxonomy-DR7Q8sVs.js → tool-taxonomy-B5zpbkHA.js} +1 -1
- package/dist/assets/{transcript-adapter-wiFIjKfq.js → transcript-adapter-C29ZJiU2.js} +1 -1
- package/dist/assets/{useSummaryDraftStream-CWOQt25o.js → useSummaryDraftStream-R2Y2bAUU.js} +1 -1
- package/dist/index.html +7 -6
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Terminal-Bo-WuezO.js +0 -1
- package/dist/assets/TerminalView-AkFY5bLC.js +0 -58
- package/dist/assets/dropdown-menu-CqRAF7Oj.js +0 -1
- package/dist/assets/index-KZ2bEg2H.css +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
var de=Object.defineProperty;var c=(s,a)=>de(s,"name",{value:a,configurable:!0});import{i as te}from"./rolldown-runtime-ZpX3ckPj.js";import{na as xe,t as ae,ta as me}from"./createLucideIcon-DJi9suAC.js";import{v as he}from"./star-BZgQbzhV.js";import{X as ne,_ as W,t as w,v as q}from"./queryKeys-DYV5MhM_.js";import{n as ue}from"./CompanyContext-CSrVsSze.js";import{Z as ge,r as pe,t as V}from"./router-2UfGeejU.js";import{n as Y,t as fe}from"./tabs-B2Os_leL.js";import{t as je}from"./PathInstructionsModal-D4GUYKIT.js";import{t as be}from"./arrow-left-Ce_LIut0.js";import{t as Ne}from"./calendar-clock-BVFltraz.js";import{t as ve}from"./circle-x-CFlSbYzD.js";import{t as ye}from"./clock-CzrJT_cP.js";import{n as U}from"./package-CYC5MDhY.js";import{t as ke}from"./folder-open-8WDYv4mw.js";import{r as M,t as $}from"./button-CMwV3L1P.js";import{t as we}from"./save-CJ1Iqyew.js";import{t as Ce}from"./shield-alert-Be9GuMrS.js";import{t as Se}from"./triangle-alert-CBVKiaXB.js";import{t as qe}from"./webhook-BVBCKjlU.js";import{t as p}from"./badge-DuA2EgZC.js";import{t as k}from"./plugins-CF2QITJB.js";import{o as Fe,t as Le}from"./slots-Dw517dxP.js";import{n as De}from"./BreadcrumbContext-BVZDZoC0.js";import{n as R,r as X,t as Pe}from"./JsonSchemaForm-ixDd6e-N.js";import{i as Z,o as F,r as L,s as D,t as P}from"./card-Bru3x_SJ.js";import{Kr as Me}from"./index-DDoARkPG.js";import{t as J}from"./separator-B2LFqBpM.js";import{t as $e}from"./useManagedSandboxOnly-CO01cDK4.js";var ie={name:"circle-check-big",size:24,node:[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-circle"]};ie.node;var Ke=ae(ie),re={name:"square-activity",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],aliases:["activity-square"]};re.node;var G=ae(re),h=te(xe(),1),e=te(me(),1);function Ns(){const{selectedCompany:s,selectedCompanyId:a}=ue(),{setBreadcrumbs:n}=De(),{companyPrefix:r,pluginId:l}=he(),{hideHostPaths:m}=$e(),[f,g]=(0,h.useState)("configuration"),{data:i,isLoading:j}=q({queryKey:w.plugins.detail(l),queryFn:c(()=>k.get(l),"queryFn"),enabled:!!l}),{data:u,isLoading:v}=q({queryKey:w.plugins.health(l),queryFn:c(()=>k.health(l),"queryFn"),enabled:!!l&&i?.status==="ready",refetchInterval:3e4}),{data:o}=q({queryKey:w.plugins.dashboard(l),queryFn:c(()=>k.dashboard(l),"queryFn"),enabled:!!l,refetchInterval:3e4}),{data:b}=q({queryKey:w.plugins.logs(l),queryFn:c(()=>k.logs(l,{limit:50}),"queryFn"),enabled:!!l&&i?.status==="ready",refetchInterval:3e4}),N=i?.manifestJson?.instanceConfigSchema,d=N&&N.properties&&Object.keys(N.properties).length>0,y=l&&a?w.plugins.config(l,a):["plugins",l??"__missing_plugin__","companies","__missing_company__","config"],{data:T,isLoading:C}=q({queryKey:y,queryFn:c(()=>k.getConfig(l,a),"queryFn"),enabled:!!l&&!!d&&!!a}),{slots:S}=Fe({slotTypes:["settingsPage"],companyId:a,enabled:!!a}),K=S.filter(t=>t.pluginId===l),E=K.length>0;if((0,h.useEffect)(()=>{n([{label:s?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins",href:"/company/settings/instance/plugins"},{label:i?.manifestJson?.displayName??i?.packageName??"Plugin Details"}])},[s?.name,n,r,i]),(0,h.useEffect)(()=>{g("configuration")},[l]),j)return(0,e.jsx)("div",{className:"p-4 text-sm text-ink-3",children:"Loading plugin details..."});if(!i)return(0,e.jsx)(pe,{to:"/company/settings/instance/plugins",replace:!0});const _=i.status,x=i.status==="ready"?"default":i.status==="error"?"destructive":"secondary",le=i.manifestJson.description||"No description provided.",O=i.manifestJson.capabilities??[],B=i.manifestJson.environmentDrivers??[],H=i.manifestJson.localFolders??[],Q=H.length>0&&!m,ce=B.map(t=>t.displayName?.trim()||t.driverKey).filter((t,A,oe)=>oe.indexOf(t)===A).join(", ");return(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(V,{to:"/company/settings/instance/plugins",children:(0,e.jsx)($,{variant:"secondary",size:"icon",className:"h-8 w-8",children:(0,e.jsx)(be,{className:"h-4 w-4"})})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ge,{className:"h-6 w-6 text-ink-3"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:i.manifestJson.displayName??i.packageName}),(0,e.jsx)(p,{variant:x,className:"ml-2",children:_}),(0,e.jsxs)(p,{variant:"outline",className:"ml-1",children:["v",i.manifestJson.version??i.version]})]})]}),(0,e.jsxs)(fe,{value:f,onValueChange:c(t=>g(t),"onValueChange"),className:"space-y-6",children:[(0,e.jsx)(Me,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:f,onValueChange:c(t=>g(t),"onValueChange")}),(0,e.jsx)(Y,{value:"configuration",className:"space-y-6",children:(0,e.jsxs)("div",{className:"space-y-8",children:[(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,e.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink-3",children:"Description"}),(0,e.jsx)("p",{className:"text-sm leading-6 text-ink/90",children:le})]}),(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h3",{className:"font-medium text-ink-3",children:"Author"}),(0,e.jsx)("p",{className:"text-ink",children:i.manifestJson.author})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"font-medium text-ink-3",children:"Categories"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:i.categories.length>0?i.categories.map(t=>(0,e.jsx)(p,{variant:"outline",className:"capitalize",children:t},t)):(0,e.jsx)("span",{className:"text-ink",children:"None"})})]})]})]})]}),(0,e.jsx)(J,{}),(0,e.jsxs)("section",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"space-y-1",children:(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),Q?(0,e.jsx)(_e,{pluginId:l,companyId:a,declarations:H}):null,E?(0,e.jsx)("div",{className:"space-y-3",children:K.map(t=>(0,e.jsx)(Le,{slot:t,context:{companyId:a,companyPrefix:r??null},missingBehavior:"placeholder"},`${t.pluginKey}:${t.id}`))}):d?(0,e.jsx)(Je,{pluginId:l,companyId:a,schema:N,initialValues:T?.configJson,isLoading:C,pluginStatus:i.status,supportsConfigTest:i.supportsConfigTest===!0}):B.length>0?(0,e.jsxs)("div",{className:"rounded-md border border-line/60 bg-bg-3/20 px-4 py-3 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-ink",children:"Configure this plugin from Settings → Environments."}),(0,e.jsxs)("p",{className:"mt-1 text-ink-3",children:[ce||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,e.jsx)("div",{className:"mt-3",children:(0,e.jsx)(V,{to:"/company/settings/instance/environments",children:(0,e.jsx)($,{variant:"secondary",size:"sm",children:"Open Environments"})})})]}):Q?null:(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This plugin does not require any settings."})]})]})}),(0,e.jsx)(Y,{value:"status",className:"space-y-6",children:(0,e.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsxs)(F,{children:[(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(U,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,e.jsx)(Z,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,e.jsx)(L,{className:"space-y-6",children:o?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(U,{className:"h-3.5 w-3.5 text-ink-3"}),"Worker Process"]}),o.worker?(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Status"}),(0,e.jsx)(p,{variant:o.worker.status==="running"?"default":"secondary",children:o.worker.status})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"PID"}),(0,e.jsx)("span",{className:"font-mono text-xs",children:o.worker.pid??"—"})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Uptime"}),(0,e.jsx)("span",{className:"text-xs",children:ze(o.worker.uptime)})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Pending RPCs"}),(0,e.jsx)("span",{className:"text-xs",children:o.worker.pendingRequests})]}),o.worker.totalCrashes>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsxs)("span",{className:"text-ink-3 flex items-center gap-1",children:[(0,e.jsx)(Se,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,e.jsxs)("span",{className:"text-xs",children:[o.worker.consecutiveCrashes," consecutive / ",o.worker.totalCrashes," total"]})]}),o.worker.lastCrashAt&&(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Last Crash"}),(0,e.jsx)("span",{className:"text-xs",children:We(o.worker.lastCrashAt)})]})]})]}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No worker process registered."})]}),(0,e.jsx)(J,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(Ne,{className:"h-3.5 w-3.5 text-ink-3"}),"Recent Job Runs"]}),o.recentJobRuns.length>0?(0,e.jsx)("div",{className:"space-y-2",children:o.recentJobRuns.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-bg-3/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Oe,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.jobKey??t.jobId,children:t.jobKey??t.jobId.slice(0,8)}),(0,e.jsx)(p,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:t.trigger})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-ink-3",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ee(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:se(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No job runs recorded yet."})]}),(0,e.jsx)(J,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5 text-ink-3"}),"Recent Webhook Deliveries"]}),o.recentWebhookDeliveries.length>0?(0,e.jsx)("div",{className:"space-y-2",children:o.recentWebhookDeliveries.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-bg-3/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Be,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.webhookKey,children:t.webhookKey})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-ink-3",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ee(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:se(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No webhook deliveries recorded yet."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-line/50 pt-2 text-xs text-ink-3",children:[(0,e.jsx)(ye,{className:"h-3 w-3"}),"Last checked: ",new Date(o.checkedAt).toLocaleTimeString()]})]}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Runtime diagnostics are unavailable right now."})})]}),b&&b.length>0?(0,e.jsxs)(P,{children:[(0,e.jsxs)(F,{children:[(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(G,{className:"h-4 w-4"}),"Recent Logs"]}),(0,e.jsxs)(Z,{children:["Last ",b.length," log entries"]})]}),(0,e.jsx)(L,{children:(0,e.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:b.map(t=>(0,e.jsxs)("div",{className:`flex gap-2 py-0.5 ${t.level==="error"?"text-bad":t.level==="warn"?"text-yellow-600 dark:text-yellow-400":t.level==="debug"?"text-ink-3/60":"text-ink-3"}`,children:[(0,e.jsx)("span",{className:"shrink-0 text-ink-3/50",children:new Date(t.createdAt).toLocaleTimeString()}),(0,e.jsx)(p,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:t.level}),(0,e.jsx)("span",{className:"truncate",title:t.message,children:t.message})]},t.id))})})]}):null]}),(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsx)(F,{children:(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(G,{className:"h-4 w-4"}),"Health Status"]})}),(0,e.jsx)(L,{children:v?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Checking health..."}):u?(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Overall"}),(0,e.jsx)(p,{variant:u.healthy?"default":"destructive",children:u.status})]}),u.checks.length>0?(0,e.jsx)("div",{className:"space-y-2 border-t border-line/50 pt-2",children:u.checks.map((t,A)=>(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:"truncate text-ink-3",title:t.name,children:t.name}),t.passed?(0,e.jsx)(Ke,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,e.jsx)(ve,{className:"h-4 w-4 shrink-0 text-bad"})]},A))}):null,u.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-bad/20 bg-bad/10 p-2 text-xs text-bad",children:u.lastError}):null]}):(0,e.jsxs)("div",{className:"space-y-3 text-sm text-ink-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{children:"Lifecycle"}),(0,e.jsx)(p,{variant:x,children:_})]}),(0,e.jsx)("p",{children:"Health checks run once the plugin is ready."}),i.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-bad/20 bg-bad/10 p-2 text-xs text-bad",children:i.lastError}):null]})})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)(F,{children:(0,e.jsx)(D,{className:"text-base",children:"Details"})}),(0,e.jsxs)(L,{className:"space-y-3 text-sm text-ink-3",children:[(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin ID"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:i.id})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin Key"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:i.pluginKey})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"NPM Package"}),(0,e.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:i.packageName,children:i.packageName})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Version"}),(0,e.jsxs)("span",{className:"text-right text-ink",children:["v",i.manifestJson.version??i.version]})]})]})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)(F,{children:(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(Ce,{className:"h-4 w-4"}),"Permissions"]})}),(0,e.jsx)(L,{children:O.length>0?(0,e.jsx)("ul",{className:"space-y-2 text-sm text-ink-3",children:O.map(t=>(0,e.jsx)("li",{className:"rounded-md bg-bg-3/40 px-2.5 py-2 font-mono text-xs text-ink/85",children:t},t))}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No special permissions requested."})})]})]})]})})]})]})}c(Ns,"PluginSettings");function _e({pluginId:s,companyId:a,declarations:n}){const{data:r,isLoading:l,error:m}=q({queryKey:a?w.plugins.localFolders(s,a):["plugins",s,"companies","none","local-folders"],queryFn:c(()=>k.listLocalFolders(s,a),"queryFn"),enabled:!!a}),f=new Map((r?.folders??[]).map(g=>[g.folderKey,g]));return a?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ke,{className:"h-4 w-4 text-ink-3"}),(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),m?(0,e.jsx)("div",{className:"rounded-md border border-bad/20 bg-bad/10 px-3 py-2 text-sm text-bad",children:m.message||"Failed to load local folder settings."}):null,l?(0,e.jsxs)("div",{className:"flex items-center gap-2 py-3 text-sm text-ink-3",children:[(0,e.jsx)(M,{className:"h-4 w-4 animate-spin"}),"Loading local folders..."]}):(0,e.jsx)("div",{className:"space-y-3",children:n.map(g=>(0,e.jsx)(Re,{pluginId:s,companyId:a,declaration:g,status:f.get(g.folderKey)},g.folderKey))})]}):(0,e.jsx)("div",{className:"rounded-md border border-line/60 bg-bg-3/20 px-4 py-3 text-sm text-ink-3",children:"Select an organization to configure this plugin's local folders."})}c(_e,"PluginLocalFoldersSettings");function Re({pluginId:s,companyId:a,declaration:n,status:r}){const l=ne(),m=r?.path??"",[f,g]=(0,h.useState)(m),[i,j]=(0,h.useState)(null);(0,h.useEffect)(()=>{g(m),j(null)},[m,n.folderKey]);const u=W({mutationFn:c(d=>k.configureLocalFolder(s,a,n.folderKey,{path:d,access:n.access,requiredDirectories:n.requiredDirectories,requiredFiles:n.requiredFiles}),"mutationFn"),onSuccess:c(d=>{j({type:d.healthy?"success":"error",text:d.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),l.invalidateQueries({queryKey:w.plugins.localFolders(s,a)})},"onSuccess"),onError:c(d=>{j({type:"error",text:d.message||"Failed to save local folder."})},"onError")}),v=f.trim(),o=v!==m,b=r?.access??n.access??"readWrite",N=(0,h.useCallback)(()=>{if(!v){j({type:"error",text:"Local folder path is required."});return}if(!Ae(v)){j({type:"error",text:"Local folder must be a full absolute path."});return}j(null),u.mutate(v)},[u,v]);return(0,e.jsxs)("div",{className:"space-y-4 rounded-md border border-line/70 bg-bg px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("h4",{className:"text-sm font-medium",children:n.displayName}),(0,e.jsx)(p,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:n.folderKey}),(0,e.jsx)(p,{variant:r?.healthy?"default":"secondary",children:r?.healthy?"Healthy":"Needs attention"})]}),n.description?(0,e.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-ink-3",children:n.description}):null]}),(0,e.jsx)(p,{variant:b==="readWrite"?"default":"outline",children:b==="readWrite"?"Read/write":"Read only"})]}),(0,e.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,e.jsx)(z,{label:"Configured",value:r?.configured?"Yes":"No",ok:!!r?.configured}),(0,e.jsx)(z,{label:"Readable",value:r?.readable?"Yes":"No",ok:!!r?.readable}),(0,e.jsx)(z,{label:"Writable",value:b==="read"?"Not requested":r?.writable?"Yes":"No",ok:b==="read"||!!r?.writable})]}),r?.path?(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-ink-3",children:"Configured path"}),(0,e.jsx)("div",{className:"break-all rounded-md bg-bg-3/60 px-2 py-1.5 font-mono text-xs text-ink",children:r.path})]}):null,(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-ink-3",htmlFor:`local-folder-${n.folderKey}`,children:"Local folder path"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("input",{id:`local-folder-${n.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-line bg-bg px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink/40 focus:ring-2 focus:ring-focus/20",value:f,onChange:c(d=>{g(d.target.value),j(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,e.jsx)(je,{className:"h-8"}),(0,e.jsxs)($,{size:"sm",onClick:N,disabled:u.isPending||!o||!a,children:[u.isPending?(0,e.jsx)(M,{className:"h-3.5 w-3.5 animate-spin"}):(0,e.jsx)(we,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,e.jsx)(Te,{status:r,declaration:n}),r?.problems?.length?(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-bad/20 bg-bad/10 px-3 py-2 text-sm text-bad",children:[(0,e.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,e.jsx)("ul",{className:"space-y-1",children:r.problems.map((d,y)=>(0,e.jsxs)("li",{children:[d.message,d.path?(0,e.jsxs)("span",{className:"font-mono",children:[" ",d.path]}):null]},`${d.code}:${d.path??""}:${y}`))})]}):null,i?(0,e.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${i.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-bad/20 bg-bad/10 text-bad"}`,children:i.text}):null]})}c(Re,"PluginLocalFolderRow");function z({label:s,value:a,ok:n}){return(0,e.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-line/60 px-2.5 py-2",children:[(0,e.jsx)("span",{className:"text-ink-3",children:s}),(0,e.jsx)(p,{variant:n?"default":"secondary",children:a})]})}c(z,"FolderStatusMetric");function Te({status:s,declaration:a}){const n=s?.requiredDirectories??a.requiredDirectories??[],r=s?.requiredFiles??a.requiredFiles??[],l=s?.missingDirectories??n,m=s?.missingFiles??r,f=Ee(s);return n.length===0&&r.length===0?null:(0,e.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,e.jsx)(I,{title:"Required directories",items:n,missingItems:l,missingLabel:"Missing directories",inspectionUnavailable:f}),(0,e.jsx)(I,{title:"Required files",items:r,missingItems:m,missingLabel:"Missing files",inspectionUnavailable:f})]})}c(Te,"FolderRequirements");function Ee(s){return!s?.configured||s.readable?!1:s.problems.some(a=>a.code==="missing"||a.code==="not_readable"||a.code==="not_directory")}c(Ee,"isRootNotInspected");function I({title:s,items:a,missingItems:n,missingLabel:r,inspectionUnavailable:l}){return(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-line/60 px-3 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:s}),l?(0,e.jsx)(p,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):n.length>0?(0,e.jsxs)(p,{variant:"destructive",className:"text-(length:--text-nano)",children:[n.length," missing"]}):(0,e.jsx)(p,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),a.length>0?(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(m=>{const f=n.includes(m);return(0,e.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${l?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":f?"border-bad/30 bg-bad/10 text-bad":"border-line bg-bg-3/50 text-ink/80"}`,children:m},m)})}):(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"None declared."}),l?(0,e.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):n.length>0?(0,e.jsxs)("p",{className:"text-xs text-bad",children:[r,": ",n.join(", ")]}):null]})}c(I,"RequirementList");function Ae(s){return s.startsWith("/")||/^[A-Za-z]:[\\/]/.test(s)||s.startsWith("\\\\")}c(Ae,"isLikelyAbsolutePath");function Je({pluginId:s,companyId:a,schema:n,initialValues:r,isLoading:l,pluginStatus:m,supportsConfigTest:f}){const g=ne(),[i,j]=(0,h.useState)(()=>({...R(n),...r??{}})),u=(0,h.useRef)(!1);(0,h.useEffect)(()=>{u.current=!1,j(R(n))},[a,s,n]),(0,h.useEffect)(()=>{r&&!u.current&&(u.current=!0,j({...R(n),...r}))},[r,n]);const[v,o]=(0,h.useState)({}),[b,N]=(0,h.useState)(null),[d,y]=(0,h.useState)(null),T=JSON.stringify(i)!==JSON.stringify({...R(n),...r??{}}),C=W({mutationFn:c(x=>{if(!a)throw new Error("Select an organization before saving plugin configuration.");return k.saveConfig(s,a,x)},"mutationFn"),onSuccess:c(()=>{N({type:"success",text:"Configuration saved."}),y(null),a&&g.invalidateQueries({queryKey:w.plugins.config(s,a)}),setTimeout(()=>N(null),3e3)},"onSuccess"),onError:c(x=>{N({type:"error",text:x.message||"Failed to save configuration."})},"onError")}),S=W({mutationFn:c(x=>{if(!a)throw new Error("Select an organization before testing plugin configuration.");return k.testConfig(s,a,x)},"mutationFn"),onSuccess:c(x=>{x.valid?y({type:"success",text:"Configuration test passed."}):y({type:"error",text:x.message||"Configuration test failed."})},"onSuccess"),onError:c(x=>{y({type:"error",text:x.message||"Configuration test failed."})},"onError")}),K=(0,h.useCallback)(x=>{j(x),o({}),N(null)},[]),E=(0,h.useCallback)(()=>{const x=X(n,i);if(Object.keys(x).length>0){o(x);return}o({}),C.mutate(i)},[n,i,C]),_=(0,h.useCallback)(()=>{const x=X(n,i);if(Object.keys(x).length>0){o(x);return}o({}),y(null),S.mutate(i)},[n,i,S]);return l?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3 py-4",children:[(0,e.jsx)(M,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(Pe,{schema:n,values:i,onChange:K,errors:v,disabled:C.isPending}),b&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${b.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-bad bg-bad/10 border-bad/20"}`,children:b.text}),d&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${d.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-bad bg-bad/10 border-bad/20"}`,children:d.text}),(0,e.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,e.jsx)($,{onClick:E,disabled:C.isPending||!T,size:"sm",children:C.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(M,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),m==="ready"&&f&&(0,e.jsx)($,{variant:"secondary",onClick:_,disabled:S.isPending||!a,size:"sm",children:S.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(M,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}c(Je,"PluginConfigForm");function ze(s){if(s==null)return"—";const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const n=Math.floor(a/60);if(n<60)return`${n}m ${a%60}s`;const r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}c(ze,"formatUptime");function ee(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}m`}c(ee,"formatDuration");function se(s){const a=Date.now()-new Date(s).getTime();if(a<0)return"just now";const n=Math.floor(a/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const l=Math.floor(r/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}c(se,"formatRelativeTime");function We(s){return new Date(s).toLocaleString()}c(We,"formatTimestamp");function Oe({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="success"||s==="succeeded"?"bg-green-500":s==="failed"?"bg-red-500":s==="running"?"bg-blue-500 animate-pulse":s==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:s})}c(Oe,"JobStatusDot");function Be({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="processed"||s==="success"?"bg-green-500":s==="failed"?"bg-red-500":s==="received"?"bg-blue-500":"bg-amber-500"}`,title:s})}c(Be,"DeliveryStatusDot");export{Ns as PluginSettings};
|
|
1
|
+
var de=Object.defineProperty;var c=(s,a)=>de(s,"name",{value:a,configurable:!0});import{i as te}from"./rolldown-runtime-ZpX3ckPj.js";import{na as xe,t as ae,ta as me}from"./createLucideIcon-DJi9suAC.js";import{v as he}from"./star-BZgQbzhV.js";import{X as ne,_ as W,t as w,v as q}from"./queryKeys-DYV5MhM_.js";import{n as ue}from"./CompanyContext-CSrVsSze.js";import{Z as ge,r as pe,t as V}from"./router-2UfGeejU.js";import{n as Y,t as fe}from"./tabs-B2Os_leL.js";import{t as je}from"./PathInstructionsModal-D4GUYKIT.js";import{t as be}from"./arrow-left-Ce_LIut0.js";import{t as Ne}from"./calendar-clock-BVFltraz.js";import{t as ve}from"./circle-x-CFlSbYzD.js";import{t as ye}from"./clock-CzrJT_cP.js";import{n as U}from"./package-CYC5MDhY.js";import{t as ke}from"./folder-open-8WDYv4mw.js";import{r as M,t as $}from"./button-CMwV3L1P.js";import{t as we}from"./save-CJ1Iqyew.js";import{t as Ce}from"./shield-alert-Be9GuMrS.js";import{t as Se}from"./triangle-alert-CBVKiaXB.js";import{t as qe}from"./webhook-BVBCKjlU.js";import{t as p}from"./badge-DuA2EgZC.js";import{t as k}from"./plugins-CF2QITJB.js";import{o as Fe,t as Le}from"./slots-Dw517dxP.js";import{n as De}from"./BreadcrumbContext-BVZDZoC0.js";import{n as R,r as X,t as Pe}from"./JsonSchemaForm-ixDd6e-N.js";import{i as Z,o as F,r as L,s as D,t as P}from"./card-Bru3x_SJ.js";import{Kr as Me}from"./index-3AxqhPET.js";import{t as J}from"./separator-B2LFqBpM.js";import{t as $e}from"./useManagedSandboxOnly-CO01cDK4.js";var ie={name:"circle-check-big",size:24,node:[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-circle"]};ie.node;var Ke=ae(ie),re={name:"square-activity",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]],aliases:["activity-square"]};re.node;var G=ae(re),h=te(xe(),1),e=te(me(),1);function Ns(){const{selectedCompany:s,selectedCompanyId:a}=ue(),{setBreadcrumbs:n}=De(),{companyPrefix:r,pluginId:l}=he(),{hideHostPaths:m}=$e(),[f,g]=(0,h.useState)("configuration"),{data:i,isLoading:j}=q({queryKey:w.plugins.detail(l),queryFn:c(()=>k.get(l),"queryFn"),enabled:!!l}),{data:u,isLoading:v}=q({queryKey:w.plugins.health(l),queryFn:c(()=>k.health(l),"queryFn"),enabled:!!l&&i?.status==="ready",refetchInterval:3e4}),{data:o}=q({queryKey:w.plugins.dashboard(l),queryFn:c(()=>k.dashboard(l),"queryFn"),enabled:!!l,refetchInterval:3e4}),{data:b}=q({queryKey:w.plugins.logs(l),queryFn:c(()=>k.logs(l,{limit:50}),"queryFn"),enabled:!!l&&i?.status==="ready",refetchInterval:3e4}),N=i?.manifestJson?.instanceConfigSchema,d=N&&N.properties&&Object.keys(N.properties).length>0,y=l&&a?w.plugins.config(l,a):["plugins",l??"__missing_plugin__","companies","__missing_company__","config"],{data:T,isLoading:C}=q({queryKey:y,queryFn:c(()=>k.getConfig(l,a),"queryFn"),enabled:!!l&&!!d&&!!a}),{slots:S}=Fe({slotTypes:["settingsPage"],companyId:a,enabled:!!a}),K=S.filter(t=>t.pluginId===l),E=K.length>0;if((0,h.useEffect)(()=>{n([{label:s?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins",href:"/company/settings/instance/plugins"},{label:i?.manifestJson?.displayName??i?.packageName??"Plugin Details"}])},[s?.name,n,r,i]),(0,h.useEffect)(()=>{g("configuration")},[l]),j)return(0,e.jsx)("div",{className:"p-4 text-sm text-ink-3",children:"Loading plugin details..."});if(!i)return(0,e.jsx)(pe,{to:"/company/settings/instance/plugins",replace:!0});const _=i.status,x=i.status==="ready"?"default":i.status==="error"?"destructive":"secondary",le=i.manifestJson.description||"No description provided.",O=i.manifestJson.capabilities??[],B=i.manifestJson.environmentDrivers??[],H=i.manifestJson.localFolders??[],Q=H.length>0&&!m,ce=B.map(t=>t.displayName?.trim()||t.driverKey).filter((t,A,oe)=>oe.indexOf(t)===A).join(", ");return(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)(V,{to:"/company/settings/instance/plugins",children:(0,e.jsx)($,{variant:"secondary",size:"icon",className:"h-8 w-8",children:(0,e.jsx)(be,{className:"h-4 w-4"})})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ge,{className:"h-6 w-6 text-ink-3"}),(0,e.jsx)("h1",{className:"text-xl font-semibold",children:i.manifestJson.displayName??i.packageName}),(0,e.jsx)(p,{variant:x,className:"ml-2",children:_}),(0,e.jsxs)(p,{variant:"outline",className:"ml-1",children:["v",i.manifestJson.version??i.version]})]})]}),(0,e.jsxs)(fe,{value:f,onValueChange:c(t=>g(t),"onValueChange"),className:"space-y-6",children:[(0,e.jsx)(Me,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:f,onValueChange:c(t=>g(t),"onValueChange")}),(0,e.jsx)(Y,{value:"configuration",className:"space-y-6",children:(0,e.jsxs)("div",{className:"space-y-8",children:[(0,e.jsxs)("section",{className:"space-y-5",children:[(0,e.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,e.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink-3",children:"Description"}),(0,e.jsx)("p",{className:"text-sm leading-6 text-ink/90",children:le})]}),(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h3",{className:"font-medium text-ink-3",children:"Author"}),(0,e.jsx)("p",{className:"text-ink",children:i.manifestJson.author})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"font-medium text-ink-3",children:"Categories"}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:i.categories.length>0?i.categories.map(t=>(0,e.jsx)(p,{variant:"outline",className:"capitalize",children:t},t)):(0,e.jsx)("span",{className:"text-ink",children:"None"})})]})]})]})]}),(0,e.jsx)(J,{}),(0,e.jsxs)("section",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"space-y-1",children:(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),Q?(0,e.jsx)(_e,{pluginId:l,companyId:a,declarations:H}):null,E?(0,e.jsx)("div",{className:"space-y-3",children:K.map(t=>(0,e.jsx)(Le,{slot:t,context:{companyId:a,companyPrefix:r??null},missingBehavior:"placeholder"},`${t.pluginKey}:${t.id}`))}):d?(0,e.jsx)(Je,{pluginId:l,companyId:a,schema:N,initialValues:T?.configJson,isLoading:C,pluginStatus:i.status,supportsConfigTest:i.supportsConfigTest===!0}):B.length>0?(0,e.jsxs)("div",{className:"rounded-md border border-line/60 bg-bg-3/20 px-4 py-3 text-sm",children:[(0,e.jsx)("p",{className:"font-medium text-ink",children:"Configure this plugin from Settings → Environments."}),(0,e.jsxs)("p",{className:"mt-1 text-ink-3",children:[ce||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,e.jsx)("div",{className:"mt-3",children:(0,e.jsx)(V,{to:"/company/settings/instance/environments",children:(0,e.jsx)($,{variant:"secondary",size:"sm",children:"Open Environments"})})})]}):Q?null:(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"This plugin does not require any settings."})]})]})}),(0,e.jsx)(Y,{value:"status",className:"space-y-6",children:(0,e.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsxs)(F,{children:[(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(U,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,e.jsx)(Z,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,e.jsx)(L,{className:"space-y-6",children:o?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(U,{className:"h-3.5 w-3.5 text-ink-3"}),"Worker Process"]}),o.worker?(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Status"}),(0,e.jsx)(p,{variant:o.worker.status==="running"?"default":"secondary",children:o.worker.status})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"PID"}),(0,e.jsx)("span",{className:"font-mono text-xs",children:o.worker.pid??"—"})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Uptime"}),(0,e.jsx)("span",{className:"text-xs",children:ze(o.worker.uptime)})]}),(0,e.jsxs)("div",{className:"flex justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Pending RPCs"}),(0,e.jsx)("span",{className:"text-xs",children:o.worker.pendingRequests})]}),o.worker.totalCrashes>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsxs)("span",{className:"text-ink-3 flex items-center gap-1",children:[(0,e.jsx)(Se,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,e.jsxs)("span",{className:"text-xs",children:[o.worker.consecutiveCrashes," consecutive / ",o.worker.totalCrashes," total"]})]}),o.worker.lastCrashAt&&(0,e.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Last Crash"}),(0,e.jsx)("span",{className:"text-xs",children:We(o.worker.lastCrashAt)})]})]})]}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No worker process registered."})]}),(0,e.jsx)(J,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(Ne,{className:"h-3.5 w-3.5 text-ink-3"}),"Recent Job Runs"]}),o.recentJobRuns.length>0?(0,e.jsx)("div",{className:"space-y-2",children:o.recentJobRuns.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-bg-3/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Oe,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.jobKey??t.jobId,children:t.jobKey??t.jobId.slice(0,8)}),(0,e.jsx)(p,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:t.trigger})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-ink-3",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ee(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:se(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No job runs recorded yet."})]}),(0,e.jsx)(J,{}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,e.jsx)(qe,{className:"h-3.5 w-3.5 text-ink-3"}),"Recent Webhook Deliveries"]}),o.recentWebhookDeliveries.length>0?(0,e.jsx)("div",{className:"space-y-2",children:o.recentWebhookDeliveries.map(t=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-bg-3/50 px-2 py-1.5 text-sm",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)(Be,{status:t.status}),(0,e.jsx)("span",{className:"truncate font-mono text-xs",title:t.webhookKey,children:t.webhookKey})]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-ink-3",children:[t.durationMs!=null?(0,e.jsx)("span",{children:ee(t.durationMs)}):null,(0,e.jsx)("span",{title:t.createdAt,children:se(t.createdAt)})]})]},t.id))}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No webhook deliveries recorded yet."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-line/50 pt-2 text-xs text-ink-3",children:[(0,e.jsx)(ye,{className:"h-3 w-3"}),"Last checked: ",new Date(o.checkedAt).toLocaleTimeString()]})]}):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Runtime diagnostics are unavailable right now."})})]}),b&&b.length>0?(0,e.jsxs)(P,{children:[(0,e.jsxs)(F,{children:[(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(G,{className:"h-4 w-4"}),"Recent Logs"]}),(0,e.jsxs)(Z,{children:["Last ",b.length," log entries"]})]}),(0,e.jsx)(L,{children:(0,e.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:b.map(t=>(0,e.jsxs)("div",{className:`flex gap-2 py-0.5 ${t.level==="error"?"text-bad":t.level==="warn"?"text-yellow-600 dark:text-yellow-400":t.level==="debug"?"text-ink-3/60":"text-ink-3"}`,children:[(0,e.jsx)("span",{className:"shrink-0 text-ink-3/50",children:new Date(t.createdAt).toLocaleTimeString()}),(0,e.jsx)(p,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:t.level}),(0,e.jsx)("span",{className:"truncate",title:t.message,children:t.message})]},t.id))})})]}):null]}),(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)(P,{children:[(0,e.jsx)(F,{children:(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(G,{className:"h-4 w-4"}),"Health Status"]})}),(0,e.jsx)(L,{children:v?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Checking health..."}):u?(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-ink-3",children:"Overall"}),(0,e.jsx)(p,{variant:u.healthy?"default":"destructive",children:u.status})]}),u.checks.length>0?(0,e.jsx)("div",{className:"space-y-2 border-t border-line/50 pt-2",children:u.checks.map((t,A)=>(0,e.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,e.jsx)("span",{className:"truncate text-ink-3",title:t.name,children:t.name}),t.passed?(0,e.jsx)(Ke,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,e.jsx)(ve,{className:"h-4 w-4 shrink-0 text-bad"})]},A))}):null,u.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-bad/20 bg-bad/10 p-2 text-xs text-bad",children:u.lastError}):null]}):(0,e.jsxs)("div",{className:"space-y-3 text-sm text-ink-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("span",{children:"Lifecycle"}),(0,e.jsx)(p,{variant:x,children:_})]}),(0,e.jsx)("p",{children:"Health checks run once the plugin is ready."}),i.lastError?(0,e.jsx)("div",{className:"break-words rounded border border-bad/20 bg-bad/10 p-2 text-xs text-bad",children:i.lastError}):null]})})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)(F,{children:(0,e.jsx)(D,{className:"text-base",children:"Details"})}),(0,e.jsxs)(L,{className:"space-y-3 text-sm text-ink-3",children:[(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin ID"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:i.id})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Plugin Key"}),(0,e.jsx)("span",{className:"font-mono text-xs text-right",children:i.pluginKey})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"NPM Package"}),(0,e.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:i.packageName,children:i.packageName})]}),(0,e.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,e.jsx)("span",{children:"Version"}),(0,e.jsxs)("span",{className:"text-right text-ink",children:["v",i.manifestJson.version??i.version]})]})]})]}),(0,e.jsxs)(P,{children:[(0,e.jsx)(F,{children:(0,e.jsxs)(D,{className:"text-base flex items-center gap-1.5",children:[(0,e.jsx)(Ce,{className:"h-4 w-4"}),"Permissions"]})}),(0,e.jsx)(L,{children:O.length>0?(0,e.jsx)("ul",{className:"space-y-2 text-sm text-ink-3",children:O.map(t=>(0,e.jsx)("li",{className:"rounded-md bg-bg-3/40 px-2.5 py-2 font-mono text-xs text-ink/85",children:t},t))}):(0,e.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No special permissions requested."})})]})]})]})})]})]})}c(Ns,"PluginSettings");function _e({pluginId:s,companyId:a,declarations:n}){const{data:r,isLoading:l,error:m}=q({queryKey:a?w.plugins.localFolders(s,a):["plugins",s,"companies","none","local-folders"],queryFn:c(()=>k.listLocalFolders(s,a),"queryFn"),enabled:!!a}),f=new Map((r?.folders??[]).map(g=>[g.folderKey,g]));return a?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(ke,{className:"h-4 w-4 text-ink-3"}),(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),m?(0,e.jsx)("div",{className:"rounded-md border border-bad/20 bg-bad/10 px-3 py-2 text-sm text-bad",children:m.message||"Failed to load local folder settings."}):null,l?(0,e.jsxs)("div",{className:"flex items-center gap-2 py-3 text-sm text-ink-3",children:[(0,e.jsx)(M,{className:"h-4 w-4 animate-spin"}),"Loading local folders..."]}):(0,e.jsx)("div",{className:"space-y-3",children:n.map(g=>(0,e.jsx)(Re,{pluginId:s,companyId:a,declaration:g,status:f.get(g.folderKey)},g.folderKey))})]}):(0,e.jsx)("div",{className:"rounded-md border border-line/60 bg-bg-3/20 px-4 py-3 text-sm text-ink-3",children:"Select an organization to configure this plugin's local folders."})}c(_e,"PluginLocalFoldersSettings");function Re({pluginId:s,companyId:a,declaration:n,status:r}){const l=ne(),m=r?.path??"",[f,g]=(0,h.useState)(m),[i,j]=(0,h.useState)(null);(0,h.useEffect)(()=>{g(m),j(null)},[m,n.folderKey]);const u=W({mutationFn:c(d=>k.configureLocalFolder(s,a,n.folderKey,{path:d,access:n.access,requiredDirectories:n.requiredDirectories,requiredFiles:n.requiredFiles}),"mutationFn"),onSuccess:c(d=>{j({type:d.healthy?"success":"error",text:d.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),l.invalidateQueries({queryKey:w.plugins.localFolders(s,a)})},"onSuccess"),onError:c(d=>{j({type:"error",text:d.message||"Failed to save local folder."})},"onError")}),v=f.trim(),o=v!==m,b=r?.access??n.access??"readWrite",N=(0,h.useCallback)(()=>{if(!v){j({type:"error",text:"Local folder path is required."});return}if(!Ae(v)){j({type:"error",text:"Local folder must be a full absolute path."});return}j(null),u.mutate(v)},[u,v]);return(0,e.jsxs)("div",{className:"space-y-4 rounded-md border border-line/70 bg-bg px-4 py-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("h4",{className:"text-sm font-medium",children:n.displayName}),(0,e.jsx)(p,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:n.folderKey}),(0,e.jsx)(p,{variant:r?.healthy?"default":"secondary",children:r?.healthy?"Healthy":"Needs attention"})]}),n.description?(0,e.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-ink-3",children:n.description}):null]}),(0,e.jsx)(p,{variant:b==="readWrite"?"default":"outline",children:b==="readWrite"?"Read/write":"Read only"})]}),(0,e.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,e.jsx)(z,{label:"Configured",value:r?.configured?"Yes":"No",ok:!!r?.configured}),(0,e.jsx)(z,{label:"Readable",value:r?.readable?"Yes":"No",ok:!!r?.readable}),(0,e.jsx)(z,{label:"Writable",value:b==="read"?"Not requested":r?.writable?"Yes":"No",ok:b==="read"||!!r?.writable})]}),r?.path?(0,e.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-ink-3",children:"Configured path"}),(0,e.jsx)("div",{className:"break-all rounded-md bg-bg-3/60 px-2 py-1.5 font-mono text-xs text-ink",children:r.path})]}):null,(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium text-ink-3",htmlFor:`local-folder-${n.folderKey}`,children:"Local folder path"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("input",{id:`local-folder-${n.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-line bg-bg px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink/40 focus:ring-2 focus:ring-focus/20",value:f,onChange:c(d=>{g(d.target.value),j(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,e.jsx)(je,{className:"h-8"}),(0,e.jsxs)($,{size:"sm",onClick:N,disabled:u.isPending||!o||!a,children:[u.isPending?(0,e.jsx)(M,{className:"h-3.5 w-3.5 animate-spin"}):(0,e.jsx)(we,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,e.jsx)(Te,{status:r,declaration:n}),r?.problems?.length?(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-bad/20 bg-bad/10 px-3 py-2 text-sm text-bad",children:[(0,e.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,e.jsx)("ul",{className:"space-y-1",children:r.problems.map((d,y)=>(0,e.jsxs)("li",{children:[d.message,d.path?(0,e.jsxs)("span",{className:"font-mono",children:[" ",d.path]}):null]},`${d.code}:${d.path??""}:${y}`))})]}):null,i?(0,e.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${i.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-bad/20 bg-bad/10 text-bad"}`,children:i.text}):null]})}c(Re,"PluginLocalFolderRow");function z({label:s,value:a,ok:n}){return(0,e.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-line/60 px-2.5 py-2",children:[(0,e.jsx)("span",{className:"text-ink-3",children:s}),(0,e.jsx)(p,{variant:n?"default":"secondary",children:a})]})}c(z,"FolderStatusMetric");function Te({status:s,declaration:a}){const n=s?.requiredDirectories??a.requiredDirectories??[],r=s?.requiredFiles??a.requiredFiles??[],l=s?.missingDirectories??n,m=s?.missingFiles??r,f=Ee(s);return n.length===0&&r.length===0?null:(0,e.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,e.jsx)(I,{title:"Required directories",items:n,missingItems:l,missingLabel:"Missing directories",inspectionUnavailable:f}),(0,e.jsx)(I,{title:"Required files",items:r,missingItems:m,missingLabel:"Missing files",inspectionUnavailable:f})]})}c(Te,"FolderRequirements");function Ee(s){return!s?.configured||s.readable?!1:s.problems.some(a=>a.code==="missing"||a.code==="not_readable"||a.code==="not_directory")}c(Ee,"isRootNotInspected");function I({title:s,items:a,missingItems:n,missingLabel:r,inspectionUnavailable:l}){return(0,e.jsxs)("div",{className:"space-y-2 rounded-md border border-line/60 px-3 py-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-ink-3",children:s}),l?(0,e.jsx)(p,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):n.length>0?(0,e.jsxs)(p,{variant:"destructive",className:"text-(length:--text-nano)",children:[n.length," missing"]}):(0,e.jsx)(p,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),a.length>0?(0,e.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.map(m=>{const f=n.includes(m);return(0,e.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${l?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":f?"border-bad/30 bg-bad/10 text-bad":"border-line bg-bg-3/50 text-ink/80"}`,children:m},m)})}):(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"None declared."}),l?(0,e.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):n.length>0?(0,e.jsxs)("p",{className:"text-xs text-bad",children:[r,": ",n.join(", ")]}):null]})}c(I,"RequirementList");function Ae(s){return s.startsWith("/")||/^[A-Za-z]:[\\/]/.test(s)||s.startsWith("\\\\")}c(Ae,"isLikelyAbsolutePath");function Je({pluginId:s,companyId:a,schema:n,initialValues:r,isLoading:l,pluginStatus:m,supportsConfigTest:f}){const g=ne(),[i,j]=(0,h.useState)(()=>({...R(n),...r??{}})),u=(0,h.useRef)(!1);(0,h.useEffect)(()=>{u.current=!1,j(R(n))},[a,s,n]),(0,h.useEffect)(()=>{r&&!u.current&&(u.current=!0,j({...R(n),...r}))},[r,n]);const[v,o]=(0,h.useState)({}),[b,N]=(0,h.useState)(null),[d,y]=(0,h.useState)(null),T=JSON.stringify(i)!==JSON.stringify({...R(n),...r??{}}),C=W({mutationFn:c(x=>{if(!a)throw new Error("Select an organization before saving plugin configuration.");return k.saveConfig(s,a,x)},"mutationFn"),onSuccess:c(()=>{N({type:"success",text:"Configuration saved."}),y(null),a&&g.invalidateQueries({queryKey:w.plugins.config(s,a)}),setTimeout(()=>N(null),3e3)},"onSuccess"),onError:c(x=>{N({type:"error",text:x.message||"Failed to save configuration."})},"onError")}),S=W({mutationFn:c(x=>{if(!a)throw new Error("Select an organization before testing plugin configuration.");return k.testConfig(s,a,x)},"mutationFn"),onSuccess:c(x=>{x.valid?y({type:"success",text:"Configuration test passed."}):y({type:"error",text:x.message||"Configuration test failed."})},"onSuccess"),onError:c(x=>{y({type:"error",text:x.message||"Configuration test failed."})},"onError")}),K=(0,h.useCallback)(x=>{j(x),o({}),N(null)},[]),E=(0,h.useCallback)(()=>{const x=X(n,i);if(Object.keys(x).length>0){o(x);return}o({}),C.mutate(i)},[n,i,C]),_=(0,h.useCallback)(()=>{const x=X(n,i);if(Object.keys(x).length>0){o(x);return}o({}),y(null),S.mutate(i)},[n,i,S]);return l?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3 py-4",children:[(0,e.jsx)(M,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(Pe,{schema:n,values:i,onChange:K,errors:v,disabled:C.isPending}),b&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${b.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-bad bg-bad/10 border-bad/20"}`,children:b.text}),d&&(0,e.jsx)("div",{className:`text-sm p-2 rounded border ${d.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-bad bg-bad/10 border-bad/20"}`,children:d.text}),(0,e.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,e.jsx)($,{onClick:E,disabled:C.isPending||!T,size:"sm",children:C.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(M,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),m==="ready"&&f&&(0,e.jsx)($,{variant:"secondary",onClick:_,disabled:S.isPending||!a,size:"sm",children:S.isPending?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(M,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}c(Je,"PluginConfigForm");function ze(s){if(s==null)return"—";const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const n=Math.floor(a/60);if(n<60)return`${n}m ${a%60}s`;const r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}c(ze,"formatUptime");function ee(s){return s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}m`}c(ee,"formatDuration");function se(s){const a=Date.now()-new Date(s).getTime();if(a<0)return"just now";const n=Math.floor(a/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const l=Math.floor(r/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}c(se,"formatRelativeTime");function We(s){return new Date(s).toLocaleString()}c(We,"formatTimestamp");function Oe({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="success"||s==="succeeded"?"bg-green-500":s==="failed"?"bg-red-500":s==="running"?"bg-blue-500 animate-pulse":s==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:s})}c(Oe,"JobStatusDot");function Be({status:s}){return(0,e.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${s==="processed"||s==="success"?"bg-green-500":s==="failed"?"bg-red-500":s==="received"?"bg-blue-500":"bg-amber-500"}`,title:s})}c(Be,"DeliveryStatusDot");export{Ns as PluginSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var le=Object.defineProperty;var t=(s,a)=>le(s,"name",{value:a,configurable:!0});import{i as V}from"./rolldown-runtime-ZpX3ckPj.js";import{b as Y,l as ee,na as oe,t as ce,ta as de}from"./createLucideIcon-DJi9suAC.js";import{v as me,y as pe}from"./star-BZgQbzhV.js";import{X as ue,_ as D,t as E,v as xe}from"./queryKeys-DYV5MhM_.js";import{n as he}from"./CompanyContext-CSrVsSze.js";import{o as fe}from"./router-2UfGeejU.js";import{t as $}from"./label-BPz3pg9_.js";import{t as ge}from"./archive-restore-DeLPtKS0.js";import{t as je}from"./copy-_wvZOjTe.js";import{t as u}from"./button-CMwV3L1P.js";import{t as ve}from"./shield-check-B0HVjzM_.js";import{t as ye}from"./trash-D7zTaHTj.js";import{t as be}from"./user-minus-B4F-9ccK.js";import{t as se}from"./badge-DuA2EgZC.js";import{i as Ne}from"./ToastContext-DMdt9oTd.js";import{a as z,i as F,n as K,r as O,s as q,t as U}from"./dialog-CKUblzlR.js";import{t as Q}from"./input-DobnTAyB.js";import{t as S}from"./tools-B-L_sU_9.js";import{n as ke}from"./BreadcrumbContext-BVZDZoC0.js";import{t as we}from"./textarea-BRPEfJ-g.js";import{Ea as Ce,Hr as Ae}from"./index-DDoARkPG.js";import{a as Te,i as te,r as ae,s as J}from"./shared-DDwmHbeD.js";import{a as Se,n as Ie,t as Pe}from"./profile-summary-unutni_7.js";import{t as De}from"./useProfilesData-2L3_71Ql.js";import{t as Ee}from"./ToolsAdminGate-BI5-WYC3.js";var ne={name:"plug-zap",size:24,node:[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],aliases:["plug-zap-2"]};ne.node;var Le=ce(ne),f=V(oe(),1),e=V(de(),1);function Re({companyId:s,profileId:a,initialCreated:n,initialReviewOpen:l}){const m=fe(),[x,v]=pe(),j=ue(),{pushToast:i}=Ne(),d=De(s),[o,h]=(0,f.useState)(null),[g,I]=(0,f.useState)(null),[L,A]=(0,f.useState)(!!l),[N,R]=(0,f.useState)({}),p=(d.profiles.data?.profiles??[]).find(r=>r.id===a)??null,M=n??x.get("created")==="1",k=p?.newToolsPendingCount??0,w=xe({queryKey:E.tools.profileNewTools(a),queryFn:t(()=>S.getProfileNewTools(a),"queryFn"),enabled:k>0}),C=t(()=>{j.invalidateQueries({queryKey:E.tools.profiles(s)}),j.invalidateQueries({queryKey:E.tools.testAgentAccesses()})},"invalidate"),b=t(r=>String(r?.message??r),"errorBody"),B=(0,f.useMemo)(()=>p?qe(p,d.catalog,d.maps.applicationsById,d.maps.connectionsById,d.connections.data?.connections??[]):[],[p,d.catalog,d.maps.applicationsById,d.maps.connectionsById,d.connections.data?.connections]),c=w.data?.tools??[];(0,f.useEffect)(()=>{x.get("review")==="new-tools"&&k>0&&A(!0)},[k,x]),(0,f.useEffect)(()=>{c.length!==0&&R(r=>{const P={...r};for(const _ of c)P[_.catalogEntryId]||(P[_.catalogEntryId]="keep_blocked");return P})},[c]);const T=D({mutationFn:t(r=>S.updateProfile(a,r),"mutationFn"),onSuccess:t(()=>{C(),i({title:"Profile updated",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not update profile",body:b(r),tone:"error"}),"onError")}),H=D({mutationFn:t(r=>S.duplicateProfile(a,r),"mutationFn"),onSuccess:t(r=>{C(),i({title:"Profile duplicated",body:"The copy is not assigned to anyone yet.",tone:"success"}),m(`/apps/advanced/profiles/${r.id}?created=1`)},"onSuccess"),onError:t(r=>i({title:"Could not duplicate",body:b(r),tone:"error"}),"onError")}),Z=D({mutationFn:t(()=>S.deleteProfile(a),"mutationFn"),onSuccess:t(()=>{C(),i({title:"Profile deleted",tone:"success"}),m("/apps/advanced/profiles")},"onSuccess"),onError:t(r=>i({title:"Could not delete",body:b(r),tone:"error"}),"onError")}),G=D({mutationFn:t(r=>S.unbindProfile(s,a,{targetType:r.targetType,targetId:r.targetId}),"mutationFn"),onSuccess:t(()=>{I(null),C(),i({title:"Assignment removed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not remove assignment",body:b(r),tone:"error"}),"onError")}),X=D({mutationFn:t(()=>S.reviewProfileNewTools(a,{decisions:c.map(r=>({catalogEntryId:r.catalogEntryId,decision:N[r.catalogEntryId]??"keep_blocked"}))}),"mutationFn"),onSuccess:t(()=>{A(!1),v({}),j.invalidateQueries({queryKey:E.tools.profiles(s)}),j.invalidateQueries({queryKey:E.tools.profileNewTools(a)}),i({title:"New tools reviewed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not submit review",body:b(r),tone:"error"}),"onError")});if(d.profiles.isLoading)return(0,e.jsx)(te,{label:"Loading profile..."});if(d.profiles.isError)return(0,e.jsx)(ae,{error:d.profiles.error,onRetry:t(()=>d.profiles.refetch(),"onRetry")});if(!p)return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(J,{title:"Profile not found",description:"This access profile may have been deleted."}),(0,e.jsx)(u,{variant:"secondary",onClick:t(()=>m("/apps/advanced/profiles"),"onClick"),children:"Back to profiles"})]});const y=p.status==="archived",re=p.summary.assignmentCount===0;return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)(J,{title:p.name,description:p.description??"No description yet.",actions:(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxs)(u,{variant:"secondary",disabled:y,onClick:t(()=>h("edit"),"onClick"),children:[(0,e.jsx)(Ce,{className:"mr-1.5 h-4 w-4"}),"Edit"]}),(0,e.jsxs)(u,{variant:"secondary",disabled:y,onClick:t(()=>h("duplicate"),"onClick"),children:[(0,e.jsx)(je,{className:"mr-1.5 h-4 w-4"}),"Duplicate"]}),y?(0,e.jsxs)(u,{variant:"secondary",onClick:t(()=>h("restore"),"onClick"),children:[(0,e.jsx)(ge,{className:"mr-1.5 h-4 w-4"}),"Restore"]}):(0,e.jsx)(u,{variant:"secondary",onClick:t(()=>h("archive"),"onClick"),children:"Archive"}),(0,e.jsxs)(u,{variant:"danger",onClick:t(()=>h("delete"),"onClick"),children:[(0,e.jsx)(ye,{className:"mr-1.5 h-4 w-4"}),"Delete"]})]})}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[(0,e.jsx)(se,{variant:y?"outline":"default",children:Pe[p.status]}),(0,e.jsxs)("span",{className:"text-ink-3",children:["Updated ",(0,e.jsx)(Te,{value:p.updatedAt})]}),(0,e.jsx)("span",{className:"text-ink-3",children:Ie(p.summary)})]}),M?(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-accent/30 bg-accent/5 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"Profile saved"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:re?"Assign it to agents before it changes their access.":"Assignments are active now."})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(u,{size:"sm",onClick:t(()=>m(`/apps/advanced/profiles/${p.id}/edit?step=3`),"onClick"),children:"Assign"}),(0,e.jsx)(u,{size:"sm",variant:"ghost",onClick:t(()=>v({}),"onClick"),children:"Dismiss"})]})]}):null,y?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile is archived. It does not apply to agents until it is restored."}):null,k>0?(0,e.jsx)(Be,{count:k,tools:c,loading:w.isLoading,onReview:t(()=>A(!0),"onReview")}):null,(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-ink",children:"What it allows"}),(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:y,onClick:t(()=>m(`/apps/advanced/profiles/${p.id}/edit?step=2`),"onClick"),children:"Edit tools"})]}),(0,e.jsx)($e,{rows:B,total:p.summary.totalToolCount})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-ink",children:"Who has it"}),(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:y,onClick:t(()=>m(`/apps/advanced/profiles/${p.id}/edit?step=3`),"onClick"),children:"Assign"})]}),(0,e.jsx)(ze,{profile:p,companyId:s,maps:d.maps,archived:y,onRemove:I})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-ink",children:"New tools that appear later"}),(0,e.jsx)(Fe,{value:p.defaultAction,disabled:y||T.isPending,onChange:t(r=>T.mutate({defaultAction:r}),"onChange")})]}),(0,e.jsxs)(u,{variant:"link",className:"h-auto px-0",onClick:t(()=>m("/apps/advanced/profiles?check=1"),"onClick"),children:[(0,e.jsx)(ve,{className:"mr-1.5 h-4 w-4"}),"Check what an agent can actually do"]}),(0,e.jsx)(Ke,{kind:o,profile:p,allProfiles:d.profiles.data?.profiles??[],pending:T.isPending||H.isPending||Z.isPending,onClose:t(()=>h(null),"onClose"),onUpdate:t(r=>T.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onUpdate"),onDuplicate:t(r=>H.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onDuplicate"),onArchive:t(()=>T.mutate({status:"archived"},{onSuccess:t(()=>h(null),"onSuccess")}),"onArchive"),onRestore:t(()=>T.mutate({status:"active"},{onSuccess:t(()=>h(null),"onSuccess")}),"onRestore"),onDelete:t(()=>Z.mutate(void 0,{onSuccess:t(()=>h(null),"onSuccess")}),"onDelete")}),(0,e.jsx)(Oe,{binding:g,label:g?ie(g,s,d.maps):"",pending:G.isPending,onClose:t(()=>I(null),"onClose"),onConfirm:t(()=>g&&G.mutate(g),"onConfirm")}),(0,e.jsx)(_e,{open:L,tools:c,loading:w.isLoading,error:w.error,decisions:N,pending:X.isPending,onClose:t(()=>A(!1),"onClose"),onRetry:t(()=>w.refetch(),"onRetry"),onDecision:t((r,P)=>R(_=>({..._,[r]:P})),"onDecision"),onSubmit:t(()=>X.mutate(),"onSubmit")})]})}t(Re,"ProfileDetail");function Be({count:s,tools:a,loading:n,onReview:l}){const m=We(a);return(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium",children:n?"New tools need review":`${m} added ${s} new ${s===1?"tool":"tools"} since your last review`}),(0,e.jsx)("p",{className:"text-amber-900/80",children:"Choose which ones this profile should allow."})]}),(0,e.jsx)(u,{size:"sm",onClick:l,children:"Review"})]})}t(Be,"NewToolsReviewBanner");function _e({open:s,tools:a,loading:n,error:l,decisions:m,pending:x,onClose:v,onRetry:j,onDecision:i,onSubmit:d}){return(0,e.jsx)(U,{open:s,onOpenChange:t(o=>!o&&v(),"onOpenChange"),children:(0,e.jsxs)(K,{className:"max-w-2xl",children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Review new tools"}),(0,e.jsx)(O,{children:"Allow the tools this profile should use. Keep the rest blocked."})]}),n?(0,e.jsx)(te,{label:"Loading new tools..."}):l?(0,e.jsx)(ae,{error:l,onRetry:j}):a.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-dashed border-line px-4 py-6 text-sm text-ink-3",children:"There are no new tools waiting for review."}):(0,e.jsx)("div",{className:"max-h-(--sz-52vh) divide-y divide-line overflow-y-auto rounded-lg border border-line",children:a.map(o=>(0,e.jsxs)("div",{className:"grid gap-3 px-3 py-3 sm:grid-cols-[1fr_auto]",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-ink",children:o.title||o.toolName}),(0,e.jsx)(se,{variant:"secondary",children:Qe(o)})]}),o.description?(0,e.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:o.description}):null,(0,e.jsxs)("p",{className:"mt-1 text-xs text-ink-3",children:[o.applicationName??o.connectionName??"App tool"," · added ",Y(o.addedAt)]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 sm:justify-end",children:[(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${o.catalogEntryId}`,checked:(m[o.catalogEntryId]??"keep_blocked")==="allow",onChange:t(()=>i(o.catalogEntryId,"allow"),"onChange")}),"Allow"]}),(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${o.catalogEntryId}`,checked:(m[o.catalogEntryId]??"keep_blocked")==="keep_blocked",onChange:t(()=>i(o.catalogEntryId,"keep_blocked"),"onChange")}),"Keep blocked"]})]})]},o.catalogEntryId))}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:v,children:"Cancel"}),(0,e.jsx)(u,{disabled:x||n||a.length===0,onClick:d,children:"Submit review"})]})]})})}t(_e,"NewToolsReviewDialog");function $e({rows:s,total:a}){return s.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile allows 0 tools. Agents with only this profile will not be able to use app tools."}):(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-line",children:[(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line bg-bg-3/40 text-left text-xs font-medium text-ink-3",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Tool"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"App"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Capabilities"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Source"})]})}),(0,e.jsx)("tbody",{children:s.slice(0,80).map(n=>(0,e.jsxs)("tr",{className:ee("border-b border-line last:border-0",n.degraded&&"bg-bg-3/30 text-ink-3"),children:[(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:n.tool}),n.degraded?(0,e.jsxs)("a",{className:"mt-0.5 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline",href:`/apps/${n.connectionId}`,children:[(0,e.jsx)(Le,{className:"h-3 w-3"}),"Reconnect"]}):null]})}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[(0,e.jsx)("span",{children:n.app}),n.degraded?(0,e.jsxs)("span",{className:"ml-2 text-xs text-ink-3",children:[n.app," is disconnected"]}):null]}),(0,e.jsx)("td",{className:"px-3 py-2 text-ink-3",children:n.capabilities}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[n.source.startsWith("added by rule")?(0,e.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-950",children:n.source}):(0,e.jsx)("span",{className:"text-ink-3",children:n.source}),n.autoAddedAt?(0,e.jsxs)("div",{className:"mt-0.5 text-xs text-ink-3",children:["added automatically · ",Y(n.autoAddedAt)]}):null]})]},n.id))})]}),s.length>80?(0,e.jsxs)("p",{className:"border-t border-line px-3 py-2 text-xs text-ink-3",children:["Showing 80 of ",s.length," allowed tools."]}):(0,e.jsxs)("p",{className:"border-t border-line px-3 py-2 text-xs text-ink-3",children:["Allows ",s.length," of ",a," known tools."]})]})}t($e,"AllowList");function ze({profile:s,companyId:a,maps:n,archived:l,onRemove:m}){return s.bindings.length===0?(0,e.jsxs)("div",{className:"rounded-lg border border-dashed border-line px-4 py-5",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"Not assigned yet"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Assign this profile before it changes access."})]}):(0,e.jsx)("div",{className:"divide-y divide-line overflow-hidden rounded-lg border border-line",children:s.bindings.map(x=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,e.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-bg-3 text-xs font-semibold text-ink-3",children:x.targetType==="company"?"Or":x.targetType.slice(0,2).toUpperCase()}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-ink",children:ie(x,a,n)}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:Ze(x.targetType)})]})]}),(0,e.jsxs)(u,{variant:"ghost",size:"sm",disabled:l,onClick:t(()=>m(x),"onClick"),children:[(0,e.jsx)(be,{className:"mr-1.5 h-4 w-4"}),"Remove"]})]},x.id))})}t(ze,"Assignments");function Fe({value:s,disabled:a,onChange:n}){return(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:[{value:"deny",title:"Stay blocked until reviewed",body:"New tools do not become available automatically."},{value:"allow",title:"Allowed automatically",body:"New tools from selected apps become available right away."}].map(l=>(0,e.jsxs)("label",{className:ee("flex cursor-pointer items-start gap-3 rounded-lg border px-4 py-3",s===l.value?"border-accent bg-accent/5":"border-line",a&&"cursor-not-allowed opacity-60"),children:[(0,e.jsx)("input",{type:"radio",className:"mt-1",disabled:a,checked:s===l.value,onChange:t(()=>n(l.value),"onChange")}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-ink",children:l.title}),(0,e.jsx)("span",{className:"block text-xs text-ink-3",children:l.body})]})]},l.value))})}t(Fe,"NewToolsSetting");function Ke({kind:s,profile:a,allProfiles:n,pending:l,onClose:m,onUpdate:x,onDuplicate:v,onArchive:j,onRestore:i,onDelete:d}){const[o,h]=(0,f.useState)(a.name),[g,I]=(0,f.useState)(a.description??""),[L,A]=(0,f.useState)(a.profileKey),[N,R]=(0,f.useState)(`${a.name} copy`),[p,M]=(0,f.useState)(!1),[k,w]=(0,f.useState)(!1),C=n.some(c=>c.id!==a.id&&c.name.trim().toLowerCase()===o.trim().toLowerCase()),b=n.some(c=>c.name.trim().toLowerCase()===N.trim().toLowerCase());if(!s)return null;const B=!!s;return s==="edit"?(0,e.jsx)(U,{open:B,onOpenChange:t(c=>!c&&m(),"onOpenChange"),children:(0,e.jsxs)(K,{children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Edit profile"}),(0,e.jsx)(O,{children:"Update the profile name and description."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"edit-profile-name",children:"Name"}),(0,e.jsx)(Q,{id:"edit-profile-name",value:o,onChange:t(c=>h(c.target.value),"onChange")}),C?(0,e.jsx)("p",{className:"text-xs text-bad",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"edit-profile-description",children:"Description"}),(0,e.jsx)(we,{id:"edit-profile-description",value:g,onChange:t(c=>I(c.target.value),"onChange"),rows:3})]}),(0,e.jsx)("button",{type:"button",className:"text-sm font-medium text-ink-3 hover:text-ink",onClick:t(()=>w(c=>!c),"onClick"),children:"Advanced"}),k?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"edit-profile-key",children:"Identifier"}),(0,e.jsx)(Q,{id:"edit-profile-key",value:L,onChange:t(c=>A(c.target.value),"onChange"),className:"font-mono text-xs"})]}):null]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:m,children:"Cancel"}),(0,e.jsx)(u,{disabled:!o.trim()||C||l,onClick:t(()=>x({name:o.trim(),description:g.trim()||null,profileKey:L.trim()}),"onClick"),children:"Save"})]})]})}):s==="duplicate"?(0,e.jsx)(U,{open:B,onOpenChange:t(c=>!c&&m(),"onOpenChange"),children:(0,e.jsxs)(K,{children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Duplicate profile"}),(0,e.jsx)(O,{children:"The copy starts unassigned unless you choose to copy assignments too."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"copy-profile-name",children:"Name"}),(0,e.jsx)(Q,{id:"copy-profile-name",value:N,onChange:t(c=>R(c.target.value),"onChange")}),b?(0,e.jsx)("p",{className:"text-xs text-bad",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:p,onChange:t(c=>M(c.target.checked),"onChange")}),"Also copy assignments?"]})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:m,children:"Cancel"}),(0,e.jsx)(u,{disabled:!N.trim()||b||l,onClick:t(()=>v({name:N.trim(),includeAssignments:p}),"onClick"),children:"Duplicate"})]})]})}):(0,e.jsx)(Se,{kind:s,profile:a,pending:l,onClose:m,onArchive:j,onRestore:i,onDelete:d})}t(Ke,"ProfileDialogs");function Oe({binding:s,label:a,pending:n,onClose:l,onConfirm:m}){return(0,e.jsx)(U,{open:!!s,onOpenChange:t(x=>!x&&l(),"onOpenChange"),children:(0,e.jsxs)(K,{children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Remove assignment"}),(0,e.jsx)(O,{children:s?.targetType==="company"?"Removing the organization default changes access for every agent that relies on it.":`Remove this profile from ${a}.`})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:l,children:"Cancel"}),(0,e.jsx)(u,{disabled:n,onClick:m,children:"Remove"})]})]})})}t(Oe,"RemoveAssignmentDialog");function qe(s,a,n,l,m){const x=s.entries.filter(i=>i.effect==="exclude"),v=s.entries.filter(i=>i.effect==="include"),j=s.summary.accessMode==="all_except";return a.filter(i=>!x.some(d=>W(d,i))).filter(i=>j||v.some(d=>W(d,i))).map(i=>{const d=j?null:v.find(g=>W(g,i))??null,o=n.get(i.applicationId??"")??l.get(i.connectionId)??"Unknown app",h=m.find(g=>g.id===i.connectionId);return{id:i.id,app:o,tool:i.title||i.toolName,capabilities:Me(i),source:Ue(d,o),autoAddedAt:s.defaultAction==="allow"&&He(i)?i.addedAt??i.firstSeenAt:null,degraded:!!(h&&(h.status!=="active"||h.healthStatus==="error")),connectionId:i.connectionId}})}t(qe,"buildAllowRows");function W(s,a){switch(s.selectorType){case"application":return!!(s.applicationId&&s.applicationId===a.applicationId);case"connection":return!!(s.connectionId&&s.connectionId===a.connectionId);case"catalog_entry":return!!(s.catalogEntryId&&s.catalogEntryId===a.id);case"tool_name":return!!(s.toolName&&s.toolName===a.toolName);case"risk_level":return!!(s.riskLevel&&s.riskLevel===a.riskLevel);default:return!1}}t(W,"entryMatchesTool");function Ue(s,a){return s?s.selectorType==="application"||s.selectorType==="connection"?`added by rule: all ${a}`:s.selectorType==="risk_level"&&s.riskLevel?`added by rule: ${s.riskLevel} tools`:"added directly":"added directly"}t(Ue,"sourceLabel");function Me(s){return s.isDestructive?"Destructive":s.isWrite?"Write":"Read"}t(Me,"capabilityLabel");function Qe(s){return s.riskLevel==="destructive"?"Destructive":s.riskLevel==="write"?"Write":s.riskLevel==="read"?"Read":s.capability}t(Qe,"capabilityText");function We(s){const a=[...new Set(s.map(n=>n.applicationName??n.connectionName).filter(Boolean))];return a.length===0?"An app":a.length===1?a[0]??"An app":a.length===2?`${a[0]} and ${a[1]}`:`${a[0]} and ${a.length-1} more apps`}t(We,"newToolsAppLabel");function He(s){const a=s.addedAt??s.firstSeenAt,n=new Date(a).getTime();return Number.isFinite(n)?Date.now()-n<=2592e6:!1}t(He,"isRecentTool");function ie(s,a,n){return s.targetType==="company"?"Organization default":s.targetType==="agent"?n.agentsById.get(s.targetId)??"Unknown agent":s.targetType==="project"?n.projectsById.get(s.targetId)??"Unknown project":s.targetType==="routine"?n.routinesById.get(s.targetId)??"Unknown routine":s.targetId===a?"Organization":s.targetId}t(ie,"assignmentLabel");function Ze(s){return s==="company"?"Organization default":s==="agent"?"Agent":s==="project"?"Project":s==="routine"?"Routine":"Scoped assignment"}t(Ze,"assignmentTypeLabel");function bs(){const{selectedCompany:s,selectedCompanyId:a}=he(),{setBreadcrumbs:n}=ke(),l=me();return(0,f.useEffect)(()=>(n([{label:s?.name??"Company",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:Ae("profiles")},{label:"Profile detail"}]),()=>n([])),[n,s?.name]),!a||!l.profileId?(0,e.jsx)("div",{className:"p-6 text-sm text-ink-3",children:"Select an organization and profile."}):(0,e.jsx)(Ee,{children:(0,e.jsx)("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5 p-4 sm:p-6",children:(0,e.jsx)(Re,{companyId:a,profileId:l.profileId})})})}t(bs,"ProfileDetailRoute");export{bs as ProfileDetailRoute};
|
|
1
|
+
var le=Object.defineProperty;var t=(s,a)=>le(s,"name",{value:a,configurable:!0});import{i as V}from"./rolldown-runtime-ZpX3ckPj.js";import{b as Y,l as ee,na as oe,t as ce,ta as de}from"./createLucideIcon-DJi9suAC.js";import{v as me,y as pe}from"./star-BZgQbzhV.js";import{X as ue,_ as D,t as E,v as xe}from"./queryKeys-DYV5MhM_.js";import{n as he}from"./CompanyContext-CSrVsSze.js";import{o as fe}from"./router-2UfGeejU.js";import{t as $}from"./label-BPz3pg9_.js";import{t as ge}from"./archive-restore-DeLPtKS0.js";import{t as je}from"./copy-_wvZOjTe.js";import{t as u}from"./button-CMwV3L1P.js";import{t as ve}from"./shield-check-B0HVjzM_.js";import{t as ye}from"./trash-D7zTaHTj.js";import{t as be}from"./user-minus-B4F-9ccK.js";import{t as se}from"./badge-DuA2EgZC.js";import{i as Ne}from"./ToastContext-DMdt9oTd.js";import{a as z,i as F,n as K,r as O,s as q,t as U}from"./dialog-CKUblzlR.js";import{t as Q}from"./input-DobnTAyB.js";import{t as S}from"./tools-B-L_sU_9.js";import{n as ke}from"./BreadcrumbContext-BVZDZoC0.js";import{t as we}from"./textarea-BRPEfJ-g.js";import{Ea as Ce,Hr as Ae}from"./index-3AxqhPET.js";import{a as Te,i as te,r as ae,s as J}from"./shared-4LF6wQ38.js";import{a as Se,n as Ie,t as Pe}from"./profile-summary-unutni_7.js";import{t as De}from"./useProfilesData-2L3_71Ql.js";import{t as Ee}from"./ToolsAdminGate-BI5-WYC3.js";var ne={name:"plug-zap",size:24,node:[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],aliases:["plug-zap-2"]};ne.node;var Le=ce(ne),f=V(oe(),1),e=V(de(),1);function Re({companyId:s,profileId:a,initialCreated:n,initialReviewOpen:l}){const m=fe(),[x,v]=pe(),j=ue(),{pushToast:i}=Ne(),d=De(s),[o,h]=(0,f.useState)(null),[g,I]=(0,f.useState)(null),[L,A]=(0,f.useState)(!!l),[N,R]=(0,f.useState)({}),p=(d.profiles.data?.profiles??[]).find(r=>r.id===a)??null,M=n??x.get("created")==="1",k=p?.newToolsPendingCount??0,w=xe({queryKey:E.tools.profileNewTools(a),queryFn:t(()=>S.getProfileNewTools(a),"queryFn"),enabled:k>0}),C=t(()=>{j.invalidateQueries({queryKey:E.tools.profiles(s)}),j.invalidateQueries({queryKey:E.tools.testAgentAccesses()})},"invalidate"),b=t(r=>String(r?.message??r),"errorBody"),B=(0,f.useMemo)(()=>p?qe(p,d.catalog,d.maps.applicationsById,d.maps.connectionsById,d.connections.data?.connections??[]):[],[p,d.catalog,d.maps.applicationsById,d.maps.connectionsById,d.connections.data?.connections]),c=w.data?.tools??[];(0,f.useEffect)(()=>{x.get("review")==="new-tools"&&k>0&&A(!0)},[k,x]),(0,f.useEffect)(()=>{c.length!==0&&R(r=>{const P={...r};for(const _ of c)P[_.catalogEntryId]||(P[_.catalogEntryId]="keep_blocked");return P})},[c]);const T=D({mutationFn:t(r=>S.updateProfile(a,r),"mutationFn"),onSuccess:t(()=>{C(),i({title:"Profile updated",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not update profile",body:b(r),tone:"error"}),"onError")}),H=D({mutationFn:t(r=>S.duplicateProfile(a,r),"mutationFn"),onSuccess:t(r=>{C(),i({title:"Profile duplicated",body:"The copy is not assigned to anyone yet.",tone:"success"}),m(`/apps/advanced/profiles/${r.id}?created=1`)},"onSuccess"),onError:t(r=>i({title:"Could not duplicate",body:b(r),tone:"error"}),"onError")}),Z=D({mutationFn:t(()=>S.deleteProfile(a),"mutationFn"),onSuccess:t(()=>{C(),i({title:"Profile deleted",tone:"success"}),m("/apps/advanced/profiles")},"onSuccess"),onError:t(r=>i({title:"Could not delete",body:b(r),tone:"error"}),"onError")}),G=D({mutationFn:t(r=>S.unbindProfile(s,a,{targetType:r.targetType,targetId:r.targetId}),"mutationFn"),onSuccess:t(()=>{I(null),C(),i({title:"Assignment removed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not remove assignment",body:b(r),tone:"error"}),"onError")}),X=D({mutationFn:t(()=>S.reviewProfileNewTools(a,{decisions:c.map(r=>({catalogEntryId:r.catalogEntryId,decision:N[r.catalogEntryId]??"keep_blocked"}))}),"mutationFn"),onSuccess:t(()=>{A(!1),v({}),j.invalidateQueries({queryKey:E.tools.profiles(s)}),j.invalidateQueries({queryKey:E.tools.profileNewTools(a)}),i({title:"New tools reviewed",tone:"success"})},"onSuccess"),onError:t(r=>i({title:"Could not submit review",body:b(r),tone:"error"}),"onError")});if(d.profiles.isLoading)return(0,e.jsx)(te,{label:"Loading profile..."});if(d.profiles.isError)return(0,e.jsx)(ae,{error:d.profiles.error,onRetry:t(()=>d.profiles.refetch(),"onRetry")});if(!p)return(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)(J,{title:"Profile not found",description:"This access profile may have been deleted."}),(0,e.jsx)(u,{variant:"secondary",onClick:t(()=>m("/apps/advanced/profiles"),"onClick"),children:"Back to profiles"})]});const y=p.status==="archived",re=p.summary.assignmentCount===0;return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)(J,{title:p.name,description:p.description??"No description yet.",actions:(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxs)(u,{variant:"secondary",disabled:y,onClick:t(()=>h("edit"),"onClick"),children:[(0,e.jsx)(Ce,{className:"mr-1.5 h-4 w-4"}),"Edit"]}),(0,e.jsxs)(u,{variant:"secondary",disabled:y,onClick:t(()=>h("duplicate"),"onClick"),children:[(0,e.jsx)(je,{className:"mr-1.5 h-4 w-4"}),"Duplicate"]}),y?(0,e.jsxs)(u,{variant:"secondary",onClick:t(()=>h("restore"),"onClick"),children:[(0,e.jsx)(ge,{className:"mr-1.5 h-4 w-4"}),"Restore"]}):(0,e.jsx)(u,{variant:"secondary",onClick:t(()=>h("archive"),"onClick"),children:"Archive"}),(0,e.jsxs)(u,{variant:"danger",onClick:t(()=>h("delete"),"onClick"),children:[(0,e.jsx)(ye,{className:"mr-1.5 h-4 w-4"}),"Delete"]})]})}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[(0,e.jsx)(se,{variant:y?"outline":"default",children:Pe[p.status]}),(0,e.jsxs)("span",{className:"text-ink-3",children:["Updated ",(0,e.jsx)(Te,{value:p.updatedAt})]}),(0,e.jsx)("span",{className:"text-ink-3",children:Ie(p.summary)})]}),M?(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-accent/30 bg-accent/5 px-4 py-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"Profile saved"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:re?"Assign it to agents before it changes their access.":"Assignments are active now."})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(u,{size:"sm",onClick:t(()=>m(`/apps/advanced/profiles/${p.id}/edit?step=3`),"onClick"),children:"Assign"}),(0,e.jsx)(u,{size:"sm",variant:"ghost",onClick:t(()=>v({}),"onClick"),children:"Dismiss"})]})]}):null,y?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile is archived. It does not apply to agents until it is restored."}):null,k>0?(0,e.jsx)(Be,{count:k,tools:c,loading:w.isLoading,onReview:t(()=>A(!0),"onReview")}):null,(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-ink",children:"What it allows"}),(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:y,onClick:t(()=>m(`/apps/advanced/profiles/${p.id}/edit?step=2`),"onClick"),children:"Edit tools"})]}),(0,e.jsx)($e,{rows:B,total:p.summary.totalToolCount})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-ink",children:"Who has it"}),(0,e.jsx)(u,{variant:"secondary",size:"sm",disabled:y,onClick:t(()=>m(`/apps/advanced/profiles/${p.id}/edit?step=3`),"onClick"),children:"Assign"})]}),(0,e.jsx)(ze,{profile:p,companyId:s,maps:d.maps,archived:y,onRemove:I})]}),(0,e.jsxs)("section",{className:"space-y-3",children:[(0,e.jsx)("h2",{className:"text-base font-semibold text-ink",children:"New tools that appear later"}),(0,e.jsx)(Fe,{value:p.defaultAction,disabled:y||T.isPending,onChange:t(r=>T.mutate({defaultAction:r}),"onChange")})]}),(0,e.jsxs)(u,{variant:"link",className:"h-auto px-0",onClick:t(()=>m("/apps/advanced/profiles?check=1"),"onClick"),children:[(0,e.jsx)(ve,{className:"mr-1.5 h-4 w-4"}),"Check what an agent can actually do"]}),(0,e.jsx)(Ke,{kind:o,profile:p,allProfiles:d.profiles.data?.profiles??[],pending:T.isPending||H.isPending||Z.isPending,onClose:t(()=>h(null),"onClose"),onUpdate:t(r=>T.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onUpdate"),onDuplicate:t(r=>H.mutate(r,{onSuccess:t(()=>h(null),"onSuccess")}),"onDuplicate"),onArchive:t(()=>T.mutate({status:"archived"},{onSuccess:t(()=>h(null),"onSuccess")}),"onArchive"),onRestore:t(()=>T.mutate({status:"active"},{onSuccess:t(()=>h(null),"onSuccess")}),"onRestore"),onDelete:t(()=>Z.mutate(void 0,{onSuccess:t(()=>h(null),"onSuccess")}),"onDelete")}),(0,e.jsx)(Oe,{binding:g,label:g?ie(g,s,d.maps):"",pending:G.isPending,onClose:t(()=>I(null),"onClose"),onConfirm:t(()=>g&&G.mutate(g),"onConfirm")}),(0,e.jsx)(_e,{open:L,tools:c,loading:w.isLoading,error:w.error,decisions:N,pending:X.isPending,onClose:t(()=>A(!1),"onClose"),onRetry:t(()=>w.refetch(),"onRetry"),onDecision:t((r,P)=>R(_=>({..._,[r]:P})),"onDecision"),onSubmit:t(()=>X.mutate(),"onSubmit")})]})}t(Re,"ProfileDetail");function Be({count:s,tools:a,loading:n,onReview:l}){const m=We(a);return(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"font-medium",children:n?"New tools need review":`${m} added ${s} new ${s===1?"tool":"tools"} since your last review`}),(0,e.jsx)("p",{className:"text-amber-900/80",children:"Choose which ones this profile should allow."})]}),(0,e.jsx)(u,{size:"sm",onClick:l,children:"Review"})]})}t(Be,"NewToolsReviewBanner");function _e({open:s,tools:a,loading:n,error:l,decisions:m,pending:x,onClose:v,onRetry:j,onDecision:i,onSubmit:d}){return(0,e.jsx)(U,{open:s,onOpenChange:t(o=>!o&&v(),"onOpenChange"),children:(0,e.jsxs)(K,{className:"max-w-2xl",children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Review new tools"}),(0,e.jsx)(O,{children:"Allow the tools this profile should use. Keep the rest blocked."})]}),n?(0,e.jsx)(te,{label:"Loading new tools..."}):l?(0,e.jsx)(ae,{error:l,onRetry:j}):a.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-dashed border-line px-4 py-6 text-sm text-ink-3",children:"There are no new tools waiting for review."}):(0,e.jsx)("div",{className:"max-h-(--sz-52vh) divide-y divide-line overflow-y-auto rounded-lg border border-line",children:a.map(o=>(0,e.jsxs)("div",{className:"grid gap-3 px-3 py-3 sm:grid-cols-[1fr_auto]",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-ink",children:o.title||o.toolName}),(0,e.jsx)(se,{variant:"secondary",children:Qe(o)})]}),o.description?(0,e.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:o.description}):null,(0,e.jsxs)("p",{className:"mt-1 text-xs text-ink-3",children:[o.applicationName??o.connectionName??"App tool"," · added ",Y(o.addedAt)]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 sm:justify-end",children:[(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${o.catalogEntryId}`,checked:(m[o.catalogEntryId]??"keep_blocked")==="allow",onChange:t(()=>i(o.catalogEntryId,"allow"),"onChange")}),"Allow"]}),(0,e.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-sm",children:[(0,e.jsx)("input",{type:"radio",name:`review-${o.catalogEntryId}`,checked:(m[o.catalogEntryId]??"keep_blocked")==="keep_blocked",onChange:t(()=>i(o.catalogEntryId,"keep_blocked"),"onChange")}),"Keep blocked"]})]})]},o.catalogEntryId))}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:v,children:"Cancel"}),(0,e.jsx)(u,{disabled:x||n||a.length===0,onClick:d,children:"Submit review"})]})]})})}t(_e,"NewToolsReviewDialog");function $e({rows:s,total:a}){return s.length===0?(0,e.jsx)("div",{className:"rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:"This profile allows 0 tools. Agents with only this profile will not be able to use app tools."}):(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-line",children:[(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-line bg-bg-3/40 text-left text-xs font-medium text-ink-3",children:[(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Tool"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"App"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Capabilities"}),(0,e.jsx)("th",{className:"px-3 py-2 font-medium",children:"Source"})]})}),(0,e.jsx)("tbody",{children:s.slice(0,80).map(n=>(0,e.jsxs)("tr",{className:ee("border-b border-line last:border-0",n.degraded&&"bg-bg-3/30 text-ink-3"),children:[(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:n.tool}),n.degraded?(0,e.jsxs)("a",{className:"mt-0.5 inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline",href:`/apps/${n.connectionId}`,children:[(0,e.jsx)(Le,{className:"h-3 w-3"}),"Reconnect"]}):null]})}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[(0,e.jsx)("span",{children:n.app}),n.degraded?(0,e.jsxs)("span",{className:"ml-2 text-xs text-ink-3",children:[n.app," is disconnected"]}):null]}),(0,e.jsx)("td",{className:"px-3 py-2 text-ink-3",children:n.capabilities}),(0,e.jsxs)("td",{className:"px-3 py-2",children:[n.source.startsWith("added by rule")?(0,e.jsx)("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-950",children:n.source}):(0,e.jsx)("span",{className:"text-ink-3",children:n.source}),n.autoAddedAt?(0,e.jsxs)("div",{className:"mt-0.5 text-xs text-ink-3",children:["added automatically · ",Y(n.autoAddedAt)]}):null]})]},n.id))})]}),s.length>80?(0,e.jsxs)("p",{className:"border-t border-line px-3 py-2 text-xs text-ink-3",children:["Showing 80 of ",s.length," allowed tools."]}):(0,e.jsxs)("p",{className:"border-t border-line px-3 py-2 text-xs text-ink-3",children:["Allows ",s.length," of ",a," known tools."]})]})}t($e,"AllowList");function ze({profile:s,companyId:a,maps:n,archived:l,onRemove:m}){return s.bindings.length===0?(0,e.jsxs)("div",{className:"rounded-lg border border-dashed border-line px-4 py-5",children:[(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"Not assigned yet"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Assign this profile before it changes access."})]}):(0,e.jsx)("div",{className:"divide-y divide-line overflow-hidden rounded-lg border border-line",children:s.bindings.map(x=>(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2.5",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,e.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-bg-3 text-xs font-semibold text-ink-3",children:x.targetType==="company"?"Or":x.targetType.slice(0,2).toUpperCase()}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"truncate text-sm font-medium text-ink",children:ie(x,a,n)}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:Ze(x.targetType)})]})]}),(0,e.jsxs)(u,{variant:"ghost",size:"sm",disabled:l,onClick:t(()=>m(x),"onClick"),children:[(0,e.jsx)(be,{className:"mr-1.5 h-4 w-4"}),"Remove"]})]},x.id))})}t(ze,"Assignments");function Fe({value:s,disabled:a,onChange:n}){return(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:[{value:"deny",title:"Stay blocked until reviewed",body:"New tools do not become available automatically."},{value:"allow",title:"Allowed automatically",body:"New tools from selected apps become available right away."}].map(l=>(0,e.jsxs)("label",{className:ee("flex cursor-pointer items-start gap-3 rounded-lg border px-4 py-3",s===l.value?"border-accent bg-accent/5":"border-line",a&&"cursor-not-allowed opacity-60"),children:[(0,e.jsx)("input",{type:"radio",className:"mt-1",disabled:a,checked:s===l.value,onChange:t(()=>n(l.value),"onChange")}),(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-ink",children:l.title}),(0,e.jsx)("span",{className:"block text-xs text-ink-3",children:l.body})]})]},l.value))})}t(Fe,"NewToolsSetting");function Ke({kind:s,profile:a,allProfiles:n,pending:l,onClose:m,onUpdate:x,onDuplicate:v,onArchive:j,onRestore:i,onDelete:d}){const[o,h]=(0,f.useState)(a.name),[g,I]=(0,f.useState)(a.description??""),[L,A]=(0,f.useState)(a.profileKey),[N,R]=(0,f.useState)(`${a.name} copy`),[p,M]=(0,f.useState)(!1),[k,w]=(0,f.useState)(!1),C=n.some(c=>c.id!==a.id&&c.name.trim().toLowerCase()===o.trim().toLowerCase()),b=n.some(c=>c.name.trim().toLowerCase()===N.trim().toLowerCase());if(!s)return null;const B=!!s;return s==="edit"?(0,e.jsx)(U,{open:B,onOpenChange:t(c=>!c&&m(),"onOpenChange"),children:(0,e.jsxs)(K,{children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Edit profile"}),(0,e.jsx)(O,{children:"Update the profile name and description."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"edit-profile-name",children:"Name"}),(0,e.jsx)(Q,{id:"edit-profile-name",value:o,onChange:t(c=>h(c.target.value),"onChange")}),C?(0,e.jsx)("p",{className:"text-xs text-bad",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"edit-profile-description",children:"Description"}),(0,e.jsx)(we,{id:"edit-profile-description",value:g,onChange:t(c=>I(c.target.value),"onChange"),rows:3})]}),(0,e.jsx)("button",{type:"button",className:"text-sm font-medium text-ink-3 hover:text-ink",onClick:t(()=>w(c=>!c),"onClick"),children:"Advanced"}),k?(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"edit-profile-key",children:"Identifier"}),(0,e.jsx)(Q,{id:"edit-profile-key",value:L,onChange:t(c=>A(c.target.value),"onChange"),className:"font-mono text-xs"})]}):null]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:m,children:"Cancel"}),(0,e.jsx)(u,{disabled:!o.trim()||C||l,onClick:t(()=>x({name:o.trim(),description:g.trim()||null,profileKey:L.trim()}),"onClick"),children:"Save"})]})]})}):s==="duplicate"?(0,e.jsx)(U,{open:B,onOpenChange:t(c=>!c&&m(),"onOpenChange"),children:(0,e.jsxs)(K,{children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Duplicate profile"}),(0,e.jsx)(O,{children:"The copy starts unassigned unless you choose to copy assignments too."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)($,{htmlFor:"copy-profile-name",children:"Name"}),(0,e.jsx)(Q,{id:"copy-profile-name",value:N,onChange:t(c=>R(c.target.value),"onChange")}),b?(0,e.jsx)("p",{className:"text-xs text-bad",children:"Another profile already uses this name."}):null]}),(0,e.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:p,onChange:t(c=>M(c.target.checked),"onChange")}),"Also copy assignments?"]})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:m,children:"Cancel"}),(0,e.jsx)(u,{disabled:!N.trim()||b||l,onClick:t(()=>v({name:N.trim(),includeAssignments:p}),"onClick"),children:"Duplicate"})]})]})}):(0,e.jsx)(Se,{kind:s,profile:a,pending:l,onClose:m,onArchive:j,onRestore:i,onDelete:d})}t(Ke,"ProfileDialogs");function Oe({binding:s,label:a,pending:n,onClose:l,onConfirm:m}){return(0,e.jsx)(U,{open:!!s,onOpenChange:t(x=>!x&&l(),"onOpenChange"),children:(0,e.jsxs)(K,{children:[(0,e.jsxs)(z,{children:[(0,e.jsx)(q,{children:"Remove assignment"}),(0,e.jsx)(O,{children:s?.targetType==="company"?"Removing the organization default changes access for every agent that relies on it.":`Remove this profile from ${a}.`})]}),(0,e.jsxs)(F,{children:[(0,e.jsx)(u,{variant:"ghost",onClick:l,children:"Cancel"}),(0,e.jsx)(u,{disabled:n,onClick:m,children:"Remove"})]})]})})}t(Oe,"RemoveAssignmentDialog");function qe(s,a,n,l,m){const x=s.entries.filter(i=>i.effect==="exclude"),v=s.entries.filter(i=>i.effect==="include"),j=s.summary.accessMode==="all_except";return a.filter(i=>!x.some(d=>W(d,i))).filter(i=>j||v.some(d=>W(d,i))).map(i=>{const d=j?null:v.find(g=>W(g,i))??null,o=n.get(i.applicationId??"")??l.get(i.connectionId)??"Unknown app",h=m.find(g=>g.id===i.connectionId);return{id:i.id,app:o,tool:i.title||i.toolName,capabilities:Me(i),source:Ue(d,o),autoAddedAt:s.defaultAction==="allow"&&He(i)?i.addedAt??i.firstSeenAt:null,degraded:!!(h&&(h.status!=="active"||h.healthStatus==="error")),connectionId:i.connectionId}})}t(qe,"buildAllowRows");function W(s,a){switch(s.selectorType){case"application":return!!(s.applicationId&&s.applicationId===a.applicationId);case"connection":return!!(s.connectionId&&s.connectionId===a.connectionId);case"catalog_entry":return!!(s.catalogEntryId&&s.catalogEntryId===a.id);case"tool_name":return!!(s.toolName&&s.toolName===a.toolName);case"risk_level":return!!(s.riskLevel&&s.riskLevel===a.riskLevel);default:return!1}}t(W,"entryMatchesTool");function Ue(s,a){return s?s.selectorType==="application"||s.selectorType==="connection"?`added by rule: all ${a}`:s.selectorType==="risk_level"&&s.riskLevel?`added by rule: ${s.riskLevel} tools`:"added directly":"added directly"}t(Ue,"sourceLabel");function Me(s){return s.isDestructive?"Destructive":s.isWrite?"Write":"Read"}t(Me,"capabilityLabel");function Qe(s){return s.riskLevel==="destructive"?"Destructive":s.riskLevel==="write"?"Write":s.riskLevel==="read"?"Read":s.capability}t(Qe,"capabilityText");function We(s){const a=[...new Set(s.map(n=>n.applicationName??n.connectionName).filter(Boolean))];return a.length===0?"An app":a.length===1?a[0]??"An app":a.length===2?`${a[0]} and ${a[1]}`:`${a[0]} and ${a.length-1} more apps`}t(We,"newToolsAppLabel");function He(s){const a=s.addedAt??s.firstSeenAt,n=new Date(a).getTime();return Number.isFinite(n)?Date.now()-n<=2592e6:!1}t(He,"isRecentTool");function ie(s,a,n){return s.targetType==="company"?"Organization default":s.targetType==="agent"?n.agentsById.get(s.targetId)??"Unknown agent":s.targetType==="project"?n.projectsById.get(s.targetId)??"Unknown project":s.targetType==="routine"?n.routinesById.get(s.targetId)??"Unknown routine":s.targetId===a?"Organization":s.targetId}t(ie,"assignmentLabel");function Ze(s){return s==="company"?"Organization default":s==="agent"?"Agent":s==="project"?"Project":s==="routine"?"Routine":"Scoped assignment"}t(Ze,"assignmentTypeLabel");function bs(){const{selectedCompany:s,selectedCompanyId:a}=he(),{setBreadcrumbs:n}=ke(),l=me();return(0,f.useEffect)(()=>(n([{label:s?.name??"Company",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:Ae("profiles")},{label:"Profile detail"}]),()=>n([])),[n,s?.name]),!a||!l.profileId?(0,e.jsx)("div",{className:"p-6 text-sm text-ink-3",children:"Select an organization and profile."}):(0,e.jsx)(Ee,{children:(0,e.jsx)("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5 p-4 sm:p-6",children:(0,e.jsx)(Re,{companyId:a,profileId:l.profileId})})})}t(bs,"ProfileDetailRoute");export{bs as ProfileDetailRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ne=Object.defineProperty;var s=(t,i)=>ne(t,"name",{value:i,configurable:!0});import{i as H}from"./rolldown-runtime-ZpX3ckPj.js";import{Qt as V,na as ie,t as Y,ta as oe}from"./createLucideIcon-DJi9suAC.js";import{X as G,_ as F,r as $,t as P,v as L}from"./queryKeys-DYV5MhM_.js";import{o as B}from"./companies-query-D9PxIiMT.js";import{n as re}from"./CompanyContext-CSrVsSze.js";import{a as le,n as ce,t as de}from"./avatar-UO226cef.js";import{t as q}from"./label-BPz3pg9_.js";import{t as me}from"./inbox-C08arfF_.js";import{r as k,t as N}from"./button-CMwV3L1P.js";import{t as ue}from"./play-CJNuUj69.js";import{t as X}from"./save-CJ1Iqyew.js";import{t as xe}from"./send-mNwfi_F1.js";import{t as J}from"./trash-D7zTaHTj.js";import{t as fe}from"./agents-DmlgUVso.js";import{t as K}from"./input-DobnTAyB.js";import{n as pe}from"./BreadcrumbContext-BVZDZoC0.js";import{t as he}from"./assets-TRDkBfss.js";import{t as O}from"./toggle-switch-BHxNtSq9.js";import{t as ge}from"./AgentMultiSelect-DsJfZtR2.js";import{t as be}from"./radio-card-DVZaXlw0.js";import{i as M,n as ve,o as ye,r as je,s as Ne}from"./select-V0Hm_q4f.js";import{t as we}from"./card-Bru3x_SJ.js";import{Ct as Se,St as T,Yn as ke,_t as Ce,at as Z,bt as Ae,ct as ee,dt as U,ft as Ie,ga as Pe,gt as Ee,ht as ze,it as _e,lt as Fe,ma as Me,mt as Te,ot as D,pt as De,rt as Le,st as z,ut as Oe,vt as $e,wt as Be,xt as qe,yt as Ke}from"./index-DDoARkPG.js";var se={name:"bell",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]};se.node;var Ue=Y(se),te={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};te.node;var R=Y(te),m=H(ie(),1),W={getMine:s(t=>$.get(`/companies/${t}/users/me/inbox-agent-policy`),"getMine"),updateMine:s((t,i)=>$.put(`/companies/${t}/users/me/inbox-agent-policy`,i),"updateMine")},e=H(oe(),1),Re=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function _(t,i){return`${t}:${[...i].sort().join(",")}`}s(_,"policyKey");function We({companyId:t}){const i=G(),[r,g]=(0,m.useState)(null),b=(0,m.useRef)(null),u=L({queryKey:t?P.inboxAgentPolicy.mine(t):["inbox-agent-policy","none"],queryFn:s(()=>W.getMine(t),"queryFn"),enabled:!!t}),d=u.data,f=L({queryKey:t?P.agents.list(t):["agents","none"],queryFn:s(()=>fe.list(t),"queryFn"),enabled:!!t}),h=(0,m.useMemo)(()=>(f.data??[]).filter(ke),[f.data]),p=(0,m.useMemo)(()=>h.map(n=>({id:n.id,name:n.name,title:n.title??n.role,icon:n.icon})),[h]),v=(0,m.useMemo)(()=>new Set(r?.allowedAgentIds??[]),[r?.allowedAgentIds]);(0,m.useEffect)(()=>{if(!d)return;const n=_(d.mode,d.allowedAgentIds);g(c=>c===null||_(c.mode,c.allowedAgentIds)===b.current?{mode:d.mode,allowedAgentIds:d.allowedAgentIds}:c),b.current=n},[d]);const x=F({mutationFn:s(n=>W.updateMine(t,{mode:n.mode,allowedAgentIds:n.mode==="allowlist"?n.allowedAgentIds:[]}),"mutationFn"),onSuccess:s(n=>{i.setQueryData(P.inboxAgentPolicy.mine(t),n)},"onSuccess")}),l=!!(r&&d&&_(r.mode,r.allowedAgentIds)!==_(d.mode,d.allowedAgentIds));return u.error?(0,e.jsx)("div",{className:"text-sm text-bad",children:u.error instanceof Error?u.error.message:"Failed to load inbox agent policy."}):u.isLoading||!r?(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading inbox agent policy…"}):(0,e.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(me,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Let agents tidy my inbox"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,e.jsx)(be,{ariaLabel:"Inbox agent archiving policy",value:r.mode,onValueChange:s(n=>g(c=>c&&{...c,mode:n}),"onValueChange"),options:Re,className:"max-w-2xl"}),r.mode==="allowlist"?(0,e.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,e.jsx)(ge,{agents:p,selectedAgentIds:v,onChange:s(n=>g(c=>c&&{...c,allowedAgentIds:[...n]}),"onChange"),triggerLabel:v.size===0?"Select agents":`${v.size} ${v.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,x.error?(0,e.jsx)("div",{className:"max-w-2xl rounded-md border border-bad/40 bg-bad/5 px-3 py-2 text-sm text-bad",children:x.error instanceof Error?x.error.message:"Failed to save inbox agent policy."}):null,(0,e.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[x.isSuccess&&!l?(0,e.jsx)("span",{className:"text-xs text-ink-3",role:"status",children:"Saved"}):null,(0,e.jsxs)(N,{type:"button",disabled:!l||x.isPending,onClick:s(()=>r&&x.mutate(r),"onClick"),children:[x.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(X,{className:"size-4"}),x.isPending?"Saving…":"Save"]})]})]})}s(We,"InboxAgentPolicyControl");var Qe={granted:"Allowed",denied:"Blocked in browser settings",default:"Not requested yet",unsupported:"Not supported in this browser"},Q={unknown:"Checking…",active:"Active on this device",off:"Off",unsupported:"Not supported in this browser",permission:"Waiting for notification permission","server-disabled":"Not available on this server",error:"Subscription failed"};function He(){const[t,i]=(0,m.useState)({});return(0,m.useEffect)(()=>{let r=!1;const g=s(()=>{Promise.all(V.map(async u=>[u,(await Ee(u))?.name])).then(u=>{if(r)return;const d={};for(const[f,h]of u)h&&(d[f]=h);i(d)})},"refresh");g();const b=Ke(g);return()=>{r=!0,b()}},[]),t}s(He,"useCustomSoundNames");function Ve({kind:t,customName:i,disabled:r,onError:g}){const b=ee(),u=b.kinds[t],d=(0,m.useId)(),[f,h]=(0,m.useState)(!1),p=De[t];async function v(n){const c=Ae(n);if(!c.ok){g(`${p}: ${c.error}`);return}h(!0);try{await $e(t,n),z(t,{soundId:U}),g(null)}catch(j){g(j instanceof Error?j.message:"Could not save the custom sound.")}finally{h(!1)}}s(v,"upload");async function x(){h(!0);try{await Ce(t),Z().kinds[t].soundId==="custom"&&z(t,{soundId:Ie[t]})}finally{h(!1)}}s(x,"remove");const l=r||!u.enabled;return(0,e.jsxs)("div",{className:"flex flex-col gap-2 border-b border-line/70 py-3 last:border-b-0 sm:flex-row sm:items-center sm:gap-3",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:w-48 sm:shrink-0",children:[(0,e.jsx)(O,{checked:u.enabled,onCheckedChange:s(n=>z(t,{enabled:n}),"onCheckedChange"),disabled:r,"aria-label":`${p} notifications`}),(0,e.jsx)("div",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:p,children:p})]}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:flex-1 sm:flex-nowrap",children:[(0,e.jsxs)(ve,{value:u.soundId,onValueChange:s(n=>z(t,{soundId:n}),"onValueChange"),disabled:l,children:[(0,e.jsx)(ye,{className:"min-w-0 flex-1 sm:w-(--sz-170px) sm:flex-none","aria-label":`${p} sound`,children:(0,e.jsx)(Ne,{})}),(0,e.jsxs)(je,{children:[Te.map(n=>(0,e.jsx)(M,{value:n.id,children:n.label},n.id)),i?(0,e.jsxs)(M,{value:U,children:["Custom: ",i]}):null,(0,e.jsx)(M,{value:ze,children:"No sound"})]})]}),(0,e.jsx)(N,{type:"button",variant:"secondary",size:"icon-sm","aria-label":`Preview ${p} sound`,disabled:l||u.soundId==="none",onClick:s(()=>{Oe(t,u.soundId,b.volume)},"onClick"),children:(0,e.jsx)(ue,{})}),(0,e.jsx)("input",{id:d,type:"file",accept:"audio/*",className:"sr-only",disabled:l||f,onChange:s(n=>{const c=n.target.files?.[0];n.target.value="",c&&v(c)},"onChange")}),(0,e.jsxs)(N,{type:"button",variant:"secondary",size:"sm",disabled:l||f,onClick:s(()=>document.getElementById(d)?.click(),"onClick"),children:[f?(0,e.jsx)(k,{className:"animate-spin"}):(0,e.jsx)(Pe,{}),i?"Replace":"Custom"]}),i?(0,e.jsx)(N,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove custom ${p} sound`,disabled:f,onClick:s(()=>{x()},"onClick"),children:(0,e.jsx)(J,{})}):null]})]})}s(Ve,"KindRow");function Ye({userId:t}){const i=ee(),r=_e(),g=He(),[b,u]=(0,m.useState)(()=>T()),[d,f]=(0,m.useState)(null),[h,p]=(0,m.useState)(null),[v,x]=(0,m.useState)(!1),l=Se(),n=r.status==="active",c=(0,m.useCallback)(()=>{t&&Le(Z(),t)},[t]);async function j(){const o=await Be();return u(o),o==="granted"&&c(),o}s(j,"askPermission");async function C(o){D(S=>({...S,enabled:o})),o&&T()==="default"&&await j()}s(C,"setEnabled");async function A(o){D(S=>({...S,pushEnabled:o})),o&&T()==="default"&&await j()}s(A,"setPushEnabled");async function I(){x(!0),f(null),p(null);try{const o=await Fe.sendWebPushTest();f(o.sent>0?`Test sent to ${o.sent} device${o.sent===1?"":"s"}.`:"No device has push turned on for your account yet.")}catch(o){p(o instanceof Error?o.message:"Could not send the test notification.")}finally{x(!1)}}s(I,"sendTest");const w=!i.enabled;return(0,e.jsxs)("section",{className:"space-y-4","aria-label":"Notifications",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ue,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Notifications"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"Sounds and alerts for approvals, agent questions, comments, assignments, reviews, failed runs and join requests. These settings apply to this browser only."})]}),(0,e.jsxs)("div",{className:"max-w-3xl space-y-4 rounded-md border border-line/70 p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Notifications on this device"}),(0,e.jsx)("div",{className:"text-xs text-ink-3",children:"Play sounds and show alerts for new inbox items."})]}),(0,e.jsx)(O,{checked:i.enabled,onCheckedChange:s(o=>{C(o)},"onCheckedChange"),"aria-label":"Notifications on this device"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Browser permission"}),(0,e.jsx)("div",{className:"text-xs text-ink-3",children:Qe[b]})]}),b==="default"?(0,e.jsx)(N,{type:"button",variant:"secondary",size:"sm",className:"shrink-0",onClick:s(()=>{j()},"onClick"),children:"Allow notifications"}):null]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Push when Wardmote is closed"}),(0,e.jsxs)("div",{className:"text-xs text-ink-3",children:[l?Q[r.status]:Q.unsupported,r.error?`: ${r.error}`:""]})]}),(0,e.jsx)(O,{checked:i.pushEnabled,onCheckedChange:s(o=>{A(o)},"onCheckedChange"),disabled:w||!l,"aria-label":"Push when Wardmote is closed"})]}),i.enabled&&!n?(0,e.jsx)("p",{className:"rounded-md bg-bg-3 px-3 py-2 text-xs text-ink-3",children:"Push is off on this device, so background alerts only work while a Wardmote tab is visible."}):null,qe()?(0,e.jsx)("p",{className:"rounded-md bg-bg-3 px-3 py-2 text-xs text-ink-3",children:"On iPhone and iPad, push notifications need Wardmote added to the Home Screen (Share, then Add to Home Screen) and opened from there."}):null,(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("label",{htmlFor:"notification-volume",className:"text-sm font-medium",children:"Volume"}),(0,e.jsx)("input",{id:"notification-volume",type:"range",min:0,max:100,step:5,value:Math.round(i.volume*100),disabled:w,onChange:s(o=>D(S=>({...S,volume:Number(o.target.value)/100})),"onChange"),className:"h-1.5 w-full max-w-xs"}),(0,e.jsxs)("span",{className:"w-10 text-right text-xs text-ink-3",children:[Math.round(i.volume*100),"%"]})]}),(0,e.jsx)("div",{children:V.map(o=>(0,e.jsx)(Ve,{kind:o,customName:g[o],disabled:w,onError:p},o))}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Custom sounds must be audio files of 512 KB or less. They play only while Wardmote is open; push notifications use your system sound."}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)(N,{type:"button",variant:"secondary",onClick:s(()=>{I()},"onClick"),disabled:v||w,children:[v?(0,e.jsx)(k,{className:"animate-spin"}):(0,e.jsx)(xe,{}),"Send test notification"]}),d?(0,e.jsx)("span",{className:"text-sm text-ink-3",children:d}):null]}),h?(0,e.jsx)("div",{className:"text-sm text-bad",children:h}):null]})]})}s(Ye,"NotificationSettingsSection");function Ge(t){const i=t.trim().split(/\s+/).filter(Boolean);return i.length>=2?`${i[0]?.[0]??""}${i[i.length-1]?.[0]??""}`.toUpperCase():t.slice(0,2).toUpperCase()}s(Ge,"deriveInitials");function js(){const{setBreadcrumbs:t}=pe(),{selectedCompanyId:i,selectedCompany:r}=re(),g=G(),b=(0,m.useId)(),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(""),[h,p]=(0,m.useState)(""),[v,x]=(0,m.useState)(null),l=L({queryKey:P.auth.session,queryFn:s(()=>B.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{t([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[t]),(0,m.useEffect)(()=>{const a=l.data;a&&(f(a.user.name??""),p(a.user.image??""))},[l.data]);function n(a){g.setQueryData(P.auth.session,y=>y&&{...y,user:{...y.user,...a}})}s(n,"syncSessionProfile");async function c(a){const y=await B.updateProfile(a);return n(y),y}s(c,"persistProfile");function j(){return d.trim()||l.data?.user.name||"Board"}s(j,"resolveProfileName");const C=F({mutationFn:s(a=>c(a),"mutationFn"),onSuccess:s(a=>{x(null),f(a.name??""),p(a.image??"")},"onSuccess"),onError:s(a=>{x(a instanceof Error?a.message:"Failed to update profile.")},"onError")}),A=F({mutationFn:s(async a=>{if(!i)throw new Error("Select an organization before uploading a profile avatar.");const y=await he.uploadImage(i,a,`profiles/${l.data?.user.id??"board-user"}`);return c({name:j(),image:y.contentPath})},"mutationFn"),onSuccess:s(a=>{x(null),f(a.name??""),p(a.image??"")},"onSuccess"),onError:s(a=>{x(a instanceof Error?a.message:"Failed to upload avatar.")},"onError")}),I=F({mutationFn:s(()=>c({name:j(),image:null}),"mutationFn"),onSuccess:s(a=>{x(null),f(a.name??""),p(a.image??"")},"onSuccess"),onError:s(a=>{x(a instanceof Error?a.message:"Failed to remove avatar.")},"onError")});if(l.isLoading)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading profile..."});if(l.error||!l.data)return(0,e.jsx)("div",{className:"text-sm text-bad",children:l.error instanceof Error?l.error.message:"Failed to load profile."});const w=d.trim()||l.data.user.name||"Board",o=h.trim()||null,S=Ge(w),E=C.isPending||A.isPending||I.isPending,ae=r?`Stored in Wardmote file storage for ${r.name}.`:"Select an organization to upload an avatar into Wardmote storage.";return(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Me,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Control how your account appears in the sidebar and other board surfaces."})]}),v?(0,e.jsx)("div",{className:"rounded-md border border-bad/40 bg-bad/5 px-3 py-2 text-sm text-bad",children:v}):null,(0,e.jsxs)("section",{className:"space-y-8",children:[(0,e.jsxs)(we,{className:"block relative overflow-hidden rounded-(--rad-28) border-line/70",children:[(0,e.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,e.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,e.jsx)("div",{className:"relative p-6 pt-10",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-end gap-5 rounded-(--rad-24) border border-line/70 bg-bg/92 p-5 shadow-(--shadow-extract-18) backdrop-blur-sm",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("label",{htmlFor:b,className:"group relative block cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-focus focus-within:ring-offset-2 focus-within:ring-offset-bg",children:[(0,e.jsx)("input",{ref:u,id:b,type:"file",accept:"image/*",className:"sr-only",disabled:!i||E,onChange:s(a=>{const y=a.target.files?.[0];y&&(A.mutate(y),a.target.value="")},"onChange")}),(0,e.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,e.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-bg bg-accent text-accent-ink shadow-sm",children:A.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(R,{className:"size-4"})}),(0,e.jsxs)(de,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-bg shadow-xl",children:[o?(0,e.jsx)(le,{src:o,alt:w}):null,(0,e.jsx)(ce,{children:S})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(N,{type:"button",variant:"secondary",onClick:s(()=>u.current?.click(),"onClick"),disabled:!i||E,children:[A.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(R,{className:"size-4"}),o?"Change photo":"Upload photo"]}),o?(0,e.jsxs)(N,{type:"button",variant:"secondary",onClick:s(()=>I.mutate(),"onClick"),disabled:E,children:[I.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(J,{className:"size-4"}),"Remove"]}):null]})]}),(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"truncate text-2xl font-semibold text-ink",children:w}),(0,e.jsx)("p",{className:"truncate text-sm text-ink-3",children:l.data.user.email??"No email"})]}),(0,e.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-ink-3",children:["Click the avatar to upload a new image. ",ae]})]})]})})]}),(0,e.jsxs)("form",{className:"grid gap-6 md:grid-cols-2",onSubmit:s(a=>{a.preventDefault(),C.mutate({name:j(),image:h.trim()||null})},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(q,{htmlFor:"profile-name",children:"Display name"}),(0,e.jsx)(K,{id:"profile-name",value:d,onChange:s(a=>f(a.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(q,{htmlFor:"profile-email",children:"Email"}),(0,e.jsx)(K,{id:"profile-email",value:l.data.user.email??"",readOnly:!0,disabled:!0}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Email is managed by your auth session and is read-only here."})]}),(0,e.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,e.jsxs)(N,{type:"submit",disabled:E||!d.trim(),children:[C.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(X,{className:"size-4"}),C.isPending?"Saving...":"Save profile"]})})]}),(0,e.jsx)(We,{companyId:i}),(0,e.jsx)(Ye,{userId:l.data.user.id??null})]})]})}s(js,"ProfileSettings");export{js as ProfileSettings};
|
|
1
|
+
var ne=Object.defineProperty;var s=(t,i)=>ne(t,"name",{value:i,configurable:!0});import{i as H}from"./rolldown-runtime-ZpX3ckPj.js";import{Qt as V,na as ie,t as Y,ta as oe}from"./createLucideIcon-DJi9suAC.js";import{X as G,_ as F,r as $,t as P,v as L}from"./queryKeys-DYV5MhM_.js";import{o as B}from"./companies-query-D9PxIiMT.js";import{n as re}from"./CompanyContext-CSrVsSze.js";import{a as le,n as ce,t as de}from"./avatar-UO226cef.js";import{t as q}from"./label-BPz3pg9_.js";import{t as me}from"./inbox-C08arfF_.js";import{r as k,t as N}from"./button-CMwV3L1P.js";import{t as ue}from"./play-CJNuUj69.js";import{t as X}from"./save-CJ1Iqyew.js";import{t as xe}from"./send-mNwfi_F1.js";import{t as J}from"./trash-D7zTaHTj.js";import{t as fe}from"./agents-DmlgUVso.js";import{t as K}from"./input-DobnTAyB.js";import{n as pe}from"./BreadcrumbContext-BVZDZoC0.js";import{t as he}from"./assets-TRDkBfss.js";import{t as O}from"./toggle-switch-BHxNtSq9.js";import{t as ge}from"./AgentMultiSelect-DsJfZtR2.js";import{t as be}from"./radio-card-DVZaXlw0.js";import{i as M,n as ve,o as ye,r as je,s as Ne}from"./select-V0Hm_q4f.js";import{t as we}from"./card-Bru3x_SJ.js";import{Ct as Se,St as T,Yn as ke,_t as Ce,at as Z,bt as Ae,ct as ee,dt as U,ft as Ie,ga as Pe,gt as Ee,ht as ze,it as _e,lt as Fe,ma as Me,mt as Te,ot as D,pt as De,rt as Le,st as z,ut as Oe,vt as $e,wt as Be,xt as qe,yt as Ke}from"./index-3AxqhPET.js";var se={name:"bell",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]};se.node;var Ue=Y(se),te={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};te.node;var R=Y(te),m=H(ie(),1),W={getMine:s(t=>$.get(`/companies/${t}/users/me/inbox-agent-policy`),"getMine"),updateMine:s((t,i)=>$.put(`/companies/${t}/users/me/inbox-agent-policy`,i),"updateMine")},e=H(oe(),1),Re=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function _(t,i){return`${t}:${[...i].sort().join(",")}`}s(_,"policyKey");function We({companyId:t}){const i=G(),[r,g]=(0,m.useState)(null),b=(0,m.useRef)(null),u=L({queryKey:t?P.inboxAgentPolicy.mine(t):["inbox-agent-policy","none"],queryFn:s(()=>W.getMine(t),"queryFn"),enabled:!!t}),d=u.data,f=L({queryKey:t?P.agents.list(t):["agents","none"],queryFn:s(()=>fe.list(t),"queryFn"),enabled:!!t}),h=(0,m.useMemo)(()=>(f.data??[]).filter(ke),[f.data]),p=(0,m.useMemo)(()=>h.map(n=>({id:n.id,name:n.name,title:n.title??n.role,icon:n.icon})),[h]),v=(0,m.useMemo)(()=>new Set(r?.allowedAgentIds??[]),[r?.allowedAgentIds]);(0,m.useEffect)(()=>{if(!d)return;const n=_(d.mode,d.allowedAgentIds);g(c=>c===null||_(c.mode,c.allowedAgentIds)===b.current?{mode:d.mode,allowedAgentIds:d.allowedAgentIds}:c),b.current=n},[d]);const x=F({mutationFn:s(n=>W.updateMine(t,{mode:n.mode,allowedAgentIds:n.mode==="allowlist"?n.allowedAgentIds:[]}),"mutationFn"),onSuccess:s(n=>{i.setQueryData(P.inboxAgentPolicy.mine(t),n)},"onSuccess")}),l=!!(r&&d&&_(r.mode,r.allowedAgentIds)!==_(d.mode,d.allowedAgentIds));return u.error?(0,e.jsx)("div",{className:"text-sm text-bad",children:u.error instanceof Error?u.error.message:"Failed to load inbox agent policy."}):u.isLoading||!r?(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading inbox agent policy…"}):(0,e.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(me,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Let agents tidy my inbox"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,e.jsx)(be,{ariaLabel:"Inbox agent archiving policy",value:r.mode,onValueChange:s(n=>g(c=>c&&{...c,mode:n}),"onValueChange"),options:Re,className:"max-w-2xl"}),r.mode==="allowlist"?(0,e.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,e.jsx)(ge,{agents:p,selectedAgentIds:v,onChange:s(n=>g(c=>c&&{...c,allowedAgentIds:[...n]}),"onChange"),triggerLabel:v.size===0?"Select agents":`${v.size} ${v.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,x.error?(0,e.jsx)("div",{className:"max-w-2xl rounded-md border border-bad/40 bg-bad/5 px-3 py-2 text-sm text-bad",children:x.error instanceof Error?x.error.message:"Failed to save inbox agent policy."}):null,(0,e.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[x.isSuccess&&!l?(0,e.jsx)("span",{className:"text-xs text-ink-3",role:"status",children:"Saved"}):null,(0,e.jsxs)(N,{type:"button",disabled:!l||x.isPending,onClick:s(()=>r&&x.mutate(r),"onClick"),children:[x.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(X,{className:"size-4"}),x.isPending?"Saving…":"Save"]})]})]})}s(We,"InboxAgentPolicyControl");var Qe={granted:"Allowed",denied:"Blocked in browser settings",default:"Not requested yet",unsupported:"Not supported in this browser"},Q={unknown:"Checking…",active:"Active on this device",off:"Off",unsupported:"Not supported in this browser",permission:"Waiting for notification permission","server-disabled":"Not available on this server",error:"Subscription failed"};function He(){const[t,i]=(0,m.useState)({});return(0,m.useEffect)(()=>{let r=!1;const g=s(()=>{Promise.all(V.map(async u=>[u,(await Ee(u))?.name])).then(u=>{if(r)return;const d={};for(const[f,h]of u)h&&(d[f]=h);i(d)})},"refresh");g();const b=Ke(g);return()=>{r=!0,b()}},[]),t}s(He,"useCustomSoundNames");function Ve({kind:t,customName:i,disabled:r,onError:g}){const b=ee(),u=b.kinds[t],d=(0,m.useId)(),[f,h]=(0,m.useState)(!1),p=De[t];async function v(n){const c=Ae(n);if(!c.ok){g(`${p}: ${c.error}`);return}h(!0);try{await $e(t,n),z(t,{soundId:U}),g(null)}catch(j){g(j instanceof Error?j.message:"Could not save the custom sound.")}finally{h(!1)}}s(v,"upload");async function x(){h(!0);try{await Ce(t),Z().kinds[t].soundId==="custom"&&z(t,{soundId:Ie[t]})}finally{h(!1)}}s(x,"remove");const l=r||!u.enabled;return(0,e.jsxs)("div",{className:"flex flex-col gap-2 border-b border-line/70 py-3 last:border-b-0 sm:flex-row sm:items-center sm:gap-3",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:w-48 sm:shrink-0",children:[(0,e.jsx)(O,{checked:u.enabled,onCheckedChange:s(n=>z(t,{enabled:n}),"onCheckedChange"),disabled:r,"aria-label":`${p} notifications`}),(0,e.jsx)("div",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:p,children:p})]}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:flex-1 sm:flex-nowrap",children:[(0,e.jsxs)(ve,{value:u.soundId,onValueChange:s(n=>z(t,{soundId:n}),"onValueChange"),disabled:l,children:[(0,e.jsx)(ye,{className:"min-w-0 flex-1 sm:w-(--sz-170px) sm:flex-none","aria-label":`${p} sound`,children:(0,e.jsx)(Ne,{})}),(0,e.jsxs)(je,{children:[Te.map(n=>(0,e.jsx)(M,{value:n.id,children:n.label},n.id)),i?(0,e.jsxs)(M,{value:U,children:["Custom: ",i]}):null,(0,e.jsx)(M,{value:ze,children:"No sound"})]})]}),(0,e.jsx)(N,{type:"button",variant:"secondary",size:"icon-sm","aria-label":`Preview ${p} sound`,disabled:l||u.soundId==="none",onClick:s(()=>{Oe(t,u.soundId,b.volume)},"onClick"),children:(0,e.jsx)(ue,{})}),(0,e.jsx)("input",{id:d,type:"file",accept:"audio/*",className:"sr-only",disabled:l||f,onChange:s(n=>{const c=n.target.files?.[0];n.target.value="",c&&v(c)},"onChange")}),(0,e.jsxs)(N,{type:"button",variant:"secondary",size:"sm",disabled:l||f,onClick:s(()=>document.getElementById(d)?.click(),"onClick"),children:[f?(0,e.jsx)(k,{className:"animate-spin"}):(0,e.jsx)(Pe,{}),i?"Replace":"Custom"]}),i?(0,e.jsx)(N,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove custom ${p} sound`,disabled:f,onClick:s(()=>{x()},"onClick"),children:(0,e.jsx)(J,{})}):null]})]})}s(Ve,"KindRow");function Ye({userId:t}){const i=ee(),r=_e(),g=He(),[b,u]=(0,m.useState)(()=>T()),[d,f]=(0,m.useState)(null),[h,p]=(0,m.useState)(null),[v,x]=(0,m.useState)(!1),l=Se(),n=r.status==="active",c=(0,m.useCallback)(()=>{t&&Le(Z(),t)},[t]);async function j(){const o=await Be();return u(o),o==="granted"&&c(),o}s(j,"askPermission");async function C(o){D(S=>({...S,enabled:o})),o&&T()==="default"&&await j()}s(C,"setEnabled");async function A(o){D(S=>({...S,pushEnabled:o})),o&&T()==="default"&&await j()}s(A,"setPushEnabled");async function I(){x(!0),f(null),p(null);try{const o=await Fe.sendWebPushTest();f(o.sent>0?`Test sent to ${o.sent} device${o.sent===1?"":"s"}.`:"No device has push turned on for your account yet.")}catch(o){p(o instanceof Error?o.message:"Could not send the test notification.")}finally{x(!1)}}s(I,"sendTest");const w=!i.enabled;return(0,e.jsxs)("section",{className:"space-y-4","aria-label":"Notifications",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ue,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h2",{className:"text-base font-semibold",children:"Notifications"})]}),(0,e.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"Sounds and alerts for approvals, agent questions, comments, assignments, reviews, failed runs and join requests. These settings apply to this browser only."})]}),(0,e.jsxs)("div",{className:"max-w-3xl space-y-4 rounded-md border border-line/70 p-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Notifications on this device"}),(0,e.jsx)("div",{className:"text-xs text-ink-3",children:"Play sounds and show alerts for new inbox items."})]}),(0,e.jsx)(O,{checked:i.enabled,onCheckedChange:s(o=>{C(o)},"onCheckedChange"),"aria-label":"Notifications on this device"})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Browser permission"}),(0,e.jsx)("div",{className:"text-xs text-ink-3",children:Qe[b]})]}),b==="default"?(0,e.jsx)(N,{type:"button",variant:"secondary",size:"sm",className:"shrink-0",onClick:s(()=>{j()},"onClick"),children:"Allow notifications"}):null]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:"Push when Wardmote is closed"}),(0,e.jsxs)("div",{className:"text-xs text-ink-3",children:[l?Q[r.status]:Q.unsupported,r.error?`: ${r.error}`:""]})]}),(0,e.jsx)(O,{checked:i.pushEnabled,onCheckedChange:s(o=>{A(o)},"onCheckedChange"),disabled:w||!l,"aria-label":"Push when Wardmote is closed"})]}),i.enabled&&!n?(0,e.jsx)("p",{className:"rounded-md bg-bg-3 px-3 py-2 text-xs text-ink-3",children:"Push is off on this device, so background alerts only work while a Wardmote tab is visible."}):null,qe()?(0,e.jsx)("p",{className:"rounded-md bg-bg-3 px-3 py-2 text-xs text-ink-3",children:"On iPhone and iPad, push notifications need Wardmote added to the Home Screen (Share, then Add to Home Screen) and opened from there."}):null,(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("label",{htmlFor:"notification-volume",className:"text-sm font-medium",children:"Volume"}),(0,e.jsx)("input",{id:"notification-volume",type:"range",min:0,max:100,step:5,value:Math.round(i.volume*100),disabled:w,onChange:s(o=>D(S=>({...S,volume:Number(o.target.value)/100})),"onChange"),className:"h-1.5 w-full max-w-xs"}),(0,e.jsxs)("span",{className:"w-10 text-right text-xs text-ink-3",children:[Math.round(i.volume*100),"%"]})]}),(0,e.jsx)("div",{children:V.map(o=>(0,e.jsx)(Ve,{kind:o,customName:g[o],disabled:w,onError:p},o))}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Custom sounds must be audio files of 512 KB or less. They play only while Wardmote is open; push notifications use your system sound."}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)(N,{type:"button",variant:"secondary",onClick:s(()=>{I()},"onClick"),disabled:v||w,children:[v?(0,e.jsx)(k,{className:"animate-spin"}):(0,e.jsx)(xe,{}),"Send test notification"]}),d?(0,e.jsx)("span",{className:"text-sm text-ink-3",children:d}):null]}),h?(0,e.jsx)("div",{className:"text-sm text-bad",children:h}):null]})]})}s(Ye,"NotificationSettingsSection");function Ge(t){const i=t.trim().split(/\s+/).filter(Boolean);return i.length>=2?`${i[0]?.[0]??""}${i[i.length-1]?.[0]??""}`.toUpperCase():t.slice(0,2).toUpperCase()}s(Ge,"deriveInitials");function js(){const{setBreadcrumbs:t}=pe(),{selectedCompanyId:i,selectedCompany:r}=re(),g=G(),b=(0,m.useId)(),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(""),[h,p]=(0,m.useState)(""),[v,x]=(0,m.useState)(null),l=L({queryKey:P.auth.session,queryFn:s(()=>B.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{t([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[t]),(0,m.useEffect)(()=>{const a=l.data;a&&(f(a.user.name??""),p(a.user.image??""))},[l.data]);function n(a){g.setQueryData(P.auth.session,y=>y&&{...y,user:{...y.user,...a}})}s(n,"syncSessionProfile");async function c(a){const y=await B.updateProfile(a);return n(y),y}s(c,"persistProfile");function j(){return d.trim()||l.data?.user.name||"Board"}s(j,"resolveProfileName");const C=F({mutationFn:s(a=>c(a),"mutationFn"),onSuccess:s(a=>{x(null),f(a.name??""),p(a.image??"")},"onSuccess"),onError:s(a=>{x(a instanceof Error?a.message:"Failed to update profile.")},"onError")}),A=F({mutationFn:s(async a=>{if(!i)throw new Error("Select an organization before uploading a profile avatar.");const y=await he.uploadImage(i,a,`profiles/${l.data?.user.id??"board-user"}`);return c({name:j(),image:y.contentPath})},"mutationFn"),onSuccess:s(a=>{x(null),f(a.name??""),p(a.image??"")},"onSuccess"),onError:s(a=>{x(a instanceof Error?a.message:"Failed to upload avatar.")},"onError")}),I=F({mutationFn:s(()=>c({name:j(),image:null}),"mutationFn"),onSuccess:s(a=>{x(null),f(a.name??""),p(a.image??"")},"onSuccess"),onError:s(a=>{x(a instanceof Error?a.message:"Failed to remove avatar.")},"onError")});if(l.isLoading)return(0,e.jsx)("div",{className:"text-sm text-ink-3",children:"Loading profile..."});if(l.error||!l.data)return(0,e.jsx)("div",{className:"text-sm text-bad",children:l.error instanceof Error?l.error.message:"Failed to load profile."});const w=d.trim()||l.data.user.name||"Board",o=h.trim()||null,S=Ge(w),E=C.isPending||A.isPending||I.isPending,ae=r?`Stored in Wardmote file storage for ${r.name}.`:"Select an organization to upload an avatar into Wardmote storage.";return(0,e.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Me,{className:"h-5 w-5 text-ink-3"}),(0,e.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Control how your account appears in the sidebar and other board surfaces."})]}),v?(0,e.jsx)("div",{className:"rounded-md border border-bad/40 bg-bad/5 px-3 py-2 text-sm text-bad",children:v}):null,(0,e.jsxs)("section",{className:"space-y-8",children:[(0,e.jsxs)(we,{className:"block relative overflow-hidden rounded-(--rad-28) border-line/70",children:[(0,e.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,e.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,e.jsx)("div",{className:"relative p-6 pt-10",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-end gap-5 rounded-(--rad-24) border border-line/70 bg-bg/92 p-5 shadow-(--shadow-extract-18) backdrop-blur-sm",children:[(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("label",{htmlFor:b,className:"group relative block cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-focus focus-within:ring-offset-2 focus-within:ring-offset-bg",children:[(0,e.jsx)("input",{ref:u,id:b,type:"file",accept:"image/*",className:"sr-only",disabled:!i||E,onChange:s(a=>{const y=a.target.files?.[0];y&&(A.mutate(y),a.target.value="")},"onChange")}),(0,e.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,e.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-bg bg-accent text-accent-ink shadow-sm",children:A.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(R,{className:"size-4"})}),(0,e.jsxs)(de,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-bg shadow-xl",children:[o?(0,e.jsx)(le,{src:o,alt:w}):null,(0,e.jsx)(ce,{children:S})]})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)(N,{type:"button",variant:"secondary",onClick:s(()=>u.current?.click(),"onClick"),disabled:!i||E,children:[A.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(R,{className:"size-4"}),o?"Change photo":"Upload photo"]}),o?(0,e.jsxs)(N,{type:"button",variant:"secondary",onClick:s(()=>I.mutate(),"onClick"),disabled:E,children:[I.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(J,{className:"size-4"}),"Remove"]}):null]})]}),(0,e.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"truncate text-2xl font-semibold text-ink",children:w}),(0,e.jsx)("p",{className:"truncate text-sm text-ink-3",children:l.data.user.email??"No email"})]}),(0,e.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-ink-3",children:["Click the avatar to upload a new image. ",ae]})]})]})})]}),(0,e.jsxs)("form",{className:"grid gap-6 md:grid-cols-2",onSubmit:s(a=>{a.preventDefault(),C.mutate({name:j(),image:h.trim()||null})},"onSubmit"),children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(q,{htmlFor:"profile-name",children:"Display name"}),(0,e.jsx)(K,{id:"profile-name",value:d,onChange:s(a=>f(a.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(q,{htmlFor:"profile-email",children:"Email"}),(0,e.jsx)(K,{id:"profile-email",value:l.data.user.email??"",readOnly:!0,disabled:!0}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Email is managed by your auth session and is read-only here."})]}),(0,e.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,e.jsxs)(N,{type:"submit",disabled:E||!d.trim(),children:[C.isPending?(0,e.jsx)(k,{className:"size-4 animate-spin"}):(0,e.jsx)(X,{className:"size-4"}),C.isPending?"Saving...":"Save profile"]})})]}),(0,e.jsx)(We,{companyId:i}),(0,e.jsx)(Ye,{userId:l.data.user.id??null})]})]})}s(js,"ProfileSettings");export{js as ProfileSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Me=Object.defineProperty;var a=(t,n)=>Me(t,"name",{value:n,configurable:!0});import{i as Ae}from"./rolldown-runtime-ZpX3ckPj.js";import{l as $,na as ze,ta as Fe}from"./createLucideIcon-DJi9suAC.js";import{v as Oe,y as qe}from"./star-BZgQbzhV.js";import{X as Ue,_ as ve,t as ye}from"./queryKeys-DYV5MhM_.js";import{n as Ve}from"./CompanyContext-CSrVsSze.js";import{o as We,t as Ye}from"./router-2UfGeejU.js";import{n as ee,r as te,t as se}from"./collapsible-CqjPlqOa.js";import{t as be}from"./checkbox-BHQhs41k.js";import{t as G}from"./label-BPz3pg9_.js";import{t as Ge}from"./check-Ctsrlfa-.js";import{t as B}from"./chevron-down-BCvxsWfI.js";import{t as Qe}from"./chevron-right-s7L6hXXq.js";import{r as Q,t as P}from"./button-CMwV3L1P.js";import{t as He}from"./plug-VjpaJcMq.js";import{t as Xe}from"./plus-C6fnr28l.js";import{t as Je}from"./search-04O7m-IF.js";import{t as Ze}from"./x-DRDFdlYE.js";import{t as Ie}from"./badge-DuA2EgZC.js";import{i as et}from"./ToastContext-DMdt9oTd.js";import{t as K}from"./input-DobnTAyB.js";import{t as T}from"./tools-B-L_sU_9.js";import{n as tt}from"./BreadcrumbContext-BVZDZoC0.js";import{t as st}from"./textarea-BRPEfJ-g.js";import{t as at}from"./AgentMultiSelect-DsJfZtR2.js";import{i as _,n as H,o as X,r as J,s as Z}from"./select-V0Hm_q4f.js";import{t as nt}from"./chip-DsDe6yck.js";import{Hr as lt}from"./index-DDoARkPG.js";import{i as Pe}from"./shared-DDwmHbeD.js";import{a as it,c as rt,d as ot,f as ct,i as dt,l as Ne,n as Le,o as ke,p as _e,r as $e,s as mt,t as pt,u as xt}from"./useProfilesData-2L3_71Ql.js";import{t as ut}from"./ToolsAdminGate-BI5-WYC3.js";var p=Ae(ze(),1),e=Ae(Fe(),1),ht=["read","write","destructive"],ft={read:"outline",write:"secondary",destructive:"destructive"};function gt(t){const{appGroups:n,catalogLoading:i,selections:r,onSelectionsChange:d}=t,[u,g]=(0,p.useState)(""),[x,s]=(0,p.useState)(null),h=(0,p.useMemo)(()=>{const c=u.trim().toLowerCase();return n.map(o=>({group:o,tools:o.tools.filter(f=>x&&_e(f)!==x?!1:c?f.toolName.toLowerCase().includes(c)||(f.title??"").toLowerCase().includes(c)||o.name.toLowerCase().includes(c):!0)})).filter(o=>o.tools.length>0)},[n,u,x]);return i?(0,e.jsx)(Pe,{label:"Loading tools…"}):n.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-line py-12 text-center",children:[(0,e.jsx)(He,{className:"h-6 w-6 text-ink-3"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"App connections are coming soon"}),(0,e.jsx)("p",{className:"mx-auto max-w-sm text-sm text-ink-3",children:"Profiles will be available once app connections are ready. Browse the planned integrations in the meantime."})]}),(0,e.jsx)(P,{asChild:!0,variant:"secondary",children:(0,e.jsx)(Ye,{to:"/apps",children:"Browse app connections"})})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative min-w-(--sz-220px) flex-1",children:[(0,e.jsx)(Je,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-ink-3"}),(0,e.jsx)(K,{value:u,onChange:a(c=>g(c.target.value),"onChange"),placeholder:"Search tools…",className:"pl-8"})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5",children:ht.map(c=>(0,e.jsx)(nt,{selected:x===c,onClick:a(()=>s(o=>o===c?null:c),"onClick"),children:Le[c]},c))})]}),h.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-dashed border-line py-10 text-center",children:[(0,e.jsxs)("p",{className:"text-sm font-medium text-ink",children:["No tools match “",u,"”."]}),(0,e.jsx)("button",{type:"button",onClick:a(()=>{g(""),s(null)},"onClick"),className:"text-sm font-medium text-accent hover:underline",children:"Clear search"})]}):(0,e.jsx)("div",{className:"divide-y divide-line overflow-hidden rounded-lg border border-line",children:h.map(({group:c,tools:o})=>(0,e.jsx)(jt,{group:c,visibleTools:o,selection:r[c.appKey],onToggleApp:a(()=>d({...r,[c.appKey]:ot(c,r[c.appKey])}),"onToggleApp"),onToggleTool:a(f=>d({...r,[c.appKey]:ct(c,r[c.appKey],f)}),"onToggleTool")},c.appKey))}),(0,e.jsx)(vt,{value:t.newToolsAction,onChange:t.onNewToolsActionChange}),(0,e.jsx)(kt,{rules:t.advancedRules,onChange:t.onAdvancedRulesChange})]})}a(gt,"WizardToolsStep");function jt({group:t,visibleTools:n,selection:i,onToggleApp:r,onToggleTool:d}){const[u,g]=(0,p.useState)(!1),x=dt(t,i);return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[(0,e.jsx)(be,{checked:x==="checked"?!0:x==="indeterminate"?"indeterminate":!1,onCheckedChange:r,"aria-label":`All ${t.name} tools`}),(0,e.jsxs)("button",{type:"button",onClick:a(()=>g(s=>!s),"onClick"),className:"flex flex-1 items-center gap-1.5 text-left",children:[u?(0,e.jsx)(B,{className:"h-4 w-4 shrink-0 text-ink-3"}):(0,e.jsx)(Qe,{className:"h-4 w-4 shrink-0 text-ink-3"}),(0,e.jsxs)("span",{className:"flex flex-col",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-ink",children:["All ",t.name," tools (",t.tools.length,")"]}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:x==="indeterminate"?it(t,i):"includes tools "+t.name+" adds later"})]})]})]}),u?(0,e.jsx)("div",{className:"space-y-0.5 border-t border-line bg-bg-3/20 px-3 py-2 pl-10",children:n.map(s=>{const h=_e(s);return(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md px-1.5 py-1.5 hover:bg-bg-3/50",children:[(0,e.jsx)(be,{className:"mt-0.5",checked:rt(t,i,s.id),onCheckedChange:a(()=>d(s.id),"onCheckedChange")}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("code",{className:"font-mono text-xs text-ink",children:s.toolName}),(0,e.jsx)(Ie,{variant:ft[h],className:"text-(length:--text-nano)",children:Le[h]})]}),s.title||s.description?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:s.title??s.description}):null]})]},s.id)})}):null]})}a(jt,"AppRow");function vt({value:t,onChange:n}){return(0,e.jsxs)("fieldset",{className:"space-y-2 rounded-lg border border-line p-4",children:[(0,e.jsx)("legend",{className:"px-1 text-sm font-medium text-ink",children:"New tools that appear later"}),(0,e.jsx)("div",{className:"space-y-2",children:[{value:"deny",label:"Stay blocked until someone allows them",hint:"New tools an app adds later won't be usable until you review them.",recommended:!0},{value:"allow",label:"Allowed automatically",hint:"Any tool an app adds later becomes usable right away."}].map(i=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5",children:[(0,e.jsx)("input",{type:"radio",name:"new-tools-action",className:"mt-0.5",checked:t===i.value,onChange:a(()=>n(i.value),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-ink",children:[i.label,i.recommended?(0,e.jsx)(Ie,{variant:"outline",className:"text-(length:--text-nano)",children:"Recommended"}):(0,e.jsx)("span",{className:"text-xs font-normal text-amber-600",children:"(risky)"})]}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:i.hint})]})]},i.value))})]})}a(vt,"NewToolsRadio");var yt=[{value:"tool_name",label:"Tool name pattern"},{value:"risk_level",label:"Risk level"},{value:"catalog_entry",label:"By tool ID"}];function bt(){const t=globalThis.crypto?.randomUUID?.();return t||`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}a(bt,"createAdvancedRuleId");function Nt(t){const n=t.effect==="include"?"Allow":"Block";return t.kind==="tool_name"?`${n} tools matching ${t.value}`:t.kind==="risk_level"?`${n} ${t.riskLevel??t.value} tools`:`${n} tool ${t.value}`}a(Nt,"ruleSummary");function kt({rules:t,onChange:n}){const[i,r]=(0,p.useState)(!1),[d,u]=(0,p.useState)("tool_name"),[g,x]=(0,p.useState)(""),[s,h]=(0,p.useState)("include"),c=a(()=>{const o=g.trim();if(!o&&d!=="risk_level")return;const f={id:bt(),kind:d,value:d==="risk_level"?o||"destructive":o,riskLevel:d==="risk_level"?o||"destructive":void 0,effect:s};n([...t,f]),x("")},"addRule");return(0,e.jsxs)(se,{open:i,onOpenChange:r,className:"rounded-lg border border-line",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Advanced rules"}),(0,e.jsx)(B,{className:$("h-4 w-4 text-ink-3 transition-transform",i&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-3 border-t border-line px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Match tools by a name pattern, a risk level, or a specific tool ID. These run on top of the choices above."}),t.length>0?(0,e.jsx)("ul",{className:"space-y-1.5",children:t.map(o=>(0,e.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-md border border-line bg-bg-3/30 px-3 py-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-ink",children:Nt(o)}),(0,e.jsx)("button",{type:"button","aria-label":"Remove rule",onClick:a(()=>n(t.filter(f=>f.id!==o.id)),"onClick"),className:"text-ink-3 hover:text-bad",children:(0,e.jsx)(Ze,{className:"h-4 w-4"})})]},o.id))}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,e.jsxs)(H,{value:s,onValueChange:a(o=>h(o),"onValueChange"),children:[(0,e.jsx)(X,{className:"w-28",children:(0,e.jsx)(Z,{})}),(0,e.jsxs)(J,{children:[(0,e.jsx)(_,{value:"include",children:"Allow"}),(0,e.jsx)(_,{value:"exclude",children:"Block"})]})]}),(0,e.jsxs)(H,{value:d,onValueChange:a(o=>u(o),"onValueChange"),children:[(0,e.jsx)(X,{className:"w-40",children:(0,e.jsx)(Z,{})}),(0,e.jsx)(J,{children:yt.map(o=>(0,e.jsx)(_,{value:o.value,children:o.label},o.value))})]}),d==="risk_level"?(0,e.jsxs)(H,{value:g||"destructive",onValueChange:x,children:[(0,e.jsx)(X,{className:"w-36",children:(0,e.jsx)(Z,{})}),(0,e.jsxs)(J,{children:[(0,e.jsx)(_,{value:"read",children:"Read-only"}),(0,e.jsx)(_,{value:"write",children:"Makes changes"}),(0,e.jsx)(_,{value:"destructive",children:"Destructive"})]})]}):(0,e.jsx)(K,{value:g,onChange:a(o=>x(o.target.value),"onChange"),placeholder:d==="tool_name"?"e.g. gmail.send*":"tool ID",className:"w-44"}),(0,e.jsxs)(P,{type:"button",variant:"secondary",size:"sm",onClick:c,children:[(0,e.jsx)(Xe,{className:"mr-1 h-3.5 w-3.5"}),"Add rule"]})]})]})]})}a(kt,"AdvancedRules");var Re="wizard";function wt(t){const n=t?.metadata?.[Re];if(!n||typeof n!="object")return null;const i=n,r=i.lastCompletedStep;return r!==1&&r!==2&&r!==3?null:{lastCompletedStep:r,template:typeof i.template=="string"?i.template:null}}a(wt,"readWizardMeta");function we(t,n){return{...t??{},[Re]:n}}a(we,"withWizardMeta");function St(t){return t?Math.min(t.lastCompletedStep+1,3):1}a(St,"resumeStep");function Se(t){return t.trim().toLowerCase().replace(/[^a-z0-9._:-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,160)}a(Se,"slugifyProfileKey");var Ce=[{step:1,label:"Name"},{step:2,label:"Choose tools"},{step:3,label:"Assign"}];function Ct({companyId:t,profileId:n,initialTemplate:i,initialStep:r}){const d=We(),u=Ue(),{pushToast:g}=et(),x=pt(t),{appGroups:s,catalog:h,profiles:c,agents:o}=x,f=c.data?.profiles??[],m=n?f.find(l=>l.id===n)??null:null,[v,A]=(0,p.useState)(1),[j,y]=(0,p.useState)(n??null),[b,R]=(0,p.useState)(i??null),[E,Ee]=(0,p.useState)(null),[I,ae]=(0,p.useState)(""),[M,ne]=(0,p.useState)(""),[z,F]=(0,p.useState)(""),[le,ie]=(0,p.useState)(!1),[L,O]=(0,p.useState)({}),[q,re]=(0,p.useState)([]),[C,oe]=(0,p.useState)("deny"),[U,ce]=(0,p.useState)(new Set),[de,me]=(0,p.useState)(new Set),[pe,xe]=(0,p.useState)(new Set),[V,ue]=(0,p.useState)(!1),W=a(l=>N=>l(k=>{const w=new Set(k);return w.has(N)?w.delete(N):w.add(N),w}),"toggleIn"),he=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(he.current||!m||s.length===0||m.id!==n)return;he.current=!0,ae(m.name),ne(m.description??""),F(m.profileKey),ie(!0),oe(m.defaultAction);const l=Ne(s,m.entries);O(l.selections),re(l.advancedRules);const N=wt(m);R(N?.template??null),A(r??(m.status==="draft"?St(N):1));const k=a(w=>new Set(m.bindings.filter(Y=>Y.targetType===w).map(Y=>Y.targetId)),"targetIds");ce(k("agent")),me(k("project")),xe(k("routine")),ue(m.bindings.some(w=>w.targetType==="company"))},[m,s,n,r]),(0,p.useEffect)(()=>{le||F(Se(I))},[I,le]);const fe=a(()=>{u.invalidateQueries({queryKey:ye.tools.profiles(t)}),u.invalidateQueries({queryKey:ye.tools.testAgentAccesses()})},"invalidate"),ge=(0,p.useMemo)(()=>mt(s,L,C,h.length),[s,L,C,h.length]),De=a(()=>{if(b==="copy"&&E){const l=f.find(N=>N.id===E);if(l)return Ne(s,l.entries).selections}return b&&b!=="copy"?xt(b,s):L},"seedSelections"),D=ve({mutationFn:a(async l=>{const N=l.seed??L,k=ke(s,N,q,C),w=we(m?.metadata??null,{lastCompletedStep:l.completedStep,template:b});return j?{created:await T.updateProfile(j,{profileKey:z||void 0,name:I.trim()||"Untitled profile",description:M.trim()||null,defaultAction:C,entries:k,metadata:w}),goToStep:l.goToStep,seed:l.seed}:{created:await T.createProfile(t,{profileKey:z||Se(I)||"profile",name:I.trim()||"Untitled profile",description:M.trim()||null,status:"draft",defaultAction:C,entries:k,metadata:w}),goToStep:l.goToStep,seed:l.seed}},"mutationFn"),onSuccess:a(({created:l,goToStep:N,seed:k})=>{y(l.id),k&&O(k),A(N),fe()},"onSuccess"),onError:a(l=>g({title:"Could not save",body:String(l?.message??l),tone:"error"}),"onError")}),je=ve({mutationFn:a(async()=>{if(!j)throw new Error("No draft to finish");const l=ke(s,L,q,C);return await Tt(t,await T.updateProfile(j,{defaultAction:C,entries:l,metadata:we(m?.metadata??null,{lastCompletedStep:3,template:b})}),{agentIds:[...U],projectIds:[...de],routineIds:[...pe],companyDefault:V}),T.updateProfile(j,{status:"active"})},"mutationFn"),onSuccess:a(l=>{g({title:"Profile saved",tone:"success"}),fe(),d(`/apps/advanced/profiles/${l.id}${U.size===0&&!V?"?created=1":""}`)},"onSuccess"),onError:a(l=>g({title:"Could not save profile",body:String(l?.message??l),tone:"error"}),"onError")}),Ke=a(()=>{const l=v;D.mutate({goToStep:v,completedStep:l},{onSuccess:a(()=>{g({title:"Draft saved",body:"Pick it back up from the profiles list.",tone:"success"}),d("/apps/advanced/profiles")},"onSuccess")})},"saveAndExit"),S=D.isPending||je.isPending,Be=I.trim().length>0&&(b!=="copy"||!!E);return n&&c.isLoading?(0,e.jsx)(Pe,{label:"Loading draft…"}):(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 pb-24",children:[(0,e.jsx)(At,{current:v}),(0,e.jsxs)("div",{className:"min-h-(--sz-320px)",children:[v===1?(0,e.jsx)(It,{template:b,onTemplate:R,copyFromId:E,onCopyFrom:Ee,copyOptions:f.filter(l=>l.status!=="archived"&&l.id!==n),name:I,onName:ae,description:M,onDescription:ne,profileKey:z,onProfileKey:a(l=>{ie(!0),F(l)},"onProfileKey")}):null,v===2?(0,e.jsx)(gt,{appGroups:s,catalogLoading:x.catalogLoading,selections:L,onSelectionsChange:O,advancedRules:q,onAdvancedRulesChange:re,newToolsAction:C,onNewToolsActionChange:oe}):null,v===3?(0,e.jsx)(Pt,{agents:(o.data??[]).map(l=>({id:l.id,name:l.name,title:l.title,icon:l.icon})),projects:(x.projects.data??[]).map(l=>({id:l.id,name:l.name})),routines:(x.routines.data??[]).map(l=>({id:l.id,name:l.title})),profiles:f,selectedAgentIds:U,onToggleAgent:W(ce),selectedProjectIds:de,onToggleProject:W(me),selectedRoutineIds:pe,onToggleRoutine:W(xe),companyDefault:V,onCompanyDefault:ue}):null]}),(0,e.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-10 border-t border-line bg-bg/95 backdrop-blur",children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl items-center justify-between gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 text-sm text-ink-3",children:[v>=2?(0,e.jsxs)("span",{children:["Allows ",(0,e.jsx)("span",{className:"font-medium text-ink",children:ge.allowed})," of ",ge.total," ","tools"]}):null,j?(0,e.jsx)("button",{type:"button",onClick:Ke,disabled:S,className:"font-medium text-accent hover:underline disabled:opacity-50",children:"Save & finish later"}):null]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[v>1?(0,e.jsx)(P,{variant:"secondary",disabled:S,onClick:a(()=>A(l=>l-1),"onClick"),children:"Back"}):(0,e.jsx)(P,{variant:"ghost",disabled:S,onClick:a(()=>d("/apps/advanced/profiles"),"onClick"),children:"Cancel"}),v===1?(0,e.jsxs)(P,{disabled:!Be||S,onClick:a(()=>D.mutate({goToStep:2,completedStep:1,seed:De()}),"onClick"),children:[S?(0,e.jsx)(Q,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,v===2?(0,e.jsxs)(P,{disabled:S,onClick:a(()=>D.mutate({goToStep:3,completedStep:2}),"onClick"),children:[S?(0,e.jsx)(Q,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,v===3?(0,e.jsxs)(P,{disabled:S,onClick:a(()=>je.mutate(),"onClick"),children:[S?(0,e.jsx)(Q,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Save profile"]}):null]})]})})]})}a(Ct,"ProfileWizard");async function Tt(t,n,i){const r=new Map;i.companyDefault&&r.set(`company:${t}`,{targetType:"company",targetId:t});for(const s of i.agentIds)r.set(`agent:${s}`,{targetType:"agent",targetId:s});for(const s of i.projectIds)r.set(`project:${s}`,{targetType:"project",targetId:s});for(const s of i.routineIds)r.set(`routine:${s}`,{targetType:"routine",targetId:s});const d=new Set(["company","agent","project","routine"]),u=new Set(n.bindings.map(s=>`${s.targetType}:${s.targetId}`)),g=[...[...r.entries()].filter(([s])=>!u.has(s)).map(([s,h])=>({key:s,apply:a(()=>T.bindProfile(t,n.id,h),"apply"),rollback:a(()=>T.unbindProfile(t,n.id,h),"rollback")})),...n.bindings.filter(s=>d.has(s.targetType)&&!r.has(`${s.targetType}:${s.targetId}`)).map(s=>{const h={targetType:s.targetType,targetId:s.targetId};return{key:`${s.targetType}:${s.targetId}`,apply:a(()=>T.unbindProfile(t,n.id,h),"apply"),rollback:a(()=>T.bindProfile(t,n.id,h),"rollback")}})],x=[];for(const s of g)try{await s.apply(),x.push(s)}catch(h){const c=(await Promise.allSettled(x.reverse().map(f=>f.rollback()))).filter(f=>f.status==="rejected").length,o=c>0?`; ${c} rollback operation(s) also failed`:"";throw new Error(`Could not update assignment ${s.key}${o}`,{cause:h})}}a(Tt,"reconcileBindings");function At({current:t}){return(0,e.jsx)("ol",{className:"flex items-center gap-2 text-sm",children:Ce.map(({step:n,label:i},r)=>{const d=t>n,u=t===n;return(0,e.jsxs)("li",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:$("inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-semibold",u&&"bg-accent text-accent-ink",d&&"bg-accent/20 text-accent",!u&&!d&&"bg-bg-3 text-ink-3"),children:d?(0,e.jsx)(Ge,{className:"h-3.5 w-3.5"}):n}),(0,e.jsx)("span",{className:$("font-medium",u?"text-ink":"text-ink-3"),children:i}),r<Ce.length-1?(0,e.jsx)("span",{className:"mx-1 text-ink-3",children:"→"}):null]},n)})})}a(At,"Stepper");function It({template:t,onTemplate:n,copyFromId:i,onCopyFrom:r,copyOptions:d,name:u,onName:g,description:x,onDescription:s,profileKey:h,onProfileKey:c}){const[o,f]=(0,p.useState)(!1);return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink",children:"Start from"}),(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:$e.map(m=>(0,e.jsxs)("button",{type:"button",onClick:a(()=>n(m.key),"onClick"),className:$("flex flex-col items-start gap-1 rounded-md border px-4 py-3 text-left transition-colors",t===m.key?"border-accent bg-accent/5 ring-1 ring-accent":"border-line hover:border-accent/40 hover:bg-bg-3/40"),children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:m.title}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:m.description})]},m.key))})]}),t==="copy"?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink",children:"Which profile?"}),d.length===0?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"You don't have another profile to copy yet."}):(0,e.jsx)("div",{className:"space-y-1.5",children:d.map(m=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2.5 rounded-md border border-line px-3 py-2",children:[(0,e.jsx)("input",{type:"radio",name:"copy-from",checked:i===m.id,onChange:a(()=>r(m.id),"onChange")}),(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:m.name})]},m.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(G,{htmlFor:"profile-name",children:"Name"}),(0,e.jsx)(K,{id:"profile-name",value:u,onChange:a(m=>g(m.target.value),"onChange"),placeholder:"e.g. Everyday work"})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(G,{htmlFor:"profile-description",children:"Description (optional)"}),(0,e.jsx)(st,{id:"profile-description",value:x,onChange:a(m=>s(m.target.value),"onChange"),placeholder:"What is this profile for?",rows:2})]})]}),(0,e.jsxs)(se,{open:o,onOpenChange:f,children:[(0,e.jsxs)(te,{className:"flex items-center gap-1.5 text-sm text-ink-3 hover:text-ink",children:[(0,e.jsx)(B,{className:$("h-4 w-4 transition-transform",o&&"rotate-180")}),"Advanced"]}),(0,e.jsx)(ee,{className:"pt-2",children:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(G,{htmlFor:"profile-key",children:"Identifier"}),(0,e.jsx)(K,{id:"profile-key",value:h,onChange:a(m=>c(m.target.value),"onChange"),className:"font-mono text-xs"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Used in exports and the API. Auto-filled from the name."})]})})]})]})}a(It,"StepName");function Pt({agents:t,projects:n=[],routines:i=[],profiles:r,selectedAgentIds:d,onToggleAgent:u,selectedProjectIds:g,onToggleProject:x,selectedRoutineIds:s,onToggleRoutine:h,companyDefault:c,onCompanyDefault:o}){const[f,m]=(0,p.useState)(!1),v=(0,p.useMemo)(()=>{const j=new Map;for(const y of r)for(const b of y.bindings)if(b.targetType==="agent"){const R=j.get(b.targetId)??[];R.push(y.name),j.set(b.targetId,R)}return j},[r]),A=r.find(j=>j.summary.isCompanyDefault)?.name??null;return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-line p-4",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-1",checked:c,onChange:a(j=>o(j.target.checked),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Make this the organization default"}),(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["Every agent without its own profile uses this one.",A?` Replaces “${A}”.`:""]})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink",children:"Assign to agents"}),(0,e.jsx)(at,{agents:t,selectedAgentIds:d,onChange:a(j=>{for(const y of t)d.has(y.id)!==j.has(y.id)&&u(y.id)},"onChange"),getDescription:a(j=>{const y=[...v.get(j.id)??[]];return A&&y.push("organization default"),y.length>0?`already has: ${y.join(" · ")}`:"no profiles yet"},"getDescription")}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"If an agent has several profiles, it can use anything any of them allows."})]}),(n.length>0||i.length>0)&&x&&h?(0,e.jsxs)(se,{open:f,onOpenChange:m,className:"rounded-lg border border-line",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"More targets"}),(0,e.jsx)(B,{className:$("h-4 w-4 text-ink-3 transition-transform",f&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-4 border-t border-line px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Assign this profile to a whole project or a scheduled routine instead of (or as well as) individual agents."}),(0,e.jsx)(Te,{label:"Projects",options:n,selected:g??new Set,onToggle:x}),(0,e.jsx)(Te,{label:"Routines",options:i,selected:s??new Set,onToggle:h})]})]}):null]})}a(Pt,"StepAssign");function Te({label:t,options:n,selected:i,onToggle:r}){return n.length===0?null:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h4",{className:"text-xs font-medium text-ink-3",children:t}),(0,e.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:n.map(d=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-ink",children:[(0,e.jsx)("input",{type:"checkbox",checked:i.has(d.id),onChange:a(()=>r(d.id),"onChange")}),d.name]},d.id))})]})}a(Te,"TargetChecklist");function os({mode:t}){const{selectedCompany:n,selectedCompanyId:i}=Ve(),{setBreadcrumbs:r}=tt(),d=Oe(),[u]=qe(),g=u.get("template"),x=Number(u.get("step")),s=$e.some(c=>c.key===g)?g:void 0,h=x===2||x===3?x:void 0;return(0,p.useEffect)(()=>(r([{label:n?.name??"Organization",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:lt("profiles")},{label:t==="edit"?"Resume draft":"New profile"}]),()=>r([])),[r,n?.name,t]),i?(0,e.jsx)(ut,{children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-5 p-4 sm:p-6",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h1",{className:"text-xl font-bold text-ink",children:t==="edit"?"Finish your profile":"New access profile"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Choose which tools this profile allows, then assign it to the agents that need them."})]}),(0,e.jsx)(Ct,{companyId:i,profileId:t==="edit"?d.profileId:void 0,initialTemplate:s,initialStep:h})]})}):(0,e.jsx)("div",{className:"p-6 text-sm text-ink-3",children:"Select an organization to create a profile."})}a(os,"ProfileWizardRoute");export{os as ProfileWizardRoute};
|
|
1
|
+
var Me=Object.defineProperty;var a=(t,n)=>Me(t,"name",{value:n,configurable:!0});import{i as Ae}from"./rolldown-runtime-ZpX3ckPj.js";import{l as $,na as ze,ta as Fe}from"./createLucideIcon-DJi9suAC.js";import{v as Oe,y as qe}from"./star-BZgQbzhV.js";import{X as Ue,_ as ve,t as ye}from"./queryKeys-DYV5MhM_.js";import{n as Ve}from"./CompanyContext-CSrVsSze.js";import{o as We,t as Ye}from"./router-2UfGeejU.js";import{n as ee,r as te,t as se}from"./collapsible-CqjPlqOa.js";import{t as be}from"./checkbox-BHQhs41k.js";import{t as G}from"./label-BPz3pg9_.js";import{t as Ge}from"./check-Ctsrlfa-.js";import{t as B}from"./chevron-down-BCvxsWfI.js";import{t as Qe}from"./chevron-right-s7L6hXXq.js";import{r as Q,t as P}from"./button-CMwV3L1P.js";import{t as He}from"./plug-VjpaJcMq.js";import{t as Xe}from"./plus-C6fnr28l.js";import{t as Je}from"./search-04O7m-IF.js";import{t as Ze}from"./x-DRDFdlYE.js";import{t as Ie}from"./badge-DuA2EgZC.js";import{i as et}from"./ToastContext-DMdt9oTd.js";import{t as K}from"./input-DobnTAyB.js";import{t as T}from"./tools-B-L_sU_9.js";import{n as tt}from"./BreadcrumbContext-BVZDZoC0.js";import{t as st}from"./textarea-BRPEfJ-g.js";import{t as at}from"./AgentMultiSelect-DsJfZtR2.js";import{i as _,n as H,o as X,r as J,s as Z}from"./select-V0Hm_q4f.js";import{t as nt}from"./chip-DsDe6yck.js";import{Hr as lt}from"./index-3AxqhPET.js";import{i as Pe}from"./shared-4LF6wQ38.js";import{a as it,c as rt,d as ot,f as ct,i as dt,l as Ne,n as Le,o as ke,p as _e,r as $e,s as mt,t as pt,u as xt}from"./useProfilesData-2L3_71Ql.js";import{t as ut}from"./ToolsAdminGate-BI5-WYC3.js";var p=Ae(ze(),1),e=Ae(Fe(),1),ht=["read","write","destructive"],ft={read:"outline",write:"secondary",destructive:"destructive"};function gt(t){const{appGroups:n,catalogLoading:i,selections:r,onSelectionsChange:d}=t,[u,g]=(0,p.useState)(""),[x,s]=(0,p.useState)(null),h=(0,p.useMemo)(()=>{const c=u.trim().toLowerCase();return n.map(o=>({group:o,tools:o.tools.filter(f=>x&&_e(f)!==x?!1:c?f.toolName.toLowerCase().includes(c)||(f.title??"").toLowerCase().includes(c)||o.name.toLowerCase().includes(c):!0)})).filter(o=>o.tools.length>0)},[n,u,x]);return i?(0,e.jsx)(Pe,{label:"Loading tools…"}):n.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-dashed border-line py-12 text-center",children:[(0,e.jsx)(He,{className:"h-6 w-6 text-ink-3"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"App connections are coming soon"}),(0,e.jsx)("p",{className:"mx-auto max-w-sm text-sm text-ink-3",children:"Profiles will be available once app connections are ready. Browse the planned integrations in the meantime."})]}),(0,e.jsx)(P,{asChild:!0,variant:"secondary",children:(0,e.jsx)(Ye,{to:"/apps",children:"Browse app connections"})})]}):(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative min-w-(--sz-220px) flex-1",children:[(0,e.jsx)(Je,{className:"pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-ink-3"}),(0,e.jsx)(K,{value:u,onChange:a(c=>g(c.target.value),"onChange"),placeholder:"Search tools…",className:"pl-8"})]}),(0,e.jsx)("div",{className:"flex items-center gap-1.5",children:ht.map(c=>(0,e.jsx)(nt,{selected:x===c,onClick:a(()=>s(o=>o===c?null:c),"onClick"),children:Le[c]},c))})]}),h.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-dashed border-line py-10 text-center",children:[(0,e.jsxs)("p",{className:"text-sm font-medium text-ink",children:["No tools match “",u,"”."]}),(0,e.jsx)("button",{type:"button",onClick:a(()=>{g(""),s(null)},"onClick"),className:"text-sm font-medium text-accent hover:underline",children:"Clear search"})]}):(0,e.jsx)("div",{className:"divide-y divide-line overflow-hidden rounded-lg border border-line",children:h.map(({group:c,tools:o})=>(0,e.jsx)(jt,{group:c,visibleTools:o,selection:r[c.appKey],onToggleApp:a(()=>d({...r,[c.appKey]:ot(c,r[c.appKey])}),"onToggleApp"),onToggleTool:a(f=>d({...r,[c.appKey]:ct(c,r[c.appKey],f)}),"onToggleTool")},c.appKey))}),(0,e.jsx)(vt,{value:t.newToolsAction,onChange:t.onNewToolsActionChange}),(0,e.jsx)(kt,{rules:t.advancedRules,onChange:t.onAdvancedRulesChange})]})}a(gt,"WizardToolsStep");function jt({group:t,visibleTools:n,selection:i,onToggleApp:r,onToggleTool:d}){const[u,g]=(0,p.useState)(!1),x=dt(t,i);return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 px-3 py-2",children:[(0,e.jsx)(be,{checked:x==="checked"?!0:x==="indeterminate"?"indeterminate":!1,onCheckedChange:r,"aria-label":`All ${t.name} tools`}),(0,e.jsxs)("button",{type:"button",onClick:a(()=>g(s=>!s),"onClick"),className:"flex flex-1 items-center gap-1.5 text-left",children:[u?(0,e.jsx)(B,{className:"h-4 w-4 shrink-0 text-ink-3"}):(0,e.jsx)(Qe,{className:"h-4 w-4 shrink-0 text-ink-3"}),(0,e.jsxs)("span",{className:"flex flex-col",children:[(0,e.jsxs)("span",{className:"text-sm font-medium text-ink",children:["All ",t.name," tools (",t.tools.length,")"]}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:x==="indeterminate"?it(t,i):"includes tools "+t.name+" adds later"})]})]})]}),u?(0,e.jsx)("div",{className:"space-y-0.5 border-t border-line bg-bg-3/20 px-3 py-2 pl-10",children:n.map(s=>{const h=_e(s);return(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md px-1.5 py-1.5 hover:bg-bg-3/50",children:[(0,e.jsx)(be,{className:"mt-0.5",checked:rt(t,i,s.id),onCheckedChange:a(()=>d(s.id),"onCheckedChange")}),(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("code",{className:"font-mono text-xs text-ink",children:s.toolName}),(0,e.jsx)(Ie,{variant:ft[h],className:"text-(length:--text-nano)",children:Le[h]})]}),s.title||s.description?(0,e.jsx)("span",{className:"text-xs text-ink-3",children:s.title??s.description}):null]})]},s.id)})}):null]})}a(jt,"AppRow");function vt({value:t,onChange:n}){return(0,e.jsxs)("fieldset",{className:"space-y-2 rounded-lg border border-line p-4",children:[(0,e.jsx)("legend",{className:"px-1 text-sm font-medium text-ink",children:"New tools that appear later"}),(0,e.jsx)("div",{className:"space-y-2",children:[{value:"deny",label:"Stay blocked until someone allows them",hint:"New tools an app adds later won't be usable until you review them.",recommended:!0},{value:"allow",label:"Allowed automatically",hint:"Any tool an app adds later becomes usable right away."}].map(i=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-start gap-2.5",children:[(0,e.jsx)("input",{type:"radio",name:"new-tools-action",className:"mt-0.5",checked:t===i.value,onChange:a(()=>n(i.value),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-ink",children:[i.label,i.recommended?(0,e.jsx)(Ie,{variant:"outline",className:"text-(length:--text-nano)",children:"Recommended"}):(0,e.jsx)("span",{className:"text-xs font-normal text-amber-600",children:"(risky)"})]}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:i.hint})]})]},i.value))})]})}a(vt,"NewToolsRadio");var yt=[{value:"tool_name",label:"Tool name pattern"},{value:"risk_level",label:"Risk level"},{value:"catalog_entry",label:"By tool ID"}];function bt(){const t=globalThis.crypto?.randomUUID?.();return t||`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}a(bt,"createAdvancedRuleId");function Nt(t){const n=t.effect==="include"?"Allow":"Block";return t.kind==="tool_name"?`${n} tools matching ${t.value}`:t.kind==="risk_level"?`${n} ${t.riskLevel??t.value} tools`:`${n} tool ${t.value}`}a(Nt,"ruleSummary");function kt({rules:t,onChange:n}){const[i,r]=(0,p.useState)(!1),[d,u]=(0,p.useState)("tool_name"),[g,x]=(0,p.useState)(""),[s,h]=(0,p.useState)("include"),c=a(()=>{const o=g.trim();if(!o&&d!=="risk_level")return;const f={id:bt(),kind:d,value:d==="risk_level"?o||"destructive":o,riskLevel:d==="risk_level"?o||"destructive":void 0,effect:s};n([...t,f]),x("")},"addRule");return(0,e.jsxs)(se,{open:i,onOpenChange:r,className:"rounded-lg border border-line",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Advanced rules"}),(0,e.jsx)(B,{className:$("h-4 w-4 text-ink-3 transition-transform",i&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-3 border-t border-line px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Match tools by a name pattern, a risk level, or a specific tool ID. These run on top of the choices above."}),t.length>0?(0,e.jsx)("ul",{className:"space-y-1.5",children:t.map(o=>(0,e.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-md border border-line bg-bg-3/30 px-3 py-1.5 text-sm",children:[(0,e.jsx)("span",{className:"text-ink",children:Nt(o)}),(0,e.jsx)("button",{type:"button","aria-label":"Remove rule",onClick:a(()=>n(t.filter(f=>f.id!==o.id)),"onClick"),className:"text-ink-3 hover:text-bad",children:(0,e.jsx)(Ze,{className:"h-4 w-4"})})]},o.id))}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-end gap-2",children:[(0,e.jsxs)(H,{value:s,onValueChange:a(o=>h(o),"onValueChange"),children:[(0,e.jsx)(X,{className:"w-28",children:(0,e.jsx)(Z,{})}),(0,e.jsxs)(J,{children:[(0,e.jsx)(_,{value:"include",children:"Allow"}),(0,e.jsx)(_,{value:"exclude",children:"Block"})]})]}),(0,e.jsxs)(H,{value:d,onValueChange:a(o=>u(o),"onValueChange"),children:[(0,e.jsx)(X,{className:"w-40",children:(0,e.jsx)(Z,{})}),(0,e.jsx)(J,{children:yt.map(o=>(0,e.jsx)(_,{value:o.value,children:o.label},o.value))})]}),d==="risk_level"?(0,e.jsxs)(H,{value:g||"destructive",onValueChange:x,children:[(0,e.jsx)(X,{className:"w-36",children:(0,e.jsx)(Z,{})}),(0,e.jsxs)(J,{children:[(0,e.jsx)(_,{value:"read",children:"Read-only"}),(0,e.jsx)(_,{value:"write",children:"Makes changes"}),(0,e.jsx)(_,{value:"destructive",children:"Destructive"})]})]}):(0,e.jsx)(K,{value:g,onChange:a(o=>x(o.target.value),"onChange"),placeholder:d==="tool_name"?"e.g. gmail.send*":"tool ID",className:"w-44"}),(0,e.jsxs)(P,{type:"button",variant:"secondary",size:"sm",onClick:c,children:[(0,e.jsx)(Xe,{className:"mr-1 h-3.5 w-3.5"}),"Add rule"]})]})]})]})}a(kt,"AdvancedRules");var Re="wizard";function wt(t){const n=t?.metadata?.[Re];if(!n||typeof n!="object")return null;const i=n,r=i.lastCompletedStep;return r!==1&&r!==2&&r!==3?null:{lastCompletedStep:r,template:typeof i.template=="string"?i.template:null}}a(wt,"readWizardMeta");function we(t,n){return{...t??{},[Re]:n}}a(we,"withWizardMeta");function St(t){return t?Math.min(t.lastCompletedStep+1,3):1}a(St,"resumeStep");function Se(t){return t.trim().toLowerCase().replace(/[^a-z0-9._:-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,160)}a(Se,"slugifyProfileKey");var Ce=[{step:1,label:"Name"},{step:2,label:"Choose tools"},{step:3,label:"Assign"}];function Ct({companyId:t,profileId:n,initialTemplate:i,initialStep:r}){const d=We(),u=Ue(),{pushToast:g}=et(),x=pt(t),{appGroups:s,catalog:h,profiles:c,agents:o}=x,f=c.data?.profiles??[],m=n?f.find(l=>l.id===n)??null:null,[v,A]=(0,p.useState)(1),[j,y]=(0,p.useState)(n??null),[b,R]=(0,p.useState)(i??null),[E,Ee]=(0,p.useState)(null),[I,ae]=(0,p.useState)(""),[M,ne]=(0,p.useState)(""),[z,F]=(0,p.useState)(""),[le,ie]=(0,p.useState)(!1),[L,O]=(0,p.useState)({}),[q,re]=(0,p.useState)([]),[C,oe]=(0,p.useState)("deny"),[U,ce]=(0,p.useState)(new Set),[de,me]=(0,p.useState)(new Set),[pe,xe]=(0,p.useState)(new Set),[V,ue]=(0,p.useState)(!1),W=a(l=>N=>l(k=>{const w=new Set(k);return w.has(N)?w.delete(N):w.add(N),w}),"toggleIn"),he=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(he.current||!m||s.length===0||m.id!==n)return;he.current=!0,ae(m.name),ne(m.description??""),F(m.profileKey),ie(!0),oe(m.defaultAction);const l=Ne(s,m.entries);O(l.selections),re(l.advancedRules);const N=wt(m);R(N?.template??null),A(r??(m.status==="draft"?St(N):1));const k=a(w=>new Set(m.bindings.filter(Y=>Y.targetType===w).map(Y=>Y.targetId)),"targetIds");ce(k("agent")),me(k("project")),xe(k("routine")),ue(m.bindings.some(w=>w.targetType==="company"))},[m,s,n,r]),(0,p.useEffect)(()=>{le||F(Se(I))},[I,le]);const fe=a(()=>{u.invalidateQueries({queryKey:ye.tools.profiles(t)}),u.invalidateQueries({queryKey:ye.tools.testAgentAccesses()})},"invalidate"),ge=(0,p.useMemo)(()=>mt(s,L,C,h.length),[s,L,C,h.length]),De=a(()=>{if(b==="copy"&&E){const l=f.find(N=>N.id===E);if(l)return Ne(s,l.entries).selections}return b&&b!=="copy"?xt(b,s):L},"seedSelections"),D=ve({mutationFn:a(async l=>{const N=l.seed??L,k=ke(s,N,q,C),w=we(m?.metadata??null,{lastCompletedStep:l.completedStep,template:b});return j?{created:await T.updateProfile(j,{profileKey:z||void 0,name:I.trim()||"Untitled profile",description:M.trim()||null,defaultAction:C,entries:k,metadata:w}),goToStep:l.goToStep,seed:l.seed}:{created:await T.createProfile(t,{profileKey:z||Se(I)||"profile",name:I.trim()||"Untitled profile",description:M.trim()||null,status:"draft",defaultAction:C,entries:k,metadata:w}),goToStep:l.goToStep,seed:l.seed}},"mutationFn"),onSuccess:a(({created:l,goToStep:N,seed:k})=>{y(l.id),k&&O(k),A(N),fe()},"onSuccess"),onError:a(l=>g({title:"Could not save",body:String(l?.message??l),tone:"error"}),"onError")}),je=ve({mutationFn:a(async()=>{if(!j)throw new Error("No draft to finish");const l=ke(s,L,q,C);return await Tt(t,await T.updateProfile(j,{defaultAction:C,entries:l,metadata:we(m?.metadata??null,{lastCompletedStep:3,template:b})}),{agentIds:[...U],projectIds:[...de],routineIds:[...pe],companyDefault:V}),T.updateProfile(j,{status:"active"})},"mutationFn"),onSuccess:a(l=>{g({title:"Profile saved",tone:"success"}),fe(),d(`/apps/advanced/profiles/${l.id}${U.size===0&&!V?"?created=1":""}`)},"onSuccess"),onError:a(l=>g({title:"Could not save profile",body:String(l?.message??l),tone:"error"}),"onError")}),Ke=a(()=>{const l=v;D.mutate({goToStep:v,completedStep:l},{onSuccess:a(()=>{g({title:"Draft saved",body:"Pick it back up from the profiles list.",tone:"success"}),d("/apps/advanced/profiles")},"onSuccess")})},"saveAndExit"),S=D.isPending||je.isPending,Be=I.trim().length>0&&(b!=="copy"||!!E);return n&&c.isLoading?(0,e.jsx)(Pe,{label:"Loading draft…"}):(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 pb-24",children:[(0,e.jsx)(At,{current:v}),(0,e.jsxs)("div",{className:"min-h-(--sz-320px)",children:[v===1?(0,e.jsx)(It,{template:b,onTemplate:R,copyFromId:E,onCopyFrom:Ee,copyOptions:f.filter(l=>l.status!=="archived"&&l.id!==n),name:I,onName:ae,description:M,onDescription:ne,profileKey:z,onProfileKey:a(l=>{ie(!0),F(l)},"onProfileKey")}):null,v===2?(0,e.jsx)(gt,{appGroups:s,catalogLoading:x.catalogLoading,selections:L,onSelectionsChange:O,advancedRules:q,onAdvancedRulesChange:re,newToolsAction:C,onNewToolsActionChange:oe}):null,v===3?(0,e.jsx)(Pt,{agents:(o.data??[]).map(l=>({id:l.id,name:l.name,title:l.title,icon:l.icon})),projects:(x.projects.data??[]).map(l=>({id:l.id,name:l.name})),routines:(x.routines.data??[]).map(l=>({id:l.id,name:l.title})),profiles:f,selectedAgentIds:U,onToggleAgent:W(ce),selectedProjectIds:de,onToggleProject:W(me),selectedRoutineIds:pe,onToggleRoutine:W(xe),companyDefault:V,onCompanyDefault:ue}):null]}),(0,e.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-10 border-t border-line bg-bg/95 backdrop-blur",children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-3xl items-center justify-between gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 text-sm text-ink-3",children:[v>=2?(0,e.jsxs)("span",{children:["Allows ",(0,e.jsx)("span",{className:"font-medium text-ink",children:ge.allowed})," of ",ge.total," ","tools"]}):null,j?(0,e.jsx)("button",{type:"button",onClick:Ke,disabled:S,className:"font-medium text-accent hover:underline disabled:opacity-50",children:"Save & finish later"}):null]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[v>1?(0,e.jsx)(P,{variant:"secondary",disabled:S,onClick:a(()=>A(l=>l-1),"onClick"),children:"Back"}):(0,e.jsx)(P,{variant:"ghost",disabled:S,onClick:a(()=>d("/apps/advanced/profiles"),"onClick"),children:"Cancel"}),v===1?(0,e.jsxs)(P,{disabled:!Be||S,onClick:a(()=>D.mutate({goToStep:2,completedStep:1,seed:De()}),"onClick"),children:[S?(0,e.jsx)(Q,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,v===2?(0,e.jsxs)(P,{disabled:S,onClick:a(()=>D.mutate({goToStep:3,completedStep:2}),"onClick"),children:[S?(0,e.jsx)(Q,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Continue"]}):null,v===3?(0,e.jsxs)(P,{disabled:S,onClick:a(()=>je.mutate(),"onClick"),children:[S?(0,e.jsx)(Q,{className:"mr-1.5 h-4 w-4 animate-spin"}):null,"Save profile"]}):null]})]})})]})}a(Ct,"ProfileWizard");async function Tt(t,n,i){const r=new Map;i.companyDefault&&r.set(`company:${t}`,{targetType:"company",targetId:t});for(const s of i.agentIds)r.set(`agent:${s}`,{targetType:"agent",targetId:s});for(const s of i.projectIds)r.set(`project:${s}`,{targetType:"project",targetId:s});for(const s of i.routineIds)r.set(`routine:${s}`,{targetType:"routine",targetId:s});const d=new Set(["company","agent","project","routine"]),u=new Set(n.bindings.map(s=>`${s.targetType}:${s.targetId}`)),g=[...[...r.entries()].filter(([s])=>!u.has(s)).map(([s,h])=>({key:s,apply:a(()=>T.bindProfile(t,n.id,h),"apply"),rollback:a(()=>T.unbindProfile(t,n.id,h),"rollback")})),...n.bindings.filter(s=>d.has(s.targetType)&&!r.has(`${s.targetType}:${s.targetId}`)).map(s=>{const h={targetType:s.targetType,targetId:s.targetId};return{key:`${s.targetType}:${s.targetId}`,apply:a(()=>T.unbindProfile(t,n.id,h),"apply"),rollback:a(()=>T.bindProfile(t,n.id,h),"rollback")}})],x=[];for(const s of g)try{await s.apply(),x.push(s)}catch(h){const c=(await Promise.allSettled(x.reverse().map(f=>f.rollback()))).filter(f=>f.status==="rejected").length,o=c>0?`; ${c} rollback operation(s) also failed`:"";throw new Error(`Could not update assignment ${s.key}${o}`,{cause:h})}}a(Tt,"reconcileBindings");function At({current:t}){return(0,e.jsx)("ol",{className:"flex items-center gap-2 text-sm",children:Ce.map(({step:n,label:i},r)=>{const d=t>n,u=t===n;return(0,e.jsxs)("li",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:$("inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-semibold",u&&"bg-accent text-accent-ink",d&&"bg-accent/20 text-accent",!u&&!d&&"bg-bg-3 text-ink-3"),children:d?(0,e.jsx)(Ge,{className:"h-3.5 w-3.5"}):n}),(0,e.jsx)("span",{className:$("font-medium",u?"text-ink":"text-ink-3"),children:i}),r<Ce.length-1?(0,e.jsx)("span",{className:"mx-1 text-ink-3",children:"→"}):null]},n)})})}a(At,"Stepper");function It({template:t,onTemplate:n,copyFromId:i,onCopyFrom:r,copyOptions:d,name:u,onName:g,description:x,onDescription:s,profileKey:h,onProfileKey:c}){const[o,f]=(0,p.useState)(!1);return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink",children:"Start from"}),(0,e.jsx)("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:$e.map(m=>(0,e.jsxs)("button",{type:"button",onClick:a(()=>n(m.key),"onClick"),className:$("flex flex-col items-start gap-1 rounded-md border px-4 py-3 text-left transition-colors",t===m.key?"border-accent bg-accent/5 ring-1 ring-accent":"border-line hover:border-accent/40 hover:bg-bg-3/40"),children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:m.title}),(0,e.jsx)("span",{className:"text-xs text-ink-3",children:m.description})]},m.key))})]}),t==="copy"?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink",children:"Which profile?"}),d.length===0?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"You don't have another profile to copy yet."}):(0,e.jsx)("div",{className:"space-y-1.5",children:d.map(m=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2.5 rounded-md border border-line px-3 py-2",children:[(0,e.jsx)("input",{type:"radio",name:"copy-from",checked:i===m.id,onChange:a(()=>r(m.id),"onChange")}),(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:m.name})]},m.id))})]}):null,(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(G,{htmlFor:"profile-name",children:"Name"}),(0,e.jsx)(K,{id:"profile-name",value:u,onChange:a(m=>g(m.target.value),"onChange"),placeholder:"e.g. Everyday work"})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(G,{htmlFor:"profile-description",children:"Description (optional)"}),(0,e.jsx)(st,{id:"profile-description",value:x,onChange:a(m=>s(m.target.value),"onChange"),placeholder:"What is this profile for?",rows:2})]})]}),(0,e.jsxs)(se,{open:o,onOpenChange:f,children:[(0,e.jsxs)(te,{className:"flex items-center gap-1.5 text-sm text-ink-3 hover:text-ink",children:[(0,e.jsx)(B,{className:$("h-4 w-4 transition-transform",o&&"rotate-180")}),"Advanced"]}),(0,e.jsx)(ee,{className:"pt-2",children:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(G,{htmlFor:"profile-key",children:"Identifier"}),(0,e.jsx)(K,{id:"profile-key",value:h,onChange:a(m=>c(m.target.value),"onChange"),className:"font-mono text-xs"}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Used in exports and the API. Auto-filled from the name."})]})})]})]})}a(It,"StepName");function Pt({agents:t,projects:n=[],routines:i=[],profiles:r,selectedAgentIds:d,onToggleAgent:u,selectedProjectIds:g,onToggleProject:x,selectedRoutineIds:s,onToggleRoutine:h,companyDefault:c,onCompanyDefault:o}){const[f,m]=(0,p.useState)(!1),v=(0,p.useMemo)(()=>{const j=new Map;for(const y of r)for(const b of y.bindings)if(b.targetType==="agent"){const R=j.get(b.targetId)??[];R.push(y.name),j.set(b.targetId,R)}return j},[r]),A=r.find(j=>j.summary.isCompanyDefault)?.name??null;return(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-line p-4",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-1",checked:c,onChange:a(j=>o(j.target.checked),"onChange")}),(0,e.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"Make this the organization default"}),(0,e.jsxs)("span",{className:"text-xs text-ink-3",children:["Every agent without its own profile uses this one.",A?` Replaces “${A}”.`:""]})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium text-ink",children:"Assign to agents"}),(0,e.jsx)(at,{agents:t,selectedAgentIds:d,onChange:a(j=>{for(const y of t)d.has(y.id)!==j.has(y.id)&&u(y.id)},"onChange"),getDescription:a(j=>{const y=[...v.get(j.id)??[]];return A&&y.push("organization default"),y.length>0?`already has: ${y.join(" · ")}`:"no profiles yet"},"getDescription")}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"If an agent has several profiles, it can use anything any of them allows."})]}),(n.length>0||i.length>0)&&x&&h?(0,e.jsxs)(se,{open:f,onOpenChange:m,className:"rounded-lg border border-line",children:[(0,e.jsxs)(te,{className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,e.jsx)("span",{className:"text-sm font-medium text-ink",children:"More targets"}),(0,e.jsx)(B,{className:$("h-4 w-4 text-ink-3 transition-transform",f&&"rotate-180")})]}),(0,e.jsxs)(ee,{className:"space-y-4 border-t border-line px-4 py-3",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Assign this profile to a whole project or a scheduled routine instead of (or as well as) individual agents."}),(0,e.jsx)(Te,{label:"Projects",options:n,selected:g??new Set,onToggle:x}),(0,e.jsx)(Te,{label:"Routines",options:i,selected:s??new Set,onToggle:h})]})]}):null]})}a(Pt,"StepAssign");function Te({label:t,options:n,selected:i,onToggle:r}){return n.length===0?null:(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("h4",{className:"text-xs font-medium text-ink-3",children:t}),(0,e.jsx)("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5",children:n.map(d=>(0,e.jsxs)("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-ink",children:[(0,e.jsx)("input",{type:"checkbox",checked:i.has(d.id),onChange:a(()=>r(d.id),"onChange")}),d.name]},d.id))})]})}a(Te,"TargetChecklist");function os({mode:t}){const{selectedCompany:n,selectedCompanyId:i}=Ve(),{setBreadcrumbs:r}=tt(),d=Oe(),[u]=qe(),g=u.get("template"),x=Number(u.get("step")),s=$e.some(c=>c.key===g)?g:void 0,h=x===2||x===3?x:void 0;return(0,p.useEffect)(()=>(r([{label:n?.name??"Organization",href:"/dashboard"},{label:"Apps",href:"/apps"},{label:"Access profiles",href:lt("profiles")},{label:t==="edit"?"Resume draft":"New profile"}]),()=>r([])),[r,n?.name,t]),i?(0,e.jsx)(ut,{children:(0,e.jsxs)("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-5 p-4 sm:p-6",children:[(0,e.jsxs)("header",{children:[(0,e.jsx)("h1",{className:"text-xl font-bold text-ink",children:t==="edit"?"Finish your profile":"New access profile"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Choose which tools this profile allows, then assign it to the agents that need them."})]}),(0,e.jsx)(Ct,{companyId:i,profileId:t==="edit"?d.profileId:void 0,initialTemplate:s,initialStep:h})]})}):(0,e.jsx)("div",{className:"p-6 text-sm text-ink-3",children:"Select an organization to create a profile."})}a(os,"ProfileWizardRoute");export{os as ProfileWizardRoute};
|