limixbot 0.3.100 → 0.3.101

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 (197) hide show
  1. package/dist/assets/{ActivityPanel-DuZNoivH.js → ActivityPanel-DZZgXWgd.js} +1 -1
  2. package/dist/assets/{App-BUF9rx3_.js → App-D24ELMyP.js} +124 -123
  3. package/dist/assets/{AppEventEditor-D2yq1wkA.js → AppEventEditor-BFkEZazQ.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-CdV5Kqhv.js → BotSettingsDialog-BNDFheN0.js} +4 -4
  5. package/dist/assets/{BrowserPanel-DjaihDp3.js → BrowserPanel-BVvlCdxG.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-Ch1HSEpX.js → BrowserProfilesManager-CQVN08cF.js} +1 -1
  7. package/dist/assets/CloudAddDialog-BqehN1pz.js +1 -0
  8. package/dist/assets/{ComputerFilesPane-B2zIb4xO.js → ComputerFilesPane-C8Xj3lsj.js} +1 -1
  9. package/dist/assets/{ComputerPanel-Bg3QoQWy.js → ComputerPanel-BfyIIg7u.js} +2 -2
  10. package/dist/assets/{DataPanel-CldVb-3K.js → DataPanel-CkOWtMCr.js} +1 -1
  11. package/dist/assets/{DesktopViewer-JxM0Thy2.js → DesktopViewer-PXMs_Z3h.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-CoQ6YMdv.js → GrokMoveDialog-B3PuFwiJ.js} +1 -1
  13. package/dist/assets/{InspectorPanel-Cj-nhLfa.js → InspectorPanel-BCiZLdqU.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-sNaxhh0F.js → KeyboardShortcutsModal-ffycwWVV.js} +1 -1
  15. package/dist/assets/{LimixResizeHandles-DPtm2mPo.js → LimixResizeHandles-CtazDkY7.js} +1 -1
  16. package/dist/assets/{LiveDesktop-dfhFXJ6C.js → LiveDesktop-CJWerWq1.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-BTqTG8D6.js → LocalVmWorkspace-CrdC3MmK.js} +1 -1
  18. package/dist/assets/{MacLocalControl-Cjkw9sl_.js → MacLocalControl-Bcdg_u2n.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-O_67JVQ6.js → MarkdownFilePreview-C-XNLE3e.js} +1 -1
  20. package/dist/assets/{MenuMotion-Dv-G0PKg.js → MenuMotion-BclWiAVe.js} +1 -1
  21. package/dist/assets/NewBotDialog-CI3c7n9d.js +1 -0
  22. package/dist/assets/{PhoneAppDialog-Dvu3up2S.js → PhoneAppDialog-CR-LtOHi.js} +1 -1
  23. package/dist/assets/PlacesRail-DyYA64do.js +1 -0
  24. package/dist/assets/{PluginsPanel-CC_Gyo86.js → PluginsPanel-79V2kP_5.js} +4 -4
  25. package/dist/assets/{ProIntroduction-BATr7O3z.js → ProIntroduction-BgEaTCd1.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-Dn2fItnk.js → RemoteAgentSettingsPanel-CpJDLN6F.js} +1 -1
  27. package/dist/assets/{RoomPanel-Cb5fVI3_.js → RoomPanel-ByAT8CqS.js} +2 -2
  28. package/dist/assets/{RoutinesPage-4bH5oJ-7.js → RoutinesPage-CA1__NjC.js} +2 -2
  29. package/dist/assets/{SettingsModal-qiA2JzQg.js → SettingsModal-DAymc03s.js} +1 -1
  30. package/dist/assets/{ShareTeamDialog-CHzxJoVu.js → ShareTeamDialog-Dr7BcuEX.js} +1 -1
  31. package/dist/assets/{SignedInSites-BR5BwDTJ.js → SignedInSites-C-DP_jaP.js} +1 -1
  32. package/dist/assets/TeamLibraryPanel-CI8JZtpN.js +3 -0
  33. package/dist/assets/{TeamMapPage-B2Ll1YMg.js → TeamMapPage-DZlNjWAA.js} +1 -1
  34. package/dist/assets/{TriggersPage-ihGGke0e.js → TriggersPage-CF1DnXkj.js} +1 -1
  35. package/dist/assets/VisibilitySection-DnGXDssr.js +22 -0
  36. package/dist/assets/{WebhookTrigger-BwBskWF-.js → WebhookTrigger-CyF3M1mk.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-CBRlU3o4.js → WorksOnGrid-D195VW8K.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-B0sLejJS.js → abnfDiagram-YUKMZFIV-CKc5IYc4.js} +1 -1
  39. package/dist/assets/{activity-CD7kcgh8.js → activity-CwaOixB9.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-UGF-gdUT.js → architectureDiagram-47P4ROYG-BzQ3blap.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-cwrrGa8s.js → blockDiagram-E7TT5TSB-Cg5etqDi.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-vMmbuHhZ.js → c4Diagram-CRA5TL53-ChJTr_PL.js} +1 -1
  43. package/dist/assets/{calendar-days-COyQwa7m.js → calendar-days-DYBafFRo.js} +1 -1
  44. package/dist/assets/channel-DI8VRWh8.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-CWyPtK1A.js → chunk-2Q5K7J3B-DwRap1YG.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-9TUKrWnK.js → chunk-5VM5RSS4-BO6BTUz7.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-BuS8SrgG.js → chunk-7TKQ45FW-B2VKEfok.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-Dk5YbrgG.js → chunk-AW2ZBBNX-C7vsX4VD.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-BOHI0PLC.js → chunk-FVRAUYC3-CIjSXjvq.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-BhOe_Asb.js → chunk-HTAEGDNF-CCWLt9W1.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-DpdE33ha.js → chunk-JWPE2WC7-CYUijN37.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-BKrqCv6E.js → chunk-KQW6MTUR-D0cFTyVc.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-DCtiPQRh.js → chunk-XXDRQBXY-CE20wx8I.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-CcvlrXAv.js → classDiagram-v2-K4WV4PDN-QBcA1FUG.js} +1 -1
  55. package/dist/assets/{coins-f9Jgj0XN.js → coins-CQDndxZe.js} +1 -1
  56. package/dist/assets/{core-DwZ-6t3T.js → core-D0gGNfT3.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-Dit08QEU.js → cose-bilkent-JH36ORCC-CPygoF45.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-O10owGR5.js → cynefin-EF2NZ3EQ-DjRSXXUK.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-CpgcavYU.js → cynefinDiagram-3GCD6N5R-C4D5WdA1.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-CmTx4ZjS.js → dagre-W4DXFKR2-CwHowYoX.js} +1 -1
  61. package/dist/assets/de-XojPh3_p.js +8 -0
  62. package/dist/assets/{diagram-2UJZ2QOL-BFHXsDIJ.js → diagram-2UJZ2QOL-IOgxIe2m.js} +1 -1
  63. package/dist/assets/{diagram-OVF4WLC6-CZ74iqIL.js → diagram-OVF4WLC6-6M2t3aC-.js} +1 -1
  64. package/dist/assets/{diagram-PFPMY2P6-BuiXUUqv.js → diagram-PFPMY2P6-C3MDtWX5.js} +1 -1
  65. package/dist/assets/{diagram-UMYRVEAY-BwgwA-S_.js → diagram-UMYRVEAY-CpXR83ix.js} +1 -1
  66. package/dist/assets/{diagram-YEKJPTXX-BQxBSIxq.js → diagram-YEKJPTXX-DF58kzII.js} +1 -1
  67. package/dist/assets/{diagram-ZIFT7M5P-iszgLJDV.js → diagram-ZIFT7M5P-BTWYDC1S.js} +1 -1
  68. package/dist/assets/{ebnfDiagram-VR2GEFS7-CRrBAw1T.js → ebnfDiagram-VR2GEFS7-DWMxXTtf.js} +1 -1
  69. package/dist/assets/{elk-IJKZMXRS-Dc3d63wO.js → elk-IJKZMXRS-ZDF01LK0.js} +1 -1
  70. package/dist/assets/{erDiagram-O2IAPWRE-C11f6UUK.js → erDiagram-O2IAPWRE-DKeRGnUv.js} +1 -1
  71. package/dist/assets/es-C0MD2HR1.js +6 -0
  72. package/dist/assets/{file-up-lwoMEra2.js → file-up-Cr20e4wl.js} +1 -1
  73. package/dist/assets/{flowDiagram-OXPTDLAJ-BmMit3lF.js → flowDiagram-OXPTDLAJ-BTJVRu9A.js} +1 -1
  74. package/dist/assets/fr-hktiWwtw.js +8 -0
  75. package/dist/assets/{ganttDiagram-R7TSEDQI-CT8fRN6Y.js → ganttDiagram-R7TSEDQI-BrBIiPkW.js} +1 -1
  76. package/dist/assets/{gitGraphDiagram-XJZIOB7I-DvAYKkDb.js → gitGraphDiagram-XJZIOB7I-xBYIjsc8.js} +1 -1
  77. package/dist/assets/hi-D_Yu59YK.js +1 -0
  78. package/dist/assets/import-name-CdyBVR45.js +1 -0
  79. package/dist/assets/{index-DG9s9Udu.js → index-DwYETevf.js} +3 -3
  80. package/dist/assets/{index-BOb2rx-6.js → index-ShhUWigV.js} +1 -1
  81. package/dist/assets/{infoDiagram-5W2HQ5XZ-DMEwquFk.js → infoDiagram-5W2HQ5XZ-B-FCUMEX.js} +1 -1
  82. package/dist/assets/{ishikawaDiagram-K3B6WC7H-B9IDfo_w.js → ishikawaDiagram-K3B6WC7H-DxhcI9nM.js} +1 -1
  83. package/dist/assets/it-zbTil6cI.js +13 -0
  84. package/dist/assets/ja-CtqaLHju.js +13 -0
  85. package/dist/assets/{journeyDiagram-COXZFDF6-CYBJUt3n.js → journeyDiagram-COXZFDF6-DSwqQn-4.js} +1 -1
  86. package/dist/assets/{kanban-definition-P3RFRI5V-CQW0b1vQ.js → kanban-definition-P3RFRI5V-Bidc1dLu.js} +1 -1
  87. package/dist/assets/ko-DrT-vz1y.js +13 -0
  88. package/dist/assets/{mcp-servers-Df95Ak35.js → mcp-servers-scq4KvN-.js} +1 -1
  89. package/dist/assets/{mermaid.core-BoAXi-iX.js → mermaid.core-1-GuV68k.js} +4 -4
  90. package/dist/assets/{mindmap-definition-LZFPQGKD-Oi2DK1e4.js → mindmap-definition-LZFPQGKD-BtlXbTTm.js} +1 -1
  91. package/dist/assets/{minimize-D0TLCKPp.js → minimize-CoPseS7J.js} +1 -1
  92. package/dist/assets/{monitor-D-xUF55E.js → monitor-B9eyPPw6.js} +1 -1
  93. package/dist/assets/new-bot-CNLntcgn.js +2 -0
  94. package/dist/assets/{org-library-Bpyraw8S.js → org-library-CyWov7QW.js} +1 -1
  95. package/dist/assets/{package-format-ncy2hbCF.js → package-format-Dx-xCjWb.js} +1 -1
  96. package/dist/assets/{pegDiagram-BGZESJAR-C3t3De6_.js → pegDiagram-BGZESJAR-uFZWnUng.js} +1 -1
  97. package/dist/assets/{pieDiagram-CAPJLFHJ-kRPnwN37.js → pieDiagram-CAPJLFHJ-B2Itft-D.js} +1 -1
  98. package/dist/assets/{pl-DYcpmSsp.js → pl-BaR1MZm6.js} +1 -1
  99. package/dist/assets/pt-br-mFy7aZD6.js +13 -0
  100. package/dist/assets/{quadrantDiagram-GDMTTRAM-Cipz55iU.js → quadrantDiagram-GDMTTRAM-Btivs4tR.js} +1 -1
  101. package/dist/assets/{rail-FyQpKAyh.js → rail-ar9TQRSE.js} +1 -1
  102. package/dist/assets/{railroadDiagram-SM67HX2B-l49ZhYVX.js → railroadDiagram-SM67HX2B-92CU8YQH.js} +1 -1
  103. package/dist/assets/{remote-desktop-panel-OlvMKUOn.js → remote-desktop-panel-BrVUx9qj.js} +1 -1
  104. package/dist/assets/{requirementDiagram-X7JNWC4A-CecvERDF.js → requirementDiagram-X7JNWC4A-5izSc7xN.js} +1 -1
  105. package/dist/assets/ru-BJ0ARJtn.js +13 -0
  106. package/dist/assets/{sankeyDiagram-UM26HJRW-DRZqZqLO.js → sankeyDiagram-UM26HJRW-DPnrZSB2.js} +1 -1
  107. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-CIew_Hl6.js → sequenceDiagram-ZO4K6R2Y-Bda0M6Hv.js} +1 -1
  108. package/dist/assets/{sizeCapture-INFHLROL-BbjJkaP6.js → sizeCapture-INFHLROL-DKRN8tPD.js} +1 -1
  109. package/dist/assets/{stateDiagram-v2-TBUQTH76-DN-g5bKL.js → stateDiagram-v2-TBUQTH76-D6MqFrrx.js} +1 -1
  110. package/dist/assets/{styles-DDktIAU-.js → styles-DOwrpvZY.js} +2 -2
  111. package/dist/assets/{swimlanes-N4OXWK64-Bu_DsU2s.js → swimlanes-N4OXWK64-D_pFpyCW.js} +1 -1
  112. package/dist/assets/swimlanesDiagram-K3J5GTZL-D6oFbwqj.js +8 -0
  113. package/dist/assets/{team-share-DxBljvTu.js → team-share-CS8lXIGF.js} +1 -1
  114. package/dist/assets/{timeline-definition-YOQAKGHF-B0HmDrNc.js → timeline-definition-YOQAKGHF-CsXwhMm7.js} +1 -1
  115. package/dist/assets/tr-DnXBUn9-.js +6 -0
  116. package/dist/assets/uk-RZHdJ2pL.js +1 -0
  117. package/dist/assets/{usecaseDiagram-VIAY4XPW-B-vm9Zaa.js → usecaseDiagram-VIAY4XPW-XU2vytSZ.js} +1 -1
  118. package/dist/assets/{vennDiagram-BLWOH2XV-BuRzEMGb.js → vennDiagram-BLWOH2XV-beqZKO-E.js} +1 -1
  119. package/dist/assets/vi-Bx9YsUag.js +15 -0
  120. package/dist/assets/{wardleyDiagram-YMQ3BMBF-COs2BbYB.js → wardleyDiagram-YMQ3BMBF-Ci5sPNvX.js} +1 -1
  121. package/dist/assets/{xychartDiagram-TAQBALBS-DV0zxl6v.js → xychartDiagram-TAQBALBS-BCJ2N2BY.js} +1 -1
  122. package/dist/assets/zh-DMiI3Rx1.js +13 -0
  123. package/dist/assets/zh-tw-DoGBLWPr.js +13 -0
  124. package/dist/index.html +2 -2
  125. package/dist/rail.html +4 -4
  126. package/dist-server/index.js +1320 -1246
  127. package/dist-server/openmausbot.js +1 -1
  128. package/dist-server/package.json +1 -1
  129. package/dist-server/server/chief-templates.js +4 -3
  130. package/dist-server/server/container-computer.js +1 -1
  131. package/dist-server/server/index.js +4 -2
  132. package/dist-server/server/industry-teams.js +20 -19
  133. package/dist-server/server/limix-factory.js +17 -0
  134. package/dist-server/server/limix-skill-store.js +8 -5
  135. package/dist-server/server/routes/bot-skills.js +2 -2
  136. package/dist-server/server/routes/bots-create.js +1 -1
  137. package/dist-server/server/routes/teams.js +2 -2
  138. package/dist-server/shared/industry-display.js +24 -0
  139. package/dist-server/shared/industry-display.json +782 -0
  140. package/dist-server/shared/industry-templates.js +37 -22
  141. package/dist-server/shared/ready-bots.js +2 -2
  142. package/dist-server/skills/industry-customer-care/assets/industry-profiles.json +400 -210
  143. package/package.json +1 -1
  144. package/skills/industry-customer-care/assets/industry-profiles.json +400 -210
  145. package/skills/limix-bot-factory/SKILL.md +98 -0
  146. package/skills/limix-bot-factory/agents/openai.yaml +3 -0
  147. package/skills/limix-bot-factory/assets/capabilities.json +102 -0
  148. package/skills/limix-bot-factory/assets/evaluations/policy-scenarios.json +21 -0
  149. package/skills/limix-bot-factory/assets/hybrid-policy.json +10 -0
  150. package/skills/limix-bot-factory/assets/schemas/bot-spec.schema.json +333 -0
  151. package/skills/limix-bot-factory/assets/templates/appointment-booking.json +65 -0
  152. package/skills/limix-bot-factory/assets/templates/custom-agent.json +56 -0
  153. package/skills/limix-bot-factory/assets/templates/customer-support.json +68 -0
  154. package/skills/limix-bot-factory/assets/templates/order-tracking.json +65 -0
  155. package/skills/limix-bot-factory/assets/templates/research-assistant.json +67 -0
  156. package/skills/limix-bot-factory/assets/templates/sales-advisor.json +72 -0
  157. package/skills/limix-bot-factory/assets/templates/social-content.json +71 -0
  158. package/skills/limix-bot-factory/assets/ui-catalog.json +57 -0
  159. package/skills/limix-bot-factory/manifest.json +18 -0
  160. package/skills/limix-bot-factory/references/bot-evaluations.md +24 -0
  161. package/skills/limix-bot-factory/references/hybrid-skills-contract.md +46 -0
  162. package/skills/limix-bot-factory/references/integration-blueprint.md +62 -0
  163. package/skills/limix-bot-factory/references/security-contract.md +34 -0
  164. package/skills/limix-bot-factory/references/template-workflow.md +48 -0
  165. package/skills/limix-bot-factory/references/vi.md +24 -0
  166. package/skills/limix-bot-factory/scripts/bot_factory.py +6 -0
  167. package/skills/limix-bot-factory/scripts/factorylib/__init__.py +2 -0
  168. package/skills/limix-bot-factory/scripts/factorylib/cli.py +125 -0
  169. package/skills/limix-bot-factory/scripts/factorylib/core.py +221 -0
  170. package/skills/limix-bot-factory/scripts/factorylib/engine.py +148 -0
  171. package/skills/limix-bot-factory/scripts/factorylib/hybrid.py +211 -0
  172. package/skills/limix-bot-factory/scripts/factorylib/policy.py +23 -0
  173. package/skills/limix-bot-factory/scripts/factorylib/stdio.py +67 -0
  174. package/skills/limix-bot-factory/scripts/mcp_server.py +117 -0
  175. package/dist/assets/CloudAddDialog-CaHBgG59.js +0 -1
  176. package/dist/assets/NewBotDialog-RhcfXb6u.js +0 -1
  177. package/dist/assets/PlacesRail-BV7okmUJ.js +0 -1
  178. package/dist/assets/TeamLibraryPanel-DkWnCUJV.js +0 -3
  179. package/dist/assets/VisibilitySection-5EOhD7ux.js +0 -22
  180. package/dist/assets/channel-bk2QY8J7.js +0 -1
  181. package/dist/assets/de-DSdUUIw0.js +0 -8
  182. package/dist/assets/es-BHqvB5c_.js +0 -6
  183. package/dist/assets/fr-BYea3ESR.js +0 -8
  184. package/dist/assets/hi-BAQE8TUj.js +0 -1
  185. package/dist/assets/import-name-DBpLwcMu.js +0 -1
  186. package/dist/assets/it-CgoFnT6M.js +0 -13
  187. package/dist/assets/ja-DL0zdFOr.js +0 -13
  188. package/dist/assets/ko-l7Fk0h22.js +0 -13
  189. package/dist/assets/new-bot-BWni80X3.js +0 -2
  190. package/dist/assets/pt-br-DTFokgJS.js +0 -13
  191. package/dist/assets/ru-ChGJdG-8.js +0 -13
  192. package/dist/assets/swimlanesDiagram-K3J5GTZL-g_8BdGfC.js +0 -8
  193. package/dist/assets/tr-DxJLR15s.js +0 -6
  194. package/dist/assets/uk-s288K1L0.js +0 -1
  195. package/dist/assets/vi-BWNMeqV0.js +0 -15
  196. package/dist/assets/zh-B1nJITne.js +0 -13
  197. package/dist/assets/zh-tw-VV_w2o3x.js +0 -13
