@seira-bot/seira 0.1.180 → 0.1.181

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 (173) hide show
  1. package/dist/assets/{ActivityPanel-DpipGqnm.js → ActivityPanel-tZLxRHYi.js} +1 -1
  2. package/dist/assets/{AnnouncementsPage-GCXia4xK.js → AnnouncementsPage-BrGYAaS0.js} +1 -1
  3. package/dist/assets/{App-BIllYA_e.js → App-h8WTNY4l.js} +136 -136
  4. package/dist/assets/{AppEventEditor-DYdUkpiM.js → AppEventEditor-CLpZ2lyb.js} +1 -1
  5. package/dist/assets/{BotSettingsDialog-DxRMUwAP.js → BotSettingsDialog-COjDhP9V.js} +1 -1
  6. package/dist/assets/{BrowserPanel-Cu_GqDA1.js → BrowserPanel-D_kPeSZ3.js} +1 -1
  7. package/dist/assets/{BrowserProfilesManager-CL3TIl73.js → BrowserProfilesManager-haN8RgPf.js} +1 -1
  8. package/dist/assets/{CloudAddDialog-DUk6i4df.js → CloudAddDialog-vwGwJIYN.js} +1 -1
  9. package/dist/assets/{ComputerFilesPane-HvpeAXhL.js → ComputerFilesPane-DJu1k1Ap.js} +1 -1
  10. package/dist/assets/{ComputerPanel-CozzFQeF.js → ComputerPanel-D9bTedHq.js} +2 -2
  11. package/dist/assets/{DataPanel-DGqcWB1O.js → DataPanel-CsuS_ybT.js} +1 -1
  12. package/dist/assets/{DesktopViewer-BoBSIDfB.js → DesktopViewer-YvIV04Lf.js} +1 -1
  13. package/dist/assets/{EnginesSettings-D643-yZk.js → EnginesSettings-C27xDaBN.js} +1 -1
  14. package/dist/assets/{FilesView-b5DFlMDt.js → FilesView-Dsxj73nW.js} +1 -1
  15. package/dist/assets/{GrokMoveDialog-gGTLfrGg.js → GrokMoveDialog-DEgRQW9G.js} +1 -1
  16. package/dist/assets/{ImportDialog-Bu5X6qOF.js → ImportDialog-DLVTgN-h.js} +1 -1
  17. package/dist/assets/{InspectorPanel-DU7_iwQR.js → InspectorPanel-gvFj5wfe.js} +1 -1
  18. package/dist/assets/{KeyboardShortcutsModal-Wxnn1d66.js → KeyboardShortcutsModal-aF0vhD29.js} +1 -1
  19. package/dist/assets/{LiveDesktop-D9PC-iAT.js → LiveDesktop-Bca91cEb.js} +1 -1
  20. package/dist/assets/{LocalVmWorkspace-0YxB-I-X.js → LocalVmWorkspace-CVLDY3ws.js} +1 -1
  21. package/dist/assets/{MacLocalControl-DoEGcs3V.js → MacLocalControl-BeNWQ9oY.js} +1 -1
  22. package/dist/assets/{MarkdownFilePreview-CAlARwd0.js → MarkdownFilePreview-CYw3CQ3T.js} +1 -1
  23. package/dist/assets/{MenuMotion-DfjnHTCi.js → MenuMotion-CHp-hB40.js} +1 -1
  24. package/dist/assets/{NewBotDialog-D3i7j_KP.js → NewBotDialog-BxeQktoI.js} +1 -1
  25. package/dist/assets/{PhoneAppDialog-OeXLO0Wb.js → PhoneAppDialog-CIlw_m5U.js} +1 -1
  26. package/dist/assets/{PlacesRail-3RaNlpug.js → PlacesRail-Df-jNTHn.js} +1 -1
  27. package/dist/assets/PluginsPanel-CMqZcDkC.js +8 -0
  28. package/dist/assets/{ProIntroduction-B3phUWnc.js → ProIntroduction-D8hWm9R5.js} +1 -1
  29. package/dist/assets/{PublishedAppsPage-BXWDYkhG.js → PublishedAppsPage-BMn3C64O.js} +1 -1
  30. package/dist/assets/{RemoteAgentSettingsPanel-vgrEf5B7.js → RemoteAgentSettingsPanel-B7QJizjx.js} +1 -1
  31. package/dist/assets/{RoomPanel-BmXypXPv.js → RoomPanel-CyWZ4kkq.js} +1 -1
  32. package/dist/assets/RoutinesPage-B9kKyfFp.js +2 -0
  33. package/dist/assets/{ServerPairingCard-c2fKq1gh.js → ServerPairingCard-D21dP5Bc.js} +1 -1
  34. package/dist/assets/SettingsModal-afRPXeYI.js +2 -0
  35. package/dist/assets/{ShareDepartmentDialog-CJITsmAd.js → ShareDepartmentDialog-CwErWDth.js} +1 -1
  36. package/dist/assets/{SignedInSites-B2pCMdic.js → SignedInSites-CFyvOLSc.js} +1 -1
  37. package/dist/assets/{TeamFilesPage-B10cdbwa.js → TeamFilesPage-BvhXs2O5.js} +1 -1
  38. package/dist/assets/{TeamLibraryPanel-CRmTfBOI.js → TeamLibraryPanel-Dm8wjNB4.js} +1 -1
  39. package/dist/assets/{TeamMapPage-BoTNppEy.js → TeamMapPage-jCSzFPvB.js} +1 -1
  40. package/dist/assets/{ToolPageShell-BPd_nyJ8.js → ToolPageShell-DKZUregg.js} +1 -1
  41. package/dist/assets/{TriggersPage-DDxtJMT4.js → TriggersPage-wSB6z1cp.js} +1 -1
  42. package/dist/assets/{VisibilitySection-Cd3TZvS_.js → VisibilitySection-CFr6fOzq.js} +1 -1
  43. package/dist/assets/{WebhookTrigger-AJduidiC.js → WebhookTrigger-BJN-V-bx.js} +1 -1
  44. package/dist/assets/{WorksOnGrid-DHo10o0j.js → WorksOnGrid-B3wYro9M.js} +1 -1
  45. package/dist/assets/{abnfDiagram-YUKMZFIV-DnIZyeSK.js → abnfDiagram-YUKMZFIV-DRhWKTiz.js} +1 -1
  46. package/dist/assets/{activity-DrX2_Hm9.js → activity-l0oTqbd6.js} +1 -1
  47. package/dist/assets/{architectureDiagram-47P4ROYG-DHdulT2e.js → architectureDiagram-47P4ROYG-C_qnTvJF.js} +1 -1
  48. package/dist/assets/{blockDiagram-E7TT5TSB-BGReDH4k.js → blockDiagram-E7TT5TSB-DzLSloVY.js} +1 -1
  49. package/dist/assets/{c4Diagram-CRA5TL53-BV9zDZsL.js → c4Diagram-CRA5TL53-BzVViHCA.js} +1 -1
  50. package/dist/assets/{calendar-days-Ddhxf1PV.js → calendar-days-DFd3GKf_.js} +1 -1
  51. package/dist/assets/channel-B2D6cAE5.js +1 -0
  52. package/dist/assets/{chunk-2Q5K7J3B-DAj16syq.js → chunk-2Q5K7J3B-hR-bQJHo.js} +1 -1
  53. package/dist/assets/{chunk-5VM5RSS4-CMyoXW_3.js → chunk-5VM5RSS4-BWmBW1XC.js} +1 -1
  54. package/dist/assets/{chunk-7TKQ45FW--z54G8Jv.js → chunk-7TKQ45FW-DuUk7RXl.js} +1 -1
  55. package/dist/assets/{chunk-AW2ZBBNX-CPPbUHIj.js → chunk-AW2ZBBNX-Madgl1uv.js} +1 -1
  56. package/dist/assets/{chunk-FVRAUYC3-pKEz9wbK.js → chunk-FVRAUYC3-WSgsvIGA.js} +2 -2
  57. package/dist/assets/{chunk-HTAEGDNF-DIOqwx2X.js → chunk-HTAEGDNF-CfoPR2yG.js} +1 -1
  58. package/dist/assets/{chunk-JWPE2WC7-BW474-Li.js → chunk-JWPE2WC7-tLRHdBom.js} +1 -1
  59. package/dist/assets/{chunk-KQW6MTUR-DjAEB-Df.js → chunk-KQW6MTUR-BqwuNuVY.js} +1 -1
  60. package/dist/assets/{chunk-XXDRQBXY-CMZz2xNV.js → chunk-XXDRQBXY-BOeb8xE4.js} +1 -1
  61. package/dist/assets/{classDiagram-v2-K4WV4PDN-7GYDWs2n.js → classDiagram-v2-K4WV4PDN-CFeH5trZ.js} +1 -1
  62. package/dist/assets/{core-Dq4LUz6X.js → core-CnInZb-o.js} +1 -1
  63. package/dist/assets/{cose-bilkent-JH36ORCC-Dy2zOVu3.js → cose-bilkent-JH36ORCC-BEg68hhI.js} +1 -1
  64. package/dist/assets/{cynefin-EF2NZ3EQ-C7I3qmqf.js → cynefin-EF2NZ3EQ-B_Xq3hQ3.js} +1 -1
  65. package/dist/assets/{cynefinDiagram-3GCD6N5R-CsPcUXHD.js → cynefinDiagram-3GCD6N5R-DN1o2ihW.js} +1 -1
  66. package/dist/assets/{dagre-W4DXFKR2-DxvGlifm.js → dagre-W4DXFKR2-BFf83-nP.js} +1 -1
  67. package/dist/assets/{de-CrlnmnfQ.js → de-BpsYkrLY.js} +1 -1
  68. package/dist/assets/{desktop-connection-Df-k5QBM.js → desktop-connection-CU6jsy2e.js} +1 -1
  69. package/dist/assets/{diagram-2UJZ2QOL-Qz2-e2_u.js → diagram-2UJZ2QOL-_qwbS5JH.js} +1 -1
  70. package/dist/assets/{diagram-OVF4WLC6-D1u4ioUX.js → diagram-OVF4WLC6-9sq9EfiF.js} +1 -1
  71. package/dist/assets/{diagram-PFPMY2P6-DZiCtcMI.js → diagram-PFPMY2P6-Ow1v5ZhK.js} +1 -1
  72. package/dist/assets/{diagram-UMYRVEAY-DmVn9h1H.js → diagram-UMYRVEAY-DDTBFPls.js} +1 -1
  73. package/dist/assets/{diagram-YEKJPTXX-CJK2ajcB.js → diagram-YEKJPTXX-D1zZ8KqI.js} +1 -1
  74. package/dist/assets/{diagram-ZIFT7M5P-NoYT_JX9.js → diagram-ZIFT7M5P-C_vZWUw8.js} +1 -1
  75. package/dist/assets/{ebnfDiagram-VR2GEFS7-BooF3Pem.js → ebnfDiagram-VR2GEFS7-D_1GvBDx.js} +1 -1
  76. package/dist/assets/{elk-IJKZMXRS-4Ai0igvq.js → elk-IJKZMXRS-CV-PzspH.js} +1 -1
  77. package/dist/assets/{erDiagram-O2IAPWRE-CdhhzqVX.js → erDiagram-O2IAPWRE-CnKVd0av.js} +1 -1
  78. package/dist/assets/{es-BIPy8tP9.js → es-COLCGADa.js} +1 -1
  79. package/dist/assets/{file-up-Bs5NWcjw.js → file-up-Bjx5Vcmk.js} +1 -1
  80. package/dist/assets/{flowDiagram-OXPTDLAJ-SeyZJAiT.js → flowDiagram-OXPTDLAJ-CGJh171P.js} +1 -1
  81. package/dist/assets/{fr-CCbXz1Dc.js → fr-CJ1x1iRl.js} +1 -1
  82. package/dist/assets/{ganttDiagram-R7TSEDQI-rmA_SJlC.js → ganttDiagram-R7TSEDQI-CygoACFs.js} +1 -1
  83. package/dist/assets/{gitGraphDiagram-XJZIOB7I-Coc2oeHo.js → gitGraphDiagram-XJZIOB7I-ByxErzHV.js} +1 -1
  84. package/dist/assets/{hi-DmCL9a_Y.js → hi-BC0iO7jD.js} +1 -1
  85. package/dist/assets/{index-uiyAwyX1.js → index-BRfvYRb5.js} +1 -1
  86. package/dist/assets/{index-D69O3YiA.js → index-DQZxP2c4.js} +2 -2
  87. package/dist/assets/{index-C1PEx1tc.js → index-DtDQrExn.js} +3 -3
  88. package/dist/assets/{infoDiagram-5W2HQ5XZ-DScYPtht.js → infoDiagram-5W2HQ5XZ-BlzjfTwq.js} +1 -1
  89. package/dist/assets/{ishikawaDiagram-K3B6WC7H-Cf7mJB_l.js → ishikawaDiagram-K3B6WC7H-2rf_4lR_.js} +1 -1
  90. package/dist/assets/{it-BWkdcVfm.js → it-BIwsqdpz.js} +2 -2
  91. package/dist/assets/{ja-BaOL6cSA.js → ja-BJYXkO5E.js} +2 -2
  92. package/dist/assets/{journeyDiagram-COXZFDF6-Dtmolw3A.js → journeyDiagram-COXZFDF6-mGgPoETt.js} +1 -1
  93. package/dist/assets/{kanban-definition-P3RFRI5V-CSL1-s5L.js → kanban-definition-P3RFRI5V-j2hU8Bw4.js} +1 -1
  94. package/dist/assets/{kit-Cjq8TV0N.js → kit-qjammJR4.js} +1 -1
  95. package/dist/assets/{ko-ebMBLBXv.js → ko-7QtaPFvf.js} +2 -2
  96. package/dist/assets/{livekit-KT4NEVZO-B3DA1PsD.js → livekit-KT4NEVZO-DbFoU2r9.js} +1 -1
  97. package/dist/assets/{mcp-servers-DoMFsds6.js → mcp-servers-Tb2cnkiM.js} +1 -1
  98. package/dist/assets/{memory-BR-ujoQY.js → memory-BNaMRI5v.js} +1 -1
  99. package/dist/assets/{mermaid.core-BK1qxlD4.js → mermaid.core-B1mlFiOp.js} +4 -4
  100. package/dist/assets/{mindmap-definition-LZFPQGKD-Cb7ESZ0y.js → mindmap-definition-LZFPQGKD-C7XLkIzZ.js} +1 -1
  101. package/dist/assets/{minimize-msM7mbil.js → minimize-Dga3UCb8.js} +1 -1
  102. package/dist/assets/{monitor-DpsqT1_R.js → monitor-DMPjQDZP.js} +1 -1
  103. package/dist/assets/{org-library-alRyzCTE.js → org-library-IKFXm7D6.js} +1 -1
  104. package/dist/assets/{package-format-BFXbXHk8.js → package-format-COujx3jP.js} +1 -1
  105. package/dist/assets/{pegDiagram-BGZESJAR-CqmJQKhe.js → pegDiagram-BGZESJAR-BS2zKH6g.js} +1 -1
  106. package/dist/assets/{phones-J7mYR-fY.js → phones-CINpTjZv.js} +1 -1
  107. package/dist/assets/{pieDiagram-CAPJLFHJ-w_QuumOv.js → pieDiagram-CAPJLFHJ-DVAuLXem.js} +1 -1
  108. package/dist/assets/{pl-CSbinyb5.js → pl-CLa2ta1_.js} +2 -2
  109. package/dist/assets/{pt-br-BkWykL5e.js → pt-br-8RQzCbpg.js} +3 -3
  110. package/dist/assets/{quadrantDiagram-GDMTTRAM-248q9C3h.js → quadrantDiagram-GDMTTRAM-H7QRxmHt.js} +1 -1
  111. package/dist/assets/{rail-DRr_33Fe.js → rail-DNpLzOxa.js} +1 -1
  112. package/dist/assets/{railroadDiagram-SM67HX2B-BLzQ_5t7.js → railroadDiagram-SM67HX2B-dq6Rokc9.js} +1 -1
  113. package/dist/assets/{remote-desktop-panel-BPK6Q0O6.js → remote-desktop-panel-Cxv6Qt3x.js} +1 -1
  114. package/dist/assets/{requirementDiagram-X7JNWC4A-Bgi1TLdN.js → requirementDiagram-X7JNWC4A-BeWeL_-r.js} +1 -1
  115. package/dist/assets/{ru-DD01Hb1S.js → ru-CIdzvRVZ.js} +2 -2
  116. package/dist/assets/{sankeyDiagram-UM26HJRW-CrZgn-Cf.js → sankeyDiagram-UM26HJRW-BmJ-9lt-.js} +1 -1
  117. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-gAwq1ZfG.js → sequenceDiagram-ZO4K6R2Y-Uuh1hEOh.js} +1 -1
  118. package/dist/assets/{sizeCapture-INFHLROL-BlXmG_DJ.js → sizeCapture-INFHLROL-mKDf6lys.js} +1 -1
  119. package/dist/assets/{stateDiagram-v2-TBUQTH76-CEFB1Iaq.js → stateDiagram-v2-TBUQTH76-BaEihzov.js} +1 -1
  120. package/dist/assets/{styles-DOJOOIp4.js → styles-3g-ZPS7M.js} +5 -5
  121. package/dist/assets/styles-CsrDURJH.css +1 -0
  122. package/dist/assets/{swimlanes-N4OXWK64-BtJmWAOz.js → swimlanes-N4OXWK64-CpP-NKGz.js} +1 -1
  123. package/dist/assets/swimlanesDiagram-K3J5GTZL-C50Dm6LQ.js +8 -0
  124. package/dist/assets/{template-add-BcTS64TG.js → template-add-CHwGLPet.js} +1 -1
  125. package/dist/assets/{timeline-definition-YOQAKGHF-BZ270zxf.js → timeline-definition-YOQAKGHF-Ca3rjetv.js} +1 -1
  126. package/dist/assets/{tr-Bw35A32w.js → tr-BhclavHM.js} +1 -1
  127. package/dist/assets/{uk-DsPsCgp4.js → uk-Or5wmf6s.js} +1 -1
  128. package/dist/assets/{usecaseDiagram-VIAY4XPW-D5yZb3KQ.js → usecaseDiagram-VIAY4XPW-BuuYl689.js} +1 -1
  129. package/dist/assets/{vennDiagram-BLWOH2XV-OFx2qTzp.js → vennDiagram-BLWOH2XV-C__pWnnE.js} +1 -1
  130. package/dist/assets/{vi-DhPdzwW-.js → vi-CYbGVqh-.js} +1 -1
  131. package/dist/assets/{wardleyDiagram-YMQ3BMBF-DzSmrVKa.js → wardleyDiagram-YMQ3BMBF-yWcEHD-N.js} +1 -1
  132. package/dist/assets/{xychartDiagram-TAQBALBS-UP1H1u5V.js → xychartDiagram-TAQBALBS-CvcdOA7A.js} +1 -1
  133. package/dist/assets/{zh-CzC3CUQA.js → zh-iptM1e_T.js} +2 -2
  134. package/dist/assets/{zh-tw-DeXHnAvy.js → zh-tw-BaO1c--E.js} +2 -2
  135. package/dist/index.html +3 -3
  136. package/dist/rail.html +5 -5
  137. package/dist-server/container-mcp.js +18 -17
  138. package/dist-server/index.js +1136 -1114
  139. package/dist-server/openmausbot.js +182 -180
  140. package/dist-server/package.json +1 -1
  141. package/dist-server/pair-cli.js +182 -180
  142. package/dist-server/server/ai-pool.js +72 -0
  143. package/dist-server/server/cloud-connected-apps.js +33 -16
  144. package/dist-server/server/composio-broker-access.js +1 -1
  145. package/dist-server/server/composio.js +3 -2
  146. package/dist-server/server/config.js +5 -7
  147. package/dist-server/server/connector-auth-config-hint.js +5 -0
  148. package/dist-server/server/drivers/claude.js +14 -11
  149. package/dist-server/server/flatpak-host.js +5 -2
  150. package/dist-server/server/host/ai-pool.js +109 -0
  151. package/dist-server/server/host/app-suggestions.js +2 -1
  152. package/dist-server/server/host/limit-takeover.js +11 -4
  153. package/dist-server/server/index.js +33 -26
  154. package/dist-server/server/limit-failover.js +3 -0
  155. package/dist-server/server/model-selection-schema.js +9 -0
  156. package/dist-server/server/routes/ai-pool-patch.js +24 -0
  157. package/dist-server/server/routes/config.js +8 -1
  158. package/dist-server/server/routine-dispatch.js +21 -0
  159. package/dist-server/server/routines.js +4 -18
  160. package/dist-server/server/tailscale.js +16 -6
  161. package/dist-server/server/workspace-backup-http.js +2 -2
  162. package/dist-server/shared/limit-backup.js +1 -1
  163. package/dist-server/shared/settings-places.js +1 -0
  164. package/dist-server/shared/toolkit-card.js +1 -0
  165. package/dist-server/vps-container-mcp.js +18 -17
  166. package/dist-server/workspace-backup.worker.js +18 -17
  167. package/package.json +1 -1
  168. package/dist/assets/PluginsPanel-B5Q70eO8.js +0 -8
  169. package/dist/assets/RoutinesPage-CLXohizn.js +0 -2
  170. package/dist/assets/SettingsModal-BlX9XoBu.js +0 -2
  171. package/dist/assets/channel-DZM5KU--.js +0 -1
  172. package/dist/assets/styles-9UFSdSaJ.css +0 -1
  173. package/dist/assets/swimlanesDiagram-K3J5GTZL-pBTtzroP.js +0 -8
