@hearsay-tools/squawk 0.18.0-pr4335.8428 → 0.18.0-pr4337.8439

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.
Files changed (149) hide show
  1. package/dist/automations/tools.d.ts +8 -8
  2. package/dist/autosave-cleanup.js +2 -1
  3. package/dist/autosave-cleanup.js.map +1 -1
  4. package/dist/boot.d.ts +5 -1
  5. package/dist/boot.js +5 -2
  6. package/dist/boot.js.map +1 -1
  7. package/dist/built-in-cli-commands.js +0 -4
  8. package/dist/built-in-cli-commands.js.map +1 -1
  9. package/dist/built-in-launch-parts.d.ts +0 -2
  10. package/dist/built-in-launch-parts.js +1 -8
  11. package/dist/built-in-launch-parts.js.map +1 -1
  12. package/dist/built-in-run-slots.js +1 -2
  13. package/dist/built-in-run-slots.js.map +1 -1
  14. package/dist/ci-wait/controller.d.ts +7 -7
  15. package/dist/ci-wait/tool-catalog.d.ts +2 -1
  16. package/dist/ci-wait/tool-catalog.js +22 -16
  17. package/dist/ci-wait/tool-catalog.js.map +1 -1
  18. package/dist/cli-dispatch.d.ts +1 -1
  19. package/dist/cli-dispatch.js +24 -16
  20. package/dist/cli-dispatch.js.map +1 -1
  21. package/dist/core/cli-registry.d.ts +3 -0
  22. package/dist/core/cli-registry.js +3 -0
  23. package/dist/core/cli-registry.js.map +1 -1
  24. package/dist/core/managed-session.d.ts +0 -5
  25. package/dist/core/managed-session.js +0 -25
  26. package/dist/core/managed-session.js.map +1 -1
  27. package/dist/core/process-ownership.d.ts +12 -0
  28. package/dist/core/process-ownership.js +33 -0
  29. package/dist/core/process-ownership.js.map +1 -0
  30. package/dist/delegation/process-liveness.d.ts +6 -3
  31. package/dist/delegation/process-liveness.js +0 -16
  32. package/dist/delegation/process-liveness.js.map +1 -1
  33. package/dist/delegation/scratch-cleanup.js +5 -5
  34. package/dist/delegation/scratch-cleanup.js.map +1 -1
  35. package/dist/delegation/transport.d.ts +10 -10
  36. package/dist/{jobs → features/jobs}/cli.js +1 -1
  37. package/dist/features/jobs/cli.js.map +1 -0
  38. package/dist/{jobs → features/jobs}/command.js +2 -2
  39. package/dist/features/jobs/command.js.map +1 -0
  40. package/dist/features/jobs/index.d.ts +11 -0
  41. package/dist/features/jobs/index.js +20 -0
  42. package/dist/features/jobs/index.js.map +1 -0
  43. package/dist/{jobs → features/jobs}/job.js +9 -10
  44. package/dist/features/jobs/job.js.map +1 -0
  45. package/dist/features/jobs/removal-slot.d.ts +14 -0
  46. package/dist/features/jobs/removal-slot.js +50 -0
  47. package/dist/features/jobs/removal-slot.js.map +1 -0
  48. package/dist/index.js +1 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/legacy-runs.js.map +1 -1
  51. package/dist/pack-check.d.ts +4 -1
  52. package/dist/pack-check.js +9 -1
  53. package/dist/pack-check.js.map +1 -1
  54. package/dist/plugin/bundled-features.d.ts +11 -0
  55. package/dist/plugin/bundled-features.js +37 -0
  56. package/dist/plugin/bundled-features.js.map +1 -0
  57. package/dist/plugin/cli.js +1 -1
  58. package/dist/plugin/index.d.ts +1 -1
  59. package/dist/plugin/loader.d.ts +2 -0
  60. package/dist/plugin/loader.js +23 -11
  61. package/dist/plugin/loader.js.map +1 -1
  62. package/dist/runners/antigravity/acp/events.d.ts +3 -5
  63. package/dist/runners/antigravity/acp/events.js +8 -11
  64. package/dist/runners/antigravity/acp/events.js.map +1 -1
  65. package/dist/runs/agent-tmpdir.d.ts +5 -4
  66. package/dist/runs/agent-tmpdir.js +7 -5
  67. package/dist/runs/agent-tmpdir.js.map +1 -1
  68. package/dist/runs/removal-slots.d.ts +15 -3
  69. package/dist/runs/removal-slots.js +12 -2
  70. package/dist/runs/removal-slots.js.map +1 -1
  71. package/dist/runs/run-exits.d.ts +352 -352
  72. package/dist/runs/worker-execution.js.map +1 -1
  73. package/dist/server/automations-routes.d.ts +150 -150
  74. package/dist/server/project-settings-routes.d.ts +107 -107
  75. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  76. package/dist/server/repo-routes.d.ts +13 -13
  77. package/dist/server/runner-install-routes.d.ts +10 -10
  78. package/dist/server/runs-routes.d.ts +957 -957
  79. package/dist/server/server.d.ts +58 -58
  80. package/dist/server/workspace-live-routes.d.ts +6 -6
  81. package/dist/worker-scope/groups.d.ts +0 -9
  82. package/dist/worker-scope/groups.js +3 -18
  83. package/dist/worker-scope/groups.js.map +1 -1
  84. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  85. package/dist/workflows/run/run-settlement.d.ts +0 -10
  86. package/dist/workflows/run/run-settlement.js +5 -38
  87. package/dist/workflows/run/run-settlement.js.map +1 -1
  88. package/dist/workflows/run/session-events.js +0 -16
  89. package/dist/workflows/run/session-events.js.map +1 -1
  90. package/dist/workflows/run/wait-engine.d.ts +72 -72
  91. package/dist/workflows/run/wait-input-descriptors.js +11 -2
  92. package/dist/workflows/run/wait-input-descriptors.js.map +1 -1
  93. package/dist/workflows/run/wait-kinds.d.ts +52 -52
  94. package/package.json +4 -4
  95. package/scripts/check-pack.mjs +5 -2
  96. package/scripts/measure-transcript-facts-health.mjs +41 -4
  97. package/scripts/measure-transcript-facts-lag.mjs +3 -3
  98. package/scripts/transcript-facts-timing.mjs +133 -9
  99. package/web/dist/assets/{accounts-section-DmCfsIhE.js → accounts-section-DPb768q9.js} +1 -1
  100. package/web/dist/assets/{activity-motion-Dl9i8LMp.js → activity-motion-D3CzGjrR.js} +1 -1
  101. package/web/dist/assets/{activity-route-Cu2YIdei.js → activity-route-DFJlsU13.js} +1 -1
  102. package/web/dist/assets/{agent-config-section-Bzm4-R__.js → agent-config-section-2esq_SCK.js} +1 -1
  103. package/web/dist/assets/{agent-defaults-section-BKqo164A.js → agent-defaults-section-DykQGFoV.js} +1 -1
  104. package/web/dist/assets/{appearance-BqzgpB-Y.js → appearance-CEhpCQZS.js} +1 -1
  105. package/web/dist/assets/{automations-route-CUgWc2Qw.js → automations-route-C6e7440u.js} +1 -1
  106. package/web/dist/assets/{commit-diff-panel-Cm558uOv.js → commit-diff-panel-CloSSaTz.js} +1 -1
  107. package/web/dist/assets/{diff-GEuSlT_R.js → diff-DVDzDVOV.js} +2 -2
  108. package/web/dist/assets/{diff-view-DLSixc9l.js → diff-view-isM51Pgu.js} +1 -1
  109. package/web/dist/assets/{file-preview-RPc0KAo_.js → file-preview-BZA9e981.js} +1 -1
  110. package/web/dist/assets/{git-toolbar-Dd_SYvD0.js → git-toolbar-DHAavjba.js} +1 -1
  111. package/web/dist/assets/{github-CQ7IuYHM.js → github-MN8flcF0.js} +1 -1
  112. package/web/dist/assets/{global-activity-route-BxZ0CMwG.js → global-activity-route-CAXyZ8LF.js} +1 -1
  113. package/web/dist/assets/{index-BRgRv29I.js → index-CHIFhfha.js} +4 -4
  114. package/web/dist/assets/{markdown-CIm2Q7mB.js → markdown-DhdLkyGx.js} +3 -3
  115. package/web/dist/assets/{notifications-section-Cw8yBZWz.js → notifications-section-Yiyd4TEk.js} +1 -1
  116. package/web/dist/assets/{preview-pane-connected-C3DmH_yh.js → preview-pane-connected-BnNucXbg.js} +1 -1
  117. package/web/dist/assets/{projects-section-DftkCQ4q.js → projects-section-CYnMlFyZ.js} +1 -1
  118. package/web/dist/assets/{prompt-templates-section-CKSYhpin.js → prompt-templates-section-BaaI89Ej.js} +1 -1
  119. package/web/dist/assets/{remote-settings-notice-C727a84A.js → remote-settings-notice-Drbpb7K4.js} +1 -1
  120. package/web/dist/assets/{repo-git-CfmNmHkb.js → repo-git-UR__WAGI.js} +1 -1
  121. package/web/dist/assets/{report-reader-wIj2Yog1.js → report-reader-DydKaDxP.js} +1 -1
  122. package/web/dist/assets/{reports-DSkGAItT.js → reports-FE9fPBLK.js} +1 -1
  123. package/web/dist/assets/{resources-section-DaEv2dar.js → resources-section-BAz7yc3V.js} +1 -1
  124. package/web/dist/assets/{run-header-CVZ0ZK7C.js → run-header-DsyPfNlS.js} +1 -1
  125. package/web/dist/assets/{settings-agent-picker-DMVlOQzv.js → settings-agent-picker-i4wCYEex.js} +1 -1
  126. package/web/dist/assets/{settings-shell-DfnGZk9I.js → settings-shell-C1RbQ--s.js} +1 -1
  127. package/web/dist/assets/{sidebar-section-DYJZAqtU.js → sidebar-section-CdvgsziI.js} +1 -1
  128. package/web/dist/assets/{skills-CfzNcHh1.js → skills-Cx1c72fB.js} +1 -1
  129. package/web/dist/assets/{task-changes-C1I9CMew.js → task-changes-CJCU26Rn.js} +1 -1
  130. package/web/dist/assets/{task-commits-d_R4H7pu.js → task-commits-BvDHw2z3.js} +1 -1
  131. package/web/dist/assets/{task-files-B2JBO9Dx.js → task-files-BtEb73_A.js} +1 -1
  132. package/web/dist/assets/{task-github-item-C9HMDHKn.js → task-github-item-DguvLtyn.js} +1 -1
  133. package/web/dist/assets/{task-thread-dKvX9xg6.js → task-thread-DiiErUqw.js} +9 -9
  134. package/web/dist/assets/thread-state-XrQOGOYN.js +4 -0
  135. package/web/dist/assets/{use-hand-to-agent-state-DzHDdmHn.js → use-hand-to-agent-state-CDqXR3F2.js} +1 -1
  136. package/web/dist/assets/{workflows-DqArthZn.js → workflows-C8Wu6BrK.js} +1 -1
  137. package/web/dist/assets/{workspace-tools-S5KvgCRm.js → workspace-tools-DG99Pw_m.js} +1 -1
  138. package/web/dist/assets/{worktrees-section-DNFnQfiW.js → worktrees-section-BtDBsA-d.js} +1 -1
  139. package/web/dist/index.html +1 -1
  140. package/dist/jobs/cli.js.map +0 -1
  141. package/dist/jobs/command.js.map +0 -1
  142. package/dist/jobs/job.js.map +0 -1
  143. package/dist/jobs/removal-slot.d.ts +0 -4
  144. package/dist/jobs/removal-slot.js +0 -10
  145. package/dist/jobs/removal-slot.js.map +0 -1
  146. package/web/dist/assets/thread-state-B3HGSNEy.js +0 -4
  147. /package/dist/{jobs → features/jobs}/cli.d.ts +0 -0
  148. /package/dist/{jobs → features/jobs}/command.d.ts +0 -0
  149. /package/dist/{jobs → features/jobs}/job.d.ts +0 -0
