limixbot 0.3.154 → 0.3.155
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-DIFL2UWu.js → ActivityPanel-Dqbr10Z_.js} +1 -1
- package/dist/assets/{App-C4yNzHVh.js → App-uoPBLmmn.js} +8 -8
- package/dist/assets/{AppEventEditor-BnHOXKlK.js → AppEventEditor-CCe9Z0N8.js} +1 -1
- package/dist/assets/{BotSettingsDialog-BDxPPRSt.js → BotSettingsDialog-Cmba9cGz.js} +1 -1
- package/dist/assets/{BrowserPanel-7C2siZvA.js → BrowserPanel-B6iHt39M.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-DT3_0YNy.js → BrowserProfilesManager-C9ezndzC.js} +1 -1
- package/dist/assets/{CloudAddDialog-DAK84Xp8.js → CloudAddDialog-CI5KrDAK.js} +1 -1
- package/dist/assets/{ComputerFilesPane-CLll40_D.js → ComputerFilesPane-B6qvtesL.js} +1 -1
- package/dist/assets/{ComputerPanel-DYVH95ii.js → ComputerPanel-DKwvVKmU.js} +2 -2
- package/dist/assets/{DataPanel-BpWU7lio.js → DataPanel-0N3mrCDA.js} +1 -1
- package/dist/assets/{GrokMoveDialog-BCsZtfLt.js → GrokMoveDialog-DvpI_tPM.js} +1 -1
- package/dist/assets/{InspectorPanel-CrzVSG7i.js → InspectorPanel-DuTyfoo6.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-BIbJVW9-.js → KeyboardShortcutsModal-BZ-uOLjK.js} +1 -1
- package/dist/assets/{KnowledgePanel-Sg_1jEKv.js → KnowledgePanel-CJmLajJP.js} +1 -1
- package/dist/assets/{LiveDesktop-DqCcsH_j.js → LiveDesktop-BzmpYGbu.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-BNdGhJf5.js → LocalVmWorkspace-Dyaqp6Wt.js} +1 -1
- package/dist/assets/{MacLocalControl-BizgfuSq.js → MacLocalControl-BvlKsh2Q.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CLkT5s2b.js → MarkdownFilePreview-qeZ4oP4K.js} +1 -1
- package/dist/assets/{NewBotDialog-8bG4Xs-l.js → NewBotDialog-DhzR6nNq.js} +1 -1
- package/dist/assets/{PhoneAppDialog-D6dh2YT4.js → PhoneAppDialog-Dp2tWPuC.js} +1 -1
- package/dist/assets/{PluginsPanel-uXur23ye.js → PluginsPanel-DNvYcp9p.js} +1 -1
- package/dist/assets/{ProIntroduction-CgzCBF5_.js → ProIntroduction-BfQjUPyg.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-DK9XpaOh.js → RemoteAgentSettingsPanel-ae-Sl0mj.js} +1 -1
- package/dist/assets/{RoomPanel-BPM4dzaG.js → RoomPanel-Culuj3c3.js} +1 -1
- package/dist/assets/{RoutinesPage-DresNrsn.js → RoutinesPage-LLBkjCgH.js} +1 -1
- package/dist/assets/{SettingsModal-DcNmqDB5.js → SettingsModal-BP6ZRuvi.js} +1 -1
- package/dist/assets/{ShareTeamDialog-lkjMPlgB.js → ShareTeamDialog-bcaYH8Fa.js} +1 -1
- package/dist/assets/{SignedInSites-COdsl-Jr.js → SignedInSites-Cw-z2pHg.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-fD3U_PVO.js → TeamLibraryPanel-DaFRiK5K.js} +1 -1
- package/dist/assets/{TeamMapPage-YL_Bca8J.js → TeamMapPage-DdZPHt-V.js} +1 -1
- package/dist/assets/{TriggersPage-PS__fjCL.js → TriggersPage-Bn-bFPJr.js} +1 -1
- package/dist/assets/{VisibilitySection-CUizRA66.js → VisibilitySection-CaWfmXSj.js} +1 -1
- package/dist/assets/{WebhookTrigger-BbHJhuck.js → WebhookTrigger-8ol0waxh.js} +1 -1
- package/dist/assets/{WorksOnGrid-SMy19r6q.js → WorksOnGrid-BQaOGo2O.js} +1 -1
- package/dist/assets/{core-CvwNH6Uy.js → core-Con7kH_C.js} +1 -1
- package/dist/assets/{import-name-Cx7z2uuD.js → import-name-a8ENd5Mj.js} +1 -1
- package/dist/assets/{index-mIEtqomC.js → index-0Js8mqlU.js} +1 -1
- package/dist/assets/{index-CnKbeHja.js → index-uM78wvX0.js} +2 -2
- package/dist/assets/{new-bot-DPL6QQjG.js → new-bot-DsFULuKY.js} +1 -1
- package/dist/assets/{org-library-DKAyPTNn.js → org-library-BP5jkVsQ.js} +1 -1
- package/dist/assets/{package-format-D52rhOI_.js → package-format-CX-_DYU-.js} +1 -1
- package/dist/assets/{remote-desktop-panel-RRGHOWOQ.js → remote-desktop-panel-BhCQ6ldP.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/index.js +134 -132
- package/dist-server/package.json +1 -1
- package/dist-server/server/index.js +3 -3
- package/dist-server/server/industry-care.js +13 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as tt,r as x,j as e,t as n,a as C,i as Le,bm as Un,ai as ln,k as dn,L as cn,X as Me,S as Yn,H as Zn}from"./styles-C4OYlVF_.js";import{b as Vn}from"./remote-desktop-DDRRx8uY.js";import{bc as Kn,b7 as Jn,B as Ve,c as Qn,L as ze,v as De}from"./PlacesRail-DbAKPGkj.js";import{jU as Ke,cw as Xn,w as Y,aP as es,jV as ts,jW as un,b7 as ns,d4 as ss,jX as as,jY as xn,u as nt,jZ as rs,a7 as kt,j_ as is,fy as te,ad as os,j$ as Nt,k0 as ne,k1 as gt,gS as ls,k2 as qe,k3 as pn,d1 as mn,c_ as Ye,k4 as xt,k5 as Xt,k6 as en,k7 as Re,q as Ze,k8 as tn,k9 as ds,ka as bt,cY as hn,aa as st,kb as Je,kc as cs,h as us,kd as xs,bs as gn,ke as ps,kf as ms,j as Ne,kg as hs,kh as gs,ki as wt,kj as nn,kk as bs,a5 as vs,ab as pt,p as fs,cV as sn,cW as ys,dQ as js,T as ks,kl as Ns,km as Ue,cK as ws,br as Ss,ga as Cs}from"./App-C4yNzHVh.js";import{u as Ts}from"./ProIntroduction-CgzCBF5_.js";import{C as Is}from"./MenuMotion-DZa0_5mG.js";const Ds=[["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",Ds);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"}]],vt=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"}]],ft=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:Ke}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===Ke||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?Kn: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(Y,{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===Ke||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(Y,{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:Ke:s?.mainThreadId??null),children:[m==="current"&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"me",children:n("routines.results.justMe")}),e.jsx("option",{value:"shared",children:n("task.sharedChat")})]}),e.jsx("p",{id:`${t}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.teamHelp")})]})}const mt="min-w-0 rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",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(mt,"w-full font-mono")}),e.jsx("span",{id:"routine-cron-help",className:"block text-[11px]",children:n("routines.cron.expressionHelp")})]}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t==="yearly"&&e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.month")}),e.jsx(Y,{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(Y,{value:s.day,onChange:m=>u({day:m.target.value}),children:[Array.from({length:31},(m,c)=>e.jsx("option",{value:String(c+1),children:c+1},c+1)),e.jsx("option",{value:"L",children:n("routines.cron.lastDay")})]})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.time")}),e.jsx("input",{type:"time",step:60,value:s.time,onChange:m=>u({time:m.target.value}),className:mt})]})]}),t!=="cron"&&Number(s.day)>28&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:n("routines.cron.skippedMonths")}),e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.timeZone")}),e.jsx("input",{list:"routine-time-zones",value:s.timeZone,onChange:m=>u({timeZone:m.target.value}),placeholder:"America/New_York",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-error",className:C(mt,"block w-full")})]}),e.jsx("datalist",{id:"routine-time-zones",children: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(Y,{"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(Y,{"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?r?.kind==="paid"?{kind:"local",next:l?"open-cloud":null}:{kind:"local",next:null}:{kind:"server"}}function Us(){const{state:t,dispatch:s}=nt(),r=Ts(),l=rs()&&window.ogb?.remoteClient?.active!==!0,i=qs({cloudHome:t.config?.cloudHome===!0,local:l,plan:r?.view??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 Ks(t){return t>=44?"roomy":t>=22?"compact":"tiny"}function Js({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(B=>B.id===S)??{name:n("routines.group")}:void 0,L=(h?t.call.botIds:[o?.botId??N?.botId??""]).flatMap(B=>s.find(f=>f.id===B)??[]),E=L[0],_=h?t.call.name:o?.routineName??N?.name??n("routines.event.automation"),F=h?"var(--color-accent)":E?Jn[E.color]:"var(--color-ink-tertiary)",A=!!(N&&!o&&!N.enabled),[M,d]=x.useState(t.durationMinutes);x.useEffect(()=>d(t.durationMinutes),[t.durationMinutes]);const b=o?.status,D=b==="failed"||b==="missed"||b==="waiting"||t.kind==="routine"&&!o&&t.needsYou===!0,P=o?kt(o):void 0,g=h||!!(N&&!o&&!A&&N.schedule.type!=="cron"),k=h?t.call.schedule:N?.schedule,T=!!(k&&k.type!=="once"),I=k?.type==="interval"?is(k.everyMinutes):null,z=Math.max(16,M/60*G),p=Ks(z),H=h?n(L.length===1?"routines.botCountOne":"routines.botCountMany",{count:L.length}):v?v.name:E?.name,w=[_,te(t.at),H,I,A?(N&&os(N))??n("routines.pausedSchedule"):P].filter(Boolean).join(" · "),R=N?.schedule.type==="cron"?n("routines.event.cronMoveHint"):"",Z=B=>{B.preventDefault(),B.stopPropagation();const f=B.clientY,de=M;let X=de;const be=ve=>{X=Math.max(ne,Math.min(240,Math.round((de+(ve.clientY-f)/G*60)/ne)*ne)),d(X)},ce=()=>{if(document.removeEventListener("pointermove",be),document.removeEventListener("pointerup",ce),X!==t.durationMinutes){if(T&&!window.confirm(n("routines.event.resizeSeries"))){d(t.durationMinutes);return}c(X)}};document.addEventListener("pointermove",be),document.addEventListener("pointerup",ce,{once:!0})},Q=!h&&e.jsx("span",{"data-event-status":A?"paused":D?"needs-you":"working",className:C("size-1.5 shrink-0 rounded-full",A?"bg-ink-tertiary":D?"bg-warning":"bg-success")}),le=B=>h?e.jsx(ft,{size:13,className:"mt-0.5 shrink-0"}):E?e.jsx(Ve,{bot:E,state:b?jn(b):A?"sleeping":"idle",size:B,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,bm as Un,ai as ln,k as dn,L as cn,X as Me,S as Yn,H as Zn}from"./styles-C4OYlVF_.js";import{b as Vn}from"./remote-desktop-DDRRx8uY.js";import{bc as Kn,b7 as Jn,B as Ve,c as Qn,L as ze,v as De}from"./PlacesRail-DbAKPGkj.js";import{jU as Ke,cw as Xn,w as Y,aP as es,jV as ts,jW as un,b7 as ns,d4 as ss,jX as as,jY as xn,u as nt,jZ as rs,a7 as kt,j_ as is,fy as te,ad as os,j$ as Nt,k0 as ne,k1 as gt,gS as ls,k2 as qe,k3 as pn,d1 as mn,c_ as Ye,k4 as xt,k5 as Xt,k6 as en,k7 as Re,q as Ze,k8 as tn,k9 as ds,ka as bt,cY as hn,aa as st,kb as Je,kc as cs,h as us,kd as xs,bs as gn,ke as ps,kf as ms,j as Ne,kg as hs,kh as gs,ki as wt,kj as nn,kk as bs,a5 as vs,ab as pt,p as fs,cV as sn,cW as ys,dQ as js,T as ks,kl as Ns,km as Ue,cK as ws,br as Ss,ga as Cs}from"./App-uoPBLmmn.js";import{u as Ts}from"./ProIntroduction-BfQjUPyg.js";import{C as Is}from"./MenuMotion-DZa0_5mG.js";const Ds=[["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",Ds);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"}]],vt=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"}]],ft=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:Ke}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===Ke||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?Kn: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(Y,{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===Ke||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(Y,{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:Ke:s?.mainThreadId??null),children:[m==="current"&&e.jsx("option",{value:"current",children:n("routines.results.keep")}),e.jsx("option",{value:"me",children:n("routines.results.justMe")}),e.jsx("option",{value:"shared",children:n("task.sharedChat")})]}),e.jsx("p",{id:`${t}-help`,className:"text-[11px] leading-relaxed text-ink-secondary",children:n("routines.results.teamHelp")})]})}const mt="min-w-0 rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[13px] text-ink outline-none focus:border-accent [color-scheme:dark]",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(mt,"w-full font-mono")}),e.jsx("span",{id:"routine-cron-help",className:"block text-[11px]",children:n("routines.cron.expressionHelp")})]}):e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t==="yearly"&&e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.month")}),e.jsx(Y,{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(Y,{value:s.day,onChange:m=>u({day:m.target.value}),children:[Array.from({length:31},(m,c)=>e.jsx("option",{value:String(c+1),children:c+1},c+1)),e.jsx("option",{value:"L",children:n("routines.cron.lastDay")})]})]}),e.jsxs("label",{className:"space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"block",children:n("routines.cron.time")}),e.jsx("input",{type:"time",step:60,value:s.time,onChange:m=>u({time:m.target.value}),className:mt})]})]}),t!=="cron"&&Number(s.day)>28&&e.jsx("p",{className:"text-[11px] text-ink-secondary",children:n("routines.cron.skippedMonths")}),e.jsxs("label",{className:"block space-y-1.5 text-[12px] text-ink-secondary",children:[e.jsx("span",{children:n("routines.cron.timeZone")}),e.jsx("input",{list:"routine-time-zones",value:s.timeZone,onChange:m=>u({timeZone:m.target.value}),placeholder:"America/New_York",spellCheck:!1,autoComplete:"off","aria-invalid":!!i,"aria-describedby":"routine-cron-error",className:C(mt,"block w-full")})]}),e.jsx("datalist",{id:"routine-time-zones",children: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(Y,{"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(Y,{"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?r?.kind==="paid"?{kind:"local",next:l?"open-cloud":null}:{kind:"local",next:null}:{kind:"server"}}function Us(){const{state:t,dispatch:s}=nt(),r=Ts(),l=rs()&&window.ogb?.remoteClient?.active!==!0,i=qs({cloudHome:t.config?.cloudHome===!0,local:l,plan:r?.view??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 Ks(t){return t>=44?"roomy":t>=22?"compact":"tiny"}function Js({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(B=>B.id===S)??{name:n("routines.group")}:void 0,L=(h?t.call.botIds:[o?.botId??N?.botId??""]).flatMap(B=>s.find(f=>f.id===B)??[]),E=L[0],_=h?t.call.name:o?.routineName??N?.name??n("routines.event.automation"),F=h?"var(--color-accent)":E?Jn[E.color]:"var(--color-ink-tertiary)",A=!!(N&&!o&&!N.enabled),[M,d]=x.useState(t.durationMinutes);x.useEffect(()=>d(t.durationMinutes),[t.durationMinutes]);const b=o?.status,D=b==="failed"||b==="missed"||b==="waiting"||t.kind==="routine"&&!o&&t.needsYou===!0,P=o?kt(o):void 0,g=h||!!(N&&!o&&!A&&N.schedule.type!=="cron"),k=h?t.call.schedule:N?.schedule,T=!!(k&&k.type!=="once"),I=k?.type==="interval"?is(k.everyMinutes):null,z=Math.max(16,M/60*G),p=Ks(z),H=h?n(L.length===1?"routines.botCountOne":"routines.botCountMany",{count:L.length}):v?v.name:E?.name,w=[_,te(t.at),H,I,A?(N&&os(N))??n("routines.pausedSchedule"):P].filter(Boolean).join(" · "),R=N?.schedule.type==="cron"?n("routines.event.cronMoveHint"):"",Z=B=>{B.preventDefault(),B.stopPropagation();const f=B.clientY,de=M;let X=de;const be=ve=>{X=Math.max(ne,Math.min(240,Math.round((de+(ve.clientY-f)/G*60)/ne)*ne)),d(X)},ce=()=>{if(document.removeEventListener("pointermove",be),document.removeEventListener("pointerup",ce),X!==t.durationMinutes){if(T&&!window.confirm(n("routines.event.resizeSeries"))){d(t.durationMinutes);return}c(X)}};document.addEventListener("pointermove",be),document.addEventListener("pointerup",ce,{once:!0})},Q=!h&&e.jsx("span",{"data-event-status":A?"paused":D?"needs-you":"working",className:C("size-1.5 shrink-0 rounded-full",A?"bg-ink-tertiary":D?"bg-warning":"bg-success")}),le=B=>h?e.jsx(ft,{size:13,className:"mt-0.5 shrink-0"}):E?e.jsx(Ve,{bot:E,state:b?jn(b):A?"sleeping":"idle",size:B,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:B=>{if(!g)return B.preventDefault();B.dataTransfer.effectAllowed="move",B.dataTransfer.setData(we,JSON.stringify({kind:t.kind,id:h?t.call.id:N.id,at:t.at}))},onClick:B=>{B.stopPropagation(),m()},"aria-pressed":u,"aria-label":`${_}, ${te(t.at)}${A?`, ${n("routines.pausedSchedule")}`:P?`, ${P}`:""}`,className:C("group absolute z-10 overflow-hidden rounded-md border border-l-[3px] text-left transition hover:z-20 focus:z-20 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",p==="roomy"?"px-1.5 py-1":"px-1.5 py-0",A&&"border-dashed opacity-70",b==="cancelled"&&"opacity-55",(b==="failed"||b==="missed")&&(o&&Nt(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, ${F} ${A?6:16}%, var(--color-card))`,borderColor:`color-mix(in srgb, ${F} 40%, transparent)`,borderLeftColor:F,color:`color-mix(in srgb, ${F} 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:[Q,e.jsxs("span",{className:"truncate",children:[te(t.at)," · ",I&&!v&&!h?`${H??""} · ${I}`: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(ft,{size:11,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold leading-none",children:_}),Q,e.jsx("span",{className:"shrink-0 text-[10px] leading-none tabular-nums opacity-80",children:te(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 yt=[0,1,2,3,4,5,6],et=[1,2,3,4,5],ht=[5,10,15,30,60],an=Array.from({length:240/ne},(t,s)=>(s+1)*ne);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"?yt: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 jt({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,K]=x.useState(i?"routine":t.kind),[L]=x.useState(()=>Date.now()),[E,_]=x.useState(o?.name??S?.name??t.name??""),[F,A]=x.useState(o?.prompt??S?.description??t.description??""),M=o?.schedule.type==="once"?o.schedule.at:o?.schedule.type==="daily"?gt(t.at,o.schedule.time):o?.schedule.type==="interval"?o.schedule.anchorAt:S?.schedule.type==="once"?S.schedule.at:S?.schedule.type==="daily"?gt(t.at,S.schedule.time):t.at,d=o?.schedule??S?.schedule??{type:"once",at:M},[b,D]=x.useState(qe(M)),[P,g]=x.useState(pn(M)),[k,T]=x.useState(o?.durationMinutes??S?.durationMinutes??t.durationMinutes),[I,z]=x.useState(o?.timeoutMinutes??null),[p,H]=x.useState(!!o),[w,R]=x.useState(o?.overlap??"skip"),[Z,Q]=x.useState(!!o?.continuity),[le,B]=x.useState(!!o?.runOnStartup),[f,de]=x.useState(t.limitReset?"limit_reset":na(d,M)),[X,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),[se,rt]=x.useState(()=>ea(d)),[y,J]=x.useState(()=>d.type==="interval"&&d.weekdays?.length?d.weekdays:[...yt]),[pe,ae]=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,Tn]=x.useState(d.type==="interval"&&d.endsAt!=null?"on-date":"never"),[St,In]=x.useState(()=>d.type==="interval"&&d.endsAt!=null?qe(d.endsAt):qe(mn(Ye(Math.max(Date.now(),M)),7))),[W,Ct]=x.useState(r?[r]:o?[o.botId]:S?.botIds??t.botIds),[it,Tt]=x.useState(()=>(o?o.resultsThreadId:t.resultsThreadId??Qe(h,W[0]))??null),$e=a=>{a[0]!==W[0]&&Tt(Qe(h,a[0])??null),Ct(a)},[V,Dn]=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),[Rt,dt]=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(j=>j.id===a)?.modelSelection.instanceId)?.snapshot.state==="available")),Be=h.groups.filter(Qs),ue=Be.find(a=>a.id===me),ct=ue?kn(ue,h.bots):s,ee=v==="routine"&&V==="room-goal",Ot=h.config?.cloudHome===!0,We=xt(b,P,o||S?M:void 0),zn=We+k*6e4,Te=W.flatMap(a=>s.find(j=>j.id===a)??[]),Et=x.useRef(null),Ie=f==="interval"&&(!Number.isInteger(q)||q<5||q>1440),je=f==="interval"&&se==="custom"&&y.length===0,Pt=xt("2000-01-01",Pe)-xt("2000-01-01",Ee),re=f==="interval"&&pe==="custom"&&(!Ee||!Pe||!Number.isFinite(Pt)||Pt<q*6e4),ut=o?.schedule.type==="interval"?o.schedule:void 0,Ht=Xt(L,Math.max(5,q||5),ut),ke=He==="on-date"?ta(St):null,he=f==="interval"&&He==="on-date"&&(ke==null||!Number.isSafeInteger(ke)||ke<Ht),$t=se==="every-day"?void 0:se==="weekdays"?et:y,Ln=pe==="custom"?{start:Ee,end:Pe}:void 0,xe=ge(f)?Ws(f,ce,L,!at&&d.type==="cron"?d:void 0):null,_t=a=>{a==="interval"&&!p&&(z(j=>j??30),H(!0)),ge(a)&&(a==="cron"&&xe?.schedule&&ve(j=>({...j,expression:xe.schedule.expression})),Ae(!0)),de(a)},An=a=>{a==="custom"&&se!=="custom"&&J(se==="weekdays"?[...et]:[...yt]),rt(a)},Ft=a=>{if(Dn(a),a==="bot"){ot("");return}_e("maus"),lt([]),zt("");const j=ue??Be[0];ot(j?.id??"");const O=rn(j,h.bots,W[0]);$e(O?[O.id]:[])},On=a=>{const j=Be.find(ie=>ie.id===a);ot(a);const O=rn(j,h.bots,W[0]);$e(O?[O.id]:[])},En=async a=>{if(!(!a?.length||ee)){Lt(j=>j+1);try{const j=await cs(Array.from(a),{allowImages:!0,getPath:xs,uploadImage:us}),O=aa(j.attachments);O.length&&(lt(ie=>[...ie,...O].slice(0,20)),ye==="cloud"&&_e("maus")),j.notice&&zt(j.notice)}finally{Lt(j=>Math.max(0,j-1))}}},Pn=async()=>{if(!Fe){if(v==="routine"&&/\[\[(SOURCE|CHANGE)\]\]/.test(F)){dt(n("routines.watchTemplateMissingScope"));return}Dt(!0),dt("");try{if(v==="routine"||i){const a=Date.now(),j=ps(a,q,ut);if(f==="interval"&&ke!=null&&ke<Xt(a,q,ut))throw new Error(n("routines.interval.endAfterFirstRun"));const O=X.engine||s.find(qn=>qn.id===(r??W[0]))?.modelSelection?.instanceId||"",ie=f==="limit_reset"?{type:"limit_reset",engine:O,repeat:X.repeat}:ge(f)?xe?.schedule:sa(f,We,fe,q,{anchorAt:j,weekdays:$t?[...$t].sort():null,window:Ln??null,endsAt:ke});if(!ie)throw new Error(xe?.error||n("routines.error.invalidSchedule"));const Wn={name:E,prompt:F,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:k,timeoutMinutes:I,overlap:w,continuity:V==="bot"&&f!=="none"&&Z,runOnStartup:f!=="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(f==="interval"||f==="limit_reset"||ge(f))throw new Error(n("routines.error.callSchedule"));const a=Nn(f,We,fe),j={name:E,description:F,botIds:W,schedule:a,durationMinutes:k,attachments:Ce},O=await Ne(S?`/api/calendar-calls/${S.id}`:"/api/calendar-calls",{method:S?"PATCH":"POST",body:JSON.stringify(j)});c(O.call)}m()}catch(a){dt(a instanceof Error?a.message:String(a))}finally{Dt(!1)}}},Hn=!!(E.trim()&&(v==="call"||F.trim())&&(!r||W[0]===r)&&(v==="call"?W.length>0:V==="room-goal"?(!me||ue)&&W[0]&&ct.some(a=>a.id===W[0]):W.length>0)&&!Ie&&!je&&!re&&!he&&!xe?.error),$n=!i&&!o&&!S&&!r,U=ln()&&!u,[Ge,_n]=x.useState(()=>!["none","daily","weekdays","weekly"].includes(f)||V==="room-goal"||Ce.length>0||ye==="cloud"||I!=null||le||w==="queue");Qn(Et,m);const Bt=$n&&e.jsxs("div",{className:C(U&&"ml-10","inline-flex rounded-lg bg-inset p-1"),children:[e.jsx("button",{type:"button",onClick:()=>{K("routine"),Ct(a=>a.slice(0,1))},className:C("rounded-md px-4 py-1.5 text-[13px] font-medium",v==="routine"?"bg-raised text-ink shadow":"text-ink-secondary"),children:n("routines.kind.routine")}),e.jsx("button",{type:"button",onClick:()=>{K("call"),(f==="interval"||f==="limit_reset"||ge(f))&&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(U&&"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(vt,{size:17,className:C("mt-0.5 shrink-0",V==="bot"?"text-accent":"text-ink-secondary")}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] font-medium text-ink",children:n("routines.editor.botTask")}),e.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-ink-secondary",children:n("routines.editor.botTaskHelp")})]})]}),e.jsxs("button",{type:"button",onClick:()=>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=f!=="interval"&&f!=="limit_reset"&&!ge(f)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v==="routine"&&f==="none"&&e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.editor.starts")}),v==="routine"&&f==="weekly"&&e.jsx("span",{className:"text-[12px] font-medium text-ink-secondary",children:n("routines.editor.on")}),(v==="call"||f==="none"||f==="weekly")&&e.jsx("input",{type:"date",value:b,onChange:a=>D(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:ne*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:te(zn)}),e.jsx(Y,{"aria-label":n("routines.editor.callDuration"),value:k,onChange:a=>T(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(Y,{"aria-label":n("routines.editor.repeat"),value:f,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:[f==="limit_reset"&&v==="routine"&&e.jsx(Gs,{value:X,botEngine:s.find(a=>a.id===(r??W[0]))?.modelSelection?.instanceId,onChange:be}),ge(f)&&v==="routine"&&xe&&e.jsx(_s,{choice:f,value:ce,onChange:a=>{ve(a),Ae(!0)},runs:xe.runs,error:xe.error}),f==="custom"&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:tn.map((a,j)=>e.jsx("button",{type:"button",onClick:()=>Oe(O=>O.includes(j)?O.length===1?O:O.filter(ie=>ie!==j):[...O,j].sort()),className:C("size-8 rounded-full text-[10px] font-semibold",fe.includes(j)?"bg-accent text-white":"bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:Ze(j).charAt(0).toLocaleUpperCase(Le())},a))}),f==="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(Y,{value:ht.includes(q)?String(q):"custom",onChange:a=>Se(a.target.value==="custom"?0:Number(a.target.value)),"aria-label":n("routines.interval.howOften"),children:[ht.map(a=>e.jsx("option",{value:a,children:a},a)),e.jsx("option",{value:"custom",children:n("routines.interval.custom")})]}),!ht.includes(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":Ie,"aria-describedby":Ie?"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",Ie?"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(Y,{value:se,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(Y,{value:pe,onChange:a=>ae(a.target.value),"aria-label":n("routines.interval.hoursLabel"),"aria-invalid":re,"aria-describedby":re?"routine-interval-window-error":void 0,children:[e.jsx("option",{value:"all-day",children:n("routines.interval.allDay")}),e.jsx("option",{value:"custom",children:n("routines.interval.customHours")})]})]}),e.jsx("span",{"aria-hidden":"true",className:"hidden text-ink-secondary sm:inline",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[e.jsx("span",{className:"font-medium",children:n("routines.interval.ends")}),e.jsxs(Y,{value:He,onChange:a=>Tn(a.target.value),"aria-label":n("routines.interval.endsLabel"),"aria-invalid":he,"aria-describedby":he?"routine-interval-end-error":void 0,children:[e.jsx("option",{value:"never",children:n("routines.interval.never")}),e.jsx("option",{value:"on-date",children:n("routines.interval.onDate")})]})]})]}),se==="custom"&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-[11px] font-medium text-ink-secondary",children:n("routines.interval.chooseDays")}),e.jsx("div",{role:"group","aria-label":n("routines.interval.customDays"),"aria-invalid":je,"aria-describedby":je?"routine-interval-days-error":void 0,className:"flex flex-wrap gap-1.5",children:tn.map((a,j)=>e.jsx("button",{type:"button",onClick:()=>J(O=>O.includes(j)?O.filter(ie=>ie!==j):[...O,j].sort()),"aria-label":n(y.includes(j)?"routines.interval.daySelected":"routines.interval.dayNotSelected",{day:Ze(j)}),"aria-pressed":y.includes(j),className:C("size-8 rounded-full text-[10px] font-semibold",y.includes(j)?"bg-accent text-white":"bg-inset text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.interval.dayChips").split(" ")[j]},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:ne*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:ne*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:St,onChange:a=>In(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")})]}),Ie&&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:I==null?n("routines.runLimit.none"):n("routines.runLimit.some",{duration:Re(I)})}),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(Y,{"aria-label":n("routines.runLimit.label"),value:I??"",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")}),f!=="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(Y,{"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")})]}),f!=="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=>B(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"&&!ee&&f!=="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",U&&"ml-8"),children:[e.jsx("input",{type:"checkbox","aria-label":n("routines.continuityLabel"),checked:Z,onChange:a=>Q(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"&&!ee&&e.jsx("div",{className:C(U&&"ml-8"),children:e.jsx(vn,{bot:s.find(a=>a.id===W[0]),value:it,allowCurrent:!!o,onChange:Tt})}),Kt=e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ds,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),ee?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(j=>j.filter(O=>O.id!==a))}),e.jsx("div",{className:"text-[11px] leading-relaxed text-ink-secondary",children:v==="routine"?n("routines.attachment.routineHelp"):Te.length>1?n("routines.attachment.callSharedHelp"):n("routines.attachment.callKeptHelp")}),Mt&&e.jsx("div",{className:"text-[12px] text-warning",children:Mt})]})]}),Jt=v==="routine"&&e.jsxs("div",{className:"flex items-start gap-4",children:[ee?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:ee?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=!U&&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.stopPropagation(),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:[U&&Bt,U&&Wt,e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("span",{className:"mt-3 size-4 shrink-0 rounded bg-accent"}),e.jsx("input",{autoFocus:!0,value:E,onChange:a=>_(a.target.value),"aria-label":n("routines.editor.titleLabel"),placeholder:v==="routine"?U?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"})]}),U?e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(bt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[Gt,qt,Ut,Yt,Zt]})]}):e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(bt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:n("routines.editor.when")}),Gt,e.jsx("div",{role:"group","aria-label":n("routines.editor.repeat"),className:"flex flex-wrap gap-1.5",children:Qt.map(([a,j])=>e.jsx("button",{type:"button","aria-pressed":f===a,onClick:()=>_t(a),className:C("rounded-full border px-3 py-1.5 text-[12px] font-medium transition",f===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(j)},a))}),!Qt.some(([a])=>a===f)&&e.jsx("div",{className:"text-[12px] text-ink-secondary",children:n("routines.editor.customRepeat")})]})]}),e.jsxs("div",{className:"flex items-start gap-4",children:[ee?e.jsx(hn,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}):e.jsx(vt,{size:18,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("div",{className:"min-w-0 flex-1",children:ee?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(Y,{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")}),ct.length>0?e.jsxs(e.Fragment,{children:[e.jsx(jt,{bots:ct,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"?U?n("routines.event.assignBot"):n("routines.editor.who"):n("routines.event.addGuests")}),s.length>0?e.jsxs(e.Fragment,{children:[e.jsx(jt,{bots:s,selected: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(Te.length===0?"routines.event.invitedNone":Te.length===1?"routines.event.invitedOne":"routines.event.invitedMany",{count:Te.length})}),v==="routine"&&e.jsx(bn,{team:h.config?.team,bot:Te[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")})]})]})})]}),U&&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:F,onChange:a=>A(a.target.value),rows:5,"aria-label":n("routines.editor.descriptionLabel"),placeholder:ee?n("routines.goal.instructionsPlaceholder"):v==="routine"?U?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"})]}),v==="routine"&&!o&&!ee&&f!=="none"&&f!=="limit_reset"&&e.jsxs("div",{className:C("flex flex-wrap items-baseline gap-x-3 gap-y-1",U&&"ml-8"),children:[e.jsx("button",{type:"button",className:"text-left text-[12px] font-medium text-accent hover:underline",onClick:()=>{const a=n("routines.watchTemplatePrompt");A(j=>j.includes(a)?j:[j.trim(),a].filter(Boolean).join(`
|
|
3
3
|
|
|
4
4
|
`)),Q(!0)},children:n("routines.watchTemplateLabel")}),e.jsx("p",{className:"text-[11px] text-ink-secondary",children:n("routines.watchTemplateHelp")})]}),Fn,U&&Kt,U&&Jt,!U&&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(Is,{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,Kt,Jt]})]}),Rt&&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(Je,{size:15,className:"mt-0.5 shrink-0"}),Rt]})]}),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"&&!ee?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,K]=x.useState(t.description??""),[L,E]=x.useState(t.botIds.length?t.botIds:s[0]?[s[0].id]:[]),[_,F]=x.useState(()=>t.resultsThreadId??Qe(c,L[0])??null),A=p=>{p[0]!==L[0]&&F(Qe(c,p[0])??null),E(p)},[M,d]=x.useState(!1),[b,D]=x.useState(""),P=x.useRef(null),[g,k]=x.useState(null),T=N==="routine"?30:t.durationMinutes;x.useLayoutEffect(()=>{if(!t.anchor){k(null);return}const p=P.current;if(!p)return;const H=()=>{const R=p.getBoundingClientRect();let Z=t.anchor.x+12,Q=t.anchor.y+12;Z+R.width>window.innerWidth-12&&(Z=t.anchor.x-R.width-12),Q+R.height>window.innerHeight-12&&(Q=t.anchor.y-R.height-12),k({left:Math.max(12,Math.min(Z,window.innerWidth-R.width-12)),top:Math.max(12,Math.min(Q,window.innerHeight-R.height-12))})};return H(),window.addEventListener("resize",H),()=>window.removeEventListener("resize",H)},[N,t.anchor]);const I=async()=>{d(!0),D("");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:T,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:T})});m(p.call)}l()}catch(p){D(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&&I()},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"),E(p=>p.slice(0,1))},className:C("rounded-lg px-3 py-1.5 text-[12px] font-medium",N==="routine"?"bg-accent/15 text-accent":"text-ink-secondary hover:bg-raised hover:text-ink"),children:n("routines.kind.routine")}),e.jsx("button",{type:"button",onClick:()=>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(bt,{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:wt(t.at)}),e.jsxs("div",{className:"mt-0.5 text-ink-secondary",children:[te(t.at),N==="call"?` – ${te(t.at+T*6e4)}`:""]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(vt,{size:16,className:"mt-2.5 shrink-0 text-ink-secondary"}),s.length===0?e.jsxs("button",{type:"button",onClick:()=>{h({type:"newBot"}),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(Y,{value:L[0]??"",onChange:p=>A([p.target.value]),className:"flex-1",children:[e.jsx("option",{value:"",children:n("routines.event.assignBot")}),s.map(p=>e.jsx("option",{value:p.id,children:p.name},p.id))]}):e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(jt,{bots:s,selected:L,multiple:!0,onChange:A})})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(st,{size:16,className:"mt-2.5 shrink-0 text-ink-secondary"}),e.jsx("textarea",{value:v,onChange:p=>K(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=>F(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:T,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:I,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,K]=x.useState(null),[L,E]=x.useState(null),_=Ye(Date.now()),F=Array.from({length:s},(g,k)=>mn(t,k)),A=s===7?64:s===3?180:280,M=`64px repeat(${s}, minmax(${A}px, 1fr))`,d=64+s*A;x.useEffect(()=>{const g=S.current;if(!g)return;const k=new Date,T=F.includes(_)?Math.max(0,k.getHours()-2):7;g.scrollTo({top:T*G})},[s]);const b=(g,k)=>{if(g.button!==0||g.target.closest("[data-event-card]"))return;const T=g.currentTarget.getBoundingClientRect(),I=Ue(k,g.clientY,T.top,G);let z=I+30*6e4;K({day:k,start:I,end:z});const p=w=>{const R=Ue(k,w.clientY,T.top,G);z=Math.max(I+ne*6e4,R+ne*6e4),K({day:k,start:I,end:z})},H=w=>{document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",H),K(null),c({kind:"routine",at:I,durationMinutes:Math.max(ne,Math.round((z-I)/6e4)),botIds:[],anchor:{x:w.clientX,y:w.clientY}})};document.addEventListener("pointermove",p),document.addEventListener("pointerup",H,{once:!0})},D=(g,k)=>{g.preventDefault(),E(null);const T=g.currentTarget.getBoundingClientRect(),I=Ue(k,g.clientY,T.top,G),z=g.dataTransfer.getData(Xe);if(z)return c({kind:"routine",at:I,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,I)}catch{}},P=(g,k)=>{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 T=g.currentTarget.getBoundingClientRect(),I=Ue(k,g.clientY,T.top,G);E(z=>z?.day===k&&z.at===I?z:{day:k,at:I})};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())}),F.map(g=>{const k=new Date(g),T=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",T&&"bg-accent/[0.035]"),children:[e.jsx("div",{className:C("text-[10px] font-medium uppercase tracking-[0.14em]",T?"text-accent":"text-ink-secondary"),children:Ze(k.getDay())}),e.jsx("div",{className:C("mx-auto mt-1 flex size-8 items-center justify-center rounded-full text-[15px] font-medium",T?"bg-accent text-accent-ink":"text-ink"),children:k.getDate()})]},g)})]}),e.jsxs("div",{role:"grid","aria-label":n("routines.calendar.label"),onDragEnd:()=>E(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,k)=>e.jsx("div",{className:"absolute right-2 -translate-y-1/2 text-[10px] tabular-nums text-ink-tertiary",style:{top:k*G},children:k===0?"":new Date(2e3,0,1,k).toLocaleTimeString(Le(),{hour:"numeric"})},k))}),F.map(g=>{const k=new Date,T=(k.getHours()*60+k.getMinutes())/60*G,I=r.filter(w=>Ye(w.at)===g),z=gs(I),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:wt(g)}),onPointerDown:w=>b(w,g),onDragOver:w=>P(w,g),onDragLeave:w=>{(!(w.relatedTarget instanceof Node)||!w.currentTarget.contains(w.relatedTarget))&&E(null)},onDrop:w=>D(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:T},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:te(H.at)})}),o.filter(w=>Ye(w.at)===g).map(w=>e.jsx(Vs,{marker:w,hourHeight:G,onDrop:$&&(R=>$(R,w))},w.engine)),I.map(w=>e.jsx(Js,{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),[K,L]=x.useState(!1),[E,_]=x.useState(void 0),[F,A]=x.useState(""),M=t.kind==="call",d=t.kind==="routine"?t.routine:null,b=E===void 0?t.kind==="routine"?t.run:null:E&&(c.routineRuns.find(y=>y.id===E.id)??E),D=t.kind==="call"?t.call:null,P=!M&&(b?.target??d?.target)==="room-goal",g=P?b?b.groupId:d?.groupId:void 0,k=c.groups.find(y=>y.id===g),T=b?.executionThreadId??b?.threadId,I=D?.botIds??[b?.botId??d?.botId??""],z=I.flatMap(y=>s.find(J=>J.id===y)??[]),p=z[0],H=P&&g?k:p,w=!!(T&&(H?.threadId===T||H?.tasks?.some(y=>y.threadId===T))),R=b?b.resultsThreadId??b.sourceThreadId:d?.resultsThreadId,Z=R??(!b&&d?.target==="bot"?p?.mainThreadId:void 0),Q=Z&&[...c.bots,...c.groups].some(y=>y.threadId===Z||y.tasks?.some(J=>J.threadId===Z)),le=D?.name??b?.routineName??d?.name??"Routine",B=D?.description??b?.prompt??d?.prompt??"",f=D?.attachments??b?.attachments??d?.attachments??[],de=D?.botIds.length===1?p?.id:void 0,X=b?b.timeoutMinutes:d?.timeoutMinutes,be=()=>{T&&(P&&g?(h({type:"switchGroupTask",groupId:g,threadId:T}),u(g)):p&&Cs(h,p,T,o),r())},ce=async(y,J="POST",pe)=>{S(!0),A("");try{const ae=await Ne(y,{method:J,...pe?{body:JSON.stringify(pe)}:{}});ae.routine&&h({type:"routinePatched",routine:ae.routine}),ae.run&&h({type:"routineRunPatched",run:ae.run})}catch(ae){A(ae instanceof Error?ae.message:String(ae))}finally{S(!1)}},ve=()=>{!d||$||v.current||(v.current=!0,L(!0),_(null),S(!0),A(""),h({type:"runRoutine",routineId:d.id,onStarted:_,onError:y=>A(y instanceof Error?y.message:String(y)),onSettled:()=>{v.current=!1,L(!1),S(!1)}}))},at=async()=>{if(D){S(!0),A("");try{const{group:y}=await Ne(`/api/calendar-calls/${D.id}/room`,{method:"POST"});h({type:"groupPatched",group:y}),u(y.id)}catch(y){A(y instanceof Error?y.message:String(y))}finally{S(!1)}}},Ae=async()=>{window.confirm(n("routines.event.deleteConfirm",{title:le}))&&(D?(await Ne(`/api/calendar-calls/${D.id}`,{method:"DELETE"}),i(D.id)):d&&h({type:"deleteRoutine",routineId:d.id}),r())},fe=d?.id??b?.routineId,Oe=fe?c.routineRuns.filter(y=>y.routineId===fe).sort((y,J)=>nn(J)-nn(y)).slice(0,3):[],q=b?.runOn??d?.runOn,Se=bs({roomGoal:P,runOn:q,computer:p?.computer,cloudHome:c.config?.cloudHome===!0}),se=R?[...c.bots,...c.groups].find(y=>y.threadId===R||y.tasks?.some(J=>J.threadId===R)):void 0,rt=R?se?.tasks?.find(y=>y.threadId===R)?.title??se?.name??n("routines.results.missing"):n("routines.results.main");return e.jsxs("aside",{"aria-label":n("routines.drawer.label"),className:"flex h-full w-[min(310px,100vw)] shrink-0 flex-col border-l border-hairline/40 bg-panel",children:[e.jsxs("div",{className:"flex items-start gap-3 border-b border-hairline/40 px-4 py-3.5",children:[M?e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/15 text-accent-text",children:e.jsx(ft,{size:16})}):P?e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-accent/15 text-accent-text",children:e.jsx(hn,{size:16})}):p&&e.jsx(Ve,{bot:p,state:b?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:[wt(t.at)," · ",te(t.at),M?` – ${te(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"}),kt(b)]}),b.output&&e.jsx("div",{className:"mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap text-[12px] leading-relaxed text-ink-secondary",children:pt(b,"output")}),b.error&&e.jsx("div",{className:C("mt-2 text-[12px]",Nt(b)?"text-warning":"text-danger"),children:pt(b,"error")})]}),b?.attention&&e.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-warning/30 bg-warning/10 px-3 py-2.5 text-warning",children:[e.jsx(Je,{size:15,className:"mt-0.5 shrink-0"}),e.jsx("div",{className:"min-w-0 whitespace-pre-wrap text-[12px] leading-relaxed",children:pt(b,"attention")})]}),b?.status==="waiting"&&!b.attention&&e.jsx("div",{className:"rounded-xl border border-warning/30 bg-warning/10 px-3 py-2.5 text-[12px] text-warning",children:n("routines.drawer.runWaiting")}),e.jsx(oe,{label:M?n("routines.drawer.guests"):P?n("routines.drawer.lead"):n("routines.drawer.bot"),children:e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[z.map(y=>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:y,state:"idle",size:22,animated:!1}),e.jsx("span",{className:"text-[12px] text-ink",children:y.name})]},y.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:k?.name??n("routines.drawer.groupUnavailable")})}),(d||D)&&e.jsxs(oe,{label:n("routines.drawer.schedule"),children:[e.jsx("div",{className:"text-[13px] text-ink",children:fs((d??D).schedule)}),d?.schedule.type==="cron"&&e.jsx("div",{className:"mt-2",children:e.jsx($s,{schedule:d.schedule,paused:!d.enabled})})]}),B&&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:B})}),!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})}),f.length>0&&e.jsxs(oe,{label:n("routines.drawer.attachments"),children:[e.jsx(wn,{attachments:f}),D&&e.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-ink-secondary",children:n(D.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:X==null?n("routines.drawer.noTimeLimit"):n("routines.drawer.stopsAfter",{duration:Re(X)})})}),!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(y=>e.jsx(oa,{run:y,current:y.id===b?.id,onOpen:()=>m?.(y)},y.id))})}),F&&e.jsx("div",{role:"alert",className:"rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:F})]}),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:[K?e.jsx(ze,{size:13,className:"animate-spin"}):e.jsx(sn,{size:13}),K?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(De,{size:13}),n("routines.drawer.joinGroup")]}),D&&D.botIds.length>1&&e.jsxs("button",{onClick:at,disabled:$,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[12px] font-semibold text-accent-ink hover:brightness-110 disabled:opacity-50",children:[e.jsx(De,{size:13}),n("routines.drawer.joinGroup")]}),P&&k&&!T&&e.jsxs("button",{onClick:()=>{u(k.id),r()},className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink",children:[e.jsx(De,{size:13}),n("routines.drawer.openGroup")]}),w&&e.jsxs("button",{onClick: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(De,{size:13}),n(P&&g?"routines.drawer.openGroupThread":"routines.drawer.openThread")]}),Q&&Z&&e.jsxs("button",{type:"button",onClick:()=>{js(h,{botId:I[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(De,{size:13}),n("routines.results.open")]}),b&&["queued","running","waiting"].includes(b.status)&&e.jsxs("button",{onClick:()=>{ce(`/api/routine-runs/${b.id}/cancel`)},disabled:$,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-ink-secondary hover:bg-raised hover:text-ink disabled:opacity-40",children:[e.jsx(Me,{size:13}),n("routines.drawer.cancelRun")]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(d||D)&&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||D)&&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:kt(t)}),"aria-current":s||void 0,className:C("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left hover:bg-raised",s&&"bg-raised"),children:[u?e.jsx(gn,{size:14,className:"shrink-0 text-success","aria-hidden":"true"}):m?Nt(t)?e.jsx(Je,{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(Je,{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:[te(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"?gt(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};
|