cezarion 0.19.0-dev.8689 → 0.19.0-dev.8699
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/web/dist/assets/{accounts-section-RDVTJfi7.js → accounts-section-CzFhdKWy.js} +1 -1
- package/web/dist/assets/activity-motion-D0Fch0mc.js +2 -0
- package/web/dist/assets/{activity-route-CjE0yxn0.js → activity-route-Cvw0jXpy.js} +1 -1
- package/web/dist/assets/{agent-config-section-DQ1RaVK2.js → agent-config-section-BCzxsvys.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-Dzm7jIza.js → agent-defaults-section-DMRK-Qlp.js} +1 -1
- package/web/dist/assets/{appearance-DQLHHfI4.js → appearance-Ew3vb_-K.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-C7_Fwy2A.js → archive-on-merge-field-g87CG6RL.js} +1 -1
- package/web/dist/assets/attention-80jX8HhC.js +1 -0
- package/web/dist/assets/automations-route-CRBtWEo1.js +2 -0
- package/web/dist/assets/commit-list-Cd14tNSj.js +1 -0
- package/web/dist/assets/diff-D55N_7Ul.js +3 -0
- package/web/dist/assets/{diff-controls-BRa3141W.js → diff-controls-CmYvdEGt.js} +1 -1
- package/web/dist/assets/diff-stat-U7DT4Ilj.js +1 -0
- package/web/dist/assets/{diff-view-CwlKCj5V.js → diff-view-DV6muJdZ.js} +1 -1
- package/web/dist/assets/{file-preview-VvCzp02k.js → file-preview-CTPfK-oR.js} +1 -1
- package/web/dist/assets/{folder-browser-B7IbnF0d.js → folder-browser-DnSFycbU.js} +1 -1
- package/web/dist/assets/git-toolbar-Dc_o1nrh.js +1 -0
- package/web/dist/assets/github-WYk7bQID.js +1 -0
- package/web/dist/assets/{global-activity-route-C4-bmfh_.js → global-activity-route-Dvx2uk8w.js} +1 -1
- package/web/dist/assets/image-preview-2S3PEy8S.js +1 -0
- package/web/dist/assets/index-CGdnowj-.js +21 -0
- package/web/dist/assets/index-DAxuDJAo.css +1 -0
- package/web/dist/assets/{label-Bt8n7Spq.js → label-o_DsEmPt.js} +1 -1
- package/web/dist/assets/{live-reads-Crd6fVGH.js → live-reads-Cgk2XbiP.js} +1 -1
- package/web/dist/assets/{markdown-9L65ixU6.js → markdown-CJzxFk0P.js} +1 -1
- package/web/dist/assets/{notifications-section-QWmuj2j2.js → notifications-section-DNYO4sd4.js} +1 -1
- package/web/dist/assets/{open-in-menu-BPp88ouw.js → open-in-menu-Bzae69TK.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-DAM2Snwh.js → preview-pane-connected-CRooCkyb.js} +2 -2
- package/web/dist/assets/{project-location-BRxXN249.js → project-location-D6riKh0Z.js} +1 -1
- package/web/dist/assets/{project-router-CLJTc7gv.js → project-router-CZ89wg-5.js} +1 -1
- package/web/dist/assets/{project-scope-context-Rv6S_BXt.js → project-scope-context-DIcqj4jJ.js} +2 -2
- package/web/dist/assets/{projects-section-DxubjpZI.js → projects-section-4rsb8E52.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-CkQneT1G.js → prompt-templates-section-G3dlAOXt.js} +1 -1
- package/web/dist/assets/{queries-qCF-eOqZ.js → queries-DZhNVAD_.js} +1 -1
- package/web/dist/assets/{reference-chip-D0v0keVC.js → reference-chip-DSJSqjmO.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-COojb6XK.js → remote-settings-notice-GNs7i0kP.js} +1 -1
- package/web/dist/assets/repo-git-CvZTTKFl.js +1 -0
- package/web/dist/assets/{report-reader-zWwalJDN.js → report-reader-CLlNdsZG.js} +1 -1
- package/web/dist/assets/reports-sl2SMDG1.js +1 -0
- package/web/dist/assets/{resources-section-Cb2WIqNv.js → resources-section-DhEoaA0K.js} +1 -1
- package/web/dist/assets/run-header-DZoOLIBZ.js +2 -0
- package/web/dist/assets/{select-y3oRuA2s.js → select-D3snxxoD.js} +1 -1
- package/web/dist/assets/{session-context-section-CiPNMiL7.js → session-context-section-esqZfONg.js} +2 -2
- package/web/dist/assets/{settings-agent-picker-CJJJncuA.js → settings-agent-picker-Dso2TmRM.js} +1 -1
- package/web/dist/assets/{settings-shell-CLToW28f.js → settings-shell-UO_0dSGl.js} +1 -1
- package/web/dist/assets/{sidebar-section-VOYJarPd.js → sidebar-section-pp7e3AZa.js} +1 -1
- package/web/dist/assets/{skills-BySF3yBA.js → skills-B99glme7.js} +1 -1
- package/web/dist/assets/{tab-link-Bu1g-ArE.js → tab-link-BGXFZZ_Z.js} +1 -1
- package/web/dist/assets/task-changes-Tn9M2OPH.js +1 -0
- package/web/dist/assets/task-commits-BHDMp1sO.js +1 -0
- package/web/dist/assets/{task-files-Bu-L_NRW.js → task-files-Csx1Bonx.js} +1 -1
- package/web/dist/assets/{task-github-item-DhiTqCjk.js → task-github-item-D0kQ0K4S.js} +1 -1
- package/web/dist/assets/{task-groups-4tzKGROI.js → task-groups-DK0I9p71.js} +1 -1
- package/web/dist/assets/{task-thread-CKkTeQdi.js → task-thread-DsMuGSug.js} +9 -9
- package/web/dist/assets/{tasks-table-C5uoZMFs.js → tasks-table-BNFYIwtc.js} +1 -1
- package/web/dist/assets/{thread-state-B_ZqjjRr.js → thread-state-DMWi6eLk.js} +1 -1
- package/web/dist/assets/{toaster-BXnLIU3z.js → toaster-0sM0sfWx.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-DqCW8Giu.js +1 -0
- package/web/dist/assets/{workflows-DlTkuM0J.js → workflows-CxJvAn6z.js} +3 -3
- package/web/dist/assets/{workspace-tools-BRK7f1Hk.js → workspace-tools-DqJ8akIy.js} +1 -1
- package/web/dist/assets/{worktrees-section-BXI0-7HH.js → worktrees-section-DBZZlAe0.js} +4 -4
- package/web/dist/index.html +16 -15
- package/web/dist/assets/activity-motion-B7km8QVK.js +0 -2
- package/web/dist/assets/attention-CBCeJN5w.js +0 -1
- package/web/dist/assets/automations-route-BcdL5f0K.js +0 -2
- package/web/dist/assets/commit-list-CN1zX-0X.js +0 -1
- package/web/dist/assets/diff-hxqBOfZH.js +0 -3
- package/web/dist/assets/git-toolbar-BulcGzsv.js +0 -1
- package/web/dist/assets/github-By3yOcFH.js +0 -1
- package/web/dist/assets/image-preview-Pgf8bnzY.js +0 -1
- package/web/dist/assets/index-C69_Sk06.css +0 -1
- package/web/dist/assets/index-DNQcTHxV.js +0 -21
- package/web/dist/assets/repo-git-Mgk4Qcmo.js +0 -1
- package/web/dist/assets/reports-BCHWt3zy.js +0 -1
- package/web/dist/assets/run-header-DeprqSP7.js +0 -2
- package/web/dist/assets/task-changes-NUwvUglx.js +0 -1
- package/web/dist/assets/task-commits-CpV1Hz9L.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-K864D69i.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{an as a,pi as o}from"./project-scope-context-Rv6S_BXt.js";import{n as s}from"./toaster-BXnLIU3z.js";import{Dt as c,Ft as l,Lt as u,Nt as d,Qt as f,Rt as p,Vt as m,xt as h}from"./queries-qCF-eOqZ.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-B7MKxYjT.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Gn as w,Gt as T,Ht as E,Jt as D,Kt as O,Ut as k,Wt as A,Yt as j,qt as M}from"./index-DNQcTHxV.js";import{t as N}from"./settings-select-CCIMGnyA.js";import{t as P}from"./save-cue-Cd3ZAPBS.js";import{n as F,t as I}from"./settings-field-DP9sYv5a.js";var L=t(n(),1),R=r();function z(){let e=c();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{s(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>s(e.message,{tone:`danger`})})}}function B({project:e,onOpenChange:t,onConfirm:n}){return(0,R.jsx)(E,{open:e!==null,onOpenChange:t,children:(0,R.jsxs)(T,{children:[(0,R.jsxs)(D,{children:[(0,R.jsxs)(j,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,R.jsxs)(O,{children:[`This only unregisters the project — `,(0,R.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,R.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,R.jsxs)(M,{children:[(0,R.jsx)(A,{children:`Keep it`}),(0,R.jsx)(k,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var V=e({MaxParallelSelect:()=>Z,ProjectTagsEditor:()=>X,ProjectsSection:()=>G,STATUS_LABEL:()=>U}),H=1,U={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function W(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function G(){let e=l(),t=h();return e.isPending||t.isPending?(0,R.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,R.jsx)(C,{icon:(0,R.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,R.jsx)(K,{config:e.data,registry:t.data})}function K({config:e,registry:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,R.jsx)(q,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,R.jsx)(q,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,R.jsx)(J,{registry:t,workspaceMax:e.resources.maxParallel}),(0,R.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,R.jsx)(w,{open:!0,onOpenChange:r}):null]})}function q({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:c,savedLabel:l,footer:u,refreshProjects:d=!1}){let p=o(),h=f({mutationFn:t=>a(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{p.setQueryData(m.config,t),e===`browseRoot`?p.invalidateQueries({queryKey:m.fsBrowseRoot}):d&&p.invalidateQueries({queryKey:m.projects})}}),[g,_]=(0,L.useState)(t),v=g.trim(),b=v===t,x=h.isError?h.error.message:null;return(0,R.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${c}-root`,value:g,disabled:h.isPending,placeholder:i,onChange:e=>{_(e.target.value),h.isError&&h.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,R.jsx)(P,{show:b&&v!==``&&!h.isPending,children:(0,R.jsx)(y,{type:`button`,variant:`primary`,size:`sm`,"data-action":`projects-save-${c}-root`,disabled:b||v===``||h.isPending,onClick:()=>h.mutate(v,{onSuccess:()=>s(`${l} set to ${v}`)}),children:`Save`})})]}),x===null?(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:u}):(0,R.jsxs)(`p`,{"data-slot":`projects-${c}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[x,` — setting unchanged`]})]})}function J({registry:e,workspaceMax:t}){let[n,r]=(0,L.useState)(null),i=z(),a=(0,L.useMemo)(()=>u(e.projects),[e.projects]);return(0,R.jsxs)(F,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,R.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,R.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{style:{width:`104px`}}),(0,R.jsx)(`col`,{style:{width:`260px`}}),(0,R.jsx)(`col`,{style:{width:`150px`}}),(0,R.jsx)(`col`,{style:{width:`72px`}}),(0,R.jsx)(`col`,{style:{width:`92px`}})]}),(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.projects.map(n=>(0,R.jsx)(Y,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,R.jsx)(B,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function Y({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,R.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,R.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,R.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-soft-foreground`,title:e.root,children:e.root})]}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,R.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:U[e.status]}),e.status===`missing`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsx)(X,{project:e,vocabulary:r})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:I,children:`Max parallel tasks`}),(0,R.jsx)(Z,{project:e,workspaceMax:n})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:W(e.addedAt)}),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,R.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,R.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,R.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function X({project:e,vocabulary:t}){let n=d(),[r,a]=(0,L.useState)(``),[o,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(-1),f=(0,L.useRef)(null),m=e.tags??[],h=p(t,m,r),g=o&&h.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>s(r),onError:e=>s(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(u(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){s(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),_([...m,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(m.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,R.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,R.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,R.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,R.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,R.jsxs)(S,{open:g,onOpenChange:c,children:[(0,R.jsx)(b,{asChild:!0,children:(0,R.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":g,"aria-controls":g?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":g&&l>=0?`${w}-${l}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),u(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;u(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&g){e.preventDefault(),c(!1),u(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(l>=0?h[l]??r:r);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&r===``&&m.length>0){e.preventDefault();let t=m[m.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,R.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,R.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>u(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function Z({project:e,workspaceMax:t}){let n=d(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,R.jsxs)(N,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>s(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>s(e.message,{tone:`danger`})})},className:`block w-full rounded-md border border-input bg-card px-2 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,R.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+H).map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})}export{z as a,B as i,U as n,V as r,Z as t};
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{t as i}from"./utils-DSMR_WLb.js";import{an as a,pi as o}from"./project-scope-context-DIcqj4jJ.js";import{n as s}from"./toaster-0sM0sfWx.js";import{Dt as c,Ft as l,Lt as u,Nt as d,Qt as f,Rt as p,Vt as m,xt as h}from"./queries-DZhNVAD_.js";import{n as g}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{O as _,ft as v}from"./design-icons-CzEoMH9c.js";import{t as y}from"./button-B7MKxYjT.js";import{n as b,r as x,t as S}from"./popover-BPgUYFyu.js";import{t as C}from"./centered-state-V15AR_qo.js";import{Gt as w,Ht as T,Jt as E,Kt as D,Ut as O,Wt as k,Yn as A,Yt as j,qt as M}from"./index-CGdnowj-.js";import{t as N}from"./settings-select-CCIMGnyA.js";import{t as P}from"./save-cue-Cd3ZAPBS.js";import{n as F,t as I}from"./settings-field-DP9sYv5a.js";var L=t(n(),1),R=r();function z(){let e=c();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{s(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>s(e.message,{tone:`danger`})})}}function B({project:e,onOpenChange:t,onConfirm:n}){return(0,R.jsx)(T,{open:e!==null,onOpenChange:t,children:(0,R.jsxs)(w,{children:[(0,R.jsxs)(E,{children:[(0,R.jsxs)(j,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,R.jsxs)(D,{children:[`This only unregisters the project — `,(0,R.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,(0,R.jsx)(`span`,{className:`mt-1 block truncate font-mono text-[11px] text-foreground`,title:e?.root,children:e?.root})]})]}),(0,R.jsxs)(M,{children:[(0,R.jsx)(k,{children:`Keep it`}),(0,R.jsx)(O,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var V=e({MaxParallelSelect:()=>Z,ProjectTagsEditor:()=>X,ProjectsSection:()=>G,STATUS_LABEL:()=>U}),H=1,U={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function W(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function G(){let e=l(),t=h();return e.isPending||t.isPending?(0,R.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,R.jsx)(C,{icon:(0,R.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,R.jsx)(K,{config:e.data,registry:t.data})}function K({config:e,registry:t}){let[n,r]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,R.jsx)(q,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,savedLabel:`Browse folder`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,R.jsx)(q,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/cezar/projects`,slot:`checkout`,savedLabel:`Checkout folder`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,R.jsx)(J,{registry:t,workspaceMax:e.resources.maxParallel}),(0,R.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,R.jsx)(A,{open:!0,onOpenChange:r}):null]})}function q({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:c,savedLabel:l,footer:u,refreshProjects:d=!1}){let p=o(),h=f({mutationFn:t=>a(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{p.setQueryData(m.config,t),e===`browseRoot`?p.invalidateQueries({queryKey:m.fsBrowseRoot}):d&&p.invalidateQueries({queryKey:m.projects})}}),[g,_]=(0,L.useState)(t),v=g.trim(),b=v===t,x=h.isError?h.error.message:null;return(0,R.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":x!==null,"data-slot":`projects-${c}-root`,value:g,disabled:h.isPending,placeholder:i,onChange:e=>{_(e.target.value),h.isError&&h.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`}),(0,R.jsx)(P,{show:b&&v!==``&&!h.isPending,children:(0,R.jsx)(y,{type:`button`,variant:`primary`,size:`sm`,"data-action":`projects-save-${c}-root`,disabled:b||v===``||h.isPending,onClick:()=>h.mutate(v,{onSuccess:()=>s(`${l} set to ${v}`)}),children:`Save`})})]}),x===null?(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:u}):(0,R.jsxs)(`p`,{"data-slot":`projects-${c}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[x,` — setting unchanged`]})]})}function J({registry:e,workspaceMax:t}){let[n,r]=(0,L.useState)(null),i=z(),a=(0,L.useMemo)(()=>u(e.projects),[e.projects]);return(0,R.jsxs)(F,{title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[e.projects.length===0?(0,R.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}):(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,R.jsx)(`caption`,{className:`sr-only`,children:`Projects registered in this workspace`}),(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{style:{width:`104px`}}),(0,R.jsx)(`col`,{style:{width:`260px`}}),(0,R.jsx)(`col`,{style:{width:`150px`}}),(0,R.jsx)(`col`,{style:{width:`72px`}}),(0,R.jsx)(`col`,{style:{width:`92px`}})]}),(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b border-border text-left text-[12px] text-soft-foreground`,children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Project`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Tags`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Max parallel`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium`,children:`Added`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-2 font-medium text-right`,children:`Actions`})]})}),(0,R.jsx)(`tbody`,{children:e.projects.map(n=>(0,R.jsx)(Y,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:a,disabled:i.isPending,onRemove:()=>r(n)},n.id))})]})}),(0,R.jsx)(B,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),i.confirm(e)}})]})}function Y({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){return(0,R.jsxs)(`tr`,{"data-slot":`project-row`,"data-project":e.id,className:`border-b border-border last:border-0`,children:[(0,R.jsxs)(`th`,{scope:`row`,className:`max-w-0 px-3 py-2 text-left font-normal`,children:[(0,R.jsx)(`span`,{className:`block truncate text-foreground`,children:e.name}),(0,R.jsx)(`span`,{className:`block truncate font-mono text-xs text-soft-foreground`,title:e.root,children:e.root})]}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,R.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:U[e.status]}),e.status===`missing`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsx)(X,{project:e,vocabulary:r})}),(0,R.jsx)(`td`,{className:`px-3 py-2`,children:(0,R.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:I,children:`Max parallel tasks`}),(0,R.jsx)(Z,{project:e,workspaceMax:n})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2 tabular-nums text-soft-foreground`,children:W(e.addedAt)}),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right`,children:[e.status===`missing`?null:(0,R.jsx)(y,{asChild:!0,variant:`outline`,className:`mr-2`,children:(0,R.jsx)(g,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,R.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function X({project:e,vocabulary:t}){let n=d(),[r,a]=(0,L.useState)(``),[o,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(-1),f=(0,L.useRef)(null),m=e.tags??[],h=p(t,m,r),g=o&&h.length>0,_=(t,r)=>{n.mutate({id:e.id,tags:t},{onSuccess:()=>s(r),onError:e=>s(e.message,{tone:`danger`})})},y=t=>{let n=t.trim().slice(0,32);if(u(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){s(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),_([...m,n],`${e.name} tagged \u201c${n}\u201d`)}},C=t=>{_(m.filter(e=>e!==t),`\u201c${t}\u201d removed from ${e.name}`)},w=`project-tag-suggestions-${e.id}`;return(0,R.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,R.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-[11px] font-medium whitespace-nowrap text-accent-text`,children:[t,(0,R.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:n.isPending,onClick:()=>C(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,R.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,R.jsxs)(S,{open:g,onOpenChange:c,children:[(0,R.jsx)(b,{asChild:!0,children:(0,R.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":g,"aria-controls":g?w:void 0,"aria-autocomplete":`list`,"aria-activedescendant":g&&l>=0?`${w}-${l}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:r,maxLength:32,disabled:n.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),u(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;u(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&g){e.preventDefault(),c(!1),u(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),y(l>=0?h[l]??r:r);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&r===``&&m.length>0){e.preventDefault();let t=m[m.length-1];t!==void 0&&C(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,R.jsxs)(x,{align:`start`,sideOffset:4,id:w,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,R.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,id:`${w}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{y(e),f.current?.focus()},onMouseEnter:()=>u(t),className:i(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function Z({project:e,workspaceMax:t}){let n=d(),r=e.maxParallel===void 0?``:String(e.maxParallel);return(0,R.jsxs)(N,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:r,disabled:n.isPending,onChange:r=>{let i=r.target.value,a=i===``?null:Number(i);n.mutate({id:e.id,maxParallel:a},{onSuccess:()=>s(a===null?`${e.name} inherits the workspace limit (${t})`:`${e.name} runs at most ${a} task${a===1?``:`s`} at a time`),onError:e=>s(e.message,{tone:`danger`})})},className:`block w-full rounded-md border border-input bg-card px-2 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,R.jsxs)(`option`,{value:``,children:[`Inherit workspace (`,t,`)`]}),Array.from({length:16},(e,t)=>t+H).map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})}export{z as a,B as i,U as n,V as r,Z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{P as i,pi as a}from"./project-scope-context-
|
|
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{P as i,pi as a}from"./project-scope-context-DIcqj4jJ.js";import{n as o}from"./toaster-0sM0sfWx.js";import{Bt as s,Qt as c,Wt as l,k as u}from"./queries-DZhNVAD_.js";import{J as d,W as f,at as p,c as m,ft as h,l as g,tt as _}from"./design-icons-CzEoMH9c.js";import{t as v}from"./button-B7MKxYjT.js";import{i as y,r as b,t as x}from"./popover-BPgUYFyu.js";import{a as S,i as C,o as w,r as T,s as E,t as D}from"./command-KdW7aO0N.js";import{f as O,i as k,p as A,u as j}from"./skills-pM_PouEs.js";import{t as M}from"./centered-state-V15AR_qo.js";import{Jn as N,Q as P,at as F,hn as I,nt as L,tt as R}from"./index-CGdnowj-.js";import{t as z}from"./textarea-vJt9undk.js";import{n as B,t as V}from"./saved-draft-BwzBc-_Y.js";import{t as H}from"./save-cue-Cd3ZAPBS.js";import{t as U}from"./settings-field-DP9sYv5a.js";var W=e(t(),1),G=n();function K(){let e=u();return e.isPending?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading prompt templates…`}):e.isError?(0,G.jsx)(M,{icon:(0,G.jsx)(f,{}),tone:`danger`,title:`Prompt templates did not load`,subtitle:e.error.message,heading:`h2`}):(0,G.jsx)(q,{initial:L(e.data.promptTemplates)})}function q({initial:e}){let t=a(),n=l(),r=u(),[f,m]=B(e,V),[g,_]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),x=c({mutationFn:e=>i({promptTemplates:e}),onSuccess:(e,n)=>{t.setQueryData(s.uiState,e),m(t=>V(t,n)?L(e.promptTemplates):t),o(`Prompt templates saved`)},onError:e=>o(e.message,{tone:`danger`})}),S=JSON.stringify(f)!==JSON.stringify(e),C=g.trim()!==``||y.trim()!==``;I(S||C);let w=f.some(e=>e.label.trim()===``||e.text.trim()===``),T=(e,t)=>m(n=>n.map(n=>n.id===e?{...n,...t}:n)),E=(e,t)=>m(n=>n.map(n=>{if(n.id!==e)return n;let r=n.skills??[],i=r.includes(t)?r.filter(e=>e!==t):[...r,t],{skills:a,...o}=n;return i.length>0?{...o,skills:i}:o})),D=e=>m(t=>t.filter(t=>t.id!==e));return(0,G.jsx)(`div`,{"data-slot":`prompt-templates-section`,"data-reports-dirty":``,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.jsxs)(Y,{title:`Reusable instructions`,hint:`Insert templates from task composers, or apply them automatically with selected skills when the prompt is empty.`,children:[(0,G.jsx)(`div`,{"data-slot":`prompt-template-list`,className:`flex flex-col gap-3`,children:f.length===0?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-empty`,className:`text-[13px] text-soft-foreground`,children:`No templates. Add one below, or reset to the built-ins.`}):f.map(e=>(0,G.jsxs)(`div`,{"data-slot":`prompt-template-row`,"data-template":e.id,className:`flex flex-col gap-1.5 rounded-md border border-border bg-card p-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`label`,{htmlFor:`template-label-${e.id}`,className:U,children:`Template label`}),(0,G.jsx)(N,{id:`template-label-${e.id}`,"aria-label":`Label for ${e.label||`this template`}`,"data-slot":`prompt-template-label-input`,value:e.label,maxLength:80,onChange:t=>T(e.id,{label:t.target.value}),className:`flex-1 border-border bg-background`})]}),(0,G.jsx)(`label`,{htmlFor:`template-text-${e.id}`,className:U,children:`Instructions`}),(0,G.jsx)(z,{id:`template-text-${e.id}`,"aria-label":`Text for ${e.label||`this template`}`,"data-slot":`prompt-template-text-input`,value:e.text,maxLength:2e3,onChange:t=>T(e.id,{text:t.target.value}),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,G.jsx)(`p`,{className:U,children:`Apply automatically with skills`}),(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(J,{label:e.label,skills:n.data??[],skillUsage:r.data?.skillUsage,selected:e.skills??[],onToggle:t=>E(e.id,t)}),(e.skills??[]).map(t=>(0,G.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skill-chip`,"data-skill":t,title:`Stop applying “${e.label}” automatically with ${t}`,onClick:()=>E(e.id,t),className:`inline-flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[t,(0,G.jsx)(h,{"aria-hidden":`true`,className:`size-3`})]},t))]}),(0,G.jsxs)(v,{type:`button`,className:`self-start`,variant:`danger-ghost`,size:`sm`,"data-action":`prompt-template-remove`,title:`Remove this template`,onClick:()=>D(e.id),children:[(0,G.jsx)(p,{"aria-hidden":`true`,className:`size-3`}),`Delete template`]})]},e.id))}),(0,G.jsxs)(`div`,{"data-slot":`prompt-template-new`,className:`flex flex-col gap-1.5 rounded-md border border-dashed border-border p-3`,children:[(0,G.jsx)(`h3`,{className:`text-lg`,children:`New template`}),(0,G.jsx)(`label`,{htmlFor:`new-template-label`,className:U,children:`Label`}),(0,G.jsx)(N,{id:`new-template-label`,"aria-label":`New template label`,"data-slot":`prompt-template-new-label`,placeholder:`e.g. Review security`,value:g,maxLength:80,onChange:e=>_(e.target.value),className:`border-border bg-background`}),(0,G.jsx)(`label`,{htmlFor:`new-template-text`,className:U,children:`Instructions to insert`}),(0,G.jsx)(z,{id:`new-template-text`,"aria-label":`New template text`,"data-slot":`prompt-template-new-text`,placeholder:`Enter reusable instructions…`,value:y,maxLength:2e3,onChange:e=>b(e.target.value),className:`min-h-14 rounded-md border border-border bg-background text-[13px]`}),(0,G.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,"data-action":`prompt-template-add`,disabled:!g.trim()||!y.trim(),onClick:()=>{let e=g.trim(),t=y.trim();!e||!t||(m(n=>[...n,{id:R(),label:e,text:t}]),_(``),b(``))},className:`self-start`,children:[(0,G.jsx)(d,{"aria-hidden":`true`,className:`size-3.5`}),`Add template`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(H,{show:!S&&!w&&!x.isPending,children:(0,G.jsx)(v,{type:`button`,variant:`primary`,size:`sm`,"data-action":`prompt-templates-save`,disabled:!S||w||x.isPending,onClick:()=>x.mutate(f),children:`Save`})}),(0,G.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`prompt-templates-reset`,disabled:x.isPending,onClick:()=>m(P.map(e=>({...e}))),children:`Reset to defaults`}),w?(0,G.jsx)(`p`,{"data-slot":`prompt-templates-invalid`,className:`text-xs text-danger`,children:`Every template needs both a label and text.`}):null]})]})})}function J({label:e,skills:t,skillUsage:n,selected:i,onToggle:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=(0,W.useRef)(null),{mostUsed:d,project:f,global:p,ranked:h}=j(t,c,n),v=(e,t)=>{let n=i.includes(e.id);return(0,G.jsxs)(w,{value:O(e),keywords:A(e.name,e.description),"data-slot":`prompt-template-skill-option`,"data-skill":e.id,"data-selected":n?`true`:void 0,onSelect:()=>a(e.id),children:[(0,G.jsx)(F,{skill:e,emphasized:t}),n?(0,G.jsx)(m,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},O(e))};return(0,G.jsxs)(x,{open:o,onOpenChange:e=>{s(e),e||l(``)},children:[(0,G.jsx)(y,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-skills-trigger`,"aria-label":`Apply ${e||`this template`} automatically with a skill`,title:`Pick the skills this template applies itself to`,className:r(`inline-flex h-[26px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i.length>0&&`text-foreground`),children:[(0,G.jsx)(_,{"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`Add skill`,(0,G.jsx)(g,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,G.jsx)(b,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,G.jsxs)(D,{shouldFilter:!1,children:[(0,G.jsx)(S,{placeholder:`search skills…`,value:c,onValueChange:l,onInput:()=>u.current?.scrollTo(0,0)}),(0,G.jsxs)(E,{ref:u,"data-slot":`prompt-template-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[c.trim()&&!t.some(e=>e.id===c.trim())?(0,G.jsx)(C,{children:(0,G.jsxs)(w,{value:`typed-skill`,onSelect:()=>a(c.trim()),children:[`Use skill id “`,c.trim(),`” (unchecked)`]})}):null,(h?h.length===0:d.length===0&&f.length===0&&p.length===0)?(0,G.jsx)(T,{children:`Nothing matches.`}):null,h?h.length>0?(0,G.jsx)(C,{children:h.map(e=>v(e,k(e)))}):null:(0,G.jsxs)(G.Fragment,{children:[d.length>0?(0,G.jsx)(C,{heading:`Most used`,children:d.map(e=>v(e,k(e)))}):null,f.length>0?(0,G.jsx)(C,{heading:`Project skills`,children:f.map(e=>v(e,!0))}):null,p.length>0?(0,G.jsx)(C,{heading:`Global`,children:p.map(e=>v(e,!1))}):null]})]})]})})]})}function Y({title:e,hint:t,children:n}){return(0,G.jsxs)(`section`,{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})]}),n]})}export{K as PromptTemplatesSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{a as i,i as a,n as o,p as s,r as c,t as l}from"./live-reads-Crd6fVGH.js";import{$t as u,C as d,Ct as f,Di as p,Dt as m,E as h,Fi as g,G as _,Gt as v,H as y,Ht as ee,In as te,Ir as ne,It as re,J as ie,Jt as ae,K as oe,Kt as se,Ln as ce,Lt as le,Mi as ue,N as de,Nn as fe,Ot as pe,Pn as me,Rr as he,S as ge,Si as _e,St as ve,T as ye,U as be,Ut as xe,V as Se,Vt as Ce,W as we,Wr as Te,Wt as Ee,X as De,Xt as Oe,Y as ke,Yt as Ae,Zt as je,_ as Me,_n as Ne,_t as Pe,ai as Fe,b as Ie,br as Le,bt as Re,ci as ze,cn as Be,dn as Ve,en as He,f as Ue,fn as We,ft as Ge,g as Ke,gn as qe,gt as Je,hn as Ye,hr as Xe,ht as Ze,ii as Qe,in as $e,it as et,j as tt,ji as nt,jt as rt,k as it,ki as at,kt as ot,li as st,ln as ct,lt,mi as ut,mn as dt,mt as ft,nn as pt,oi as mt,p as ht,pi as b,pt as gt,qt as _t,r as vt,ri as yt,rn as bt,si as xt,sn as St,ti as x,tn as Ct,ui as wt,un as Tt,v as Et,vi as Dt,vt as Ot,w as kt,wi as At,wt as jt,x as Mt,xt as Nt,y as Pt,yi as Ft,yt as It,zn as Lt,zr as Rt,zt}from"./project-scope-context-Rv6S_BXt.js";import{A as Bt,B as S,F as C,H as w,I as T,N as E,P as D,W as O,Z as k,j as A,z as j}from"./live-protocol-DMhTnCmf.js";import{n as Vt,r as Ht}from"./toaster-BXnLIU3z.js";var Ut=class extends Dt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Wt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ft({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Wt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Gt=class extends g{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),nt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&_e(t.mutationKey)!==_e(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Wt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){k.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Kt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function qt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Jt=class extends g{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,k.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!nt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Kt(e,n).forEach(e=>{e.destroy()}),Kt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=at(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new ut(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=qt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=b(n),i=wt(),a=st(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{yt(e);let t=r.getQueryCache().get(e.queryHash);mt(e,a,t)}),ze(a);let[s]=M.useState(()=>new Jt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>d?s.subscribe(k.batchCalls(e)):p,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),M.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Fe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Fe(n,e)?Qe(n,new ut(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let m=c.find((e,t)=>{let n=o[t];return n&&xt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function P(e,t){let n=b(t),[r]=M.useState(()=>new Gt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(p)},[r]);if(i.error&&ue(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Yt(e,t=!0,n=!1,r){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>pe(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:W.models(t),refetchType:n})}function Xt(e,t=!0,n){return x({...Zt(e,n),enabled:t})}var Zt=(e,t)=>({queryKey:W.models(e,t),queryFn:({signal:n})=>Lt(e,{signal:n},t),staleTime:300*1e3});function Qt(e,t=!0){let n=N({queries:e.map(e=>({...Zt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function $t(e,t){return JSON.stringify([e,t])}function en(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function tn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var nn=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set($t(e.projectId,e.id),t))}at(e,t){return this.positions.get($t(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function rn(e,t,n){let r=new nn(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=un(i,e.project,e.usage,r);else{let t=sn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){return sn(e,t,n,new nn(e.runs))}function sn(e,t,n,r){let{project:i}=t,a=r.at(i,en(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,i,n))return{index:e,reconcile:!0};let l=at(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||tn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return ln(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&tn(u,i)>e.perProjectLimit}}function cn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function ln(e,t,n){let r=cn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function un(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=at(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function dn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function fn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function pn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function mn(e){e.stream=void 0}function hn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,en(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function gn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function _n(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function vn(e,t,n){if(!_n(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=on(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],yn=[`workspace`,`projects`],bn=6e4,xn=100,Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t||(t=On(e),Sn.set(e,t)),t}function wn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cn(t).merge(e)}function Tn(e){let t=e.getQueryData(yn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function En(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function Dn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function On(e){let t=fn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=Tn(e),{index:s,reconcile:c}=rn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,xn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){pn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){mn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Dn(e,r);if(!hn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),gn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=dn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=vn(t,n,Tn(e));for(let e of l)i.index=dn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),En(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}function kn(e,t,r=!0){let i=mi(),a=K(),{runner:o,ready:c}=s(e??i.data?.defaultRunner??`claude`),l=a.data?.capabilities?.localHandoff===!1?null:t,u=n(),d=x({queryKey:U.runnerSkills(o,l),queryFn:({signal:e})=>ge(o,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...d,runner:o,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var An={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},jn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Mn(e){return typeof e==`string`&&Object.hasOwn(An,e)}function Nn(e){return e!==void 0&&Mn(e)?An[e]:void 0}var Pn=`cez.reference-statuses.v1`,Fn=`cez.reference-conflicts.v1`,B=new Map(zn()),In=1e3;function Ln(e,t){if(B.get(e)!==t){for(B.delete(e),B.set(e,t);B.size>In;){let e=B.keys().next().value;if(e===void 0)break;B.delete(e)}Hn()}}var V=new Set(Bn());function Rn(e,t){if(V.has(e)!==t){if(t)for(V.add(e);V.size>In;){let e=V.values().next().value;if(e===void 0)break;V.delete(e)}else V.delete(e);Hn()}}function zn(){try{let e=globalThis.sessionStorage?.getItem(Pn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&Mn(e[1])):[]}catch{return[]}}function Bn(){try{let e=globalThis.sessionStorage?.getItem(Fn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Vn;function Hn(){Vn===void 0&&(Vn=setTimeout(()=>{Vn=void 0;try{globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...B])),globalThis.sessionStorage?.setItem(Fn,JSON.stringify([...V]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Un(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Wn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function Gn(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;Ln(t,o),s!==void 0&&Rn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Kn(e,t,n){let r=H(t),i=B.get(r),a=V.has(r)?!0:void 0,o=n.data;if(o?.available){Gn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Un(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Un(i,a)});return}e.set(r,{state:`loading`,...Un(i,a)})}function qn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Wn(i))Kn(n,e,t)}),n}var U={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},W={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...W.fsBrowseRoot,e,t]};function Jn(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Yn(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Xn(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Zn(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Qn(){let e=b();return x({queryKey:W.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(W.providerStatus),r=await pt(!1,{signal:t});return Le(n,e.getQueryData(W.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function $n(){let e=b();return P({mutationFn:()=>pt(!0),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Le(r,e,t)),L(e)}})}function er(){let e=b();return P({mutationFn:({provider:e,authFailureId:t})=>Ve(e,t),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Le(r,e,t,n.authFailureId)),L(e,n.provider)}})}function tr(e={}){return x({queryKey:W.projects,queryFn:({signal:e})=>Ct({signal:e}),...e})}function nr(e,t=!1){return x({queryKey:W.fsBrowse(e,t),queryFn:({signal:n})=>Ee(e??void 0,{signal:n,showHidden:t}),retry:!1})}function rr(){let e=b();return P({mutationFn:e=>St(e),onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function ir(){let e=b();return P({mutationFn:e=>ct(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:W.projects})}})}function ar(){let e=b();return P({mutationFn:e=>{let{id:t,...n}=e;return qe(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:W.projects});let r=e.getQueryData(W.projects);return e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?or(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(W.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:W.projects})})}function or(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Zn(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function sr(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(W.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:W.projects})})}function cr(){return sr(e=>{let{projectId:t,...n}=e;return Ae(t,n)})}function lr(){return sr(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function ur(){return sr(({projectId:e,webhookId:t})=>Tt(e,t))}function dr(){return P({mutationFn:({projectId:e,webhookId:t})=>dt(e,t),retry:!1})}function G(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:W.agentProfiles}),t.invalidateQueries({queryKey:W.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:U.health}),t.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function fr(){return G(e=>_t(e))}function pr(){return G(e=>{let{id:t,...n}=e;return Ye(t,n)})}function mr(){return G(e=>Be(e))}function hr(){return G(e=>We(e))}function gr(e,t){return x({queryKey:W.agentAccountStatus(e),queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function _r(){let e=b();return P({mutationFn:({provider:e,profileId:t})=>se(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:W.agentProfiles}),e.invalidateQueries({queryKey:W.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:U.health}),e.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function vr(){let e=b();return P({mutationFn:e=>Oe(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.agentAccountStatus(n),t),e.invalidateQueries({queryKey:W.agentProfiles}),L(e,t.status.provider)}})}function yr(){let e=b();return P({mutationFn:e=>v(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function br(){let e=b();return P({mutationFn:e=>ae(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function xr({enabled:e}){return x({queryKey:W.githubOwners,queryFn:({signal:e})=>u({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Sr(){let e=b();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(U.health);n&&(he({bootProject:n.bootProject??`default`,apiBase:r()}),t??=c(`health`,t=>{e.setQueryData(U.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),Te()}},[e])}function K(){return x({queryKey:U.health,queryFn:({signal:e})=>He({signal:e})})}function Cr(e,t){let n=K().data,r=tr(t).data?.projects,i=vt(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?Jn(n?.repo?.remote):void 0}function wr(){return x({queryKey:W.uiState,queryFn:({signal:e})=>$e({signal:e})})}function Tr(){return x({queryKey:W.config,queryFn:({signal:e})=>bt({signal:e})})}function Er(){return x({queryKey:W.agentProfiles,queryFn:({signal:e})=>je({signal:e})})}var q=[`workspace`,`runs-index`],J=e=>[e.cacheScope,`runs`,`list`],Y=e=>[e.cacheScope,`runs`,`detail`,e.runId],X=e=>typeof e==`function`?e():e;function Dr(e){let{seenAt:t,...n}=e;return n}function Or(e,t){let n=Dr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function kr(e,t,n){return t?{...e,seenAt:n}:Dr(e)}function Ar(e){let t=()=>{e.invalidateQueries({queryKey:q})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Rt(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:J(X(n))}),await e.cancelQueries({queryKey:Y(X(n))});let i=e.getQueryData(J(X(n))),a=e.getQueryData(Y(X(n))),o=X(n).runId,s=new Date().toISOString();return e.setQueryData(J(X(n)),e=>e?.map(e=>e.id===o?kr(e,r,s):e)),e.setQueryData(Y(X(n)),e=>e&&kr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(J(X(n)),i),a&&e.setQueryData(Y(X(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(J(X(n)),e=>e?.map(e=>e.id===o?Or(e,t):e)),a&&e.setQueryData(Y(X(n)),e=>e&&Or(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?kr(e,r,i.seenAt):e;e.setQueryData(J(X(n)),e=>e?.map(a));let s={...X(n),runId:r?o:i.id};e.setQueryData(Y(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:q});let i=e.getQueryData(q),a=n();return e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(q,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function Z(){let e=b();return(0,M.useMemo)(()=>Ar(e),[e])}async function jr(e,t=!1){return ce(await me.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),te(e,`/worker-destroy`))}function Mr(){return x({queryKey:U.openTargets,queryFn:({signal:e})=>Pe({signal:e}),staleTime:5*6e4})}function Nr(){return x({queryKey:U.runs.list(),queryFn:({signal:e})=>pe(F(),{signal:e})})}function Pr(e,t){return Ht({queryKey:U.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Ge({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function Fr(e){let t=e.trim();return x({queryKey:W.runsSearch(t),queryFn:({signal:e})=>Ce(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function Ir(e=!0,t=bn,n){let r=Cn(b());return o(`/api/v1/workspace/runs-index`,W.runsIndex,a(e?t:!1),wn),x({queryKey:W.runsIndex,queryFn:({signal:e})=>ot({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function Lr(e){let t=b();return P({mutationFn:({workerId:e,discardWork:t=!1})=>jr(e,t),onSettled:()=>t.invalidateQueries({queryKey:U.runs.relationships(e)})})}function Rr(e,t={}){return x({queryKey:U.runs.relationships(e),queryFn:({signal:t})=>m(e,{signal:t}),enabled:t.enabled??!0})}function zr(e){return x({queryKey:U.runs.detail(e??``),queryFn:({signal:t})=>Ot(I(e),{signal:t}),enabled:!!e})}function Br(e,t,n=!0){return x({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Ot(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Vr(e){return x({queryKey:U.runs.diff(e??``),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:!!e})}function Hr(e,t=!1){return o(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,U.runs.changes(e??``),a(t?4e3:!1)),x({queryKey:U.runs.changes(e??``),queryFn:({signal:t})=>It(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ur(e,t){return x({queryKey:U.runs.file(e??``,t??``),queryFn:({signal:n})=>f(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Wr(e,t){return x({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Je(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Gr(e,t){return x({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>gt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Kr(e,t){return x({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>ft(e,t,{signal:n}),enabled:t!==null,retry:!1})}function qr(e){return x({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Ze(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Jr(e,t=!1){return o(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,U.runs.commits(e??``),a(t?5e3:!1)),x({queryKey:U.runs.commits(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Yr(e,t){return x({queryKey:U.runs.commit(e??``,t??``),queryFn:({signal:n})=>Re(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Xr(e,t=!0){return x({queryKey:U.runs.handoff(e??``),queryFn:({signal:t})=>jt(I(e),{signal:t}),enabled:!!e&&t})}function Zr(e,t,n){return x({queryKey:e===void 0?U.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>jt(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Qr(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>Ke({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function $r(e){let t=b();return P({mutationFn:t=>rt(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ei(e){let t=b();return P({mutationFn:t=>re(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ti(e){let t=Z(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>xe(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ni(){let e=Z();return P({mutationFn:e=>xe(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ri(e){let t=Z();return P({mutationFn:({id:t,pinned:n})=>le(I(t,e),n),onError:e=>Vt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function ii(e,t){let n=Z();return P({mutationFn:n=>ee(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof fe&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ai(e,t){let n=Z();return P({mutationFn:(n={})=>et(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function oi(e){let t=b();return P({mutationFn:({msgId:t,message:n})=>lt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function si(e){let t=b();return P({mutationFn:t=>zt(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ci(){return x({queryKey:U.workflows,queryFn:({signal:e})=>ye({signal:e})})}function li(){return x({queryKey:U.repo,queryFn:({signal:e})=>Et({signal:e})})}function ui(e){return x({queryKey:[e,`repo`],queryFn:({signal:t})=>Et({signal:t},e)})}function di(){return x({queryKey:U.repoBranches,queryFn:({signal:e})=>Pt({signal:e})})}function fi(){return x({queryKey:U.repoChanges,queryFn:({signal:e})=>Ie({signal:e}),retry:!1})}function pi(e){return x({queryKey:U.repoCommit(e??``),queryFn:({signal:t})=>Mt(e,{signal:t}),enabled:!!e,retry:!1})}function mi(){return x({queryKey:U.config,queryFn:({signal:e})=>Me({signal:e})})}function hi(){return x({queryKey:U.worktrees,queryFn:({signal:e})=>h({signal:e})})}function gi(e){return x({queryKey:[e,`worktrees`],queryFn:({signal:t})=>h({signal:t},e),staleTime:0})}function _i(e,t=!0,n=!1){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>kt({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ne(e.sidebarLimits)},enabled:t})}function vi(){return _i(n())}function yi(){return x({queryKey:U.agentConfig,queryFn:({signal:e})=>Ue({signal:e})})}function bi(e){return x({queryKey:U.agentConfigFile(e??``),queryFn:({signal:t})=>ht(e,{signal:t}),enabled:e!==null})}function xi(){return x({queryKey:U.sessionContext,queryFn:({signal:e})=>d({signal:e})})}function Si(e,t,n=``){return x({queryKey:U.sessionContextPreview(e,t,n),queryFn:({signal:n})=>it({content:e,role:t},{signal:n}),placeholderData:At,staleTime:0,retry:!1})}function Ci(){let e=b();return P({onMutate:()=>({fileKey:U.sessionContext}),mutationFn:e=>de(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function wi(e){let t=b(),n=U.agentConfig,r=U.agentConfigFile(e);return P({mutationFn:t=>tt(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var Ti=A([`passing`,`failing`,`pending`]).nullable(),Q=S({kind:A([`issue`,`pr`]),number:j(),title:O(),author:O(),createdAt:O(),labels:E(O()),body:O().optional(),url:O(),comments:j(),assignees:E(O()).optional(),projectIds:E(O()).optional(),isDraft:D().optional(),additions:j().optional(),deletions:j().optional(),checks:Ti.optional()});C(`available`,[S({available:T(!0),item:Q.nullable(),labelColors:w(O(),O()).optional()}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),number:Bt().int().positive().safe()});var Ei=S({id:O(),title:O(),url:O()});S({available:D(),reason:O().optional(),repo:O().optional(),syncedAt:O().optional(),issues:E(Q),prs:E(Q),labelColors:w(O(),O()).optional(),viewerLogin:O().optional(),projects:E(Ei).optional(),projectsReason:O().optional(),projectsState:A([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:O().optional(),issuesTotal:j().int().nonnegative().optional(),prsTotal:j().int().nonnegative().optional(),issuesNextCursor:O().nullable().optional(),prsNextCursor:O().nullable().optional(),commentsDeferred:T(!0).optional()});var Di=O().min(1).max(2e3).optional();S({limit:O().optional(),refresh:O().optional(),issuesCursor:Di,prsCursor:Di,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),S({kind:A([`issue`,`pr`]),numbers:O().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),C(`available`,[S({available:T(!0),counts:w(j(),j().int().nonnegative())}),S({available:T(!1),reason:O()})]),C(`available`,[S({available:T(!0),checks:w(j(),Ti)}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),q:O().trim().min(1).max(256),limit:Bt().int().positive().max(50).optional()}),S({available:D(),projectsReason:O().optional(),reason:O().optional(),items:E(Q),truncated:D().optional(),labelColors:w(O(),O()).optional()});var Oi=j().nullable();C(`available`,[S({available:T(!0),prs:w(j(),Xe),issues:w(j(),Xe),conflicts:E(j()).optional(),recheckAfterMs:Oi}),S({available:T(!1),reason:O(),recheckAfterMs:Oi})]);var ki=S({id:j(),author:O(),avatarUrl:O().optional(),createdAt:O(),body:O(),kind:A([`comment`,`review`]),reviewState:A([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:O()}),Ai=A([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ji=S({id:O(),kind:Ai,actor:O(),avatarUrl:O().optional(),createdAt:O(),url:O().optional(),sha:O().optional(),message:O().optional(),checks:Ti.optional(),label:S({name:O(),color:O().optional()}).optional(),subject:O().optional(),refNumber:j().optional(),refTitle:O().optional(),refIsPr:D().optional()});S({available:D(),reason:O().optional(),comments:E(ki),truncated:D().optional(),events:E(ji).optional(),detail:S({body:O(),additions:j().int().nonnegative().optional(),deletions:j().int().nonnegative().optional()}).optional()});var Mi=A([`merge`,`squash`,`rebase`]),Ni=S({name:O(),state:A([`passing`,`failing`,`pending`,`unknown`]),required:D().nullable(),url:O().optional()}),Pi=S({number:j(),title:O(),url:O(),state:A([`open`,`closed`,`merged`]),isDraft:D(),headRef:O(),baseRef:O(),headSha:O(),mergeable:A([`mergeable`,`conflicting`,`unknown`]),reviewDecision:A([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:E(Ni),methods:E(Mi),defaultMethod:Mi.nullable(),eligibility:A([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:E(S({code:O(),message:O()})),canMerge:D(),canOverride:D()});C(`available`,[S({available:T(!0),mergeState:Pi}),S({available:T(!1),reason:O()})]),S({merged:T(!0),number:j(),url:O(),method:Mi,mergeCommitSha:O().optional()});var Fi=S({path:O(),previousPath:O().optional(),status:A([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:j(),deletions:j(),patch:O().optional(),patchUnavailableReason:A([`binary`,`too-large`,`not-provided`]).optional(),truncated:D().optional()});C(`available`,[S({available:T(!0),number:j(),headSha:O(),files:E(Fi),additions:j(),deletions:j(),truncated:D(),reason:O().optional()}),S({available:T(!1),reason:O()})]),S({generation:O().uuid()}),C(`state`,[S({generation:O().uuid(),state:T(`ready`),projects:E(Ei),membership:w(O(),E(O()))}),S({generation:O().uuid(),state:T(`unavailable`),reason:O()})]);function Ii(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Li(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Ri(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function zi(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Ri(t.issues,a,r),Ri(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var $=e=>e.map(e=>e.number).join(`,`);function Bi(e,t){let n=e[0];if(e.length>1&&n&&($(n.issues)!==$(t.issues)||$(n.prs)!==$(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function Vi(e={},t=!0){let r=b(),i=U.github(e);o(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let s=x({queryKey:U.github(e),queryFn:({signal:t})=>Se({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),c=s.data?.projectsGeneration,l=x({queryKey:[...i,`projects`,c],queryFn:({signal:e})=>ie(c,{signal:e}),enabled:t&&s.data?.projectsState===`refreshing`&&!!c,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!c||!l.data&&!l.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==c||e.projectsState!==`refreshing`)return e;let t=l.data;return t?.generation&&t.generation!==c?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,c,l.data,l.error,i]),s}var Hi=class extends Error{};function Ui(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await Se({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Hi(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Ii(e),retry:(e,t)=>!(t instanceof Hi)&&!(t instanceof fe&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Wi(e=50,t=!0){let r=b(),i=U.githubPages(e),s=U.githubPagesHead(e);o(`/api/v1/p/${n()}/github?limit=${e}`,s,a(t?6e4:!1));let c=Ht({...Ui(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),l=x({queryKey:s,queryFn:({signal:t})=>Se({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:u}=c;(0,M.useEffect)(()=>{if(!l.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=Bi(e.pages,l.data);t===`refetch`?u():r.setQueryData(i,{...e,pages:t})},[r,l.dataUpdatedAt,u]);let d=(c.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),f=N({queries:d.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ie(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{f.forEach((e,t)=>{let n=d[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,f.map((e,t)=>e.data||e.error?d[t]:``).join(`,`)]),{pages:c,data:(0,M.useMemo)(()=>zi(c.data?.pages??[]),[c.data])}}function Gi(e,t=50,n=!0){let r=Ht({...Ui([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>zi(r.data?.pages??[]),[r.data])}}function Ki(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:U.githubCommentCounts(e,t),queryFn:({signal:n})=>be(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function qi(e,t,n,r=!0){return x({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>De(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Ji(e,t=!0){return x({queryKey:U.githubChecks(e),queryFn:({signal:t})=>y(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Yi(e,t,n=!0){return x({queryKey:U.githubSearch(e,t),queryFn:({signal:n})=>De(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Xi=100;function Zi(e){return[...e].sort((e,t)=>t-e).slice(0,Xi).sort((e,t)=>e-t)}function Qi(){let e=vt(),t=K();return e.projectId??t.data?.bootProject}function $i(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))Ln(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))Ln(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var ea=5*6e4;function ta(e){return e?e.recheckAfterMs:ea}function na(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:Zi(t.prs),issues:Zi(t.issues)}))},[e.map(H).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:U.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>ke(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:ta(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||i())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=U.githubRefStatus(t.projectId,t.prs,t.issues);return l({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,M.useMemo)(()=>qn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=B.get(t);return{state:`idle`,...r?{status:r}:{},...V.has(t)?{conflicting:!0}:{}}},[s])}function ra(e,t,n=!0){return x({queryKey:U.githubComments(e,t),queryFn:({signal:n})=>we(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ia(e,t,n=!0){return x({queryKey:U.githubItem(e,t),queryFn:({signal:n})=>_(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function aa(e){return x({queryKey:U.githubPrChanges(e??0),queryFn:({signal:t})=>oe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Vr as $,N as $t,ci as A,hr as At,Wr as B,U as Bt,li as C,vr as Ct,xi as D,ir as Dt,pi as E,mr as Et,qr as F,Tr as Ft,ei as G,Cn as Gt,ni as H,jn as Ht,Qr as I,wr as It,si as J,Xt as Jt,ri as K,L as Kt,ai as L,Yn as Lt,Pr as M,pr as Mt,Gr as N,ar as Nt,Si as O,ur as Ot,Kr as P,lr as Pt,Jr as Q,P as Qt,Lr as R,Xn as Rt,Ci as S,Qn as St,fi as T,rr as Tt,$r as U,Nn as Ut,ti as V,W as Vt,Mr as W,kn as Wt,Hr as X,F as Xt,zr as Y,Yt,Yr as Z,I as Zt,mi as _,xr as _t,ra as a,Fr as at,gi as b,Cr as bt,aa as c,Z as ct,qi as d,yr as dt,Ut as en,Ur as et,Qi as f,_r as ft,bi as g,nr as gt,yi as h,cr as ht,Ki as i,Ir as it,hi as j,dr as jt,vi as k,er as kt,Yi as l,gr as lt,Li as m,br as mt,Vi as n,Rr as nt,ia as o,ii as ot,na as p,fr as pt,Br as q,Qt as qt,Ji as r,Nr as rt,Wi as s,Zr as st,$i as t,Xr as tt,Gi as u,Er as ut,ui as v,K as vt,di as w,$n as wt,wi as x,tr as xt,_i as y,Sr as yt,oi as z,Jn as zt};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{c as n,o as r}from"./utils-DSMR_WLb.js";import{a as i,i as a,n as o,p as s,r as c,t as l}from"./live-reads-Cgk2XbiP.js";import{$t as u,C as d,Ct as f,Di as p,Dt as m,E as h,Fi as g,G as _,Gt as v,H as y,Ht as ee,In as te,Ir as ne,It as re,J as ie,Jt as ae,K as oe,Kt as se,Ln as ce,Lt as le,Mi as ue,N as de,Nn as fe,Ot as pe,Pn as me,Rr as he,S as ge,Si as _e,St as ve,T as ye,U as be,Ut as xe,V as Se,Vt as Ce,W as we,Wr as Te,Wt as Ee,X as De,Xt as Oe,Y as ke,Yt as Ae,Zt as je,_ as Me,_n as Ne,_t as Pe,ai as Fe,b as Ie,br as Le,bt as Re,ci as ze,cn as Be,dn as Ve,en as He,f as Ue,fn as We,ft as Ge,g as Ke,gn as qe,gt as Je,hn as Ye,hr as Xe,ht as Ze,ii as Qe,in as $e,it as et,j as tt,ji as nt,jt as rt,k as it,ki as at,kt as ot,li as st,ln as ct,lt,mi as ut,mn as dt,mt as ft,nn as pt,oi as mt,p as ht,pi as b,pt as gt,qt as _t,r as vt,ri as yt,rn as bt,si as xt,sn as St,ti as x,tn as Ct,ui as wt,un as Tt,v as Et,vi as Dt,vt as Ot,w as kt,wi as At,wt as jt,x as Mt,xt as Nt,y as Pt,yi as Ft,yt as It,zn as Lt,zr as Rt,zt}from"./project-scope-context-DIcqj4jJ.js";import{A as Bt,B as S,F as C,H as w,I as T,N as E,P as D,W as O,Z as k,j as A,z as j}from"./live-protocol-DMhTnCmf.js";import{n as Vt,r as Ht}from"./toaster-0sM0sfWx.js";var Ut=class extends Dt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Wt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Ft({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),k.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Wt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Gt=class extends g{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),nt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&_e(t.mutationKey)!==_e(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Wt();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){k.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Kt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function qt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Jt=class extends g{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,k.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!nt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Kt(e,n).forEach(e=>{e.destroy()}),Kt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=at(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new ut(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=qt(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&k.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},M=e(t(),1);function N({queries:e,...t},n){let r=b(n),i=wt(),a=st(),o=M.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{yt(e);let t=r.getQueryCache().get(e.queryHash);mt(e,a,t)}),ze(a);let[s]=M.useState(()=>new Jt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;M.useSyncExternalStore(M.useCallback(e=>d?s.subscribe(k.batchCalls(e)):p,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),M.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Fe(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Fe(n,e)?Qe(n,new ut(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let m=c.find((e,t)=>{let n=o[t];return n&&xt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function P(e,t){let n=b(t),[r]=M.useState(()=>new Gt(n,e));M.useEffect(()=>{r.setOptions(e)},[r,e]);let i=M.useSyncExternalStore(M.useCallback(e=>r.subscribe(k.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=M.useCallback((e,t)=>{r.mutate(e,t).catch(p)},[r]);if(i.error&&ue(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function F(e={}){let t=e.projectId??n();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function I(e,t={}){return{...F(t),runId:e}}function Yt(e,t=!0,n=!1,r){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>pe(F({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:W.models(t),refetchType:n})}function Xt(e,t=!0,n){return x({...Zt(e,n),enabled:t})}var Zt=(e,t)=>({queryKey:W.models(e,t),queryFn:({signal:n})=>Lt(e,{signal:n},t),staleTime:300*1e3});function Qt(e,t=!0){let n=N({queries:e.map(e=>({...Zt(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function $t(e,t){return JSON.stringify([e,t])}function en(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function tn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var nn=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set($t(e.projectId,e.id),t))}at(e,t){return this.positions.get($t(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function rn(e,t,n){let r=new nn(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=un(i,e.project,e.usage,r);else{let t=sn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function an(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function on(e,t,n){return sn(e,t,n,new nn(e.runs))}function sn(e,t,n,r){let{project:i}=t,a=r.at(i,en(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!an(e,i,n))return{index:e,reconcile:!0};let l=at(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||tn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return ln(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&tn(u,i)>e.perProjectLimit}}function cn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function ln(e,t,n){let r=cn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function un(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=at(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function dn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function fn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function pn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function mn(e){e.stream=void 0}function hn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,en(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function gn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function _n(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function vn(e,t,n){if(!_n(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=on(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],yn=[`workspace`,`projects`],bn=6e4,xn=100,Sn=new WeakMap;function Cn(e){let t=Sn.get(e);return t||(t=On(e),Sn.set(e,t)),t}function wn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cn(t).merge(e)}function Tn(e){let t=e.getQueryData(yn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function En(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function Dn(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function On(e){let t=fn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},h=()=>e.getQueryData(z),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=Tn(e),{index:s,reconcile:c}=rn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},y=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,xn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){pn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){mn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Dn(e,r);if(!hn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),y()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),y()}},dropProject(e){l.add(e),gn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=dn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=vn(t,n,Tn(e));for(let e of l)i.index=dn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),En(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}function kn(e,t,r=!0){let i=mi(),a=K(),{runner:o,ready:c}=s(e??i.data?.defaultRunner??`claude`),l=a.data?.capabilities?.localHandoff===!1?null:t,u=n(),d=x({queryKey:U.runnerSkills(o,l),queryFn:({signal:e})=>ge(o,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...d,runner:o,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var An={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},jn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Mn(e){return typeof e==`string`&&Object.hasOwn(An,e)}function Nn(e){return e!==void 0&&Mn(e)?An[e]:void 0}var Pn=`cez.reference-statuses.v1`,Fn=`cez.reference-conflicts.v1`,B=new Map(zn()),In=1e3;function Ln(e,t){if(B.get(e)!==t){for(B.delete(e),B.set(e,t);B.size>In;){let e=B.keys().next().value;if(e===void 0)break;B.delete(e)}Hn()}}var V=new Set(Bn());function Rn(e,t){if(V.has(e)!==t){if(t)for(V.add(e);V.size>In;){let e=V.values().next().value;if(e===void 0)break;V.delete(e)}else V.delete(e);Hn()}}function zn(){try{let e=globalThis.sessionStorage?.getItem(Pn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&Mn(e[1])):[]}catch{return[]}}function Bn(){try{let e=globalThis.sessionStorage?.getItem(Fn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var Vn;function Hn(){Vn===void 0&&(Vn=setTimeout(()=>{Vn=void 0;try{globalThis.sessionStorage?.setItem(Pn,JSON.stringify([...B])),globalThis.sessionStorage?.setItem(Fn,JSON.stringify([...V]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function Un(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Wn(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function Gn(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;Ln(t,o),s!==void 0&&Rn(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Kn(e,t,n){let r=H(t),i=B.get(r),a=V.has(r)?!0:void 0,o=n.data;if(o?.available){Gn(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Un(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Un(i,a)});return}e.set(r,{state:`loading`,...Un(i,a)})}function qn(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Wn(i))Kn(n,e,t)}),n}var U={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t)=>[n(),`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},W={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:z,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...W.fsBrowseRoot,e,t]};function Jn(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Yn(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Xn(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Zn(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Qn(){let e=b();return x({queryKey:W.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(W.providerStatus),r=await pt(!1,{signal:t});return Le(n,e.getQueryData(W.providerStatus),r)},staleTime:5*6e4,refetchInterval:a(!1),refetchOnWindowFocus:!0})}function $n(){let e=b();return P({mutationFn:()=>pt(!0),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Le(r,e,t)),L(e)}})}function er(){let e=b();return P({mutationFn:({provider:e,authFailureId:t})=>Ve(e,t),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Le(r,e,t,n.authFailureId)),L(e,n.provider)}})}function tr(e={}){return x({queryKey:W.projects,queryFn:({signal:e})=>Ct({signal:e}),...e})}function nr(e,t=!1){return x({queryKey:W.fsBrowse(e,t),queryFn:({signal:n})=>Ee(e??void 0,{signal:n,showHidden:t}),retry:!1})}function rr(){let e=b();return P({mutationFn:e=>St(e),onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function ir(){let e=b();return P({mutationFn:e=>ct(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:W.projects})}})}function ar(){let e=b();return P({mutationFn:e=>{let{id:t,...n}=e;return qe(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:W.projects});let r=e.getQueryData(W.projects);return e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?or(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(W.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:W.projects})})}function or(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Zn(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function sr(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(W.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:W.projects})})}function cr(){return sr(e=>{let{projectId:t,...n}=e;return Ae(t,n)})}function lr(){return sr(e=>{let{projectId:t,webhookId:n,...r}=e;return Ne(t,n,r)})}function ur(){return sr(({projectId:e,webhookId:t})=>Tt(e,t))}function dr(){return P({mutationFn:({projectId:e,webhookId:t})=>dt(e,t),retry:!1})}function G(e){let t=b();return P({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:W.agentProfiles}),t.invalidateQueries({queryKey:W.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:U.health}),t.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function fr(){return G(e=>_t(e))}function pr(){return G(e=>{let{id:t,...n}=e;return Ye(t,n)})}function mr(){return G(e=>Be(e))}function hr(){return G(e=>We(e))}function gr(e,t){return x({queryKey:W.agentAccountStatus(e),queryFn:({signal:t})=>Oe(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function _r(){let e=b();return P({mutationFn:({provider:e,profileId:t})=>se(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:W.agentProfiles}),e.invalidateQueries({queryKey:W.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:U.health}),e.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function vr(){let e=b();return P({mutationFn:e=>Oe(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.agentAccountStatus(n),t),e.invalidateQueries({queryKey:W.agentProfiles}),L(e,t.status.provider)}})}function yr(){let e=b();return P({mutationFn:e=>v(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function br(){let e=b();return P({mutationFn:e=>ae(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function xr({enabled:e}){return x({queryKey:W.githubOwners,queryFn:({signal:e})=>u({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Sr(){let e=b();(0,M.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(U.health);n&&(he({bootProject:n.bootProject??`default`,apiBase:r()}),t??=c(`health`,t=>{e.setQueryData(U.health,t)}))};n();let i=e.getQueryCache().subscribe(n);return()=>{i(),t?.(),Te()}},[e])}function K(){return x({queryKey:U.health,queryFn:({signal:e})=>He({signal:e})})}function Cr(e,t){let n=K().data,r=tr(t).data?.projects,i=vt(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?Jn(n?.repo?.remote):void 0}function wr(){return x({queryKey:W.uiState,queryFn:({signal:e})=>$e({signal:e})})}function Tr(){return x({queryKey:W.config,queryFn:({signal:e})=>bt({signal:e})})}function Er(){return x({queryKey:W.agentProfiles,queryFn:({signal:e})=>je({signal:e})})}var q=[`workspace`,`runs-index`],J=e=>[e.cacheScope,`runs`,`list`],Y=e=>[e.cacheScope,`runs`,`detail`,e.runId],X=e=>typeof e==`function`?e():e;function Dr(e){let{seenAt:t,...n}=e;return n}function Or(e,t){let n=Dr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function kr(e,t,n){return t?{...e,seenAt:n}:Dr(e)}function Ar(e){let t=()=>{e.invalidateQueries({queryKey:q})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Rt(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,n()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:J(X(n))}),await e.cancelQueries({queryKey:Y(X(n))});let i=e.getQueryData(J(X(n))),a=e.getQueryData(Y(X(n))),o=X(n).runId,s=new Date().toISOString();return e.setQueryData(J(X(n)),e=>e?.map(e=>e.id===o?kr(e,r,s):e)),e.setQueryData(Y(X(n)),e=>e&&kr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(J(X(n)),i),a&&e.setQueryData(Y(X(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(J(X(n)),e=>e?.map(e=>e.id===o?Or(e,t):e)),a&&e.setQueryData(Y(X(n)),e=>e&&Or(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?kr(e,r,i.seenAt):e;e.setQueryData(J(X(n)),e=>e?.map(a));let s={...X(n),runId:r?o:i.id};e.setQueryData(Y(s),e=>e?a(e):i),t()}}}async function a(t,n){await e.cancelQueries({queryKey:q});let i=e.getQueryData(q),a=n();return e.setQueryData(q,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(q,i)},settle(){r(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:r}}function Z(){let e=b();return(0,M.useMemo)(()=>Ar(e),[e])}async function jr(e,t=!1){return ce(await me.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),te(e,`/worker-destroy`))}function Mr(){return x({queryKey:U.openTargets,queryFn:({signal:e})=>Pe({signal:e}),staleTime:5*6e4})}function Nr(){return x({queryKey:U.runs.list(),queryFn:({signal:e})=>pe(F(),{signal:e})})}function Pr(e,t){return Ht({queryKey:U.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>Ge({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function Fr(e){let t=e.trim();return x({queryKey:W.runsSearch(t),queryFn:({signal:e})=>Ce(t,{signal:e}),enabled:t.length>=2,placeholderData:At,staleTime:1e4})}function Ir(e=!0,t=bn,n){let r=Cn(b());return o(`/api/v1/workspace/runs-index`,W.runsIndex,a(e?t:!1),wn),x({queryKey:W.runsIndex,queryFn:({signal:e})=>ot({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function Lr(e){let t=b();return P({mutationFn:({workerId:e,discardWork:t=!1})=>jr(e,t),onSettled:()=>t.invalidateQueries({queryKey:U.runs.relationships(e)})})}function Rr(e,t={}){return x({queryKey:U.runs.relationships(e),queryFn:({signal:t})=>m(e,{signal:t}),enabled:t.enabled??!0})}function zr(e){return x({queryKey:U.runs.detail(e??``),queryFn:({signal:t})=>Ot(I(e),{signal:t}),enabled:!!e})}function Br(e,t,n=!0){return x({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Ot(I(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t})}function Vr(e){return x({queryKey:U.runs.diff(e??``),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:!!e})}function Hr(e,t=!1){return o(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,U.runs.changes(e??``),a(t?4e3:!1)),x({queryKey:U.runs.changes(e??``),queryFn:({signal:t})=>It(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ur(e,t){return x({queryKey:U.runs.file(e??``,t??``),queryFn:({signal:n})=>f(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Wr(e,t){return x({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Je(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Gr(e,t){return x({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>gt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Kr(e,t){return x({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>ft(e,t,{signal:n}),enabled:t!==null,retry:!1})}function qr(e){return x({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Ze(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Jr(e,t=!1){return o(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,U.runs.commits(e??``),a(t?5e3:!1)),x({queryKey:U.runs.commits(e??``),queryFn:({signal:t})=>Nt(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Yr(e,t){return x({queryKey:U.runs.commit(e??``,t??``),queryFn:({signal:n})=>Re(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Xr(e,t=!0){return x({queryKey:U.runs.handoff(e??``),queryFn:({signal:t})=>jt(I(e),{signal:t}),enabled:!!e&&t})}function Zr(e,t,n){return x({queryKey:e===void 0?U.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>jt(I(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function Qr(e,t){let r=[...new Set(e)],i=N({queries:r.map(e=>({queryKey:[e??n(),`automations`,`names`],queryFn:({signal:t})=>Ke({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,M.useMemo)(()=>{let e=new Map;return a.forEach((t,n)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([r[n]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([r,i.map(e=>e.dataUpdatedAt)])])}function $r(e){let t=b();return P({mutationFn:t=>rt(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ei(e){let t=b();return P({mutationFn:t=>re(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ti(e){let t=Z(),n=e?.projectId,r=e?.cacheScope,i=P({mutationFn:e=>xe(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,M.useCallback)(e=>({...I(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,M.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,M.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,M.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function ni(){let e=Z();return P({mutationFn:e=>xe(I(e),!1),onMutate:t=>e.patchRead(()=>I(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ri(e){let t=Z();return P({mutationFn:({id:t,pinned:n})=>le(I(t,e),n),onError:e=>Vt(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??F(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function ii(e,t){let n=Z();return P({mutationFn:n=>ee(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof fe&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ai(e,t){let n=Z();return P({mutationFn:(n={})=>et(I(e,{projectId:t}),n),onMutate:()=>F({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function oi(e){let t=b();return P({mutationFn:({msgId:t,message:n})=>lt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function si(e){let t=b();return P({mutationFn:t=>zt(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ci(){return x({queryKey:U.workflows,queryFn:({signal:e})=>ye({signal:e})})}function li(){return x({queryKey:U.repo,queryFn:({signal:e})=>Et({signal:e})})}function ui(e){return x({queryKey:[e,`repo`],queryFn:({signal:t})=>Et({signal:t},e)})}function di(){return x({queryKey:U.repoBranches,queryFn:({signal:e})=>Pt({signal:e})})}function fi(){return x({queryKey:U.repoChanges,queryFn:({signal:e})=>Ie({signal:e}),retry:!1})}function pi(e){return x({queryKey:U.repoCommit(e??``),queryFn:({signal:t})=>Mt(e,{signal:t}),enabled:!!e,retry:!1})}function mi(){return x({queryKey:U.config,queryFn:({signal:e})=>Me({signal:e})})}function hi(){return x({queryKey:U.worktrees,queryFn:({signal:e})=>h({signal:e})})}function gi(e){return x({queryKey:[e,`worktrees`],queryFn:({signal:t})=>h({signal:t},e),staleTime:0})}function _i(e,t=!0,n=!1){return x({queryKey:[F({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>kt({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ne(e.sidebarLimits)},enabled:t})}function vi(){return _i(n())}function yi(){return x({queryKey:U.agentConfig,queryFn:({signal:e})=>Ue({signal:e})})}function bi(e){return x({queryKey:U.agentConfigFile(e??``),queryFn:({signal:t})=>ht(e,{signal:t}),enabled:e!==null})}function xi(){return x({queryKey:U.sessionContext,queryFn:({signal:e})=>d({signal:e})})}function Si(e,t,n=``){return x({queryKey:U.sessionContextPreview(e,t,n),queryFn:({signal:n})=>it({content:e,role:t},{signal:n}),placeholderData:At,staleTime:0,retry:!1})}function Ci(){let e=b();return P({onMutate:()=>({fileKey:U.sessionContext}),mutationFn:e=>de(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function wi(e){let t=b(),n=U.agentConfig,r=U.agentConfigFile(e);return P({mutationFn:t=>tt(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var Ti=A([`passing`,`failing`,`pending`]).nullable(),Q=S({kind:A([`issue`,`pr`]),number:j(),title:O(),author:O(),createdAt:O(),labels:E(O()),body:O().optional(),url:O(),comments:j(),assignees:E(O()).optional(),projectIds:E(O()).optional(),isDraft:D().optional(),additions:j().optional(),deletions:j().optional(),checks:Ti.optional()});C(`available`,[S({available:T(!0),item:Q.nullable(),labelColors:w(O(),O()).optional()}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),number:Bt().int().positive().safe()});var Ei=S({id:O(),title:O(),url:O()});S({available:D(),reason:O().optional(),repo:O().optional(),syncedAt:O().optional(),issues:E(Q),prs:E(Q),labelColors:w(O(),O()).optional(),viewerLogin:O().optional(),projects:E(Ei).optional(),projectsReason:O().optional(),projectsState:A([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:O().optional(),issuesTotal:j().int().nonnegative().optional(),prsTotal:j().int().nonnegative().optional(),issuesNextCursor:O().nullable().optional(),prsNextCursor:O().nullable().optional(),commentsDeferred:T(!0).optional()});var Di=O().min(1).max(2e3).optional();S({limit:O().optional(),refresh:O().optional(),issuesCursor:Di,prsCursor:Di,issuesDone:T(`1`).optional(),prsDone:T(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),S({kind:A([`issue`,`pr`]),numbers:O().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:T(`1`).optional()}),C(`available`,[S({available:T(!0),counts:w(j(),j().int().nonnegative())}),S({available:T(!1),reason:O()})]),C(`available`,[S({available:T(!0),checks:w(j(),Ti)}),S({available:T(!1),reason:O()})]),S({kind:A([`issue`,`pr`]),q:O().trim().min(1).max(256),limit:Bt().int().positive().max(50).optional()}),S({available:D(),projectsReason:O().optional(),reason:O().optional(),items:E(Q),truncated:D().optional(),labelColors:w(O(),O()).optional()});var Oi=j().nullable();C(`available`,[S({available:T(!0),prs:w(j(),Xe),issues:w(j(),Xe),conflicts:E(j()).optional(),recheckAfterMs:Oi}),S({available:T(!1),reason:O(),recheckAfterMs:Oi})]);var ki=S({id:j(),author:O(),avatarUrl:O().optional(),createdAt:O(),body:O(),kind:A([`comment`,`review`]),reviewState:A([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:O()}),Ai=A([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ji=S({id:O(),kind:Ai,actor:O(),avatarUrl:O().optional(),createdAt:O(),url:O().optional(),sha:O().optional(),message:O().optional(),checks:Ti.optional(),label:S({name:O(),color:O().optional()}).optional(),subject:O().optional(),refNumber:j().optional(),refTitle:O().optional(),refIsPr:D().optional()});S({available:D(),reason:O().optional(),comments:E(ki),truncated:D().optional(),events:E(ji).optional(),detail:S({body:O(),additions:j().int().nonnegative().optional(),deletions:j().int().nonnegative().optional()}).optional()});var Mi=A([`merge`,`squash`,`rebase`]),Ni=S({name:O(),state:A([`passing`,`failing`,`pending`,`unknown`]),required:D().nullable(),url:O().optional()}),Pi=S({number:j(),title:O(),url:O(),state:A([`open`,`closed`,`merged`]),isDraft:D(),headRef:O(),baseRef:O(),headSha:O(),mergeable:A([`mergeable`,`conflicting`,`unknown`]),reviewDecision:A([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:E(Ni),methods:E(Mi),defaultMethod:Mi.nullable(),eligibility:A([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:E(S({code:O(),message:O()})),canMerge:D(),canOverride:D()});C(`available`,[S({available:T(!0),mergeState:Pi}),S({available:T(!1),reason:O()})]),S({merged:T(!0),number:j(),url:O(),method:Mi,mergeCommitSha:O().optional()});var Fi=S({path:O(),previousPath:O().optional(),status:A([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:j(),deletions:j(),patch:O().optional(),patchUnavailableReason:A([`binary`,`too-large`,`not-provided`]).optional(),truncated:D().optional()});C(`available`,[S({available:T(!0),number:j(),headSha:O(),files:E(Fi),additions:j(),deletions:j(),truncated:D(),reason:O().optional()}),S({available:T(!1),reason:O()})]),S({generation:O().uuid()}),C(`state`,[S({generation:O().uuid(),state:T(`ready`),projects:E(Ei),membership:w(O(),E(O()))}),S({generation:O().uuid(),state:T(`unavailable`),reason:O()})]);function Ii(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function Li(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Ri(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function zi(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Ri(t.issues,a,r),Ri(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var $=e=>e.map(e=>e.number).join(`,`);function Bi(e,t){let n=e[0];if(e.length>1&&n&&($(n.issues)!==$(t.issues)||$(n.prs)!==$(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}function Vi(e={},t=!0){let r=b(),i=U.github(e);o(`/api/v1/p/${n()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,a(t?6e4:!1));let s=x({queryKey:U.github(e),queryFn:({signal:t})=>Se({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),c=s.data?.projectsGeneration,l=x({queryKey:[...i,`projects`,c],queryFn:({signal:e})=>ie(c,{signal:e}),enabled:t&&s.data?.projectsState===`refreshing`&&!!c,staleTime:1/0,retry:!1});return(0,M.useEffect)(()=>{!c||!l.data&&!l.error||r.setQueryData(i,e=>{if(!e||e.projectsGeneration!==c||e.projectsState!==`refreshing`)return e;let t=l.data;return t?.generation&&t.generation!==c?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[r,c,l.data,l.error,i]),s}var Hi=class extends Error{};function Ui(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await Se({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Hi(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Ii(e),retry:(e,t)=>!(t instanceof Hi)&&!(t instanceof fe&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Wi(e=50,t=!0){let r=b(),i=U.githubPages(e),s=U.githubPagesHead(e);o(`/api/v1/p/${n()}/github?limit=${e}`,s,a(t?6e4:!1));let c=Ht({...Ui(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),l=x({queryKey:s,queryFn:({signal:t})=>Se({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:u}=c;(0,M.useEffect)(()=>{if(!l.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=Bi(e.pages,l.data);t===`refetch`?u():r.setQueryData(i,{...e,pages:t})},[r,l.dataUpdatedAt,u]);let d=(c.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),f=N({queries:d.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ie(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,M.useEffect)(()=>{f.forEach((e,t)=>{let n=d[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,f.map((e,t)=>e.data||e.error?d[t]:``).join(`,`)]),{pages:c,data:(0,M.useMemo)(()=>zi(c.data?.pages??[]),[c.data])}}function Gi(e,t=50,n=!0){let r=Ht({...Ui([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,M.useMemo)(()=>zi(r.data?.pages??[]),[r.data])}}function Ki(e,t,n=!0){let r=N({queries:t.filter(e=>e.length>0).map(t=>({queryKey:U.githubCommentCounts(e,t),queryFn:({signal:n})=>be(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,M.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function qi(e,t,n,r=!0){return x({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>De(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Ji(e,t=!0){return x({queryKey:U.githubChecks(e),queryFn:({signal:t})=>y(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Yi(e,t,n=!0){return x({queryKey:U.githubSearch(e,t),queryFn:({signal:n})=>De(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Xi=100;function Zi(e){return[...e].sort((e,t)=>t-e).slice(0,Xi).sort((e,t)=>e-t)}function Qi(){let e=vt(),t=K();return e.projectId??t.data?.bootProject}function $i(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))Ln(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))Ln(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var ea=5*6e4;function ta(e){return e?e.recheckAfterMs:ea}function na(e,t=!0){let n=(0,M.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:Zi(t.prs),issues:Zi(t.issues)}))},[e.map(H).sort().join(`|`)]),r=N({queries:n.map(e=>({queryKey:U.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>ke(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:ta(r[t]?.data)??!1})));(0,M.useEffect)(()=>{if(!t||i())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=U.githubRefStatus(t.projectId,t.prs,t.issues);return l({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,M.useMemo)(()=>qn(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,M.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=B.get(t);return{state:`idle`,...r?{status:r}:{},...V.has(t)?{conflicting:!0}:{}}},[s])}function ra(e,t,n=!0){return x({queryKey:U.githubComments(e,t),queryFn:({signal:n})=>we(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ia(e,t,n=!0){return x({queryKey:U.githubItem(e,t),queryFn:({signal:n})=>_(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function aa(e){return x({queryKey:U.githubPrChanges(e??0),queryFn:({signal:t})=>oe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Vr as $,N as $t,ci as A,hr as At,Wr as B,U as Bt,li as C,vr as Ct,xi as D,ir as Dt,pi as E,mr as Et,qr as F,Tr as Ft,ei as G,Cn as Gt,ni as H,jn as Ht,Qr as I,wr as It,si as J,Xt as Jt,ri as K,L as Kt,ai as L,Yn as Lt,Pr as M,pr as Mt,Gr as N,ar as Nt,Si as O,ur as Ot,Kr as P,lr as Pt,Jr as Q,P as Qt,Lr as R,Xn as Rt,Ci as S,Qn as St,fi as T,rr as Tt,$r as U,Nn as Ut,ti as V,W as Vt,Mr as W,kn as Wt,Hr as X,F as Xt,zr as Y,Yt,Yr as Z,I as Zt,mi as _,xr as _t,ra as a,Fr as at,gi as b,Cr as bt,aa as c,Z as ct,qi as d,yr as dt,Ut as en,Ur as et,Qi as f,_r as ft,bi as g,nr as gt,yi as h,cr as ht,Ki as i,Ir as it,hi as j,dr as jt,vi as k,er as kt,Yi as l,gr as lt,Li as m,br as mt,Vi as n,Rr as nt,ia as o,ii as ot,na as p,fr as pt,Br as q,Qt as qt,Ji as r,Nr as rt,Wi as s,Zr as st,$i as t,Xr as tt,Gi as u,Er as ut,ui as v,K as vt,di as w,$n as wt,wi as x,tr as xt,_i as y,Sr as yt,oi as z,Jn as zt};
|
|
@@ -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{n as r,t as i}from"./utils-DSMR_WLb.js";import{Ht as a,Ut as o,p as s}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{n as r,t as i}from"./utils-DSMR_WLb.js";import{Ht as a,Ut as o,p as s}from"./queries-DZhNVAD_.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-BNFYIwtc.js";import{F as u,H as d,M as f,N as p,P as m,f as h,g,h as _,m as v,ot as y,p as b}from"./design-icons-CzEoMH9c.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-BPgUYFyu.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agent defaults`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function D(e,t=` → `){return E[e].join(t)}var O=e(t(),1),k=n(),A=(0,O.createContext)(null);function j({children:e}){let[t,n]=(0,O.useState)(()=>new Map),r=(0,O.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,O.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=s((0,O.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,O.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,k.jsx)(A.Provider,{value:o,children:e})}var M=(0,O.createContext)(null);function ee({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,O.useContext)(A),a=(0,O.useContext)(M),o=(0,O.useId)();(0,O.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=s(i?N:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,O.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,k.jsx)(M.Provider,{value:d,children:r})}var N=[];function P(e,t,n){let r=(0,O.useContext)(M),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function F(e,t){let n=(0,O.useContext)(M),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function I(){let e=(0,O.useContext)(M);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),ne={success:`border-success/40 text-success`,danger:`border-danger/40 text-danger`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-pending-strong`,conflict:`border-conflict/45 text-conflict`},L={success:`text-success`,danger:`text-danger`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-info`,neutral:`text-soft-foreground`,pending:`text-pending-strong`,conflict:`text-conflict`},re={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},R={draft:m,"review-required":u,"changes-requested":d,"checks-pending":null,"checks-failing":g,ready:h,merged:f,closed:p,open:b,completed:h,"not-planned":_};function z(e){return e===`PR`?`pr-chip`:`issue-chip`}function B(e){return e?{"data-conflicting":`true`}:{}}function V(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function H(e,t,n){return e===`PR`&&(t??n)===!0}function U({plain:e,inert:t,conflicting:n,className:r,tone:a}){return e?i(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):i(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,ne[a],r)}function W(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function G(e){return e===`PR`?`pull request`:`issue`}function K(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function q(e,t){return e&&t?L[t.tone]:void 0}function J(e,t){return!e&&(!t||!r(t))}function Y({conflicting:e,presentation:t,status:n,plain:r,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,k.jsxs)(k.Fragment,{children:[e?(0,k.jsx)(y,{className:i(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,k.jsx)($,{status:t?n:void 0,className:r?i(`size-2.5`,l):void 0}),r&&a?s===`PR`?(0,k.jsx)(u,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,k.jsx)(b,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,k.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function ie({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,k.jsx)(`span`,{"data-slot":z(e),"data-status":t,"data-inert":`true`,...B(n),className:r,children:i})}function ae({kind:e,number:t,tooltip:n,url:i}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,k.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,k.jsx)(`span`,{className:`block opacity-70`,children:n.also}):null,i&&r(i)?(0,k.jsx)(`span`,{className:`block opacity-70`,children:i.replace(/^https?:\/\//,``)}):null]})}function oe({reference:e,taskTitle:t,status:n,conflicting:r,conflictAction:s,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=I(),y=P(h,V(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=o(b),S=H(h,r,y.conflicting),C=S?a:x,w=C?.tone??`accent`,T=U({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=ue(y,C,S?x:void 0),D=W(h,g,p,f),O=G(h),A=K(O,g,t,C),j=(0,k.jsx)(Y,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:D,glyphClass:q(p,C)});if(m)return(0,k.jsx)(ie,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=J(u,_)?(0,k.jsx)(`span`,{"data-slot":z(h),"data-status":b,...B(S),"aria-label":C?`${O} ${D} — ${C.label}`:void 0,className:T,children:j}):(0,k.jsx)(se,{to:u,url:_,"data-slot":z(h),"data-status":b,...B(S),title:E?void 0:_,"aria-label":A,className:p?T:i(T,re[w]),children:j});return E?(0,k.jsx)(le,{chip:M,action:S?s:void 0,state:y.state,children:(0,k.jsx)(ae,{kind:h,number:g,tooltip:E,url:_})}):M}function se({to:e,url:t,children:n,...r}){return e?(0,k.jsx)(c,{to:e,...r,children:n}):(0,k.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,O.createContext)(()=>{});function ce(){return(0,O.useContext)(X)}var Z=150,Q=120;function le({chip:e,action:t,state:n,children:r}){let[i,a]=(0,O.useState)(!1),o=(0,O.useRef)(null),s=(0,O.useRef)(null),c=(0,O.useRef)(void 0),l=(0,O.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,O.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,O.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,k.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,k.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,Z)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,k.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Q)},children:[(0,k.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,k.jsx)(X.Provider,{value:u,children:t}):null]})]})}function ue(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${de(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function de(e){return e.charAt(0).toLowerCase()+e.slice(1)}function fe({kind:e,number:t,className:n}){let r=P(e,t),s=o(r.status),c=e===`PR`&&r.conflicting===!0,l=c?a:s;if(!l)return null;let u=i(`size-2.5`,L[l.tone]);return(0,k.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":r.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:i(`inline-flex items-center`,n),children:c?(0,k.jsx)(y,{className:i(`shrink-0`,u),"aria-hidden":`true`}):(0,k.jsx)($,{status:r.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,k.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:i(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=R[e];return n?(0,k.jsx)(n,{className:i(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{j as a,P as c,ee as i,D as l,fe as n,F as o,ce as r,I as s,oe as t,T as u};
|
package/web/dist/assets/{remote-settings-notice-COojb6XK.js → remote-settings-notice-GNs7i0kP.js}
RENAMED
|
@@ -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{pi as r}from"./project-scope-context-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{pi as r}from"./project-scope-context-DIcqj4jJ.js";import{Bt as i,Vt as a,vt as o}from"./queries-DZhNVAD_.js";import{gn as s}from"./index-CGdnowj-.js";var c=e(t(),1),l=n();function u(){let e=r(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:a.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return o().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,n as i,t as a}from"./utils-DSMR_WLb.js";import{F as o,I as s,Nn as c,Pt as l,ot as u,pi as d,s as f,u as p}from"./project-scope-context-DIcqj4jJ.js";import{Z as m}from"./live-protocol-DMhTnCmf.js";import{n as h}from"./toaster-0sM0sfWx.js";import{Bt as g,C as _,E as v,Qt as y,T as b,Ut as x,W as S,bt as C,j as ee,n as w,rt as T,vt as te,w as E}from"./queries-DZhNVAD_.js";import{g as ne,h as re}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as D}from"./tasks-table-BNFYIwtc.js";import{A as O,C as k,E as ie,F as ae,J as oe,M as se,X as ce,Y as le,at as ue,j as de,n as fe,ot as A,s as pe,u as me,v as he,x as ge}from"./design-icons-CzEoMH9c.js";import{t as _e}from"./createLucideIcon-BHp8sXmF.js";import{n as ve,t as ye}from"./circle-x-7nTlobAF.js";import{_ as be}from"./nav-row-styles-DKeXbc4N.js";import{i as xe,r as Se,t as Ce}from"./git-toolbar-Dc_o1nrh.js";import{t as j}from"./info-DA1x_4bz.js";import{t as we}from"./loader-circle-CPBhhDbB.js";import{n as Te,r as Ee}from"./diff-controls-CmYvdEGt.js";import{c as De,i as Oe,l as ke,t as Ae}from"./reference-chip-DSJSqjmO.js";import{t as M}from"./button-B7MKxYjT.js";import{i as N,l as je,p as Me,r as Ne,t as Pe}from"./dropdown-menu-4e2iKSMT.js";import{t as P}from"./project-router-CZ89wg-5.js";import{t as Fe}from"./status-dot-BRzVlF2X.js";import{a as F,o as Ie}from"./format-BU7D3IfE.js";import{d as Le,n as Re,o as I,s as ze,t as Be,u as Ve}from"./page-shell-7pLJMOgh.js";import{t as L}from"./centered-state-V15AR_qo.js";import{At as He,Bt as Ue,Cn as We,D as R,E as Ge,Ft as Ke,Gt as z,Ht as B,It as V,Jn as H,Jt as U,Kt as W,Lt as qe,Mt as Je,Nt as Ye,Ot as Xe,Pt as Ze,Rt as Qe,Tn as $e,Ut as G,Vt as et,Wt as K,Yt as q,cr as tt,en as J,jt as nt,kt as rt,qt as Y,tr as it,ur as at,wn as ot,zt as st}from"./index-CGdnowj-.js";import{t as ct}from"./markdown-BBDDg-4t.js";import{t as lt}from"./diff-D55N_7Ul.js";import{t as ut}from"./change-counts-CW7O8g5Y.js";import{n as dt,r as ft}from"./commit-list-Cd14tNSj.js";var X=e(t(),1);function pt(e,t){let n=d(t),r=n.getQueryCache();return X.useSyncExternalStore(X.useCallback(e=>r.subscribe(m.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var mt=_e(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),ht=_e(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Z=n();function gt(){let e=r(),t=_(),n=d(),i=pt({queryKey:g.repo})>0,o=t.data?.info?t.data:null,s=Xe(e,o,`screen`);return(0,Z.jsx)(Ve,{route:`repo-git`,density:o?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,Z.jsx)(ze,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:i,onClick:()=>{n.invalidateQueries({queryKey:g.repo}),n.invalidateQueries({queryKey:g.worktrees})},children:(0,Z.jsx)(le,{size:17,"aria-hidden":`true`,className:a(`size-[17px]`,i&&`motion-safe:animate-spin`)})})},children:(0,Z.jsxs)(`div`,{"data-slot":`git-screen`,children:[o?.info?(0,Z.jsx)(`div`,{className:`mb-[16px]`,children:(0,Z.jsx)(nt,{scope:e,repo:o,info:o.info,variant:`screen`},e)}):t.isPending?(0,Z.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,Z.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,Z.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,Z.jsx)(rt,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})})}function _t({entry:e}){return e.keptReason?(0,Z.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function vt({repo:e,info:t}){let n=r(),i=[n,`repo`],o=[n,`health`],s=te(),c=E(),l=new Map((c.data?.branches??[]).map(e=>[e.name,e])),u=d(),p=y({mutationFn:e=>f({name:e},n),onSuccess:async e=>{h(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([u.invalidateQueries({queryKey:i}),u.invalidateQueries({queryKey:o})]),u.setQueryData(i,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),u.setQueryData(o,t=>Ye(t,n,e.branch))},onError:e=>h(e.message,{tone:`danger`})}),[m,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(``),b=_.trim().toLowerCase(),x=Q(e,c.data?.branches),S=b?x.filter(e=>e.toLowerCase().includes(b)):x;return(0,Z.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 md:grid-cols-[minmax(0,1fr)_290px]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,Z.jsxs)(`label`,{className:`relative block`,children:[(0,Z.jsx)(ce,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,Z.jsx)(H,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:_,onChange:e=>v(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,Z.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[S.map(e=>{let n=e===t.branch,r=l.get(e);return(0,Z.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":r?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[r?.runId?(0,Z.jsx)(P,{to:`/tasks/${r.runId}`,"data-slot":`branch-task-link`,title:r.title?`Open the task ${r.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,Z.jsx)(`span`,{className:a(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),r&&!(n&&r.class===`active`)?(0,Z.jsx)(Ct,{entry:r}):null]}),r?(0,Z.jsx)(_t,{entry:r}):null,e.startsWith(`cez/`)&&!n?null:n?(0,Z.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,Z.jsxs)(M,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:p.isPending,onClick:()=>p.mutate(e),children:[(0,Z.jsx)(O,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),S.length===0?(0,Z.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,_.trim(),`”.`]}):null]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,Z.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-5 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=m.trim();t&&p.mutate(t,{onSuccess:()=>g(``)})},children:[(0,Z.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,Z.jsxs)(`p`,{"data-slot":`branch-create-base`,className:`-mt-1 text-xs text-muted-foreground`,children:[`Create from `,(0,Z.jsx)(`span`,{className:`font-mono text-[11px] text-foreground`,children:t.branch}),`.`]}),(0,Z.jsx)(H,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background placeholder:text-muted-foreground/70`,value:m,onChange:e=>g(e.target.value)}),(0,Z.jsxs)(M,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!m.trim()||p.isPending,children:[(0,Z.jsx)(oe,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,Z.jsx)(`p`,{"data-slot":`branch-create-note`,className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),s.data?.forge?.available?(0,Z.jsx)(yt,{}):null]})}function yt(){let e=w({limit:20});return(0,Z.jsxs)(`div`,{"data-slot":`repo-prs`,className:`min-w-0 rounded-xl border border-border bg-card p-5 md:col-span-2`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold`,children:`Open pull requests`}),e.isPending?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Loading pull requests…`}):e.isError?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`No open pull requests.`}):(0,Z.jsx)(`ul`,{className:`mt-3 flex flex-col divide-y divide-border border-t border-border`,children:e.data.prs.map(e=>(0,Z.jsx)(bt,{pr:e},e.number))}):(0,Z.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-3 text-xs text-muted-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function bt({pr:e}){let t=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ae,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,Z.jsx)(xt,{checks:e.checks}):null]}),n=`flex min-h-11 min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,Z.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:i(e.url)?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:a(n,`hover:bg-muted`),children:t}):(0,Z.jsx)(`span`,{className:n,children:t})})}function xt({checks:e}){let t=e===`passing`?ve:e===`failing`?ye:tt;return(0,Z.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:a(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,Z.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var St={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Ct({entry:e}){return(0,Z.jsx)(`span`,{"data-slot":`branch-class`,className:a(`shrink-0 rounded-[4px] border px-1.5 py-px text-[11px] leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:St[e.class]})}function Q(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function wt(){let e=b(),t=J(),[n,r]=(0,X.useState)(`unified`),[i,a]=(0,X.useState)(!0),[o,s]=(0,X.useState)(!1),[l,u]=(0,X.useState)(null),d=(0,X.useRef)(null),f=e.isError&&e.error instanceof c&&e.error.status===409,p=e.data?.files??[],m=(0,X.useMemo)(()=>Se(p),[p]),h=(0,X.useMemo)(()=>p.some(ct),[p]),g=t?n:`unified`;return(0,Z.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,Z.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,Z.jsx)(L,{icon:f?(0,Z.jsx)(k,{size:16}):(0,Z.jsx)(A,{size:16}),tone:f?`neutral`:`danger`,heading:`h2`,title:f?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):p.length===0?(0,Z.jsx)(L,{icon:(0,Z.jsx)(k,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,Z.jsx)(Ce,{stat:e.data.stat}):null,(0,Z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h?(0,Z.jsx)(Ee,{preview:o,onPreviewChange:s}):null,(0,Z.jsx)(`span`,{className:`flex items-center gap-1.5`,children:(0,Z.jsx)(Te,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 [--diff-sticky-top:1rem] md:flex-row md:items-start`,children:[(0,Z.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[288px]`,children:[(0,Z.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,Z.jsx)(xe,{root:m,selected:l,onSelect:e=>{u(e),d.current?.scrollToPath(e)}})]}),(0,Z.jsx)(lt,{files:p,viewRef:d,mode:g,wrap:i,preview:o,totals:!1,className:`min-w-0 flex-1`})]})]})})}function Tt({repo:e,info:t}){let{sha:n}=re(),r=e.log,i=(0,X.useMemo)(()=>et(r),[r]);if(n)return(0,Z.jsx)(Ot,{sha:n});let a=qe(e,t),o=a&&a.behind>0?(0,Z.jsx)(Dt,{info:t,tracking:a}):null;return r.length===0?(0,Z.jsxs)(Z.Fragment,{children:[o?(0,Z.jsx)(`div`,{children:o}):null,(0,Z.jsx)(L,{icon:(0,Z.jsx)(de,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]}):(0,Z.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[o,i.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-h-[52px] items-center gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsxs)(P,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Z.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,Z.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(dt,{sha:e.hash}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,Z.jsx)(`span`,{title:Ue(e.when,e.at),children:st(e.when,e.at)})]})]})]}),(0,Z.jsx)(Et,{source:e.source})]},e.hash))})]},e.label))]})}function Et({source:e}){let t=`hidden max-w-[45%] shrink-0 items-center gap-[5px] pr-4 text-[11.5px] text-muted-foreground md:flex`;return e?(0,Z.jsxs)(P,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:a(t,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(se,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,Z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,Z.jsx)(pe,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,Z.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:t,children:`no task found`})}function Dt({info:e,tracking:t}){let n=Ze(r(),e),i=(0,X.useRef)(null);return(0,Z.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,Z.jsx)(mt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,Z.jsxs)(`button`,{ref:i,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,Z.jsx)(we,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Z.jsx)(fe,{"aria-hidden":`true`}),`Pull`]}),(0,Z.jsx)(Je,{checkout:n,returnFocus:i})]})}function Ot({sha:e}){return(0,Z.jsx)(ft,{commit:v(e),sha:e,backTo:J()?`/git`:Ke,backLabel:`All recent commits`,slot:`repo-commit`,className:`flex min-h-0 flex-1 flex-col`,diffClassName:`px-4 py-4 [--diff-sticky-top:1rem] md:px-9`})}var kt=`Squash-merged branches may show as not landed without GitHub`;function At(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function jt(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}var Mt={done:`success`,failed:`danger`,cancelled:`neutral`};function Nt(){let e=E(),t=T(),n=r(),i=C(),[a,o]=(0,X.useState)(null);if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,Z.jsx)(L,{icon:(0,Z.jsx)(A,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=At(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=jt(e.data.branches),u=l>0?(0,Z.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,Z.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,Z.jsx)(P,{to:V.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,d=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,Z.jsxs)(Oe,{projectId:n,repoBase:i,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,Z.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,Z.jsx)(Pt,{}),u,s.length===0?(0,Z.jsx)(Be,{icon:(0,Z.jsx)(it,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(P,{to:V.cleanup,children:`Check cleanup`})}),(0,Z.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(P,{to:`/`,children:`View tasks`})})]})}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,Z.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,Z.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,Z.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{}),(0,Z.jsx)(`span`,{children:e.note})]}):null]}),(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,Z.jsx)(Ft,{entry:e,finishedAt:e.runId?d.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,Z.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,Z.jsx)(j,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,Z.jsx)(Re,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,Z.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,Z.jsx)(P,{to:V.cleanup,children:`Open cleanup`})})}):null]})]}),(0,Z.jsx)(Bt,{entry:a,onClose:()=>o(null)})]})}function Pt({className:e}){return(0,Z.jsxs)(`p`,{"data-slot":`git-no-forge`,className:a(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,Z.jsx)(j,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),kt,`.`]})}function Ft({entry:e,finishedAt:t,onDelete:n}){return(0,Z.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,Z.jsx)(Rt,{entry:e,finishedAt:t}),(0,Z.jsx)(It,{entry:e}),(0,Z.jsx)(Lt,{entry:e,onDelete:n})]})}function It({entry:e}){return(0,Z.jsx)(Z.Fragment,{children:e.pr?(0,Z.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,Z.jsx)(Ae,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,Z.jsx)(zt,{entry:e})]}):null})}function Lt({entry:e,onDelete:t}){let n=d(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=y({mutationFn:()=>u(e.runId),onSuccess:e=>{h(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:g.repoBranches}),n.invalidateQueries({queryKey:g.runs.all})},onError:e=>h(e instanceof c&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),l=()=>void navigator.clipboard.writeText(e.name).then(()=>h(`Copied ${e.name}`),()=>h(`Could not copy the branch name`,{tone:`danger`})),f=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,Z.jsxs)(Z.Fragment,{children:[e.runId?(0,Z.jsx)(P,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:a(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:a(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Z.jsx)(ht,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,Z.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,onClick:l,className:a(f,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,Z.jsx)(he,{"aria-hidden":`true`}),`Copy branch`]}):null,(0,Z.jsxs)(Pe,{children:[(0,Z.jsx)(Me,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,Z.jsx)(ge,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,Z.jsxs)(Ne,{align:`end`,className:`w-52`,children:[e.runId?(0,Z.jsx)(N,{asChild:!0,className:`md:hidden`,children:(0,Z.jsx)(P,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,Z.jsx)(N,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,Z.jsx)(N,{className:a(!r&&`md:hidden`),onSelect:l,children:`Copy branch`}),(0,Z.jsx)(je,{className:`md:hidden`}),(0,Z.jsx)(N,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function Rt({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=F(i),o=n||!e.runStatus?a:`${e.runStatus}${a?` ${a}`:``}`,s=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,Z.jsx)(be,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,Z.jsx)(Fe,{tone:e.runStatus&&Mt[e.runStatus]||`neutral`,"aria-label":e.runStatus??void 0})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,Z.jsx)(P,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,Z.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,Z.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,Z.jsx)($,{}),(0,Z.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{}),(0,Z.jsx)(ut,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{}),(0,Z.jsx)(`span`,{className:`truncate`,title:s,children:o})]}):null]}),e.parentRunId?(0,Z.jsx)(P,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,Z.jsx)(_t,{entry:e})]})]})}function $(){return(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function zt({entry:e}){let t=x(De(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{}),(0,Z.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function Bt({entry:e,onClose:t}){let n=d(),[r,i]=(0,X.useState)(``),a=(0,X.useId)(),o=y({mutationFn:e=>p({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;h(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:g.repo}),s()},onError:e=>h(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,Z.jsx)(B,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,Z.jsxs)(z,{"data-slot":`delete-branch-dialog`,children:[(0,Z.jsxs)(U,{children:[(0,Z.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,Z.jsx)(W,{asChild:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,Z.jsxs)(Z.Fragment,{children:[`This drops the work of `,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,Z.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,Z.jsxs)(Z.Fragment,{children:[` (`,(0,Z.jsx)($e,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,Z.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,Z.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,Z.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,Z.jsx)(H,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(K,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,Z.jsx)(G,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function Vt({base:e}){let t=E(),n=d(),[r,i]=(0,X.useState)({merged:!1,empty:!1}),[a,o]=(0,X.useState)(!1),s=(t.data?.branches??[]).filter(e=>e.class===`merged`),c=(t.data?.branches??[]).filter(e=>e.class===`empty`),l=[...s,...c],u=y({mutationFn:e=>p({names:e}),onSuccess:e=>{let t=e.refused.length;h(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:g.repo})},onError:e=>{n.invalidateQueries({queryKey:g.repo}),h(e.message,{tone:`danger`})}});if(t.isPending)return(0,Z.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,Z.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let f=l.length,m=`branch${f===1?``:`es`}`;return(0,Z.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,f]}),(0,Z.jsxs)(`p`,{className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:f===0||u.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(ue,{"aria-hidden":`true`,className:`size-[12px]`}),u.isPending?`Deleting…`:`Delete ${f} ${m}`]})]}),(0,Z.jsx)(Ht,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:kt.toLowerCase(),rows:s,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,Z.jsx)(Ht,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:c,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,Z.jsx)(B,{open:a,onOpenChange:o,children:(0,Z.jsxs)(z,{children:[(0,Z.jsxs)(U,{children:[(0,Z.jsxs)(q,{children:[`Delete `,f,` `,m,`?`]}),(0,Z.jsxs)(W,{children:[s.length,` merged into `,e,` and `,c.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(K,{children:`Keep them`}),(0,Z.jsxs)(G,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{u.mutate(l.map(e=>e.name)),o(!1)},children:[`Delete `,f,` `,m]})]})]})})]})}function Ht({kind:e,title:t,hint:n,rows:r,open:i,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,Z.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":s,disabled:r.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,Z.jsx)(`span`,{className:`truncate text-[11px] text-soft-foreground`,children:n})]}),r.length>0?(0,Z.jsx)(me,{"aria-hidden":`true`,className:a(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,Z.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,Z.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-[11.5px]`,children:[(0,Z.jsx)(We,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,Z.jsx)(P,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,Z.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,Z.jsx)(ot,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function Ut(){let e=ee(),t=S().data?.targets.find(e=>e.id===`finder`),n=y({mutationFn:e=>l(e,t.id),onError:e=>h(e.message,{tone:`danger`})}),r=d(),[i,a]=(0,X.useState)(!1),c=()=>Promise.all([r.invalidateQueries({queryKey:g.worktrees}),r.invalidateQueries({queryKey:g.repoBranches})]),u=y({mutationFn:e=>s(),onSuccess:(e,t)=>{c();let n=e.reclaimed.length,r=Math.max(0,t-n);h(n===0?r>0?`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Nothing to reclaim — no finished worktrees exceed the keep limit`:`Reclaimed ${n} worktree${n===1?``:`s`} (branch kept)${r>0?` · ${r} kept: uncommitted work or in use`:``}`)},onError:e=>h(e.message,{tone:`danger`})}),f=y({mutationFn:e=>o(e.runId),onSuccess:(e,t)=>{c(),h(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{c(),h(e.message,{tone:`danger`})}});if(e.isPending)return(0,Z.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,Z.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:p,totalBytes:m,keep:_}=e.data,v=u.isPending||f.isPending,b=p.filter(e=>e.pastKeep),x=b.length>0,C=b.some(e=>e.sizeBytes===null)?null:b.reduce((e,t)=>e+(t.sizeBytes??0),0),w=x?C?`Reclaim ${D(C)} now`:`Reclaim ${b.length} now`:`Reclaim now`,T=m?D(m):null;return(0,Z.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,T?` · ${T}`:``]}),(0,Z.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-[11.5px] leading-[17px] text-soft-foreground`,children:[_===0?`Retention is unlimited (`:`Retention keeps the newest ${_} finished checkout${_===1?``:`s`} (`,(0,Z.jsx)(P,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:ke(`worktrees`,` › `)}),_===0?`), so nothing is reclaimed on its own.`:`) and reclaims the rest.`,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,Z.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:v||!x,title:x?void 0:`Nothing past the keep limit to reclaim`,onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,Z.jsx)(at,{"aria-hidden":`true`,className:`size-[12px]`}),w]})]}),p.length===0?(0,Z.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,Z.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:p.map(e=>(0,Z.jsx)(Kt,{worktree:e,keep:_,disabled:v,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>f.mutate(e)},e.runId))}),(0,Z.jsx)(B,{open:i,onOpenChange:a,children:(0,Z.jsxs)(z,{children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(q,{children:`Reclaim old worktrees?`}),(0,Z.jsxs)(W,{children:[b.length,` finished worktree`,b.length===1?``:`s`,` beyond the keep limit`,C?` (${D(C)})`:``,` `,b.length===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,Z.jsxs)(Y,{children:[(0,Z.jsx)(K,{children:`Keep them`}),(0,Z.jsx)(G,{"data-action":`worktrees-confirm`,onClick:()=>{u.mutate(b.length),a(!1)},children:w})]})]})})]})}var Wt=new Set([`queued`,`running`,`waiting`,`review`]);function Gt(e,t){return Wt.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`}:e.pastKeep?{label:`reclaimable`,tone:`plain`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`}}function Kt({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:o}){let s=Gt(e,t),c=F(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Ie(c)}`:e.status,u=(0,Z.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.tone===`in-use`?`in-use`:e.pastKeep?`reclaimable`:`kept`,className:a(`text-[11.5px]`,s.tone===`in-use`?`text-status-running`:`text-soft-foreground`),children:s.label}),d=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`;return(0,Z.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-[11px] text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,Z.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,Z.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-[11.5px] tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:D(e.sizeBytes)||`0 kB`}),(0,Z.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:u}),r?(0,Z.jsx)(`button`,{type:`button`,className:d,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,Z.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,Z.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":`Reclaim the worktree of ${e.title} (branch kept)`,title:`Reclaim the directory (branch kept)`,disabled:n,onClick:o,className:d,children:(0,Z.jsx)(at,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function qt(e){return e===`main`||e===`changes`?`Split`:`Table`}function Jt({section:e,index:t=!1}){let n=_(),r=J(),[i]=ne(),a=qt(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,Z.jsx)(gt,{});if(n.isPending)return(0,Z.jsx)(Ge,{});if(n.isError)return(0,Z.jsx)(I,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(R,{}),children:(0,Z.jsx)(L,{icon:(0,Z.jsx)(A,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,Z.jsx)(Yt,{repo:n.data,info:o,section:e}):(0,Z.jsx)(I,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,Z.jsx)(R,{}),children:(0,Z.jsx)(L,{icon:(0,Z.jsx)(O,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function Yt({repo:e,info:t,section:n}){let r=qt(n),i=E(),a=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Q(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,Z.jsx)(I,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:Le(a),rootProps:{"data-git-section":n},beforeHeader:(0,Z.jsx)(R,{}),header:{title:He(n,t.branch),headerSlot:`repo-header`,subtitle:(0,Z.jsx)(Xt,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`},children:n===`main`?(0,Z.jsx)(Tt,{repo:e,info:t}):n===`not-landed`?(0,Z.jsx)(Nt,{}):n===`cleanup`?(0,Z.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,Z.jsx)(Ut,{}),(0,Z.jsx)(Vt,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,Z.jsx)(vt,{repo:e,info:t}):(0,Z.jsx)(wt,{})})}function Xt({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,Z.jsxs)(Z.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${Qe(e.tracking)}`:``]});case`not-landed`:return(0,Z.jsxs)(Z.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,Z.jsx)(Zt,{repo:e,info:t});case`changes`:return(0,Z.jsxs)(Z.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,Z.jsxs)(Z.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Zt({repo:e,info:t}){let n=Q(e,E().data?.branches).length;return(0,Z.jsxs)(Z.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{Jt as RepoGitRoute};
|
|
@@ -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{Nn as r,et as i}from"./project-scope-context-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Nn as r,et as i}from"./project-scope-context-DIcqj4jJ.js";import{B as a,N as o}from"./queries-DZhNVAD_.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ot as p,r as m}from"./design-icons-CzEoMH9c.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-CTPfK-oR.js";import{t as b}from"./button-B7MKxYjT.js";import{t as x}from"./centered-state-V15AR_qo.js";import{_ as S,g as C,h as w}from"./index-CGdnowj-.js";import{r as T}from"./html-report-BX3msvci.js";import{t as E}from"./html-report-frame-uuqkBC0u.js";var D=e(t(),1),O=n();function k(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=A(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function A(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function j(e){return e?.type===`file`?e:null}function M(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function N(){let{id:e=``}=l(),t=M(),n=s(),r=k();return(0,O.jsx)(P,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function P({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=I(e,t,a),f=S(w,!0),p=S(C,!1),m=s(),[h,g]=(0,D.useState)(!1),_=j(d.data);if(i===`route`&&L(_))return(0,O.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=z(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&R(_),x=F(m.pathname,e,t);return(0,O.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,O.jsx)(B,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,O.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,O.jsx)(V,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function F(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function I(e,t,n){let{path:r=null,artifactId:i=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=a(e,i||s||c?null:r),u=o(e,s||c?null:i),d=c&&n?{...n,data:void 0}:i?u:l;return{path:r,conflict:s,selected:r!==null||i!==null,result:d}}function L(e){return e!==null&&(!T(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function R(e){return e!==null&&!e.tooLarge&&!e.binary}function z(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function B({runId:e,file:t,name:n,source:r,onSource:a,onBack:o,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,D.useRef)(null);(0,D.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,O.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,O.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:o,"aria-label":s,children:[(0,O.jsx)(m,{size:18,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,O.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?`Published snapshot · ${new Date(d.createdAt).toLocaleString()}`:`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,O.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:a,children:r?`Preview`:`Source`}):null,d&&!c?(0,O.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:i(e,d.id,`download`),children:`Download`}):null]})}function V({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,O.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,O.jsx)(H,{result:n});let c=n.data;return c.type===`file`?o&&!T(c.path)?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,O.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,O.jsx)(U,{icon:(0,O.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,O.jsx)(U,{icon:(0,O.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,O.jsx)(`div`,{className:`bg-card`,children:(0,O.jsx)(y,{path:c.path,text:c.content??``})}):(0,O.jsx)(E,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,O.jsx)(U,{icon:(0,O.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function H({result:e}){let t=e.error instanceof r&&e.error.status===404;return(0,O.jsx)(U,{icon:t?(0,O.jsx)(v,{}):(0,O.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,O.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function U({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,O.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,O.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{P as ReportReader,N as TaskReportRoute};
|