@open-mercato/cezar 0.21.0-pr2277.5621 → 0.21.0-pr2278.5622
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/{active-forge-DF_8eN8I.js → active-forge-D7KktUX2.js} +1 -1
- package/web/dist/assets/{agent-task-pickers-BRhPPiTU.js → agent-task-pickers-DDHPTsha.js} +1 -1
- package/web/dist/assets/{ask-card-C4fLUOSK.js → ask-card-CRpg-s95.js} +1 -1
- package/web/dist/assets/{assets-view-ZU0vJzey.js → assets-view-Fk0rkBCq.js} +1 -1
- package/web/dist/assets/{automations-route-BWoglySO.js → automations-route-BKqBE0G9.js} +1 -1
- package/web/dist/assets/{cache-status-BMMy1Tbu.js → cache-status-Bz_wvRo7.js} +1 -1
- package/web/dist/assets/{commit-list-8lcDkxb9.js → commit-list-S88imiO1.js} +1 -1
- package/web/dist/assets/{compare-variants-CDj9bUcO.js → compare-variants-BQ4Iob37.js} +1 -1
- package/web/dist/assets/{composer-zqlaY3u_.js → composer-CYI1vkuE.js} +1 -1
- package/web/dist/assets/{composer-attachments-BaR4lEhp.js → composer-attachments-Cm7P9QDp.js} +1 -1
- package/web/dist/assets/{dashboard-Ad3MF5yS.js → dashboard-Cr0XtV6r.js} +1 -1
- package/web/dist/assets/{diff-CBzEVY_b.js → diff-NP3sUeNI.js} +2 -2
- package/web/dist/assets/{diff-view-DGKc6LsB.js → diff-view-e82Ziu93.js} +1 -1
- package/web/dist/assets/{file-preview-ClQP-PIX.js → file-preview-D8U51DZ0.js} +1 -1
- package/web/dist/assets/{follow-up-engine-SyeMi0Ff.js → follow-up-engine-Dt_DZGEh.js} +1 -1
- package/web/dist/assets/git-tab-loading-0dliVjtD.js +1 -0
- package/web/dist/assets/{github-BnmyOOMJ.js → github-ZeCEEntL.js} +1 -1
- package/web/dist/assets/{host-usage-v85c7hJR.js → host-usage-BpApV_I4.js} +1 -1
- package/web/dist/assets/{impact-control-BRToOdT3.js → impact-control-CI8Sc534.js} +1 -1
- package/web/dist/assets/{impact-model-Cgc3vnDT.js → impact-model-UkOCm8DL.js} +1 -1
- package/web/dist/assets/{index-CuX9ehIb.js → index-Dkgcny7F.js} +7 -7
- package/web/dist/assets/{manager-approval-Doi2yLa6.js → manager-approval-BPKeFlSe.js} +1 -1
- package/web/dist/assets/{manager-approvals-B2lqMWtq.js → manager-approvals-VFbO4g02.js} +1 -1
- package/web/dist/assets/{manager-chat-Bpj3yUTi.js → manager-chat-B-fQeN4H.js} +1 -1
- package/web/dist/assets/{manager-index-ClK0A6Yu.js → manager-index-CxlasZsO.js} +1 -1
- package/web/dist/assets/{manager-loading-ZLoOqH3N.js → manager-loading-DH44LYFR.js} +1 -1
- package/web/dist/assets/{manager-new-D46Nb_vn.js → manager-new-D_lYK_BI.js} +1 -1
- package/web/dist/assets/{manager-pickers-C6ZL8lNP.js → manager-pickers-D4ani5k-.js} +1 -1
- package/web/dist/assets/{manager-settings-D-62i2fG.js → manager-settings-C7sho_JW.js} +1 -1
- package/web/dist/assets/{managers-Cgz-qnAk.js → managers-BwT6DK--.js} +1 -1
- package/web/dist/assets/markdown-Bo0_d7Dw.js +4 -0
- package/web/dist/assets/{phone-app-CmcrHMAZ.js → phone-app-CJnsBy5w.js} +1 -1
- package/web/dist/assets/{project-router-Bm4c2tHW.js → project-router-BM4IWQob.js} +1 -1
- package/web/dist/assets/{project-terminal-CBMlh-Ja.js → project-terminal-Dd7Q7m-3.js} +2 -2
- package/web/dist/assets/{queries-dvQqxBLo.js → queries-Dy1pV6Rm.js} +1 -1
- package/web/dist/assets/{reasoning-effort-pill-DcnasJdc.js → reasoning-effort-pill-D-tsxUUU.js} +1 -1
- package/web/dist/assets/{reference-chip-kHEAt0n5.js → reference-chip-C2e5zgtn.js} +1 -1
- package/web/dist/assets/{reference-conflict-action-DU1t9568.js → reference-conflict-action-jMCHpvxa.js} +1 -1
- package/web/dist/assets/{repo-git-DvNhcHqm.js → repo-git-Drg6qxce.js} +1 -1
- package/web/dist/assets/{run-actions-CUW6zWlf.js → run-actions-D6ciV-B7.js} +1 -1
- package/web/dist/assets/{run-diff-Ci1Z3i8z.js → run-diff-BgymmcxW.js} +1 -1
- package/web/dist/assets/{segmented-CdgJjIWr.js → segmented-Bt_z4Y5J.js} +1 -1
- package/web/dist/assets/{skills-D6BKpzQF.js → skills-CQW7a6vn.js} +1 -1
- package/web/dist/assets/{task-commits-DC7X1oNs.js → task-commits-C8OCVA7L.js} +1 -1
- package/web/dist/assets/task-graph-D1S6AgMk.js +1 -0
- package/web/dist/assets/task-notes-D0FlZyz6.js +1 -0
- package/web/dist/assets/task-workspace-DfzS6b5Y.js +16 -0
- package/web/dist/assets/{telemetry-o5Hx3VMD.js → telemetry-D3z5gIuy.js} +1 -1
- package/web/dist/assets/{terminal-drawer-DV7N6njI.js → terminal-drawer-BptPco0Q.js} +1 -1
- package/web/dist/assets/{terminal-pane-BBYTihdF.js → terminal-pane-CLpJInij.js} +1 -1
- package/web/dist/assets/{terminal-scope-CcbQqkFy.js → terminal-scope-BCBjBDK4.js} +1 -1
- package/web/dist/assets/{thread-items-D4JQ300F.js → thread-items-C0CdCp4R.js} +2 -2
- package/web/dist/assets/{tracker-DtIP53bn.js → tracker-CvsgE6Vw.js} +1 -1
- package/web/dist/assets/{tree-pane-resize-FyOTRhOV.js → tree-pane-resize-BQlM3QTs.js} +1 -1
- package/web/dist/assets/{use-media-query-B4DeGA_a.js → use-media-query-25tNisvg.js} +1 -1
- package/web/dist/assets/{workflow-graph-C8tp5izZ.js → workflow-graph-CK9Hj50n.js} +1 -1
- package/web/dist/assets/{worktree-lifecycle-Cbv7KBJY.js → worktree-lifecycle-BjvFWd9y.js} +1 -1
- package/web/dist/assets/{worktree-lifecycle-operation-LYslaK-Z.js → worktree-lifecycle-operation-BboLqYup.js} +1 -1
- package/web/dist/index.html +24 -24
- package/web/dist/assets/git-tab-loading-D2sHCSoE.js +0 -1
- package/web/dist/assets/markdown-BdkuAy-J.js +0 -4
- package/web/dist/assets/task-graph-CknKUts5.js +0 -1
- package/web/dist/assets/task-notes-DB-qokpp.js +0 -1
- package/web/dist/assets/task-workspace-DCKeDifx.js +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/cezar",
|
|
3
|
-
"version": "0.21.0-
|
|
3
|
+
"version": "0.21.0-pr2278.5622",
|
|
4
4
|
"description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"zod": "^4.6.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@open-mercato/cezar-api-client": "0.21.0-
|
|
60
|
-
"@open-mercato/cezar-contract": "0.21.0-
|
|
59
|
+
"@open-mercato/cezar-api-client": "0.21.0-pr2278.5622",
|
|
60
|
+
"@open-mercato/cezar-contract": "0.21.0-pr2278.5622",
|
|
61
61
|
"@types/node": "^20.14.0",
|
|
62
62
|
"@types/proper-lockfile": "4.1.4",
|
|
63
63
|
"@types/ws": "^8.18.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{$ as n,F as r}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{$ as n,F as r}from"./queries-Dy1pV6Rm.js";import{t as i}from"./createLucideIcon-BHp8sXmF.js";import{c as a}from"./project-router-BM4IWQob.js";var o=i(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),s=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),c=e(t(),1),l={github:`gh`};function u(e){return l[e]}function d(e){return`the ${e} CLI is not installed or not logged in — run \`${e} auth login\``}function f(e,t,n){let r=t?.bootProject??e?.bootProject??null;if(n===null||n==="default"||n===r)return e?.forge;let i=t?.projects?.find(e=>e.id===n);if(!i||!e)return;if(!i.forge)return null;let a=u(i.forge),o=a?e.checks?.find(e=>e.name===a):void 0;return!a||!o?{kind:i.forge}:o.available?{kind:i.forge,available:!0}:{kind:i.forge,available:!1,reason:d(a)}}function p(){let e=r().data,t=n().data,i=a();return(0,c.useMemo)(()=>f(e,t,i),[e,t,i])}export{s as n,o as r,p as t};
|
|
@@ -1 +1 @@
|
|
|
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-Mxa0e2-I.js";import{M as i}from"./run-actions-
|
|
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-Mxa0e2-I.js";import{M as i}from"./run-actions-D6ciV-B7.js";import{B as a}from"./button-DPW_5ujg.js";import{r as o}from"./dist-KgumXxNc.js";import{t as s}from"./workflow-BEP63Wt4.js";import{_ as c}from"./impact-model-UkOCm8DL.js";import{S as l,b as u,m as d,v as f,x as p}from"./composer-CYI1vkuE.js";import{t as m}from"./project-router-BM4IWQob.js";import{i as h,r as g,t as _}from"./popover-CJhYlOGy.js";import{t as v}from"./icon-tooltip-yJInZkjY.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./command-BZ4kTFgf.js";import{i as T}from"./chip-C-AtTfag.js";import"./picker-pill-inZ7-90v.js";import{l as E}from"./index-Dkgcny7F.js";var D=n();function O({name:e,route:t,selected:n,list:i,detail:a}){return(0,D.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,D.jsx)(`section`,{"data-slot":`${e}-list`,className:r(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,n?`hidden`:`flex`),children:i}),(0,D.jsx)(`section`,{"data-slot":`${e}-detail`,className:r(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:a})]})}function k({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,D.jsxs)(`span`,{"data-slot":t,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,D.jsx)(m,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var A=e(t(),1);function j({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[c,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(``),m=(0,A.useRef)(null),v=p(e,d);return(0,D.jsxs)(_,{open:c,onOpenChange:e=>{u(e),e||f(``)},children:[(0,D.jsx)(h,{asChild:!0,children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(T,t&&`border-foreground/60 font-mono text-meta font-semibold text-foreground`),children:[(0,D.jsx)(s,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,D.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,D.jsx)(o,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,D.jsx)(g,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,D.jsxs)(w,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,D.jsx)(y,{placeholder:`search workflows…`,value:d,onValueChange:f,onInput:()=>m.current?.scrollTo(0,0)}),(0,D.jsxs)(C,{ref:m,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[v.length===0?(0,D.jsx)(S,{children:`Nothing matches.`}):null,(0,D.jsx)(b,{children:v.map(e=>{let r=t===e.name;return(0,D.jsxs)(x,{value:`workflow ${e.name}`,keywords:l(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),u(!1)},children:[(0,D.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-muted-foreground`,children:e.description}):null,r?(0,D.jsx)(a,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function M({skills:e,skillUsage:t,selected:n,onToggle:s,maxSelections:p,slotPrefix:m=`gh`}){let[O,k]=(0,A.useState)(!1),[j,M]=(0,A.useState)(``),[N,P]=(0,A.useState)(null),F=(0,A.useRef)(null),{mostUsed:I,project:L,global:R}=f(u(e,j,t),t),z=(e,t)=>{let i=n.includes(e.name);return(0,D.jsxs)(x,{value:`skill ${e.name} ${e.path}`,keywords:l(e.name,e.description),"data-slot":`${m}-skill-option`,"data-skill":e.name,"data-selected":i?`true`:void 0,disabled:!i&&p!==void 0&&n.length>=p,onSelect:()=>s(e.name),children:[(0,D.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-muted-foreground`,children:e.description}):null,(0,D.jsx)(v,{label:`View skill`,children:(0,D.jsx)(`button`,{type:`button`,"data-slot":`${m}-skill-view`,"aria-label":`View skill ${e.name}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),P(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,D.jsx)(c,{"aria-hidden":`true`,className:`size-3.5`})})}),i?(0,D.jsx)(a,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(E,{skill:N,onClose:()=>P(null)}),(0,D.jsxs)(_,{open:O,onOpenChange:e=>{k(e),e||M(``)},children:[(0,D.jsx)(h,{asChild:!0,children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`${m}-skills-trigger`,"aria-label":`Choose skills`,className:r(T,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,D.jsx)(i,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,D.jsx)(o,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,D.jsx)(g,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,D.jsxs)(w,{label:`Choose skills`,shouldFilter:!1,children:[(0,D.jsx)(y,{placeholder:`search skills…`,value:j,onValueChange:M,onInput:()=>F.current?.scrollTo(0,0)}),(0,D.jsxs)(C,{ref:F,"data-slot":`${m}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[I.length===0&&L.length===0&&R.length===0?(0,D.jsx)(S,{children:`Nothing matches.`}):null,I.length>0?(0,D.jsx)(b,{heading:`Most used`,children:I.map(e=>z(e,d(e)))}):null,L.length>0?(0,D.jsx)(b,{heading:`Project skills`,children:L.map(e=>z(e,!0))}):null,R.length>0?(0,D.jsx)(b,{heading:`Global`,children:R.map(e=>z(e,!1))}):null]})]})})]})]})}export{O as i,j as n,k as r,M as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Qn as r}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Qn as r}from"./queries-Dy1pV6Rm.js";import{t as i}from"./utils-Mxa0e2-I.js";import{l as a}from"./chunk-KS7C4IRE-DtL2Gzw3.js";import{t as o}from"./createLucideIcon-BHp8sXmF.js";import{B as s,t as c}from"./button-DPW_5ujg.js";import{t as l}from"./textarea-C1UnTzWH.js";import{t as u}from"./project-router-BM4IWQob.js";import{t as d}from"./status-dot-ntyrUVQa.js";import{s as f}from"./reference-conflict-action-jMCHpvxa.js";import{n as p}from"./chip-C-AtTfag.js";import{r as m,t as h}from"./enter-key-Bsscx4Nx.js";var g=o(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),_=e(t(),1),v=n(),y=`I need more information to answer this — please explain the context and ask again.`;function b(e,t){let n=t.split(`
|
|
2
2
|
`);if(n.length!==e.questions.length)return null;let r=n.map((t,n)=>{let r=`${e.questions[n]?.header??``}: `;return t.startsWith(r)?{header:e.questions[n].header,value:t.slice(r.length)}:null});return r.every(e=>e!==null&&e.value.trim()!==``)?r:null}function x(e,t){if(t===`I need more information to answer this — please explain the context and ask again.`)return{picks:[],moreInfo:!0};let n=e.options.map(e=>e.label).sort((e,t)=>t.length-e.length),r=[],i=t;for(;i!==``;){let e=n.find(e=>!r.includes(e)&&(i===e||i.startsWith(`${e}, `)));if(!e)break;r.push(e),i=i.slice(Math.min(i.length,e.length+2))}return i===``?{picks:r}:{picks:r,own:i}}function S({questions:e,lines:t,slot:n}){return(0,v.jsx)(`dl`,{"data-slot":n,className:`flex flex-col gap-2`,children:t.map(({header:t,value:n},r)=>{let i=e[r],a=i?x(i,n):{picks:[],own:n},o=i?.options.filter(e=>a.picks.includes(e.label)&&e.description)??[];return(0,v.jsxs)(`div`,{"data-slot":`ask-answer`,className:`flex min-w-0 flex-col gap-1`,children:[(0,v.jsxs)(`dt`,{className:`eyebrow text-muted-foreground`,children:[t,(0,v.jsx)(`span`,{className:`sr-only`,children:`:`})]}),(0,v.jsxs)(`dd`,{className:`min-w-0`,children:[(0,v.jsxs)(`ul`,{className:`flex flex-wrap gap-1.5`,children:[i?.options.map(e=>{let t=a.picks.includes(e.label);return(0,v.jsx)(`li`,{className:`flex min-w-0 max-w-full`,children:(0,v.jsxs)(p,{active:t,title:e.description,icon:t?(0,v.jsx)(s,{"aria-hidden":`true`,className:`size-3 shrink-0 text-success`}):void 0,children:[e.label,t?(0,v.jsx)(`span`,{className:`sr-only`,children:` (chosen)`}):null]})},e.label)}),a.own?(0,v.jsx)(`li`,{className:`flex min-w-0 max-w-full`,children:(0,v.jsxs)(p,{active:!0,dashed:!0,"data-answer":`other`,icon:(0,v.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0`}),children:[(0,v.jsx)(`span`,{className:`sr-only`,children:`Own answer: `}),a.own]})}):null,a.moreInfo?(0,v.jsx)(`li`,{className:`flex min-w-0 max-w-full`,children:(0,v.jsxs)(p,{active:!0,dashed:!0,"data-answer":`more-info`,children:[`Need more info`,(0,v.jsx)(`span`,{className:`sr-only`,children:` (chosen)`})]})}):null]}),o.map(e=>(0,v.jsx)(`p`,{"data-slot":`ask-answer-description`,className:`mt-1 break-words text-meta text-muted-foreground`,children:e.description},e.label))]})]},r)})})}var C=new Map,w=(e,t)=>JSON.stringify([e,t.id,t.questions.map(e=>[e.header,e.question,e.options.map(e=>e.label)])]);function T(e,t){return C.get(w(e,t))??{}}function E(e,t,n){C.set(w(e,t),n)}function D(e,t){C.delete(w(e,t))}var O={labels:[]},k=r({status:`waiting`}),A=e=>e.other?.trim().replace(/\s+/g,` `)??``,j=e=>e.moreInfo===!0||e.labels.length>0||A(e)!==``;function M(e,t){if(t.moreInfo)return`${e.header}: ${y}`;let n=A(t);return`${e.header}: ${[...t.labels,...n?[n]:[]].join(`, `)}`}function N({ask:e,run:t}){(0,_.useEffect)(()=>{e.resolved&&D(t.id,e)},[e,t.id]);let n=e.resolved&&e.answer?b(e,e.answer):null;return n?(0,v.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`flex flex-col gap-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-label text-muted-foreground`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1 text-soft-foreground`,children:[(0,v.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Answered`]}),(0,v.jsx)(S,{questions:e.questions,lines:n,slot:`ask-answers`})]}):e.resolved?(0,v.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-label text-muted-foreground`,children:[(0,v.jsx)(s,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px] text-soft-foreground`}),(0,v.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,v.jsx)(`span`,{className:`ml-1.5 break-words whitespace-pre-line text-foreground`,children:e.answer}):null]}):(0,v.jsx)(P,{ask:e,run:t})}function P({ask:e,run:t}){let n=f(t);return(0,v.jsx)(F,{ask:e,ownerId:t.id,delivery:n,asker:e.fromWorkflow?`The workflow is asking`:`The agent is asking`})}function F({ask:e,ownerId:t,delivery:n,asker:r}){let i=n.blockedBy!==void 0,o=e.questions,s=o.length===1&&o[0]?.multiSelect!==!0,[l,f]=(0,_.useState)(()=>T(t,e)),p=(n,r)=>f(i=>{let a={...i,[n]:r};return E(t,e,a),a}),m=e=>l[e]??O,h=e=>j(m(e)),g=o.every((e,t)=>h(t)),y=o.some((e,t)=>h(t))?o.filter((e,t)=>!h(t)).map(e=>e.header):[],b=()=>void n.send(o.map((e,t)=>M(e,m(t))).join(`
|
|
3
3
|
`)),x=n.mode===`resume`,S=(0,_.useRef)(null),{hash:C}=a();return(0,_.useEffect)(()=>{C!==`#ask`||!S.current||(S.current.scrollIntoView?.({block:`center`}),S.current.querySelector(`button, input, textarea`)?.focus())},[C]),(0,v.jsxs)(`div`,{ref:S,"data-slot":`ask-card`,"data-resolved":`false`,"data-delivery":n.mode,"aria-busy":n.isPending||void 0,"data-tone":k.tone,className:`rounded-lg border border-info/30 bg-info/5 px-4 pt-3.5 pb-3.5`,children:[(0,v.jsxs)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:[(0,v.jsx)(d,{tone:k.tone,pulse:k.pulse}),(0,v.jsx)(`span`,{"data-slot":`ask-asker`,className:`text-label font-semibold text-foreground`,children:r}),n.isPending?(0,v.jsx)(`span`,{"data-slot":`ask-sending`,role:`status`,className:`ml-auto text-meta text-muted-foreground`,children:`Sending…`}):null]}),(0,v.jsx)(`div`,{className:`flex flex-col gap-4`,children:o.map((e,t)=>(0,v.jsx)(I,{question:e,disabled:n.isPending||i,oneTap:s,answer:m(t),onChange:e=>{i||p(t,e)},onSubmit:t=>{!i&&j(t)&&n.send(M(e,t))}},e.id??t))}),s?x?(0,v.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mt-3 text-meta text-muted-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,v.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-2.5 gap-y-1.5`,children:[(0,v.jsx)(c,{size:`sm`,disabled:n.isPending||i||!g,className:`pointer-coarse:min-h-11 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100 disabled:shadow-[inset_0_0_0_1px_var(--border)]`,onClick:b,children:x?`Send answer & reopen`:`Send answer`}),(0,v.jsx)(`span`,{"data-slot":x?`ask-resume-hint`:`ask-hint`,className:`min-w-0 text-meta text-muted-foreground`,children:x?`the session has ended — sending reopens it`:`${o.length>1?`answer each question`:`pick one or more`} — or type a reply below`})]}),!s&&y.length>0?(0,v.jsxs)(`p`,{"data-slot":`ask-unanswered`,className:`mt-2 text-meta text-muted-foreground`,children:[`unanswered: `,y.join(`, `)]}):null,n.blockedBy===`provider`?(0,v.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-label text-muted-foreground`,children:[(0,v.jsx)(`span`,{children:n.reason}),(0,v.jsx)(u,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,n.blockedBy===`no-session`?(0,v.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-label text-muted-foreground`,children:n.reason}):null,n.error?(0,v.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-label text-danger`,children:n.error}):null]})}function I({question:e,disabled:t,oneTap:n,answer:r,onChange:i,onSubmit:a}){let o=e.multiSelect===!0,s=m(),u=(0,_.useId)(),d=r.other!==void 0,f=(0,_.useRef)(null),[p,g]=(0,_.useState)(!1);(0,_.useEffect)(()=>{p&&(f.current?.focus(),g(!1))},[p]);let y=e=>n?a(e):i(e),b=e=>{if(!o){y({labels:[e]});return}i({labels:r.labels.includes(e)?r.labels.filter(t=>t!==e):[...r.labels,e],...d?{other:r.other}:{}})};return(0,v.jsxs)(`div`,{role:`group`,"aria-labelledby":u,children:[(0,v.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`rounded-md bg-primary px-1.5 py-0.5 eyebrow text-primary-foreground`,children:e.header}),o?(0,v.jsx)(`span`,{"aria-hidden":`true`,className:`ml-auto text-micro text-soft-foreground`,children:`select all that apply`}):null]}),(0,v.jsxs)(`p`,{id:u,className:`mb-2.5 break-words text-body font-semibold text-foreground`,children:[e.question,o?(0,v.jsx)(`span`,{className:`sr-only`,children:` (select all that apply)`}):null]}),(0,v.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.options.map(e=>(0,v.jsx)(L,{label:e.label,description:e.description,checkbox:o,selected:r.labels.includes(e.label),disabled:t,onClick:()=>b(e.label)},e.label)),(0,v.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,v.jsx)(R,{slot:`ask-other`,selected:d,disabled:t,onClick:()=>{if(d){i({labels:r.labels});return}i({labels:o?r.labels:[],other:``}),g(!0)},children:`Other…`}),(0,v.jsx)(R,{slot:`ask-more-info`,selected:r.moreInfo===!0,disabled:t,onClick:()=>r.moreInfo?i(O):y({labels:[],moreInfo:!0}),children:`Need more info`})]}),d?(0,v.jsxs)(`div`,{"data-slot":`ask-other-input`,className:`flex flex-col gap-2`,children:[(0,v.jsx)(l,{ref:f,rows:2,"aria-label":`Your own answer: ${e.question}`,placeholder:`Type your own answer`,value:r.other,disabled:t,enterKeyHint:n&&!s?`send`:`enter`,onChange:e=>i({...r,other:e.target.value}),onKeyDown:e=>{let t=h({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing,keyCode:e.keyCode},s);n&&t&&(e.preventDefault(),a(r))}}),n?(0,v.jsx)(`div`,{children:(0,v.jsx)(c,{size:`sm`,disabled:t||!j(r),onClick:()=>a(r),children:`Send answer`})}):null]}):null]})]})}function L({label:e,description:t,checkbox:n,selected:r,disabled:a,onClick:o}){return(0,v.jsxs)(`button`,{type:`button`,disabled:a,"aria-pressed":r,onClick:o,className:i(`flex w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left outline-none transition-colors motion-reduce:transition-none`,`focus-visible:ring-[3px] focus-visible:ring-ring/50`,`hover:border-primary/50 hover:bg-primary/[0.06] disabled:pointer-events-none disabled:opacity-50`,r?`border-primary/60 bg-primary/[0.06]`:`border-border bg-card`),children:[(0,v.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-ui font-semibold text-foreground`,children:[n?(0,v.jsx)(`span`,{"aria-hidden":!0,className:i(`flex size-4 shrink-0 items-center justify-center rounded border text-micro`,r?`border-primary bg-primary text-primary-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,v.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]}),t?(0,v.jsx)(`span`,{className:`min-w-0 break-words text-label text-muted-foreground`,children:t}):null]})}function R({slot:e,selected:t,disabled:n,onClick:r,children:a}){return(0,v.jsx)(`button`,{type:`button`,"data-slot":e,disabled:n,"aria-pressed":t,onClick:r,className:i(`rounded-md border border-dashed px-3 py-1.5 text-label font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none`,`focus-visible:ring-[3px] focus-visible:ring-ring/50 pointer-coarse:min-h-11 pointer-coarse:px-3.5`,`hover:border-primary/50 hover:bg-primary/[0.06] hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,t?`border-primary/60 bg-primary/[0.06] text-foreground`:`border-border bg-card`),children:a})}export{b as a,S as i,F as n,D as r,N as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ct as r,Oa as i,wt as a}from"./queries-dvQqxBLo.js";import{kt as o,t as s}from"./utils-Mxa0e2-I.js";import{f as c}from"./chunk-KS7C4IRE-DtL2Gzw3.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{O as u}from"./run-actions-CUW6zWlf.js";import{t as d}from"./button-DPW_5ujg.js";import{r as f}from"./dist-KgumXxNc.js";import{a as p,o as m,p as h,r as g,s as _,t as v}from"./dropdown-menu-7_Jr7yCh.js";import{t as y}from"./download-CfgyYHf7.js";import{t as b}from"./external-link-BE6y205O.js";import{t as x}from"./file-preview-ClQP-PIX.js";import{t as S}from"./file--aqoYe_k.js";import{t as C}from"./layers-CS8s30-0.js";import{t as w}from"./loader-circle-CPBhhDbB.js";import{a as T,c as E,n as D,s as O}from"./sidebar-rail-CKo-kvV9.js";import{a as k,c as A,d as j,f as M,i as N,l as P,o as F,r as I,s as ee,t as te,u as L}from"./follow-up-engine-SyeMi0Ff.js";import{t as R}from"./triangle-alert-CIzim6ZN.js";import{t as z}from"./x-BqECUykl.js";import{l as B}from"./project-router-Bm4c2tHW.js";import{t as V}from"./icon-tooltip-yJInZkjY.js";import{r as H}from"./format-BUbPQpzw.js";import{t as U}from"./centered-state-vm_lrdiA.js";import{t as W}from"./markdown-BdkuAy-J.js";import{Q as G}from"./index-CuX9ehIb.js";var K=l(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),q=l(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),J=e(t(),1);function Y(e){let t=o.safeParse(e);return t.success?{ref:t.data.ref,label:t.data.label.slice(0,200)}:null}function X(e,t){return e?`About ${e.ref} ("${e.label}"): ${t}`:t}function Z(e,t){let n=(0,J.useRef)(t);n.current=t,(0,J.useEffect)(()=>{let t=t=>{let r=e.current?.contentWindow;if(!r||t.source!==r)return;let i=Y(t.data);i&&n.current(i)};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}var Q=n();function ne({run:e,reference:t,onClearReference:n}){let r=te(e),i=I(e,r.continueWith),a=u(e),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=(0,J.useId)(),h=e.status===`running`||e.status===`waiting`,g=e.status===`queued`,_=!h&&!g&&r.available;if(!h&&!g&&!_||e.worktreeLifecycle?.activeOperationId)return null;let v=h&&!a.usable?a.reason:_&&!r.canContinue?r.reason??`No provider can continue this task.`:void 0,y=!v&&!c&&o.trim()!==``,b=async e=>{if(e?.preventDefault(),y){l(!0),p(null);try{await i(X(t,o.trim()),[]),s(``),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}}};return(0,Q.jsxs)(`form`,{"data-slot":`assets-ask`,"aria-label":`Ask about this asset`,onSubmit:e=>void b(e),className:`shrink-0 border-t border-border bg-background px-2 py-2 sm:px-3`,children:[t?(0,Q.jsxs)(`span`,{"data-slot":`assets-ask-ref`,className:`mb-1.5 inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-muted py-0.5 pr-0.5 pl-2 text-meta`,children:[(0,Q.jsx)(K,{"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`}),(0,Q.jsx)(V,{label:`${t.ref} — ${t.label}`,children:(0,Q.jsxs)(`span`,{className:`truncate`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t.ref}),` `,t.label]})}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`assets-ask-ref-remove`,"aria-label":`Remove reference`,onClick:n,className:`rounded-full p-0.5 text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(z,{"aria-hidden":`true`,className:`size-3`})})]}):null,(0,Q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Q.jsx)(`textarea`,{"data-slot":`assets-ask-input`,"aria-label":t?`Ask about ${t.label||t.ref}`:`Ask the agent about this asset`,"aria-describedby":v||f?m:void 0,rows:1,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&b()},disabled:!!v,placeholder:t?`Ask or correct — ⌘↵ to send`:`Ask the agent about this report — click an element to reference it`,className:`max-h-32 min-h-9 flex-1 resize-y rounded-md border border-border bg-card px-2.5 py-2 text-ui focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:opacity-60`}),(0,Q.jsxs)(d,{type:`submit`,size:`sm`,"data-action":`assets-ask-send`,disabled:!y,"aria-busy":c||void 0,children:[c?(0,Q.jsx)(w,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(j,{"aria-hidden":`true`}),_?`Continue`:`Send`]})]}),v||f?(0,Q.jsx)(`p`,{id:m,"data-slot":`assets-ask-reason`,className:`mt-1 text-label text-muted-foreground`,children:f??v}):null]})}var re=`No assets yet`,ie=`Agents publish pages here when they write to the run's artifacts folder.`;function ae({runId:e,routed:t,run:n}){let r=a(e),o=c(),l=B(),[u,f]=(0,J.useState)(void 0),p=t?o.name:u,m=r.data?.artifacts??[],h=A(m,p),g=(0,J.useCallback)(n=>{t?l(`/tasks/${e}/assets/${encodeURIComponent(n)}`,{replace:!0}):f(n)},[l,t,e]),[_,v]=se(),[x,S]=(0,J.useState)(0),[T,D]=(0,J.useState)(void 0),k=h?.kind===`html`?oe(r.data?.versions,h.name):[],j=k.at(-1)?.version,N=T&&h&&T.name===h.name&&T.version!==j&&k.some(e=>e.version===T.version)?T.version:void 0,P=(0,J.useRef)(null),[F,I]=(0,J.useState)(null);return Z(P,I),r.isPending?(0,Q.jsx)(U,{icon:(0,Q.jsx)(w,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:`h2`,title:`Loading assets…`}):r.isError?(0,Q.jsx)(U,{icon:(0,Q.jsx)(R,{}),tone:`danger`,heading:`h2`,title:`Could not load this task's assets`,subtitle:r.error.message}):(0,Q.jsxs)(`section`,{"data-slot":`assets-view`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,Q.jsxs)(`div`,{"data-slot":`assets-toolbar`,role:`toolbar`,"aria-label":`Assets`,className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-2 sm:px-3`,children:[h?(0,Q.jsx)(ce,{artifacts:m,current:h,onSelect:g}):(0,Q.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`Assets`}),h?.kind===`html`?(0,Q.jsx)(V,{label:`Runs in a sandbox: no access to cezar, your cookies or the network beyond pinned CDN scripts`,children:(0,Q.jsxs)(`span`,{"data-slot":`assets-sandboxed`,tabIndex:0,className:`hidden items-center gap-1 rounded-sm border border-border px-1.5 py-px text-meta text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none sm:inline-flex`,children:[(0,Q.jsx)(G,{"aria-hidden":`true`,className:`size-3`}),`sandboxed`]})}):null,h&&k.length>1?(0,Q.jsx)($,{versions:k,viewing:N,onSelect:e=>D(e===j?void 0:{name:h.name,version:e})}):null,N===void 0?null:(0,Q.jsxs)(`span`,{"data-slot":`assets-viewing-version`,className:`inline-flex items-center gap-1.5 text-meta text-muted-foreground`,children:[`Viewing v`,N,(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`assets-version-current`,onClick:()=>D(void 0),className:`font-medium text-foreground underline underline-offset-2`,children:`back to current`})]}),r.data.truncated?(0,Q.jsxs)(`span`,{className:`hidden text-meta text-muted-foreground md:inline`,children:[`Showing the newest `,r.data.artifacts.length,` files; the folder has more`]}):null,(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(V,{label:_?`Leave focus — bring the sidebar back`:`Focus — fold the sidebar to icons while Assets is open`,children:(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-action":`assets-focus`,"aria-pressed":_,"aria-label":_?`Leave focus`:`Focus`,className:s(`text-muted-foreground`,_&&`bg-muted text-foreground`),onClick:()=>v(!_),children:_?(0,Q.jsx)(O,{"aria-hidden":`true`}):(0,Q.jsx)(E,{"aria-hidden":`true`})})}),h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Q.jsxs)(`a`,{"data-action":`assets-open`,href:i(e,h.name,N),target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open in new tab`,title:`Open in new tab (still sandboxed)`,children:[(0,Q.jsx)(b,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-sm:sr-only`,children:`Open in new tab`})]})}),(0,Q.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Q.jsxs)(`a`,{"data-action":`assets-download`,href:i(e,h.name,N),download:h.name,"aria-label":`Download`,children:[(0,Q.jsx)(y,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-sm:sr-only`,children:`Download`})]})}),(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-reload`,"aria-label":`Reload`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,onClick:()=>S(e=>e+1),children:[(0,Q.jsx)(M,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-sm:sr-only`,children:`Reload`})]})]}):null]})]}),h?(0,Q.jsx)(le,{runId:e,artifact:h,version:N,frameRef:P},`${h.name}@${h.updatedAt}#${x}v${N??``}`):(0,Q.jsx)(U,{icon:(0,Q.jsx)(C,{}),tone:`neutral`,heading:`h2`,title:re,subtitle:ie}),n&&h?(0,Q.jsx)(ne,{run:n,reference:F,onClearReference:()=>I(null)}):null]})}function oe(e,t){return(e??[]).filter(e=>e.files.includes(t))}function $({versions:e,viewing:t,onSelect:n}){let r=e.at(-1),i=t??r?.version;return(0,Q.jsxs)(v,{children:[(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-versions`,"aria-label":`Version v${i} — pick another version`,className:`h-7 gap-1 px-2 text-label text-muted-foreground`,children:[(0,Q.jsx)(q,{"aria-hidden":`true`,className:`size-3.5`}),`v`,i,r&&t===void 0?(0,Q.jsxs)(`span`,{className:`hidden sm:inline`,children:[`· `,H(r.updatedAt),` ago`]}):null,(0,Q.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 opacity-60`})]})}),(0,Q.jsxs)(g,{align:`start`,className:`w-56`,children:[(0,Q.jsx)(p,{children:`Versions`}),(0,Q.jsx)(m,{value:String(i),onValueChange:e=>n(Number(e)),children:[...e].reverse().map(e=>(0,Q.jsxs)(_,{value:String(e.version),"data-version":e.version,children:[`v`,e.version,` · `,H(e.updatedAt),` ago`,e.version===r?.version?(0,Q.jsx)(`span`,{className:`ml-auto text-meta text-muted-foreground`,children:`current`}):null]},e.version))})]})]})}function se(){let[e,t]=(0,J.useState)(()=>P(`assets`)),n=(0,J.useCallback)(e=>{L(`assets`,e),t(e)},[]);return(0,J.useEffect)(()=>{if(e)return D(()=>n(!1))},[e,n]),[e,n]}function ce({artifacts:e,current:t,onSelect:n}){let r=ee(e);return(0,Q.jsxs)(v,{children:[(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-switcher`,"aria-label":`Asset: ${F(t)} — switch asset`,className:`h-7 min-w-0 max-w-[min(28rem,60vw)] gap-1.5 px-2 text-ui font-medium`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:F(t)}),(0,Q.jsx)(`span`,{className:`shrink-0 text-meta font-normal text-muted-foreground`,children:k[t.kind]}),(0,Q.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0 opacity-60`})]})}),(0,Q.jsxs)(g,{align:`start`,className:`max-h-80 w-80 overflow-y-auto`,children:[(0,Q.jsxs)(p,{children:[e.length,` `,e.length===1?`asset`:`assets`]}),(0,Q.jsx)(m,{value:t.name,onValueChange:n,children:r.map(e=>(0,Q.jsx)(_,{value:e.name,"data-asset":e.name,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:F(e)}),(0,Q.jsxs)(`span`,{className:`truncate font-mono text-meta text-muted-foreground`,children:[e.name,` · `,k[e.kind],` · `,H(e.updatedAt)]})]})},e.name))})]})]})}function le({runId:e,artifact:t,version:n,frameRef:r}){let a=T(),o=i(e,t.name,n);switch(t.kind){case`html`:return(0,Q.jsx)(`iframe`,{ref:r,"data-slot":`assets-frame`,title:F(t),src:`${o}#theme=${a}`,sandbox:N,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-background`});case`image`:return(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Q.jsx)(`img`,{"data-slot":`assets-image`,src:o,alt:F(t),className:`max-w-full rounded-sm`})});case`markdown`:case`json`:return(0,Q.jsx)(ue,{runId:e,artifact:t});case`other`:return(0,Q.jsx)(U,{icon:(0,Q.jsx)(S,{}),tone:`neutral`,heading:`h2`,title:`No preview for this file`,subtitle:`${t.name} — download it to open it locally.`,actions:(0,Q.jsx)(d,{asChild:!0,variant:`outline`,children:(0,Q.jsxs)(`a`,{"data-action":`assets-download-file`,href:o,download:t.name,children:[(0,Q.jsx)(y,{"aria-hidden":`true`}),`Download`]})})})}}function ue({runId:e,artifact:t}){let n=r(e,t.name,t.updatedAt);return n.isPending?(0,Q.jsxs)(`p`,{className:`px-4 py-6 text-center text-label text-soft-foreground`,children:[`Loading `,t.name,`…`]}):n.isError?(0,Q.jsx)(U,{icon:(0,Q.jsx)(R,{}),tone:`danger`,heading:`h2`,title:`Could not load this asset`,subtitle:n.error.message}):(0,Q.jsx)(`div`,{"data-slot":`assets-${t.kind}`,className:`min-h-0 flex-1 overflow-auto`,children:t.kind===`markdown`?(0,Q.jsx)(`div`,{className:`mx-auto max-w-3xl px-4 py-4`,children:(0,Q.jsx)(W,{children:n.data})}):(0,Q.jsx)(x,{path:t.name,text:n.data})})}export{ae as AssetsView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ct as r,Oa as i,wt as a}from"./queries-Dy1pV6Rm.js";import{kt as o,t as s}from"./utils-Mxa0e2-I.js";import{f as c}from"./chunk-KS7C4IRE-DtL2Gzw3.js";import{t as l}from"./createLucideIcon-BHp8sXmF.js";import{O as u}from"./run-actions-D6ciV-B7.js";import{t as d}from"./button-DPW_5ujg.js";import{r as f}from"./dist-KgumXxNc.js";import{a as p,o as m,p as h,r as g,s as _,t as v}from"./dropdown-menu-7_Jr7yCh.js";import{t as y}from"./download-CfgyYHf7.js";import{t as b}from"./external-link-BE6y205O.js";import{t as x}from"./file-preview-D8U51DZ0.js";import{t as S}from"./file--aqoYe_k.js";import{t as C}from"./layers-CS8s30-0.js";import{t as w}from"./loader-circle-CPBhhDbB.js";import{a as T,c as E,n as D,s as O}from"./sidebar-rail-CKo-kvV9.js";import{a as k,c as A,d as j,f as M,i as N,l as P,o as F,r as I,s as ee,t as te,u as L}from"./follow-up-engine-Dt_DZGEh.js";import{t as R}from"./triangle-alert-CIzim6ZN.js";import{t as z}from"./x-BqECUykl.js";import{l as B}from"./project-router-BM4IWQob.js";import{t as V}from"./icon-tooltip-yJInZkjY.js";import{r as H}from"./format-BUbPQpzw.js";import{t as U}from"./centered-state-vm_lrdiA.js";import{t as W}from"./markdown-Bo0_d7Dw.js";import{Q as G}from"./index-Dkgcny7F.js";var K=l(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),q=l(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),J=e(t(),1);function Y(e){let t=o.safeParse(e);return t.success?{ref:t.data.ref,label:t.data.label.slice(0,200)}:null}function X(e,t){return e?`About ${e.ref} ("${e.label}"): ${t}`:t}function Z(e,t){let n=(0,J.useRef)(t);n.current=t,(0,J.useEffect)(()=>{let t=t=>{let r=e.current?.contentWindow;if(!r||t.source!==r)return;let i=Y(t.data);i&&n.current(i)};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}var Q=n();function ne({run:e,reference:t,onClearReference:n}){let r=te(e),i=I(e,r.continueWith),a=u(e),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=(0,J.useId)(),h=e.status===`running`||e.status===`waiting`,g=e.status===`queued`,_=!h&&!g&&r.available;if(!h&&!g&&!_||e.worktreeLifecycle?.activeOperationId)return null;let v=h&&!a.usable?a.reason:_&&!r.canContinue?r.reason??`No provider can continue this task.`:void 0,y=!v&&!c&&o.trim()!==``,b=async e=>{if(e?.preventDefault(),y){l(!0),p(null);try{await i(X(t,o.trim()),[]),s(``),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}}};return(0,Q.jsxs)(`form`,{"data-slot":`assets-ask`,"aria-label":`Ask about this asset`,onSubmit:e=>void b(e),className:`shrink-0 border-t border-border bg-background px-2 py-2 sm:px-3`,children:[t?(0,Q.jsxs)(`span`,{"data-slot":`assets-ask-ref`,className:`mb-1.5 inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-muted py-0.5 pr-0.5 pl-2 text-meta`,children:[(0,Q.jsx)(K,{"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`}),(0,Q.jsx)(V,{label:`${t.ref} — ${t.label}`,children:(0,Q.jsxs)(`span`,{className:`truncate`,children:[(0,Q.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t.ref}),` `,t.label]})}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`assets-ask-ref-remove`,"aria-label":`Remove reference`,onClick:n,className:`rounded-full p-0.5 text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(z,{"aria-hidden":`true`,className:`size-3`})})]}):null,(0,Q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Q.jsx)(`textarea`,{"data-slot":`assets-ask-input`,"aria-label":t?`Ask about ${t.label||t.ref}`:`Ask the agent about this asset`,"aria-describedby":v||f?m:void 0,rows:1,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&b()},disabled:!!v,placeholder:t?`Ask or correct — ⌘↵ to send`:`Ask the agent about this report — click an element to reference it`,className:`max-h-32 min-h-9 flex-1 resize-y rounded-md border border-border bg-card px-2.5 py-2 text-ui focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:opacity-60`}),(0,Q.jsxs)(d,{type:`submit`,size:`sm`,"data-action":`assets-ask-send`,disabled:!y,"aria-busy":c||void 0,children:[c?(0,Q.jsx)(w,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(j,{"aria-hidden":`true`}),_?`Continue`:`Send`]})]}),v||f?(0,Q.jsx)(`p`,{id:m,"data-slot":`assets-ask-reason`,className:`mt-1 text-label text-muted-foreground`,children:f??v}):null]})}var re=`No assets yet`,ie=`Agents publish pages here when they write to the run's artifacts folder.`;function ae({runId:e,routed:t,run:n}){let r=a(e),o=c(),l=B(),[u,f]=(0,J.useState)(void 0),p=t?o.name:u,m=r.data?.artifacts??[],h=A(m,p),g=(0,J.useCallback)(n=>{t?l(`/tasks/${e}/assets/${encodeURIComponent(n)}`,{replace:!0}):f(n)},[l,t,e]),[_,v]=se(),[x,S]=(0,J.useState)(0),[T,D]=(0,J.useState)(void 0),k=h?.kind===`html`?oe(r.data?.versions,h.name):[],j=k.at(-1)?.version,N=T&&h&&T.name===h.name&&T.version!==j&&k.some(e=>e.version===T.version)?T.version:void 0,P=(0,J.useRef)(null),[F,I]=(0,J.useState)(null);return Z(P,I),r.isPending?(0,Q.jsx)(U,{icon:(0,Q.jsx)(w,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:`h2`,title:`Loading assets…`}):r.isError?(0,Q.jsx)(U,{icon:(0,Q.jsx)(R,{}),tone:`danger`,heading:`h2`,title:`Could not load this task's assets`,subtitle:r.error.message}):(0,Q.jsxs)(`section`,{"data-slot":`assets-view`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,Q.jsxs)(`div`,{"data-slot":`assets-toolbar`,role:`toolbar`,"aria-label":`Assets`,className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-2 sm:px-3`,children:[h?(0,Q.jsx)(ce,{artifacts:m,current:h,onSelect:g}):(0,Q.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`Assets`}),h?.kind===`html`?(0,Q.jsx)(V,{label:`Runs in a sandbox: no access to cezar, your cookies or the network beyond pinned CDN scripts`,children:(0,Q.jsxs)(`span`,{"data-slot":`assets-sandboxed`,tabIndex:0,className:`hidden items-center gap-1 rounded-sm border border-border px-1.5 py-px text-meta text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none sm:inline-flex`,children:[(0,Q.jsx)(G,{"aria-hidden":`true`,className:`size-3`}),`sandboxed`]})}):null,h&&k.length>1?(0,Q.jsx)($,{versions:k,viewing:N,onSelect:e=>D(e===j?void 0:{name:h.name,version:e})}):null,N===void 0?null:(0,Q.jsxs)(`span`,{"data-slot":`assets-viewing-version`,className:`inline-flex items-center gap-1.5 text-meta text-muted-foreground`,children:[`Viewing v`,N,(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,Q.jsx)(`button`,{type:`button`,"data-action":`assets-version-current`,onClick:()=>D(void 0),className:`font-medium text-foreground underline underline-offset-2`,children:`back to current`})]}),r.data.truncated?(0,Q.jsxs)(`span`,{className:`hidden text-meta text-muted-foreground md:inline`,children:[`Showing the newest `,r.data.artifacts.length,` files; the folder has more`]}):null,(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(V,{label:_?`Leave focus — bring the sidebar back`:`Focus — fold the sidebar to icons while Assets is open`,children:(0,Q.jsx)(d,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-action":`assets-focus`,"aria-pressed":_,"aria-label":_?`Leave focus`:`Focus`,className:s(`text-muted-foreground`,_&&`bg-muted text-foreground`),onClick:()=>v(!_),children:_?(0,Q.jsx)(O,{"aria-hidden":`true`}):(0,Q.jsx)(E,{"aria-hidden":`true`})})}),h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Q.jsxs)(`a`,{"data-action":`assets-open`,href:i(e,h.name,N),target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open in new tab`,title:`Open in new tab (still sandboxed)`,children:[(0,Q.jsx)(b,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-sm:sr-only`,children:`Open in new tab`})]})}),(0,Q.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Q.jsxs)(`a`,{"data-action":`assets-download`,href:i(e,h.name,N),download:h.name,"aria-label":`Download`,children:[(0,Q.jsx)(y,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-sm:sr-only`,children:`Download`})]})}),(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-reload`,"aria-label":`Reload`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,onClick:()=>S(e=>e+1),children:[(0,Q.jsx)(M,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-sm:sr-only`,children:`Reload`})]})]}):null]})]}),h?(0,Q.jsx)(le,{runId:e,artifact:h,version:N,frameRef:P},`${h.name}@${h.updatedAt}#${x}v${N??``}`):(0,Q.jsx)(U,{icon:(0,Q.jsx)(C,{}),tone:`neutral`,heading:`h2`,title:re,subtitle:ie}),n&&h?(0,Q.jsx)(ne,{run:n,reference:F,onClearReference:()=>I(null)}):null]})}function oe(e,t){return(e??[]).filter(e=>e.files.includes(t))}function $({versions:e,viewing:t,onSelect:n}){let r=e.at(-1),i=t??r?.version;return(0,Q.jsxs)(v,{children:[(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-versions`,"aria-label":`Version v${i} — pick another version`,className:`h-7 gap-1 px-2 text-label text-muted-foreground`,children:[(0,Q.jsx)(q,{"aria-hidden":`true`,className:`size-3.5`}),`v`,i,r&&t===void 0?(0,Q.jsxs)(`span`,{className:`hidden sm:inline`,children:[`· `,H(r.updatedAt),` ago`]}):null,(0,Q.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 opacity-60`})]})}),(0,Q.jsxs)(g,{align:`start`,className:`w-56`,children:[(0,Q.jsx)(p,{children:`Versions`}),(0,Q.jsx)(m,{value:String(i),onValueChange:e=>n(Number(e)),children:[...e].reverse().map(e=>(0,Q.jsxs)(_,{value:String(e.version),"data-version":e.version,children:[`v`,e.version,` · `,H(e.updatedAt),` ago`,e.version===r?.version?(0,Q.jsx)(`span`,{className:`ml-auto text-meta text-muted-foreground`,children:`current`}):null]},e.version))})]})]})}function se(){let[e,t]=(0,J.useState)(()=>P(`assets`)),n=(0,J.useCallback)(e=>{L(`assets`,e),t(e)},[]);return(0,J.useEffect)(()=>{if(e)return D(()=>n(!1))},[e,n]),[e,n]}function ce({artifacts:e,current:t,onSelect:n}){let r=ee(e);return(0,Q.jsxs)(v,{children:[(0,Q.jsx)(h,{asChild:!0,children:(0,Q.jsxs)(d,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-switcher`,"aria-label":`Asset: ${F(t)} — switch asset`,className:`h-7 min-w-0 max-w-[min(28rem,60vw)] gap-1.5 px-2 text-ui font-medium`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:F(t)}),(0,Q.jsx)(`span`,{className:`shrink-0 text-meta font-normal text-muted-foreground`,children:k[t.kind]}),(0,Q.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0 opacity-60`})]})}),(0,Q.jsxs)(g,{align:`start`,className:`max-h-80 w-80 overflow-y-auto`,children:[(0,Q.jsxs)(p,{children:[e.length,` `,e.length===1?`asset`:`assets`]}),(0,Q.jsx)(m,{value:t.name,onValueChange:n,children:r.map(e=>(0,Q.jsx)(_,{value:e.name,"data-asset":e.name,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:F(e)}),(0,Q.jsxs)(`span`,{className:`truncate font-mono text-meta text-muted-foreground`,children:[e.name,` · `,k[e.kind],` · `,H(e.updatedAt)]})]})},e.name))})]})]})}function le({runId:e,artifact:t,version:n,frameRef:r}){let a=T(),o=i(e,t.name,n);switch(t.kind){case`html`:return(0,Q.jsx)(`iframe`,{ref:r,"data-slot":`assets-frame`,title:F(t),src:`${o}#theme=${a}`,sandbox:N,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-background`});case`image`:return(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Q.jsx)(`img`,{"data-slot":`assets-image`,src:o,alt:F(t),className:`max-w-full rounded-sm`})});case`markdown`:case`json`:return(0,Q.jsx)(ue,{runId:e,artifact:t});case`other`:return(0,Q.jsx)(U,{icon:(0,Q.jsx)(S,{}),tone:`neutral`,heading:`h2`,title:`No preview for this file`,subtitle:`${t.name} — download it to open it locally.`,actions:(0,Q.jsx)(d,{asChild:!0,variant:`outline`,children:(0,Q.jsxs)(`a`,{"data-action":`assets-download-file`,href:o,download:t.name,children:[(0,Q.jsx)(y,{"aria-hidden":`true`}),`Download`]})})})}}function ue({runId:e,artifact:t}){let n=r(e,t.name,t.updatedAt);return n.isPending?(0,Q.jsxs)(`p`,{className:`px-4 py-6 text-center text-label text-soft-foreground`,children:[`Loading `,t.name,`…`]}):n.isError?(0,Q.jsx)(U,{icon:(0,Q.jsx)(R,{}),tone:`danger`,heading:`h2`,title:`Could not load this asset`,subtitle:n.error.message}):(0,Q.jsx)(`div`,{"data-slot":`assets-${t.kind}`,className:`min-h-0 flex-1 overflow-auto`,children:t.kind===`markdown`?(0,Q.jsx)(`div`,{className:`mx-auto max-w-3xl px-4 py-4`,children:(0,Q.jsx)(W,{children:n.data})}):(0,Q.jsx)(x,{path:t.name,text:n.data})})}export{ae as AssetsView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,$r as i,Ai as a,Da as o,Do as s,F as c,It as l,Jr as u,Kt as d,La as f,Mi as p,Oo as m,Pr as h,Qn as g,Qr as _,Ri as v,Ya as y,ca as b,cn as x,hr as S,in as C,jo as ee,ko as w,pt as te,r as T}from"./queries-dvQqxBLo.js";import{B as E,G as ne,H as re,J as ie,K as ae,U as D,Ut as oe,V as se,W as ce,X as O,Z as le,c as k,t as A,z as ue}from"./utils-Mxa0e2-I.js";import{f as de,p as fe}from"./chunk-KS7C4IRE-DtL2Gzw3.js";import{t as pe}from"./use-now-BpFsrkTr.js";import{T as me}from"./managers-Cgz-qnAk.js";import{i as he,t as ge}from"./segmented-CdgJjIWr.js";import{a as _e,i as ve,o as ye,r as be,t as xe}from"./sheet-V0-7oBDu.js";import{t as j}from"./createLucideIcon-BHp8sXmF.js";import{t as Se}from"./arrow-down-NfQPLFhe.js";import{t as Ce}from"./arrow-left-BfRd_mrv.js";import{d as we}from"./reference-chip-kHEAt0n5.js";import{t as Te}from"./arrow-up-CssRwnnv.js";import{A as Ee}from"./run-actions-CUW6zWlf.js";import{a as De,c as Oe,d as ke,i as Ae,l as je,n as Me,o as Ne,r as Pe,s as Fe,t as Ie,u as M}from"./automation-format-BVa8GfLP.js";import{n as Le,t as N,z as Re}from"./button-DPW_5ujg.js";import{t as ze}from"./chevron-left-D0UFBpi5.js";import{r as Be}from"./dist-KgumXxNc.js";import{i as P,n as F,o as I,s as L,t as R}from"./select-CDNFJfBJ.js";import{t as Ve}from"./circle-question-mark-X2pmbDJg.js";import{c as He,i as z,p as Ue,r as We,t as Ge}from"./dropdown-menu-7_Jr7yCh.js";import{n as Ke,t as qe}from"./pencil-BWoe1EL-.js";import{L as Je,j as B}from"./manager-loading-ZLoOqH3N.js";import{t as Ye}from"./download-CfgyYHf7.js";import{n as Xe}from"./workflow-BEP63Wt4.js";import{_ as Ze}from"./impact-model-Cgc3vnDT.js";import{t as Qe}from"./file-text-D2QdCz-z.js";import{t as $e}from"./upload-BE8GV7hh.js";import{n as et,t as tt}from"./settings-2-B8aEkWqd.js";import{u as nt}from"./worktree-lifecycle-operation-LYslaK-Z.js";import{n as rt,t as it}from"./switch-Bj2j4bg0.js";import{_ as at,a as ot,c as st,o as ct}from"./composer-zqlaY3u_.js";import{t as lt}from"./play-CmVAj_fu.js";import{t as ut}from"./plus-CxRU2X8C.js";import{t as dt}from"./terminal-CxnJmFUC.js";import{n as ft,t as pt}from"./textarea-C1UnTzWH.js";import{t as mt}from"./triangle-alert-CIzim6ZN.js";import{c as ht,l as V,t as H}from"./project-router-Bm4c2tHW.js";import{a as gt,c as _t,d as vt,f as yt,i as bt,l as xt,o as St,p as Ct,s as wt,t as Tt,u as Et}from"./sortable.esm-B7aanBL9.js";import{n as Dt,r as Ot,t as kt}from"./collapsible-D2PzOtFb.js";import{a as At,c as jt,i as Mt,n as Nt,o as Pt,r as Ft,s as It,t as Lt}from"./alert-dialog-CCN6Eo9S.js";import{t as U}from"./icon-tooltip-yJInZkjY.js";import{a as Rt,i as zt,n as Bt,o as Vt,r as Ht,t as Ut}from"./dialog-Cfqi9LM_.js";import{a as Wt,i as Gt}from"./loading-state-BcfD4D-3.js";import{t as W}from"./input-BbFy6kTc.js";import{r as Kt}from"./toaster-DfddV8rk.js";import{r as qt}from"./format-BUbPQpzw.js";import{t as G}from"./status-dot-ntyrUVQa.js";import{t as Jt}from"./pill-BnGDkiot.js";import{t as Yt}from"./centered-state-vm_lrdiA.js";import{t as K}from"./chip-C-AtTfag.js";import{v as Xt}from"./new-task-form-Bd0bjUVF.js";import{t as Zt}from"./picker-pill-inZ7-90v.js";import{F as Qt,G as $t,H as en,I as tn,J as nn,K as rn,L as an,M as on,N as sn,P as cn,R as ln,U as un,V as dn,W as fn,et as pn,f as mn,i as hn,j as gn,nt as _n,q as vn,r as yn,s as bn}from"./index-CuX9ehIb.js";var xn=j(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Sn=j(`list-x`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`m15.5 9.5 5 5`,key:`ytk86i`}],[`path`,{d:`m20.5 9.5-5 5`,key:`17o44f`}]]),Cn=j(`message-square-share`,[[`path`,{d:`M12 3H4a2 2 0 0 0-2 2v16.286a.71.71 0 0 0 1.212.502l2.202-2.202A2 2 0 0 1 6.828 19H20a2 2 0 0 0 2-2v-4`,key:`11da1y`}],[`path`,{d:`M16 3h6v6`,key:`1bx56c`}],[`path`,{d:`m16 9 6-6`,key:`m4dnic`}]]),wn=j(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Tn=j(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),En=j(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),q=e(t(),1),J=n();function Dn({association:e,selected:t,onSelect:n,onRemove:r}){let i=s({queryKey:[`tracker`,k(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>p({association:e,state:`all`,limit:50,cursor:t},{signal:n}),getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,retry:!1,staleTime:6e4}),a=i.data?.pages??[],o=a.at(-1),c=a.find(e=>!e.available),l=i.isError||!!c,u=[...new Set([...t,...l?[]:a.flatMap(e=>e.available?e.items.flatMap(e=>e.labels):[])])].filter(e=>t.includes(e)||e.length>0&&e.length<=200).sort((e,t)=>e.localeCompare(t));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:u.map(e=>(0,J.jsx)(K,{active:t.includes(e),"aria-pressed":t.includes(e),disabled:!t.includes(e)&&t.length>=100,onClick:()=>t.includes(e)?r(e):n(e),children:e},e))}),i.isFetching?(0,J.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,l?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,J.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,J.jsxs)(J.Fragment,{children:[!i.isPending&&!i.isFetching&&u.length===0?(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,J.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,disabled:i.isFetching,onClick:()=>void i.fetchNextPage(),children:`Load labels from more tasks`}):null,!i.hasNextPage&&o?.available&&o.truncated?(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var On=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function kn(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function An(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function jn(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function Mn(e){return e?.source===`skill`?{skill:e.ref,workflow:Xt,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var Nn=[2,5,10,15,30,60],Pn=[1,2,4,6,8],Fn={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},In={type:`daily`,hour:4,minute:0};function Ln(){return{name:``,kind:`schedule`,schedule:{...In},events:[`issue.opened`],intervalSeconds:300,filters:{...Fn},prompt:``,workflow:Xt,skill:null,customSteps:null,runner:null,account:null,model:null,reasoningEffort:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var Y=e=>(e??[]).join(`, `);function Rn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function zn(e){return{authors:Y(e.authors),assignees:Y(e.assignees),anyLabels:Y(e.anyLabels),allLabels:Y(e.allLabels),excludeLabels:Y(e.excludeLabels),changedLabels:Y(e.changedLabels),reviewers:Y(e.reviewers),lookbackDays:e.lookbackDays,maxRecords:e.maxRecords}}function Bn(e){let t=Ln(),{task:n,filters:r}=e,i=An(n.steps);return{...t,name:e.name,kind:e.kind,trackerTrigger:e.trackerTrigger,schedule:e.schedule?{...e.schedule}:t.schedule,schedules:e.schedules?.map(e=>({...e})),events:e.events?.length?[...e.events]:t.events,intervalSeconds:e.intervalSeconds??t.intervalSeconds,filters:r?zn(r):t.filters,prompt:n.prompt,workflow:n.workflow??t.workflow,skill:i,customSteps:n.steps&&!i?n.steps:null,runner:n.runner??null,account:n.agentProfile??null,model:n.model??null,reasoningEffort:n.reasoningEffort??null,autonomous:n.autonomous??!1,dispatch:n.dispatch!==void 0,maxSubtasks:n.dispatch?.maxSubtasks??t.maxSubtasks,reviewChild:n.dispatch?.reviewChild??t.reviewChild,enabled:e.enabled,...n.checkout===void 0?{}:{checkout:n.checkout},...n.allowForkHeads===void 0?{}:{allowForkHeads:n.allowForkHeads}}}function Vn(e){return{name:e.name,kind:e.kind,...e.schedule?{schedule:e.schedule}:{},...e.schedules?{schedules:e.schedules}:{},...e.events?{events:e.events}:{},...e.intervalSeconds===void 0?{}:{intervalSeconds:e.intervalSeconds},...e.filters?{filters:e.filters}:{},prompt:e.task.prompt,...e.task.workflow?{workflow:e.task.workflow}:{},...e.task.steps?{steps:e.task.steps}:{},...e.task.runner?{runner:e.task.runner}:{},...e.task.model===void 0?{}:{model:e.task.model},...e.task.reasoningEffort?{reasoningEffort:e.task.reasoningEffort}:{},...e.task.autonomous===void 0?{}:{autonomous:e.task.autonomous},...e.task.dispatch?{dispatch:e.task.dispatch}:{},...e.task.checkout?{checkout:e.task.checkout}:{},...e.task.allowForkHeads===void 0?{}:{allowForkHeads:e.task.allowForkHeads}}}var Hn=e=>oe.safeParse(e).success;function Un(e,t){let n=An(t.steps);return{...e,name:t.name,kind:t.kind,schedule:t.schedule?{...t.schedule}:e.schedule,schedules:t.schedules?.map(e=>({...e})),events:t.events?.length?[...t.events]:e.events,intervalSeconds:t.intervalSeconds??e.intervalSeconds,filters:t.filters?zn(t.filters):{...Fn},prompt:t.prompt,...t.steps?{skill:n,customSteps:n?null:t.steps,workflow:Xt}:Mn(t.workflow?{source:`workflow`,ref:t.workflow}:null),checkout:t.checkout,allowForkHeads:t.allowForkHeads,runner:t.runner!==void 0&&Hn(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&Hn(t.runner)?null:e.account,model:t.model??e.model,reasoningEffort:t.reasoningEffort??(t.runner!==void 0||t.model!==void 0?null:e.reasoningEffort),autonomous:t.autonomous??e.autonomous,dispatch:t.dispatch!==void 0,maxSubtasks:t.dispatch?.maxSubtasks??e.maxSubtasks,reviewChild:t.dispatch?.reviewChild??e.reviewChild}}function Wn(e){let t=ae(e);switch(t.type){case`hours`:return{type:`hours`,every:t.every};case`weekly`:return{type:`weekly`,hour:t.hour,minute:t.minute,day:t.day};case`once`:return{type:`once`,hour:t.hour,minute:t.minute,...t.date?{date:t.date}:{}};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function Gn(e){let t={prompt:e.prompt,...e.skill?{steps:kn(e.skill)}:e.customSteps?{steps:e.customSteps}:e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.account?{agentProfile:e.account}:{},...e.model?{model:e.model}:{},...e.reasoningEffort?{reasoningEffort:e.reasoningEffort}:{},autonomous:e.autonomous,...e.dispatch?{dispatch:{maxSubtasks:e.maxSubtasks,reviewChild:e.reviewChild}}:{}};if(e.kind===`schedule`)return{name:e.name.trim(),kind:`schedule`,schedule:Wn(e.schedule),...e.schedules?{schedules:[e.schedule,...e.schedules.slice(1)].map(Wn)}:{},task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:Kn(e.filters.lookbackDays,1,90),maxRecords:Kn(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Rn(e);return n.length>0?{[t]:n}:{}};return{name:e.name.trim(),kind:`github`,events:[...e.events],intervalSeconds:e.intervalSeconds,filters:{...r(n.authors,`authors`),...r(n.assignees,`assignees`),...r(n.anyLabels,`anyLabels`),...r(n.allLabels,`allLabels`),...r(n.excludeLabels,`excludeLabels`),...r(n.changedLabels,`changedLabels`),...r(n.reviewers,`reviewers`),lookbackDays:Kn(n.lookbackDays,1,90),maxRecords:Kn(n.maxRecords,1,100)},task:{...t,...e.checkout===void 0?{}:{checkout:e.checkout},...e.allowForkHeads===void 0?{}:{allowForkHeads:e.allowForkHeads}}}}function Kn(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function qn(e){let t=Gn(e);return{name:t.name,kind:e.kind,...t.trackerTrigger?{trackerTrigger:t.trackerTrigger}:{},...t.schedule?{schedule:t.schedule}:{},...t.schedules?{schedules:t.schedules}:{},...t.events?{events:t.events}:{},...t.intervalSeconds===void 0?{}:{intervalSeconds:t.intervalSeconds},...t.filters?{filters:t.filters}:{},task:t.task,...e.enabled?{enable:!0}:{}}}var Jn=`([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})`,Yn=RegExp(`\\b(?:user|author|by)\\s+(?:\`@?${Jn}\`|@${Jn}(?![\\w/-]))`,`gi`),Xn=[`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`],Zn=new Set(`a an the this that these those any all each every some me my you your it its them their us our we he she they who whom which what someone anyone everyone others other pull pr prs issue issues review reviews reviewer reviewers request requests team teams user users human humans changes code now approval merge`.split(` `)),Qn=`(?:\`@?${Jn}\`|@${Jn}(?![\\w/-]))`,$n=RegExp(`\\breview(?:s|\\s+requests?)?\\s+(?:(?:is|are)\\s+)?(?:requested\\s+)?(?:for|from|of)\\s+(?:${Qn}|${Jn}\\b(?![/@-]))`,`gi`),er=RegExp(`\\b(?:requested\\s+)?reviewer\\s+${Qn}`,`gi`),tr=RegExp(`${Qn}\\s+(?:(?:is|are|gets?)\\s+)?requested\\s+as\\s+(?:a\\s+)?reviewer\\b`,`gi`);function nr(e){if(e.kind!==`github`)return[];let t=new Set([e.filters.authors,e.filters.assignees,e.filters.reviewers].flatMap(Rn).map(e=>e.replace(/^@/,``).toLowerCase())),n=new Map,r=(e,r)=>{let i=e?.toLowerCase();!e||!i||t.has(i)||n.has(i)||n.set(i,{login:e,field:r})};if(e.events?.some(e=>Xn.includes(e)))for(let t of[$n,er,tr])for(let n of e.prompt.matchAll(t)){let e=n[1]??n[2]??n[3];e&&!Zn.has(e.toLowerCase())&&r(e,`reviewers`)}for(let t of e.prompt.matchAll(Yn))r(t[1]??t[2],`authors`);return[...n.values()]}function rr(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var ir=e=>[1,2,3,4,6,8,12].includes(e);function ar({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,o]=(0,q.useState)(``),c=k(),l=s({queryKey:[`tracker`,c,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>a({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),u=s({queryKey:[`tracker`,c,`automation-options`,i],enabled:!!i&&l.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>a({...i?{search:i}:{},...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),d=i?u:l,f=l.data?.pages[0],p=f?.available?f:void 0,m=!!p&&!!e&&JSON.stringify(p.association)===JSON.stringify(e.association),h=!!e?.access&&m&&!!e?.events.length&&e.events.every(e=>p?.events.includes(e))&&(e.requiredLabels?.length??0)<=100&&(e.requiredLabels??[]).every(e=>e.length>0&&e.length<=200)&&(!e.events.includes(`issue.status_changed`)||!!e.targetStatusIds?.length)&&(!(e.events.includes(`issue.labeled`)||e.events.includes(`issue.unlabeled`))||!!e.changedLabelIds?.length);(0,q.useEffect)(()=>(r(h),()=>r(!1)),[h,r]);let g=d.data?.pages.flatMap(e=>e.available?[e]:[])??[],_=[...new Map(g.flatMap(e=>e.statuses).map(e=>[e.id,e])).values()],v=new Map((l.data?.pages.flatMap(e=>e.available?e.statuses:[])??[]).map(e=>[e.id,e.name])),y=(e?.targetStatusIds??[]).filter(e=>!_.some(t=>t.id===e)),b=[...new Map(g.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],x=e?.events.includes(`issue.status_changed`),S=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),C=x&&S?`Search tracker statuses and labels`:S?`Search tracker labels`:`Search tracker statuses`;return(0,J.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[l.isPending?(0,J.jsx)(`p`,{children:`Loading tracker events…`}):null,l.isError||f&&!f.available?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsxs)(`p`,{children:[f&&!f.available?f.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,J.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry`})]}):null,p?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[p.association.kind===`jira`?`Jira`:`Linear`,` · `,p.association.externalName]}),e&&!m?(0,J.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,J.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:p.events.map(t=>(0,J.jsx)(K,{active:m&&e?.events.includes(t),"aria-pressed":m&&e?.events.includes(t),onClick:()=>{let r=m?e.events:[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a=e?.access??(e?void 0:{version:1,writes:[]}),o={...m?e:{},...a?{access:a}:{},association:p.association,events:i};t===`issue.status_changed`&&!i.includes(t)&&delete o.targetStatusIds,n({trackerTrigger:o,...m?{}:{enabled:!1}})},children:t},t))}),m&&e?(0,J.jsx)(Dn,{association:p.association,selected:e.requiredLabels??[],onRemove:t=>n({trackerTrigger:{...e,requiredLabels:(e.requiredLabels??[]).filter(e=>e!==t)}}),onSelect:t=>n({trackerTrigger:{...e,requiredLabels:[...new Set([...e.requiredLabels??[],t])]}})},JSON.stringify(p.association)):null,(0,J.jsxs)(`details`,{className:`text-label text-muted-foreground`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,J.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),p.limitations.map(e=>(0,J.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(W,{"aria-label":C,placeholder:C,value:i,onChange:e=>o(e.target.value)}),d.isFetching?(0,J.jsx)(`p`,{role:`status`,children:`Searching…`}):null,d.isError||d.data?.pages[0]&&!d.data.pages[0].available?(0,J.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,J.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void d.refetch(),children:`Retry search`})]}):null,!d.isFetching&&d.data?.pages[0]?.available&&x&&_.length===0?(0,J.jsx)(`p`,{children:`No matching statuses.`}):null,!d.isFetching&&d.data?.pages[0]?.available&&S&&b.length===0?(0,J.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[_.map(t=>(0,J.jsx)(K,{active:e.targetStatusIds?.includes(t.id),"aria-pressed":e.targetStatusIds?.includes(t.id),onClick:()=>{let r=e.targetStatusIds??[];n({trackerTrigger:{...e,targetStatusIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id)),y.map(t=>(0,J.jsxs)(K,{active:!0,"aria-pressed":!0,onClick:()=>{n({trackerTrigger:{...e,targetStatusIds:(e.targetStatusIds??[]).filter(e=>e!==t)}})},children:[v.get(t)??t,` (not in current results)`]},t))]}):null,e.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,J.jsx)(K,{active:e.changedLabelIds?.includes(t.id),"aria-pressed":e.changedLabelIds?.includes(t.id),onClick:()=>{let r=e.changedLabelIds??[];n({trackerTrigger:{...e,changedLabelIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id))}):null,d.hasNextPage?(0,J.jsx)(N,{variant:`outline`,size:`sm`,disabled:d.isFetchingNextPage,onClick:()=>void d.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,J.jsxs)(R,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(I,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:Nn.map(e=>(0,J.jsxs)(P,{value:String(e),children:[e,` min`]},e))})]})]}),e&&m?(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`legend`,{children:`Tracker access`}),e.access?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{children:`Fresh issue details and accessible comments are read by cezar. Attachments and custom fields are not included. Tokens stay with cezar.`}),[`comment`,`transition`].map(t=>(0,J.jsxs)(`label`,{className:`flex gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.access.writes.includes(t),onChange:r=>n({trackerTrigger:{...e,access:{version:1,writes:r.target.checked?[...e.access.writes,t]:e.access.writes.filter(e=>e!==t)}}})}),`Allow agent to `,t===`comment`?`post comments`:`change status`,` on this issue without further approval`]},t))]}):(0,J.jsxs)(`div`,{role:`alert`,children:[`This automation previously gave its agent a tracker token. Review the prompt: only reading this issue, comments and status transitions are now supported. Other operations need a revised workflow.`,(0,J.jsx)(N,{type:`button`,variant:`outline`,onClick:()=>n({trackerTrigger:{...e,access:{version:1,writes:[]}}}),children:`Confirm migration to read-only access`})]})]}):null,(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Only events after enabling are eligible. Existing backlog is not launched. Use a token with minimal read permissions; grant provider write permissions only for selected write actions.`})]})}function or(e){return g({status:e})}function sr(e,t=!0){return e.kind===`github`&&!t?{tone:`neutral`,pulse:!1,label:`paused by capability`}:e.enabled?e.kind===`schedule`?{tone:`success`,pulse:!1,label:`enabled`}:{tone:`pending`,pulse:!0,label:`enabled`}:{tone:`neutral`,pulse:!1,label:`paused`}}function cr(e){return e===`scheduled`?{tone:`success`,pulse:!1,label:`Scheduler running`}:{tone:`neutral`,pulse:!1,label:`Scheduler idle`}}function lr({definition:e}){let t=nn(e),n=(0,q.useMemo)(()=>vn(e),[e]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`Copy as CLI`}),(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void en(n,t?rn:void 0),children:[(0,J.jsx)(Ke,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-meta leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:n}),(0,J.jsx)(`p`,{className:`mt-2 mb-0 text-meta leading-[1.5] text-soft-foreground`,children:t?rn:(0,J.jsxs)(J.Fragment,{children:[`The same definition the cockpit saves — `,(0,J.jsx)(`code`,{className:`text-meta`,children:`cez automation schema`}),` prints its shape.`]})})]})}function ur({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=Pn.includes(n)?Pn:[...Pn,n].sort((e,t)=>e-t);return(0,J.jsxs)(`div`,{"data-slot":`editor-dispatch`,"data-enabled":t?`true`:void 0,className:`flex flex-wrap items-center gap-2.5 border-t border-border pt-3 text-ui text-muted-foreground`,children:[(0,J.jsxs)(rt,{className:`text-ui font-medium text-foreground`,children:[(0,J.jsx)(et,{"aria-hidden":`true`,className:A(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,J.jsx)(it,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i(e?{dispatch:!0}:{dispatch:!1,reviewChild:!1})})]}),t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,J.jsxs)(R,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:a.map(e=>(0,J.jsx)(P,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(rt,{className:`text-ui font-normal text-muted-foreground`,children:[(0,J.jsx)(it,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,J.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-meta whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null,(0,J.jsxs)(`p`,{"data-slot":`editor-dispatch-why`,className:`m-0 basis-full text-label text-muted-foreground`,children:[`Lets the run start its own subtasks with `,(0,J.jsx)(`code`,{className:`text-label`,children:`cez task create`}),`, each in a worktree forked off its branch, reporting back into the parent session.`]})]})}var dr={"pull_request.opened":`A pull request opens`,"issue.opened":`An issue opens`,"issue.labeled":`An issue gets a label`,"issue.unlabeled":`An issue loses a label`,"pull_request.reviewed":`A review is submitted`,"pull_request.review_requested":`A review is requested`,"pull_request.rereview_requested":`A re-review is requested`,"pull_request.closed":`A pull request closes`,"pull_request.merged":`A pull request merges`};function fr({events:e,intervalSeconds:t,filters:n,onChange:r}){let i=[`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].filter(e=>n[e].trim().length>0),[a,o]=(0,q.useState)(i.length>0||n.lookbackDays!==7||n.maxRecords!==25),s=(e,t)=>r({filters:{...n,[e]:t}}),c=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:On.filter(e=>n.includes(e))})},l=rr(e),u=l&&n.changedLabels.trim().length===0;return(0,J.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:On.map(t=>(0,J.jsxs)(K,{active:e.includes(t),"aria-pressed":e.includes(t),"aria-label":t,className:`h-8 gap-2 px-3`,onClick:()=>c(t),children:[dr[t],(0,J.jsx)(`span`,{className:`font-mono text-micro font-normal text-soft-foreground`,children:t})]},t))}),e.length===0?(0,J.jsx)(`p`,{className:`m-0 text-label text-danger`,children:`Pick at least one event.`}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-ui text-muted-foreground`,children:[`Checks GitHub every`,(0,J.jsxs)(R,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Poll interval`,className:`text-ui`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:Nn.map(e=>(0,J.jsxs)(P,{value:String(e),children:[e,` min`]},e))})]}),(0,J.jsxs)(`span`,{children:[`while this cockpit is open, looking back `,n.lookbackDays,` days, at most `,n.maxRecords,` records.`]})]}),(0,J.jsxs)(`p`,{"data-slot":`editor-github-how`,className:`-mt-2 m-0 text-label text-soft-foreground`,children:[`Through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL needed.`]}),(0,J.jsxs)(kt,{open:a,onOpenChange:o,children:[(0,J.jsx)(Ot,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-ui text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(Be,{"aria-hidden":`true`,className:A(`size-3 transition-transform`,a?``:`-rotate-90`)}),`Filters`,u?(0,J.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):i.length>0?(0,J.jsxs)(`span`,{className:`text-soft-foreground`,children:[`· `,i.length,` set`]}):(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`· authors, labels, reviewers`})]})}),(0,J.jsxs)(Dt,{children:[(0,J.jsx)(`p`,{className:`m-0 pt-2 text-label text-soft-foreground`,children:`Only matching events start a task. Names in the prompt do not narrow it down; these do.`}),(0,J.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-3 sm:grid-cols-2`,children:[(0,J.jsx)(X,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>s(`authors`,e)}),(0,J.jsx)(X,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>s(`assignees`,e)}),(0,J.jsx)(X,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>s(`anyLabels`,e)}),(0,J.jsx)(X,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>s(`allLabels`,e)}),(0,J.jsx)(X,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>s(`excludeLabels`,e)}),(0,J.jsx)(X,{id:`filter-changed-labels`,label:l?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:u,onChange:e=>s(`changedLabels`,e)}),(0,J.jsx)(X,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>s(`reviewers`,e)}),(0,J.jsx)(pr,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>s(`lookbackDays`,e)}),(0,J.jsx)(pr,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>s(`maxRecords`,e)})]})]})]})]})}function X({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(rt,{htmlFor:e,className:`text-label text-muted-foreground`,children:t}),(0,J.jsx)(W,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-ui`})]})}function pr({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{id:`${e}-label`,className:`text-label text-muted-foreground`,children:t}),(0,J.jsx)(hn,{"data-slot":e,"aria-label":t,value:n,min:r,max:i,onCommit:e=>{e!==null&&a(e)}})]})}function mr({source:e,sourcesReady:t,skills:n,skillUsage:r,workflows:i,onSource:a,pick:o,onPick:s,baseBranch:c,autonomous:l,onAutonomous:u}){return(0,J.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(bn,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,J.jsx)(mn,{pick:o,onChange:s,accounts:!0}),(0,J.jsx)(Zt,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,J.jsxs)(`span`,{className:`text-meta`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(rt,{className:`text-ui font-medium`,children:[`Autonomous`,(0,J.jsx)(it,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function hr({className:e,...t}){return(0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:A(`inline-flex h-5 items-center rounded-full bg-muted px-2 font-mono text-ui font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var gr=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`],[`once`,`Once`]],_r=e=>String(e).padStart(2,`0`);function vr(e){let t=Date.now()+864e5,n=O(t,e);return n?`${n.year}-${_r(n.month)}-${_r(n.day)}`:new Date(t).toISOString().slice(0,10)}function yr({schedule:e,timeZone:t,onChange:n,allowOnce:r=!0}){let i=ae(e),a=e=>{let{date:r,...a}=i,o={...a,...r?{date:r}:{},...e};o.type===`once`&&!o.date&&(o.date=vr(t)),n(o)},o=i.type===`once`&&i.date!==null&&ce({type:`once`,date:i.date,hour:i.hour,minute:i.minute},Date.now(),t)===null;return(0,J.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:gr.filter(([e])=>r||e!==`once`).map(([e,t])=>(0,J.jsx)(K,{active:i.type===e,"aria-pressed":i.type===e,onClick:()=>a({type:e}),children:t},e))}),i.type===`weekly`?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:E.map((e,t)=>(0,J.jsx)(K,{active:i.day===t+1,"aria-pressed":i.day===t+1,className:`px-[9px]`,onClick:()=>a({day:t+1}),children:e},e))}):null,i.type===`once`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`on`,(0,J.jsx)(W,{type:`date`,"aria-label":`Date`,value:i.date??``,onChange:e=>{e.target.value&&a({date:e.target.value})},className:`w-40 font-mono`})]}):null,i.type===`hours`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`every`,(0,J.jsxs)(R,{value:String(i.every),onValueChange:e=>{let t=Number(e);ir(t)&&a({every:t})},children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Every N hours`,className:`text-ui`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:ue.map(e=>(0,J.jsxs)(P,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`at`,(0,J.jsx)(W,{"aria-label":`Hour`,inputMode:`numeric`,value:_r(i.hour),onChange:e=>a({hour:Math.min(23,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),`:`,(0,J.jsx)(W,{"aria-label":`Minute`,inputMode:`numeric`,value:_r(i.minute),onChange:e=>a({minute:Math.min(59,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),(0,J.jsx)(`span`,{className:`text-label`,children:t})]}),i.type===`once`?(0,J.jsx)(`p`,{"data-slot":`editor-once-note`,className:`m-0 text-label ${o?`text-danger`:`text-muted-foreground`}`,children:o?`This time has passed — pick a later one to enable it.`:`Runs a single time, then pauses itself.`}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 text-label text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cron`}),(0,J.jsx)(hr,{"data-slot":`editor-cron`,children:re(e)})]})]})}var br={schedule:[`{{date}}`,`{{project}}`],github:[`{{github.url}}`,`{{github.title}}`,`{{github.number}}`,`{{github.author}}`,`{{github.labels}}`,`{{date}}`,`{{project}}`],tracker:[`{{tracker.key}}`,`{{tracker.title}}`,`{{tracker.url}}`,`{{tracker.status}}`,`{{date}}`,`{{project}}`]};function xr(e){return Oe({kind:e.kind,events:e.events,intervalSeconds:e.intervalSeconds,schedule:e.schedule,...e.trackerTrigger?{trackerTrigger:e.trackerTrigger}:{}})}function Sr(e,t){let n=xr(e),r=jn(e),i=[`${r?`${r.source===`skill`?`skill`:`workflow`} ${r.ref}`:`a quick task`} on ${e.runner??`the default agent`}${e.model?` (${e.model})`:``}`];return i.push(e.autonomous?`autonomous`:`pausing when it needs you`),t&&e.dispatch&&i.push(`up to ${e.maxSubtasks} subtasks`),`${n.charAt(0).toUpperCase()+n.slice(1)}: ${i.join(`, `)}.`}function Cr(e,t){return e.kind===`schedule`?!0:e.kind===`tracker`?t:e.events.length>0&&(!rr(e.events)||e.filters.changedLabels.trim().length>0)}function wr(e,t){let n=[Cr(e,t),e.prompt.trim().length>0,e.name.trim().length>0],r=n.indexOf(!1);return[{id:`when`,label:`When`},{id:`what`,label:`What`},{id:`live`,label:`Go live`}].map((e,t)=>({...e,state:n[t]&&(r===-1||t<r)?`done`:t===r||r===-1&&t===2?`current`:`next`}))}var Tr=[{value:`post-result`,label:`Every result`},{value:`notify-on-failure`,label:`Failures only`},{value:`none`,label:`Nothing`}];function Er({report:e,managers:t,busy:n=!1,onChange:r}){if(!e&&!t?.length)return null;let i=e?t?.find(t=>t.id===e.managerId):void 0;return(0,J.jsxs)(M,{flush:!0,"data-slot":`manager-report-card`,className:`min-w-0 px-3.5 py-3`,children:[(0,J.jsx)(`h2`,{className:`m-0 mb-2 text-meta font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Reports to`}),e?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`m-0 flex items-center gap-1.5 text-ui font-medium text-foreground`,children:[(0,J.jsx)(Cn,{"aria-hidden":`true`,className:`size-3.5 text-violet`}),(0,J.jsx)(`span`,{className:`truncate`,children:i?.name??`A manager no longer listed`})]}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,J.jsxs)(R,{value:e.mode,disabled:n,onValueChange:t=>r({managerId:e.managerId,mode:t}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`What to post`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:Tr.map(e=>(0,J.jsx)(P,{value:e.value,children:e.label},e.value))})]}),(0,J.jsx)(N,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>r(null),children:`Unlink`})]}),(0,J.jsx)(`p`,{className:`m-0 mt-2 text-meta text-muted-foreground`,children:e.mode===`post-result`?`Each finished run’s last message is posted to its chat; a failure is marked important.`:e.mode===`notify-on-failure`?`Only a failed run is posted, marked important.`:`Linked, but nothing is posted.`})]}):(0,J.jsxs)(R,{value:``,disabled:n,onValueChange:e=>r({managerId:e,mode:`post-result`}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Report to a manager`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(L,{placeholder:`Post results to a manager…`})}),(0,J.jsx)(F,{children:t?.map(e=>(0,J.jsx)(P,{value:e.id,children:e.name},e.id))})]})]})}function Dr({automationId:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){let a=ee(),o=k(),s=(0,q.useMemo)(()=>[o,`automation-log`,e],[o,e]),c=w({queryKey:s,queryFn:({signal:t})=>_(e,{signal:t})}),u=(0,q.useMemo)(()=>Or(c.data?.records??[]),[c.data?.records]),d=l((0,q.useMemo)(()=>{let e=new Set(u.map(e=>e.runId));return t=>t.filter(t=>e.has(t.id)).map(({id:e,title:t,status:n,costUsd:r})=>({id:e,title:t,status:n,costUsd:r}))},[u]));return(0,q.useEffect)(()=>he((t,n)=>{if(t!==`automation-change`)return;let r=n;r?.automationId===e&&(o==="default"||r.project===void 0||r.project===o)&&a.invalidateQueries({queryKey:s})}),[e,o,a,s]),(0,J.jsxs)(M,{flush:!0,"data-slot":`recent-runs-card`,className:`min-w-0 px-3.5 py-3`,children:[(0,J.jsx)(`h2`,{className:`m-0 mb-2 eyebrow text-soft-foreground`,children:`Recent runs`}),c.isPending?(0,J.jsx)(`p`,{role:`status`,className:`m-0 text-label text-muted-foreground`,children:`Loading recent runs…`}):null,c.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`text-label text-muted-foreground`,children:[(0,J.jsx)(`p`,{className:`m-0`,children:c.data?`Could not refresh recent runs.`:`Could not load recent runs.`}),(0,J.jsx)(N,{variant:`ghost`,size:`sm`,disabled:c.isFetching,onClick:()=>void c.refetch(),children:`Retry`})]}):null,c.data&&u.length===0?(0,J.jsx)(`p`,{className:`m-0 text-label text-muted-foreground`,children:`No runs launched yet.`}):null,u.length>0?(0,J.jsx)(`ul`,{"aria-label":`Recent runs`,className:`m-0 list-none divide-y divide-border p-0`,children:u.map(e=>{let t=d.data?.find(t=>t.id===e.runId)??c.data?.runs[e.runId],n=t?.title||`Task ${e.runId.slice(0,8)}`,r=t?or(t.status):void 0;return(0,J.jsxs)(`li`,{className:`min-w-0 py-2 first:pt-0 last:pb-0`,children:[(0,J.jsx)(H,{to:`/tasks/${encodeURIComponent(e.runId)}`,className:`block truncate rounded-sm text-ui font-medium hover:underline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,children:n}),(0,J.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-label text-muted-foreground`,children:[(0,J.jsx)(G,{"aria-hidden":`true`,tone:r?.tone??`neutral`,pulse:r?.pulse??!1}),(0,J.jsx)(`span`,{children:r?r.label:`Status unavailable`}),(0,J.jsx)(`time`,{dateTime:e.ts,children:qt(e.ts,i)}),null]})]},e.runId)})}):null,(0,J.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap gap-1.5`,children:[t?(0,J.jsxs)(N,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,J.jsx)(lt,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}):null,n?(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,J.jsx)(En,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}function Or(e){let t=new Set;return[...e].sort((e,t)=>t.seq-e.seq).filter(e=>!e.runId||t.has(e.runId)?!1:(t.add(e.runId),!0)).slice(0,5)}var kr=864e5;function Ar({kind:e,schedule:t,schedules:n,intervalSeconds:r,timeZone:i,now:a}){let[o,s]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>{if(a!==void 0)return;let e=setInterval(()=>s(Date.now()),6e4);return()=>clearInterval(e)},[a]);let c=a??o,l=(0,q.useMemo)(()=>{if(e!==`schedule`)return[];if(t.type===`once`){let e=ne({schedule:t,schedules:n},c,i);return e===null?[]:[e]}return ie({schedule:t,schedules:n},c,c+9*kr,i,5)},[e,t,n,c,i]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:e===`schedule`?t.type===`once`?`Runs once`:`Next 5 runs`:`How it polls`}),e===`schedule`?l.length===0?(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:t.type===`once`?`This time has already passed.`:`Nothing in the next nine days.`}):l.map(e=>(0,J.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-ui`,children:[(0,J.jsx)(`span`,{className:`w-[82px] shrink-0 text-label font-medium whitespace-nowrap text-foreground tabular-nums`,children:Pe(e,i)}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:De(e,c)})]},e)):(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,J.jsxs)(J.Fragment,{children:[`Checks the project tracker every `,Math.round(r/60),` min while this cockpit is open. No webhook or public URL required.`]}):(0,J.jsxs)(J.Fragment,{children:[`Checks GitHub every `,Math.round(r/60),` min while this cockpit is open, through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var jr=[{name:`Nightly dependency bump`,when:`Every day at 04:00`,kind:`schedule`,schedule:{type:`daily`,hour:4,minute:0},prompt:`Run npm outdated, bump patch and minor versions, run the test suite, open a draft PR if anything changed.`},{name:`Triage new issues`,when:`On issue.opened · every 5 min`,kind:`github`,events:[`issue.opened`],intervalSeconds:300,prompt:`Read {{github.url}}. Label it, add a repro or a clarification request. Never close it.`},{name:`Weekly changelog draft`,when:`Fridays at 16:00`,kind:`schedule`,schedule:{type:`weekly`,day:5,hour:16,minute:0},prompt:`Collect merged PRs since last week, write CHANGELOG entries, open a draft PR.`},{name:`Stale PR nudge`,when:`Every 6 hours`,kind:`schedule`,schedule:{type:`hours`,every:6},prompt:`Comment on PRs idle for 48h with what is blocking them.`},{name:`Flaky test hunt`,when:`Tuesdays at 02:00`,kind:`schedule`,schedule:{type:`weekly`,day:2,hour:2,minute:0},prompt:`Run the suite 5×, quarantine intermittent tests, open an issue per test.`,dispatch:{maxSubtasks:8,reviewChild:!0}},{name:`Security advisories`,when:`Every day at 06:00`,kind:`schedule`,schedule:{type:`daily`,hour:6,minute:0},prompt:`Run npm audit; for each high/critical advisory open a task with the upgrade path.`}],Mr=e=>[k(),`automation-templates`,e??``];function Nr({onPick:e}){let[t,n]=(0,q.useState)(`builtin`),r=ht(),a=w({queryKey:Mr(r),queryFn:({signal:e})=>i(r,{signal:e}),enabled:t===`mine`}),o=t===`builtin`?jr.map(e=>({...e,key:e.name})):(a.data?.templates??[]).map(e=>({...Vn(e),key:`${e.project.id}:${e.id}`,when:Oe(e),project:e.project.name}));return(0,J.jsxs)(M,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,J.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,J.jsx)(Pr,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,J.jsx)(Pr,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,J.jsx)(`span`,{className:`ml-auto min-w-0 overflow-hidden pb-2 text-label text-ellipsis whitespace-nowrap text-muted-foreground`,children:t===`builtin`?`Built-in`:`Registered in ~/.cezar/config.json`})]}),t===`mine`&&a.isPending?(0,J.jsx)(Gt,{label:`Loading automations…`,className:`px-4 pt-3`,children:(0,J.jsx)(Wt,{rows:3})}):t===`mine`&&a.isError?(0,J.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-label text-danger`,children:a.error.message}):o.length===0?(0,J.jsx)(`p`,{className:`px-4 pt-3 text-label text-muted-foreground`,children:`No automations in your other projects yet.`}):(0,J.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:o.map(t=>(0,J.jsxs)(`div`,{"data-slot":`template-card`,className:`flex flex-col gap-1.5 rounded-[10px] border border-border bg-card-2 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui font-semibold`,children:[t.kind===`github`?(0,J.jsx)(B,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,J.jsx)(_n,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,J.jsx)(hr,{className:`ml-auto`,children:t.project}):null]}),(0,J.jsx)(`div`,{className:`text-meta text-muted-foreground`,children:t.when}),(0,J.jsx)(`div`,{className:`line-clamp-2 text-label leading-[1.45] text-muted-foreground`,children:t.prompt}),(0,J.jsx)(N,{variant:`outline`,size:`sm`,className:`mt-0.5 self-start`,"aria-label":`Use this: ${t.name}`,onClick:()=>e(t),children:`Use this`})]},t.key))})]})}function Pr({active:e,onClick:t,children:n}){return(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:A(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-ui font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function Fr(e){let t=e.toLowerCase();return/\b(events?|filters?|schedule|interval|changedlabels|changed labels|lookback|maxrecords)\b/.test(t)?`when`:/\b(prompt|workflow|runner|model|dispatch)\b/.test(t)?`what`:`top`}var Ir={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`What should the agent do each time? Say it the way you would in New task.`,github:`What should the agent do for each match? Say it the way you would in New task.`};function Lr({data:e,automation:t,actions:n,initialKind:r,onBack:i,onSaved:a,onLog:o}){let s=ee(),l=V(),u=c(),p=C(),m=x(),g=d(),_=te(),v=r===`github`&&e?.available===!1?`schedule`:r,[b,w]=(0,q.useState)(()=>t?Bn(t):v?{...Ln(),kind:v,...v===`tracker`?{intervalSeconds:1800,enabled:!1}:{}}:Ln()),[T,E]=(0,q.useState)(!t&&!v),[ne,re]=(0,q.useState)(!1),[ie,ae]=(0,q.useState)(!1),[D,oe]=(0,q.useState)(null),[se,ce]=(0,q.useState)(!1),O=(0,q.useRef)(null),le=t?.revision,k=(0,q.useRef)(le);(0,q.useEffect)(()=>{!t||le===k.current||(k.current=le,w(Bn(t)),ce(!1),oe(null))},[t,le]);let A=e=>w(t=>({...t,...e})),ue=e?.timeZone??`UTC`,de=e?.available!==!1,fe=u.data?.capabilities.dispatch===!0,pe=(0,q.useMemo)(()=>ot(st(p.data?.promptTemplates),u.data?.capabilities),[p.data?.promptTemplates,u.data?.capabilities]),he=m.data?.workflows??[],ge=he.map(e=>e.name),_e=g.data,ve=(_e??[]).map(e=>e.name),ye=p.data?.skillUsage,be=(0,q.useMemo)(()=>at(_e??[],ye),[_e,ye]),xe=g.data!==void 0&&m.data!==void 0&&!p.isPending,j=_.data?.baseBranch??_.data?.info?.branch??void 0,Se=(0,q.useMemo)(()=>qn(b),[b]),we=(0,q.useMemo)(()=>nr(b),[b]),Te=e=>we.filter(t=>t.field===e).map(e=>e.login),Ee=b.name.trim().length>0&&b.prompt.trim().length>0&&!ie&&(b.kind!==`tracker`||ne),De=wr(b,ne),Oe=Sr(b,fe),ke=e=>{let t=O.current,n=t?.selectionStart??b.prompt.length,r=ct(b.prompt,n,e);A({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},Ae=e=>{let t=O.current,n=t?.selectionStart??b.prompt.length,r=b.prompt.slice(0,n),i=b.prompt.slice(n),a=r.length>0&&!/\s$/.test(r)?` `:``,o=`${r}${a}${e}${i.length>0&&!/^\s/.test(i)?` `:``}${i}`,s=r.length+a.length+e.length;A({prompt:o}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(s,s))})},je=async()=>{ae(!0),oe(null),ce(!1);try{let e=Gn(b);t?await y(t.id,{...e,enabled:b.enabled,expectedRevision:t.revision}):await h({...e,enable:b.enabled}),await s.invalidateQueries({queryKey:dn()}),a()}catch(e){if(t&&e instanceof S&&e.status===409)ce(!0);else{let t=e instanceof Error?e.message:String(e);oe({message:t,section:e instanceof S&&e.status===400?Fr(t):`top`})}}finally{ae(!1)}},Me=()=>void s.invalidateQueries({queryKey:dn()}),Ne=u.data?.capabilities.managers===!0,Pe=me(Ne&&!!t),[Fe,Ie]=(0,q.useState)(!1),[M,Le]=(0,q.useState)(null),Re=async e=>{if(t){Ie(!0),Le(null);try{await f(t.id,e),await s.invalidateQueries({queryKey:dn()})}catch(e){Le(e instanceof Error?e.message:String(e))}finally{Ie(!1)}}},ze=t?`Save changes`:b.enabled?`Save and enable`:`Save paused`,Be=`Change the kind by creating a new automation`,P=!!t,F=e=>{e!==b.kind&&A({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})};return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,"data-onboarding":``,className:`flex min-h-full flex-col`,children:[(0,J.jsxs)(`header`,{className:`sticky top-0 z-10 flex min-h-14 shrink-0 flex-wrap items-center gap-3 border-b border-border bg-background px-5 max-md:py-2 md:h-14 md:flex-nowrap`,children:[(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:i,children:(0,J.jsx)(Ce,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,J.jsx)(Jt,{dot:sr(t,de).tone,pulse:sr(t,de).pulse,children:sr(t,de).label}):null,(0,J.jsx)(`span`,{className:`flex-1`}),t?null:(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,"aria-expanded":T,"aria-label":T?`Hide templates`:`Start from a template`,onClick:()=>E(e=>!e),children:[(0,J.jsx)(xn,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`max-md:hidden`,children:T?`Hide templates`:`Start from a template`})]}),(0,J.jsx)(N,{variant:`outline`,className:`font-normal`,onClick:i,children:`Cancel`}),(0,J.jsx)(N,{className:`font-normal`,disabled:!Ee,onClick:()=>void je(),children:ze})]}),(0,J.jsx)(`div`,{className:`flex justify-center px-5 pb-16`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-3xl flex-col items-center`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-strip`,className:`sticky top-14 z-10 flex w-full flex-wrap items-center gap-x-6 gap-y-1.5 border-b border-border bg-background/95 py-2.5 backdrop-blur max-md:static`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 max-md:basis-full`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-ui text-muted-foreground`,"aria-hidden":`true`,children:`Name`}),(0,J.jsx)(W,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:b.name,onChange:e=>A({name:e.target.value}),className:`h-9 w-full max-w-md text-lead md:text-lead`})]}),(0,J.jsx)(cn,{steps:De})]}),se||D?.section===`top`||T&&!t?(0,J.jsxs)(`div`,{className:`mt-6 flex w-full flex-col gap-4`,children:[se?(0,J.jsxs)(`div`,{role:`alert`,"data-slot":`editor-conflict`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-ui text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,J.jsx)(N,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:Me,children:`Reload`})]}):null,D?.section===`top`?(0,J.jsx)(Br,{children:D.message}):null,T&&!t?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`p`,{className:`m-0 text-center text-ui text-muted-foreground`,children:`Start from a template, or fill in the three parts below.`}),(0,J.jsx)(Nr,{onPick:e=>{let t=e.workflow&&ge.includes(e.workflow)?e.workflow:void 0,n=e.steps?.every(e=>!e.skill||ve.includes(e.skill))?e.steps:void 0;w(r=>Un(r,{...e,workflow:t,steps:n})),E(!1)}})]}):null]}):null,(0,J.jsxs)(zr,{slot:`when`,title:`When`,why:P?`The trigger is fixed once saved; change it by creating a new automation.`:`What starts a run. Pick one, then say how often or on which change.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`grid gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(tn,{value:`schedule`,title:`On a schedule`,description:`At a time you set.`,selected:b.kind===`schedule`,disabled:P&&b.kind!==`schedule`,reason:P&&b.kind!==`schedule`?Be:void 0,onClick:()=>F(`schedule`),picture:(0,J.jsx)(Vr,{})}),(0,J.jsx)(tn,{value:`github`,title:`When GitHub changes`,description:`A pull request, an issue, a review.`,selected:b.kind===`github`,disabled:!de||P&&b.kind!==`github`,reason:de?P&&b.kind!==`github`?Be:void 0:e?.reason??`GitHub is unavailable`,onClick:()=>F(`github`),picture:(0,J.jsx)(B,{className:`size-7 text-muted-foreground`,"aria-hidden":!0})}),(0,J.jsx)(tn,{value:`tracker`,title:`When Jira / Linear changes`,description:`An issue is created or moves.`,selected:b.kind===`tracker`,disabled:P&&b.kind!==`tracker`,reason:P&&b.kind!==`tracker`?Be:void 0,onClick:()=>F(`tracker`),picture:(0,J.jsx)(Hr,{})})]}),(0,J.jsx)(`div`,{className:`mt-5`,children:b.kind===`schedule`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[[b.schedule,...b.schedules?.slice(1)??[]].map((e,t,n)=>(0,J.jsxs)(`fieldset`,{className:`min-w-0 rounded-md border p-3`,children:[(0,J.jsxs)(`legend`,{className:`px-1 text-label text-muted-foreground`,children:[`Schedule `,t+1]}),(0,J.jsx)(yr,{schedule:e,timeZone:ue,allowOnce:n.length===1,onChange:e=>{let r=n.map((n,r)=>r===t?e:n),i=r[0];i&&A({schedule:i,schedules:r.length>1?r:void 0})}}),n.length>1?(0,J.jsx)(N,{variant:`ghost`,size:`sm`,"aria-label":`Remove schedule ${t+1}`,onClick:()=>{let e=n.filter((e,n)=>n!==t),r=e[0];r&&A({schedule:r,schedules:e.length>1?e:void 0})},children:`Remove schedule`}):null]},t)),(0,J.jsx)(N,{variant:`outline`,size:`sm`,disabled:(b.schedules?.length??1)>=16||b.schedule.type===`once`,onClick:()=>A({schedules:[b.schedule,...b.schedules?.slice(1)??[],{type:`daily`,hour:4,minute:0}]}),children:`Add schedule`}),(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Times that coincide start one task. One-time schedules run on their own.`})]}):b.kind===`tracker`?(0,J.jsx)(ar,{trigger:b.trackerTrigger,intervalSeconds:b.intervalSeconds,onChange:A,onValid:re}):(0,J.jsx)(fr,{events:b.events,intervalSeconds:b.intervalSeconds,filters:b.filters,onChange:e=>A(e)})}),b.kind===`schedule`?(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(Ar,{kind:b.kind,schedule:b.schedule,schedules:b.schedules,intervalSeconds:b.intervalSeconds,timeZone:ue})}):null,D?.section===`when`?(0,J.jsx)(Br,{children:D.message}):null]}),(0,J.jsxs)(zr,{slot:`what`,title:`What the agent does`,why:`The same words you would type into New task. Placeholders fill in per run.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-placeholders`,className:`flex flex-wrap items-center gap-1.5 text-label text-muted-foreground`,children:[`Insert`,br[b.kind].map(e=>(0,J.jsx)(K,{className:`h-6 font-mono text-meta`,onClick:()=>Ae(e),children:e},e))]}),(0,J.jsx)(pt,{ref:O,"aria-label":`Prompt`,rows:5,placeholder:Ir[b.kind],value:b.prompt,onChange:e=>A({prompt:e.target.value}),className:`mt-3 min-h-[120px] rounded-xl px-4 py-3 text-lead leading-[1.55] md:text-lead`}),(0,J.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-label text-muted-foreground`,children:[(0,J.jsx)(Qe,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,pe.map(e=>(0,J.jsx)(U,{label:Rr(e.text),children:(0,J.jsx)(K,{className:`h-6 text-meta`,onClick:()=>ke(e.text),children:e.label})},e.id)),(0,J.jsx)(K,{dashed:!0,className:`h-6 text-meta`,icon:(0,J.jsx)(tt,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>l(`${yn(`project`,`instructions`)}#prompt-templates`),children:`Manage…`})]}),we.length>0?(0,J.jsxs)(`div`,{role:`status`,"data-slot":`editor-prompt-condition`,className:`mt-3 flex flex-wrap items-center gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-label text-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`The prompt names `,we.map(({login:e})=>`@${e}`).join(`, `),`, but prompt text does not decide what launches — without a filter every matching event starts a task.`]}),[`authors`,`reviewers`].map(e=>Te(e).length>0?(0,J.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>A({filters:{...b.filters,[e]:[...Rn(b.filters[e]),...Te(e)].join(`, `)}}),children:e===`authors`?`Add to Authors`:`Add to Reviewers`},e):null)]}):null,(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(mr,{source:jn(b),sourcesReady:xe,skills:be,skillUsage:ye,workflows:he,onSource:e=>A(Mn(e)),pick:{runner:b.runner,model:b.model,reasoningEffort:b.reasoningEffort,account:b.account},onPick:e=>A({runner:e.runner,model:e.model,reasoningEffort:e.reasoningEffort??null,account:e.account}),baseBranch:j,autonomous:b.autonomous,onAutonomous:e=>A({autonomous:e})})}),(0,J.jsx)(`p`,{className:`mt-3 mb-0 text-label leading-[1.5] text-muted-foreground`,children:`Each run is an ordinary cezar task in its own worktree — it queues behind the parallel cap like anything else and never auto-merges.`}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(ur,{available:fe,enabled:b.dispatch,maxSubtasks:b.maxSubtasks,reviewChild:b.reviewChild,onChange:e=>A(e)})}),D?.section===`what`?(0,J.jsx)(Br,{children:D.message}):null]}),(0,J.jsxs)(zr,{slot:`live`,title:`Go live`,why:`Paused, it waits in the list where you can preview it. Enabled, it starts counting from now.`,children:[(0,J.jsx)(`p`,{"data-slot":`editor-summary`,className:`m-0 rounded-xl border border-violet/40 bg-violet/10 px-4 py-3 text-body text-foreground`,children:Oe}),(0,J.jsxs)(rt,{className:`mt-4 flex items-start gap-3 text-ui font-normal`,children:[(0,J.jsx)(it,{"aria-label":`Enabled`,checked:b.enabled,onCheckedChange:e=>A({enabled:e}),className:`mt-0.5`}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-body text-foreground`,children:`Enabled`}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:b.kind===`schedule`?b.enabled?`Runs at the next time listed above.`:`Saved paused. Enable it from the list, or Run now to try it once.`:`Counts from a current-time baseline; existing matches will not launch.`})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3`,children:[(0,J.jsx)(lr,{definition:Se}),t&&t.kind!==`schedule`&&n?(0,J.jsx)(N,{variant:`outline`,className:`self-start font-normal`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t&&(Ne||t.report)?(0,J.jsx)(Er,{report:t.report,managers:Pe.data?.managers,busy:Fe,onChange:e=>void Re(e)}):null,M?(0,J.jsx)(Br,{children:M}):null,t?(0,J.jsx)(Dr,{automationId:t.id,busy:n?.busy,onRunNow:n?()=>void n.runNow(t):void 0,onLog:o}):null]})]})]})})]})}function Rr(e){let t=e.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$i as r,$r as i,Ai as a,Da as o,Do as s,F as c,It as l,Jr as u,Kt as d,La as f,Mi as p,Oo as m,Pr as h,Qn as g,Qr as _,Ri as v,Ya as y,ca as b,cn as x,hr as S,in as C,jo as ee,ko as w,pt as te,r as T}from"./queries-Dy1pV6Rm.js";import{B as E,G as ne,H as re,J as ie,K as ae,U as D,Ut as oe,V as se,W as ce,X as O,Z as le,c as k,t as A,z as ue}from"./utils-Mxa0e2-I.js";import{f as de,p as fe}from"./chunk-KS7C4IRE-DtL2Gzw3.js";import{t as pe}from"./use-now-BpFsrkTr.js";import{T as me}from"./managers-BwT6DK--.js";import{i as he,t as ge}from"./segmented-Bt_z4Y5J.js";import{a as _e,i as ve,o as ye,r as be,t as xe}from"./sheet-V0-7oBDu.js";import{t as j}from"./createLucideIcon-BHp8sXmF.js";import{t as Se}from"./arrow-down-NfQPLFhe.js";import{t as Ce}from"./arrow-left-BfRd_mrv.js";import{d as we}from"./reference-chip-C2e5zgtn.js";import{t as Te}from"./arrow-up-CssRwnnv.js";import{A as Ee}from"./run-actions-D6ciV-B7.js";import{a as De,c as Oe,d as ke,i as Ae,l as je,n as Me,o as Ne,r as Pe,s as Fe,t as Ie,u as M}from"./automation-format-BVa8GfLP.js";import{n as Le,t as N,z as Re}from"./button-DPW_5ujg.js";import{t as ze}from"./chevron-left-D0UFBpi5.js";import{r as Be}from"./dist-KgumXxNc.js";import{i as P,n as F,o as I,s as L,t as R}from"./select-CDNFJfBJ.js";import{t as Ve}from"./circle-question-mark-X2pmbDJg.js";import{c as He,i as z,p as Ue,r as We,t as Ge}from"./dropdown-menu-7_Jr7yCh.js";import{n as Ke,t as qe}from"./pencil-BWoe1EL-.js";import{L as Je,j as B}from"./manager-loading-DH44LYFR.js";import{t as Ye}from"./download-CfgyYHf7.js";import{n as Xe}from"./workflow-BEP63Wt4.js";import{_ as Ze}from"./impact-model-UkOCm8DL.js";import{t as Qe}from"./file-text-D2QdCz-z.js";import{t as $e}from"./upload-BE8GV7hh.js";import{n as et,t as tt}from"./settings-2-B8aEkWqd.js";import{u as nt}from"./worktree-lifecycle-operation-BboLqYup.js";import{n as rt,t as it}from"./switch-Bj2j4bg0.js";import{_ as at,a as ot,c as st,o as ct}from"./composer-CYI1vkuE.js";import{t as lt}from"./play-CmVAj_fu.js";import{t as ut}from"./plus-CxRU2X8C.js";import{t as dt}from"./terminal-CxnJmFUC.js";import{n as ft,t as pt}from"./textarea-C1UnTzWH.js";import{t as mt}from"./triangle-alert-CIzim6ZN.js";import{c as ht,l as V,t as H}from"./project-router-BM4IWQob.js";import{a as gt,c as _t,d as vt,f as yt,i as bt,l as xt,o as St,p as Ct,s as wt,t as Tt,u as Et}from"./sortable.esm-B7aanBL9.js";import{n as Dt,r as Ot,t as kt}from"./collapsible-D2PzOtFb.js";import{a as At,c as jt,i as Mt,n as Nt,o as Pt,r as Ft,s as It,t as Lt}from"./alert-dialog-CCN6Eo9S.js";import{t as U}from"./icon-tooltip-yJInZkjY.js";import{a as Rt,i as zt,n as Bt,o as Vt,r as Ht,t as Ut}from"./dialog-Cfqi9LM_.js";import{a as Wt,i as Gt}from"./loading-state-BcfD4D-3.js";import{t as W}from"./input-BbFy6kTc.js";import{r as Kt}from"./toaster-DfddV8rk.js";import{r as qt}from"./format-BUbPQpzw.js";import{t as G}from"./status-dot-ntyrUVQa.js";import{t as Jt}from"./pill-BnGDkiot.js";import{t as Yt}from"./centered-state-vm_lrdiA.js";import{t as K}from"./chip-C-AtTfag.js";import{v as Xt}from"./new-task-form-Bd0bjUVF.js";import{t as Zt}from"./picker-pill-inZ7-90v.js";import{F as Qt,G as $t,H as en,I as tn,J as nn,K as rn,L as an,M as on,N as sn,P as cn,R as ln,U as un,V as dn,W as fn,et as pn,f as mn,i as hn,j as gn,nt as _n,q as vn,r as yn,s as bn}from"./index-Dkgcny7F.js";var xn=j(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),Sn=j(`list-x`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`m15.5 9.5 5 5`,key:`ytk86i`}],[`path`,{d:`m20.5 9.5-5 5`,key:`17o44f`}]]),Cn=j(`message-square-share`,[[`path`,{d:`M12 3H4a2 2 0 0 0-2 2v16.286a.71.71 0 0 0 1.212.502l2.202-2.202A2 2 0 0 1 6.828 19H20a2 2 0 0 0 2-2v-4`,key:`11da1y`}],[`path`,{d:`M16 3h6v6`,key:`1bx56c`}],[`path`,{d:`m16 9 6-6`,key:`m4dnic`}]]),wn=j(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Tn=j(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),En=j(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),q=e(t(),1),J=n();function Dn({association:e,selected:t,onSelect:n,onRemove:r}){let i=s({queryKey:[`tracker`,k(),`label-suggestions`,e],initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>p({association:e,state:`all`,limit:50,cursor:t},{signal:n}),getNextPageParam:e=>e.available&&e.truncated?e.nextCursor:void 0,retry:!1,staleTime:6e4}),a=i.data?.pages??[],o=a.at(-1),c=a.find(e=>!e.available),l=i.isError||!!c,u=[...new Set([...t,...l?[]:a.flatMap(e=>e.available?e.items.flatMap(e=>e.labels):[])])].filter(e=>t.includes(e)||e.length>0&&e.length<=200).sort((e,t)=>e.localeCompare(t));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,"aria-label":`Project label suggestions`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`Required labels`}),(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`All selected labels must match. Leave unselected to allow any label.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Required labels`,className:`flex flex-wrap gap-1.5`,children:u.map(e=>(0,J.jsx)(K,{active:t.includes(e),"aria-pressed":t.includes(e),disabled:!t.includes(e)&&t.length>=100,onClick:()=>t.includes(e)?r(e):n(e),children:e},e))}),i.isFetching?(0,J.jsx)(`p`,{role:`status`,children:`Loading labels…`}):null,l?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsx)(`p`,{children:`Could not load labels. Your selection is preserved.`}),(0,J.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:`Retry label suggestions`})]}):(0,J.jsxs)(J.Fragment,{children:[!i.isPending&&!i.isFetching&&u.length===0?(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`No labels found in the loaded tasks.`}):null,i.hasNextPage?(0,J.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,disabled:i.isFetching,onClick:()=>void i.fetchNextPage(),children:`Load labels from more tasks`}):null,!i.hasNextPage&&o?.available&&o.truncated?(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`The provider returned a limited task list.`}):null]})]})}var On=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function kn(e){return[{id:`task`,name:e,skill:e,prompt:`{{task}}`}]}function An(e){let[t,...n]=e??[];return t&&n.length===0&&t.skill&&t.prompt===`{{task}}`?t.skill:null}function jn(e){return e.skill?{source:`skill`,ref:e.skill}:e.workflow&&e.workflow!==`quick-task`?{source:`workflow`,ref:e.workflow}:null}function Mn(e){return e?.source===`skill`?{skill:e.ref,workflow:Xt,customSteps:null}:{skill:null,workflow:e?.ref??`quick-task`,customSteps:null}}var Nn=[2,5,10,15,30,60],Pn=[1,2,4,6,8],Fn={authors:``,assignees:``,anyLabels:``,allLabels:``,excludeLabels:``,changedLabels:``,reviewers:``,lookbackDays:7,maxRecords:25},In={type:`daily`,hour:4,minute:0};function Ln(){return{name:``,kind:`schedule`,schedule:{...In},events:[`issue.opened`],intervalSeconds:300,filters:{...Fn},prompt:``,workflow:Xt,skill:null,customSteps:null,runner:null,account:null,model:null,reasoningEffort:null,autonomous:!0,dispatch:!1,maxSubtasks:4,reviewChild:!0,enabled:!1}}var Y=e=>(e??[]).join(`, `);function Rn(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function zn(e){return{authors:Y(e.authors),assignees:Y(e.assignees),anyLabels:Y(e.anyLabels),allLabels:Y(e.allLabels),excludeLabels:Y(e.excludeLabels),changedLabels:Y(e.changedLabels),reviewers:Y(e.reviewers),lookbackDays:e.lookbackDays,maxRecords:e.maxRecords}}function Bn(e){let t=Ln(),{task:n,filters:r}=e,i=An(n.steps);return{...t,name:e.name,kind:e.kind,trackerTrigger:e.trackerTrigger,schedule:e.schedule?{...e.schedule}:t.schedule,schedules:e.schedules?.map(e=>({...e})),events:e.events?.length?[...e.events]:t.events,intervalSeconds:e.intervalSeconds??t.intervalSeconds,filters:r?zn(r):t.filters,prompt:n.prompt,workflow:n.workflow??t.workflow,skill:i,customSteps:n.steps&&!i?n.steps:null,runner:n.runner??null,account:n.agentProfile??null,model:n.model??null,reasoningEffort:n.reasoningEffort??null,autonomous:n.autonomous??!1,dispatch:n.dispatch!==void 0,maxSubtasks:n.dispatch?.maxSubtasks??t.maxSubtasks,reviewChild:n.dispatch?.reviewChild??t.reviewChild,enabled:e.enabled,...n.checkout===void 0?{}:{checkout:n.checkout},...n.allowForkHeads===void 0?{}:{allowForkHeads:n.allowForkHeads}}}function Vn(e){return{name:e.name,kind:e.kind,...e.schedule?{schedule:e.schedule}:{},...e.schedules?{schedules:e.schedules}:{},...e.events?{events:e.events}:{},...e.intervalSeconds===void 0?{}:{intervalSeconds:e.intervalSeconds},...e.filters?{filters:e.filters}:{},prompt:e.task.prompt,...e.task.workflow?{workflow:e.task.workflow}:{},...e.task.steps?{steps:e.task.steps}:{},...e.task.runner?{runner:e.task.runner}:{},...e.task.model===void 0?{}:{model:e.task.model},...e.task.reasoningEffort?{reasoningEffort:e.task.reasoningEffort}:{},...e.task.autonomous===void 0?{}:{autonomous:e.task.autonomous},...e.task.dispatch?{dispatch:e.task.dispatch}:{},...e.task.checkout?{checkout:e.task.checkout}:{},...e.task.allowForkHeads===void 0?{}:{allowForkHeads:e.task.allowForkHeads}}}var Hn=e=>oe.safeParse(e).success;function Un(e,t){let n=An(t.steps);return{...e,name:t.name,kind:t.kind,schedule:t.schedule?{...t.schedule}:e.schedule,schedules:t.schedules?.map(e=>({...e})),events:t.events?.length?[...t.events]:e.events,intervalSeconds:t.intervalSeconds??e.intervalSeconds,filters:t.filters?zn(t.filters):{...Fn},prompt:t.prompt,...t.steps?{skill:n,customSteps:n?null:t.steps,workflow:Xt}:Mn(t.workflow?{source:`workflow`,ref:t.workflow}:null),checkout:t.checkout,allowForkHeads:t.allowForkHeads,runner:t.runner!==void 0&&Hn(t.runner)?t.runner:e.runner,account:t.runner!==void 0&&Hn(t.runner)?null:e.account,model:t.model??e.model,reasoningEffort:t.reasoningEffort??(t.runner!==void 0||t.model!==void 0?null:e.reasoningEffort),autonomous:t.autonomous??e.autonomous,dispatch:t.dispatch!==void 0,maxSubtasks:t.dispatch?.maxSubtasks??e.maxSubtasks,reviewChild:t.dispatch?.reviewChild??e.reviewChild}}function Wn(e){let t=ae(e);switch(t.type){case`hours`:return{type:`hours`,every:t.every};case`weekly`:return{type:`weekly`,hour:t.hour,minute:t.minute,day:t.day};case`once`:return{type:`once`,hour:t.hour,minute:t.minute,...t.date?{date:t.date}:{}};default:return{type:t.type,hour:t.hour,minute:t.minute}}}function Gn(e){let t={prompt:e.prompt,...e.skill?{steps:kn(e.skill)}:e.customSteps?{steps:e.customSteps}:e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.account?{agentProfile:e.account}:{},...e.model?{model:e.model}:{},...e.reasoningEffort?{reasoningEffort:e.reasoningEffort}:{},autonomous:e.autonomous,...e.dispatch?{dispatch:{maxSubtasks:e.maxSubtasks,reviewChild:e.reviewChild}}:{}};if(e.kind===`schedule`)return{name:e.name.trim(),kind:`schedule`,schedule:Wn(e.schedule),...e.schedules?{schedules:[e.schedule,...e.schedules.slice(1)].map(Wn)}:{},task:t};if(e.kind===`tracker`)return{name:e.name.trim(),kind:`tracker`,trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:{lookbackDays:Kn(e.filters.lookbackDays,1,90),maxRecords:Kn(e.filters.maxRecords,1,100)},task:t};let n=e.filters,r=(e,t)=>{let n=Rn(e);return n.length>0?{[t]:n}:{}};return{name:e.name.trim(),kind:`github`,events:[...e.events],intervalSeconds:e.intervalSeconds,filters:{...r(n.authors,`authors`),...r(n.assignees,`assignees`),...r(n.anyLabels,`anyLabels`),...r(n.allLabels,`allLabels`),...r(n.excludeLabels,`excludeLabels`),...r(n.changedLabels,`changedLabels`),...r(n.reviewers,`reviewers`),lookbackDays:Kn(n.lookbackDays,1,90),maxRecords:Kn(n.maxRecords,1,100)},task:{...t,...e.checkout===void 0?{}:{checkout:e.checkout},...e.allowForkHeads===void 0?{}:{allowForkHeads:e.allowForkHeads}}}}function Kn(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function qn(e){let t=Gn(e);return{name:t.name,kind:e.kind,...t.trackerTrigger?{trackerTrigger:t.trackerTrigger}:{},...t.schedule?{schedule:t.schedule}:{},...t.schedules?{schedules:t.schedules}:{},...t.events?{events:t.events}:{},...t.intervalSeconds===void 0?{}:{intervalSeconds:t.intervalSeconds},...t.filters?{filters:t.filters}:{},task:t.task,...e.enabled?{enable:!0}:{}}}var Jn=`([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})`,Yn=RegExp(`\\b(?:user|author|by)\\s+(?:\`@?${Jn}\`|@${Jn}(?![\\w/-]))`,`gi`),Xn=[`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`],Zn=new Set(`a an the this that these those any all each every some me my you your it its them their us our we he she they who whom which what someone anyone everyone others other pull pr prs issue issues review reviews reviewer reviewers request requests team teams user users human humans changes code now approval merge`.split(` `)),Qn=`(?:\`@?${Jn}\`|@${Jn}(?![\\w/-]))`,$n=RegExp(`\\breview(?:s|\\s+requests?)?\\s+(?:(?:is|are)\\s+)?(?:requested\\s+)?(?:for|from|of)\\s+(?:${Qn}|${Jn}\\b(?![/@-]))`,`gi`),er=RegExp(`\\b(?:requested\\s+)?reviewer\\s+${Qn}`,`gi`),tr=RegExp(`${Qn}\\s+(?:(?:is|are|gets?)\\s+)?requested\\s+as\\s+(?:a\\s+)?reviewer\\b`,`gi`);function nr(e){if(e.kind!==`github`)return[];let t=new Set([e.filters.authors,e.filters.assignees,e.filters.reviewers].flatMap(Rn).map(e=>e.replace(/^@/,``).toLowerCase())),n=new Map,r=(e,r)=>{let i=e?.toLowerCase();!e||!i||t.has(i)||n.has(i)||n.set(i,{login:e,field:r})};if(e.events?.some(e=>Xn.includes(e)))for(let t of[$n,er,tr])for(let n of e.prompt.matchAll(t)){let e=n[1]??n[2]??n[3];e&&!Zn.has(e.toLowerCase())&&r(e,`reviewers`)}for(let t of e.prompt.matchAll(Yn))r(t[1]??t[2],`authors`);return[...n.values()]}function rr(e){return e.includes(`issue.labeled`)||e.includes(`issue.unlabeled`)}var ir=e=>[1,2,3,4,6,8,12].includes(e);function ar({trigger:e,intervalSeconds:t,onChange:n,onValid:r}){let[i,o]=(0,q.useState)(``),c=k(),l=s({queryKey:[`tracker`,c,`automation-options`,``],initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>a({...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),u=s({queryKey:[`tracker`,c,`automation-options`,i],enabled:!!i&&l.data?.pages[0]?.available===!0,initialPageParam:void 0,queryFn:({signal:e,pageParam:t})=>a({...i?{search:i}:{},...t?{cursor:t}:{}},{signal:e}),getNextPageParam:e=>e.available?e.nextCursor:void 0,retry:!1}),d=i?u:l,f=l.data?.pages[0],p=f?.available?f:void 0,m=!!p&&!!e&&JSON.stringify(p.association)===JSON.stringify(e.association),h=!!e?.access&&m&&!!e?.events.length&&e.events.every(e=>p?.events.includes(e))&&(e.requiredLabels?.length??0)<=100&&(e.requiredLabels??[]).every(e=>e.length>0&&e.length<=200)&&(!e.events.includes(`issue.status_changed`)||!!e.targetStatusIds?.length)&&(!(e.events.includes(`issue.labeled`)||e.events.includes(`issue.unlabeled`))||!!e.changedLabelIds?.length);(0,q.useEffect)(()=>(r(h),()=>r(!1)),[h,r]);let g=d.data?.pages.flatMap(e=>e.available?[e]:[])??[],_=[...new Map(g.flatMap(e=>e.statuses).map(e=>[e.id,e])).values()],v=new Map((l.data?.pages.flatMap(e=>e.available?e.statuses:[])??[]).map(e=>[e.id,e.name])),y=(e?.targetStatusIds??[]).filter(e=>!_.some(t=>t.id===e)),b=[...new Map(g.flatMap(e=>e.labels).map(e=>[e.id,e])).values()],x=e?.events.includes(`issue.status_changed`),S=e?.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`),C=x&&S?`Search tracker statuses and labels`:S?`Search tracker labels`:`Search tracker statuses`;return(0,J.jsxs)(`div`,{"data-slot":`editor-tracker`,className:`flex flex-col gap-3 text-sm`,children:[l.isPending?(0,J.jsx)(`p`,{children:`Loading tracker events…`}):null,l.isError||f&&!f.available?(0,J.jsxs)(`div`,{role:`alert`,children:[(0,J.jsxs)(`p`,{children:[f&&!f.available?f.reason:`Could not load tracker events.`,` Check the project’s Issue tracker settings.`]}),(0,J.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void l.refetch(),children:`Retry`})]}):null,p?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[p.association.kind===`jira`?`Jira`:`Linear`,` · `,p.association.externalName]}),e&&!m?(0,J.jsx)(`p`,{role:`alert`,children:`The tracker connection changed. Select an event again before saving.`}):null,e?null:(0,J.jsx)(`p`,{children:`Select an event to complete this automation.`}),(0,J.jsx)(`div`,{role:`group`,"aria-label":`Tracker events`,className:`flex flex-wrap gap-1.5`,children:p.events.map(t=>(0,J.jsx)(K,{active:m&&e?.events.includes(t),"aria-pressed":m&&e?.events.includes(t),onClick:()=>{let r=m?e.events:[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],a=e?.access??(e?void 0:{version:1,writes:[]}),o={...m?e:{},...a?{access:a}:{},association:p.association,events:i};t===`issue.status_changed`&&!i.includes(t)&&delete o.targetStatusIds,n({trackerTrigger:o,...m?{}:{enabled:!1}})},children:t},t))}),m&&e?(0,J.jsx)(Dn,{association:p.association,selected:e.requiredLabels??[],onRemove:t=>n({trackerTrigger:{...e,requiredLabels:(e.requiredLabels??[]).filter(e=>e!==t)}}),onSelect:t=>n({trackerTrigger:{...e,requiredLabels:[...new Set([...e.requiredLabels??[],t])]}})},JSON.stringify(p.association)):null,(0,J.jsxs)(`details`,{className:`text-label text-muted-foreground`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer`,children:`Integration details`}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,J.jsx)(`p`,{children:`Label choices come from loaded tasks in this project, including closed tasks. Saved selections remain available.`}),p.limitations.map(e=>(0,J.jsx)(`p`,{children:e},e))]})]}),e?.events.some(e=>e!==`issue.opened`)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(W,{"aria-label":C,placeholder:C,value:i,onChange:e=>o(e.target.value)}),d.isFetching?(0,J.jsx)(`p`,{role:`status`,children:`Searching…`}):null,d.isError||d.data?.pages[0]&&!d.data.pages[0].available?(0,J.jsxs)(`div`,{role:`alert`,children:[`Could not load search results. `,(0,J.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>void d.refetch(),children:`Retry search`})]}):null,!d.isFetching&&d.data?.pages[0]?.available&&x&&_.length===0?(0,J.jsx)(`p`,{children:`No matching statuses.`}):null,!d.isFetching&&d.data?.pages[0]?.available&&S&&b.length===0?(0,J.jsx)(`p`,{children:`No matching labels.`}):null,e.events.includes(`issue.status_changed`)?(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Target statuses`,className:`flex flex-wrap gap-1.5`,children:[_.map(t=>(0,J.jsx)(K,{active:e.targetStatusIds?.includes(t.id),"aria-pressed":e.targetStatusIds?.includes(t.id),onClick:()=>{let r=e.targetStatusIds??[];n({trackerTrigger:{...e,targetStatusIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id)),y.map(t=>(0,J.jsxs)(K,{active:!0,"aria-pressed":!0,onClick:()=>{n({trackerTrigger:{...e,targetStatusIds:(e.targetStatusIds??[]).filter(e=>e!==t)}})},children:[v.get(t)??t,` (not in current results)`]},t))]}):null,e.events.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Changed labels`,className:`flex flex-wrap gap-1.5`,children:b.map(t=>(0,J.jsx)(K,{active:e.changedLabelIds?.includes(t.id),"aria-pressed":e.changedLabelIds?.includes(t.id),onClick:()=>{let r=e.changedLabelIds??[];n({trackerTrigger:{...e,changedLabelIds:r.includes(t.id)?r.filter(e=>e!==t.id):[...r,t.id]}})},children:t.name},t.id))}):null,d.hasNextPage?(0,J.jsx)(N,{variant:`outline`,size:`sm`,disabled:d.isFetchingNextPage,onClick:()=>void d.fetchNextPage(),children:`Load more`}):null]}):null]}):null,(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Check every`,(0,J.jsxs)(R,{value:String(t/60),onValueChange:e=>n({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(I,{"aria-label":`Tracker poll interval`,className:`w-28`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:Nn.map(e=>(0,J.jsxs)(P,{value:String(e),children:[e,` min`]},e))})]})]}),e&&m?(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`legend`,{children:`Tracker access`}),e.access?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{children:`Fresh issue details and accessible comments are read by cezar. Attachments and custom fields are not included. Tokens stay with cezar.`}),[`comment`,`transition`].map(t=>(0,J.jsxs)(`label`,{className:`flex gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.access.writes.includes(t),onChange:r=>n({trackerTrigger:{...e,access:{version:1,writes:r.target.checked?[...e.access.writes,t]:e.access.writes.filter(e=>e!==t)}}})}),`Allow agent to `,t===`comment`?`post comments`:`change status`,` on this issue without further approval`]},t))]}):(0,J.jsxs)(`div`,{role:`alert`,children:[`This automation previously gave its agent a tracker token. Review the prompt: only reading this issue, comments and status transitions are now supported. Other operations need a revised workflow.`,(0,J.jsx)(N,{type:`button`,variant:`outline`,onClick:()=>n({trackerTrigger:{...e,access:{version:1,writes:[]}}}),children:`Confirm migration to read-only access`})]})]}):null,(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Only events after enabling are eligible. Existing backlog is not launched. Use a token with minimal read permissions; grant provider write permissions only for selected write actions.`})]})}function or(e){return g({status:e})}function sr(e,t=!0){return e.kind===`github`&&!t?{tone:`neutral`,pulse:!1,label:`paused by capability`}:e.enabled?e.kind===`schedule`?{tone:`success`,pulse:!1,label:`enabled`}:{tone:`pending`,pulse:!0,label:`enabled`}:{tone:`neutral`,pulse:!1,label:`paused`}}function cr(e){return e===`scheduled`?{tone:`success`,pulse:!1,label:`Scheduler running`}:{tone:`neutral`,pulse:!1,label:`Scheduler idle`}}function lr({definition:e}){let t=nn(e),n=(0,q.useMemo)(()=>vn(e),[e]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`copy-as-cli`,className:`px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`Copy as CLI`}),(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,className:`ml-auto h-6`,onClick:()=>void en(n,t?rn:void 0),children:[(0,J.jsx)(Ke,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})]}),(0,J.jsx)(`pre`,{className:`m-0 rounded-lg border border-border bg-card-2 px-2.5 py-2 font-mono text-meta leading-[1.6] break-words whitespace-pre-wrap text-muted-foreground`,children:n}),(0,J.jsx)(`p`,{className:`mt-2 mb-0 text-meta leading-[1.5] text-soft-foreground`,children:t?rn:(0,J.jsxs)(J.Fragment,{children:[`The same definition the cockpit saves — `,(0,J.jsx)(`code`,{className:`text-meta`,children:`cez automation schema`}),` prints its shape.`]})})]})}function ur({available:e,enabled:t,maxSubtasks:n,reviewChild:r,onChange:i}){if(!e)return null;let a=Pn.includes(n)?Pn:[...Pn,n].sort((e,t)=>e-t);return(0,J.jsxs)(`div`,{"data-slot":`editor-dispatch`,"data-enabled":t?`true`:void 0,className:`flex flex-wrap items-center gap-2.5 border-t border-border pt-3 text-ui text-muted-foreground`,children:[(0,J.jsxs)(rt,{className:`text-ui font-medium text-foreground`,children:[(0,J.jsx)(et,{"aria-hidden":`true`,className:A(`size-3.5`,t?`text-violet`:`text-soft-foreground`)}),`Dispatch`,(0,J.jsx)(it,{"aria-label":`Dispatch`,checked:t,onCheckedChange:e=>i(e?{dispatch:!0}:{dispatch:!1,reviewChild:!1})})]}),t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`up to`,(0,J.jsxs)(R,{value:String(n),onValueChange:e=>i({maxSubtasks:Number(e)}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Max subtasks`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:a.map(e=>(0,J.jsx)(P,{value:String(e),children:e},e))})]}),`subtasks`]}),(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(rt,{className:`text-ui font-normal text-muted-foreground`,children:[(0,J.jsx)(it,{size:`sm`,"aria-label":`Review child`,checked:r,onCheckedChange:e=>i({reviewChild:e})}),`review child`]}),(0,J.jsxs)(`span`,{"data-slot":`editor-dispatch-hint`,className:`ml-auto text-meta whitespace-nowrap text-soft-foreground`,children:[`≤ `,n+1,` agents`]})]}):null,(0,J.jsxs)(`p`,{"data-slot":`editor-dispatch-why`,className:`m-0 basis-full text-label text-muted-foreground`,children:[`Lets the run start its own subtasks with `,(0,J.jsx)(`code`,{className:`text-label`,children:`cez task create`}),`, each in a worktree forked off its branch, reporting back into the parent session.`]})]})}var dr={"pull_request.opened":`A pull request opens`,"issue.opened":`An issue opens`,"issue.labeled":`An issue gets a label`,"issue.unlabeled":`An issue loses a label`,"pull_request.reviewed":`A review is submitted`,"pull_request.review_requested":`A review is requested`,"pull_request.rereview_requested":`A re-review is requested`,"pull_request.closed":`A pull request closes`,"pull_request.merged":`A pull request merges`};function fr({events:e,intervalSeconds:t,filters:n,onChange:r}){let i=[`authors`,`assignees`,`anyLabels`,`allLabels`,`excludeLabels`,`changedLabels`,`reviewers`].filter(e=>n[e].trim().length>0),[a,o]=(0,q.useState)(i.length>0||n.lookbackDays!==7||n.maxRecords!==25),s=(e,t)=>r({filters:{...n,[e]:t}}),c=t=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];r({events:On.filter(e=>n.includes(e))})},l=rr(e),u=l&&n.changedLabels.trim().length===0;return(0,J.jsxs)(`div`,{"data-slot":`editor-github`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-1.5`,children:On.map(t=>(0,J.jsxs)(K,{active:e.includes(t),"aria-pressed":e.includes(t),"aria-label":t,className:`h-8 gap-2 px-3`,onClick:()=>c(t),children:[dr[t],(0,J.jsx)(`span`,{className:`font-mono text-micro font-normal text-soft-foreground`,children:t})]},t))}),e.length===0?(0,J.jsx)(`p`,{className:`m-0 text-label text-danger`,children:`Pick at least one event.`}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-ui text-muted-foreground`,children:[`Checks GitHub every`,(0,J.jsxs)(R,{value:String(Math.round(t/60)),onValueChange:e=>r({intervalSeconds:Number(e)*60}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Poll interval`,className:`text-ui`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:Nn.map(e=>(0,J.jsxs)(P,{value:String(e),children:[e,` min`]},e))})]}),(0,J.jsxs)(`span`,{children:[`while this cockpit is open, looking back `,n.lookbackDays,` days, at most `,n.maxRecords,` records.`]})]}),(0,J.jsxs)(`p`,{"data-slot":`editor-github-how`,className:`-mt-2 m-0 text-label text-soft-foreground`,children:[`Through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL needed.`]}),(0,J.jsxs)(kt,{open:a,onOpenChange:o,children:[(0,J.jsx)(Ot,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`inline-flex h-6 items-center gap-1 text-ui text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(Be,{"aria-hidden":`true`,className:A(`size-3 transition-transform`,a?``:`-rotate-90`)}),`Filters`,u?(0,J.jsx)(`span`,{className:`text-danger`,children:`· changed labels required`}):i.length>0?(0,J.jsxs)(`span`,{className:`text-soft-foreground`,children:[`· `,i.length,` set`]}):(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`· authors, labels, reviewers`})]})}),(0,J.jsxs)(Dt,{children:[(0,J.jsx)(`p`,{className:`m-0 pt-2 text-label text-soft-foreground`,children:`Only matching events start a task. Names in the prompt do not narrow it down; these do.`}),(0,J.jsxs)(`div`,{"data-slot":`editor-github-filters`,className:`grid grid-cols-1 gap-3 pt-3 sm:grid-cols-2`,children:[(0,J.jsx)(X,{id:`filter-authors`,label:`Authors`,value:n.authors,onChange:e=>s(`authors`,e)}),(0,J.jsx)(X,{id:`filter-assignees`,label:`Assignees`,value:n.assignees,onChange:e=>s(`assignees`,e)}),(0,J.jsx)(X,{id:`filter-any-labels`,label:`Any of labels`,value:n.anyLabels,onChange:e=>s(`anyLabels`,e)}),(0,J.jsx)(X,{id:`filter-all-labels`,label:`All of labels`,value:n.allLabels,onChange:e=>s(`allLabels`,e)}),(0,J.jsx)(X,{id:`filter-exclude-labels`,label:`Exclude labels`,value:n.excludeLabels,onChange:e=>s(`excludeLabels`,e)}),(0,J.jsx)(X,{id:`filter-changed-labels`,label:l?`Changed labels (required)`:`Changed labels`,value:n.changedLabels,invalid:u,onChange:e=>s(`changedLabels`,e)}),(0,J.jsx)(X,{id:`filter-reviewers`,label:`Reviewers`,value:n.reviewers,onChange:e=>s(`reviewers`,e)}),(0,J.jsx)(pr,{id:`filter-lookback`,label:`Lookback days (1–90)`,value:n.lookbackDays,min:1,max:90,onChange:e=>s(`lookbackDays`,e)}),(0,J.jsx)(pr,{id:`filter-max-records`,label:`Max records (1–100)`,value:n.maxRecords,min:1,max:100,onChange:e=>s(`maxRecords`,e)})]})]})]})]})}function X({id:e,label:t,value:n,invalid:r=!1,onChange:i}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(rt,{htmlFor:e,className:`text-label text-muted-foreground`,children:t}),(0,J.jsx)(W,{id:e,value:n,placeholder:`comma-separated`,"aria-invalid":r||void 0,onChange:e=>i(e.target.value),className:`h-8 text-ui`})]})}function pr({id:e,label:t,value:n,min:r,max:i,onChange:a}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`span`,{id:`${e}-label`,className:`text-label text-muted-foreground`,children:t}),(0,J.jsx)(hn,{"data-slot":e,"aria-label":t,value:n,min:r,max:i,onCommit:e=>{e!==null&&a(e)}})]})}function mr({source:e,sourcesReady:t,skills:n,skillUsage:r,workflows:i,onSource:a,pick:o,onPick:s,baseBranch:c,autonomous:l,onAutonomous:u}){return(0,J.jsxs)(`div`,{"data-slot":`editor-run-as`,className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(bn,{source:e,ready:t,skills:n,skillUsage:r,workflows:i,onPick:a}),(0,J.jsx)(mn,{pick:o,onChange:s,accounts:!0}),(0,J.jsx)(Zt,{slot:`editor-base-pill`,ariaLabel:`Base branch`,readOnly:!0,hint:`Every run branches off the project's base branch.`,label:(0,J.jsxs)(`span`,{className:`text-meta`,children:[`base: `,c??`…`]}),value:c??``,options:[],onPick:()=>void 0}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(rt,{className:`text-ui font-medium`,children:[`Autonomous`,(0,J.jsx)(it,{"aria-label":`Autonomous`,checked:l,onCheckedChange:u})]})]})}function hr({className:e,...t}){return(0,J.jsx)(`span`,{"data-slot":`branch-chip`,className:A(`inline-flex h-5 items-center rounded-full bg-muted px-2 font-mono text-ui font-medium whitespace-nowrap text-muted-foreground`,e),...t})}var gr=[[`daily`,`Every day`],[`weekdays`,`Weekdays`],[`weekly`,`Weekly`],[`hours`,`Every N hours`],[`once`,`Once`]],_r=e=>String(e).padStart(2,`0`);function vr(e){let t=Date.now()+864e5,n=O(t,e);return n?`${n.year}-${_r(n.month)}-${_r(n.day)}`:new Date(t).toISOString().slice(0,10)}function yr({schedule:e,timeZone:t,onChange:n,allowOnce:r=!0}){let i=ae(e),a=e=>{let{date:r,...a}=i,o={...a,...r?{date:r}:{},...e};o.type===`once`&&!o.date&&(o.date=vr(t)),n(o)},o=i.type===`once`&&i.date!==null&&ce({type:`once`,date:i.date,hour:i.hour,minute:i.minute},Date.now(),t)===null;return(0,J.jsxs)(`div`,{"data-slot":`editor-schedule`,className:`flex flex-col gap-3.5`,children:[(0,J.jsx)(`div`,{role:`group`,"aria-label":`Schedule type`,className:`flex flex-wrap gap-1.5`,children:gr.filter(([e])=>r||e!==`once`).map(([e,t])=>(0,J.jsx)(K,{active:i.type===e,"aria-pressed":i.type===e,onClick:()=>a({type:e}),children:t},e))}),i.type===`weekly`?(0,J.jsx)(`div`,{role:`group`,"aria-label":`Weekday`,className:`flex flex-wrap gap-1.5`,children:E.map((e,t)=>(0,J.jsx)(K,{active:i.day===t+1,"aria-pressed":i.day===t+1,className:`px-[9px]`,onClick:()=>a({day:t+1}),children:e},e))}):null,i.type===`once`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`on`,(0,J.jsx)(W,{type:`date`,"aria-label":`Date`,value:i.date??``,onChange:e=>{e.target.value&&a({date:e.target.value})},className:`w-40 font-mono`})]}):null,i.type===`hours`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`every`,(0,J.jsxs)(R,{value:String(i.every),onValueChange:e=>{let t=Number(e);ir(t)&&a({every:t})},children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Every N hours`,className:`text-ui`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:ue.map(e=>(0,J.jsxs)(P,{value:String(e),children:[e,` h`]},e))})]}),`starting at 00:00`]}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[`at`,(0,J.jsx)(W,{"aria-label":`Hour`,inputMode:`numeric`,value:_r(i.hour),onChange:e=>a({hour:Math.min(23,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),`:`,(0,J.jsx)(W,{"aria-label":`Minute`,inputMode:`numeric`,value:_r(i.minute),onChange:e=>a({minute:Math.min(59,Math.max(0,Number(e.target.value)||0))}),className:`w-14 text-center font-mono`}),(0,J.jsx)(`span`,{className:`text-label`,children:t})]}),i.type===`once`?(0,J.jsx)(`p`,{"data-slot":`editor-once-note`,className:`m-0 text-label ${o?`text-danger`:`text-muted-foreground`}`,children:o?`This time has passed — pick a later one to enable it.`:`Runs a single time, then pauses itself.`}):(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 text-label text-soft-foreground`,children:[(0,J.jsx)(`span`,{children:`cron`}),(0,J.jsx)(hr,{"data-slot":`editor-cron`,children:re(e)})]})]})}var br={schedule:[`{{date}}`,`{{project}}`],github:[`{{github.url}}`,`{{github.title}}`,`{{github.number}}`,`{{github.author}}`,`{{github.labels}}`,`{{date}}`,`{{project}}`],tracker:[`{{tracker.key}}`,`{{tracker.title}}`,`{{tracker.url}}`,`{{tracker.status}}`,`{{date}}`,`{{project}}`]};function xr(e){return Oe({kind:e.kind,events:e.events,intervalSeconds:e.intervalSeconds,schedule:e.schedule,...e.trackerTrigger?{trackerTrigger:e.trackerTrigger}:{}})}function Sr(e,t){let n=xr(e),r=jn(e),i=[`${r?`${r.source===`skill`?`skill`:`workflow`} ${r.ref}`:`a quick task`} on ${e.runner??`the default agent`}${e.model?` (${e.model})`:``}`];return i.push(e.autonomous?`autonomous`:`pausing when it needs you`),t&&e.dispatch&&i.push(`up to ${e.maxSubtasks} subtasks`),`${n.charAt(0).toUpperCase()+n.slice(1)}: ${i.join(`, `)}.`}function Cr(e,t){return e.kind===`schedule`?!0:e.kind===`tracker`?t:e.events.length>0&&(!rr(e.events)||e.filters.changedLabels.trim().length>0)}function wr(e,t){let n=[Cr(e,t),e.prompt.trim().length>0,e.name.trim().length>0],r=n.indexOf(!1);return[{id:`when`,label:`When`},{id:`what`,label:`What`},{id:`live`,label:`Go live`}].map((e,t)=>({...e,state:n[t]&&(r===-1||t<r)?`done`:t===r||r===-1&&t===2?`current`:`next`}))}var Tr=[{value:`post-result`,label:`Every result`},{value:`notify-on-failure`,label:`Failures only`},{value:`none`,label:`Nothing`}];function Er({report:e,managers:t,busy:n=!1,onChange:r}){if(!e&&!t?.length)return null;let i=e?t?.find(t=>t.id===e.managerId):void 0;return(0,J.jsxs)(M,{flush:!0,"data-slot":`manager-report-card`,className:`min-w-0 px-3.5 py-3`,children:[(0,J.jsx)(`h2`,{className:`m-0 mb-2 text-meta font-semibold tracking-[.05em] uppercase text-soft-foreground`,children:`Reports to`}),e?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`m-0 flex items-center gap-1.5 text-ui font-medium text-foreground`,children:[(0,J.jsx)(Cn,{"aria-hidden":`true`,className:`size-3.5 text-violet`}),(0,J.jsx)(`span`,{className:`truncate`,children:i?.name??`A manager no longer listed`})]}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,J.jsxs)(R,{value:e.mode,disabled:n,onValueChange:t=>r({managerId:e.managerId,mode:t}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`What to post`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(L,{})}),(0,J.jsx)(F,{children:Tr.map(e=>(0,J.jsx)(P,{value:e.value,children:e.label},e.value))})]}),(0,J.jsx)(N,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>r(null),children:`Unlink`})]}),(0,J.jsx)(`p`,{className:`m-0 mt-2 text-meta text-muted-foreground`,children:e.mode===`post-result`?`Each finished run’s last message is posted to its chat; a failure is marked important.`:e.mode===`notify-on-failure`?`Only a failed run is posted, marked important.`:`Linked, but nothing is posted.`})]}):(0,J.jsxs)(R,{value:``,disabled:n,onValueChange:e=>r({managerId:e,mode:`post-result`}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Report to a manager`,className:`h-7 px-2 text-label`,children:(0,J.jsx)(L,{placeholder:`Post results to a manager…`})}),(0,J.jsx)(F,{children:t?.map(e=>(0,J.jsx)(P,{value:e.id,children:e.name},e.id))})]})]})}function Dr({automationId:e,onRunNow:t,onLog:n,busy:r=!1,now:i}){let a=ee(),o=k(),s=(0,q.useMemo)(()=>[o,`automation-log`,e],[o,e]),c=w({queryKey:s,queryFn:({signal:t})=>_(e,{signal:t})}),u=(0,q.useMemo)(()=>Or(c.data?.records??[]),[c.data?.records]),d=l((0,q.useMemo)(()=>{let e=new Set(u.map(e=>e.runId));return t=>t.filter(t=>e.has(t.id)).map(({id:e,title:t,status:n,costUsd:r})=>({id:e,title:t,status:n,costUsd:r}))},[u]));return(0,q.useEffect)(()=>he((t,n)=>{if(t!==`automation-change`)return;let r=n;r?.automationId===e&&(o==="default"||r.project===void 0||r.project===o)&&a.invalidateQueries({queryKey:s})}),[e,o,a,s]),(0,J.jsxs)(M,{flush:!0,"data-slot":`recent-runs-card`,className:`min-w-0 px-3.5 py-3`,children:[(0,J.jsx)(`h2`,{className:`m-0 mb-2 eyebrow text-soft-foreground`,children:`Recent runs`}),c.isPending?(0,J.jsx)(`p`,{role:`status`,className:`m-0 text-label text-muted-foreground`,children:`Loading recent runs…`}):null,c.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`text-label text-muted-foreground`,children:[(0,J.jsx)(`p`,{className:`m-0`,children:c.data?`Could not refresh recent runs.`:`Could not load recent runs.`}),(0,J.jsx)(N,{variant:`ghost`,size:`sm`,disabled:c.isFetching,onClick:()=>void c.refetch(),children:`Retry`})]}):null,c.data&&u.length===0?(0,J.jsx)(`p`,{className:`m-0 text-label text-muted-foreground`,children:`No runs launched yet.`}):null,u.length>0?(0,J.jsx)(`ul`,{"aria-label":`Recent runs`,className:`m-0 list-none divide-y divide-border p-0`,children:u.map(e=>{let t=d.data?.find(t=>t.id===e.runId)??c.data?.runs[e.runId],n=t?.title||`Task ${e.runId.slice(0,8)}`,r=t?or(t.status):void 0;return(0,J.jsxs)(`li`,{className:`min-w-0 py-2 first:pt-0 last:pb-0`,children:[(0,J.jsx)(H,{to:`/tasks/${encodeURIComponent(e.runId)}`,className:`block truncate rounded-sm text-ui font-medium hover:underline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2`,children:n}),(0,J.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-label text-muted-foreground`,children:[(0,J.jsx)(G,{"aria-hidden":`true`,tone:r?.tone??`neutral`,pulse:r?.pulse??!1}),(0,J.jsx)(`span`,{children:r?r.label:`Status unavailable`}),(0,J.jsx)(`time`,{dateTime:e.ts,children:qt(e.ts,i)}),null]})]},e.runId)})}):null,(0,J.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap gap-1.5`,children:[t?(0,J.jsxs)(N,{variant:`outline`,size:`sm`,disabled:r,onClick:t,children:[(0,J.jsx)(lt,{"aria-hidden":`true`,className:`size-3`}),`Run now`]}):null,n?(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,onClick:n,children:[(0,J.jsx)(En,{"aria-hidden":`true`,className:`size-3`}),`View log`]}):null]})]})}function Or(e){let t=new Set;return[...e].sort((e,t)=>t.seq-e.seq).filter(e=>!e.runId||t.has(e.runId)?!1:(t.add(e.runId),!0)).slice(0,5)}var kr=864e5;function Ar({kind:e,schedule:t,schedules:n,intervalSeconds:r,timeZone:i,now:a}){let[o,s]=(0,q.useState)(()=>Date.now());(0,q.useEffect)(()=>{if(a!==void 0)return;let e=setInterval(()=>s(Date.now()),6e4);return()=>clearInterval(e)},[a]);let c=a??o,l=(0,q.useMemo)(()=>{if(e!==`schedule`)return[];if(t.type===`once`){let e=ne({schedule:t,schedules:n},c,i);return e===null?[]:[e]}return ie({schedule:t,schedules:n},c,c+9*kr,i,5)},[e,t,n,c,i]);return(0,J.jsxs)(M,{flush:!0,"data-slot":`next-runs-preview`,className:`pt-3 pb-2`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:e===`schedule`?t.type===`once`?`Runs once`:`Next 5 runs`:`How it polls`}),e===`schedule`?l.length===0?(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:t.type===`once`?`This time has already passed.`:`Nothing in the next nine days.`}):l.map(e=>(0,J.jsxs)(`div`,{"data-slot":`next-run`,className:`flex gap-2.5 px-3.5 py-[5px] text-ui`,children:[(0,J.jsx)(`span`,{className:`w-[82px] shrink-0 text-label font-medium whitespace-nowrap text-foreground tabular-nums`,children:Pe(e,i)}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:De(e,c)})]},e)):(0,J.jsx)(`p`,{className:`m-0 px-3.5 pb-1.5 text-label leading-[1.5] text-muted-foreground`,children:e===`tracker`?(0,J.jsxs)(J.Fragment,{children:[`Checks the project tracker every `,Math.round(r/60),` min while this cockpit is open. No webhook or public URL required.`]}):(0,J.jsxs)(J.Fragment,{children:[`Checks GitHub every `,Math.round(r/60),` min while this cockpit is open, through your `,(0,J.jsx)(`code`,{className:`text-xs`,children:`gh`}),`. No webhook or public URL required.`]})})]})}var jr=[{name:`Nightly dependency bump`,when:`Every day at 04:00`,kind:`schedule`,schedule:{type:`daily`,hour:4,minute:0},prompt:`Run npm outdated, bump patch and minor versions, run the test suite, open a draft PR if anything changed.`},{name:`Triage new issues`,when:`On issue.opened · every 5 min`,kind:`github`,events:[`issue.opened`],intervalSeconds:300,prompt:`Read {{github.url}}. Label it, add a repro or a clarification request. Never close it.`},{name:`Weekly changelog draft`,when:`Fridays at 16:00`,kind:`schedule`,schedule:{type:`weekly`,day:5,hour:16,minute:0},prompt:`Collect merged PRs since last week, write CHANGELOG entries, open a draft PR.`},{name:`Stale PR nudge`,when:`Every 6 hours`,kind:`schedule`,schedule:{type:`hours`,every:6},prompt:`Comment on PRs idle for 48h with what is blocking them.`},{name:`Flaky test hunt`,when:`Tuesdays at 02:00`,kind:`schedule`,schedule:{type:`weekly`,day:2,hour:2,minute:0},prompt:`Run the suite 5×, quarantine intermittent tests, open an issue per test.`,dispatch:{maxSubtasks:8,reviewChild:!0}},{name:`Security advisories`,when:`Every day at 06:00`,kind:`schedule`,schedule:{type:`daily`,hour:6,minute:0},prompt:`Run npm audit; for each high/critical advisory open a task with the upgrade path.`}],Mr=e=>[k(),`automation-templates`,e??``];function Nr({onPick:e}){let[t,n]=(0,q.useState)(`builtin`),r=ht(),a=w({queryKey:Mr(r),queryFn:({signal:e})=>i(r,{signal:e}),enabled:t===`mine`}),o=t===`builtin`?jr.map(e=>({...e,key:e.name})):(a.data?.templates??[]).map(e=>({...Vn(e),key:`${e.project.id}:${e.id}`,when:Oe(e),project:e.project.name}));return(0,J.jsxs)(M,{flush:!0,"data-slot":`template-palette`,className:`pb-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-end gap-3 border-b border-border px-4 pt-2.5`,children:[(0,J.jsxs)(`div`,{role:`tablist`,"aria-label":`Template source`,className:`flex shrink-0`,children:[(0,J.jsx)(Pr,{active:t===`builtin`,onClick:()=>n(`builtin`),children:`Built-in`}),(0,J.jsx)(Pr,{active:t===`mine`,onClick:()=>n(`mine`),children:`From your other projects`})]}),(0,J.jsx)(`span`,{className:`ml-auto min-w-0 overflow-hidden pb-2 text-label text-ellipsis whitespace-nowrap text-muted-foreground`,children:t===`builtin`?`Built-in`:`Registered in ~/.cezar/config.json`})]}),t===`mine`&&a.isPending?(0,J.jsx)(Gt,{label:`Loading automations…`,className:`px-4 pt-3`,children:(0,J.jsx)(Wt,{rows:3})}):t===`mine`&&a.isError?(0,J.jsx)(`p`,{role:`alert`,className:`px-4 pt-3 text-label text-danger`,children:a.error.message}):o.length===0?(0,J.jsx)(`p`,{className:`px-4 pt-3 text-label text-muted-foreground`,children:`No automations in your other projects yet.`}):(0,J.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2.5 px-4 pt-3`,children:o.map(t=>(0,J.jsxs)(`div`,{"data-slot":`template-card`,className:`flex flex-col gap-1.5 rounded-[10px] border border-border bg-card-2 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-ui font-semibold`,children:[t.kind===`github`?(0,J.jsx)(B,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}):(0,J.jsx)(_n,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:t.name}),t.project?(0,J.jsx)(hr,{className:`ml-auto`,children:t.project}):null]}),(0,J.jsx)(`div`,{className:`text-meta text-muted-foreground`,children:t.when}),(0,J.jsx)(`div`,{className:`line-clamp-2 text-label leading-[1.45] text-muted-foreground`,children:t.prompt}),(0,J.jsx)(N,{variant:`outline`,size:`sm`,className:`mt-0.5 self-start`,"aria-label":`Use this: ${t.name}`,onClick:()=>e(t),children:`Use this`})]},t.key))})]})}function Pr({active:e,onClick:t,children:n}){return(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e,onClick:t,className:A(`-mb-px flex h-8 items-center rounded-t-md border-b-2 px-3 text-ui font-medium`,e?`border-foreground font-semibold text-foreground`:`border-transparent text-muted-foreground hover:bg-muted hover:text-foreground`),children:n})}function Fr(e){let t=e.toLowerCase();return/\b(events?|filters?|schedule|interval|changedlabels|changed labels|lookback|maxrecords)\b/.test(t)?`when`:/\b(prompt|workflow|runner|model|dispatch)\b/.test(t)?`what`:`top`}var Ir={tracker:`Implement {{tracker.key}} and prepare a pull request.`,schedule:`What should the agent do each time? Say it the way you would in New task.`,github:`What should the agent do for each match? Say it the way you would in New task.`};function Lr({data:e,automation:t,actions:n,initialKind:r,onBack:i,onSaved:a,onLog:o}){let s=ee(),l=V(),u=c(),p=C(),m=x(),g=d(),_=te(),v=r===`github`&&e?.available===!1?`schedule`:r,[b,w]=(0,q.useState)(()=>t?Bn(t):v?{...Ln(),kind:v,...v===`tracker`?{intervalSeconds:1800,enabled:!1}:{}}:Ln()),[T,E]=(0,q.useState)(!t&&!v),[ne,re]=(0,q.useState)(!1),[ie,ae]=(0,q.useState)(!1),[D,oe]=(0,q.useState)(null),[se,ce]=(0,q.useState)(!1),O=(0,q.useRef)(null),le=t?.revision,k=(0,q.useRef)(le);(0,q.useEffect)(()=>{!t||le===k.current||(k.current=le,w(Bn(t)),ce(!1),oe(null))},[t,le]);let A=e=>w(t=>({...t,...e})),ue=e?.timeZone??`UTC`,de=e?.available!==!1,fe=u.data?.capabilities.dispatch===!0,pe=(0,q.useMemo)(()=>ot(st(p.data?.promptTemplates),u.data?.capabilities),[p.data?.promptTemplates,u.data?.capabilities]),he=m.data?.workflows??[],ge=he.map(e=>e.name),_e=g.data,ve=(_e??[]).map(e=>e.name),ye=p.data?.skillUsage,be=(0,q.useMemo)(()=>at(_e??[],ye),[_e,ye]),xe=g.data!==void 0&&m.data!==void 0&&!p.isPending,j=_.data?.baseBranch??_.data?.info?.branch??void 0,Se=(0,q.useMemo)(()=>qn(b),[b]),we=(0,q.useMemo)(()=>nr(b),[b]),Te=e=>we.filter(t=>t.field===e).map(e=>e.login),Ee=b.name.trim().length>0&&b.prompt.trim().length>0&&!ie&&(b.kind!==`tracker`||ne),De=wr(b,ne),Oe=Sr(b,fe),ke=e=>{let t=O.current,n=t?.selectionStart??b.prompt.length,r=ct(b.prompt,n,e);A({prompt:r.text}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(r.caret,r.caret))})},Ae=e=>{let t=O.current,n=t?.selectionStart??b.prompt.length,r=b.prompt.slice(0,n),i=b.prompt.slice(n),a=r.length>0&&!/\s$/.test(r)?` `:``,o=`${r}${a}${e}${i.length>0&&!/^\s/.test(i)?` `:``}${i}`,s=r.length+a.length+e.length;A({prompt:o}),requestAnimationFrame(()=>{t&&(t.focus(),t.setSelectionRange(s,s))})},je=async()=>{ae(!0),oe(null),ce(!1);try{let e=Gn(b);t?await y(t.id,{...e,enabled:b.enabled,expectedRevision:t.revision}):await h({...e,enable:b.enabled}),await s.invalidateQueries({queryKey:dn()}),a()}catch(e){if(t&&e instanceof S&&e.status===409)ce(!0);else{let t=e instanceof Error?e.message:String(e);oe({message:t,section:e instanceof S&&e.status===400?Fr(t):`top`})}}finally{ae(!1)}},Me=()=>void s.invalidateQueries({queryKey:dn()}),Ne=u.data?.capabilities.managers===!0,Pe=me(Ne&&!!t),[Fe,Ie]=(0,q.useState)(!1),[M,Le]=(0,q.useState)(null),Re=async e=>{if(t){Ie(!0),Le(null);try{await f(t.id,e),await s.invalidateQueries({queryKey:dn()})}catch(e){Le(e instanceof Error?e.message:String(e))}finally{Ie(!1)}}},ze=t?`Save changes`:b.enabled?`Save and enable`:`Save paused`,Be=`Change the kind by creating a new automation`,P=!!t,F=e=>{e!==b.kind&&A({kind:e,...e===`tracker`?{intervalSeconds:1800,enabled:!1}:{}})};return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-editor`,"data-onboarding":``,className:`flex min-h-full flex-col`,children:[(0,J.jsxs)(`header`,{className:`sticky top-0 z-10 flex min-h-14 shrink-0 flex-wrap items-center gap-3 border-b border-border bg-background px-5 max-md:py-2 md:h-14 md:flex-nowrap`,children:[(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:i,children:(0,J.jsx)(Ce,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:t?`Edit automation`:`New automation`}),t?(0,J.jsx)(Jt,{dot:sr(t,de).tone,pulse:sr(t,de).pulse,children:sr(t,de).label}):null,(0,J.jsx)(`span`,{className:`flex-1`}),t?null:(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,"aria-expanded":T,"aria-label":T?`Hide templates`:`Start from a template`,onClick:()=>E(e=>!e),children:[(0,J.jsx)(xn,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`max-md:hidden`,children:T?`Hide templates`:`Start from a template`})]}),(0,J.jsx)(N,{variant:`outline`,className:`font-normal`,onClick:i,children:`Cancel`}),(0,J.jsx)(N,{className:`font-normal`,disabled:!Ee,onClick:()=>void je(),children:ze})]}),(0,J.jsx)(`div`,{className:`flex justify-center px-5 pb-16`,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-3xl flex-col items-center`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-strip`,className:`sticky top-14 z-10 flex w-full flex-wrap items-center gap-x-6 gap-y-1.5 border-b border-border bg-background/95 py-2.5 backdrop-blur max-md:static`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 max-md:basis-full`,children:[(0,J.jsx)(`span`,{className:`shrink-0 text-ui text-muted-foreground`,"aria-hidden":`true`,children:`Name`}),(0,J.jsx)(W,{"aria-label":`Name`,placeholder:`Nightly dependency bump`,value:b.name,onChange:e=>A({name:e.target.value}),className:`h-9 w-full max-w-md text-lead md:text-lead`})]}),(0,J.jsx)(cn,{steps:De})]}),se||D?.section===`top`||T&&!t?(0,J.jsxs)(`div`,{className:`mt-6 flex w-full flex-col gap-4`,children:[se?(0,J.jsxs)(`div`,{role:`alert`,"data-slot":`editor-conflict`,className:`flex flex-wrap items-center gap-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-ui text-foreground`,children:[`Edited elsewhere — reload to see the latest version`,(0,J.jsx)(N,{variant:`outline`,size:`sm`,className:`ml-auto`,onClick:Me,children:`Reload`})]}):null,D?.section===`top`?(0,J.jsx)(Br,{children:D.message}):null,T&&!t?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`p`,{className:`m-0 text-center text-ui text-muted-foreground`,children:`Start from a template, or fill in the three parts below.`}),(0,J.jsx)(Nr,{onPick:e=>{let t=e.workflow&&ge.includes(e.workflow)?e.workflow:void 0,n=e.steps?.every(e=>!e.skill||ve.includes(e.skill))?e.steps:void 0;w(r=>Un(r,{...e,workflow:t,steps:n})),E(!1)}})]}):null]}):null,(0,J.jsxs)(zr,{slot:`when`,title:`When`,why:P?`The trigger is fixed once saved; change it by creating a new automation.`:`What starts a run. Pick one, then say how often or on which change.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-kind`,role:`group`,"aria-label":`Trigger`,className:`grid gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(tn,{value:`schedule`,title:`On a schedule`,description:`At a time you set.`,selected:b.kind===`schedule`,disabled:P&&b.kind!==`schedule`,reason:P&&b.kind!==`schedule`?Be:void 0,onClick:()=>F(`schedule`),picture:(0,J.jsx)(Vr,{})}),(0,J.jsx)(tn,{value:`github`,title:`When GitHub changes`,description:`A pull request, an issue, a review.`,selected:b.kind===`github`,disabled:!de||P&&b.kind!==`github`,reason:de?P&&b.kind!==`github`?Be:void 0:e?.reason??`GitHub is unavailable`,onClick:()=>F(`github`),picture:(0,J.jsx)(B,{className:`size-7 text-muted-foreground`,"aria-hidden":!0})}),(0,J.jsx)(tn,{value:`tracker`,title:`When Jira / Linear changes`,description:`An issue is created or moves.`,selected:b.kind===`tracker`,disabled:P&&b.kind!==`tracker`,reason:P&&b.kind!==`tracker`?Be:void 0,onClick:()=>F(`tracker`),picture:(0,J.jsx)(Hr,{})})]}),(0,J.jsx)(`div`,{className:`mt-5`,children:b.kind===`schedule`?(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[[b.schedule,...b.schedules?.slice(1)??[]].map((e,t,n)=>(0,J.jsxs)(`fieldset`,{className:`min-w-0 rounded-md border p-3`,children:[(0,J.jsxs)(`legend`,{className:`px-1 text-label text-muted-foreground`,children:[`Schedule `,t+1]}),(0,J.jsx)(yr,{schedule:e,timeZone:ue,allowOnce:n.length===1,onChange:e=>{let r=n.map((n,r)=>r===t?e:n),i=r[0];i&&A({schedule:i,schedules:r.length>1?r:void 0})}}),n.length>1?(0,J.jsx)(N,{variant:`ghost`,size:`sm`,"aria-label":`Remove schedule ${t+1}`,onClick:()=>{let e=n.filter((e,n)=>n!==t),r=e[0];r&&A({schedule:r,schedules:e.length>1?e:void 0})},children:`Remove schedule`}):null]},t)),(0,J.jsx)(N,{variant:`outline`,size:`sm`,disabled:(b.schedules?.length??1)>=16||b.schedule.type===`once`,onClick:()=>A({schedules:[b.schedule,...b.schedules?.slice(1)??[],{type:`daily`,hour:4,minute:0}]}),children:`Add schedule`}),(0,J.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Times that coincide start one task. One-time schedules run on their own.`})]}):b.kind===`tracker`?(0,J.jsx)(ar,{trigger:b.trackerTrigger,intervalSeconds:b.intervalSeconds,onChange:A,onValid:re}):(0,J.jsx)(fr,{events:b.events,intervalSeconds:b.intervalSeconds,filters:b.filters,onChange:e=>A(e)})}),b.kind===`schedule`?(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(Ar,{kind:b.kind,schedule:b.schedule,schedules:b.schedules,intervalSeconds:b.intervalSeconds,timeZone:ue})}):null,D?.section===`when`?(0,J.jsx)(Br,{children:D.message}):null]}),(0,J.jsxs)(zr,{slot:`what`,title:`What the agent does`,why:`The same words you would type into New task. Placeholders fill in per run.`,children:[(0,J.jsxs)(`div`,{"data-slot":`editor-placeholders`,className:`flex flex-wrap items-center gap-1.5 text-label text-muted-foreground`,children:[`Insert`,br[b.kind].map(e=>(0,J.jsx)(K,{className:`h-6 font-mono text-meta`,onClick:()=>Ae(e),children:e},e))]}),(0,J.jsx)(pt,{ref:O,"aria-label":`Prompt`,rows:5,placeholder:Ir[b.kind],value:b.prompt,onChange:e=>A({prompt:e.target.value}),className:`mt-3 min-h-[120px] rounded-xl px-4 py-3 text-lead leading-[1.55] md:text-lead`}),(0,J.jsxs)(`div`,{"data-slot":`editor-prompt-templates`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-label text-muted-foreground`,children:[(0,J.jsx)(Qe,{"aria-hidden":`true`,className:`size-3`}),`Prompt templates`,pe.map(e=>(0,J.jsx)(U,{label:Rr(e.text),children:(0,J.jsx)(K,{className:`h-6 text-meta`,onClick:()=>ke(e.text),children:e.label})},e.id)),(0,J.jsx)(K,{dashed:!0,className:`h-6 text-meta`,icon:(0,J.jsx)(tt,{"aria-hidden":`true`,className:`size-3`}),onClick:()=>l(`${yn(`project`,`instructions`)}#prompt-templates`),children:`Manage…`})]}),we.length>0?(0,J.jsxs)(`div`,{role:`status`,"data-slot":`editor-prompt-condition`,className:`mt-3 flex flex-wrap items-center gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-label text-foreground`,children:[(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`The prompt names `,we.map(({login:e})=>`@${e}`).join(`, `),`, but prompt text does not decide what launches — without a filter every matching event starts a task.`]}),[`authors`,`reviewers`].map(e=>Te(e).length>0?(0,J.jsx)(N,{variant:`outline`,size:`sm`,onClick:()=>A({filters:{...b.filters,[e]:[...Rn(b.filters[e]),...Te(e)].join(`, `)}}),children:e===`authors`?`Add to Authors`:`Add to Reviewers`},e):null)]}):null,(0,J.jsx)(`div`,{className:`mt-5`,children:(0,J.jsx)(mr,{source:jn(b),sourcesReady:xe,skills:be,skillUsage:ye,workflows:he,onSource:e=>A(Mn(e)),pick:{runner:b.runner,model:b.model,reasoningEffort:b.reasoningEffort,account:b.account},onPick:e=>A({runner:e.runner,model:e.model,reasoningEffort:e.reasoningEffort??null,account:e.account}),baseBranch:j,autonomous:b.autonomous,onAutonomous:e=>A({autonomous:e})})}),(0,J.jsx)(`p`,{className:`mt-3 mb-0 text-label leading-[1.5] text-muted-foreground`,children:`Each run is an ordinary cezar task in its own worktree — it queues behind the parallel cap like anything else and never auto-merges.`}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(ur,{available:fe,enabled:b.dispatch,maxSubtasks:b.maxSubtasks,reviewChild:b.reviewChild,onChange:e=>A(e)})}),D?.section===`what`?(0,J.jsx)(Br,{children:D.message}):null]}),(0,J.jsxs)(zr,{slot:`live`,title:`Go live`,why:`Paused, it waits in the list where you can preview it. Enabled, it starts counting from now.`,children:[(0,J.jsx)(`p`,{"data-slot":`editor-summary`,className:`m-0 rounded-xl border border-violet/40 bg-violet/10 px-4 py-3 text-body text-foreground`,children:Oe}),(0,J.jsxs)(rt,{className:`mt-4 flex items-start gap-3 text-ui font-normal`,children:[(0,J.jsx)(it,{"aria-label":`Enabled`,checked:b.enabled,onCheckedChange:e=>A({enabled:e}),className:`mt-0.5`}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`text-body text-foreground`,children:`Enabled`}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:b.kind===`schedule`?b.enabled?`Runs at the next time listed above.`:`Saved paused. Enable it from the list, or Run now to try it once.`:`Counts from a current-time baseline; existing matches will not launch.`})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex flex-col gap-3`,children:[(0,J.jsx)(lr,{definition:Se}),t&&t.kind!==`schedule`&&n?(0,J.jsx)(N,{variant:`outline`,className:`self-start font-normal`,disabled:n.busy,onClick:()=>void n.preview(t),children:`Preview saved matches`}):null,t&&(Ne||t.report)?(0,J.jsx)(Er,{report:t.report,managers:Pe.data?.managers,busy:Fe,onChange:e=>void Re(e)}):null,M?(0,J.jsx)(Br,{children:M}):null,t?(0,J.jsx)(Dr,{automationId:t.id,busy:n?.busy,onRunNow:n?()=>void n.runNow(t):void 0,onLog:o}):null]})]})]})})]})}function Rr(e){let t=e.split(`
|
|
2
2
|
`).map(e=>e.trim()).find(Boolean)??``;return t.length>90?`${t.slice(0,89)}…`:t}function zr({slot:e,title:t,why:n,children:r}){return(0,J.jsxs)(`section`,{"data-slot":`editor-section`,"data-section":e,className:`mt-7 w-full border-t border-border pt-6 first-of-type:mt-6 first-of-type:border-t-0 first-of-type:pt-0`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-light tracking-tight text-foreground`,children:t}),(0,J.jsx)(`p`,{className:`mt-1 mb-5 text-ui text-muted-foreground`,children:n}),r]})}function Br({children:e}){return(0,J.jsx)(`div`,{role:`alert`,className:A(`mt-3 rounded-lg border border-danger/40 bg-danger/10 px-3.5 py-2.5 text-ui text-foreground`),children:e})}function Vr(){return(0,J.jsxs)(`span`,{className:`flex w-12 flex-col gap-1`,children:[(0,J.jsxs)(`span`,{className:`flex items-center justify-between rounded-md border border-violet bg-violet/15 px-1 py-0.5 font-mono text-[7px] text-foreground`,children:[`09:00`,(0,J.jsx)(`span`,{className:`size-1 rounded-full bg-violet`})]}),(0,J.jsxs)(`span`,{className:`flex items-center justify-between rounded-md border border-border px-1 py-0.5 font-mono text-[7px] text-muted-foreground`,children:[`16:00`,(0,J.jsx)(`span`,{className:`size-1 rounded-full bg-muted-foreground/50`})]})]})}function Hr(){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-[7px]`,children:[(0,J.jsx)(`span`,{className:`rounded border border-border px-1 py-0.5 text-muted-foreground`,children:`To do`}),(0,J.jsx)(`span`,{className:`h-px w-1.5 bg-violet`}),(0,J.jsx)(`span`,{className:`rounded border border-violet bg-violet/15 px-1 py-0.5 text-foreground`,children:`Ready`})]})}function Ur({automationId:e,automation:t,timeZone:n,onBack:r}){let i=V(),a=ee(),s=k(),c=(0,q.useMemo)(()=>[s,`automation-log`,e],[s,e]),l=w({queryKey:c,queryFn:({signal:t})=>_(e,{signal:t})}),[u,d]=(0,q.useState)(`all`),[f,p]=(0,q.useState)(`all`);(0,q.useEffect)(()=>he((t,n)=>{t===`automation-change`&&n.automationId===e&&a.invalidateQueries({queryKey:c})}),[e,a,c]);let h=m({mutationFn:e=>o(e),onSuccess:()=>a.invalidateQueries({queryKey:c}),onError:e=>Kt(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=n??`UTC`,v=l.data?.records.filter(e=>(u===`all`||e.result===u)&&(f===`all`||e.event===f));return(0,J.jsxs)(`div`,{"data-route":`automations`,"data-slot":`automation-log`,className:`flex min-h-full flex-col`,children:[(0,J.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5`,children:[(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Back`,onClick:r,children:(0,J.jsx)(Ce,{className:`size-[15px]`})}),(0,J.jsx)(`h1`,{className:`m-0 text-base font-semibold`,children:t?t.name:`Automation`}),(0,J.jsx)(`span`,{className:`text-ui text-muted-foreground`,children:`· execution log`}),(0,J.jsxs)(`div`,{className:`flex flex-1 items-center justify-end gap-2`,children:[(0,J.jsxs)(R,{value:u,onValueChange:e=>d(e),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Filter by result`,className:`text-label`,children:(0,J.jsx)(L,{placeholder:`All results`})}),(0,J.jsxs)(F,{children:[(0,J.jsx)(P,{value:`all`,children:`All results`}),Wr.map(e=>(0,J.jsx)(P,{value:e,children:e},e))]})]}),(0,J.jsxs)(R,{value:f,onValueChange:e=>p(e),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Filter by event`,className:`text-label`,children:(0,J.jsx)(L,{placeholder:`All events`})}),(0,J.jsxs)(F,{children:[(0,J.jsx)(P,{value:`all`,children:`All events`}),Gr.map(e=>(0,J.jsx)(P,{value:e,children:e},e))]})]})]}),(0,J.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>i(`/automations/${encodeURIComponent(e)}`),children:[(0,J.jsx)(qe,{className:`size-[13px]`}),`Edit`]})]}),(0,J.jsx)(`div`,{className:`flex justify-center p-5`,children:l.isError?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:l.error instanceof Error?l.error.message:String(l.error)})}):v===void 0?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:`Loading execution log…`})}):v.length===0?(0,J.jsx)(`div`,{className:`w-full max-w-[820px]`,children:(0,J.jsx)($,{text:`No checks have run yet.`})}):(0,J.jsx)(M,{flush:!0,className:`w-full max-w-[820px]`,children:v.map((e,t)=>(0,J.jsx)(qr,{record:e,run:e.runId===void 0?void 0:l.data?.runs[e.runId],last:t===v.length-1,timeZone:g,retrying:h.isPending&&h.variables===e.receiptId,onRetry:e=>h.mutate(e)},e.seq))})})]})}var Wr=[`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`manual`,`catch-up`,`skipped`,`failed`],Gr=[`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`,`pull_request.reviewed`,`pull_request.review_requested`,`pull_request.rereview_requested`,`pull_request.closed`,`pull_request.merged`];function Kr(e){return e.result===`failed`&&e.runId===void 0?e.receiptId:void 0}function qr({record:e,run:t,last:n,timeZone:r,retrying:i,onRetry:a}){let o=Ne(e.result),s=t?.children??[],c=Kr(e);return(0,J.jsxs)(`div`,{"data-slot":`log-row`,"data-result":e.result,className:`grid grid-cols-[90px_110px_1fr_auto] items-center gap-x-3 gap-y-2 px-4 py-3 text-ui ${n?``:`border-b border-border`}`,children:[(0,J.jsx)(`span`,{className:`text-label font-medium text-muted-foreground tabular-nums`,children:Ae(e.ts,r)}),(0,J.jsx)(Jt,{dot:o,className:`w-fit`,children:e.result}),(0,J.jsx)(`span`,{className:`min-w-0 break-words ${o===`danger`?`text-danger`:`text-muted-foreground`}`,children:e.reason??``}),null,e.runId===void 0?c===void 0?(0,J.jsx)(`span`,{}):(0,J.jsxs)(N,{variant:`ghost`,size:`sm`,disabled:i,onClick:()=>a(c),children:[(0,J.jsx)(pn,{className:`size-3`}),`Retry task`]}):(0,J.jsx)(N,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,J.jsxs)(H,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open task`,(0,J.jsx)(we,{className:`size-3`})]})}),s.length>0?(0,J.jsx)(`div`,{className:`col-span-full flex flex-col gap-1 pl-3.5`,children:s.map(e=>{let t=or(e.status);return(0,J.jsxs)(`div`,{"data-slot":`log-child`,className:`grid grid-cols-[14px_70px_1fr_auto] items-center gap-2.5 text-label`,children:[(0,J.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:`└`}),(0,J.jsx)(`span`,{className:`w-fit rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:e.kind??`implement`}),(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(G,{tone:t.tone,pulse:t.pulse}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.title})]}),null,(0,J.jsx)(N,{variant:`ghost`,size:`sm`,className:`h-6`,asChild:!0,children:(0,J.jsxs)(H,{to:`/tasks/${encodeURIComponent(e.runId)}`,children:[`Open`,(0,J.jsx)(we,{className:`size-[11px]`})]})})]},e.runId)})}):null]})}function Jr({data:e}){let t=V(),[n,r]=q.useState(!1),i=e.available===!1,a=e=>t(`/automations/new?kind=${e}`);return(0,J.jsxs)(sn,{wide:!0,slot:`automations`,title:`Let the routine run itself`,why:`An automation is a prompt cezar turns into a task on its own: at a time you set, when something happens on GitHub, or when an issue moves in Jira or Linear.`,children:[(0,J.jsxs)(`div`,{"data-slot":`automation-triggers`,className:`mt-8 grid w-full gap-3 sm:grid-cols-3`,children:[(0,J.jsx)(gn,{title:`On a schedule`,description:`Every weekday at 9:00, Fridays at 16:00, every six hours.`,recommended:!0,onClick:()=>a(`schedule`),picture:(0,J.jsx)($r,{})}),(0,J.jsx)(gn,{title:`When GitHub changes`,description:i?`Sign in to the GitHub CLI first.`:`A new pull request, an issue labelled, a review requested.`,onClick:()=>i?t(`/github`):a(`github`),picture:i?(0,J.jsx)(B,{className:`size-9 text-muted-foreground`,"aria-hidden":!0}):(0,J.jsx)(ei,{})}),(0,J.jsx)(gn,{title:`When an issue moves`,description:`A Jira or Linear issue is created or changes status.`,onClick:()=>a(`tracker`),picture:(0,J.jsx)(ti,{})})]}),(0,J.jsx)(`ol`,{"data-slot":`automation-steps`,className:`mt-10 grid w-full gap-6 text-left sm:grid-cols-3`,children:Yr.map((e,t)=>(0,J.jsxs)(`li`,{className:`flex gap-3`,children:[(0,J.jsx)(`span`,{className:`mt-0.5 grid size-6 shrink-0 place-items-center rounded-full border border-violet font-mono text-meta text-foreground`,"aria-hidden":`true`,children:t+1}),(0,J.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-lead text-foreground`,children:e.title}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:e.body})]})]},e.title))}),(0,J.jsxs)(`div`,{className:`mt-10 flex flex-col items-center gap-4`,children:[(0,J.jsx)(N,{asChild:!0,className:`font-normal`,children:(0,J.jsxs)(H,{to:`/automations/new`,children:[(0,J.jsx)(ut,{className:`size-[15px]`,"aria-hidden":`true`}),`New automation`]})}),(0,J.jsxs)(`button`,{type:`button`,className:ln,onClick:()=>r(!0),children:[(0,J.jsx)(Ve,{className:`size-3.5`,"aria-hidden":`true`}),`See it in pictures`]})]}),n?(0,J.jsx)(Xr,{onOpenChange:r}):null]})}var Yr=[{title:`Write it as a prompt`,body:`Say what the agent should do each time. Placeholders such as {{github.url}} or {{date}} fill in per run.`},{title:`Preview, then enable`,body:`A new automation starts paused. A poll shows what it would have matched, a schedule shows its next runs. Enable it when that looks right.`},{title:`Every run is a task`,body:`Each match starts an ordinary task in its own worktree. It ends at the review gate, never merges on its own, and the log keeps every run.`}];function Xr({onOpenChange:e}){let t=V();return(0,J.jsx)(on,{slot:`automations-guide-page`,title:`How automations work`,description:`Four things to know.`,pages:[{id:`prompt`,title:`A prompt that runs itself`,body:`An automation is the same thing you type into New task, kept and run for you. Placeholders fill in what changed: the pull request, the issue, the date.`,picture:(0,J.jsx)(ni,{})},{id:`triggers`,title:`Three ways to start`,body:`On a schedule, when GitHub changes, or when an issue moves in Jira or Linear. A GitHub or tracker automation polls every few minutes and starts one task per match.`,picture:(0,J.jsx)(ri,{})},{id:`paused`,title:`Paused first, then live`,body:`A new automation is paused. Preview shows what it would have matched, or when it runs next. Enable it when that looks right, and pause it again any time.`,picture:(0,J.jsx)(ii,{})},{id:`tasks`,title:`Every run is a task`,body:`Each run shows up in the task list like one you started yourself, in its own worktree, ending at the review gate. The automation’s log keeps every run.`,picture:(0,J.jsx)(oi,{}),action:{label:`New automation`,onClick:()=>t(`/automations/new`)}}],onOpenChange:e})}var Zr=`flex items-center gap-2 rounded-md px-2 py-1 text-micro`;function Qr({on:e=!0}){return(0,J.jsx)(`span`,{className:A(`flex h-3.5 w-6 items-center rounded-full px-0.5`,e?`justify-end bg-violet`:`justify-start bg-muted-foreground/40`),children:(0,J.jsx)(`span`,{className:`size-2.5 rounded-full bg-background`})})}function $r(){return(0,J.jsx)(`span`,{className:`flex w-20 flex-col gap-1`,children:[`Mon 09:00`,`Fri 16:00`].map((e,t)=>(0,J.jsxs)(`span`,{className:A(`flex items-center justify-between rounded-md border px-1.5 py-1 font-mono text-[9px]`,t===0?`border-violet bg-violet/15 text-foreground`:`border-border text-muted-foreground`),children:[e,(0,J.jsx)(`span`,{className:A(`size-1.5 rounded-full`,t===0?`bg-violet`:`bg-muted-foreground/50`)})]},e))})}function ei(){return(0,J.jsxs)(`span`,{className:`flex w-20 flex-col gap-1.5`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-violet bg-violet/15 px-1.5 py-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-violet`}),(0,J.jsx)(`span`,{className:`h-1 flex-1 rounded bg-violet/60`}),(0,J.jsx)(`span`,{className:`rounded-sm bg-violet/40 px-1 text-[7px] text-foreground`,children:`PR`})]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-md border border-border px-1.5 py-1`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`}),(0,J.jsx)(`span`,{className:`h-1 w-2/3 rounded bg-muted`})]})]})}function ti(){return(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[9px]`,children:[(0,J.jsx)(`span`,{className:`rounded-md border border-border px-1.5 py-1 text-muted-foreground`,children:`To do`}),(0,J.jsx)(`span`,{className:`h-px w-3 bg-violet`}),(0,J.jsx)(`span`,{className:`rounded-md border border-violet bg-violet/15 px-1.5 py-1 text-foreground`,children:`Ready`})]})}function ni(){return(0,J.jsxs)(Qt,{bar:(0,J.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`What to run`}),children:[(0,J.jsxs)(`p`,{className:`text-meta leading-relaxed text-foreground`,children:[`Review `,(0,J.jsx)(`span`,{className:`rounded-sm bg-violet/15 px-1 text-violet`,children:`{{github.url}}`}),` for real issues only and leave one comment per finding.`]}),(0,J.jsx)(`div`,{className:A(an,`mt-3 w-1/2`)})]})}function ri(){return(0,J.jsx)(Qt,{children:[`Every weekday at 9:00`,`When a pull request opens`,`When PROJ-42 reaches Ready`].map((e,t)=>(0,J.jsxs)(`div`,{style:{"--i":t},className:A(Zr,`tip-rise justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(Qr,{})]},e))})}function ii(){return(0,J.jsxs)(Qt,{children:[(0,J.jsxs)(`div`,{className:A(Zr,`justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:`Triage new issues`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-micro text-soft-foreground`,children:[`paused`,(0,J.jsx)(Qr,{on:!1})]})]}),(0,J.jsx)(`div`,{style:{"--i":2},className:`tip-rise mt-2 rounded-md border border-violet/50 bg-violet/10 px-2 py-1.5 text-micro text-foreground`,children:`Preview: would have matched 3 issues this week`}),(0,J.jsxs)(`div`,{style:{"--i":5},className:A(Zr,`tip-rise mt-2 justify-between text-foreground`),children:[(0,J.jsx)(`span`,{children:`Triage new issues`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-micro text-success`,children:[`enabled`,(0,J.jsx)(Qr,{})]})]})]})}var ai={info:`text-info`,violet:`text-violet`,success:`text-success`,danger:`text-danger`,pending:`text-pending-strong`,idle:`text-conflict`,neutral:`text-muted-foreground`};function oi(){return(0,J.jsx)(Qt,{bar:(0,J.jsx)(`span`,{className:`ml-3 text-micro text-soft-foreground`,children:`Tasks`}),children:[[`review`,`Triage issue 412: missing repro`],[`running`,`Nightly dependency bump`],[`done`,`Weekly changelog draft`]].map(([e,t],n)=>{let r=g({status:e});return(0,J.jsxs)(`div`,{style:{"--i":n},className:A(Zr,`tip-rise text-foreground`),children:[(0,J.jsx)(`span`,{"data-slot":`picture-status`,"data-tone":r.tone,className:A(`w-16 shrink-0 text-micro`,ai[r.tone]),children:r.label}),(0,J.jsx)(`span`,{className:`truncate`,children:t})]},t)})})}var si=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function ci(e){let t=[],n=e.queued.filter(e=>e.kind===`continuation`).length,r=e.queued.length-n;if(e.queued.length){let i=[r?`${r} never started`:``,n?`${n} continuing earlier work`:``].filter(Boolean).join(`, `);t.push(`${si(e.queued.length,`queued task`)} (${i}) will still start when a slot frees up, unless you cancel them.`)}return e.active.length&&t.push(`${si(e.active.length,`task`)} ${e.active.length===1?`is`:`are`} running or waiting and will keep going — stop them from Tasks. They can no longer dispatch new subtasks.`),t}function li(e){return e.queued.length>0||e.active.length>0}function ui({automation:e,work:t,pausing:n,onOpenChange:r,onConfirm:i}){let a=e=>e.stopPropagation(),o=t?ci(t):[],s=t?.queued.length??0;return(0,J.jsx)(Lt,{open:t!==void 0,onOpenChange:r,children:(0,J.jsxs)(Mt,{onClick:a,children:[(0,J.jsxs)(It,{children:[(0,J.jsx)(jt,{children:n?`Pause “${e.name}”?`:`Work still pending for “${e.name}”`}),(0,J.jsx)(At,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{children:n?`Pausing stops new launches. Tasks it already started are not stopped:`:`This automation is paused, but tasks it started earlier remain:`}),o.length?(0,J.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:o.map(e=>(0,J.jsx)(`li`,{children:e},e))}):(0,J.jsx)(`p`,{children:`Nothing is queued or running.`})]})})]}),(0,J.jsxs)(Pt,{children:[(0,J.jsx)(Ft,{children:n?`Cancel`:`Close`}),n?(0,J.jsx)(Nt,{onClick:()=>i(!1),children:`Pause`}):null,s>0?(0,J.jsx)(Nt,{"data-variant":`destructive`,className:Le({variant:`destructive`}),onClick:()=>i(!0),children:n?`Pause and cancel ${si(s,`queued task`)}`:`Cancel ${si(s,`queued task`)}`}):null]})]})})}function di({automation:e,actions:t}){let n=V(),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(),s=async()=>{if(!e.enabled)return t.toggleEnabled(e);let n=await t.loadWork(e);n&&li(n)?o({work:n,pausing:!0}):await t.toggleEnabled(e)},c=async()=>{let n=await t.loadWork(e);n&&o({work:n,pausing:!1})},l=async n=>{let r=a?.pausing??!1;o(void 0),r&&await t.toggleEnabled(e),n&&await t.cancelQueued(e)},u=e=>e.stopPropagation(),d=`/automations/${encodeURIComponent(e.id)}`,f=e.enabled?`Pause`:`Enable`;return(0,J.jsxs)(`span`,{"data-slot":`row-actions`,className:`inline-flex gap-0.5`,onClick:u,children:[e.kind===`schedule`?null:(0,J.jsx)(U,{label:`Preview matches`,children:(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Preview matches`,disabled:t.busy,onClick:()=>void t.preview(e),children:(0,J.jsx)(Ze,{className:`size-[13px]`})})}),(0,J.jsx)(U,{label:`Run now`,children:(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run now`,disabled:t.busy,onClick:()=>void t.runNow(e),children:(0,J.jsx)(lt,{className:`size-[13px]`})})}),(0,J.jsx)(U,{label:f,children:(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":f,disabled:t.busy,onClick:()=>void s(),children:e.enabled?(0,J.jsx)(wn,{className:`size-[13px]`}):(0,J.jsx)(Tn,{className:`size-[13px]`})})}),(0,J.jsxs)(Ge,{children:[(0,J.jsx)(Ue,{asChild:!0,children:(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`More`,children:(0,J.jsx)(Xe,{className:`size-3.5`})})}),(0,J.jsxs)(We,{align:`end`,className:`w-[200px]`,onClick:u,children:[(0,J.jsxs)(z,{onSelect:()=>n(d),children:[(0,J.jsx)(qe,{}),`Edit`]}),(0,J.jsxs)(z,{onSelect:()=>n(`${d}/log`),children:[(0,J.jsx)(En,{}),`View log`]}),(0,J.jsxs)(z,{onSelect:()=>void t.duplicate(e),children:[(0,J.jsx)(Ke,{}),`Duplicate`]}),(0,J.jsxs)(z,{onSelect:()=>void t.copyCli(e),children:[(0,J.jsx)(dt,{}),`Copy as CLI`]}),e.enabled?null:(0,J.jsxs)(z,{onSelect:()=>void c(),children:[(0,J.jsx)(Sn,{}),`Pending tasks…`]}),(0,J.jsx)(He,{}),(0,J.jsxs)(z,{variant:`destructive`,onSelect:()=>i(!0),children:[(0,J.jsx)(ft,{}),`Delete`]})]})]}),(0,J.jsx)(ui,{automation:e,work:a?.work,pausing:a?.pausing??!1,onOpenChange:e=>{e||o(void 0)},onConfirm:e=>void l(e)}),(0,J.jsx)(Lt,{open:r,onOpenChange:i,children:(0,J.jsxs)(Mt,{onClick:u,children:[(0,J.jsxs)(It,{children:[(0,J.jsxs)(jt,{children:[`Delete “`,e.name,`”?`]}),(0,J.jsx)(At,{children:`The automation is deleted and cannot be undone. Tasks it already launched and its execution log stay.`})]}),(0,J.jsxs)(Pt,{children:[(0,J.jsx)(Ft,{children:`Cancel`}),(0,J.jsx)(Nt,{"data-variant":`destructive`,className:Le({variant:`destructive`}),onClick:()=>void t.remove(e),children:`Delete`})]})]})})]})}function fi(e){let t=typeof e==`object`&&e&&!Array.isArray(e)?e:{},n=t.sort===`manual`||t.sort===`nextRun`?t.sort:`name`,r=new Set;if(Array.isArray(t.order))for(let e of t.order){if(typeof e!=`string`)continue;let t=e.trim();if(t&&t.length<=200&&r.add(t),r.size>=200)break}return{sort:n,order:[...r]}}function pi(e,t,n){if(!e.enabled||e.kind!==`schedule`)return null;if(e.nextRunAt!==void 0){let t=Date.parse(e.nextRunAt);return Number.isFinite(t)?t:null}let r=`schedules`in e?e.schedules:void 0,i=null;for(let a of Array.isArray(r)?r:[e.schedule]){let e=se.safeParse(a);if(!e.success)continue;let r=ce(e.data,n,t);r!==null&&Number.isFinite(r)&&(i===null||r<i)&&(i=r)}return i}var mi=(e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id);function hi(e,t,n,r){if(t.sort===`manual`){let n=new Map(t.order.map((e,t)=>[e,t])),r=e.filter(e=>!n.has(e.id)).sort(mi),i=e.filter(e=>n.has(e.id)).sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0));return[...r,...i]}if(t.sort===`name`)return[...e].sort(mi);let i=e=>{let t=pi(e,n,r);return t===null?[e.enabled&&e.kind!==`schedule`?1:2,0]:[0,t]},a=new Map(e.map(e=>[e.id,i(e)]));return[...e].sort((e,t)=>{let n=a.get(e.id),r=a.get(t.id);return n===void 0||r===void 0?mi(e,t):n[0]-r[0]||n[1]-r[1]||mi(e,t)})}function gi(e,t,n){if(t<0||n<0||t>=e.length||n>=e.length||t===n)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}var Z=`h-[38px] border-b border-border px-[10px] text-left eyebrow whitespace-nowrap text-soft-foreground`,Q=`h-12 border-b border-border px-[10px] text-ui leading-none whitespace-nowrap`,_i=`cz-auto-wide max-[1280px]:hidden`,vi=(0,J.jsx)(`span`,{className:`text-label text-soft-foreground`,children:`—`});function yi({data:e,actions:t,now:n=Date.now(),automations:r=e.automations,reorder:i}){let a=yt(vt(xt,{activationConstraint:{distance:4}}),vt(_t,{coordinateGetter:bt})),o=e=>{let t=r.findIndex(t=>t.id===e),n=r[t];return n?`${n.name}, position ${t+1} of ${r.length}`:`automation`};return(0,J.jsx)(wt,{sensors:a,collisionDetection:Et,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${o(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${o(e.id)} moved to ${o(t.id)}.`:`No drop position.`,onDragEnd:({active:e,over:t})=>t?`${o(e.id)} dropped at ${o(t.id)}.`:`Order unchanged.`,onDragCancel:()=>`Reordering cancelled. The order is unchanged.`}},onDragEnd:({active:e,over:t})=>{if(!i?.enabled||t===null)return;let n=r.findIndex(t=>t.id===e.id),a=r.findIndex(e=>e.id===t.id);n>=0&&a>=0&&n!==a&&i.onMove(n,a)},children:(0,J.jsx)(M,{flush:!0,"data-slot":`automations-table`,className:`min-w-0 overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full border-collapse [&_tbody_tr:last-child>td]:border-b-0`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[i?(0,J.jsx)(`th`,{className:Z,children:`Order`}):null,(0,J.jsx)(`th`,{className:A(Z,`pl-4`),children:`State`}),(0,J.jsx)(`th`,{className:Z,children:`Automation`}),(0,J.jsx)(`th`,{className:Z,children:`Trigger`}),(0,J.jsx)(`th`,{className:A(Z,_i),children:`Runs as`}),(0,J.jsx)(`th`,{className:Z,children:`Next run`}),(0,J.jsx)(`th`,{className:Z,children:`Last run`}),(0,J.jsx)(`th`,{className:A(Z,_i,`text-right`),children:`Runs 7d`}),null,(0,J.jsx)(`th`,{className:A(Z,`pr-4`)})]})}),(0,J.jsx)(`tbody`,{children:(0,J.jsx)(Tt,{items:r.map(e=>e.id),strategy:St,children:r.map((a,o)=>(0,J.jsx)(bi,{automation:a,actions:t,timeZone:e.timeZone,available:e.available,showCost:!1,now:n,position:o,total:r.length,...i?{reorder:i}:{}},a.id))})})]})})})}function bi({automation:e,actions:t,timeZone:n,available:r,showCost:i,now:a,position:o,total:s,reorder:c}){let l=V(),u=gt({id:e.id,disabled:!c?.enabled}),d=e.kind===`github`,f=sr(e,r),p=e.task.dispatch,m=Oe(e),h=[e.task.workflow,e.task.runner].filter(Boolean),g=e.lastRun?or(e.lastRun.status):void 0,_=e=>e.stopPropagation();return(0,J.jsxs)(`tr`,{ref:u.setNodeRef,style:{transform:Ct.Transform.toString(u.transform),transition:u.transition},"data-slot":`automation-row`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,className:A(`group/row cursor-pointer hover:bg-muted`,!e.enabled&&`opacity-60`),onClick:()=>l(`/automations/${encodeURIComponent(e.id)}`),children:[c?(0,J.jsx)(`td`,{className:A(Q,`w-px`),onClick:_,children:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,className:`touch-none cursor-grab`,ref:u.setActivatorNodeRef,...u.attributes,...u.listeners,"aria-label":`Reorder ${e.name}`,disabled:!c.enabled,children:(0,J.jsx)(nt,{className:`size-3.5`})}),(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Move ${e.name} up`,disabled:!c.enabled||o===0,onClick:()=>c.onMove(o,o-1),children:(0,J.jsx)(Te,{className:`size-3.5`})}),(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Move ${e.name} down`,disabled:!c.enabled||o===s-1,onClick:()=>c.onMove(o,o+1),children:(0,J.jsx)(Se,{className:`size-3.5`})})]})}):null,(0,J.jsx)(`td`,{className:A(Q,`pl-4`),children:(0,J.jsx)(Jt,{dot:f.tone,pulse:f.pulse,children:f.label})}),(0,J.jsx)(`td`,{className:A(Q,`max-w-0 min-w-[200px]`),children:(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[d?(0,J.jsx)(B,{className:`size-3.5 shrink-0 text-soft-foreground`}):e.kind===`tracker`?(0,J.jsx)(Ee,{className:`size-3.5 shrink-0 text-soft-foreground`}):(0,J.jsx)(_n,{className:`size-3.5 shrink-0 text-soft-foreground`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ui font-medium text-ellipsis whitespace-nowrap`,children:e.name}),p?(0,J.jsx)(U,{label:`Dispatch · up to ${p.maxSubtasks??1} subtasks`,children:(0,J.jsxs)(`span`,{"data-slot":`dispatch-badge`,"aria-label":`dispatch · up to ${p.maxSubtasks??1} subtasks`,className:`inline-flex shrink-0 items-center gap-[3px] rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:[(0,J.jsx)(et,{className:`size-2.5`}),`×`,p.maxSubtasks??1]})}):null,e.kind===`tracker`&&e.trackerTrigger&&!e.trackerTrigger.access?(0,J.jsx)(U,{label:`Tracker access changed — open this automation and review its access`,children:(0,J.jsxs)(`span`,{"data-slot":`needs-review-badge`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full bg-muted px-1.5 py-px text-micro font-medium text-muted-foreground`,children:[(0,J.jsx)(G,{tone:`info`}),`Needs review`]})}):null]})}),(0,J.jsx)(`td`,{"data-slot":`trigger`,className:A(Q,`max-w-[320px] overflow-hidden text-label text-ellipsis text-muted-foreground`),title:m,children:m}),(0,J.jsx)(`td`,{className:A(Q,_i,`text-label text-muted-foreground`),children:h.length?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[h.map((e,t)=>(0,J.jsxs)(`span`,{className:`contents`,children:[t>0?(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}):null,e]},e)),e.task.autonomous?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsx)(U,{label:`Autonomous`,children:(0,J.jsx)(`span`,{"aria-label":`autonomous`,"data-slot":`autonomous-mark`,className:`inline-flex`,children:(0,J.jsx)(Ee,{"aria-hidden":`true`,className:`size-[11px] text-soft-foreground`})})})]}):null]}):vi}),(0,J.jsx)(`td`,{"data-slot":`next-run`,className:A(Q,`tabular-nums`,e.enabled?`text-foreground`:`text-soft-foreground`),children:xi(e,n,a)}),(0,J.jsx)(`td`,{className:Q,children:e.lastRun&&g?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,J.jsx)(G,{tone:g.tone,pulse:g.pulse}),(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:g.label}),(0,J.jsx)(`span`,{className:`text-label text-soft-foreground`,children:qt(e.lastRun.ts,a)}),(0,J.jsxs)(H,{to:`/tasks/${encodeURIComponent(e.lastRun.runId)}`,"data-slot":`task-link`,onClick:_,className:`inline-flex items-center gap-0.5 rounded-full border border-violet/40 px-1.5 py-px text-micro font-semibold text-violet`,children:[`task`,(0,J.jsx)(we,{className:`size-[9px]`})]})]}):vi}),(0,J.jsx)(`td`,{className:A(Q,_i,`text-right text-label text-muted-foreground tabular-nums`),children:e.runs7d}),i?(0,J.jsx)(`td`,{className:A(Q,_i,`text-right text-label text-muted-foreground tabular-nums`),children:e.costUsd7d===void 0?vi:je(e.costUsd7d)}):null,(0,J.jsx)(`td`,{className:A(Q,`pr-3 text-right`,`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 has-[[data-state=open]]:opacity-100 no-hover:opacity-100`),children:(0,J.jsx)(di,{automation:e,actions:t})})]})}function xi(e,t,n){if(!e.enabled)return`—`;if(e.kind!==`schedule`)return`continuous`;let r=pi(e,t,n);return r===null?`—`:Pe(r,t)||`—`}var Si=new WeakMap;function Ci(){let e=ee(),t=C(),n=k(),r=(0,q.useMemo)(()=>T.uiState,[n]),i=fi(t.data?.automationList),a=t=>{let i=e.getQueryData(r);if(i===void 0)return;let a=i.automationList,o={...typeof a==`object`&&a&&!Array.isArray(a)?a:{},...fi(a),...t};e.setQueryData(r,{...i,automationList:o});let s=Si.get(e);s===void 0&&(s=new Map,Si.set(e,s));let c=s.get(n);c===void 0&&(c={sequence:0,chain:Promise.resolve()},s.set(n,c));let l=++c.sequence,u=c,d=c.chain.then(async()=>{let t=await b({automationList:o},n);l===u.sequence&&e.setQueryData(r,t)});c.chain=d.catch(t=>{Kt(t instanceof Error?t.message:String(t),{tone:`danger`}),l===u.sequence&&e.invalidateQueries({queryKey:r})})};return{preferences:i,canSave:t.data!==void 0,loadError:t.isError&&t.data===void 0,retry:()=>{t.refetch()},setSort:e=>a({sort:e}),setOrder:e=>a({order:fi({order:e}).order})}}function wi(e){return e.hour*60+e.minute}function Ti(e,t,n=0){let r=O(e,t);if(!r)return null;let i=new Date(Date.UTC(r.year,r.month-1,r.day+n));return le(i.getUTCFullYear(),i.getUTCMonth()+1,i.getUTCDate(),0,0,t)}function Ei(e,t,n,r){let i=[];for(let a of e)if(!(a.kind!==`schedule`||!a.schedule))for(let e of ie(a,t,n,r)){let t=O(e,r);t&&i.push({automation:a,at:e,parts:t})}return i.sort((e,t)=>e.at-t.at)}function Di(e){let t=new Map;return e.map(e=>{let n=wi(e.parts),r=t.get(n)??0;return t.set(n,r+1),{occurrence:e,stack:r}})}function Oi({automation:e,minute:t,stack:n=0,wide:r=!1}){let i=V(),a=D(Math.floor(t/60),t%60),o=[e.task.workflow,e.task.runner].filter(Boolean).join(` · `);return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`event-block`,"data-automation":e.id,"data-enabled":e.enabled?`true`:`false`,"aria-label":`${e.name} · ${a}`,title:`${e.name} · ${a}`,onClick:()=>i(`/automations/${encodeURIComponent(e.id)}`),className:A(`absolute right-[3px] left-[3px] flex cursor-pointer overflow-hidden rounded-[6px] border border-border bg-card text-left text-meta leading-[1.3] font-medium text-foreground shadow-xs`,r?`h-12 flex-col items-start gap-[3px] px-2 py-[5px]`:`h-6 flex-row items-center gap-1.5 px-1.5`,!e.enabled&&`opacity-50`),style:{top:t/60*34+1+26*n},children:[(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(G,{tone:e.task.runner===`codex`?`violet`:`success`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),r?(0,J.jsxs)(`span`,{className:`max-w-full overflow-hidden text-micro leading-[1.3] font-normal text-ellipsis whitespace-nowrap text-muted-foreground tabular-nums`,children:[a,o?` · ${o}`:``]}):null]})}function ki(){return(0,J.jsx)(`div`,{"data-slot":`hour-gutter`,className:`w-12 shrink-0`,children:Array.from({length:24},(e,t)=>(0,J.jsx)(`div`,{className:`-translate-y-[6px] pr-2 text-right text-micro text-soft-foreground tabular-nums`,style:{height:34},children:t?D(t):``},t))})}function Ai({minute:e}){return(0,J.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`now-line`,className:`absolute inset-x-0 z-[2] h-[2px] bg-primary`,style:{top:e/60*34},children:(0,J.jsx)(`span`,{className:`absolute -top-[3px] -left-[3px] size-[8px] rounded-full bg-primary`})})}function ji(){return(0,J.jsx)(J.Fragment,{children:Array.from({length:24},(e,t)=>(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 h-px bg-border`,style:{top:t*34}},t))})}function Mi({automations:e}){let t=e.filter(e=>e.kind===`github`&&e.enabled);return t.length?(0,J.jsxs)(`div`,{"data-slot":`poll-band`,className:`grid grid-cols-[48px_minmax(0,1fr)] border-b border-border`,children:[(0,J.jsx)(`div`,{className:`py-2 pr-2 text-right text-micro text-soft-foreground`,children:`poll`}),(0,J.jsx)(`div`,{className:`flex flex-col gap-1 border-l border-border px-2 py-1.5`,children:t.map(e=>(0,J.jsxs)(`div`,{"data-slot":`poll-row`,className:`flex h-[22px] min-w-0 items-center gap-2 overflow-hidden rounded-[6px] border border-violet/25 bg-violet/8 px-2 text-meta font-medium`,children:[(0,J.jsx)(B,{className:`size-3 shrink-0 text-violet`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name}),(0,J.jsx)(`span`,{className:`overflow-hidden text-micro font-normal text-ellipsis whitespace-nowrap text-muted-foreground`,children:Oe(e)}),(0,J.jsxs)(`span`,{className:`ml-auto shrink-0 text-micro font-normal whitespace-nowrap text-soft-foreground tabular-nums`,children:[e.runs7d,` runs`]})]},e.id))})]}):null}var Ni=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function Pi({data:e}){let t=pe(6e4),n=V(),[r,i]=(0,q.useState)(0),a=e.timeZone,o=Ti(t,a,r),s=Ti(t,a,r+1),c=o===null?null:O(o,a),l=O(t,a);if(o===null||s===null||!c||!l)return(0,J.jsx)(`div`,{"data-slot":`day-view`,className:`p-5`,children:(0,J.jsxs)(`p`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:[`Cannot draw the day: unknown time zone “`,a,`”.`]})});let u=r===0,d=Di(Ei(e.automations,o,s,a)),f=e.automations.filter(e=>e.kind===`github`&&e.enabled),p=`${Me(c.weekday)} ${c.day} ${Ni[c.month-1]??``}`;return(0,J.jsxs)(`div`,{"data-slot":`day-view`,className:`grid grid-cols-[minmax(0,1fr)_320px] items-start gap-4 p-5 max-md:grid-cols-1`,children:[(0,J.jsxs)(M,{flush:!0,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3.5 py-2.5`,children:[(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous day`,onClick:()=>i(e=>e-1),children:(0,J.jsx)(ze,{className:`size-3.5`})}),(0,J.jsx)(N,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next day`,onClick:()=>i(e=>e+1),children:(0,J.jsx)(Re,{className:`size-3.5`})}),(0,J.jsx)(`span`,{"data-slot":`day-title`,className:`text-sm font-semibold whitespace-nowrap`,children:p}),u?(0,J.jsx)(Jt,{dot:`success`,children:`today`}):null,(0,J.jsxs)(`span`,{className:`ml-auto text-label whitespace-nowrap text-muted-foreground`,children:[d.length,` scheduled runs`,f.length?` · ${f.length} GitHub poll${f.length===1?``:`s`}`:``]})]}),(0,J.jsx)(Mi,{automations:e.automations}),(0,J.jsxs)(`div`,{className:`flex max-h-[600px] overflow-y-auto`,children:[(0,J.jsx)(ki,{}),(0,J.jsxs)(`div`,{"data-slot":`day-column`,"data-today":u?`true`:void 0,className:`relative flex-1 border-l border-border`,style:{height:816},children:[(0,J.jsx)(ji,{}),u?(0,J.jsx)(Ai,{minute:wi(l)}):null,d.map(({occurrence:e,stack:t})=>(0,J.jsx)(Oi,{automation:e.automation,minute:wi(e.parts),stack:t,wide:!0},`${e.automation.id}-${e.at}`))]})]})]}),(0,J.jsxs)(M,{flush:!0,"data-slot":`agenda`,className:`py-3`,children:[(0,J.jsx)(`div`,{className:`px-3.5 pb-2 eyebrow text-soft-foreground`,children:`Agenda`}),f.map(e=>(0,J.jsxs)(`button`,{type:`button`,"data-slot":`agenda-poll`,onClick:()=>n(`/automations/${encodeURIComponent(e.id)}`),className:`grid w-full cursor-pointer grid-cols-[48px_1fr] gap-2.5 px-3.5 py-2 text-left hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:`text-micro font-medium text-soft-foreground`,children:`poll`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-ui font-medium`,children:[(0,J.jsx)(B,{className:`size-3 shrink-0 text-violet`}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:e.name})]}),(0,J.jsxs)(`span`,{className:`mt-0.5 block overflow-hidden text-meta leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:[Oe(e),` · continuous`]})]})]},e.id)),d.map(({occurrence:e})=>{let r=e.at<t,{automation:i}=e,a=r&&i.lastRun?or(i.lastRun.status):void 0;return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`agenda-row`,"data-past":r?`true`:`false`,onClick:()=>n(`/automations/${encodeURIComponent(i.id)}`),className:`grid w-full cursor-pointer grid-cols-[48px_1fr] gap-2.5 px-3.5 py-2 text-left hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:A(`text-label font-medium tabular-nums`,r?`text-soft-foreground`:`text-foreground`),children:D(e.parts.hour,e.parts.minute)}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsxs)(`span`,{className:A(`flex items-center gap-2 text-ui font-medium`,r&&`text-muted-foreground`),children:[(0,J.jsx)(G,{tone:a?.tone??`neutral`,pulse:a?.pulse??!1}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-nowrap`,children:i.name})]}),(0,J.jsx)(`span`,{className:`mt-0.5 block overflow-hidden text-meta leading-[1.4] text-ellipsis whitespace-nowrap text-soft-foreground`,children:i.task.prompt})]})]},`${i.id}-${e.at}`)}),d.length===0?(0,J.jsx)(`p`,{className:`px-3.5 py-2 text-label text-soft-foreground`,children:f.length?`Nothing scheduled — the GitHub polls above still run.`:`Nothing scheduled.`}):null]})]})}function Fi(e,t,n,r=12){let i=[];for(let a of e)if(!(!a.enabled||a.kind!==`schedule`||!a.schedule))for(let e of ie(a,t,t+14*864e5,n,r))i.push({automation:a,at:e});return i.sort((e,t)=>e.at-t.at).slice(0,r)}function Ii({open:e,onOpenChange:t,upcoming:n,pollCount:r,timeZone:i,now:a}){let o=V(),s=O(a,i);return(0,J.jsx)(xe,{open:e,onOpenChange:t,children:(0,J.jsxs)(be,{side:`right`,"data-slot":`next-runs-rail`,"aria-describedby":void 0,className:`w-[360px] gap-0 sm:max-w-[360px]`,children:[(0,J.jsxs)(_e,{className:`px-4 pt-4 pb-2`,children:[(0,J.jsxs)(ye,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,J.jsx)(ke,{className:`size-4`}),`Next runs`]}),(0,J.jsx)(ve,{className:`sr-only`,children:`Upcoming scheduled runs, soonest first.`})]}),(0,J.jsxs)(`div`,{className:`overflow-y-auto`,children:[n.map((e,n)=>{let r=O(e.at,i),c=r!==null&&s!==null&&r.year===s.year&&r.month===s.month&&r.day===s.day,l=r?`${c?``:`${Me(r.weekday)} `}${D(r.hour,r.minute)}`:``;return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`next-run-row`,"data-automation":e.automation.id,onClick:()=>{t(!1),o(`/automations/${encodeURIComponent(e.automation.id)}`)},className:`grid w-full cursor-pointer grid-cols-[76px_1fr_auto] items-center gap-2 px-4 py-2 text-left text-ui hover:bg-muted`,children:[(0,J.jsx)(`span`,{className:`text-label font-medium whitespace-nowrap text-muted-foreground tabular-nums`,children:l}),(0,J.jsx)(`span`,{className:`overflow-hidden text-ui font-medium text-ellipsis whitespace-nowrap`,children:e.automation.name}),(0,J.jsx)(`span`,{className:`text-meta whitespace-nowrap text-soft-foreground`,children:De(e.at,a)})]},`${e.automation.id}-${n}`)}),n.length===0?(0,J.jsx)(`p`,{className:`px-4 py-2 text-label text-soft-foreground`,children:`No scheduled runs in the next two weeks.`}):null,(0,J.jsxs)(`div`,{"data-slot":`next-runs-footer`,className:`mt-1.5 flex items-center gap-2 border-t border-border px-3.5 pt-2.5 pb-1 text-label text-muted-foreground`,children:[(0,J.jsx)(G,{tone:`pending`,pulse:!0}),r,` GitHub polls running continuously`]})]})]})})}function Li({stats:e,pollCount:t,upcoming:n,timeZone:r,railOpen:i,onOpenRail:a}){let o=n[0];return(0,J.jsxs)(`div`,{"data-slot":`stats-strip`,className:`flex flex-wrap items-center gap-4 text-label text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`eyebrow text-soft-foreground`,children:`This week`}),(0,J.jsx)(Ri,{label:`runs`,value:String(e.runs)}),null,(0,J.jsx)(Ri,{label:`failed`,value:String(e.failed),danger:e.failed>0}),(0,J.jsx)(Ri,{label:`agent time`,value:Ie(e.agentSeconds)}),(0,J.jsxs)(`span`,{"data-slot":`stats-polls`,className:`inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,J.jsx)(G,{tone:`pending`,pulse:!0}),t,` GitHub polls continuous`]}),(0,J.jsx)(`span`,{className:`flex-1`}),(0,J.jsxs)(`span`,{"data-slot":`stats-next`,className:`inline-flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,J.jsx)(_n,{className:`size-[13px] text-soft-foreground`}),`next`,` `,(0,J.jsx)(`b`,{className:`text-label font-medium text-foreground tabular-nums`,children:o?Fe(o.at,r):`—`}),` `,(0,J.jsx)(`span`,{className:`max-w-[180px] overflow-hidden text-ellipsis`,children:o?.automation.name??``})]}),(0,J.jsxs)(N,{variant:`outline`,size:`sm`,"aria-expanded":i,className:`shrink-0`,onClick:a,children:[(0,J.jsx)(ke,{className:`size-3.5`}),`Next runs`,(0,J.jsx)(`span`,{className:`text-meta font-medium text-muted-foreground tabular-nums`,children:n.length})]})]})}function Ri({label:e,value:t,danger:n=!1}){return(0,J.jsxs)(`span`,{"data-slot":`stat`,"data-label":e,className:`inline-flex shrink-0 items-baseline gap-[5px] whitespace-nowrap`,children:[(0,J.jsx)(`b`,{className:A(`text-body font-semibold tabular-nums`,n?`text-danger`:`text-foreground`),children:t}),e]})}var zi=e=>e instanceof Error?e.message:String(e);function Bi(){let[e,t]=(0,q.useState)(!1);return{run:async()=>{t(!0);try{let e=await u(),t=URL.createObjectURL(new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`cezar-automations-${e.exportedAt.slice(0,10)}.json`,document.body.append(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)}catch(e){Kt(zi(e),{tone:`danger`})}finally{t(!1)}},busy:e}}function Vi(e,t){let n={};for(let r of e){let e=t[r.index];if(e)if(r.collision){if(!e.action)continue;n[String(r.index)]={action:e.action,...e.action!==`skip`&&e.acceptCommands?{acceptCommands:!0}:{}}}else e.acceptCommands&&(n[String(r.index)]={action:`create`,acceptCommands:!0})}return n}var Hi={create:{label:`Create`,className:`border-success/40 text-success`},rename:{label:`Rename`,className:`border-violet/40 text-violet`},replace:{label:`Replace`,className:`border-warning/40 text-warning`},skip:{label:`Skip`,className:`text-muted-foreground`}};function Ui(e){let t=e.filter(e=>e.action===`replace`).length,n=e.filter(e=>e.action===`create`||e.action===`rename`).length,r=e=>`${e} automation${e===1?``:`s`}`;return t?n?`Import ${r(n)} and replace ${t} (paused)`:`Replace ${r(t)} (paused)`:`Import ${r(n)} (paused)`}function Wi({open:e,onOpenChange:t}){let n=ee(),i=(0,q.useId)(),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)({}),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),[_,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(0),S=(0,q.useRef)(0),C=()=>{S.current++,o(null),c({}),u(null),f(null),m(null),g(!1),y(!1)},w=l?Vi(l.rows,s):{},te=JSON.stringify(w);(0,q.useEffect)(()=>{if(!a)return;let e=++S.current;g(!0),r({file:a,...te===`{}`?{}:{resolutions:JSON.parse(te)}}).then(t=>{e===S.current&&(u(t),f(null))}).catch(t=>{e===S.current&&(u(null),f(zi(t)))}).finally(()=>{e===S.current&&g(!1)})},[a,te,b]);let T=async e=>{if(C(),!e)return;let t;try{t=JSON.parse(await e.text())}catch{f(`"${e.name}" is not valid JSON — pick a file cezar exported.`);return}o(t)},E=l?.rows??[],ne=E.some(e=>e.action!==`skip`&&e.issues.length>0),re=E.filter(e=>e.action!==`skip`).length,ie=async()=>{if(!(!a||!l)){y(!0),m(null);try{let e=await v({file:a,...Object.keys(w).length?{resolutions:w}:{},planDigest:l.planDigest}),r=e.created.length+e.replaced.length;Kt(`Imported ${r} automation${r===1?``:`s`}, paused.`),n.invalidateQueries({queryKey:dn()}),C(),t(!1)}catch(e){m(zi(e))}finally{y(!1)}}},ae=(e,t)=>c(n=>({...n,[e]:{...n[e],...t}}));return(0,J.jsx)(Ut,{open:e,onOpenChange:e=>{e||C(),t(e)},children:(0,J.jsxs)(Bt,{"data-slot":`automations-import`,className:`max-h-[90dvh] overflow-y-auto sm:max-w-3xl`,children:[(0,J.jsxs)(Rt,{children:[(0,J.jsx)(Vt,{children:`Import automations`}),(0,J.jsx)(Ht,{children:`Pick a file exported from cezar. Nothing is written until you confirm, and every imported automation lands paused.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:`Automations file`}),(0,J.jsx)(`input`,{id:i,type:`file`,accept:`.json,application/json`,"data-slot":`automations-import-file`,onChange:e=>void T(e.target.files?.[0]),className:`block w-full text-sm text-muted-foreground file:mr-3 file:rounded-md file:border file:border-input file:bg-card file:px-3 file:py-1.5 file:text-sm file:text-foreground focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`})]}),d?(0,J.jsx)(`p`,{role:`alert`,"data-slot":`automations-import-error`,className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-sm text-danger`,children:d}):null,l?E.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This file has no automations.`}):(0,J.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,J.jsxs)(`table`,{"data-slot":`automations-import-preview`,"aria-busy":h,className:`w-full text-sm`,children:[(0,J.jsx)(`thead`,{className:`bg-muted/50 text-left`,children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,className:`px-3 py-2 eyebrow text-soft-foreground`,children:`Name`}),(0,J.jsx)(`th`,{scope:`col`,className:`px-3 py-2 eyebrow text-soft-foreground`,children:`Kind`}),(0,J.jsx)(`th`,{scope:`col`,className:`px-3 py-2 eyebrow text-soft-foreground`,children:`Action`}),(0,J.jsx)(`th`,{scope:`col`,className:`px-3 py-2 eyebrow text-soft-foreground`,children:`Notes`})]})}),(0,J.jsx)(`tbody`,{children:E.map(e=>(0,J.jsx)(Gi,{row:e,choice:s[e.index]??{},onChoice:t=>ae(e.index,t)},e.index))})]})}):h?(0,J.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Reading the file…`}):null,p?(0,J.jsxs)(`div`,{role:`alert`,"data-slot":`automations-import-conflict`,className:`flex flex-wrap items-center gap-3 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-sm text-danger`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1`,children:p}),(0,J.jsx)(N,{size:`sm`,variant:`outline`,onClick:()=>{m(null),x(e=>e+1)},children:`Review again`})]}):null,(0,J.jsxs)(zt,{children:[(0,J.jsx)(N,{variant:`outline`,onClick:()=>{C(),t(!1)},children:`Cancel`}),(0,J.jsx)(N,{"data-action":`automations-import-confirm`,disabled:!l||h||_||ne||re===0||p!==null,onClick:()=>void ie(),children:Ui(E)})]})]})})}function Gi({row:e,choice:t,onChoice:n}){let r=e.action,i=Hi[r],a=e.newName??`${e.name} (imported)`;return(0,J.jsxs)(`tr`,{"data-row":e.index,className:A(`border-t border-border align-top`,e.action===`skip`&&`text-muted-foreground`),children:[(0,J.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,J.jsx)(`div`,{className:`font-medium text-foreground`,children:e.name}),e.runsCommands?(0,J.jsxs)(Je,{variant:`outline`,className:`mt-1 border-warning/40 text-warning`,children:[(0,J.jsx)(mt,{"aria-hidden":!0}),`runs shell commands`]}):null]}),(0,J.jsx)(`td`,{className:`px-3 py-2 capitalize`,children:e.kind}),(0,J.jsx)(`td`,{className:`px-3 py-2`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(Je,{variant:`outline`,"data-action-chip":r,className:i.className,children:i.label}),e.collision?(0,J.jsxs)(R,{value:t.action??e.action,onValueChange:e=>n({action:e}),children:[(0,J.jsx)(I,{size:`sm`,"aria-label":`Action for ${e.name}`,className:`w-full min-w-44 text-ui`,children:(0,J.jsx)(L,{})}),(0,J.jsxs)(F,{children:[(0,J.jsx)(P,{value:`skip`,children:`Skip`}),(0,J.jsx)(P,{value:`rename`,children:`Rename to "${a}"`}),e.collision.id?(0,J.jsx)(P,{value:`replace`,children:`Replace`}):null]})]}):null]})}),(0,J.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,J.jsxs)(`ul`,{className:`flex flex-col gap-1 text-label`,children:[e.collision&&e.action===`skip`?(0,J.jsx)(`li`,{className:`text-muted-foreground`,children:`An automation named "${e.collision.name}" already exists.`}):null,e.action===`replace`&&e.collision?(0,J.jsx)(`li`,{className:`text-warning`,children:`Replaces and pauses "${e.collision.name}".`}):null,e.action===`rename`&&e.collision?(0,J.jsx)(`li`,{children:`Lands as "${a}".`}):null,e.issues.map(e=>(0,J.jsx)(`li`,{className:`text-danger`,children:e},e)),e.warnings.map(e=>(0,J.jsx)(`li`,{className:`text-warning`,children:e},e))]}),e.runsCommands&&e.action!==`skip`?(0,J.jsxs)(`label`,{className:`mt-1.5 flex items-start gap-2 text-label text-foreground`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t.acceptCommands===!0,onChange:e=>n({acceptCommands:e.target.checked}),className:`mt-0.5 accent-primary`}),`I reviewed its shell commands and allow them to run`]}):null]})]})}var Ki=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function qi({data:e}){let t=pe(6e4),n=e.timeZone,r=O(t,n),i=r?Array.from({length:8},(e,i)=>Ti(t,n,i-(r.weekday-1))):[],a=i[0],o=i[7];if(!r||a==null||o==null)return(0,J.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,J.jsxs)(`p`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:[`Cannot draw the week: unknown time zone “`,n,`”.`]})});let s=r.weekday-1,c=Ei(e.automations,a,o,n),l=Ki.map((e,t)=>{let r=i[t];return{label:e,dayOfMonth:r==null?null:O(r,n)?.day??null,isToday:t===s,blocks:Di(c.filter(e=>e.parts.weekday-1===t))}});return(0,J.jsx)(`div`,{"data-slot":`week-view`,className:`p-5`,children:(0,J.jsxs)(M,{flush:!0,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[48px_repeat(7,minmax(0,1fr))] border-b border-border`,children:[(0,J.jsx)(`div`,{}),l.map(e=>(0,J.jsxs)(`div`,{"data-slot":`week-day-header`,"data-today":e.isToday?`true`:void 0,className:A(`flex items-center gap-2 border-l border-border px-2 py-2.5 eyebrow`,e.isToday?`text-foreground`:`text-soft-foreground`),children:[e.label,(0,J.jsx)(`span`,{className:A(`rounded-full px-[7px] py-px text-ui font-medium tracking-normal normal-case`,e.isToday?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e.dayOfMonth??``})]},e.label))]}),(0,J.jsx)(Mi,{automations:e.automations}),(0,J.jsxs)(`div`,{className:`flex max-h-[560px] overflow-y-auto`,children:[(0,J.jsx)(ki,{}),l.map(e=>(0,J.jsxs)(`div`,{"data-slot":`week-column`,"data-today":e.isToday?`true`:void 0,className:A(`relative min-w-0 flex-1 border-l border-border`,e.isToday&&`bg-muted/35`),style:{height:816},children:[(0,J.jsx)(ji,{}),e.isToday?(0,J.jsx)(Ai,{minute:wi(r)}):null,e.blocks.map(({occurrence:e,stack:t})=>(0,J.jsx)(Oi,{automation:e.automation,minute:wi(e.parts),stack:t},`${e.automation.id}-${e.at}`))]},e.label))]})]})})}function Ji(e){return[{value:`list`,label:`List`,...e===void 0?{}:{count:e}},{value:`week`,label:`Week`},{value:`day`,label:`Day`}]}function Yi({data:e,error:t,actions:n,view:r,onViewChange:i}){let[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),d=Bi(),{preferences:f,canSave:p,loadError:m,retry:h,setSort:g,setOrder:_}=Ci(),v=Date.now(),y=e?Fi(e.automations,v,e.timeZone,12):[],b=e?e.automations.filter(e=>e.kind===`github`&&e.enabled).length:0,x=e?hi(e.automations,f,e.timeZone,v):[],S=x.length<=200,C=e?cr(e.scheduler.state):void 0;return(0,J.jsxs)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col`,children:[(0,J.jsxs)(`header`,{className:`sticky top-0 z-10 shrink-0 border-b border-border bg-background`,children:[(0,J.jsxs)(`div`,{"data-slot":`automations-title`,className:`flex h-14 items-center gap-3 px-5`,children:[(0,J.jsx)(`h1`,{className:`text-base font-semibold`,children:`Automations`}),(0,J.jsx)(`div`,{className:`flex-1`}),e&&C?(0,J.jsxs)(`span`,{"data-slot":`automations-status`,className:`inline-flex min-w-0 items-center gap-2 overflow-hidden text-label text-ellipsis whitespace-nowrap text-muted-foreground max-[1280px]:hidden`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(G,{tone:C.tone,pulse:C.pulse}),C.label]}),(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(G,{tone:e.available?`success`:`neutral`}),e.available?`GitHub available`:`GitHub unavailable${e.reason?` · ${e.reason}`:``}`]}),(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:`·`}),(0,J.jsx)(`span`,{children:e.timeZone})]}):null]}),(0,J.jsxs)(`div`,{"data-slot":`automations-toolbar`,className:`flex min-h-12 flex-wrap items-center gap-3 px-5 pb-2 md:pb-0`,children:[(0,J.jsx)(ge,{slot:`automations-view`,label:`View`,value:r,options:Ji(e?.automations.length),onChange:i}),(0,J.jsx)(`div`,{className:`flex-1`}),(0,J.jsxs)(Ge,{children:[(0,J.jsx)(U,{label:`More actions`,children:(0,J.jsx)(Ue,{asChild:!0,children:(0,J.jsx)(N,{variant:`outline`,size:`icon`,"aria-label":`More actions`,"data-slot":`automations-more`,children:(0,J.jsx)(Xe,{className:`size-4`})})})}),(0,J.jsxs)(We,{align:`end`,className:`w-[220px]`,children:[(0,J.jsxs)(z,{"data-action":`automations-export`,disabled:!e?.automations.length||d.busy,onSelect:()=>void d.run(),children:[(0,J.jsx)(Ye,{}),`Export automations`]}),(0,J.jsxs)(z,{"data-action":`automations-import`,onSelect:()=>c(!0),children:[(0,J.jsx)($e,{}),`Import automations…`]}),(0,J.jsx)(He,{}),(0,J.jsxs)(z,{"data-slot":`automations-guide`,onSelect:()=>u(!0),children:[(0,J.jsx)(Ve,{}),`How automations work`]})]})]}),(0,J.jsx)(N,{asChild:!0,className:`shrink-0`,children:(0,J.jsxs)(H,{to:`/automations/new`,children:[(0,J.jsx)(ut,{className:`size-[15px]`}),`New automation`]})})]})]}),(0,J.jsx)(Wi,{open:s,onOpenChange:c}),l?(0,J.jsx)(Xr,{onOpenChange:u}):null,t===void 0?e?e.automations.length===0?(0,J.jsx)(`div`,{className:`flex flex-1 flex-col px-5`,children:(0,J.jsx)(Jr,{data:e})}):r===`week`?(0,J.jsx)(qi,{data:e}):r===`day`?(0,J.jsx)(Pi,{data:e}):(0,J.jsxs)(`div`,{"data-slot":`automations-list`,className:`flex flex-col gap-3 p-5`,children:[(0,J.jsx)(Li,{stats:e.stats,pollCount:b,upcoming:y,timeZone:e.timeZone,railOpen:a,onOpenRail:()=>o(!0)}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:`Sort`}),(0,J.jsx)(`fieldset`,{disabled:!p,"aria-label":`Automation sort`,className:`min-w-0`,children:(0,J.jsx)(ge,{slot:`automations-sort`,label:`Sort automations`,value:f.sort,options:[{value:`manual`,label:`Manual`},{value:`name`,label:`Name`},{value:`nextRun`,label:`Next run`}],onChange:g})}),p?f.sort===`manual`?(0,J.jsx)(`span`,{className:`text-label text-muted-foreground`,children:S?`Drag a handle or use Move up and down.`:`Manual placement supports up to 200 automations.`}):null:(0,J.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-2 text-label text-muted-foreground`,children:[m?`Saved order unavailable.`:`Loading saved order…`,m?(0,J.jsx)(N,{size:`sm`,variant:`ghost`,onClick:h,children:`Retry`}):null]})]}),(0,J.jsx)(yi,{data:e,automations:x,actions:n,now:v,...f.sort===`manual`?{reorder:{enabled:p&&S,onMove:(e,t)=>_(gi(x.map(e=>e.id),e,t))}}:{}}),(0,J.jsx)(Ii,{open:a,onOpenChange:o,upcoming:y,pollCount:b,timeZone:e.timeZone,now:v})]}):(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)($,{text:`Loading automations…`})}):(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)($,{text:t})})]})}function Xi({mode:e=`list`}){let{automationId:t}=de(),n=V(),r=fn(),i=$t(r.known&&!r.off),a=i.data?{...i.data,automations:i.data.automations.filter(e=>!e.deferredStart)}:void 0,o=un(a),[s,c]=fe(),l=Zi(s.get(`view`));if(!r.known)return(0,J.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,J.jsx)($,{text:`Loading automations…`})});if(r.off)return(0,J.jsx)(`div`,{"data-route":`automations`,className:`flex min-h-full flex-col p-3 md:p-5`,children:(0,J.jsx)(Yt,{icon:(0,J.jsx)(Ee,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This cockpit was started with CEZ_AUTOMATIONS=0. Unset it and restart the service to turn automations on.`,heading:`h2`})});let u=()=>n(`/automations`);if(e===`new`)return(0,J.jsx)(Lr,{data:a,initialKind:Qi(s.get(`kind`)),onBack:u,onSaved:u});if(e===`edit`){let e=a?.automations.find(e=>e.id===t);return a&&!e?(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Automation not found.`})}):e?(0,J.jsx)(Lr,{data:a,automation:e,actions:o,onBack:u,onSaved:u,onLog:()=>n(`/automations/${encodeURIComponent(e.id)}/log`)}):(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Loading automation…`})})}if(e===`log`){let e=a?.automations.find(e=>e.id===t);return t?(0,J.jsx)(Ur,{automationId:t,automation:e,timeZone:a?.timeZone,onBack:u}):(0,J.jsx)(`div`,{"data-route":`automations`,className:`p-5`,children:(0,J.jsx)($,{text:`Automation not found.`})})}return(0,J.jsx)(Yi,{data:a,error:i.error?String(i.error instanceof Error?i.error.message:i.error):void 0,actions:o,view:l,onViewChange:e=>c(t=>{let n=new URLSearchParams(t);return e===`list`?n.delete(`view`):n.set(`view`,e),n},{replace:!0})})}function Zi(e){return e===`week`||e===`day`?e:`list`}function Qi(e){return e===`schedule`||e===`github`||e===`tracker`?e:void 0}function $({text:e}){return(0,J.jsx)(`div`,{className:`rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e})}export{Xi as AutomationsRoute};
|