cezarion 0.19.0-dev.8828 → 0.19.0-dev.8841
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/package.json +3 -3
- package/web/dist/assets/{accounts-section-CnQrgrlx.js → accounts-section-D1dia-hG.js} +1 -1
- package/web/dist/assets/{activity-motion-SZyZ3Vcd.js → activity-motion-fPvKJxvA.js} +1 -1
- package/web/dist/assets/{activity-route-kA927mMd.js → activity-route-CB5nog2G.js} +1 -1
- package/web/dist/assets/{agent-config-section-DZ9lz-oU.js → agent-config-section-D0_Hh9sa.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-CAyM93lD.js → agent-defaults-section-Da8_EROm.js} +1 -1
- package/web/dist/assets/{appearance-jU-y46Hc.js → appearance-D6Jy-FOI.js} +1 -1
- package/web/dist/assets/automations-route-CctTxl3u.js +2 -0
- package/web/dist/assets/{commit-list-JK2MEtR0.js → commit-list-FImAZR2z.js} +1 -1
- package/web/dist/assets/{diff-CC-HnvfR.js → diff-DqOJaV4a.js} +2 -2
- package/web/dist/assets/{diff-controls-CnrIcRRG.js → diff-controls-DzbvRI1Q.js} +1 -1
- package/web/dist/assets/{diff-view-Dzl9i4zr.js → diff-view-D8TGCcR9.js} +1 -1
- package/web/dist/assets/{file-preview-C1Nd5SH3.js → file-preview-B4UtCBRw.js} +1 -1
- package/web/dist/assets/{git-toolbar-q-HOZgdL.js → git-toolbar-Dun1QqPH.js} +1 -1
- package/web/dist/assets/{github-RqiwU49D.js → github-BN-W-GO8.js} +1 -1
- package/web/dist/assets/{global-activity-route-DTuWu-5a.js → global-activity-route--JbzbeqH.js} +1 -1
- package/web/dist/assets/index-DEWnkuj6.js +21 -0
- package/web/dist/assets/index-DOVwFCfP.css +1 -0
- package/web/dist/assets/{markdown-NDbXgnqb.js → markdown-DOEDwgDr.js} +1 -1
- package/web/dist/assets/{notifications-section-CQ4HSyLK.js → notifications-section-WK58Ps4V.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-Dm-Ga2KN.js → preview-pane-connected-BWcpAxTc.js} +1 -1
- package/web/dist/assets/{projects-section-CKPqFZP7.js → projects-section-DOMgdG7r.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-D9Tsgav9.js → prompt-templates-section-DQK4c-Yk.js} +1 -1
- package/web/dist/assets/{reference-chip-CV_vG2eP.js → reference-chip-DXFYkdLT.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-40uqklAG.js → remote-settings-notice-B8a6aNBw.js} +1 -1
- package/web/dist/assets/{repo-git-BBalirax.js → repo-git-CL-s-Ml4.js} +1 -1
- package/web/dist/assets/{report-reader-D3Heszz3.js → report-reader-CYzRGRF-.js} +1 -1
- package/web/dist/assets/{reports-CEaxAigM.js → reports-BF3eEnvh.js} +1 -1
- package/web/dist/assets/{resources-section-ohdWkreq.js → resources-section-Bvw0anG8.js} +1 -1
- package/web/dist/assets/{review-panel-CthaDvZO.js → review-panel-DJivUXQc.js} +1 -1
- package/web/dist/assets/{run-header-9NNASXmJ.js → run-header-B1lhW0fF.js} +2 -2
- package/web/dist/assets/{select-Bh7vwx79.js → select-ttlXTWN-.js} +1 -1
- package/web/dist/assets/{session-context-section-B5Ee7GbQ.js → session-context-section-DhNuv3zS.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-DeczgUDV.js → settings-agent-picker-B-a6cPMj.js} +1 -1
- package/web/dist/assets/{settings-shell-BvRwl06q.js → settings-shell-kDDr8_Jd.js} +1 -1
- package/web/dist/assets/{sidebar-section-Bn1Uv9AQ.js → sidebar-section-BP2FtFmc.js} +1 -1
- package/web/dist/assets/{skills-DMyaR3WX.js → skills-CWozz5P0.js} +1 -1
- package/web/dist/assets/{task-changes-ChM901cL.js → task-changes-CQEaFA9P.js} +1 -1
- package/web/dist/assets/{task-commits-DOP65FDx.js → task-commits-BHYH-E_r.js} +1 -1
- package/web/dist/assets/{task-file-scope-emNQrzps.js → task-file-scope-CgfssVeu.js} +1 -1
- package/web/dist/assets/{task-files-BYPCvDCO.js → task-files-CD4LqOtt.js} +1 -1
- package/web/dist/assets/task-github-item-BBwSUB9p.js +1 -0
- package/web/dist/assets/{task-thread-BI2pi8dZ.js → task-thread-BPS4pya8.js} +2 -2
- package/web/dist/assets/tasks-table-B9Hu3rBi.js +1 -0
- package/web/dist/assets/{thread-state-CdKvrn7R.js → thread-state-22G0OlcH.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-stc7Vzni.js → use-hand-to-agent-state-BdkYBCvG.js} +1 -1
- package/web/dist/assets/{workflows-DagjPw_m.js → workflows-C9gvUvUy.js} +1 -1
- package/web/dist/assets/{workspace-tools-BaLORh9B.js → workspace-tools-Cg0RKomm.js} +1 -1
- package/web/dist/assets/{worktrees-section-CSERluzw.js → worktrees-section-DHiLUz-l.js} +1 -1
- package/web/dist/index.html +4 -4
- package/web/dist/assets/automations-route-DzIrboEQ.js +0 -2
- package/web/dist/assets/index-6yHpyOyH.js +0 -21
- package/web/dist/assets/index-DNgBNd8o.css +0 -1
- package/web/dist/assets/task-github-item-CHGyiC4k.js +0 -1
- package/web/dist/assets/tasks-table-BY5niMlY.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{A as i,_ as a,nn as o,rn as s,sn as c,tn as l}from"./queries-D0v1z40Y.js";import{B as u,Fn as d,H as f,Ur as p,V as m,_ as h,ar as g,c as ee,d as _,g as v,ir as y,ni as b,nr as x,o as te,s as S,sr as ne,ti as re,v as ie,z as ae}from"./toaster-DMfiAEnw.js";import{B as C,G as oe,H as w,I as T,K as se,N as E,P as D,V as ce,W as O,j as k,z as A}from"./live-protocol-DMhTnCmf.js";import{h as le}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as ue,t as j}from"./label-D91E4F0a.js";import{I as de,J as fe,Y as pe,it as me,l as he,pt as ge,ut as _e,y as ve}from"./design-icons-CzEoMH9c.js";import{t as ye}from"./check-OP-CVgZG.js";import{t as M}from"./button-B7MKxYjT.js";import{n as be,r as xe,t as Se}from"./collapsible-BEV4FO-1.js";import{a as N,i as P,n as F,r as I,t as L}from"./select-Bh7vwx79.js";import{t as Ce}from"./switch-DKqVf8-p.js";import{c as we,s as Te,t as R}from"./project-router-BifLGgRR.js";import{a as Ee,c as De,d as Oe,n as ke,s as z,u as B}from"./page-shell-7pLJMOgh.js";import{t as Ae}from"./centered-state-V15AR_qo.js";import{D as je,G as Me,In as Ne,Ln as Pe,N as Fe,O as Ie,Sn as Le,W as Re,Zn as V,k as ze,mn as Be,q as Ve,r as He,t as Ue,ur as We,vn as Ge}from"./index-6yHpyOyH.js";import{t as Ke}from"./textarea-vJt9undk.js";import{_ as qe,a as Je,c as Ye,d as Xe,f as Ze,g as Qe,h as $e,i as et,l as tt,m as nt,n as rt,o as it,p as at,r as ot,s as st,t as H,u as ct,v as lt}from"./automation-format-DB34jUyF.js";var U=e(t(),1),W=k([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ut=C({includeExisting:D().optional(),authors:E(O()).optional(),assignees:E(O()).optional(),requireCurrentLabels:D().optional(),allLabels:E(O()).optional(),anyLabels:E(O()).optional(),excludeLabels:E(O()).optional(),changedLabels:E(O()).optional(),lookbackDays:A(),maxRecords:A()}),dt=k([`github`,`schedule`]),ft=x.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:O(),variants:oe([T(1),T(2),T(3)]).optional(),systemPrompt:O().optional()}),pt=C({at:O(),outcome:k([`launched`,`cancelled`]),runId:O().optional(),receiptId:O().optional(),trigger:k([`schedule`,`late`,`manual`,`retry`]).optional()}),G=C({id:O(),revision:A(),name:O(),description:O().optional(),enabled:D(),kind:dt,events:E(W).optional(),intervalSeconds:A().optional(),filters:ut.optional(),schedule:Ye.optional(),task:ft,archived:pt.optional(),createdAt:O(),updatedAt:O()}),K=C({timestamp:O(),tieBreaker:O().optional()}),mt=C({since:O().datetime(),until:O().datetime(),source:A().int().min(0).max(2),page:A().int().min(1).max(10),item:A().int().min(0).max(100),event:A().int().min(0).max(1e3),cursor:K.optional()}),ht={lastError:O().max(1e3).optional(),lastErrorAt:O().datetime().optional()},gt=C({revision:A().optional(),baselineAt:O().optional(),armedAt:O().optional(),historyScan:mt.optional(),cursor:K.optional(),frozenHighWatermark:K.extend({tieBreaker:O()}).optional(),backlogAfter:K.extend({tieBreaker:O()}).optional(),nextCheckAt:O().optional(),lastSuccessAt:O().optional(),nextRunAt:O().optional(),lastRunAt:O().optional(),etags:w(O(),O()).optional(),backoffUntil:O().optional(),consecutiveFailures:A().optional(),...ht,onceOutcome:k([`failed`,`missed`]).optional()});function _t(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var vt=k([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),yt=C({seq:A(),ts:O(),automationId:O(),revision:A(),event:W.optional(),result:vt,reason:O().optional(),durationMs:A().optional(),receiptId:O().optional(),runId:O().optional(),githubNumber:A().optional(),githubTitle:O().optional(),githubUrl:O().optional(),rateLimit:C({bucket:k([`core`,`search`]),remaining:A().optional(),resetAt:O().optional()}).optional()}),bt=C({matches:A(),launched:A(),duplicates:A(),errors:A()}),xt=G.extend({state:gt.optional(),latestLog:yt.optional(),counts:bt,nextRunAt:O().optional(),onceStatus:at.optional()});C({available:D(),reason:O().optional(),timeZone:O(),scheduler:C({state:k([`scheduled`,`idle`]),nextDue:O().optional()}),automations:E(xt)}),C({automation:G}).extend({once:C({dueAt:O(),timeZone:O(),resolvedInstant:O(),note:O()}).optional()}),C({automation:G,state:gt.optional(),latestLog:yt.optional(),onceStatus:at.optional()}),C({id:O(),automationId:O(),mode:k([`preview`,`execute`]),status:k([`queued`,`running`,`complete`,`error`]),createdAt:O(),completedAt:O().optional(),matches:A().optional(),truncated:D().optional(),error:O().optional()}),C({checkId:O()}),C({records:E(yt)}),C({receiptId:O(),runId:O()}),C({runId:O()}),G.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:dt.optional(),task:ft.omit({variants:!0}).strict(),enable:D().optional()}).omit({enable:!0}).extend({enabled:D().optional(),expectedRevision:A()}),C({archived:k([`include`,`only`]).optional()}),C({mode:k([`preview`,`execute`])});var q=n();function J({text:e}){return(0,q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var St={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`pending`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},Ct={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function wt(e){let[t,n]=(0,U.useState)(),[r,i]=(0,U.useState)(``),a=(0,U.useCallback)(t=>h(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,U.useEffect)(()=>{a()},[a]),(0,U.useEffect)(()=>p(a),[a]),(0,U.useEffect)(()=>ue((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function Tt(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function Et({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&Tt(e,t),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await ae(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,q.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,q.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(He,{dot:St[e.result],children:Ct[e.result]}),(0,q.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:rt(e.ts,n,u)})]}),e.reason?(0,q.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,q.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,q.jsx)(M,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var Y=`all`;function Dt({label:e,value:t,onChange:n,options:r}){return(0,q.jsxs)(L,{value:t,onValueChange:n,children:[(0,q.jsx)(P,{"aria-label":e,className:`w-full sm:w-52`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:r.map(e=>(0,q.jsx)(I,{value:e.value,children:e.label},e.value))})]})}function Ot({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=wt(e),[s,c]=(0,U.useState)(Y),[l,u]=(0,U.useState)(Y),d=(0,U.useMemo)(()=>(i??[]).filter(e=>(s===Y||e.result===s)&&(l===Y||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,q.jsx)(De,{route:`automations`,density:i?Oe(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,q.jsx)(z,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:a}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,q.jsx)(J,{text:`Nothing has run yet.`}):(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Dt,{label:`Result`,value:s,onChange:c,options:[{value:Y,label:`All results`},...vt.options.map(e=>({value:e,label:Ct[e]}))]}),f?(0,q.jsx)(Dt,{label:`Event`,value:l,onChange:u,options:[{value:Y,label:`All events`},...W.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,q.jsx)(J,{text:`No rows match these filters.`}):(0,q.jsx)(Et,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,q.jsx)(J,{text:`Loading execution log…`})})}function kt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=wt(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`flex flex-wrap items-center gap-x-2 border-t border-border pt-2.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,q.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(J,{text:o}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,q.jsx)(Et,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function At({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?ot(i):null,[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(``),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await _(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,q.jsx)(De,{route:`automations`,density:`sparse`,header:{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`},children:(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,q.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,q.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${H(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,q.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,q.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,q.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,q.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,q.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,q.jsxs)(`section`,{className:`min-w-0`,children:[(0,q.jsx)(kt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,q.jsx)(M,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,q.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,q.jsx)(M,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,q.jsx)(M,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})]}),u?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var jt=k([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),X=E(O().trim().min(1).max(200)).max(100).optional(),Mt=C({includeExisting:D().optional(),requireCurrentLabels:D().optional(),authors:X,assignees:X,allLabels:X,anyLabels:X,excludeLabels:X,changedLabels:X,lookbackDays:A().int().min(1).max(90).default(7),maxRecords:A().int().min(1).max(100).default(25)}).passthrough(),Nt=C({prompt:O().min(1).max(1e5),workflow:O().trim().min(1).max(200).optional(),steps:E(y).min(1).max(100).optional(),runner:re.optional(),model:O().trim().min(1).max(200).optional(),effort:O().trim().min(1).max(32).optional(),variants:oe([T(1),T(2),T(3)]).optional(),worktree:D().optional(),autonomous:D().optional(),...g,...ne,systemPrompt:O().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),Pt=new Set(Object.keys(Nt.shape).filter(e=>e!==`variants`));function Ft(e){return Object.fromEntries(Object.entries(e).filter(([e])=>Pt.has(e)))}ce(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},C({id:O().min(1).max(100),revision:A().int().positive(),name:O().trim().min(1).max(200),description:O().max(2e3).optional(),enabled:D().default(!1),kind:dt.default(`github`),events:E(jt).min(1).max(4).optional(),intervalSeconds:A().int().min(60).max(86400).optional(),filters:Mt.optional(),schedule:Ye.passthrough().optional(),task:Nt,archived:C({at:O().datetime(),outcome:k([`launched`,`cancelled`]),runId:O().optional(),receiptId:O().optional(),trigger:k([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:O().datetime(),updatedAt:O().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:b.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:b.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:b.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:b.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:b.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),C({version:T(1).default(1),automations:E(se()).default([]),tombstones:w(O(),O().datetime()).optional()}).passthrough();var It=C({timestamp:O().datetime(),tieBreaker:O().optional()}).passthrough(),Lt=mt.extend({cursor:It.optional()}),Rt=C({revision:A().int().positive().optional(),baselineAt:O().datetime().optional(),armedAt:O().datetime().optional(),historyScan:Lt.optional(),cursor:It.optional(),frozenHighWatermark:It.extend({tieBreaker:O()}).optional(),backlogAfter:It.extend({tieBreaker:O()}).optional(),nextCheckAt:O().datetime().optional(),lastSuccessAt:O().datetime().optional(),nextRunAt:O().datetime().optional(),lastRunAt:O().datetime().optional(),etags:w(O(),O()).optional(),backoffUntil:O().datetime().optional(),consecutiveFailures:A().int().nonnegative().optional(),...ht,onceOutcome:k([`failed`,`missed`]).optional()}).passthrough();C({version:T(1).default(1),states:w(O(),Rt).default({})}).passthrough(),C({receiptId:O().min(1),receiptKey:O().min(1),eventId:O().min(1),automationId:O().min(1),revision:A().int().positive(),status:k([`reserved`,`launched`,`launch-error`,`released`]),runId:O().optional(),observedAt:O().datetime(),updatedAt:O().datetime(),error:O().max(2e3).optional(),occurrenceAt:O().datetime().optional(),candidate:C({eventId:O(),event:jt,timestamp:O().datetime(),tieBreaker:O(),repo:O(),nodeId:O(),number:A().int().positive(),title:O().max(500),url:O().url(),author:O().max(200),assignees:E(O().max(200)).max(100),labels:E(O().max(200)).max(100),changedLabel:O().max(200).optional()}).passthrough().optional()}).passthrough();var zt=k([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);C({seq:A().int().positive(),ts:O().datetime(),automationId:O().min(1),revision:A().int().positive(),event:jt.optional(),result:zt,reason:O().max(2e3).optional(),durationMs:A().int().nonnegative().optional(),receiptId:O().optional(),runId:O().optional(),githubNumber:A().int().positive().optional(),githubTitle:O().max(500).optional(),githubUrl:O().url().optional(),rateLimit:C({bucket:k([`core`,`search`]),remaining:A().int().nonnegative().optional(),resetAt:O().datetime().optional()}).passthrough().optional()}).passthrough();var Bt=`quick-task`;function Vt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Ft(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:ct(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Bt}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function Ht(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Ut(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Wt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Ht(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Ut(e)}}function Gt(e){return{...Wt(e),enable:e.enabled}}function Kt(e,t){return{...Wt(e),task:{...Ut(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Z(e){return`'${e.replace(/'/g,`'\\''`)}'`}var qt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Jt=new Set([`anyLabels`,`authors`,`changedLabels`]);function Yt(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!qt.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||Jt.has(e)&&Array.isArray(t)&&t.length>0)}function Xt(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function Zt(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function Q(e,t){return t.startsWith(`-`)?`--${e}=${Z(t)}`:`--${e} ${Z(t)}`}function Qt(e){let t=[`${Be()} automation add`,Q(`name`,e.name)];if(e.schedule?.type===`once`)t.push(Q(`at`,e.schedule.at),Q(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(Q(`latest-start`,Zt(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Q(`cron`,tt(e.schedule)));else{t.push(Q(`on`,e.events.join(`,`)),`--every ${Xt(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(Q(`label`,n));for(let n of e.filters?.authors??[])t.push(Q(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(Q(`changed-label`,n))}return t.push(...$t(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Q(`prompt`,e.task.prompt)),t.join(` `)}function $t(e){let t=[];return e.workflow&&t.push(Q(`workflow`,e.workflow)),e.runner&&t.push(Q(`runner`,e.runner)),e.model&&t.push(Q(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function en(e,t){let n=Gt(e),r=Yt(n)?Qt(n):`${Be()} automation create --json ${Z(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Z(t.origin)} CEZ_PROJECT_ID=${Z(t.projectId)} HSQ_COCKPIT_URL=${Z(t.origin)} HSQ_PROJECT_ID=${Z(t.projectId)} ${r}`:r}function tn(e){let t=[],n=!1;for(let r of nn(e)){let e=t.length-1;!n&&/^[A-Z_][A-Z0-9_]*=/.test(r)?t.push(r):r.startsWith(`--`)||!n?(t.push(r),n=!0):t[e]=`${t[e]} ${r}`}return t.map((e,t)=>t===0?e:` ${e}`).join(` \\
|
|
2
|
-
`)}function nn(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];!r&&a===`\\`&&i+1<e.length?(n+=a+e[i+1],i+=1):a===`'`?(r=!r,n+=a):a===` `&&!r?(n&&t.push(n),n=``):n+=a}return n&&t.push(n),t}function rn({draft:e}){let t=Te(),n=window.location.origin,i=(0,U.useMemo)(()=>{let r=en(e);return t?`HSQ_COCKPIT_URL=${Z(n)} HSQ_PROJECT_ID=${Z(t)} ${r}`:r},[e,n,t]),a=(0,U.useMemo)(()=>tn(i),[i]),[o,s]=(0,U.useState)(`idle`),[c,l]=(0,U.useState)(!1),u=(0,U.useId)(),d=(0,U.useRef)(void 0);(0,U.useEffect)(()=>()=>clearTimeout(d.current),[]),(0,U.useEffect)(()=>s(`idle`),[i]);let f=async()=>{clearTimeout(d.current);try{await navigator.clipboard.writeText(a),s(`copied`),d.current=setTimeout(()=>s(`idle`),1600)}catch{s(`failed`)}};return(0,q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,q.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":c,"aria-controls":u,"aria-label":c?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>l(e=>!e),children:[(0,q.jsx)(`span`,{className:`truncate`,children:c?`Hide`:`Show`}),(0,q.jsx)(he,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,c&&`rotate-180`)})]}),(0,q.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>void f(),children:[o===`copied`?(0,q.jsx)(ye,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(We,{"aria-hidden":`true`,className:`size-3.5`}),o===`copied`?`Copied`:`Copy`]})]}),(0,q.jsx)(`div`,{id:u,hidden:!c,className:`mbs-2 max-w-full rounded-lg border border-border bg-muted has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring`,children:(0,q.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:a})}),(0,q.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:o===`failed`?`Could not copy — select the line and copy it by hand.`:(0,q.jsxs)(q.Fragment,{children:[`The definition Save paused would create. `,(0,q.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${Be()} automation schema`}),` prints its shape.`]})})]})}function an({pressed:e,onClick:t,disabled:n,children:i}){return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:r(`inline-flex min-h-11 items-center justify-center rounded-md border px-3.5 text-[13px] font-medium transition-colors outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,e?`border-border bg-card font-semibold text-foreground shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:text-foreground`),children:i})}var on={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},sn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function cn(e){let t=e.map(e=>on[e]);if(t.length===0)return`When GitHub changes`;let n=t.slice(0,-1),r=t[t.length-1];return`When ${n.length>0?`${n.join(`, `)} or ${r}`:r}`}var ln=W.options,un=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],dn=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],fn=e=>(e??[]).join(`, `),pn=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function mn(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function hn(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${mn(e.filters.includeExisting)}`}function gn({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=pn(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=un.some(t=>t.seconds===e.intervalSeconds)?un:[...un,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,q.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,q.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:ln.map(t=>(0,q.jsx)(an,{pressed:e.events.includes(t),onClick:()=>r(t),children:sn[t]},t))}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-interval`,children:`Check every`}),(0,q.jsxs)(L,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,q.jsx)(P,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:o.map(e=>(0,q.jsx)(I,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ce,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,q.jsx)(`span`,{children:`Include existing items`})]}),(0,q.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:mn(e.filters.includeExisting)})]}),(0,q.jsxs)(Se,{children:[(0,q.jsxs)(xe,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,q.jsx)(he,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,q.jsx)(be,{children:(0,q.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[dn.map(t=>(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,q.jsx)(V,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:fn(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,q.jsx)(V,{id:`automation-filter-lookback`,className:`border-border`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,q.jsx)(V,{id:`automation-filter-max`,className:`border-border`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var _n=e=>String(e).padStart(2,`0`);function vn({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,U.useState)(_n(t)),o=(0,U.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${_n(n)}.`,l=(0,U.useId)();return(0,U.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(V,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 border-border text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(_n(t))}),s?(0,q.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var yn=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],bn=`none`,xn=e=>String(e).padStart(2,`0`);function Sn(e,t=Date.now()){let n=lt(t,e)??lt(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${xn(r.getUTCMonth()+1)}-${xn(r.getUTCDate())}T09:00`}function Cn(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function wn({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?nt(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${xn(t)}:${xn(n)}`}),l=(0,U.useRef)(null),u=(0,U.useId)(),d=Ze(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,U.useEffect)(()=>{l.current?.setCustomValidity(f?Je:``)},[f]);let p=ot(e);return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-once-date`,children:`Date`}),(0,q.jsx)(V,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full border-border`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,q.jsx)(vn,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,q.jsx)(vn,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,q.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:Je}):null,(0,q.jsx)(En,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,q.jsx)(Dn,{value:e.latestStartMinutes,onChange:t=>n(Tn(e,t))}),p?(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function Tn(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function En({value:e,onCommit:t}){let[n,r]=(0,U.useState)(e),i=(0,U.useRef)(null),a=(0,U.useId)(),o=(0,U.useId)(),[s]=(0,U.useState)(Cn),c=n!==e||!qe(n),l=Qe(n);return(0,U.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,q.jsx)(V,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full border-border sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),qe(e.target.value)&&t(e.target.value)}}),(0,q.jsx)(`datalist`,{id:a,children:s.map(e=>(0,q.jsx)(`option`,{value:e},e))}),c?(0,q.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function Dn({value:e,onChange:t}){let n=yn.some(t=>t.minutes===e)||e===void 0?yn:[...yn,{minutes:e,label:`${e} minutes`}];return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,q.jsxs)(L,{value:e===void 0?bn:String(e),onValueChange:e=>t(e===bn?void 0:Number(e)),children:[(0,q.jsx)(P,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:n.map(e=>(0,q.jsx)(I,{value:e.minutes===void 0?bn:String(e.minutes),children:e.label},e.label))})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var On=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function kn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??Sn(r),timeZone:e.timeZone??r}:{type:t});return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:On.map(t=>(0,q.jsx)(an,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,q.jsx)(wn,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,q.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:st.map((t,n)=>(0,q.jsx)(an,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-every`,children:`Run every`}),(0,q.jsxs)(L,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,q.jsx)(P,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:it.map(e=>(0,q.jsx)(I,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,q.jsx)(vn,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,q.jsx)(vn,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,q.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,q.jsx)(`code`,{className:`font-mono text-foreground`,children:tt(e)})]})]})}var An=40*864e5,jn=5;function Mn({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,q.jsx)(Nn,{schedule:e,now:n});let r=Xe(e,n+1,n+An,t,jn);return(0,q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,q.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,q.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,q.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:H(new Date(e).toISOString(),t)}),(0,q.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:et(n,e)})]},e))}),(0,q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function Nn({schedule:e,now:t}){let n=Ze(e),r=ot(e);return(0,q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,q.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:et(t,n)}):null]}),r?.note?(0,q.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,q.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,q.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var Pn={schedule:`On a schedule`,github:`When GitHub changes`};function Fn(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function In({title:e,hideLegend:t=!1,failure:n,section:r,children:i}){let a=(0,U.useId)();return(0,q.jsxs)(`section`,{role:t?void 0:`group`,"aria-labelledby":t?void 0:a,className:`grid min-w-0 gap-3.5 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[t?null:(0,q.jsx)(`h2`,{id:a,className:`text-sm font-semibold text-foreground`,children:e}),i,n?.section===r&&!n.conflict?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:n.message}):null]})}function Ln({draft:e,patch:t,forge:n,automation:r}){return(0,q.jsx)(q.Fragment,{children:r?(0,q.jsxs)(`p`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Pn[e.kind]]}):(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(Ue,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Pn.schedule},{value:`github`,label:Pn.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Rn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,q.jsx)(kn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,q.jsx)(gn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function zn({draft:e,patch:t,saving:n,automation:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(j,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,q.jsx)(Ke,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:3,className:`[field-sizing:fixed] min-h-[88px] resize-none border-border bg-background`,required:!0}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,q.jsxs)(q.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,q.jsxs)(q.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,q.jsx)(Wn,{draft:e,patch:t}),(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ce,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,q.jsxs)(`span`,{children:[`Autonomous `,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,q.jsx)(ze,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,q.jsx)(Ie,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Bn({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ce,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,q.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:mn(e.filters.includeExisting)})]})}function Vn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,U.useState)(()=>Vt(e)),[s,c]=(0,U.useState)(e?.revision),[l,u]=(0,U.useState)(),[p,h]=(0,U.useState)(!1),[g,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1),[x,te]=(0,U.useState)(``),S=e=>o(t=>({...t,...e})),ne=async t=>{if(t.preventDefault(),p)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await f(e.id,Kt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await ee(Gt(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof d&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`enable`:Fn(n),message:n})}finally{h(!1)}},re=async()=>{if(!(!e||y)){b(!0),te(``);try{await _(e.id),r()}catch(e){te(e instanceof Error?e.message:String(e))}finally{b(!1)}}},ie=(0,U.useId)(),ae=(0,U.useId)(),C=a.kind===`schedule`;return(0,q.jsx)(Ee,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Un({automation:e,draft:a,formId:ie,saveHintId:ae,saving:p}),children:(0,q.jsxs)(`form`,{id:ie,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:ne,children:[(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,q.jsx)(In,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(j,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,q.jsx)(V,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>S({name:e.target.value}),required:!0})]})}),(0,q.jsxs)(In,{title:`When`,section:`when`,failure:l,children:[(0,q.jsx)(Ln,{draft:a,patch:S,forge:t,automation:e}),(0,q.jsx)(Rn,{draft:a,patch:S,forge:t,timeZone:n,automation:e})]}),(0,q.jsx)(In,{title:`What to run`,section:`run`,failure:l,children:(0,q.jsx)(zn,{draft:a,patch:S,saving:p,automation:e})}),(0,q.jsx)(In,{title:`Enable`,section:`enable`,failure:l,children:(0,q.jsx)(Bn,{draft:a,patch:S,automation:e})}),l?.section===`form`?(0,q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,q.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,q.jsx)(M,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[g?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:y,onClick:()=>void re(),children:`Delete automation`}),(0,q.jsx)(M,{type:`button`,variant:`outline`,disabled:y,onClick:()=>{v(!1),te(``)},children:`Keep`})]})]}):(0,q.jsx)(M,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>v(!0),children:`Delete`}),x?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:x}):null]}):null]}),(0,q.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4`,children:[C?(0,q.jsx)(Mn,{schedule:a.schedule,timeZone:n}):(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,q.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,q.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:hn(a)})]}),(0,q.jsx)(rn,{draft:a})]})]})})}function Hn(e){let t=[!e.name.trim()&&`a name`,!e.prompt.trim()&&`a prompt`].filter(Boolean);return t.length?`Add ${t.join(` and `)} to save.`:``}function Un({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Hn(t),s=e?`Save changes`:t.enabled?`Save and enable`:`Save paused`;return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:o?(0,q.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`text-xs text-muted-foreground`,children:o}):void 0,secondaryActions:(0,q.jsx)(z,{type:`button`,variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,q.jsx)(z,{type:`submit`,form:n,variant:`primary`,disabled:i||a!==``,title:a?`${a} is required`:void 0,"aria-describedby":o?r:void 0,children:i?`Saving…`:s})}}function Wn({draft:e,patch:t}){let n=i(),r=Ge(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=o(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),ee=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],_=[...new Set([...u,...e.runner?[e.runner]:[]])],v=Fe(m,p.data,g.data,[e.model]),y=v.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,b=e=>(0,q.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,q.jsx)(Me,{children:(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Re,{slot:`automation-workflow-pill`,icon:b(_e),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:ee.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,q.jsx)(Re,{slot:`automation-runner-pill`,icon:b(me),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?l(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},..._.map(e=>({value:e,label:l(p.data,e)}))],footer:(0,q.jsx)(Ve,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,q.jsx)(Re,{slot:`automation-model-pill`,icon:b(ve),fieldLabel:!0,ariaLabel:`Model`,label:y,value:e.model??``,options:v.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Gn({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,U.useState)({}),[c,l]=(0,U.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){d(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},p=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),h=e=>f(e.id,async()=>{d(e.id,void 0),await m(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await te(e.id),await n()}),ee=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await S(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await v(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)}),_=e?.automations??[],y=_.filter(e=>!e.archived),b=_.filter(e=>!!e.archived),x=i?b:y;return(0,q.jsx)(B,{route:`automations`,density:e?Oe(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,q.jsx)(z,{variant:`primary`,asChild:!0,children:(0,q.jsxs)(R,{to:`/automations/new`,children:[(0,q.jsx)(fe,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,q.jsx)(ke,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,q.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,q.jsx)(R,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:t}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,q.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,q.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!i,onClick:()=>a(!1),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,!i&&`border-accent-text text-foreground`),children:[`Current`,(0,q.jsx)(Kn,{count:y.length})]}),(0,q.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":i,onClick:()=>a(!0),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`border-accent-text text-foreground`),children:[`Archived`,(0,q.jsx)(Kn,{count:b.length})]})]}):(0,q.jsx)(`span`,{}),(0,q.jsx)(`div`,{className:`pb-2.5`,children:(0,q.jsx)(qn,{data:e})})]}),i&&x.length===0?(0,q.jsx)(J,{text:`No archived one-time schedules.`}):x.length===0?(0,q.jsx)(Ae,{icon:(0,q.jsx)(ge,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,q.jsx)(M,{variant:`primary`,asChild:!0,children:(0,q.jsxs)(R,{to:`/automations/new`,children:[(0,q.jsx)(fe,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,q.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,q.jsx)(nr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void h(t),onPreview:()=>void ee(t),onCancel:()=>void g(t)},t.id))})]}):(0,q.jsx)(J,{text:`Loading automations…`})})}function Kn({count:e}){return e===0?null:(0,q.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function qn({data:e}){return(0,q.jsx)(`p`,{"data-slot":`automation-scheduler`,className:r(`text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function Jn(e){return e.kind===`schedule`&&e.schedule?$e(e.schedule):`${cn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function Yn({automation:e,nextRun:t}){let n=e.kind===`schedule`?pe:de,r=Le(e);return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,q.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,q.jsxs)(`p`,{"data-slot":`automation-meta`,className:`mt-1 flex flex-wrap items-baseline gap-x-1.5 ps-6 text-xs break-words text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:Jn(e)}),t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,q.jsx)(He,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function Xn({automation:e,archive:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(M,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}`,children:`Details`})})})]})}function Zn({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,q.jsx)(`span`,{children:`continuous`}):r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${H(r,t)}`}),(0,q.jsx)(`span`,{children:`· ${et(Date.now(),Date.parse(r))}`})]}):(0,q.jsx)(`span`,{children:`Next run: —`})}function Qn({automation:e,timeZone:t}){let n=e.enabled?_t(e.state):void 0;return n?(0,q.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${H(n.retryAt,t)}`}):null]}):null}var $=`h-8 px-3 max-md:h-11 no-hover:h-11`;function $n({automation:e,busy:t,confirmingCancel:n,cancelRef:i,onToggle:a,onRun:o,onPreview:s,onOpenCancel:c}){let l=e.kind===`schedule`,u=e.schedule?.type===`once`;return(0,q.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function er({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,q.jsx)(M,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function tr({note:e}){return(0,q.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function nr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,q.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,q.jsx)(Yn,{automation:e,nextRun:h?void 0:(0,q.jsx)(Zn,{automation:e,timeZone:t})}),h?(0,q.jsx)(Xn,{automation:e,archive:h}):null,h?null:(0,q.jsx)(Qn,{automation:e,timeZone:t}),h?null:(0,q.jsx)($n,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,q.jsx)(er,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,q.jsx)(tr,{note:n}):null,(0,q.jsx)(kt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function rr(e){let t=Te(),n=Pe(),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(``),s=(0,U.useCallback)(t=>ie({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,U.useEffect)(()=>{n&&s()},[n,s]),(0,U.useEffect)(()=>p(async e=>{n&&await s(e)}),[n,s]),(0,U.useEffect)(()=>ue((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function ir({mode:e=`list`}){let{automationId:t}=le(),n=we(),[r,i]=(0,U.useState)(!1),{data:a,error:o,refresh:s}=rr(`include`),[c,l]=(0,U.useState)(0),u=Ne();if(u===`unknown`)return(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(J,{text:`Loading automations…`})});if(u===`absent`)return(0,q.jsx)(je,{});if(u===`disabled`)return(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(Ae,{icon:(0,q.jsx)(ge,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,q.jsx)(Gn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,q.jsx)(B,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:o}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(J,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,q.jsx)(Vn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,q.jsx)(At,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,q.jsx)(Vn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,q.jsx)(B,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,q.jsx)(M,{asChild:!0,variant:`outline`,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})}):t?(0,q.jsx)(Ot,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,q.jsx)(J,{text:`Automation not found.`})}export{ir as AutomationsRoute};
|