@@ -1,2 +0,0 @@
1
- import{c as tt,r as x,j as e,t as n,a as C,i as ze,c8 as Vn,bE as Jn,y as ln,v as dn,L as cn,X as Me,d as Kn,x as Qn}from"./styles-DOJOOIp4.js";import{b as Xn}from"./remote-desktop-CsSfkXSy.js";import{y as es,B as Ve,a as ts,L as Le,k as De}from"./PlacesRail-3RaNlpug.js";import{kx as Je,at as ns,y as q,bG as ss,ky as as,kz as un,bY as rs,cZ as is,kA as os,kB as xn,u as nt,kC as ls,hY as ds,aN as kt,kD as cs,gc as ee,aS as us,kE as Nt,kF as te,kG as gt,fJ as xs,kH as Ge,kI as pn,cW as mn,cT as Ye,kJ as xt,kK as en,kL as tn,kM as be,w as Ze,kN as nn,kO as ps,kP as ms,kQ as bt,cR as hn,a7 as st,kR as Ke,kS as gn,kT as bn,kU as hs,i as gs,kV as bs,bQ as vn,kW as vs,kX as fs,g as we,kY as ys,kZ as js,k_ as wt,k$ as sn,l0 as ks,aL as Ns,aQ as pt,v as ws,cP as an,cQ as Ss,dG as Cs,T as Is,l1 as Ts,l2 as qe,cE as Rs,bP as Ds,gS as Ms}from"./App-BIllYA_e.js";import{u as Ls}from"./ProIntroduction-B3phUWnc.js";import{C as zs}from"./MenuMotion-DfjnHTCi.js";const Os=[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]],Es=tt("hourglass",Os);const As=[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]],Ps=tt("repeat-2",As);const _s=[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]],vt=tt("user-round-plus",_s);const $s=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ft=tt("video",$s);function Qe(t,s){if(!t.config?.team)return;const r=t.bots.find(i=>i.id===s);if(r?.defaultBot?.person)return null;const o=r&&t.activeView==="chat"&&t.selectedId===r.id?r.tasks?.find(i=>i.threadId===r.threadId):void 0;return o&&o.private!==!0&&!o.routineRunId?r.mainThreadId??null:Je}function Hs(t,s,r){const o=i=>typeof i=="string"&&!!t.tasks?.some(u=>u.threadId===i&&u.private===!0);return!!t.defaultBot?.person||s===Je||o(s)||o(r)}function fn({team:t,bot:s,value:r,madeIn:o}){if(!t||!s)return null;const i=Hs(s,r,o),u=i?es:ss;return e.jsxs("p",{role:"note","data-routine-audience":i?"me":"shared",className:"mt-2 flex items-center gap-1 text-[12px] leading-4 text-ink-secondary",children:[e.jsx(u,{size:12,"aria-hidden":"true",className:"shrink-0"}),e.jsx("span",{children:i?n("team.privateHeader"):as(t.name,s.onlyPeopleAdded)})]})}function yn({bot:t,value:s,allowCurrent:r=!1,team:o,onChange:i}){const u=x.useId(),m=ns();if(o??m!==null)return e.jsx(Fs,{id:u,bot:t,value:s,allowCurrent:r,onChange:i});const c=(t?.tasks??[]).filter(l=>!l.routineRunId),h=typeof s=="string"&&!c.some(l=>l.threadId===s),N=[...t?.projects??[],{id:"",name:n("folder.none")}];return e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("label",{htmlFor:u,className:"block text-[12px] font-medium text-ink",children:n("routines.results.label")}),e.jsxs(q,{className:"w-full",id:u,"aria-describedby":`${u}-help`,disabled:!t,value:s??(s===null?"new":"current"),onChange:l=>i(l.target.value==="new"?null:l.target.value==="current"?void 0:l.target.value),children:[r&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"new",children:n("routines.results.main")}),h&&e.jsx("option",{value:s,disabled:!0,children:n("routines.results.unavailable")}),N.map(l=>{const $=c.filter(S=>l.id?S.projectId===l.id:!t?.projects?.some(v=>v.id===S.projectId));return $.length?e.jsx("optgroup",{label:l.name,children:$.map(S=>e.jsx("option",{value:S.threadId,children:S.title},S.threadId))},l.id):null})]}),e.jsx("p",{id:`${u}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.mainHelp")})]})}function Fs({id:t,bot:s,value:r,allowCurrent:o,onChange:i}){const u=typeof r=="string"&&!!s?.tasks?.some(c=>c.threadId===r&&c.private===!0),m=r===void 0&&o?"current":r===Je||u?"me":"shared";return e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("label",{htmlFor:t,className:"block text-[12px] font-medium text-ink",children:n("routines.results.label")}),e.jsxs(q,{className:"w-full",id:t,"aria-describedby":`${t}-help`,disabled:!s,value:m,onChange:c=>i(c.target.value==="current"?void 0:c.target.value==="me"?u?r:Je:s?.mainThreadId??null),children:[m==="current"&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"me",children:n("routines.results.justMe")}),e.jsx("option",{value:"shared",children:n("task.sharedChat")})]}),e.jsx("p",{id:`${t}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.teamHelp")})]})}const mt="min-w-0 rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",Bs=t=>Array.from({length:12},(s,r)=>new Intl.DateTimeFormat(t,{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2024,r,1)))),Us=["UTC",...typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[]];function jn({runs:t,timeZone:s,paused:r=!1}){if(!t.length)return null;const o=new Intl.DateTimeFormat(ze(),{timeZone:s,weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return e.jsxs("div",{className:"space-y-1 text-[11px] leading-relaxed text-ink-secondary","aria-label":n(r?"routines.cron.pausedPreviewLabel":"routines.cron.nextRunsLabel"),children:[e.jsxs("div",{className:"font-medium",children:[n(r?"routines.cron.pausedPreview":"routines.cron.nextRuns")," · ",s]}),t.map(i=>e.jsx("div",{children:e.jsx("time",{dateTime:new Date(i).toISOString(),children:o.format(i)})},i)),e.jsx("div",{className:"pt-1",children:n("routines.cron.clockChanges")})]})}function Ws({schedule:t,paused:s=!1}){const r=x.useMemo(()=>{try{return un(t,Date.now(),3)}catch{return[]}},[t]);return e.jsx(jn,{runs:r,timeZone:t.timeZone,paused:s})}function Gs({choice:t,value:s,onChange:r,runs:o,error:i}){const u=m=>r({...s,...m});return e.jsxs("div",{className:"space-y-3",children:[t==="cron"?e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.expression")}),e.jsx("input",{value:s.expression,onChange:m=>u({expression:m.target.value}),placeholder:"0 9 1 * *",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-help routine-cron-error",className:C(mt,"w-full font-mono")}),e.jsx("span",{id:"routine-cron-help",className:"block text-[11px]",children:n("routines.cron.expressionHelp")})]}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t==="yearly"&&e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.month")}),e.jsx(q,{value:s.month,onChange:m=>u({month:m.target.value}),children:Bs(ze()).map((m,c)=>e.jsx("option",{value:String(c+1),children:m},m))})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.dayOfMonth")}),e.jsxs(q,{value:s.day,onChange:m=>u({day:m.target.value}),children:[Array.from({length:31},(m,c)=>e.jsx("option",{value:String(c+1),children:c+1},c+1)),e.jsx("option",{value:"L",children:n("routines.cron.lastDay")})]})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.time")}),e.jsx("input",{type:"time",step:60,value:s.time,onChange:m=>u({time:m.target.value}),className:mt})]})]}),t!=="cron"&&Number(s.day)>28&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:n("routines.cron.skippedMonths")}),e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.timeZone")}),e.jsx("input",{list:"routine-time-zones",value:s.timeZone,onChange:m=>u({timeZone:m.target.value}),placeholder:"America/New_York",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-error",className:C(mt,"block w-full")})]}),e.jsx("datalist",{id:"routine-time-zones",children:Us.map(m=>e.jsx("option",{value:m},m))}),i&&e.jsx("p",{id:"routine-cron-error",role:"alert",className:"text-[12px] text-danger",children:i}),!i&&e.jsx(jn,{runs:o,timeZone:s.timeZone.trim()})]})}const ge=t=>["monthly","yearly","cron"].includes(t);function kn(t){const s=t.trim().split(/\s+/);if(s.length!==5)return null;const[r,o,i,u,m]=s;return!/^\d+$/.test(r)||Number(r)>59||!/^\d+$/.test(o)||Number(o)>23||!(i==="L"||/^\d+$/.test(i)&&Number(i)>=1&&Number(i)<=31)||!(u==="*"||/^\d+$/.test(u)&&Number(u)>=1&&Number(u)<=12)||m!=="*"?null:{day:i==="L"?i:String(Number(i)),month:u,time:`${String(Number(o)).padStart(2,"0")}:${String(Number(r)).padStart(2,"0")}`}}function qs(t){const s=kn(t.expression);return s?s.month==="*"?"monthly":"yearly":"cron"}function Ys(t,s){const r=t?.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone,o=t&&kn(t.expression);let i;try{i=new Intl.DateTimeFormat("en-US",{timeZone:r,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s)}catch{i=new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s)}const u=h=>i.find(N=>N.type===h).value,m=o?.time??`${u("hour")}:${u("minute")}`,c=o?.day??u("day");return{expression:t?.expression??`${Number(m.slice(3))} ${Number(m.slice(0,2))} ${c} * *`,timeZone:r,day:c,month:o&&o.month!=="*"?String(Number(o.month)):u("month"),time:m}}function Zs(t,s,r,o){try{if(t!=="cron"&&!/^\d{2}:\d{2}$/.test(s.time))throw new Error(n("routines.cron.chooseTime"));const[i,u]=s.time.split(":"),m=o??{type:"cron",timeZone:s.timeZone,expression:t==="cron"?s.expression:`${Number(u)} ${Number(i)} ${s.day} ${t==="yearly"?s.month:"*"} *`},c=rs(m,r);return{schedule:o??c,runs:un(c,r,3),error:""}}catch(i){return{schedule:null,runs:[],error:i instanceof Error?i.message:String(i)}}}function Vs({value:t,botEngine:s,onChange:r}){const o=is(),i=t.engine||s||o[0]?.engine||"",u=[...new Set([...s?[s]:[],...o.map(c=>c.engine),...i?[i]:[]])],m=o.find(c=>c.engine===i)?.resetsAt??null;return e.jsxs("div",{className:"space-y-2 text-[13px] text-ink","data-testid":"limit-reset-fields",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n("routines.limitReset.engine")}),e.jsx(q,{"aria-label":n("routines.limitReset.engine"),value:i,onChange:c=>r({...t,engine:c.target.value}),children:u.map(c=>e.jsx("option",{value:c,children:os(c)},c))}),e.jsxs(q,{"aria-label":n("routines.limitReset.repeat"),value:t.repeat,onChange:c=>r({...t,engine:i,repeat:c.target.value}),children:[e.jsx("option",{value:"once",children:n("routines.limitReset.once")}),e.jsx("option",{value:"every_reset",children:n("routines.limitReset.every")})]})]}),e.jsx("div",{className:"text-[12px] text-ink-secondary",children:m!==null&&m>Date.now()?n("routines.limitReset.next",{time:xn(m)}):n("routines.limitReset.unknown")})]})}function Js({cloudHome:t,local:s,plan:r,ready:o,offersAllowed:i}){return t?{kind:"cloud"}:s?r?.kind==="paid"?{kind:"local",next:o?"open-cloud":null}:{kind:"local",next:r&&i&&ds(r)?"add-cloud":null}:{kind:"server"}}function Ks(){const{state:t,dispatch:s}=nt(),r=Ls(),o=ls()&&window.ogb?.remoteClient?.active!==!0,i=Js({cloudHome:t.config?.cloudHome===!0,local:o,plan:r?.view??null,ready:r?.account?.machine?.status==="ready",offersAllowed:Vn().source!=="file"}),u="text-left underline underline-offset-2 hover:text-ink",m=()=>{window.confirm(n("routines.scheduleNote.leave"))&&window.ogb?.cloudAccount?.connectHome().catch(()=>{})};return e.jsx("p",{"data-routine-schedule-note":i.kind==="local"?i.next??"local":i.kind,className:"text-[11px] leading-relaxed text-ink-secondary",children:i.kind==="cloud"?n("routines.scheduleNote.cloud"):i.kind==="server"?n("routines.scheduleNote.server"):e.jsxs(e.Fragment,{children:[n("routines.scheduleNote.local"),i.next==="add-cloud"&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:u,onClick:()=>s({type:"openCloudAdd",source:"app_routines"}),children:n("routines.scheduleNote.addCloud")})]}),i.next==="open-cloud"&&e.jsxs(e.Fragment,{children:[" ",n("routines.scheduleNote.openCloud")," ",e.jsx("button",{type:"button",className:u,onClick:m,children:n("cloudHome.connect")})]})]})})}const Xe="application/x-openmaus-bot",Se="application/x-openmaus-calendar-event",Qs=t=>t.dataTransfer.types.includes(Xe)||t.dataTransfer.types.includes(Se);function Xs(t){const s=t.dataTransfer.getData(Xe);if(s)return{botId:s};try{const r=JSON.parse(t.dataTransfer.getData(Se));return(r.kind==="routine"||r.kind==="call")&&typeof r.id=="string"&&typeof r.at=="number"?{event:{kind:r.kind,id:r.id,at:r.at}}:null}catch{return null}}function ea({marker:t,hourHeight:s,onDrop:r}){const[o,i]=x.useState(!1),u=new Date(t.at),m=n("limits.marker",{engine:t.name,time:xn(t.at,t.at)});return e.jsxs("div",{"data-limit-marker":t.engine,role:"note","aria-label":m,title:n("limits.markerDrop",{engine:t.name}),className:"absolute inset-x-0 z-[25] -translate-y-1/2 py-1.5",style:{top:(u.getHours()*60+u.getMinutes())/60*s},onPointerDown:c=>c.stopPropagation(),onDragOver:c=>{!r||!Qs(c)||(c.preventDefault(),c.stopPropagation(),c.dataTransfer.dropEffect="copy",i(!0))},onDragLeave:()=>i(!1),onDrop:c=>{c.preventDefault(),c.stopPropagation(),i(!1);const h=Xs(c);h&&r?.(h)},children:[e.jsx("div",{className:C("h-0 border-t-2 border-dashed",o?"border-accent":"border-warning/80")}),e.jsxs("span",{className:C("absolute left-1 top-0 flex max-w-[calc(100%-8px)] items-center gap-1 truncate rounded-full border px-1.5 py-0.5 text-[10px] font-medium shadow-sm",o?"border-accent bg-accent text-accent-ink":"border-warning/50 bg-panel text-ink"),children:[e.jsx(Es,{size:10,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:m})]})]})}const W=64;function Nn(t){return t==="running"?"working":t==="waiting"?"curious":t==="completed"?"proud":t==="failed"||t==="missed"?"sad":t==="cancelled"?"sleeping":"drowsy"}function ta(t){return t>=44?"roomy":t>=22?"compact":"tiny"}function na({item:t,bots:s,groups:r,compact:o,layout:i,selected:u=!1,onOpen:m,onResize:c}){const h=t.kind==="call",N=t.kind==="routine"?t.routine:null,l=t.kind==="routine"?t.run:null,S=!h&&(l?.target??N?.target)==="room-goal"?l?.groupId??N?.groupId:void 0,v=S?r.find(F=>F.id===S)??{name:n("routines.group")}:void 0,z=(h?t.call.botIds:[l?.botId??N?.botId??""]).flatMap(F=>s.find(y=>y.id===F)??[]),E=z[0],H=h?t.call.name:l?.routineName??N?.name??n("routines.event.automation"),B=h?"var(--color-accent)":E?Jn[E.color]:"var(--color-ink-tertiary)",A=!!(N&&!l&&!N.enabled),[M,d]=x.useState(t.durationMinutes);x.useEffect(()=>d(t.durationMinutes),[t.durationMinutes]);const b=l?.status,R=b==="failed"||b==="missed"||b==="waiting"||t.kind==="routine"&&!l&&t.needsYou===!0,P=l?kt(l):void 0,g=h||!!(N&&!l&&!A&&N.schedule.type!=="cron"),j=h?t.call.schedule:N?.schedule,I=!!(j&&j.type!=="once"),T=j?.type==="interval"?cs(j.everyMinutes):null,L=Math.max(16,M/60*W),p=ta(L),_=h?n(z.length===1?"routines.botCountOne":"routines.botCountMany",{count:z.length}):v?v.name:E?.name,w=[H,ee(t.at),_,T,A?(N&&us(N))??n("routines.pausedSchedule"):P].filter(Boolean).join(" · "),D=N?.schedule.type==="cron"?n("routines.event.cronMoveHint"):"",Z=F=>{F.preventDefault(),F.stopPropagation();const y=F.clientY,de=M;let Q=de;const ve=fe=>{Q=Math.max(te,Math.min(240,Math.round((de+(fe.clientY-y)/W*60)/te)*te)),d(Q)},ce=()=>{if(document.removeEventListener("pointermove",ve),document.removeEventListener("pointerup",ce),Q!==t.durationMinutes){if(I&&!window.confirm(n("routines.event.resizeSeries"))){d(t.durationMinutes);return}c(Q)}};document.addEventListener("pointermove",ve),document.addEventListener("pointerup",ce,{once:!0})},ne=!h&&e.jsx("span",{"data-event-status":A?"paused":R?"needs-you":"working",className:C("size-1.5 shrink-0 rounded-full",A?"bg-ink-tertiary":R?"bg-warning":"bg-success")}),le=F=>h?e.jsx(ft,{size:13,className:"mt-0.5 shrink-0"}):E?e.jsx(Ve,{bot:E,state:b?Nn(b):A?"sleeping":"idle",size:F,animated:b==="running"||b==="waiting"}):null;return e.jsxs("button",{"data-event-card":!0,"data-event-fit":p,type:"button",draggable:g,title:D?`${w}
2
- ${D}`:w,onDragStart:F=>{if(!g)return F.preventDefault();F.dataTransfer.effectAllowed="move",F.dataTransfer.setData(Se,JSON.stringify({kind:t.kind,id:h?t.call.id:N.id,at:t.at}))},onClick:F=>{F.stopPropagation(),m()},"aria-pressed":u,"aria-label":`${H}, ${ee(t.at)}${A?`, ${n("routines.pausedSchedule")}`:P?`, ${P}`:""}`,className:C("group absolute z-10 overflow-hidden rounded-md border border-l-[3px] text-left transition hover:z-20 focus:z-20 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",p==="roomy"?"px-1.5 py-1":"px-1.5 py-0",A&&"border-dashed opacity-70",b==="cancelled"&&"opacity-55",(b==="failed"||b==="missed")&&(l&&Nt(l)?"border-warning/60":"border-danger/60"),u&&"z-20 ring-2 ring-accent ring-offset-1 ring-offset-app"),style:{left:`calc(${i.column/i.columns*100}% + 2px)`,width:`calc(${100/i.columns}% - 4px)`,top:`${(new Date(t.at).getHours()*60+new Date(t.at).getMinutes())/60*W}px`,height:`${L}px`,background:`color-mix(in srgb, ${B} ${A?6:16}%, var(--color-card))`,borderColor:`color-mix(in srgb, ${B} 40%, transparent)`,borderLeftColor:B,color:`color-mix(in srgb, ${B} 55%, var(--color-ink))`},children:[p==="roomy"?e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[le(o?18:22),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[11px] font-semibold leading-tight",children:H}),e.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-[10px] opacity-80",children:[ne,e.jsxs("span",{className:"truncate",children:[ee(t.at)," · ",T&&!v&&!h?`${_??""} · ${T}`:_]})]})]}),z.length>1&&e.jsxs("span",{className:"rounded bg-inset/60 px-1 py-0.5 text-[8px]",children:["+",z.length-1]})]}):p==="compact"?e.jsxs("div",{className:"flex h-full min-w-0 items-center gap-1",children:[h&&e.jsx(ft,{size:11,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold leading-none",children:H}),ne,e.jsx("span",{className:"shrink-0 text-[10px] leading-none tabular-nums opacity-80",children:ee(t.at)})]}):e.jsx("div",{className:"flex h-full min-w-0 items-center truncate text-[10px] font-semibold leading-none",children:H}),h&&e.jsx("div",{onPointerDown:Z,className:"absolute inset-x-1 bottom-0 h-1.5 cursor-ns-resize rounded-full opacity-0 transition group-hover:opacity-100","aria-label":n("routines.event.resize"),children:e.jsx("div",{className:"mx-auto mt-0.5 h-0.5 w-5 rounded-full bg-current opacity-50"})})]})}const yt=[0,1,2,3,4,5,6],et=[1,2,3,4,5],ht=[5,10,15,30,60],wn=Array.from({length:240/te},(t,s)=>(s+1)*te),sa=[...wn,300,360,480,720,ps];function Sn(t,s){return t?t.memberIds.flatMap(r=>{const o=s.find(i=>i.id===r);return o&&!o.hidden?[o]:[]}):s.filter(r=>!r.hidden)}function aa(t){return t.dm?!1:!(Object.prototype.hasOwnProperty.call(t,"setupCompletedAt")||Object.prototype.hasOwnProperty.call(t,"setupSkippedAt"))||t.setupCompletedAt!=null||t.setupSkippedAt!=null||(t.messages?.length??0)>0}function rn(t,s,r){const o=Sn(t,s),i=t?.defaultResponder.kind==="member"?t.defaultResponder.botId:void 0;return o.find(u=>u.id===r)??o.find(u=>u.id===i)??o.find(u=>u.chiefOfStaff)??o[0]}function on(){const t=new Date(Date.now()+36e5);return t.setMinutes(0,0,0),t.getTime()}function ra(t,s){return!!(t&&t.length===s.length&&t.every((r,o)=>r===s[o]))}function ia(t){return t.type!=="interval"||!t.weekdays||t.weekdays.length===7?"every-day":ra(t.weekdays,et)?"weekdays":"custom"}function oa(t){const s=new Date(`${t}T00:00`);return s.setHours(23,59,59,999),s.getTime()}function la(t,s){return t.type==="once"?"none":t.type==="limit_reset"?"limit_reset":t.type==="interval"?"interval":t.type==="cron"?qs(t):t.weekdays.length===7?"daily":t.weekdays.join(",")==="1,2,3,4,5"?"weekdays":t.weekdays.length===1&&t.weekdays[0]===new Date(s).getDay()?"weekly":"custom"}function Cn(t,s,r){if(t==="none")return{type:"once",at:s};const o=t==="daily"?yt:t==="weekdays"?et:t==="weekly"?[new Date(s).getDay()]:r;return{type:"daily",time:pn(s),weekdays:[...o].sort()}}function da(t,s,r,o,i){return t==="interval"?{type:"interval",everyMinutes:o,...i}:Cn(t,s,r)}function In({attachments:t,onRemove:s}){return t.length?e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(r=>e.jsxs("div",{className:"flex max-w-[260px] items-center gap-2 rounded-lg border border-hairline/50 bg-inset px-2.5 py-2 text-[12px] text-ink",children:[e.jsx(st,{size:14,className:"shrink-0 text-accent"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s&&e.jsx("button",{type:"button",onClick:()=>s(r.id),className:"rounded p-0.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":n("routines.attachment.remove",{name:r.name}),children:e.jsx(Me,{size:12})})]},r.id))}):null}function jt({bots:t,selected:s,multiple:r,locked:o,onChange:i}){const[u,m]=x.useState(""),c=t.filter(h=>`${h.name} ${h.title}`.toLowerCase().includes(u.toLowerCase()));return e.jsxs("div",{className:"rounded-xl border border-hairline/50 bg-inset/60 p-2",children:[!o&&t.length>5&&e.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-transparent bg-panel px-2.5 py-2 text-ink-secondary focus-within:border-focus",children:[e.jsx(Kn,{size:14}),e.jsx("input",{value:u,onChange:h=>m(h.target.value),placeholder:n("routines.findBot"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-ink outline-none placeholder:text-ink-tertiary"})]}),e.jsx("div",{className:"grid max-h-48 grid-cols-1 gap-1 overflow-y-auto sm:grid-cols-2",children:c.map(h=>{const N=s.includes(h.id);return e.jsxs("button",{type:"button",disabled:o,onClick:()=>i(r?N?s.filter(l=>l!==h.id):[...s,h.id]:[h.id]),className:C("flex min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition",N?"bg-accent/12 ring-1 ring-accent/50":"hover:bg-raised",o&&"cursor-default"),children:[e.jsx(Ve,{bot:h,state:N?"happy":"idle",size:32,animated:!1}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium text-ink",children:h.name}),N&&e.jsx(vn,{size:14,className:"shrink-0 text-accent"})]},h.id)})})]})}function ca(t){return t.flatMap(s=>s.kind==="paste"||s.kind==="citation"?[]:[{id:s.id,kind:s.kind,name:s.name,path:s.path,size:s.size}])}function ua({seed:t,bots:s,lockedBotId:r,defaultRunOn:o,routinesOnly:i=!1,plain:u=!1,onClose:m,onSavedCall:c}){const{state:h,dispatch:N}=nt(),l=t.routine,{request:$}=xs(),S=t.call,[v,J]=x.useState(i?"routine":t.kind),[z]=x.useState(()=>Date.now()),[E,H]=x.useState(l?.name??S?.name??t.name??""),[B,A]=x.useState(l?.prompt??S?.description??t.description??""),M=l?.schedule.type==="once"?l.schedule.at:l?.schedule.type==="daily"?gt(t.at,l.schedule.time):l?.schedule.type==="interval"?l.schedule.anchorAt:S?.schedule.type==="once"?S.schedule.at:S?.schedule.type==="daily"?gt(t.at,S.schedule.time):t.at,d=l?.schedule??S?.schedule??{type:"once",at:M},[b,R]=x.useState(Ge(M)),[P,g]=x.useState(pn(M)),[j,I]=x.useState(l?.durationMinutes??S?.durationMinutes??t.durationMinutes),[T,L]=x.useState(l?.timeoutMinutes??null),[p,_]=x.useState(!!l),[w,D]=x.useState(l?.overlap??"skip"),[Z,ne]=x.useState(!!l?.continuity),[le,F]=x.useState(!!l?.runOnStartup),[y,de]=x.useState(t.limitReset?"limit_reset":la(d,M)),[Q,ve]=x.useState(d.type==="limit_reset"?d:{engine:t.limitReset?.engine??"",repeat:"once"}),[ce,fe]=x.useState(()=>Ys(d.type==="cron"?d:void 0,M)),[at,Oe]=x.useState(!1),[ye,Ee]=x.useState(d.type==="daily"?d.weekdays:[new Date(M).getDay()]),[G,Ce]=x.useState(d.type==="interval"?d.everyMinutes:15),[se,rt]=x.useState(()=>ia(d)),[f,K]=x.useState(()=>d.type==="interval"&&d.weekdays?.length?d.weekdays:[...yt]),[pe,ae]=x.useState(d.type==="interval"&&d.window?"custom":"all-day"),[Ae,Tn]=x.useState(d.type==="interval"?d.window?.start??"09:00":"09:00"),[Pe,Rn]=x.useState(d.type==="interval"?d.window?.end??"17:00":"17:00"),[_e,Dn]=x.useState(d.type==="interval"&&d.endsAt!=null?"on-date":"never"),[St,Mn]=x.useState(()=>d.type==="interval"&&d.endsAt!=null?Ge(d.endsAt):Ge(mn(Ye(Math.max(Date.now(),M)),7))),[U,Ct]=x.useState(r?[r]:l?[l.botId]:S?.botIds??t.botIds),[it,It]=x.useState(()=>(l?l.resultsThreadId:t.resultsThreadId??Qe(h,U[0]))??null),$e=a=>{a[0]!==U[0]&&It(Qe(h,a[0])??null),Ct(a)},[V,Ln]=x.useState(l?.target??"bot"),[me,ot]=x.useState(l?.groupId??""),[je,He]=x.useState(l?.runOn??o??"maus"),[Ie,lt]=x.useState(l?.target==="room-goal"?[]:l?.attachments??S?.attachments??[]),[Tt,Rt]=x.useState(!1),[Dt,Mt]=x.useState(""),[Lt,zt]=x.useState(""),[zn,Ot]=x.useState(0),Fe=zn>0,Et=x.useRef(null),On=!!(h.config?.box.configured&&U.length>0&&U.every(a=>Xn(h.instances,s.find(k=>k.id===a)?.modelSelection.instanceId)?.snapshot.state==="available")),Be=h.groups.filter(aa),ue=Be.find(a=>a.id===me),dt=ue?Sn(ue,h.bots):s,X=v==="routine"&&V==="room-goal",At=h.config?.cloudHome===!0,Ue=xt(b,P,l||S?M:void 0),En=Ue+j*6e4,Te=U.flatMap(a=>s.find(k=>k.id===a)??[]),Pt=x.useRef(null),Re=y==="interval"&&(!Number.isInteger(G)||G<5||G>1440),ke=y==="interval"&&se==="custom"&&f.length===0,_t=xt("2000-01-01",Pe)-xt("2000-01-01",Ae),re=y==="interval"&&pe==="custom"&&(!Ae||!Pe||!Number.isFinite(_t)||_t<G*6e4),ct=l?.schedule.type==="interval"?l.schedule:void 0,$t=en(z,Math.max(5,G||5),ct),Ne=_e==="on-date"?oa(St):null,he=y==="interval"&&_e==="on-date"&&(Ne==null||!Number.isSafeInteger(Ne)||Ne<$t),Ht=se==="every-day"?void 0:se==="weekdays"?et:f,An=pe==="custom"?{start:Ae,end:Pe}:void 0,xe=ge(y)?Zs(y,ce,z,!at&&d.type==="cron"?d:void 0):null,Ft=a=>{a==="interval"&&!p&&(L(k=>k??30),_(!0)),ge(a)&&(a==="cron"&&xe?.schedule&&fe(k=>({...k,expression:xe.schedule.expression})),Oe(!0)),de(a)},Pn=a=>{a==="custom"&&se!=="custom"&&K(se==="weekdays"?[...et]:[...yt]),rt(a)},Bt=a=>{if(Ln(a),a==="bot"){ot("");return}He("maus"),lt([]),zt("");const k=ue??Be[0];ot(k?.id??"");const O=rn(k,h.bots,U[0]);$e(O?[O.id]:[])},_n=a=>{const k=Be.find(ie=>ie.id===a);ot(a);const O=rn(k,h.bots,U[0]);$e(O?[O.id]:[])},$n=async a=>{if(!(!a?.length||X)){Ot(k=>k+1);try{const k=await hs(Array.from(a),{allowImages:!0,getPath:bs,uploadImage:gs}),O=ca(k.attachments);O.length&&(lt(ie=>[...ie,...O].slice(0,20)),je==="cloud"&&He("maus")),k.notice&&zt(k.notice)}finally{Ot(k=>Math.max(0,k-1))}}},Hn=async()=>{if(!Fe){Rt(!0),Mt("");try{if(v==="routine"||i){const a=Date.now(),k=vs(a,G,ct);if(y==="interval"&&Ne!=null&&Ne<en(a,G,ct))throw new Error(n("routines.interval.endAfterFirstRun"));const O=Q.engine||s.find(Zn=>Zn.id===(r??U[0]))?.modelSelection?.instanceId||"",ie=y==="limit_reset"?{type:"limit_reset",engine:O,repeat:Q.repeat}:ge(y)?xe?.schedule:da(y,Ue,ye,G,{anchorAt:k,weekdays:Ht?[...Ht].sort():null,window:An??null,endsAt:Ne});if(!ie)throw new Error(xe?.error||n("routines.error.invalidSchedule"));const qn={name:E,prompt:B,target:V,botId:r??U[0]??"",groupId:V==="room-goal"&&me?me:null,runOn:V==="room-goal"?"maus":je,enabled:l&&(l.enabled||!fs(l,a))?void 0:!0,schedule:ie,durationMinutes:j,timeoutMinutes:T,overlap:w,continuity:V==="bot"&&y!=="none"&&Z,runOnStartup:y!=="none"&&le,attachments:V==="room-goal"?[]:Ie,...V==="bot"?{resultsThreadId:it}:{}},Yn=await $(l?`/api/routines/${l.id}`:"/api/routines",{method:l?"PATCH":"POST",body:JSON.stringify(qn)});N({type:"routinePatched",routine:Yn.routine})}else{if(y==="interval"||y==="limit_reset"||ge(y))throw new Error(n("routines.error.callSchedule"));const a=Cn(y,Ue,ye),k={name:E,description:B,botIds:U,schedule:a,durationMinutes:j,attachments:Ie},O=await we(S?`/api/calendar-calls/${S.id}`:"/api/calendar-calls",{method:S?"PATCH":"POST",body:JSON.stringify(k)});c(O.call)}m()}catch(a){Mt(a instanceof Error?a.message:String(a))}finally{Rt(!1)}}},Fn=!!(E.trim()&&(v==="call"||B.trim())&&(!r||U[0]===r)&&(v==="call"?U.length>0:V==="room-goal"?(!me||ue)&&U[0]&&dt.some(a=>a.id===U[0]):U.length>0)&&!Re&&!ke&&!re&&!he&&!xe?.error),Bn=!i&&!l&&!S&&!r,Y=ln()&&!u,[We,Un]=x.useState(()=>!["none","daily","weekdays","weekly"].includes(y)||V==="room-goal"||Ie.length>0||je==="cloud"||T!=null||le||w==="queue");ts(Pt,m);const Ut=Bn&&e.jsxs("div",{className:C(Y&&"ml-10","inline-flex rounded-lg bg-inset p-1"),children:[e.jsx("button",{type:"button",onClick:()=>{J("routine"),Ct(a=>a.slice(0,1))},className:C("rounded-md px-4 py-1.5 text-[13px] font-medium",v==="routine"?"bg-raised text-ink shadow":"text-ink-secondary"),children:n("routines.kind.routine")}),e.jsx("button",{type:"button",onClick:()=>{J("call"),(y==="interval"||y==="limit_reset"||ge(y))&&de("none")},className:C("rounded-md px-4 py-1.5 text-[13px] font-medium",v==="call"?"bg-raised text-ink shadow":"text-ink-secondary"),children:n("routines.kind.call")})]}),Wt=v==="routine"&&!r&&e.jsxs("div",{className:C(Y&&"ml-10"),children:[e.jsx("div",{className:"mb-2 text-[11px] font-medium uppercase tracking-wider text-ink-secondary",children:n("routines.editor.type")}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>Bt("bot"),className:C("flex items-start gap-3 rounded-xl border p-3 text-left transition",V==="bot"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx(vt,{size:17,className:C("mt-0.5 shrink-0",V==="bot"?"text-accent":"text-ink-secondary")}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.editor.botTask")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.botTaskHelp")})]})]}),e.jsxs("button",{type:"button",onClick:()=>Bt("room-goal"),className:C("flex items-start gap-3 rounded-xl border p-3 text-left transition",V==="room-goal"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx(tn,{size:17,className:C("mt-0.5 shrink-0",V==="room-goal"?"text-accent":"text-ink-secondary")}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.editor.teamGoal")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.teamGoalHelp")})]})]})]})]}),Gt=y!=="interval"&&y!=="limit_reset"&&!ge(y)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v==="routine"&&y==="none"&&e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.editor.starts")}),v==="routine"&&y==="weekly"&&e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.editor.on")}),(v==="call"||y==="none"||y==="weekly")&&e.jsx("input",{type:"date",value:b,onChange:a=>R(a.target.value),className:"rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]"}),e.jsx("input",{type:"time",step:te*60,value:P,onChange:a=>g(a.target.value),className:"rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]"}),v==="call"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[12px] text-ink-secondary",children:n("routines.editor.to")}),e.jsx("span",{className:"rounded-lg border border-hairline/40 bg-inset/60 px-3 py-2 text-[13px] text-ink",children:ee(En)}),e.jsx(q,{"aria-label":n("routines.editor.callDuration"),value:j,onChange:a=>I(Number(a.target.value)),children:wn.map(a=>e.jsx("option",{value:a,children:be(a)},a))})]})]}),qt=e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ps,{size:14,className:"text-ink-secondary"}),e.jsxs(q,{"aria-label":n("routines.editor.repeat"),value:y,onChange:a=>Ft(a.target.value),children:[e.jsx("option",{value:"none",children:n("routines.repeat.none")}),v==="routine"&&e.jsx("option",{value:"interval",children:n("routines.repeat.interval")}),e.jsx("option",{value:"daily",children:n("routines.repeat.dailyOption")}),e.jsx("option",{value:"weekdays",children:n("routines.repeat.weekdaysOption")}),e.jsx("option",{value:"weekly",children:n("routines.schedule.weeklyOn",{day:Ze(new Date(Ue).getDay())})}),e.jsx("option",{value:"custom",children:n("routines.repeat.selectedWeekdays")}),v==="routine"&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"monthly",children:n("routines.repeat.monthly")}),e.jsx("option",{value:"yearly",children:n("routines.repeat.yearly")}),e.jsx("option",{value:"cron",children:n("routines.repeat.customCron")})]}),v==="routine"&&e.jsx("option",{value:"limit_reset",children:n("routines.limitReset.option")})]})]}),Yt=v==="routine"&&e.jsx(Ks,{}),Zt=e.jsxs(e.Fragment,{children:[y==="limit_reset"&&v==="routine"&&e.jsx(Vs,{value:Q,botEngine:s.find(a=>a.id===(r??U[0]))?.modelSelection?.instanceId,onChange:ve}),ge(y)&&v==="routine"&&xe&&e.jsx(Gs,{choice:y,value:ce,onChange:a=>{fe(a),Oe(!0)},runs:xe.runs,error:xe.error}),y==="custom"&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:nn.map((a,k)=>e.jsx("button",{type:"button",onClick:()=>Ee(O=>O.includes(k)?O.length===1?O:O.filter(ie=>ie!==k):[...O,k].sort()),className:C("size-8 rounded-full text-[10px] font-semibold",ye.includes(k)?"bg-accent text-white":"bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:Ze(k).charAt(0).toLocaleUpperCase(ze())},a))}),y==="interval"&&v==="routine"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px] text-ink",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.runsEvery")}),e.jsxs(q,{value:ht.includes(G)?String(G):"custom",onChange:a=>Ce(a.target.value==="custom"?0:Number(a.target.value)),"aria-label":n("routines.interval.howOften"),children:[ht.map(a=>e.jsx("option",{value:a,children:a},a)),e.jsx("option",{value:"custom",children:n("routines.interval.custom")})]}),!ht.includes(G)&&e.jsx("input",{type:"number",min:5,max:1440,step:1,value:G||"",onChange:a=>Ce(Number(a.target.value)),"aria-label":n("routines.interval.customMinutes"),"aria-invalid":Re,"aria-describedby":Re?"routine-interval-error":"routine-interval-help",autoFocus:!0,className:C("w-20 rounded-lg border bg-inset px-3 py-2 text-[13px] tabular-nums text-ink outline-none focus:border-accent",Re?"border-danger/70":"border-hairline/50")}),e.jsx("span",{children:n("routines.interval.minutesUnit")})]}),e.jsxs("div",{className:"grid items-center gap-2 text-[13px] text-ink sm:flex sm:flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.on")}),e.jsxs(q,{value:se,onChange:a=>Pn(a.target.value),"aria-label":n("routines.interval.daysLabel"),"aria-invalid":ke,"aria-describedby":ke?"routine-interval-days-error":void 0,children:[e.jsx("option",{value:"every-day",children:n("routines.repeat.daily")}),e.jsx("option",{value:"weekdays",children:n("routines.repeat.weekdays")}),e.jsx("option",{value:"custom",children:n("routines.interval.custom")})]})]}),e.jsx("span",{"aria-hidden":"true",className:"hidden text-ink-secondary sm:inline",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.during")}),e.jsxs(q,{value:pe,onChange:a=>ae(a.target.value),"aria-label":n("routines.interval.hoursLabel"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,children:[e.jsx("option",{value:"all-day",children:n("routines.interval.allDay")}),e.jsx("option",{value:"custom",children:n("routines.interval.customHours")})]})]}),e.jsx("span",{"aria-hidden":"true",className:"hidden text-ink-secondary sm:inline",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.ends")}),e.jsxs(q,{value:_e,onChange:a=>Dn(a.target.value),"aria-label":n("routines.interval.endsLabel"),"aria-invalid":he,"aria-describedby":he?"routine-interval-end-error":void 0,children:[e.jsx("option",{value:"never",children:n("routines.interval.never")}),e.jsx("option",{value:"on-date",children:n("routines.interval.onDate")})]})]})]}),se==="custom"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] font-medium text-ink-secondary",children:n("routines.interval.chooseDays")}),e.jsx("div",{role:"group","aria-label":n("routines.interval.customDays"),"aria-invalid":ke,"aria-describedby":ke?"routine-interval-days-error":void 0,className:"flex flex-wrap gap-1.5",children:nn.map((a,k)=>e.jsx("button",{type:"button",onClick:()=>K(O=>O.includes(k)?O.filter(ie=>ie!==k):[...O,k].sort()),"aria-label":n(f.includes(k)?"routines.interval.daySelected":"routines.interval.dayNotSelected",{day:Ze(k)}),"aria-pressed":f.includes(k),className:C("size-8 rounded-full text-[10px] font-semibold",f.includes(k)?"bg-accent text-white":"bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.interval.dayChips").split(" ")[k]},a))})]}),pe==="custom"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{className:"font-medium text-ink-secondary",children:n("routines.interval.runBetween")}),e.jsx("input",{"aria-label":n("routines.interval.windowStart"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,type:"time",step:te*60,value:Ae,onChange:a=>Tn(a.target.value),className:C("rounded-lg border bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",re?"border-danger/70":"border-hairline/50")}),e.jsx("span",{className:"text-ink-secondary",children:n("routines.interval.and")}),e.jsx("input",{"aria-label":n("routines.interval.windowEnd"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,type:"time",step:te*60,value:Pe,onChange:a=>Rn(a.target.value),className:C("rounded-lg border bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",re?"border-danger/70":"border-hairline/50")})]}),_e==="on-date"&&e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{className:"font-medium text-ink-secondary",children:n("routines.interval.stopAfter")}),e.jsx("input",{"aria-label":n("routines.interval.endDate"),"aria-invalid":he,"aria-describedby":he?"routine-interval-end-error":void 0,type:"date",min:Ge($t),value:St,onChange:a=>Mn(a.target.value),className:C("rounded-lg border bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",he?"border-danger/70":"border-hairline/50")})]}),Re&&e.jsx("div",{id:"routine-interval-error",className:"text-[11px] text-danger",children:n("routines.interval.invalidMinutes")}),ke&&e.jsx("div",{id:"routine-interval-days-error",className:"text-[11px] text-danger",children:n("routines.interval.invalidDays")}),re&&e.jsx("div",{id:"routine-interval-window-error",className:"text-[11px] text-danger",children:n("routines.interval.invalidWindow",{minutes:G||5})}),he&&e.jsx("div",{id:"routine-interval-end-error",className:"text-[11px] text-danger",children:n("routines.interval.endAfterFirstRun")}),e.jsx("div",{id:"routine-interval-help",className:"text-[11px] leading-relaxed text-ink-secondary",children:n(w==="queue"?"routines.overlapQueueHelp":"routines.overlapSkipHelp")})]})]}),ut=be(X?gn:bn),Vt=v==="routine"&&e.jsxs("details",{className:"rounded-xl border border-hairline/40 bg-inset/40 px-3 py-2.5",children:[e.jsx("summary",{className:"cursor-pointer select-none text-[12px] font-medium text-ink-secondary hover:text-ink",children:T==null?n("routines.runLimit.none",{duration:ut}):n("routines.runLimit.some",{duration:be(T)})}),e.jsxs("div",{className:"mt-3 border-t border-hairline/35 pt-3",children:[e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{children:n("routines.runLimit.stopAfter")}),e.jsxs(q,{"aria-label":n("routines.runLimit.label"),value:T??"",onChange:a=>L(a.target.value?Number(a.target.value):null),children:[e.jsx("option",{value:"",children:n("routines.runLimit.noLimit",{duration:ut})}),sa.map(a=>e.jsx("option",{value:a,children:be(a)},a))]})]}),e.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n("routines.runLimit.help",{duration:ut})}),y!=="none"&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{children:n("routines.overlapLabel")}),e.jsxs(q,{"aria-label":n("routines.overlapLabel"),value:w,onChange:a=>D(a.target.value==="queue"?"queue":"skip"),children:[e.jsx("option",{value:"skip",children:n("routines.overlapSkip")}),e.jsx("option",{value:"queue",children:n("routines.overlapQueue")})]})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n(w==="queue"?"routines.overlapQueueHelp":"routines.overlapSkipHelp")})]}),y!=="none"&&e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-[12px] text-ink",children:[e.jsx("input",{type:"checkbox","aria-label":n("routines.runOnStartupLabel"),checked:le,onChange:a=>F(a.target.checked),className:"mt-0.5 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block",children:n("routines.runOnStartupLabel")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.runOnStartupHelp")})]})]})]})]}),Wn=v==="routine"&&!X&&y!=="none"&&e.jsxs("label",{className:C("flex items-start gap-3 rounded-xl border border-hairline/40 bg-inset/40 px-3.5 py-3",Y&&"ml-8"),children:[e.jsx("input",{type:"checkbox","aria-label":n("routines.continuityLabel"),checked:Z,onChange:a=>ne(a.target.checked),className:"mt-0.5 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.continuityLabel")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.continuityHelp")})]})]}),Jt=v==="routine"&&!X&&e.jsx("div",{className:C(Y&&"ml-8"),children:e.jsx(yn,{bot:s.find(a=>a.id===U[0]),value:it,allowCurrent:!!l,onChange:It})}),Kt=e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ms,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),X?e.jsxs("div",{className:"min-w-0 flex-1 rounded-xl border border-hairline/50 bg-inset px-3.5 py-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.groupContext")}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.teamGoalAttachments")})]}):e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("input",{ref:Et,type:"file",multiple:!0,className:"hidden",onChange:a=>{$n(a.target.files),a.target.value=""}}),e.jsx("button",{type:"button",onClick:()=>Et.current?.click(),className:"rounded-lg border border-hairline/50 px-3 py-2 text-[13px] font-medium text-ink hover:bg-raised",children:n("routines.attachment.add")}),e.jsx(In,{attachments:Ie,onRemove:a=>lt(k=>k.filter(O=>O.id!==a))}),e.jsx("div",{className:"text-[11px] leading-relaxed text-ink-secondary",children:v==="routine"?n("routines.attachment.routineHelp"):Te.length>1?n("routines.attachment.callSharedHelp"):n("routines.attachment.callKeptHelp")}),Lt&&e.jsx("div",{className:"text-[12px] text-warning",children:Lt})]})]}),Qt=v==="routine"&&e.jsxs("div",{className:"flex items-start gap-4",children:[X?e.jsx(tn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):je==="cloud"?e.jsx(dn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):e.jsx(cn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("div",{className:"min-w-0 flex-1",children:X?e.jsxs("div",{className:"rounded-xl border border-accent/35 bg-accent/[0.07] p-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n(At?"routines.editor.goalRunsOnCloud":"routines.editor.goalRunsOnComputer")}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.roomGoalKept")})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>He("maus"),className:C("rounded-xl border p-3 text-left",je==="maus"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.currentSetup")}),e.jsx("div",{className:"mt-1 text-[11px] text-ink-secondary",children:"Keeps its model and configured computer, including a self-hosted VPS."})]}),e.jsxs("button",{type:"button",disabled:!On||Ie.length>0,onClick:()=>He("cloud"),className:C("rounded-xl border p-3 text-left disabled:cursor-not-allowed disabled:opacity-45",je==="cloud"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.runsOn.boat")}),e.jsx("div",{className:"mt-1 text-[11px] text-ink-secondary",children:n(At?"routines.runsOn.boatHintCloudHome":"routines.runsOn.boatHint")})]})]})})]}),Gn=!Y&&v==="routine"?n(u?l?"automations.editor.edit":"automations.editor.new":l?"routines.editor.edit":"routines.editor.new"):n(l||S?"routines.event.edit":"routines.event.new"),Xt=[["none","routines.repeat.once"],["daily","routines.repeat.daily"],["weekdays","routines.repeat.weekdays"],["weekly","routines.repeat.weekly"]];return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/65 p-3",onMouseDown:a=>a.target===a.currentTarget&&m(),children:e.jsxs("div",{ref:Pt,role:"dialog","aria-modal":"true","aria-label":n(l||S?"routines.event.editLabel":"routines.event.createLabel"),tabIndex:-1,className:"max-h-[94vh] w-full max-w-[760px] overflow-y-auto rounded-2xl border border-hairline/60 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-hairline/40 bg-panel/95 px-5 py-3.5 backdrop-blur",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:Gn}),e.jsx("button",{onClick:m,className:"rounded-full p-2 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":n("common.close"),children:e.jsx(Me,{size:18})})]}),e.jsxs("div",{className:"space-y-5 px-5 py-5 sm:px-8",children:[Y&&Ut,Y&&Wt,e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"mt-3 size-4 shrink-0 rounded bg-accent"}),e.jsx("input",{autoFocus:!0,value:E,onChange:a=>H(a.target.value),"aria-label":n("routines.editor.titleLabel"),placeholder:v==="routine"?Y?n("routines.event.addTitle"):n("routines.editor.titlePlaceholder"):n("routines.event.addCallTitle"),className:"min-w-0 flex-1 border-b border-hairline/60 bg-transparent px-1 pb-2 text-[22px] font-medium text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"})]}),Y?e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(bt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[Gt,qt,Yt,Zt,Vt]})]}):e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(bt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.when")}),Gt,e.jsx("div",{role:"group","aria-label":n("routines.editor.repeat"),className:"flex flex-wrap gap-1.5",children:Xt.map(([a,k])=>e.jsx("button",{type:"button","aria-pressed":y===a,onClick:()=>Ft(a),className:C("rounded-full border px-3 py-1.5 text-[12px] font-medium transition",y===a?"border-accent-border bg-accent/15 text-accent-text":"border-hairline/50 bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:n(k)},a))}),!Xt.some(([a])=>a===y)&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:n("routines.editor.customRepeat")})]})]}),e.jsxs("div",{className:"flex items-start gap-4",children:[X?e.jsx(hn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):e.jsx(vt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("div",{className:"min-w-0 flex-1",children:X?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"routine-goal-room",className:"mb-2 block text-[13px] font-medium text-ink",children:n("routines.editor.goalWhere")}),e.jsxs(q,{id:"routine-goal-room",value:me,onChange:a=>_n(a.target.value),className:"w-full",children:[me&&!ue&&e.jsx("option",{value:me,disabled:!0,children:n("routines.editor.roomMissing")}),e.jsx("option",{value:"",children:n("routines.editor.goalOneOnOne")}),Be.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[13px] font-medium text-ink",children:ue?n("routines.goal.chooseLead"):n("routines.editor.who")}),dt.length>0?e.jsxs(e.Fragment,{children:[e.jsx(jt,{bots:dt,selected:U,multiple:!1,onChange:$e}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ue?n("routines.goal.leadHelp",{name:ue.name}):n("routines.editor.goalOneOnOneHelp")})]}):e.jsx("div",{className:"rounded-xl border border-warning/30 bg-warning/10 px-3.5 py-3 text-[12px] text-warning",children:n("routines.goal.noMembers")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-2 text-[13px] font-medium text-ink",children:v==="routine"?Y?n("routines.event.assignBot"):n("routines.editor.who"):n("routines.event.addGuests")}),s.length>0?e.jsxs(e.Fragment,{children:[e.jsx(jt,{bots:s,selected:U,multiple:v==="call",locked:!!r,onChange:$e}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:v==="routine"?n("routines.event.botOwnsRuns"):n(Te.length===0?"routines.event.invitedNone":Te.length===1?"routines.event.invitedOne":"routines.event.invitedMany",{count:Te.length})}),v==="routine"&&e.jsx(fn,{team:h.config?.team,bot:Te[0],value:it,madeIn:l?.sourceThreadId})]}):e.jsxs("button",{type:"button",onClick:()=>{N({type:"newBot"}),m()},className:"w-full rounded-xl border border-dashed border-accent/45 bg-accent/[0.06] px-4 py-4 text-left hover:bg-accent/10",children:[e.jsx("div",{className:"text-[13px] font-medium text-accent",children:n("routines.event.createFirstBot")}),e.jsx("div",{className:"mt-1 text-[12px] text-ink-secondary",children:n("routines.event.needsBot")})]})]})})]}),Y&&Jt,e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(st,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("textarea",{value:B,onChange:a=>A(a.target.value),rows:5,"aria-label":n("routines.editor.descriptionLabel"),placeholder:X?n("routines.goal.instructionsPlaceholder"):v==="routine"?Y?n("routines.event.instructionsPlaceholder"):n("routines.editor.instructionsPlaceholder"):n("routines.event.agendaPlaceholder"),className:"min-w-0 flex-1 resize-y rounded-xl border border-hairline/50 bg-inset px-3.5 py-3 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"})]}),Wn,Y&&Kt,Y&&Qt,!Y&&e.jsxs("div",{children:[e.jsxs("button",{type:"button","aria-expanded":We,"aria-controls":"routine-more-options",onClick:()=>Un(a=>!a),className:"flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-[13px] font-medium text-accent-text hover:bg-raised",children:[e.jsx(zs,{size:14,className:C("transition-transform",We&&"rotate-90")}),n(We?"routines.editor.fewer":"routines.editor.more")]}),We&&e.jsxs("div",{id:"routine-more-options",className:"mt-3 space-y-5 rounded-xl border border-hairline/40 bg-inset/30 p-4",children:[Ut,Wt,e.jsxs("div",{className:"space-y-3",children:[qt,Yt,Zt,Vt]}),Jt,Kt,Qt]})]}),Dt&&e.jsxs("div",{className:"ml-10 flex items-start gap-2 rounded-xl border border-danger/30 bg-danger/10 px-3 py-2.5 text-[13px] text-danger",children:[e.jsx(Ke,{size:15,className:"mt-0.5 shrink-0"}),Dt]})]}),e.jsxs("div",{className:"sticky bottom-0 flex items-center justify-end gap-2 border-t border-hairline/40 bg-panel/95 px-5 py-3.5 backdrop-blur",children:[e.jsx("button",{onClick:m,className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:n("common.cancel")}),e.jsxs("button",{onClick:Hn,disabled:Tt||Fe||!Fn,className:"flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-semibold text-white hover:brightness-110 disabled:opacity-40",children:[(Tt||Fe)&&e.jsx(Le,{size:14,className:"animate-spin"}),Fe?n("routines.attachment.attaching"):l||S||v==="routine"&&!X?n("automations.editor.app.save"):n(v==="call"?"routines.event.scheduleCall":"routines.goal.schedule")]})]})]})})}function ja({seed:t,bots:s,routinesOnly:r=!1,onClose:o,onMore:i,onSavedRoutine:u,onSavedCall:m}){const{state:c,dispatch:h}=nt(),[N,l]=x.useState(r||t.limitReset?"routine":t.kind),[$,S]=x.useState(t.name??""),[v,J]=x.useState(t.description??""),[z,E]=x.useState(t.botIds.length?t.botIds:s[0]?[s[0].id]:[]),[H,B]=x.useState(()=>t.resultsThreadId??Qe(c,z[0])??null),A=p=>{p[0]!==z[0]&&B(Qe(c,p[0])??null),E(p)},[M,d]=x.useState(!1),[b,R]=x.useState(""),P=x.useRef(null),[g,j]=x.useState(null),I=N==="routine"?30:t.durationMinutes;x.useLayoutEffect(()=>{if(!t.anchor){j(null);return}const p=P.current;if(!p)return;const _=()=>{const D=p.getBoundingClientRect();let Z=t.anchor.x+12,ne=t.anchor.y+12;Z+D.width>window.innerWidth-12&&(Z=t.anchor.x-D.width-12),ne+D.height>window.innerHeight-12&&(ne=t.anchor.y-D.height-12),j({left:Math.max(12,Math.min(Z,window.innerWidth-D.width-12)),top:Math.max(12,Math.min(ne,window.innerHeight-D.height-12))})};return _(),window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[N,t.anchor]);const T=async()=>{d(!0),R("");try{if(N==="routine"||r){const p=await we("/api/routines",{method:"POST",body:JSON.stringify({name:$,prompt:v,botId:z[0],runOn:"maus",enabled:!0,schedule:t.limitReset?{type:"limit_reset",engine:t.limitReset.engine,repeat:"once"}:{type:"once",at:t.at},durationMinutes:I,attachments:[],resultsThreadId:H})});u(p.routine)}else{const p=await we("/api/calendar-calls",{method:"POST",body:JSON.stringify({name:$,description:v,botIds:z,schedule:{type:"once",at:t.at},durationMinutes:I})});m(p.call)}o()}catch(p){R(p instanceof Error?p.message:String(p))}finally{d(!1)}},L=!!($.trim()&&z.length&&(N==="call"||v.trim()));return e.jsxs("div",{ref:P,role:"dialog","aria-label":n("routines.quick.label"),style:g??void 0,className:C("fixed z-50 max-h-[calc(100vh-24px)] w-[min(430px,calc(100vw-24px))] overflow-y-auto rounded-2xl border border-hairline/60 bg-panel shadow-2xl",!g&&"left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2"),children:[e.jsxs("div",{className:"flex items-center justify-between bg-raised/70 px-4 py-2.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.quick.title")}),e.jsx("button",{onClick:o,className:"rounded-full p-1.5 text-ink-secondary hover:bg-inset hover:text-ink","aria-label":n("common.close"),children:e.jsx(Me,{size:16})})]}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsx("input",{autoFocus:!0,value:$,onChange:p=>S(p.target.value),"aria-label":n("routines.editor.titleLabel"),placeholder:n("routines.event.addTitle"),onKeyDown:p=>{p.key==="Enter"&&L&&T()},className:"w-full border-b border-hairline/60 bg-transparent pb-2 text-[18px] font-medium text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"}),!r&&!t.limitReset&&e.jsxs("div",{className:"flex items-center gap-1 border-b border-hairline/35 pb-2",children:[e.jsx("button",{type:"button",onClick:()=>{l("routine"),E(p=>p.slice(0,1))},className:C("rounded-lg px-3 py-1.5 text-[12px] font-medium",N==="routine"?"bg-accent/15 text-accent":"text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.kind.routine")}),e.jsx("button",{type:"button",onClick:()=>l("call"),className:C("rounded-lg px-3 py-1.5 text-[12px] font-medium",N==="call"?"bg-accent/15 text-accent":"text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.kind.call")})]}),e.jsxs("div",{className:"flex items-start gap-3 text-[13px] text-ink",children:[e.jsx(bt,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),t.limitReset?e.jsx("div",{"data-testid":"quick-limit-reset",children:Ts({engine:t.limitReset.engine,repeat:"once"})}):e.jsxs("div",{children:[e.jsx("div",{children:wt(t.at)}),e.jsxs("div",{className:"mt-0.5 text-ink-secondary",children:[ee(t.at),N==="call"?` – ${ee(t.at+I*6e4)}`:""]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(vt,{size:16,className:"mt-2.5 shrink-0 text-ink-secondary"}),s.length===0?e.jsxs("button",{type:"button",onClick:()=>{h({type:"newBot"}),o()},className:"min-w-0 flex-1 rounded-xl border border-dashed border-accent/45 bg-accent/[0.06] px-3 py-3 text-left hover:bg-accent/10",children:[e.jsx("div",{className:"text-[12px] font-medium text-accent",children:n("routines.event.createFirstBot")}),e.jsx("div",{className:"mt-0.5 text-[11px] text-ink-secondary",children:n("routines.quick.comeBack")})]}):N==="routine"?e.jsxs(q,{value:z[0]??"",onChange:p=>A([p.target.value]),className:"flex-1",children:[e.jsx("option",{value:"",children:n("routines.event.assignBot")}),s.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}):e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(jt,{bots:s,selected:z,multiple:!0,onChange:A})})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(st,{size:16,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("textarea",{value:v,onChange:p=>J(p.target.value),rows:3,"aria-label":n("routines.editor.descriptionLabel"),placeholder:n(N==="routine"?"routines.quick.whatToDo":"routines.quick.description"),className:"min-w-0 flex-1 resize-none rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"})]}),N==="routine"&&e.jsx(yn,{bot:s.find(p=>p.id===z[0]),value:H,onChange:p=>B(p??null)}),N==="routine"&&e.jsx(fn,{team:c.config?.team,bot:s.find(p=>p.id===z[0]),value:H}),b&&e.jsx("div",{className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:b})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-hairline/40 px-4 py-3",children:[e.jsx("button",{onClick:()=>i({...t,kind:N,botIds:z,name:$,description:v,durationMinutes:I,resultsThreadId:H}),title:n("routines.quick.moreTitle"),className:"rounded-lg px-3 py-2 text-[12px] font-medium text-accent hover:bg-accent/10",children:n("routines.editor.more")}),e.jsxs("button",{onClick:T,disabled:!L||M,className:"flex items-center gap-1.5 rounded-lg bg-accent px-4 py-2 text-[12px] font-semibold text-white hover:brightness-110 disabled:opacity-40",children:[M&&e.jsx(Le,{size:13,className:"animate-spin"}),n("common.save")]})]})]})}function ka({anchor:t,days:s,items:r,bots:o,groups:i,selectedId:u,onOpen:m,onCreate:c,onMove:h,onResize:N,markers:l=[],onDropOnReset:$}){const S=x.useRef(null),[v,J]=x.useState(null),[z,E]=x.useState(null),H=Ye(Date.now()),B=Array.from({length:s},(g,j)=>mn(t,j)),A=s===7?64:s===3?180:280,M=`64px repeat(${s}, minmax(${A}px, 1fr))`,d=64+s*A;x.useEffect(()=>{const g=S.current;if(!g)return;const j=new Date,I=B.includes(H)?Math.max(0,j.getHours()-2):7;g.scrollTo({top:I*W})},[s]);const b=(g,j)=>{if(g.button!==0||g.target.closest("[data-event-card]"))return;const I=g.currentTarget.getBoundingClientRect(),T=qe(j,g.clientY,I.top,W);let L=T+30*6e4;J({day:j,start:T,end:L});const p=w=>{const D=qe(j,w.clientY,I.top,W);L=Math.max(T+te*6e4,D+te*6e4),J({day:j,start:T,end:L})},_=w=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",_),J(null),c({kind:"routine",at:T,durationMinutes:Math.max(te,Math.round((L-T)/6e4)),botIds:[],anchor:{x:w.clientX,y:w.clientY}})};document.addEventListener("pointermove",p),document.addEventListener("pointerup",_,{once:!0})},R=(g,j)=>{g.preventDefault(),E(null);const I=g.currentTarget.getBoundingClientRect(),T=qe(j,g.clientY,I.top,W),L=g.dataTransfer.getData(Xe);if(L)return c({kind:"routine",at:T,durationMinutes:30,botIds:[L],anchor:{x:g.clientX,y:g.clientY}});const p=g.dataTransfer.getData(Se);if(p)try{const _=JSON.parse(p);h(_,T)}catch{}},P=(g,j)=>{if(!g.dataTransfer.types.includes(Xe)&&!g.dataTransfer.types.includes(Se))return;g.preventDefault(),g.dataTransfer.dropEffect=g.dataTransfer.types.includes(Se)?"move":"copy";const I=g.currentTarget.getBoundingClientRect(),T=qe(j,g.clientY,I.top,W);E(L=>L?.day===j&&L.at===T?L:{day:j,at:T})};return e.jsxs("div",{ref:S,className:"min-h-0 flex-1 overflow-auto border-l border-t border-hairline/40 bg-app",children:[e.jsxs("div",{className:"sticky top-0 z-30 grid bg-app/95 backdrop-blur",style:{gridTemplateColumns:M,minWidth:d},children:[e.jsx("div",{className:"border-b border-r border-hairline/40 px-2 py-3 text-center text-[9px] uppercase tracking-wider text-ink-secondary",children:ys(-new Date(t).getTimezoneOffset())}),B.map(g=>{const j=new Date(g),I=g===H;return e.jsxs("div",{role:"columnheader",className:C("border-b border-r border-hairline/40 px-2 py-2 text-center last:border-r-0",I&&"bg-accent/[0.035]"),children:[e.jsx("div",{className:C("text-[10px] font-medium uppercase tracking-[0.14em]",I?"text-accent":"text-ink-secondary"),children:Ze(j.getDay())}),e.jsx("div",{className:C("mx-auto mt-1 flex size-8 items-center justify-center rounded-full text-[15px] font-medium",I?"bg-accent text-accent-ink":"text-ink"),children:j.getDate()})]},g)})]}),e.jsxs("div",{role:"grid","aria-label":n("routines.calendar.label"),onDragEnd:()=>E(null),className:"relative grid",style:{height:W*24,gridTemplateColumns:M,minWidth:d},children:[e.jsx("div",{className:"relative border-r border-hairline/40",children:Array.from({length:24},(g,j)=>e.jsx("div",{className:"absolute right-2 -translate-y-1/2 text-[10px] tabular-nums text-ink-tertiary",style:{top:j*W},children:j===0?"":new Date(2e3,0,1,j).toLocaleTimeString(ze(),{hour:"numeric"})},j))}),B.map(g=>{const j=new Date,I=(j.getHours()*60+j.getMinutes())/60*W,T=r.filter(w=>Ye(w.at)===g),L=js(T),p=v?.day===g?v:null,_=z?.day===g?z:null;return e.jsxs("div",{role:"gridcell","aria-label":n("routines.calendar.day",{date:wt(g)}),onPointerDown:w=>b(w,g),onDragOver:w=>P(w,g),onDragLeave:w=>{(!(w.relatedTarget instanceof Node)||!w.currentTarget.contains(w.relatedTarget))&&E(null)},onDrop:w=>R(w,g),className:C("relative border-r border-hairline/40 last:border-r-0",g===H&&"bg-accent/[0.025]"),children:[Array.from({length:48},(w,D)=>e.jsx("div",{className:C("pointer-events-none absolute inset-x-0 border-t",D%2===0?"border-hairline/30":"border-hairline/10"),style:{top:D/2*W}},D)),g===H&&e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 z-20 flex items-center",style:{top:I},children:[e.jsx("span",{className:"-ml-1 size-2 rounded-full bg-danger"}),e.jsx("span",{className:"h-px flex-1 bg-danger/80"})]}),p&&e.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-md border border-accent/70 bg-accent/20",style:{top:(new Date(p.start).getHours()*60+new Date(p.start).getMinutes())/60*W,height:Math.max(16,(p.end-p.start)/36e5*W)}}),_&&e.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-20 rounded-md border border-accent/80 bg-accent/25 shadow-sm",style:{top:(new Date(_.at).getHours()*60+new Date(_.at).getMinutes())/60*W,height:W/2},children:e.jsx("div",{className:"px-2 py-1 text-[10px] font-medium text-accent",children:ee(_.at)})}),l.filter(w=>Ye(w.at)===g).map(w=>e.jsx(ea,{marker:w,hourHeight:W,onDrop:$&&(D=>$(D,w))},w.engine)),T.map(w=>e.jsx(na,{item:w,bots:o,groups:i,compact:s===7,layout:L.get(w.id)??{column:0,columns:1},selected:w.id===u,onOpen:()=>m(w),onResize:D=>N(w,D)},w.id))]},g)})]})]})}function Na({item:t,bots:s,onClose:r,onEdit:o,onCallChanged:i,onOpenRoom:u,onOpenRun:m}){const{state:c,dispatch:h}=nt(),N=ln(),l=Qn(),[$,S]=x.useState(!1),v=x.useRef(!1),[J,z]=x.useState(!1),[E,H]=x.useState(void 0),[B,A]=x.useState(""),M=t.kind==="call",d=t.kind==="routine"?t.routine:null,b=E===void 0?t.kind==="routine"?t.run:null:E&&(c.routineRuns.find(f=>f.id===E.id)??E),R=t.kind==="call"?t.call:null,P=!M&&(b?.target??d?.target)==="room-goal",g=P?b?b.groupId:d?.groupId:void 0,j=c.groups.find(f=>f.id===g),I=b?.executionThreadId??b?.threadId,T=R?.botIds??[b?.botId??d?.botId??""],L=T.flatMap(f=>s.find(K=>K.id===f)??[]),p=L[0],_=P&&g?j:p,w=!!(I&&(_?.threadId===I||_?.tasks?.some(f=>f.threadId===I))),D=b?b.resultsThreadId??b.sourceThreadId:d?.resultsThreadId,Z=D??(!b&&d?.target==="bot"?p?.mainThreadId:void 0),ne=Z&&[...c.bots,...c.groups].some(f=>f.threadId===Z||f.tasks?.some(K=>K.threadId===Z)),le=R?.name??b?.routineName??d?.name??"Routine",F=R?.description??b?.prompt??d?.prompt??"",y=R?.attachments??b?.attachments??d?.attachments??[],de=R?.botIds.length===1?p?.id:void 0,Q=b?b.timeoutMinutes:d?.timeoutMinutes,ve=()=>{I&&(P&&g?(h({type:"switchGroupTask",groupId:g,threadId:I}),u(g)):p&&Ms(h,p,I,l),r())},ce=async(f,K="POST",pe)=>{S(!0),A("");try{const ae=await we(f,{method:K,...pe?{body:JSON.stringify(pe)}:{}});ae.routine&&h({type:"routinePatched",routine:ae.routine}),ae.run&&h({type:"routineRunPatched",run:ae.run})}catch(ae){A(ae instanceof Error?ae.message:String(ae))}finally{S(!1)}},fe=()=>{!d||$||v.current||(v.current=!0,z(!0),H(null),S(!0),A(""),h({type:"runRoutine",routineId:d.id,onStarted:H,onError:f=>A(f instanceof Error?f.message:String(f)),onSettled:()=>{v.current=!1,z(!1),S(!1)}}))},at=async()=>{if(R){S(!0),A("");try{const{group:f}=await we(`/api/calendar-calls/${R.id}/room`,{method:"POST"});h({type:"groupPatched",group:f}),u(f.id)}catch(f){A(f instanceof Error?f.message:String(f))}finally{S(!1)}}},Oe=async()=>{window.confirm(n("routines.event.deleteConfirm",{title:le}))&&(R?(await we(`/api/calendar-calls/${R.id}`,{method:"DELETE"}),i(R.id)):d&&h({type:"deleteRoutine",routineId:d.id}),r())},ye=d?.id??b?.routineId,Ee=ye?c.routineRuns.filter(f=>f.routineId===ye).sort((f,K)=>sn(K)-sn(f)).slice(0,3):[],G=b?.runOn??d?.runOn,Ce=ks({roomGoal:P,runOn:G,computer:p?.computer,cloudHome:c.config?.cloudHome===!0}),se=D?[...c.bots,...c.groups].find(f=>f.threadId===D||f.tasks?.some(K=>K.threadId===D)):void 0,rt=D?se?.tasks?.find(f=>f.threadId===D)?.title??se?.name??n("routines.results.missing"):n("routines.results.main");return e.jsxs("aside",{"aria-label":n("routines.drawer.label"),className:"flex h-full w-[min(310px,100vw)] shrink-0 flex-col border-l border-hairline/40 bg-panel",children:[e.jsxs("div",{className:"flex items-start gap-3 border-b border-hairline/40 px-4 py-3.5",children:[M?e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/15 text-accent-text",children:e.jsx(ft,{size:16})}):P?e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/15 text-accent-text",children:e.jsx(hn,{size:16})}):p&&e.jsx(Ve,{bot:p,state:b?Nn(b.status):d?.enabled===!1?"sleeping":"idle",size:36,animated:!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words text-[15px] font-semibold leading-snug text-ink",children:le}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[d&&e.jsx("span",{className:C("rounded-full px-2 py-0.5 text-[11px] font-medium",d.enabled?"bg-success/15 text-success":"bg-inset text-ink-secondary"),children:Ns(d)}),e.jsxs("span",{className:"text-[11px] text-ink-secondary",children:[wt(t.at)," · ",ee(t.at),M?` – ${ee(t.at+t.durationMinutes*6e4)}`:""]})]})]}),e.jsx("button",{type:"button",onClick:r,className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":n("routines.drawer.close"),children:e.jsx(Me,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4",children:[b&&e.jsxs("div",{role:"status","aria-live":"polite",className:"rounded-xl border border-hairline/40 bg-inset p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-medium text-ink",children:[b.status==="running"&&e.jsx(Le,{size:13,className:"animate-spin text-accent"}),kt(b)]}),b.output&&e.jsx("div",{className:"mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap text-[12px] leading-relaxed text-ink-secondary",children:pt(b,"output")}),b.error&&e.jsx("div",{className:C("mt-2 text-[12px]",Nt(b)?"text-warning":"text-danger"),children:pt(b,"error")})]}),b?.attention&&e.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-warning/30 bg-warning/10 px-3 py-2.5 text-warning",children:[e.jsx(Ke,{size:15,className:"mt-0.5 shrink-0"}),e.jsx("div",{className:"min-w-0 whitespace-pre-wrap text-[12px] leading-relaxed",children:pt(b,"attention")})]}),b?.status==="waiting"&&!b.attention&&e.jsx("div",{className:"rounded-xl border border-warning/30 bg-warning/10 px-3 py-2.5 text-[12px] text-warning",children:n("routines.drawer.runWaiting")}),e.jsx(oe,{label:M?n("routines.drawer.guests"):P?n("routines.drawer.lead"):n("routines.drawer.bot"),children:e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L.map(f=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-hairline/50 bg-inset py-0.5 pl-0.5 pr-2.5",children:[e.jsx(Ve,{bot:f,state:"idle",size:22,animated:!1}),e.jsx("span",{className:"text-[12px] text-ink",children:f.name})]},f.id)),L.length===0&&e.jsx("span",{className:"text-[13px] text-ink-secondary",children:n("routines.unavailableBot")})]})}),P&&g&&e.jsx(oe,{label:n("routines.drawer.group"),children:e.jsx("div",{className:"text-[13px] text-ink",children:j?.name??n("routines.drawer.groupUnavailable")})}),(d||R)&&e.jsxs(oe,{label:n("routines.drawer.schedule"),children:[e.jsx("div",{className:"text-[13px] text-ink",children:ws((d??R).schedule)}),d?.schedule.type==="cron"&&e.jsx("div",{className:"mt-2",children:e.jsx(Ws,{schedule:d.schedule,paused:!d.enabled})})]}),F&&e.jsx(oe,{label:M?n("routines.drawer.agenda"):n("routines.drawer.what"),children:e.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-relaxed text-ink",children:F})}),!M&&e.jsxs(oe,{label:n("routines.drawer.runsOn"),children:[e.jsxs("div",{className:"flex items-start gap-2 text-[13px] text-ink",children:[G==="cloud"?e.jsx(dn,{size:14,className:"mt-0.5 shrink-0 text-ink-secondary"}):e.jsx(cn,{size:14,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsx("span",{children:Ce.label})]}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-ink-secondary",children:Ce.hint})]}),!M&&!P&&e.jsx(oe,{label:n("routines.results.label"),children:e.jsx("div",{className:"text-[13px] text-ink",children:rt})}),y.length>0&&e.jsxs(oe,{label:n("routines.drawer.attachments"),children:[e.jsx(In,{attachments:y}),R&&e.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n(R.botIds.length>1?"routines.drawer.callSharedHelp":"routines.drawer.callKeptHelp")})]}),N&&!M&&e.jsx(oe,{label:n("routines.drawer.runLimit"),children:e.jsx("div",{className:"text-[13px] text-ink",children:Q==null?n("routines.drawer.noTimeLimit",{duration:be(P?gn:bn)}):n("routines.drawer.stopsAfter",{duration:be(Q)})})}),!M&&e.jsx(oe,{label:n("routines.logs"),action:d&&e.jsxs("button",{type:"button",onClick:()=>{h({type:"showRoutines",section:"logs",routineId:d.id,botId:d.botId}),r()},className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-accent-text hover:bg-raised",children:[e.jsx(st,{size:11}),n("routines.drawer.allRuns")]}),children:Ee.length===0?e.jsx("div",{className:"text-[12px] text-ink-secondary",children:n("routines.drawer.noRuns")}):e.jsx("div",{className:"space-y-1",children:Ee.map(f=>e.jsx(pa,{run:f,current:f.id===b?.id,onOpen:()=>m?.(f)},f.id))})}),B&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:B})]}),e.jsxs("div",{className:"space-y-2 border-t border-hairline/40 px-4 py-3",children:[d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:fe,disabled:$,className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110 disabled:opacity-50",children:[J?e.jsx(Le,{size:13,className:"animate-spin"}):e.jsx(an,{size:13}),J?n("routines.starting"):n("routines.runNow")]}),e.jsxs("button",{disabled:$,onClick:()=>{ce(`/api/routines/${d.id}`,"PATCH",{enabled:!d.enabled})},title:n(d.enabled?"routines.drawer.pauseRoutine":"routines.drawer.resumeRoutine"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-hairline/50 bg-control px-3 py-2 text-[12px] font-medium text-ink hover:bg-raised-hover disabled:opacity-40",children:[d.enabled?e.jsx(Ss,{size:13}):e.jsx(an,{size:13}),d.enabled?n("routines.pause"):n("routines.resume")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[de&&e.jsxs("button",{onClick:()=>u(de),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110",children:[e.jsx(De,{size:13}),n("routines.drawer.joinGroup")]}),R&&R.botIds.length>1&&e.jsxs("button",{onClick:at,disabled:$,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110 disabled:opacity-50",children:[e.jsx(De,{size:13}),n("routines.drawer.joinGroup")]}),P&&j&&!I&&e.jsxs("button",{onClick:()=>{u(j.id),r()},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(De,{size:13}),n("routines.drawer.openGroup")]}),w&&e.jsxs("button",{onClick:ve,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(De,{size:13}),n(P&&g?"routines.drawer.openGroupThread":"routines.drawer.openThread")]}),ne&&Z&&e.jsxs("button",{type:"button",onClick:()=>{Cs(h,{botId:T[0],threadId:Z},c,l),r()},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(De,{size:13}),n("routines.results.open")]}),b&&["queued","running","waiting"].includes(b.status)&&e.jsxs("button",{onClick:()=>{ce(`/api/routine-runs/${b.id}/cancel`)},disabled:$,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:[e.jsx(Me,{size:13}),n("routines.drawer.cancelRun")]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(d||R)&&e.jsx("button",{onClick:o,className:"rounded-lg px-2.5 py-1.5 text-[12px] font-medium text-ink hover:bg-raised",children:n("routines.edit")}),(d||R)&&e.jsx("button",{onClick:()=>{Oe()},className:"rounded-lg p-2 text-ink-secondary hover:bg-danger/10 hover:text-danger",title:n("routines.delete"),"aria-label":n("routines.delete"),children:e.jsx(Is,{size:14})})]})]})]})]})}function oe({label:t,action:s,children:r}){return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t}),s]}),r]})}function xa(t){if(t.startedAt==null||t.finishedAt==null||t.finishedAt<t.startedAt)return null;const s=Math.round((t.finishedAt-t.startedAt)/1e3);return s<60?`${s}s`:be(Math.round(s/60))}function pa({run:t,current:s,onOpen:r}){const o=t.startedAt??t.scheduledFor,i=xa(t),u=t.status==="completed"&&(!t.goalStatus||t.goalStatus==="completed"),m=Rs(t)||t.goalStatus==="failed"||t.goalStatus==="blocked",c=["queued","running","waiting"].includes(t.status);return e.jsxs("button",{type:"button",onClick:r,"aria-label":n("routines.openRun",{name:t.routineName,status:kt(t)}),"aria-current":s||void 0,className:C("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left hover:bg-raised",s&&"bg-raised"),children:[u?e.jsx(vn,{size:14,className:"shrink-0 text-success","aria-hidden":"true"}):m?Nt(t)?e.jsx(Ke,{size:14,className:"shrink-0 text-warning","aria-hidden":"true"}):e.jsx(Ds,{size:14,className:"shrink-0 text-danger","aria-hidden":"true"}):c?e.jsx(Le,{size:14,className:"shrink-0 animate-spin text-accent","aria-hidden":"true"}):e.jsx(Ke,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-ink",children:new Date(o).toLocaleDateString(ze(),{month:"short",day:"numeric"})}),e.jsxs("span",{className:"shrink-0 text-[11px] tabular-nums text-ink-secondary",children:[ee(o),i?` · ${i}`:""]})]})}function ma({routine:t,bots:s,lockedBotId:r,initialBotId:o,defaultRunOn:i,plain:u,onClose:m}){const c=t?.schedule.type==="once"?t.schedule.at:t?.schedule.type==="daily"?gt(Date.now(),t.schedule.time):t?.schedule.type==="interval"?t.schedule.anchorAt:t?.schedule.type==="cron"?t.nextRunAt??on():on();return e.jsx(ua,{seed:{kind:"routine",at:c,durationMinutes:t?.durationMinutes??30,botIds:r?[r]:t?[t.botId]:o?[o]:s.length===1?[s[0].id]:[],routine:t},bots:s,lockedBotId:r,defaultRunOn:i,plain:u,onClose:m,onSavedCall:()=>{}})}const wa=Object.freeze(Object.defineProperty({__proto__:null,RoutineEditor:ma},Symbol.toStringTag,{value:"Module"}));export{ka as C,Na as E,Es as H,ja as Q,ma as R,Ps as a,ua as b,wa as c};