@@ -1 +1 @@
1
- import{j as e,t,a as S,i as ie,d as he,r as m,X as be,C as fe,n as Ae,S as Re}from"./styles-DDktIAU-.js";import{C as Ee,K as ze,B as Te,c as Me,d as Le,P as ce,V as Oe}from"./PlacesRail-BV7okmUJ.js";import{cv as ge,cw as Pe,cx as Fe,cy as oe,Y as $e,u as H,cz as We,cA as Ye,cB as ee,cC as ye,cD as de,cE as _e,cF as ke,cG as He,cH as Ue,cI as Ge,cJ as Je,bw as Ke,cK as Qe,cL as je,cM as ue,cN as qe,cO as Ve,T as Xe,cP as Ze,cQ as et,cR as Z,cS as ve,cn as we,cT as tt,cU as ne,cV as st,cW as nt,cX as Ne,j as W,cY as Ce,cZ as at,c_ as it,c$ as ot,d0 as xe,d1 as rt,d2 as lt,d3 as dt,d4 as ct,w as re,C as ut,d5 as xt,bO as pt,d6 as mt,bM as ht,d7 as bt,d8 as ft,S as Se,d9 as gt,da as yt}from"./App-BUF9rx3_.js";import{AppEventEditor as kt}from"./AppEventEditor-D2yq1wkA.js";import{C as Ie,S as jt}from"./MenuMotion-Dv-G0PKg.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-4bH5oJ-7.js";import{WebhookEditor as Bt}from"./WebhookTrigger-BwBskWF-.js";import"./monitor-D-xUF55E.js";import"./index-DG9s9Udu.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-BATr7O3z.js";const le="\0general";function Dt(n,r){const l=n.filter(h=>!h.hidden),g=new Set(l.map(h=>h.section).filter(h=>!!h));return{names:r.filter(h=>g.has(h)),hasGeneral:l.some(h=>!h.section)}}function te(n,r){return r==="all"?!0:n?r===le?!n.section:n.section===r:!1}function At({trigger:n}){const{attempts:r,service:l}=ge(),g=r.filter(o=>o.triggerId===n.id).slice(-6).reverse(),h=Pe(n);return e.jsxs("section",{"data-app-events":n.id,children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.events")}),h&&e.jsx("p",{className:"mb-2 rounded-lg bg-warning/10 px-2.5 py-1.5 text-[12px] text-warning",children:h}),g.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noEvents")}):e.jsx("ul",{className:"space-y-1",children:g.map(o=>{const b=Fe(o),p=oe(o.at);return e.jsxs("li",{className:"flex items-baseline gap-2 px-2 py-1 text-[13px]",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:p.charAt(0).toLocaleUpperCase()+p.slice(1)}),e.jsx("span",{className:S("shrink-0 font-semibold",b.mark==="✓"?"text-success":b.mark==="✗"?"text-danger":"text-ink-tertiary"),children:b.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",title:b.text,children:b.text})]},o.id)})}),l?.eventsPerDay&&e.jsx("p",{className:"mt-2 text-[11px] text-ink-tertiary",children:t("automations.app.limit",{count:l.eventsPerDay.toLocaleString(ie()),place:t(l.plan==="cloud"?"automations.app.placeCloud":"automations.app.placeDesktop")})})]})}function Be({status:n,className:r}){return n.state==="needs-you"?e.jsx($e,{size:15,"aria-hidden":"true",className:S("shrink-0 text-warning",r)}):n.state==="done"?e.jsx(he,{size:14,"aria-hidden":"true",className:S("shrink-0 text-ink-tertiary",r)}):e.jsx("span",{"aria-hidden":"true",className:S("size-2.5 shrink-0 rounded-full",n.state==="working"?"bg-success":"bg-ink-tertiary/60",r)})}function De({automation:n,status:r,actions:l,onEdit:g,className:h}){const{dispatch:o}=H();if(r.state!=="needs-you"||!r.fix)return null;const b=r.fix,p=b==="answer"?We(n.runs):void 0,i=()=>{b==="answer"?l.openRun(n,p):b==="sign-in"?l.openRun(n,n.runs.find(x=>x.status!=="queued")):b==="usage"?o({type:"toggleAppSettings",open:!0,section:"usage"}):b==="edit"?g():b==="reconnect"?o({type:"togglePlugins",open:!0,surface:"apps"}):l.runNow(n)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:i,disabled:!!l.busy,className:S("shrink-0 rounded-lg bg-warning/15 px-2.5 py-1 text-[12px] font-medium text-warning hover:bg-warning/25 disabled:opacity-50",h),children:t(Ye[b])}),p&&e.jsx("button",{type:"button","data-automation-cancel-run":!0,onClick:()=>{l.cancelRun(n,p)},disabled:!!l.busy,className:S("shrink-0 rounded-lg px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",h),children:t("routines.drawer.cancelRun")})]})}const Rt=5,q="flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[13px] font-medium disabled:opacity-50";function Et({automation:n,sentence:r,onClose:l,onEdit:g,onDeleted:h}){const{state:o,dispatch:b}=H(),[p]=m.useState(()=>new Set(n.runs.filter(u=>ee(u)&&!u.seenAt).map(u=>u.id))),i=n.runs.filter((u,C)=>C<Rt||p.has(u.id)||ee(u)&&!u.seenAt);m.useEffect(()=>{for(const u of n.runs)ee(u)&&!u.seenAt&&b({type:"markRoutineRunSeen",runId:u.id})},[n.runs,b]);const x=ye(),j=de(n),f=n.kind==="webhook"?o.webhooks.find(u=>u.id===n.id):void 0,v=f?_e(ke())[f.id]:void 0,y=o.webhookIngress?.available!==!1,N=t(He[j.state]),w=n.name.trim(),R=o.bots.find(u=>u.id===n.botId)?.name??t("routines.unavailableBot"),B=n.instructions.trim(),c=j.state==="done"?t("automations.reason.done"):j.reason,I=f?Ue(f.id,o.webhookAttempts):[],T=f?Ge(f,o.webhookAttempts):null,[A,Y]=m.useState(null),[M,D]=m.useState(!1),[E,_]=m.useState(!1),z=async u=>{if(await ze(u)!=="copied"){x.setError(t("automations.address.copyFailed"));return}_(!0),setTimeout(()=>_(!1),1800)};return e.jsxs("aside",{"aria-label":t("automations.panel.label"),className:"flex h-full w-[min(380px,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-5 py-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-[16px] font-semibold leading-snug text-ink",children:w||r}),w&&e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:Je(n,R)})]}),e.jsx("button",{type:"button",onClick:l,className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("automations.panel.close"),children:e.jsx(be,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]","data-automation-status":j.state,children:[e.jsx(Be,{status:j}),e.jsx("span",{className:S("font-medium",j.state==="needs-you"?"text-warning":"text-ink"),children:N}),c&&e.jsx("span",{className:"min-w-0 text-ink-secondary",children:c}),e.jsx(De,{automation:n,status:j,actions:x,onEdit:g})]}),f&&e.jsxs("section",{className:"rounded-xl border border-hairline/45 bg-inset/50 p-3.5",children:[e.jsx("h3",{className:"text-[13px] font-medium text-ink",children:t("automations.address.title")}),e.jsxs("button",{type:"button",disabled:!!x.busy||!y,onClick:()=>{x.copyAddress(f.id)},className:S(q,"mt-2.5 bg-accent text-accent-ink hover:brightness-110"),children:[x.copied===f.id?e.jsx(he,{size:14}):e.jsx(Ee,{size:14}),x.copied===f.id?t("automations.address.copied"):t("automations.address.copy")]}),(!y||!o.config?.cloudHome)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:y?t("automations.address.keepOpen"):t("automations.address.unavailable")}),e.jsxs("details",{className:"mt-2.5 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer select-none font-medium text-ink-secondary hover:text-ink",children:t("automations.more")}),e.jsxs("div",{className:"mt-2 space-y-2 leading-relaxed",children:[T&&e.jsxs("section",{"aria-label":t("automations.received.title"),children:[e.jsxs("p",{className:"font-medium text-ink",children:[t("automations.received.title")," · ",oe(T.at)]}),e.jsx("p",{className:"mt-0.5",children:t("automations.received.help")}),e.jsx("pre",{className:"mt-1.5 max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-inset px-2.5 py-2 font-mono text-[11px] text-ink",children:T.preview.slice(0,1e3)})]}),e.jsxs("section",{"aria-label":t("automations.calls.title"),children:[e.jsx("p",{className:"font-medium text-ink",children:t("automations.calls.title")}),I.length===0?e.jsx("p",{className:"mt-0.5",children:t("automations.calls.none")}):e.jsx("ul",{className:"mt-1 space-y-0.5",children:I.map(u=>e.jsxs("li",{"data-call":u.ok?"ok":"refused",children:[e.jsxs("button",{type:"button","aria-expanded":A===u.id,onClick:()=>Y(C=>C===u.id?null:u.id),className:"flex w-full items-baseline gap-2 rounded-md px-1.5 py-1 text-left hover:bg-raised",children:[e.jsx("span",{className:"shrink-0",children:Ke(oe(u.at))}),e.jsx("span",{className:S("shrink-0 font-semibold",u.ok?"text-success":"text-danger"),children:u.ok?"✓":"✗"}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:u.reason})]}),A===u.id&&e.jsx("pre",{className:"mx-1.5 mb-1 whitespace-pre-wrap break-all rounded-md bg-inset px-2 py-1.5 font-mono text-[11px] text-ink",children:u.preview||t("automations.calls.empty")})]},u.id))})]}),e.jsx("p",{className:"font-medium text-ink",children:t("automations.address.showSecret")}),v?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1","data-secret":M?"shown":"masked",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[11px]",children:t("automations.address.secret",{secret:M?v.secret:"••••••••"})}),e.jsx("button",{type:"button","aria-label":t(M?"automations.address.hideSecretLabel":"automations.address.showSecretLabel"),onClick:()=>D(u=>!u),className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:t(M?"automations.address.hideSecret":"automations.address.revealSecret")}),e.jsx("button",{type:"button","aria-label":t("automations.address.copySecretLabel"),onClick:()=>{z(v.secret)},className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:E?t("automations.address.copied"):t("automations.address.copySecret")})]}):e.jsx("p",{className:"break-all font-mono text-[11px]",children:t("automations.address.secretUnknown")}),e.jsx("p",{children:t("automations.address.header")}),f.eventTypes?.length?e.jsx("p",{children:t("automations.address.events",{events:f.eventTypes.join(", ")})}):null,e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{window.confirm(t("automations.address.replaceConfirm"))&&x.copyAddress(f.id,!0)},className:"flex items-center gap-1.5 rounded-lg border border-hairline/50 px-2.5 py-1.5 text-ink hover:bg-raised",children:[e.jsx(Qe,{size:12}),t("automations.address.replace")]})]})]})]}),w&&B&&e.jsx("p",{"data-testid":"automation-instructions",className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed text-ink",children:B}),n.appTrigger&&e.jsx(At,{trigger:n.appTrigger}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.recent")}),n.runs.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noRuns")}):e.jsx("ul",{className:"space-y-1",children:i.map(u=>{const C=je(u);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!u.threadId,onClick:()=>x.openRun(n,u),title:u.threadId?t("automations.panel.open"):void 0,className:"flex w-full items-baseline gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] hover:bg-raised disabled:hover:bg-transparent",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:C.when}),e.jsx("span",{className:S("shrink-0 font-semibold",C.mark==="✓"?"text-success":C.mark==="✗"?"text-danger":"text-warning"),children:C.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:C.text})]})},u.id)})})]}),x.error&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:x.error})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 border-t border-hairline/40 px-5 py-3.5",children:[e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.runNow(n)},className:S(q,"bg-accent text-accent-ink hover:brightness-110"),children:[e.jsx(ue,{size:14}),x.busy===`run:${n.id}`?t("automations.starting"):t("automations.runNow")]}),j.state!=="done"&&e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.toggle(n)},className:S(q,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[n.enabled?e.jsx(qe,{size:14}):e.jsx(ue,{size:14}),n.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:g,className:S(q,"text-ink hover:bg-raised"),children:[e.jsx(Ve,{size:14}),t("automations.edit")]}),e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.remove(n,t("automations.deleteConfirm",{sentence:r})).then(u=>{u&&h()})},className:S(q,"text-danger hover:bg-danger/10"),children:[e.jsx(Xe,{size:14}),t("automations.delete")]})]})]})}const zt=()=>Array.from({length:7},(n,r)=>new Intl.DateTimeFormat(Ae(),{weekday:"narrow",timeZone:"UTC"}).format(Date.UTC(2023,0,2+r)));function ae(n){const r=new Date(n);return new Date(r.getFullYear(),r.getMonth(),1)}function pe(n,r){return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function me(n,r){return new Date(n.getFullYear(),n.getMonth()+r,1)}function Tt({anchor:n,onSelect:r}){const[l,g]=m.useState(()=>ae(n));m.useEffect(()=>{g(ae(n))},[n]);const h=m.useMemo(()=>{const i=ae(l),x=(i.getDay()+6)%7,j=new Date(i);return j.setDate(i.getDate()-x),Array.from({length:42},(f,v)=>{const y=new Date(j);return y.setDate(j.getDate()+v),y})},[l]),o=new Date(n),b=new Date,p=l.toLocaleDateString(ie(),{month:"long",year:"numeric"});return e.jsxs("section",{"aria-label":t("routines.miniCalendar.label"),className:"select-none px-3 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsx("div",{className:"text-[13px] font-semibold text-ink",children:p}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,-1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.previous"),children:e.jsx(fe,{size:15,"aria-hidden":"true"})}),e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.next"),children:e.jsx(Ie,{size:15,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"grid grid-cols-7","aria-hidden":"true",children:zt().map((i,x)=>e.jsx("div",{className:"flex h-6 items-center justify-center text-[9px] font-semibold uppercase tracking-[0.08em] text-ink-tertiary",children:i},`${i}-${x}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:h.map(i=>{const x=pe(i,o),j=pe(i,b),f=i.getMonth()!==l.getMonth(),v=i.toLocaleDateString(ie(),{weekday:"long",month:"long",day:"numeric",year:"numeric"});return e.jsx("button",{type:"button",onClick:()=>r(i.getTime()),"aria-label":v,"aria-current":j?"date":void 0,"aria-pressed":x,className:"group flex h-7 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60",children:e.jsx("span",{className:`flex size-6 items-center justify-center rounded-full text-[11px] transition-colors ${x?"bg-accent font-semibold text-white shadow-sm":j?"font-semibold text-accent group-hover:bg-accent/12":f?"text-ink-tertiary group-hover:bg-raised group-hover:text-ink":"text-ink group-hover:bg-raised"}`,children:i.getDate()})},`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`)})})]})}const Mt="application/x-openmaus-bot";function Lt({bots:n,anchor:r,onSelectDate:l}){const[g,h]=m.useState(""),o=m.useMemo(()=>{const p=g.trim().toLocaleLowerCase();return p?n.filter(i=>`${i.name} ${i.title} ${i.description}`.toLocaleLowerCase().includes(p)):n},[n,g]),b=(p,i)=>{p.dataTransfer.effectAllowed="copy",p.dataTransfer.setData(Mt,i.id),p.dataTransfer.setData("text/plain",i.id)};return e.jsxs("aside",{"aria-label":t("routines.sidebar.label"),className:"flex h-full w-[320px] shrink-0 flex-col overflow-hidden border-r border-hairline/40 bg-panel",children:[e.jsx(Tt,{anchor:r,onSelect:l}),e.jsx("div",{className:"mx-4 border-t border-hairline/40"}),e.jsxs("section",{"aria-labelledby":"calendar-bots-heading",className:"flex min-h-0 flex-1 flex-col px-3 pb-3 pt-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsxs("div",{id:"calendar-bots-heading",className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.11em] text-ink-secondary",children:[e.jsx(Ze,{size:13,"aria-hidden":"true"}),t("routines.sidebar.myBots")]}),e.jsx("span",{className:"rounded-full bg-raised px-1.5 py-0.5 text-[9px] tabular-nums text-ink-secondary",children:n.length})]}),e.jsxs("label",{className:"relative mb-2 block",children:[e.jsx("span",{className:"sr-only",children:t("routines.sidebar.searchBots")}),e.jsx(Re,{size:13,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-tertiary","aria-hidden":"true"}),e.jsx("input",{value:g,onChange:p=>h(p.target.value),type:"search",placeholder:t("routines.sidebar.searchBots"),className:"h-8 w-full rounded-lg border border-hairline/45 bg-control/55 pl-8 pr-2.5 text-[12px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/60 focus:bg-control"})]}),e.jsxs("div",{role:"list","aria-label":t("routines.sidebar.availableBots"),className:"min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-0.5",children:[o.map(p=>e.jsxs("div",{draggable:!0,onDragStart:i=>b(i,p),role:"listitem",className:"group flex cursor-grab items-center gap-2 rounded-xl px-2 py-2 transition-colors hover:bg-raised/80 active:cursor-grabbing","aria-label":t("routines.sidebar.dragBot",{name:p.name}),title:t("routines.sidebar.dragBot",{name:p.name}),children:[e.jsx(et,{size:13,className:"shrink-0 text-ink-secondary/35 transition-colors group-hover:text-ink-secondary","aria-hidden":"true"}),e.jsx(Te,{bot:p,size:27,animated:!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-ink",children:p.name}),e.jsx("div",{className:"truncate text-[10px] text-ink-tertiary",children:p.title||t("routines.sidebar.botFallback")})]}),e.jsx("span",{className:"shrink-0 rounded-full border border-hairline/50 px-1.5 py-0.5 text-[9px] text-ink-tertiary opacity-0 transition-opacity group-hover:opacity-100",children:t("routines.sidebar.drag")})]},p.id)),o.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] leading-relaxed text-ink-secondary",children:n.length===0?t("routines.sidebar.noBots"):t("routines.sidebar.noMatch")})]}),e.jsx("p",{className:"mt-2 px-2 text-[10px] leading-relaxed text-ink-tertiary",children:t("routines.sidebar.dragHint")})]})]})}function Ot({botFilter:n,department:r="all",selectedAutomationId:l,onOpenAutomation:g,onOpenRoom:h}){const{state:o,dispatch:b}=H(),p=window.ogb?.remoteClient?.active===!0,[i,x]=m.useState(()=>window.innerWidth<640?1:7),[j,f]=m.useState(()=>Z(Date.now())),[v,y]=m.useState([]),[N,w]=m.useState(null),[R,B]=m.useState(null),[c,I]=m.useState(null),[T,A]=m.useState(""),Y=o.bots.filter(a=>!a.hidden),M=ve(Y,we(),R?.botIds[0]),D=i===7?tt(j):Z(j),E=ne(D,i);st(D);const _=nt(Ne(),D,E),z=m.useCallback(async()=>{try{y((await W("/api/calendar-calls")).calls??[])}catch(a){A(a instanceof Error?a.message:String(a))}},[]);m.useEffect(()=>{p||z()},[z,p]);const u=m.useMemo(()=>{const a=new Set(o.bots.map(k=>k.id)),s=o.routines.filter(k=>a.has(k.botId)),d=new Set(Ce({routines:s,webhooks:[],runs:o.routineRuns}).filter(k=>de(k).state==="needs-you").map(k=>k.id)),P=at(s,o.routineRuns.filter(k=>a.has(k.botId)),D,E).map(k=>({...k,kind:"routine",needsYou:!!(k.routine&&!k.run&&d.has(k.routine.id))})),F=it(v,D,E).map(k=>({...k,kind:"call"})),$=k=>o.bots.find(Q=>Q.id===k);return[...P,...F].filter(k=>k.kind==="call"?k.call.botIds.some(Q=>te($(Q),r)):te($(k.routine?.botId??k.run?.botId),r)).filter(k=>n==="all"||(k.kind==="call"?k.call.botIds.includes(n):(k.routine?.botId??k.run?.botId)===n)).sort((k,Q)=>k.at-Q.at)},[o.routines,o.routineRuns,o.bots,v,D,E,n,r]),C=c?.kind==="call"?(()=>{const a=v.find(s=>s.id===c.call.id);return a?{...c,call:a}:null})():null,U=a=>{if(a.kind==="call"){I(a);return}I(null);const s=a.routine?.id??a.run?.routineId;s&&g(s)},V=a=>g(a.routineId),L=C?.id??u.find(a=>a.kind==="routine"&&(a.routine?.id??a.run?.routineId)===l)?.id,O=a=>y(s=>s.some(d=>d.id===a.id)?s.map(d=>d.id===a.id?a:d):[a,...s]),G=async(a,s)=>{if(s!==a.at)try{if(a.kind==="routine"){const d=o.routines.find(F=>F.id===a.id);if(!d)return;if(d.schedule.type==="cron")throw new Error(t("automations.calendar.cronMove"));if(d.schedule.type!=="once"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/routines/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});b({type:"routinePatched",routine:P.routine})}else{const d=v.find(F=>F.id===a.id);if(!d||d.schedule.type==="daily"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/calendar-calls/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});O(P.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},se=async(a,s)=>{if("botId"in a){I(null),w({kind:"routine",at:s.at,durationMinutes:30,botIds:[a.botId],limitReset:{engine:s.engine}});return}if(a.event.kind!=="routine")return A(t("limits.callNotOnReset"));try{const d=await W(`/api/routines/${a.event.id}`,{method:"PATCH",body:JSON.stringify({schedule:{type:"limit_reset",engine:s.engine,repeat:"once"}})});b({type:"routinePatched",routine:d.routine})}catch(d){A(d instanceof Error?d.message:String(d))}},X=async(a,s)=>{try{if(a.kind==="routine"&&a.routine){const d=await W(`/api/routines/${a.routine.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});b({type:"routinePatched",routine:d.routine})}else if(a.kind==="call"){const d=await W(`/api/calendar-calls/${a.call.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});O(d.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},J=()=>{C&&(B({kind:"call",at:C.at,durationMinutes:C.call.durationMinutes,botIds:C.call.botIds,call:C.call}),I(null))},K=a=>S("rounded-md px-3 py-1 text-[12px] font-medium",a?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink");return e.jsxs("div",{className:"@container/routines relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-hairline/30 px-4 py-2",children:[e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,-i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.previous"),children:e.jsx(fe,{size:16})}),e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.next"),children:e.jsx(Ie,{size:16})}),e.jsx("div",{className:"min-w-0 truncate px-1 text-[14px] font-medium text-ink","aria-live":"polite",children:ot(D,i)}),e.jsx("button",{type:"button",onClick:()=>f(Z(Date.now())),className:"rounded-lg border border-hairline/50 px-2.5 py-1 text-[12px] font-medium text-ink hover:bg-raised",children:t("routines.today")}),e.jsxs("div",{role:"group",className:"ml-auto flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5","aria-label":t("routines.view.label"),children:[e.jsx("button",{type:"button","aria-pressed":i===1,onClick:()=>x(1),className:K(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>x(7),className:K(i===7),children:t("routines.view.week")})]}),T&&e.jsx("button",{type:"button",onClick:()=>A(""),className:"w-full text-left text-[12px] text-danger",children:T})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[!C&&e.jsx("div",{className:"hidden shrink-0 @min-[1040px]/routines:block",children:e.jsx(Lt,{bots:Y,anchor:j,onSelectDate:a=>f(Z(a))})}),e.jsx(vt,{anchor:D,days:i,items:u,bots:o.bots,groups:o.groups,selectedId:L,onOpen:U,onCreate:a=>{I(null),w(a)},onMove:(a,s)=>{G(a,s)},onResize:(a,s)=>{X(a,s)},markers:_,onDropOnReset:(a,s)=>{se(a,s)}}),C&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl @min-[760px]/routines:static @min-[760px]/routines:shadow-none",children:e.jsx(wt,{item:C,bots:o.bots,onClose:()=>I(null),onEdit:J,onOpenRun:V,onCallChanged:a=>{a?y(s=>s.filter(d=>d.id!==a)):z()},onOpenRoom:h},`${C.kind}:${C.id}`)})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/25",onMouseDown:()=>w(null)}),e.jsx(Nt,{seed:N,bots:M,routinesOnly:p,onClose:()=>w(null),onMore:a=>{w(null),B(a)},onSavedRoutine:a=>b({type:"routinePatched",routine:a}),onSavedCall:O})]}),R&&e.jsx(Ct,{seed:R,bots:M,routinesOnly:p,onClose:()=>B(null),onSavedCall:O})]})}function Pt({botFilter:n="all"}){const{state:r,dispatch:l}=H(),g=rt(Ne()),[h,o]=m.useState(null),[b,p]=m.useState(null),[i,x]=m.useState("");if(!g.length)return null;const j=y=>r.bots.find(N=>N.id===y)?.modelSelection?.instanceId,f=r.routines.filter(y=>n==="all"||y.botId===n),v=async(y,N)=>{o(y.engine),x("");try{for(const w of N){const R=await W("/api/limit-resets/after-reset",{method:"POST",body:JSON.stringify({routineId:w.id,engine:y.engine})});l({type:"routinePatched",routine:R.routine})}p(y.engine)}catch(w){x(w instanceof Error?w.message:String(w))}finally{o(null)}};return e.jsxs("section",{"aria-label":t("limits.title"),className:"mb-4 space-y-2",children:[g.map(y=>{const N=lt(f,j,y);return e.jsxs("div",{"data-limit-warning":y.engine,role:"status",className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 rounded-xl border border-warning/40 bg-warning/10 px-3.5 py-2.5 text-[13px] text-ink",children:[e.jsx(St,{size:15,className:"shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{className:"font-medium tabular-nums",children:dt(y)}),N.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-secondary",children:t(N.length===1?"limits.dueOne":"limits.dueMany",{count:N.length})}),e.jsx("button",{type:"button",disabled:h===y.engine,onClick:()=>{v(y,N)},className:"ml-auto rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",children:t("limits.moveAfterReset")})]}):b===y.engine&&e.jsx("span",{className:"text-ink-secondary",children:t("limits.moved")})]},y.engine)}),i&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:i})]})}function Ft(n,r){const l=n.find(h=>h.id===r);if(l)return l;const g=h=>h.messages.at(-1)?.at??0;return[...n].sort((h,o)=>g(o)-g(h))[0]}function $t({initialText:n="",onClose:r,onSetUpYourself:l}){const{state:g,dispatch:h}=H(),o=g.bots.filter(c=>!c.hidden),[b,p]=m.useState(n),[i,x]=m.useState(()=>Ft(o,g.selectedId)?.id??""),[j,f]=m.useState(!1),[v,y]=m.useState("schedule"),N=m.useRef(null);Me(N,r);const w=o.find(c=>c.id===i),R=()=>{const c=b.trim();!c||!w||(h({type:"select",id:w.id}),h({type:"send",botId:w.id,text:c,threadId:w.threadId}),r())},B=(c,I,T)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":v===c,onClick:()=>y(c),className:S("flex w-full items-center gap-3 rounded-xl border px-3.5 py-3 text-left text-[14px]",v===c?"border-accent/70 bg-accent/10 text-ink":"border-hairline/50 text-ink-secondary hover:bg-raised"),children:[e.jsx(T,{size:16,className:"shrink-0 text-accent"}),I]});return e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-5 pt-[14vh] backdrop-blur-sm",onMouseDown:c=>c.stopPropagation(),children:e.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-label":t("automations.newBox.title"),tabIndex:-1,className:"w-full max-w-[560px] rounded-2xl border border-hairline/60 bg-panel p-5 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:j?t("automations.newBox.when"):t("automations.newBox.title")}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("automations.newBox.cancel"),className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(be,{size:16})})]}),j?e.jsxs(e.Fragment,{children:[e.jsxs("div",{role:"radiogroup","aria-label":t("automations.newBox.when"),className:"mt-4 space-y-2",children:[B("schedule",t("automations.newBox.onSchedule"),ut),B("app",t("automations.newBox.whenAppEvent"),xt),B("webhook",t("automations.newBox.whenApp"),pt)]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:t("automations.newBox.back")}),e.jsx("button",{type:"button",onClick:()=>l(v,w?.id??""),className:"rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:t("automations.newBox.continue")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{autoFocus:!0,value:b,onChange:c=>p(c.target.value),rows:3,"aria-label":t("automations.newBox.title"),placeholder:t("automations.newBox.placeholder"),onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!ct(c.nativeEvent)&&(c.preventDefault(),R())},className:"mt-4 w-full resize-none rounded-xl border border-hairline/60 bg-inset px-3.5 py-3 text-[14px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/70"}),o.length===0&&e.jsx("p",{className:"mt-2 text-[13px] text-warning",children:t("automations.newBox.noBots")}),o.length>1&&e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink-secondary",children:[t("automations.newBox.bot"),e.jsx(re,{size:"sm",value:i,onChange:c=>x(c.target.value),"aria-label":t("automations.newBox.bot"),className:"max-w-[220px]",children:o.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!0),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline",children:t("automations.newBox.yourself")}),e.jsxs("button",{type:"button",disabled:!b.trim()||!w,onClick:R,className:"flex items-center gap-2 rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-40",children:[e.jsx(jt,{size:14}),t("automations.newBox.send")]})]})]})]})})}const Wt=9;function es({onBack:n,onOpenRoom:r}){const{state:l,dispatch:g}=H(),{capabilities:h}=Le(),o=ye(),b=ge(),p=m.useRef(null),i=l.routinesFocus,x=i?.view==="calendar"?"calendar":"list",[j,f]=m.useState(i?.section!=="logs"?i?.routineId??null:null),[v,y]=m.useState(i?.botId??"all"),[N,w]=m.useState("all"),[R,B]=m.useState(null),[c,I]=m.useState(null),T=window.ogb?.remoteClient?.active===!0,A=l.bots.filter(s=>!s.hidden),Y=we(),M=s=>l.bots.find(d=>d.id===s)?.name??t("routines.unavailableBot");m.useEffect(()=>{y(i?.botId??"all"),i?.routineId&&i.section!=="logs"&&f(i.routineId)},[i]),m.useEffect(()=>{p.current?.focus({preventScroll:!0})},[]);const D=m.useMemo(()=>Ce({routines:l.routines,webhooks:T?[]:l.webhooks,appTriggers:b.triggers,runs:l.routineRuns,bots:l.bots}),[l.routines,l.webhooks,b.triggers,l.routineRuns,l.bots,T]),E=Dt(l.bots,[...new Set([...l.sections??[],...l.bots.flatMap(s=>s.section?[s.section]:[])])]),_=E.names.length+(E.hasGeneral?1:0)>1,z=N==="all"||(N===le?E.hasGeneral:E.names.includes(N))?N:"all";m.useEffect(()=>{z!==N&&(w("all"),y("all"))},[z,N]);const u=s=>te(l.bots.find(d=>d.id===s),z),C=A.filter(s=>te(s,z)),U=D.length>=Wt&&new Set(D.map(s=>s.botId)).size>1,V=mt(D.filter(s=>u(s.botId)&&(!U||v==="all"||s.botId===v))),L=D.find(s=>s.id===j)??null,O=s=>yt(s,M(s.botId)),G=h.windowChrome==="mac-inset",se=G?{WebkitAppRegion:"drag"}:void 0,X=G?{WebkitAppRegion:"no-drag"}:void 0,J=c?.kind==="schedule"?l.routines.find(s=>s.id===c.id):void 0,K=c?.kind==="webhook"?l.webhooks.find(s=>s.id===c.id):void 0,a=c?.kind==="app"?b.triggers.find(s=>s.id===c.id):void 0;return e.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app animate-workspace-in",children:[e.jsx("header",{className:S("shrink-0 border-b border-hairline/35 bg-app py-3 pr-4",G&&!Oe(h)&&x==="calendar"?"pl-[86px]":x==="list"?"pl-12 md:pl-4":"pl-4"),style:se,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",ref:p,onClick:n,"aria-label":t("automations.back"),title:t("automations.back"),className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-raised hover:text-ink",style:X,children:e.jsx(ht,{size:18})}),e.jsx("h1",{"data-tour":"automations-page",className:"mr-1 text-[18px] font-semibold tracking-tight text-ink",children:t("automations.title")}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",style:X,children:[_&&e.jsxs(re,{size:"sm","aria-label":t("automations.allDepartments"),value:z,onChange:s=>{w(s.target.value),y("all")},className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allDepartments")}),E.names.map(s=>e.jsx("option",{value:s,children:s},s)),E.hasGeneral&&e.jsx("option",{value:le,children:t("automations.generalDepartment")})]}),U&&x==="list"&&e.jsxs(re,{size:"sm","aria-label":t("automations.allBots"),value:v,onChange:s=>y(s.target.value),className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allBots")}),C.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]}),e.jsx("div",{role:"group","aria-label":t("automations.view"),className:"flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5",children:["list","calendar"].map(s=>e.jsx("button",{type:"button","aria-pressed":x===s,onClick:()=>g({type:"showRoutines",view:s,botId:v==="all"?void 0:v}),className:S("rounded-md px-3 py-1 text-[13px] font-medium",x===s?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s==="list"?t("automations.list"):t("automations.calendar")},s))}),e.jsxs("button",{type:"button",onClick:()=>B(""),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3.5 py-2 text-[13px] font-semibold text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15,"aria-hidden":"true"}),t("automations.new")]})]})]})}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[x==="calendar"?e.jsx(Ot,{botFilter:v,department:z,selectedAutomationId:j,onOpenAutomation:f,onOpenRoom:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl p-4 sm:p-6",children:[e.jsx(Pt,{botFilter:U?v:"all"}),D.length===0&&l.routinesLoadState!=="loading"&&l.hydrated?e.jsxs("section",{"aria-label":t("automations.empty.title"),className:"px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex size-12 items-center justify-center rounded-2xl bg-accent/10 text-accent",children:e.jsx(bt,{size:22})}),e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:t("automations.empty.title")}),e.jsx("button",{type:"button",onClick:()=>B(t("automations.empty.example")),className:"mt-3 text-[14px] text-accent-text underline-offset-2 hover:underline",children:t("automations.empty.try")}),e.jsx("div",{children:e.jsxs("button",{type:"button",onClick:()=>B(""),className:"mt-6 inline-flex items-center gap-2 rounded-xl bg-accent px-4 py-2.5 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15}),t("automations.new")]})})]}):e.jsx("ul",{"aria-label":t("automations.title"),className:"divide-y divide-hairline/30 overflow-hidden rounded-2xl border border-hairline/40 bg-card",children:V.map(s=>{const d=de(s),P=s.name.trim(),F=s.runs.find(k=>ee(k)&&!k.seenAt),$=F&&je(F);return e.jsxs("li",{"data-automation":s.id,"data-automation-status":d.state,className:S("flex items-start gap-3 px-4 py-3.5",j===s.id&&"bg-raised/60"),children:[e.jsx(Be,{status:d,className:"mt-[5px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>f(s.id),className:"block text-left text-[15px] font-medium leading-snug text-ink hover:text-accent-text",children:P||O(s)}),P&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink",children:O(s)}),d.state==="needs-you"?e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-[13px] text-warning",children:[t("automations.needsYou",{reason:d.reason??""}),e.jsx(De,{automation:s,status:d,actions:o,onEdit:()=>I({kind:s.kind,id:s.id})})]}):e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:ft(s)}),$&&e.jsxs("button",{type:"button",onClick:()=>f(s.id),className:"mt-1 flex items-baseline gap-2 text-left text-[13px] text-danger",children:[e.jsx("span",{"aria-hidden":"true",className:"size-2 shrink-0 self-center rounded-full bg-danger"}),e.jsxs("span",{children:[$.when," ",$.mark," ",$.text]})]}),o.error&&o.errorFor?.endsWith(`:${s.id}`)&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:o.error})]}),d.state!=="done"&&e.jsx(Se,{checked:s.enabled,disabled:o.busy===`toggle:${s.id}`,"aria-label":t("automations.toggle",{name:s.name}),onClick:()=>{o.toggle(s)},className:"mt-0.5 shrink-0"})]},s.id)})}),o.error&&!V.some(s=>o.errorFor?.endsWith(`:${s.id}`))&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:o.error}),e.jsx(Yt,{})]})}),L&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl lg:static lg:shadow-none",children:e.jsx(Et,{automation:L,sentence:O(L),onClose:()=>f(null),onDeleted:()=>f(null),onEdit:()=>I({kind:L.kind,id:L.id})},L.id)})]}),R!==null&&e.jsx($t,{initialText:R,onClose:()=>B(null),onSetUpYourself:(s,d)=>{B(null),I({kind:s,botId:d})}}),c?.kind==="schedule"&&(J||!c.id)&&e.jsx(It,{routine:J,bots:ve(A,Y,J?.botId),initialBotId:c.botId,plain:!0,onClose:()=>I(null)}),c?.kind==="webhook"&&(K||!c.id)&&e.jsx(Bt,{webhook:K,bots:A,initialBotId:c.botId,onClose:()=>I(null),onCredential:(s,d)=>{gt(ke(),d,s),f(d)}}),c?.kind==="app"&&(a||!c.id)&&e.jsx(kt,{trigger:a,bots:A,initialBotId:c.botId,onClose:()=>I(null),onSaved:s=>f(s.id)})]})}function Yt(){const n=typeof window<"u"?window.ogb?.routines:void 0,[r,l]=m.useState(null),[g,h]=m.useState(!1);return m.useEffect(()=>{if(!n)return;let o=!1;const b=()=>n.wakeState().then(i=>{o||l(i)}).catch(()=>{});b();const p=window.setInterval(b,3e4);return()=>{o=!0,window.clearInterval(p)}},[n]),!n||!r?null:e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-4 px-1 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[t("automations.wake"),r.keepAwake&&r.onBattery?` ${t("automations.wakeBattery")}`:""]}),e.jsx(Se,{checked:r.keepAwake,disabled:g,"aria-label":t("automations.wake"),onClick:()=>{h(!0),n.keepAwake(!r.keepAwake).then(l).catch(()=>{}).finally(()=>h(!1))},className:"shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}export{es as TriggersPage};
1
+ import{j as e,t,a as S,i as ie,d as he,r as m,X as be,C as fe,n as Ae,S as Re}from"./styles-DOwrpvZY.js";import{C as Ee,K as ze,B as Te,c as Me,d as Le,P as ce,V as Oe}from"./PlacesRail-DyYA64do.js";import{cx as ge,cy as Pe,cz as Fe,cA as oe,Y as $e,u as H,cB as We,cC as Ye,cD as ee,cE as ye,cF as de,cG as _e,cH as ke,cI as He,cJ as Ue,cK as Ge,cL as Je,bw as Ke,cM as Qe,cN as je,cO as ue,cP as qe,cQ as Ve,T as Xe,cR as Ze,cS as et,cT as Z,cU as ve,c4 as we,cV as tt,cW as ne,cX as st,cY as nt,cZ as Ne,j as W,c_ as Ce,c$ as at,d0 as it,d1 as ot,d2 as xe,d3 as rt,d4 as lt,d5 as dt,d6 as ct,w as re,C as ut,d7 as xt,cv as pt,d8 as mt,ct as ht,d9 as bt,da as ft,S as Se,db as gt,dc as yt}from"./App-D24ELMyP.js";import{AppEventEditor as kt}from"./AppEventEditor-BFkEZazQ.js";import{C as Ie,S as jt}from"./MenuMotion-BclWiAVe.js";import{C as vt,E as wt,Q as Nt,b as Ct,H as St,R as It}from"./RoutinesPage-CA1__NjC.js";import{WebhookEditor as Bt}from"./WebhookTrigger-CyF3M1mk.js";import"./monitor-B9eyPPw6.js";import"./index-DwYETevf.js";import"./remote-desktop-DDRRx8uY.js";import"./ProIntroduction-BgEaTCd1.js";const le="\0general";function Dt(n,r){const l=n.filter(h=>!h.hidden),g=new Set(l.map(h=>h.section).filter(h=>!!h));return{names:r.filter(h=>g.has(h)),hasGeneral:l.some(h=>!h.section)}}function te(n,r){return r==="all"?!0:n?r===le?!n.section:n.section===r:!1}function At({trigger:n}){const{attempts:r,service:l}=ge(),g=r.filter(o=>o.triggerId===n.id).slice(-6).reverse(),h=Pe(n);return e.jsxs("section",{"data-app-events":n.id,children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.events")}),h&&e.jsx("p",{className:"mb-2 rounded-lg bg-warning/10 px-2.5 py-1.5 text-[12px] text-warning",children:h}),g.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noEvents")}):e.jsx("ul",{className:"space-y-1",children:g.map(o=>{const b=Fe(o),p=oe(o.at);return e.jsxs("li",{className:"flex items-baseline gap-2 px-2 py-1 text-[13px]",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:p.charAt(0).toLocaleUpperCase()+p.slice(1)}),e.jsx("span",{className:S("shrink-0 font-semibold",b.mark==="✓"?"text-success":b.mark==="✗"?"text-danger":"text-ink-tertiary"),children:b.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",title:b.text,children:b.text})]},o.id)})}),l?.eventsPerDay&&e.jsx("p",{className:"mt-2 text-[11px] text-ink-tertiary",children:t("automations.app.limit",{count:l.eventsPerDay.toLocaleString(ie()),place:t(l.plan==="cloud"?"automations.app.placeCloud":"automations.app.placeDesktop")})})]})}function Be({status:n,className:r}){return n.state==="needs-you"?e.jsx($e,{size:15,"aria-hidden":"true",className:S("shrink-0 text-warning",r)}):n.state==="done"?e.jsx(he,{size:14,"aria-hidden":"true",className:S("shrink-0 text-ink-tertiary",r)}):e.jsx("span",{"aria-hidden":"true",className:S("size-2.5 shrink-0 rounded-full",n.state==="working"?"bg-success":"bg-ink-tertiary/60",r)})}function De({automation:n,status:r,actions:l,onEdit:g,className:h}){const{dispatch:o}=H();if(r.state!=="needs-you"||!r.fix)return null;const b=r.fix,p=b==="answer"?We(n.runs):void 0,i=()=>{b==="answer"?l.openRun(n,p):b==="sign-in"?l.openRun(n,n.runs.find(x=>x.status!=="queued")):b==="usage"?o({type:"toggleAppSettings",open:!0,section:"usage"}):b==="edit"?g():b==="reconnect"?o({type:"togglePlugins",open:!0,surface:"apps"}):l.runNow(n)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:i,disabled:!!l.busy,className:S("shrink-0 rounded-lg bg-warning/15 px-2.5 py-1 text-[12px] font-medium text-warning hover:bg-warning/25 disabled:opacity-50",h),children:t(Ye[b])}),p&&e.jsx("button",{type:"button","data-automation-cancel-run":!0,onClick:()=>{l.cancelRun(n,p)},disabled:!!l.busy,className:S("shrink-0 rounded-lg px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",h),children:t("routines.drawer.cancelRun")})]})}const Rt=5,q="flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-[13px] font-medium disabled:opacity-50";function Et({automation:n,sentence:r,onClose:l,onEdit:g,onDeleted:h}){const{state:o,dispatch:b}=H(),[p]=m.useState(()=>new Set(n.runs.filter(u=>ee(u)&&!u.seenAt).map(u=>u.id))),i=n.runs.filter((u,C)=>C<Rt||p.has(u.id)||ee(u)&&!u.seenAt);m.useEffect(()=>{for(const u of n.runs)ee(u)&&!u.seenAt&&b({type:"markRoutineRunSeen",runId:u.id})},[n.runs,b]);const x=ye(),j=de(n),f=n.kind==="webhook"?o.webhooks.find(u=>u.id===n.id):void 0,v=f?_e(ke())[f.id]:void 0,y=o.webhookIngress?.available!==!1,N=t(He[j.state]),w=n.name.trim(),R=o.bots.find(u=>u.id===n.botId)?.name??t("routines.unavailableBot"),B=n.instructions.trim(),c=j.state==="done"?t("automations.reason.done"):j.reason,I=f?Ue(f.id,o.webhookAttempts):[],T=f?Ge(f,o.webhookAttempts):null,[A,Y]=m.useState(null),[M,D]=m.useState(!1),[E,_]=m.useState(!1),z=async u=>{if(await ze(u)!=="copied"){x.setError(t("automations.address.copyFailed"));return}_(!0),setTimeout(()=>_(!1),1800)};return e.jsxs("aside",{"aria-label":t("automations.panel.label"),className:"flex h-full w-[min(380px,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-5 py-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-[16px] font-semibold leading-snug text-ink",children:w||r}),w&&e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:Je(n,R)})]}),e.jsx("button",{type:"button",onClick:l,className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("automations.panel.close"),children:e.jsx(be,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px]","data-automation-status":j.state,children:[e.jsx(Be,{status:j}),e.jsx("span",{className:S("font-medium",j.state==="needs-you"?"text-warning":"text-ink"),children:N}),c&&e.jsx("span",{className:"min-w-0 text-ink-secondary",children:c}),e.jsx(De,{automation:n,status:j,actions:x,onEdit:g})]}),f&&e.jsxs("section",{className:"rounded-xl border border-hairline/45 bg-inset/50 p-3.5",children:[e.jsx("h3",{className:"text-[13px] font-medium text-ink",children:t("automations.address.title")}),e.jsxs("button",{type:"button",disabled:!!x.busy||!y,onClick:()=>{x.copyAddress(f.id)},className:S(q,"mt-2.5 bg-accent text-accent-ink hover:brightness-110"),children:[x.copied===f.id?e.jsx(he,{size:14}):e.jsx(Ee,{size:14}),x.copied===f.id?t("automations.address.copied"):t("automations.address.copy")]}),(!y||!o.config?.cloudHome)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:y?t("automations.address.keepOpen"):t("automations.address.unavailable")}),e.jsxs("details",{className:"mt-2.5 text-[12px] text-ink-secondary",children:[e.jsx("summary",{className:"cursor-pointer select-none font-medium text-ink-secondary hover:text-ink",children:t("automations.more")}),e.jsxs("div",{className:"mt-2 space-y-2 leading-relaxed",children:[T&&e.jsxs("section",{"aria-label":t("automations.received.title"),children:[e.jsxs("p",{className:"font-medium text-ink",children:[t("automations.received.title")," · ",oe(T.at)]}),e.jsx("p",{className:"mt-0.5",children:t("automations.received.help")}),e.jsx("pre",{className:"mt-1.5 max-h-40 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-inset px-2.5 py-2 font-mono text-[11px] text-ink",children:T.preview.slice(0,1e3)})]}),e.jsxs("section",{"aria-label":t("automations.calls.title"),children:[e.jsx("p",{className:"font-medium text-ink",children:t("automations.calls.title")}),I.length===0?e.jsx("p",{className:"mt-0.5",children:t("automations.calls.none")}):e.jsx("ul",{className:"mt-1 space-y-0.5",children:I.map(u=>e.jsxs("li",{"data-call":u.ok?"ok":"refused",children:[e.jsxs("button",{type:"button","aria-expanded":A===u.id,onClick:()=>Y(C=>C===u.id?null:u.id),className:"flex w-full items-baseline gap-2 rounded-md px-1.5 py-1 text-left hover:bg-raised",children:[e.jsx("span",{className:"shrink-0",children:Ke(oe(u.at))}),e.jsx("span",{className:S("shrink-0 font-semibold",u.ok?"text-success":"text-danger"),children:u.ok?"✓":"✗"}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:u.reason})]}),A===u.id&&e.jsx("pre",{className:"mx-1.5 mb-1 whitespace-pre-wrap break-all rounded-md bg-inset px-2 py-1.5 font-mono text-[11px] text-ink",children:u.preview||t("automations.calls.empty")})]},u.id))})]}),e.jsx("p",{className:"font-medium text-ink",children:t("automations.address.showSecret")}),v?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1","data-secret":M?"shown":"masked",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[11px]",children:t("automations.address.secret",{secret:M?v.secret:"••••••••"})}),e.jsx("button",{type:"button","aria-label":t(M?"automations.address.hideSecretLabel":"automations.address.showSecretLabel"),onClick:()=>D(u=>!u),className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:t(M?"automations.address.hideSecret":"automations.address.revealSecret")}),e.jsx("button",{type:"button","aria-label":t("automations.address.copySecretLabel"),onClick:()=>{z(v.secret)},className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:E?t("automations.address.copied"):t("automations.address.copySecret")})]}):e.jsx("p",{className:"break-all font-mono text-[11px]",children:t("automations.address.secretUnknown")}),e.jsx("p",{children:t("automations.address.header")}),f.eventTypes?.length?e.jsx("p",{children:t("automations.address.events",{events:f.eventTypes.join(", ")})}):null,e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{window.confirm(t("automations.address.replaceConfirm"))&&x.copyAddress(f.id,!0)},className:"flex items-center gap-1.5 rounded-lg border border-hairline/50 px-2.5 py-1.5 text-ink hover:bg-raised",children:[e.jsx(Qe,{size:12}),t("automations.address.replace")]})]})]})]}),w&&B&&e.jsx("p",{"data-testid":"automation-instructions",className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed text-ink",children:B}),n.appTrigger&&e.jsx(At,{trigger:n.appTrigger}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.recent")}),n.runs.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noRuns")}):e.jsx("ul",{className:"space-y-1",children:i.map(u=>{const C=je(u);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!u.threadId,onClick:()=>x.openRun(n,u),title:u.threadId?t("automations.panel.open"):void 0,className:"flex w-full items-baseline gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] hover:bg-raised disabled:hover:bg-transparent",children:[e.jsx("span",{className:"shrink-0 text-ink-secondary",children:C.when}),e.jsx("span",{className:S("shrink-0 font-semibold",C.mark==="✓"?"text-success":C.mark==="✗"?"text-danger":"text-warning"),children:C.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:C.text})]})},u.id)})})]}),x.error&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:x.error})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 border-t border-hairline/40 px-5 py-3.5",children:[e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.runNow(n)},className:S(q,"bg-accent text-accent-ink hover:brightness-110"),children:[e.jsx(ue,{size:14}),x.busy===`run:${n.id}`?t("automations.starting"):t("automations.runNow")]}),j.state!=="done"&&e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.toggle(n)},className:S(q,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[n.enabled?e.jsx(qe,{size:14}):e.jsx(ue,{size:14}),n.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:g,className:S(q,"text-ink hover:bg-raised"),children:[e.jsx(Ve,{size:14}),t("automations.edit")]}),e.jsxs("button",{type:"button",disabled:!!x.busy,onClick:()=>{x.remove(n,t("automations.deleteConfirm",{sentence:r})).then(u=>{u&&h()})},className:S(q,"text-danger hover:bg-danger/10"),children:[e.jsx(Xe,{size:14}),t("automations.delete")]})]})]})}const zt=()=>Array.from({length:7},(n,r)=>new Intl.DateTimeFormat(Ae(),{weekday:"narrow",timeZone:"UTC"}).format(Date.UTC(2023,0,2+r)));function ae(n){const r=new Date(n);return new Date(r.getFullYear(),r.getMonth(),1)}function pe(n,r){return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function me(n,r){return new Date(n.getFullYear(),n.getMonth()+r,1)}function Tt({anchor:n,onSelect:r}){const[l,g]=m.useState(()=>ae(n));m.useEffect(()=>{g(ae(n))},[n]);const h=m.useMemo(()=>{const i=ae(l),x=(i.getDay()+6)%7,j=new Date(i);return j.setDate(i.getDate()-x),Array.from({length:42},(f,v)=>{const y=new Date(j);return y.setDate(j.getDate()+v),y})},[l]),o=new Date(n),b=new Date,p=l.toLocaleDateString(ie(),{month:"long",year:"numeric"});return e.jsxs("section",{"aria-label":t("routines.miniCalendar.label"),className:"select-none px-3 py-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsx("div",{className:"text-[13px] font-semibold text-ink",children:p}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,-1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.previous"),children:e.jsx(fe,{size:15,"aria-hidden":"true"})}),e.jsx("button",{type:"button",onClick:()=>g(i=>me(i,1)),className:"flex size-7 items-center justify-center rounded-full text-ink-secondary transition-colors hover:bg-raised hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60","aria-label":t("routines.miniCalendar.next"),children:e.jsx(Ie,{size:15,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"grid grid-cols-7","aria-hidden":"true",children:zt().map((i,x)=>e.jsx("div",{className:"flex h-6 items-center justify-center text-[9px] font-semibold uppercase tracking-[0.08em] text-ink-tertiary",children:i},`${i}-${x}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:h.map(i=>{const x=pe(i,o),j=pe(i,b),f=i.getMonth()!==l.getMonth(),v=i.toLocaleDateString(ie(),{weekday:"long",month:"long",day:"numeric",year:"numeric"});return e.jsx("button",{type:"button",onClick:()=>r(i.getTime()),"aria-label":v,"aria-current":j?"date":void 0,"aria-pressed":x,className:"group flex h-7 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60",children:e.jsx("span",{className:`flex size-6 items-center justify-center rounded-full text-[11px] transition-colors ${x?"bg-accent font-semibold text-white shadow-sm":j?"font-semibold text-accent group-hover:bg-accent/12":f?"text-ink-tertiary group-hover:bg-raised group-hover:text-ink":"text-ink group-hover:bg-raised"}`,children:i.getDate()})},`${i.getFullYear()}-${i.getMonth()}-${i.getDate()}`)})})]})}const Mt="application/x-openmaus-bot";function Lt({bots:n,anchor:r,onSelectDate:l}){const[g,h]=m.useState(""),o=m.useMemo(()=>{const p=g.trim().toLocaleLowerCase();return p?n.filter(i=>`${i.name} ${i.title} ${i.description}`.toLocaleLowerCase().includes(p)):n},[n,g]),b=(p,i)=>{p.dataTransfer.effectAllowed="copy",p.dataTransfer.setData(Mt,i.id),p.dataTransfer.setData("text/plain",i.id)};return e.jsxs("aside",{"aria-label":t("routines.sidebar.label"),className:"flex h-full w-[320px] shrink-0 flex-col overflow-hidden border-r border-hairline/40 bg-panel",children:[e.jsx(Tt,{anchor:r,onSelect:l}),e.jsx("div",{className:"mx-4 border-t border-hairline/40"}),e.jsxs("section",{"aria-labelledby":"calendar-bots-heading",className:"flex min-h-0 flex-1 flex-col px-3 pb-3 pt-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[e.jsxs("div",{id:"calendar-bots-heading",className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.11em] text-ink-secondary",children:[e.jsx(Ze,{size:13,"aria-hidden":"true"}),t("routines.sidebar.myBots")]}),e.jsx("span",{className:"rounded-full bg-raised px-1.5 py-0.5 text-[9px] tabular-nums text-ink-secondary",children:n.length})]}),e.jsxs("label",{className:"relative mb-2 block",children:[e.jsx("span",{className:"sr-only",children:t("routines.sidebar.searchBots")}),e.jsx(Re,{size:13,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ink-tertiary","aria-hidden":"true"}),e.jsx("input",{value:g,onChange:p=>h(p.target.value),type:"search",placeholder:t("routines.sidebar.searchBots"),className:"h-8 w-full rounded-lg border border-hairline/45 bg-control/55 pl-8 pr-2.5 text-[12px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/60 focus:bg-control"})]}),e.jsxs("div",{role:"list","aria-label":t("routines.sidebar.availableBots"),className:"min-h-0 flex-1 space-y-0.5 overflow-y-auto pr-0.5",children:[o.map(p=>e.jsxs("div",{draggable:!0,onDragStart:i=>b(i,p),role:"listitem",className:"group flex cursor-grab items-center gap-2 rounded-xl px-2 py-2 transition-colors hover:bg-raised/80 active:cursor-grabbing","aria-label":t("routines.sidebar.dragBot",{name:p.name}),title:t("routines.sidebar.dragBot",{name:p.name}),children:[e.jsx(et,{size:13,className:"shrink-0 text-ink-secondary/35 transition-colors group-hover:text-ink-secondary","aria-hidden":"true"}),e.jsx(Te,{bot:p,size:27,animated:!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-ink",children:p.name}),e.jsx("div",{className:"truncate text-[10px] text-ink-tertiary",children:p.title||t("routines.sidebar.botFallback")})]}),e.jsx("span",{className:"shrink-0 rounded-full border border-hairline/50 px-1.5 py-0.5 text-[9px] text-ink-tertiary opacity-0 transition-opacity group-hover:opacity-100",children:t("routines.sidebar.drag")})]},p.id)),o.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] leading-relaxed text-ink-secondary",children:n.length===0?t("routines.sidebar.noBots"):t("routines.sidebar.noMatch")})]}),e.jsx("p",{className:"mt-2 px-2 text-[10px] leading-relaxed text-ink-tertiary",children:t("routines.sidebar.dragHint")})]})]})}function Ot({botFilter:n,department:r="all",selectedAutomationId:l,onOpenAutomation:g,onOpenRoom:h}){const{state:o,dispatch:b}=H(),p=window.ogb?.remoteClient?.active===!0,[i,x]=m.useState(()=>window.innerWidth<640?1:7),[j,f]=m.useState(()=>Z(Date.now())),[v,y]=m.useState([]),[N,w]=m.useState(null),[R,B]=m.useState(null),[c,I]=m.useState(null),[T,A]=m.useState(""),Y=o.bots.filter(a=>!a.hidden),M=ve(Y,we(),R?.botIds[0]),D=i===7?tt(j):Z(j),E=ne(D,i);st(D);const _=nt(Ne(),D,E),z=m.useCallback(async()=>{try{y((await W("/api/calendar-calls")).calls??[])}catch(a){A(a instanceof Error?a.message:String(a))}},[]);m.useEffect(()=>{p||z()},[z,p]);const u=m.useMemo(()=>{const a=new Set(o.bots.map(k=>k.id)),s=o.routines.filter(k=>a.has(k.botId)),d=new Set(Ce({routines:s,webhooks:[],runs:o.routineRuns}).filter(k=>de(k).state==="needs-you").map(k=>k.id)),P=at(s,o.routineRuns.filter(k=>a.has(k.botId)),D,E).map(k=>({...k,kind:"routine",needsYou:!!(k.routine&&!k.run&&d.has(k.routine.id))})),F=it(v,D,E).map(k=>({...k,kind:"call"})),$=k=>o.bots.find(Q=>Q.id===k);return[...P,...F].filter(k=>k.kind==="call"?k.call.botIds.some(Q=>te($(Q),r)):te($(k.routine?.botId??k.run?.botId),r)).filter(k=>n==="all"||(k.kind==="call"?k.call.botIds.includes(n):(k.routine?.botId??k.run?.botId)===n)).sort((k,Q)=>k.at-Q.at)},[o.routines,o.routineRuns,o.bots,v,D,E,n,r]),C=c?.kind==="call"?(()=>{const a=v.find(s=>s.id===c.call.id);return a?{...c,call:a}:null})():null,U=a=>{if(a.kind==="call"){I(a);return}I(null);const s=a.routine?.id??a.run?.routineId;s&&g(s)},V=a=>g(a.routineId),L=C?.id??u.find(a=>a.kind==="routine"&&(a.routine?.id??a.run?.routineId)===l)?.id,O=a=>y(s=>s.some(d=>d.id===a.id)?s.map(d=>d.id===a.id?a:d):[a,...s]),G=async(a,s)=>{if(s!==a.at)try{if(a.kind==="routine"){const d=o.routines.find(F=>F.id===a.id);if(!d)return;if(d.schedule.type==="cron")throw new Error(t("automations.calendar.cronMove"));if(d.schedule.type!=="once"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/routines/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});b({type:"routinePatched",routine:P.routine})}else{const d=v.find(F=>F.id===a.id);if(!d||d.schedule.type==="daily"&&!window.confirm(t("automations.calendar.moveSeries")))return;const P=await W(`/api/calendar-calls/${d.id}`,{method:"PATCH",body:JSON.stringify({schedule:xe(d.schedule,a.at,s)})});O(P.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},se=async(a,s)=>{if("botId"in a){I(null),w({kind:"routine",at:s.at,durationMinutes:30,botIds:[a.botId],limitReset:{engine:s.engine}});return}if(a.event.kind!=="routine")return A(t("limits.callNotOnReset"));try{const d=await W(`/api/routines/${a.event.id}`,{method:"PATCH",body:JSON.stringify({schedule:{type:"limit_reset",engine:s.engine,repeat:"once"}})});b({type:"routinePatched",routine:d.routine})}catch(d){A(d instanceof Error?d.message:String(d))}},X=async(a,s)=>{try{if(a.kind==="routine"&&a.routine){const d=await W(`/api/routines/${a.routine.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});b({type:"routinePatched",routine:d.routine})}else if(a.kind==="call"){const d=await W(`/api/calendar-calls/${a.call.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:s})});O(d.call)}}catch(d){A(d instanceof Error?d.message:String(d))}},J=()=>{C&&(B({kind:"call",at:C.at,durationMinutes:C.call.durationMinutes,botIds:C.call.botIds,call:C.call}),I(null))},K=a=>S("rounded-md px-3 py-1 text-[12px] font-medium",a?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink");return e.jsxs("div",{className:"@container/routines relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-hairline/30 px-4 py-2",children:[e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,-i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.previous"),children:e.jsx(fe,{size:16})}),e.jsx("button",{type:"button",onClick:()=>f(a=>ne(a,i)),className:"rounded-md p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":t("routines.next"),children:e.jsx(Ie,{size:16})}),e.jsx("div",{className:"min-w-0 truncate px-1 text-[14px] font-medium text-ink","aria-live":"polite",children:ot(D,i)}),e.jsx("button",{type:"button",onClick:()=>f(Z(Date.now())),className:"rounded-lg border border-hairline/50 px-2.5 py-1 text-[12px] font-medium text-ink hover:bg-raised",children:t("routines.today")}),e.jsxs("div",{role:"group",className:"ml-auto flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5","aria-label":t("routines.view.label"),children:[e.jsx("button",{type:"button","aria-pressed":i===1,onClick:()=>x(1),className:K(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>x(7),className:K(i===7),children:t("routines.view.week")})]}),T&&e.jsx("button",{type:"button",onClick:()=>A(""),className:"w-full text-left text-[12px] text-danger",children:T})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[!C&&e.jsx("div",{className:"hidden shrink-0 @min-[1040px]/routines:block",children:e.jsx(Lt,{bots:Y,anchor:j,onSelectDate:a=>f(Z(a))})}),e.jsx(vt,{anchor:D,days:i,items:u,bots:o.bots,groups:o.groups,selectedId:L,onOpen:U,onCreate:a=>{I(null),w(a)},onMove:(a,s)=>{G(a,s)},onResize:(a,s)=>{X(a,s)},markers:_,onDropOnReset:(a,s)=>{se(a,s)}}),C&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl @min-[760px]/routines:static @min-[760px]/routines:shadow-none",children:e.jsx(wt,{item:C,bots:o.bots,onClose:()=>I(null),onEdit:J,onOpenRun:V,onCallChanged:a=>{a?y(s=>s.filter(d=>d.id!==a)):z()},onOpenRoom:h},`${C.kind}:${C.id}`)})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/25",onMouseDown:()=>w(null)}),e.jsx(Nt,{seed:N,bots:M,routinesOnly:p,onClose:()=>w(null),onMore:a=>{w(null),B(a)},onSavedRoutine:a=>b({type:"routinePatched",routine:a}),onSavedCall:O})]}),R&&e.jsx(Ct,{seed:R,bots:M,routinesOnly:p,onClose:()=>B(null),onSavedCall:O})]})}function Pt({botFilter:n="all"}){const{state:r,dispatch:l}=H(),g=rt(Ne()),[h,o]=m.useState(null),[b,p]=m.useState(null),[i,x]=m.useState("");if(!g.length)return null;const j=y=>r.bots.find(N=>N.id===y)?.modelSelection?.instanceId,f=r.routines.filter(y=>n==="all"||y.botId===n),v=async(y,N)=>{o(y.engine),x("");try{for(const w of N){const R=await W("/api/limit-resets/after-reset",{method:"POST",body:JSON.stringify({routineId:w.id,engine:y.engine})});l({type:"routinePatched",routine:R.routine})}p(y.engine)}catch(w){x(w instanceof Error?w.message:String(w))}finally{o(null)}};return e.jsxs("section",{"aria-label":t("limits.title"),className:"mb-4 space-y-2",children:[g.map(y=>{const N=lt(f,j,y);return e.jsxs("div",{"data-limit-warning":y.engine,role:"status",className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 rounded-xl border border-warning/40 bg-warning/10 px-3.5 py-2.5 text-[13px] text-ink",children:[e.jsx(St,{size:15,className:"shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{className:"font-medium tabular-nums",children:dt(y)}),N.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-secondary",children:t(N.length===1?"limits.dueOne":"limits.dueMany",{count:N.length})}),e.jsx("button",{type:"button",disabled:h===y.engine,onClick:()=>{v(y,N)},className:"ml-auto rounded-lg bg-accent px-3 py-1.5 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-50",children:t("limits.moveAfterReset")})]}):b===y.engine&&e.jsx("span",{className:"text-ink-secondary",children:t("limits.moved")})]},y.engine)}),i&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:i})]})}function Ft(n,r){const l=n.find(h=>h.id===r);if(l)return l;const g=h=>h.messages.at(-1)?.at??0;return[...n].sort((h,o)=>g(o)-g(h))[0]}function $t({initialText:n="",onClose:r,onSetUpYourself:l}){const{state:g,dispatch:h}=H(),o=g.bots.filter(c=>!c.hidden),[b,p]=m.useState(n),[i,x]=m.useState(()=>Ft(o,g.selectedId)?.id??""),[j,f]=m.useState(!1),[v,y]=m.useState("schedule"),N=m.useRef(null);Me(N,r);const w=o.find(c=>c.id===i),R=()=>{const c=b.trim();!c||!w||(h({type:"select",id:w.id}),h({type:"send",botId:w.id,text:c,threadId:w.threadId}),r())},B=(c,I,T)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":v===c,onClick:()=>y(c),className:S("flex w-full items-center gap-3 rounded-xl border px-3.5 py-3 text-left text-[14px]",v===c?"border-accent/70 bg-accent/10 text-ink":"border-hairline/50 text-ink-secondary hover:bg-raised"),children:[e.jsx(T,{size:16,className:"shrink-0 text-accent"}),I]});return e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/50 p-5 pt-[14vh] backdrop-blur-sm",onMouseDown:c=>c.stopPropagation(),children:e.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-label":t("automations.newBox.title"),tabIndex:-1,className:"w-full max-w-[560px] rounded-2xl border border-hairline/60 bg-panel p-5 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:j?t("automations.newBox.when"):t("automations.newBox.title")}),e.jsx("button",{type:"button",onClick:r,"aria-label":t("automations.newBox.cancel"),className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(be,{size:16})})]}),j?e.jsxs(e.Fragment,{children:[e.jsxs("div",{role:"radiogroup","aria-label":t("automations.newBox.when"),className:"mt-4 space-y-2",children:[B("schedule",t("automations.newBox.onSchedule"),ut),B("app",t("automations.newBox.whenAppEvent"),xt),B("webhook",t("automations.newBox.whenApp"),pt)]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!1),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:t("automations.newBox.back")}),e.jsx("button",{type:"button",onClick:()=>l(v,w?.id??""),className:"rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:t("automations.newBox.continue")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{autoFocus:!0,value:b,onChange:c=>p(c.target.value),rows:3,"aria-label":t("automations.newBox.title"),placeholder:t("automations.newBox.placeholder"),onKeyDown:c=>{c.key==="Enter"&&!c.shiftKey&&!ct(c.nativeEvent)&&(c.preventDefault(),R())},className:"mt-4 w-full resize-none rounded-xl border border-hairline/60 bg-inset px-3.5 py-3 text-[14px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent/70"}),o.length===0&&e.jsx("p",{className:"mt-2 text-[13px] text-warning",children:t("automations.newBox.noBots")}),o.length>1&&e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink-secondary",children:[t("automations.newBox.bot"),e.jsx(re,{size:"sm",value:i,onChange:c=>x(c.target.value),"aria-label":t("automations.newBox.bot"),className:"max-w-[220px]",children:o.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>f(!0),className:"rounded-lg px-2 py-1.5 text-[13px] text-ink-secondary underline-offset-2 hover:text-ink hover:underline",children:t("automations.newBox.yourself")}),e.jsxs("button",{type:"button",disabled:!b.trim()||!w,onClick:R,className:"flex items-center gap-2 rounded-xl bg-accent px-4 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110 disabled:opacity-40",children:[e.jsx(jt,{size:14}),t("automations.newBox.send")]})]})]})]})})}const Wt=9;function es({onBack:n,onOpenRoom:r}){const{state:l,dispatch:g}=H(),{capabilities:h}=Le(),o=ye(),b=ge(),p=m.useRef(null),i=l.routinesFocus,x=i?.view==="calendar"?"calendar":"list",[j,f]=m.useState(i?.section!=="logs"?i?.routineId??null:null),[v,y]=m.useState(i?.botId??"all"),[N,w]=m.useState("all"),[R,B]=m.useState(null),[c,I]=m.useState(null),T=window.ogb?.remoteClient?.active===!0,A=l.bots.filter(s=>!s.hidden),Y=we(),M=s=>l.bots.find(d=>d.id===s)?.name??t("routines.unavailableBot");m.useEffect(()=>{y(i?.botId??"all"),i?.routineId&&i.section!=="logs"&&f(i.routineId)},[i]),m.useEffect(()=>{p.current?.focus({preventScroll:!0})},[]);const D=m.useMemo(()=>Ce({routines:l.routines,webhooks:T?[]:l.webhooks,appTriggers:b.triggers,runs:l.routineRuns,bots:l.bots}),[l.routines,l.webhooks,b.triggers,l.routineRuns,l.bots,T]),E=Dt(l.bots,[...new Set([...l.sections??[],...l.bots.flatMap(s=>s.section?[s.section]:[])])]),_=E.names.length+(E.hasGeneral?1:0)>1,z=N==="all"||(N===le?E.hasGeneral:E.names.includes(N))?N:"all";m.useEffect(()=>{z!==N&&(w("all"),y("all"))},[z,N]);const u=s=>te(l.bots.find(d=>d.id===s),z),C=A.filter(s=>te(s,z)),U=D.length>=Wt&&new Set(D.map(s=>s.botId)).size>1,V=mt(D.filter(s=>u(s.botId)&&(!U||v==="all"||s.botId===v))),L=D.find(s=>s.id===j)??null,O=s=>yt(s,M(s.botId)),G=h.windowChrome==="mac-inset",se=G?{WebkitAppRegion:"drag"}:void 0,X=G?{WebkitAppRegion:"no-drag"}:void 0,J=c?.kind==="schedule"?l.routines.find(s=>s.id===c.id):void 0,K=c?.kind==="webhook"?l.webhooks.find(s=>s.id===c.id):void 0,a=c?.kind==="app"?b.triggers.find(s=>s.id===c.id):void 0;return e.jsxs("main",{className:"flex h-full min-w-0 flex-1 flex-col bg-app animate-workspace-in",children:[e.jsx("header",{className:S("shrink-0 border-b border-hairline/35 bg-app py-3 pr-4",G&&!Oe(h)&&x==="calendar"?"pl-[86px]":x==="list"?"pl-12 md:pl-4":"pl-4"),style:se,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",ref:p,onClick:n,"aria-label":t("automations.back"),title:t("automations.back"),className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-raised hover:text-ink",style:X,children:e.jsx(ht,{size:18})}),e.jsx("h1",{"data-tour":"automations-page",className:"mr-1 text-[18px] font-semibold tracking-tight text-ink",children:t("automations.title")}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",style:X,children:[_&&e.jsxs(re,{size:"sm","aria-label":t("automations.allDepartments"),value:z,onChange:s=>{w(s.target.value),y("all")},className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allDepartments")}),E.names.map(s=>e.jsx("option",{value:s,children:s},s)),E.hasGeneral&&e.jsx("option",{value:le,children:t("automations.generalDepartment")})]}),U&&x==="list"&&e.jsxs(re,{size:"sm","aria-label":t("automations.allBots"),value:v,onChange:s=>y(s.target.value),className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allBots")}),C.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]}),e.jsx("div",{role:"group","aria-label":t("automations.view"),className:"flex items-center rounded-lg border border-hairline/50 bg-panel p-0.5",children:["list","calendar"].map(s=>e.jsx("button",{type:"button","aria-pressed":x===s,onClick:()=>g({type:"showRoutines",view:s,botId:v==="all"?void 0:v}),className:S("rounded-md px-3 py-1 text-[13px] font-medium",x===s?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:s==="list"?t("automations.list"):t("automations.calendar")},s))}),e.jsxs("button",{type:"button",onClick:()=>B(""),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3.5 py-2 text-[13px] font-semibold text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15,"aria-hidden":"true"}),t("automations.new")]})]})]})}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[x==="calendar"?e.jsx(Ot,{botFilter:v,department:z,selectedAutomationId:j,onOpenAutomation:f,onOpenRoom:r}):e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl p-4 sm:p-6",children:[e.jsx(Pt,{botFilter:U?v:"all"}),D.length===0&&l.routinesLoadState!=="loading"&&l.hydrated?e.jsxs("section",{"aria-label":t("automations.empty.title"),className:"px-6 py-16 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex size-12 items-center justify-center rounded-2xl bg-accent/10 text-accent",children:e.jsx(bt,{size:22})}),e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:t("automations.empty.title")}),e.jsx("button",{type:"button",onClick:()=>B(t("automations.empty.example")),className:"mt-3 text-[14px] text-accent-text underline-offset-2 hover:underline",children:t("automations.empty.try")}),e.jsx("div",{children:e.jsxs("button",{type:"button",onClick:()=>B(""),className:"mt-6 inline-flex items-center gap-2 rounded-xl bg-accent px-4 py-2.5 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(ce,{size:15}),t("automations.new")]})})]}):e.jsx("ul",{"aria-label":t("automations.title"),className:"divide-y divide-hairline/30 overflow-hidden rounded-2xl border border-hairline/40 bg-card",children:V.map(s=>{const d=de(s),P=s.name.trim(),F=s.runs.find(k=>ee(k)&&!k.seenAt),$=F&&je(F);return e.jsxs("li",{"data-automation":s.id,"data-automation-status":d.state,className:S("flex items-start gap-3 px-4 py-3.5",j===s.id&&"bg-raised/60"),children:[e.jsx(Be,{status:d,className:"mt-[5px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>f(s.id),className:"block text-left text-[15px] font-medium leading-snug text-ink hover:text-accent-text",children:P||O(s)}),P&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink",children:O(s)}),d.state==="needs-you"?e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-[13px] text-warning",children:[t("automations.needsYou",{reason:d.reason??""}),e.jsx(De,{automation:s,status:d,actions:o,onEdit:()=>I({kind:s.kind,id:s.id})})]}):e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:ft(s)}),$&&e.jsxs("button",{type:"button",onClick:()=>f(s.id),className:"mt-1 flex items-baseline gap-2 text-left text-[13px] text-danger",children:[e.jsx("span",{"aria-hidden":"true",className:"size-2 shrink-0 self-center rounded-full bg-danger"}),e.jsxs("span",{children:[$.when," ",$.mark," ",$.text]})]}),o.error&&o.errorFor?.endsWith(`:${s.id}`)&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:o.error})]}),d.state!=="done"&&e.jsx(Se,{checked:s.enabled,disabled:o.busy===`toggle:${s.id}`,"aria-label":t("automations.toggle",{name:s.name}),onClick:()=>{o.toggle(s)},className:"mt-0.5 shrink-0"})]},s.id)})}),o.error&&!V.some(s=>o.errorFor?.endsWith(`:${s.id}`))&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:o.error}),e.jsx(Yt,{})]})}),L&&e.jsx("div",{className:"absolute inset-y-0 right-0 z-30 flex shadow-2xl lg:static lg:shadow-none",children:e.jsx(Et,{automation:L,sentence:O(L),onClose:()=>f(null),onDeleted:()=>f(null),onEdit:()=>I({kind:L.kind,id:L.id})},L.id)})]}),R!==null&&e.jsx($t,{initialText:R,onClose:()=>B(null),onSetUpYourself:(s,d)=>{B(null),I({kind:s,botId:d})}}),c?.kind==="schedule"&&(J||!c.id)&&e.jsx(It,{routine:J,bots:ve(A,Y,J?.botId),initialBotId:c.botId,plain:!0,onClose:()=>I(null)}),c?.kind==="webhook"&&(K||!c.id)&&e.jsx(Bt,{webhook:K,bots:A,initialBotId:c.botId,onClose:()=>I(null),onCredential:(s,d)=>{gt(ke(),d,s),f(d)}}),c?.kind==="app"&&(a||!c.id)&&e.jsx(kt,{trigger:a,bots:A,initialBotId:c.botId,onClose:()=>I(null),onSaved:s=>f(s.id)})]})}function Yt(){const n=typeof window<"u"?window.ogb?.routines:void 0,[r,l]=m.useState(null),[g,h]=m.useState(!1);return m.useEffect(()=>{if(!n)return;let o=!1;const b=()=>n.wakeState().then(i=>{o||l(i)}).catch(()=>{});b();const p=window.setInterval(b,3e4);return()=>{o=!0,window.clearInterval(p)}},[n]),!n||!r?null:e.jsxs("div",{className:"mt-6 flex items-center justify-between gap-4 px-1 text-[12px] text-ink-secondary",children:[e.jsxs("span",{children:[t("automations.wake"),r.keepAwake&&r.onBattery?` ${t("automations.wakeBattery")}`:""]}),e.jsx(Se,{checked:r.keepAwake,disabled:g,"aria-label":t("automations.wake"),onClick:()=>{h(!0),n.keepAwake(!r.keepAwake).then(l).catch(()=>{}).finally(()=>h(!1))},className:"shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}export{es as TriggersPage};