@@ -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{A as r,An as i,Ut as a,br as o,ci as s,r as c,un as l}from"./project-scope-context-D9axDY18.js";import{$t as u,Dt as d,Et as f,Kt as p,Lt as m,Qt as h,Rt as g,S as _,Ut as v,Wt as y,Xt as b,_ as x,in as S,st as C,vt as w,xt as T,yt as E}from"./queries-DzwCG927.js";import{n as D}from"./toaster-Bo5vCbz-.js";import{s as O}from"./design-icons-CzEoMH9c.js";import{t as k}from"./button-BQ2y4XRB.js";import{t as A}from"./switch-Bv2Zf1uU.js";import{t as j}from"./status-dot-DtAOFiIi.js";import{t as M}from"./centered-state-V15AR_qo.js";import{N,_n as P,bn as F,j as I}from"./index-BRgRv29I.js";import{t as L}from"./textarea-vJt9undk.js";import{a as R,i as z,n as B,r as V,t as H}from"./settings-agent-picker-DMVlOQzv.js";import{n as U}from"./saved-draft-BwzBc-_Y.js";var W=e(t(),1),G=n(),K={connected:{label:`Credentials found`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function q(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function J(e,t){return e?K[e]:t?{label:`Checking…`,tone:`neutral`}:K.unknown}function Y(e,t){return e===`unknown`||t&&!e}function X({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,G.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,G.jsx)(`code`,{children:e.loginCommand}),`.`]}):Y(t,r)?(0,G.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,G.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function ee({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,G.jsx)(A,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t)}),l?(0,G.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>D(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,G.jsx)(B,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>D(`${e.displayName} can be tried again.`),onError:e=>D(e.message,{tone:`danger`})}),children:`Try again`})]})}function te({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,G.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ne(){let e=b(),t=E(),n=T(),r=f(),c=s(),[u,d]=(0,W.useState)(null),p=(0,W.useRef)(Promise.resolve()),m=(0,W.useRef)({}),_=(0,W.useRef)({}),x=(0,W.useRef)(t.data);(0,W.useEffect)(()=>{u&&o(t.data,u.provider)?.status===`connected`&&d(null)},[u,t.data]),(0,W.useEffect)(()=>{if(t.data){if(Object.values(_.current).every(e=>e===0)||!x.current){x.current=t.data;return}x.current={providers:t.data.providers.map(e=>({...e,enabled:(_.current[e.provider]??0)>0?o(x.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let C=(0,W.useCallback)((e,t)=>{let n=g.providerStatus,r=c.getQueryData(n);if(!r)return;x.current||=r;let i=q(r,e,t);_.current[e]=(_.current[e]??0)+1,c.setQueryData(n,i);let a=(m.current[e]??0)+1;m.current[e]=a,p.current=p.current.then(async()=>{try{let r=await l(e,t),i=o(r,e)?.enabled;if(i===void 0)return;if(x.current=q(x.current??r,e,i),a===m.current[e]){let t=c.getQueryData(n);c.setQueryData(n,t?q(t,e,i):r)}}catch(t){if(a===m.current[e]){let r=o(x.current,e)?.enabled,i=c.getQueryData(n);i&&r!==void 0?c.setQueryData(n,q(i,e,r)):x.current?c.setQueryData(n,x.current):c.removeQueries({queryKey:n,exact:!0}),D(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{_.current[e]=(_.current[e]??0)-1}})},[c]),w=S({mutationFn:e=>a(e),onSuccess:async(e,t)=>{d(null),D(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await c.invalidateQueries({queryKey:g.providerStatus}),await h(c,t,`none`)},onError:(t,n)=>{if(t instanceof i&&t.command){let r=v(e.data,n);d({provider:n,label:r,message:t.message,command:t.command});return}D(t.message,{tone:`danger`})}}),O=async e=>{try{await navigator.clipboard.writeText(e),D(`Command copied`)}catch{D(`Could not copy the command`,{tone:`danger`})}};return(0,G.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:y(e.data).map(e=>{let i=o(t.data,e.id),a=i?.status,s=J(a,t.isPending),c=w.isPending&&w.variables===e.id,l=i?.authFailureId;return(0,G.jsxs)(W.Fragment,{children:[(0,G.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,G.jsx)(j,{tone:s.tone,pulse:t.isPending}),(0,G.jsx)(`span`,{children:s.label}),i?.enabled===!1?(0,G.jsx)(`span`,{children:`Disabled`}):null]}),(0,G.jsx)(X,{provider:e,state:a,current:i,statusIsError:t.isError})]}),(0,G.jsx)(ee,{provider:e,state:a,current:i,isConnecting:c,incidentId:l,refresh:n,connect:w,retry:r,queueToggle:C})]}),l===void 0?null:(0,G.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,G.jsx)(te,{manual:u,provider:e.id,connected:a===`connected`,onCopy:O})]},e.id)})})]})}var Z=2e4;function re(){let e=x(),t=b(),n=u(p(t.data)),r=E();return e.isPending?(0,G.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,G.jsx)(M,{icon:(0,G.jsx)(O,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,G.jsx)(ie,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ie({config:e,catalogs:t,providerStatus:n,runners:i}){let a=_(),o=s(),c=S({mutationFn:e=>r(e),onSuccess:e=>{o.setQueryData(m.config,e),o.invalidateQueries({queryKey:m.health}),o.invalidateQueries({queryKey:m.repo})},onError:e=>D(e.message,{tone:`danger`})}),[l,u]=U(e.systemPrompt??``),d=l.trim(),f=d===(e.systemPrompt??``),p=d.length>Z;return P(!f),(0,G.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,G.jsx)(ae,{defaultRunner:e.defaultRunner,providerStatus:n,saving:c.isPending,onPick:e=>c.mutate({defaultRunner:e})}),(0,G.jsx)(Q,{title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Auto lets the runner decide per task.`,children:(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:y(i).map(r=>{let{providerConnected:a,providerReason:o}=R(n,r.id),s=t[r.id],l=I(r.id,i,s),u=N(r.id,i,s?.data,[e.defaultModels[r.id]]),d=e.defaultModels[r.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,G.jsxs)(`label`,{className:`settings-option-row`,children:[(0,G.jsx)(`div`,{children:(0,G.jsx)(`h3`,{children:r.pickerLabel})}),e.modelsLocked?(0,G.jsx)(`output`,{"aria-label":`Default model for ${r.pickerLabel}`,"data-slot":`agents-model`,"data-runner":r.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,G.jsxs)(`select`,{"aria-label":`Default model for ${r.pickerLabel}`,"data-slot":`agents-model`,"data-runner":r.id,value:d,title:o??r.pickerDescription,disabled:c.isPending||!a,onChange:e=>c.mutate({defaultModels:{[r.id]:e.target.value||null}}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[u.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.id===``?`Native agent default`:e.label},e.id)),l?(0,G.jsx)(`option`,{disabled:!0,children:l}):null]})]},r.id)})})}),(0,G.jsxs)(Q,{title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,G.jsx)(L,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:l,onChange:e=>u(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,G.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,G.jsx)(k,{type:`button`,variant:`primary`,size:`sm`,"data-action":`agents-save-prompt`,disabled:f||p||c.isPending,onClick:()=>c.mutate({systemPrompt:d===``?null:d},{onSuccess:()=>D(d===``?`System prompt cleared`:`System prompt saved`)}),children:`Save prompt`}),p?(0,G.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-[11px] text-danger`,children:[d.length.toLocaleString(),` characters — the limit is`,` `,Z.toLocaleString(),`.`]}):(0,G.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]}),(0,G.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,G.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,children:(0,G.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,G.jsx)(A,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:c.isPending,onCheckedChange:e=>c.mutate({liveTitleUpdates:e},{onSuccess:()=>D(e?`Live title updates on`:`Live title updates off`)})}),(0,G.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,G.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,children:(0,G.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,G.jsx)(A,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:c.isPending,onCheckedChange:e=>c.mutate({reviewGate:e},{onSuccess:()=>D(e?`Review gate on`:`Review gate off`)})}),(0,G.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,G.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:a.data?.info?(0,G.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:c.isPending,onChange:e=>c.mutate({baseBranch:e.target.value||null}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,G.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),a.data.branches.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}):(0,G.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:a.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,G.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,G.jsx)(`summary`,{children:`Provider connections`}),(0,G.jsx)(ne,{})]})]})}function ae({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=C(),a=w(),s=c(),l=_(),u=d(),f=s.projectId??`default`,p=l.data?.info?.root,m=F(i.data,s.projectId,p),h=b().data,g=V(i.data?.profiles??[],h),v=z(g,h);return(0,G.jsxs)(Q,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,children:[(0,G.jsx)(H,{rows:g,runner:e,accountFor:e=>m?.[e]??null,providerStatus:t,disabled:n,accountDisabled:u.isPending||a.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&u.mutate({projectId:f,provider:t,profileId:n},{onError:e=>D(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&o(t.data,e)?.enabled===!1?(0,G.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,v?(0,G.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function Q({title:e,hint:t,reportsDirty:n,children:r}){return(0,G.jsxs)(`section`,{"data-reports-dirty":n?``:void 0,className:`settings-field flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),r]})}function $({title:e,hint:t,children:n}){return(0,G.jsxs)(`section`,{className:`settings-option-row`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{children:e}),(0,G.jsx)(`p`,{children:t})]}),n]})}export{re as AgentDefaultsSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,An as i,Ut as a,br as o,ci as s,r as c,un as l}from"./project-scope-context-D9axDY18.js";import{$t as u,Dt as d,Et as f,Kt as p,Lt as m,Qt as h,Rt as g,S as _,Ut as v,Wt as y,Xt as b,_ as x,in as S,st as C,vt as w,xt as T,yt as E}from"./queries-DzwCG927.js";import{n as D}from"./toaster-Bo5vCbz-.js";import{s as O}from"./design-icons-CzEoMH9c.js";import{t as k}from"./button-BQ2y4XRB.js";import{t as A}from"./switch-Bv2Zf1uU.js";import{t as j}from"./status-dot-DtAOFiIi.js";import{t as M}from"./centered-state-V15AR_qo.js";import{N,_n as P,bn as F,j as I}from"./index-CHIFhfha.js";import{t as L}from"./textarea-vJt9undk.js";import{a as R,i as z,n as B,r as V,t as H}from"./settings-agent-picker-i4wCYEex.js";import{n as U}from"./saved-draft-BwzBc-_Y.js";var W=e(t(),1),G=n(),K={connected:{label:`Credentials found`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function q(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function J(e,t){return e?K[e]:t?{label:`Checking…`,tone:`neutral`}:K.unknown}function Y(e,t){return e===`unknown`||t&&!e}function X({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,G.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,G.jsx)(`code`,{children:e.loginCommand}),`.`]}):Y(t,r)?(0,G.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,G.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function ee({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,G.jsx)(A,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t)}),l?(0,G.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>D(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,G.jsx)(B,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>D(`${e.displayName} can be tried again.`),onError:e=>D(e.message,{tone:`danger`})}),children:`Try again`})]})}function te({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,G.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,G.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ne(){let e=b(),t=E(),n=T(),r=f(),c=s(),[u,d]=(0,W.useState)(null),p=(0,W.useRef)(Promise.resolve()),m=(0,W.useRef)({}),_=(0,W.useRef)({}),x=(0,W.useRef)(t.data);(0,W.useEffect)(()=>{u&&o(t.data,u.provider)?.status===`connected`&&d(null)},[u,t.data]),(0,W.useEffect)(()=>{if(t.data){if(Object.values(_.current).every(e=>e===0)||!x.current){x.current=t.data;return}x.current={providers:t.data.providers.map(e=>({...e,enabled:(_.current[e.provider]??0)>0?o(x.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let C=(0,W.useCallback)((e,t)=>{let n=g.providerStatus,r=c.getQueryData(n);if(!r)return;x.current||=r;let i=q(r,e,t);_.current[e]=(_.current[e]??0)+1,c.setQueryData(n,i);let a=(m.current[e]??0)+1;m.current[e]=a,p.current=p.current.then(async()=>{try{let r=await l(e,t),i=o(r,e)?.enabled;if(i===void 0)return;if(x.current=q(x.current??r,e,i),a===m.current[e]){let t=c.getQueryData(n);c.setQueryData(n,t?q(t,e,i):r)}}catch(t){if(a===m.current[e]){let r=o(x.current,e)?.enabled,i=c.getQueryData(n);i&&r!==void 0?c.setQueryData(n,q(i,e,r)):x.current?c.setQueryData(n,x.current):c.removeQueries({queryKey:n,exact:!0}),D(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{_.current[e]=(_.current[e]??0)-1}})},[c]),w=S({mutationFn:e=>a(e),onSuccess:async(e,t)=>{d(null),D(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await c.invalidateQueries({queryKey:g.providerStatus}),await h(c,t,`none`)},onError:(t,n)=>{if(t instanceof i&&t.command){let r=v(e.data,n);d({provider:n,label:r,message:t.message,command:t.command});return}D(t.message,{tone:`danger`})}}),O=async e=>{try{await navigator.clipboard.writeText(e),D(`Command copied`)}catch{D(`Could not copy the command`,{tone:`danger`})}};return(0,G.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,G.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,G.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:y(e.data).map(e=>{let i=o(t.data,e.id),a=i?.status,s=J(a,t.isPending),c=w.isPending&&w.variables===e.id,l=i?.authFailureId;return(0,G.jsxs)(W.Fragment,{children:[(0,G.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,G.jsx)(j,{tone:s.tone,pulse:t.isPending}),(0,G.jsx)(`span`,{children:s.label}),i?.enabled===!1?(0,G.jsx)(`span`,{children:`Disabled`}):null]}),(0,G.jsx)(X,{provider:e,state:a,current:i,statusIsError:t.isError})]}),(0,G.jsx)(ee,{provider:e,state:a,current:i,isConnecting:c,incidentId:l,refresh:n,connect:w,retry:r,queueToggle:C})]}),l===void 0?null:(0,G.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,G.jsx)(te,{manual:u,provider:e.id,connected:a===`connected`,onCopy:O})]},e.id)})})]})}var Z=2e4;function re(){let e=x(),t=b(),n=u(p(t.data)),r=E();return e.isPending?(0,G.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,G.jsx)(M,{icon:(0,G.jsx)(O,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,G.jsx)(ie,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ie({config:e,catalogs:t,providerStatus:n,runners:i}){let a=_(),o=s(),c=S({mutationFn:e=>r(e),onSuccess:e=>{o.setQueryData(m.config,e),o.invalidateQueries({queryKey:m.health}),o.invalidateQueries({queryKey:m.repo})},onError:e=>D(e.message,{tone:`danger`})}),[l,u]=U(e.systemPrompt??``),d=l.trim(),f=d===(e.systemPrompt??``),p=d.length>Z;return P(!f),(0,G.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,G.jsx)(ae,{defaultRunner:e.defaultRunner,providerStatus:n,saving:c.isPending,onPick:e=>c.mutate({defaultRunner:e})}),(0,G.jsx)(Q,{title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Auto lets the runner decide per task.`,children:(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:y(i).map(r=>{let{providerConnected:a,providerReason:o}=R(n,r.id),s=t[r.id],l=I(r.id,i,s),u=N(r.id,i,s?.data,[e.defaultModels[r.id]]),d=e.defaultModels[r.id]??``,f=u.find(e=>e.id===d)?.label??d??`auto (default)`;return(0,G.jsxs)(`label`,{className:`settings-option-row`,children:[(0,G.jsx)(`div`,{children:(0,G.jsx)(`h3`,{children:r.pickerLabel})}),e.modelsLocked?(0,G.jsx)(`output`,{"aria-label":`Default model for ${r.pickerLabel}`,"data-slot":`agents-model`,"data-runner":r.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,G.jsxs)(`select`,{"aria-label":`Default model for ${r.pickerLabel}`,"data-slot":`agents-model`,"data-runner":r.id,value:d,title:o??r.pickerDescription,disabled:c.isPending||!a,onChange:e=>c.mutate({defaultModels:{[r.id]:e.target.value||null}}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[u.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.id===``?`Native agent default`:e.label},e.id)),l?(0,G.jsx)(`option`,{disabled:!0,children:l}):null]})]},r.id)})})}),(0,G.jsxs)(Q,{title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,G.jsx)(L,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:l,onChange:e=>u(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,G.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,G.jsx)(k,{type:`button`,variant:`primary`,size:`sm`,"data-action":`agents-save-prompt`,disabled:f||p||c.isPending,onClick:()=>c.mutate({systemPrompt:d===``?null:d},{onSuccess:()=>D(d===``?`System prompt cleared`:`System prompt saved`)}),children:`Save prompt`}),p?(0,G.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-[11px] text-danger`,children:[d.length.toLocaleString(),` characters — the limit is`,` `,Z.toLocaleString(),`.`]}):(0,G.jsx)(`p`,{className:`text-[11px] text-soft-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})]})]}),(0,G.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,G.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,children:(0,G.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,G.jsx)(A,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:c.isPending,onCheckedChange:e=>c.mutate({liveTitleUpdates:e},{onSuccess:()=>D(e?`Live title updates on`:`Live title updates off`)})}),(0,G.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,G.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,children:(0,G.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,G.jsx)(A,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:c.isPending,onCheckedChange:e=>c.mutate({reviewGate:e},{onSuccess:()=>D(e?`Review gate on`:`Review gate off`)})}),(0,G.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,G.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,children:a.data?.info?(0,G.jsxs)(`select`,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:c.isPending,onChange:e=>c.mutate({baseBranch:e.target.value||null}),className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,G.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),a.data.branches.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}):(0,G.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:a.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,G.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,G.jsx)(`summary`,{children:`Provider connections`}),(0,G.jsx)(ne,{})]})]})}function ae({defaultRunner:e,providerStatus:t,saving:n,onPick:r}){let i=C(),a=w(),s=c(),l=_(),u=d(),f=s.projectId??`default`,p=l.data?.info?.root,m=F(i.data,s.projectId,p),h=b().data,g=V(i.data?.profiles??[],h),v=z(g,h);return(0,G.jsxs)(Q,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,children:[(0,G.jsx)(H,{rows:g,runner:e,accountFor:e=>m?.[e]??null,providerStatus:t,disabled:n,accountDisabled:u.isPending||a.data===void 0,onPick:(t,n,i)=>{t!==e&&r(t),i&&u.mutate({projectId:f,provider:t,profileId:n},{onError:e=>D(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&o(t.data,e)?.enabled===!1?(0,G.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,v?(0,G.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function Q({title:e,hint:t,reportsDirty:n,children:r}){return(0,G.jsxs)(`section`,{"data-reports-dirty":n?``:void 0,className:`settings-field flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,G.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),r]})}function $({title:e,hint:t,children:n}){return(0,G.jsxs)(`section`,{className:`settings-option-row`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{children:e}),(0,G.jsx)(`p`,{children:t})]}),n]})}export{re as AgentDefaultsSection};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DSMR_WLb.js";import{vt as n}from"./queries-DzwCG927.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BQ2y4XRB.js";import{Bn as s,Cn as c,ut as l}from"./index-BRgRv29I.js";var u=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),d=e(),f=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:u},{value:`dark`,label:`Dark`,icon:a}],p=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],m=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Compact for real`}],h=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function g({slot:e,label:n,value:r,options:i,onChange:a}){return(0,d.jsx)(`div`,{role:`radiogroup`,"aria-label":n,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-md border border-border bg-card p-0.5 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let n=e.value===r;return(0,d.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"data-value":e.value,onClick:()=>a(e.value),className:t(`flex min-h-11 items-center gap-2 rounded-sm px-3 py-1.5 text-[13px] font-medium transition-colors`,n?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,d.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,d.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function _({title:e,hint:t,children:n}){return(0,d.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,d.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function v(){let e=n(),{order:t,canReorder:r,reset:i}=c();return!((e.data?.projects.length??0)>1)||t.length===0?null:(0,d.jsx)(_,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,d.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function y(){let{theme:e,setTheme:t}=s(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:c}=l();return(0,d.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,d.jsx)(_,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,children:(0,d.jsx)(g,{slot:`appearance-theme`,label:`Theme`,value:e,options:f,onChange:t})}),p.length>1?(0,d.jsx)(_,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,children:(0,d.jsx)(g,{slot:`appearance-accent`,label:`Accent`,value:n,options:p,onChange:a})}):null,(0,d.jsx)(_,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,children:(0,d.jsx)(g,{slot:`appearance-density`,label:`Density`,value:r,options:m,onChange:o})}),(0,d.jsx)(_,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,children:(0,d.jsx)(g,{slot:`appearance-width`,label:`Reading width`,value:i,options:h,onChange:c})}),(0,d.jsx)(v,{}),(0,d.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,d.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,d.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,d.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,d.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-accent-strong/30 bg-accent-strong/10 px-4 py-3 text-xs text-accent-text`,children:`Open task`})]}),(0,d.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{y as AppearanceSection};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DSMR_WLb.js";import{vt as n}from"./queries-DzwCG927.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BQ2y4XRB.js";import{Bn as s,Cn as c,ut as l}from"./index-CHIFhfha.js";var u=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),d=e(),f=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:u},{value:`dark`,label:`Dark`,icon:a}],p=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],m=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Compact for real`}],h=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function g({slot:e,label:n,value:r,options:i,onChange:a}){return(0,d.jsx)(`div`,{role:`radiogroup`,"aria-label":n,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-md border border-border bg-card p-0.5 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let n=e.value===r;return(0,d.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"data-value":e.value,onClick:()=>a(e.value),className:t(`flex min-h-11 items-center gap-2 rounded-sm px-3 py-1.5 text-[13px] font-medium transition-colors`,n?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,d.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,d.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function _({title:e,hint:t,children:n}){return(0,d.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),(0,d.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:t})]}),n]})}function v(){let e=n(),{order:t,canReorder:r,reset:i}=c();return!((e.data?.projects.length??0)>1)||t.length===0?null:(0,d.jsx)(_,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,d.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function y(){let{theme:e,setTheme:t}=s(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:c}=l();return(0,d.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,d.jsx)(_,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,children:(0,d.jsx)(g,{slot:`appearance-theme`,label:`Theme`,value:e,options:f,onChange:t})}),p.length>1?(0,d.jsx)(_,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,children:(0,d.jsx)(g,{slot:`appearance-accent`,label:`Accent`,value:n,options:p,onChange:a})}):null,(0,d.jsx)(_,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,children:(0,d.jsx)(g,{slot:`appearance-density`,label:`Density`,value:r,options:m,onChange:o})}),(0,d.jsx)(_,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,children:(0,d.jsx)(g,{slot:`appearance-width`,label:`Reading width`,value:i,options:h,onChange:c})}),(0,d.jsx)(v,{}),(0,d.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,d.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,d.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,d.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,d.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-accent-strong/30 bg-accent-strong/10 px-4 py-3 text-xs text-accent-text`,children:`Open task`})]}),(0,d.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{y as AppearanceSection};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{$n as a,An as o,F as s,I as c,L as l,P as u,Rr as d,Xr as f,Zn as p,Zr as m,a as h,er as g,g as _,h as v,i as y,l as b,m as x,nr as S,o as ee}from"./project-scope-context-D9axDY18.js";import{B as C,G as w,H as T,I as E,K as D,N as O,P as k,V as A,W as j,j as M,z as N}from"./live-protocol-DteqtbyN.js";import{D as P,Jt as te,Xt as ne,Yt as re,_ as ie,en as ae}from"./queries-DzwCG927.js";import{h as oe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as se,t as F}from"./label-6PgIe3Ny.js";import{I as ce,Y as le,c as ue,d as de,it as fe,l as pe,pt as me,ut as he,y as ge}from"./design-icons-CzEoMH9c.js";import{n as _e,r as ve}from"./dist-C28wFbz0.js";import{t as I}from"./button-BQ2y4XRB.js";import{a as L,n as ye}from"./dist-BW234Kg5.js";import{a as R,i as be,n as z,r as B,t as xe}from"./dist-C5mlVBmd.js";import{h as Se,m as Ce}from"./dropdown-menu-4e2iKSMT.js";import{a as we,c as Te,i as Ee,l as De,n as Oe,o as ke,r as Ae,t as je,u as Me}from"./es2015-CQth82uv.js";import{n as Ne,r as Pe,t as Fe}from"./collapsible-BEV4FO-1.js";import{n as Ie,t as Le}from"./switch-Bv2Zf1uU.js";import{a as Re,i as ze,n as Be,r as Ve,t as He}from"./dist-BAoXdNsT.js";import{c as Ue,s as We,t as V}from"./project-router-CDPfL2Jz.js";import{t as Ge}from"./centered-state-V15AR_qo.js";import{En as Ke,G as qe,Gn as H,J as Je,N as Ye,O as Xe,Sn as Ze,Tn as Qe,W as $e,k as et,nr as tt,q as nt,r as rt,t as it,vn as at}from"./index-BRgRv29I.js";import{_ as ot,a as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,l as mt,m as ht,n as gt,o as _t,p as vt,r as yt,s as bt,t as xt,u as St,v as Ct}from"./automation-format-CUP262Tk.js";import{t as wt}from"./textarea-vJt9undk.js";function Tt(e,[t,n]){return Math.min(n,Math.max(t,e))}var U=e(t(),1),Et=e(n(),1),W=r(),Dt=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Ot=[` `,`Enter`],G=`Select`,[kt,At,jt]=Se(G),[K,Mt]=be(G,[jt,Re]),Nt=Re(),[Pt,q]=K(G),[Ft,It]=K(G),Lt=`SelectProvider`;function Rt(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Nt(t),[_,v]=U.useState(null),[y,b]=U.useState(null),[x,S]=U.useState(!1),ee=Ce(l),[C,w]=xe({prop:r,defaultProp:i??!1,onChange:a,caller:G}),[T,E]=xe({prop:o,defaultProp:s,onChange:c,caller:G}),D=U.useRef(null),O=U.useRef(T);U.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=()=>E(O.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,E]);let k=!_||!!m||!!_.closest(`form`),[A,j]=U.useState(new Set),M=De(),N=Array.from(A).map(e=>e.props.value).join(`;`),P=U.useCallback(e=>{j(t=>new Set(t).add(e))},[]),te=U.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),ne={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:M,value:T,onValueChange:E,open:C,onOpenChange:w,dir:ee,triggerPointerDownPosRef:D,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:A,nativeSelectKey:N,isFormControl:k};return(0,W.jsx)(ze,{...g,children:(0,W.jsx)(Pt,{scope:t,...ne,children:(0,W.jsx)(kt.Provider,{scope:t,children:(0,W.jsx)(Ft,{scope:t,onNativeOptionAdd:P,onNativeOptionRemove:te,children:In(h)?h(ne):n})})})})}Rt.displayName=Lt;var zt=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(Rt,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(Fn,{__scopeSelect:t}):null]})})};zt.displayName=G;var Bt=`SelectTrigger`,Vt=U.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Nt(n),o=q(Bt,n),s=o.disabled||r,c=L(t,o.onTriggerChange),l=At(n),u=U.useRef(`touch`),[d,f,p]=Rn(e=>{let t=l().filter(e=>!e.disabled),n=zn(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,W.jsx)(He,{asChild:!0,...a,children:(0,W.jsx)(R.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Ln(o.value)?``:void 0,...i,ref:c,onClick:B(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:B(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:B(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Dt.includes(e.key)&&(m(),e.preventDefault())})})})});Vt.displayName=Bt;var Ht=`SelectValue`,Ut=U.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=q(Ht,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=L(t,c.onValueNodeChange);z(()=>{l(u)},[l,u]);let f=Ln(c.value);return(0,W.jsx)(R.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(U.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});Ut.displayName=Ht;var Wt=`SelectIcon`,Gt=U.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(R.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Gt.displayName=Wt;var Kt=`SelectPortal`,[qt,Jt]=K(Kt,{forceMount:void 0}),Yt=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(qt,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(Ee,{asChild:!0,...r})})};Yt.displayName=Kt;var J=`SelectContent`,Xt=U.forwardRef((e,t)=>{let n=Jt(J,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(J,e.__scopeSelect),[o,s]=U.useState();return z(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(Me,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(tn,{...i,ref:t}):(0,W.jsx)(Zt,{...i,fragment:o})})});Xt.displayName=J;var Zt=U.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?Et.createPortal((0,W.jsx)(Qt,{scope:n,children:(0,W.jsx)(kt.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null});Zt.displayName=`SelectContentFragment`;var Y=10,[Qt,X]=K(J),$t=`SelectContentImpl`,en=ye(`SelectContent.RemoveScroll`),tn=U.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=q(J,n),[y,b]=U.useState(null),[x,S]=U.useState(null),ee=L(t,b),[C,w]=U.useState(null),[T,E]=U.useState(null),D=At(n),[O,k]=U.useState(!1),A=U.useRef(!1);U.useEffect(()=>{if(y)return je(y)},[y]),Ae();let j=U.useCallback(e=>{let[t,...n]=D().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[D,x]),M=U.useCallback(()=>j([C,y]),[j,C,y]);U.useEffect(()=>{O&&M()},[O,M]);let{onOpenChange:N,triggerPointerDownPosRef:P}=v;U.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(P.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(P.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||N(!1),document.removeEventListener(`pointermove`,t),P.current=null};return P.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,N,P]),U.useEffect(()=>{let e=()=>N(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[N]);let[te,ne]=Rn(e=>{let t=D().filter(e=>!e.disabled),n=zn(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),re=U.useCallback((e,t,n)=>{let r=!A.current&&!n;(v.value!==void 0&&v.value===t||r)&&(w(e),r&&(A.current=!0))},[v.value]),ie=U.useCallback(()=>y?.focus(),[y]),ae=U.useCallback((e,t,n)=>{let r=!A.current&&!n;(v.value!==void 0&&v.value===t||r)&&E(e)},[v.value]),oe=r===`popper`?on:rn,se=oe===on?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(Qt,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:re,selectedItem:C,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:M,selectedItemText:T,position:r,isPositioned:O,searchRef:te,children:(0,W.jsx)(Oe,{as:en,allowPinchZoom:!0,children:(0,W.jsx)(we,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:B(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(ke,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...se,onPlaced:()=>k(!0),ref:ee,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:B(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=D().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>j(t)),e.preventDefault()}})})})})})})});tn.displayName=$t;var nn=`SelectItemAlignedPosition`,rn=U.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=q(J,n),o=X(J,n),[s,c]=U.useState(null),[l,u]=U.useState(null),d=L(t,u),f=At(n),p=U.useRef(!1),m=U.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=U.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Y,d=Tt(a,[Y,Math.max(Y,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Y,d=Tt(a,[Y,Math.max(Y,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Y*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),ee=window.getComputedStyle(h),C=parseInt(ee.paddingTop,10),w=parseInt(ee.paddingBottom,10),T=e.top+e.height/2-Y,E=c-T,D=g.offsetHeight/2,O=g.offsetTop+D,k=m+v+O,A=x-k;if(k<=T){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(E,D+(e?w:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(T,m+h.offsetTop+(e?C:0)+D)+A;s.style.height=t+`px`,h.scrollTop=k-T+h.offsetTop}s.style.margin=`${Y}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);z(()=>y(),[y]);let[b,x]=U.useState();return z(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,W.jsx)(sn,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:U.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(R.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});rn.displayName=nn;var an=`SelectPopperPosition`,on=U.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Y,...a}=e,o=Nt(n);return(0,W.jsx)(Ve,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});on.displayName=an;var[sn,cn]=K(J,{}),ln=`SelectViewport`,un=U.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=X(ln,n),o=cn(ln,n),s=L(t,a.onViewportChange),c=U.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(kt.Slot,{scope:n,children:(0,W.jsx)(R.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:B(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Y*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});un.displayName=ln;var dn=`SelectGroup`,[fn,pn]=K(dn),mn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=De();return(0,W.jsx)(fn,{scope:n,id:i,children:(0,W.jsx)(R.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});mn.displayName=dn;var hn=`SelectLabel`,gn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=pn(hn,n);return(0,W.jsx)(R.div,{id:i.id,...r,ref:t})});gn.displayName=hn;var _n=`SelectItem`,[vn,yn]=K(_n),bn=U.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=q(_n,n),c=X(_n,n),l=s.value===r,[u,d]=U.useState(a??``),[f,p]=U.useState(!1),m=L(t,Te(e=>c.itemRefCallback?.(e,r,i))),h=De(),g=U.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,W.jsx)(vn,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:U.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(kt.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(R.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:B(o.onFocus,()=>p(!0)),onBlur:B(o.onBlur,()=>p(!1)),onClick:B(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:B(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:B(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:B(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:B(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:B(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(Ot.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});bn.displayName=_n;var xn=`SelectItemText`,Sn=U.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=q(xn,n),s=X(xn,n),c=yn(xn,n),l=It(xn,n),[u,d]=U.useState(null),f=Te(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=L(t,d,c.onItemTextChange,f),m=u?.textContent,h=U.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return z(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(R.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Ln(o.value)?Et.createPortal(a.children,o.valueNode):null]})});Sn.displayName=xn;var Cn=`SelectItemIndicator`,wn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return yn(Cn,n).isSelected?(0,W.jsx)(R.span,{"aria-hidden":!0,...r,ref:t}):null});wn.displayName=Cn;var Tn=`SelectScrollUpButton`,En=U.forwardRef((e,t)=>{let n=X(Tn,e.__scopeSelect),r=cn(Tn,e.__scopeSelect),[i,a]=U.useState(!1),o=L(t,r.onScrollButtonChange);return z(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(kn,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});En.displayName=Tn;var Dn=`SelectScrollDownButton`,On=U.forwardRef((e,t)=>{let n=X(Dn,e.__scopeSelect),r=cn(Dn,e.__scopeSelect),[i,a]=U.useState(!1),o=L(t,r.onScrollButtonChange);return z(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(kn,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});On.displayName=Dn;var kn=U.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=X(`SelectScrollButton`,n),o=U.useRef(null),s=At(n),c=U.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return U.useEffect(()=>()=>c(),[c]),z(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,W.jsx)(R.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:B(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:B(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:B(i.onPointerLeave,()=>{c()})})}),An=`SelectSeparator`,jn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,W.jsx)(R.div,{"aria-hidden":!0,...r,ref:t})});jn.displayName=An;var Mn=`SelectArrow`,Nn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Nt(n);return X(Mn,n).position===`popper`?(0,W.jsx)(Be,{...i,...r,ref:t}):null});Nn.displayName=Mn;var Pn=`SelectBubbleInput`,Fn=U.forwardRef(({__scopeSelect:e,...t},n)=>{let r=q(Pn,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=U.useRef(null),m=L(n,p),h=i??``,g=Ie(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return U.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,W.jsxs)(R.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{..._e,...t.style},ref:m,defaultValue:h,children:[Ln(i)&&!_?(0,W.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});Fn.displayName=Pn;function In(e){return typeof e==`function`}function Ln(e){return e===``||e===void 0}function Rn(e){let t=Te(e),n=U.useRef(``),r=U.useRef(0),i=U.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=U.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return U.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function zn(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Bn(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Bn(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vn=M([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),Hn=C({includeExisting:k().optional(),authors:O(j()).optional(),assignees:O(j()).optional(),requireCurrentLabels:k().optional(),allLabels:O(j()).optional(),anyLabels:O(j()).optional(),excludeLabels:O(j()).optional(),changedLabels:O(j()).optional(),lookbackDays:N(),maxRecords:N()}),Un=M([`github`,`schedule`]),Wn=p.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:j(),variants:w([E(1),E(2),E(3)]).optional(),systemPrompt:j().optional()}),Gn=C({at:j(),outcome:M([`launched`,`cancelled`]),runId:j().optional(),receiptId:j().optional(),trigger:M([`schedule`,`late`,`manual`,`retry`]).optional()}),Kn=C({id:j(),revision:N(),name:j(),description:j().optional(),enabled:k(),kind:Un,events:O(Vn).optional(),intervalSeconds:N().optional(),filters:Hn.optional(),schedule:ct.optional(),task:Wn,archived:Gn.optional(),createdAt:j(),updatedAt:j()}),qn=C({timestamp:j(),tieBreaker:j().optional()}),Jn=C({since:j().datetime(),until:j().datetime(),source:N().int().min(0).max(2),page:N().int().min(1).max(10),item:N().int().min(0).max(100),event:N().int().min(0).max(1e3),cursor:qn.optional()}),Yn={lastError:j().max(1e3).optional(),lastErrorAt:j().datetime().optional()},Xn=C({revision:N().optional(),baselineAt:j().optional(),armedAt:j().optional(),historyScan:Jn.optional(),cursor:qn.optional(),frozenHighWatermark:qn.extend({tieBreaker:j()}).optional(),backlogAfter:qn.extend({tieBreaker:j()}).optional(),nextCheckAt:j().optional(),lastSuccessAt:j().optional(),nextRunAt:j().optional(),lastRunAt:j().optional(),etags:T(j(),j()).optional(),backoffUntil:j().optional(),consecutiveFailures:N().optional(),...Yn,onceOutcome:M([`failed`,`missed`]).optional()});function Zn(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var Qn=M([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),$n=C({seq:N(),ts:j(),automationId:j(),revision:N(),event:Vn.optional(),result:Qn,reason:j().optional(),durationMs:N().optional(),receiptId:j().optional(),runId:j().optional(),githubNumber:N().optional(),githubTitle:j().optional(),githubUrl:j().optional(),rateLimit:C({bucket:M([`core`,`search`]),remaining:N().optional(),resetAt:j().optional()}).optional()}),er=C({matches:N(),launched:N(),duplicates:N(),errors:N()}),tr=Kn.extend({state:Xn.optional(),latestLog:$n.optional(),counts:er,nextRunAt:j().optional(),onceStatus:vt.optional()});C({available:k(),reason:j().optional(),timeZone:j(),scheduler:C({state:M([`scheduled`,`idle`]),nextDue:j().optional()}),automations:O(tr)}),C({automation:Kn}).extend({once:C({dueAt:j(),timeZone:j(),resolvedInstant:j(),note:j()}).optional()}),C({automation:Kn,state:Xn.optional(),latestLog:$n.optional(),onceStatus:vt.optional()}),C({id:j(),automationId:j(),mode:M([`preview`,`execute`]),status:M([`queued`,`running`,`complete`,`error`]),createdAt:j(),completedAt:j().optional(),matches:N().optional(),truncated:k().optional(),error:j().optional()}),C({checkId:j()}),C({records:O($n)}),C({receiptId:j(),runId:j()}),C({runId:j()}),Kn.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:Un.optional(),task:Wn.omit({variants:!0}).strict(),enable:k().optional()}).omit({enable:!0}).extend({enabled:k().optional(),expectedRevision:N()}),C({archived:M([`include`,`only`]).optional()}),C({mode:M([`preview`,`execute`])});function nr({...e}){return(0,W.jsx)(zt,{"data-slot":`select`,...e})}function rr({...e}){return(0,W.jsx)(Ut,{"data-slot":`select-value`,...e})}function ir({className:e,size:t=`default`,children:n,...r}){return(0,W.jsxs)(Vt,{"data-slot":`select-trigger`,"data-size":t,className:i(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-sm whitespace-nowrap shadow-none transition-[color,box-shadow] outline-hidden focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-11 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 pointer-hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,W.jsx)(Gt,{asChild:!0,children:(0,W.jsx)(pe,{className:`size-4 opacity-50`})})]})}function ar({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,W.jsx)(Yt,{children:(0,W.jsxs)(Xt,{"data-slot":`select-content`,className:i(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,W.jsx)(sr,{}),(0,W.jsx)(un,{className:i(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,W.jsx)(cr,{})]})})}function or({className:e,children:t,...n}){return(0,W.jsxs)(bn,{"data-slot":`select-item`,className:i(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,W.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute end-2 flex size-3.5 items-center justify-center`,children:(0,W.jsx)(wn,{children:(0,W.jsx)(ue,{className:`size-4`})})}),(0,W.jsx)(Sn,{children:t})]})}function sr({className:e,...t}){return(0,W.jsx)(En,{"data-slot":`select-scroll-up-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(de,{className:`size-4`})})}function cr({className:e,...t}){return(0,W.jsx)(On,{"data-slot":`select-scroll-down-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(pe,{className:`size-4`})})}function lr({title:e,subtitle:t,action:n,children:r}){return(0,W.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full max-w-full min-w-0 max-md:p-4!`,children:[(0,W.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5 max-md:mb-4 max-md:gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`mb-2 text-[28px] font-medium max-md:text-[22px]`,children:e}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function Z({text:e}){return(0,W.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}var ur={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`neutral`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},dr={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function fr(e){let[t,n]=(0,U.useState)(),[r,i]=(0,U.useState)(``),a=(0,U.useCallback)(t=>v(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,U.useEffect)(()=>{a()},[a]),(0,U.useEffect)(()=>d(a),[a]),(0,U.useEffect)(()=>se((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function pr(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function mr({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&pr(e,t),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(),d=Date.now(),f=async e=>{s(e),l(void 0);try{await u(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,W.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,W.jsxs)(`li`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(rt,{dot:ur[e.result],children:dr[e.result]}),(0,W.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:gt(e.ts,n,d)})]}),e.reason?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,W.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,W.jsx)(I,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void f(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var hr=`all`;function gr({label:e,value:t,onChange:n,options:r}){return(0,W.jsxs)(nr,{value:t,onValueChange:n,children:[(0,W.jsx)(ir,{"aria-label":e,className:`w-full sm:w-52`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:r.map(e=>(0,W.jsx)(or,{value:e.value,children:e.label},e.value))})]})}function _r({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=fr(e),[s,c]=(0,U.useState)(hr),[l,u]=(0,U.useState)(hr),d=(0,U.useMemo)(()=>(i??[]).filter(e=>(s===hr||e.result===s)&&(l===hr||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,W.jsx)(lr,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations`,children:`Back to automations`})}),children:a&&!i?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(Z,{text:a}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,W.jsx)(Z,{text:`Nothing has run yet.`}):(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(gr,{label:`Result`,value:s,onChange:c,options:[{value:hr,label:`All results`},...Qn.options.map(e=>({value:e,label:dr[e]}))]}),f?(0,W.jsx)(gr,{label:`Event`,value:l,onChange:u,options:[{value:hr,label:`All events`},...Vn.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,W.jsx)(Z,{text:`No rows match these filters.`}):(0,W.jsx)(mr,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,W.jsx)(Z,{text:`Loading execution log…`})})}function vr({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=fr(e);return(0,W.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-4 min-w-0 border-t pt-4`,children:[(0,W.jsxs)(`h3`,{className:`mb-3 text-sm font-medium`,children:[`Recent activity`,r&&t?` · ${t}`:``]}),o&&!a?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(Z,{text:o}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing has run yet.`}):(0,W.jsx)(mr,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`})]})}function yr({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?yt(i):null,[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(``),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await b(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,W.jsx)(lr,{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`,children:(0,W.jsxs)(`div`,{className:`grid min-w-0 max-w-3xl gap-5`,children:[(0,W.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,W.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${xt(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,W.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,W.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,W.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,W.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,W.jsxs)(`section`,{className:`min-w-0`,children:[(0,W.jsx)(vr,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,W.jsx)(I,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,W.jsx)(V,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,W.jsx)(I,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations`,children:`Back to automations`})})]}),u?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var br=M([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),xr=O(j().trim().min(1).max(200)).max(100).optional(),Sr=C({includeExisting:k().optional(),requireCurrentLabels:k().optional(),authors:xr,assignees:xr,allLabels:xr,anyLabels:xr,excludeLabels:xr,changedLabels:xr,lookbackDays:N().int().min(1).max(90).default(7),maxRecords:N().int().min(1).max(100).default(25)}).passthrough(),Cr=C({prompt:j().min(1).max(1e5),workflow:j().trim().min(1).max(200).optional(),steps:O(a).min(1).max(100).optional(),runner:f.optional(),model:j().trim().min(1).max(200).optional(),effort:j().trim().min(1).max(32).optional(),variants:w([E(1),E(2),E(3)]).optional(),worktree:k().optional(),autonomous:k().optional(),...g,...S,systemPrompt:j().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),wr=new Set(Object.keys(Cr.shape).filter(e=>e!==`variants`));function Tr(e){return Object.fromEntries(Object.entries(e).filter(([e])=>wr.has(e)))}A(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},C({id:j().min(1).max(100),revision:N().int().positive(),name:j().trim().min(1).max(200),description:j().max(2e3).optional(),enabled:k().default(!1),kind:Un.default(`github`),events:O(br).min(1).max(4).optional(),intervalSeconds:N().int().min(60).max(86400).optional(),filters:Sr.optional(),schedule:ct.passthrough().optional(),task:Cr,archived:C({at:j().datetime(),outcome:M([`launched`,`cancelled`]),runId:j().optional(),receiptId:j().optional(),trigger:M([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:j().datetime(),updatedAt:j().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:m.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:m.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:m.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:m.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:m.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),C({version:E(1).default(1),automations:O(D()).default([]),tombstones:T(j(),j().datetime()).optional()}).passthrough();var Er=C({timestamp:j().datetime(),tieBreaker:j().optional()}).passthrough(),Dr=Jn.extend({cursor:Er.optional()}),Or=C({revision:N().int().positive().optional(),baselineAt:j().datetime().optional(),armedAt:j().datetime().optional(),historyScan:Dr.optional(),cursor:Er.optional(),frozenHighWatermark:Er.extend({tieBreaker:j()}).optional(),backlogAfter:Er.extend({tieBreaker:j()}).optional(),nextCheckAt:j().datetime().optional(),lastSuccessAt:j().datetime().optional(),nextRunAt:j().datetime().optional(),lastRunAt:j().datetime().optional(),etags:T(j(),j()).optional(),backoffUntil:j().datetime().optional(),consecutiveFailures:N().int().nonnegative().optional(),...Yn,onceOutcome:M([`failed`,`missed`]).optional()}).passthrough();C({version:E(1).default(1),states:T(j(),Or).default({})}).passthrough(),C({receiptId:j().min(1),receiptKey:j().min(1),eventId:j().min(1),automationId:j().min(1),revision:N().int().positive(),status:M([`reserved`,`launched`,`launch-error`,`released`]),runId:j().optional(),observedAt:j().datetime(),updatedAt:j().datetime(),error:j().max(2e3).optional(),occurrenceAt:j().datetime().optional(),candidate:C({eventId:j(),event:br,timestamp:j().datetime(),tieBreaker:j(),repo:j(),nodeId:j(),number:N().int().positive(),title:j().max(500),url:j().url(),author:j().max(200),assignees:O(j().max(200)).max(100),labels:O(j().max(200)).max(100),changedLabel:j().max(200).optional()}).passthrough().optional()}).passthrough();var kr=M([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);C({seq:N().int().positive(),ts:j().datetime(),automationId:j().min(1),revision:N().int().positive(),event:br.optional(),result:kr,reason:j().max(2e3).optional(),durationMs:N().int().nonnegative().optional(),receiptId:j().optional(),runId:j().optional(),githubNumber:N().int().positive().optional(),githubTitle:j().max(500).optional(),githubUrl:j().url().optional(),rateLimit:C({bucket:M([`core`,`search`]),remaining:N().int().nonnegative().optional(),resetAt:j().datetime().optional()}).passthrough().optional()}).passthrough();var Ar=`quick-task`;function jr(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Tr(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:St(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Ar}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function Mr(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Nr(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Pr(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Mr(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Nr(e)}}function Fr(e){return{...Pr(e),enable:e.enabled}}function Ir(e,t){return{...Pr(e),task:{...Nr(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Q(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Lr=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Rr=new Set([`anyLabels`,`authors`,`changedLabels`]);function zr(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!Lr.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||Rr.has(e)&&Array.isArray(t)&&t.length>0)}function Br(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function Vr(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function $(e,t){return t.startsWith(`-`)?`--${e}=${Q(t)}`:`--${e} ${Q(t)}`}function Hr(e){let t=[`${at()} automation add`,$(`name`,e.name)];if(e.schedule?.type===`once`)t.push($(`at`,e.schedule.at),$(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push($(`latest-start`,Vr(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push($(`cron`,mt(e.schedule)));else{t.push($(`on`,e.events.join(`,`)),`--every ${Br(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push($(`label`,n));for(let n of e.filters?.authors??[])t.push($(`author`,n));for(let n of e.filters?.changedLabels??[])t.push($(`changed-label`,n))}return t.push(...Ur(e.task)),e.enable===!0&&t.push(`--enable`),t.push($(`prompt`,e.task.prompt)),t.join(` `)}function Ur(e){let t=[];return e.workflow&&t.push($(`workflow`,e.workflow)),e.runner&&t.push($(`runner`,e.runner)),e.model&&t.push($(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function Wr(e,t){let n=Fr(e),r=zr(n)?Hr(n):`${at()} automation create --json ${Q(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Q(t.origin)} CEZ_PROJECT_ID=${Q(t.projectId)} HSQ_COCKPIT_URL=${Q(t.origin)} HSQ_PROJECT_ID=${Q(t.projectId)} ${r}`:r}function Gr({draft:e}){let t=We(),n=window.location.origin,r=(0,U.useMemo)(()=>Wr(e,t?{origin:n,projectId:t}:void 0),[e,n,t]),[i,a]=(0,U.useState)(`idle`),o=(0,U.useRef)(void 0);(0,U.useEffect)(()=>()=>clearTimeout(o.current),[]),(0,U.useEffect)(()=>a(`idle`),[r]);let s=async()=>{clearTimeout(o.current);try{await navigator.clipboard.writeText(r),a(`copied`),o.current=setTimeout(()=>a(`idle`),1600)}catch{a(`failed`)}};return(0,W.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`mbs-4 rounded-xl border bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`mbe-2 flex items-center gap-2`,children:[(0,W.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[15px] font-medium`,children:`Copy as CLI`}),(0,W.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`ms-auto`,onClick:()=>void s(),children:[i===`copied`?(0,W.jsx)(ve,{"aria-hidden":`true`}):(0,W.jsx)(tt,{"aria-hidden":`true`}),i===`copied`?`Copied`:`Copy`]})]}),(0,W.jsx)(`pre`,{className:`m-0 rounded-lg border bg-muted px-2.5 py-2 font-mono text-xs/relaxed break-words whitespace-pre-wrap text-muted-foreground`,children:r}),(0,W.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:i===`failed`?`Could not copy — select the line and copy it by hand.`:(0,W.jsxs)(W.Fragment,{children:[`The definition Save would create. `,(0,W.jsxs)(`code`,{children:[at(),` automation schema`]}),` prints its shape.`]})})]})}function Kr({pressed:e,onClick:t,disabled:n,children:r}){return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:i(Je,`h-11 px-4 text-[13px]`,e&&`border-transparent bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong hover:text-accent-strong-foreground`),children:r})}var qr=Vn.options,Jr=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],Yr=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],Xr=e=>(e??[]).join(`, `),Zr=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function Qr(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function $r(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${Qr(e.filters.includeExisting)}`}function ei({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=Zr(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=Jr.some(t=>t.seconds===e.intervalSeconds)?Jr:[...Jr,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,W.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,W.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-2`,children:qr.map(t=>(0,W.jsx)(Kr,{pressed:e.events.includes(t),onClick:()=>r(t),children:t},t))}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-interval`,children:`Check every`}),(0,W.jsxs)(nr,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,W.jsx)(ir,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:o.map(e=>(0,W.jsx)(or,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Le,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,W.jsx)(`span`,{children:`Include existing items`})]}),(0,W.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:Qr(e.filters.includeExisting)})]}),(0,W.jsxs)(Fe,{children:[(0,W.jsxs)(Pe,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,W.jsx)(pe,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,W.jsx)(Ne,{children:(0,W.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[Yr.map(t=>(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,W.jsx)(H,{id:`automation-filter-${t.key}`,placeholder:`comma separated`,value:Xr(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,W.jsx)(H,{id:`automation-filter-lookback`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,W.jsx)(H,{id:`automation-filter-max`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var ti=e=>String(e).padStart(2,`0`);function ni({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,U.useState)(ti(t)),o=(0,U.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${ti(n)}.`,l=(0,U.useId)();return(0,U.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(ti(t))}),s?(0,W.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var ri=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],ii=`none`,ai=e=>String(e).padStart(2,`0`);function oi(e,t=Date.now()){let n=Ct(t,e)??Ct(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${ai(r.getUTCMonth()+1)}-${ai(r.getUTCDate())}T09:00`}function si(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function ci({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?ht(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${ai(t)}:${ai(n)}`}),l=(0,U.useRef)(null),u=(0,U.useId)(),d=ut(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,U.useEffect)(()=>{l.current?.setCustomValidity(f?st:``)},[f]);let p=yt(e);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-once-date`,children:`Date`}),(0,W.jsx)(H,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(ni,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(ni,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,W.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:st}):null,(0,W.jsx)(ui,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,W.jsx)(di,{value:e.latestStartMinutes,onChange:t=>n(li(e,t))}),p?(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function li(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function ui({value:e,onCommit:t}){let[n,r]=(0,U.useState)(e),i=(0,U.useRef)(null),a=(0,U.useId)(),o=(0,U.useId)(),[s]=(0,U.useState)(si),c=n!==e||!ot(n),l=dt(n);return(0,U.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,W.jsx)(H,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),ot(e.target.value)&&t(e.target.value)}}),(0,W.jsx)(`datalist`,{id:a,children:s.map(e=>(0,W.jsx)(`option`,{value:e},e))}),c?(0,W.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function di({value:e,onChange:t}){let n=ri.some(t=>t.minutes===e)||e===void 0?ri:[...ri,{minutes:e,label:`${e} minutes`}];return(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,W.jsxs)(nr,{value:e===void 0?ii:String(e),onValueChange:e=>t(e===ii?void 0:Number(e)),children:[(0,W.jsx)(ir,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:n.map(e=>(0,W.jsx)(or,{value:e.minutes===void 0?ii:String(e.minutes),children:e.label},e.label))})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var fi=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function pi({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??oi(r),timeZone:e.timeZone??r}:{type:t});return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`flex flex-wrap gap-2`,children:fi.map(t=>(0,W.jsx)(Kr,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,W.jsx)(ci,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,W.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`flex flex-wrap gap-2`,children:bt.map((t,n)=>(0,W.jsx)(Kr,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-every`,children:`Run every`}),(0,W.jsxs)(nr,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,W.jsx)(ir,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:_t.map(e=>(0,W.jsx)(or,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(ni,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(ni,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,W.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,W.jsx)(`code`,{className:`font-mono text-foreground`,children:mt(e)})]})]})}var mi=40*864e5,hi=5;function gi({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,W.jsx)(_i,{schedule:e,now:n});let r=lt(e,n+1,n+mi,t,hi);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Next 5 runs`}),r.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,W.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid gap-1.5 text-sm`,children:r.map(e=>(0,W.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:xt(new Date(e).toISOString(),t)}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:pt(n,e)})]},e))}),(0,W.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function _i({schedule:e,now:t}){let n=ut(e),r=yt(e);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Runs once`}),n===null||!r?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,W.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:pt(t,n)}):null]}),r?.note?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,W.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,W.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var vi={schedule:`On a schedule`,github:`When GitHub changes`};function yi(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function bi({title:e,failure:t,section:n,children:r}){return(0,W.jsxs)(`fieldset`,{className:`grid min-w-0 gap-4 rounded-xl border p-5 max-md:p-4!`,children:[(0,W.jsx)(`legend`,{className:`px-0`,children:e}),r,t?.section===n&&!t.conflict?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:t.message}):null]})}function xi({draft:e,patch:t,forge:n,automation:r}){return(0,W.jsx)(W.Fragment,{children:r?(0,W.jsxs)(`p`,{className:`text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),vi[e.kind]]}):(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(it,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:vi.schedule},{value:`github`,label:vi.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Si({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,W.jsx)(pi,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,W.jsx)(ei,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Ci({draft:e,patch:t,saving:n,automation:r}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,W.jsx)(wt,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:4,required:!0}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,W.jsx)(Ei,{draft:e,patch:t}),(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Le,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,W.jsxs)(`span`,{children:[`Autonomous `,(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,W.jsx)(et,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,W.jsx)(Xe,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function wi({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Le,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,W.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:Qr(e.filters.includeExisting)})]})}function Ti({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,s]=(0,U.useState)(()=>jr(e)),[u,d]=(0,U.useState)(e?.revision),[f,p]=(0,U.useState)(),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(!1),[x,S]=(0,U.useState)(``),C=e=>s(t=>({...t,...e})),w=async t=>{if(t.preventDefault(),m)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),p(void 0);let i=`save`;try{if(e&&u!==void 0){let{automation:t}=await l(e.id,Ir({...a,enabled:e.enabled},u));d(t.revision),a.enabled!==e.enabled&&(i=`enable`,await c(e.id,a.enabled))}else await ee(Fr(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof o&&t.status===409&&/revision conflict/i.test(n)?p({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):p({section:i===`enable`?`enable`:yi(n),message:n})}finally{h(!1)}},T=async()=>{if(!(!e||v)){y(!0),S(``);try{await b(e.id),r()}catch(e){S(e instanceof Error?e.message:String(e))}finally{y(!1)}}},E=e?`Save changes`:a.enabled?`Save and enable`:`Save paused`,D=a.kind===`schedule`;return(0,W.jsx)(lr,{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,children:(0,W.jsxs)(`form`,{className:`automation-editor grid min-w-0 gap-5 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:w,children:[(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,W.jsx)(bi,{title:`Name`,section:`name`,failure:f,children:(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-name`,children:`Name`}),(0,W.jsx)(H,{id:`automation-name`,value:a.name,onChange:e=>C({name:e.target.value}),required:!0})]})}),(0,W.jsxs)(bi,{title:`When`,section:`when`,failure:f,children:[(0,W.jsx)(xi,{draft:a,patch:C,forge:t,automation:e}),(0,W.jsx)(Si,{draft:a,patch:C,forge:t,timeZone:n,automation:e})]}),(0,W.jsx)(bi,{title:`What to run`,section:`run`,failure:f,children:(0,W.jsx)(Ci,{draft:a,patch:C,saving:m,automation:e})}),(0,W.jsx)(bi,{title:`Enable`,section:`enable`,failure:f,children:(0,W.jsx)(wi,{draft:a,patch:C,automation:e})}),f?.section===`form`?(0,W.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,W.jsx)(`span`,{className:`break-words`,children:f.message}),f.conflict&&i?(0,W.jsx)(I,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{type:`submit`,disabled:m,children:m?`Saving…`:E}),(0,W.jsx)(I,{type:`button`,variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations`,children:`Cancel`})})]}),e?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:v,onClick:()=>void T(),children:`Delete automation`}),(0,W.jsx)(I,{type:`button`,variant:`outline`,disabled:v,onClick:()=>{_(!1),S(``)},children:`Keep`})]})]}):(0,W.jsx)(I,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>_(!0),children:`Delete`}),x?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:x}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`min-w-0 md:sticky md:top-4`,children:[D?(0,W.jsx)(gi,{schedule:a.schedule,timeZone:n}):(0,W.jsxs)(`section`,{className:`rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{className:`mb-2 text-[15px] font-medium`,children:`How it polls`}),(0,W.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:$r(a)})]}),(0,W.jsx)(Gr,{draft:a})]})]})})}function Ei({draft:e,patch:t}){let n=P(),r=Ze(),{runners:i,signedOut:a}=r.runnersOn(e=>r.repoAccount?.[e]),o=ie(),s=ne(),{runner:c,ready:l}=re(e.runner??o.data?.defaultRunner??`claude`),u=ae(c,l,r.repoAccount?.[c]),d=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],f=[...new Set([...i,...e.runner?[e.runner]:[]])],p=Ye(c,s.data,u.data,[e.model]),m=p.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,h=e=>(0,W.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,W.jsx)(qe,{children:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)($e,{slot:`automation-workflow-pill`,icon:h(he),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:d.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,W.jsx)($e,{slot:`automation-runner-pill`,icon:h(fe),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner??`default`,value:e.runner??``,disabled:!s.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},...f.map(e=>({value:e,label:te(s.data,e)}))],footer:(0,W.jsx)(nt,{uninstalled:r.uninstalled,signedOut:a.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,W.jsx)($e,{slot:`automation-model-pill`,icon:h(ge),fieldLabel:!0,ariaLabel:`Model`,label:m,value:e.model??``,options:p.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Di({data:e,error:t,refresh:n,archived:r=!1,onArchivedChange:i}){let[a,o]=(0,U.useState)({}),[l,u]=(0,U.useState)({}),d=(e,t)=>o(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t)=>{u(t=>({...t,[e]:!0}));try{await t()}catch(t){d(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{u(t=>({...t,[e]:!1}))}},p=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await s(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),m=e=>f(e.id,async()=>{d(e.id,void 0),await c(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await y(e.id),await n()}),_=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await h(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await x(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)});return(0,W.jsx)(lr,{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,action:(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(V,{to:`/automations/new`,children:`New automation`})}),children:t&&!e?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(Z,{text:t}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Oi,{data:e}),i?(0,W.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,children:(0,W.jsx)(Kr,{pressed:r,onClick:()=>i(!r),children:`Archived`})}):null,r&&e.automations.length===0?(0,W.jsx)(Z,{text:`No archived one-time schedules.`}):e.automations.length===0?(0,W.jsx)(Ge,{icon:(0,W.jsx)(me,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(V,{to:`/automations/new`,children:`New automation`})})}):(0,W.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:e.automations.map(t=>(0,W.jsx)(zi,{automation:t,timeZone:e.timeZone,note:a[t.id],busy:l[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void m(t),onPreview:()=>void _(t),onCancel:()=>void g(t)},t.id))})]}):(0,W.jsx)(Z,{text:`Loading automations…`})})}function Oi({data:e}){return(0,W.jsx)(`p`,{"data-slot":`automation-scheduler`,className:i(`mb-4 text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function ki(e){return e.kind===`schedule`&&e.schedule?ft(e.schedule):`on ${(e.events??[]).join(`, `)} · every ${Math.round((e.intervalSeconds??300)/60)} min`}var Ai={waiting:{label:`Waiting`,dot:`success`},paused:{label:`Paused`,dot:`neutral`},failed:{label:`Failed`,dot:`danger`},missed:{label:`Missed`,dot:`pending`},archived:{label:`Archived`,dot:`neutral`}};function ji(e){if(e.schedule?.type===`once`)return Ai[e.onceStatus??(e.enabled?`waiting`:`paused`)]}function Mi({automation:e,badge:t}){return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,W.jsx)(e.kind===`schedule`?le:ce,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[13px] break-words text-muted-foreground`,children:ki(e)})]}),t?(0,W.jsx)(rt,{dot:t.dot,children:t.label}):(0,W.jsx)(rt,{dot:e.enabled?`success`:`neutral`,children:e.enabled?`Enabled`:`Paused`})]})}function Ni({automation:e,archive:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`mt-3 text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations/${e.id}`,children:`Details`})})})]})}function Pi({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return(0,W.jsx)(`p`,{className:`mt-3 text-sm`,children:!n&&e.enabled?(0,W.jsx)(`span`,{children:`continuous`}):r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`Next run: ${xt(r,t)}`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:` · ${pt(Date.now(),Date.parse(r))}`})]}):(0,W.jsx)(`span`,{children:`Next run: —`})})}function Fi({automation:e,timeZone:t}){let n=e.enabled?Zn(e.state):void 0;return n?(0,W.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`mt-3 text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${xt(n.retryAt,t)}`}):null]}):null}function Ii({automation:e,busy:t,confirmingCancel:n,cancelRef:r,onToggle:i,onRun:a,onPreview:o,onOpenCancel:s}){let c=e.kind===`schedule`,l=e.schedule?.type===`once`;return(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations/${e.id}`,children:`Edit`})}),(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,W.jsx)(I,{variant:`outline`,"data-action":`automation-toggle`,disabled:t,onClick:i,children:e.enabled?`Pause`:`Enable`}),c?(0,W.jsx)(I,{variant:`outline`,"data-action":`automation-run`,disabled:t,onClick:a,children:`Run now`}):(0,W.jsx)(I,{variant:`outline`,"data-action":`automation-preview`,disabled:t,onClick:o,children:`Test filter`}),l&&!n?(0,W.jsx)(I,{variant:`outline`,ref:r,"data-action":`automation-cancel`,disabled:t,onClick:s,children:`Cancel`}):null]})}function Li({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,W.jsxs)(`div`,{className:`mt-3 grid justify-items-start gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,W.jsx)(I,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function Ri({note:e}){return(0,W.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:i(`mt-3 text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function zi({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,W.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsx)(Mi,{automation:e,badge:ji(e)}),h?(0,W.jsx)(Ni,{automation:e,archive:h}):null,h?null:(0,W.jsx)(Pi,{automation:e,timeZone:t}),h?null:(0,W.jsx)(Fi,{automation:e,timeZone:t}),h?null:(0,W.jsx)(Ii,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,W.jsx)(Li,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,W.jsx)(Ri,{note:n}):null,(0,W.jsx)(vr,{automationId:e.id,automationName:e.name,timeZone:t})]})}function Bi(e){let t=We(),n=Ke(),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(``),s=(0,U.useCallback)(t=>_({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,U.useEffect)(()=>{n&&s()},[n,s]),(0,U.useEffect)(()=>d(async e=>{n&&await s(e)}),[n,s]),(0,U.useEffect)(()=>se((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function Vi({mode:e=`list`}){let{automationId:t}=oe(),n=Ue(),[r,i]=(0,U.useState)(!1),{data:a,error:o,refresh:s}=Bi(e===`list`?r?`only`:void 0:`include`),[c,l]=(0,U.useState)(0),u=Qe();if(u===`unknown`)return(0,W.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,W.jsx)(Z,{text:`Loading automations…`})});if(u===`unavailable`)return(0,W.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,W.jsx)(Ge,{icon:(0,W.jsx)(me,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,W.jsx)(Di,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,W.jsx)(lr,{title:`Automations`,subtitle:`Could not load automations.`,children:(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(Z,{text:o}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,W.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,W.jsx)(Z,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,W.jsx)(Ti,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,W.jsx)(yr,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,W.jsx)(Ti,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,W.jsx)(lr,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,W.jsx)(I,{asChild:!0,variant:`outline`,children:(0,W.jsx)(V,{to:`/automations`,children:`Back to automations`})})}):t?(0,W.jsx)(_r,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,W.jsx)(Z,{text:`Automation not found.`})}export{Vi as AutomationsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{$n as a,An as o,F as s,I as c,L as l,P as u,Rr as d,Xr as f,Zn as p,Zr as m,a as h,er as g,g as _,h as v,i as y,l as b,m as x,nr as S,o as ee}from"./project-scope-context-D9axDY18.js";import{B as C,G as w,H as T,I as E,K as D,N as O,P as k,V as A,W as j,j as M,z as N}from"./live-protocol-DteqtbyN.js";import{D as P,Jt as te,Xt as ne,Yt as re,_ as ie,en as ae}from"./queries-DzwCG927.js";import{h as oe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as se,t as F}from"./label-6PgIe3Ny.js";import{I as ce,Y as le,c as ue,d as de,it as fe,l as pe,pt as me,ut as he,y as ge}from"./design-icons-CzEoMH9c.js";import{n as _e,r as ve}from"./dist-C28wFbz0.js";import{t as I}from"./button-BQ2y4XRB.js";import{a as L,n as ye}from"./dist-BW234Kg5.js";import{a as R,i as be,n as z,r as B,t as xe}from"./dist-C5mlVBmd.js";import{h as Se,m as Ce}from"./dropdown-menu-4e2iKSMT.js";import{a as we,c as Te,i as Ee,l as De,n as Oe,o as ke,r as Ae,t as je,u as Me}from"./es2015-CQth82uv.js";import{n as Ne,r as Pe,t as Fe}from"./collapsible-BEV4FO-1.js";import{n as Ie,t as Le}from"./switch-Bv2Zf1uU.js";import{a as Re,i as ze,n as Be,r as Ve,t as He}from"./dist-BAoXdNsT.js";import{c as Ue,s as We,t as V}from"./project-router-CDPfL2Jz.js";import{t as Ge}from"./centered-state-V15AR_qo.js";import{En as Ke,G as qe,Gn as H,J as Je,N as Ye,O as Xe,Sn as Ze,Tn as Qe,W as $e,k as et,nr as tt,q as nt,r as rt,t as it,vn as at}from"./index-CHIFhfha.js";import{_ as ot,a as st,c as ct,d as lt,f as ut,g as dt,h as ft,i as pt,l as mt,m as ht,n as gt,o as _t,p as vt,r as yt,s as bt,t as xt,u as St,v as Ct}from"./automation-format-CUP262Tk.js";import{t as wt}from"./textarea-vJt9undk.js";function Tt(e,[t,n]){return Math.min(n,Math.max(t,e))}var U=e(t(),1),Et=e(n(),1),W=r(),Dt=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Ot=[` `,`Enter`],G=`Select`,[kt,At,jt]=Se(G),[K,Mt]=be(G,[jt,Re]),Nt=Re(),[Pt,q]=K(G),[Ft,It]=K(G),Lt=`SelectProvider`;function Rt(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Nt(t),[_,v]=U.useState(null),[y,b]=U.useState(null),[x,S]=U.useState(!1),ee=Ce(l),[C,w]=xe({prop:r,defaultProp:i??!1,onChange:a,caller:G}),[T,E]=xe({prop:o,defaultProp:s,onChange:c,caller:G}),D=U.useRef(null),O=U.useRef(T);U.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=()=>E(O.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,E]);let k=!_||!!m||!!_.closest(`form`),[A,j]=U.useState(new Set),M=De(),N=Array.from(A).map(e=>e.props.value).join(`;`),P=U.useCallback(e=>{j(t=>new Set(t).add(e))},[]),te=U.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),ne={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:M,value:T,onValueChange:E,open:C,onOpenChange:w,dir:ee,triggerPointerDownPosRef:D,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:A,nativeSelectKey:N,isFormControl:k};return(0,W.jsx)(ze,{...g,children:(0,W.jsx)(Pt,{scope:t,...ne,children:(0,W.jsx)(kt.Provider,{scope:t,children:(0,W.jsx)(Ft,{scope:t,onNativeOptionAdd:P,onNativeOptionRemove:te,children:In(h)?h(ne):n})})})})}Rt.displayName=Lt;var zt=e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(Rt,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(Fn,{__scopeSelect:t}):null]})})};zt.displayName=G;var Bt=`SelectTrigger`,Vt=U.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Nt(n),o=q(Bt,n),s=o.disabled||r,c=L(t,o.onTriggerChange),l=At(n),u=U.useRef(`touch`),[d,f,p]=Rn(e=>{let t=l().filter(e=>!e.disabled),n=zn(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,W.jsx)(He,{asChild:!0,...a,children:(0,W.jsx)(R.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Ln(o.value)?``:void 0,...i,ref:c,onClick:B(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:B(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:B(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Dt.includes(e.key)&&(m(),e.preventDefault())})})})});Vt.displayName=Bt;var Ht=`SelectValue`,Ut=U.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=q(Ht,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=L(t,c.onValueNodeChange);z(()=>{l(u)},[l,u]);let f=Ln(c.value);return(0,W.jsx)(R.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(U.Fragment,{children:f?o:a},f?`placeholder`:`value`)})});Ut.displayName=Ht;var Wt=`SelectIcon`,Gt=U.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(R.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});Gt.displayName=Wt;var Kt=`SelectPortal`,[qt,Jt]=K(Kt,{forceMount:void 0}),Yt=e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(qt,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(Ee,{asChild:!0,...r})})};Yt.displayName=Kt;var J=`SelectContent`,Xt=U.forwardRef((e,t)=>{let n=Jt(J,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(J,e.__scopeSelect),[o,s]=U.useState();return z(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(Me,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(tn,{...i,ref:t}):(0,W.jsx)(Zt,{...i,fragment:o})})});Xt.displayName=J;var Zt=U.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,fragment:i}=e;return i?Et.createPortal((0,W.jsx)(Qt,{scope:n,children:(0,W.jsx)(kt.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null});Zt.displayName=`SelectContentFragment`;var Y=10,[Qt,X]=K(J),$t=`SelectContentImpl`,en=ye(`SelectContent.RemoveScroll`),tn=U.forwardRef((e,t)=>{let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=q(J,n),[y,b]=U.useState(null),[x,S]=U.useState(null),ee=L(t,b),[C,w]=U.useState(null),[T,E]=U.useState(null),D=At(n),[O,k]=U.useState(!1),A=U.useRef(!1);U.useEffect(()=>{if(y)return je(y)},[y]),Ae();let j=U.useCallback(e=>{let[t,...n]=D().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[D,x]),M=U.useCallback(()=>j([C,y]),[j,C,y]);U.useEffect(()=>{O&&M()},[O,M]);let{onOpenChange:N,triggerPointerDownPosRef:P}=v;U.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(P.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(P.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||N(!1),document.removeEventListener(`pointermove`,t),P.current=null};return P.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,N,P]),U.useEffect(()=>{let e=()=>N(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[N]);let[te,ne]=Rn(e=>{let t=D().filter(e=>!e.disabled),n=zn(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),re=U.useCallback((e,t,n)=>{let r=!A.current&&!n;(v.value!==void 0&&v.value===t||r)&&(w(e),r&&(A.current=!0))},[v.value]),ie=U.useCallback(()=>y?.focus(),[y]),ae=U.useCallback((e,t,n)=>{let r=!A.current&&!n;(v.value!==void 0&&v.value===t||r)&&E(e)},[v.value]),oe=r===`popper`?on:rn,se=oe===on?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(Qt,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:re,selectedItem:C,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:M,selectedItemText:T,position:r,isPositioned:O,searchRef:te,children:(0,W.jsx)(Oe,{as:en,allowPinchZoom:!0,children:(0,W.jsx)(we,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:B(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(ke,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...se,onPlaced:()=>k(!0),ref:ee,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:B(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=D().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>j(t)),e.preventDefault()}})})})})})})});tn.displayName=$t;var nn=`SelectItemAlignedPosition`,rn=U.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=q(J,n),o=X(J,n),[s,c]=U.useState(null),[l,u]=U.useState(null),d=L(t,u),f=At(n),p=U.useRef(!1),m=U.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=U.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Y,d=Tt(a,[Y,Math.max(Y,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Y,d=Tt(a,[Y,Math.max(Y,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Y*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),ee=window.getComputedStyle(h),C=parseInt(ee.paddingTop,10),w=parseInt(ee.paddingBottom,10),T=e.top+e.height/2-Y,E=c-T,D=g.offsetHeight/2,O=g.offsetTop+D,k=m+v+O,A=x-k;if(k<=T){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=k+Math.max(E,D+(e?w:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(T,m+h.offsetTop+(e?C:0)+D)+A;s.style.height=t+`px`,h.scrollTop=k-T+h.offsetTop}s.style.margin=`${Y}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);z(()=>y(),[y]);let[b,x]=U.useState();return z(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,W.jsx)(sn,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:U.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(R.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});rn.displayName=nn;var an=`SelectPopperPosition`,on=U.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Y,...a}=e,o=Nt(n);return(0,W.jsx)(Ve,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});on.displayName=an;var[sn,cn]=K(J,{}),ln=`SelectViewport`,un=U.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=X(ln,n),o=cn(ln,n),s=L(t,a.onViewportChange),c=U.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(kt.Slot,{scope:n,children:(0,W.jsx)(R.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:B(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Y*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});un.displayName=ln;var dn=`SelectGroup`,[fn,pn]=K(dn),mn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=De();return(0,W.jsx)(fn,{scope:n,id:i,children:(0,W.jsx)(R.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});mn.displayName=dn;var hn=`SelectLabel`,gn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=pn(hn,n);return(0,W.jsx)(R.div,{id:i.id,...r,ref:t})});gn.displayName=hn;var _n=`SelectItem`,[vn,yn]=K(_n),bn=U.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=q(_n,n),c=X(_n,n),l=s.value===r,[u,d]=U.useState(a??``),[f,p]=U.useState(!1),m=L(t,Te(e=>c.itemRefCallback?.(e,r,i))),h=De(),g=U.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};return(0,W.jsx)(vn,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:U.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(kt.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(R.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:B(o.onFocus,()=>p(!0)),onBlur:B(o.onBlur,()=>p(!1)),onClick:B(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:B(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:B(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:B(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:B(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:B(o.onKeyDown,e=>{i||e.target!==e.currentTarget||c.searchRef?.current!==``&&e.key===` `||(Ot.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});bn.displayName=_n;var xn=`SelectItemText`,Sn=U.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=q(xn,n),s=X(xn,n),c=yn(xn,n),l=It(xn,n),[u,d]=U.useState(null),f=Te(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=L(t,d,c.onItemTextChange,f),m=u?.textContent,h=U.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return z(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(R.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!Ln(o.value)?Et.createPortal(a.children,o.valueNode):null]})});Sn.displayName=xn;var Cn=`SelectItemIndicator`,wn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return yn(Cn,n).isSelected?(0,W.jsx)(R.span,{"aria-hidden":!0,...r,ref:t}):null});wn.displayName=Cn;var Tn=`SelectScrollUpButton`,En=U.forwardRef((e,t)=>{let n=X(Tn,e.__scopeSelect),r=cn(Tn,e.__scopeSelect),[i,a]=U.useState(!1),o=L(t,r.onScrollButtonChange);return z(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(kn,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});En.displayName=Tn;var Dn=`SelectScrollDownButton`,On=U.forwardRef((e,t)=>{let n=X(Dn,e.__scopeSelect),r=cn(Dn,e.__scopeSelect),[i,a]=U.useState(!1),o=L(t,r.onScrollButtonChange);return z(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(kn,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});On.displayName=Dn;var kn=U.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=X(`SelectScrollButton`,n),o=U.useRef(null),s=At(n),c=U.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return U.useEffect(()=>()=>c(),[c]),z(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,W.jsx)(R.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:B(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:B(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:B(i.onPointerLeave,()=>{c()})})}),An=`SelectSeparator`,jn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,W.jsx)(R.div,{"aria-hidden":!0,...r,ref:t})});jn.displayName=An;var Mn=`SelectArrow`,Nn=U.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Nt(n);return X(Mn,n).position===`popper`?(0,W.jsx)(Be,{...i,...r,ref:t}):null});Nn.displayName=Mn;var Pn=`SelectBubbleInput`,Fn=U.forwardRef(({__scopeSelect:e,...t},n)=>{let r=q(Pn,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=U.useRef(null),m=L(n,p),h=i??``,g=Ie(h),_=Array.from(d).some(e=>(e.props.value??``)===``);return U.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(g!==h&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,h),e.dispatchEvent(t)}},[g,h]),(0,W.jsxs)(R.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{..._e,...t.style},ref:m,defaultValue:h,children:[Ln(i)&&!_?(0,W.jsx)(`option`,{value:``}):null,Array.from(d)]},f)});Fn.displayName=Pn;function In(e){return typeof e==`function`}function Ln(e){return e===``||e===void 0}function Rn(e){let t=Te(e),n=U.useRef(``),r=U.useRef(0),i=U.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=U.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return U.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function zn(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Bn(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Bn(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vn=M([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),Hn=C({includeExisting:k().optional(),authors:O(j()).optional(),assignees:O(j()).optional(),requireCurrentLabels:k().optional(),allLabels:O(j()).optional(),anyLabels:O(j()).optional(),excludeLabels:O(j()).optional(),changedLabels:O(j()).optional(),lookbackDays:N(),maxRecords:N()}),Un=M([`github`,`schedule`]),Wn=p.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:j(),variants:w([E(1),E(2),E(3)]).optional(),systemPrompt:j().optional()}),Gn=C({at:j(),outcome:M([`launched`,`cancelled`]),runId:j().optional(),receiptId:j().optional(),trigger:M([`schedule`,`late`,`manual`,`retry`]).optional()}),Kn=C({id:j(),revision:N(),name:j(),description:j().optional(),enabled:k(),kind:Un,events:O(Vn).optional(),intervalSeconds:N().optional(),filters:Hn.optional(),schedule:ct.optional(),task:Wn,archived:Gn.optional(),createdAt:j(),updatedAt:j()}),qn=C({timestamp:j(),tieBreaker:j().optional()}),Jn=C({since:j().datetime(),until:j().datetime(),source:N().int().min(0).max(2),page:N().int().min(1).max(10),item:N().int().min(0).max(100),event:N().int().min(0).max(1e3),cursor:qn.optional()}),Yn={lastError:j().max(1e3).optional(),lastErrorAt:j().datetime().optional()},Xn=C({revision:N().optional(),baselineAt:j().optional(),armedAt:j().optional(),historyScan:Jn.optional(),cursor:qn.optional(),frozenHighWatermark:qn.extend({tieBreaker:j()}).optional(),backlogAfter:qn.extend({tieBreaker:j()}).optional(),nextCheckAt:j().optional(),lastSuccessAt:j().optional(),nextRunAt:j().optional(),lastRunAt:j().optional(),etags:T(j(),j()).optional(),backoffUntil:j().optional(),consecutiveFailures:N().optional(),...Yn,onceOutcome:M([`failed`,`missed`]).optional()});function Zn(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var Qn=M([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),$n=C({seq:N(),ts:j(),automationId:j(),revision:N(),event:Vn.optional(),result:Qn,reason:j().optional(),durationMs:N().optional(),receiptId:j().optional(),runId:j().optional(),githubNumber:N().optional(),githubTitle:j().optional(),githubUrl:j().optional(),rateLimit:C({bucket:M([`core`,`search`]),remaining:N().optional(),resetAt:j().optional()}).optional()}),er=C({matches:N(),launched:N(),duplicates:N(),errors:N()}),tr=Kn.extend({state:Xn.optional(),latestLog:$n.optional(),counts:er,nextRunAt:j().optional(),onceStatus:vt.optional()});C({available:k(),reason:j().optional(),timeZone:j(),scheduler:C({state:M([`scheduled`,`idle`]),nextDue:j().optional()}),automations:O(tr)}),C({automation:Kn}).extend({once:C({dueAt:j(),timeZone:j(),resolvedInstant:j(),note:j()}).optional()}),C({automation:Kn,state:Xn.optional(),latestLog:$n.optional(),onceStatus:vt.optional()}),C({id:j(),automationId:j(),mode:M([`preview`,`execute`]),status:M([`queued`,`running`,`complete`,`error`]),createdAt:j(),completedAt:j().optional(),matches:N().optional(),truncated:k().optional(),error:j().optional()}),C({checkId:j()}),C({records:O($n)}),C({receiptId:j(),runId:j()}),C({runId:j()}),Kn.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:Un.optional(),task:Wn.omit({variants:!0}).strict(),enable:k().optional()}).omit({enable:!0}).extend({enabled:k().optional(),expectedRevision:N()}),C({archived:M([`include`,`only`]).optional()}),C({mode:M([`preview`,`execute`])});function nr({...e}){return(0,W.jsx)(zt,{"data-slot":`select`,...e})}function rr({...e}){return(0,W.jsx)(Ut,{"data-slot":`select-value`,...e})}function ir({className:e,size:t=`default`,children:n,...r}){return(0,W.jsxs)(Vt,{"data-slot":`select-trigger`,"data-size":t,className:i(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-[var(--task-brand-bg)] px-3 py-2 text-sm whitespace-nowrap shadow-none transition-[color,box-shadow] outline-hidden focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-11 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 pointer-hover:bg-muted [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,W.jsx)(Gt,{asChild:!0,children:(0,W.jsx)(pe,{className:`size-4 opacity-50`})})]})}function ar({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,W.jsx)(Yt,{children:(0,W.jsxs)(Xt,{"data-slot":`select-content`,className:i(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...a,children:[(0,W.jsx)(sr,{}),(0,W.jsx)(un,{className:i(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,W.jsx)(cr,{})]})})}function or({className:e,children:t,...n}){return(0,W.jsxs)(bn,{"data-slot":`select-item`,className:i(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pe-8 ps-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,W.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute end-2 flex size-3.5 items-center justify-center`,children:(0,W.jsx)(wn,{children:(0,W.jsx)(ue,{className:`size-4`})})}),(0,W.jsx)(Sn,{children:t})]})}function sr({className:e,...t}){return(0,W.jsx)(En,{"data-slot":`select-scroll-up-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(de,{className:`size-4`})})}function cr({className:e,...t}){return(0,W.jsx)(On,{"data-slot":`select-scroll-down-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(pe,{className:`size-4`})})}function lr({title:e,subtitle:t,action:n,children:r}){return(0,W.jsxs)(`main`,{"data-route":`automations`,className:`task-flow-page w-full max-w-full min-w-0 max-md:p-4!`,children:[(0,W.jsxs)(`header`,{className:`mb-6 flex flex-col items-start gap-5 max-md:mb-4 max-md:gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`mb-2 text-[28px] font-medium max-md:text-[22px]`,children:e}),(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]}),n]}),r]})}function Z({text:e}){return(0,W.jsx)(`div`,{role:`status`,className:`rounded-xl border bg-card p-6 text-sm text-muted-foreground`,children:e})}var ur={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`neutral`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},dr={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function fr(e){let[t,n]=(0,U.useState)(),[r,i]=(0,U.useState)(``),a=(0,U.useCallback)(t=>v(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,U.useEffect)(()=>{a()},[a]),(0,U.useEffect)(()=>d(a),[a]),(0,U.useEffect)(()=>se((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function pr(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function mr({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&pr(e,t),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(),d=Date.now(),f=async e=>{s(e),l(void 0);try{await u(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,W.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,W.jsxs)(`li`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(rt,{dot:ur[e.result],children:dr[e.result]}),(0,W.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:gt(e.ts,n,d)})]}),e.reason?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,W.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,W.jsx)(I,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void f(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var hr=`all`;function gr({label:e,value:t,onChange:n,options:r}){return(0,W.jsxs)(nr,{value:t,onValueChange:n,children:[(0,W.jsx)(ir,{"aria-label":e,className:`w-full sm:w-52`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:r.map(e=>(0,W.jsx)(or,{value:e.value,children:e.label},e.value))})]})}function _r({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=fr(e),[s,c]=(0,U.useState)(hr),[l,u]=(0,U.useState)(hr),d=(0,U.useMemo)(()=>(i??[]).filter(e=>(s===hr||e.result===s)&&(l===hr||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,W.jsx)(lr,{title:`Execution log`,subtitle:t??`Automation activity`,action:(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations`,children:`Back to automations`})}),children:a&&!i?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(Z,{text:a}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,W.jsx)(Z,{text:`Nothing has run yet.`}):(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(gr,{label:`Result`,value:s,onChange:c,options:[{value:hr,label:`All results`},...Qn.options.map(e=>({value:e,label:dr[e]}))]}),f?(0,W.jsx)(gr,{label:`Event`,value:l,onChange:u,options:[{value:hr,label:`All events`},...Vn.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,W.jsx)(Z,{text:`No rows match these filters.`}):(0,W.jsx)(mr,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,W.jsx)(Z,{text:`Loading execution log…`})})}function vr({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=fr(e);return(0,W.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`mt-4 min-w-0 border-t pt-4`,children:[(0,W.jsxs)(`h3`,{className:`mb-3 text-sm font-medium`,children:[`Recent activity`,r&&t?` · ${t}`:``]}),o&&!a?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(Z,{text:o}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing has run yet.`}):(0,W.jsx)(mr,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading activity…`})]})}function yr({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?yt(i):null,[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(``),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await b(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,W.jsx)(lr,{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`,children:(0,W.jsxs)(`div`,{className:`grid min-w-0 max-w-3xl gap-5`,children:[(0,W.jsxs)(`section`,{className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,W.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${xt(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,W.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,W.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,W.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,W.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,W.jsxs)(`section`,{className:`min-w-0`,children:[(0,W.jsx)(vr,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,W.jsx)(I,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,W.jsx)(V,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,W.jsx)(I,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations`,children:`Back to automations`})})]}),u?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var br=M([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),xr=O(j().trim().min(1).max(200)).max(100).optional(),Sr=C({includeExisting:k().optional(),requireCurrentLabels:k().optional(),authors:xr,assignees:xr,allLabels:xr,anyLabels:xr,excludeLabels:xr,changedLabels:xr,lookbackDays:N().int().min(1).max(90).default(7),maxRecords:N().int().min(1).max(100).default(25)}).passthrough(),Cr=C({prompt:j().min(1).max(1e5),workflow:j().trim().min(1).max(200).optional(),steps:O(a).min(1).max(100).optional(),runner:f.optional(),model:j().trim().min(1).max(200).optional(),effort:j().trim().min(1).max(32).optional(),variants:w([E(1),E(2),E(3)]).optional(),worktree:k().optional(),autonomous:k().optional(),...g,...S,systemPrompt:j().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),wr=new Set(Object.keys(Cr.shape).filter(e=>e!==`variants`));function Tr(e){return Object.fromEntries(Object.entries(e).filter(([e])=>wr.has(e)))}A(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},C({id:j().min(1).max(100),revision:N().int().positive(),name:j().trim().min(1).max(200),description:j().max(2e3).optional(),enabled:k().default(!1),kind:Un.default(`github`),events:O(br).min(1).max(4).optional(),intervalSeconds:N().int().min(60).max(86400).optional(),filters:Sr.optional(),schedule:ct.passthrough().optional(),task:Cr,archived:C({at:j().datetime(),outcome:M([`launched`,`cancelled`]),runId:j().optional(),receiptId:j().optional(),trigger:M([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:j().datetime(),updatedAt:j().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:m.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:m.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:m.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:m.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:m.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),C({version:E(1).default(1),automations:O(D()).default([]),tombstones:T(j(),j().datetime()).optional()}).passthrough();var Er=C({timestamp:j().datetime(),tieBreaker:j().optional()}).passthrough(),Dr=Jn.extend({cursor:Er.optional()}),Or=C({revision:N().int().positive().optional(),baselineAt:j().datetime().optional(),armedAt:j().datetime().optional(),historyScan:Dr.optional(),cursor:Er.optional(),frozenHighWatermark:Er.extend({tieBreaker:j()}).optional(),backlogAfter:Er.extend({tieBreaker:j()}).optional(),nextCheckAt:j().datetime().optional(),lastSuccessAt:j().datetime().optional(),nextRunAt:j().datetime().optional(),lastRunAt:j().datetime().optional(),etags:T(j(),j()).optional(),backoffUntil:j().datetime().optional(),consecutiveFailures:N().int().nonnegative().optional(),...Yn,onceOutcome:M([`failed`,`missed`]).optional()}).passthrough();C({version:E(1).default(1),states:T(j(),Or).default({})}).passthrough(),C({receiptId:j().min(1),receiptKey:j().min(1),eventId:j().min(1),automationId:j().min(1),revision:N().int().positive(),status:M([`reserved`,`launched`,`launch-error`,`released`]),runId:j().optional(),observedAt:j().datetime(),updatedAt:j().datetime(),error:j().max(2e3).optional(),occurrenceAt:j().datetime().optional(),candidate:C({eventId:j(),event:br,timestamp:j().datetime(),tieBreaker:j(),repo:j(),nodeId:j(),number:N().int().positive(),title:j().max(500),url:j().url(),author:j().max(200),assignees:O(j().max(200)).max(100),labels:O(j().max(200)).max(100),changedLabel:j().max(200).optional()}).passthrough().optional()}).passthrough();var kr=M([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);C({seq:N().int().positive(),ts:j().datetime(),automationId:j().min(1),revision:N().int().positive(),event:br.optional(),result:kr,reason:j().max(2e3).optional(),durationMs:N().int().nonnegative().optional(),receiptId:j().optional(),runId:j().optional(),githubNumber:N().int().positive().optional(),githubTitle:j().max(500).optional(),githubUrl:j().url().optional(),rateLimit:C({bucket:M([`core`,`search`]),remaining:N().int().nonnegative().optional(),resetAt:j().datetime().optional()}).passthrough().optional()}).passthrough();var Ar=`quick-task`;function jr(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Tr(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:St(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Ar}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function Mr(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Nr(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Pr(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Mr(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Nr(e)}}function Fr(e){return{...Pr(e),enable:e.enabled}}function Ir(e,t){return{...Pr(e),task:{...Nr(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Q(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Lr=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Rr=new Set([`anyLabels`,`authors`,`changedLabels`]);function zr(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!Lr.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||Rr.has(e)&&Array.isArray(t)&&t.length>0)}function Br(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function Vr(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function $(e,t){return t.startsWith(`-`)?`--${e}=${Q(t)}`:`--${e} ${Q(t)}`}function Hr(e){let t=[`${at()} automation add`,$(`name`,e.name)];if(e.schedule?.type===`once`)t.push($(`at`,e.schedule.at),$(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push($(`latest-start`,Vr(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push($(`cron`,mt(e.schedule)));else{t.push($(`on`,e.events.join(`,`)),`--every ${Br(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push($(`label`,n));for(let n of e.filters?.authors??[])t.push($(`author`,n));for(let n of e.filters?.changedLabels??[])t.push($(`changed-label`,n))}return t.push(...Ur(e.task)),e.enable===!0&&t.push(`--enable`),t.push($(`prompt`,e.task.prompt)),t.join(` `)}function Ur(e){let t=[];return e.workflow&&t.push($(`workflow`,e.workflow)),e.runner&&t.push($(`runner`,e.runner)),e.model&&t.push($(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function Wr(e,t){let n=Fr(e),r=zr(n)?Hr(n):`${at()} automation create --json ${Q(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Q(t.origin)} CEZ_PROJECT_ID=${Q(t.projectId)} HSQ_COCKPIT_URL=${Q(t.origin)} HSQ_PROJECT_ID=${Q(t.projectId)} ${r}`:r}function Gr({draft:e}){let t=We(),n=window.location.origin,r=(0,U.useMemo)(()=>Wr(e,t?{origin:n,projectId:t}:void 0),[e,n,t]),[i,a]=(0,U.useState)(`idle`),o=(0,U.useRef)(void 0);(0,U.useEffect)(()=>()=>clearTimeout(o.current),[]),(0,U.useEffect)(()=>a(`idle`),[r]);let s=async()=>{clearTimeout(o.current);try{await navigator.clipboard.writeText(r),a(`copied`),o.current=setTimeout(()=>a(`idle`),1600)}catch{a(`failed`)}};return(0,W.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`mbs-4 rounded-xl border bg-card p-4`,children:[(0,W.jsxs)(`div`,{className:`mbe-2 flex items-center gap-2`,children:[(0,W.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[15px] font-medium`,children:`Copy as CLI`}),(0,W.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`ms-auto`,onClick:()=>void s(),children:[i===`copied`?(0,W.jsx)(ve,{"aria-hidden":`true`}):(0,W.jsx)(tt,{"aria-hidden":`true`}),i===`copied`?`Copied`:`Copy`]})]}),(0,W.jsx)(`pre`,{className:`m-0 rounded-lg border bg-muted px-2.5 py-2 font-mono text-xs/relaxed break-words whitespace-pre-wrap text-muted-foreground`,children:r}),(0,W.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:i===`failed`?`Could not copy — select the line and copy it by hand.`:(0,W.jsxs)(W.Fragment,{children:[`The definition Save would create. `,(0,W.jsxs)(`code`,{children:[at(),` automation schema`]}),` prints its shape.`]})})]})}function Kr({pressed:e,onClick:t,disabled:n,children:r}){return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:i(Je,`h-11 px-4 text-[13px]`,e&&`border-transparent bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong hover:text-accent-strong-foreground`),children:r})}var qr=Vn.options,Jr=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],Yr=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],Xr=e=>(e??[]).join(`, `),Zr=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function Qr(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function $r(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${Qr(e.filters.includeExisting)}`}function ei({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=Zr(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=Jr.some(t=>t.seconds===e.intervalSeconds)?Jr:[...Jr,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,W.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,W.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`flex flex-wrap gap-2`,children:qr.map(t=>(0,W.jsx)(Kr,{pressed:e.events.includes(t),onClick:()=>r(t),children:t},t))}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-interval`,children:`Check every`}),(0,W.jsxs)(nr,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,W.jsx)(ir,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:o.map(e=>(0,W.jsx)(or,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Le,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,W.jsx)(`span`,{children:`Include existing items`})]}),(0,W.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:Qr(e.filters.includeExisting)})]}),(0,W.jsxs)(Fe,{children:[(0,W.jsxs)(Pe,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,W.jsx)(pe,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,W.jsx)(Ne,{children:(0,W.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[Yr.map(t=>(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,W.jsx)(H,{id:`automation-filter-${t.key}`,placeholder:`comma separated`,value:Xr(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,W.jsx)(H,{id:`automation-filter-lookback`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,W.jsx)(H,{id:`automation-filter-max`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var ti=e=>String(e).padStart(2,`0`);function ni({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,U.useState)(ti(t)),o=(0,U.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${ti(n)}.`,l=(0,U.useId)();return(0,U.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(H,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(ti(t))}),s?(0,W.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var ri=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],ii=`none`,ai=e=>String(e).padStart(2,`0`);function oi(e,t=Date.now()){let n=Ct(t,e)??Ct(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${ai(r.getUTCMonth()+1)}-${ai(r.getUTCDate())}T09:00`}function si(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function ci({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?ht(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${ai(t)}:${ai(n)}`}),l=(0,U.useRef)(null),u=(0,U.useId)(),d=ut(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,U.useEffect)(()=>{l.current?.setCustomValidity(f?st:``)},[f]);let p=yt(e);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-once-date`,children:`Date`}),(0,W.jsx)(H,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(ni,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(ni,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,W.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:st}):null,(0,W.jsx)(ui,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,W.jsx)(di,{value:e.latestStartMinutes,onChange:t=>n(li(e,t))}),p?(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function li(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function ui({value:e,onCommit:t}){let[n,r]=(0,U.useState)(e),i=(0,U.useRef)(null),a=(0,U.useId)(),o=(0,U.useId)(),[s]=(0,U.useState)(si),c=n!==e||!ot(n),l=dt(n);return(0,U.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,W.jsx)(H,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),ot(e.target.value)&&t(e.target.value)}}),(0,W.jsx)(`datalist`,{id:a,children:s.map(e=>(0,W.jsx)(`option`,{value:e},e))}),c?(0,W.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function di({value:e,onChange:t}){let n=ri.some(t=>t.minutes===e)||e===void 0?ri:[...ri,{minutes:e,label:`${e} minutes`}];return(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,W.jsxs)(nr,{value:e===void 0?ii:String(e),onValueChange:e=>t(e===ii?void 0:Number(e)),children:[(0,W.jsx)(ir,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:n.map(e=>(0,W.jsx)(or,{value:e.minutes===void 0?ii:String(e.minutes),children:e.label},e.label))})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var fi=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function pi({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??oi(r),timeZone:e.timeZone??r}:{type:t});return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`flex flex-wrap gap-2`,children:fi.map(t=>(0,W.jsx)(Kr,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,W.jsx)(ci,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,W.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`flex flex-wrap gap-2`,children:bt.map((t,n)=>(0,W.jsx)(Kr,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-every`,children:`Run every`}),(0,W.jsxs)(nr,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,W.jsx)(ir,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,W.jsx)(rr,{})}),(0,W.jsx)(ar,{children:_t.map(e=>(0,W.jsx)(or,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(ni,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(ni,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,W.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,W.jsx)(`code`,{className:`font-mono text-foreground`,children:mt(e)})]})]})}var mi=40*864e5,hi=5;function gi({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,W.jsx)(_i,{schedule:e,now:n});let r=lt(e,n+1,n+mi,t,hi);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Next 5 runs`}),r.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,W.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid gap-1.5 text-sm`,children:r.map(e=>(0,W.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:xt(new Date(e).toISOString(),t)}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:pt(n,e)})]},e))}),(0,W.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function _i({schedule:e,now:t}){let n=ut(e),r=yt(e);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,className:`rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-[15px] font-medium`,children:`Runs once`}),n===null||!r?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,W.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:pt(t,n)}):null]}),r?.note?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,W.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,W.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var vi={schedule:`On a schedule`,github:`When GitHub changes`};function yi(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function bi({title:e,failure:t,section:n,children:r}){return(0,W.jsxs)(`fieldset`,{className:`grid min-w-0 gap-4 rounded-xl border p-5 max-md:p-4!`,children:[(0,W.jsx)(`legend`,{className:`px-0`,children:e}),r,t?.section===n&&!t.conflict?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:t.message}):null]})}function xi({draft:e,patch:t,forge:n,automation:r}){return(0,W.jsx)(W.Fragment,{children:r?(0,W.jsxs)(`p`,{className:`text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),vi[e.kind]]}):(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(it,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:vi.schedule},{value:`github`,label:vi.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Si({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,W.jsx)(pi,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,W.jsx)(ei,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Ci({draft:e,patch:t,saving:n,automation:r}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,W.jsx)(wt,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:4,required:!0}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,W.jsx)(Ei,{draft:e,patch:t}),(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Le,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,W.jsxs)(`span`,{children:[`Autonomous `,(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,W.jsx)(et,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,W.jsx)(Xe,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function wi({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Le,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,W.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:Qr(e.filters.includeExisting)})]})}function Ti({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,s]=(0,U.useState)(()=>jr(e)),[u,d]=(0,U.useState)(e?.revision),[f,p]=(0,U.useState)(),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(!1),[x,S]=(0,U.useState)(``),C=e=>s(t=>({...t,...e})),w=async t=>{if(t.preventDefault(),m)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),p(void 0);let i=`save`;try{if(e&&u!==void 0){let{automation:t}=await l(e.id,Ir({...a,enabled:e.enabled},u));d(t.revision),a.enabled!==e.enabled&&(i=`enable`,await c(e.id,a.enabled))}else await ee(Fr(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof o&&t.status===409&&/revision conflict/i.test(n)?p({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):p({section:i===`enable`?`enable`:yi(n),message:n})}finally{h(!1)}},T=async()=>{if(!(!e||v)){y(!0),S(``);try{await b(e.id),r()}catch(e){S(e instanceof Error?e.message:String(e))}finally{y(!1)}}},E=e?`Save changes`:a.enabled?`Save and enable`:`Save paused`,D=a.kind===`schedule`;return(0,W.jsx)(lr,{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,children:(0,W.jsxs)(`form`,{className:`automation-editor grid min-w-0 gap-5 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:w,children:[(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,W.jsx)(bi,{title:`Name`,section:`name`,failure:f,children:(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(F,{htmlFor:`automation-name`,children:`Name`}),(0,W.jsx)(H,{id:`automation-name`,value:a.name,onChange:e=>C({name:e.target.value}),required:!0})]})}),(0,W.jsxs)(bi,{title:`When`,section:`when`,failure:f,children:[(0,W.jsx)(xi,{draft:a,patch:C,forge:t,automation:e}),(0,W.jsx)(Si,{draft:a,patch:C,forge:t,timeZone:n,automation:e})]}),(0,W.jsx)(bi,{title:`What to run`,section:`run`,failure:f,children:(0,W.jsx)(Ci,{draft:a,patch:C,saving:m,automation:e})}),(0,W.jsx)(bi,{title:`Enable`,section:`enable`,failure:f,children:(0,W.jsx)(wi,{draft:a,patch:C,automation:e})}),f?.section===`form`?(0,W.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,W.jsx)(`span`,{className:`break-words`,children:f.message}),f.conflict&&i?(0,W.jsx)(I,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{type:`submit`,disabled:m,children:m?`Saving…`:E}),(0,W.jsx)(I,{type:`button`,variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations`,children:`Cancel`})})]}),e?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[g?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:v,onClick:()=>void T(),children:`Delete automation`}),(0,W.jsx)(I,{type:`button`,variant:`outline`,disabled:v,onClick:()=>{_(!1),S(``)},children:`Keep`})]})]}):(0,W.jsx)(I,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>_(!0),children:`Delete`}),x?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:x}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`min-w-0 md:sticky md:top-4`,children:[D?(0,W.jsx)(gi,{schedule:a.schedule,timeZone:n}):(0,W.jsxs)(`section`,{className:`rounded-xl border bg-card p-4`,children:[(0,W.jsx)(`h2`,{className:`mb-2 text-[15px] font-medium`,children:`How it polls`}),(0,W.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:$r(a)})]}),(0,W.jsx)(Gr,{draft:a})]})]})})}function Ei({draft:e,patch:t}){let n=P(),r=Ze(),{runners:i,signedOut:a}=r.runnersOn(e=>r.repoAccount?.[e]),o=ie(),s=ne(),{runner:c,ready:l}=re(e.runner??o.data?.defaultRunner??`claude`),u=ae(c,l,r.repoAccount?.[c]),d=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],f=[...new Set([...i,...e.runner?[e.runner]:[]])],p=Ye(c,s.data,u.data,[e.model]),m=p.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,h=e=>(0,W.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,W.jsx)(qe,{children:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)($e,{slot:`automation-workflow-pill`,icon:h(he),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:d.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,W.jsx)($e,{slot:`automation-runner-pill`,icon:h(fe),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner??`default`,value:e.runner??``,disabled:!s.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},...f.map(e=>({value:e,label:te(s.data,e)}))],footer:(0,W.jsx)(nt,{uninstalled:r.uninstalled,signedOut:a.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,W.jsx)($e,{slot:`automation-model-pill`,icon:h(ge),fieldLabel:!0,ariaLabel:`Model`,label:m,value:e.model??``,options:p.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Di({data:e,error:t,refresh:n,archived:r=!1,onArchivedChange:i}){let[a,o]=(0,U.useState)({}),[l,u]=(0,U.useState)({}),d=(e,t)=>o(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t)=>{u(t=>({...t,[e]:!0}));try{await t()}catch(t){d(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{u(t=>({...t,[e]:!1}))}},p=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await s(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),m=e=>f(e.id,async()=>{d(e.id,void 0),await c(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await y(e.id),await n()}),_=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await h(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await x(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)});return(0,W.jsx)(lr,{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,action:(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(V,{to:`/automations/new`,children:`New automation`})}),children:t&&!e?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(Z,{text:t}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Oi,{data:e}),i?(0,W.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,children:(0,W.jsx)(Kr,{pressed:r,onClick:()=>i(!r),children:`Archived`})}):null,r&&e.automations.length===0?(0,W.jsx)(Z,{text:`No archived one-time schedules.`}):e.automations.length===0?(0,W.jsx)(Ge,{icon:(0,W.jsx)(me,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,W.jsx)(I,{asChild:!0,children:(0,W.jsx)(V,{to:`/automations/new`,children:`New automation`})})}):(0,W.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:e.automations.map(t=>(0,W.jsx)(zi,{automation:t,timeZone:e.timeZone,note:a[t.id],busy:l[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void m(t),onPreview:()=>void _(t),onCancel:()=>void g(t)},t.id))})]}):(0,W.jsx)(Z,{text:`Loading automations…`})})}function Oi({data:e}){return(0,W.jsx)(`p`,{"data-slot":`automation-scheduler`,className:i(`mb-4 text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function ki(e){return e.kind===`schedule`&&e.schedule?ft(e.schedule):`on ${(e.events??[]).join(`, `)} · every ${Math.round((e.intervalSeconds??300)/60)} min`}var Ai={waiting:{label:`Waiting`,dot:`success`},paused:{label:`Paused`,dot:`neutral`},failed:{label:`Failed`,dot:`danger`},missed:{label:`Missed`,dot:`pending`},archived:{label:`Archived`,dot:`neutral`}};function ji(e){if(e.schedule?.type===`once`)return Ai[e.onceStatus??(e.enabled?`waiting`:`paused`)]}function Mi({automation:e,badge:t}){return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,W.jsx)(e.kind===`schedule`?le:ce,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[13px] break-words text-muted-foreground`,children:ki(e)})]}),t?(0,W.jsx)(rt,{dot:t.dot,children:t.label}):(0,W.jsx)(rt,{dot:e.enabled?`success`:`neutral`,children:e.enabled?`Enabled`:`Paused`})]})}function Ni({automation:e,archive:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`mt-3 text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations/${e.id}`,children:`Details`})})})]})}function Pi({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return(0,W.jsx)(`p`,{className:`mt-3 text-sm`,children:!n&&e.enabled?(0,W.jsx)(`span`,{children:`continuous`}):r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`Next run: ${xt(r,t)}`}),(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:` · ${pt(Date.now(),Date.parse(r))}`})]}):(0,W.jsx)(`span`,{children:`Next run: —`})})}function Fi({automation:e,timeZone:t}){let n=e.enabled?Zn(e.state):void 0;return n?(0,W.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`mt-3 text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${xt(n.retryAt,t)}`}):null]}):null}function Ii({automation:e,busy:t,confirmingCancel:n,cancelRef:r,onToggle:i,onRun:a,onPreview:o,onOpenCancel:s}){let c=e.kind===`schedule`,l=e.schedule?.type===`once`;return(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations/${e.id}`,children:`Edit`})}),(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(V,{to:`/automations/${e.id}/log`,children:`Execution log`})}),(0,W.jsx)(I,{variant:`outline`,"data-action":`automation-toggle`,disabled:t,onClick:i,children:e.enabled?`Pause`:`Enable`}),c?(0,W.jsx)(I,{variant:`outline`,"data-action":`automation-run`,disabled:t,onClick:a,children:`Run now`}):(0,W.jsx)(I,{variant:`outline`,"data-action":`automation-preview`,disabled:t,onClick:o,children:`Test filter`}),l&&!n?(0,W.jsx)(I,{variant:`outline`,ref:r,"data-action":`automation-cancel`,disabled:t,onClick:s,children:`Cancel`}):null]})}function Li({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,W.jsxs)(`div`,{className:`mt-3 grid justify-items-start gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(I,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,W.jsx)(I,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function Ri({note:e}){return(0,W.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:i(`mt-3 text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(V,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function zi({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,W.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`min-w-0 rounded-xl border bg-card p-4`,children:[(0,W.jsx)(Mi,{automation:e,badge:ji(e)}),h?(0,W.jsx)(Ni,{automation:e,archive:h}):null,h?null:(0,W.jsx)(Pi,{automation:e,timeZone:t}),h?null:(0,W.jsx)(Fi,{automation:e,timeZone:t}),h?null:(0,W.jsx)(Ii,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,W.jsx)(Li,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,W.jsx)(Ri,{note:n}):null,(0,W.jsx)(vr,{automationId:e.id,automationName:e.name,timeZone:t})]})}function Bi(e){let t=We(),n=Ke(),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(``),s=(0,U.useCallback)(t=>_({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,U.useEffect)(()=>{n&&s()},[n,s]),(0,U.useEffect)(()=>d(async e=>{n&&await s(e)}),[n,s]),(0,U.useEffect)(()=>se((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function Vi({mode:e=`list`}){let{automationId:t}=oe(),n=Ue(),[r,i]=(0,U.useState)(!1),{data:a,error:o,refresh:s}=Bi(e===`list`?r?`only`:void 0:`include`),[c,l]=(0,U.useState)(0),u=Qe();if(u===`unknown`)return(0,W.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,W.jsx)(Z,{text:`Loading automations…`})});if(u===`unavailable`)return(0,W.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,W.jsx)(Ge,{icon:(0,W.jsx)(me,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,W.jsx)(Di,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,W.jsx)(lr,{title:`Automations`,subtitle:`Could not load automations.`,children:(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(Z,{text:o}),(0,W.jsx)(I,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,W.jsx)(`div`,{"data-route":`automations`,className:`task-flow-page flex min-h-full flex-col`,children:(0,W.jsx)(Z,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,W.jsx)(Ti,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,W.jsx)(yr,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,W.jsx)(Ti,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,W.jsx)(lr,{title:`Automation not found`,subtitle:`This automation may have been removed.`,children:(0,W.jsx)(I,{asChild:!0,variant:`outline`,children:(0,W.jsx)(V,{to:`/automations`,children:`Back to automations`})})}):t?(0,W.jsx)(_r,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,W.jsx)(Z,{text:`Automation not found.`})}export{Vi as AutomationsRoute};
@@ -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{An as r}from"./project-scope-context-D9axDY18.js";import{j as i,ot as a,r as o}from"./design-icons-CzEoMH9c.js";import{n as s}from"./diff-controls-BSWICnsb.js";import{u as c}from"./reference-chip-BnIoiMgY.js";import{t as l}from"./button-BQ2y4XRB.js";import{t as u}from"./project-router-CDPfL2Jz.js";import{t as d}from"./centered-state-V15AR_qo.js";import{en as f,gn as p}from"./index-BRgRv29I.js";import{t as m}from"./diff-GEuSlT_R.js";var h=e(t(),1),g=n();function _({commit:e,sha:t,backTo:n,backLabel:_,slot:v,className:y,diffClassName:b}){let x=f(),[S,C]=(0,h.useState)(`unified`),[w,T]=(0,h.useState)(!1),E=e.isError&&e.error instanceof r&&e.error.status===409,D=x?S:`unified`,O=!x||w;return(0,g.jsxs)(`section`,{"data-slot":v,"data-sha":t,className:y,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,g.jsx)(l,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,g.jsxs)(u,{to:n,children:[(0,g.jsx)(o,{size:16,"aria-hidden":`true`}),_]})}),e.data?(0,g.jsx)(p,{stat:e.data.stat}):null,(0,g.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,g.jsx)(s,{mode:S,wrap:w,onModeChange:C,onWrapChange:T})})]}),e.isPending?(0,g.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):e.isError?(0,g.jsx)(d,{icon:E?(0,g.jsx)(c,{}):(0,g.jsx)(a,{size:16}),tone:E?`neutral`:`danger`,heading:`h2`,title:E?`Commit not found`:`Could not load the commit`,subtitle:e.error.message}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold`,children:e.data.subject}),(0,g.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[e.data.author,` · `,e.data.when,` ·`,` `,(0,g.jsx)(`span`,{className:`font-mono select-all`,children:e.data.sha})]})]}),e.data.files.length===0?(0,g.jsx)(d,{icon:(0,g.jsx)(i,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,g.jsx)(`div`,{className:b,children:(0,g.jsx)(m,{files:e.data.files,mode:D,wrap:O,className:`min-w-0`})})]})]})}export{_ as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{An as r}from"./project-scope-context-D9axDY18.js";import{j as i,ot as a,r as o}from"./design-icons-CzEoMH9c.js";import{n as s}from"./diff-controls-BSWICnsb.js";import{u as c}from"./reference-chip-BnIoiMgY.js";import{t as l}from"./button-BQ2y4XRB.js";import{t as u}from"./project-router-CDPfL2Jz.js";import{t as d}from"./centered-state-V15AR_qo.js";import{en as f,gn as p}from"./index-CHIFhfha.js";import{t as m}from"./diff-DVDzDVOV.js";var h=e(t(),1),g=n();function _({commit:e,sha:t,backTo:n,backLabel:_,slot:v,className:y,diffClassName:b}){let x=f(),[S,C]=(0,h.useState)(`unified`),[w,T]=(0,h.useState)(!1),E=e.isError&&e.error instanceof r&&e.error.status===409,D=x?S:`unified`,O=!x||w;return(0,g.jsxs)(`section`,{"data-slot":v,"data-sha":t,className:y,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,g.jsx)(l,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,g.jsxs)(u,{to:n,children:[(0,g.jsx)(o,{size:16,"aria-hidden":`true`}),_]})}),e.data?(0,g.jsx)(p,{stat:e.data.stat}):null,(0,g.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,g.jsx)(s,{mode:S,wrap:w,onModeChange:C,onWrapChange:T})})]}),e.isPending?(0,g.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):e.isError?(0,g.jsx)(d,{icon:E?(0,g.jsx)(c,{}):(0,g.jsx)(a,{size:16}),tone:E?`neutral`:`danger`,heading:`h2`,title:E?`Commit not found`:`Could not load the commit`,subtitle:e.error.message}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold`,children:e.data.subject}),(0,g.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[e.data.author,` · `,e.data.when,` ·`,` `,(0,g.jsx)(`span`,{className:`font-mono select-all`,children:e.data.sha})]})]}),e.data.files.length===0?(0,g.jsx)(d,{icon:(0,g.jsx)(i,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,g.jsx)(`div`,{className:b,children:(0,g.jsx)(m,{files:e.data.files,mode:D,wrap:O,className:`min-w-0`})})]})]})}export{_ as t};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-DLSixc9l.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/utils-DSMR_WLb.js","assets/bundle-mjs-rHxsej31.js","assets/chevron-right-BENZ-1ZN.js","assets/createLucideIcon-BHp8sXmF.js","assets/eye-B8okNWXU.js","assets/index-BRgRv29I.js","assets/live-refetch-CZb2VOyu.js","assets/project-scope-context-D9axDY18.js","assets/live-protocol-DteqtbyN.js","assets/useInfiniteQuery-GZp9laKm.js","assets/queries-DzwCG927.js","assets/useQuery-CzVHT8UE.js","assets/live-reads-BxjlQXfN.js","assets/toaster-Bo5vCbz-.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-Cg8l-LDN.js","assets/label-6PgIe3Ny.js","assets/cez-idle-CQtDz5jk.js","assets/dist-C5mlVBmd.js","assets/dist-BW234Kg5.js","assets/tasks-table-CmESFng9.js","assets/task-groups-DoiPFEfM.js","assets/attention-CvHM4cjG.js","assets/design-icons-CzEoMH9c.js","assets/open-in-menu-AZMtej8C.js","assets/bot-TkDIw4y-.js","assets/external-link-BE6y205O.js","assets/folder-o-AvL3y3.js","assets/smartphone-Lr8Ug2z_.js","assets/square-terminal-B6RYYieR.js","assets/button-BQ2y4XRB.js","assets/dropdown-menu-4e2iKSMT.js","assets/es2015-CQth82uv.js","assets/dist-BAoXdNsT.js","assets/dist-DXO3xwbC.js","assets/own-lookup-DS54wXvD.js","assets/dist-C28wFbz0.js","assets/chevron-down-CHGyCDBH.js","assets/nav-row-styles-DqKjMToI.js","assets/folder-browser-CffyHz8w.js","assets/format-BNCkW110.js","assets/play-CmVAj_fu.js","assets/reference-chip-BnIoiMgY.js","assets/popover-BPgUYFyu.js","assets/dist-Da4ckcJG.js","assets/switch-Bv2Zf1uU.js","assets/badge-D9JrXe0o.js","assets/dialog-BVF6dIeS.js","assets/project-router-CDPfL2Jz.js","assets/status-dot-DtAOFiIi.js","assets/command-CDt1BsZy.js","assets/project-order-AcHI4Dcl.js","assets/skills-pM_PouEs.js","assets/agents-settings-path-7X6_cvUg.js","assets/centered-state-V15AR_qo.js","assets/index-HkNWm2JB.css","assets/highlighter-DvLzHjjY.js","assets/image-preview-CNBuRrK5.js","assets/zoomable-image-CIQl1Wpe.js","assets/markdown-BBDDg-4t.js","assets/markdown-CIm2Q7mB.js","assets/chunk-BO2N2NFS-DQrpGzb-.js","assets/lib-DrPFkMXk.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{gn as a}from"./index-BRgRv29I.js";import{n as o,t as s}from"./image-preview-CNBuRrK5.js";var c=e(t(),1),l=n();function u(e){let[t,n]=(0,c.useState)(null);return(0,c.useEffect)(()=>{let e=!1;return i(()=>import(`./diff-view-DLSixc9l.js`).then(t=>{e||n({View:t.DiffView})},()=>{e||n(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65])),()=>{e=!0}},[]),e.files.length===0?(0,l.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,l.jsx)(d,{...e}):t===null?(0,l.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,l.jsx)(t.View,{...e})}function d({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:i,viewRef:o,className:s}){let u={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of d.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,l.jsxs)(`div`,{ref:d,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,s),children:[(0,l.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,l.jsx)(a,{stat:u})]}),e.map(e=>(0,l.jsx)(f,{file:e,wrap:t,imageSrc:n,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function f({file:e,wrap:t,imageSrc:n,onOpenInApp:i}){let c=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,l.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,l.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border/50 px-3 py-2`,children:[(0,l.jsx)(`span`,{"data-slot":`diff-file-path`,title:c,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:c}),(0,l.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,l.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,l.jsx)(s,{file:e,imageSrc:n,onOpenInApp:i}):e.binary?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,l.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-isM51Pgu.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/utils-DSMR_WLb.js","assets/bundle-mjs-rHxsej31.js","assets/chevron-right-BENZ-1ZN.js","assets/createLucideIcon-BHp8sXmF.js","assets/eye-B8okNWXU.js","assets/index-CHIFhfha.js","assets/live-refetch-CZb2VOyu.js","assets/project-scope-context-D9axDY18.js","assets/live-protocol-DteqtbyN.js","assets/useInfiniteQuery-GZp9laKm.js","assets/queries-DzwCG927.js","assets/useQuery-CzVHT8UE.js","assets/live-reads-BxjlQXfN.js","assets/toaster-Bo5vCbz-.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-Cg8l-LDN.js","assets/label-6PgIe3Ny.js","assets/cez-idle-CQtDz5jk.js","assets/dist-C5mlVBmd.js","assets/dist-BW234Kg5.js","assets/tasks-table-CmESFng9.js","assets/task-groups-DoiPFEfM.js","assets/attention-CvHM4cjG.js","assets/design-icons-CzEoMH9c.js","assets/open-in-menu-AZMtej8C.js","assets/bot-TkDIw4y-.js","assets/external-link-BE6y205O.js","assets/folder-o-AvL3y3.js","assets/smartphone-Lr8Ug2z_.js","assets/square-terminal-B6RYYieR.js","assets/button-BQ2y4XRB.js","assets/dropdown-menu-4e2iKSMT.js","assets/es2015-CQth82uv.js","assets/dist-BAoXdNsT.js","assets/dist-DXO3xwbC.js","assets/own-lookup-DS54wXvD.js","assets/dist-C28wFbz0.js","assets/chevron-down-CHGyCDBH.js","assets/nav-row-styles-DqKjMToI.js","assets/folder-browser-CffyHz8w.js","assets/format-BNCkW110.js","assets/play-CmVAj_fu.js","assets/reference-chip-BnIoiMgY.js","assets/popover-BPgUYFyu.js","assets/dist-Da4ckcJG.js","assets/switch-Bv2Zf1uU.js","assets/badge-D9JrXe0o.js","assets/dialog-BVF6dIeS.js","assets/project-router-CDPfL2Jz.js","assets/status-dot-DtAOFiIi.js","assets/command-CDt1BsZy.js","assets/project-order-AcHI4Dcl.js","assets/skills-pM_PouEs.js","assets/agents-settings-path-7X6_cvUg.js","assets/centered-state-V15AR_qo.js","assets/index-HkNWm2JB.css","assets/highlighter-DvLzHjjY.js","assets/image-preview-CNBuRrK5.js","assets/zoomable-image-CIQl1Wpe.js","assets/markdown-BBDDg-4t.js","assets/markdown-DhdLkyGx.js","assets/chunk-BO2N2NFS-DQrpGzb-.js","assets/lib-DrPFkMXk.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{gn as a}from"./index-CHIFhfha.js";import{n as o,t as s}from"./image-preview-CNBuRrK5.js";var c=e(t(),1),l=n();function u(e){let[t,n]=(0,c.useState)(null);return(0,c.useEffect)(()=>{let e=!1;return i(()=>import(`./diff-view-isM51Pgu.js`).then(t=>{e||n({View:t.DiffView})},()=>{e||n(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65])),()=>{e=!0}},[]),e.files.length===0?(0,l.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,l.jsx)(d,{...e}):t===null?(0,l.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,l.jsx)(t.View,{...e})}function d({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:i,viewRef:o,className:s}){let u={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of d.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,l.jsxs)(`div`,{ref:d,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,s),children:[(0,l.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,l.jsx)(a,{stat:u})]}),e.map(e=>(0,l.jsx)(f,{file:e,wrap:t,imageSrc:n,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function f({file:e,wrap:t,imageSrc:n,onOpenInApp:i}){let c=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,l.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,l.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border/50 px-3 py-2`,children:[(0,l.jsx)(`span`,{"data-slot":`diff-file-path`,title:c,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:c}),(0,l.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,l.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,l.jsx)(s,{file:e,imageSrc:n,onOpenInApp:i}):e.binary?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,l.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
3
3
  `).map((e,t)=>(0,l.jsxs)(`span`,{className:r(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}export{u as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{t as i}from"./chevron-right-BENZ-1ZN.js";import{t as a}from"./eye-B8okNWXU.js";import{gn as o,s}from"./index-BRgRv29I.js";import{a as c,i as l,r as u}from"./highlighter-DvLzHjjY.js";import{n as d,t as f}from"./image-preview-CNBuRrK5.js";import{n as p,t as m}from"./markdown-BBDDg-4t.js";import{t as h}from"./markdown-CIm2Q7mB.js";var g=e(t(),1),_=44;function v(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{t as i}from"./chevron-right-BENZ-1ZN.js";import{t as a}from"./eye-B8okNWXU.js";import{gn as o,s}from"./index-CHIFhfha.js";import{a as c,i as l,r as u}from"./highlighter-DvLzHjjY.js";import{n as d,t as f}from"./image-preview-CNBuRrK5.js";import{n as p,t as m}from"./markdown-BBDDg-4t.js";import{t as h}from"./markdown-DhdLkyGx.js";var g=e(t(),1),_=44;function v(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
2
2
  `),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function y(e){return v(e)*20+_}function b(e){return e.reduce((e,t)=>e+v(t),0)}function x(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function S(e){return`${e.oldPath??``}→${e.path}`}function C(e){let t=0;for(let n of e.split(`
3
3
  `))n.length>t&&(t=n.length);return t}var w=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,T=300,E=.3;function D(e,t){if(e===t)return null;let n=e.match(w)??[],r=t.match(w)??[];if(n.length===0||r.length===0||n.length>T||r.length>T)return null;let i=O(n,r),a=r.length+1;return(i[n.length*a+r.length]??0)/Math.max(n.length,r.length)<E?null:k(n,r,i)}function O(e,t){let n=t.length+1,r=new Uint16Array((e.length+1)*n);for(let i=1;i<=e.length;i++)for(let a=1;a<=t.length;a++)r[i*n+a]=e[i-1]===t[a-1]?(r[(i-1)*n+(a-1)]??0)+1:Math.max(r[(i-1)*n+a]??0,r[i*n+(a-1)]??0);return r}function k(e,t,n){let r=t.length+1,i=Array.from({length:e.length},()=>!1),a=Array.from({length:t.length},()=>!1),o=e.length,s=t.length;for(;o>0&&s>0;)e[o-1]===t[s-1]?(i[o-1]=!0,a[s-1]=!0,o--,s--):(n[(o-1)*r+s]??0)>=(n[o*r+(s-1)]??0)?o--:s--;return{del:A(e,i),add:A(t,a)}}function A(e,t){let n=[];return e.forEach((e,r)=>{let i=!(t[r]??!1),a=n[n.length-1];a&&a.changed===i?a.text+=e:n.push({text:e,changed:i})}),n}function j(e,t,n){if(!t||t.length===0)return e?e.map(e=>({text:e.content,color:e.color,changed:!1})):n===``?[]:[{text:n,changed:!1}];if(!e||e.length===0)return t.map(e=>({text:e.text,changed:e.changed}));let r=[],i=0,a=0,o=0,s=0;for(;i<e.length&&o<t.length;){let n=e[i],c=t[o],l=n.content.length-a,u=c.text.length-s,d=Math.min(l,u);d>0&&(r.push({text:n.content.slice(a,a+d),color:n.color,changed:c.changed}),a+=d,s+=d),n.content.length-a<=0&&(i++,a=0),c.text.length-s<=0&&(o++,s=0)}for(;i<e.length;){let t=e[i],n=t.content.slice(a);n!==``&&r.push({text:n,color:t.color,changed:!1}),i++,a=0}return r}var M=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,N=`… (patch truncated)`;function P(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
4
4
  `);o.at(-1)===``&&o.pop();for(let e of o){let o=M.exec(e);if(o){r={header:e,oldStart:Number(o[1]),oldCount:o[2]===void 0?1:Number(o[2]),newStart:Number(o[3]),newCount:o[4]===void 0?1:Number(o[4]),lines:[]},i=r.oldStart,a=r.newStart,t.push(r);continue}if(e.includes(N)){n=!0,r=null;continue}r&&(e.startsWith(`+`)?r.lines.push({kind:`add`,text:e.slice(1),newLine:a++}):e.startsWith(`-`)?r.lines.push({kind:`del`,text:e.slice(1),oldLine:i++}):e.startsWith(`\\`)||r.lines.push({kind:`context`,text:e.slice(1),oldLine:i++,newLine:a++}))}return{hunks:t,truncated:n}}function F(e,t=!1){let n=[],r=e[0];if(!r)return n;r.newStart>1&&n.push({beforeHunk:0,count:r.newStart-1,oldStart:1,newStart:1});for(let t=1;t<e.length;t++){let r=e[t-1],i=e[t],a=r.oldStart+r.oldCount,o=r.newStart+r.newCount,s=i.newStart-o;s>0&&n.push({beforeHunk:t,count:s,oldStart:a,newStart:o})}if(t){let t=e[e.length-1];n.push({beforeHunk:e.length,oldStart:t.oldStart+t.oldCount,newStart:t.newStart+t.newCount})}return n}function I(e,t){let n=e.count===void 0?t.length:e.newStart+e.count-1,r=e.oldStart-e.newStart,i=[];for(let a=e.newStart;a<=Math.min(n,t.length);a++)i.push({kind:`context`,text:t[a-1]??``,oldLine:a+r,newLine:a});return i}function L(e,t){let n=Array.from({length:e.length}),r=Array.from({length:t.length}),i=Math.min(e.length,t.length);for(let a=0;a<i;a++){let i=D(e[a].text,t[a].text);i&&(n[a]=i.del,r[a]=i.add)}return{dels:e,adds:t,delSpans:n,addSpans:r}}function R(e,t,n){let r=0;for(;r<e.lines.length;){let i=e.lines[r];if(i.kind===`del`||i.kind===`add`){let t=[],i=[];for(;r<e.lines.length&&e.lines[r].kind===`del`;)t.push(e.lines[r++]);for(;r<e.lines.length&&e.lines[r].kind===`add`;)i.push(e.lines[r++]);n(L(t,i))}else t(i),r++}}function z(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`line`,cell:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),R(e,e=>i.push({type:`line`,cell:{line:e}}),e=>{e.dels.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.delSpans[n]}})),e.adds.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.addSpans[n]}}))})}),a(e.length),i}function B(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`pair`,left:{line:e},right:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),R(e,e=>i.push({type:`pair`,left:{line:e},right:{line:e}}),e=>{let t=Math.max(e.dels.length,e.adds.length);for(let n=0;n<t;n++){let t=e.dels[n],r=e.adds[n];i.push({type:`pair`,...t?{left:{line:t,spans:e.delSpans[n]}}:{},...r?{right:{line:r,spans:e.addSpans[n]}}:{}})}})}),a(e.length),i}var V=n();function H({file:e,loadFileText:t,imageSrc:n}){let r=(0,g.useMemo)(()=>U(e),[e]),i=(0,g.useRef)(t);i.current=t;let a=(0,g.useRef)(n);a.current=n;let o=t!==void 0,[s,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{let t=i.current;if(!t)return;let n=!1;return t(e.path).then(t=>!n&&c({path:e.path,text:t}),()=>!n&&c({path:e.path,text:null})),()=>{n=!0}},[e.path,e.patch,o]);let l=(0,g.useCallback)(t=>{let n=a.current,r=n?p(e.path,t):null;return r===null||!n?null:n(r)},[e.path]),u=s?.path===e.path?s:null;if(o&&u===null)return(0,V.jsx)(`p`,{role:`status`,className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Loading preview…`});let d=u?.text??null;if(d===null&&r.text===``)return(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes to preview.`});let f=d!==null||r.complete?null:o?`The full file could not be loaded. Showing the changed sections only.`:`Showing the changed sections only.`;return(0,V.jsx)(`div`,{"data-slot":`diff-markdown-preview`,className:`px-4 py-5 md:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto max-w-[72ch]`,children:[f?(0,V.jsx)(`p`,{className:`mb-4 text-xs text-soft-foreground`,children:f}):null,(0,V.jsx)(h,{document:!0,imageSrc:l,children:d??r.text})]})})}function U(e){let t=P(e.patch);return{text:t.hunks.map(e=>e.lines.filter(e=>e.kind!==`del`).map(e=>e.text).join(`