@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.
Files changed (140) hide show
  1. package/dist/assets/{ActiveAgentsPanel-Budj8e9v.js → ActiveAgentsPanel-CF0fwsze.js} +1 -1
  2. package/dist/assets/{AdapterManager-DhiW44Eo.js → AdapterManager-DUXWwNxv.js} +1 -1
  3. package/dist/assets/{AdvancedToolsRoute-CICI1XRd.js → AdvancedToolsRoute-BamlkE3p.js} +1 -1
  4. package/dist/assets/{AgentActionButtons-DIhpv51Y.js → AgentActionButtons-CPIhsP04.js} +1 -1
  5. package/dist/assets/{AgentBubbleActionRow-DIr3TdR9.js → AgentBubbleActionRow-BUAUmJKa.js} +1 -1
  6. package/dist/assets/{AgentChat-CeuGtMXr.js → AgentChat-BAn_ghsu.js} +1 -1
  7. package/dist/assets/{AgentChats-CmDtTrMa.js → AgentChats-f73hodzr.js} +1 -1
  8. package/dist/assets/{AgentDefaults-DpYaMGkf.js → AgentDefaults-BL1XYvEo.js} +1 -1
  9. package/dist/assets/{AgentDetail-DFTeFc4-.js → AgentDetail-DthxFfuB.js} +1 -1
  10. package/dist/assets/{AgentTodoCard-DRXZ7hmU.js → AgentTodoCard-BvgkWD0T.js} +1 -1
  11. package/dist/assets/{Agents-CClUUMUq.js → Agents-D5qI6yZZ.js} +3 -3
  12. package/dist/assets/{AppDetail-DfHLFOtj.js → AppDetail-B6PtMl8J.js} +1 -1
  13. package/dist/assets/{AppNotConnected-CcmXbFtD.js → AppNotConnected-C_tGn786.js} +1 -1
  14. package/dist/assets/{ApprovalCard-uT_9D_uH.js → ApprovalCard-DrfZAdGQ.js} +1 -1
  15. package/dist/assets/{ApprovalDetail-CE41WFbd.js → ApprovalDetail-sfPpfdXc.js} +1 -1
  16. package/dist/assets/{ApprovalPayload-_zU9bukt.js → ApprovalPayload-C4F3ItGH.js} +1 -1
  17. package/dist/assets/{Approvals-BXrjqpKc.js → Approvals-DZoMl7_m.js} +1 -1
  18. package/dist/assets/{AppsConnect-DH7aSjtS.js → AppsConnect-D8Gu187f.js} +1 -1
  19. package/dist/assets/{AppsReview-C0Y3SxmZ.js → AppsReview-DokFETm0.js} +1 -1
  20. package/dist/assets/{ArtifactCard-DKUUBZ0K.js → ArtifactCard-BTf2-JIV.js} +1 -1
  21. package/dist/assets/{Artifacts-Bsv5m0aU.js → Artifacts-CK8FaygC.js} +1 -1
  22. package/dist/assets/{AssistantConnection-Dm2PaSeU.js → AssistantConnection-BlKC7jk0.js} +1 -1
  23. package/dist/assets/{AttentionInteractionResolver-CBjNuhYo.js → AttentionInteractionResolver-C2iz6oqT.js} +1 -1
  24. package/dist/assets/{AuditHub-DbUni0O_.js → AuditHub-DMhunMn8.js} +1 -1
  25. package/dist/assets/{BoardChat-CgzCuFIL.js → BoardChat-C4W8JLKB.js} +1 -1
  26. package/dist/assets/{BootstrapSetupUxLab-D-niQCV5.js → BootstrapSetupUxLab-D58OwniR.js} +1 -1
  27. package/dist/assets/{Browse-0bmB5mqw.js → Browse-BDjohBak.js} +1 -1
  28. package/dist/assets/{BudgetPolicyCard-CqFUHqOj.js → BudgetPolicyCard-DfAAgk9Z.js} +1 -1
  29. package/dist/assets/{CaseDetail-DakrB2jI.js → CaseDetail-CL0FC5sG.js} +1 -1
  30. package/dist/assets/{Cases-DXbr4HJt.js → Cases-C-7dXrEt.js} +1 -1
  31. package/dist/assets/{ChatEndpointDetail-BdDKo-Gq.js → ChatEndpointDetail-C-IYAYG8.js} +1 -1
  32. package/dist/assets/{ChatEndpointSetup-BX3iDH7N.js → ChatEndpointSetup-CM3QixMj.js} +1 -1
  33. package/dist/assets/{ChoiceControls-Bu-fd6qI.js → ChoiceControls-3Qpci4yE.js} +1 -1
  34. package/dist/assets/{Companies-FcUNLIkt.js → Companies-97toQ8Cw.js} +1 -1
  35. package/dist/assets/{CompanyAccess-BUcTNg7_.js → CompanyAccess-CKhS1BaS.js} +1 -1
  36. package/dist/assets/{CompanyActivity-ScpRBz1G.js → CompanyActivity-DzNrAyAb.js} +1 -1
  37. package/dist/assets/{CompanyConnections-DMEwbZv7.js → CompanyConnections-ORCH4i3U.js} +1 -1
  38. package/dist/assets/{CompanyEnvironments-EqXhVruZ.js → CompanyEnvironments-DphURbtb.js} +1 -1
  39. package/dist/assets/{CompanyExport-DQ9ffuua.js → CompanyExport-XeVCUcK3.js} +1 -1
  40. package/dist/assets/{CompanyImport-BhuZu4oc.js → CompanyImport-DPKpUaRa.js} +1 -1
  41. package/dist/assets/{CompanySettings-BSkg4ahA.js → CompanySettings-4JQpzuS1.js} +1 -1
  42. package/dist/assets/{CompanySettingsPluginPage-BzZkZqh-.js → CompanySettingsPluginPage-cVvXh0_G.js} +1 -1
  43. package/dist/assets/{CompanySkills-BbA4RKIw.js → CompanySkills-BA_9Ztwj.js} +1 -1
  44. package/dist/assets/{ComposerAddMenu-D9z2INup.js → ComposerAddMenu-DNp4ecG8.js} +1 -1
  45. package/dist/assets/{ConfigureBuiltInAgentModal-BUJPbmWc.js → ConfigureBuiltInAgentModal-CQCHDkl4.js} +1 -1
  46. package/dist/assets/{ConnectionSetupFlow-DKjP5RBZ.js → ConnectionSetupFlow-BaarToKu.js} +1 -1
  47. package/dist/assets/{CopyableGatewayUrl-BZyE_jT9.js → CopyableGatewayUrl-DxQsV7Hr.js} +1 -1
  48. package/dist/assets/{Dashboard--lTwxjV-.js → Dashboard--iaPJqJp.js} +1 -1
  49. package/dist/assets/{DashboardLive-BYyTgF5d.js → DashboardLive-4rGeotay.js} +1 -1
  50. package/dist/assets/{DecisionDateChips-vXwAFdua.js → DecisionDateChips-CJOLtNrJ.js} +1 -1
  51. package/dist/assets/{DecisionModelSettings-NrNERkaW.js → DecisionModelSettings-D-OxKIGP.js} +1 -1
  52. package/dist/assets/{DecisionQueuePage-BaaKuZBi.js → DecisionQueuePage-D-kNFav_.js} +1 -1
  53. package/dist/assets/{DesignGuide-DS6MuXWY.js → DesignGuide-D7486q4b.js} +1 -1
  54. package/dist/assets/{DocumentFrameHeader-DTSqcw4Q.js → DocumentFrameHeader-B61HhahB.js} +1 -1
  55. package/dist/assets/{EmailEndpointSetup-CJFYu2G0.js → EmailEndpointSetup-6OHb9B4q.js} +1 -1
  56. package/dist/assets/{ExecutionWorkspaceDetail-CuD5xWOB.js → ExecutionWorkspaceDetail-BGV-9D5Y.js} +1 -1
  57. package/dist/assets/{FolderControls-B7TWghGc.js → FolderControls-L2RzbfdQ.js} +1 -1
  58. package/dist/assets/{GatewayDetail-xNVOxSIs.js → GatewayDetail-CdXNQ9gD.js} +1 -1
  59. package/dist/assets/{GatewaysList-DsSKLm1h.js → GatewaysList-B0Jq1IRC.js} +1 -1
  60. package/dist/assets/{GoalDetail-oN5pyUUY.js → GoalDetail-D2VhPtvw.js} +1 -1
  61. package/dist/assets/{GoalTree-DaFizciF.js → GoalTree-kFpgH4dA.js} +1 -1
  62. package/dist/assets/{Goals-xgGKfQZi.js → Goals-B-_gq_Qu.js} +1 -1
  63. package/dist/assets/{ImageGalleryModal-CjHED0Lb.js → ImageGalleryModal-DzKBMOnu.js} +1 -1
  64. package/dist/assets/{Inbox-wHhHozfr.js → Inbox-zllmqRcB.js} +1 -1
  65. package/dist/assets/{InstanceAdvanced-Bdf2a4c_.js → InstanceAdvanced-B7tDfjwG.js} +1 -1
  66. package/dist/assets/{InviteLanding-McBYpNeW.js → InviteLanding-brwa_8NC.js} +1 -1
  67. package/dist/assets/{IssueChatLongThreadPerf-DD3RLbBo.js → IssueChatLongThreadPerf-D0HJe6IV.js} +1 -1
  68. package/dist/assets/{IssueChatThread-BN-_8hT8.js → IssueChatThread-CMXzuvrF.js} +1 -1
  69. package/dist/assets/{IssueDetail-CsaD311l.js → IssueDetail-DGdg-mB8.js} +1 -1
  70. package/dist/assets/{IssueDocumentAnnotations-BVdH4RTa.js → IssueDocumentAnnotations-BK-LgExc.js} +1 -1
  71. package/dist/assets/{IssueOutputSection-CDIMRaF0.js → IssueOutputSection-aSyiE1pg.js} +1 -1
  72. package/dist/assets/{IssueRecoveryActionCard-C9qJAHes.js → IssueRecoveryActionCard-vAuL_OEC.js} +1 -1
  73. package/dist/assets/{IssueThreadInteractionCard-BbigJB2U.js → IssueThreadInteractionCard-wFidFTIh.js} +1 -1
  74. package/dist/assets/{Issues-BWoc80Y9.js → Issues-CsmM33z_.js} +1 -1
  75. package/dist/assets/{LiveNowTodoLine-B9oTH2L0.js → LiveNowTodoLine-CP32NNp_.js} +1 -1
  76. package/dist/assets/{ManagedAiConnectionDetails-B0aWUPkf.js → ManagedAiConnectionDetails-Ba0awZ-O.js} +1 -1
  77. package/dist/assets/{McpConnect-Dzf7W2K6.js → McpConnect-CYLP1yLX.js} +1 -1
  78. package/dist/assets/{MembershipAction-oiLtxQm3.js → MembershipAction-CKs7Ua9x.js} +1 -1
  79. package/dist/assets/{ModelsAndProviders-BEb4Z38S.js → ModelsAndProviders-gaR7HDQm.js} +1 -1
  80. package/dist/assets/{NewAgent-C3MxIRJj.js → NewAgent-DBQzvxIr.js} +1 -1
  81. package/dist/assets/{OmpAllSettings-DBtL1qDL.js → OmpAllSettings-B_Knr51Z.js} +1 -1
  82. package/dist/assets/{PipelineSettings-BcAtsehE.js → PipelineSettings-Dl-94FB5.js} +1 -1
  83. package/dist/assets/{Pipelines-CkiYUQS-.js → Pipelines-CY9hGe0h.js} +1 -1
  84. package/dist/assets/{PixelsOffice-BSlctoug.js → PixelsOffice-BgyGZsiV.js} +1 -1
  85. package/dist/assets/{PluginPage-C6Qnf9ka.js → PluginPage-CMA4Ei50.js} +1 -1
  86. package/dist/assets/{PluginSettings-Do37r6Zu.js → PluginSettings-Cm4H1JRT.js} +1 -1
  87. package/dist/assets/{ProfileDetailRoute-DRFQNId6.js → ProfileDetailRoute-BEBctbC6.js} +1 -1
  88. package/dist/assets/{ProfileSettings-BMwLBQDB.js → ProfileSettings-Djo7BLIj.js} +1 -1
  89. package/dist/assets/{ProfileWizardRoute-XnnvzH9S.js → ProfileWizardRoute-DxLujEtD.js} +1 -1
  90. package/dist/assets/{ProjectDetail-BW6Lr4Iq.js → ProjectDetail-CmmdvUHn.js} +1 -1
  91. package/dist/assets/{ProjectWorkspaceDetail-DR4JCa1b.js → ProjectWorkspaceDetail-BsA0hJ-k.js} +1 -1
  92. package/dist/assets/{ProjectWorkspacesContent-CadPZn0k.js → ProjectWorkspacesContent-BNNI_WAk.js} +1 -1
  93. package/dist/assets/{Projects-DLBFbxcj.js → Projects-BTAauZr0.js} +1 -1
  94. package/dist/assets/{PublicIssueSharePage-C9yRZOdP.js → PublicIssueSharePage-DdPjfmD9.js} +1 -1
  95. package/dist/assets/{ReviewQueueCard-CIkiY-Lm.js → ReviewQueueCard-BC6VY8Bc.js} +1 -1
  96. package/dist/assets/{RichWorkProductCard-JGHGU_RI.js → RichWorkProductCard-ClpMt_Bh.js} +1 -1
  97. package/dist/assets/{RoutineDetail-izWzADvA.js → RoutineDetail-BT6_GKnC.js} +1 -1
  98. package/dist/assets/{RoutineRunVariablesDialog-DiT_o5Dm.js → RoutineRunVariablesDialog-D_Mls1sV.js} +1 -1
  99. package/dist/assets/{Routines-CHtabiYj.js → Routines-4LevOfvV.js} +1 -1
  100. package/dist/assets/{ScrollToBottom-pyHLjOjY.js → ScrollToBottom-jItsgDR8.js} +1 -1
  101. package/dist/assets/{Search-yNNB6kys.js → Search-bmcm0_m_.js} +1 -1
  102. package/dist/assets/{Secrets-BOyOk5BF.js → Secrets-DfR1fBAZ.js} +1 -1
  103. package/dist/assets/{SkillSourceTree-M58QwBFF.js → SkillSourceTree--FWKWyF3.js} +1 -1
  104. package/dist/assets/{SkillSources-Cw4PU-Bz.js → SkillSources-jUDjqy5i.js} +1 -1
  105. package/dist/assets/{SkillStudio-Cj_M3ZJa.js → SkillStudio-BsqtUnzF.js} +1 -1
  106. package/dist/assets/{SourceTrustBadge-BZBQe5No.js → SourceTrustBadge-CfBrvKL3.js} +1 -1
  107. package/dist/assets/{StatusCards-DaJdQUN5.js → StatusCards-Dt3zorUZ.js} +1 -1
  108. package/dist/assets/{SummarySlotCard-DlSmN6PL.js → SummarySlotCard-D1C0qH2L.js} +1 -1
  109. package/dist/assets/{TaskChatLab-CU5eA7nX.js → TaskChatLab-B0coUvdp.js} +1 -1
  110. package/dist/assets/{TaskChatMarker-wBVUFL3u.js → TaskChatMarker-C40twVjh.js} +1 -1
  111. package/dist/assets/{TaskChatProtocolCard-D-Dwy2EL.js → TaskChatProtocolCard--bi_tc6i.js} +1 -1
  112. package/dist/assets/{TaskChatThreadView-Crlf9I05.js → TaskChatThreadView-DkzFDrLW.js} +1 -1
  113. package/dist/assets/{TaskDetailRelationsPanel-CkktN1EC.js → TaskDetailRelationsPanel-DZGkinoJ.js} +1 -1
  114. package/dist/assets/{TaskTreeControls-B_ulMOi1.js → TaskTreeControls-DznugVpi.js} +1 -1
  115. package/dist/assets/Terminal-NjEb5-2b.js +1 -0
  116. package/dist/assets/TerminalView-DZxK2Ei5.js +58 -0
  117. package/dist/assets/{TrustPresetSection-DTc1Rj4q.js → TrustPresetSection-CjNwNBo3.js} +1 -1
  118. package/dist/assets/{UserProfile-C6q55R0Q.js → UserProfile-Dujv3qdz.js} +1 -1
  119. package/dist/assets/{WhatNeedsMe-1igJA4gL.js → WhatNeedsMe-C9P2EsqQ.js} +1 -1
  120. package/dist/assets/{Workspaces-rtQKliW0.js → Workspaces-BTgSx9nA.js} +1 -1
  121. package/dist/assets/{connection-owner-CZwxTEuM.js → connection-owner-DL4yKhSt.js} +1 -1
  122. package/dist/assets/dist-ypeTPGg_.js +1 -0
  123. package/dist/assets/dropdown-menu-DEO3mF_E.js +1 -0
  124. package/dist/assets/{environment-variables-editor-CCxeFKKk.js → environment-variables-editor-0qgSPgNN.js} +1 -1
  125. package/dist/assets/{index-DDoARkPG.js → index-3AxqhPET.js} +4 -4
  126. package/dist/assets/index-B5bd7Tk6.css +2 -0
  127. package/dist/assets/{issue-properties-lmRBaUTG.js → issue-properties-B1cYnBDU.js} +1 -1
  128. package/dist/assets/{issue-workspace-selection-4JI2Uh9p.js → issue-workspace-selection-S8UgGgK1.js} +1 -1
  129. package/dist/assets/{pipeline-stage-presentation-BSuBql6K.js → pipeline-stage-presentation-5UBw7nsb.js} +1 -1
  130. package/dist/assets/{shared-DDwmHbeD.js → shared-4LF6wQ38.js} +1 -1
  131. package/dist/assets/{tool-taxonomy-DR7Q8sVs.js → tool-taxonomy-B5zpbkHA.js} +1 -1
  132. package/dist/assets/{transcript-adapter-wiFIjKfq.js → transcript-adapter-C29ZJiU2.js} +1 -1
  133. package/dist/assets/{useSummaryDraftStream-CWOQt25o.js → useSummaryDraftStream-R2Y2bAUU.js} +1 -1
  134. package/dist/index.html +7 -6
  135. package/dist/sw.js +1 -1
  136. package/package.json +1 -1
  137. package/dist/assets/Terminal-Bo-WuezO.js +0 -1
  138. package/dist/assets/TerminalView-AkFY5bLC.js +0 -58
  139. package/dist/assets/dropdown-menu-CqRAF7Oj.js +0 -1
  140. package/dist/assets/index-KZ2bEg2H.css +0 -2
