@seira-bot/seira 0.1.180 → 0.1.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-DpipGqnm.js → ActivityPanel-tZLxRHYi.js} +1 -1
- package/dist/assets/{AnnouncementsPage-GCXia4xK.js → AnnouncementsPage-BrGYAaS0.js} +1 -1
- package/dist/assets/{App-BIllYA_e.js → App-h8WTNY4l.js} +136 -136
- package/dist/assets/{AppEventEditor-DYdUkpiM.js → AppEventEditor-CLpZ2lyb.js} +1 -1
- package/dist/assets/{BotSettingsDialog-DxRMUwAP.js → BotSettingsDialog-COjDhP9V.js} +1 -1
- package/dist/assets/{BrowserPanel-Cu_GqDA1.js → BrowserPanel-D_kPeSZ3.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-CL3TIl73.js → BrowserProfilesManager-haN8RgPf.js} +1 -1
- package/dist/assets/{CloudAddDialog-DUk6i4df.js → CloudAddDialog-vwGwJIYN.js} +1 -1
- package/dist/assets/{ComputerFilesPane-HvpeAXhL.js → ComputerFilesPane-DJu1k1Ap.js} +1 -1
- package/dist/assets/{ComputerPanel-CozzFQeF.js → ComputerPanel-D9bTedHq.js} +2 -2
- package/dist/assets/{DataPanel-DGqcWB1O.js → DataPanel-CsuS_ybT.js} +1 -1
- package/dist/assets/{DesktopViewer-BoBSIDfB.js → DesktopViewer-YvIV04Lf.js} +1 -1
- package/dist/assets/{EnginesSettings-D643-yZk.js → EnginesSettings-C27xDaBN.js} +1 -1
- package/dist/assets/{FilesView-b5DFlMDt.js → FilesView-Dsxj73nW.js} +1 -1
- package/dist/assets/{GrokMoveDialog-gGTLfrGg.js → GrokMoveDialog-DEgRQW9G.js} +1 -1
- package/dist/assets/{ImportDialog-Bu5X6qOF.js → ImportDialog-DLVTgN-h.js} +1 -1
- package/dist/assets/{InspectorPanel-DU7_iwQR.js → InspectorPanel-gvFj5wfe.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-Wxnn1d66.js → KeyboardShortcutsModal-aF0vhD29.js} +1 -1
- package/dist/assets/{LiveDesktop-D9PC-iAT.js → LiveDesktop-Bca91cEb.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-0YxB-I-X.js → LocalVmWorkspace-CVLDY3ws.js} +1 -1
- package/dist/assets/{MacLocalControl-DoEGcs3V.js → MacLocalControl-BeNWQ9oY.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CAlARwd0.js → MarkdownFilePreview-CYw3CQ3T.js} +1 -1
- package/dist/assets/{MenuMotion-DfjnHTCi.js → MenuMotion-CHp-hB40.js} +1 -1
- package/dist/assets/{NewBotDialog-D3i7j_KP.js → NewBotDialog-BxeQktoI.js} +1 -1
- package/dist/assets/{PhoneAppDialog-OeXLO0Wb.js → PhoneAppDialog-CIlw_m5U.js} +1 -1
- package/dist/assets/{PlacesRail-3RaNlpug.js → PlacesRail-Df-jNTHn.js} +1 -1
- package/dist/assets/PluginsPanel-CMqZcDkC.js +8 -0
- package/dist/assets/{ProIntroduction-B3phUWnc.js → ProIntroduction-D8hWm9R5.js} +1 -1
- package/dist/assets/{PublishedAppsPage-BXWDYkhG.js → PublishedAppsPage-BMn3C64O.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-vgrEf5B7.js → RemoteAgentSettingsPanel-B7QJizjx.js} +1 -1
- package/dist/assets/{RoomPanel-BmXypXPv.js → RoomPanel-CyWZ4kkq.js} +1 -1
- package/dist/assets/RoutinesPage-B9kKyfFp.js +2 -0
- package/dist/assets/{ServerPairingCard-c2fKq1gh.js → ServerPairingCard-D21dP5Bc.js} +1 -1
- package/dist/assets/SettingsModal-afRPXeYI.js +2 -0
- package/dist/assets/{ShareDepartmentDialog-CJITsmAd.js → ShareDepartmentDialog-CwErWDth.js} +1 -1
- package/dist/assets/{SignedInSites-B2pCMdic.js → SignedInSites-CFyvOLSc.js} +1 -1
- package/dist/assets/{TeamFilesPage-B10cdbwa.js → TeamFilesPage-BvhXs2O5.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-CRmTfBOI.js → TeamLibraryPanel-Dm8wjNB4.js} +1 -1
- package/dist/assets/{TeamMapPage-BoTNppEy.js → TeamMapPage-jCSzFPvB.js} +1 -1
- package/dist/assets/{ToolPageShell-BPd_nyJ8.js → ToolPageShell-DKZUregg.js} +1 -1
- package/dist/assets/{TriggersPage-DDxtJMT4.js → TriggersPage-wSB6z1cp.js} +1 -1
- package/dist/assets/{VisibilitySection-Cd3TZvS_.js → VisibilitySection-CFr6fOzq.js} +1 -1
- package/dist/assets/{WebhookTrigger-AJduidiC.js → WebhookTrigger-BJN-V-bx.js} +1 -1
- package/dist/assets/{WorksOnGrid-DHo10o0j.js → WorksOnGrid-B3wYro9M.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-DnIZyeSK.js → abnfDiagram-YUKMZFIV-DRhWKTiz.js} +1 -1
- package/dist/assets/{activity-DrX2_Hm9.js → activity-l0oTqbd6.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-DHdulT2e.js → architectureDiagram-47P4ROYG-C_qnTvJF.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-BGReDH4k.js → blockDiagram-E7TT5TSB-DzLSloVY.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-BV9zDZsL.js → c4Diagram-CRA5TL53-BzVViHCA.js} +1 -1
- package/dist/assets/{calendar-days-Ddhxf1PV.js → calendar-days-DFd3GKf_.js} +1 -1
- package/dist/assets/channel-B2D6cAE5.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DAj16syq.js → chunk-2Q5K7J3B-hR-bQJHo.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-CMyoXW_3.js → chunk-5VM5RSS4-BWmBW1XC.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW--z54G8Jv.js → chunk-7TKQ45FW-DuUk7RXl.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-CPPbUHIj.js → chunk-AW2ZBBNX-Madgl1uv.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-pKEz9wbK.js → chunk-FVRAUYC3-WSgsvIGA.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-DIOqwx2X.js → chunk-HTAEGDNF-CfoPR2yG.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BW474-Li.js → chunk-JWPE2WC7-tLRHdBom.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-DjAEB-Df.js → chunk-KQW6MTUR-BqwuNuVY.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CMZz2xNV.js → chunk-XXDRQBXY-BOeb8xE4.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-7GYDWs2n.js → classDiagram-v2-K4WV4PDN-CFeH5trZ.js} +1 -1
- package/dist/assets/{core-Dq4LUz6X.js → core-CnInZb-o.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-Dy2zOVu3.js → cose-bilkent-JH36ORCC-BEg68hhI.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-C7I3qmqf.js → cynefin-EF2NZ3EQ-B_Xq3hQ3.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-CsPcUXHD.js → cynefinDiagram-3GCD6N5R-DN1o2ihW.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-DxvGlifm.js → dagre-W4DXFKR2-BFf83-nP.js} +1 -1
- package/dist/assets/{de-CrlnmnfQ.js → de-BpsYkrLY.js} +1 -1
- package/dist/assets/{desktop-connection-Df-k5QBM.js → desktop-connection-CU6jsy2e.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-Qz2-e2_u.js → diagram-2UJZ2QOL-_qwbS5JH.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-D1u4ioUX.js → diagram-OVF4WLC6-9sq9EfiF.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-DZiCtcMI.js → diagram-PFPMY2P6-Ow1v5ZhK.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-DmVn9h1H.js → diagram-UMYRVEAY-DDTBFPls.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-CJK2ajcB.js → diagram-YEKJPTXX-D1zZ8KqI.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-NoYT_JX9.js → diagram-ZIFT7M5P-C_vZWUw8.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BooF3Pem.js → ebnfDiagram-VR2GEFS7-D_1GvBDx.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-4Ai0igvq.js → elk-IJKZMXRS-CV-PzspH.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-CdhhzqVX.js → erDiagram-O2IAPWRE-CnKVd0av.js} +1 -1
- package/dist/assets/{es-BIPy8tP9.js → es-COLCGADa.js} +1 -1
- package/dist/assets/{file-up-Bs5NWcjw.js → file-up-Bjx5Vcmk.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-SeyZJAiT.js → flowDiagram-OXPTDLAJ-CGJh171P.js} +1 -1
- package/dist/assets/{fr-CCbXz1Dc.js → fr-CJ1x1iRl.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-rmA_SJlC.js → ganttDiagram-R7TSEDQI-CygoACFs.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-Coc2oeHo.js → gitGraphDiagram-XJZIOB7I-ByxErzHV.js} +1 -1
- package/dist/assets/{hi-DmCL9a_Y.js → hi-BC0iO7jD.js} +1 -1
- package/dist/assets/{index-uiyAwyX1.js → index-BRfvYRb5.js} +1 -1
- package/dist/assets/{index-D69O3YiA.js → index-DQZxP2c4.js} +2 -2
- package/dist/assets/{index-C1PEx1tc.js → index-DtDQrExn.js} +3 -3
- package/dist/assets/{infoDiagram-5W2HQ5XZ-DScYPtht.js → infoDiagram-5W2HQ5XZ-BlzjfTwq.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-Cf7mJB_l.js → ishikawaDiagram-K3B6WC7H-2rf_4lR_.js} +1 -1
- package/dist/assets/{it-BWkdcVfm.js → it-BIwsqdpz.js} +2 -2
- package/dist/assets/{ja-BaOL6cSA.js → ja-BJYXkO5E.js} +2 -2
- package/dist/assets/{journeyDiagram-COXZFDF6-Dtmolw3A.js → journeyDiagram-COXZFDF6-mGgPoETt.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-CSL1-s5L.js → kanban-definition-P3RFRI5V-j2hU8Bw4.js} +1 -1
- package/dist/assets/{kit-Cjq8TV0N.js → kit-qjammJR4.js} +1 -1
- package/dist/assets/{ko-ebMBLBXv.js → ko-7QtaPFvf.js} +2 -2
- package/dist/assets/{livekit-KT4NEVZO-B3DA1PsD.js → livekit-KT4NEVZO-DbFoU2r9.js} +1 -1
- package/dist/assets/{mcp-servers-DoMFsds6.js → mcp-servers-Tb2cnkiM.js} +1 -1
- package/dist/assets/{memory-BR-ujoQY.js → memory-BNaMRI5v.js} +1 -1
- package/dist/assets/{mermaid.core-BK1qxlD4.js → mermaid.core-B1mlFiOp.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-Cb7ESZ0y.js → mindmap-definition-LZFPQGKD-C7XLkIzZ.js} +1 -1
- package/dist/assets/{minimize-msM7mbil.js → minimize-Dga3UCb8.js} +1 -1
- package/dist/assets/{monitor-DpsqT1_R.js → monitor-DMPjQDZP.js} +1 -1
- package/dist/assets/{org-library-alRyzCTE.js → org-library-IKFXm7D6.js} +1 -1
- package/dist/assets/{package-format-BFXbXHk8.js → package-format-COujx3jP.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-CqmJQKhe.js → pegDiagram-BGZESJAR-BS2zKH6g.js} +1 -1
- package/dist/assets/{phones-J7mYR-fY.js → phones-CINpTjZv.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-w_QuumOv.js → pieDiagram-CAPJLFHJ-DVAuLXem.js} +1 -1
- package/dist/assets/{pl-CSbinyb5.js → pl-CLa2ta1_.js} +2 -2
- package/dist/assets/{pt-br-BkWykL5e.js → pt-br-8RQzCbpg.js} +3 -3
- package/dist/assets/{quadrantDiagram-GDMTTRAM-248q9C3h.js → quadrantDiagram-GDMTTRAM-H7QRxmHt.js} +1 -1
- package/dist/assets/{rail-DRr_33Fe.js → rail-DNpLzOxa.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-BLzQ_5t7.js → railroadDiagram-SM67HX2B-dq6Rokc9.js} +1 -1
- package/dist/assets/{remote-desktop-panel-BPK6Q0O6.js → remote-desktop-panel-Cxv6Qt3x.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-Bgi1TLdN.js → requirementDiagram-X7JNWC4A-BeWeL_-r.js} +1 -1
- package/dist/assets/{ru-DD01Hb1S.js → ru-CIdzvRVZ.js} +2 -2
- package/dist/assets/{sankeyDiagram-UM26HJRW-CrZgn-Cf.js → sankeyDiagram-UM26HJRW-BmJ-9lt-.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-gAwq1ZfG.js → sequenceDiagram-ZO4K6R2Y-Uuh1hEOh.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BlXmG_DJ.js → sizeCapture-INFHLROL-mKDf6lys.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-CEFB1Iaq.js → stateDiagram-v2-TBUQTH76-BaEihzov.js} +1 -1
- package/dist/assets/{styles-DOJOOIp4.js → styles-3g-ZPS7M.js} +5 -5
- package/dist/assets/styles-CsrDURJH.css +1 -0
- package/dist/assets/{swimlanes-N4OXWK64-BtJmWAOz.js → swimlanes-N4OXWK64-CpP-NKGz.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-C50Dm6LQ.js +8 -0
- package/dist/assets/{template-add-BcTS64TG.js → template-add-CHwGLPet.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-BZ270zxf.js → timeline-definition-YOQAKGHF-Ca3rjetv.js} +1 -1
- package/dist/assets/{tr-Bw35A32w.js → tr-BhclavHM.js} +1 -1
- package/dist/assets/{uk-DsPsCgp4.js → uk-Or5wmf6s.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-D5yZb3KQ.js → usecaseDiagram-VIAY4XPW-BuuYl689.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-OFx2qTzp.js → vennDiagram-BLWOH2XV-C__pWnnE.js} +1 -1
- package/dist/assets/{vi-DhPdzwW-.js → vi-CYbGVqh-.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-DzSmrVKa.js → wardleyDiagram-YMQ3BMBF-yWcEHD-N.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-UP1H1u5V.js → xychartDiagram-TAQBALBS-CvcdOA7A.js} +1 -1
- package/dist/assets/{zh-CzC3CUQA.js → zh-iptM1e_T.js} +2 -2
- package/dist/assets/{zh-tw-DeXHnAvy.js → zh-tw-BaO1c--E.js} +2 -2
- package/dist/index.html +3 -3
- package/dist/rail.html +5 -5
- package/dist-server/container-mcp.js +18 -17
- package/dist-server/index.js +1136 -1114
- package/dist-server/openmausbot.js +182 -180
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +182 -180
- package/dist-server/server/ai-pool.js +72 -0
- package/dist-server/server/cloud-connected-apps.js +33 -16
- package/dist-server/server/composio-broker-access.js +1 -1
- package/dist-server/server/composio.js +3 -2
- package/dist-server/server/config.js +5 -7
- package/dist-server/server/connector-auth-config-hint.js +5 -0
- package/dist-server/server/drivers/claude.js +14 -11
- package/dist-server/server/flatpak-host.js +5 -2
- package/dist-server/server/host/ai-pool.js +109 -0
- package/dist-server/server/host/app-suggestions.js +2 -1
- package/dist-server/server/host/limit-takeover.js +11 -4
- package/dist-server/server/index.js +33 -26
- package/dist-server/server/limit-failover.js +3 -0
- package/dist-server/server/model-selection-schema.js +9 -0
- package/dist-server/server/routes/ai-pool-patch.js +24 -0
- package/dist-server/server/routes/config.js +8 -1
- package/dist-server/server/routine-dispatch.js +21 -0
- package/dist-server/server/routines.js +4 -18
- package/dist-server/server/tailscale.js +16 -6
- package/dist-server/server/workspace-backup-http.js +2 -2
- package/dist-server/shared/limit-backup.js +1 -1
- package/dist-server/shared/settings-places.js +1 -0
- package/dist-server/shared/toolkit-card.js +1 -0
- package/dist-server/vps-container-mcp.js +18 -17
- package/dist-server/workspace-backup.worker.js +18 -17
- package/package.json +1 -1
- package/dist/assets/PluginsPanel-B5Q70eO8.js +0 -8
- package/dist/assets/RoutinesPage-CLXohizn.js +0 -2
- package/dist/assets/SettingsModal-BlX9XoBu.js +0 -2
- package/dist/assets/channel-DZM5KU--.js +0 -1
- package/dist/assets/styles-9UFSdSaJ.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-pBTtzroP.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,t,a as B,i as ae,w as he,r as x,X as be,C as fe,n as Ae,d as Re,S as Te}from"./styles-DOJOOIp4.js";import{cy as ge,cz as Ee,cA as ze,cB as ie,al as Me,u as U,cC as Le,cD as Oe,cE as ee,cF as ye,cG as le,cH as Pe,cI as ke,cJ as Fe,cK as $e,cL as We,cM as _e,bT as Ue,cN as Ye,cO as je,cP as ce,cQ as He,a9 as Ge,T as Je,cR as qe,cS as Qe,cT as Z,cU as ve,at as we,cV as Ke,cW as se,cX as Ve,cY as Xe,cZ as Ne,g as W,c_ as Se,c$ as Ze,d0 as et,d1 as tt,d2 as ue,d3 as st,d4 as nt,d5 as at,d6 as it,y as re,o as rt,d7 as ot,d8 as lt,d9 as dt,da as ct,S as Ce,db as ut,dc as xt}from"./App-BIllYA_e.js";import{AppEventEditor as mt}from"./AppEventEditor-DYdUkpiM.js";import{C as pt,q as ht,B as bt,a as ft,P as xe}from"./PlacesRail-3RaNlpug.js";import{C as Ie,S as gt}from"./MenuMotion-DfjnHTCi.js";import{C as yt,E as kt,Q as jt,b as vt,H as wt,R as Nt}from"./RoutinesPage-CLXohizn.js";import{T as St,a as Ct,b as It,c as Bt}from"./ToolPageShell-BPd_nyJ8.js";import{WebhookEditor as Dt}from"./WebhookTrigger-AJduidiC.js";import"./index-C1PEx1tc.js";import"./monitor-DpsqT1_R.js";import"./placement-BKtVnQht.js";import"./remote-desktop-CsSfkXSy.js";import"./ProIntroduction-B3phUWnc.js";const oe="\0general";function At(s,o){const r=s.filter(c=>!c.hidden),k=new Set(r.map(c=>c.section).filter(c=>!!c));return{names:o.filter(c=>k.has(c)),hasGeneral:r.some(c=>!c.section)}}function te(s,o){return o==="all"?!0:s?o===oe?!s.section:s.section===o:!1}function Rt({trigger:s}){const{attempts:o,service:r}=ge(),k=o.filter(l=>l.triggerId===s.id).slice(-6).reverse(),c=Ee(s);return e.jsxs("section",{"data-app-events":s.id,children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.events")}),c&&e.jsx("p",{className:"mb-2 rounded-lg bg-warning/10 px-2.5 py-1.5 text-[12px] text-warning",children:c}),k.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noEvents")}):e.jsx("ul",{className:"space-y-1",children:k.map(l=>{const b=ze(l),d=ie(l.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:d.charAt(0).toLocaleUpperCase()+d.slice(1)}),e.jsx("span",{className:B("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})]},l.id)})}),r?.eventsPerDay&&e.jsx("p",{className:"mt-2 text-[11px] text-ink-tertiary",children:t("automations.app.limit",{count:r.eventsPerDay.toLocaleString(ae()),place:t(r.plan==="cloud"?"automations.app.placeCloud":"automations.app.placeDesktop")})})]})}function Be({status:s,className:o}){return s.state==="needs-you"?e.jsx(Me,{size:15,"aria-hidden":"true",className:B("shrink-0 text-warning",o)}):s.state==="done"?e.jsx(he,{size:14,"aria-hidden":"true",className:B("shrink-0 text-ink-tertiary",o)}):e.jsx("span",{"aria-hidden":"true",className:B("size-2.5 shrink-0 rounded-full",s.state==="working"?"bg-success":"bg-ink-tertiary/60",o)})}function De({automation:s,status:o,actions:r,onEdit:k,className:c}){const{dispatch:l}=U();if(o.state!=="needs-you"||!o.fix)return null;const b=o.fix,d=b==="answer"?Le(s.runs):void 0,i=()=>{b==="answer"?r.openRun(s,d):b==="sign-in"?r.openRun(s,s.runs.find(h=>h.status!=="queued")):b==="usage"?l({type:"toggleAppSettings",open:!0,section:"usage"}):b==="edit"?k():b==="reconnect"?l({type:"togglePlugins",open:!0,surface:"apps"}):r.runNow(s)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:i,disabled:!!r.busy,className:B("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",c),children:t(Oe[b])}),d&&e.jsx("button",{type:"button","data-automation-cancel-run":!0,onClick:()=>{r.cancelRun(s,d)},disabled:!!r.busy,className:B("shrink-0 rounded-lg px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",c),children:t("routines.drawer.cancelRun")})]})}const Tt=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:s,sentence:o,onClose:r,onEdit:k,onDeleted:c}){const{state:l,dispatch:b}=U(),[d]=x.useState(()=>new Set(s.runs.filter(u=>ee(u)&&!u.seenAt).map(u=>u.id))),i=s.runs.filter((u,S)=>S<Tt||d.has(u.id)||ee(u)&&!u.seenAt);x.useEffect(()=>{for(const u of s.runs)ee(u)&&!u.seenAt&&b({type:"markRoutineRunSeen",runId:u.id})},[s.runs,b]);const h=ye(),j=le(s),y=s.kind==="webhook"?l.webhooks.find(u=>u.id===s.id):void 0,C=y?Pe(ke())[y.id]:void 0,f=l.webhookIngress?.available!==!1,I=t(Fe[j.state]),N=s.name.trim(),R=l.bots.find(u=>u.id===s.botId)?.name??t("routines.unavailableBot"),w=s.instructions.trim(),m=j.state==="done"?t("automations.reason.done"):j.reason,T=y?$e(y.id,l.webhookAttempts):[],E=y?We(y,l.webhookAttempts):null,[M,_]=x.useState(null),[z,D]=x.useState(!1),[O,L]=x.useState(!1),$=async u=>{if(await ht(u)!=="copied"){h.setError(t("automations.address.copyFailed"));return}L(!0),setTimeout(()=>L(!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:N||o}),N&&e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:_e(s,R)})]}),e.jsx("button",{type:"button",onClick:r,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:B("font-medium",j.state==="needs-you"?"text-warning":"text-ink"),children:I}),m&&e.jsx("span",{className:"min-w-0 text-ink-secondary",children:m}),e.jsx(De,{automation:s,status:j,actions:h,onEdit:k})]}),y&&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:!!h.busy||!f,onClick:()=>{h.copyAddress(y.id)},className:B(Q,"mt-2.5 bg-accent text-accent-ink hover:brightness-110"),children:[h.copied===y.id?e.jsx(he,{size:14}):e.jsx(pt,{size:14}),h.copied===y.id?t("automations.address.copied"):t("automations.address.copy")]}),(!f||!l.config?.cloudHome)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:f?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:[E&&e.jsxs("section",{"aria-label":t("automations.received.title"),children:[e.jsxs("p",{className:"font-medium text-ink",children:[t("automations.received.title")," · ",ie(E.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:E.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")}),T.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:T.map(u=>e.jsxs("li",{"data-call":u.ok?"ok":"refused",children:[e.jsxs("button",{type:"button","aria-expanded":M===u.id,onClick:()=>_(S=>S===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:Ue(ie(u.at))}),e.jsx("span",{className:B("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})]}),M===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")}),C?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1","data-secret":z?"shown":"masked",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[11px]",children:t("automations.address.secret",{secret:z?C.secret:"••••••••"})}),e.jsx("button",{type:"button","aria-label":t(z?"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(z?"automations.address.hideSecret":"automations.address.revealSecret")}),e.jsx("button",{type:"button","aria-label":t("automations.address.copySecretLabel"),onClick:()=>{$(C.secret)},className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:O?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")}),y.eventTypes?.length?e.jsx("p",{children:t("automations.address.events",{events:y.eventTypes.join(", ")})}):null,e.jsxs("button",{type:"button",disabled:!!h.busy,onClick:()=>{window.confirm(t("automations.address.replaceConfirm"))&&h.copyAddress(y.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(Ye,{size:12}),t("automations.address.replace")]})]})]})]}),N&&w&&e.jsx("p",{"data-testid":"automation-instructions",className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed text-ink",children:w}),s.appTrigger&&e.jsx(Rt,{trigger:s.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")}),s.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 S=je(u);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!u.threadId,onClick:()=>h.openRun(s,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:S.when}),e.jsx("span",{className:B("shrink-0 font-semibold",S.mark==="✓"?"text-success":S.mark==="✗"?"text-danger":"text-warning"),children:S.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:S.text})]})},u.id)})})]}),h.error&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:h.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:!!h.busy,onClick:()=>{h.runNow(s)},className:B(Q,"bg-accent text-accent-ink hover:brightness-110"),children:[e.jsx(ce,{size:14}),h.busy===`run:${s.id}`?t("automations.starting"):t("automations.runNow")]}),j.state!=="done"&&e.jsxs("button",{type:"button",disabled:!!h.busy,onClick:()=>{h.toggle(s)},className:B(Q,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[s.enabled?e.jsx(He,{size:14}):e.jsx(ce,{size:14}),s.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:k,className:B(Q,"text-ink hover:bg-raised"),children:[e.jsx(Ge,{size:14}),t("automations.edit")]}),e.jsxs("button",{type:"button",disabled:!!h.busy,onClick:()=>{h.remove(s,t("automations.deleteConfirm",{sentence:o})).then(u=>{u&&c()})},className:B(Q,"text-danger hover:bg-danger/10"),children:[e.jsx(Je,{size:14}),t("automations.delete")]})]})]})}const zt=()=>Array.from({length:7},(s,o)=>new Intl.DateTimeFormat(Ae(),{weekday:"narrow",timeZone:"UTC"}).format(Date.UTC(2023,0,2+o)));function ne(s){const o=new Date(s);return new Date(o.getFullYear(),o.getMonth(),1)}function me(s,o){return s.getFullYear()===o.getFullYear()&&s.getMonth()===o.getMonth()&&s.getDate()===o.getDate()}function pe(s,o){return new Date(s.getFullYear(),s.getMonth()+o,1)}function Mt({anchor:s,onSelect:o}){const[r,k]=x.useState(()=>ne(s));x.useEffect(()=>{k(ne(s))},[s]);const c=x.useMemo(()=>{const i=ne(r),h=(i.getDay()+6)%7,j=new Date(i);return j.setDate(i.getDate()-h),Array.from({length:42},(y,C)=>{const f=new Date(j);return f.setDate(j.getDate()+C),f})},[r]),l=new Date(s),b=new Date,d=r.toLocaleDateString(ae(),{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:d}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>k(i=>pe(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:()=>k(i=>pe(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,h)=>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}-${h}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:c.map(i=>{const h=me(i,l),j=me(i,b),y=i.getMonth()!==r.getMonth(),C=i.toLocaleDateString(ae(),{weekday:"long",month:"long",day:"numeric",year:"numeric"});return e.jsx("button",{type:"button",onClick:()=>o(i.getTime()),"aria-label":C,"aria-current":j?"date":void 0,"aria-pressed":h,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 ${h?"bg-accent font-semibold text-white shadow-sm":j?"font-semibold text-accent group-hover:bg-accent/12":y?"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 Lt="application/x-openmaus-bot";function Ot({bots:s,anchor:o,onSelectDate:r}){const[k,c]=x.useState(""),l=x.useMemo(()=>{const d=k.trim().toLocaleLowerCase();return d?s.filter(i=>`${i.name} ${i.title} ${i.description}`.toLocaleLowerCase().includes(d)):s},[s,k]),b=(d,i)=>{d.dataTransfer.effectAllowed="copy",d.dataTransfer.setData(Lt,i.id),d.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(Mt,{anchor:o,onSelect:r}),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(qe,{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:s.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:k,onChange:d=>c(d.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:[l.map(d=>e.jsxs("div",{draggable:!0,onDragStart:i=>b(i,d),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:d.name}),title:t("routines.sidebar.dragBot",{name:d.name}),children:[e.jsx(Qe,{size:13,className:"shrink-0 text-ink-secondary/35 transition-colors group-hover:text-ink-secondary","aria-hidden":"true"}),e.jsx(bt,{bot:d,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:d.name}),e.jsx("div",{className:"truncate text-[10px] text-ink-tertiary",children:d.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")})]},d.id)),l.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] leading-relaxed text-ink-secondary",children:s.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 Pt({botFilter:s,department:o="all",selectedAutomationId:r,onOpenAutomation:k,onOpenRoom:c}){const{state:l,dispatch:b}=U(),d=window.ogb?.remoteClient?.active===!0,[i,h]=x.useState(()=>window.innerWidth<640?1:7),[j,y]=x.useState(()=>Z(Date.now())),[C,f]=x.useState([]),[I,N]=x.useState(null),[R,w]=x.useState(null),[m,T]=x.useState(null),[E,M]=x.useState(""),_=l.bots.filter(a=>!a.hidden),z=ve(_,we(),R?.botIds[0]),D=i===7?Ke(j):Z(j),O=se(D,i);Ve(D);const L=Xe(Ne(),D,O),$=x.useCallback(async()=>{try{f((await W("/api/calendar-calls")).calls??[])}catch(a){M(a instanceof Error?a.message:String(a))}},[]);x.useEffect(()=>{d||$()},[$,d]);const u=x.useMemo(()=>{const a=new Set(l.bots.map(v=>v.id)),g=l.routines.filter(v=>a.has(v.botId)),p=new Set(Se({routines:g,webhooks:[],runs:l.routineRuns}).filter(v=>le(v).state==="needs-you").map(v=>v.id)),G=Ze(g,l.routineRuns.filter(v=>a.has(v.botId)),D,O).map(v=>({...v,kind:"routine",needsYou:!!(v.routine&&!v.run&&p.has(v.routine.id))})),J=et(C,D,O).map(v=>({...v,kind:"call"})),de=v=>l.bots.find(q=>q.id===v);return[...G,...J].filter(v=>v.kind==="call"?v.call.botIds.some(q=>te(de(q),o)):te(de(v.routine?.botId??v.run?.botId),o)).filter(v=>s==="all"||(v.kind==="call"?v.call.botIds.includes(s):(v.routine?.botId??v.run?.botId)===s)).sort((v,q)=>v.at-q.at)},[l.routines,l.routineRuns,l.bots,C,D,O,s,o]),S=m?.kind==="call"?(()=>{const a=C.find(g=>g.id===m.call.id);return a?{...m,call:a}:null})():null,K=a=>{if(a.kind==="call"){T(a);return}T(null);const g=a.routine?.id??a.run?.routineId;g&&k(g)},P=a=>k(a.routineId),Y=S?.id??u.find(a=>a.kind==="routine"&&(a.routine?.id??a.run?.routineId)===r)?.id,F=a=>f(g=>g.some(p=>p.id===a.id)?g.map(p=>p.id===a.id?a:p):[a,...g]),V=async(a,g)=>{if(g!==a.at)try{if(a.kind==="routine"){const p=l.routines.find(J=>J.id===a.id);if(!p)return;if(p.schedule.type==="cron")throw new Error(t("automations.calendar.cronMove"));if(p.schedule.type!=="once"&&!window.confirm(t("automations.calendar.moveSeries")))return;const G=await W(`/api/routines/${p.id}`,{method:"PATCH",body:JSON.stringify({schedule:ue(p.schedule,a.at,g)})});b({type:"routinePatched",routine:G.routine})}else{const p=C.find(J=>J.id===a.id);if(!p||p.schedule.type==="daily"&&!window.confirm(t("automations.calendar.moveSeries")))return;const G=await W(`/api/calendar-calls/${p.id}`,{method:"PATCH",body:JSON.stringify({schedule:ue(p.schedule,a.at,g)})});F(G.call)}}catch(p){M(p instanceof Error?p.message:String(p))}},X=async(a,g)=>{if("botId"in a){T(null),N({kind:"routine",at:g.at,durationMinutes:30,botIds:[a.botId],limitReset:{engine:g.engine}});return}if(a.event.kind!=="routine")return M(t("limits.callNotOnReset"));try{const p=await W(`/api/routines/${a.event.id}`,{method:"PATCH",body:JSON.stringify({schedule:{type:"limit_reset",engine:g.engine,repeat:"once"}})});b({type:"routinePatched",routine:p.routine})}catch(p){M(p instanceof Error?p.message:String(p))}},n=async(a,g)=>{try{if(a.kind==="routine"&&a.routine){const p=await W(`/api/routines/${a.routine.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:g})});b({type:"routinePatched",routine:p.routine})}else if(a.kind==="call"){const p=await W(`/api/calendar-calls/${a.call.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:g})});F(p.call)}}catch(p){M(p instanceof Error?p.message:String(p))}},A=()=>{S&&(w({kind:"call",at:S.at,durationMinutes:S.call.durationMinutes,botIds:S.call.botIds,call:S.call}),T(null))},H=a=>B("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:()=>y(a=>se(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:()=>y(a=>se(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:tt(D,i)}),e.jsx("button",{type:"button",onClick:()=>y(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:()=>h(1),className:H(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>h(7),className:H(i===7),children:t("routines.view.week")})]}),E&&e.jsx("button",{type:"button",onClick:()=>M(""),className:"w-full text-left text-[12px] text-danger",children:E})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[!S&&e.jsx("div",{className:"hidden shrink-0 @min-[1040px]/routines:block",children:e.jsx(Ot,{bots:_,anchor:j,onSelectDate:a=>y(Z(a))})}),e.jsx(yt,{anchor:D,days:i,items:u,bots:l.bots,groups:l.groups,selectedId:Y,onOpen:K,onCreate:a=>{T(null),N(a)},onMove:(a,g)=>{V(a,g)},onResize:(a,g)=>{n(a,g)},markers:L,onDropOnReset:(a,g)=>{X(a,g)}}),S&&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(kt,{item:S,bots:l.bots,onClose:()=>T(null),onEdit:A,onOpenRun:P,onCallChanged:a=>{a?f(g=>g.filter(p=>p.id!==a)):$()},onOpenRoom:c},`${S.kind}:${S.id}`)})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/25",onMouseDown:()=>N(null)}),e.jsx(jt,{seed:I,bots:z,routinesOnly:d,onClose:()=>N(null),onMore:a=>{N(null),w(a)},onSavedRoutine:a=>b({type:"routinePatched",routine:a}),onSavedCall:F})]}),R&&e.jsx(vt,{seed:R,bots:z,routinesOnly:d,onClose:()=>w(null),onSavedCall:F})]})}function Ft({botFilter:s="all"}){const{state:o,dispatch:r}=U(),k=st(Ne()),[c,l]=x.useState(null),[b,d]=x.useState(null),[i,h]=x.useState("");if(!k.length)return null;const j=f=>o.bots.find(I=>I.id===f)?.modelSelection?.instanceId,y=o.routines.filter(f=>s==="all"||f.botId===s),C=async(f,I)=>{l(f.engine),h("");try{for(const N of I){const R=await W("/api/limit-resets/after-reset",{method:"POST",body:JSON.stringify({routineId:N.id,engine:f.engine})});r({type:"routinePatched",routine:R.routine})}d(f.engine)}catch(N){h(N instanceof Error?N.message:String(N))}finally{l(null)}};return e.jsxs("section",{"aria-label":t("limits.title"),className:"mb-4 space-y-2",children:[k.map(f=>{const I=nt(y,j,f);return e.jsxs("div",{"data-limit-warning":f.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(wt,{size:15,className:"shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{className:"font-medium tabular-nums",children:at(f)}),I.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-secondary",children:t(I.length===1?"limits.dueOne":"limits.dueMany",{count:I.length})}),e.jsx("button",{type:"button",disabled:c===f.engine,onClick:()=>{C(f,I)},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===f.engine&&e.jsx("span",{className:"text-ink-secondary",children:t("limits.moved")})]},f.engine)}),i&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:i})]})}function $t(s,o){const r=s.find(c=>c.id===o);if(r)return r;const k=c=>c.messages.at(-1)?.at??0;return[...s].sort((c,l)=>k(l)-k(c))[0]}function Wt({initialText:s="",onClose:o,onSetUpYourself:r}){const{state:k,dispatch:c}=U(),l=k.bots.filter(m=>!m.hidden),[b,d]=x.useState(s),[i,h]=x.useState(()=>$t(l,k.selectedId)?.id??""),[j,y]=x.useState(!1),[C,f]=x.useState("schedule"),I=x.useRef(null);ft(I,o);const N=l.find(m=>m.id===i),R=()=>{const m=b.trim();!m||!N||(c({type:"select",id:N.id}),c({type:"send",botId:N.id,text:m,threadId:N.threadId}),o())},w=(m,T,E)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":C===m,onClick:()=>f(m),className:B("flex w-full items-center gap-3 rounded-xl border px-3.5 py-3 text-left text-[14px]",C===m?"border-accent/70 bg-accent/10 text-ink":"border-hairline/50 text-ink-secondary hover:bg-raised"),children:[e.jsx(E,{size:16,className:"shrink-0 text-accent"}),T]});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:m=>m.target===m.currentTarget&&o(),children:e.jsxs("div",{ref:I,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:o,"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:[w("schedule",t("automations.newBox.onSchedule"),rt),w("app",t("automations.newBox.whenAppEvent"),ot),w("webhook",t("automations.newBox.whenApp"),lt)]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>y(!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:()=>r(C,N?.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:m=>d(m.target.value),rows:3,"aria-label":t("automations.newBox.title"),placeholder:t("automations.newBox.placeholder"),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&!it(m.nativeEvent)&&(m.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"}),l.length===0&&e.jsx("p",{className:"mt-2 text-[13px] text-warning",children:t("automations.newBox.noBots")}),l.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:m=>h(m.target.value),"aria-label":t("automations.newBox.bot"),className:"max-w-[220px]",children:l.map(m=>e.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>y(!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()||!N,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(gt,{size:14}),t("automations.newBox.send")]})]})]})]})})}const _t=9;function ns({onBack:s,onOpenRoom:o}){const{state:r,dispatch:k}=U(),c=ye(),l=ge(),b=x.useRef(null),d=r.routinesFocus,i=d?.view==="calendar"?"calendar":"list",[h,j]=x.useState(d?.section!=="logs"?d?.routineId??null:null),[y,C]=x.useState(d?.botId??"all"),[f,I]=x.useState("all"),[N,R]=x.useState(null),[w,m]=x.useState(null),T=window.ogb?.remoteClient?.active===!0,E=r.bots.filter(n=>!n.hidden),M=we(),_=n=>r.bots.find(A=>A.id===n)?.name??t("routines.unavailableBot");x.useEffect(()=>{C(d?.botId??"all"),d?.routineId&&d.section!=="logs"&&j(d.routineId)},[d]),x.useEffect(()=>{b.current?.focus({preventScroll:!0})},[]);const z=x.useMemo(()=>Se({routines:r.routines,webhooks:T?[]:r.webhooks,appTriggers:l.triggers,runs:r.routineRuns,bots:r.bots}),[r.routines,r.webhooks,l.triggers,r.routineRuns,r.bots,T]),D=At(r.bots,[...new Set([...r.sections??[],...r.bots.flatMap(n=>n.section?[n.section]:[])])]),O=D.names.length+(D.hasGeneral?1:0)>1,L=f==="all"||(f===oe?D.hasGeneral:D.names.includes(f))?f:"all";x.useEffect(()=>{L!==f&&(I("all"),C("all"))},[L,f]);const $=n=>te(r.bots.find(A=>A.id===n),L),u=E.filter(n=>te(n,L)),S=z.length>=_t&&new Set(z.map(n=>n.botId)).size>1,K=dt(z.filter(n=>$(n.botId)&&(!S||y==="all"||n.botId===y))),P=z.find(n=>n.id===h)??null,Y=n=>xt(n,_(n.botId)),F=w?.kind==="schedule"?r.routines.find(n=>n.id===w.id):void 0,V=w?.kind==="webhook"?r.webhooks.find(n=>n.id===w.id):void 0,X=w?.kind==="app"?l.triggers.find(n=>n.id===w.id):void 0;return e.jsxs(St,{children:[e.jsxs(Ct,{backLabel:t("automations.back"),onBack:s,backRef:b,besideSidebar:i==="list",children:[e.jsx("h1",{"data-tour":"automations-page",className:It,children:t("automations.title")}),e.jsxs(Bt,{children:[O&&e.jsxs(re,{size:"sm","aria-label":t("automations.allDepartments"),value:L,onChange:n=>{I(n.target.value),C("all")},className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allDepartments")}),D.names.map(n=>e.jsx("option",{value:n,children:n},n)),D.hasGeneral&&e.jsx("option",{value:oe,children:t("automations.generalDepartment")})]}),S&&i==="list"&&e.jsxs(re,{size:"sm","aria-label":t("automations.allBots"),value:y,onChange:n=>C(n.target.value),className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allBots")}),u.map(n=>e.jsx("option",{value:n.id,children:n.name},n.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(n=>e.jsx("button",{type:"button","aria-pressed":i===n,onClick:()=>k({type:"showRoutines",view:n,botId:y==="all"?void 0:y}),className:B("rounded-md px-3 py-1 text-[13px] font-medium",i===n?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:n==="list"?t("automations.list"):t("automations.calendar")},n))}),e.jsxs("button",{type:"button",onClick:()=>R(""),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(xe,{size:15,"aria-hidden":"true"}),t("automations.new")]})]})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[i==="calendar"?e.jsx(Pt,{botFilter:y,department:L,selectedAutomationId:h,onOpenAutomation:j,onOpenRoom:o}):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(Ft,{botFilter:S?y:"all"}),r.config?.routinesUnreadable&&e.jsx("div",{role:"alert",className:"mb-4 rounded-lg bg-danger/10 p-3 text-[12px] leading-relaxed text-danger","data-routines-unreadable":"",children:t("routines.unreadable")}),z.length===0&&!r.config?.routinesUnreadable&&r.routinesLoadState!=="loading"&&r.hydrated?e.jsxs("section",{"aria-label":t("automations.empty.title"),className:"px-6 py-16 text-center",children:[e.jsx(Te,{state:"sleep",size:96,className:"mx-auto mb-2"}),e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:t("automations.empty.title")}),e.jsx("button",{type:"button",onClick:()=>R(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:()=>R(""),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(xe,{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:K.map(n=>{const A=le(n),H=n.name.trim(),a=n.runs.find(p=>ee(p)&&!p.seenAt),g=a&&je(a);return e.jsxs("li",{"data-automation":n.id,"data-automation-status":A.state,className:B("relative flex items-start gap-3 px-4 py-3.5",h===n.id&&"bg-raised/60"),children:[e.jsx(Be,{status:A,className:"mt-[5px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>j(n.id),className:"block text-left text-[15px] font-medium leading-snug text-ink after:absolute after:inset-0 hover:text-accent-text",children:H||Y(n)}),H&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink",children:Y(n)}),A.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:A.reason??""}),e.jsx(De,{automation:n,status:A,actions:c,onEdit:()=>m({kind:n.kind,id:n.id}),className:"relative z-10"})]}):e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:ct(n)}),g&&e.jsxs("button",{type:"button",onClick:()=>j(n.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:[g.when," ",g.mark," ",g.text]})]}),!!n.noStartStreak&&e.jsx("div",{className:"mt-1 text-[13px] text-warning","data-automation-no-start":"",children:t("routines.noStartStreak",{count:n.noStartStreak})}),c.error&&c.errorFor?.endsWith(`:${n.id}`)&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:c.error})]}),A.state!=="done"&&e.jsx(Ce,{checked:n.enabled,disabled:c.busy===`toggle:${n.id}`,"aria-label":t("automations.toggle",{name:n.name}),onClick:()=>{c.toggle(n)},className:"relative z-10 mt-0.5 shrink-0"})]},n.id)})}),c.error&&!K.some(n=>c.errorFor?.endsWith(`:${n.id}`))&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:c.error}),e.jsx(Ut,{})]})}),P&&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:P,sentence:Y(P),onClose:()=>j(null),onDeleted:()=>j(null),onEdit:()=>m({kind:P.kind,id:P.id})},P.id)})]}),N!==null&&e.jsx(Wt,{initialText:N,onClose:()=>R(null),onSetUpYourself:(n,A)=>{R(null),m({kind:n,botId:A})}}),w?.kind==="schedule"&&(F||!w.id)&&e.jsx(Nt,{routine:F,bots:ve(E,M,F?.botId),initialBotId:w.botId,plain:!0,onClose:()=>m(null)}),w?.kind==="webhook"&&(V||!w.id)&&e.jsx(Dt,{webhook:V,bots:E,initialBotId:w.botId,onClose:()=>m(null),onCredential:(n,A)=>{ut(ke(),A,n),j(A)}}),w?.kind==="app"&&(X||!w.id)&&e.jsx(mt,{trigger:X,bots:E,initialBotId:w.botId,onClose:()=>m(null),onSaved:n=>j(n.id)})]})}function Ut(){const s=typeof window<"u"?window.ogb?.routines:void 0,[o,r]=x.useState(null),[k,c]=x.useState(!1);return x.useEffect(()=>{if(!s)return;let l=!1;const b=()=>s.wakeState().then(i=>{l||r(i)}).catch(()=>{});b();const d=window.setInterval(b,3e4);return()=>{l=!0,window.clearInterval(d)}},[s]),!s||!o?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"),o.keepAwake&&o.onBattery?` ${t("automations.wakeBattery")}`:""]}),e.jsx(Ce,{checked:o.keepAwake,disabled:k,"aria-label":t("automations.wake"),onClick:()=>{c(!0),s.keepAwake(!o.keepAwake).then(r).catch(()=>{}).finally(()=>c(!1))},className:"shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}export{ns as TriggersPage};
|
|
1
|
+
import{j as e,t,a as B,i as ae,w as he,r as x,X as be,C as fe,n as Ae,d as Re,S as Te}from"./styles-3g-ZPS7M.js";import{cy as ge,cz as Ee,cA as ze,cB as ie,al as Me,u as U,cC as Le,cD as Oe,cE as ee,cF as ye,cG as le,cH as Pe,cI as ke,cJ as Fe,cK as $e,cL as We,cM as _e,bT as Ue,cN as Ye,cO as je,cP as ce,cQ as He,a9 as Ge,T as Je,cR as qe,cS as Qe,cT as Z,cU as ve,at as we,cV as Ke,cW as se,cX as Ve,cY as Xe,cZ as Ne,g as W,c_ as Se,c$ as Ze,d0 as et,d1 as tt,d2 as ue,d3 as st,d4 as nt,d5 as at,d6 as it,y as re,o as rt,d7 as ot,d8 as lt,d9 as dt,da as ct,S as Ce,db as ut,dc as xt}from"./App-h8WTNY4l.js";import{AppEventEditor as mt}from"./AppEventEditor-CLpZ2lyb.js";import{C as pt,q as ht,B as bt,a as ft,P as xe}from"./PlacesRail-Df-jNTHn.js";import{C as Ie,S as gt}from"./MenuMotion-CHp-hB40.js";import{C as yt,E as kt,Q as jt,b as vt,H as wt,R as Nt}from"./RoutinesPage-B9kKyfFp.js";import{T as St,a as Ct,b as It,c as Bt}from"./ToolPageShell-DKZUregg.js";import{WebhookEditor as Dt}from"./WebhookTrigger-BJN-V-bx.js";import"./index-DtDQrExn.js";import"./monitor-DMPjQDZP.js";import"./placement-BKtVnQht.js";import"./remote-desktop-CsSfkXSy.js";import"./ProIntroduction-D8hWm9R5.js";const oe="\0general";function At(s,o){const r=s.filter(c=>!c.hidden),k=new Set(r.map(c=>c.section).filter(c=>!!c));return{names:o.filter(c=>k.has(c)),hasGeneral:r.some(c=>!c.section)}}function te(s,o){return o==="all"?!0:s?o===oe?!s.section:s.section===o:!1}function Rt({trigger:s}){const{attempts:o,service:r}=ge(),k=o.filter(l=>l.triggerId===s.id).slice(-6).reverse(),c=Ee(s);return e.jsxs("section",{"data-app-events":s.id,children:[e.jsx("h3",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t("automations.panel.events")}),c&&e.jsx("p",{className:"mb-2 rounded-lg bg-warning/10 px-2.5 py-1.5 text-[12px] text-warning",children:c}),k.length===0?e.jsx("p",{className:"text-[13px] text-ink-secondary",children:t("automations.panel.noEvents")}):e.jsx("ul",{className:"space-y-1",children:k.map(l=>{const b=ze(l),d=ie(l.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:d.charAt(0).toLocaleUpperCase()+d.slice(1)}),e.jsx("span",{className:B("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})]},l.id)})}),r?.eventsPerDay&&e.jsx("p",{className:"mt-2 text-[11px] text-ink-tertiary",children:t("automations.app.limit",{count:r.eventsPerDay.toLocaleString(ae()),place:t(r.plan==="cloud"?"automations.app.placeCloud":"automations.app.placeDesktop")})})]})}function Be({status:s,className:o}){return s.state==="needs-you"?e.jsx(Me,{size:15,"aria-hidden":"true",className:B("shrink-0 text-warning",o)}):s.state==="done"?e.jsx(he,{size:14,"aria-hidden":"true",className:B("shrink-0 text-ink-tertiary",o)}):e.jsx("span",{"aria-hidden":"true",className:B("size-2.5 shrink-0 rounded-full",s.state==="working"?"bg-success":"bg-ink-tertiary/60",o)})}function De({automation:s,status:o,actions:r,onEdit:k,className:c}){const{dispatch:l}=U();if(o.state!=="needs-you"||!o.fix)return null;const b=o.fix,d=b==="answer"?Le(s.runs):void 0,i=()=>{b==="answer"?r.openRun(s,d):b==="sign-in"?r.openRun(s,s.runs.find(h=>h.status!=="queued")):b==="usage"?l({type:"toggleAppSettings",open:!0,section:"usage"}):b==="edit"?k():b==="reconnect"?l({type:"togglePlugins",open:!0,surface:"apps"}):r.runNow(s)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:i,disabled:!!r.busy,className:B("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",c),children:t(Oe[b])}),d&&e.jsx("button",{type:"button","data-automation-cancel-run":!0,onClick:()=>{r.cancelRun(s,d)},disabled:!!r.busy,className:B("shrink-0 rounded-lg px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-50",c),children:t("routines.drawer.cancelRun")})]})}const Tt=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:s,sentence:o,onClose:r,onEdit:k,onDeleted:c}){const{state:l,dispatch:b}=U(),[d]=x.useState(()=>new Set(s.runs.filter(u=>ee(u)&&!u.seenAt).map(u=>u.id))),i=s.runs.filter((u,S)=>S<Tt||d.has(u.id)||ee(u)&&!u.seenAt);x.useEffect(()=>{for(const u of s.runs)ee(u)&&!u.seenAt&&b({type:"markRoutineRunSeen",runId:u.id})},[s.runs,b]);const h=ye(),j=le(s),y=s.kind==="webhook"?l.webhooks.find(u=>u.id===s.id):void 0,C=y?Pe(ke())[y.id]:void 0,f=l.webhookIngress?.available!==!1,I=t(Fe[j.state]),N=s.name.trim(),R=l.bots.find(u=>u.id===s.botId)?.name??t("routines.unavailableBot"),w=s.instructions.trim(),m=j.state==="done"?t("automations.reason.done"):j.reason,T=y?$e(y.id,l.webhookAttempts):[],E=y?We(y,l.webhookAttempts):null,[M,_]=x.useState(null),[z,D]=x.useState(!1),[O,L]=x.useState(!1),$=async u=>{if(await ht(u)!=="copied"){h.setError(t("automations.address.copyFailed"));return}L(!0),setTimeout(()=>L(!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:N||o}),N&&e.jsx("p",{className:"mt-0.5 text-[13px] text-ink-secondary",children:_e(s,R)})]}),e.jsx("button",{type:"button",onClick:r,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:B("font-medium",j.state==="needs-you"?"text-warning":"text-ink"),children:I}),m&&e.jsx("span",{className:"min-w-0 text-ink-secondary",children:m}),e.jsx(De,{automation:s,status:j,actions:h,onEdit:k})]}),y&&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:!!h.busy||!f,onClick:()=>{h.copyAddress(y.id)},className:B(Q,"mt-2.5 bg-accent text-accent-ink hover:brightness-110"),children:[h.copied===y.id?e.jsx(he,{size:14}):e.jsx(pt,{size:14}),h.copied===y.id?t("automations.address.copied"):t("automations.address.copy")]}),(!f||!l.config?.cloudHome)&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:f?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:[E&&e.jsxs("section",{"aria-label":t("automations.received.title"),children:[e.jsxs("p",{className:"font-medium text-ink",children:[t("automations.received.title")," · ",ie(E.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:E.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")}),T.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:T.map(u=>e.jsxs("li",{"data-call":u.ok?"ok":"refused",children:[e.jsxs("button",{type:"button","aria-expanded":M===u.id,onClick:()=>_(S=>S===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:Ue(ie(u.at))}),e.jsx("span",{className:B("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})]}),M===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")}),C?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1","data-secret":z?"shown":"masked",children:[e.jsx("span",{className:"min-w-0 break-all font-mono text-[11px]",children:t("automations.address.secret",{secret:z?C.secret:"••••••••"})}),e.jsx("button",{type:"button","aria-label":t(z?"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(z?"automations.address.hideSecret":"automations.address.revealSecret")}),e.jsx("button",{type:"button","aria-label":t("automations.address.copySecretLabel"),onClick:()=>{$(C.secret)},className:"rounded-md px-1.5 py-0.5 font-medium text-ink hover:bg-raised",children:O?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")}),y.eventTypes?.length?e.jsx("p",{children:t("automations.address.events",{events:y.eventTypes.join(", ")})}):null,e.jsxs("button",{type:"button",disabled:!!h.busy,onClick:()=>{window.confirm(t("automations.address.replaceConfirm"))&&h.copyAddress(y.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(Ye,{size:12}),t("automations.address.replace")]})]})]})]}),N&&w&&e.jsx("p",{"data-testid":"automation-instructions",className:"whitespace-pre-wrap break-words text-[13px] leading-relaxed text-ink",children:w}),s.appTrigger&&e.jsx(Rt,{trigger:s.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")}),s.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 S=je(u);return e.jsx("li",{children:e.jsxs("button",{type:"button",disabled:!u.threadId,onClick:()=>h.openRun(s,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:S.when}),e.jsx("span",{className:B("shrink-0 font-semibold",S.mark==="✓"?"text-success":S.mark==="✗"?"text-danger":"text-warning"),children:S.mark}),e.jsx("span",{className:"min-w-0 truncate text-ink",children:S.text})]})},u.id)})})]}),h.error&&e.jsx("p",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:h.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:!!h.busy,onClick:()=>{h.runNow(s)},className:B(Q,"bg-accent text-accent-ink hover:brightness-110"),children:[e.jsx(ce,{size:14}),h.busy===`run:${s.id}`?t("automations.starting"):t("automations.runNow")]}),j.state!=="done"&&e.jsxs("button",{type:"button",disabled:!!h.busy,onClick:()=>{h.toggle(s)},className:B(Q,"border border-hairline/50 bg-control text-ink hover:bg-raised-hover"),children:[s.enabled?e.jsx(He,{size:14}):e.jsx(ce,{size:14}),s.enabled?t("automations.pause"):t("automations.resume")]}),e.jsxs("button",{type:"button",onClick:k,className:B(Q,"text-ink hover:bg-raised"),children:[e.jsx(Ge,{size:14}),t("automations.edit")]}),e.jsxs("button",{type:"button",disabled:!!h.busy,onClick:()=>{h.remove(s,t("automations.deleteConfirm",{sentence:o})).then(u=>{u&&c()})},className:B(Q,"text-danger hover:bg-danger/10"),children:[e.jsx(Je,{size:14}),t("automations.delete")]})]})]})}const zt=()=>Array.from({length:7},(s,o)=>new Intl.DateTimeFormat(Ae(),{weekday:"narrow",timeZone:"UTC"}).format(Date.UTC(2023,0,2+o)));function ne(s){const o=new Date(s);return new Date(o.getFullYear(),o.getMonth(),1)}function me(s,o){return s.getFullYear()===o.getFullYear()&&s.getMonth()===o.getMonth()&&s.getDate()===o.getDate()}function pe(s,o){return new Date(s.getFullYear(),s.getMonth()+o,1)}function Mt({anchor:s,onSelect:o}){const[r,k]=x.useState(()=>ne(s));x.useEffect(()=>{k(ne(s))},[s]);const c=x.useMemo(()=>{const i=ne(r),h=(i.getDay()+6)%7,j=new Date(i);return j.setDate(i.getDate()-h),Array.from({length:42},(y,C)=>{const f=new Date(j);return f.setDate(j.getDate()+C),f})},[r]),l=new Date(s),b=new Date,d=r.toLocaleDateString(ae(),{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:d}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>k(i=>pe(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:()=>k(i=>pe(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,h)=>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}-${h}`))}),e.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:c.map(i=>{const h=me(i,l),j=me(i,b),y=i.getMonth()!==r.getMonth(),C=i.toLocaleDateString(ae(),{weekday:"long",month:"long",day:"numeric",year:"numeric"});return e.jsx("button",{type:"button",onClick:()=>o(i.getTime()),"aria-label":C,"aria-current":j?"date":void 0,"aria-pressed":h,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 ${h?"bg-accent font-semibold text-white shadow-sm":j?"font-semibold text-accent group-hover:bg-accent/12":y?"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 Lt="application/x-openmaus-bot";function Ot({bots:s,anchor:o,onSelectDate:r}){const[k,c]=x.useState(""),l=x.useMemo(()=>{const d=k.trim().toLocaleLowerCase();return d?s.filter(i=>`${i.name} ${i.title} ${i.description}`.toLocaleLowerCase().includes(d)):s},[s,k]),b=(d,i)=>{d.dataTransfer.effectAllowed="copy",d.dataTransfer.setData(Lt,i.id),d.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(Mt,{anchor:o,onSelect:r}),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(qe,{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:s.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:k,onChange:d=>c(d.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:[l.map(d=>e.jsxs("div",{draggable:!0,onDragStart:i=>b(i,d),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:d.name}),title:t("routines.sidebar.dragBot",{name:d.name}),children:[e.jsx(Qe,{size:13,className:"shrink-0 text-ink-secondary/35 transition-colors group-hover:text-ink-secondary","aria-hidden":"true"}),e.jsx(bt,{bot:d,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:d.name}),e.jsx("div",{className:"truncate text-[10px] text-ink-tertiary",children:d.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")})]},d.id)),l.length===0&&e.jsx("div",{className:"px-3 py-8 text-center text-[11px] leading-relaxed text-ink-secondary",children:s.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 Pt({botFilter:s,department:o="all",selectedAutomationId:r,onOpenAutomation:k,onOpenRoom:c}){const{state:l,dispatch:b}=U(),d=window.ogb?.remoteClient?.active===!0,[i,h]=x.useState(()=>window.innerWidth<640?1:7),[j,y]=x.useState(()=>Z(Date.now())),[C,f]=x.useState([]),[I,N]=x.useState(null),[R,w]=x.useState(null),[m,T]=x.useState(null),[E,M]=x.useState(""),_=l.bots.filter(a=>!a.hidden),z=ve(_,we(),R?.botIds[0]),D=i===7?Ke(j):Z(j),O=se(D,i);Ve(D);const L=Xe(Ne(),D,O),$=x.useCallback(async()=>{try{f((await W("/api/calendar-calls")).calls??[])}catch(a){M(a instanceof Error?a.message:String(a))}},[]);x.useEffect(()=>{d||$()},[$,d]);const u=x.useMemo(()=>{const a=new Set(l.bots.map(v=>v.id)),g=l.routines.filter(v=>a.has(v.botId)),p=new Set(Se({routines:g,webhooks:[],runs:l.routineRuns}).filter(v=>le(v).state==="needs-you").map(v=>v.id)),G=Ze(g,l.routineRuns.filter(v=>a.has(v.botId)),D,O).map(v=>({...v,kind:"routine",needsYou:!!(v.routine&&!v.run&&p.has(v.routine.id))})),J=et(C,D,O).map(v=>({...v,kind:"call"})),de=v=>l.bots.find(q=>q.id===v);return[...G,...J].filter(v=>v.kind==="call"?v.call.botIds.some(q=>te(de(q),o)):te(de(v.routine?.botId??v.run?.botId),o)).filter(v=>s==="all"||(v.kind==="call"?v.call.botIds.includes(s):(v.routine?.botId??v.run?.botId)===s)).sort((v,q)=>v.at-q.at)},[l.routines,l.routineRuns,l.bots,C,D,O,s,o]),S=m?.kind==="call"?(()=>{const a=C.find(g=>g.id===m.call.id);return a?{...m,call:a}:null})():null,K=a=>{if(a.kind==="call"){T(a);return}T(null);const g=a.routine?.id??a.run?.routineId;g&&k(g)},P=a=>k(a.routineId),Y=S?.id??u.find(a=>a.kind==="routine"&&(a.routine?.id??a.run?.routineId)===r)?.id,F=a=>f(g=>g.some(p=>p.id===a.id)?g.map(p=>p.id===a.id?a:p):[a,...g]),V=async(a,g)=>{if(g!==a.at)try{if(a.kind==="routine"){const p=l.routines.find(J=>J.id===a.id);if(!p)return;if(p.schedule.type==="cron")throw new Error(t("automations.calendar.cronMove"));if(p.schedule.type!=="once"&&!window.confirm(t("automations.calendar.moveSeries")))return;const G=await W(`/api/routines/${p.id}`,{method:"PATCH",body:JSON.stringify({schedule:ue(p.schedule,a.at,g)})});b({type:"routinePatched",routine:G.routine})}else{const p=C.find(J=>J.id===a.id);if(!p||p.schedule.type==="daily"&&!window.confirm(t("automations.calendar.moveSeries")))return;const G=await W(`/api/calendar-calls/${p.id}`,{method:"PATCH",body:JSON.stringify({schedule:ue(p.schedule,a.at,g)})});F(G.call)}}catch(p){M(p instanceof Error?p.message:String(p))}},X=async(a,g)=>{if("botId"in a){T(null),N({kind:"routine",at:g.at,durationMinutes:30,botIds:[a.botId],limitReset:{engine:g.engine}});return}if(a.event.kind!=="routine")return M(t("limits.callNotOnReset"));try{const p=await W(`/api/routines/${a.event.id}`,{method:"PATCH",body:JSON.stringify({schedule:{type:"limit_reset",engine:g.engine,repeat:"once"}})});b({type:"routinePatched",routine:p.routine})}catch(p){M(p instanceof Error?p.message:String(p))}},n=async(a,g)=>{try{if(a.kind==="routine"&&a.routine){const p=await W(`/api/routines/${a.routine.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:g})});b({type:"routinePatched",routine:p.routine})}else if(a.kind==="call"){const p=await W(`/api/calendar-calls/${a.call.id}`,{method:"PATCH",body:JSON.stringify({durationMinutes:g})});F(p.call)}}catch(p){M(p instanceof Error?p.message:String(p))}},A=()=>{S&&(w({kind:"call",at:S.at,durationMinutes:S.call.durationMinutes,botIds:S.call.botIds,call:S.call}),T(null))},H=a=>B("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:()=>y(a=>se(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:()=>y(a=>se(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:tt(D,i)}),e.jsx("button",{type:"button",onClick:()=>y(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:()=>h(1),className:H(i===1),children:t("routines.view.day")}),e.jsx("button",{type:"button","aria-pressed":i===7,onClick:()=>h(7),className:H(i===7),children:t("routines.view.week")})]}),E&&e.jsx("button",{type:"button",onClick:()=>M(""),className:"w-full text-left text-[12px] text-danger",children:E})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[!S&&e.jsx("div",{className:"hidden shrink-0 @min-[1040px]/routines:block",children:e.jsx(Ot,{bots:_,anchor:j,onSelectDate:a=>y(Z(a))})}),e.jsx(yt,{anchor:D,days:i,items:u,bots:l.bots,groups:l.groups,selectedId:Y,onOpen:K,onCreate:a=>{T(null),N(a)},onMove:(a,g)=>{V(a,g)},onResize:(a,g)=>{n(a,g)},markers:L,onDropOnReset:(a,g)=>{X(a,g)}}),S&&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(kt,{item:S,bots:l.bots,onClose:()=>T(null),onEdit:A,onOpenRun:P,onCallChanged:a=>{a?f(g=>g.filter(p=>p.id!==a)):$()},onOpenRoom:c},`${S.kind}:${S.id}`)})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40 bg-black/25",onMouseDown:()=>N(null)}),e.jsx(jt,{seed:I,bots:z,routinesOnly:d,onClose:()=>N(null),onMore:a=>{N(null),w(a)},onSavedRoutine:a=>b({type:"routinePatched",routine:a}),onSavedCall:F})]}),R&&e.jsx(vt,{seed:R,bots:z,routinesOnly:d,onClose:()=>w(null),onSavedCall:F})]})}function Ft({botFilter:s="all"}){const{state:o,dispatch:r}=U(),k=st(Ne()),[c,l]=x.useState(null),[b,d]=x.useState(null),[i,h]=x.useState("");if(!k.length)return null;const j=f=>o.bots.find(I=>I.id===f)?.modelSelection?.instanceId,y=o.routines.filter(f=>s==="all"||f.botId===s),C=async(f,I)=>{l(f.engine),h("");try{for(const N of I){const R=await W("/api/limit-resets/after-reset",{method:"POST",body:JSON.stringify({routineId:N.id,engine:f.engine})});r({type:"routinePatched",routine:R.routine})}d(f.engine)}catch(N){h(N instanceof Error?N.message:String(N))}finally{l(null)}};return e.jsxs("section",{"aria-label":t("limits.title"),className:"mb-4 space-y-2",children:[k.map(f=>{const I=nt(y,j,f);return e.jsxs("div",{"data-limit-warning":f.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(wt,{size:15,className:"shrink-0 text-warning","aria-hidden":"true"}),e.jsx("span",{className:"font-medium tabular-nums",children:at(f)}),I.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-ink-secondary",children:t(I.length===1?"limits.dueOne":"limits.dueMany",{count:I.length})}),e.jsx("button",{type:"button",disabled:c===f.engine,onClick:()=>{C(f,I)},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===f.engine&&e.jsx("span",{className:"text-ink-secondary",children:t("limits.moved")})]},f.engine)}),i&&e.jsx("p",{role:"alert",className:"text-[12px] text-danger",children:i})]})}function $t(s,o){const r=s.find(c=>c.id===o);if(r)return r;const k=c=>c.messages.at(-1)?.at??0;return[...s].sort((c,l)=>k(l)-k(c))[0]}function Wt({initialText:s="",onClose:o,onSetUpYourself:r}){const{state:k,dispatch:c}=U(),l=k.bots.filter(m=>!m.hidden),[b,d]=x.useState(s),[i,h]=x.useState(()=>$t(l,k.selectedId)?.id??""),[j,y]=x.useState(!1),[C,f]=x.useState("schedule"),I=x.useRef(null);ft(I,o);const N=l.find(m=>m.id===i),R=()=>{const m=b.trim();!m||!N||(c({type:"select",id:N.id}),c({type:"send",botId:N.id,text:m,threadId:N.threadId}),o())},w=(m,T,E)=>e.jsxs("button",{type:"button",role:"radio","aria-checked":C===m,onClick:()=>f(m),className:B("flex w-full items-center gap-3 rounded-xl border px-3.5 py-3 text-left text-[14px]",C===m?"border-accent/70 bg-accent/10 text-ink":"border-hairline/50 text-ink-secondary hover:bg-raised"),children:[e.jsx(E,{size:16,className:"shrink-0 text-accent"}),T]});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:m=>m.target===m.currentTarget&&o(),children:e.jsxs("div",{ref:I,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:o,"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:[w("schedule",t("automations.newBox.onSchedule"),rt),w("app",t("automations.newBox.whenAppEvent"),ot),w("webhook",t("automations.newBox.whenApp"),lt)]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>y(!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:()=>r(C,N?.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:m=>d(m.target.value),rows:3,"aria-label":t("automations.newBox.title"),placeholder:t("automations.newBox.placeholder"),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&!it(m.nativeEvent)&&(m.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"}),l.length===0&&e.jsx("p",{className:"mt-2 text-[13px] text-warning",children:t("automations.newBox.noBots")}),l.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:m=>h(m.target.value),"aria-label":t("automations.newBox.bot"),className:"max-w-[220px]",children:l.map(m=>e.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>y(!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()||!N,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(gt,{size:14}),t("automations.newBox.send")]})]})]})]})})}const _t=9;function ns({onBack:s,onOpenRoom:o}){const{state:r,dispatch:k}=U(),c=ye(),l=ge(),b=x.useRef(null),d=r.routinesFocus,i=d?.view==="calendar"?"calendar":"list",[h,j]=x.useState(d?.section!=="logs"?d?.routineId??null:null),[y,C]=x.useState(d?.botId??"all"),[f,I]=x.useState("all"),[N,R]=x.useState(null),[w,m]=x.useState(null),T=window.ogb?.remoteClient?.active===!0,E=r.bots.filter(n=>!n.hidden),M=we(),_=n=>r.bots.find(A=>A.id===n)?.name??t("routines.unavailableBot");x.useEffect(()=>{C(d?.botId??"all"),d?.routineId&&d.section!=="logs"&&j(d.routineId)},[d]),x.useEffect(()=>{b.current?.focus({preventScroll:!0})},[]);const z=x.useMemo(()=>Se({routines:r.routines,webhooks:T?[]:r.webhooks,appTriggers:l.triggers,runs:r.routineRuns,bots:r.bots}),[r.routines,r.webhooks,l.triggers,r.routineRuns,r.bots,T]),D=At(r.bots,[...new Set([...r.sections??[],...r.bots.flatMap(n=>n.section?[n.section]:[])])]),O=D.names.length+(D.hasGeneral?1:0)>1,L=f==="all"||(f===oe?D.hasGeneral:D.names.includes(f))?f:"all";x.useEffect(()=>{L!==f&&(I("all"),C("all"))},[L,f]);const $=n=>te(r.bots.find(A=>A.id===n),L),u=E.filter(n=>te(n,L)),S=z.length>=_t&&new Set(z.map(n=>n.botId)).size>1,K=dt(z.filter(n=>$(n.botId)&&(!S||y==="all"||n.botId===y))),P=z.find(n=>n.id===h)??null,Y=n=>xt(n,_(n.botId)),F=w?.kind==="schedule"?r.routines.find(n=>n.id===w.id):void 0,V=w?.kind==="webhook"?r.webhooks.find(n=>n.id===w.id):void 0,X=w?.kind==="app"?l.triggers.find(n=>n.id===w.id):void 0;return e.jsxs(St,{children:[e.jsxs(Ct,{backLabel:t("automations.back"),onBack:s,backRef:b,besideSidebar:i==="list",children:[e.jsx("h1",{"data-tour":"automations-page",className:It,children:t("automations.title")}),e.jsxs(Bt,{children:[O&&e.jsxs(re,{size:"sm","aria-label":t("automations.allDepartments"),value:L,onChange:n=>{I(n.target.value),C("all")},className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allDepartments")}),D.names.map(n=>e.jsx("option",{value:n,children:n},n)),D.hasGeneral&&e.jsx("option",{value:oe,children:t("automations.generalDepartment")})]}),S&&i==="list"&&e.jsxs(re,{size:"sm","aria-label":t("automations.allBots"),value:y,onChange:n=>C(n.target.value),className:"max-w-[180px]",children:[e.jsx("option",{value:"all",children:t("automations.allBots")}),u.map(n=>e.jsx("option",{value:n.id,children:n.name},n.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(n=>e.jsx("button",{type:"button","aria-pressed":i===n,onClick:()=>k({type:"showRoutines",view:n,botId:y==="all"?void 0:y}),className:B("rounded-md px-3 py-1 text-[13px] font-medium",i===n?"bg-raised text-ink shadow-sm":"text-ink-secondary hover:text-ink"),children:n==="list"?t("automations.list"):t("automations.calendar")},n))}),e.jsxs("button",{type:"button",onClick:()=>R(""),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(xe,{size:15,"aria-hidden":"true"}),t("automations.new")]})]})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[i==="calendar"?e.jsx(Pt,{botFilter:y,department:L,selectedAutomationId:h,onOpenAutomation:j,onOpenRoom:o}):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(Ft,{botFilter:S?y:"all"}),r.config?.routinesUnreadable&&e.jsx("div",{role:"alert",className:"mb-4 rounded-lg bg-danger/10 p-3 text-[12px] leading-relaxed text-danger","data-routines-unreadable":"",children:t("routines.unreadable")}),z.length===0&&!r.config?.routinesUnreadable&&r.routinesLoadState!=="loading"&&r.hydrated?e.jsxs("section",{"aria-label":t("automations.empty.title"),className:"px-6 py-16 text-center",children:[e.jsx(Te,{state:"sleep",size:96,className:"mx-auto mb-2"}),e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:t("automations.empty.title")}),e.jsx("button",{type:"button",onClick:()=>R(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:()=>R(""),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(xe,{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:K.map(n=>{const A=le(n),H=n.name.trim(),a=n.runs.find(p=>ee(p)&&!p.seenAt),g=a&&je(a);return e.jsxs("li",{"data-automation":n.id,"data-automation-status":A.state,className:B("relative flex items-start gap-3 px-4 py-3.5",h===n.id&&"bg-raised/60"),children:[e.jsx(Be,{status:A,className:"mt-[5px]"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("button",{type:"button",onClick:()=>j(n.id),className:"block text-left text-[15px] font-medium leading-snug text-ink after:absolute after:inset-0 hover:text-accent-text",children:H||Y(n)}),H&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink",children:Y(n)}),A.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:A.reason??""}),e.jsx(De,{automation:n,status:A,actions:c,onEdit:()=>m({kind:n.kind,id:n.id}),className:"relative z-10"})]}):e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:ct(n)}),g&&e.jsxs("button",{type:"button",onClick:()=>j(n.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:[g.when," ",g.mark," ",g.text]})]}),!!n.noStartStreak&&e.jsx("div",{className:"mt-1 text-[13px] text-warning","data-automation-no-start":"",children:t("routines.noStartStreak",{count:n.noStartStreak})}),c.error&&c.errorFor?.endsWith(`:${n.id}`)&&e.jsx("p",{role:"alert",className:"mt-1 text-[12px] text-danger",children:c.error})]}),A.state!=="done"&&e.jsx(Ce,{checked:n.enabled,disabled:c.busy===`toggle:${n.id}`,"aria-label":t("automations.toggle",{name:n.name}),onClick:()=>{c.toggle(n)},className:"relative z-10 mt-0.5 shrink-0"})]},n.id)})}),c.error&&!K.some(n=>c.errorFor?.endsWith(`:${n.id}`))&&e.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-danger",children:c.error}),e.jsx(Ut,{})]})}),P&&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:P,sentence:Y(P),onClose:()=>j(null),onDeleted:()=>j(null),onEdit:()=>m({kind:P.kind,id:P.id})},P.id)})]}),N!==null&&e.jsx(Wt,{initialText:N,onClose:()=>R(null),onSetUpYourself:(n,A)=>{R(null),m({kind:n,botId:A})}}),w?.kind==="schedule"&&(F||!w.id)&&e.jsx(Nt,{routine:F,bots:ve(E,M,F?.botId),initialBotId:w.botId,plain:!0,onClose:()=>m(null)}),w?.kind==="webhook"&&(V||!w.id)&&e.jsx(Dt,{webhook:V,bots:E,initialBotId:w.botId,onClose:()=>m(null),onCredential:(n,A)=>{ut(ke(),A,n),j(A)}}),w?.kind==="app"&&(X||!w.id)&&e.jsx(mt,{trigger:X,bots:E,initialBotId:w.botId,onClose:()=>m(null),onSaved:n=>j(n.id)})]})}function Ut(){const s=typeof window<"u"?window.ogb?.routines:void 0,[o,r]=x.useState(null),[k,c]=x.useState(!1);return x.useEffect(()=>{if(!s)return;let l=!1;const b=()=>s.wakeState().then(i=>{l||r(i)}).catch(()=>{});b();const d=window.setInterval(b,3e4);return()=>{l=!0,window.clearInterval(d)}},[s]),!s||!o?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"),o.keepAwake&&o.onBattery?` ${t("automations.wakeBattery")}`:""]}),e.jsx(Ce,{checked:o.keepAwake,disabled:k,"aria-label":t("automations.wake"),onClick:()=>{c(!0),s.keepAwake(!o.keepAwake).then(r).catch(()=>{}).finally(()=>c(!1))},className:"shrink-0 disabled:cursor-wait disabled:opacity-50"})]})}export{ns as TriggersPage};
|