limixbot 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-BDwrkDBX.js → ActivityPanel-CagbdBtd.js} +1 -1
- package/dist/assets/{App-Cb2UOJS6.js → App-DFjF9FvF.js} +119 -119
- package/dist/assets/{AppEventEditor-B383TR3m.js → AppEventEditor-BgX3KO6T.js} +1 -1
- package/dist/assets/{BotSettingsDialog-CbbZerHF.js → BotSettingsDialog-ieeszW_3.js} +4 -4
- package/dist/assets/{BrowserPanel-DY-yCZ9T.js → BrowserPanel-BB3qz5lN.js} +2 -2
- package/dist/assets/{BrowserProfilesManager-BmOMzdgM.js → BrowserProfilesManager-CVdcfOF8.js} +1 -1
- package/dist/assets/CloudAddDialog-Bl1bRrYD.js +1 -0
- package/dist/assets/{ComputerFilesPane-CB2u6MXN.js → ComputerFilesPane-piKNDkt6.js} +1 -1
- package/dist/assets/ComputerPanel-COQweEJR.js +2 -0
- package/dist/assets/{DataPanel-fAjB6GSn.js → DataPanel-DdHxcsUa.js} +1 -1
- package/dist/assets/{DesktopViewer-mWGetNwB.js → DesktopViewer-BNIgo9Nm.js} +1 -1
- package/dist/assets/{FilesView-CLR6NiY2.js → FilesView-Dy1gKmcM.js} +1 -1
- package/dist/assets/{GrokMoveDialog-lZOa5ZKz.js → GrokMoveDialog-CUnJWZi7.js} +6 -6
- package/dist/assets/{InspectorPanel-lOPEUSb8.js → InspectorPanel-CWdxtHne.js} +2 -2
- package/dist/assets/{KeyboardShortcutsModal-BGRMc9wJ.js → KeyboardShortcutsModal-6FMUgbpC.js} +1 -1
- package/dist/assets/{LiveDesktop-LRjYEzUz.js → LiveDesktop-CDbI9dPy.js} +1 -1
- package/dist/assets/LocalVmWorkspace-CslSGvNI.js +1 -0
- package/dist/assets/{MacLocalControl-DuTxY3A3.js → MacLocalControl-CwHtEWES.js} +1 -1
- package/dist/assets/MarkdownFilePreview-DrdGFCnN.js +1 -0
- package/dist/assets/{MenuMotion-DKMkKESs.js → MenuMotion-IQitGKH4.js} +1 -1
- package/dist/assets/{NewBotDialog-Bpi6-xSj.js → NewBotDialog-V2wMpLPn.js} +1 -1
- package/dist/assets/PhoneAppDialog-DmBPVDxr.js +1 -0
- package/dist/assets/{PlacesRail-4ErVypbT.js → PlacesRail-v1XIqiBG.js} +9 -9
- package/dist/assets/{PluginsPanel-Cw8XeQBF.js → PluginsPanel-CMARnTMq.js} +2 -2
- package/dist/assets/{ProIntroduction-DPYk--IK.js → ProIntroduction--jIMb4bL.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-qxzESq_H.js → RemoteAgentSettingsPanel-Co34aJHb.js} +1 -1
- package/dist/assets/{RoomPanel-DaoRmKS_.js → RoomPanel-ClyWQx9x.js} +2 -2
- package/dist/assets/{RoutinesPage-CD1DvtyW.js → RoutinesPage-DRwSDyGu.js} +1 -1
- package/dist/assets/SettingsModal-CHa_Zc-J.js +11 -0
- package/dist/assets/{ShareTeamDialog-rc1xx02E.js → ShareTeamDialog-BQ9h2Rd2.js} +1 -1
- package/dist/assets/{SignedInSites-CPp5ofCJ.js → SignedInSites-B16Ruhd0.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-D-iDVZPU.js → TeamLibraryPanel-NwC4Fc9C.js} +1 -1
- package/dist/assets/TeamMapPage-DabJFxkf.js +1 -0
- package/dist/assets/{TriggersPage-D2ovyRGM.js → TriggersPage-Cn_f8AcZ.js} +1 -1
- package/dist/assets/{VisibilitySection-oSi2vtmx.js → VisibilitySection-DyGNmx9n.js} +1 -1
- package/dist/assets/{WebhookTrigger-CyP8At0y.js → WebhookTrigger-C-9-FE3w.js} +1 -1
- package/dist/assets/WorksOnGrid-M_5NkZch.js +1 -0
- package/dist/assets/{abnfDiagram-YUKMZFIV-C7wn2CLu.js → abnfDiagram-YUKMZFIV-CBzJU2O6.js} +1 -1
- package/dist/assets/{activity-Cru8B1z7.js → activity-bd7MWK8m.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-DgFc7YIC.js → architectureDiagram-47P4ROYG-DVR1DP3v.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-qR-t8DMo.js → blockDiagram-E7TT5TSB-BYqUHhoh.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-DdmUjVbB.js → c4Diagram-CRA5TL53-BtQERHwr.js} +1 -1
- package/dist/assets/{calendar-days-CN7x0QvP.js → calendar-days-YMHxUvlg.js} +1 -1
- package/dist/assets/channel-D6e78p3W.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D09jrdDt.js → chunk-2Q5K7J3B-Cwf_xeHP.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-DJXT-XDN.js → chunk-5VM5RSS4-Doo-zxI4.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-CaULsRlr.js → chunk-7TKQ45FW-CD2AgrRj.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-BcEB179w.js → chunk-AW2ZBBNX-e5OuWeq_.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-DMhPq4_N.js → chunk-FVRAUYC3-C8jo43it.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-DcoWRcH-.js → chunk-HTAEGDNF-DLsD4agj.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CpN6DEZO.js → chunk-JWPE2WC7-UZDUbeTy.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-BxIldIqB.js → chunk-KQW6MTUR-DR9SuVX3.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY--M4TxaOR.js → chunk-XXDRQBXY-DwEl4815.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-DQUUn5pg.js → classDiagram-v2-K4WV4PDN-CQZho8e0.js} +1 -1
- package/dist/assets/{coins-DxQLVJqa.js → coins-DpzGN3sd.js} +1 -1
- package/dist/assets/{core-CjjU--NA.js → core-BNopzNRl.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DCCMLnpT.js → cose-bilkent-JH36ORCC-DUZ9OWzu.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-iK--S4gB.js → cynefin-EF2NZ3EQ-DVHnJdjN.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-DiwEQVzk.js → cynefinDiagram-3GCD6N5R-dYhbIkRt.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-Bb-WXIrp.js → dagre-W4DXFKR2-DqJNpw5w.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-CU1G-LPy.js → diagram-2UJZ2QOL-DKNDqAnE.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-KUL_hQtY.js → diagram-OVF4WLC6-DENMVM-d.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-Du0EMvGo.js → diagram-PFPMY2P6-CrRFeR5V.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-BUNv47Vc.js → diagram-UMYRVEAY-B5w-desO.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-DyWO406P.js → diagram-YEKJPTXX-C7AVX3MB.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-DGps1w58.js → diagram-ZIFT7M5P-BgkTRwwr.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BxaaJRK8.js → ebnfDiagram-VR2GEFS7-yY_2KNsK.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-BuVZZmTr.js → elk-IJKZMXRS-xWtfkoqT.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-qhhsO6Fp.js → erDiagram-O2IAPWRE-BMM4saPI.js} +1 -1
- package/dist/assets/{file-up-BiK20g0M.js → file-up-Bl7ViNTL.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-BsRrcKnA.js → flowDiagram-OXPTDLAJ-BCRe8i6T.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-jVqCmREp.js → ganttDiagram-R7TSEDQI-COBrcDi7.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-COi9bChD.js → gitGraphDiagram-XJZIOB7I-Dc4RKydD.js} +1 -1
- package/dist/assets/{import-name-CrWA8Hw3.js → import-name-DA_MmEsd.js} +1 -1
- package/dist/assets/{index-Dy5VWChH.js → index-BXLNny-w.js} +1 -1
- package/dist/assets/index-CwYJ9TX8.js +2 -0
- package/dist/assets/{index-BIC6c7Sg.js → index-D6huutPz.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-CUfzOgVW.js → infoDiagram-5W2HQ5XZ-BV8RRI_4.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-DMR_Ey1I.js → ishikawaDiagram-K3B6WC7H-H-XILdGm.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-UiPc_2sp.js → journeyDiagram-COXZFDF6-ChLduKEj.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-VvQXCMxr.js → kanban-definition-P3RFRI5V-FSZ9F3JH.js} +1 -1
- package/dist/assets/{mcp-servers-CBCpG62C.js → mcp-servers-CYvHVOYi.js} +1 -1
- package/dist/assets/{mermaid.core-BZKmLobY.js → mermaid.core-BRsJ02Pz.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-BJi3q0s6.js → mindmap-definition-LZFPQGKD-TWHzZjNT.js} +1 -1
- package/dist/assets/{minimize-B78LHbd3.js → minimize-BYscOtPM.js} +1 -1
- package/dist/assets/{monitor-UBjV7Qf5.js → monitor-DFEzCfQk.js} +1 -1
- package/dist/assets/{new-bot-D0DDXTKe.js → new-bot-_oEUbcDw.js} +2 -2
- package/dist/assets/{org-library-BdlqWown.js → org-library-CapoiPaN.js} +1 -1
- package/dist/assets/{package-format-EwGfXp1v.js → package-format-Cn4nABBW.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-C6W87HN9.js → pegDiagram-BGZESJAR-LQWOF7IE.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-B1E_Ycub.js → pieDiagram-CAPJLFHJ-BRXp4qFw.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-BasGTzC_.js → quadrantDiagram-GDMTTRAM-DyIdGBZo.js} +1 -1
- package/dist/assets/{rail-BFRrwJ6b.js → rail-Du7tlPwj.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-BZVzOUlx.js → railroadDiagram-SM67HX2B-BrL1MhW1.js} +1 -1
- package/dist/assets/{remote-desktop-panel--ikzFjV8.js → remote-desktop-panel-DbxYe3uv.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-C8s2XakO.js → requirementDiagram-X7JNWC4A-DTYjaC8j.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-CCCP1mnQ.js → sankeyDiagram-UM26HJRW-BR9dASO5.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-BvwC79vw.js → sequenceDiagram-ZO4K6R2Y-BR1k8h2_.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-DzRVDjCL.js → sizeCapture-INFHLROL-u8zOvZVi.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-CKVmZfLe.js → stateDiagram-v2-TBUQTH76-mQ64BAFv.js} +1 -1
- package/dist/assets/{styles-Bo7bYxUt.js → styles-BlayaJti.js} +6 -6
- package/dist/assets/{swimlanes-N4OXWK64-BaSkTx2s.js → swimlanes-N4OXWK64-CmzC3Mu0.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-Coei7rJr.js +8 -0
- package/dist/assets/{team-share-BgI5VFVf.js → team-share-C3w1L3WL.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-Np9aXu8d.js → timeline-definition-YOQAKGHF-9aPCRsK2.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-CaHpESyo.js → usecaseDiagram-VIAY4XPW--ngAouwr.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-BpnM9QrV.js → vennDiagram-BLWOH2XV-C3zKxuAB.js} +1 -1
- package/dist/assets/{vi-B8BbvT0G.js → vi-uLErku_e.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-Cb0psm8G.js → wardleyDiagram-YMQ3BMBF-CZWsQPSF.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-Bi_SjN1M.js → xychartDiagram-TAQBALBS-BTcsDP6v.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/rail.html +4 -4
- package/dist-server/package.json +1 -1
- package/package.json +1 -1
- package/dist/assets/CloudAddDialog-DP5-ha1H.js +0 -1
- package/dist/assets/ComputerPanel-DI10c-7Z.js +0 -2
- package/dist/assets/LocalVmWorkspace-Bwq-s97O.js +0 -1
- package/dist/assets/MarkdownFilePreview-B69UWgiO.js +0 -1
- package/dist/assets/PhoneAppDialog-V46SXKel.js +0 -1
- package/dist/assets/SettingsModal-C359HBUM.js +0 -11
- package/dist/assets/TeamMapPage-od4f3NJr.js +0 -1
- package/dist/assets/WorksOnGrid-DbfBPgPv.js +0 -1
- package/dist/assets/channel-BIffrG1w.js +0 -1
- package/dist/assets/index-Bhz3ZrDI.js +0 -2
- package/dist/assets/module-DCUsy2BQ.js +0 -3
- package/dist/assets/swimlanesDiagram-K3J5GTZL-D67LlSLv.js +0 -8
package/dist/assets/{RemoteAgentSettingsPanel-qxzESq_H.js → RemoteAgentSettingsPanel-Co34aJHb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as e,C as w,t as n,X as C,a as S}from"./styles-
|
|
1
|
+
import{r,j as e,C as w,t as n,X as C,a as S}from"./styles-BlayaJti.js";import{u as A,I as z,T,B as p,V as L,k as P,S as B,m as E,n as I}from"./App-DFjF9FvF.js";import{u as R,B as F,L as U,b as V}from"./PlacesRail-v1XIqiBG.js";import"./index-CwYJ9TX8.js";import"./monitor-DFEzCfQk.js";import"./MenuMotion-IQitGKH4.js";function M({bot:t,overlay:b=!1}){const{dispatch:f}=A(),{dragProps:k}=R(),[x,g]=r.useState(!1),[h,l]=r.useState(""),[v,j]=r.useState(!1),d=r.useRef(null),o=r.useRef(null),c=r.useRef(null),y=()=>f({type:"toggleSettings",open:!1}),i=a=>{if(o.current={...o.current,...a},c.current)return c.current;g(!0),l("");const s=async()=>{for(;o.current;){const u=o.current;o.current=null,l("");try{const m=await I(`/api/bots/${t.id}/profile`,{method:"PATCH",body:JSON.stringify(u)});f({type:"botPatched",bot:m.bot})}catch(m){l(m instanceof Error?m.message:n("remoteAgent.updateFailed"))}}};return c.current=s().finally(()=>{c.current=null,g(!1)}),c.current},N=async a=>{if(a){j(!0),l("");try{const s=await E(a),u=s?V(s.path):null;if(!u)throw new Error(n("settings.profile.avatar.invalidType"));await i({avatarUrl:u,avatarCrop:t.avatarCrop==="square"?"square":"circle"})}catch(s){l(s instanceof Error?s.message:String(s))}finally{j(!1),d.current&&(d.current.value="")}}};return e.jsxs("aside",{className:S("animate-panel-in absolute inset-0 z-40 flex h-full min-w-0 flex-col border-l border-hairline/40 bg-panel",b?"md:left-auto md:w-[400px] md:shadow-2xl":"md:relative md:z-20 md:w-[400px] md:shrink-0"),children:[e.jsxs("div",{...k,className:"flex items-center justify-between px-4 py-3",children:[e.jsx("button",{onClick:y,"aria-label":n("remoteAgent.collapse"),className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(w,{size:18})}),e.jsx("span",{className:"text-[15px] font-semibold text-ink",children:n("remoteAgent.title")}),e.jsx("button",{onClick:y,"aria-label":n("remoteAgent.close"),className:"flex size-10 items-center justify-center rounded-md text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(C,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 pb-5",children:e.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(F,{bot:t,state:"idle",size:64,motion:"none",motionKey:0,animated:!1}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:d,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:a=>{N(a.target.files?.[0])}}),e.jsxs("button",{type:"button",disabled:v||x,onClick:()=>d.current?.click(),className:"flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",children:[v?e.jsx(U,{size:14,className:"animate-spin"}):e.jsx(z,{size:14})," ",n("botIdentity.avatar")]}),t.avatarUrl&&e.jsx("button",{type:"button",disabled:x,onClick:()=>{i({avatarUrl:null,avatarCrop:"mascot"})},"aria-label":n("remoteAgent.removeAvatar"),className:"flex size-9 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(T,{size:14})})]})]}),e.jsxs("label",{className:"block text-[12px] font-medium text-ink-secondary",children:[n("botSettings.identity.name"),e.jsx("input",{defaultValue:t.name,maxLength:p.name,onBlur:a=>{const s=a.currentTarget.value.trim();s&&s!==t.name&&i({name:s})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:[n("botSettings.identity.title"),e.jsx("input",{defaultValue:t.title??"",maxLength:p.title,onBlur:a=>{a.currentTarget.value!==(t.title??"")&&i({title:a.currentTarget.value})},className:"mt-1 w-full rounded-lg bg-inset px-3 py-2 text-[14px] text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]}),e.jsxs("label",{className:"mt-3 block text-[12px] font-medium text-ink-secondary",children:[n("remoteAgent.description"),e.jsx("textarea",{defaultValue:t.description??"",maxLength:p.description,rows:4,onBlur:a=>{a.currentTarget.value!==(t.description??"")&&i({description:a.currentTarget.value})},className:"mt-1 w-full resize-y rounded-lg bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink focus:outline-none focus:ring-1 focus:ring-accent"},t.id)]})]}),e.jsx(L,{bot:t,workspaceConfigurationLocked:!0,onPatch:a=>{i(a)}}),e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(P,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:n("notifications.title")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:n("remoteAgent.notificationsHint")})]})]}),e.jsx(B,{checked:t.notifications,disabled:x,"aria-label":n("remoteAgent.notifications"),onClick:()=>{i({notifications:!t.notifications})}})]}),h?e.jsx("div",{role:"alert",className:"text-[12px] text-danger",children:h}):null]})})]})}export{M as RemoteAgentSettingsPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,a as z,t,
|
|
2
|
-
`)[0]?.trim();return e.jsxs("button",{ref:l,type:"button","data-panel-edit":"instructions","aria-label":`${t("botSettings.simple.edit")}: ${t("room.panel.instructions")}`,onClick:n.start,className:z(Re,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-ink/[0.05] text-ink-secondary max-md:size-8 max-md:rounded-full","aria-hidden":"true",children:e.jsx(ve,{size:15})}),e.jsx(C,{title:t("room.panel.instructions"),hint:e.jsx("span",{dir:"auto",className:"line-clamp-1",children:p||t("room.panel.instructionsHint")})}),e.jsx(Se,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}function Oe({group:a,overlay:n=!1}){const{state:l}=g(),{dragProps:u}=q(),[o,p]=d.useState(null),[r,f]=d.useState(!1),h=d.useRef(null),s=d.useRef(null),x=d.useRef(null),m=d.useRef(null),b=d.useMemo(()=>a.memberIds.map(c=>l.bots.find(y=>y.id===c)).filter(c=>!!c),[a.memberIds,l.bots]),i=ue(a),I=d.useCallback(()=>f(!1),[]),w=c=>{p(c),s.current?.scrollTo({top:0})},v=()=>{m.current=o,p(null)};d.useEffect(()=>{o!==null?s.current?.querySelector("[data-panel-back]")?.focus():m.current&&(s.current?.querySelector(`[data-panel-page="${m.current}"]`)?.focus(),m.current=null)},[o]),d.useEffect(()=>{const c=h.current;c?.focus();const y=j=>{j.key!=="Escape"||j.defaultPrevented||c&&j.target instanceof Node&&!c.contains(j.target)||(j.preventDefault(),S({refocus:!0}))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const D=c=>{c.key!=="Escape"||c.defaultPrevented||o===null||(c.preventDefault(),c.stopPropagation(),v())};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{ref:h,role:"dialog","aria-labelledby":"room-panel-title",tabIndex:-1,"data-room-panel":!0,onKeyDown:D,className:je(n,!0),children:[e.jsxs("div",{...u,className:"flex h-[52px] shrink-0 items-center justify-end gap-2 px-3.5",children:[e.jsx(Te,{group:a}),e.jsx("button",{type:"button",onClick:()=>S({refocus:!0}),"aria-label":t("botSettings.simple.close"),className:pe,children:e.jsx(B,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:s,className:"@container relative min-h-0 flex-1 overflow-y-auto px-5 pb-7",children:o===null?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{group:a,members:b}),e.jsxs(
|
|
1
|
+
import{j as e,a as z,t,z as F,r as d,S as L,X as B}from"./styles-BlayaJti.js";import{E as O,C as $,T as G,B as E,j as K,u as q,r as H}from"./PlacesRail-v1XIqiBG.js";import{an as U,u as g,ao as A,ap as W,aq as X,ar as _,as as J,at as Q,au as V,av as Y,aw as P,ax as Z,ay as ee,az as ae,P as te,aA as se,aB as ne,aC as oe,aD as re,aE as le,aF as ie,aG as ce,aH as M,aI as R,aJ as de,aK as ue,aL as pe,aM as S,aN as k,aO as me,d as fe,aP as xe,aQ as he,aR as be,aS as je,aT as ye,aU as ke,aV as ge,aW as C,aX as we,ac as ve,aY as Re}from"./App-DFjF9FvF.js";import{C as Se}from"./MenuMotion-IQitGKH4.js";import"./monitor-DFEzCfQk.js";import"./index-CwYJ9TX8.js";function N(a){return a===60?t("room.panel.hour"):a%60===0?t("room.panel.hours",{hours:a/60}):t("room.panel.minutes",{minutes:a})}function Ce(a){const{dispatch:n}=g(),l=F(),u=A(a.threadId),o=W(a),[p,r]=d.useState(null),f=a.messages,h=f.length>0,s=()=>oe({title:a.name,messages:f,isGroup:!0}),x=l?[]:X(a.tasks??[]),m=_(a.usage);return{items:[{key:"find",label:t("chat.find"),icon:e.jsx(L,{size:16}),active:u,trailing:e.jsx(Q,{id:"find-conversation"}),onSelect:()=>J(a.threadId)},...l?[]:[{key:"new-thread",heading:t("task.list"),separatorBefore:!0,label:t("task.newShort"),icon:e.jsx(V,{size:16}),onSelect:()=>n({type:"newGroupTask",groupId:a.id})}],...x.length<2?[]:[{key:"threads",label:t("task.switch"),icon:e.jsx(P,{size:16}),value:String(x.length),submenu:x.map(i=>({key:`thread:${i.threadId}`,label:Y(i.title||t("task.newShort")),active:i.threadId===a.threadId,onSelect:()=>n({type:"switchGroupTask",groupId:a.id,threadId:i.threadId})})),onSelect:()=>{}}],{key:"copy",heading:t("chat.export.heading"),separatorBefore:!0,label:t("chat.export.copy"),icon:e.jsx($,{size:16}),disabled:!h,keepOpen:!0,trailing:p&&e.jsx("span",{role:"status",className:"text-[11px] text-ink-secondary",children:t(p==="copied"?"chat.export.copied":"chat.export.copyFailed")}),onSelect:()=>{Z(s()).then(i=>r(i?"copied":"failed"))}},{key:"download",label:t("chat.export.download"),icon:e.jsx(te,{size:16}),disabled:!h,onSelect:()=>ee(ae(a.name),s())},{key:"turn-limit",label:t("room.panel.turnLimit"),icon:e.jsx(G,{size:16}),separatorBefore:!0,value:N(o.saved??o.globalMinutes),submenu:[{key:"turn-limit:default",label:t("room.turnLimit.default",{minutes:o.globalMinutes}),active:o.saved===null,onSelect:()=>o.save(null)},...se.map(i=>({key:`turn-limit:${i}`,label:N(i),active:o.saved===i,onSelect:()=>o.save(i)}))],onSelect:()=>{}},...m?[{key:"usage",label:t("chat.usage.menu"),icon:e.jsx(ne,{size:16}),keepOpen:!0,trailing:e.jsx("span",{title:m.title,"data-testid":"group-usage-chip",className:"tabular-nums text-[12px] text-ink-secondary",children:m.short}),onSelect:()=>{}}]:[]],on:u}}function Ne({group:a}){const{items:n,on:l}=Ce(a);return e.jsx(U,{items:n,ariaLabel:t("chat.more"),triggerClassName:"rounded-full",triggerTitle:t("chat.more"),renderTrigger:({open:u})=>e.jsx("span",{"data-testid":"room-more",className:z("flex size-8 items-center justify-center rounded-full bg-raised/50 transition-colors hover:bg-raised","max-md:size-9 max-md:border max-md:border-hairline max-md:bg-card",u||l?"text-accent":"text-ink"),children:e.jsx(O,{size:16})})})}function Te({group:a}){return e.jsx(Ne,{group:a},a.threadId)}function ze({group:a,members:n}){const{state:l,dispatch:u}=g(),o=re(l.config),p=le(a,n),r=ie(p),f=s=>{s!==r&&u({type:"patchGroup",groupId:a.id,patch:{defaultResponder:de(s,p)}})},h=[{choice:"auto",title:t("room.panel.responder.autoOption"),hint:o?void 0:t("room.responder.autoOff",{name:ce(a,n)??t("room.responder.leadFallback")})},{choice:"everyone",title:t("room.panel.responder.everyone")},{choice:"mentions",title:t("room.panel.responder.mentions")}];return e.jsx("div",{role:"radiogroup","aria-label":t("room.panel.whoResponds"),children:e.jsxs(M,{children:[n.map(s=>e.jsx(R,{"data-panel-choice":`member:${s.id}`,title:e.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(E,{bot:s,state:K(s.mascotExpression)??"happy",size:22,animated:!1}),e.jsx("span",{className:"truncate",children:s.name})]}),checked:r===`member:${s.id}`,onClick:()=>f(`member:${s.id}`)},s.id)),h.map(({choice:s,title:x,hint:m})=>e.jsx(R,{"data-panel-choice":s,title:x,hint:m,checked:r===s,onClick:()=>f(s)},s))]})})}const T={responder:{title:"room.panel.whoResponds",intro:"room.panel.responder.intro"},folder:{title:"room.folder.title",intro:"room.folder.detail"}};function Ee({group:a,members:n}){return e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{"data-room-panel-faces":!0,className:"mt-0.5 flex -space-x-3",children:n.slice(0,3).map(l=>e.jsx(E,{bot:l,state:"happy",size:52,animated:!1},l.id))}),e.jsx("h2",{id:"room-panel-title",className:"mt-2.5 max-w-full truncate px-1.5 text-[18px] font-semibold text-ink",children:a.name}),a.description&&e.jsx("p",{className:"mt-px line-clamp-2 max-w-full text-[13px] text-ink-secondary",children:a.description})]})}function Pe({group:a}){const n=ke(a),l=d.useRef(null),u=d.useRef(!1);d.useEffect(()=>{n.open||!u.current||(u.current=!1,l.current?.focus())},[n.open]);const o=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation()),(r.key==="Escape"||r.key==="Enter"&&(r.metaKey||r.ctrlKey))&&(u.current=!0),n.onKeyDown(r)};if(n.open)return e.jsxs(ge,{"data-panel-row":"instructions",children:[e.jsx(C,{title:t("room.panel.instructions")}),e.jsx("textarea",{autoFocus:!0,dir:"auto","aria-label":t("room.panel.instructions"),value:n.draft,onChange:r=>n.setDraft(r.target.value),onBlur:n.save,onKeyDown:o,placeholder:t("room.bulletin.placeholder"),rows:6,className:"w-full resize-y rounded-lg border border-hairline bg-inset px-2.5 py-2 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"instructions",onMouseDown:r=>r.preventDefault(),onClick:()=>{u.current=!0,n.save()},className:we,children:t("botSettings.simple.done")})})]});const p=a.bulletin.split(`
|
|
2
|
+
`)[0]?.trim();return e.jsxs("button",{ref:l,type:"button","data-panel-edit":"instructions","aria-label":`${t("botSettings.simple.edit")}: ${t("room.panel.instructions")}`,onClick:n.start,className:z(Re,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-ink/[0.05] text-ink-secondary max-md:size-8 max-md:rounded-full","aria-hidden":"true",children:e.jsx(ve,{size:15})}),e.jsx(C,{title:t("room.panel.instructions"),hint:e.jsx("span",{dir:"auto",className:"line-clamp-1",children:p||t("room.panel.instructionsHint")})}),e.jsx(Se,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}function Oe({group:a,overlay:n=!1}){const{state:l}=g(),{dragProps:u}=q(),[o,p]=d.useState(null),[r,f]=d.useState(!1),h=d.useRef(null),s=d.useRef(null),x=d.useRef(null),m=d.useRef(null),b=d.useMemo(()=>a.memberIds.map(c=>l.bots.find(y=>y.id===c)).filter(c=>!!c),[a.memberIds,l.bots]),i=ue(a),I=d.useCallback(()=>f(!1),[]),w=c=>{p(c),s.current?.scrollTo({top:0})},v=()=>{m.current=o,p(null)};d.useEffect(()=>{o!==null?s.current?.querySelector("[data-panel-back]")?.focus():m.current&&(s.current?.querySelector(`[data-panel-page="${m.current}"]`)?.focus(),m.current=null)},[o]),d.useEffect(()=>{const c=h.current;c?.focus();const y=j=>{j.key!=="Escape"||j.defaultPrevented||c&&j.target instanceof Node&&!c.contains(j.target)||(j.preventDefault(),S({refocus:!0}))};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[]);const D=c=>{c.key!=="Escape"||c.defaultPrevented||o===null||(c.preventDefault(),c.stopPropagation(),v())};return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{ref:h,role:"dialog","aria-labelledby":"room-panel-title",tabIndex:-1,"data-room-panel":!0,onKeyDown:D,className:je(n,!0),children:[e.jsxs("div",{...u,className:"flex h-[52px] shrink-0 items-center justify-end gap-2 px-3.5",children:[e.jsx(Te,{group:a}),e.jsx("button",{type:"button",onClick:()=>S({refocus:!0}),"aria-label":t("botSettings.simple.close"),className:pe,children:e.jsx(B,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:s,className:"@container relative min-h-0 flex-1 overflow-y-auto px-5 pb-7",children:o===null?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{group:a,members:b}),e.jsxs(M,{children:[e.jsx(k,{"data-panel-page":"responder",icon:P,title:t("room.panel.whoResponds"),value:me(a,b),onClick:()=>w("responder")}),e.jsx(k,{"data-panel-page":"folder",icon:fe,title:t("room.folder.title"),value:i?.name??t("room.panel.folder.own"),tooltip:i?.path,onClick:()=>w("folder")}),e.jsx(Pe,{group:a}),e.jsx(k,{ref:x,"data-panel-row":"members",icon:xe,title:t("room.panel.members"),value:String(b.length),onClick:()=>f(!0)})]})]}):e.jsxs("div",{"data-panel-page-view":o,children:[e.jsx("span",{id:"room-panel-title",className:"sr-only",children:a.name}),e.jsx(he,{back:a.name,title:t(T[o].title),intro:t(T[o].intro),onBack:v}),e.jsx("div",{className:"mt-4 flex flex-col gap-3",children:o==="responder"?e.jsx(ze,{group:a,members:b}):e.jsx(be,{group:a,heading:!1})})]})})]}),r&&H.createPortal(e.jsx(ye,{group:a,onClose:I,triggerRef:x}),document.body)]})}export{Oe as RoomPanel};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as tt,r as x,j as e,t as n,a as C,i as Le,bq as Un,ah as ln,g as dn,L as cn,X as Me,S as Yn,B as Zn}from"./styles-Bo7bYxUt.js";import{b as Vn}from"./remote-desktop-DDRRx8uY.js";import{ak as Jn,a$ as Kn,B as Ve,c as Qn,L as ze,y as Te}from"./PlacesRail-4ErVypbT.js";import{je as Je,cg as Xn,D as U,aM as es,jf as ts,jg as un,be as ns,cR as ss,jh as as,ji as xn,u as nt,jj as rs,a6 as jt,jk as is,fg as X,ac as os,jl as kt,jm as ee,jn as ht,gq as ls,jo as qe,jp as pn,cO as mn,cL as Ye,jq as ut,jr as Xt,js as en,jt as Re,y as Ze,ju as tn,jv as ds,jw as gt,cJ as hn,a9 as st,jx as Ke,jy as cs,m as us,jz as xs,bo as gn,jA as ps,jB as ms,n as Ne,jC as hs,jD as gs,jE as Nt,jF as nn,jG as bs,a4 as vs,aa as xt,x as fs,cG as sn,cH as ys,dB as js,T as ks,jH as Ns,jI as Ue,cv as ws,bn as Ss,fP as Cs}from"./App-Cb2UOJS6.js";import{u as Is}from"./ProIntroduction-DPYk--IK.js";import{C as Ds}from"./MenuMotion-DKMkKESs.js";const Ts=[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]],Rs=tt("hourglass",Ts);const Ms=[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]],zs=tt("repeat-2",Ms);const Ls=[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]],bt=tt("user-round-plus",Ls);const As=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],vt=tt("video",As);function Qe(t,s){if(!t.config?.team)return;const r=t.bots.find(i=>i.id===s);if(r?.defaultBot?.person)return null;const l=r&&t.activeView==="chat"&&t.selectedId===r.id?r.tasks?.find(i=>i.threadId===r.threadId):void 0;return l&&l.private!==!0&&!l.routineRunId?r.mainThreadId??null:Je}function Os(t,s,r){const l=i=>typeof i=="string"&&!!t.tasks?.some(u=>u.threadId===i&&u.private===!0);return!!t.defaultBot?.person||s===Je||l(s)||l(r)}function bn({team:t,bot:s,value:r,madeIn:l}){if(!t||!s)return null;const i=Os(s,r,l),u=i?Jn:es;return e.jsxs("p",{role:"note","data-routine-audience":i?"me":"shared",className:"mt-2 flex items-center gap-1 text-[12px] leading-4 text-ink-secondary",children:[e.jsx(u,{size:12,"aria-hidden":"true",className:"shrink-0"}),e.jsx("span",{children:i?n("team.privateHeader"):ts(t.name,s.onlyPeopleAdded)})]})}function vn({bot:t,value:s,allowCurrent:r=!1,team:l,onChange:i}){const u=x.useId(),m=Xn();if(l??m!==null)return e.jsx(Es,{id:u,bot:t,value:s,allowCurrent:r,onChange:i});const c=(t?.tasks??[]).filter(o=>!o.routineRunId),h=typeof s=="string"&&!c.some(o=>o.threadId===s),N=[...t?.projects??[],{id:"",name:n("folder.none")}];return e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("label",{htmlFor:u,className:"block text-[12px] font-medium text-ink",children:n("routines.results.label")}),e.jsxs(U,{className:"w-full",id:u,"aria-describedby":`${u}-help`,disabled:!t,value:s??(s===null?"new":"current"),onChange:o=>i(o.target.value==="new"?null:o.target.value==="current"?void 0:o.target.value),children:[r&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"new",children:n("routines.results.main")}),h&&e.jsx("option",{value:s,disabled:!0,children:n("routines.results.unavailable")}),N.map(o=>{const $=c.filter(S=>o.id?S.projectId===o.id:!t?.projects?.some(v=>v.id===S.projectId));return $.length?e.jsx("optgroup",{label:o.name,children:$.map(S=>e.jsx("option",{value:S.threadId,children:S.title},S.threadId))},o.id):null})]}),e.jsx("p",{id:`${u}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.mainHelp")})]})}function Es({id:t,bot:s,value:r,allowCurrent:l,onChange:i}){const u=typeof r=="string"&&!!s?.tasks?.some(c=>c.threadId===r&&c.private===!0),m=r===void 0&&l?"current":r===Je||u?"me":"shared";return e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("label",{htmlFor:t,className:"block text-[12px] font-medium text-ink",children:n("routines.results.label")}),e.jsxs(U,{className:"w-full",id:t,"aria-describedby":`${t}-help`,disabled:!s,value:m,onChange:c=>i(c.target.value==="current"?void 0:c.target.value==="me"?u?r:Je:s?.mainThreadId??null),children:[m==="current"&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"me",children:n("routines.results.justMe")}),e.jsx("option",{value:"shared",children:n("task.sharedChat")})]}),e.jsx("p",{id:`${t}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.teamHelp")})]})}const pt="min-w-0 rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",Ps=t=>Array.from({length:12},(s,r)=>new Intl.DateTimeFormat(t,{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2024,r,1)))),Hs=["UTC",...typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[]];function fn({runs:t,timeZone:s,paused:r=!1}){if(!t.length)return null;const l=new Intl.DateTimeFormat(Le(),{timeZone:s,weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return e.jsxs("div",{className:"space-y-1 text-[11px] leading-relaxed text-ink-secondary","aria-label":n(r?"routines.cron.pausedPreviewLabel":"routines.cron.nextRunsLabel"),children:[e.jsxs("div",{className:"font-medium",children:[n(r?"routines.cron.pausedPreview":"routines.cron.nextRuns")," · ",s]}),t.map(i=>e.jsx("div",{children:e.jsx("time",{dateTime:new Date(i).toISOString(),children:l.format(i)})},i)),e.jsx("div",{className:"pt-1",children:n("routines.cron.clockChanges")})]})}function $s({schedule:t,paused:s=!1}){const r=x.useMemo(()=>{try{return un(t,Date.now(),3)}catch{return[]}},[t]);return e.jsx(fn,{runs:r,timeZone:t.timeZone,paused:s})}function _s({choice:t,value:s,onChange:r,runs:l,error:i}){const u=m=>r({...s,...m});return e.jsxs("div",{className:"space-y-3",children:[t==="cron"?e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.expression")}),e.jsx("input",{value:s.expression,onChange:m=>u({expression:m.target.value}),placeholder:"0 9 1 * *",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-help routine-cron-error",className:C(pt,"w-full font-mono")}),e.jsx("span",{id:"routine-cron-help",className:"block text-[11px]",children:n("routines.cron.expressionHelp")})]}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t==="yearly"&&e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.month")}),e.jsx(U,{value:s.month,onChange:m=>u({month:m.target.value}),children:Ps(Le()).map((m,c)=>e.jsx("option",{value:String(c+1),children:m},m))})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.dayOfMonth")}),e.jsxs(U,{value:s.day,onChange:m=>u({day:m.target.value}),children:[Array.from({length:31},(m,c)=>e.jsx("option",{value:String(c+1),children:c+1},c+1)),e.jsx("option",{value:"L",children:n("routines.cron.lastDay")})]})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.time")}),e.jsx("input",{type:"time",step:60,value:s.time,onChange:m=>u({time:m.target.value}),className:pt})]})]}),t!=="cron"&&Number(s.day)>28&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:n("routines.cron.skippedMonths")}),e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.timeZone")}),e.jsx("input",{list:"routine-time-zones",value:s.timeZone,onChange:m=>u({timeZone:m.target.value}),placeholder:"America/New_York",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-error",className:C(pt,"block w-full")})]}),e.jsx("datalist",{id:"routine-time-zones",children:Hs.map(m=>e.jsx("option",{value:m},m))}),i&&e.jsx("p",{id:"routine-cron-error",role:"alert",className:"text-[12px] text-danger",children:i}),!i&&e.jsx(fn,{runs:l,timeZone:s.timeZone.trim()})]})}const ge=t=>["monthly","yearly","cron"].includes(t);function yn(t){const s=t.trim().split(/\s+/);if(s.length!==5)return null;const[r,l,i,u,m]=s;return!/^\d+$/.test(r)||Number(r)>59||!/^\d+$/.test(l)||Number(l)>23||!(i==="L"||/^\d+$/.test(i)&&Number(i)>=1&&Number(i)<=31)||!(u==="*"||/^\d+$/.test(u)&&Number(u)>=1&&Number(u)<=12)||m!=="*"?null:{day:i==="L"?i:String(Number(i)),month:u,time:`${String(Number(l)).padStart(2,"0")}:${String(Number(r)).padStart(2,"0")}`}}function Fs(t){const s=yn(t.expression);return s?s.month==="*"?"monthly":"yearly":"cron"}function Bs(t,s){const r=t?.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone,l=t&&yn(t.expression);let i;try{i=new Intl.DateTimeFormat("en-US",{timeZone:r,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s)}catch{i=new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s)}const u=h=>i.find(N=>N.type===h).value,m=l?.time??`${u("hour")}:${u("minute")}`,c=l?.day??u("day");return{expression:t?.expression??`${Number(m.slice(3))} ${Number(m.slice(0,2))} ${c} * *`,timeZone:r,day:c,month:l&&l.month!=="*"?String(Number(l.month)):u("month"),time:m}}function Ws(t,s,r,l){try{if(t!=="cron"&&!/^\d{2}:\d{2}$/.test(s.time))throw new Error(n("routines.cron.chooseTime"));const[i,u]=s.time.split(":"),m=l??{type:"cron",timeZone:s.timeZone,expression:t==="cron"?s.expression:`${Number(u)} ${Number(i)} ${s.day} ${t==="yearly"?s.month:"*"} *`},c=ns(m,r);return{schedule:l??c,runs:un(c,r,3),error:""}}catch(i){return{schedule:null,runs:[],error:i instanceof Error?i.message:String(i)}}}function Gs({value:t,botEngine:s,onChange:r}){const l=ss(),i=t.engine||s||l[0]?.engine||"",u=[...new Set([...s?[s]:[],...l.map(c=>c.engine),...i?[i]:[]])],m=l.find(c=>c.engine===i)?.resetsAt??null;return e.jsxs("div",{className:"space-y-2 text-[13px] text-ink","data-testid":"limit-reset-fields",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n("routines.limitReset.engine")}),e.jsx(U,{"aria-label":n("routines.limitReset.engine"),value:i,onChange:c=>r({...t,engine:c.target.value}),children:u.map(c=>e.jsx("option",{value:c,children:as(c)},c))}),e.jsxs(U,{"aria-label":n("routines.limitReset.repeat"),value:t.repeat,onChange:c=>r({...t,engine:i,repeat:c.target.value}),children:[e.jsx("option",{value:"once",children:n("routines.limitReset.once")}),e.jsx("option",{value:"every_reset",children:n("routines.limitReset.every")})]})]}),e.jsx("div",{className:"text-[12px] text-ink-secondary",children:m!==null&&m>Date.now()?n("routines.limitReset.next",{time:xn(m)}):n("routines.limitReset.unknown")})]})}function qs({cloudHome:t,local:s,plan:r,ready:l,offersAllowed:i}){return t?{kind:"cloud"}:s?{kind:"local",next:null}:{kind:"server"}}function Us(){const{state:t,dispatch:s}=nt(),r=Is(),l=rs()&&window.ogb?.remoteClient?.active!==!0,i=qs({cloudHome:t.config?.cloudHome===!0,local:l,plan:null,ready:r?.account?.machine?.status==="ready",offersAllowed:Un().source!=="file"}),u="text-left underline underline-offset-2 hover:text-ink",m=()=>{window.confirm(n("routines.scheduleNote.leave"))&&window.ogb?.cloudAccount?.connectHome().catch(()=>{})};return e.jsx("p",{"data-routine-schedule-note":i.kind==="local"?i.next??"local":i.kind,className:"text-[11px] leading-relaxed text-ink-secondary",children:i.kind==="cloud"?n("routines.scheduleNote.cloud"):i.kind==="server"?n("routines.scheduleNote.server"):e.jsxs(e.Fragment,{children:[n("routines.scheduleNote.local"),i.next==="add-cloud"&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:u,onClick:()=>s({type:"openCloudAdd",source:"app_routines"}),children:n("routines.scheduleNote.addCloud")})]}),i.next==="open-cloud"&&e.jsxs(e.Fragment,{children:[" ",n("routines.scheduleNote.openCloud")," ",e.jsx("button",{type:"button",className:u,onClick:m,children:n("cloudHome.connect")})]})]})})}const Xe="application/x-openmaus-bot",we="application/x-openmaus-calendar-event",Ys=t=>t.dataTransfer.types.includes(Xe)||t.dataTransfer.types.includes(we);function Zs(t){const s=t.dataTransfer.getData(Xe);if(s)return{botId:s};try{const r=JSON.parse(t.dataTransfer.getData(we));return(r.kind==="routine"||r.kind==="call")&&typeof r.id=="string"&&typeof r.at=="number"?{event:{kind:r.kind,id:r.id,at:r.at}}:null}catch{return null}}function Vs({marker:t,hourHeight:s,onDrop:r}){const[l,i]=x.useState(!1),u=new Date(t.at),m=n("limits.marker",{engine:t.name,time:xn(t.at,t.at)});return e.jsxs("div",{"data-limit-marker":t.engine,role:"note","aria-label":m,title:n("limits.markerDrop",{engine:t.name}),className:"absolute inset-x-0 z-[25] -translate-y-1/2 py-1.5",style:{top:(u.getHours()*60+u.getMinutes())/60*s},onPointerDown:c=>c.stopPropagation(),onDragOver:c=>{!r||!Ys(c)||(c.preventDefault(),c.stopPropagation(),c.dataTransfer.dropEffect="copy",i(!0))},onDragLeave:()=>i(!1),onDrop:c=>{c.preventDefault(),c.stopPropagation(),i(!1);const h=Zs(c);h&&r?.(h)},children:[e.jsx("div",{className:C("h-0 border-t-2 border-dashed",l?"border-accent":"border-warning/80")}),e.jsxs("span",{className:C("absolute left-1 top-0 flex max-w-[calc(100%-8px)] items-center gap-1 truncate rounded-full border px-1.5 py-0.5 text-[10px] font-medium shadow-sm",l?"border-accent bg-accent text-accent-ink":"border-warning/50 bg-panel text-ink"),children:[e.jsx(Rs,{size:10,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:m})]})]})}const G=64;function jn(t){return t==="running"?"working":t==="waiting"?"curious":t==="completed"?"proud":t==="failed"||t==="missed"?"sad":t==="cancelled"?"sleeping":"drowsy"}function Js(t){return t>=44?"roomy":t>=22?"compact":"tiny"}function Ks({item:t,bots:s,groups:r,compact:l,layout:i,selected:u=!1,onOpen:m,onResize:c}){const h=t.kind==="call",N=t.kind==="routine"?t.routine:null,o=t.kind==="routine"?t.run:null,S=!h&&(o?.target??N?.target)==="room-goal"?o?.groupId??N?.groupId:void 0,v=S?r.find(F=>F.id===S)??{name:n("routines.group")}:void 0,L=(h?t.call.botIds:[o?.botId??N?.botId??""]).flatMap(F=>s.find(y=>y.id===F)??[]),O=L[0],_=h?t.call.name:o?.routineName??N?.name??n("routines.event.automation"),B=h?"var(--color-accent)":O?Kn[O.color]:"var(--color-ink-tertiary)",E=!!(N&&!o&&!N.enabled),[M,d]=x.useState(t.durationMinutes);x.useEffect(()=>d(t.durationMinutes),[t.durationMinutes]);const b=o?.status,T=b==="failed"||b==="missed"||b==="waiting"||t.kind==="routine"&&!o&&t.needsYou===!0,P=o?jt(o):void 0,g=h||!!(N&&!o&&!E&&N.schedule.type!=="cron"),j=h?t.call.schedule:N?.schedule,I=!!(j&&j.type!=="once"),D=j?.type==="interval"?is(j.everyMinutes):null,z=Math.max(16,M/60*G),p=Js(z),H=h?n(L.length===1?"routines.botCountOne":"routines.botCountMany",{count:L.length}):v?v.name:O?.name,w=[_,X(t.at),H,D,E?(N&&os(N))??n("routines.pausedSchedule"):P].filter(Boolean).join(" · "),R=N?.schedule.type==="cron"?n("routines.event.cronMoveHint"):"",Z=F=>{F.preventDefault(),F.stopPropagation();const y=F.clientY,de=M;let Q=de;const be=ve=>{Q=Math.max(ee,Math.min(240,Math.round((de+(ve.clientY-y)/G*60)/ee)*ee)),d(Q)},ce=()=>{if(document.removeEventListener("pointermove",be),document.removeEventListener("pointerup",ce),Q!==t.durationMinutes){if(I&&!window.confirm(n("routines.event.resizeSeries"))){d(t.durationMinutes);return}c(Q)}};document.addEventListener("pointermove",be),document.addEventListener("pointerup",ce,{once:!0})},te=!h&&e.jsx("span",{"data-event-status":E?"paused":T?"needs-you":"working",className:C("size-1.5 shrink-0 rounded-full",E?"bg-ink-tertiary":T?"bg-warning":"bg-success")}),le=F=>h?e.jsx(vt,{size:13,className:"mt-0.5 shrink-0"}):O?e.jsx(Ve,{bot:O,state:b?jn(b):E?"sleeping":"idle",size:F,animated:b==="running"||b==="waiting"}):null;return e.jsxs("button",{"data-event-card":!0,"data-event-fit":p,type:"button",draggable:g,title:R?`${w}
|
|
1
|
+
import{c as tt,r as x,j as e,t as n,a as C,i as Le,bi as Un,ad as ln,g as dn,L as cn,X as Me,S as Yn,z as Zn}from"./styles-BlayaJti.js";import{b as Vn}from"./remote-desktop-DDRRx8uY.js";import{al as Jn,b2 as Kn,B as Ve,c as Qn,L as ze,z as Te}from"./PlacesRail-v1XIqiBG.js";import{ji as Je,cj as Xn,D as U,aP as es,jj as ts,jk as un,bh as ns,cU as ss,jl as as,jm as xn,u as nt,jn as rs,a9 as jt,jo as is,fk as X,af as os,jp as kt,jq as ee,jr as ht,gu as ls,js as qe,jt as pn,cR as mn,cO as Ye,ju as ut,jv as Xt,jw as en,jx as Re,y as Ze,jy as tn,jz as ds,jA as gt,cM as hn,ac as st,jB as Ke,jC as cs,m as us,jD as xs,br as gn,jE as ps,jF as ms,n as Ne,jG as hs,jH as gs,jI as Nt,jJ as nn,jK as bs,a7 as vs,ad as xt,x as fs,cJ as sn,cK as ys,dE as js,T as ks,jL as Ns,jM as Ue,cy as ws,bq as Ss,fT as Cs}from"./App-DFjF9FvF.js";import{u as Is}from"./ProIntroduction--jIMb4bL.js";import{C as Ds}from"./MenuMotion-IQitGKH4.js";const Ts=[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]],Rs=tt("hourglass",Ts);const Ms=[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]],zs=tt("repeat-2",Ms);const Ls=[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]],bt=tt("user-round-plus",Ls);const As=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],vt=tt("video",As);function Qe(t,s){if(!t.config?.team)return;const r=t.bots.find(i=>i.id===s);if(r?.defaultBot?.person)return null;const l=r&&t.activeView==="chat"&&t.selectedId===r.id?r.tasks?.find(i=>i.threadId===r.threadId):void 0;return l&&l.private!==!0&&!l.routineRunId?r.mainThreadId??null:Je}function Os(t,s,r){const l=i=>typeof i=="string"&&!!t.tasks?.some(u=>u.threadId===i&&u.private===!0);return!!t.defaultBot?.person||s===Je||l(s)||l(r)}function bn({team:t,bot:s,value:r,madeIn:l}){if(!t||!s)return null;const i=Os(s,r,l),u=i?Jn:es;return e.jsxs("p",{role:"note","data-routine-audience":i?"me":"shared",className:"mt-2 flex items-center gap-1 text-[12px] leading-4 text-ink-secondary",children:[e.jsx(u,{size:12,"aria-hidden":"true",className:"shrink-0"}),e.jsx("span",{children:i?n("team.privateHeader"):ts(t.name,s.onlyPeopleAdded)})]})}function vn({bot:t,value:s,allowCurrent:r=!1,team:l,onChange:i}){const u=x.useId(),m=Xn();if(l??m!==null)return e.jsx(Es,{id:u,bot:t,value:s,allowCurrent:r,onChange:i});const c=(t?.tasks??[]).filter(o=>!o.routineRunId),h=typeof s=="string"&&!c.some(o=>o.threadId===s),N=[...t?.projects??[],{id:"",name:n("folder.none")}];return e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("label",{htmlFor:u,className:"block text-[12px] font-medium text-ink",children:n("routines.results.label")}),e.jsxs(U,{className:"w-full",id:u,"aria-describedby":`${u}-help`,disabled:!t,value:s??(s===null?"new":"current"),onChange:o=>i(o.target.value==="new"?null:o.target.value==="current"?void 0:o.target.value),children:[r&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"new",children:n("routines.results.main")}),h&&e.jsx("option",{value:s,disabled:!0,children:n("routines.results.unavailable")}),N.map(o=>{const $=c.filter(S=>o.id?S.projectId===o.id:!t?.projects?.some(v=>v.id===S.projectId));return $.length?e.jsx("optgroup",{label:o.name,children:$.map(S=>e.jsx("option",{value:S.threadId,children:S.title},S.threadId))},o.id):null})]}),e.jsx("p",{id:`${u}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.mainHelp")})]})}function Es({id:t,bot:s,value:r,allowCurrent:l,onChange:i}){const u=typeof r=="string"&&!!s?.tasks?.some(c=>c.threadId===r&&c.private===!0),m=r===void 0&&l?"current":r===Je||u?"me":"shared";return e.jsxs("div",{className:"min-w-0 space-y-1.5",children:[e.jsx("label",{htmlFor:t,className:"block text-[12px] font-medium text-ink",children:n("routines.results.label")}),e.jsxs(U,{className:"w-full",id:t,"aria-describedby":`${t}-help`,disabled:!s,value:m,onChange:c=>i(c.target.value==="current"?void 0:c.target.value==="me"?u?r:Je:s?.mainThreadId??null),children:[m==="current"&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"me",children:n("routines.results.justMe")}),e.jsx("option",{value:"shared",children:n("task.sharedChat")})]}),e.jsx("p",{id:`${t}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.teamHelp")})]})}const pt="min-w-0 rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",Ps=t=>Array.from({length:12},(s,r)=>new Intl.DateTimeFormat(t,{month:"long",timeZone:"UTC"}).format(new Date(Date.UTC(2024,r,1)))),Hs=["UTC",...typeof Intl.supportedValuesOf=="function"?Intl.supportedValuesOf("timeZone"):[]];function fn({runs:t,timeZone:s,paused:r=!1}){if(!t.length)return null;const l=new Intl.DateTimeFormat(Le(),{timeZone:s,weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});return e.jsxs("div",{className:"space-y-1 text-[11px] leading-relaxed text-ink-secondary","aria-label":n(r?"routines.cron.pausedPreviewLabel":"routines.cron.nextRunsLabel"),children:[e.jsxs("div",{className:"font-medium",children:[n(r?"routines.cron.pausedPreview":"routines.cron.nextRuns")," · ",s]}),t.map(i=>e.jsx("div",{children:e.jsx("time",{dateTime:new Date(i).toISOString(),children:l.format(i)})},i)),e.jsx("div",{className:"pt-1",children:n("routines.cron.clockChanges")})]})}function $s({schedule:t,paused:s=!1}){const r=x.useMemo(()=>{try{return un(t,Date.now(),3)}catch{return[]}},[t]);return e.jsx(fn,{runs:r,timeZone:t.timeZone,paused:s})}function _s({choice:t,value:s,onChange:r,runs:l,error:i}){const u=m=>r({...s,...m});return e.jsxs("div",{className:"space-y-3",children:[t==="cron"?e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.expression")}),e.jsx("input",{value:s.expression,onChange:m=>u({expression:m.target.value}),placeholder:"0 9 1 * *",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-help routine-cron-error",className:C(pt,"w-full font-mono")}),e.jsx("span",{id:"routine-cron-help",className:"block text-[11px]",children:n("routines.cron.expressionHelp")})]}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t==="yearly"&&e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.month")}),e.jsx(U,{value:s.month,onChange:m=>u({month:m.target.value}),children:Ps(Le()).map((m,c)=>e.jsx("option",{value:String(c+1),children:m},m))})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.dayOfMonth")}),e.jsxs(U,{value:s.day,onChange:m=>u({day:m.target.value}),children:[Array.from({length:31},(m,c)=>e.jsx("option",{value:String(c+1),children:c+1},c+1)),e.jsx("option",{value:"L",children:n("routines.cron.lastDay")})]})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.time")}),e.jsx("input",{type:"time",step:60,value:s.time,onChange:m=>u({time:m.target.value}),className:pt})]})]}),t!=="cron"&&Number(s.day)>28&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:n("routines.cron.skippedMonths")}),e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.timeZone")}),e.jsx("input",{list:"routine-time-zones",value:s.timeZone,onChange:m=>u({timeZone:m.target.value}),placeholder:"America/New_York",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-error",className:C(pt,"block w-full")})]}),e.jsx("datalist",{id:"routine-time-zones",children:Hs.map(m=>e.jsx("option",{value:m},m))}),i&&e.jsx("p",{id:"routine-cron-error",role:"alert",className:"text-[12px] text-danger",children:i}),!i&&e.jsx(fn,{runs:l,timeZone:s.timeZone.trim()})]})}const ge=t=>["monthly","yearly","cron"].includes(t);function yn(t){const s=t.trim().split(/\s+/);if(s.length!==5)return null;const[r,l,i,u,m]=s;return!/^\d+$/.test(r)||Number(r)>59||!/^\d+$/.test(l)||Number(l)>23||!(i==="L"||/^\d+$/.test(i)&&Number(i)>=1&&Number(i)<=31)||!(u==="*"||/^\d+$/.test(u)&&Number(u)>=1&&Number(u)<=12)||m!=="*"?null:{day:i==="L"?i:String(Number(i)),month:u,time:`${String(Number(l)).padStart(2,"0")}:${String(Number(r)).padStart(2,"0")}`}}function Fs(t){const s=yn(t.expression);return s?s.month==="*"?"monthly":"yearly":"cron"}function Bs(t,s){const r=t?.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone,l=t&&yn(t.expression);let i;try{i=new Intl.DateTimeFormat("en-US",{timeZone:r,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s)}catch{i=new Intl.DateTimeFormat("en-US",{timeZone:"UTC",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(s)}const u=h=>i.find(N=>N.type===h).value,m=l?.time??`${u("hour")}:${u("minute")}`,c=l?.day??u("day");return{expression:t?.expression??`${Number(m.slice(3))} ${Number(m.slice(0,2))} ${c} * *`,timeZone:r,day:c,month:l&&l.month!=="*"?String(Number(l.month)):u("month"),time:m}}function Ws(t,s,r,l){try{if(t!=="cron"&&!/^\d{2}:\d{2}$/.test(s.time))throw new Error(n("routines.cron.chooseTime"));const[i,u]=s.time.split(":"),m=l??{type:"cron",timeZone:s.timeZone,expression:t==="cron"?s.expression:`${Number(u)} ${Number(i)} ${s.day} ${t==="yearly"?s.month:"*"} *`},c=ns(m,r);return{schedule:l??c,runs:un(c,r,3),error:""}}catch(i){return{schedule:null,runs:[],error:i instanceof Error?i.message:String(i)}}}function Gs({value:t,botEngine:s,onChange:r}){const l=ss(),i=t.engine||s||l[0]?.engine||"",u=[...new Set([...s?[s]:[],...l.map(c=>c.engine),...i?[i]:[]])],m=l.find(c=>c.engine===i)?.resetsAt??null;return e.jsxs("div",{className:"space-y-2 text-[13px] text-ink","data-testid":"limit-reset-fields",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:n("routines.limitReset.engine")}),e.jsx(U,{"aria-label":n("routines.limitReset.engine"),value:i,onChange:c=>r({...t,engine:c.target.value}),children:u.map(c=>e.jsx("option",{value:c,children:as(c)},c))}),e.jsxs(U,{"aria-label":n("routines.limitReset.repeat"),value:t.repeat,onChange:c=>r({...t,engine:i,repeat:c.target.value}),children:[e.jsx("option",{value:"once",children:n("routines.limitReset.once")}),e.jsx("option",{value:"every_reset",children:n("routines.limitReset.every")})]})]}),e.jsx("div",{className:"text-[12px] text-ink-secondary",children:m!==null&&m>Date.now()?n("routines.limitReset.next",{time:xn(m)}):n("routines.limitReset.unknown")})]})}function qs({cloudHome:t,local:s,plan:r,ready:l,offersAllowed:i}){return t?{kind:"cloud"}:s?{kind:"local",next:null}:{kind:"server"}}function Us(){const{state:t,dispatch:s}=nt(),r=Is(),l=rs()&&window.ogb?.remoteClient?.active!==!0,i=qs({cloudHome:t.config?.cloudHome===!0,local:l,plan:null,ready:r?.account?.machine?.status==="ready",offersAllowed:Un().source!=="file"}),u="text-left underline underline-offset-2 hover:text-ink",m=()=>{window.confirm(n("routines.scheduleNote.leave"))&&window.ogb?.cloudAccount?.connectHome().catch(()=>{})};return e.jsx("p",{"data-routine-schedule-note":i.kind==="local"?i.next??"local":i.kind,className:"text-[11px] leading-relaxed text-ink-secondary",children:i.kind==="cloud"?n("routines.scheduleNote.cloud"):i.kind==="server"?n("routines.scheduleNote.server"):e.jsxs(e.Fragment,{children:[n("routines.scheduleNote.local"),i.next==="add-cloud"&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:u,onClick:()=>s({type:"openCloudAdd",source:"app_routines"}),children:n("routines.scheduleNote.addCloud")})]}),i.next==="open-cloud"&&e.jsxs(e.Fragment,{children:[" ",n("routines.scheduleNote.openCloud")," ",e.jsx("button",{type:"button",className:u,onClick:m,children:n("cloudHome.connect")})]})]})})}const Xe="application/x-openmaus-bot",we="application/x-openmaus-calendar-event",Ys=t=>t.dataTransfer.types.includes(Xe)||t.dataTransfer.types.includes(we);function Zs(t){const s=t.dataTransfer.getData(Xe);if(s)return{botId:s};try{const r=JSON.parse(t.dataTransfer.getData(we));return(r.kind==="routine"||r.kind==="call")&&typeof r.id=="string"&&typeof r.at=="number"?{event:{kind:r.kind,id:r.id,at:r.at}}:null}catch{return null}}function Vs({marker:t,hourHeight:s,onDrop:r}){const[l,i]=x.useState(!1),u=new Date(t.at),m=n("limits.marker",{engine:t.name,time:xn(t.at,t.at)});return e.jsxs("div",{"data-limit-marker":t.engine,role:"note","aria-label":m,title:n("limits.markerDrop",{engine:t.name}),className:"absolute inset-x-0 z-[25] -translate-y-1/2 py-1.5",style:{top:(u.getHours()*60+u.getMinutes())/60*s},onPointerDown:c=>c.stopPropagation(),onDragOver:c=>{!r||!Ys(c)||(c.preventDefault(),c.stopPropagation(),c.dataTransfer.dropEffect="copy",i(!0))},onDragLeave:()=>i(!1),onDrop:c=>{c.preventDefault(),c.stopPropagation(),i(!1);const h=Zs(c);h&&r?.(h)},children:[e.jsx("div",{className:C("h-0 border-t-2 border-dashed",l?"border-accent":"border-warning/80")}),e.jsxs("span",{className:C("absolute left-1 top-0 flex max-w-[calc(100%-8px)] items-center gap-1 truncate rounded-full border px-1.5 py-0.5 text-[10px] font-medium shadow-sm",l?"border-accent bg-accent text-accent-ink":"border-warning/50 bg-panel text-ink"),children:[e.jsx(Rs,{size:10,className:"shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:m})]})]})}const G=64;function jn(t){return t==="running"?"working":t==="waiting"?"curious":t==="completed"?"proud":t==="failed"||t==="missed"?"sad":t==="cancelled"?"sleeping":"drowsy"}function Js(t){return t>=44?"roomy":t>=22?"compact":"tiny"}function Ks({item:t,bots:s,groups:r,compact:l,layout:i,selected:u=!1,onOpen:m,onResize:c}){const h=t.kind==="call",N=t.kind==="routine"?t.routine:null,o=t.kind==="routine"?t.run:null,S=!h&&(o?.target??N?.target)==="room-goal"?o?.groupId??N?.groupId:void 0,v=S?r.find(F=>F.id===S)??{name:n("routines.group")}:void 0,L=(h?t.call.botIds:[o?.botId??N?.botId??""]).flatMap(F=>s.find(y=>y.id===F)??[]),O=L[0],_=h?t.call.name:o?.routineName??N?.name??n("routines.event.automation"),B=h?"var(--color-accent)":O?Kn[O.color]:"var(--color-ink-tertiary)",E=!!(N&&!o&&!N.enabled),[M,d]=x.useState(t.durationMinutes);x.useEffect(()=>d(t.durationMinutes),[t.durationMinutes]);const b=o?.status,T=b==="failed"||b==="missed"||b==="waiting"||t.kind==="routine"&&!o&&t.needsYou===!0,P=o?jt(o):void 0,g=h||!!(N&&!o&&!E&&N.schedule.type!=="cron"),j=h?t.call.schedule:N?.schedule,I=!!(j&&j.type!=="once"),D=j?.type==="interval"?is(j.everyMinutes):null,z=Math.max(16,M/60*G),p=Js(z),H=h?n(L.length===1?"routines.botCountOne":"routines.botCountMany",{count:L.length}):v?v.name:O?.name,w=[_,X(t.at),H,D,E?(N&&os(N))??n("routines.pausedSchedule"):P].filter(Boolean).join(" · "),R=N?.schedule.type==="cron"?n("routines.event.cronMoveHint"):"",Z=F=>{F.preventDefault(),F.stopPropagation();const y=F.clientY,de=M;let Q=de;const be=ve=>{Q=Math.max(ee,Math.min(240,Math.round((de+(ve.clientY-y)/G*60)/ee)*ee)),d(Q)},ce=()=>{if(document.removeEventListener("pointermove",be),document.removeEventListener("pointerup",ce),Q!==t.durationMinutes){if(I&&!window.confirm(n("routines.event.resizeSeries"))){d(t.durationMinutes);return}c(Q)}};document.addEventListener("pointermove",be),document.addEventListener("pointerup",ce,{once:!0})},te=!h&&e.jsx("span",{"data-event-status":E?"paused":T?"needs-you":"working",className:C("size-1.5 shrink-0 rounded-full",E?"bg-ink-tertiary":T?"bg-warning":"bg-success")}),le=F=>h?e.jsx(vt,{size:13,className:"mt-0.5 shrink-0"}):O?e.jsx(Ve,{bot:O,state:b?jn(b):E?"sleeping":"idle",size:F,animated:b==="running"||b==="waiting"}):null;return e.jsxs("button",{"data-event-card":!0,"data-event-fit":p,type:"button",draggable:g,title:R?`${w}
|
|
2
2
|
${R}`:w,onDragStart:F=>{if(!g)return F.preventDefault();F.dataTransfer.effectAllowed="move",F.dataTransfer.setData(we,JSON.stringify({kind:t.kind,id:h?t.call.id:N.id,at:t.at}))},onClick:F=>{F.stopPropagation(),m()},"aria-pressed":u,"aria-label":`${_}, ${X(t.at)}${E?`, ${n("routines.pausedSchedule")}`:P?`, ${P}`:""}`,className:C("group absolute z-10 overflow-hidden rounded-md border border-l-[3px] text-left transition hover:z-20 focus:z-20 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",p==="roomy"?"px-1.5 py-1":"px-1.5 py-0",E&&"border-dashed opacity-70",b==="cancelled"&&"opacity-55",(b==="failed"||b==="missed")&&(o&&kt(o)?"border-warning/60":"border-danger/60"),u&&"z-20 ring-2 ring-accent ring-offset-1 ring-offset-app"),style:{left:`calc(${i.column/i.columns*100}% + 2px)`,width:`calc(${100/i.columns}% - 4px)`,top:`${(new Date(t.at).getHours()*60+new Date(t.at).getMinutes())/60*G}px`,height:`${z}px`,background:`color-mix(in srgb, ${B} ${E?6:16}%, var(--color-card))`,borderColor:`color-mix(in srgb, ${B} 40%, transparent)`,borderLeftColor:B,color:`color-mix(in srgb, ${B} 55%, var(--color-ink))`},children:[p==="roomy"?e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[le(l?18:22),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[11px] font-semibold leading-tight",children:_}),e.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-[10px] opacity-80",children:[te,e.jsxs("span",{className:"truncate",children:[X(t.at)," · ",D&&!v&&!h?`${H??""} · ${D}`:H]})]})]}),L.length>1&&e.jsxs("span",{className:"rounded bg-inset/60 px-1 py-0.5 text-[8px]",children:["+",L.length-1]})]}):p==="compact"?e.jsxs("div",{className:"flex h-full min-w-0 items-center gap-1",children:[h&&e.jsx(vt,{size:11,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold leading-none",children:_}),te,e.jsx("span",{className:"shrink-0 text-[10px] leading-none tabular-nums opacity-80",children:X(t.at)})]}):e.jsx("div",{className:"flex h-full min-w-0 items-center truncate text-[10px] font-semibold leading-none",children:_}),h&&e.jsx("div",{onPointerDown:Z,className:"absolute inset-x-1 bottom-0 h-1.5 cursor-ns-resize rounded-full opacity-0 transition group-hover:opacity-100","aria-label":n("routines.event.resize"),children:e.jsx("div",{className:"mx-auto mt-0.5 h-0.5 w-5 rounded-full bg-current opacity-50"})})]})}const ft=[0,1,2,3,4,5,6],et=[1,2,3,4,5],mt=[5,10,15,30,60],an=Array.from({length:240/ee},(t,s)=>(s+1)*ee);function kn(t,s){return t?t.memberIds.flatMap(r=>{const l=s.find(i=>i.id===r);return l&&!l.hidden?[l]:[]}):s.filter(r=>!r.hidden)}function Qs(t){return t.dm?!1:!(Object.prototype.hasOwnProperty.call(t,"setupCompletedAt")||Object.prototype.hasOwnProperty.call(t,"setupSkippedAt"))||t.setupCompletedAt!=null||t.setupSkippedAt!=null||(t.messages?.length??0)>0}function rn(t,s,r){const l=kn(t,s),i=t?.defaultResponder.kind==="member"?t.defaultResponder.botId:void 0;return l.find(u=>u.id===r)??l.find(u=>u.id===i)??l.find(u=>u.chiefOfStaff)??l[0]}function on(){const t=new Date(Date.now()+36e5);return t.setMinutes(0,0,0),t.getTime()}function Xs(t,s){return!!(t&&t.length===s.length&&t.every((r,l)=>r===s[l]))}function ea(t){return t.type!=="interval"||!t.weekdays||t.weekdays.length===7?"every-day":Xs(t.weekdays,et)?"weekdays":"custom"}function ta(t){const s=new Date(`${t}T00:00`);return s.setHours(23,59,59,999),s.getTime()}function na(t,s){return t.type==="once"?"none":t.type==="limit_reset"?"limit_reset":t.type==="interval"?"interval":t.type==="cron"?Fs(t):t.weekdays.length===7?"daily":t.weekdays.join(",")==="1,2,3,4,5"?"weekdays":t.weekdays.length===1&&t.weekdays[0]===new Date(s).getDay()?"weekly":"custom"}function Nn(t,s,r){if(t==="none")return{type:"once",at:s};const l=t==="daily"?ft:t==="weekdays"?et:t==="weekly"?[new Date(s).getDay()]:r;return{type:"daily",time:pn(s),weekdays:[...l].sort()}}function sa(t,s,r,l,i){return t==="interval"?{type:"interval",everyMinutes:l,...i}:Nn(t,s,r)}function wn({attachments:t,onRemove:s}){return t.length?e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(r=>e.jsxs("div",{className:"flex max-w-[260px] items-center gap-2 rounded-lg border border-hairline/50 bg-inset px-2.5 py-2 text-[12px] text-ink",children:[e.jsx(st,{size:14,className:"shrink-0 text-accent"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),s&&e.jsx("button",{type:"button",onClick:()=>s(r.id),className:"rounded p-0.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":n("routines.attachment.remove",{name:r.name}),children:e.jsx(Me,{size:12})})]},r.id))}):null}function yt({bots:t,selected:s,multiple:r,locked:l,onChange:i}){const[u,m]=x.useState(""),c=t.filter(h=>`${h.name} ${h.title}`.toLowerCase().includes(u.toLowerCase()));return e.jsxs("div",{className:"rounded-xl border border-hairline/50 bg-inset/60 p-2",children:[!l&&t.length>5&&e.jsxs("label",{className:"mb-2 flex items-center gap-2 rounded-lg border border-transparent bg-panel px-2.5 py-2 text-ink-secondary focus-within:border-focus",children:[e.jsx(Yn,{size:14}),e.jsx("input",{value:u,onChange:h=>m(h.target.value),placeholder:n("routines.findBot"),className:"min-w-0 flex-1 bg-transparent text-[12px] text-ink outline-none placeholder:text-ink-tertiary"})]}),e.jsx("div",{className:"grid max-h-48 grid-cols-1 gap-1 overflow-y-auto sm:grid-cols-2",children:c.map(h=>{const N=s.includes(h.id);return e.jsxs("button",{type:"button",disabled:l,onClick:()=>i(r?N?s.filter(o=>o!==h.id):[...s,h.id]:[h.id]),className:C("flex min-w-0 items-center gap-2 rounded-lg px-2 py-2 text-left transition",N?"bg-accent/12 ring-1 ring-accent/50":"hover:bg-raised",l&&"cursor-default"),children:[e.jsx(Ve,{bot:h,state:N?"happy":"idle",size:32,animated:!1}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium text-ink",children:h.name}),N&&e.jsx(gn,{size:14,className:"shrink-0 text-accent"})]},h.id)})})]})}function aa(t){return t.flatMap(s=>s.kind==="paste"||s.kind==="citation"?[]:[{id:s.id,kind:s.kind,name:s.name,path:s.path,size:s.size}])}function ra({seed:t,bots:s,lockedBotId:r,defaultRunOn:l,routinesOnly:i=!1,plain:u=!1,onClose:m,onSavedCall:c}){const{state:h,dispatch:N}=nt(),o=t.routine,{request:$}=ls(),S=t.call,[v,J]=x.useState(i?"routine":t.kind),[L]=x.useState(()=>Date.now()),[O,_]=x.useState(o?.name??S?.name??t.name??""),[B,E]=x.useState(o?.prompt??S?.description??t.description??""),M=o?.schedule.type==="once"?o.schedule.at:o?.schedule.type==="daily"?ht(t.at,o.schedule.time):o?.schedule.type==="interval"?o.schedule.anchorAt:S?.schedule.type==="once"?S.schedule.at:S?.schedule.type==="daily"?ht(t.at,S.schedule.time):t.at,d=o?.schedule??S?.schedule??{type:"once",at:M},[b,T]=x.useState(qe(M)),[P,g]=x.useState(pn(M)),[j,I]=x.useState(o?.durationMinutes??S?.durationMinutes??t.durationMinutes),[D,z]=x.useState(o?.timeoutMinutes??null),[p,H]=x.useState(!!o),[w,R]=x.useState(o?.overlap??"skip"),[Z,te]=x.useState(!!o?.continuity),[le,F]=x.useState(!!o?.runOnStartup),[y,de]=x.useState(t.limitReset?"limit_reset":na(d,M)),[Q,be]=x.useState(d.type==="limit_reset"?d:{engine:t.limitReset?.engine??"",repeat:"once"}),[ce,ve]=x.useState(()=>Bs(d.type==="cron"?d:void 0,M)),[at,Ae]=x.useState(!1),[fe,Oe]=x.useState(d.type==="daily"?d.weekdays:[new Date(M).getDay()]),[q,Se]=x.useState(d.type==="interval"?d.everyMinutes:15),[ne,rt]=x.useState(()=>ea(d)),[f,K]=x.useState(()=>d.type==="interval"&&d.weekdays?.length?d.weekdays:[...ft]),[pe,se]=x.useState(d.type==="interval"&&d.window?"custom":"all-day"),[Ee,Sn]=x.useState(d.type==="interval"?d.window?.start??"09:00":"09:00"),[Pe,Cn]=x.useState(d.type==="interval"?d.window?.end??"17:00":"17:00"),[He,In]=x.useState(d.type==="interval"&&d.endsAt!=null?"on-date":"never"),[wt,Dn]=x.useState(()=>d.type==="interval"&&d.endsAt!=null?qe(d.endsAt):qe(mn(Ye(Math.max(Date.now(),M)),7))),[W,St]=x.useState(r?[r]:o?[o.botId]:S?.botIds??t.botIds),[it,Ct]=x.useState(()=>(o?o.resultsThreadId:t.resultsThreadId??Qe(h,W[0]))??null),$e=a=>{a[0]!==W[0]&&Ct(Qe(h,a[0])??null),St(a)},[V,Tn]=x.useState(o?.target??"bot"),[me,ot]=x.useState(o?.groupId??""),[ye,_e]=x.useState(o?.runOn??l??"maus"),[Ce,lt]=x.useState(o?.target==="room-goal"?[]:o?.attachments??S?.attachments??[]),[It,Dt]=x.useState(!1),[Tt,Rt]=x.useState(""),[Mt,zt]=x.useState(""),[Rn,Lt]=x.useState(0),Fe=Rn>0,At=x.useRef(null),Mn=!!(h.config?.box.configured&&W.length>0&&W.every(a=>Vn(h.instances,s.find(k=>k.id===a)?.modelSelection.instanceId)?.snapshot.state==="available")),Be=h.groups.filter(Qs),ue=Be.find(a=>a.id===me),dt=ue?kn(ue,h.bots):s,ae=v==="routine"&&V==="room-goal",Ot=h.config?.cloudHome===!0,We=ut(b,P,o||S?M:void 0),zn=We+j*6e4,Ie=W.flatMap(a=>s.find(k=>k.id===a)??[]),Et=x.useRef(null),De=y==="interval"&&(!Number.isInteger(q)||q<5||q>1440),je=y==="interval"&&ne==="custom"&&f.length===0,Pt=ut("2000-01-01",Pe)-ut("2000-01-01",Ee),re=y==="interval"&&pe==="custom"&&(!Ee||!Pe||!Number.isFinite(Pt)||Pt<q*6e4),ct=o?.schedule.type==="interval"?o.schedule:void 0,Ht=Xt(L,Math.max(5,q||5),ct),ke=He==="on-date"?ta(wt):null,he=y==="interval"&&He==="on-date"&&(ke==null||!Number.isSafeInteger(ke)||ke<Ht),$t=ne==="every-day"?void 0:ne==="weekdays"?et:f,Ln=pe==="custom"?{start:Ee,end:Pe}:void 0,xe=ge(y)?Ws(y,ce,L,!at&&d.type==="cron"?d:void 0):null,_t=a=>{a==="interval"&&!p&&(z(k=>k??30),H(!0)),ge(a)&&(a==="cron"&&xe?.schedule&&ve(k=>({...k,expression:xe.schedule.expression})),Ae(!0)),de(a)},An=a=>{a==="custom"&&ne!=="custom"&&K(ne==="weekdays"?[...et]:[...ft]),rt(a)},Ft=a=>{if(Tn(a),a==="bot"){ot("");return}_e("maus"),lt([]),zt("");const k=ue??Be[0];ot(k?.id??"");const A=rn(k,h.bots,W[0]);$e(A?[A.id]:[])},On=a=>{const k=Be.find(ie=>ie.id===a);ot(a);const A=rn(k,h.bots,W[0]);$e(A?[A.id]:[])},En=async a=>{if(!(!a?.length||ae)){Lt(k=>k+1);try{const k=await cs(Array.from(a),{allowImages:!0,getPath:xs,uploadImage:us}),A=aa(k.attachments);A.length&&(lt(ie=>[...ie,...A].slice(0,20)),ye==="cloud"&&_e("maus")),k.notice&&zt(k.notice)}finally{Lt(k=>Math.max(0,k-1))}}},Pn=async()=>{if(!Fe){Dt(!0),Rt("");try{if(v==="routine"||i){const a=Date.now(),k=ps(a,q,ct);if(y==="interval"&&ke!=null&&ke<Xt(a,q,ct))throw new Error(n("routines.interval.endAfterFirstRun"));const A=Q.engine||s.find(qn=>qn.id===(r??W[0]))?.modelSelection?.instanceId||"",ie=y==="limit_reset"?{type:"limit_reset",engine:A,repeat:Q.repeat}:ge(y)?xe?.schedule:sa(y,We,fe,q,{anchorAt:k,weekdays:$t?[...$t].sort():null,window:Ln??null,endsAt:ke});if(!ie)throw new Error(xe?.error||n("routines.error.invalidSchedule"));const Wn={name:O,prompt:B,target:V,botId:r??W[0]??"",groupId:V==="room-goal"&&me?me:null,runOn:V==="room-goal"?"maus":ye,enabled:o&&(o.enabled||!ms(o,a))?void 0:!0,schedule:ie,durationMinutes:j,timeoutMinutes:D,overlap:w,continuity:V==="bot"&&y!=="none"&&Z,runOnStartup:y!=="none"&&le,attachments:V==="room-goal"?[]:Ce,...V==="bot"?{resultsThreadId:it}:{}},Gn=await $(o?`/api/routines/${o.id}`:"/api/routines",{method:o?"PATCH":"POST",body:JSON.stringify(Wn)});N({type:"routinePatched",routine:Gn.routine})}else{if(y==="interval"||y==="limit_reset"||ge(y))throw new Error(n("routines.error.callSchedule"));const a=Nn(y,We,fe),k={name:O,description:B,botIds:W,schedule:a,durationMinutes:j,attachments:Ce},A=await Ne(S?`/api/calendar-calls/${S.id}`:"/api/calendar-calls",{method:S?"PATCH":"POST",body:JSON.stringify(k)});c(A.call)}m()}catch(a){Rt(a instanceof Error?a.message:String(a))}finally{Dt(!1)}}},Hn=!!(O.trim()&&(v==="call"||B.trim())&&(!r||W[0]===r)&&(v==="call"?W.length>0:V==="room-goal"?(!me||ue)&&W[0]&&dt.some(a=>a.id===W[0]):W.length>0)&&!De&&!je&&!re&&!he&&!xe?.error),$n=!i&&!o&&!S&&!r,Y=ln()&&!u,[Ge,_n]=x.useState(()=>!["none","daily","weekdays","weekly"].includes(y)||V==="room-goal"||Ce.length>0||ye==="cloud"||D!=null||le||w==="queue");Qn(Et,m);const Bt=$n&&e.jsxs("div",{className:C(Y&&"ml-10","inline-flex rounded-lg bg-inset p-1"),children:[e.jsx("button",{type:"button",onClick:()=>{J("routine"),St(a=>a.slice(0,1))},className:C("rounded-md px-4 py-1.5 text-[13px] font-medium",v==="routine"?"bg-raised text-ink shadow":"text-ink-secondary"),children:n("routines.kind.routine")}),e.jsx("button",{type:"button",onClick:()=>{J("call"),(y==="interval"||y==="limit_reset"||ge(y))&&de("none")},className:C("rounded-md px-4 py-1.5 text-[13px] font-medium",v==="call"?"bg-raised text-ink shadow":"text-ink-secondary"),children:n("routines.kind.call")})]}),Wt=v==="routine"&&!r&&e.jsxs("div",{className:C(Y&&"ml-10"),children:[e.jsx("div",{className:"mb-2 text-[11px] font-medium uppercase tracking-wider text-ink-secondary",children:n("routines.editor.type")}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>Ft("bot"),className:C("flex items-start gap-3 rounded-xl border p-3 text-left transition",V==="bot"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx(bt,{size:17,className:C("mt-0.5 shrink-0",V==="bot"?"text-accent":"text-ink-secondary")}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.editor.botTask")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.botTaskHelp")})]})]}),e.jsxs("button",{type:"button",onClick:()=>Ft("room-goal"),className:C("flex items-start gap-3 rounded-xl border p-3 text-left transition",V==="room-goal"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx(en,{size:17,className:C("mt-0.5 shrink-0",V==="room-goal"?"text-accent":"text-ink-secondary")}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.editor.teamGoal")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.teamGoalHelp")})]})]})]})]}),Gt=y!=="interval"&&y!=="limit_reset"&&!ge(y)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v==="routine"&&y==="none"&&e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.editor.starts")}),v==="routine"&&y==="weekly"&&e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.editor.on")}),(v==="call"||y==="none"||y==="weekly")&&e.jsx("input",{type:"date",value:b,onChange:a=>T(a.target.value),className:"rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]"}),e.jsx("input",{type:"time",step:ee*60,value:P,onChange:a=>g(a.target.value),className:"rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]"}),v==="call"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[12px] text-ink-secondary",children:n("routines.editor.to")}),e.jsx("span",{className:"rounded-lg border border-hairline/40 bg-inset/60 px-3 py-2 text-[13px] text-ink",children:X(zn)}),e.jsx(U,{"aria-label":n("routines.editor.callDuration"),value:j,onChange:a=>I(Number(a.target.value)),children:an.map(a=>e.jsx("option",{value:a,children:Re(a)},a))})]})]}),qt=e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(zs,{size:14,className:"text-ink-secondary"}),e.jsxs(U,{"aria-label":n("routines.editor.repeat"),value:y,onChange:a=>_t(a.target.value),children:[e.jsx("option",{value:"none",children:n("routines.repeat.none")}),v==="routine"&&e.jsx("option",{value:"interval",children:n("routines.repeat.interval")}),e.jsx("option",{value:"daily",children:n("routines.repeat.dailyOption")}),e.jsx("option",{value:"weekdays",children:n("routines.repeat.weekdaysOption")}),e.jsx("option",{value:"weekly",children:n("routines.schedule.weeklyOn",{day:Ze(new Date(We).getDay())})}),e.jsx("option",{value:"custom",children:n("routines.repeat.selectedWeekdays")}),v==="routine"&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"monthly",children:n("routines.repeat.monthly")}),e.jsx("option",{value:"yearly",children:n("routines.repeat.yearly")}),e.jsx("option",{value:"cron",children:n("routines.repeat.customCron")})]}),v==="routine"&&e.jsx("option",{value:"limit_reset",children:n("routines.limitReset.option")})]})]}),Ut=v==="routine"&&e.jsx(Us,{}),Yt=e.jsxs(e.Fragment,{children:[y==="limit_reset"&&v==="routine"&&e.jsx(Gs,{value:Q,botEngine:s.find(a=>a.id===(r??W[0]))?.modelSelection?.instanceId,onChange:be}),ge(y)&&v==="routine"&&xe&&e.jsx(_s,{choice:y,value:ce,onChange:a=>{ve(a),Ae(!0)},runs:xe.runs,error:xe.error}),y==="custom"&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:tn.map((a,k)=>e.jsx("button",{type:"button",onClick:()=>Oe(A=>A.includes(k)?A.length===1?A:A.filter(ie=>ie!==k):[...A,k].sort()),className:C("size-8 rounded-full text-[10px] font-semibold",fe.includes(k)?"bg-accent text-white":"bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:Ze(k).charAt(0).toLocaleUpperCase(Le())},a))}),y==="interval"&&v==="routine"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[13px] text-ink",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.runsEvery")}),e.jsxs(U,{value:mt.includes(q)?String(q):"custom",onChange:a=>Se(a.target.value==="custom"?0:Number(a.target.value)),"aria-label":n("routines.interval.howOften"),children:[mt.map(a=>e.jsx("option",{value:a,children:a},a)),e.jsx("option",{value:"custom",children:n("routines.interval.custom")})]}),!mt.includes(q)&&e.jsx("input",{type:"number",min:5,max:1440,step:1,value:q||"",onChange:a=>Se(Number(a.target.value)),"aria-label":n("routines.interval.customMinutes"),"aria-invalid":De,"aria-describedby":De?"routine-interval-error":"routine-interval-help",autoFocus:!0,className:C("w-20 rounded-lg border bg-inset px-3 py-2 text-[13px] tabular-nums text-ink outline-none focus:border-accent",De?"border-danger/70":"border-hairline/50")}),e.jsx("span",{children:n("routines.interval.minutesUnit")})]}),e.jsxs("div",{className:"grid items-center gap-2 text-[13px] text-ink sm:flex sm:flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.on")}),e.jsxs(U,{value:ne,onChange:a=>An(a.target.value),"aria-label":n("routines.interval.daysLabel"),"aria-invalid":je,"aria-describedby":je?"routine-interval-days-error":void 0,children:[e.jsx("option",{value:"every-day",children:n("routines.repeat.daily")}),e.jsx("option",{value:"weekdays",children:n("routines.repeat.weekdays")}),e.jsx("option",{value:"custom",children:n("routines.interval.custom")})]})]}),e.jsx("span",{"aria-hidden":"true",className:"hidden text-ink-secondary sm:inline",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.during")}),e.jsxs(U,{value:pe,onChange:a=>se(a.target.value),"aria-label":n("routines.interval.hoursLabel"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,children:[e.jsx("option",{value:"all-day",children:n("routines.interval.allDay")}),e.jsx("option",{value:"custom",children:n("routines.interval.customHours")})]})]}),e.jsx("span",{"aria-hidden":"true",className:"hidden text-ink-secondary sm:inline",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.ends")}),e.jsxs(U,{value:He,onChange:a=>In(a.target.value),"aria-label":n("routines.interval.endsLabel"),"aria-invalid":he,"aria-describedby":he?"routine-interval-end-error":void 0,children:[e.jsx("option",{value:"never",children:n("routines.interval.never")}),e.jsx("option",{value:"on-date",children:n("routines.interval.onDate")})]})]})]}),ne==="custom"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] font-medium text-ink-secondary",children:n("routines.interval.chooseDays")}),e.jsx("div",{role:"group","aria-label":n("routines.interval.customDays"),"aria-invalid":je,"aria-describedby":je?"routine-interval-days-error":void 0,className:"flex flex-wrap gap-1.5",children:tn.map((a,k)=>e.jsx("button",{type:"button",onClick:()=>K(A=>A.includes(k)?A.filter(ie=>ie!==k):[...A,k].sort()),"aria-label":n(f.includes(k)?"routines.interval.daySelected":"routines.interval.dayNotSelected",{day:Ze(k)}),"aria-pressed":f.includes(k),className:C("size-8 rounded-full text-[10px] font-semibold",f.includes(k)?"bg-accent text-white":"bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.interval.dayChips").split(" ")[k]},a))})]}),pe==="custom"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{className:"font-medium text-ink-secondary",children:n("routines.interval.runBetween")}),e.jsx("input",{"aria-label":n("routines.interval.windowStart"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,type:"time",step:ee*60,value:Ee,onChange:a=>Sn(a.target.value),className:C("rounded-lg border bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",re?"border-danger/70":"border-hairline/50")}),e.jsx("span",{className:"text-ink-secondary",children:n("routines.interval.and")}),e.jsx("input",{"aria-label":n("routines.interval.windowEnd"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,type:"time",step:ee*60,value:Pe,onChange:a=>Cn(a.target.value),className:C("rounded-lg border bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",re?"border-danger/70":"border-hairline/50")})]}),He==="on-date"&&e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{className:"font-medium text-ink-secondary",children:n("routines.interval.stopAfter")}),e.jsx("input",{"aria-label":n("routines.interval.endDate"),"aria-invalid":he,"aria-describedby":he?"routine-interval-end-error":void 0,type:"date",min:qe(Ht),value:wt,onChange:a=>Dn(a.target.value),className:C("rounded-lg border bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",he?"border-danger/70":"border-hairline/50")})]}),De&&e.jsx("div",{id:"routine-interval-error",className:"text-[11px] text-danger",children:n("routines.interval.invalidMinutes")}),je&&e.jsx("div",{id:"routine-interval-days-error",className:"text-[11px] text-danger",children:n("routines.interval.invalidDays")}),re&&e.jsx("div",{id:"routine-interval-window-error",className:"text-[11px] text-danger",children:n("routines.interval.invalidWindow",{minutes:q||5})}),he&&e.jsx("div",{id:"routine-interval-end-error",className:"text-[11px] text-danger",children:n("routines.interval.endAfterFirstRun")}),e.jsx("div",{id:"routine-interval-help",className:"text-[11px] leading-relaxed text-ink-secondary",children:n(w==="queue"?"routines.overlapQueueHelp":"routines.overlapSkipHelp")})]})]}),Zt=v==="routine"&&e.jsxs("details",{className:"rounded-xl border border-hairline/40 bg-inset/40 px-3 py-2.5",children:[e.jsx("summary",{className:"cursor-pointer select-none text-[12px] font-medium text-ink-secondary hover:text-ink",children:D==null?n("routines.runLimit.none"):n("routines.runLimit.some",{duration:Re(D)})}),e.jsxs("div",{className:"mt-3 border-t border-hairline/35 pt-3",children:[e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{children:n("routines.runLimit.stopAfter")}),e.jsxs(U,{"aria-label":n("routines.runLimit.label"),value:D??"",onChange:a=>z(a.target.value?Number(a.target.value):null),children:[e.jsx("option",{value:"",children:n("routines.runLimit.noLimit")}),an.map(a=>e.jsx("option",{value:a,children:Re(a)},a))]})]}),e.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n("routines.runLimit.help")}),y!=="none"&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-[12px] text-ink",children:[e.jsx("span",{children:n("routines.overlapLabel")}),e.jsxs(U,{"aria-label":n("routines.overlapLabel"),value:w,onChange:a=>R(a.target.value==="queue"?"queue":"skip"),children:[e.jsx("option",{value:"skip",children:n("routines.overlapSkip")}),e.jsx("option",{value:"queue",children:n("routines.overlapQueue")})]})]}),e.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n(w==="queue"?"routines.overlapQueueHelp":"routines.overlapSkipHelp")})]}),y!=="none"&&e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-[12px] text-ink",children:[e.jsx("input",{type:"checkbox","aria-label":n("routines.runOnStartupLabel"),checked:le,onChange:a=>F(a.target.checked),className:"mt-0.5 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block",children:n("routines.runOnStartupLabel")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.runOnStartupHelp")})]})]})]})]}),Fn=v==="routine"&&!ae&&y!=="none"&&e.jsxs("label",{className:C("flex items-start gap-3 rounded-xl border border-hairline/40 bg-inset/40 px-3.5 py-3",Y&&"ml-8"),children:[e.jsx("input",{type:"checkbox","aria-label":n("routines.continuityLabel"),checked:Z,onChange:a=>te(a.target.checked),className:"mt-0.5 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.continuityLabel")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.continuityHelp")})]})]}),Vt=v==="routine"&&!ae&&e.jsx("div",{className:C(Y&&"ml-8"),children:e.jsx(vn,{bot:s.find(a=>a.id===W[0]),value:it,allowCurrent:!!o,onChange:Ct})}),Jt=e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ds,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),ae?e.jsxs("div",{className:"min-w-0 flex-1 rounded-xl border border-hairline/50 bg-inset px-3.5 py-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.groupContext")}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.teamGoalAttachments")})]}):e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx("input",{ref:At,type:"file",multiple:!0,className:"hidden",onChange:a=>{En(a.target.files),a.target.value=""}}),e.jsx("button",{type:"button",onClick:()=>At.current?.click(),className:"rounded-lg border border-hairline/50 px-3 py-2 text-[13px] font-medium text-ink hover:bg-raised",children:n("routines.attachment.add")}),e.jsx(wn,{attachments:Ce,onRemove:a=>lt(k=>k.filter(A=>A.id!==a))}),e.jsx("div",{className:"text-[11px] leading-relaxed text-ink-secondary",children:v==="routine"?n("routines.attachment.routineHelp"):Ie.length>1?n("routines.attachment.callSharedHelp"):n("routines.attachment.callKeptHelp")}),Mt&&e.jsx("div",{className:"text-[12px] text-warning",children:Mt})]})]}),Kt=v==="routine"&&e.jsxs("div",{className:"flex items-start gap-4",children:[ae?e.jsx(en,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):ye==="cloud"?e.jsx(dn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):e.jsx(cn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("div",{className:"min-w-0 flex-1",children:ae?e.jsxs("div",{className:"rounded-xl border border-accent/35 bg-accent/[0.07] p-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n(Ot?"routines.editor.goalRunsOnCloud":"routines.editor.goalRunsOnComputer")}),e.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.roomGoalKept")})]}):e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>_e("maus"),className:C("rounded-xl border p-3 text-left",ye==="maus"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.currentSetup")}),e.jsx("div",{className:"mt-1 text-[11px] text-ink-secondary",children:"Keeps its model and configured computer, including a self-hosted VPS."})]}),e.jsxs("button",{type:"button",disabled:!Mn||Ce.length>0,onClick:()=>_e("cloud"),className:C("rounded-xl border p-3 text-left disabled:cursor-not-allowed disabled:opacity-45",ye==="cloud"?"border-accent/60 bg-accent/10":"border-hairline/50 bg-inset hover:bg-raised"),children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.runsOn.boat")}),e.jsx("div",{className:"mt-1 text-[11px] text-ink-secondary",children:n(Ot?"routines.runsOn.boatHintCloudHome":"routines.runsOn.boatHint")})]})]})})]}),Bn=!Y&&v==="routine"?n(u?o?"automations.editor.edit":"automations.editor.new":o?"routines.editor.edit":"routines.editor.new"):n(o||S?"routines.event.edit":"routines.event.new"),Qt=[["none","routines.repeat.once"],["daily","routines.repeat.daily"],["weekdays","routines.repeat.weekdays"],["weekly","routines.repeat.weekly"]];return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/65 p-3",onMouseDown:a=>a.target===a.currentTarget&&m(),children:e.jsxs("div",{ref:Et,role:"dialog","aria-modal":"true","aria-label":n(o||S?"routines.event.editLabel":"routines.event.createLabel"),tabIndex:-1,className:"max-h-[94vh] w-full max-w-[760px] overflow-y-auto rounded-2xl border border-hairline/60 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"sticky top-0 z-20 flex items-center justify-between border-b border-hairline/40 bg-panel/95 px-5 py-3.5 backdrop-blur",children:[e.jsx("div",{className:"text-[15px] font-semibold text-ink",children:Bn}),e.jsx("button",{onClick:m,className:"rounded-full p-2 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":n("common.close"),children:e.jsx(Me,{size:18})})]}),e.jsxs("div",{className:"space-y-5 px-5 py-5 sm:px-8",children:[Y&&Bt,Y&&Wt,e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"mt-3 size-4 shrink-0 rounded bg-accent"}),e.jsx("input",{autoFocus:!0,value:O,onChange:a=>_(a.target.value),"aria-label":n("routines.editor.titleLabel"),placeholder:v==="routine"?Y?n("routines.event.addTitle"):n("routines.editor.titlePlaceholder"):n("routines.event.addCallTitle"),className:"min-w-0 flex-1 border-b border-hairline/60 bg-transparent px-1 pb-2 text-[22px] font-medium text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"})]}),Y?e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(gt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[Gt,qt,Ut,Yt,Zt]})]}):e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(gt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.when")}),Gt,e.jsx("div",{role:"group","aria-label":n("routines.editor.repeat"),className:"flex flex-wrap gap-1.5",children:Qt.map(([a,k])=>e.jsx("button",{type:"button","aria-pressed":y===a,onClick:()=>_t(a),className:C("rounded-full border px-3 py-1.5 text-[12px] font-medium transition",y===a?"border-accent-border bg-accent/15 text-accent-text":"border-hairline/50 bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:n(k)},a))}),!Qt.some(([a])=>a===y)&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:n("routines.editor.customRepeat")})]})]}),e.jsxs("div",{className:"flex items-start gap-4",children:[ae?e.jsx(hn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):e.jsx(bt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("div",{className:"min-w-0 flex-1",children:ae?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"routine-goal-room",className:"mb-2 block text-[13px] font-medium text-ink",children:n("routines.editor.goalWhere")}),e.jsxs(U,{id:"routine-goal-room",value:me,onChange:a=>On(a.target.value),className:"w-full",children:[me&&!ue&&e.jsx("option",{value:me,disabled:!0,children:n("routines.editor.roomMissing")}),e.jsx("option",{value:"",children:n("routines.editor.goalOneOnOne")}),Be.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[13px] font-medium text-ink",children:ue?n("routines.goal.chooseLead"):n("routines.editor.who")}),dt.length>0?e.jsxs(e.Fragment,{children:[e.jsx(yt,{bots:dt,selected:W,multiple:!1,onChange:$e}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ue?n("routines.goal.leadHelp",{name:ue.name}):n("routines.editor.goalOneOnOneHelp")})]}):e.jsx("div",{className:"rounded-xl border border-warning/30 bg-warning/10 px-3.5 py-3 text-[12px] text-warning",children:n("routines.goal.noMembers")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-2 text-[13px] font-medium text-ink",children:v==="routine"?Y?n("routines.event.assignBot"):n("routines.editor.who"):n("routines.event.addGuests")}),s.length>0?e.jsxs(e.Fragment,{children:[e.jsx(yt,{bots:s,selected:W,multiple:v==="call",locked:!!r,onChange:$e}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:v==="routine"?n("routines.event.botOwnsRuns"):n(Ie.length===0?"routines.event.invitedNone":Ie.length===1?"routines.event.invitedOne":"routines.event.invitedMany",{count:Ie.length})}),v==="routine"&&e.jsx(bn,{team:h.config?.team,bot:Ie[0],value:it,madeIn:o?.sourceThreadId})]}):e.jsxs("button",{type:"button",onClick:()=>{N({type:"newBot"}),m()},className:"w-full rounded-xl border border-dashed border-accent/45 bg-accent/[0.06] px-4 py-4 text-left hover:bg-accent/10",children:[e.jsx("div",{className:"text-[13px] font-medium text-accent",children:n("routines.event.createFirstBot")}),e.jsx("div",{className:"mt-1 text-[12px] text-ink-secondary",children:n("routines.event.needsBot")})]})]})})]}),Y&&Vt,e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(st,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("textarea",{value:B,onChange:a=>E(a.target.value),rows:5,"aria-label":n("routines.editor.descriptionLabel"),placeholder:ae?n("routines.goal.instructionsPlaceholder"):v==="routine"?Y?n("routines.event.instructionsPlaceholder"):n("routines.editor.instructionsPlaceholder"):n("routines.event.agendaPlaceholder"),className:"min-w-0 flex-1 resize-y rounded-xl border border-hairline/50 bg-inset px-3.5 py-3 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"})]}),Fn,Y&&Jt,Y&&Kt,!Y&&e.jsxs("div",{children:[e.jsxs("button",{type:"button","aria-expanded":Ge,"aria-controls":"routine-more-options",onClick:()=>_n(a=>!a),className:"flex items-center gap-1.5 rounded-lg px-2 py-1.5 text-[13px] font-medium text-accent-text hover:bg-raised",children:[e.jsx(Ds,{size:14,className:C("transition-transform",Ge&&"rotate-90")}),n(Ge?"routines.editor.fewer":"routines.editor.more")]}),Ge&&e.jsxs("div",{id:"routine-more-options",className:"mt-3 space-y-5 rounded-xl border border-hairline/40 bg-inset/30 p-4",children:[Bt,Wt,e.jsxs("div",{className:"space-y-3",children:[qt,Ut,Yt,Zt]}),Vt,Jt,Kt]})]}),Tt&&e.jsxs("div",{className:"ml-10 flex items-start gap-2 rounded-xl border border-danger/30 bg-danger/10 px-3 py-2.5 text-[13px] text-danger",children:[e.jsx(Ke,{size:15,className:"mt-0.5 shrink-0"}),Tt]})]}),e.jsxs("div",{className:"sticky bottom-0 flex items-center justify-end gap-2 border-t border-hairline/40 bg-panel/95 px-5 py-3.5 backdrop-blur",children:[e.jsx("button",{onClick:m,className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-raised hover:text-ink",children:n("common.cancel")}),e.jsxs("button",{onClick:Pn,disabled:It||Fe||!Hn,className:"flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-semibold text-white hover:brightness-110 disabled:opacity-40",children:[(It||Fe)&&e.jsx(ze,{size:14,className:"animate-spin"}),Fe?n("routines.attachment.attaching"):o||S||v==="routine"&&!ae?n("automations.editor.app.save"):n(v==="call"?"routines.event.scheduleCall":"routines.goal.schedule")]})]})]})})}function ha({seed:t,bots:s,routinesOnly:r=!1,onClose:l,onMore:i,onSavedRoutine:u,onSavedCall:m}){const{state:c,dispatch:h}=nt(),[N,o]=x.useState(r||t.limitReset?"routine":t.kind),[$,S]=x.useState(t.name??""),[v,J]=x.useState(t.description??""),[L,O]=x.useState(t.botIds.length?t.botIds:s[0]?[s[0].id]:[]),[_,B]=x.useState(()=>t.resultsThreadId??Qe(c,L[0])??null),E=p=>{p[0]!==L[0]&&B(Qe(c,p[0])??null),O(p)},[M,d]=x.useState(!1),[b,T]=x.useState(""),P=x.useRef(null),[g,j]=x.useState(null),I=N==="routine"?30:t.durationMinutes;x.useLayoutEffect(()=>{if(!t.anchor){j(null);return}const p=P.current;if(!p)return;const H=()=>{const R=p.getBoundingClientRect();let Z=t.anchor.x+12,te=t.anchor.y+12;Z+R.width>window.innerWidth-12&&(Z=t.anchor.x-R.width-12),te+R.height>window.innerHeight-12&&(te=t.anchor.y-R.height-12),j({left:Math.max(12,Math.min(Z,window.innerWidth-R.width-12)),top:Math.max(12,Math.min(te,window.innerHeight-R.height-12))})};return H(),window.addEventListener("resize",H),()=>window.removeEventListener("resize",H)},[N,t.anchor]);const D=async()=>{d(!0),T("");try{if(N==="routine"||r){const p=await Ne("/api/routines",{method:"POST",body:JSON.stringify({name:$,prompt:v,botId:L[0],runOn:"maus",enabled:!0,schedule:t.limitReset?{type:"limit_reset",engine:t.limitReset.engine,repeat:"once"}:{type:"once",at:t.at},durationMinutes:I,attachments:[],resultsThreadId:_})});u(p.routine)}else{const p=await Ne("/api/calendar-calls",{method:"POST",body:JSON.stringify({name:$,description:v,botIds:L,schedule:{type:"once",at:t.at},durationMinutes:I})});m(p.call)}l()}catch(p){T(p instanceof Error?p.message:String(p))}finally{d(!1)}},z=!!($.trim()&&L.length&&(N==="call"||v.trim()));return e.jsxs("div",{ref:P,role:"dialog","aria-label":n("routines.quick.label"),style:g??void 0,className:C("fixed z-50 max-h-[calc(100vh-24px)] w-[min(430px,calc(100vw-24px))] overflow-y-auto rounded-2xl border border-hairline/60 bg-panel shadow-2xl",!g&&"left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2"),children:[e.jsxs("div",{className:"flex items-center justify-between bg-raised/70 px-4 py-2.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.quick.title")}),e.jsx("button",{onClick:l,className:"rounded-full p-1.5 text-ink-secondary hover:bg-inset hover:text-ink","aria-label":n("common.close"),children:e.jsx(Me,{size:16})})]}),e.jsxs("div",{className:"space-y-3 p-4",children:[e.jsx("input",{autoFocus:!0,value:$,onChange:p=>S(p.target.value),"aria-label":n("routines.editor.titleLabel"),placeholder:n("routines.event.addTitle"),onKeyDown:p=>{p.key==="Enter"&&z&&D()},className:"w-full border-b border-hairline/60 bg-transparent pb-2 text-[18px] font-medium text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"}),!r&&!t.limitReset&&e.jsxs("div",{className:"flex items-center gap-1 border-b border-hairline/35 pb-2",children:[e.jsx("button",{type:"button",onClick:()=>{o("routine"),O(p=>p.slice(0,1))},className:C("rounded-lg px-3 py-1.5 text-[12px] font-medium",N==="routine"?"bg-accent/15 text-accent":"text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.kind.routine")}),e.jsx("button",{type:"button",onClick:()=>o("call"),className:C("rounded-lg px-3 py-1.5 text-[12px] font-medium",N==="call"?"bg-accent/15 text-accent":"text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.kind.call")})]}),e.jsxs("div",{className:"flex items-start gap-3 text-[13px] text-ink",children:[e.jsx(gt,{size:16,className:"mt-0.5 shrink-0 text-ink-secondary"}),t.limitReset?e.jsx("div",{"data-testid":"quick-limit-reset",children:Ns({engine:t.limitReset.engine,repeat:"once"})}):e.jsxs("div",{children:[e.jsx("div",{children:Nt(t.at)}),e.jsxs("div",{className:"mt-0.5 text-ink-secondary",children:[X(t.at),N==="call"?` – ${X(t.at+I*6e4)}`:""]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(bt,{size:16,className:"mt-2.5 shrink-0 text-ink-secondary"}),s.length===0?e.jsxs("button",{type:"button",onClick:()=>{h({type:"newBot"}),l()},className:"min-w-0 flex-1 rounded-xl border border-dashed border-accent/45 bg-accent/[0.06] px-3 py-3 text-left hover:bg-accent/10",children:[e.jsx("div",{className:"text-[12px] font-medium text-accent",children:n("routines.event.createFirstBot")}),e.jsx("div",{className:"mt-0.5 text-[11px] text-ink-secondary",children:n("routines.quick.comeBack")})]}):N==="routine"?e.jsxs(U,{value:L[0]??"",onChange:p=>E([p.target.value]),className:"flex-1",children:[e.jsx("option",{value:"",children:n("routines.event.assignBot")}),s.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}):e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(yt,{bots:s,selected:L,multiple:!0,onChange:E})})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(st,{size:16,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("textarea",{value:v,onChange:p=>J(p.target.value),rows:3,"aria-label":n("routines.editor.descriptionLabel"),placeholder:n(N==="routine"?"routines.quick.whatToDo":"routines.quick.description"),className:"min-w-0 flex-1 resize-none rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] leading-relaxed text-ink outline-none placeholder:text-ink-tertiary focus:border-accent"})]}),N==="routine"&&e.jsx(vn,{bot:s.find(p=>p.id===L[0]),value:_,onChange:p=>B(p??null)}),N==="routine"&&e.jsx(bn,{team:c.config?.team,bot:s.find(p=>p.id===L[0]),value:_}),b&&e.jsx("div",{className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:b})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-hairline/40 px-4 py-3",children:[e.jsx("button",{onClick:()=>i({...t,kind:N,botIds:L,name:$,description:v,durationMinutes:I,resultsThreadId:_}),title:n("routines.quick.moreTitle"),className:"rounded-lg px-3 py-2 text-[12px] font-medium text-accent hover:bg-accent/10",children:n("routines.editor.more")}),e.jsxs("button",{onClick:D,disabled:!z||M,className:"flex items-center gap-1.5 rounded-lg bg-accent px-4 py-2 text-[12px] font-semibold text-white hover:brightness-110 disabled:opacity-40",children:[M&&e.jsx(ze,{size:13,className:"animate-spin"}),n("common.save")]})]})]})}function ga({anchor:t,days:s,items:r,bots:l,groups:i,selectedId:u,onOpen:m,onCreate:c,onMove:h,onResize:N,markers:o=[],onDropOnReset:$}){const S=x.useRef(null),[v,J]=x.useState(null),[L,O]=x.useState(null),_=Ye(Date.now()),B=Array.from({length:s},(g,j)=>mn(t,j)),E=s===7?64:s===3?180:280,M=`64px repeat(${s}, minmax(${E}px, 1fr))`,d=64+s*E;x.useEffect(()=>{const g=S.current;if(!g)return;const j=new Date,I=B.includes(_)?Math.max(0,j.getHours()-2):7;g.scrollTo({top:I*G})},[s]);const b=(g,j)=>{if(g.button!==0||g.target.closest("[data-event-card]"))return;const I=g.currentTarget.getBoundingClientRect(),D=Ue(j,g.clientY,I.top,G);let z=D+30*6e4;J({day:j,start:D,end:z});const p=w=>{const R=Ue(j,w.clientY,I.top,G);z=Math.max(D+ee*6e4,R+ee*6e4),J({day:j,start:D,end:z})},H=w=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",H),J(null),c({kind:"routine",at:D,durationMinutes:Math.max(ee,Math.round((z-D)/6e4)),botIds:[],anchor:{x:w.clientX,y:w.clientY}})};document.addEventListener("pointermove",p),document.addEventListener("pointerup",H,{once:!0})},T=(g,j)=>{g.preventDefault(),O(null);const I=g.currentTarget.getBoundingClientRect(),D=Ue(j,g.clientY,I.top,G),z=g.dataTransfer.getData(Xe);if(z)return c({kind:"routine",at:D,durationMinutes:30,botIds:[z],anchor:{x:g.clientX,y:g.clientY}});const p=g.dataTransfer.getData(we);if(p)try{const H=JSON.parse(p);h(H,D)}catch{}},P=(g,j)=>{if(!g.dataTransfer.types.includes(Xe)&&!g.dataTransfer.types.includes(we))return;g.preventDefault(),g.dataTransfer.dropEffect=g.dataTransfer.types.includes(we)?"move":"copy";const I=g.currentTarget.getBoundingClientRect(),D=Ue(j,g.clientY,I.top,G);O(z=>z?.day===j&&z.at===D?z:{day:j,at:D})};return e.jsxs("div",{ref:S,className:"min-h-0 flex-1 overflow-auto border-l border-t border-hairline/40 bg-app",children:[e.jsxs("div",{className:"sticky top-0 z-30 grid bg-app/95 backdrop-blur",style:{gridTemplateColumns:M,minWidth:d},children:[e.jsx("div",{className:"border-b border-r border-hairline/40 px-2 py-3 text-center text-[9px] uppercase tracking-wider text-ink-secondary",children:hs(-new Date(t).getTimezoneOffset())}),B.map(g=>{const j=new Date(g),I=g===_;return e.jsxs("div",{role:"columnheader",className:C("border-b border-r border-hairline/40 px-2 py-2 text-center last:border-r-0",I&&"bg-accent/[0.035]"),children:[e.jsx("div",{className:C("text-[10px] font-medium uppercase tracking-[0.14em]",I?"text-accent":"text-ink-secondary"),children:Ze(j.getDay())}),e.jsx("div",{className:C("mx-auto mt-1 flex size-8 items-center justify-center rounded-full text-[15px] font-medium",I?"bg-accent text-accent-ink":"text-ink"),children:j.getDate()})]},g)})]}),e.jsxs("div",{role:"grid","aria-label":n("routines.calendar.label"),onDragEnd:()=>O(null),className:"relative grid",style:{height:G*24,gridTemplateColumns:M,minWidth:d},children:[e.jsx("div",{className:"relative border-r border-hairline/40",children:Array.from({length:24},(g,j)=>e.jsx("div",{className:"absolute right-2 -translate-y-1/2 text-[10px] tabular-nums text-ink-tertiary",style:{top:j*G},children:j===0?"":new Date(2e3,0,1,j).toLocaleTimeString(Le(),{hour:"numeric"})},j))}),B.map(g=>{const j=new Date,I=(j.getHours()*60+j.getMinutes())/60*G,D=r.filter(w=>Ye(w.at)===g),z=gs(D),p=v?.day===g?v:null,H=L?.day===g?L:null;return e.jsxs("div",{role:"gridcell","aria-label":n("routines.calendar.day",{date:Nt(g)}),onPointerDown:w=>b(w,g),onDragOver:w=>P(w,g),onDragLeave:w=>{(!(w.relatedTarget instanceof Node)||!w.currentTarget.contains(w.relatedTarget))&&O(null)},onDrop:w=>T(w,g),className:C("relative border-r border-hairline/40 last:border-r-0",g===_&&"bg-accent/[0.025]"),children:[Array.from({length:48},(w,R)=>e.jsx("div",{className:C("pointer-events-none absolute inset-x-0 border-t",R%2===0?"border-hairline/30":"border-hairline/10"),style:{top:R/2*G}},R)),g===_&&e.jsxs("div",{className:"pointer-events-none absolute inset-x-0 z-20 flex items-center",style:{top:I},children:[e.jsx("span",{className:"-ml-1 size-2 rounded-full bg-danger"}),e.jsx("span",{className:"h-px flex-1 bg-danger/80"})]}),p&&e.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-10 rounded-md border border-accent/70 bg-accent/20",style:{top:(new Date(p.start).getHours()*60+new Date(p.start).getMinutes())/60*G,height:Math.max(16,(p.end-p.start)/36e5*G)}}),H&&e.jsx("div",{className:"pointer-events-none absolute inset-x-1 z-20 rounded-md border border-accent/80 bg-accent/25 shadow-sm",style:{top:(new Date(H.at).getHours()*60+new Date(H.at).getMinutes())/60*G,height:G/2},children:e.jsx("div",{className:"px-2 py-1 text-[10px] font-medium text-accent",children:X(H.at)})}),o.filter(w=>Ye(w.at)===g).map(w=>e.jsx(Vs,{marker:w,hourHeight:G,onDrop:$&&(R=>$(R,w))},w.engine)),D.map(w=>e.jsx(Ks,{item:w,bots:l,groups:i,compact:s===7,layout:z.get(w.id)??{column:0,columns:1},selected:w.id===u,onOpen:()=>m(w),onResize:R=>N(w,R)},w.id))]},g)})]})]})}function ba({item:t,bots:s,onClose:r,onEdit:l,onCallChanged:i,onOpenRoom:u,onOpenRun:m}){const{state:c,dispatch:h}=nt(),N=ln(),o=Zn(),[$,S]=x.useState(!1),v=x.useRef(!1),[J,L]=x.useState(!1),[O,_]=x.useState(void 0),[B,E]=x.useState(""),M=t.kind==="call",d=t.kind==="routine"?t.routine:null,b=O===void 0?t.kind==="routine"?t.run:null:O&&(c.routineRuns.find(f=>f.id===O.id)??O),T=t.kind==="call"?t.call:null,P=!M&&(b?.target??d?.target)==="room-goal",g=P?b?b.groupId:d?.groupId:void 0,j=c.groups.find(f=>f.id===g),I=b?.executionThreadId??b?.threadId,D=T?.botIds??[b?.botId??d?.botId??""],z=D.flatMap(f=>s.find(K=>K.id===f)??[]),p=z[0],H=P&&g?j:p,w=!!(I&&(H?.threadId===I||H?.tasks?.some(f=>f.threadId===I))),R=b?b.resultsThreadId??b.sourceThreadId:d?.resultsThreadId,Z=R??(!b&&d?.target==="bot"?p?.mainThreadId:void 0),te=Z&&[...c.bots,...c.groups].some(f=>f.threadId===Z||f.tasks?.some(K=>K.threadId===Z)),le=T?.name??b?.routineName??d?.name??"Routine",F=T?.description??b?.prompt??d?.prompt??"",y=T?.attachments??b?.attachments??d?.attachments??[],de=T?.botIds.length===1?p?.id:void 0,Q=b?b.timeoutMinutes:d?.timeoutMinutes,be=()=>{I&&(P&&g?(h({type:"switchGroupTask",groupId:g,threadId:I}),u(g)):p&&Cs(h,p,I,o),r())},ce=async(f,K="POST",pe)=>{S(!0),E("");try{const se=await Ne(f,{method:K,...pe?{body:JSON.stringify(pe)}:{}});se.routine&&h({type:"routinePatched",routine:se.routine}),se.run&&h({type:"routineRunPatched",run:se.run})}catch(se){E(se instanceof Error?se.message:String(se))}finally{S(!1)}},ve=()=>{!d||$||v.current||(v.current=!0,L(!0),_(null),S(!0),E(""),h({type:"runRoutine",routineId:d.id,onStarted:_,onError:f=>E(f instanceof Error?f.message:String(f)),onSettled:()=>{v.current=!1,L(!1),S(!1)}}))},at=async()=>{if(T){S(!0),E("");try{const{group:f}=await Ne(`/api/calendar-calls/${T.id}/room`,{method:"POST"});h({type:"groupPatched",group:f}),u(f.id)}catch(f){E(f instanceof Error?f.message:String(f))}finally{S(!1)}}},Ae=async()=>{window.confirm(n("routines.event.deleteConfirm",{title:le}))&&(T?(await Ne(`/api/calendar-calls/${T.id}`,{method:"DELETE"}),i(T.id)):d&&h({type:"deleteRoutine",routineId:d.id}),r())},fe=d?.id??b?.routineId,Oe=fe?c.routineRuns.filter(f=>f.routineId===fe).sort((f,K)=>nn(K)-nn(f)).slice(0,3):[],q=b?.runOn??d?.runOn,Se=bs({roomGoal:P,runOn:q,computer:p?.computer,cloudHome:c.config?.cloudHome===!0}),ne=R?[...c.bots,...c.groups].find(f=>f.threadId===R||f.tasks?.some(K=>K.threadId===R)):void 0,rt=R?ne?.tasks?.find(f=>f.threadId===R)?.title??ne?.name??n("routines.results.missing"):n("routines.results.main");return e.jsxs("aside",{"aria-label":n("routines.drawer.label"),className:"flex h-full w-[min(310px,100vw)] shrink-0 flex-col border-l border-hairline/40 bg-panel",children:[e.jsxs("div",{className:"flex items-start gap-3 border-b border-hairline/40 px-4 py-3.5",children:[M?e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/15 text-accent-text",children:e.jsx(vt,{size:16})}):P?e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/15 text-accent-text",children:e.jsx(hn,{size:16})}):p&&e.jsx(Ve,{bot:p,state:b?jn(b.status):d?.enabled===!1?"sleeping":"idle",size:36,animated:!1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"break-words text-[15px] font-semibold leading-snug text-ink",children:le}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[d&&e.jsx("span",{className:C("rounded-full px-2 py-0.5 text-[11px] font-medium",d.enabled?"bg-success/15 text-success":"bg-inset text-ink-secondary"),children:vs(d)}),e.jsxs("span",{className:"text-[11px] text-ink-secondary",children:[Nt(t.at)," · ",X(t.at),M?` – ${X(t.at+t.durationMinutes*6e4)}`:""]})]})]}),e.jsx("button",{type:"button",onClick:r,className:"rounded-full p-1.5 text-ink-secondary hover:bg-raised hover:text-ink","aria-label":n("routines.drawer.close"),children:e.jsx(Me,{size:16})})]}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4",children:[b&&e.jsxs("div",{role:"status","aria-live":"polite",className:"rounded-xl border border-hairline/40 bg-inset p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-medium text-ink",children:[b.status==="running"&&e.jsx(ze,{size:13,className:"animate-spin text-accent"}),jt(b)]}),b.output&&e.jsx("div",{className:"mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap text-[12px] leading-relaxed text-ink-secondary",children:xt(b,"output")}),b.error&&e.jsx("div",{className:C("mt-2 text-[12px]",kt(b)?"text-warning":"text-danger"),children:xt(b,"error")})]}),b?.attention&&e.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-warning/30 bg-warning/10 px-3 py-2.5 text-warning",children:[e.jsx(Ke,{size:15,className:"mt-0.5 shrink-0"}),e.jsx("div",{className:"min-w-0 whitespace-pre-wrap text-[12px] leading-relaxed",children:xt(b,"attention")})]}),b?.status==="waiting"&&!b.attention&&e.jsx("div",{className:"rounded-xl border border-warning/30 bg-warning/10 px-3 py-2.5 text-[12px] text-warning",children:n("routines.drawer.runWaiting")}),e.jsx(oe,{label:M?n("routines.drawer.guests"):P?n("routines.drawer.lead"):n("routines.drawer.bot"),children:e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[z.map(f=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-hairline/50 bg-inset py-0.5 pl-0.5 pr-2.5",children:[e.jsx(Ve,{bot:f,state:"idle",size:22,animated:!1}),e.jsx("span",{className:"text-[12px] text-ink",children:f.name})]},f.id)),z.length===0&&e.jsx("span",{className:"text-[13px] text-ink-secondary",children:n("routines.unavailableBot")})]})}),P&&g&&e.jsx(oe,{label:n("routines.drawer.group"),children:e.jsx("div",{className:"text-[13px] text-ink",children:j?.name??n("routines.drawer.groupUnavailable")})}),(d||T)&&e.jsxs(oe,{label:n("routines.drawer.schedule"),children:[e.jsx("div",{className:"text-[13px] text-ink",children:fs((d??T).schedule)}),d?.schedule.type==="cron"&&e.jsx("div",{className:"mt-2",children:e.jsx($s,{schedule:d.schedule,paused:!d.enabled})})]}),F&&e.jsx(oe,{label:M?n("routines.drawer.agenda"):n("routines.drawer.what"),children:e.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-relaxed text-ink",children:F})}),!M&&e.jsxs(oe,{label:n("routines.drawer.runsOn"),children:[e.jsxs("div",{className:"flex items-start gap-2 text-[13px] text-ink",children:[q==="cloud"?e.jsx(dn,{size:14,className:"mt-0.5 shrink-0 text-ink-secondary"}):e.jsx(cn,{size:14,className:"mt-0.5 shrink-0 text-ink-secondary"}),e.jsx("span",{children:Se.label})]}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-ink-secondary",children:Se.hint})]}),!M&&!P&&e.jsx(oe,{label:n("routines.results.label"),children:e.jsx("div",{className:"text-[13px] text-ink",children:rt})}),y.length>0&&e.jsxs(oe,{label:n("routines.drawer.attachments"),children:[e.jsx(wn,{attachments:y}),T&&e.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n(T.botIds.length>1?"routines.drawer.callSharedHelp":"routines.drawer.callKeptHelp")})]}),N&&!M&&e.jsx(oe,{label:n("routines.drawer.runLimit"),children:e.jsx("div",{className:"text-[13px] text-ink",children:Q==null?n("routines.drawer.noTimeLimit"):n("routines.drawer.stopsAfter",{duration:Re(Q)})})}),!M&&e.jsx(oe,{label:n("routines.logs"),action:d&&e.jsxs("button",{type:"button",onClick:()=>{h({type:"showRoutines",section:"logs",routineId:d.id,botId:d.botId}),r()},className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-accent-text hover:bg-raised",children:[e.jsx(st,{size:11}),n("routines.drawer.allRuns")]}),children:Oe.length===0?e.jsx("div",{className:"text-[12px] text-ink-secondary",children:n("routines.drawer.noRuns")}):e.jsx("div",{className:"space-y-1",children:Oe.map(f=>e.jsx(oa,{run:f,current:f.id===b?.id,onOpen:()=>m?.(f)},f.id))})}),B&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:B})]}),e.jsxs("div",{className:"space-y-2 border-t border-hairline/40 px-4 py-3",children:[d&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:ve,disabled:$,className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110 disabled:opacity-50",children:[J?e.jsx(ze,{size:13,className:"animate-spin"}):e.jsx(sn,{size:13}),J?n("routines.starting"):n("routines.runNow")]}),e.jsxs("button",{disabled:$,onClick:()=>{ce(`/api/routines/${d.id}`,"PATCH",{enabled:!d.enabled})},title:n(d.enabled?"routines.drawer.pauseRoutine":"routines.drawer.resumeRoutine"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-hairline/50 bg-control px-3 py-2 text-[12px] font-medium text-ink hover:bg-raised-hover disabled:opacity-40",children:[d.enabled?e.jsx(ys,{size:13}):e.jsx(sn,{size:13}),d.enabled?n("routines.pause"):n("routines.resume")]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[de&&e.jsxs("button",{onClick:()=>u(de),className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110",children:[e.jsx(Te,{size:13}),n("routines.drawer.joinGroup")]}),T&&T.botIds.length>1&&e.jsxs("button",{onClick:at,disabled:$,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110 disabled:opacity-50",children:[e.jsx(Te,{size:13}),n("routines.drawer.joinGroup")]}),P&&j&&!I&&e.jsxs("button",{onClick:()=>{u(j.id),r()},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(Te,{size:13}),n("routines.drawer.openGroup")]}),w&&e.jsxs("button",{onClick:be,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(Te,{size:13}),n(P&&g?"routines.drawer.openGroupThread":"routines.drawer.openThread")]}),te&&Z&&e.jsxs("button",{type:"button",onClick:()=>{js(h,{botId:D[0],threadId:Z},c,o),r()},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(Te,{size:13}),n("routines.results.open")]}),b&&["queued","running","waiting"].includes(b.status)&&e.jsxs("button",{onClick:()=>{ce(`/api/routine-runs/${b.id}/cancel`)},disabled:$,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:[e.jsx(Me,{size:13}),n("routines.drawer.cancelRun")]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(d||T)&&e.jsx("button",{onClick:l,className:"rounded-lg px-2.5 py-1.5 text-[12px] font-medium text-ink hover:bg-raised",children:n("routines.edit")}),(d||T)&&e.jsx("button",{onClick:()=>{Ae()},className:"rounded-lg p-2 text-ink-secondary hover:bg-danger/10 hover:text-danger",title:n("routines.delete"),"aria-label":n("routines.delete"),children:e.jsx(ks,{size:14})})]})]})]})]})}function oe({label:t,action:s,children:r}){return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-ink-tertiary",children:t}),s]}),r]})}function ia(t){if(t.startedAt==null||t.finishedAt==null||t.finishedAt<t.startedAt)return null;const s=Math.round((t.finishedAt-t.startedAt)/1e3);return s<60?`${s}s`:Re(Math.round(s/60))}function oa({run:t,current:s,onOpen:r}){const l=t.startedAt??t.scheduledFor,i=ia(t),u=t.status==="completed"&&(!t.goalStatus||t.goalStatus==="completed"),m=ws(t)||t.goalStatus==="failed"||t.goalStatus==="blocked",c=["queued","running","waiting"].includes(t.status);return e.jsxs("button",{type:"button",onClick:r,"aria-label":n("routines.openRun",{name:t.routineName,status:jt(t)}),"aria-current":s||void 0,className:C("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left hover:bg-raised",s&&"bg-raised"),children:[u?e.jsx(gn,{size:14,className:"shrink-0 text-success","aria-hidden":"true"}):m?kt(t)?e.jsx(Ke,{size:14,className:"shrink-0 text-warning","aria-hidden":"true"}):e.jsx(Ss,{size:14,className:"shrink-0 text-danger","aria-hidden":"true"}):c?e.jsx(ze,{size:14,className:"shrink-0 animate-spin text-accent","aria-hidden":"true"}):e.jsx(Ke,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] text-ink",children:new Date(l).toLocaleDateString(Le(),{month:"short",day:"numeric"})}),e.jsxs("span",{className:"shrink-0 text-[11px] tabular-nums text-ink-secondary",children:[X(l),i?` · ${i}`:""]})]})}function la({routine:t,bots:s,lockedBotId:r,initialBotId:l,defaultRunOn:i,plain:u,onClose:m}){const c=t?.schedule.type==="once"?t.schedule.at:t?.schedule.type==="daily"?ht(Date.now(),t.schedule.time):t?.schedule.type==="interval"?t.schedule.anchorAt:t?.schedule.type==="cron"?t.nextRunAt??on():on();return e.jsx(ra,{seed:{kind:"routine",at:c,durationMinutes:t?.durationMinutes??30,botIds:r?[r]:t?[t.botId]:l?[l]:s.length===1?[s[0].id]:[],routine:t},bots:s,lockedBotId:r,defaultRunOn:i,plain:u,onClose:m,onSavedCall:()=>{}})}const va=Object.freeze(Object.defineProperty({__proto__:null,RoutineEditor:la},Symbol.toStringTag,{value:"Module"}));export{ga as C,ba as E,Rs as H,ha as Q,la as R,zs as a,ra as b,va as c};
|