@@ -1 +1 @@
1
- var We=Object.defineProperty;var a=(s,n)=>We(s,"name",{value:n,configurable:!0});import{i as ge}from"./rolldown-runtime-ZpX3ckPj.js";import{T as Ie,l as H,na as we,ta as Ne}from"./createLucideIcon-DJi9suAC.js";import{t as K,v as G}from"./queryKeys-DYV5MhM_.js";import{n as ye}from"./CompanyContext-CSrVsSze.js";import{ot as ae,t as Z}from"./router-2UfGeejU.js";import{t as ee}from"./label-BPz3pg9_.js";import{t as _e}from"./check-Ctsrlfa-.js";import{t as ve}from"./SearchableSelect-CIJ5K8ih.js";import{t as Se}from"./copy-_wvZOjTe.js";import{t as Ce}from"./file-search-DZpRLS-j.js";import{t as Pe}from"./folder-open-8WDYv4mw.js";import{t as Re}from"./folder-search-D0WkVTZt.js";import{t as L}from"./button-CMwV3L1P.js";import{t as Ee}from"./x-DRDFdlYE.js";import{t as Oe}from"./badge-DuA2EgZC.js";import{t as oe}from"./AgentAvatar-DgGEobSY.js";import{t as je}from"./instanceSettings-D8g_QlS-.js";import{a as Me,i as Ae,n as Be,r as Te,s as Ve,t as Fe}from"./dialog-CKUblzlR.js";import{t as se}from"./input-DobnTAyB.js";import{t as De}from"./textarea-BRPEfJ-g.js";import{i as qe,r as Le,t as ze}from"./recent-assignees-DmalYaLf.js";import{t as ce}from"./InlineEntitySelector-v2Q4C8oT.js";import{i as D,n as ie,o as le,r as de,s as ue}from"./select-V0Hm_q4f.js";import{t as Ue}from"./environments-BLQs1ScE.js";import{t as $e}from"./clipboard-CTLKYvRL.js";import{Bn as Ke,Ea as Ge,Hn as He,Mn as Je,Nn as Xe,kn as Qe,nr as be,tr as Ye,zn as Ze}from"./index-DDoARkPG.js";import{n as es,t as ss}from"./issue-workspace-selection-4JI2Uh9p.js";var c=ge(we(),1),e=ge(Ne(),1),ts="h-8 px-2 py-1.5 text-xs font-normal";function ns({value:s,workspaces:n,onValueChange:u,placeholder:m="Choose an existing workspace",loading:k=!1,error:f=!1,disabled:I=!1,className:P,triggerClassName:i,disablePortal:_}){const j=(0,c.useMemo)(()=>Qe(n),[n]);return(0,e.jsx)(ve,{value:s,groups:j,onValueChange:u,placeholder:m,searchPlaceholder:"Search workspaces...",emptyMessage:f?"Workspaces failed to load.":"No matching workspaces.",loadingMessage:"Loading workspaces...",loading:k,disabled:I,className:P,triggerClassName:H(ts,i),filterOption:Je,scoreOption:Xe,disablePortal:_,renderOption:a((b,{selected:d})=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:H("truncate",d&&"font-medium"),children:b.label}),(0,e.jsxs)("span",{className:"truncate text-(length:--text-micro) text-ink-3",children:[b.workspace.status?`${b.workspace.status} - `:"",b.description]})]}),"renderOption")})}a(ns,"ReusableExecutionWorkspaceSelect");var rs=[{value:"shared_workspace",label:"Project default"},{value:"isolated_workspace",label:"New isolated workspace"},{value:"reuse_existing",label:"Reuse existing workspace"}];function q({text:s}){const n=[],u=s.split(/(?<=[\/-])/);for(let m=0;m<u.length;m++)m>0&&n.push((0,e.jsx)("wbr",{},m)),n.push(u[m]);return(0,e.jsx)(e.Fragment,{children:n})}a(q,"BreakablePath");function te({value:s,label:n,mono:u}){const[m,k]=(0,c.useState)(!1),f=(0,c.useRef)(void 0);(0,c.useEffect)(()=>()=>clearTimeout(f.current),[]);const I=(0,c.useCallback)(async()=>{try{await $e(s),k(!0),clearTimeout(f.current),f.current=setTimeout(()=>k(!1),1500)}catch{}},[s]);return(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 group/copy",children:[n&&(0,e.jsx)("span",{className:"text-ink-3",children:n}),(0,e.jsx)("span",{className:H("min-w-0",u&&"font-mono"),style:{overflowWrap:"anywhere"},children:(0,e.jsx)(q,{text:s})}),(0,e.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-bg-3/50 transition-colors text-ink-3 hover:text-ink opacity-0 group-hover/copy:opacity-100 focus:opacity-100",onClick:I,title:m?"Copied!":"Copy","aria-label":m?"Copied to clipboard":`Copy ${n??"value"}`,children:m?(0,e.jsx)(_e,{className:"h-3 w-3 text-green-500"}):(0,e.jsx)(Se,{className:"h-3 w-3"})})]})}a(te,"CopyableInline");function as(s){switch(s){case"isolated_workspace":return"Isolated workspace";case"operator_branch":return"Operator branch";case"cloud_sandbox":return"Cloud environment";case"adapter_managed":return"Adapter managed";default:return"Workspace"}}a(as,"workspaceModeLabel");function os(s,n){switch(s){case"isolated_workspace":return"New isolated workspace";case"reuse_existing":return n?.mode==="isolated_workspace"?"Existing isolated workspace":"Reuse existing workspace";default:return"Project default"}}a(os,"configuredWorkspaceLabel");function cs(s){return!s.projectId||!s.projectWorkspaceId?null:Ie({id:s.projectId,urlKey:s.projectId},s.projectWorkspaceId)}a(cs,"projectWorkspaceDetailLink");function pe(s){const n=s.workspace?.projectWorkspaceId??s.issueProjectWorkspaceId??null;return s.workspace?.mode==="shared_workspace"?cs({projectId:s.projectId,projectWorkspaceId:n}):s.workspace?`/execution-workspaces/${s.workspace.id}`:null}a(pe,"workspaceDetailLink");function xe(s){const n={active:"bg-green-500/15 text-green-700 dark:text-green-400",idle:"bg-bg-3 text-ink-3",in_review:"bg-blue-500/15 text-blue-700 dark:text-blue-400",archived:"bg-bg-3 text-ink-3"};return(0,e.jsx)(Oe,{variant:"ghost",className:H("text-(length:--text-nano) px-1.5",n[s]??n.idle),children:s.replace(/_/g," ")})}a(xe,"statusBadge");function is({issue:s,project:n,onUpdate:u,initialEditing:m=!1,livePreview:k=!1,onDraftChange:f,onBrowseFiles:I,onOpenFileByPath:P}){const{visible:i}=be(),{selectedCompanyId:_}=ye(),j=s.companyId??_,[b,d]=(0,c.useState)(m),{data:w}=G({queryKey:K.instance.experimentalSettings,queryFn:a(()=>je.getExperimental(),"queryFn")}),h=w?.enableEnvironments===!0,T=w===void 0||w.enableManagedSandboxOnly===!0,N=w?.enableIsolatedWorkspaces===!0&&!!n?.executionWorkspacePolicy?.enabled,l=s.currentExecutionWorkspace,{data:J}=G({queryKey:K.environments.list(j),queryFn:a(()=>Ue.list(j),"queryFn"),enabled:!!j&&h}),{data:X,isLoading:Q,isError:z}=G({queryKey:K.executionWorkspaces.list(j,{projectId:s.projectId??void 0,projectWorkspaceId:s.projectWorkspaceId??void 0,reuseEligible:!0}),queryFn:a(()=>Ye.list(j,{projectId:s.projectId??void 0,projectWorkspaceId:s.projectWorkspaceId??void 0,reuseEligible:!0}),"queryFn"),enabled:!!j&&!!s.projectId&&b&&i}),p=X??[],W=p.find(x=>x.id===s.executionWorkspaceId)??l??null,g=es(s,n)??He(n),[v,V]=(0,c.useState)(g),[y,R]=(0,c.useState)(s.executionWorkspaceId??""),U=h?n?.executionWorkspacePolicy?.environmentId??null:null,C=W?.config?.environmentId??null,S=h?(g==="reuse_existing"&&C)??l?.config?.environmentId??U:null,M=J?.find(x=>x.id===S)??null;(0,c.useEffect)(()=>{b||(V(g),R(s.executionWorkspaceId??""))},[g,b,s.executionWorkspaceId]);const F=!!(l&&l.mode!=="shared_workspace"),E=p.find(x=>x.id===y)??(y===s.executionWorkspaceId?W:null),$=pe({projectId:n?.id,issueProjectWorkspaceId:s.projectWorkspaceId,workspace:W}),A=pe({projectId:n?.id,issueProjectWorkspaceId:s.projectWorkspaceId,workspace:l}),O=v!=="reuse_existing"||y.length>0,t=v==="reuse_existing"&&E?.mode!=="shared_workspace"?E?.branchName??null:null,r=(0,c.useCallback)(()=>ss(v,y||null,E?.mode),[E?.mode,y,v]);(0,c.useEffect)(()=>{!f||!i||f(r(),{canSave:O,workspaceBranchName:t})},[r,O,t,f,i]);const o=(0,c.useCallback)(()=>{if(!O||!i)return;const x=r();x&&(u(x),d(!1))},[r,O,i,u]),Y=(0,c.useCallback)(()=>{V(g),R(s.executionWorkspaceId??""),d(!1)},[g,s.executionWorkspaceId]);if(!N||!n)return null;const B=i&&(k||b);return(0,e.jsxs)("div",{className:"rounded-lg border border-line p-3 space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-ink",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5 text-ink-3"}),F&&l?as(l.mode):os(g,W),xe(l?l.status:"idle")]}),i&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:B?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:Y,children:[(0,e.jsx)(Ee,{className:"h-3 w-3 mr-1"}),"Cancel"]}),(0,e.jsx)(L,{size:"sm",className:"h-6 px-2 text-xs",onClick:o,disabled:!O,children:"Save"})]}):(0,e.jsxs)(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:a(()=>d(!0),"onClick"),children:[(0,e.jsx)(Ge,{className:"h-3 w-3 mr-1"}),"Edit"]})})]}),!B&&(0,e.jsxs)("div",{className:"space-y-1.5 text-xs",children:[l?.branchName&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(ae,{className:"h-3 w-3 text-ink-3 shrink-0"}),(0,e.jsx)(te,{value:l.branchName,mono:!0})]}),l?.cwd&&!T&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Pe,{className:"h-3 w-3 text-ink-3 shrink-0"}),(0,e.jsx)(te,{value:l.cwd,mono:!0})]}),l?.repoUrl&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-ink-3",children:[(0,e.jsx)("span",{className:"text-(length:--text-micro)",children:"Repo:"}),(0,e.jsx)(te,{value:l.repoUrl,mono:!0})]}),h&&S&&(0,e.jsxs)("div",{className:"text-ink-3",style:{overflowWrap:"anywhere"},children:["Environment: ",(0,e.jsx)("span",{className:"text-ink",children:M?.name??S}),g==="reuse_existing"&&C===S?" · reused workspace":!s.executionWorkspaceSettings?.environmentId&&U===S?" · project default":null]}),!l&&(0,e.jsx)("div",{className:"text-ink-3",children:g==="isolated_workspace"?"A fresh isolated workspace will be created when this task runs.":g==="reuse_existing"?"This task will reuse an existing workspace when it runs.":"This task will use the project default workspace configuration when it runs."}),g==="reuse_existing"&&W&&(0,e.jsxs)("div",{className:"text-ink-3",style:{overflowWrap:"anywhere"},children:["Reusing:"," ",$?(0,e.jsx)(Z,{to:$,className:"hover:text-ink hover:underline",children:(0,e.jsx)(q,{text:W.name})}):(0,e.jsx)(q,{text:W.name})]}),l&&A&&(0,e.jsx)("div",{className:"pt-0.5",children:(0,e.jsx)(Z,{to:A,className:"text-(length:--text-micro) text-ink-3 hover:text-ink hover:underline",children:"View workspace details →"})})]}),b&&i&&(0,e.jsxs)("div",{className:"space-y-2 pt-1",children:[(0,e.jsx)("select",{className:"w-full rounded border border-line bg-transparent px-2 py-1.5 text-xs outline-none",value:v,onChange:a(x=>{const re=x.target.value;V(re),re!=="reuse_existing"?R(""):!y&&s.executionWorkspaceId&&R(s.executionWorkspaceId)},"onChange"),children:rs.map(x=>(0,e.jsx)("option",{value:x.value,children:x.value==="reuse_existing"&&E?.mode==="isolated_workspace"?"Existing isolated workspace":x.label},x.value))}),v==="reuse_existing"&&(0,e.jsx)(ns,{value:y,workspaces:p,onValueChange:a(x=>R(x),"onValueChange"),loading:Q,error:z}),l&&(0,e.jsx)("div",{className:"text-(length:--text-micro) text-ink-3 space-y-0.5 pt-1 border-t border-line/50",children:(0,e.jsxs)("div",{style:{overflowWrap:"anywhere"},children:["Current:"," ",A?(0,e.jsx)(Z,{to:A,className:"hover:text-ink hover:underline",children:(0,e.jsx)(q,{text:l.name})}):(0,e.jsx)(q,{text:l.name})," · ",l.status]})})]}),!B&&I&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-line/50 pt-2 text-xs",children:[(0,e.jsxs)("button",{type:"button",onClick:I,className:"inline-flex items-center gap-1.5 text-ink-3 transition-colors hover:text-ink",children:[(0,e.jsx)(Re,{className:"h-3.5 w-3.5 shrink-0"}),"Browse files…"]}),(0,e.jsxs)("button",{type:"button",onClick:P??I,className:"inline-flex items-center gap-1.5 text-ink-3 transition-colors hover:text-ink",children:[(0,e.jsx)(Ce,{className:"h-3.5 w-3.5 shrink-0"}),"Open file by path…"]})]})]})}a(is,"IssueWorkspaceCard");function ls(s){return Object.fromEntries(s.map(n=>[n.name,n.defaultValue??""]))}a(ls,"buildInitialValues");function me(s){return{assigneeAgentId:s.defaultAssigneeAgentId??"",projectId:s.defaultProjectId??""}}a(me,"buildInitialRunSelection");function he(s){return s?s.executionWorkspacePolicy?.defaultProjectWorkspaceId??s.workspaces?.find(n=>n.isPrimary)?.id??s.workspaces?.[0]?.id??null:null}a(he,"defaultProjectWorkspaceIdForProject");function ds(s){const n=s?.executionWorkspacePolicy?.enabled?s.executionWorkspacePolicy.defaultMode:null;return n==="isolated_workspace"||n==="operator_branch"||n==="adapter_default"?n==="adapter_default"?"agent_default":n:"shared_workspace"}a(ds,"defaultExecutionWorkspaceModeForProject");function us(s){return s==="isolated_workspace"||s==="operator_branch"||s==="shared_workspace"?s:s==="adapter_managed"||s==="cloud_sandbox"?"agent_default":"shared_workspace"}a(us,"issueModeForExistingWorkspace");function ps(s,n){return s==="inherit"||s==="shared_workspace"||s==="isolated_workspace"||s==="operator_branch"||s==="reuse_existing"||s==="agent_default"?s:n}a(ps,"issueWorkspacePreferenceFromDraft");function ne(s,n){if(n&&n.projectId===s?.id)return{executionWorkspaceId:n.id,executionWorkspacePreference:"reuse_existing",executionWorkspaceSettings:{mode:us(n.mode)},projectWorkspaceId:n.projectWorkspaceId??he(s)};const u=ds(s);return{executionWorkspaceId:null,executionWorkspacePreference:u,executionWorkspaceSettings:{mode:u},projectWorkspaceId:he(s)}}a(ne,"buildInitialWorkspaceConfig");function xs(s,n){return s.executionWorkspaceId===n.executionWorkspaceId&&s.executionWorkspacePreference===n.executionWorkspacePreference&&s.projectWorkspaceId===n.projectWorkspaceId&&JSON.stringify(s.executionWorkspaceSettings??null)===JSON.stringify(n.executionWorkspaceSettings??null)}a(xs,"workspaceConfigEquals");function ke(s,n){const u={...s,executionWorkspaceId:n.executionWorkspaceId??null,executionWorkspacePreference:ps(n.executionWorkspacePreference,s.executionWorkspacePreference),executionWorkspaceSettings:n.executionWorkspaceSettings??s.executionWorkspaceSettings};return xs(s,u)?s:u}a(ke,"applyWorkspaceDraft");function fe(s){return s==null||typeof s=="string"&&s.trim().length===0}a(fe,"isMissingRequiredValue");function ms(s){return s.type==="date"}a(ms,"shouldUseDateInput");function hs(s,n){return n&&!!s?.executionWorkspacePolicy?.enabled}a(hs,"supportsRoutineRunWorkspaceSelection");function $s({open:s,onOpenChange:n,companyId:u,routineName:m,projects:k,agents:f,defaultProjectId:I,defaultAssigneeAgentId:P,defaultExecutionWorkspace:i,variables:_,isPending:j,onSubmit:b}){const[d,w]=(0,c.useState)({}),[h,T]=(0,c.useState)(()=>me({defaultAssigneeAgentId:P,defaultProjectId:I})),N=(0,c.useMemo)(()=>k.find(t=>t.id===h.projectId)??null,[k,h.projectId]),l=(0,c.useMemo)(()=>ze(),[s]),J=(0,c.useMemo)(()=>Ze(),[s]),X=(0,c.useMemo)(()=>Le(f.filter(t=>t.status!=="terminated"),l).map(t=>({id:t.id,label:t.name,searchText:`${t.name} ${t.role} ${t.title??""}`})),[f,l]),Q=(0,c.useMemo)(()=>k.map(t=>({id:t.id,label:t.name,searchText:t.description??""})),[k]),z=h.assigneeAgentId?f.find(t=>t.id===h.assigneeAgentId)??null:null,[p,W]=(0,c.useState)(()=>ne(N,i)),[g,v]=(0,c.useState)(!0),[V,y]=(0,c.useState)(null),{data:R}=G({queryKey:K.instance.experimentalSettings,queryFn:a(()=>je.getExperimental(),"queryFn"),retry:!1}),{visible:U}=be(),C=U&&hs(N,R?.enableIsolatedWorkspaces===!0);(0,c.useEffect)(()=>{if(!s)return;w(ls(_));const t=me({defaultAssigneeAgentId:P,defaultProjectId:I});T(t),W(ne(k.find(r=>r.id===t.projectId)??null,i)),v(!0),y(i?.branchName??null)},[P,i,I,s,k,_]);const S=C?V:i?.projectId===h.projectId?i?.branchName??null:null,M=(0,c.useCallback)(t=>t.name==="workspaceBranch"&&!!S,[S]),F=(0,c.useMemo)(()=>_.filter(t=>t.required).filter(t=>!M(t)).filter(t=>fe(d[t.name])).map(t=>t.label||t.name),[M,d,_]),E=(0,c.useMemo)(()=>({companyId:u??null,projectId:N?.id??null,projectWorkspaceId:p.projectWorkspaceId,executionWorkspaceId:p.executionWorkspaceId,executionWorkspacePreference:p.executionWorkspacePreference,executionWorkspaceSettings:p.executionWorkspaceSettings,currentExecutionWorkspace:p.executionWorkspaceId&&p.executionWorkspaceId===i?.id?i:null}),[u,i,N?.id,p.executionWorkspaceId,p.executionWorkspacePreference,p.executionWorkspaceSettings,p.projectWorkspaceId]),$=h.assigneeAgentId.trim().length>0&&F.length===0&&(!C||g),A=(0,c.useCallback)(t=>{W(r=>ke(r,t))},[]),O=(0,c.useCallback)((t,r)=>{t&&W(o=>ke(o,t)),v(o=>o===r.canSave?o:r.canSave),y(o=>{const Y=i?.branchName??null,B=r.workspaceBranchName??(t?.executionWorkspaceId===i?.id?Y:null)??null;return o===B?o:B})},[i]);return(0,e.jsx)(Fe,{open:s,onOpenChange:a(t=>!j&&n(t),"onOpenChange"),children:(0,e.jsxs)(Be,{className:"flex h-(--sz-calc-18) max-h-(--sz-calc-18) max-w-xl flex-col gap-0 overflow-hidden p-0 sm:h-auto sm:max-h-(--sz-calc-20)",children:[(0,e.jsxs)(Me,{className:"shrink-0 border-b border-line/60 px-6 pb-4 pr-12 pt-6",children:[m&&(0,e.jsx)("p",{className:"text-ink-3 text-sm",children:m}),(0,e.jsx)(Ve,{children:"Run routine"}),(0,e.jsx)(Te,{children:"Choose the agent and optional project for this one run. Routine defaults are prefilled and won't be changed."})]}),(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 py-4",children:[(0,e.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(ee,{className:"text-xs",children:"Agent *"}),(0,e.jsx)(ce,{value:h.assigneeAgentId,options:X,recentOptionIds:l,placeholder:"Agent",noneLabel:"Select an agent",searchPlaceholder:"Search agents...",emptyMessage:"No agents found.",disablePortal:!0,openOnFocus:!1,onChange:a(t=>{t&&qe(t),T(r=>({...r,assigneeAgentId:t}))},"onChange"),renderTriggerValue:a(t=>t?z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(oe,{agent:z,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,e.jsx)("span",{className:"truncate",children:t.label})]}):(0,e.jsx)("span",{className:"truncate",children:t.label}):(0,e.jsx)("span",{className:"text-ink-3",children:"Select an agent"}),"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const r=f.find(o=>o.id===t.id);return(0,e.jsxs)(e.Fragment,{children:[r?(0,e.jsx)(oe,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(ee,{className:"text-xs",children:"Project"}),(0,e.jsx)(ce,{value:h.projectId,options:Q,recentOptionIds:J,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",disablePortal:!0,openOnFocus:!1,onChange:a(t=>{const r=k.find(o=>o.id===t)??null;t&&Ke(t),T(o=>({...o,projectId:t})),W(ne(r,i)),v(!0),y(i&&i.projectId===r?.id?i.branchName:null)},"onChange"),renderTriggerValue:a(t=>t&&N?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:t.label})]}):(0,e.jsx)("span",{className:"text-ink-3",children:"No project"}),"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const r=k.find(o=>o.id===t.id);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")})]})]}),_.map(t=>(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)(ee,{className:"text-xs",children:[t.label||t.name,t.required?" *":""]}),M(t)?(0,e.jsx)(se,{readOnly:!0,disabled:!0,value:S??""}):t.type==="textarea"?(0,e.jsx)(De,{rows:4,value:typeof d[t.name]=="string"?d[t.name]:"",onChange:a(r=>w(o=>({...o,[t.name]:r.target.value})),"onChange")}):t.type==="boolean"?(0,e.jsxs)(ie,{value:d[t.name]===!0?"true":d[t.name]===!1?"false":"__unset__",onValueChange:a(r=>w(o=>({...o,[t.name]:r==="__unset__"?"":r==="true"})),"onValueChange"),children:[(0,e.jsx)(le,{children:(0,e.jsx)(ue,{})}),(0,e.jsxs)(de,{children:[(0,e.jsx)(D,{value:"__unset__",children:"No value"}),(0,e.jsx)(D,{value:"true",children:"True"}),(0,e.jsx)(D,{value:"false",children:"False"})]})]}):t.type==="select"?(0,e.jsxs)(ie,{value:typeof d[t.name]=="string"&&d[t.name]?d[t.name]:"__unset__",onValueChange:a(r=>w(o=>({...o,[t.name]:r==="__unset__"?"":r})),"onValueChange"),children:[(0,e.jsx)(le,{children:(0,e.jsx)(ue,{placeholder:"Choose a value"})}),(0,e.jsxs)(de,{children:[(0,e.jsx)(D,{value:"__unset__",children:"No value"}),t.options.map(r=>(0,e.jsx)(D,{value:r,children:r},r))]})]}):ms(t)?(0,e.jsx)(se,{type:"date",value:d[t.name]==null?"":String(d[t.name]),onChange:a(r=>w(o=>({...o,[t.name]:r.target.value})),"onChange")}):(0,e.jsx)(se,{type:t.type==="number"?"number":"text",value:d[t.name]==null?"":String(d[t.name]),onChange:a(r=>w(o=>({...o,[t.name]:r.target.value})),"onChange")})]},t.name)),C&&N&&u?(0,e.jsx)(is,{issue:E,project:N,initialEditing:!0,livePreview:!0,onUpdate:A,onDraftChange:O},`${s?"open":"closed"}:${N.id}`):null]}),(0,e.jsxs)(Ae,{showCloseButton:!1,className:"shrink-0 border-t border-line/60 bg-bg px-6 pb-(--sz-calc-19) pt-4",children:[h.assigneeAgentId?F.length>0?(0,e.jsxs)("p",{className:"mr-auto text-xs text-amber-600",children:["Missing: ",F.join(", ")]}):C&&!g?(0,e.jsx)("p",{className:"mr-auto text-xs text-amber-600",children:"Choose an existing workspace before running."}):(0,e.jsx)("span",{className:"mr-auto"}):(0,e.jsx)("p",{className:"mr-auto text-xs text-amber-600",children:"Default agent required for this run."}),(0,e.jsx)(L,{variant:"ghost",onClick:a(()=>n(!1),"onClick"),disabled:j,children:"Cancel"}),(0,e.jsx)(L,{onClick:a(()=>{const t={};for(const r of _){if(M(r)){t[r.name]=S;continue}const o=d[r.name];fe(o)||(r.type==="number"?t[r.name]=Number(o):r.type==="boolean"?t[r.name]=o===!0:t[r.name]=String(o))}b({variables:t,assigneeAgentId:h.assigneeAgentId,projectId:h.projectId||null,...C?{executionWorkspaceId:p.executionWorkspaceId,executionWorkspacePreference:p.executionWorkspacePreference,executionWorkspaceSettings:p.executionWorkspaceSettings}:{}})},"onClick"),disabled:j||!$,children:j?"Running...":"Run routine"})]})]})})}a($s,"RoutineRunVariablesDialog");export{$s as t};
1
+ var We=Object.defineProperty;var a=(s,n)=>We(s,"name",{value:n,configurable:!0});import{i as ge}from"./rolldown-runtime-ZpX3ckPj.js";import{T as Ie,l as H,na as we,ta as Ne}from"./createLucideIcon-DJi9suAC.js";import{t as K,v as G}from"./queryKeys-DYV5MhM_.js";import{n as ye}from"./CompanyContext-CSrVsSze.js";import{ot as ae,t as Z}from"./router-2UfGeejU.js";import{t as ee}from"./label-BPz3pg9_.js";import{t as _e}from"./check-Ctsrlfa-.js";import{t as ve}from"./SearchableSelect-CIJ5K8ih.js";import{t as Se}from"./copy-_wvZOjTe.js";import{t as Ce}from"./file-search-DZpRLS-j.js";import{t as Pe}from"./folder-open-8WDYv4mw.js";import{t as Re}from"./folder-search-D0WkVTZt.js";import{t as L}from"./button-CMwV3L1P.js";import{t as Ee}from"./x-DRDFdlYE.js";import{t as Oe}from"./badge-DuA2EgZC.js";import{t as oe}from"./AgentAvatar-DgGEobSY.js";import{t as je}from"./instanceSettings-D8g_QlS-.js";import{a as Me,i as Ae,n as Be,r as Te,s as Ve,t as Fe}from"./dialog-CKUblzlR.js";import{t as se}from"./input-DobnTAyB.js";import{t as De}from"./textarea-BRPEfJ-g.js";import{i as qe,r as Le,t as ze}from"./recent-assignees-DmalYaLf.js";import{t as ce}from"./InlineEntitySelector-v2Q4C8oT.js";import{i as D,n as ie,o as le,r as de,s as ue}from"./select-V0Hm_q4f.js";import{t as Ue}from"./environments-BLQs1ScE.js";import{t as $e}from"./clipboard-CTLKYvRL.js";import{Bn as Ke,Ea as Ge,Hn as He,Mn as Je,Nn as Xe,kn as Qe,nr as be,tr as Ye,zn as Ze}from"./index-3AxqhPET.js";import{n as es,t as ss}from"./issue-workspace-selection-S8UgGgK1.js";var c=ge(we(),1),e=ge(Ne(),1),ts="h-8 px-2 py-1.5 text-xs font-normal";function ns({value:s,workspaces:n,onValueChange:u,placeholder:m="Choose an existing workspace",loading:k=!1,error:f=!1,disabled:I=!1,className:P,triggerClassName:i,disablePortal:_}){const j=(0,c.useMemo)(()=>Qe(n),[n]);return(0,e.jsx)(ve,{value:s,groups:j,onValueChange:u,placeholder:m,searchPlaceholder:"Search workspaces...",emptyMessage:f?"Workspaces failed to load.":"No matching workspaces.",loadingMessage:"Loading workspaces...",loading:k,disabled:I,className:P,triggerClassName:H(ts,i),filterOption:Je,scoreOption:Xe,disablePortal:_,renderOption:a((b,{selected:d})=>(0,e.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,e.jsx)("span",{className:H("truncate",d&&"font-medium"),children:b.label}),(0,e.jsxs)("span",{className:"truncate text-(length:--text-micro) text-ink-3",children:[b.workspace.status?`${b.workspace.status} - `:"",b.description]})]}),"renderOption")})}a(ns,"ReusableExecutionWorkspaceSelect");var rs=[{value:"shared_workspace",label:"Project default"},{value:"isolated_workspace",label:"New isolated workspace"},{value:"reuse_existing",label:"Reuse existing workspace"}];function q({text:s}){const n=[],u=s.split(/(?<=[\/-])/);for(let m=0;m<u.length;m++)m>0&&n.push((0,e.jsx)("wbr",{},m)),n.push(u[m]);return(0,e.jsx)(e.Fragment,{children:n})}a(q,"BreakablePath");function te({value:s,label:n,mono:u}){const[m,k]=(0,c.useState)(!1),f=(0,c.useRef)(void 0);(0,c.useEffect)(()=>()=>clearTimeout(f.current),[]);const I=(0,c.useCallback)(async()=>{try{await $e(s),k(!0),clearTimeout(f.current),f.current=setTimeout(()=>k(!1),1500)}catch{}},[s]);return(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 group/copy",children:[n&&(0,e.jsx)("span",{className:"text-ink-3",children:n}),(0,e.jsx)("span",{className:H("min-w-0",u&&"font-mono"),style:{overflowWrap:"anywhere"},children:(0,e.jsx)(q,{text:s})}),(0,e.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-bg-3/50 transition-colors text-ink-3 hover:text-ink opacity-0 group-hover/copy:opacity-100 focus:opacity-100",onClick:I,title:m?"Copied!":"Copy","aria-label":m?"Copied to clipboard":`Copy ${n??"value"}`,children:m?(0,e.jsx)(_e,{className:"h-3 w-3 text-green-500"}):(0,e.jsx)(Se,{className:"h-3 w-3"})})]})}a(te,"CopyableInline");function as(s){switch(s){case"isolated_workspace":return"Isolated workspace";case"operator_branch":return"Operator branch";case"cloud_sandbox":return"Cloud environment";case"adapter_managed":return"Adapter managed";default:return"Workspace"}}a(as,"workspaceModeLabel");function os(s,n){switch(s){case"isolated_workspace":return"New isolated workspace";case"reuse_existing":return n?.mode==="isolated_workspace"?"Existing isolated workspace":"Reuse existing workspace";default:return"Project default"}}a(os,"configuredWorkspaceLabel");function cs(s){return!s.projectId||!s.projectWorkspaceId?null:Ie({id:s.projectId,urlKey:s.projectId},s.projectWorkspaceId)}a(cs,"projectWorkspaceDetailLink");function pe(s){const n=s.workspace?.projectWorkspaceId??s.issueProjectWorkspaceId??null;return s.workspace?.mode==="shared_workspace"?cs({projectId:s.projectId,projectWorkspaceId:n}):s.workspace?`/execution-workspaces/${s.workspace.id}`:null}a(pe,"workspaceDetailLink");function xe(s){const n={active:"bg-green-500/15 text-green-700 dark:text-green-400",idle:"bg-bg-3 text-ink-3",in_review:"bg-blue-500/15 text-blue-700 dark:text-blue-400",archived:"bg-bg-3 text-ink-3"};return(0,e.jsx)(Oe,{variant:"ghost",className:H("text-(length:--text-nano) px-1.5",n[s]??n.idle),children:s.replace(/_/g," ")})}a(xe,"statusBadge");function is({issue:s,project:n,onUpdate:u,initialEditing:m=!1,livePreview:k=!1,onDraftChange:f,onBrowseFiles:I,onOpenFileByPath:P}){const{visible:i}=be(),{selectedCompanyId:_}=ye(),j=s.companyId??_,[b,d]=(0,c.useState)(m),{data:w}=G({queryKey:K.instance.experimentalSettings,queryFn:a(()=>je.getExperimental(),"queryFn")}),h=w?.enableEnvironments===!0,T=w===void 0||w.enableManagedSandboxOnly===!0,N=w?.enableIsolatedWorkspaces===!0&&!!n?.executionWorkspacePolicy?.enabled,l=s.currentExecutionWorkspace,{data:J}=G({queryKey:K.environments.list(j),queryFn:a(()=>Ue.list(j),"queryFn"),enabled:!!j&&h}),{data:X,isLoading:Q,isError:z}=G({queryKey:K.executionWorkspaces.list(j,{projectId:s.projectId??void 0,projectWorkspaceId:s.projectWorkspaceId??void 0,reuseEligible:!0}),queryFn:a(()=>Ye.list(j,{projectId:s.projectId??void 0,projectWorkspaceId:s.projectWorkspaceId??void 0,reuseEligible:!0}),"queryFn"),enabled:!!j&&!!s.projectId&&b&&i}),p=X??[],W=p.find(x=>x.id===s.executionWorkspaceId)??l??null,g=es(s,n)??He(n),[v,V]=(0,c.useState)(g),[y,R]=(0,c.useState)(s.executionWorkspaceId??""),U=h?n?.executionWorkspacePolicy?.environmentId??null:null,C=W?.config?.environmentId??null,S=h?(g==="reuse_existing"&&C)??l?.config?.environmentId??U:null,M=J?.find(x=>x.id===S)??null;(0,c.useEffect)(()=>{b||(V(g),R(s.executionWorkspaceId??""))},[g,b,s.executionWorkspaceId]);const F=!!(l&&l.mode!=="shared_workspace"),E=p.find(x=>x.id===y)??(y===s.executionWorkspaceId?W:null),$=pe({projectId:n?.id,issueProjectWorkspaceId:s.projectWorkspaceId,workspace:W}),A=pe({projectId:n?.id,issueProjectWorkspaceId:s.projectWorkspaceId,workspace:l}),O=v!=="reuse_existing"||y.length>0,t=v==="reuse_existing"&&E?.mode!=="shared_workspace"?E?.branchName??null:null,r=(0,c.useCallback)(()=>ss(v,y||null,E?.mode),[E?.mode,y,v]);(0,c.useEffect)(()=>{!f||!i||f(r(),{canSave:O,workspaceBranchName:t})},[r,O,t,f,i]);const o=(0,c.useCallback)(()=>{if(!O||!i)return;const x=r();x&&(u(x),d(!1))},[r,O,i,u]),Y=(0,c.useCallback)(()=>{V(g),R(s.executionWorkspaceId??""),d(!1)},[g,s.executionWorkspaceId]);if(!N||!n)return null;const B=i&&(k||b);return(0,e.jsxs)("div",{className:"rounded-lg border border-line p-3 space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-ink",children:[(0,e.jsx)(ae,{className:"h-3.5 w-3.5 text-ink-3"}),F&&l?as(l.mode):os(g,W),xe(l?l.status:"idle")]}),i&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:B?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:Y,children:[(0,e.jsx)(Ee,{className:"h-3 w-3 mr-1"}),"Cancel"]}),(0,e.jsx)(L,{size:"sm",className:"h-6 px-2 text-xs",onClick:o,disabled:!O,children:"Save"})]}):(0,e.jsxs)(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:a(()=>d(!0),"onClick"),children:[(0,e.jsx)(Ge,{className:"h-3 w-3 mr-1"}),"Edit"]})})]}),!B&&(0,e.jsxs)("div",{className:"space-y-1.5 text-xs",children:[l?.branchName&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(ae,{className:"h-3 w-3 text-ink-3 shrink-0"}),(0,e.jsx)(te,{value:l.branchName,mono:!0})]}),l?.cwd&&!T&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Pe,{className:"h-3 w-3 text-ink-3 shrink-0"}),(0,e.jsx)(te,{value:l.cwd,mono:!0})]}),l?.repoUrl&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 text-ink-3",children:[(0,e.jsx)("span",{className:"text-(length:--text-micro)",children:"Repo:"}),(0,e.jsx)(te,{value:l.repoUrl,mono:!0})]}),h&&S&&(0,e.jsxs)("div",{className:"text-ink-3",style:{overflowWrap:"anywhere"},children:["Environment: ",(0,e.jsx)("span",{className:"text-ink",children:M?.name??S}),g==="reuse_existing"&&C===S?" · reused workspace":!s.executionWorkspaceSettings?.environmentId&&U===S?" · project default":null]}),!l&&(0,e.jsx)("div",{className:"text-ink-3",children:g==="isolated_workspace"?"A fresh isolated workspace will be created when this task runs.":g==="reuse_existing"?"This task will reuse an existing workspace when it runs.":"This task will use the project default workspace configuration when it runs."}),g==="reuse_existing"&&W&&(0,e.jsxs)("div",{className:"text-ink-3",style:{overflowWrap:"anywhere"},children:["Reusing:"," ",$?(0,e.jsx)(Z,{to:$,className:"hover:text-ink hover:underline",children:(0,e.jsx)(q,{text:W.name})}):(0,e.jsx)(q,{text:W.name})]}),l&&A&&(0,e.jsx)("div",{className:"pt-0.5",children:(0,e.jsx)(Z,{to:A,className:"text-(length:--text-micro) text-ink-3 hover:text-ink hover:underline",children:"View workspace details →"})})]}),b&&i&&(0,e.jsxs)("div",{className:"space-y-2 pt-1",children:[(0,e.jsx)("select",{className:"w-full rounded border border-line bg-transparent px-2 py-1.5 text-xs outline-none",value:v,onChange:a(x=>{const re=x.target.value;V(re),re!=="reuse_existing"?R(""):!y&&s.executionWorkspaceId&&R(s.executionWorkspaceId)},"onChange"),children:rs.map(x=>(0,e.jsx)("option",{value:x.value,children:x.value==="reuse_existing"&&E?.mode==="isolated_workspace"?"Existing isolated workspace":x.label},x.value))}),v==="reuse_existing"&&(0,e.jsx)(ns,{value:y,workspaces:p,onValueChange:a(x=>R(x),"onValueChange"),loading:Q,error:z}),l&&(0,e.jsx)("div",{className:"text-(length:--text-micro) text-ink-3 space-y-0.5 pt-1 border-t border-line/50",children:(0,e.jsxs)("div",{style:{overflowWrap:"anywhere"},children:["Current:"," ",A?(0,e.jsx)(Z,{to:A,className:"hover:text-ink hover:underline",children:(0,e.jsx)(q,{text:l.name})}):(0,e.jsx)(q,{text:l.name})," · ",l.status]})})]}),!B&&I&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-line/50 pt-2 text-xs",children:[(0,e.jsxs)("button",{type:"button",onClick:I,className:"inline-flex items-center gap-1.5 text-ink-3 transition-colors hover:text-ink",children:[(0,e.jsx)(Re,{className:"h-3.5 w-3.5 shrink-0"}),"Browse files…"]}),(0,e.jsxs)("button",{type:"button",onClick:P??I,className:"inline-flex items-center gap-1.5 text-ink-3 transition-colors hover:text-ink",children:[(0,e.jsx)(Ce,{className:"h-3.5 w-3.5 shrink-0"}),"Open file by path…"]})]})]})}a(is,"IssueWorkspaceCard");function ls(s){return Object.fromEntries(s.map(n=>[n.name,n.defaultValue??""]))}a(ls,"buildInitialValues");function me(s){return{assigneeAgentId:s.defaultAssigneeAgentId??"",projectId:s.defaultProjectId??""}}a(me,"buildInitialRunSelection");function he(s){return s?s.executionWorkspacePolicy?.defaultProjectWorkspaceId??s.workspaces?.find(n=>n.isPrimary)?.id??s.workspaces?.[0]?.id??null:null}a(he,"defaultProjectWorkspaceIdForProject");function ds(s){const n=s?.executionWorkspacePolicy?.enabled?s.executionWorkspacePolicy.defaultMode:null;return n==="isolated_workspace"||n==="operator_branch"||n==="adapter_default"?n==="adapter_default"?"agent_default":n:"shared_workspace"}a(ds,"defaultExecutionWorkspaceModeForProject");function us(s){return s==="isolated_workspace"||s==="operator_branch"||s==="shared_workspace"?s:s==="adapter_managed"||s==="cloud_sandbox"?"agent_default":"shared_workspace"}a(us,"issueModeForExistingWorkspace");function ps(s,n){return s==="inherit"||s==="shared_workspace"||s==="isolated_workspace"||s==="operator_branch"||s==="reuse_existing"||s==="agent_default"?s:n}a(ps,"issueWorkspacePreferenceFromDraft");function ne(s,n){if(n&&n.projectId===s?.id)return{executionWorkspaceId:n.id,executionWorkspacePreference:"reuse_existing",executionWorkspaceSettings:{mode:us(n.mode)},projectWorkspaceId:n.projectWorkspaceId??he(s)};const u=ds(s);return{executionWorkspaceId:null,executionWorkspacePreference:u,executionWorkspaceSettings:{mode:u},projectWorkspaceId:he(s)}}a(ne,"buildInitialWorkspaceConfig");function xs(s,n){return s.executionWorkspaceId===n.executionWorkspaceId&&s.executionWorkspacePreference===n.executionWorkspacePreference&&s.projectWorkspaceId===n.projectWorkspaceId&&JSON.stringify(s.executionWorkspaceSettings??null)===JSON.stringify(n.executionWorkspaceSettings??null)}a(xs,"workspaceConfigEquals");function ke(s,n){const u={...s,executionWorkspaceId:n.executionWorkspaceId??null,executionWorkspacePreference:ps(n.executionWorkspacePreference,s.executionWorkspacePreference),executionWorkspaceSettings:n.executionWorkspaceSettings??s.executionWorkspaceSettings};return xs(s,u)?s:u}a(ke,"applyWorkspaceDraft");function fe(s){return s==null||typeof s=="string"&&s.trim().length===0}a(fe,"isMissingRequiredValue");function ms(s){return s.type==="date"}a(ms,"shouldUseDateInput");function hs(s,n){return n&&!!s?.executionWorkspacePolicy?.enabled}a(hs,"supportsRoutineRunWorkspaceSelection");function $s({open:s,onOpenChange:n,companyId:u,routineName:m,projects:k,agents:f,defaultProjectId:I,defaultAssigneeAgentId:P,defaultExecutionWorkspace:i,variables:_,isPending:j,onSubmit:b}){const[d,w]=(0,c.useState)({}),[h,T]=(0,c.useState)(()=>me({defaultAssigneeAgentId:P,defaultProjectId:I})),N=(0,c.useMemo)(()=>k.find(t=>t.id===h.projectId)??null,[k,h.projectId]),l=(0,c.useMemo)(()=>ze(),[s]),J=(0,c.useMemo)(()=>Ze(),[s]),X=(0,c.useMemo)(()=>Le(f.filter(t=>t.status!=="terminated"),l).map(t=>({id:t.id,label:t.name,searchText:`${t.name} ${t.role} ${t.title??""}`})),[f,l]),Q=(0,c.useMemo)(()=>k.map(t=>({id:t.id,label:t.name,searchText:t.description??""})),[k]),z=h.assigneeAgentId?f.find(t=>t.id===h.assigneeAgentId)??null:null,[p,W]=(0,c.useState)(()=>ne(N,i)),[g,v]=(0,c.useState)(!0),[V,y]=(0,c.useState)(null),{data:R}=G({queryKey:K.instance.experimentalSettings,queryFn:a(()=>je.getExperimental(),"queryFn"),retry:!1}),{visible:U}=be(),C=U&&hs(N,R?.enableIsolatedWorkspaces===!0);(0,c.useEffect)(()=>{if(!s)return;w(ls(_));const t=me({defaultAssigneeAgentId:P,defaultProjectId:I});T(t),W(ne(k.find(r=>r.id===t.projectId)??null,i)),v(!0),y(i?.branchName??null)},[P,i,I,s,k,_]);const S=C?V:i?.projectId===h.projectId?i?.branchName??null:null,M=(0,c.useCallback)(t=>t.name==="workspaceBranch"&&!!S,[S]),F=(0,c.useMemo)(()=>_.filter(t=>t.required).filter(t=>!M(t)).filter(t=>fe(d[t.name])).map(t=>t.label||t.name),[M,d,_]),E=(0,c.useMemo)(()=>({companyId:u??null,projectId:N?.id??null,projectWorkspaceId:p.projectWorkspaceId,executionWorkspaceId:p.executionWorkspaceId,executionWorkspacePreference:p.executionWorkspacePreference,executionWorkspaceSettings:p.executionWorkspaceSettings,currentExecutionWorkspace:p.executionWorkspaceId&&p.executionWorkspaceId===i?.id?i:null}),[u,i,N?.id,p.executionWorkspaceId,p.executionWorkspacePreference,p.executionWorkspaceSettings,p.projectWorkspaceId]),$=h.assigneeAgentId.trim().length>0&&F.length===0&&(!C||g),A=(0,c.useCallback)(t=>{W(r=>ke(r,t))},[]),O=(0,c.useCallback)((t,r)=>{t&&W(o=>ke(o,t)),v(o=>o===r.canSave?o:r.canSave),y(o=>{const Y=i?.branchName??null,B=r.workspaceBranchName??(t?.executionWorkspaceId===i?.id?Y:null)??null;return o===B?o:B})},[i]);return(0,e.jsx)(Fe,{open:s,onOpenChange:a(t=>!j&&n(t),"onOpenChange"),children:(0,e.jsxs)(Be,{className:"flex h-(--sz-calc-18) max-h-(--sz-calc-18) max-w-xl flex-col gap-0 overflow-hidden p-0 sm:h-auto sm:max-h-(--sz-calc-20)",children:[(0,e.jsxs)(Me,{className:"shrink-0 border-b border-line/60 px-6 pb-4 pr-12 pt-6",children:[m&&(0,e.jsx)("p",{className:"text-ink-3 text-sm",children:m}),(0,e.jsx)(Ve,{children:"Run routine"}),(0,e.jsx)(Te,{children:"Choose the agent and optional project for this one run. Routine defaults are prefilled and won't be changed."})]}),(0,e.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto overscroll-contain px-6 py-4",children:[(0,e.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(ee,{className:"text-xs",children:"Agent *"}),(0,e.jsx)(ce,{value:h.assigneeAgentId,options:X,recentOptionIds:l,placeholder:"Agent",noneLabel:"Select an agent",searchPlaceholder:"Search agents...",emptyMessage:"No agents found.",disablePortal:!0,openOnFocus:!1,onChange:a(t=>{t&&qe(t),T(r=>({...r,assigneeAgentId:t}))},"onChange"),renderTriggerValue:a(t=>t?z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(oe,{agent:z,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,e.jsx)("span",{className:"truncate",children:t.label})]}):(0,e.jsx)("span",{className:"truncate",children:t.label}):(0,e.jsx)("span",{className:"text-ink-3",children:"Select an agent"}),"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const r=f.find(o=>o.id===t.id);return(0,e.jsxs)(e.Fragment,{children:[r?(0,e.jsx)(oe,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(ee,{className:"text-xs",children:"Project"}),(0,e.jsx)(ce,{value:h.projectId,options:Q,recentOptionIds:J,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",disablePortal:!0,openOnFocus:!1,onChange:a(t=>{const r=k.find(o=>o.id===t)??null;t&&Ke(t),T(o=>({...o,projectId:t})),W(ne(r,i)),v(!0),y(i&&i.projectId===r?.id?i.branchName:null)},"onChange"),renderTriggerValue:a(t=>t&&N?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:t.label})]}):(0,e.jsx)("span",{className:"text-ink-3",children:"No project"}),"renderTriggerValue"),renderOption:a(t=>{if(!t.id)return(0,e.jsx)("span",{className:"truncate",children:t.label});const r=k.find(o=>o.id===t.id);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,e.jsx)("span",{className:"truncate",children:t.label})]})},"renderOption")})]})]}),_.map(t=>(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsxs)(ee,{className:"text-xs",children:[t.label||t.name,t.required?" *":""]}),M(t)?(0,e.jsx)(se,{readOnly:!0,disabled:!0,value:S??""}):t.type==="textarea"?(0,e.jsx)(De,{rows:4,value:typeof d[t.name]=="string"?d[t.name]:"",onChange:a(r=>w(o=>({...o,[t.name]:r.target.value})),"onChange")}):t.type==="boolean"?(0,e.jsxs)(ie,{value:d[t.name]===!0?"true":d[t.name]===!1?"false":"__unset__",onValueChange:a(r=>w(o=>({...o,[t.name]:r==="__unset__"?"":r==="true"})),"onValueChange"),children:[(0,e.jsx)(le,{children:(0,e.jsx)(ue,{})}),(0,e.jsxs)(de,{children:[(0,e.jsx)(D,{value:"__unset__",children:"No value"}),(0,e.jsx)(D,{value:"true",children:"True"}),(0,e.jsx)(D,{value:"false",children:"False"})]})]}):t.type==="select"?(0,e.jsxs)(ie,{value:typeof d[t.name]=="string"&&d[t.name]?d[t.name]:"__unset__",onValueChange:a(r=>w(o=>({...o,[t.name]:r==="__unset__"?"":r})),"onValueChange"),children:[(0,e.jsx)(le,{children:(0,e.jsx)(ue,{placeholder:"Choose a value"})}),(0,e.jsxs)(de,{children:[(0,e.jsx)(D,{value:"__unset__",children:"No value"}),t.options.map(r=>(0,e.jsx)(D,{value:r,children:r},r))]})]}):ms(t)?(0,e.jsx)(se,{type:"date",value:d[t.name]==null?"":String(d[t.name]),onChange:a(r=>w(o=>({...o,[t.name]:r.target.value})),"onChange")}):(0,e.jsx)(se,{type:t.type==="number"?"number":"text",value:d[t.name]==null?"":String(d[t.name]),onChange:a(r=>w(o=>({...o,[t.name]:r.target.value})),"onChange")})]},t.name)),C&&N&&u?(0,e.jsx)(is,{issue:E,project:N,initialEditing:!0,livePreview:!0,onUpdate:A,onDraftChange:O},`${s?"open":"closed"}:${N.id}`):null]}),(0,e.jsxs)(Ae,{showCloseButton:!1,className:"shrink-0 border-t border-line/60 bg-bg px-6 pb-(--sz-calc-19) pt-4",children:[h.assigneeAgentId?F.length>0?(0,e.jsxs)("p",{className:"mr-auto text-xs text-amber-600",children:["Missing: ",F.join(", ")]}):C&&!g?(0,e.jsx)("p",{className:"mr-auto text-xs text-amber-600",children:"Choose an existing workspace before running."}):(0,e.jsx)("span",{className:"mr-auto"}):(0,e.jsx)("p",{className:"mr-auto text-xs text-amber-600",children:"Default agent required for this run."}),(0,e.jsx)(L,{variant:"ghost",onClick:a(()=>n(!1),"onClick"),disabled:j,children:"Cancel"}),(0,e.jsx)(L,{onClick:a(()=>{const t={};for(const r of _){if(M(r)){t[r.name]=S;continue}const o=d[r.name];fe(o)||(r.type==="number"?t[r.name]=Number(o):r.type==="boolean"?t[r.name]=o===!0:t[r.name]=String(o))}b({variables:t,assigneeAgentId:h.assigneeAgentId,projectId:h.projectId||null,...C?{executionWorkspaceId:p.executionWorkspaceId,executionWorkspacePreference:p.executionWorkspacePreference,executionWorkspaceSettings:p.executionWorkspaceSettings}:{}})},"onClick"),disabled:j||!$,children:j?"Running...":"Run routine"})]})]})})}a($s,"RoutineRunVariablesDialog");export{$s as t};
@@ -1 +1 @@
1
- var bt=Object.defineProperty;var s=(n,c)=>bt(n,"name",{value:c,configurable:!0});import{i as tt}from"./rolldown-runtime-ZpX3ckPj.js";import{l as wt,na as Nt,ta as It}from"./createLucideIcon-DJi9suAC.js";import{y as kt}from"./star-BZgQbzhV.js";import{X as _t,_ as F,t as p,v as D}from"./queryKeys-DYV5MhM_.js";import{n as Ct}from"./CompanyContext-CSrVsSze.js";import{o as Rt,r as St,t as Ft,tt as At}from"./router-2UfGeejU.js";import{n as Qe,r as st,t as Be}from"./collapsible-CqjPlqOa.js";import{t as Pt}from"./MarkdownEditor-DXD-Cu3u.js";import{o as Ve,r as We,t as ze}from"./popover-BhYHYj7q.js";import{t as Mt}from"./arrow-up-down-Bpe9xqCo.js";import{t as Dt}from"./check-Ctsrlfa-.js";import{t as qt}from"./chevron-down-BCvxsWfI.js";import{t as nt}from"./chevron-right-s7L6hXXq.js";import{t as _}from"./button-CMwV3L1P.js";import{t as Y}from"./plus-C6fnr28l.js";import{t as Z}from"./repeat-DGPKlc5I.js";import{t as $e}from"./AgentAvatar-DgGEobSY.js";import{a as Tt}from"./ToastContext-DMdt9oTd.js";import{t as Ot}from"./agents-DmlgUVso.js";import{t as Kt}from"./heartbeats-DOyojsaN.js";import{n as Ut,t as Et}from"./useSharedPolling-D4Xn8mY2.js";import{t as Lt}from"./projects-mixWrT5q.js";import{n as Qt,t as Bt}from"./dialog-CKUblzlR.js";import{t as Vt}from"./access-GAosX22P.js";import{r as Ge}from"./audit-navigation-IalprBz0.js";import{t as J}from"./routines-KPtwxuS7.js";import{n as Wt}from"./BreadcrumbContext-BVZDZoC0.js";import{i as zt,r as $t,t as Gt}from"./recent-assignees-DmalYaLf.js";import{t as He}from"./InlineEntitySelector-v2Q4C8oT.js";import{i as X,n as fe,o as xe,r as he,s as ge}from"./select-V0Hm_q4f.js";import{r as Ht,t as Yt}from"./card-Bru3x_SJ.js";import{Bn as Jt,I as je,Jn as Xt,Nr as Zt,T as ye,_ as es,n as ts,t as ss,zn as ns}from"./index-DDoARkPG.js";import{a as rs,c as is,d as os,f as as,i as ls,l as cs,n as ds,o as us,r as ms,s as ps,t as fs,u as xs,x as A}from"./FolderControls-B7TWghGc.js";import{t as hs}from"./RoutineRunVariablesDialog-DiT_o5Dm.js";var l=tt(Nt(),1),t=tt(It(),1),gs=["coalesce_if_active","always_enqueue","skip_if_active"],js=["skip_missed","enqueue_missed_with_cap"],ys={coalesce_if_active:"If a run is already active, keep just one follow-up run queued.",always_enqueue:"Queue every trigger occurrence, even if the routine is already running.",skip_if_active:"Drop new trigger occurrences while a run is still active."},vs={skip_missed:"Ignore windows that were missed while the scheduler or routine was paused.",enqueue_missed_with_cap:"Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap."};function Ye(n){n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)}s(Ye,"autoResizeTextarea");var bs="__built_in_routines",Je={sortField:"title",sortDir:"asc",groupBy:"folder",collapsedGroups:[]};function Xe(n){try{const c=localStorage.getItem(n);if(c)return{...Je,...JSON.parse(c)}}catch{}return{...Je}}s(Xe,"getRoutineViewState");function ws(n,c){localStorage.setItem(n,JSON.stringify(c))}s(ws,"saveRoutineViewState");function q(n){if(!n)return Number.NEGATIVE_INFINITY;const c=new Date(n).getTime();return Number.isFinite(c)?c:Number.NEGATIVE_INFINITY}s(q,"timestampValue");function Ze(n,c){return(n??"").localeCompare(c??"",void 0,{sensitivity:"base"})}s(Ze,"compareNullableText");function Ns(n){return{...n,description:n.description.trim()||null,projectId:n.projectId||null,folderId:n.folderId||null,assigneeAgentId:n.assigneeAgentId||null}}s(Ns,"buildRoutineMutationPayload");function Is(n,c,d,N,x){if(c==="none")return[{key:"__all",label:null,items:n}];if(c==="folder"){const i=je(n,o=>o.folderId??"__unfiled");return Object.keys(i).sort((o,j)=>{if(o==="__unfiled"||j==="__unfiled")return o===j?0:o==="__unfiled"?1:-1;const b=x.get(o),I=x.get(j),U=(Number.isFinite(b?.position)?b.position:Number.POSITIVE_INFINITY)-(Number.isFinite(I?.position)?I.position:Number.POSITIVE_INFINITY);return U!==0?U:(b?.name??"Unknown folder").localeCompare(I?.name??"Unknown folder",void 0,{sensitivity:"base"})||o.localeCompare(j)}).map(o=>({key:o,label:o==="__unfiled"?"Unfiled":x.get(o)?.name??"Unknown folder",items:i[o]}))}if(c==="project"){const i=je(n,o=>o.projectId??"__no_project");return Object.keys(i).sort((o,j)=>{const b=o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",I=j==="__no_project"?"No project":d.get(j)?.name??"Unknown project";return b.localeCompare(I)}).map(o=>({key:o,label:o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",items:i[o]}))}const h=je(n,i=>i.assigneeAgentId??"__unassigned");return Object.keys(h).sort((i,o)=>{const j=i==="__unassigned"?"Unassigned":N.get(i)?.name??"Unknown agent",b=o==="__unassigned"?"Unassigned":N.get(o)?.name??"Unknown agent";return j.localeCompare(b)}).map(i=>({key:i,label:i==="__unassigned"?"Unassigned":N.get(i)?.name??"Unknown agent",items:h[i]}))}s(Is,"buildRoutineGroups");function et(n){return n.originKind==="built_in_agent_bundle"}s(et,"isBuiltInRoutine");function ks(n,c,d,N,x){const h=n.filter(et),i=Is(n.filter(o=>!et(o)),c,d,N,x).filter(o=>o.items.length>0).map(o=>h.length>0&&c==="none"&&o.key==="__all"?{...o,label:"Custom routines"}:o);return h.length===0?i:[...i,{key:bs,label:"Built-in routines",items:h}]}s(ks,"buildRoutineSections");function _s(n,c,d){const N=d==="asc"?1:-1;return[...n].sort((x,h)=>{let i=0;return c==="title"?i=Ze(x.title,h.title):c==="created"?i=q(x.createdAt)-q(h.createdAt):c==="lastRun"?i=q(x.lastRun?.triggeredAt??x.lastTriggeredAt)-q(h.lastRun?.triggeredAt??h.lastTriggeredAt):i=q(x.updatedAt)-q(h.updatedAt),i!==0?i*N:Ze(x.title,h.title)})}s(_s,"sortRoutines");function Cs({label:n,count:c,isOpen:d}){return(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,t.jsxs)(st,{className:"flex items-center gap-1.5",children:[(0,t.jsx)(nt,{className:"h-3.5 w-3.5 shrink-0 text-ink-3 transition-transform [[data-state=open]>&]:rotate-90"}),(0,t.jsx)("span",{"data-routine-section-label":!0,className:"text-sm font-medium",children:n})]}),(0,t.jsx)("span",{className:"text-xs text-ink-3",children:c})]})}s(Cs,"RoutineSectionHeader");function un(){const{selectedCompanyId:n}=Ct(),{setBreadcrumbs:c}=Wt(),d=_t(),N=Rt(),[x,h]=kt(),{pushToast:i}=Tt(),o=(0,l.useRef)(null),j=(0,l.useRef)(null),b=(0,l.useRef)(null),I=(0,l.useRef)(null),[U,T]=(0,l.useState)(!1),[ee,E]=(0,l.useState)(null),[L,te]=(0,l.useState)(null),[rt,ve]=(0,l.useState)(!1),[se,ne]=(0,l.useState)(!1),[Q,B]=(0,l.useState)([]),[be,we]=(0,l.useState)([]),[it,Ne]=(0,l.useState)(null),[ot,Ie]=(0,l.useState)(null),[C,re]=(0,l.useState)(null),[V,W]=(0,l.useState)(!1),[ke,ie]=(0,l.useState)(!1),at=x.get("tab")==="runs",[m,k]=(0,l.useState)({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),z=n?`wardmote:routines-view:${n}`:"wardmote:routines-view",[u,_e]=(0,l.useState)(()=>Xe(z)),f=os(x.get("folder"));(0,l.useEffect)(()=>{c([{label:"Routines"}])},[c]),(0,l.useEffect)(()=>{_e(Xe(z))},[z]);const{data:Ce,isLoading:lt,error:oe}=D({queryKey:p.routines.list(n),queryFn:s(()=>J.list(n),"queryFn"),enabled:!!n}),{data:g,isLoading:Re}=D({queryKey:p.folders.list(n,"routine"),queryFn:s(()=>A.list(n,"routine"),"queryFn"),enabled:!!n}),{data:R}=D({queryKey:p.agents.list(n),queryFn:s(()=>Ot.list(n),"queryFn"),enabled:!!n}),{data:S}=D({queryKey:p.projects.list(n,{includeArchived:!0}),queryFn:s(()=>Lt.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:Se}=D({queryKey:p.access.companyUserDirectory(n),queryFn:s(()=>Vt.listUserDirectory(n),"queryFn"),enabled:!!n}),Fe=p.liveRuns(n),ae=Ut({companyId:n,resourceKey:"live-runs",queryKey:Fe,enabled:!!n&&!1,refetchInterval:!1,leaderOnly:!0}),{data:ct,dataUpdatedAt:dt}=D({queryKey:Fe,queryFn:s(()=>Kt.liveRunsForCompany(n),"queryFn"),enabled:ae.enabled,refetchInterval:ae.refetchInterval});Et(ae,ct,dt),(0,l.useEffect)(()=>{Ye(j.current)},[m.title,V]);const ut=(0,l.useMemo)(()=>Xt({agents:R,projects:(S??[]).filter(e=>!e.archivedAt),members:Se?.users}),[R,Se?.users,S]),w=F({mutationFn:s(()=>J.create(n,Ns(m)),"mutationFn"),onSuccess:s(async e=>{k({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),W(!1),ie(!1),await d.invalidateQueries({queryKey:p.routines.list(n)}),i({title:"Routine created",body:e.assigneeAgentId?"Add the first trigger to turn it into a live workflow.":"Draft saved. Add a default agent before enabling automation.",tone:"success"}),N(Zt(e.id,"triggers"))},"onSuccess")}),Ae=F({mutationFn:s(e=>A.create(n,{kind:"routine",...e}),"mutationFn"),onSuccess:s(async e=>{if(T(!1),E(null),await d.invalidateQueries({queryKey:p.folders.list(n,"routine")}),be.length>0){const r=be;we([]);try{await Promise.all(r.map(a=>A.moveItem(n,{kind:"routine",itemId:a,folderId:e.id}))),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})])}catch(a){i({title:"Folder created, move failed",body:a instanceof Error?a.message:"Wardmote could not move the selected routines.",tone:"error"});return}}else G(e.id);i({title:"Folder created",body:e.name,tone:"success"})},"onSuccess"),onError:s(e=>{i({title:"Failed to save folder",body:e instanceof Error?e.message:"Wardmote could not save the folder.",tone:"error"})},"onError")}),le=F({mutationFn:s(({folderId:e,payload:r})=>A.update(n,e,r),"mutationFn"),onSuccess:s(async()=>{T(!1),E(null),await d.invalidateQueries({queryKey:p.folders.list(n,"routine")})},"onSuccess"),onError:s(e=>{i({title:"Folder save failed",body:e instanceof Error?e.message:"Wardmote could not update the folder.",tone:"error"})},"onError")}),Pe=F({mutationFn:s(e=>A.delete(n,e),"mutationFn"),onSuccess:s(async(e,r)=>{f===r&&G("all"),te(null),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})]),i({title:"Folder deleted",body:"Items moved to Unfiled.",tone:"success"})},"onSuccess"),onError:s(e=>{i({title:"Folder delete failed",body:e instanceof Error?e.message:"Wardmote could not delete the folder.",tone:"error"})},"onError")}),Me=F({mutationFn:s(({itemId:e,folderId:r})=>A.moveItem(n,{kind:"routine",itemId:e,folderId:r}),"mutationFn"),onSuccess:s(async()=>{await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})])},"onSuccess"),onError:s(e=>{i({title:"Move failed",body:e instanceof Error?e.message:"Wardmote could not move the routine.",tone:"error"})},"onError")}),De=F({mutationFn:s(({id:e,status:r})=>J.update(e,{status:r}),"mutationFn"),onMutate:s(({id:e})=>{Ie(e)},"onMutate"),onSuccess:s(async(e,r)=>{await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.routines.detail(r.id)})])},"onSuccess"),onSettled:s(()=>{Ie(null)},"onSettled"),onError:s(e=>{i({title:"Failed to update routine",body:e instanceof Error?e.message:"Wardmote could not update the routine.",tone:"error"})},"onError")}),qe=F({mutationFn:s(({id:e,data:r})=>J.run(e,{...r?.variables&&Object.keys(r.variables).length>0?{variables:r.variables}:{},...r?.assigneeAgentId!==void 0?{assigneeAgentId:r.assigneeAgentId}:{},...r?.projectId!==void 0?{projectId:r.projectId}:{},...r?.executionWorkspaceId!==void 0?{executionWorkspaceId:r.executionWorkspaceId}:{},...r?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:r.executionWorkspacePreference}:{},...r?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:r.executionWorkspaceSettings}:{}}),"mutationFn"),onMutate:s(({id:e})=>{Ne(e)},"onMutate"),onSuccess:s(async(e,{id:r})=>{re(null),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.routines.detail(r)})])},"onSuccess"),onSettled:s(()=>{Ne(null)},"onSettled"),onError:s(e=>{i({title:"Routine run failed",body:e instanceof Error?e.message:"Wardmote could not start the routine run.",tone:"error"})},"onError")}),ce=(0,l.useMemo)(()=>Gt(),[V]),mt=(0,l.useMemo)(()=>ns(),[V]),pt=(0,l.useMemo)(()=>$t((R??[]).filter(e=>e.status!=="terminated"),ce).map(e=>({id:e.id,label:e.name,searchText:`${e.name} ${e.role} ${e.title??""}`})),[R,ce]),ft=(0,l.useMemo)(()=>(S??[]).filter(e=>!e.archivedAt).map(e=>({id:e.id,label:e.name,searchText:e.description??""})),[S]),O=(0,l.useMemo)(()=>new Map((R??[]).map(e=>[e.id,e])),[R]),K=(0,l.useMemo)(()=>new Map((S??[]).map(e=>[e.id,e])),[S]),Te=(0,l.useMemo)(()=>new Map((g?.folders??[]).map(e=>[e.id,e])),[g]),y=(0,l.useMemo)(()=>(Ce??[]).filter(e=>e.status!=="archived"),[Ce]),Oe=(0,l.useMemo)(()=>u.groupBy!=="folder"||f==="all"?y:f==="unfiled"?y.filter(e=>!e.folderId):y.filter(e=>e.folderId===f),[f,u.groupBy,y]),de=(0,l.useMemo)(()=>{if(!g)return g;const e=new Map;let r=0;for(const a of y)a.folderId?e.set(a.folderId,(e.get(a.folderId)??0)+1):r+=1;return{...g,allCount:y.length,unfiledCount:r,folders:g.folders.map(a=>({...a,itemCount:e.get(a.id)??0}))}},[g,y]),P=(0,l.useMemo)(()=>_s(Oe,u.sortField,u.sortDir),[Oe,u.sortDir,u.sortField]),xt=(0,l.useMemo)(()=>ks(P,u.groupBy,K,O,Te),[O,Te,K,u.groupBy,P]),Ke=m.assigneeAgentId?O.get(m.assigneeAgentId)??null:null,Ue=m.projectId?K.get(m.projectId)??null:null,Ee=as(g?.folders??[],f),$=(g?.folders.length??0)>0,ue=u.groupBy==="folder"&&$;function me(e){_e(r=>{const a={...r,...e};return ws(z,a),a})}s(me,"updateRoutineView");function G(e){h(r=>{const a=new URLSearchParams(r),v=xs(e);return v?a.set("folder",v):a.delete("folder"),a})}s(G,"setFolderSelection");function M(e=[]){we(e),E(null),T(!0)}s(M,"openCreateFolder");function Le(){k(e=>({...e,folderId:f==="all"||f==="unfiled"?null:f})),W(!0)}s(Le,"openCreateRoutine");async function ht(e){const r=Q;if(r.length!==0)try{await Promise.all(r.map(a=>A.moveItem(n,{kind:"routine",itemId:a,folderId:e}))),B([]),ne(!1),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})]),i({title:"Routines moved",body:`${r.length} routine${r.length===1?"":"s"} filed.`,tone:"success"})}catch(a){i({title:"Failed to move routines",body:a instanceof Error?a.message:"Wardmote could not move the selected routines.",tone:"error"})}}s(ht,"moveSelectedRoutines");function gt(e){re(e)}s(gt,"handleRunNow");function jt(e,r){if(!r&&!e.assigneeAgentId){i({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}De.mutate({id:e.id,status:ts(e.status,!r)})}s(jt,"handleToggleEnabled");function yt(e){De.mutate({id:e.id,status:e.status==="archived"?"active":"archived"})}return s(yt,"handleToggleArchived"),n?at?(0,t.jsx)(St,{to:Ge("runs",{}),replace:!0}):lt?(0,t.jsx)(es,{variant:"issues-list"}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h1",{className:"text-xl font-bold",children:"Routines"}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Recurring work definitions that materialize into auditable execution tasks."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(_,{variant:"secondary",asChild:!0,children:(0,t.jsx)(Ft,{to:Ge("runs",{}),children:"View all runs"})}),(0,t.jsxs)(_,{onClick:Le,children:[(0,t.jsx)(Y,{className:"mr-2 h-4 w-4"}),"Create routine"]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("p",{className:"text-sm text-ink-3",children:[y.length," routine",y.length===1?"":"s"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)(ze,{children:[(0,t.jsx)(Ve,{asChild:!0,children:(0,t.jsxs)(_,{variant:"ghost",size:"sm",className:"text-xs",title:"Sort",children:[(0,t.jsx)(Mt,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Sort"})]})}),(0,t.jsx)(We,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["updated","Updated"],["created","Created"],["lastRun","Last run"],["title","Title"]].map(([e,r])=>(0,t.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.sortField===e?"bg-bg-3/50 text-ink":"text-ink-3 hover:bg-bg-3/50"}`,onClick:s(()=>{me(u.sortField===e?{sortDir:u.sortDir==="asc"?"desc":"asc"}:{sortField:e,sortDir:e==="title"?"asc":"desc"})},"onClick"),children:[(0,t.jsx)("span",{children:r}),u.sortField===e?(0,t.jsx)("span",{className:"text-xs text-ink-3",children:u.sortDir==="asc"?"Asc":"Desc"}):null]},e))})})]}),(0,t.jsxs)(ze,{children:[(0,t.jsx)(Ve,{asChild:!0,children:(0,t.jsxs)(_,{variant:"ghost",size:"sm",className:"text-xs",title:"Group",children:[(0,t.jsx)(At,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Group"})]})}),(0,t.jsx)(We,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["folder","Folder"],["project","Project"],["assignee","Agent"],["none","None"]].map(([e,r])=>(0,t.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.groupBy===e?"bg-bg-3/50 text-ink":"text-ink-3 hover:bg-bg-3/50"}`,onClick:s(()=>me({groupBy:e,collapsedGroups:[]}),"onClick"),children:[(0,t.jsx)("span",{children:r}),u.groupBy===e?(0,t.jsx)(Dt,{className:"h-3.5 w-3.5"}):null]},e))})})]}),u.groupBy==="folder"&&!$?(0,t.jsxs)(_,{variant:"secondary",size:"sm",onClick:s(()=>M(),"onClick"),children:[(0,t.jsx)(Y,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}):null,ue?(0,t.jsx)(_,{variant:"ghost",size:"sm",className:"text-xs",onClick:s(()=>ne(e=>!e),"onClick"),children:se?"Done":"Select"}):null]})]}),u.groupBy==="folder"?(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsx)(ls,{result:de,selection:f,allLabel:"All routines",onClick:s(()=>ve(!0),"onClick")})}):null]}),(0,t.jsx)(Bt,{open:V,onOpenChange:s(e=>{w.isPending||W(e)},"onOpenChange"),children:(0,t.jsxs)(Qt,{showCloseButton:!1,className:"flex max-h-(--sz-calc-18) max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center justify-between gap-3 border-b border-line/60 px-5 py-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-ink-3",children:"New routine"}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Define the recurring work first. Default project and agent are optional for draft routines."})]}),(0,t.jsx)(_,{variant:"ghost",size:"sm",onClick:s(()=>{W(!1),ie(!1)},"onClick"),disabled:w.isPending,children:"Cancel"})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,t.jsx)("div",{className:"px-5 pt-5 pb-3",children:(0,t.jsx)("textarea",{ref:j,className:"w-full resize-none overflow-hidden bg-transparent text-xl font-semibold outline-none placeholder:text-ink-3/50",placeholder:"Routine title",rows:1,value:m.title,onChange:s(e=>{k(r=>({...r,title:e.target.value})),Ye(e.target)},"onChange"),onKeyDown:s(e=>{if(e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing){e.preventDefault(),o.current?.focus();return}e.key==="Tab"&&!e.shiftKey&&(e.preventDefault(),m.assigneeAgentId?m.projectId?o.current?.focus():I.current?.focus():b.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-5 pb-3",children:(0,t.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,t.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-ink-3 sm:min-w-max sm:flex-nowrap",children:[(0,t.jsx)("span",{children:"For"}),(0,t.jsx)(He,{ref:b,value:m.assigneeAgentId,options:pt,recentOptionIds:ce,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:s(e=>{e&&zt(e),k(r=>({...r,assigneeAgentId:e}))},"onChange"),onConfirm:s(()=>{m.projectId?o.current?.focus():I.current?.focus()},"onConfirm"),renderTriggerValue:s(e=>e?Ke?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)($e,{agent:Ke,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"truncate",children:e.label}):(0,t.jsx)("span",{className:"text-ink-3",children:"Responsible"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=O.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[r?(0,t.jsx)($e,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"in"}),(0,t.jsx)(He,{ref:I,value:m.projectId,options:ft,recentOptionIds:mt,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:s(e=>{e&&Jt(e),k(r=>({...r,projectId:e}))},"onChange"),onConfirm:s(()=>o.current?.focus(),"onConfirm"),renderTriggerValue:s(e=>e&&Ue?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:Ue.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"text-ink-3",children:"Project"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=K.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"filed in"}),(0,t.jsxs)(fe,{value:m.folderId??"__unfiled",onValueChange:s(e=>k(r=>({...r,folderId:e==="__unfiled"?null:e})),"onValueChange"),children:[(0,t.jsx)(xe,{className:"h-8 w-auto min-w-32 border-0 bg-bg-3/50 px-2 shadow-none",children:(0,t.jsx)(ge,{})}),(0,t.jsxs)(he,{children:[(0,t.jsx)(X,{value:"__unfiled",children:"Unfiled"}),(g?.folders??[]).map(e=>(0,t.jsx)(X,{value:e.id,children:e.name},e.id))]})]})]})})}),(0,t.jsx)("div",{className:"border-t border-line/60 px-5 py-4",children:(0,t.jsx)(Pt,{ref:o,value:m.description,onChange:s(e=>k(r=>({...r,description:e})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-160px) text-sm text-ink-3",mentions:ut,onSubmit:s(()=>{!w.isPending&&m.title.trim()&&m.projectId&&m.assigneeAgentId&&w.mutate()},"onSubmit")})}),(0,t.jsx)("div",{className:"border-t border-line/60 px-5 py-3",children:(0,t.jsxs)(Be,{open:ke,onOpenChange:ie,children:[(0,t.jsxs)(st,{className:"flex w-full items-center justify-between text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Advanced delivery settings"}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Keep policy controls secondary to the work definition."})]}),ke?(0,t.jsx)(qt,{className:"h-4 w-4 text-ink-3"}):(0,t.jsx)(nt,{className:"h-4 w-4 text-ink-3"})]}),(0,t.jsx)(Qe,{className:"pt-3",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-ink-3",children:"Concurrency"}),(0,t.jsxs)(fe,{value:m.concurrencyPolicy,onValueChange:s(e=>k(r=>({...r,concurrencyPolicy:e})),"onValueChange"),children:[(0,t.jsx)(xe,{children:(0,t.jsx)(ge,{})}),(0,t.jsx)(he,{children:gs.map(e=>(0,t.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:ys[m.concurrencyPolicy]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-ink-3",children:"Catch-up"}),(0,t.jsxs)(fe,{value:m.catchUpPolicy,onValueChange:s(e=>k(r=>({...r,catchUpPolicy:e})),"onValueChange"),children:[(0,t.jsx)(xe,{children:(0,t.jsx)(ge,{})}),(0,t.jsx)(he,{children:js.map(e=>(0,t.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:vs[m.catchUpPolicy]})]})]})})]})})]}),(0,t.jsxs)("div",{className:"shrink-0 flex flex-col gap-3 border-t border-line/60 px-5 py-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)("div",{className:"text-sm text-ink-3",children:"After creation, Wardmote takes you straight to trigger setup. Draft routines stay paused until you add a default agent."}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:items-end",children:[(0,t.jsxs)(_,{onClick:s(()=>w.mutate(),"onClick"),disabled:w.isPending||!m.title.trim(),children:[(0,t.jsx)(Y,{className:"mr-2 h-4 w-4"}),w.isPending?"Creating...":"Create routine"]}),w.isError?(0,t.jsx)("p",{className:"text-sm text-bad",children:w.error instanceof Error?w.error.message:"Failed to create routine"}):null]})]})]})}),oe?(0,t.jsx)(Yt,{children:(0,t.jsx)(Ht,{className:"pt-6 text-sm text-bad",children:oe instanceof Error?oe.message:"Failed to load routines"})}):null,(0,t.jsxs)("div",{className:wt(ue&&"flex gap-4"),children:[ue?(0,t.jsx)(us,{result:de,selection:f,allLabel:"All routines",itemLabelPlural:"routines",loading:Re,onSelect:G,onCreate:s(()=>M(),"onCreate"),onRename:s((e,r)=>le.mutate({folderId:e.id,payload:{name:r}}),"onRename"),onEdit:s(e=>{E(e),T(!0)},"onEdit"),onDelete:te}):null,(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[u.groupBy==="folder"&&$?(0,t.jsx)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:f==="all"?(0,t.jsx)(Rs,{label:"All routines",count:P.length}):(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(ps,{color:Ee?.color}),(0,t.jsx)("span",{className:"truncate font-medium",children:f==="unfiled"?"Unfiled":Ee?.name??"Folder"}),(0,t.jsxs)("span",{className:"text-ink-3",children:[P.length," routine",P.length===1?"":"s"]})]})}):null,u.groupBy==="folder"&&!$&&!Re&&y.length>0?(0,t.jsx)(fs,{storageKey:`wardmote:routines-folder-nudge:${n??"none"}`,itemLabelPlural:"routines",onCreateFolder:s(()=>M(),"onCreateFolder")}):null,se?(0,t.jsx)(ds,{selectedCount:Q.length,folders:g?.folders??[],onMove:s(e=>{ht(e)},"onMove"),onCreateAndMove:s(()=>M(Q),"onCreateAndMove"),onClear:s(()=>B([]),"onClear"),onDone:s(()=>{ne(!1),B([])},"onDone")}):null,y.length===0?(0,t.jsx)("div",{className:"py-12",children:(0,t.jsx)(ye,{icon:Z,message:"No active routines. Use Create routine to define the first recurring workflow."})}):P.length===0?(0,t.jsxs)("div",{className:"py-12",children:[(0,t.jsx)(ye,{icon:Z,message:f==="all"?"No routines match this view.":"This folder is empty."}),f!=="all"?(0,t.jsx)("div",{className:"mt-3 flex justify-center",children:(0,t.jsxs)(_,{size:"sm",onClick:Le,children:[(0,t.jsx)(Y,{className:"mr-2 h-3.5 w-3.5"}),"New routine in this folder"]})}):null]}):(0,t.jsx)("div",{className:"flex flex-col gap-3",children:xt.map(e=>{const r=!u.collapsedGroups.includes(e.key);return(0,t.jsxs)(Be,{open:r,onOpenChange:s(a=>{me({collapsedGroups:a?u.collapsedGroups.filter(v=>v!==e.key):[...u.collapsedGroups,e.key]})},"onOpenChange"),children:[e.label?(0,t.jsx)(Cs,{label:e.label,count:e.items.length,isOpen:r}):null,(0,t.jsx)(Qe,{children:e.items.map(a=>(0,t.jsx)(ss,{routine:a,projectById:K,agentById:O,runningRoutineId:it,statusMutationRoutineId:ot,href:`/routines/${a.id}`,runNowButton:!0,divider:!1,onRunNow:gt,onToggleEnabled:jt,onToggleArchived:yt,selectMode:se,selected:Q.includes(a.id),onSelectChange:s((v,pe)=>{B(H=>pe?Array.from(new Set([...H,v.id])):H.filter(vt=>vt!==v.id))},"onSelectChange"),extraMenuItems:(0,t.jsx)(cs,{folders:g?.folders??[],currentFolderId:a.folderId??null,onMove:s(v=>{const pe=a.folderId??null;Me.mutate({itemId:a.id,folderId:v}),i({title:"Routine moved",body:v?`Moved "${a.title}" to ${g?.folders.find(H=>H.id===v)?.name??"folder"}.`:`Moved "${a.title}" to Unfiled.`,tone:"success",action:{label:"Undo",onClick:s(()=>Me.mutate({itemId:a.id,folderId:pe}),"onClick")}})},"onMove"),onCreateAndMove:s(()=>M([a.id]),"onCreateAndMove")})},a.id))})]},e.key)})})]})]}),(0,t.jsx)(rs,{open:U,kind:"routine",folder:ee,pending:Ae.isPending||le.isPending,onOpenChange:T,onSubmit:s(e=>{ee?le.mutate({folderId:ee.id,payload:e}):Ae.mutate(e)},"onSubmit")}),(0,t.jsx)(ms,{open:L!==null,folder:L,itemLabelPlural:"routines",pending:Pe.isPending,onOpenChange:s(e=>{e||te(null)},"onOpenChange"),onConfirm:s(()=>{L&&Pe.mutate(L.id)},"onConfirm")}),(0,t.jsx)(is,{open:rt,onOpenChange:ve,result:de,selection:f,allLabel:"All routines",itemLabelPlural:"Routines",onSelect:G,onCreate:s(()=>M(),"onCreate")}),(0,t.jsx)(hs,{open:C!==null,onOpenChange:s(e=>{e||re(null)},"onOpenChange"),companyId:n,routineName:C?.title??null,agents:R??[],projects:S??[],defaultProjectId:C?.projectId??null,defaultAssigneeAgentId:C?.assigneeAgentId??null,variables:C?.variables??[],isPending:qe.isPending,onSubmit:s(e=>{C&&qe.mutate({id:C.id,data:e})},"onSubmit")})]}):(0,t.jsx)(ye,{icon:Z,message:"Select an organization to view routines."})}s(un,"Routines");function Rs({label:n,count:c}){return(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(Z,{className:"h-3.5 w-3.5 text-ink-3"}),(0,t.jsx)("span",{className:"truncate font-medium",children:n}),(0,t.jsxs)("span",{className:"text-ink-3",children:[c," routine",c===1?"":"s"]})]})}s(Rs,"FolderIconHeader");export{un as Routines};
1
+ var bt=Object.defineProperty;var s=(n,c)=>bt(n,"name",{value:c,configurable:!0});import{i as tt}from"./rolldown-runtime-ZpX3ckPj.js";import{l as wt,na as Nt,ta as It}from"./createLucideIcon-DJi9suAC.js";import{y as kt}from"./star-BZgQbzhV.js";import{X as _t,_ as F,t as p,v as D}from"./queryKeys-DYV5MhM_.js";import{n as Ct}from"./CompanyContext-CSrVsSze.js";import{o as Rt,r as St,t as Ft,tt as At}from"./router-2UfGeejU.js";import{n as Qe,r as st,t as Be}from"./collapsible-CqjPlqOa.js";import{t as Pt}from"./MarkdownEditor-DXD-Cu3u.js";import{o as Ve,r as We,t as ze}from"./popover-BhYHYj7q.js";import{t as Mt}from"./arrow-up-down-Bpe9xqCo.js";import{t as Dt}from"./check-Ctsrlfa-.js";import{t as qt}from"./chevron-down-BCvxsWfI.js";import{t as nt}from"./chevron-right-s7L6hXXq.js";import{t as _}from"./button-CMwV3L1P.js";import{t as Y}from"./plus-C6fnr28l.js";import{t as Z}from"./repeat-DGPKlc5I.js";import{t as $e}from"./AgentAvatar-DgGEobSY.js";import{a as Tt}from"./ToastContext-DMdt9oTd.js";import{t as Ot}from"./agents-DmlgUVso.js";import{t as Kt}from"./heartbeats-DOyojsaN.js";import{n as Ut,t as Et}from"./useSharedPolling-D4Xn8mY2.js";import{t as Lt}from"./projects-mixWrT5q.js";import{n as Qt,t as Bt}from"./dialog-CKUblzlR.js";import{t as Vt}from"./access-GAosX22P.js";import{r as Ge}from"./audit-navigation-IalprBz0.js";import{t as J}from"./routines-KPtwxuS7.js";import{n as Wt}from"./BreadcrumbContext-BVZDZoC0.js";import{i as zt,r as $t,t as Gt}from"./recent-assignees-DmalYaLf.js";import{t as He}from"./InlineEntitySelector-v2Q4C8oT.js";import{i as X,n as fe,o as xe,r as he,s as ge}from"./select-V0Hm_q4f.js";import{r as Ht,t as Yt}from"./card-Bru3x_SJ.js";import{Bn as Jt,I as je,Jn as Xt,Nr as Zt,T as ye,_ as es,n as ts,t as ss,zn as ns}from"./index-3AxqhPET.js";import{a as rs,c as is,d as os,f as as,i as ls,l as cs,n as ds,o as us,r as ms,s as ps,t as fs,u as xs,x as A}from"./FolderControls-L2RzbfdQ.js";import{t as hs}from"./RoutineRunVariablesDialog-D_Mls1sV.js";var l=tt(Nt(),1),t=tt(It(),1),gs=["coalesce_if_active","always_enqueue","skip_if_active"],js=["skip_missed","enqueue_missed_with_cap"],ys={coalesce_if_active:"If a run is already active, keep just one follow-up run queued.",always_enqueue:"Queue every trigger occurrence, even if the routine is already running.",skip_if_active:"Drop new trigger occurrences while a run is still active."},vs={skip_missed:"Ignore windows that were missed while the scheduler or routine was paused.",enqueue_missed_with_cap:"Catch up missed schedule windows after recovery; sub-hourly schedules are combined into one catch-up run, slower schedules replay each missed window up to a cap."};function Ye(n){n&&(n.style.height="auto",n.style.height=`${n.scrollHeight}px`)}s(Ye,"autoResizeTextarea");var bs="__built_in_routines",Je={sortField:"title",sortDir:"asc",groupBy:"folder",collapsedGroups:[]};function Xe(n){try{const c=localStorage.getItem(n);if(c)return{...Je,...JSON.parse(c)}}catch{}return{...Je}}s(Xe,"getRoutineViewState");function ws(n,c){localStorage.setItem(n,JSON.stringify(c))}s(ws,"saveRoutineViewState");function q(n){if(!n)return Number.NEGATIVE_INFINITY;const c=new Date(n).getTime();return Number.isFinite(c)?c:Number.NEGATIVE_INFINITY}s(q,"timestampValue");function Ze(n,c){return(n??"").localeCompare(c??"",void 0,{sensitivity:"base"})}s(Ze,"compareNullableText");function Ns(n){return{...n,description:n.description.trim()||null,projectId:n.projectId||null,folderId:n.folderId||null,assigneeAgentId:n.assigneeAgentId||null}}s(Ns,"buildRoutineMutationPayload");function Is(n,c,d,N,x){if(c==="none")return[{key:"__all",label:null,items:n}];if(c==="folder"){const i=je(n,o=>o.folderId??"__unfiled");return Object.keys(i).sort((o,j)=>{if(o==="__unfiled"||j==="__unfiled")return o===j?0:o==="__unfiled"?1:-1;const b=x.get(o),I=x.get(j),U=(Number.isFinite(b?.position)?b.position:Number.POSITIVE_INFINITY)-(Number.isFinite(I?.position)?I.position:Number.POSITIVE_INFINITY);return U!==0?U:(b?.name??"Unknown folder").localeCompare(I?.name??"Unknown folder",void 0,{sensitivity:"base"})||o.localeCompare(j)}).map(o=>({key:o,label:o==="__unfiled"?"Unfiled":x.get(o)?.name??"Unknown folder",items:i[o]}))}if(c==="project"){const i=je(n,o=>o.projectId??"__no_project");return Object.keys(i).sort((o,j)=>{const b=o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",I=j==="__no_project"?"No project":d.get(j)?.name??"Unknown project";return b.localeCompare(I)}).map(o=>({key:o,label:o==="__no_project"?"No project":d.get(o)?.name??"Unknown project",items:i[o]}))}const h=je(n,i=>i.assigneeAgentId??"__unassigned");return Object.keys(h).sort((i,o)=>{const j=i==="__unassigned"?"Unassigned":N.get(i)?.name??"Unknown agent",b=o==="__unassigned"?"Unassigned":N.get(o)?.name??"Unknown agent";return j.localeCompare(b)}).map(i=>({key:i,label:i==="__unassigned"?"Unassigned":N.get(i)?.name??"Unknown agent",items:h[i]}))}s(Is,"buildRoutineGroups");function et(n){return n.originKind==="built_in_agent_bundle"}s(et,"isBuiltInRoutine");function ks(n,c,d,N,x){const h=n.filter(et),i=Is(n.filter(o=>!et(o)),c,d,N,x).filter(o=>o.items.length>0).map(o=>h.length>0&&c==="none"&&o.key==="__all"?{...o,label:"Custom routines"}:o);return h.length===0?i:[...i,{key:bs,label:"Built-in routines",items:h}]}s(ks,"buildRoutineSections");function _s(n,c,d){const N=d==="asc"?1:-1;return[...n].sort((x,h)=>{let i=0;return c==="title"?i=Ze(x.title,h.title):c==="created"?i=q(x.createdAt)-q(h.createdAt):c==="lastRun"?i=q(x.lastRun?.triggeredAt??x.lastTriggeredAt)-q(h.lastRun?.triggeredAt??h.lastTriggeredAt):i=q(x.updatedAt)-q(h.updatedAt),i!==0?i*N:Ze(x.title,h.title)})}s(_s,"sortRoutines");function Cs({label:n,count:c,isOpen:d}){return(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,t.jsxs)(st,{className:"flex items-center gap-1.5",children:[(0,t.jsx)(nt,{className:"h-3.5 w-3.5 shrink-0 text-ink-3 transition-transform [[data-state=open]>&]:rotate-90"}),(0,t.jsx)("span",{"data-routine-section-label":!0,className:"text-sm font-medium",children:n})]}),(0,t.jsx)("span",{className:"text-xs text-ink-3",children:c})]})}s(Cs,"RoutineSectionHeader");function un(){const{selectedCompanyId:n}=Ct(),{setBreadcrumbs:c}=Wt(),d=_t(),N=Rt(),[x,h]=kt(),{pushToast:i}=Tt(),o=(0,l.useRef)(null),j=(0,l.useRef)(null),b=(0,l.useRef)(null),I=(0,l.useRef)(null),[U,T]=(0,l.useState)(!1),[ee,E]=(0,l.useState)(null),[L,te]=(0,l.useState)(null),[rt,ve]=(0,l.useState)(!1),[se,ne]=(0,l.useState)(!1),[Q,B]=(0,l.useState)([]),[be,we]=(0,l.useState)([]),[it,Ne]=(0,l.useState)(null),[ot,Ie]=(0,l.useState)(null),[C,re]=(0,l.useState)(null),[V,W]=(0,l.useState)(!1),[ke,ie]=(0,l.useState)(!1),at=x.get("tab")==="runs",[m,k]=(0,l.useState)({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),z=n?`wardmote:routines-view:${n}`:"wardmote:routines-view",[u,_e]=(0,l.useState)(()=>Xe(z)),f=os(x.get("folder"));(0,l.useEffect)(()=>{c([{label:"Routines"}])},[c]),(0,l.useEffect)(()=>{_e(Xe(z))},[z]);const{data:Ce,isLoading:lt,error:oe}=D({queryKey:p.routines.list(n),queryFn:s(()=>J.list(n),"queryFn"),enabled:!!n}),{data:g,isLoading:Re}=D({queryKey:p.folders.list(n,"routine"),queryFn:s(()=>A.list(n,"routine"),"queryFn"),enabled:!!n}),{data:R}=D({queryKey:p.agents.list(n),queryFn:s(()=>Ot.list(n),"queryFn"),enabled:!!n}),{data:S}=D({queryKey:p.projects.list(n,{includeArchived:!0}),queryFn:s(()=>Lt.list(n,{includeArchived:!0}),"queryFn"),enabled:!!n}),{data:Se}=D({queryKey:p.access.companyUserDirectory(n),queryFn:s(()=>Vt.listUserDirectory(n),"queryFn"),enabled:!!n}),Fe=p.liveRuns(n),ae=Ut({companyId:n,resourceKey:"live-runs",queryKey:Fe,enabled:!!n&&!1,refetchInterval:!1,leaderOnly:!0}),{data:ct,dataUpdatedAt:dt}=D({queryKey:Fe,queryFn:s(()=>Kt.liveRunsForCompany(n),"queryFn"),enabled:ae.enabled,refetchInterval:ae.refetchInterval});Et(ae,ct,dt),(0,l.useEffect)(()=>{Ye(j.current)},[m.title,V]);const ut=(0,l.useMemo)(()=>Xt({agents:R,projects:(S??[]).filter(e=>!e.archivedAt),members:Se?.users}),[R,Se?.users,S]),w=F({mutationFn:s(()=>J.create(n,Ns(m)),"mutationFn"),onSuccess:s(async e=>{k({title:"",description:"",projectId:"",folderId:null,assigneeAgentId:"",priority:"medium",concurrencyPolicy:"coalesce_if_active",catchUpPolicy:"skip_missed",variables:[]}),W(!1),ie(!1),await d.invalidateQueries({queryKey:p.routines.list(n)}),i({title:"Routine created",body:e.assigneeAgentId?"Add the first trigger to turn it into a live workflow.":"Draft saved. Add a default agent before enabling automation.",tone:"success"}),N(Zt(e.id,"triggers"))},"onSuccess")}),Ae=F({mutationFn:s(e=>A.create(n,{kind:"routine",...e}),"mutationFn"),onSuccess:s(async e=>{if(T(!1),E(null),await d.invalidateQueries({queryKey:p.folders.list(n,"routine")}),be.length>0){const r=be;we([]);try{await Promise.all(r.map(a=>A.moveItem(n,{kind:"routine",itemId:a,folderId:e.id}))),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})])}catch(a){i({title:"Folder created, move failed",body:a instanceof Error?a.message:"Wardmote could not move the selected routines.",tone:"error"});return}}else G(e.id);i({title:"Folder created",body:e.name,tone:"success"})},"onSuccess"),onError:s(e=>{i({title:"Failed to save folder",body:e instanceof Error?e.message:"Wardmote could not save the folder.",tone:"error"})},"onError")}),le=F({mutationFn:s(({folderId:e,payload:r})=>A.update(n,e,r),"mutationFn"),onSuccess:s(async()=>{T(!1),E(null),await d.invalidateQueries({queryKey:p.folders.list(n,"routine")})},"onSuccess"),onError:s(e=>{i({title:"Folder save failed",body:e instanceof Error?e.message:"Wardmote could not update the folder.",tone:"error"})},"onError")}),Pe=F({mutationFn:s(e=>A.delete(n,e),"mutationFn"),onSuccess:s(async(e,r)=>{f===r&&G("all"),te(null),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})]),i({title:"Folder deleted",body:"Items moved to Unfiled.",tone:"success"})},"onSuccess"),onError:s(e=>{i({title:"Folder delete failed",body:e instanceof Error?e.message:"Wardmote could not delete the folder.",tone:"error"})},"onError")}),Me=F({mutationFn:s(({itemId:e,folderId:r})=>A.moveItem(n,{kind:"routine",itemId:e,folderId:r}),"mutationFn"),onSuccess:s(async()=>{await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})])},"onSuccess"),onError:s(e=>{i({title:"Move failed",body:e instanceof Error?e.message:"Wardmote could not move the routine.",tone:"error"})},"onError")}),De=F({mutationFn:s(({id:e,status:r})=>J.update(e,{status:r}),"mutationFn"),onMutate:s(({id:e})=>{Ie(e)},"onMutate"),onSuccess:s(async(e,r)=>{await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.routines.detail(r.id)})])},"onSuccess"),onSettled:s(()=>{Ie(null)},"onSettled"),onError:s(e=>{i({title:"Failed to update routine",body:e instanceof Error?e.message:"Wardmote could not update the routine.",tone:"error"})},"onError")}),qe=F({mutationFn:s(({id:e,data:r})=>J.run(e,{...r?.variables&&Object.keys(r.variables).length>0?{variables:r.variables}:{},...r?.assigneeAgentId!==void 0?{assigneeAgentId:r.assigneeAgentId}:{},...r?.projectId!==void 0?{projectId:r.projectId}:{},...r?.executionWorkspaceId!==void 0?{executionWorkspaceId:r.executionWorkspaceId}:{},...r?.executionWorkspacePreference!==void 0?{executionWorkspacePreference:r.executionWorkspacePreference}:{},...r?.executionWorkspaceSettings!==void 0?{executionWorkspaceSettings:r.executionWorkspaceSettings}:{}}),"mutationFn"),onMutate:s(({id:e})=>{Ne(e)},"onMutate"),onSuccess:s(async(e,{id:r})=>{re(null),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.routines.detail(r)})])},"onSuccess"),onSettled:s(()=>{Ne(null)},"onSettled"),onError:s(e=>{i({title:"Routine run failed",body:e instanceof Error?e.message:"Wardmote could not start the routine run.",tone:"error"})},"onError")}),ce=(0,l.useMemo)(()=>Gt(),[V]),mt=(0,l.useMemo)(()=>ns(),[V]),pt=(0,l.useMemo)(()=>$t((R??[]).filter(e=>e.status!=="terminated"),ce).map(e=>({id:e.id,label:e.name,searchText:`${e.name} ${e.role} ${e.title??""}`})),[R,ce]),ft=(0,l.useMemo)(()=>(S??[]).filter(e=>!e.archivedAt).map(e=>({id:e.id,label:e.name,searchText:e.description??""})),[S]),O=(0,l.useMemo)(()=>new Map((R??[]).map(e=>[e.id,e])),[R]),K=(0,l.useMemo)(()=>new Map((S??[]).map(e=>[e.id,e])),[S]),Te=(0,l.useMemo)(()=>new Map((g?.folders??[]).map(e=>[e.id,e])),[g]),y=(0,l.useMemo)(()=>(Ce??[]).filter(e=>e.status!=="archived"),[Ce]),Oe=(0,l.useMemo)(()=>u.groupBy!=="folder"||f==="all"?y:f==="unfiled"?y.filter(e=>!e.folderId):y.filter(e=>e.folderId===f),[f,u.groupBy,y]),de=(0,l.useMemo)(()=>{if(!g)return g;const e=new Map;let r=0;for(const a of y)a.folderId?e.set(a.folderId,(e.get(a.folderId)??0)+1):r+=1;return{...g,allCount:y.length,unfiledCount:r,folders:g.folders.map(a=>({...a,itemCount:e.get(a.id)??0}))}},[g,y]),P=(0,l.useMemo)(()=>_s(Oe,u.sortField,u.sortDir),[Oe,u.sortDir,u.sortField]),xt=(0,l.useMemo)(()=>ks(P,u.groupBy,K,O,Te),[O,Te,K,u.groupBy,P]),Ke=m.assigneeAgentId?O.get(m.assigneeAgentId)??null:null,Ue=m.projectId?K.get(m.projectId)??null:null,Ee=as(g?.folders??[],f),$=(g?.folders.length??0)>0,ue=u.groupBy==="folder"&&$;function me(e){_e(r=>{const a={...r,...e};return ws(z,a),a})}s(me,"updateRoutineView");function G(e){h(r=>{const a=new URLSearchParams(r),v=xs(e);return v?a.set("folder",v):a.delete("folder"),a})}s(G,"setFolderSelection");function M(e=[]){we(e),E(null),T(!0)}s(M,"openCreateFolder");function Le(){k(e=>({...e,folderId:f==="all"||f==="unfiled"?null:f})),W(!0)}s(Le,"openCreateRoutine");async function ht(e){const r=Q;if(r.length!==0)try{await Promise.all(r.map(a=>A.moveItem(n,{kind:"routine",itemId:a,folderId:e}))),B([]),ne(!1),await Promise.all([d.invalidateQueries({queryKey:p.routines.list(n)}),d.invalidateQueries({queryKey:p.folders.list(n,"routine")})]),i({title:"Routines moved",body:`${r.length} routine${r.length===1?"":"s"} filed.`,tone:"success"})}catch(a){i({title:"Failed to move routines",body:a instanceof Error?a.message:"Wardmote could not move the selected routines.",tone:"error"})}}s(ht,"moveSelectedRoutines");function gt(e){re(e)}s(gt,"handleRunNow");function jt(e,r){if(!r&&!e.assigneeAgentId){i({title:"Default agent required",body:"Set a default agent before enabling routine automation.",tone:"warn"});return}De.mutate({id:e.id,status:ts(e.status,!r)})}s(jt,"handleToggleEnabled");function yt(e){De.mutate({id:e.id,status:e.status==="archived"?"active":"archived"})}return s(yt,"handleToggleArchived"),n?at?(0,t.jsx)(St,{to:Ge("runs",{}),replace:!0}):lt?(0,t.jsx)(es,{variant:"issues-list"}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h1",{className:"text-xl font-bold",children:"Routines"}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Recurring work definitions that materialize into auditable execution tasks."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(_,{variant:"secondary",asChild:!0,children:(0,t.jsx)(Ft,{to:Ge("runs",{}),children:"View all runs"})}),(0,t.jsxs)(_,{onClick:Le,children:[(0,t.jsx)(Y,{className:"mr-2 h-4 w-4"}),"Create routine"]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("p",{className:"text-sm text-ink-3",children:[y.length," routine",y.length===1?"":"s"]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)(ze,{children:[(0,t.jsx)(Ve,{asChild:!0,children:(0,t.jsxs)(_,{variant:"ghost",size:"sm",className:"text-xs",title:"Sort",children:[(0,t.jsx)(Mt,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Sort"})]})}),(0,t.jsx)(We,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["updated","Updated"],["created","Created"],["lastRun","Last run"],["title","Title"]].map(([e,r])=>(0,t.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.sortField===e?"bg-bg-3/50 text-ink":"text-ink-3 hover:bg-bg-3/50"}`,onClick:s(()=>{me(u.sortField===e?{sortDir:u.sortDir==="asc"?"desc":"asc"}:{sortField:e,sortDir:e==="title"?"asc":"desc"})},"onClick"),children:[(0,t.jsx)("span",{children:r}),u.sortField===e?(0,t.jsx)("span",{className:"text-xs text-ink-3",children:u.sortDir==="asc"?"Asc":"Desc"}):null]},e))})})]}),(0,t.jsxs)(ze,{children:[(0,t.jsx)(Ve,{asChild:!0,children:(0,t.jsxs)(_,{variant:"ghost",size:"sm",className:"text-xs",title:"Group",children:[(0,t.jsx)(At,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 sm:mr-1"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Group"})]})}),(0,t.jsx)(We,{align:"end",className:"w-44 p-0",children:(0,t.jsx)("div",{className:"p-2 space-y-0.5",children:[["folder","Folder"],["project","Project"],["assignee","Agent"],["none","None"]].map(([e,r])=>(0,t.jsxs)("button",{className:`flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm ${u.groupBy===e?"bg-bg-3/50 text-ink":"text-ink-3 hover:bg-bg-3/50"}`,onClick:s(()=>me({groupBy:e,collapsedGroups:[]}),"onClick"),children:[(0,t.jsx)("span",{children:r}),u.groupBy===e?(0,t.jsx)(Dt,{className:"h-3.5 w-3.5"}):null]},e))})})]}),u.groupBy==="folder"&&!$?(0,t.jsxs)(_,{variant:"secondary",size:"sm",onClick:s(()=>M(),"onClick"),children:[(0,t.jsx)(Y,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}):null,ue?(0,t.jsx)(_,{variant:"ghost",size:"sm",className:"text-xs",onClick:s(()=>ne(e=>!e),"onClick"),children:se?"Done":"Select"}):null]})]}),u.groupBy==="folder"?(0,t.jsx)("div",{className:"md:hidden",children:(0,t.jsx)(ls,{result:de,selection:f,allLabel:"All routines",onClick:s(()=>ve(!0),"onClick")})}):null]}),(0,t.jsx)(Bt,{open:V,onOpenChange:s(e=>{w.isPending||W(e)},"onOpenChange"),children:(0,t.jsxs)(Qt,{showCloseButton:!1,className:"flex max-h-(--sz-calc-18) max-w-3xl flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center justify-between gap-3 border-b border-line/60 px-5 py-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-ink-3",children:"New routine"}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Define the recurring work first. Default project and agent are optional for draft routines."})]}),(0,t.jsx)(_,{variant:"ghost",size:"sm",onClick:s(()=>{W(!1),ie(!1)},"onClick"),disabled:w.isPending,children:"Cancel"})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,t.jsx)("div",{className:"px-5 pt-5 pb-3",children:(0,t.jsx)("textarea",{ref:j,className:"w-full resize-none overflow-hidden bg-transparent text-xl font-semibold outline-none placeholder:text-ink-3/50",placeholder:"Routine title",rows:1,value:m.title,onChange:s(e=>{k(r=>({...r,title:e.target.value})),Ye(e.target)},"onChange"),onKeyDown:s(e=>{if(e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.nativeEvent.isComposing){e.preventDefault(),o.current?.focus();return}e.key==="Tab"&&!e.shiftKey&&(e.preventDefault(),m.assigneeAgentId?m.projectId?o.current?.focus():I.current?.focus():b.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-5 pb-3",children:(0,t.jsx)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,t.jsxs)("div",{className:"inline-flex min-w-full flex-wrap items-center gap-2 text-sm text-ink-3 sm:min-w-max sm:flex-nowrap",children:[(0,t.jsx)("span",{children:"For"}),(0,t.jsx)(He,{ref:b,value:m.assigneeAgentId,options:pt,recentOptionIds:ce,placeholder:"Responsible",noneLabel:"No responsible",searchPlaceholder:"Search responsible...",emptyMessage:"No responsible found.",onChange:s(e=>{e&&zt(e),k(r=>({...r,assigneeAgentId:e}))},"onChange"),onConfirm:s(()=>{m.projectId?o.current?.focus():I.current?.focus()},"onConfirm"),renderTriggerValue:s(e=>e?Ke?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)($e,{agent:Ke,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"truncate",children:e.label}):(0,t.jsx)("span",{className:"text-ink-3",children:"Responsible"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=O.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[r?(0,t.jsx)($e,{agent:r,size:16,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):null,(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"in"}),(0,t.jsx)(He,{ref:I,value:m.projectId,options:ft,recentOptionIds:mt,placeholder:"Project",noneLabel:"No project",searchPlaceholder:"Search projects...",emptyMessage:"No projects found.",onChange:s(e=>{e&&Jt(e),k(r=>({...r,projectId:e}))},"onChange"),onConfirm:s(()=>o.current?.focus(),"onConfirm"),renderTriggerValue:s(e=>e&&Ue?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:Ue.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]}):(0,t.jsx)("span",{className:"text-ink-3",children:"Project"}),"renderTriggerValue"),renderOption:s(e=>{if(!e.id)return(0,t.jsx)("span",{className:"truncate",children:e.label});const r=K.get(e.id);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:r?.color??"var(--project-none)"}}),(0,t.jsx)("span",{className:"truncate",children:e.label})]})},"renderOption")}),(0,t.jsx)("span",{children:"filed in"}),(0,t.jsxs)(fe,{value:m.folderId??"__unfiled",onValueChange:s(e=>k(r=>({...r,folderId:e==="__unfiled"?null:e})),"onValueChange"),children:[(0,t.jsx)(xe,{className:"h-8 w-auto min-w-32 border-0 bg-bg-3/50 px-2 shadow-none",children:(0,t.jsx)(ge,{})}),(0,t.jsxs)(he,{children:[(0,t.jsx)(X,{value:"__unfiled",children:"Unfiled"}),(g?.folders??[]).map(e=>(0,t.jsx)(X,{value:e.id,children:e.name},e.id))]})]})]})})}),(0,t.jsx)("div",{className:"border-t border-line/60 px-5 py-4",children:(0,t.jsx)(Pt,{ref:o,value:m.description,onChange:s(e=>k(r=>({...r,description:e})),"onChange"),placeholder:"Add instructions...",bordered:!1,contentClassName:"min-h-(--sz-160px) text-sm text-ink-3",mentions:ut,onSubmit:s(()=>{!w.isPending&&m.title.trim()&&m.projectId&&m.assigneeAgentId&&w.mutate()},"onSubmit")})}),(0,t.jsx)("div",{className:"border-t border-line/60 px-5 py-3",children:(0,t.jsxs)(Be,{open:ke,onOpenChange:ie,children:[(0,t.jsxs)(st,{className:"flex w-full items-center justify-between text-left",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Advanced delivery settings"}),(0,t.jsx)("p",{className:"text-sm text-ink-3",children:"Keep policy controls secondary to the work definition."})]}),ke?(0,t.jsx)(qt,{className:"h-4 w-4 text-ink-3"}):(0,t.jsx)(nt,{className:"h-4 w-4 text-ink-3"})]}),(0,t.jsx)(Qe,{className:"pt-3",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-ink-3",children:"Concurrency"}),(0,t.jsxs)(fe,{value:m.concurrencyPolicy,onValueChange:s(e=>k(r=>({...r,concurrencyPolicy:e})),"onValueChange"),children:[(0,t.jsx)(xe,{children:(0,t.jsx)(ge,{})}),(0,t.jsx)(he,{children:gs.map(e=>(0,t.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:ys[m.concurrencyPolicy]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs font-medium uppercase tracking-(--tracking-caps) text-ink-3",children:"Catch-up"}),(0,t.jsxs)(fe,{value:m.catchUpPolicy,onValueChange:s(e=>k(r=>({...r,catchUpPolicy:e})),"onValueChange"),children:[(0,t.jsx)(xe,{children:(0,t.jsx)(ge,{})}),(0,t.jsx)(he,{children:js.map(e=>(0,t.jsx)(X,{value:e,children:e.replaceAll("_"," ")},e))})]}),(0,t.jsx)("p",{className:"text-xs text-ink-3",children:vs[m.catchUpPolicy]})]})]})})]})})]}),(0,t.jsxs)("div",{className:"shrink-0 flex flex-col gap-3 border-t border-line/60 px-5 py-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)("div",{className:"text-sm text-ink-3",children:"After creation, Wardmote takes you straight to trigger setup. Draft routines stay paused until you add a default agent."}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:items-end",children:[(0,t.jsxs)(_,{onClick:s(()=>w.mutate(),"onClick"),disabled:w.isPending||!m.title.trim(),children:[(0,t.jsx)(Y,{className:"mr-2 h-4 w-4"}),w.isPending?"Creating...":"Create routine"]}),w.isError?(0,t.jsx)("p",{className:"text-sm text-bad",children:w.error instanceof Error?w.error.message:"Failed to create routine"}):null]})]})]})}),oe?(0,t.jsx)(Yt,{children:(0,t.jsx)(Ht,{className:"pt-6 text-sm text-bad",children:oe instanceof Error?oe.message:"Failed to load routines"})}):null,(0,t.jsxs)("div",{className:wt(ue&&"flex gap-4"),children:[ue?(0,t.jsx)(us,{result:de,selection:f,allLabel:"All routines",itemLabelPlural:"routines",loading:Re,onSelect:G,onCreate:s(()=>M(),"onCreate"),onRename:s((e,r)=>le.mutate({folderId:e.id,payload:{name:r}}),"onRename"),onEdit:s(e=>{E(e),T(!0)},"onEdit"),onDelete:te}):null,(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[u.groupBy==="folder"&&$?(0,t.jsx)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:f==="all"?(0,t.jsx)(Rs,{label:"All routines",count:P.length}):(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(ps,{color:Ee?.color}),(0,t.jsx)("span",{className:"truncate font-medium",children:f==="unfiled"?"Unfiled":Ee?.name??"Folder"}),(0,t.jsxs)("span",{className:"text-ink-3",children:[P.length," routine",P.length===1?"":"s"]})]})}):null,u.groupBy==="folder"&&!$&&!Re&&y.length>0?(0,t.jsx)(fs,{storageKey:`wardmote:routines-folder-nudge:${n??"none"}`,itemLabelPlural:"routines",onCreateFolder:s(()=>M(),"onCreateFolder")}):null,se?(0,t.jsx)(ds,{selectedCount:Q.length,folders:g?.folders??[],onMove:s(e=>{ht(e)},"onMove"),onCreateAndMove:s(()=>M(Q),"onCreateAndMove"),onClear:s(()=>B([]),"onClear"),onDone:s(()=>{ne(!1),B([])},"onDone")}):null,y.length===0?(0,t.jsx)("div",{className:"py-12",children:(0,t.jsx)(ye,{icon:Z,message:"No active routines. Use Create routine to define the first recurring workflow."})}):P.length===0?(0,t.jsxs)("div",{className:"py-12",children:[(0,t.jsx)(ye,{icon:Z,message:f==="all"?"No routines match this view.":"This folder is empty."}),f!=="all"?(0,t.jsx)("div",{className:"mt-3 flex justify-center",children:(0,t.jsxs)(_,{size:"sm",onClick:Le,children:[(0,t.jsx)(Y,{className:"mr-2 h-3.5 w-3.5"}),"New routine in this folder"]})}):null]}):(0,t.jsx)("div",{className:"flex flex-col gap-3",children:xt.map(e=>{const r=!u.collapsedGroups.includes(e.key);return(0,t.jsxs)(Be,{open:r,onOpenChange:s(a=>{me({collapsedGroups:a?u.collapsedGroups.filter(v=>v!==e.key):[...u.collapsedGroups,e.key]})},"onOpenChange"),children:[e.label?(0,t.jsx)(Cs,{label:e.label,count:e.items.length,isOpen:r}):null,(0,t.jsx)(Qe,{children:e.items.map(a=>(0,t.jsx)(ss,{routine:a,projectById:K,agentById:O,runningRoutineId:it,statusMutationRoutineId:ot,href:`/routines/${a.id}`,runNowButton:!0,divider:!1,onRunNow:gt,onToggleEnabled:jt,onToggleArchived:yt,selectMode:se,selected:Q.includes(a.id),onSelectChange:s((v,pe)=>{B(H=>pe?Array.from(new Set([...H,v.id])):H.filter(vt=>vt!==v.id))},"onSelectChange"),extraMenuItems:(0,t.jsx)(cs,{folders:g?.folders??[],currentFolderId:a.folderId??null,onMove:s(v=>{const pe=a.folderId??null;Me.mutate({itemId:a.id,folderId:v}),i({title:"Routine moved",body:v?`Moved "${a.title}" to ${g?.folders.find(H=>H.id===v)?.name??"folder"}.`:`Moved "${a.title}" to Unfiled.`,tone:"success",action:{label:"Undo",onClick:s(()=>Me.mutate({itemId:a.id,folderId:pe}),"onClick")}})},"onMove"),onCreateAndMove:s(()=>M([a.id]),"onCreateAndMove")})},a.id))})]},e.key)})})]})]}),(0,t.jsx)(rs,{open:U,kind:"routine",folder:ee,pending:Ae.isPending||le.isPending,onOpenChange:T,onSubmit:s(e=>{ee?le.mutate({folderId:ee.id,payload:e}):Ae.mutate(e)},"onSubmit")}),(0,t.jsx)(ms,{open:L!==null,folder:L,itemLabelPlural:"routines",pending:Pe.isPending,onOpenChange:s(e=>{e||te(null)},"onOpenChange"),onConfirm:s(()=>{L&&Pe.mutate(L.id)},"onConfirm")}),(0,t.jsx)(is,{open:rt,onOpenChange:ve,result:de,selection:f,allLabel:"All routines",itemLabelPlural:"Routines",onSelect:G,onCreate:s(()=>M(),"onCreate")}),(0,t.jsx)(hs,{open:C!==null,onOpenChange:s(e=>{e||re(null)},"onOpenChange"),companyId:n,routineName:C?.title??null,agents:R??[],projects:S??[],defaultProjectId:C?.projectId??null,defaultAssigneeAgentId:C?.assigneeAgentId??null,variables:C?.variables??[],isPending:qe.isPending,onSubmit:s(e=>{C&&qe.mutate({id:C.id,data:e})},"onSubmit")})]}):(0,t.jsx)(ye,{icon:Z,message:"Select an organization to view routines."})}s(un,"Routines");function Rs({label:n,count:c}){return(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(Z,{className:"h-3.5 w-3.5 text-ink-3"}),(0,t.jsx)("span",{className:"truncate font-medium",children:n}),(0,t.jsxs)("span",{className:"text-ink-3",children:[c," routine",c===1?"":"s"]})]})}s(Rs,"FolderIconHeader");export{un as Routines};