@wjarka/cezarion 0.18.0-dev.7101 → 0.18.0-dev.7113
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 +2 -2
- package/web/dist/assets/{activity-motion-YVMdTv1H.js → activity-motion-CRjdIuq0.js} +2 -2
- package/web/dist/assets/{activity-route-Bd9LuD0o.js → activity-route-4yon6jwC.js} +1 -1
- package/web/dist/assets/{agent-accounts-DetCQbKD.js → agent-accounts-l_Gn-Dja.js} +1 -1
- package/web/dist/assets/attention-DcMKBngT.js +1 -0
- package/web/dist/assets/{cez-idle-CnPEf2T2.js → cez-idle-BEO5j8ow.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-BY9ItExV.js → commit-diff-panel-Cfnt30Tt.js} +1 -1
- package/web/dist/assets/{diff-nSqnAkNf.js → diff-Dx1bGt0w.js} +2 -2
- package/web/dist/assets/{diff-view-Bp_dyecW.js → diff-view-DJ4iFfkd.js} +1 -1
- package/web/dist/assets/{file-preview-Dkl6S-Ej.js → file-preview-6POBIfS-.js} +1 -1
- package/web/dist/assets/{git-toolbar-xd4qbEj6.js → git-toolbar-DwK9tJOu.js} +1 -1
- package/web/dist/assets/github-shozEZ-Z.js +1 -0
- package/web/dist/assets/{global-activity-route-BMBowNcw.js → global-activity-route-D_JqpAAR.js} +1 -1
- package/web/dist/assets/index-DMq98FV0.js +14 -0
- package/web/dist/assets/{live-protocol-C_Z-JQOy.js → live-protocol-Bn-xWBmZ.js} +1 -1
- package/web/dist/assets/{markdown-CZVLEjwk.js → markdown-fN_tqxh3.js} +1 -1
- package/web/dist/assets/picker-pill-BuYiT3fS.js +15 -0
- package/web/dist/assets/preview-pane-connected-D81HxFOI.js +3 -0
- package/web/dist/assets/{project-router-D5aSJsZ7.js → project-router-C68VktrY.js} +1 -1
- package/web/dist/assets/{project-scope-context-BUXmC8my.js → project-scope-context-Vv8ygMl6.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-De-8v5io.js → prompt-template-menu-hXOsL4ia.js} +1 -1
- package/web/dist/assets/{queries-DkipLnOL.js → queries-Drt3XAiW.js} +1 -1
- package/web/dist/assets/{reference-chip-BVB5YsfP.js → reference-chip-oVw9Lal9.js} +1 -1
- package/web/dist/assets/{repo-git-BdRmck7y.js → repo-git-B295X5Wv.js} +1 -1
- package/web/dist/assets/{report-reader-C8_2WEz6.js → report-reader-HocN04sH.js} +1 -1
- package/web/dist/assets/{reports-DxAL6BCk.js → reports-B1KiT5at.js} +1 -1
- package/web/dist/assets/run-header-DyKGLM8b.js +2 -0
- package/web/dist/assets/{skills-C49LGb-4.js → skills-BRDqkbTt.js} +1 -1
- package/web/dist/assets/{tab-link-BTFjRC1e.js → tab-link-B4u5eY7O.js} +1 -1
- package/web/dist/assets/{task-changes-B0oxkbcW.js → task-changes-Bx8mrihw.js} +1 -1
- package/web/dist/assets/{task-commits-DDZcksfZ.js → task-commits-bARHGfsG.js} +1 -1
- package/web/dist/assets/{task-files-BTj0Ehlx.js → task-files-_SX670LL.js} +1 -1
- package/web/dist/assets/{task-github-item-y1rABsg2.js → task-github-item-Cw8-5BXV.js} +1 -1
- package/web/dist/assets/{task-thread-CaRlk42s.js → task-thread-BAeGEFEe.js} +7 -7
- package/web/dist/assets/{thread-state-BE9onTdO.js → thread-state-BpW3fVNR.js} +1 -1
- package/web/dist/assets/{use-desktop-DWhNBxlY.js → use-desktop-CuYLi0j4.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-DU4XEkhv.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-0WCd35C5.js → useInfiniteQuery-LV3jJNT5.js} +1 -1
- package/web/dist/assets/useQuery-DdfGRa2n.js +1 -0
- package/web/dist/assets/workflows-B_b47Jog.js +7 -0
- package/web/dist/assets/{ws-DJraxHk2.js → ws-DfYRWmd-.js} +1 -1
- package/web/dist/index.html +15 -15
- package/web/dist/live-worker.js +1 -1
- package/web/dist/assets/attention-Bs96zuwc.js +0 -1
- package/web/dist/assets/github-DRMN6FYi.js +0 -1
- package/web/dist/assets/index-QM9AFNSj.js +0 -14
- package/web/dist/assets/picker-pill-DKbLlGPr.js +0 -18
- package/web/dist/assets/preview-pane-connected-DCz8ZSjW.js +0 -3
- package/web/dist/assets/run-header-Dhh86q4A.js +0 -2
- package/web/dist/assets/use-hand-to-agent-state-D_Yp8YT9.js +0 -1
- package/web/dist/assets/useQuery-BifRjEjr.js +0 -1
- package/web/dist/assets/workflows-BN66M7yw.js +0 -7
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{l as t,o as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{$ as o,L as s,N as c,P as l,X as u,Z as d,at as f,it as p,nt as m}from"./live-protocol-C_Z-JQOy.js";import{P as h}from"./queries-DkipLnOL.js";import{X as g,l as _}from"./design-icons-B6-0w7Aw.js";import{h as v,l as y}from"./es2015-DTn4s5Lh.js";import{c as ee,i as te,p as b,r as x,s as S,t as C}from"./dropdown-menu-CzUYjvx4.js";import{a as w,o as T,r as E,t as D}from"./dist-CwBtGUlU.js";import{i as O,o as k,r as A,s as j,t as M}from"./dialog-tMSuX5a7.js";import{i as N}from"./agent-accounts-DetCQbKD.js";var P=e(i(),1);function F(e){return e?.capabilities?.automations===!0}function I(){let e=h().data,t=(0,P.useRef)(void 0);(0,P.useEffect)(()=>{e&&(t.current=e)},[e]);let n=e??t.current;return n?F(n)?`available`:`unavailable`:`unknown`}function L(){return I()===`available`}var R=1,ne=.9,re=.8,ie=.17,z=.1,ae=.999,oe=.9999,se=.99,ce=/[\\\/_+.#"@\[\(\{&]/,le=/[\\\/_+.#"@\[\(\{&]/g,ue=/[\s-]/,de=/[\s-]/g;function fe(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?R:se;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=fe(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=R:ce.test(e.charAt(l-1))?(d*=re,p=e.slice(i,l-1).match(le),p&&i>0&&(d*=ae**+p.length)):ue.test(e.charAt(l-1))?(d*=ne,m=e.slice(i,l-1).match(de),m&&i>0&&(d*=ae**+m.length)):(d*=ie,i>0&&(d*=ae**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=oe)),(d<z&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=fe(e,t,n,r,l+1,a+2,o),f*z>d&&(d=f*z)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function pe(e){return e.toLowerCase().replace(de,` `)}function me(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,fe(e,t,pe(e),pe(t),0,0,{})}var B=`[cmdk-group=""]`,he=`[cmdk-group-items=""]`,ge=`[cmdk-group-heading=""]`,_e=`[cmdk-item=""]`,ve=`${_e}:not([aria-disabled="true"])`,V=`cmdk-item-select`,H=`data-value`,ye=(e,t,n)=>me(e,t,n),be=P.createContext(void 0),U=()=>P.useContext(be),xe=P.createContext(void 0),W=()=>P.useContext(xe),Se=P.createContext(void 0),Ce=P.forwardRef((e,t)=>{let n=q(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=q(()=>new Set),i=q(()=>new Map),a=q(()=>new Map),o=q(()=>new Set),s=Pe(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,ee=y(),te=y(),b=y(),x=P.useRef(null),S=Ie();K(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),K(()=>{S(6,k)},[]);let C=P.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(ee))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=P.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:ee,inputId:b,labelId:te,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ye;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(he);t?t.appendChild(e.parentElement===t?e:e.closest(`${he} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${he} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${B}[${H}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(H);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(B)?.querySelector(ge))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${_e}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(ve)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(H))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(H))}function F(e){let t=A()?.closest(B),n;for(;t&&!n;)t=e>0?Me(t,B):Ne(t,B),n=t?.querySelector(ve);n?C.setState(`value`,n.getAttribute(H)):N(e)}let I=()=>M(j().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):N(1)},R=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?F(-1):N(-1)};return P.createElement(v.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(V);t.dispatchEvent(e)}}}}},P.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Re},c),Y(e,e=>P.createElement(xe.Provider,{value:C},P.createElement(be.Provider,{value:w},e))))}),we=P.forwardRef((e,t)=>{let r=y(),i=P.useRef(null),a=P.useContext(Se),o=U(),s=Pe(e),c=s.current?.forceMount??a?.forceMount;K(()=>{if(!c)return o.item(r,a?.id)},[c]);let l=Fe(r,i,[e.value,e.children,i],e.keywords),u=W(),d=J(e=>e.value&&e.value===l.current),f=J(e=>c||o.filter()===!1?!0:!e.search||e.filtered.items.get(r)>0);P.useEffect(()=>{let t=i.current;if(!(!t||e.disabled))return t.addEventListener(V,p),()=>t.removeEventListener(V,p)},[f,e.onSelect,e.disabled]);function p(){var e,t;m(),(t=(e=s.current).onSelect)==null||t.call(e,l.current)}function m(){u.setState(`value`,l.current,!0)}if(!f)return null;let{disabled:h,value:g,onSelect:_,forceMount:ee,keywords:te,...b}=e;return P.createElement(v.div,{ref:n(i,t),...b,id:r,"cmdk-item":``,role:`option`,"aria-disabled":!!h,"aria-selected":!!d,"data-disabled":!!h,"data-selected":!!d,onPointerMove:h||o.getDisablePointerSelection()?void 0:m,onClick:h?void 0:p},e.children)}),Te=P.forwardRef((e,t)=>{let{heading:r,children:i,forceMount:a,...o}=e,s=y(),c=P.useRef(null),l=P.useRef(null),u=y(),d=U(),f=J(e=>a||d.filter()===!1?!0:!e.search||e.filtered.groups.has(s));K(()=>d.group(s),[]),Fe(s,c,[e.value,e.heading,l]);let p=P.useMemo(()=>({id:s,forceMount:a}),[a]);return P.createElement(v.div,{ref:n(c,t),...o,"cmdk-group":``,role:`presentation`,hidden:!f||void 0},r&&P.createElement(`div`,{ref:l,"cmdk-group-heading":``,"aria-hidden":!0,id:u},r),Y(e,e=>P.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":r?u:void 0},P.createElement(Se.Provider,{value:p},e))))}),Ee=P.forwardRef((e,t)=>{let{alwaysRender:r,...i}=e,a=P.useRef(null),o=J(e=>!e.search);return!r&&!o?null:P.createElement(v.div,{ref:n(a,t),...i,"cmdk-separator":``,role:`separator`})}),De=P.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=W(),o=J(e=>e.search),s=J(e=>e.selectedItemId),c=U();return P.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),P.createElement(v.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Oe=P.forwardRef((e,t)=>{let{children:r,label:i=`Suggestions`,...a}=e,o=P.useRef(null),s=P.useRef(null),c=J(e=>e.selectedItemId),l=U();return P.useEffect(()=>{if(s.current&&o.current){let e=s.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),P.createElement(v.div,{ref:n(o,t),...a,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":c,"aria-label":i,id:l.listId},Y(e,e=>P.createElement(`div`,{ref:n(s,l.listInnerRef),"cmdk-list-sizer":``},e)))}),ke=P.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return P.createElement(D,{open:n,onOpenChange:r},P.createElement(T,{container:o},P.createElement(w,{"cmdk-overlay":``,className:i}),P.createElement(E,{"aria-label":e.label,"cmdk-dialog":``,className:a},P.createElement(Ce,{ref:t,...s}))))}),Ae=P.forwardRef((e,t)=>J(e=>e.filtered.count===0)?P.createElement(v.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),je=P.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return P.createElement(v.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Y(e,e=>P.createElement(`div`,{"aria-hidden":!0},e)))}),G=Object.assign(Ce,{List:Oe,Item:we,Input:De,Group:Te,Separator:Ee,Dialog:ke,Empty:Ae,Loading:je});function Me(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Ne(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Pe(e){let t=P.useRef(e);return K(()=>{t.current=e}),t}var K=typeof window>`u`?P.useEffect:P.useLayoutEffect;function q(e){let t=P.useRef();return t.current===void 0&&(t.current=e()),t}function J(e){let t=W(),n=()=>e(t.snapshot());return P.useSyncExternalStore(t.subscribe,n,n)}function Fe(e,t,n,r=[]){let i=P.useRef(),a=U();return K(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(H,s),i.current=s}),i}var Ie=()=>{let[e,t]=P.useState(),n=q(()=>new Map);return K(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Le(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Y({asChild:e,children:t},n){return e&&P.isValidElement(t)?P.cloneElement(Le(t),{ref:t.ref},n(t.props.children)):n(t)}var Re={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},X=a();function ze({className:e,...t}){return(0,X.jsx)(G,{"data-slot":`command`,className:r(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function Be({title:e=`Command Palette`,description:n=`Search for a command to run...`,children:i,className:a,showCloseButton:o=!0,filter:s,...c}){return(0,X.jsxs)(M,{...c,children:[(0,X.jsxs)(k,{className:`sr-only`,children:[(0,X.jsx)(j,{children:e}),(0,X.jsx)(O,{children:n})]}),(0,X.jsx)(A,{className:r(`overflow-hidden p-0`,a),showCloseButton:o,children:(0,X.jsx)(ze,{...t({filter:s}),className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:i})})]})}function Ve({className:e,...t}){return(0,X.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-ss-[inherit] rounded-se-[inherit] border-b px-3`,children:[(0,X.jsx)(g,{className:`size-4 shrink-0 opacity-50`}),(0,X.jsx)(G.Input,{"data-slot":`command-input`,className:r(`flex h-11 min-w-0 flex-1 rounded-md bg-transparent py-3 text-base md:text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function He({className:e,onPointerMoveCapture:t,...n}){return(0,X.jsx)(G.List,{"data-slot":`command-list`,onPointerMoveCapture:e=>{t?.(e),e.pointerType===`touch`&&e.stopPropagation()},className:r(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...n})}function Ue({...e}){return(0,X.jsx)(G.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function We({className:e,...t}){return(0,X.jsx)(G.Group,{"data-slot":`command-group`,className:r(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Ge({className:e,...t}){return(0,X.jsx)(G.Separator,{"data-slot":`command-separator`,className:r(`-mx-1 h-px bg-border`,e),...t})}function Ke({className:e,...t}){return(0,X.jsx)(G.Item,{"data-slot":`command-item`,className:r(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function qe({className:e,...t}){return(0,X.jsx)(`span`,{"data-slot":`command-shortcut`,className:r(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var Je=`default`,Ye=m({id:f(),label:f(),path:f(),exists:d()}),Xe=m({id:f(),provider:c,label:f(),configDir:f(),path:f(),exists:d(),looksValid:d(),isDefault:d(),status:l.optional(),files:u(Ye)});function Ze(e){return e.isDefault?`default:${e.provider}`:e.id}var Z=s();m({editable:d(),profiles:u(Xe),profileCapableProviders:u(c),selections:p(f(),Z),defaults:Z}),m({projectId:f().min(1).max(64).nullable(),provider:c,profileId:f().max(64).nullable()}),m({selections:p(f(),Z),defaults:Z}),m({status:l}),m({available:d(),reason:f().optional(),fields:u(m({label:f(),value:f()}))}),m({file:f().min(1).max(200),target:f().min(1).max(64).optional()}),m({opened:o(!0),path:f()}),m({provider:c,label:f().trim().max(200).optional(),configDir:f().trim().min(1).max(4096)}),m({profile:Xe}),m({label:f().trim().max(200).optional(),configDir:f().trim().min(1).max(4096).optional()}),m({removed:o(!0),id:f()});var Qe=80,$e=2e3,et=50,tt=200,nt=50,rt=[{id:`add-tests`,label:`Add tests`,text:`Also add or update tests covering this change.`},{id:`explain-change`,label:`Explain the change`,text:`Explain what changed and why before finishing.`},{id:`keep-minimal`,label:`Keep it minimal`,text:`Keep the change as small and targeted as possible — no unrelated refactors.`},{id:`update-docs`,label:`Update docs`,text:`Also update any relevant documentation or comments.`},{id:`check-edge-cases`,label:`Double-check edge cases`,text:`Double-check edge cases and error handling before finishing.`},{id:`create-automation`,label:`Create an automation`,text:`Create an automation for this repository.
|
|
2
|
-
Trigger: <a GitHub event or a schedule, e.g. every new pull request; every issue labelled \`needs-agent\`; every day at 04:00; weekdays at 07:30; every 6 hours>.
|
|
3
|
-
Task for each run: <what the launched task must do, e.g. review the diff, run the tests and post findings as a review comment>.
|
|
4
|
-
Leave it paused and, for a GitHub trigger, preview its matches so I can check the filter before enabling it.`}],it=new Set([`create-automation`]);function at(e,t){return t.automations===!0?e:e.filter(e=>!it.has(e.id))}function ot(e){return!!e&&typeof e==`object`}function st(e){if(e===void 0||!Array.isArray(e))return rt.map(e=>({...e}));let t=new Set,n=[];for(let r of e){if(!ot(r))continue;let e=typeof r.id==`string`?r.id.trim():``,i=typeof r.label==`string`?r.label.trim():``,a=typeof r.text==`string`?r.text.trim():``;if(!e||!i||!a||t.has(e))continue;t.add(e);let o=ct(r.skills);if(n.push({id:e,label:i.slice(0,Qe),text:a.slice(0,$e),...o.length>0?{skills:o}:{}}),n.length>=et)break}return n}function ct(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();if(!(!e||t.has(e))&&(t.add(e.slice(0,tt)),t.size>=nt))break}return[...t]}function lt(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.skills?.some(e=>n.has(e)))}function ut(e,t){return lt(e,t).map(e=>e.text).join(`
|
|
5
|
-
|
|
6
|
-
`)}function dt(e,t,n,r=``){if(e===``||e===r||e===t){let e=r&&n?`${r}\n\n${n}`:r||n;return{text:e,applied:n?e:``}}return{text:e,applied:t}}function ft(){return`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function pt(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=``;i.length>0&&(o=i.endsWith(`
|
|
7
|
-
|
|
8
|
-
`)?``:i.endsWith(`
|
|
9
|
-
`)?`
|
|
10
|
-
`:`
|
|
11
|
-
|
|
12
|
-
`);let s=a.replace(/^[ \t]+/,``),c=``;return s.length>0&&(c=s.startsWith(`
|
|
13
|
-
|
|
14
|
-
`)?``:s.startsWith(`
|
|
15
|
-
`)?`
|
|
16
|
-
`:`
|
|
17
|
-
|
|
18
|
-
`),{text:i+o+n+c+s,caret:i.length+o.length+n.length}}function mt({prompt:e,base:t,selectionStart:n,focused:r,remembered:i}){return e===t?e.length:r&&n!=null||n!=null&&n>0?n:i??e.length}var ht=`inline-flex h-[26px] min-w-0 max-w-full items-center gap-1.5 rounded-full border border-control-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:border-dashed disabled:bg-muted`,gt=(0,X.jsx)(_,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-supporting-foreground`}),_t=(0,P.createContext)(null),Q=e=>Number.parseFloat(e)||0;function vt({pill:e,box:t,full:n}){let r=getComputedStyle(e),i=[...e.children].filter(e=>{if(e===t)return!1;let n=getComputedStyle(e);return n.display!==`none`&&n.position!==`absolute`});return i.reduce((e,t)=>e+t.getBoundingClientRect().width,0)+Q(r.columnGap)*i.length+n.getBoundingClientRect().width+Q(r.paddingLeft)+Q(r.paddingRight)+Q(r.borderLeftWidth)+Q(r.borderRightWidth)}function yt(e){for(let t=e.parentElement;t;t=t.parentElement){if(t.dataset.slot===`picker-pill-disabled-wrapper`)continue;let e=getComputedStyle(t).display;if(e===`grid`||e===`flex`)return t}return e.parentElement}function bt(e){let t=new Map;for(let n of e){let e=yt(n.pill),r=t.get(e)??new Map,i=Math.round(n.pill.getBoundingClientRect().top);r.set(i,[...r.get(i)??[],n]),t.set(e,r)}for(let[e,n]of t){let t=getComputedStyle(e),r=e.clientWidth-Q(t.paddingLeft)-Q(t.paddingRight);for(let e of n.values())if(e.reduce((e,t)=>e+vt(t),0)+Q(t.columnGap)*(e.length-1)>r+.5)return!1}return!0}function xt({children:e}){let t=(0,P.useRef)(new Map),n=(0,P.useRef)(null),[r,i]=(0,P.useState)(!0),a=(0,P.useCallback)(()=>i(bt([...t.current.values()])),[]),o=(0,P.useCallback)((e,r)=>{if(t.current.set(e,r),typeof ResizeObserver<`u`){n.current??=new ResizeObserver(a);for(let e of[r.box,r.full,yt(r.pill)])n.current.observe(e)}return a(),()=>{if(t.current.delete(e),typeof ResizeObserver<`u`)for(let e of[r.box,r.full])n.current?.unobserve(e);a()}},[a]);(0,P.useLayoutEffect)(()=>()=>n.current?.disconnect(),[]);let s=(0,P.useMemo)(()=>({register:o,showPrefixes:r}),[o,r]);return(0,X.jsx)(_t.Provider,{value:s,children:e})}function St({field:e,children:t}){let n=(0,P.useRef)(null),i=(0,P.useRef)(null),a=(0,P.useContext)(_t),o=a?.register,s=(0,P.useId)(),[c,l]=(0,P.useState)(!0);(0,P.useLayoutEffect)(()=>{let e=n.current,t=i.current;if(o){let n=e.closest(`[data-slot$="pill"]`);return n?o(s,{pill:n,box:e,full:t}):void 0}let r=()=>l(t.getBoundingClientRect().width<=e.getBoundingClientRect().width+.5);if(r(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(r);return a.observe(e),a.observe(t),()=>a.disconnect()},[e,t,s,o]);let u=a!==null,d=u?a.showPrefixes:c,f=u&&!d;return(0,X.jsxs)(`span`,{ref:n,className:`relative min-w-0 overflow-hidden`,"aria-hidden":`true`,children:[(0,X.jsxs)(`span`,{ref:i,className:r(`invisible w-max whitespace-nowrap`,f?`absolute left-0 top-0`:`block`),children:[e,` · `,t]}),(0,X.jsxs)(`span`,{"data-slot":`picker-label`,className:r(`block truncate`,f?`relative`:`absolute inset-0`),children:[d?(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,` · `]}):null,t]})]})}function Ct({fieldLabel:e,ariaLabel:t,label:n,options:r,value:i}){return e?`${t} · ${typeof n==`string`?n:r.find(e=>e.value===i)?.label??i}`:t}function wt({readOnly:e,disabled:t,hint:n,disabledHint:r}){return e?r??n:t?r:n}function Tt({fieldLabel:e,fullLabel:t,explanation:n}){return e?[t,n].filter(Boolean).join(` — `):n}function Et({icon:e,fieldLabel:t,ariaLabel:n,label:r}){return(0,X.jsxs)(X.Fragment,{children:[e,t?(0,X.jsx)(St,{field:n,children:r}):(0,X.jsx)(`span`,{className:`min-w-0 truncate`,title:typeof r==`string`?r:void 0,children:r})]})}function Dt({slot:e,ariaLabel:t,label:n,value:i,options:a,onPick:o,disabled:s=!1,readOnly:c=!1,hint:l,disabledHint:u,status:d,searchPlaceholder:f,icon:p,fieldLabel:m=!1}){let[h,v]=(0,P.useState)(!1),[y,w]=(0,P.useState)(``),T=(0,P.useRef)(null),E=(0,P.useRef)(null),D=f?a.filter(e=>e.label.toLowerCase().includes(y.trim().toLowerCase())):a;(0,P.useEffect)(()=>{if(!h||!f)return;let e=window.setTimeout(()=>T.current?.focus());return()=>window.clearTimeout(e)},[h,f]);let O=e=>{T.current&&document.activeElement===T.current&&e.preventDefault()},k=p?` h-11 gap-2 rounded-lg border-border px-3 text-foreground`:``,A=Ct({fieldLabel:m,ariaLabel:t,label:n,options:a,value:i}),j=Tt({fieldLabel:m,fullLabel:A,explanation:wt({readOnly:c,disabled:s,hint:l,disabledHint:u})}),M=Et({icon:p,fieldLabel:m,ariaLabel:t,label:n});if(c)return(0,X.jsxs)(`span`,{"data-slot":e,"aria-label":A,title:j,className:r(ht,k,`cursor-default hover:bg-card hover:text-muted-foreground`),children:[M,m?(0,X.jsx)(`span`,{className:`sr-only`,children:A}):null]});let N=(0,X.jsxs)(`button`,{type:`button`,"data-slot":e,"aria-label":A,disabled:s,title:j,className:r(ht,k),children:[M,p?(0,X.jsx)(_,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-muted-foreground`}):gt]});return s?(0,X.jsx)(`span`,{"data-slot":`picker-pill-disabled-wrapper`,title:j,className:`inline-flex min-w-0 max-w-full`,children:N}):(0,X.jsxs)(C,{open:h,onOpenChange:e=>{v(e),e||w(``)},children:[(0,X.jsx)(b,{asChild:!0,children:N}),(0,X.jsxs)(x,{ref:E,align:`start`,"data-testid":`${e}-menu`,children:[f?(0,X.jsxs)(`div`,{"data-slot":`picker-search`,className:`mbe-1 flex min-h-11 min-w-56 items-center gap-2 border-b border-border px-2`,children:[(0,X.jsx)(g,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,X.jsx)(`input`,{ref:T,type:`search`,"aria-label":f,placeholder:f,value:y,onChange:e=>w(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let t=E.current?.querySelectorAll(`[role="menuitemradio"]:not([data-disabled])`);(e.key===`ArrowDown`?t?.[0]:t?.[t.length-1])?.focus()}else e.key!==`Escape`&&e.stopPropagation()},className:`h-11 w-0 min-w-0 flex-1 bg-transparent text-sm placeholder:text-muted-foreground`})]}):null,(0,X.jsx)(S,{value:i,onValueChange:o,children:D.map(e=>(0,X.jsx)(ee,{value:e.value,className:r(`gap-2.5`,f&&`min-h-11`),onPointerMove:O,onPointerLeave:O,onKeyDown:t=>{T.current&&(t.key===`ArrowUp`&&e===D[0]||t.key===`Tab`&&t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),T.current.focus())},children:(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.label}),e.desc?(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.desc}):null]})},e.value))}),f&&D.length===0?(0,X.jsx)(`p`,{role:`status`,className:`px-2 py-5 text-center text-xs text-muted-foreground`,children:`No matches found.`}):null,d?(0,X.jsx)(te,{disabled:!0,onPointerMove:O,onPointerLeave:O,className:`border-t border-border text-[11px] text-muted-foreground`,children:d}):null]})]})}var $=(e,t)=>t===null?e:`${e}:${t}`;function Ot({runners:e,value:t,onPick:n,disabled:r=!1,accounts:i=[],account:a=null,repoAccount:o,icon:s,fieldLabel:c}){let l=N.filter(t=>e.includes(t.id)).flatMap(e=>{let t=i.filter(t=>t.provider===e.id);return t.length<2?[{value:$(e.id,null),label:e.id,desc:e.desc}]:t.map(t=>({value:$(e.id,t.id),label:`${e.id} · ${t.label}`,desc:t.configDir}))}),u=a??o?.[t]??`default`,d=l.some(e=>e.value===$(t,u))?$(t,u):$(t,null);return(0,X.jsx)(Dt,{icon:s,fieldLabel:c,slot:`runner-pill`,ariaLabel:`Runner`,label:l.find(e=>e.value===d)?.label??t,value:d,disabled:r,onPick:e=>{let[t,r]=e.split(`:`);n(t,r??null)},options:l})}export{Ge as C,L as D,I as E,He as S,F as T,Be as _,ht as a,Ve as b,pt as c,dt as d,mt as f,ze as g,Ze as h,gt as i,ft as l,Je as m,xt as n,rt as o,at as p,Ot as r,ut as s,Dt as t,st as u,Ue as v,qe as w,Ke as x,We as y};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{L as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Dr as o,Er as s,Tr as c,sr as l}from"./project-scope-context-BUXmC8my.js";import{n as u}from"./toaster-CoMJoQvk.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./arrow-right-Dh_Lx3um.js";import{n as p,r as m,t as h}from"./hourglass-B0lPAJvT.js";import{t as g}from"./info-DA1x_4bz.js";import{a as _}from"./format-BNCkW110.js";import{t as v}from"./play-CmVAj_fu.js";import{d as y,l as ee,n as b,u as x}from"./thread-state-BE9onTdO.js";import{a as S,c as C,i as w,l as T,p as E,r as D,s as O,t as k}from"./dropdown-menu-CzUYjvx4.js";import{s as te}from"./project-router-D5aSJsZ7.js";import{Ft as A,Gt as j,It as ne,Nt as re,Pt as ie,Qt as ae,Xt as oe,Zt as se,b as ce,cn as M,d as le,dn as ue,f as de,fn as N,g as fe,h as P,in as pe,m as me,nn as he,p as ge,rn as _e,sn as ve,tn as ye,un as F,x as be,y as xe}from"./index-QM9AFNSj.js";var Se=d(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),I=d(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),L=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),R=d(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),z=d(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),B=d(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),Ce=d(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),we=d(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),V=d(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),H=d(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),U=d(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),W=d(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),G=d(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),K=d(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),q=d(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Te=d(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Ee=d(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),De=d(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Oe=d(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),J=e(i(),1),ke=1e3,Ae=[500,1e3,2e3,4e3,8e3],je=1;function Me(e,t){let n=`/api/v1/p/${encodeURIComponent(e.projectId)}/runs/${encodeURIComponent(e.runId)}/preview/ws`,r=()=>`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${n}`,i=null,a,o=!1,u=!1,d=0,f=0,p=()=>typeof document>`u`||c(),m=()=>{if(o||!p())return;let e=globalThis.WebSocket;if(typeof e!=`function`)return;let n=new e(r());n.binaryType=`blob`,i=n,n.addEventListener(`open`,()=>{n===i&&(u=!0,t.onTransport(`open`))}),n.addEventListener(`message`,e=>{if(n!==i)return;let r=e.data;if(typeof r==`string`){let e;try{e=JSON.parse(r)}catch{return}let n=l.safeParse(e);n.success&&t.onMessage(n.data);return}r instanceof Blob&&(f=0,t.onFrame(r))}),n.addEventListener(`error`,()=>void 0),n.addEventListener(`close`,()=>{if(n!==i||o)return;if(i=null,!u){if(d+=1,d>=2){o=!0,t.onTransport(`blocked`);return}t.onTransport(`reconnecting`,d),a=setTimeout(m,ke);return}if(f>=5){o=!0,t.onTransport(`closed`);return}let e=Ae[Math.min(f,Ae.length-1)];f+=1,t.onTransport(`reconnecting`,f),a=setTimeout(m,e)})},h=s(e=>{if(!o)if(e)i||m();else{clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}});return t.onTransport(`connecting`),m(),{send(e){i?.readyState===je&&i.send(JSON.stringify(e))},close(){o=!0,h(),clearTimeout(a),a=void 0;let e=i;i=null,e?.close()}}}var Y=a();function Ne({iconOnly:e=!1,responsive:t=!1,className:n}){return t?(0,Y.jsx)(A,{children:(0,Y.jsxs)(re,{children:[(0,Y.jsx)(ne,{asChild:!0,children:(0,Y.jsxs)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex h-7 min-w-7 shrink-0 items-center justify-center gap-0 rounded-full bg-muted px-0 text-xs font-semibold text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none @min-[640px]:gap-1.5 @min-[640px]:px-2.5`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline`,children:`Experimental`})]})}),(0,Y.jsx)(ie,{children:`Experimental`})]})}):e?(0,Y.jsx)(A,{children:(0,Y.jsxs)(re,{children:[(0,Y.jsx)(ne,{asChild:!0,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":`Experimental`,tabIndex:0,"data-slot":`preview-experimental`,className:r(`inline-flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n),children:(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsx)(ie,{children:`Experimental`})]})}):(0,Y.jsxs)(`span`,{"data-slot":`preview-experimental`,className:r(`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-muted px-2.5 text-xs font-semibold text-muted-foreground`,n),children:[(0,Y.jsx)(z,{className:`size-3.5`,"aria-hidden":`true`}),`Experimental`]})}function Pe({text:e,source:t,onCopy:n,className:i}){let a=e.replace(/\s+$/,``).split(`
|
|
2
|
-
`);return(0,Y.jsxs)(`div`,{"data-slot":`preview-log-tail`,className:r(`min-w-0 rounded-lg bg-muted px-3.5 py-3 font-mono text-xs`,i),children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 font-sans text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,Y.jsx)(`span`,{className:`font-semibold tracking-wide uppercase`,children:`Log tail`}),` last ${a.length} ${a.length===1?`line`:`lines`} · ${t}`]}),(0,Y.jsxs)(`button`,{type:`button`,className:`-m-2 inline-flex min-h-11 items-center gap-1.5 rounded-sm p-2 text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:min-h-0 md:p-0`,onClick:()=>n(e),children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":`true`}),`Copy`]})]}),(0,Y.jsx)(`pre`,{className:`max-h-48 overflow-auto break-words whitespace-pre-wrap text-foreground`,children:e.replace(/\s+$/,``)})]})}var Fe=/^([a-z][a-z0-9+.-]*):/i;function Ie(e,t){let n=e.trim();if(n===``)return{kind:`error`,message:`Type a URL or a port.`};if(/^\d{1,5}$/.test(n)){let e=Number(n);return e<1||e>65535?{kind:`error`,message:`A port is a number from 1 to 65535.`}:t.some(t=>t.port===e)?{kind:`server`,port:e}:{kind:`url`,url:`http://localhost:${e}`}}let r=Fe.exec(n)?.[1]?.toLowerCase();return r&&!/^[a-z0-9.-]+:\d/i.test(n)?r!==`http`&&r!==`https`?{kind:`error`,message:`Only http and https addresses open here.`}:Le(n):Le(`http://${n}`)}function Le(e){let t={kind:`error`,message:`That is not a valid address.`};if(/\s/.test(e))return t;try{new URL(e)}catch{return t}return{kind:`url`,url:e}}function Re(e){return e.replace(/^https?:\/\//i,``)}var ze=`https://github.com/hearsay-tools/squawk#environment-variables`;function Be({state:e,actions:t,url:n,worktree:r}){switch(e.stage){case`chromium-missing`:return(0,Y.jsx)(We,{state:e,actions:t});case`downloading`:return(0,Y.jsx)(Ke,{state:e,actions:t});case`download-failed`:return(0,Y.jsx)(qe,{state:e,actions:t});case`sandbox-failed`:return(0,Y.jsx)(Je,{state:e,actions:t});case`browser-exited`:return(0,Y.jsx)(Ye,{state:e,actions:t});case`needs-approval`:return(0,Y.jsx)(Qe,{state:e,actions:t});case`port-held`:return(0,Y.jsx)($e,{state:e,actions:t});case`server-starting`:return(0,Y.jsx)(et,{state:e,actions:t});case`server-stalled`:return(0,Y.jsx)(tt,{state:e,actions:t});case`server-exited`:return(0,Y.jsx)(nt,{state:e,actions:t});case`server-stopped`:return(0,Y.jsx)(rt,{state:e,actions:t});case`loading`:return(0,Y.jsx)(at,{step:e.step,url:n});case`worktree-removed`:return(0,Y.jsx)(ot,{state:e,actions:t,worktree:r});case`proxy-blocked`:return(0,Y.jsx)(st,{actions:t});case`taken-over`:return(0,Y.jsx)(lt,{state:e,actions:t})}}function X({icon:e,title:t,children:n,state:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":r,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:e}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:t}),n]})}var Z=({children:e})=>(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e}),Q=({children:e})=>(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e});function Ve({server:e}){return(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(se,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Runs ${P(e.command)} in this task's worktree, on the host.`})]})}function He({copy:e,command:t,label:n}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-install-command`,className:`min-w-0 rounded-lg bg-muted px-3.5 py-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-3 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:[(0,Y.jsx)(`span`,{children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,className:`-m-2 inline-flex size-11 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:m-0 md:size-6`,onClick:()=>e(t),children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":`true`})})]}),(0,Y.jsx)(`code`,{className:`block font-mono text-sm break-words whitespace-pre-wrap text-foreground`,children:t})]})}function Ue({server:e,status:t}){return(0,Y.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1`,children:[(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t})]}),(0,Y.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,Y.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.command}),e.cwd?(0,Y.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,Y.jsx)(`span`,{children:`cwd`}),(0,Y.jsx)(`span`,{className:`break-all`,children:e.cwd})]}):null]}),(0,Y.jsx)(`div`,{className:`mt-2.5`,children:(0,Y.jsx)(Ve,{server:e})})]})}function We({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`This host has no browser yet`,children:[(0,Y.jsx)(Z,{children:e.canDownload?`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} can download it into ~/.cache/cez/ (about 150 MB). Nothing else on the host changes.`:`Preview runs Chromium on the machine ${t(`cezar`)} runs on. ${t(`cezar`)} has no download for this platform, so install it with the system package manager.`}),e.canDownload?(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.download,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Download Chromium`]})}):null,(0,Y.jsx)(He,{command:e.installCommand,copy:r.copy,label:e.canDownload?`Or install it yourself`:`Install it yourself`})]})}function Ge(e){return Math.round(e/1e6)}function Ke({state:e,actions:t}){let r=(0,J.useRef)(null);r.current??={at:Date.now(),received:e.received};let i=e.total>0?Math.min(100,Math.floor(e.received/e.total*100)):0,a=(Date.now()-r.current.at)/1e3,o=a>=1?(e.received-r.current.received)/a:0,s=o>0?Math.ceil((e.total-e.received)/o):void 0;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(R,{}),title:`Downloading Chromium`,children:[(0,Y.jsx)(Z,{children:`Into ~/.cache/cez/, no root needed. Nothing else on the host changes.`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Chromium download`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,className:`h-1.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-success`,style:{width:`${i}%`}})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:`${Ge(e.received)} of ${Ge(e.total)} MB · ${i}%`}),s===void 0?null:(0,Y.jsx)(`span`,{children:`about ${s} s left`})]})]}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.cancelDownload,children:`Cancel`})})]})}function qe({state:e,actions:t}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-danger`}),title:`Couldn't download Chromium`,children:[(0,Y.jsx)(Z,{children:`${e.error.replace(/\.$/,``)}. Install Chromium with the system package manager, then retry.`}),(0,Y.jsx)(He,{command:e.installCommand,copy:t.copy,label:`Install it yourself`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.download,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry download`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`Chromium download failed\n${e.error}\nInstall: ${e.installCommand}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}function Je({state:e,actions:r}){return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(q,{className:`text-danger`}),title:`Chromium couldn't start its sandbox`,children:[(0,Y.jsxs)(Z,{children:[`The host blocks the sandbox Chromium needs. This usually means `,t(`cezar`),` runs as root, or inside a container without user namespaces.`]}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:r.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:r.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>r.copy(`Chromium failed to start its sandbox\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]}),(0,Y.jsx)(`a`,{className:`text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Docs: running without the sandbox (CEZ_PREVIEW_NO_SANDBOX=1)`})]})}function Ye({state:e,actions:t}){let r=e.reason===`timeout`,i=e.signal?` (${e.signal})`:e.exitCode===void 0?``:` (code ${e.exitCode})`,a=e.serverUp?`The dev server is still up; only the browser needs a restart.`:`The browser needs a restart.`,o=r?`Chromium did not start in time`:`Chromium exited${i}`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:r?`The browser did not start`:`The browser stopped`,children:[(0,Y.jsx)(Z,{children:r?`Chromium did not open its DevTools port in time. ${a}`:`Chromium exited unexpectedly${i}. ${a}`}),(0,Y.jsx)(Pe,{text:e.stderrTail,source:`chromium`,onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.retryBrowser,children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Retry`]}),(0,Y.jsxs)(n,{variant:`outline`,onClick:()=>t.copy(`${o}\n${e.stderrTail}`),children:[(0,Y.jsx)(M,{"aria-hidden":`true`}),`Copy diagnostics`]})]})]})}var Xe=2;function Ze(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Qe({state:e,actions:r}){let{server:i,wasRunning:a}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:a?(0,Y.jsx)(De,{className:`text-pending-strong`}):(0,Y.jsx)(v,{}),title:a?`Nothing answers on :${i.port} anymore`:`${i.label} isn't running yet`,children:[(0,Y.jsx)(Z,{children:a?`${i.label} was running when the agent registered it, likely inside the agent's own session, which has ended. ${t(`cezar`)} can start it with the registered command.`:`The agent registered this server. Nothing runs until you approve it here.`}),(0,Y.jsx)(Ue,{server:i,status:a?`was running when registered · silent now`:`registered · not started`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(v,{"aria-hidden":`true`}),`Run and open`]})})]})}function $e({state:e,actions:t}){let{server:r,ownerTitle:i}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(Ee,{className:`text-pending-strong`}),title:`${r.label} :${r.port} is in use by another task`,children:[(0,Y.jsx)(Z,{children:`Task "${i}" is running its own server on :${r.port}. Register a different port for this task, or stop that task's server.`}),(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`contrast`,onClick:t.close,children:`Close preview`})})]})}function et({state:e,actions:r}){let{server:i}=e,a=Ze(1e3),o=Math.max(0,Math.floor((a-Date.parse(e.startedAt))/1e3)),[s,c]=(0,J.useState)(()=>Date.now());(0,J.useEffect)(()=>c(Date.now()),[e.attempt]);let l=Math.max(0,Math.ceil(Xe-(a-s)/1e3));return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(v,{}),title:`Starting ${i.label}`,children:[(0,Y.jsx)(Z,{children:`${t(`cezar`)} ran ${P(i.command)} in the worktree. The page opens as soon as :${i.port} answers.`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-border px-3.5 py-3 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2.5 font-semibold text-foreground`,children:[(0,Y.jsx)(_,{className:`size-4 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}),l>0?`Attempt ${e.attempt} · next try in ${l} s`:`Attempt ${e.attempt}`]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`started ${o} s ago`})]}),e.logTail.length>0?(0,Y.jsx)(Pe,{text:e.logTail.join(`
|
|
3
|
-
`),source:P(i.command),onCopy:r.copy}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>r.stop(i.port),children:`Stop server`})})]})}function tt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(h,{className:`text-pending-strong`}),title:`${r.label} is running, but :${r.port} is silent`,children:[(0,Y.jsx)(Z,{children:`The process has run for 2 min without opening the port. It may be waiting on another service, or listening somewhere else.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:P(r.command),onCopy:t.copy}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`contrast`,onClick:()=>t.keepWaiting(r.port),children:`Keep waiting`}),(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t.stop(r.port),children:`Stop server`})]})]})}function nt({state:e,actions:t}){let{server:r}=e;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(p,{className:`text-danger`}),title:e.exitCode===null?`${r.label} was stopped by a signal`:`${r.label} exited with code ${e.exitCode}`,children:[(0,Y.jsx)(Z,{children:`${P(r.command)} stopped.`}),(0,Y.jsx)(Pe,{text:e.logTail,source:P(r.command),onCopy:t.copy}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>t.run(r.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:r})]})}function rt({state:e,actions:r}){let{server:i}=e,a=e.reason===`idle`;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(ye,{}),title:a?`Stopped after 15 min idle`:`${i.label} stopped`,children:[(0,Y.jsx)(Z,{children:a?`Nobody had this pane open for 15 min, so ${t(`cezar`)} stopped ${i.label} :${i.port} and the browser to free memory. Start again reopens ${Re(e.lastUrl)}.`:`You stopped ${i.label} :${i.port}. Start again reopens ${Re(e.lastUrl)}.`}),(0,Y.jsx)(Q,{children:(0,Y.jsxs)(n,{variant:`contrast`,onClick:()=>r.run(i.port),children:[(0,Y.jsx)(y,{"aria-hidden":`true`}),`Start again`]})}),(0,Y.jsx)(Ve,{server:i})]})}var it=[`browser`,`page`,`frame`];function at({step:e,url:t}){let n=it.indexOf(e),i=t?Re(t):`the page`;return(0,Y.jsx)(`div`,{"data-slot":`preview-state`,"data-state":`loading`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center px-6 py-8`,children:(0,Y.jsx)(`ol`,{"aria-label":`Opening the page`,className:`mx-auto flex flex-col gap-4 text-sm`,children:[{done:`Browser started`,active:`Starting the browser`},{done:`Opened ${i}`,active:`Opening ${i}`},{done:`First frame`,active:`First frame`}].map((e,t)=>{let i=t<n,a=t===n;return(0,Y.jsxs)(`li`,{"aria-current":a?`step`:void 0,className:r(`flex items-center gap-3`,a?`font-semibold text-foreground`:i?`text-foreground`:`text-soft-foreground`),children:[i?(0,Y.jsx)(m,{className:`size-5 text-success`,"aria-hidden":`true`}):a?(0,Y.jsx)(_,{className:`size-5 animate-spin text-success motion-reduce:animate-none`,"aria-hidden":`true`}):(0,Y.jsx)(L,{className:`size-5 text-border`,"aria-hidden":`true`}),i?e.done:a?e.active:e.done]},t)})})})}function ot({state:e,actions:t,worktree:r}){let i=r?/\.ai\/(?:cezar|squawk)\/worktrees\/[^/]+/.exec(r)?.[0]:void 0,a=e.server?.label;return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(B,{}),title:`This task's worktree is gone`,children:[(0,Y.jsx)(Z,{children:`${a??`The server`} ran in ${i??`this task's worktree`}, which has been removed. There is nothing left to start.`}),e.server?(0,Y.jsx)(ee,{entry:{kind:`preview-server`,id:`preview-server:${e.server.port}`,server:e.server,state:`unavailable`},inPreview:!1}):null,(0,Y.jsx)(Q,{children:(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})})]})}function st({actions:e}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":`proxy-blocked`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(Ne,{})}),(0,Y.jsx)(`div`,{"aria-hidden":`true`,className:`flex size-9 items-center justify-center rounded-lg bg-muted text-foreground [&_svg]:size-[18px]`,children:(0,Y.jsx)(W,{})}),(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Preview doesn't work behind this proxy yet`}),(0,Y.jsxs)(Z,{children:[`The proxy in front of `,t(`cezar`),` didn't let the preview's WebSocket through. This is a known gap behind Basic Auth. Everything else in `,t(`cezar`),` keeps working.`]}),(0,Y.jsxs)(Q,{children:[(0,Y.jsx)(n,{variant:`outline`,onClick:e.close,children:`Close preview`}),(0,Y.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-sm font-medium text-accent-text underline-offset-2 hover:underline`,href:ze,target:`_blank`,rel:`noopener noreferrer`,children:`Which setups work`})]})]})}function ct(e){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:/Windows/.test(e)?`Windows`:/Mac OS X|Macintosh/.test(e)?`Mac`:/Linux|X11/.test(e)?`Linux`:``,n=/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:``;return n&&t?`${n} on ${t}`:n||t}function lt({state:e,actions:t}){let r=ct(e.by);return(0,Y.jsxs)(X,{state:e.stage,icon:(0,Y.jsx)(U,{}),title:`Preview is open somewhere else`,children:[(0,Y.jsx)(Z,{children:`Another tab took this browser${r?` (${r})`:``}. Only one tab can view and drive it at a time.`}),(0,Y.jsxs)(Q,{children:[(0,Y.jsxs)(n,{variant:`contrast`,onClick:t.useHere,children:[(0,Y.jsx)(R,{"aria-hidden":`true`}),`Use it here`]}),(0,Y.jsx)(n,{variant:`outline`,onClick:t.close,children:`Close preview`})]})]})}function ut({attempt:e,exhausted:t,onReconnect:r}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-connection-banner`,role:`status`,className:`absolute inset-x-3 top-3 z-10 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-sm shadow-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(Oe,{className:`size-4 shrink-0 text-danger`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,children:`Lost the connection to the host`}),t?null:(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:` · reconnecting (attempt ${e} of 5)`})]})]}),(0,Y.jsx)(n,{variant:`outline`,onClick:r,children:t?`Reconnect`:`Reconnect now`})]})}function dt({servers:e,states:t,onOpen:r,agentLive:i=!1,agentIdle:a=!1,onOpenAgent:o}){return(0,Y.jsxs)(`div`,{"data-slot":`preview-state`,"data-state":a?`agent-idle`:`empty`,className:`mx-auto flex h-full w-full max-w-[560px] flex-col justify-center gap-4 px-6 py-8`,children:[(0,Y.jsx)(`h2`,{className:`text-xl leading-tight font-semibold text-foreground`,children:`Open a page in this task's browser`}),(0,Y.jsx)(Z,{children:`The browser runs on the host, next to the worktree. Type a URL, a bare port such as 3000, or open a server the agent registered.`}),a?(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-start gap-2 text-sm text-foreground`,children:[(0,Y.jsx)(De,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`The agent is not driving the browser now.`})]}):null,i&&o!==void 0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-agent`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-agent`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Driven by the agent`}),(0,Y.jsxs)(`div`,{"data-slot":`preview-agent-entry`,className:`flex items-center justify-between gap-3 px-3.5 py-2 text-sm`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`The agent drives this page through agent-browser.`})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,"aria-label":`Open the agent's page`,onClick:o,children:`Open`})]})]}):null,e.length>0?(0,Y.jsxs)(`section`,{"aria-labelledby":`preview-registered`,className:`overflow-hidden rounded-lg border border-border bg-card`,children:[(0,Y.jsx)(`h3`,{id:`preview-registered`,className:`border-b border-border px-3.5 py-2.5 text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Registered in this task`}),(0,Y.jsx)(`ul`,{children:e.map(e=>{let i=ge(e,t),a=fe(i);return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border px-3.5 py-2 text-sm last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5`,children:[(0,Y.jsx)(j,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,e.port]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:a.text})]}),(0,Y.jsx)(n,{variant:`outline`,size:`sm`,className:`max-md:h-11`,onClick:()=>r(e.port),children:me(i)?`Open`:`Review`})]},e.port)})})]}):null,(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,Y.jsx)(g,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:`Review opens a server's approval in this pane: its command, cwd and Run and open. Nothing runs from this list. Paste works; copying text out, file pickers and downloads don't yet.`})]})]})}function ft({dialog:e,onResult:t}){let[r,i]=(0,J.useState)(e.defaultPrompt??``),a=e.type===`beforeunload`,o=(0,J.useRef)(null),s=(0,J.useRef)(null);(0,J.useEffect)(()=>{(e.type===`prompt`?s.current:o.current)?.focus()},[e.type]);let c=(0,J.useRef)(t);c.current=t,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||e.defaultPrevented)return;let t=e.target instanceof Element?e.target:null;t&&t!==document.body&&!t.closest(`[data-slot="preview-pane-body"], [data-slot="preview-page-dialog"]`)||(e.stopPropagation(),c.current({accept:!1}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let l=()=>t(e.type===`prompt`?{accept:!0,text:r}:{accept:!0});return(0,Y.jsx)(`div`,{"data-slot":`preview-page-dialog`,className:`absolute inset-0 z-20 flex items-center justify-center bg-foreground/30 p-4`,children:(0,Y.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":`${e.origin} says`,className:`w-full max-w-[380px] rounded-xl border border-border bg-card p-4 shadow-lg`,children:[(0,Y.jsx)(`p`,{className:`mb-3 truncate font-mono text-xs text-muted-foreground`,children:`${e.origin} says`}),(0,Y.jsx)(`p`,{className:`mb-4 text-sm break-words whitespace-pre-wrap text-foreground`,children:e.message||(a?`Changes you made may not be saved.`:``)}),e.type===`prompt`?(0,Y.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l()},className:`mb-4 h-11 w-full rounded-md border border-border bg-background px-3 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}):null,(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[e.type===`alert`?null:(0,Y.jsx)(n,{variant:`outline`,onClick:()=>t({accept:!1}),children:a?`Stay`:`Cancel`}),(0,Y.jsx)(n,{ref:o,variant:`contrast`,onClick:l,children:a?`Leave`:`OK`})]})]})})}var pt=10,mt=500,ht=500,gt=4,_t=16,vt=e=>!!e.altKey|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0);function yt(e,t,n,r){return{x:Math.round((e-n.left)/r),y:Math.round((t-n.top)/r)}}function bt(e,t){return{rect:e,scale:t,touches:new Map,multiTouch:!1,click:{at:-1/0,x:0,y:0,button:-1,count:1}}}var xt=[`left`,`middle`,`right`];function $(e,t,n,r){let i=yt(n.clientX,n.clientY,t.rect,t.scale);return{t:`mouse`,type:e,x:i.x,y:i.y,button:xt[n.button]??`none`,buttons:n.buttons,clickCount:1,modifiers:vt(n),...r}}var St=e=>e===0?0:-e;function Ct(e,t,n,r,i){let a=yt(t,n,e.rect,e.scale);return{t:`mouse`,type:`mouseWheel`,x:a.x,y:a.y,button:`none`,buttons:0,deltaX:St(r/e.scale),deltaY:St(i/e.scale),modifiers:0}}function wt(e,t){let{touches:n}=t,r=n.get(e.pointerId),i=()=>{n.delete(e.pointerId),n.size===0&&(t.multiTouch=!1)};switch(e.type){case`pointerdown`:return n.set(e.pointerId,{startX:e.clientX,startY:e.clientY,startAt:e.timeStamp,lastX:e.clientX,lastY:e.clientY,scrolling:!1}),n.size>1&&(t.multiTouch=!0),[];case`pointermove`:{if(!r)return[];if(t.multiTouch)return r.lastX=e.clientX,r.lastY=e.clientY,[];if(!r.scrolling){if(Math.hypot(e.clientX-r.startX,e.clientY-r.startY)<=pt)return[];r.scrolling=!0}let n=e.clientX-r.lastX,i=e.clientY-r.lastY;return r.lastX=e.clientX,r.lastY=e.clientY,n===0&&i===0?[]:[Ct(t,e.clientX,e.clientY,n,i)]}case`pointerup`:{let n=r!==void 0&&!t.multiTouch&&!r.scrolling&&e.timeStamp-r.startAt<=mt;if(i(),!n||!r)return[];let a={...e,clientX:r.startX,clientY:r.startY};return[$(`mouseMoved`,t,a,{button:`none`,buttons:0}),$(`mousePressed`,t,a,{button:`left`,buttons:1}),$(`mouseReleased`,t,a,{button:`left`,buttons:0})]}case`pointercancel`:return i(),[]}}function Tt(e,t){if(e.pointerType===`touch`)return wt(e,t);switch(e.type){case`pointerdown`:{let n=t.click,r=n.button===e.button&&e.timeStamp-n.at<=ht&&Math.hypot(e.clientX-n.x,e.clientY-n.y)<=gt;return t.click={at:e.timeStamp,x:e.clientX,y:e.clientY,button:e.button,count:r?n.count+1:1},[$(`mousePressed`,t,e,{clickCount:t.click.count})]}case`pointermove`:return[$(`mouseMoved`,t,e,{button:e.buttons&1?`left`:`none`})];case`pointerup`:return[$(`mouseReleased`,t,e,{clickCount:t.click.count})];case`pointercancel`:return[]}}function Et(e,t,n){let r=yt(e.clientX,e.clientY,t,n),i=e.deltaMode===1?_t:1;return{t:`mouse`,type:`mouseWheel`,x:r.x,y:r.y,button:`none`,buttons:e.buttons??0,deltaX:e.deltaX*i/n,deltaY:e.deltaY*i/n,modifiers:vt(e)}}var Dt={a:`selectAll`,c:`copy`,x:`cut`,z:`undo`,y:`redo`};function Ot(e){let t=e.key.toLowerCase(),n=(e.ctrlKey||e.metaKey)&&!e.getModifierState?.(`AltGraph`);if(n&&(t===`v`||t===`k`))return;let r={t:`key`,key:e.key,code:e.code,modifiers:vt(e),vk:e.keyCode};if(e.type===`keyup`)return{...r,type:`keyUp`};let i=n?``:e.key.length===1?e.key:e.key===`Enter`?`\r`:e.key===`Tab`?` `:``,a=n?t===`z`&&e.shiftKey?`redo`:Dt[t]:void 0,o={t:`key`,type:i?`keyDown`:`rawKeyDown`,key:e.key,code:e.code,text:i,modifiers:vt(e),vk:e.keyCode};return a?{...o,commands:[a]}:o}function kt(e){return e?{t:`insertText`,text:e}:void 0}var At=e=>e,jt=e=>e.key===`Escape`&&e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey;function Mt({scale:e,send:t,onLeave:n}){let r=(0,J.useRef)(null),i=(0,J.useRef)(bt({left:0,top:0},e)),a=(0,J.useRef)(e);a.current=e;let o=(0,J.useRef)(t);o.current=t;let s=(0,J.useRef)(void 0),c=()=>{let e=r.current;e&&(i.current.rect=e.getBoundingClientRect()),i.current.scale=a.current},l=e=>{c();for(let t of Tt(At(e),i.current))o.current(t)},u=()=>{let e=s.current;e&&(s.current=void 0,cancelAnimationFrame(e.frame),l(e.event))};(0,J.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current.frame)},[]),(0,J.useEffect)(()=>{document.activeElement===document.body&&r.current?.focus({preventScroll:!0})},[]),(0,J.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{e.preventDefault(),c(),o.current(Et(e,i.current.rect,i.current.scale))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,J.useEffect)(()=>{let e=e=>{if(document.activeElement!==r.current)return;let t=kt(e.clipboardData?.getData(`text`)??``);t&&(e.preventDefault(),o.current(t))};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[]);let d=e=>{u(),r.current?.focus({preventScroll:!0});try{r.current?.setPointerCapture(e.pointerId)}catch{}l(e.nativeEvent)},f=e=>{let t=e.nativeEvent;if(t.pointerType===`touch`)return l(t);let n=s.current;if(n){n.event=t;return}s.current={event:t,frame:requestAnimationFrame(()=>{let e=s.current;s.current=void 0,e&&l(e.event)})}},p=e=>{u(),l(e.nativeEvent)},m=e=>{if(jt(e)){e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&(n?n():r.current?.blur());return}let i=Ot(e.nativeEvent);i&&(e.preventDefault(),e.stopPropagation(),t(i))};return(0,Y.jsx)(`div`,{ref:r,"data-slot":`preview-input`,role:`application`,"aria-label":`Page preview, interactive`,"aria-description":`Keys go to the page, Tab included. Press Shift+Escape to return to the cockpit.`,tabIndex:0,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onContextMenu:e=>e.preventDefault(),onKeyDown:m,onKeyUp:m,className:`absolute inset-0 touch-none select-none outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset`})}async function Nt(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,release:()=>t.close()}}let t=URL.createObjectURL(e),n=new Image;return n.src=t,await n.decode(),{source:n,width:n.naturalWidth,height:n.naturalHeight,release:()=>URL.revokeObjectURL(t)}}function Pt({ref:e,viewport:t,dimmed:n=!1,cursor:i,onSize:a,renderInput:o,children:s}){let l=(0,J.useRef)(0),u=(0,J.useRef)(null),d=(0,J.useRef)(null),[f,p]=(0,J.useState)(null),m=(0,J.useRef)(a);m.current=a,(0,J.useImperativeHandle)(e,()=>({async draw(e){let t=++l.current,n=d.current,r=n?.getContext(`2d`);if(!(!n||!r||!c()))try{let i=await Nt(e);try{if(t!==l.current||!c()||d.current!==n)return;n.width!==i.width&&(n.width=i.width),n.height!==i.height&&(n.height=i.height),r.drawImage(i.source,0,0)}finally{i.release()}}catch{}}}),[]),(0,J.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>{let t=Math.round(e.clientWidth),n=Math.round(e.clientHeight);t===0||n===0||(p(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n}),m.current?.({w:t,h:n}))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let h=t===`fit`?f:t,g=t===`fit`||!f?1:Math.min(1,(f.w-24)/t.w,(f.h-24)/t.h),_=h?{width:Math.floor(h.w*g),height:Math.floor(h.h*g)}:void 0;return(0,Y.jsxs)(`div`,{ref:u,"data-slot":`preview-stage`,"data-viewport":t===`fit`?`fit`:`${t.w}x${t.h}`,className:r(`relative min-h-0 flex-1 overflow-hidden bg-muted`,t!==`fit`&&`flex items-start justify-center overflow-auto p-3`),children:[h?(0,Y.jsxs)(`div`,{"data-slot":`preview-surface`,"data-scale":g,style:{..._,cursor:i},className:r(`relative shrink-0 bg-card`,t!==`fit`&&`shadow-md`,n&&`opacity-60 saturate-50`),children:[(0,Y.jsx)(`canvas`,{ref:d,"aria-label":`Page preview`,role:`img`,style:_,className:`block touch-none select-none`}),o?.({canvas:d.current,scale:g,viewport:h})]}):null,s]})}var Ft=`cez-preview-quality`,It=[{value:`normal`,label:`Normal`,detail:`The default. Lighter on CPU and network.`},{value:`high`,label:`High`,detail:`Sharper text and fine detail. Uses more CPU and network.`},{value:`ultra`,label:`Ultra`,detail:`High at your screen's pixel density, up to 2×. Uses the most CPU and network.`}];function Lt(e){return It.find(t=>t.value===e)?.value??`normal`}var Rt=e=>It.find(t=>t.value===e)?.label??`Normal`;function zt(){try{return Lt(localStorage.getItem(Ft))}catch{return`normal`}}function Bt(e){try{localStorage.setItem(Ft,e)}catch{}}var Vt=[{w:390,h:844,icon:ae},{w:820,h:1180,icon:Te},{w:1440,h:900,icon:he}],Ht=`size-8 shrink-0 max-md:size-11`,Ut=e=>e===`fit`?`Fit`:`${e.w} × ${e.h}`;function Wt(e){let[t,n]=(0,J.useState)(()=>Date.now());return(0,J.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var Gt=e=>`${e.fps} fps · ${e.kbps} KB/s${e.rttMs===void 0?``:` · ${e.rttMs} ms`}`;function Kt({stats:e,shrunk:t}){let n=Wt(250),r=e.lastFrameAt===void 0||n-e.lastFrameAt>=1e3;return t?(0,Y.jsx)(j,{"data-slot":`preview-stats`,tone:r?`neutral`:`success`,"aria-label":`Preview is live`,role:`img`}):(0,Y.jsxs)(`span`,{"data-slot":`preview-stats`,role:`img`,"aria-label":r?`idle`:Gt(e),className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:r?`neutral`:`success`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[640px]:inline-block w-[28ch] overflow-hidden text-ellipsis`,children:r?`idle`:Gt(e)})]})}function qt({current:e,agentShown:t,...r}){let i=e?e.label:t?`Agent's page`:`Server`;return(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`max-w-[11rem] min-w-0 gap-1.5 max-md:h-11`,"aria-label":e?`Server: ${e.label} :${e.port}`:t?`Server: ${i}`:`Server`,...r,children:[e||t?(0,Y.jsx)(j,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i}),e?(0,Y.jsxs)(`span`,{className:`font-mono font-normal text-muted-foreground`,children:[`:`,e.port]}):null,(0,Y.jsx)(F,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}function Jt({shown:e,live:t,onSelect:n}){return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":e||void 0,onSelect:n,children:[(0,Y.jsx)(j,{tone:t?`success`:`neutral`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Agent's page`}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`agent-browser`}),e?(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`}):null]})}function Yt(e,t){return e?`${e.label} :${e.port}`:t?`Agent's page`:`Preview`}function Xt(e){let t=e.onPickAgent!==void 0,n=e.agentLive===!0&&t,r=e.agentShown===!0;return{agentLive:n,agentShown:r,agentListed:n||r&&t}}function Zt(e){let{compact:t=!1,navEnabled:r,loading:i=!1}=e,a=(0,J.useRef)(null),o=e.urlInputRef??a,s=(0,J.useRef)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),p=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Back`,disabled:!r,onClick:e.onBack,children:(0,Y.jsx)(Se,{"aria-hidden":`true`})}),m=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Forward`,disabled:!r,onClick:e.onForward,children:(0,Y.jsx)(f,{"aria-hidden":`true`})}),h=(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Reload`,"aria-busy":i||void 0,disabled:!r||i,onClick:()=>e.onReload(!1),children:(0,Y.jsx)(K,{"aria-hidden":`true`})}),g=e.onSession?(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1 max-md:h-11`,onClick:e.onSession,children:[(0,Y.jsx)(ue,{"aria-hidden":`true`}),`Session`]}):null,_=i?(0,Y.jsx)(`div`,{role:`progressbar`,"aria-label":`Loading the page`,className:`absolute inset-x-0 bottom-0 h-0.5 overflow-hidden bg-transparent`,children:(0,Y.jsx)(`div`,{className:`preview-progress h-full w-2/5 bg-success`})}):null,v=(0,Y.jsx)($t,{props:e,input:o,draft:c,setDraft:l,focused:u,setFocused:d}),{agentListed:y}=Xt(e),ee=e.servers.length+ +!!y>=2,b=ee||e.adopted,x={back:p,forward:m,reload:h,address:v,more:(0,Y.jsx)(an,{props:e,compact:t,crowded:b}),session:g,progress:_};return t?(0,Y.jsx)(on,{props:e,elements:x}):(0,Y.jsx)(sn,{props:e,elements:x,switcher:ee,crowded:b,input:o,focusUrlAfterMenu:s})}function Qt({props:e,input:t,focusUrlAfterMenu:n}){let{servers:r,current:i}=e,{agentLive:a,agentShown:o,agentListed:s}=Xt(e);return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(qt,{current:i,agentShown:o})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-64`,onCloseAutoFocus:e=>{n.current&&(n.current=!1,e.preventDefault(),t.current?.focus())},children:[s?(0,Y.jsx)(Jt,{shown:o,live:a,onSelect:()=>e.onPickAgent?.()}):null,r.map(t=>{let n=fe(ge(t,e.serverStates));return(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,"aria-current":i?.port===t.port||void 0,onSelect:()=>e.onPickServer(t.port),children:[(0,Y.jsx)(j,{tone:n.tone,shape:n.ring?`ring`:`filled`,pulse:n.pulse,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-semibold`,children:t.label}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,t.port]}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:n.text}),i?.port===t.port?(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`}):null]},t.port)}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>{n.current=!0},children:[(0,Y.jsx)(pe,{"aria-hidden":`true`}),`Type a URL instead`]})]})]})}function $t({props:e,input:n,draft:i,setDraft:a,focused:o,setFocused:s}){let{url:c,adopted:l}=e;return(0,Y.jsxs)(`div`,{className:`relative flex min-w-[9rem] flex-1 items-center`,children:[(0,Y.jsx)(pe,{className:`pointer-events-none absolute left-2.5 size-4 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:n,type:`text`,"aria-label":`Page address`,placeholder:`Type a URL or a port`,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:i??(o?c:Re(c)),title:c||void 0,className:r(`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-muted pl-8 font-mono text-[13px] text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:bg-background focus-visible:ring-[3px] focus-visible:ring-ring/30 max-md:h-11`,l?`pr-40`:`pr-2.5`),onFocus:e=>{let t=e.currentTarget;s(!0),requestAnimationFrame(()=>{document.activeElement===t&&t.select()})},onBlur:()=>{s(!1),a(null)},onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(e.onNavigate(i??c),t.currentTarget.blur()):t.key===`Escape`&&t.currentTarget.blur()}}),l&&!o?(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute right-2 inline-flex h-6 items-center gap-1 rounded-full border border-border bg-card px-2 text-xs font-semibold text-muted-foreground`,children:[(0,Y.jsx)(we,{className:`size-3`,"aria-hidden":`true`}),`Not started by `,t(`cezar`)]}):null]})}function en({props:e}){let{viewport:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Viewport size: ${Ut(t)}`,children:[t===`fit`?(0,Y.jsx)(H,{"aria-hidden":`true`}):(0,Y.jsx)(he,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:r(`hidden @min-[500px]:inline`,t!==`fit`&&`font-mono font-normal`),children:Ut(t)}),(0,Y.jsx)(F,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`min-w-56`,children:[(0,Y.jsxs)(w,{className:`gap-2.5`,"aria-current":t===`fit`||void 0,onSelect:()=>e.onViewport(`fit`),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Fit`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:`pane size`}),t===`fit`?(0,Y.jsx)(N,{className:`size-4`,"aria-hidden":`true`}):null]}),Vt.map(({w:n,h:r,icon:i})=>(0,Y.jsxs)(w,{className:`gap-2.5 font-mono`,"aria-current":t!==`fit`&&t.w===n&&t.h===r||void 0,onSelect:()=>e.onViewport({w:n,h:r}),children:[(0,Y.jsx)(i,{"aria-hidden":`true`}),n,` × `,r,t!==`fit`&&t.w===n&&t.h===r?(0,Y.jsx)(N,{className:`ml-auto size-4`,"aria-hidden":`true`}):null]},`${n}x${r}`))]})]})}function tn({quality:e,onQuality:t,compact:n}){return(0,Y.jsx)(O,{value:e,onValueChange:e=>t(Lt(e)),children:It.map(e=>(0,Y.jsx)(C,{value:e.value,"data-quality":e.value,className:r(`items-start`,n&&`min-h-11`),children:(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{children:e.label}),(0,Y.jsx)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:e.detail})]})},e.value))})}function nn({props:e}){let{quality:t}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsxs)(n,{variant:`outline`,size:`sm`,className:`shrink-0 gap-1.5`,"aria-label":`Stream quality: ${Rt(t)}`,children:[(0,Y.jsx)(Ce,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`hidden @min-[560px]:inline`,children:Rt(t)}),(0,Y.jsx)(F,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,Y.jsxs)(D,{align:`start`,className:`w-64`,children:[(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:t,onQuality:e.onQuality,compact:!1})]})]})}function rn({stats:e,status:t,crowded:n}){return e?(0,Y.jsx)(Kt,{stats:e,shrunk:n}):t?(0,Y.jsxs)(`span`,{"data-slot":`preview-status`,className:`flex shrink-0 items-center gap-1.5 font-mono text-xs whitespace-nowrap text-muted-foreground`,children:[(0,Y.jsx)(j,{tone:t.tone,"aria-hidden":`true`}),t.label]}):null}function an({props:e,compact:r,crowded:i}){let{stats:a,navEnabled:o,url:s,current:c,adopted:l}=e;return(0,Y.jsxs)(k,{children:[(0,Y.jsx)(E,{asChild:!0,children:(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`More`,children:(0,Y.jsx)(ve,{"aria-hidden":`true`})})}),(0,Y.jsxs)(D,{align:`end`,className:`min-w-64`,children:[i&&a&&!r?(0,Y.jsx)(S,{className:`font-mono text-xs font-normal text-muted-foreground`,children:Gt(a)}):null,(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:!o,onSelect:()=>e.onReload(!0),children:[(0,Y.jsx)(G,{"aria-hidden":`true`}),`Reload without cache`]}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5 md:min-h-0`,disabled:s===``,onSelect:e.onCopyUrl,children:[(0,Y.jsx)(_e,{"aria-hidden":`true`}),`Copy page URL`]}),c?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),l?(0,Y.jsxs)(w,{disabled:!0,className:`items-start gap-2.5 opacity-100 data-[disabled]:opacity-100`,children:[(0,Y.jsx)(V,{className:`mt-0.5 text-muted-foreground`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Stop server · ${c.label} :${c.port}`}),(0,Y.jsxs)(`span`,{className:`text-xs whitespace-normal text-muted-foreground`,children:[t(`cezar`),` didn't start this server, so it won't stop it. Stop it where it was started.`]})]})]}):(0,Y.jsxs)(w,{variant:`destructive`,className:`min-h-11 gap-2.5 md:min-h-0`,onSelect:()=>e.onStop(c.port),children:[(0,Y.jsx)(I,{"aria-hidden":`true`}),`Stop server · ${c.label} :${c.port}`]})]}):null,r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{}),(0,Y.jsx)(S,{className:`text-xs font-normal text-muted-foreground`,children:`Stream quality`}),(0,Y.jsx)(tn,{quality:e.quality,onQuality:e.onQuality,compact:!0}),(0,Y.jsx)(T,{}),(0,Y.jsxs)(w,{className:`min-h-11 gap-2.5`,onSelect:e.onClose,children:[(0,Y.jsx)(oe,{"aria-hidden":`true`}),`Close preview`]})]}):null]})]})}function on({props:e,elements:t}){let{stats:n,current:r,badge:i=!0}=e,{agentShown:a}=Xt(e),{back:o,forward:s,reload:c,address:l,more:u,session:d,progress:f}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,"data-compact":``,className:`relative flex shrink-0 flex-col border-b border-border bg-background`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pt-[max(0.25rem,env(safe-area-inset-top))]`,children:[d,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-center leading-tight`,children:[(0,Y.jsxs)(`span`,{className:`flex max-w-full items-center gap-1.5 text-sm font-semibold text-foreground`,children:[n?(0,Y.jsx)(j,{tone:`success`,"aria-hidden":`true`}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:Yt(r,a)})]}),i?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Experimental`}):null]}),u]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[o,s,c,l]}),f]})}function sn({props:e,elements:t,switcher:r,crowded:i,input:a,focusUrlAfterMenu:o}){let{badge:s=!0,stats:c,status:l}=e,{back:u,forward:d,reload:f,address:p,more:m,session:h,progress:g}=t;return(0,Y.jsxs)(`div`,{"data-slot":`preview-toolbar`,className:`@container relative flex shrink-0 items-center gap-1.5 border-b border-border bg-background px-2.5 py-2`,children:[h,u,d,f,r?(0,Y.jsx)(Qt,{props:e,input:a,focusUrlAfterMenu:o}):null,p,(0,Y.jsx)(en,{props:e}),(0,Y.jsx)(nn,{props:e}),(0,Y.jsx)(rn,{stats:c,status:l,crowded:i}),s?(0,Y.jsx)(Ne,{iconOnly:i,responsive:!i}):null,(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}),m,(0,Y.jsx)(n,{variant:`ghost`,size:`icon-sm`,className:Ht,"aria-label":`Close preview`,onClick:e.onClose,children:(0,Y.jsx)(oe,{"aria-hidden":`true`})}),g]})}function cn({transport:e,takenOver:t,empty:n,stage:r,hasFrame:i,lost:a,url:o,worktree:s}){let c=a||e!==`blocked`&&t!==void 0;return e===`blocked`?{content:{kind:`state`,state:{stage:`proxy-blocked`}},dim:c}:t===void 0?n||r?.stage===`agent-idle`?{content:{kind:`empty`,agentIdle:!n&&r?.stage===`agent-idle`},dim:c}:r?.stage===`streaming`||r?.stage===`loading`&&i?{content:{kind:`none`},dim:c}:r?{content:{kind:`state`,state:r,url:o,worktree:s},dim:c}:a?{content:{kind:`none`},dim:c}:{content:{kind:`state`,state:{t:`state`,stage:`loading`,step:`browser`},url:o},dim:c}:{content:{kind:`state`,state:{stage:`taken-over`,by:t}},dim:c}}function ln(e,{servers:t,serverStates:n,agentLive:r,openServer:i,openAgent:a,actions:o}){switch(e.kind){case`none`:return null;case`state`:{let{kind:t,...n}=e;return(0,Y.jsx)(Be,{...n,actions:o})}case`empty`:return(0,Y.jsx)(dt,{servers:t,states:n,onOpen:e=>i(e),agentLive:r===!0,agentIdle:e.agentIdle,onOpenAgent:a})}}function un(){let e=typeof window>`u`?void 0:window.devicePixelRatio;return typeof e==`number`&&e>0?e:1}function dn(){let[e,t]=(0,J.useState)(un);return(0,J.useEffect)(()=>{let n=window.matchMedia?.(`(resolution: ${e}dppx)`);if(!n)return;let r=()=>t(un());return n.addEventListener(`change`,r),()=>n.removeEventListener(`change`,r)},[e]),e}var fn=2e3,pn=500,mn=1e3;function hn(e,t){switch(e.stage){case`needs-approval`:case`port-held`:case`server-starting`:case`server-stalled`:case`server-exited`:case`server-stopped`:return e.server.port===t;case`loading`:case`streaming`:return!0;default:return!1}}function gn(e){navigator.clipboard?.writeText(e).then(()=>u(`Copied`),()=>u(`Couldn't copy to the clipboard`,{tone:`danger`}))}var _n=e=>`http://localhost:${e.port}${e.path&&e.path!==`/`?e.path:``}`;function vn(e,t){return e?.port===void 0?e?.agent===!0||e?.url!==void 0:e.restored!==!0||t.some(t=>t.port===e.port)}function yn(e){return`port`in e?{port:e.port}:`agent`in e?{agent:!0}:{url:e.url}}function bn({run:e,servers:t,request:n,onTarget:r,onLive:i,onClose:a}){let s=dn(),l=(0,J.useRef)(s);l.current=s;let u=o(),d=(0,J.useRef)(crypto.randomUUID()),f=(0,J.useRef)(!1),p=te(),m=ce(xe,!1),[h,g]=(0,J.useState)(0),[_,v]=(0,J.useState)({state:`connecting`,attempt:0}),[y,ee]=(0,J.useState)(!1),[b,x]=(0,J.useState)(void 0),[S,C]=(0,J.useState)(void 0),[w,T]=(0,J.useState)(``),[E,D]=(0,J.useState)(void 0),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(void 0),[ne,re]=(0,J.useState)(!1),[ie,ae]=(0,J.useState)(!1),[oe,se]=(0,J.useState)(void 0),[M,le]=(0,J.useState)(void 0),[ue,de]=(0,J.useState)(void 0),[N,fe]=(0,J.useState)(`fit`),[P,pe]=(0,J.useState)(zt),[me,he]=(0,J.useState)(null),[ge,_e]=(0,J.useState)(void 0),[ve,ye]=(0,J.useState)(0),F=(0,J.useRef)(void 0),be=(0,J.useRef)(null),Se=(0,J.useRef)(null),I=(0,J.useRef)(void 0),L=(0,J.useRef)(void 0),R=(0,J.useRef)(P);R.current=P;let z=(0,J.useRef)({port:E,stage:S,agent:O});z.current={port:E,stage:S,agent:O};let B=(0,J.useRef)([]),Ce=(0,J.useRef)(void 0),we=(0,J.useRef)(!1),V=(0,J.useRef)(!1),H=(0,J.useCallback)(e=>{V.current&&F.current?.send(e)},[]);(0,J.useEffect)(()=>{let t;return t=Me({projectId:p??`default`,runId:e.id},{onFrame(e){if(!c())return;let n=Date.now();B.current.push({at:n,bytes:e.size}),we.current||(we.current=!0,ae(!0)),(be.current?.draw(e)??Promise.resolve()).finally(()=>t?.send({t:`ack`}))},onMessage(e){switch(e.t){case`state`:if(C(e),(e.stage===`streaming`||e.stage===`loading`)&&ye(e=>e+1),L.current!==void 0&&hn(e,L.current)){let n=L.current;L.current=void 0,(e.stage===`needs-approval`||e.stage===`server-exited`||e.stage===`server-stopped`)&&t?.send({t:`run`,port:n})}return;case`url`:return T(e.url);case`cursor`:return se(e.cursor);case`dialog`:return le(e);case`pong`:Ce.current=Math.max(0,Date.now()-e.ts);return;case`downloadProgress`:C(t=>t?.stage===`downloading`?{...t,received:e.received,total:e.total}:t);return;case`replaced`:x(e.by),V.current=!1,t?.close();return}},onTransport(e,n){V.current=e===`open`,v({state:e,attempt:n??0}),e===`open`&&(ee(!0),I.current&&(t?.send({t:`open`,target:I.current,viewerId:d.current,resume:f.current,quality:R.current,dpr:l.current}),f.current=!0))}}),F.current=t,()=>{V.current=!1,t?.close(),F.current===t&&(F.current=void 0)}},[p,e.id,h]);let U=u&&_.state===`open`&&b===void 0,W=m||N===`fit`?me:N;(0,J.useEffect)(()=>{W&&U&&(S?.stage===`streaming`||S?.stage===`loading`)&&H({t:`resize`,w:W.w,h:W.h,...s===1?{}:{dpr:s}})},[W?.w,W?.h,s,U,S?.stage,ve,H]),(0,J.useEffect)(()=>{if(!U)return;let e=setInterval(()=>H({t:`ping`,ts:Date.now()}),fn);return()=>clearInterval(e)},[U,H]);let G=U&&S?.stage===`streaming`;(0,J.useEffect)(()=>{if(!G){de(void 0);return}let e=setInterval(()=>{let e=Date.now();B.current=B.current.filter(t=>e-t.at<=mn);let t={fps:B.current.length,kbps:Math.round(B.current.reduce((e,t)=>e+t.bytes,0)/1024),...Ce.current===void 0?{}:{rttMs:Ce.current},...B.current.length>0?{lastFrameAt:B.current.at(-1).at}:{}};de(e=>{let n=t.lastFrameAt??e?.lastFrameAt,r={...t,...n===void 0?{}:{lastFrameAt:n}};return e&&e.fps===r.fps&&e.kbps===r.kbps&&e.rttMs===r.rttMs&&e.lastFrameAt===r.lastFrameAt?e:r})},pn);return()=>clearInterval(e)},[G]),(0,J.useEffect)(()=>(i?.(G),()=>i?.(!1)),[G,i]),(0,J.useEffect)(()=>{A&&r?.(A)},[A,r]);let K=(0,J.useCallback)((e,t,n=!1)=>{I.current=e,L.current=n&&`port`in e?e.port:void 0,re(!0),C(void 0),x(void 0),_e(void 0),T(t),D(`port`in e?e.port:void 0),k(`agent`in e),j(yn(e)),H({t:`open`,target:e,viewerId:d.current,quality:R.current,dpr:l.current}),f.current=V.current},[H]),q=(0,J.useCallback)((e,n=!1)=>{let r=t.find(t=>t.port===e);K({port:e},r?_n(r):`http://localhost:${e}`,n)},[t,K]),Te=(0,J.useCallback)(()=>K({agent:!0},``),[K]);(0,J.useEffect)(()=>{if(n?.agent){if(z.current.agent&&z.current.stage?.stage===`streaming`)return;Te();return}if(n?.url!==void 0){let e=Ie(n.url,t);e.kind===`server`?q(e.port):e.kind===`url`&&K({url:e.url},e.url);return}n?.port!==void 0&&(n.restored&&!t.some(e=>e.port===n.port)||z.current.port===n.port&&z.current.stage?.stage===`streaming`&&n.run!==!0||q(n.port,n.run===!0))},[n]);let Ee=!ne&&!b&&_.state!==`blocked`,De=vn(n,t);(0,J.useEffect)(()=>{Ee&&!De&&Se.current?.focus()},[Ee,De]);let Oe=e=>{let n=Ie(e,t);if(n.kind===`error`)return _e(n.message);if(n.kind===`server`)return q(n.port);if(z.current.stage?.stage===`streaming`&&!z.current.agent)return I.current={url:n.url},L.current=void 0,D(void 0),j({url:n.url}),_e(void 0),T(n.url),H({t:`nav`,url:n.url});K({url:n.url},n.url)},ke=(0,J.useCallback)(e=>{R.current=e,pe(e),Bt(e),H({t:`quality`,quality:e})},[H]),Ae=()=>{f.current=!1,x(void 0),v({state:`connecting`,attempt:0}),we.current=!1,g(e=>e+1)};return{compact:m,transport:_,everOpened:y,takenOver:b,stage:S,url:w,port:E,agent:O,hasFrame:ie,cursor:oe,dialog:M,setDialog:le,stats:ue,viewport:N,setViewport:fe,quality:P,chooseQuality:ke,setStageSize:he,addressError:ge,stageHandle:be,urlInput:Se,send:H,connected:U,streaming:G,openServer:q,openAgent:Te,empty:Ee,navigate:Oe,reconnect:Ae,actions:(0,J.useMemo)(()=>({download:()=>H({t:`download`}),cancelDownload:()=>H({t:`cancelDownload`}),retryBrowser:()=>H({t:`retryBrowser`}),run:e=>H({t:`run`,port:e}),stop:e=>H({t:`stop`,port:e}),keepWaiting:e=>H({t:`keepWaiting`,port:e}),close:a,useHere:Ae,copy:gn}),[H,a])}}function xn(e){return(0,Y.jsx)(be,{onClose:e.onClose,children:(0,Y.jsx)(wn,{...e})})}function Sn(e,t,n,r){return e.state===`blocked`?{tone:`neutral`,label:`not supported`}:n?{tone:`neutral`,label:`paused`}:t&&(e.state===`reconnecting`||e.state===`closed`)?{tone:`danger`,label:`offline`}:e.state===`open`?r?Cn(r):void 0:{tone:`neutral`,label:`connecting…`}}function Cn(e){switch(e.stage){case`downloading`:return{tone:`pending`,label:`downloading`};case`download-failed`:return{tone:`danger`,label:`download failed`};case`sandbox-failed`:return{tone:`danger`,label:`browser failed`};case`browser-exited`:return{tone:`danger`,label:e.reason===`timeout`?`browser timed out`:`browser exited`};case`needs-approval`:return{tone:`neutral`,label:`not started`};case`port-held`:return{tone:`danger`,label:`port in use`};case`server-starting`:return{tone:`pending`,label:`waiting for :${e.server.port}`};case`server-stalled`:return{tone:`pending`,label:`waiting · 2 min`};case`server-exited`:return{tone:`danger`,label:`server exited`};case`server-stopped`:return{tone:`neutral`,label:`stopped`};case`agent-idle`:return{tone:`neutral`,label:`agent idle`};case`loading`:return{tone:`neutral`,label:`connecting…`};default:return}}function wn(e){let{run:t,servers:n,serverStates:r,agentLive:i,onSession:a,onClose:o}=e,s=bn(e),{compact:c,transport:l,everOpened:u,takenOver:d,stage:f,url:p,port:m,agent:h,hasFrame:g,stats:_,viewport:v,setViewport:y,quality:ee,chooseQuality:b,addressError:x,urlInput:S,send:C,streaming:w,openServer:T,openAgent:E,empty:D,navigate:O,actions:k}=s,te=n.find(e=>e.port===m),A=f?.stage===`streaming`&&f.adopted,j=u&&(l.state===`reconnecting`||l.state===`closed`),{content:ne,dim:re}=cn({transport:l.state,takenOver:d,empty:D,stage:f,hasFrame:g,lost:j,url:p,worktree:t.worktreePath}),ie=ln(ne,{servers:n,serverStates:r,agentLive:i,openServer:T,openAgent:E,actions:k});return(0,Y.jsxs)(`section`,{"data-slot":`preview-pane-body`,"aria-label":`Live preview`,className:`flex h-full min-h-0 flex-col bg-background text-foreground`,children:[(0,Y.jsx)(Zt,{url:p,servers:n,serverStates:r,badge:l.state!==`blocked`,current:te,agentLive:i===!0,agentShown:h,adopted:A,viewport:c?`fit`:v,quality:ee,compact:c,navEnabled:w,loading:f?.stage===`loading`,stats:w?_??{fps:0,kbps:0}:void 0,status:w?void 0:Sn(l,u,d!==void 0,f),urlInputRef:S,onSession:a,onNavigate:O,onBack:()=>C({t:`back`}),onForward:()=>C({t:`forward`}),onReload:e=>C({t:`reload`,...e?{ignoreCache:!0}:{}}),onPickServer:e=>T(e),onPickAgent:E,onViewport:y,onQuality:b,onCopyUrl:()=>gn(p),onStop:e=>C({t:`stop`,port:e}),onClose:o}),x?(0,Y.jsx)(`p`,{role:`alert`,className:`border-b border-border bg-card px-3 py-1.5 text-xs text-danger`,children:x}):null,(0,Y.jsx)(Tn,{transportState:s,overlay:ie,dim:re,lost:j})]})}function Tn({transportState:e,overlay:t,dim:n,lost:r}){let{connected:i,dialog:a,hasFrame:o,stage:s,stageHandle:c,compact:l,viewport:u,cursor:d,setStageSize:f,send:p,urlInput:m,transport:h,reconnect:g,setDialog:_}=e,v=s?.stage,y=i&&t===null&&!a;return(0,Y.jsxs)(Pt,{ref:c,viewport:l?`fit`:u,dimmed:n&&o&&(v===`streaming`||v===`loading`||n),cursor:d,onSize:f,renderInput:e=>y?(0,Y.jsx)(Mt,{scale:e.scale,send:p,onLeave:()=>m.current?.focus()}):null,children:[r?(0,Y.jsx)(ut,{attempt:h.attempt,exhausted:h.state===`closed`,onReconnect:g}):null,t?(0,Y.jsx)(`div`,{"data-slot":`preview-overlay`,className:n&&o?`absolute inset-0 overflow-auto bg-background/85`:`absolute inset-0 overflow-auto bg-background`,children:t}):null,a?(0,Y.jsx)(ft,{dialog:a,onResult:e=>{_(void 0),p({t:`dialogResult`,...e})}}):null]})}function En(e){let{visibleEvents:t}=de(e);return(0,J.useMemo)(()=>{let e=new Map;for(let n of b(t,{activeTurn:!1}).turns)for(let t of n.items)t.kind===`preview-server`&&e.set(t.server.port,t);return e},[t])}function Dn(e){let t=En(e.run.id),n=le(e.run.id);return(0,Y.jsx)(xn,{...e,serverStates:t,agentLive:n})}export{Dn as ConnectedPreviewPane};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,L as n,S as r,d as i,t as a,u as o}from"./button-DGwhwRuD.js";import{i as s,t as c}from"./react-runtime-CCIEwYL0.js";import{Gn as l,Ht as u,In as d,Ln as f,Nn as ee,Qn as p,Vt as m,Wn as h,Xn as g,Yn as _,hr as v,i as te,k as y,o as ne,zr as re}from"./project-scope-context-BUXmC8my.js";import{B as b,H as ie,Jt as ae,K as x,L as S,P as oe,Q as C,R as w,V as T,Xt as se,Yt as ce,Z as le,Zt as E,bt as ue,mt as de,n as fe,tt as pe,wt as me,x as he,xt as D}from"./queries-DkipLnOL.js";import{J as ge,L as _e,S as ve,_ as ye,a as be,b as xe,d as Se,f as Ce,n as we,o as Te,p as Ee,r as De,v as Oe,y as ke,z as O}from"./use-desktop-DWhNBxlY.js";import{n as k}from"./toaster-CoMJoQvk.js";import{A as Ae,F as je,a as Me,at as Ne,f as Pe,ft as A,g as Fe,h as Ie,i as j,l as M,m as Le,p as Re,q as ze,t as Be,v as N,x as Ve}from"./design-icons-B6-0w7Aw.js";import{t as P}from"./createLucideIcon-BHp8sXmF.js";import{t as He}from"./app-window-CSHwDX9N.js";import{t as Ue}from"./info-DA1x_4bz.js";import{a as We,t as Ge}from"./format-BNCkW110.js";import{t as Ke}from"./message-square-B-MD-8rD.js";import{i as qe,n as Je,t as F}from"./reference-chip-BVB5YsfP.js";import{a as I,i as L,l as R,n as z,p as B,r as V,t as H}from"./dropdown-menu-CzUYjvx4.js";import{a as Ye,i as Xe,o as Ze,r as Qe,s as $e,t as et}from"./dialog-tMSuX5a7.js";import{c as tt,s as nt,t as U}from"./project-router-D5aSJsZ7.js";import"./attention-Bs96zuwc.js";import{$t as W,Ct as rt,Dt as G,Gt as it,Jt as at,Kt as ot,Lt as st,M as ct,N as lt,Ot as K,Rt as ut,V as dt,Zt as ft,_ as pt,a as mt,ct as q,dt as ht,en as gt,ft as _t,gt as vt,hn as yt,ht as bt,j as xt,lt as St,mt as Ct,o as wt,on as Tt,pt as Et,qt as Dt,r as Ot,st as kt,t as At,ut as jt,vt as Mt,yt as Nt,zt as Pt}from"./index-QM9AFNSj.js";import{r as Ft,t as It}from"./markdown-CZVLEjwk.js";import{t as J}from"./tab-link-BTFjRC1e.js";var Lt=P(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Rt=P(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),zt=P(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Y=e(s(),1),X=c();function Bt(e){let t=ae();return E({mutationFn:t=>ne(se(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>ce()),onError:e=>k(e.message,{tone:`danger`})})}function Vt(e){return e.archived?`Unarchive`:`Archive task`}function Ht({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,X.jsx)(kt,{open:t,onOpenChange:n,children:(0,X.jsxs)(jt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(Et,{children:[(0,X.jsx)(Ct,{children:`Archive task?`}),(0,X.jsxs)(ht,{children:[`Move “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:O(e),children:O(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,X.jsxs)(_t,{children:[(0,X.jsx)(St,{children:`Cancel`}),(0,X.jsx)(q,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Z({run:e,className:t,compactOnMobile:n=!1}){let[r,i]=(0,Y.useState)(!1),s=Bt(e.id),c=Vt(e);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(a,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":c,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:s.isPending,className:o(`h-11 gap-[7px] px-3`,n&&`max-md:size-11 max-md:px-0`,t),onClick:()=>e.archived?s.mutate(!1):i(!0),children:[e.archived?(0,X.jsx)(yt,{"aria-hidden":`true`}):(0,X.jsx)(Be,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:o(n&&`max-md:sr-only`),children:c})]}),(0,X.jsx)(Ht,{run:e,open:r,onOpenChange:i,onConfirm:()=>{s.mutate(!0),i(!1)}})]})}function Ut({run:e,action:t,prUrl:n,patch:r}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:t.phase===`blocked`?`Completion blocked`:`Completion pending`}),` · `,t.message||(t.phase===`blocked`?`Completion needs attention.`:`Checking completion actions.`)]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n&&i(n)?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:`Open PR`})}):null,e.autoMergePr?(0,X.jsx)(a,{variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({autoMergePr:!1},{onError:e=>k(e.message,{tone:`danger`})}),children:r.isPending?`Saving…`:`Disable auto-merge`}):null]})]})}function Wt({run:e,blocker:t,flags:n}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`text-sm [overflow-wrap:anywhere]`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:`Archive blocked`}),` · `,t.message]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.runId?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(U,{to:`/tasks/${t.runId}`,children:`Open blocking task`})}):null,t.pullRequestUrl&&i(t.pullRequestUrl)?(0,X.jsx)(a,{variant:`outline`,asChild:!0,children:(0,X.jsx)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,children:`Open blocking PR`})}):null,n.archive?(0,X.jsx)(Z,{run:e}):null]})]})}function Gt({run:e}){let t=T(e.id),n=K(e),r=e.status===`done`?e.completionAction:void 0,i=n.archive?e.archiveBlocker:void 0,a=r&&r.phase!==`complete`?r:void 0;if(!a&&!i)return null;let o=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url;return(0,X.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-border bg-card p-3 [margin-block:0.75rem]`,children:[a?(0,X.jsx)(Ut,{run:e,action:a,prUrl:o,patch:t}):null,i?(0,X.jsx)(Wt,{run:e,blocker:i,flags:n}):null]})}var Kt=[`running`,`queued`,`waiting`];function qt(e,{queuePosition:t,now:n=new Date}){let r=ee(e),i=r.label.charAt(0).toUpperCase()+r.label.slice(1),a=t===void 0?i:`${i} #${t}`,o=Kt.includes(e.status)?Yt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Jt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function Yt(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Ge(n,t)}}async function Q(e,t){try{await navigator.clipboard.writeText(e),k(t)}catch{k(`Run manually: ${e}`)}}function Xt(e){let t=x(),n=pe(),r=(0,Y.useMemo)(()=>ve(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,Y.useMemo)(()=>n===void 0?[]:r.filter(e=>Se(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Zt(e){return E({mutationFn:()=>u(e.id),onError:e=>{if(e instanceof te&&e.command){Q(e.command,`No terminal found — command copied to clipboard.`);return}k(e.message,{tone:`danger`})}})}function $(e,t){let n=b(),r=C(),i=E({mutationFn:t=>m(e.id,t),onError:e=>k(e.message,{tone:`danger`})}),a=v(r.data),o=e=>!r.isSuccess||a.includes(e??`claude`);return{canResumeHere:t&&o(rt(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=Dt(e.id);return t===void 0||o(t)}).map(t=>({target:t,...Nt(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:i}}function Qt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:o}=$(e,t),s=G(e);return!r&&i.length===0&&!s?null:(0,X.jsxs)(X.Fragment,{children:[r||i.length>0?(0,X.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,X.jsxs)(a,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,X.jsx)(ft,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=at(e);return(0,X.jsxs)(a,{variant:`outline`,"data-target":e.id,title:n,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:[(0,X.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,X.jsxs)(a,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>k(`Worktree path copied`)).catch(()=>k(`Path: ${t}`))},children:[(0,X.jsx)(N,{}),`Copy worktree path`]}):null]}):null,s?(0,X.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,X.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,X.jsxs)(a,{variant:`outline`,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{}),`Copy resume command`]})]}):null]})}function $t({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:o}=$(e,t),s=G(e),c=e.worktreePath;if(!r&&i.length===0&&!s&&!c)return null;let l=`max-md:min-h-11`;return(0,X.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,X.jsx)(ot,{choices:i,onPick:e=>o.mutate(e),disabled:o.isPending,triggerVariant:`outline`,className:l,leading:r?(0,X.jsxs)(L,{"data-target":`terminal-resume`,onSelect:n,children:[(0,X.jsx)(ft,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,c?(0,X.jsxs)(a,{variant:`outline`,size:`sm`,className:l,onClick:()=>void Q(c,`Worktree path copied`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy worktree path`]}):null,s?(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:s,className:l,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function en({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:o,choices:s}=$(e,t);return!o&&s.length===0?null:r?(0,X.jsx)(L,{onSelect:r,children:`Open in…`}):(0,X.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,X.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,X.jsx)(A,{})})]}),e.worktreePath?(0,X.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(Qt,{run:e,canResume:t,onResume:n})})]})}function tn({branch:e}){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{k(`Could not copy branch. Select and copy: ${e}`)}};return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium break-all`,children:e}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function nn({run:e}){let t=x(),n=pe(),r=r=>n===void 0?void 0:Oe(n,e.id,r,t),a=(0,Y.useMemo)(()=>ve(e,t),[e,t]),o=[],s=[],c=a.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,X.jsx)(F,{reference:t,to:r(t),taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,X.jsx)(vt,{run:e,prNumber:t.number})},Ee(t)));let l=xe(e);l&&i(l)&&!c.some(e=>e.url===l)&&o.push((0,X.jsx)(F,{reference:{kind:`PR`,url:l},taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=a.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,X.jsx)(F,{reference:t,to:r(t),taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},Ee(t)));let d=ye(e,t);if(d&&i(d)&&!u.some(e=>e.url===d)){let t=Ce(d);s.push((0,X.jsx)(F,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?r({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:O(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,X.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].map(([e,t,n])=>n.length>0?(0,X.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,X.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function rn(){let e=nt(),t=le();return xt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var an=e=>e.map(e=>`${e.name}: ${ct(e.url)}`).join(`
|
|
2
|
-
`);function on(e){return rn().length>0||e.notify===!0}function sn({run:e}){let t=rn(),n=t.length>0,r=w(e.id),[i,o]=(0,Y.useState)(null),s=e.notify===!0;return!n&&!s?null:(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsxs)(H,{children:[(0,X.jsx)(B,{asChild:!0,children:(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`notifying-chip`,className:`h-11 gap-1.5 md:h-[30px]`,"aria-label":n?`Notifying ${lt(t)} — webhook actions`:`Notifying — webhook actions`,title:n?an(t):void 0,children:[(0,X.jsx)(it,{tone:`success`}),(0,X.jsx)(`span`,{children:`Notifying`}),(0,X.jsx)(M,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,X.jsxs)(V,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[n?(0,X.jsx)(I,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-[11px] font-normal text-muted-foreground`,children:t.map(e=>(0,X.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:ct(e.url),children:e.name},e.id))}):null,n?(0,X.jsxs)(L,{className:`min-h-11`,onSelect:()=>o(`note`),children:[(0,X.jsx)(Ke,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,X.jsxs)(L,{variant:`destructive`,className:`min-h-11`,disabled:r.isPending,onSelect:()=>r.mutate({notify:!1},{onSuccess:()=>k(`Stopped notifying the webhook`),onError:e=>k(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),children:[(0,X.jsx)(Lt,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-action":`handoff`,className:`size-11 px-0 md:h-[30px] md:w-auto md:px-2.5`,"aria-label":`Hand off to webhook`,onClick:()=>o(`handoff`),children:[(0,X.jsx)(W,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),n?(0,X.jsx)(cn,{mode:i,targets:t,pending:r.isPending,onOpenChange:e=>!e&&o(null),onSubmit:e=>r.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{o(null),k(i===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>k(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null]})}function cn({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let o=(0,Y.useId)(),s=(0,Y.useId)(),[c,l]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{e!==null&&l(``)},[e]);let u=e===`note`,d=lt(t);return(0,X.jsx)(et,{open:e!==null,onOpenChange:e=>{e||l(``),r(e)},children:(0,X.jsx)(Qe,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,X.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(c.trim())},children:[(0,X.jsxs)(Ze,{className:`text-left`,children:[(0,X.jsx)($e,{children:u?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,X.jsx)(Xe,{children:(0,X.jsx)(`span`,{"data-webhook-destination":``,title:an(t),children:u?`${d} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${d} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,X.jsx)(`label`,{htmlFor:o,className:`text-[13px] font-medium`,children:`Note`}),(0,X.jsx)(dt,{id:o,"data-slot":`handoff-note`,"aria-describedby":s,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:c,onChange:e=>l(e.target.value)}),(0,X.jsxs)(`p`,{id:s,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,X.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,X.jsxs)(Ye,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:h-11 max-sm:[&>button]:w-full`,children:[(0,X.jsx)(a,{type:`button`,variant:`ghost`,className:`sm:h-9`,onClick:()=>r(!1),children:`Cancel`}),(0,X.jsxs)(a,{type:`submit`,variant:`contrast`,className:`sm:h-9`,"data-action":`handoff-submit`,disabled:n||u&&c.trim()===``,children:[(0,X.jsx)(W,{"aria-hidden":`true`}),u?`Send note`:`Hand off`]})]})]})})})}function ln({runId:e,children:t}){let n=r(),i=(0,Y.useMemo)(()=>({runId:e}),[e]);return n?(0,X.jsx)(un,{runId:e,children:t}):(0,X.jsx)(Ft.Provider,{value:i,children:t})}function un({runId:e,children:n}){let{projectId:r}=t(),i=(0,Y.useMemo)(()=>({runId:e,...r?{projectId:r}:{}}),[e,r]);return(0,X.jsx)(Ft.Provider,{value:i,children:n})}function dn(e,t,n,r){return n?r===`step`?`Step ${e} of ${t}`:`${e} of ${t} complete`:`${e} / ${t}`}function fn(e){return typeof e==`object`&&!!e&&!(0,Y.isValidElement)(e)&&`keep`in e}function pn({slot:e,icon:t,title:n,meta:r,summary:i,aside:a,open:s,onToggle:c,className:l,children:u}){let d=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center text-accent-text`,children:t}),(0,X.jsx)(`span`,{className:o(`truncate text-[14px] font-semibold text-foreground`,typeof n==`string`?`shrink-0`:`min-w-0 shrink`),children:n}),i??(fn(r)?(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta`,className:`contents text-[13px] text-muted-foreground tabular-nums`,children:[r.drop===void 0?null:(0,X.jsxs)(`span`,{className:`flex h-[1lh] min-w-0 shrink-[2] flex-wrap overflow-hidden`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[1lh] w-0`}),(0,X.jsxs)(`span`,{"data-slot":`run-activity-meta-drop`,className:`whitespace-nowrap`,children:[r.drop,(0,X.jsx)(`span`,{className:`text-soft-foreground`,children:` ·`})]})]}),` `,(0,X.jsx)(`span`,{"data-slot":`run-activity-meta-keep`,className:`shrink-0 whitespace-nowrap`,children:r.keep})]}):r===void 0?null:(0,X.jsx)(`span`,{"data-slot":`run-activity-meta`,className:`min-w-0 shrink-[2] truncate text-[13px] text-muted-foreground tabular-nums`,children:r}))]}),f=c!==void 0;return(0,X.jsxs)(`div`,{"data-slot":`run-activity-${e}`,"data-state":f&&s?`open`:`collapsed`,className:o(`min-w-0 border-t border-border first:border-t-0`,l),children:[f?(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:c,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-start hover:bg-muted/40 active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,children:[d,a,(0,X.jsx)(M,{"aria-hidden":!0,className:o(`size-4 shrink-0 text-soft-foreground motion-safe:transition-transform motion-reduce:transition-none`,!a&&`ms-auto`,s&&`rotate-180`)})]}):(0,X.jsxs)(`div`,{className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2`,children:[d,a]}),f&&s?(0,X.jsx)(`div`,{"data-slot":`run-activity-body`,className:`min-w-0 border-t border-border/60 bg-muted/30 px-3.5 py-2.5`,children:u}):null]})}function mn(e,t){let n=e?.role===`root`?e.receipts.map(e=>e.workerId).reverse():[];return[...new Set([...n,...(t?.workers??[]).map(e=>e.workerId)])]}function hn(e){let t=e.delegation,n=t?.role===`root`,r=D(e.id,{enabled:n});if(!n||!t)return`complete`;if(!r.isSuccess)return r.isError||r.fetchStatus===`paused`?`unknown`:`pending`;let i=new Map(r.data.workers.map(e=>[e.workerId,e])),a=mn(t,r.data).map(e=>{let t=i.get(e)?.status;return t===`done`||t===`cancelled`?`complete`:t===void 0||t===`failed`?`issue`:`pending`});return a.includes(`pending`)?`pending`:a.includes(`issue`)?`issue`:`complete`}function gn(e){let t=D(e.id,{enabled:e.delegation?.role===`root`});return t.isSuccess&&t.data.workers.some(e=>ge(e.status))}function _n({run:e,open:t,onToggle:n}){let r=D(e.id),i=me(),s=we(),c=e.delegation,l=new Map(r.data?.workers.map(e=>[e.workerId,e])),u=mn(c,r.data),d=_(e)??p(e),f=d?vn(e,d):void 0;return(0,X.jsx)(pn,{slot:`workers`,icon:(0,X.jsx)(Ae,{className:`size-4`}),title:`Workers`,meta:yn({ids:u,workers:l,desktop:s,query:r}),aside:r.data?.capacity?(0,X.jsx)(En,{capacity:r.data.capacity}):void 0,open:t,onToggle:n,children:(0,X.jsxs)(`div`,{"aria-label":`Task relationships`,className:`min-w-0 text-[13px] text-muted-foreground`,role:`group`,children:[r.data?.capacity&&r.data.capacity.outstanding>=r.data.capacity.limit?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`All worker slots are in use. Clean up finished workers to free a slot.`}):null,d?(0,X.jsx)(Cn,{wait:d,dependencyLabel:f}):null,u.length>0?(0,X.jsx)(`ul`,{className:`grid max-h-64 min-w-0 gap-0.5 overflow-y-auto`,children:u.map(t=>{let n=l.get(t),a=i.data?.find(e=>e.id===t)??r.data?.titles?.find(e=>e.id===t),s=n?xn(n.status):r.isSuccess?`Record unavailable or deleted`:`Status unavailable`;return(0,X.jsxs)(`li`,{"data-slot":`worker-item`,"data-status":n?.status,className:`min-w-0`,children:[(0,X.jsxs)(U,{to:`/tasks/${t}`,"aria-label":`Worker task ${t}`,className:`group flex min-h-11 min-w-0 items-center gap-2.5 rounded-md px-1 text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(bn,{status:n?.status}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a?O(a):`Worker ${t.slice(0,8)}`}),(0,X.jsx)(`span`,{className:o(`max-w-[45%] shrink-0 truncate text-xs`,Sn(n?.status)),children:s}),(0,X.jsx)(Me,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`})]}),n?(0,X.jsx)(On,{parentRunId:e.id,worker:n}):null,n?.destroy?(0,X.jsx)(An,{state:n.destroy}):null]},t)})}):c?.role===`root`&&r.isSuccess?(0,X.jsx)(`p`,{className:`px-1 py-1`,children:`No workers`}):null,r.fetchStatus===`paused`?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Offline — relationship details will refresh when connected.`}):r.isPending?(0,X.jsx)(`p`,{role:`status`,className:`px-1 py-1`,children:`Loading relationships…`}):null,r.isError?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-1 py-1`,children:[(0,X.jsx)(`p`,{role:`status`,children:`Could not load relationships. Known task links are retained.`}),(0,X.jsx)(a,{variant:`outline`,className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry relationships`})]}):null]})})}function vn(e,t){let n=e.delegation;if(!(!n||n.role===`invalid`))return f(e)??d(n.role,t,`requestIds`in t&&g(n,t.requestIds))}function yn({ids:e,workers:t,desktop:n,query:r}){if(e.length===0)return r.isError?`Unavailable`:r.isPending?`Linking…`:`No workers`;let i=`${e.length} linked`;if(!n)return i;let a=new Map;for(let n of e){let e=t.get(n)?.status;e!==void 0&&a.set(e,(a.get(e)??0)+1)}return[i,...[...a.entries()].map(([e,t])=>`${t} ${e}`)].join(` · `)}function bn({status:e}){let t=`size-[15px] shrink-0`;return e===`done`?(0,X.jsx)(Pe,{"aria-hidden":!0,className:o(t,`text-success`)}):e===`failed`?(0,X.jsx)(Fe,{"aria-hidden":!0,className:o(t,`text-danger`)}):e===`cancelled`?(0,X.jsx)(Ie,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)}):e===`running`||e===`waiting`||e===`review`?(0,X.jsx)(We,{role:`status`,"aria-label":`Worker running`,className:o(t,`animate-spin stroke-pending motion-reduce:animate-none`)}):(0,X.jsx)(Le,{"aria-hidden":!0,className:o(t,`text-soft-foreground`)})}function xn(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function Sn(e){return e===`done`?`text-success`:e===`failed`?`text-danger`:`text-muted-foreground`}function Cn({wait:e,dependencyLabel:t}){return(0,X.jsxs)(`p`,{className:`px-2 break-words`,children:[e.phase===`parked`&&t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`requestIds`in e&&e.requestIds?e.phase===`parked`?`Waiting on request replies`:e.phase===`wake-pending`?`Conversation update queued for this task`:`Request wait registered — the agent is finishing its turn`:e.phase===`parked`?`Waiting on workers`:e.phase===`wake-pending`?`Worker update queued for the parent`:`Worker wait registered — the agent is finishing its turn`,`.`,`deadline`in e?(0,X.jsxs)(X.Fragment,{children:[` `,`Deadline: `,(0,X.jsx)(`time`,{dateTime:e.deadline,children:e.deadline})]}):` No deadline: ${n(`Cezar`)} wakes this task when they have all settled.`]})}function wn(e){return e.delegation?.role===`worker`&&p(e)?.phase===`wake-pending`}function Tn({run:e}){let t=p(e);return e.delegation?.role===`worker`&&t?.phase===`wake-pending`?(0,X.jsx)(Cn,{wait:t,dependencyLabel:d(`worker`,t)}):null}function En({capacity:e}){return(0,X.jsxs)(`span`,{"data-slot":`worker-capacity`,role:`status`,"aria-label":`Worker capacity: ${e.outstanding} of ${e.limit} in use`,className:`ms-auto shrink-0 whitespace-nowrap text-[13px] font-normal text-muted-foreground tabular-nums`,children:[e.outstanding,` of `,e.limit,` in use`]})}var Dn=new Set([`review`,`done`,`failed`,`cancelled`]);function On({parentRunId:e,worker:t}){let n=he(e),[r,i]=(0,Y.useState)(!1);if(!Dn.has(t.status)||t.destroy?.phase===`complete`&&t.destroy.remaining.length===0)return null;let o=t.workerId.slice(0,8),s=!!t.destroy&&t.destroy.phase!==`complete`;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 px-1`,children:[r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`break-words text-xs`,children:`Removes this worker's worktree and branch. Its result is saved first.`}),(0,X.jsx)(a,{variant:`danger-ghost`,size:`sm`,className:`min-h-11`,"aria-label":`Confirm clean up of worker ${o}`,onClick:()=>{i(!1),n.mutate(t.workerId)},children:`Clean up`}),(0,X.jsx)(a,{variant:`outline`,size:`sm`,className:`min-h-11`,onClick:()=>i(!1),children:`Cancel`})]}):(0,X.jsx)(a,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":s?`Retry clean up of worker ${o}`:`Clean up worker ${o}`,disabled:n.isPending,onClick:()=>i(!0),children:n.isPending?`Cleaning up…`:s?`Retry clean up`:`Clean up`}),n.isError&&!r?(0,X.jsxs)(`span`,{role:`status`,className:`break-words text-xs`,children:[`Cleanup did not finish: `,n.error.message]}):null]})}function kn(e){return e!==void 0&&(e.phase!==`complete`||e.remaining.length>0||e.error!==void 0)}function An({state:e}){if(!kn(e))return null;let t=e.phase===`complete`?void 0:e.retry,n=t&&(0,X.jsx)(jn,{at:t.nextAt});return(0,X.jsxs)(`p`,{className:`px-2 pb-2 break-words`,children:[t?.needsAttention?`Cleanup needs attention`:e.phase===`incomplete`?`Cleanup incomplete`:e.phase===`complete`?`Cleanup complete`:`Cleanup ${e.phase}`,e.remaining.length?` — remaining: ${e.remaining.join(`, `)}`:``,e.error?` — ${t?e.error.replace(/\.$/,``):e.error}`:``,t?.needsAttention?(0,X.jsxs)(X.Fragment,{children:[`. Nothing changed after `,t.attempts,` automatic attempts; checking hourly, next check `,n,`. Retry clean up to try now.`]}):t?(0,X.jsxs)(X.Fragment,{children:[`. Retrying automatically, next attempt `,n,`.`]}):null]})}function jn({at:e}){let t=bt(3e4);return(0,X.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:At(t,Date.parse(e))})}function Mn({id:e}){return(0,X.jsxs)(U,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function Nn({id:e}){let t=de(e),n=t.data?O(t.data):e;return(0,X.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,X.jsxs)(U,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,X.jsx)(j,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,X.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,X.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,X.jsx)(a,{variant:`outline`,className:`min-h-11`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var Pn=3,Fn=(e,t)=>e.kind===t.kind&&e.number===t.number;function In(e,t,n=Pn){let r=t?e.findIndex(e=>Fn(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var Ln=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function Rn({tab:e}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(e.kind===`pr`?je:Re,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,X.jsx)(Je,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function zn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function Bn({servers:e}){let t=pt();if(t===null)return null;let n=t.agentLive===!0,r=e[0],i=e.length+ +!!n===1?r?{port:r.port}:{agent:!0}:{};return(0,X.jsxs)(a,{variant:`outline`,size:`sm`,"data-slot":`preview-toggle`,className:`max-md:h-11`,"aria-pressed":t.open,onClick:()=>t.openPane(i),children:[(0,X.jsx)(He,{"aria-hidden":`true`}),zn(e,n),t.live?(0,X.jsx)(it,{tone:`success`,"aria-label":`Preview is live`}):null]})}function Vn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function Hn({run:e,compact:t=!1}){return e.delegation?.role===`worker`?t?(0,X.jsx)(Mn,{id:e.delegation.parentRunId}):(0,X.jsx)(Nn,{id:e.delegation.parentRunId}):null}function Un(e,t,n,r){return!e.archiveBlocker&&t.archive&&(n!==`session`||!Mt(e,r))?(0,X.jsx)(Z,{run:e}):null}function Wn({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,X.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function Gn({shown:e,run:t,archiveButton:n,previewToggle:r}){let i=on(t);return e&&(n||r||i)?(0,X.jsxs)(`div`,{"data-slot":`run-mobile-actions`,className:`flex flex-wrap items-center gap-2 pt-2`,children:[n,r,(0,X.jsx)(sn,{run:t})]}):null}function Kn({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:i,phoneBar:a,isDesktop:o}){let s=(0,Y.useRef)(null),c=n?`${n.kind}#${n.number}`:null;return(0,Y.useEffect)(()=>{!c||o||s.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[c,r.map(e=>`${e.kind}#${e.number}`).join(`,`),o]),(0,X.jsxs)(`div`,{ref:s,"data-slot":`run-tabs`,"data-phone-bar":a||void 0,className:`mt-3 flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-3.5 max-md:[&>a]:text-[13.5px]`,children:[(0,X.jsx)(J,{to:`/tasks/${e.id}`,active:t===`session`,replace:a,children:`Session`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:a,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:a,children:`Commits`}),(0,X.jsx)(J,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:a,children:`Files`}),r.map(t=>(0,X.jsx)(J,{to:Ln(e.id,t),active:n!==null&&Fn(t,n),replace:a,children:(0,X.jsx)(Rn,{tab:t})},`${t.kind}-${t.number}`)),i.length>0?(0,X.jsxs)(H,{children:[(0,X.jsxs)(B,{"data-slot":`run-tabs-more`,"aria-label":`${i.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,i.length]}),(0,X.jsx)(V,{align:`end`,children:i.map(t=>(0,X.jsx)(L,{asChild:!0,children:(0,X.jsx)(U,{to:Ln(e.id,t),replace:a,children:(0,X.jsx)(Rn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function qn({run:e,tab:t=`session`,onMarkedUnread:n}){let r=ee(e),i=K(e),a=gn(e),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=Jn(e,n),f=me(),p=oe(),m=qt(e,{queuePosition:e.status===`queued`?_e(f.data??[]).get(e.id):void 0}),h=Pt(),g=ut(),_=h!==null&&!g?h:null,v=_!==null,{referenceProjectId:te,repoBase:y,requests:ne}=Xt(e),re=(0,Y.useMemo)(()=>ke(e,y),[e,y]),b=typeof t==`object`?t:null,{inline:ie,overflow:ae}=In(re,b),x=p.data?.capabilities?.preview===!0,S=e.worktreePath&&x?(0,X.jsx)(Bn,{servers:e.previewServers??[]}):null,C=(0,X.jsx)(Qn,{run:e,actions:d,onOpenChooser:()=>u(!0),onToggleNotes:()=>c(e=>!e)}),w=Un(e,i,t,a);return(0,X.jsx)(qe,{projectId:te,repoBase:y,requests:ne,children:(0,X.jsxs)(`header`,{"data-slot":`run-header`,className:o(`relative z-20 bg-background px-[18px] md:px-9 md:pt-7`,v?`pt-0`:`pt-[18px]`,t===`session`&&`md:sticky md:top-0`),children:[(0,X.jsx)(Wn,{run:e}),(0,X.jsx)(Gt,{run:e}),(0,X.jsxs)(`div`,{className:`w-full`,children:[(0,X.jsx)(Hn,{run:e}),_?(0,X.jsxs)(st,{slot:_,children:[(0,X.jsx)(Zn,{run:e}),(0,X.jsx)(Hn,{run:e,compact:!0}),C]}):(0,X.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,X.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:Vn(e.delegation)}),(0,X.jsx)(Xn,{run:e}),(0,X.jsx)(Ot,{dot:r.tone,shape:r.shape,pulse:r.pulse,className:`max-md:hidden`,children:Jt(m)}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[w,S,(0,X.jsx)(sn,{run:e}),C]})]}),(0,X.jsx)(Gn,{shown:_!==null,run:e,archiveButton:w,previewToggle:S}),(0,X.jsx)(Kn,{run:e,tab:t,activeItem:b,inlineItemTabs:ie,overflowItemTabs:ae,phoneBar:v,isDesktop:g}),s?(0,X.jsx)(tr,{runId:e.id,onClose:()=>c(!1)}):null,l?(0,X.jsx)(en,{run:e,canResume:K(e).terminal,onResume:()=>d.terminal.mutate(),onClose:()=>u(!1)}):null]}),(0,X.jsx)(er,{run:e,actions:d})]})})}function Jn(e,t){let n=re(),r=tt(),[i,a]=(0,Y.useState)(null),o=()=>n.invalidateQueries({queryKey:fe.runs.all}),s=e=>k(e.message,{tone:`danger`}),c=ie(),l={isPending:c.isPending,mutate:()=>c.mutate({id:e.id,pinned:!e.pinned})},u=S();return{pin:l,markUnread:{isPending:u.isPending,mutate:()=>{t?.(),u.mutate(e.id,{onError:s})}},delete:E({mutationFn:()=>y(e.id),onSuccess:()=>{o(),r(`/`)},onError:s}),terminal:Zt(e),confirming:i,setConfirming:a}}function Yn(e){let t=T(e.id),n=O(e);return{title:n,editor:wt(n,e=>t.mutate({title:e},{onError:e=>k(e.message,{tone:`danger`})}))}}function Xn({run:e}){let{title:t,editor:n}=Yn(e);return n.editing?(0,X.jsx)(mt,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,X.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,X.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(gt,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Zn({run:e}){let{title:t,editor:n}=Yn(e);return(0,X.jsxs)(De,{open:n.editing,onOpenChange:e=>{e?n.begin():n.commit()},children:[(0,X.jsx)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-px`,children:(0,X.jsx)(`h1`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,title:e.task,children:t})}),(0,X.jsx)(Te,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,className:`flex size-11 shrink-0 items-center justify-center rounded-sm text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,X.jsx)(gt,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,X.jsx)(be,{align:`end`,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),n.cancel()},children:(0,X.jsx)(mt,{editor:n,className:`text-[16px] font-semibold`})})]})}function Qn({run:e,actions:t,onToggleNotes:n,onOpenChooser:r}){let i=K(e),o=G(e),s=T(e.id),c=(0,Y.useId)();return(0,X.jsxs)(H,{children:[(0,X.jsx)(B,{asChild:!0,children:(0,X.jsx)(a,{variant:`ghost`,size:`icon-sm`,className:`size-11`,"aria-label":`Run actions`,children:(0,X.jsx)(Ve,{"aria-hidden":`true`})})}),(0,X.jsxs)(V,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,children:[(0,X.jsx)(I,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),(0,X.jsxs)(L,{onSelect:n,children:[(0,X.jsx)(Tt,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,X.jsx)(en,{run:e,canResume:i.terminal,onResume:()=>t.terminal.mutate(),onOpen:r}),o?(0,X.jsxs)(L,{onSelect:()=>void Q(o,`Command copied to clipboard.`),children:[(0,X.jsx)(N,{"aria-hidden":`true`}),` Copy resume command`]}):null,i.markUnread?(0,X.jsxs)(L,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,X.jsx)(Rt,{"aria-hidden":`true`}),` Mark unread`]}):null,i.pin?(0,X.jsxs)(z,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,X.jsx)(zt,{"aria-hidden":`true`}):(0,X.jsx)(ze,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,(0,X.jsx)(R,{}),(0,X.jsx)(I,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,X.jsx)(z,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:s.isPending,onCheckedChange:e=>s.mutate({archiveWhenDone:e},{onError:e=>k(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,X.jsx)(z,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:s.isPending,"aria-describedby":c,onCheckedChange:e=>s.mutate({autoMergePr:e},{onError:e=>k(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,X.jsx)(`p`,{id:c,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,X.jsx)($n,{run:e,patch:s}),i.deleteRun?(0,X.jsx)(R,{}):null,i.deleteRun?(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,X.jsx)(Ne,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})}function $n({run:e,patch:t}){let r=(0,Y.useId)(),i=(0,Y.useId)(),a=(0,Y.useId)(),o=e=>k(e.message,{tone:`danger`});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{}),(0,X.jsx)(I,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,X.jsxs)(z,{"data-slot":`allow-workers`,className:`min-h-11`,checked:l(e),disabled:t.isPending,"aria-describedby":`${r} ${a}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:o}),children:[`Allow `,n(`cezar`),` workers`]}),(0,X.jsxs)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:[`Agents in this task can start `,n(`Cezar`),` workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`]}),(0,X.jsx)(z,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:h(e),disabled:t.isPending,"aria-describedby":`${i} ${a}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:o}),children:`Allow task messaging`}),(0,X.jsx)(`p`,{id:i,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,X.jsx)(`p`,{id:a,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function er({run:e,actions:t}){let n=t.confirming;return(0,X.jsx)(kt,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,X.jsxs)(jt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,X.jsxs)(Et,{children:[(0,X.jsx)(Ct,{className:`text-danger`,children:`Delete task permanently?`}),(0,X.jsx)(ht,{children:(0,X.jsxs)(X.Fragment,{children:[`Delete “`,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,title:O(e),children:O(e)}),`” and its transcript, worktree and branch. This cannot be undone.`]})})]}),(0,X.jsxs)(_t,{children:[(0,X.jsx)(St,{children:`Cancel`}),(0,X.jsx)(q,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function tr({runId:e,onClose:t}){let n=ue(e);return(0,X.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 rounded-xl border border-border bg-card p-6`,children:[(0,X.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,X.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,X.jsx)(A,{})})]}),n.isPending?(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,X.jsx)(ln,{runId:e,children:(0,X.jsx)(It,{children:n.data})}):(0,X.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`}),(0,X.jsxs)(`div`,{className:`mt-4 flex gap-3`,children:[(0,X.jsx)(a,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Q(n.data??``,`Notes copied`),children:`Copy notes`}),(0,X.jsx)(a,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{qt as _,kn as a,hn as c,ln as d,tn as f,Xt as g,Zt as h,Tn as i,pn as l,$t as m,An as n,wn as o,nn as p,_n as r,gn as s,qn as t,dn as u,Z as v};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{C as o,It as s,Zt as c,hr as l,nt as u,r as d,rt as f,zr as p}from"./project-scope-context-BUXmC8my.js";import{Bt as m,Ct as h,Ft as g,M as _,O as v,Q as y,Zt as b,h as x,jt as S,n as C,tt as w}from"./queries-DkipLnOL.js";import{t as T}from"./useQuery-BifRjEjr.js";import{a as E,o as D,r as O,tt as k}from"./use-desktop-DWhNBxlY.js";import{n as A}from"./toaster-CoMJoQvk.js";import{Y as j,c as M,ct as N,ft as P,g as F,it as ee,k as te,l as I,m as L,ot as R,r as ne,tt as z,u as re,ut as ie,y as ae}from"./design-icons-B6-0w7Aw.js";import{t as oe}from"./eye-B8okNWXU.js";import{a as se,i as B}from"./format-BNCkW110.js";import{t as ce}from"./message-square-B-MD-8rD.js";import{t as le}from"./play-CmVAj_fu.js";import{a as ue,i as de,o as fe,r as pe,s as me,t as he}from"./dialog-tMSuX5a7.js";import{d as V,t as ge,y as H}from"./prompt-template-menu-De-8v5io.js";import{t as U}from"./project-router-D5aSJsZ7.js";import{D as _e,S as ve,a as ye,b as be,c as xe,d as Se,f as Ce,g as we,m as Te,n as Ee,p as De,r as Oe,s as ke,t as W,u as Ae,v as je,x as G,y as K}from"./picker-pill-DKbLlGPr.js";import{d as Me,f as q,i as Ne,o as Pe,p as Fe,s as Ie,t as Le,u as Re}from"./skills-pM_PouEs.js";import{c as ze,d as Be,f as Ve,h as He,l as Ue,n as We,p as Ge,s as Ke,t as qe}from"./agent-accounts-DetCQbKD.js";import{F as Je,L as Ye,R as Xe,V as Ze,dn as Qe}from"./index-QM9AFNSj.js";import{t as $e}from"./markdown-CZVLEjwk.js";import{t as et}from"./diff-nSqnAkNf.js";import{t as tt}from"./tab-link-BTFjRC1e.js";var J=e(i(),1),Y=a(),nt={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function X({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:r(t,`text-success`)}):e===`failing`?(0,Y.jsx)(F,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:r(t,`text-danger`)}):e===`pending`?(0,Y.jsx)(se,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:r(t,`animate-spin text-warning`)}):(0,Y.jsx)(L,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:r(t,`text-soft-foreground`)})}function rt(e){return e?.available?e.mergeState:null}function it(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function at(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function ot(e){return e===`approved`||e===`not-required`?`passing`:e===`unknown`?`unknown`:`failing`}function st(e){return e===`mergeable`?`passing`:e===`conflicting`?`failing`:`unknown`}function ct(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function lt(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function ut(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function dt(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function Z(e){return e?nt[e]:`Merge`}function ft(e){return e===`conflicting`?`true`:void 0}function pt({check:e}){return(0,Y.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(X,{state:e.state}),(0,Y.jsxs)(`span`,{children:[e.name,` · `,e.state,lt(e.required)]})]}),e.url&&t(e.url)?(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function mt({reason:e}){return(0,Y.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function ht({state:e,selectedMethod:t,overrideRules:i,mergeEnabled:a,refreshPending:o,onRefresh:s,onRunAgent:c,onConfirm:l,onMethodChange:u,onOverrideChange:d}){let f=at(e),p=ot(e.reviewDecision),m=st(e.mergeable);return(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,Y.jsx)(R,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:f}),(0,Y.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,disabled:o,onClick:s,children:[(0,Y.jsx)(j,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,o&&`animate-spin`)}),`Refresh`]})]}),(0,Y.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[e.headRef,` (`,e.headSha.slice(0,7),`) → `,e.baseRef]}),(0,Y.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(X,{state:p}),(0,Y.jsxs)(`span`,{children:[`Reviews: `,e.reviewDecision.replaceAll(`-`,` `)]})]}),(0,Y.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(X,{state:m}),(0,Y.jsxs)(`span`,{children:[`Conflicts: `,ct(e.mergeable)]})]}),e.checks.length===0?(0,Y.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,Y.jsx)(pt,{check:e},e.name)),e.blockers.map(e=>(0,Y.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&c?(0,Y.jsx)(n,{className:`mt-4`,onClick:c,children:`Run agent on this PR`}):null,e.canOverride?(0,Y.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>d(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,Y.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,Y.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,Y.jsx)(`select`,{"aria-label":`Merge method`,value:t??``,onChange:e=>u(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:e.methods.map(e=>(0,Y.jsx)(`option`,{value:e,children:nt[e]},e))}),(0,Y.jsx)(n,{disabled:!a,onClick:l,children:Z(t)})]}):null]})]})}function gt({number:e,state:t,selectedMethod:r,confirming:i,overrideRules:a,mergePending:o,mergeError:s,onOpenChange:c,onMerge:l}){return(0,Y.jsx)(he,{open:i,onOpenChange:c,children:(0,Y.jsxs)(pe,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,Y.jsxs)(fe,{children:[(0,Y.jsxs)(me,{children:[Z(r),` pull request #`,e,`?`]}),(0,Y.jsx)(de,{asChild:!0,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),a&&t.canOverride?(0,Y.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),s?(0,Y.jsx)(`p`,{className:`text-sm text-danger`,children:s.message}):null,(0,Y.jsxs)(ue,{children:[(0,Y.jsx)(n,{variant:`outline`,disabled:o,onClick:()=>c(!1),children:`Cancel`}),(0,Y.jsx)(n,{disabled:o,onClick:l,children:o?`Merging…`:Z(r)})]})]})})}function _t({number:e,onRunAgent:t}){let n=p(),r=w(),i=T({queryKey:C.githubMergeState(e),queryFn:({signal:t})=>f(e,{},{signal:t}),retry:!1}),a=rt(i.data),[o,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,m]=(0,J.useState)(!1),h=b({mutationFn:t=>f(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>A(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=it(o,a),_=()=>({mergeState:C.githubMergeState(e),list:C.githubPages(50),comments:C.githubComments(`pr`,e),item:C.githubItem(`pr`,e),refStatus:r===void 0?void 0:C.githubRefStatusOf(r)}),v=b({mutationFn:t=>{if(!a||!g)throw Error(`No merge method is available.`);return s(e,{method:g,expectedHeadSha:a.headSha,...d&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),A(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{A(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,Y.jsx)(H,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,Y.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":ft(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,Y.jsx)(ht,{state:a,selectedMethod:g,overrideRules:d,mergeEnabled:dt(g,a,d),refreshPending:h.isPending,onRefresh:()=>h.mutate(C.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:c,onOverrideChange:m}),(0,Y.jsx)(gt,{number:e,state:a,selectedMethod:g,confirming:l,overrideRules:d,mergePending:v.isPending,mergeError:v.error,onOpenChange:u,onMerge:()=>v.mutate(_())})]}):(0,Y.jsx)(mt,{reason:ut(i.data)})}function vt(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function yt(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function bt(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function Q(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function xt({label:e,color:t,plain:n=!1}){return(0,Y.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:Q(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function St(e){return e===`pr`?`pull request`:`issue`}function Ct(e,t,n){return e===`pr`&&!!(t||n)}function wt({backLink:e}){return e?(0,Y.jsxs)(U,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,Y.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}function Tt({item:e,kindWord:n,commentCount:r,hasDiffStat:i,additions:a,deletions:o}){return(0,Y.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,Y.jsx)(`span`,{children:n}),`·`,(0,Y.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,Y.jsxs)(`span`,{children:[B(e.createdAt),` ago`]}),r?(0,Y.jsxs)(Y.Fragment,{children:[`·`,(0,Y.jsx)(Yt,{count:r})]}):null,i?(0,Y.jsxs)(Y.Fragment,{children:[`·`,(0,Y.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,a??0]}),` `,(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`−`,o??0]})]})]}):null,`·`,t(e.url)?(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,Y.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function Et({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,Y.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,Y.jsx)(tt,{to:V(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,Y.jsx)(tt,{to:V(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,Y.jsx)(U,{to:V(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function Dt({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,Y.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,Y.jsx)(xt,{label:e,color:t[e]},e)),n?(0,Y.jsx)(Xt,{checks:n,url:e.url}):null]}):null}function Ot({item:e,colors:t,body:n}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:n?(0,Y.jsx)($e,{children:n}):(0,Y.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,Y.jsx)(jt,{item:e,colors:t})]})}function kt({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,children:c}){let l=a?.changes??!1,u=St(e.kind),d=v(e.kind,e.number,!l).data?.detail,f=d?.body??e.body,p=d?.additions??e.additions,m=d?.deletions??e.deletions,h=Ct(e.kind,p,m),g=r??e.comments;return(0,Y.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,Y.jsx)(wt,{backLink:i}),(0,Y.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,Y.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,Y.jsx)(Tt,{item:e,kindWord:u,commentCount:g,hasDiffStat:h,additions:p,deletions:m}),e.kind===`pr`?null:(0,Y.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,(0,Y.jsx)(Et,{item:e,subNav:a,changes:l}),(0,Y.jsx)(Dt,{item:e,colors:t,checks:n}),l&&e.kind===`pr`?(0,Y.jsx)(At,{item:e}):(0,Y.jsx)(Ot,{item:e,colors:t,body:f})]}),e.kind===`pr`?(0,Y.jsx)(_t,{number:e.number,onRunAgent:o}):null,c]})}function At({item:e}){let i=p(),a=_(e.number),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(null),d=a.data,f=d?.available?d.files.filter(e=>e.path.toLowerCase().includes(o.toLowerCase())):[],m=f.findIndex(e=>e.path===c);(0,J.useEffect)(()=>{f.length>0&&!f.some(e=>e.path===c)&&l(f[0].path)},[d?.available?d.headSha:``,o]);let h=async()=>{let t=d?.available?d.headSha:null,n=C.githubPrChanges(e.number),r=await u(e.number,{refresh:!0});i.setQueryData(n,r),r.available&&t&&t!==r.headSha&&(l(r.files[0]?.path??null),A(`The reviewed revision changed.`))};if(a.isPending)return(0,Y.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(a.isError||!d)return(0,Y.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!d.available)return(0,Y.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:d.reason});let g=f.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),v=t(e.url)?`${e.url}/files`:null,y=f.find(e=>e.path===c);return(0,Y.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,Y.jsxs)(`strong`,{children:[d.files.length,` changed files`]}),(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,d.additions]}),(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`−`,d.deletions]}),(0,Y.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:d.headSha,children:[`head `,d.headSha.slice(0,8)]}),(0,Y.jsx)(n,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void h(),children:`Refresh`})]}),d.truncated?(0,Y.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[d.reason??`This response is incomplete.`,` `,v?(0,Y.jsx)(`a`,{href:v,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,Y.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,Y.jsxs)(`aside`,{className:`min-w-0`,children:[(0,Y.jsx)(`input`,{"aria-label":`Filter changed files`,value:o,onChange:e=>s(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,Y.jsx)(`select`,{"aria-label":`Select changed file`,value:c??``,onChange:e=>l(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:f.map(e=>(0,Y.jsx)(`option`,{children:e.path},e.path))}),(0,Y.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:f.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(e.path),className:r(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,c===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,Y.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,Y.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,Y.jsx)(n,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<=0,onClick:()=>l(f[m-1]?.path??null),children:(0,Y.jsx)(Qe,{})}),(0,Y.jsx)(n,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<0||m>=f.length-1,onClick:()=>l(f[m+1]?.path??null),children:(0,Y.jsx)(re,{size:16})})]}),f.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(et,{files:g.filter(e=>e.path===c),wrap:!0,className:`min-w-0`}),y&&!y.patch?(0,Y.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,y.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function jt({item:e,colors:t}){let n=v(e.kind,e.number),r=n.data,i=(0,J.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Mt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,Y.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,Y.jsx)(H,{className:`mb-3 h-3 w-24`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(H,{className:`h-14 w-full`}),(0,Y.jsx)(H,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,Y.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,Y.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,Y.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,Y.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Nt(i).map(e=>e.group===`commits`?(0,Y.jsx)(Pt,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,Y.jsx)(Gt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,Y.jsx)(It,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Mt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Nt(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function Pt({commits:e,colors:t}){let[n,r]=(0,J.useState)(!1),i=e[0]?.actor??`?`;return n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:Ft.committed}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Y.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,Y.jsx)(It,{event:e,colors:t},e.id))]}):(0,Y.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:Ft.committed}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,Y.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:B(e[e.length-1].createdAt)})]})})}var Ft={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function It({event:e,colors:t}){return(0,Y.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:r(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:Ft[e.kind]}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,Y.jsx)(Ht,{event:e,colors:t}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:B(e.createdAt)}),e.url?(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Lt({event:e}){return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,Y.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,Y.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,Y.jsx)(Ut,{checks:e.checks})]})}function Rt({event:e,colors:t}){return(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,Y.jsx)(`span`,{"data-slot":`gh-event-label`,style:Q(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,Y.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function zt({event:e}){return(0,Y.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Bt({event:e}){return(0,Y.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Vt={committed:e=>(0,Y.jsx)(Lt,{event:e}),labeled:(e,t)=>(0,Y.jsx)(Rt,{event:e,colors:t}),unlabeled:(e,t)=>(0,Y.jsx)(Rt,{event:e,colors:t}),assigned:e=>(0,Y.jsx)(zt,{event:e}),unassigned:e=>(0,Y.jsx)(zt,{event:e}),merged:()=>(0,Y.jsx)(`span`,{children:`merged this`}),closed:()=>(0,Y.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,Y.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,Y.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,Y.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,Y.jsx)(Bt,{event:e})};function Ht({event:e,colors:t}){return Vt[e.kind]?.(e,t)??null}function Ut({checks:e}){return e?(0,Y.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:r(`shrink-0`,Jt[e]),children:qt[e]}):null}var Wt={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function Gt({comment:e}){let t=e.reviewState?Wt[e.reviewState]:null;return(0,Y.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,Y.jsx)(Kt,{url:e.avatarUrl,login:e.author}),(0,Y.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,Y.jsx)(`span`,{children:B(e.createdAt)}),t?(0,Y.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:r(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(k,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,Y.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,Y.jsx)($e,{children:e.body}):(0,Y.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function Kt({url:e,login:t}){let[n,r]=(0,J.useState)(!1);return e&&!n?(0,Y.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,Y.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var qt={passing:`✓`,failing:`✗`,pending:`○`},Jt={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function Yt({count:e}){return e?(0,Y.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,Y.jsx)(ce,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function Xt({checks:e,url:t}){let n=r(`text-[11px] font-medium`,Jt[e],t&&`hover:underline`),i=`${qt[e]} checks ${e}`;return t?(0,Y.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:i}):(0,Y.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:i})}function Zt({checks:e}){return(0,Y.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:r(`shrink-0 font-sans text-[11px] font-semibold`,Jt[e]),children:qt[e]})}function Qt(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function $t(e,t=[]){let n=Qt(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=en(t)),n}function en(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function tn(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function nn(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function rn(e,t,n){let r=(n??``).trim();if(!r)return $t(e,t);let i=Qt(e),a=r.startsWith(i)?i+tn(r.slice(i.length),e):tn(r,e),o=nn(a,e)?a:`${i}\n\n${a}`;return t.length?o+en(t):o}function an(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function on(e,t,n,r,i={}){return t?{...i,workflow:t,task:rn(e,n.map(e=>e.id),r)}:n.length?{...i,steps:an(n.map(e=>e.id)).map((e,t)=>({...e,...n[t]?.path===void 0?{}:{skillPath:n[t].path}})),task:rn(e,[],r)}:{...i,workflow:`quick-task`,task:rn(e,[],r)}}function sn(e){let t=y(),n=x(),r=l(t.data),i=n.data?.defaultRunner,a=Ge(e.runner,r,i??r[0]??`claude`),o=h(a),s=n.data?.modelsLocked===!0,{accounts:c,repoAccount:u}=We(),d=c.some(t=>t.provider===a&&t.id===e.account)?e.account:null,f=Ve(s?null:e.model,a,n.data?.defaultModels,o.data),p=Ke(a,f,o.data);return{runner:a,runnerExplicit:e.runner!==null,model:f,effort:s?``:Be(e.effort,p),effortOptions:p,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:s,providerPending:t.isPending,providerError:t.isError,accounts:c,account:d,repoAccount:u}}function cn(e){return{runner:He(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function ln(e){return{...cn(e),...e.account?{agentProfile:e.account}:{}}}function un({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,J.useRef)(null),o=(0,J.useRef)(null),[s,c]=(0,J.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,J.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[i]),(0,J.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let l=sn(e),{runner:u,model:d,effort:f,effortOptions:p,runners:m,canRun:g,modelsLocked:_}=l,v=x(),y=h(u),b=Ue(u,y.data,[e.model,v.data?.defaultModels?.[u]]),S=n||!g,C=r?l.accounts:[],w=m.length>1||m.some(e=>qe(C,e))?(0,Y.jsx)(Oe,{icon:(0,Y.jsx)(ee,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:m,value:u,accounts:C,account:r?l.account:null,repoAccount:r?l.repoAccount:void 0,disabled:S,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===u?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,T=(0,Y.jsx)(W,{icon:(0,Y.jsx)(ae,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:d===``?`Default`:b.find(e=>e.id===d).label,value:d,disabled:S,readOnly:_===!0,disabledHint:_?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=Ke(u,n,y.data);t({...e,model:n,effort:e.effort===null?null:Be(e.effort,r)})},options:b.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:ze(u,y.data,y.isError,y.isFetching)},`model`),E=(0,Y.jsx)(W,{icon:(0,Y.jsx)(te,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:p.find(e=>e.value===f)?.label??`auto`,value:f,disabled:S,readOnly:_===!0,disabledHint:_?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:p.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,Y.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,Y.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,Y.jsx)(Ee,{children:s?[w,E,T]:[w,T,E]})})}):(0,Y.jsxs)(Ee,{children:[w,T,E]})}var dn={workflow:null,skills:[]},fn=`cez-followup-selection`;function pn(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.flatMap(e=>typeof e==`string`?[{id:e}]:!e||typeof e!=`object`||typeof e.id!=`string`?[]:[{id:e.id,...typeof e.path==`string`?{path:e.path}:{}}]):[]}}function mn(){try{let e=localStorage.getItem(fn);return e?pn(JSON.parse(e)):{...dn}}catch{return{...dn}}}function hn(e){try{localStorage.setItem(fn,JSON.stringify(e))}catch{}}var $=`cez-followup-prompt:`;function gn(e){try{return localStorage.getItem($+e)??``}catch{return``}}function _n(e,t){try{t===``?localStorage.removeItem($+e):localStorage.setItem($+e,t)}catch{}}function vn({item:e,workflows:r,skills:i,workflow:a,onWorkflowChange:s,selectedSkills:l,onSkillsChange:u,engine:d,onEngineChange:f,queuedRunId:h,onQueued:g}){let _=p(),v=S(),y=_e(),x=e.kind===`pr`?`PR`:`issue`,w=sn(d),T=m(w.runner,w.account),E=l.filter(e=>T.unchecked||e.path===void 0||i.some(t=>t.id===e.id&&(e.path===void 0||t.path===e.path))),D=E.length!==l.length,[O]=(0,J.useState)(()=>Qt(e)),[k,j]=(0,J.useState)(()=>gn(e.url)||O),N=(0,J.useRef)(null),P=(0,J.useRef)(null);(0,J.useEffect)(()=>{_n(e.url,k===O?``:k)},[e.url,k,O]);let F=(0,J.useMemo)(()=>De(Ae(v.data?.promptTemplates),{automations:y}),[v.data?.promptTemplates,y]),ee=e=>{let t=N.current,n=Ce({prompt:k,base:O,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:P.current}),r=xe(k,n,e);j(r.text),P.current=r.caret,requestAnimationFrame(()=>{N.current?.focus(),N.current?.setSelectionRange(r.caret,r.caret)})},te=ke(F,E.map(e=>e.id)),I=(0,J.useRef)(k);I.current=k;let L=(0,J.useRef)(``);(0,J.useEffect)(()=>{let e=Se(I.current,L.current,te,O);L.current=e.applied,e.text!==I.current&&j(e.text)},[te,O]);let R=b({mutationFn:async()=>!w.canRun||D?null:o(on(e,a,E,k,ln(w))),onSuccess:t=>{if(t===null)return;let n=t;n&&g(e.url,n.id),A(`Added to the queue — ${x} #${e.number}`),E.length>0&&v.data!==void 0&&c({skillUsage:E.reduce((e,t)=>Le(e,t.id),v.data.skillUsage)}).then(()=>_.invalidateQueries({queryKey:C.uiState})).catch(()=>{}),_n(e.url,``),j(O),L.current=``,_.invalidateQueries({queryKey:C.runs.all})},onError:e=>A(e.message,{tone:`danger`})}),ne=e=>{Ye({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!R.isPending&&w.canRun&&R.mutate())},z=e=>u(l.some(t=>q(t)===q(e))?l.filter(t=>q(t)!==q(e)):[...l,Ie(e)]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,Y.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,Y.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,Y.jsx)(`span`,{children:`Instructions for the agent`}),(0,Y.jsx)(Ze,{ref:N,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:k,onChange:e=>j(e.target.value),onSelect:e=>{P.current=e.currentTarget.selectionStart},onKeyDown:ne,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,Y.jsx)(ge,{templates:F,onInsert:ee}),(0,Y.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,Y.jsxs)(`div`,{className:`gh-field`,children:[(0,Y.jsx)(`span`,{children:`Workflow`}),(0,Y.jsx)(bn,{workflows:r,value:a,onChange:s})]}),(0,Y.jsxs)(`div`,{className:`gh-field`,children:[(0,Y.jsx)(`span`,{children:`Skills · select one or more`}),(0,Y.jsx)(Sn,{skills:i,skillUsage:v.data?.skillUsage,selected:l,onToggle:z})]}),l.length>0?(0,Y.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:l.map(e=>(0,Y.jsx)(yn,{skill:e,skills:i,unchecked:T.unchecked,onRemove:()=>z(e)},q(e)))}):null,D?(0,Y.jsx)(`p`,{role:`alert`,children:`A selected skill path is unavailable. Remove it or choose a current copy before starting.`}):null,(0,Y.jsx)(un,{layout:`row`,pick:d,onChange:f,disabled:R.isPending||!w.canRun,accounts:!0}),(0,Y.jsxs)(`div`,{className:`gh-field`,children:[(0,Y.jsx)(`span`,{children:`Account`}),(0,Y.jsx)(xn,{resolved:w,disabled:R.isPending||!w.canRun,onPick:e=>f({...d,account:e})})]}),!w.providerPending&&!w.canRun?(0,Y.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[w.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,Y.jsx)(U,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,Y.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,Y.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[t(e.url)?(0,Y.jsx)(n,{asChild:!0,variant:`outline`,children:(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,Y.jsxs)(n,{variant:`primary`,"data-action":`gh-run`,disabled:R.isPending||!w.canRun||D,onClick:()=>R.mutate(),children:[(0,Y.jsx)(le,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,x]}),(0,Y.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:Xe()}),h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,Y.jsx)(U,{to:`/tasks/${h}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function yn({skill:e,skills:t,unchecked:n,onRemove:r}){let i=t.find(t=>t.id===e.id&&(e.path===void 0||t.path===e.path)),a=[i?.name??e.id,e.path].filter(Boolean).join(` · `),o=!n&&e.path!==void 0&&!i?` (unavailable)`:n||!i?` (unchecked)`:``;return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e.id,onClick:r,title:`Remove skill ${a}`,"aria-label":`Remove skill ${a}`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[a,o,(0,Y.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3`})]})}function bn({workflows:e,value:t,onChange:n}){let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(``),c=(0,J.useRef)(null),l=Me(e,o);return(0,Y.jsxs)(O,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(ye,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,Y.jsx)(ie,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,Y.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,Y.jsx)(I,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Y.jsx)(E,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Y.jsxs)(we,{shouldFilter:!1,children:[(0,Y.jsx)(be,{placeholder:`search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,Y.jsxs)(ve,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Y.jsx)(je,{children:`Nothing matches.`}):null,(0,Y.jsx)(K,{children:l.map(e=>{let r=t===e.name;return(0,Y.jsxs)(G,{value:`workflow ${e.name}`,keywords:Fe(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),a(!1)},children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function xn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:Te,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,Y.jsx)(W,{icon:(0,Y.jsx)(N,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function Sn({skills:e,skillUsage:t,selected:n,onToggle:i}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(null),d=(0,J.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=Re(e,s,t),g=(e,t)=>{let a=n.some(t=>q(t)===q(e));return(0,Y.jsxs)(G,{value:q(e),keywords:Fe(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.id,"data-selected":a?`true`:void 0,onSelect:()=>i(Ie(e)),children:[(0,Y.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.path?(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:e.path}):null,e.description?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,Y.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Y.jsx)(oe,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,Y.jsx)(M,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},q(e))};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Je,{skill:l,onClose:()=>u(null)}),(0,Y.jsxs)(O,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,Y.jsx)(D,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:r(ye,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,Y.jsx)(z,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,Y.jsx)(I,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Y.jsx)(E,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Y.jsxs)(we,{shouldFilter:!1,children:[(0,Y.jsx)(be,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,Y.jsxs)(ve,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[s.trim()&&!e.some(e=>e.id===s.trim())?(0,Y.jsx)(K,{children:(0,Y.jsxs)(G,{value:`typed-skill`,onSelect:()=>i({id:s.trim()}),children:[`Use skill id “`,s.trim(),`” (unchecked)`]})}):null,(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,Y.jsx)(je,{children:`Nothing matches.`}):null,h?h.length>0?(0,Y.jsx)(K,{children:h.map(e=>g(e,Ne(e)))}):null:(0,Y.jsxs)(Y.Fragment,{children:[f.length>0?(0,Y.jsx)(K,{heading:`Most used`,children:f.map(e=>g(e,Ne(e)))}):null,p.length>0?(0,Y.jsx)(K,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,Y.jsx)(K,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var Cn=new WeakMap;function wn(){let e=mn(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&hn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Tn(){let e=p(),{projectId:t}=d(),n=Cn.get(e);n||Cn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=wn());let{snapshot:i,subscribe:a,update:o}=r,s=(0,J.useSyncExternalStore)(a,i,i),c=g(),l=sn(s.engine),u=m(l.runner,l.account),f=S(),h=c.data?.workflows;(0,J.useEffect)(()=>{h&&s.workflow!==null&&!h.some(e=>e.name===s.workflow)&&o({workflow:null})},[o,h,s.workflow]);let _=(0,J.useMemo)(()=>Pe(u.data??[],f.data?.skillUsage),[u.data,f.data?.skillUsage]);return{...s,workflows:c,skillList:_,skillsUnchecked:u.unchecked,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{Yt as a,Nt as c,Q as d,bt as f,Zt as i,vt as l,vn as n,kt as o,$t as r,xt as s,Tn as t,yt as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Br as e,kr as t}from"./project-scope-context-BUXmC8my.js";function n(n,r){return t(n,e,r)}export{n as t};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{A as o,Kt as s,T as c,Ut as l,i as u,zr as d}from"./project-scope-context-BUXmC8my.js";import{Bt as f,Ft as p,Zt as m,jt as ee,n as te}from"./queries-DkipLnOL.js";import{n as h}from"./toaster-CoMJoQvk.js";import{J as g,S as _,X as v,at as y,b as ne,c as re,ft as ie,i as b,l as x,lt as S,n as ae,ot as oe,st as C,tt as se,v as w,x as T}from"./design-icons-B6-0w7Aw.js";import{i as E,p as ce,r as D,t as O}from"./dropdown-menu-CzUYjvx4.js";import{i as k,o as A,r as j,s as le,t as M}from"./dialog-tMSuX5a7.js";import{_ as ue,a as de,d as fe,g as pe,h as N,i as P,l as me,m as F,o as he,p as ge,r as _e,s as ve,t as ye,v as I}from"./sortable.esm-zp_qkYGV.js";import{i as L,l as be,o as xe}from"./skills-pM_PouEs.js";import{t as Se}from"./centered-state-B5QmAy2y.js";import{O as Ce,V as R,Yt as z,ct as B,dt as V,ft as H,lt as U,mt as W,pt as G,st as K,ut as we}from"./index-QM9AFNSj.js";var q=e(i(),1);function J(e){let t=[];for(let n of e){if(n.command||!n.skill||n.prompt!==void 0&&n.prompt!==`{{task}}`||n.name!==void 0&&n.name!==n.skill||n.timeoutMs!==void 0||n.model||n.effort!==void 0||n.runner||n.agentProfile||n.allowedTools||n.bashAllowlist||n.onFail)return null;t.push(n.skill)}return t.length?t:null}function Te(e,t){let n=new Set(t.map(e=>e.id)),r=e;for(let t=2;n.has(r);t++)r=`${e}-${t}`;return{id:r,name:e,skill:e,prompt:`{{task}}`}}function Ee(e,t,n){let r=[...e];return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function De(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}function Oe(e,t){return e.filter((e,n)=>n!==t)}function Y(e){let t=String(e),n=/^[A-Za-z0-9._][A-Za-z0-9 ._/-]*$/.test(t)&&!t.endsWith(` `),r=/^(true|false|yes|no|on|off|null|~)$/i.test(t)||/^[-+.]?\d/.test(t);return n&&!r?t:JSON.stringify(t)}function X(e,t,n){let r=` `.repeat(n);return t.includes(`
|
|
2
|
-
`)?[`${r}${e}: |`,...t.split(`
|
|
3
|
-
`).map(e=>`${r} ${e}`)]:[`${r}${e}: ${Y(t)}`]}function ke(e){let t=[];return e.name&&e.name!==e.id&&t.push(` name: ${Y(e.name)}`),e.skill&&t.push(` skill: ${Y(e.skill)}`),t}function Ae(e){let t=[];return e.model&&t.push(` model: ${Y(e.model)}`),e.timeoutMs!==void 0&&t.push(` timeoutMs: ${e.timeoutMs}`),e.effort!==void 0&&t.push(` effort: ${Y(e.effort)}`),e.runner&&t.push(` runner: ${Y(e.runner)}`),e.agentProfile&&t.push(` agentProfile: ${Y(e.agentProfile)}`),t}function Z(e){let t=[];return e.allowedTools&&t.push(` allowedTools: [${e.allowedTools.map(Y).join(`, `)}]`),e.bashAllowlist&&t.push(` bashAllowlist: [${e.bashAllowlist.map(Y).join(`, `)}]`),t}function je(e){return e.onFail?[` onFail:`,` retry: ${Y(e.onFail.retry)}`,` max: ${e.onFail.max??2}`]:[]}function Me(e){return[` - id: ${Y(e.id)}`,...ke(e),...e.prompt?X(`prompt`,e.prompt,4):[],...Ae(e),...Z(e),...e.command?X(`command`,e.command,4):[],...je(e)]}function Ne(e,t,n){let r=[`name: ${Y(e.trim()||`my-workflow`)}`];t.trim()&&r.push(...X(`description`,t.trim(),0));let i=J(n);if(i){r.push(`skills:`);for(let e of i)r.push(` - ${Y(e)}`)}else if(n.length){r.push(`steps:`);for(let e of n)r.push(...Me(e))}else r.push(`skills: []`);return`${r.join(`
|
|
4
|
-
`)}\n`}function Pe(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`workflow`}function Fe(e){let t=J(e)?`skill`:`step`;return`${e.length} ${t}${e.length===1?``:`s`}`}function Ie(e,t){let n=new Set,r=[];for(let t of e.steps.slice(0,8)){let e=t.id||`step`,i=e;for(let t=2;n.has(i);t++)i=`${e}-${t}`;n.add(i),r.push({...t,id:i})}return{name:e.name?.trim()||t,steps:r}}function Le(e,t,n){let r=J(n);return{name:e.trim(),...t.trim()?{description:t.trim()}:{},...r?{skills:r}:{steps:[...n]}}}var Q=a();function Re(){return(0,Q.jsx)(Q.Fragment,{children:`No skills reported by this runner and account. You can type a skill id in Add step.`})}function ze({workflows:e,draft:t,trimmedName:n,nameRef:r,onDraft:i,onLoadWorkflow:a}){return(0,Q.jsxs)(`section`,{"data-slot":`wb-metadata`,className:`flex min-w-0 flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{"data-slot":`wb-load`,className:`flex flex-col items-start gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`workflow-load`,className:`text-xs text-muted-foreground`,children:`Load an existing workflow`}),(0,Q.jsxs)(`div`,{className:`relative max-w-full`,children:[(0,Q.jsx)(x,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsxs)(`select`,{id:`workflow-load`,value:e.some(e=>e.name===n)?n:``,onChange:t=>{let n=e.find(e=>e.name===t.target.value);n&&a(n)},className:`h-11 max-w-full rounded-lg border border-border bg-card pl-9 pr-3 text-xs font-medium appearance-none focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`option`,{value:``,disabled:!0,children:`Choose a workflow`}),e.map(e=>(0,Q.jsx)(`option`,{value:e.name,"data-slot":`wb-load-option`,"data-name":e.name,children:e.name},e.name))]})]})]}),(0,Q.jsx)(`label`,{htmlFor:`workflow-name`,className:`text-xs font-semibold`,children:`Workflow name`}),(0,Q.jsx)(z,{id:`workflow-name`,ref:r,"data-slot":`wb-name`,"aria-label":`Workflow name`,spellCheck:!1,value:t.name,onChange:e=>i({...t,name:e.target.value}),className:`h-12 bg-card text-sm`}),(0,Q.jsx)(`label`,{htmlFor:`workflow-description`,className:`text-xs font-semibold`,children:`Description`}),(0,Q.jsx)(R,{id:`workflow-description`,"data-slot":`wb-description`,"aria-label":`Description`,value:t.description,onChange:e=>i({...t,description:e.target.value}),className:`min-h-[72px] bg-card p-3.5 text-sm`})]})}function Be({savedFile:e,autoOpen:t,onImportToggle:r,onExport:i,onAutoToggle:a,onDeleteRequest:o}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-actions`,className:`grid grid-cols-[max-content_max-content] items-center justify-start gap-2 sm:flex sm:flex-wrap [&_button]:min-h-11 [&_button]:border [&_button]:border-border [&_button]:bg-card`,children:[(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import`,className:`col-span-2 justify-self-start`,onClick:r,children:[(0,Q.jsx)(C,{"aria-hidden":`true`,className:`size-3`}),`Import`]}),(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-export`,className:`col-span-2 justify-self-start`,title:`Download workflow.yaml`,onClick:i,children:[(0,Q.jsx)(ne,{"aria-hidden":`true`,className:`size-3`}),`Export`]}),(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto`,"aria-expanded":t,title:`Describe a chain — the agent builds it`,onClick:a,children:[(0,Q.jsx)(S,{"aria-hidden":`true`,className:`size-3`}),`Auto`]}),e?(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-delete`,className:`text-danger hover:text-danger`,title:`Delete the saved workflow file`,onClick:o,children:[(0,Q.jsx)(y,{"aria-hidden":`true`,className:`size-3`}),`Delete`]}):null]})}function Ve({text:e,onTextChange:t,pending:r,onRun:i,onCancel:a}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-auto-panel`,className:`rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-normal`,children:`Build a chain from a prompt`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] leading-relaxed text-muted-foreground`,children:`Describe the outcome. An agent proposes a title and ordered skill/check steps. Review the result, edit it, then Save.`}),(0,Q.jsx)(R,{"data-slot":`wb-auto-text`,"aria-label":`Describe the chain to build`,rows:3,autoFocus:!0,placeholder:`e.g. Fix the bug, run the tests, then review the diff for regressions.`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),i())},className:`mt-4 min-h-[108px] bg-background p-4 text-sm`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsxs)(n,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-auto-run`,disabled:r||e.trim()===``,onClick:i,children:[(0,Q.jsx)(S,{"aria-hidden":`true`,className:`size-3`}),r?`Building…`:`Build chain`]}),(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto-cancel`,onClick:a,children:[(0,Q.jsx)(ie,{"aria-hidden":`true`,className:`size-4`}),`Cancel`]})]}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Creates an editable draft. Review the generated name and steps before saving.`})]})}function He({open:e,onOpenChange:t,text:r,onTextChange:i,error:a,pending:o,onRun:s,onCancel:c}){return(0,Q.jsx)(M,{open:e,onOpenChange:t,children:(0,Q.jsxs)(j,{showCloseButton:!1,"data-slot":`wb-import-panel`,className:`max-md:translate-x-0 max-md:translate-y-0 sm:max-w-[660px] rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,Q.jsx)(le,{className:`text-xl font-normal`,children:`Import workflow YAML`}),(0,Q.jsx)(k,{className:`sr-only`,children:`Paste a portable workflow definition to import.`}),(0,Q.jsx)(R,{"data-slot":`wb-import-text`,"aria-label":`Workflow YAML to import`,rows:4,spellCheck:!1,placeholder:`name: my-flow
|
|
5
|
-
skills:
|
|
6
|
-
- test-conventions
|
|
7
|
-
- commit-style`,value:r,onChange:e=>i(e.target.value),className:`mt-4 min-h-[124px] bg-background p-4 font-mono text-[13px] leading-relaxed`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Paste a portable workflow definition. Imported steps appear in execution order.`}),a===``?null:(0,Q.jsx)(`p`,{"data-slot":`wb-import-error`,role:`alert`,className:`mt-2 text-xs text-danger`,children:a}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(n,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-import-run`,disabled:o,onClick:s,children:`Import`}),(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import-cancel`,onClick:c,children:`Cancel`})]})]})})}function Ue({paletteSkills:e,query:t,onQueryChange:n,error:r,inFlow:i,onAdd:a,yaml:o}){return(0,Q.jsxs)(`aside`,{"data-slot":`wb-aside`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:`Available skills`}),(0,Q.jsxs)(`div`,{className:`sw-search relative mt-4`,children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(z,{"data-slot":`wb-filter`,placeholder:`Find a skill…`,"aria-label":`Filter skills`,value:t,onChange:e=>n(e.target.value),className:`h-11 pl-9 text-xs`})]}),(0,Q.jsx)(rt,{skills:e,query:t,error:r,inFlow:i,onAdd:a}),(0,Q.jsx)(`h3`,{className:`mt-5 text-sm font-semibold`,children:`workflow.yaml`}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-muted-foreground`,children:`Export the workflow to use this chain in another project.`}),(0,Q.jsxs)(`details`,{className:`mt-4 min-w-0`,children:[(0,Q.jsxs)(`summary`,{"data-slot":`wb-yaml-toggle`,className:`inline-flex min-h-[44px] cursor-pointer items-center rounded-lg border border-border px-3 text-xs font-medium focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(_,{"aria-hidden":`true`,className:`mr-2 size-4`}),`View YAML`]}),(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsx)(at,{yaml:o})}),(0,Q.jsx)(`pre`,{"data-slot":`wb-yaml`,className:`mt-2 max-h-96 overflow-auto rounded-lg border border-border bg-background p-3 font-mono text-[11px] leading-relaxed whitespace-pre text-muted-foreground`,children:o})]})]})}function We({dragging:e,steps:t,skills:n}){return e?.type===`palette`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-[13px] font-medium shadow-md`,children:[(0,Q.jsx)(se,{"aria-hidden":`true`,className:`size-3.5 text-link-foreground`}),e.skill]}):e?.type===`step`?(0,Q.jsx)(nt,{step:e.step,index:t.findIndex(t=>t.id===e.step.id),skills:n,overlay:!0}):null}function Ge({open:e,onOpenChange:t,query:r,onQueryChange:i,matches:a,skillsCount:o,error:s,selectedSkill:c,onSelectSkill:l,stepsCount:u,onCloseAutoFocus:d,onCancel:f,onAdd:p}){return(0,Q.jsx)(M,{open:e,onOpenChange:t,children:(0,Q.jsxs)(j,{"data-slot":`wb-add-dialog`,onCloseAutoFocus:d,className:`max-h-[85dvh] overflow-y-auto sm:max-w-[660px] [&_button]:min-h-11`,children:[(0,Q.jsxs)(A,{children:[(0,Q.jsx)(le,{className:`text-xl font-normal`,children:`Add step`}),(0,Q.jsx)(k,{className:`sr-only`,children:`Choose a skill to append to this workflow.`})]}),(0,Q.jsx)(z,{"aria-label":`Filter skills`,placeholder:`Filter skills…`,value:r,onChange:e=>i(e.target.value)}),s===null?(0,Q.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Available skills`,className:`grid max-h-80 gap-2 overflow-y-auto`,children:[a.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg py-2 has-[:checked]:bg-accent-strong/10 has-[:focus-visible]:outline-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`workflow-add-skill`,className:`sr-only`,value:e.id,checked:c===e.id,onChange:()=>l(e.id)}),(0,Q.jsxs)(`span`,{className:`min-w-0 break-words text-sm`,children:[(0,Q.jsx)(`span`,{className:`block`,children:e.name}),(0,Q.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.description}),e.path?(0,Q.jsx)(`span`,{className:`block break-all text-xs`,children:e.path}):null]})]},JSON.stringify([e.id,e.path]))),a.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o===0?`No skills available in this project.`:`No matching skills.`}):null]}):(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not load skills: `,s]}),r.trim()&&!a.some(e=>e.id===r.trim())?(0,Q.jsxs)(n,{onClick:()=>l(r.trim()),children:[`Use skill id “`,r.trim(),`” (unchecked)`]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(n,{variant:`outline`,onClick:f,children:`Cancel`}),(0,Q.jsx)(n,{variant:`primary`,disabled:!c||u>=8,onClick:()=>{c&&p(c)},children:`Add selected skill`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Append the selected skill, then reorder it in the existing canvas.`}),u>=8?(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`A workflow can contain up to `,8,` steps. Remove a step before adding another.`]}):null]})})}function Ke({trimmedName:e,savedFile:t,overwriteOpen:n,onOverwriteDismiss:r,deleteOpen:i,onDeleteDismiss:a,onOverwrite:o,onDelete:s}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(K,{open:n,onOpenChange:e=>!e&&r(),children:(0,Q.jsxs)(we,{"data-slot":`wb-overwrite-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(G,{children:[(0,Q.jsxs)(W,{children:[`“`,e,`” already exists`]}),(0,Q.jsx)(V,{children:`Saving overwrites the existing workflow file. There is no undo.`})]}),(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{children:`Keep the file`}),(0,Q.jsx)(B,{"data-slot":`wb-overwrite-confirm`,className:`bg-danger text-danger-foreground`,onClick:o,children:`Overwrite`})]})]})}),(0,Q.jsx)(K,{open:i,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(we,{"data-slot":`wb-delete-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(G,{children:[(0,Q.jsxs)(W,{children:[`Delete workflow “`,e,`”?`]}),(0,Q.jsxs)(V,{children:[`Removes `,t?.path?.split(`/`).pop()??`the saved file`,` from`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/workflows/`}),`. There is no undo.`]})]}),(0,Q.jsxs)(H,{children:[(0,Q.jsx)(U,{children:`Keep the file`}),(0,Q.jsx)(B,{"data-slot":`wb-delete-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:s,children:`Delete workflow`})]})]})})]})}function qe(e){return e.name??e.skill??e.id}function Je(e){return e.prompt?.trim()===`{{task}}`?void 0:e.prompt?.trim()}function Ye(e){let t=e.onFail?` — on fail retry from "${e.onFail.retry}" (×${e.onFail.max??2})`:``;return`$ ${e.command}${t}`}function Xe(e,t){return Je(e)||t?.description||`Not listed by this runner and account. Step open will check the skill id.`}function Ze(e,t){return e.command?Ye(e):e.skill?Xe(e,t):e.prompt??``}function Qe(e,t){return e.skill&&!t?`unknown`:null}function $e(e){return e.command?`Command step${e.onFail?` · Retry ×${e.onFail.max??2}`:``}`:e.skill?`Skill step`:`Prompt step`}function et({index:e,title:t,badge:i,onRemove:a,gripProps:o}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-step-heading`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-step-grip`,"aria-label":`Reorder step ${e+1}: ${t}`,className:`inline-flex size-[26px] shrink-0 cursor-grab items-center justify-center rounded-md text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,...o,children:(0,Q.jsx)(`span`,{className:`rounded bg-accent-strong/10 px-2 py-1 font-mono text-[12px] text-link-foreground`,children:String(e+1).padStart(2,`0`)})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 break-words text-sm font-medium [overflow-wrap:anywhere]`,children:t}),i?(0,Q.jsx)(`span`,{"data-slot":`wb-step-badge`,className:r(`shrink-0 rounded-full border px-2 py-px font-mono text-[11px]`,i===`unknown`&&`border-danger/35 text-danger`),children:i}):null,a?(0,Q.jsxs)(O,{children:[(0,Q.jsx)(ce,{asChild:!0,children:(0,Q.jsx)(n,{"data-slot":`wb-step-actions`,variant:`ghost`,size:`icon`,className:`size-[26px]`,"aria-label":`Step ${e+1} actions: ${t}`,children:(0,Q.jsx)(T,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(D,{align:`end`,children:(0,Q.jsxs)(E,{"data-slot":`wb-step-remove`,"aria-label":`Remove step ${e+1}: ${t}`,onSelect:a,children:[(0,Q.jsx)(y,{"aria-hidden":`true`}),` Remove step`]})})]}):null]})}function tt({index:e,onMoveUp:t,onMoveDown:r}){return(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 @min-[900px]:hidden`,children:[(0,Q.jsxs)(n,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} up`,disabled:!t,onClick:t,children:[(0,Q.jsx)(b,{"aria-hidden":`true`,className:`size-4`}),`Move up`]}),(0,Q.jsxs)(n,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} down`,disabled:!r,onClick:r,children:[(0,Q.jsx)(ae,{"aria-hidden":`true`,className:`size-4`}),`Move down`]})]})}function nt({step:e,index:t,skills:n,onRemove:i,gripProps:a,onMoveUp:o,onMoveDown:s,overlay:c=!1}){let l=n.find(t=>t.id===e.skill),u=qe(e),d=Ze(e,l),f=Qe(e,l);return(0,Q.jsxs)(`div`,{"data-slot":`wb-step`,"data-id":e.id,"data-index":t,className:r(`rounded-lg border border-border bg-background p-4`,c&&`shadow-md`),children:[(0,Q.jsx)(et,{index:t,title:u,badge:f,onRemove:i,gripProps:a}),d?(0,Q.jsx)(`div`,{"data-slot":`wb-step-summary`,className:`mt-3 break-words text-xs leading-relaxed text-muted-foreground`,children:d}):null,(0,Q.jsx)(`p`,{"data-slot":`wb-step-kind`,className:`mt-3 text-[12px] text-link-foreground`,children:$e(e)}),c?null:(0,Q.jsx)(tt,{index:t,onMoveUp:o,onMoveDown:s})]})}function rt({skills:e,query:t,error:n,inFlow:r,onAdd:i}){if(n!==null)return(0,Q.jsxs)(`p`,{"data-slot":`wb-palette`,className:`mt-2.5 text-xs text-danger`,children:[`Could not load skills: `,n]});let a=be(e,t);return(0,Q.jsx)(`div`,{"data-slot":`wb-palette`,className:`mt-2.5 flex flex-col gap-1`,children:a.length>0?a.map(e=>(0,Q.jsx)(it,{skill:e,inFlow:r.has(e.id),onAdd:i},JSON.stringify([e.id,e.path]))):(0,Q.jsx)(`p`,{className:`py-1 text-xs leading-relaxed text-soft-foreground`,children:e.length>0?`No skills match.`:(0,Q.jsx)(Re,{})})})}function it({skill:e,inFlow:t,onAdd:n}){let{attributes:i,listeners:a,setNodeRef:o,isDragging:s}=F({id:`palette:${JSON.stringify([e.id,e.path])}`,data:{type:`palette`,skill:e.id}});return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`wb-skill`,"data-skill":e.id,"data-in-flow":t||void 0,title:e.description??``,className:r(`flex min-h-11 cursor-grab items-center gap-2 rounded-md py-1 transition-colors hover:bg-muted`,s&&`opacity-40`),...i,...a,children:[(0,Q.jsxs)(`span`,{className:r(`min-w-0 flex-1 break-words text-xs`,L(e)?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:[e.name,e.path?(0,Q.jsx)(`span`,{className:`block break-all text-xs text-soft-foreground`,children:e.path}):null]}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-skill-add`,"aria-label":`Add ${e.name} to the flow`,title:`Add to the flow`,onClick:()=>n(e.id),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-link-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,Q.jsx)(g,{"aria-hidden":`true`,className:`size-3.5`})})]})}function at({yaml:e}){let[t,n]=(0,q.useState)(!1),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-copy`,title:`Copy the YAML`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),1600)},className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(re,{"aria-hidden":`true`,className:`size-3 text-success`}),`Copied`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(w,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})})}var ot=`wb-canvas`;function $(){return{name:`my-workflow`,description:``,steps:[]}}function st(e){return{name:e.name,description:e.description??``,steps:structuredClone(e.steps??[])}}function ct(){let{name:e}=t();return(0,Q.jsx)(lt,{routeName:e},e??``)}function lt({routeName:e}){let t=p(),r=f(),i=ee(),a=d(),[_,v]=(0,q.useState)(null),[y,ne]=(0,q.useState)(``),[ie,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(``),[ae,C]=(0,q.useState)(null),[se,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(``),[ce,D]=(0,q.useState)(``),[O,k]=(0,q.useState)(!1),[A,j]=(0,q.useState)(``),[le,M]=(0,q.useState)(!1),[de,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(null),[ye,I]=(0,q.useState)(null),L=(0,q.useRef)(null),R=(0,q.useRef)(null),z=t.data?.workflows??[],B=r.data??[],V=xe(B,i.data?.skillUsage),H=be(V,x,i.data?.skillUsage);(0,q.useEffect)(()=>{if(_!==null||t.data===void 0)return;let n=t.data.workflows,r=(e?n.find(t=>t.name===e):void 0)??n.find(e=>e.source===`file`);v(r?st(r):$())},[_,t.data,e]);let U=e=>v(t=>t===null?t:{...t,steps:e}),W=m({mutationFn:e=>l(e),onSuccess:e=>{v({name:e.name,description:e.description??``,steps:e.steps}),w(!1),E(``),D(``),h(`Imported "${e.name}" — review, then Save.`)},onError:e=>D(e.message)}),G=m({mutationFn:e=>s(e),onSuccess:e=>{v(t=>{let n=t??$(),{name:r,steps:i}=Ie(e,n.name);return{...n,name:r,steps:i}}),k(!1),j(``),h(e.fallback?`Planner unavailable — added a single step. Edit, then Save.`:`Built "${e.name??_?.name??`workflow`}" — review, tweak, then Save.`,e.fallback?{tone:`danger`}:void 0)},onError:e=>h(e instanceof Error?e.message:String(e),{tone:`danger`})}),K=m({mutationFn:e=>c({...Le(_?.name??``,_?.description??``,_?.steps??[]),...e?{overwrite:!0}:{}}),onSuccess:e=>{M(!1),h(`Saved — ${e.path.split(`/`).pop()??e.path}`),a.invalidateQueries({queryKey:te.workflows})},onError:e=>{e instanceof u&&e.exists===!0?M(!0):h(e instanceof Error?e.message:String(e),{tone:`danger`})}}),we=m({mutationFn:e=>o(e),onSuccess:(e,t)=>{N(!1),h(`Deleted "${t}".`),v($()),a.invalidateQueries({queryKey:te.workflows})},onError:e=>{N(!1),h(e instanceof Error?e.message:String(e),{tone:`danger`})}}),J=ue(pe(fe,{activationConstraint:{distance:4}}),pe(me,{coordinateGetter:_e}));if(t.isError)return(0,Q.jsx)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,Q.jsx)(Se,{icon:(0,Q.jsx)(oe,{}),tone:`danger`,title:`Could not load workflows`,subtitle:t.error.message})});if(_===null)return(0,Q.jsx)(Ce,{});let Y=_.steps,X=_.name.trim(),ke=z.find(e=>e.name===X&&e.source===`file`),Ae=Ne(_.name,_.description,Y),Z=(e,t=Y.length)=>{if(Y.length>=8){h(`A workflow holds at most 8 steps.`,{tone:`danger`});return}U(Ee(Y,Te(e,Y),t))};return(0,Q.jsxs)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`mb-[22px] flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Portable skill chains. Steps run from top to bottom.`})]}),(0,Q.jsxs)(n,{variant:`primary`,"data-slot":`wb-new`,className:`min-h-11`,onClick:()=>v($()),children:[(0,Q.jsx)(g,{"aria-hidden":`true`,className:`size-4`}),`New workflow`]})]}),(0,Q.jsxs)(he,{sensors:J,collisionDetection:ge,onDragStart:e=>{let t=e.active.data.current;F(t??null)},onDragOver:e=>{I(e.over?String(e.over.id):null)},onDragEnd:e=>{F(null),I(null);let{active:t,over:n}=e;if(n===null)return;let r=t.data.current;if(r?.type===`palette`){let e=n.id===ot?Y.length:Y.findIndex(e=>e.id===n.id);Z(r.skill,e===-1?Y.length:e);return}if(n.id===t.id)return;let i=Y.findIndex(e=>e.id===t.id),a=Y.findIndex(e=>e.id===n.id);i!==-1&&a!==-1&&U(De(Y,i,a))},onDragCancel:()=>{F(null),I(null)},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[22px] pb-[calc(32px+env(safe-area-inset-bottom))]`,children:[(0,Q.jsx)(ze,{workflows:z,draft:_,trimmedName:X,nameRef:L,onDraft:v,onLoadWorkflow:e=>v(st(e))}),(0,Q.jsx)(Be,{savedFile:ke,autoOpen:O,onImportToggle:()=>{D(``),k(!1),w(e=>!e)},onExport:()=>{let e=new Blob([Ae],{type:`text/yaml`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${Pe(_.name)}.yaml`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},onAutoToggle:()=>{w(!1),k(e=>!e)},onDeleteRequest:()=>N(!0)}),O?(0,Q.jsx)(Ve,{text:A,onTextChange:j,pending:G.isPending,onRun:()=>{let e=A.trim();e===``||G.isPending||G.mutate(e)},onCancel:()=>{k(!1),j(``)}}):null,(0,Q.jsx)(He,{open:se,onOpenChange:w,text:T,onTextChange:E,error:ce,pending:W.isPending,onRun:()=>{let e=T.trim();e!==``&&W.mutate(e)},onCancel:()=>{w(!1),E(``),D(``)}}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] @min-[700px]:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`section`,{"data-slot":`wb-main`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Steps · `,Y.length,` of `,8,(0,Q.jsx)(`span`,{"data-slot":`wb-count`,className:`sr-only`,children:Fe(Y)})]}),(0,Q.jsx)(ut,{steps:Y,skills:B,dragging:P!==null,overId:ye,activeStepId:P?.type===`step`?P.step.id:null,onRemove:e=>U(Oe(Y,e)),onMove:(e,t)=>U(De(Y,e,t))}),(0,Q.jsxs)(n,{ref:R,variant:`outline`,className:`mt-4 min-h-11`,onClick:()=>{C(null),S(``),b(!0)},children:[(0,Q.jsx)(g,{"aria-hidden":`true`,className:`size-4`}),`Add step`]}),(0,Q.jsxs)(`p`,{className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`hidden @min-[900px]:inline`,children:`Drag to reorder. The agent follows this sequence from top to bottom.`}),(0,Q.jsx)(`span`,{className:`@min-[900px]:hidden`,children:`Use Move up / Move down to reorder without dragging.`})]}),(0,Q.jsxs)(`footer`,{className:`mt-4 flex flex-wrap items-center justify-between gap-4 border-t border-border pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Review the name and steps, then save to a workflow file.`}),(0,Q.jsxs)(n,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 max-sm:w-full`,"data-slot":`wb-save`,disabled:K.isPending,onClick:()=>{if(X===``){L.current?.focus();return}if(Y.length===0){h(`Add at least one step first.`,{tone:`danger`});return}K.mutate(!1)},children:[(0,Q.jsx)(re,{"aria-hidden":`true`,className:`size-3`}),`Save`]})]})]}),(0,Q.jsx)(Ue,{paletteSkills:V,query:y,onQueryChange:ne,error:r.isError?r.error.message:null,inFlow:new Set(Y.map(e=>e.skill).filter(e=>!!e)),onAdd:e=>Z(e),yaml:Ae})]})]}),(0,Q.jsx)(ve,{children:(0,Q.jsx)(ft,{dragging:P,steps:Y,skills:B})})]}),(0,Q.jsx)(Ge,{open:ie,onOpenChange:b,query:x,onQueryChange:S,matches:H,skillsCount:B.length,error:r.isError?r.error.message:null,selectedSkill:ae,onSelectSkill:C,stepsCount:Y.length,onCloseAutoFocus:e=>{e.preventDefault(),R.current?.focus()},onCancel:()=>b(!1),onAdd:e=>{Z(e),b(!1)}}),(0,Q.jsx)(Ke,{trimmedName:X,savedFile:ke,overwriteOpen:le,onOverwriteDismiss:()=>M(!1),deleteOpen:de,onDeleteDismiss:()=>N(!1),onOverwrite:()=>K.mutate(!0),onDelete:()=>we.mutate(X)})]})}function ut({steps:e,skills:t,dragging:n,overId:i,activeStepId:a,onRemove:o,onMove:s}){let{setNodeRef:c,isOver:l}=N({id:ot}),u=n&&i===ot;return(0,Q.jsx)(`div`,{ref:c,"data-slot":`wb-steps`,"data-dragging":n||void 0,className:r(`relative mt-4 rounded-lg transition-colors`,l?`border-accent-strong/60 bg-accent-strong/5`:`border-muted-foreground/25`),children:e.length===0?(0,Q.jsx)(`p`,{className:r(`rounded-md px-3 py-10 text-center text-[13px] transition-colors`,l?`text-link-foreground`:`text-muted-foreground`),children:`Drop a skill here — or Import a workflow.yaml`}):(0,Q.jsxs)(ye,{items:e.map(e=>e.id),strategy:de,children:[(0,Q.jsx)(`ol`,{className:`flex flex-col gap-4`,children:e.map((r,c)=>(0,Q.jsx)(dt,{step:r,index:c,skills:t,dragging:n,insertBefore:n&&i===r.id&&a!==r.id,onRemove:()=>o(c),onMoveUp:c>0?()=>s(c,c-1):void 0,onMoveDown:c<e.length-1?()=>s(c,c+1):void 0},r.id))}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute inset-x-0 mt-1 h-[3px] rounded-full transition-colors`,u?`bg-accent-strong`:`bg-transparent`)})]})})}function dt({step:e,index:t,insertBefore:n,onRemove:i,onMoveUp:a,onMoveDown:o}){let s=f(e.runner,e.agentProfile),{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:p,isDragging:m}=P({id:e.id,data:{type:`step`,step:e}});return(0,Q.jsxs)(`li`,{ref:u,style:{transform:I.Transform.toString(d),transition:p},className:r(`relative`,m&&`opacity-40`),children:[n?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`wb-drop-line`,className:`pointer-events-none absolute -top-[7px] right-0 left-0 h-[3px] rounded-full bg-accent-strong`}):null,(0,Q.jsx)(nt,{step:e,index:t,skills:s.data??[],onRemove:i,onMoveUp:a,onMoveDown:o,gripProps:{...c,...l}})]})}function ft(e){let t=e.dragging?.type===`step`?e.dragging.step:void 0,n=f(t?.runner,t?.agentProfile,!!t);return(0,Q.jsx)(We,{...e,skills:t?n.data??[]:e.skills})}export{ct as WorkflowsRoute};
|