@sma1lboy/rove 0.9.278-next.17 → 0.9.278-next.18

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.
@@ -125,7 +125,7 @@ void main() {
125
125
  `).slice(-10).join(`
126
126
  `)}`},e.label))]})}var jV=30;function MV(e,t,n){let r=t.join(`\0`),[i,a]=(0,g.useState)(()=>Object.fromEntries(t.map(t=>[t,Bs(e,`routine.runs`,{id:t})?.runs??[]])));return(0,g.useEffect)(()=>{let n=!0;for(let r of t)Hs(e,`routine.runs`,{id:r}).then(e=>n&&a(t=>({...t,[r]:e.runs}))).catch(()=>void 0);return()=>{n=!1}},[e,r,n]),i}function NV(e){B();let{auto:t}=bL(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(null);(0,g.useEffect)(()=>r(null),[e.followId]);let o=n===null?e.followId??``:n,s=o===``?e.routines.map(e=>e.id):[o],c=MV(e.c,s,e.tick),l=new Map(e.routines.map(e=>[e.id,e.name])),u=bV(c,o===``?null:o,i),d=e=>{if(e.status===`skipped_blocked`){let t=e.blocked?.reason;return t?xL(z(`runLog.blockedRun`),{reason:z(`runLog.blocked.${t}`)}):z(`runLog.outcome.blocked`)}return t.runStatus[e.status]??e.status},f=(e,t,n,r)=>(0,V.jsx)(H,{variant:`pill`,hit:`tight`,"aria-current":t,className:`max-w-40 truncate`,onClick:n,children:`[ ${e} ]`},r);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`runLog.title`)}),e.routines.length>1&&(0,V.jsx)(DA,{label:z(`runLog.routine`),value:o,picks:[{value:``,label:z(`runLog.allRoutines`)},...e.routines.map(e=>({value:e.id,label:e.name}))],onPick:r}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[f(z(`runLog.all`),i===null,()=>a(null),`all`),hV.map(e=>f(z(`runLog.outcome.${e}`),i===e,()=>a(e),e))]}),u.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:bV(c,o===``?null:o,null).length===0?t.noRuns:z(`runLog.empty`)}):u.slice(0,jV).map(n=>{let r=OV(n.status),i=rB(n,e.now),a=i===`awaiting`?`, ${t.responseAwaiting}`:i===`missing`?`, ${t.responseMissing}`:``,s=vV(n),c=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{children:DV[r]}),(0,V.jsx)(`span`,{children:`#${n.runNumber}`}),o===``&&(0,V.jsx)(`span`,{className:`max-w-[20ch] truncate`,children:l.get(n.automationId)??``}),(0,V.jsx)(`span`,{className:oV,children:`${d(n)}${n.tabId?`, ${n.tabId}`:``}${a}`}),(0,V.jsx)(`span`,{className:`text-subtle`,children:z(`runLog.source.${_V[n.trigger]}`)}),s!==null&&(0,V.jsx)(`span`,{className:`text-muted`,children:yV(s)}),(0,V.jsx)(`span`,{className:`text-muted`,children:e.when(n.at)})]}),u=n.error?CV(n.error):null,f=n.taskId,p=i===`missing`?`text-warning`:EV[r];return(0,V.jsxs)(`div`,{className:`${nV} ${p}`,children:[f?(0,V.jsx)(`button`,{type:`button`,className:`mono ${aV}`,onClick:()=>e.openRun(f),children:c}):(0,V.jsx)(`span`,{className:`mono ${iV}`,children:c}),u&&(0,V.jsxs)(`details`,{className:`mono pl-[calc(2ch+16px)] [&_summary]:cursor-pointer [&_summary]:list-none [&_summary]:truncate [&_summary::-webkit-details-marker]:hidden [&[open]_summary]:whitespace-normal [&_pre]:mx-0 [&_pre]:mt-1 [&_pre]:mb-1.5 [&_pre]:max-h-[16lh] [&_pre]:overflow-auto [&_pre]:rounded-sm [&_pre]:bg-inset [&_pre]:px-2 [&_pre]:py-1.5 [&_pre]:whitespace-pre-wrap [&_pre]:wrap-anywhere [&_pre]:text-muted`,children:[(0,V.jsx)(`summary`,{children:u.summary}),(0,V.jsx)(`pre`,{children:u.full})]})]},n.id)}),u.length>jV&&(0,V.jsx)(`p`,{className:`text-muted`,children:z(`runLog.more`,{count:u.length-jV})})]})}var PV=5e3;function FV({model:e}){let{auto:t,common:n}=bL(),r=e.client,[i,a]=kL(PV),o=v(e.tasks),s=DL(e),c=OL(e),[l,u]=(0,g.useState)(()=>Bs(r,`routine.list`)??null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(null),y=ML(),b=SL(),x=B()===`zh`?`zh-CN`:`en-US`,S=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=!0;return Hs(r,`routine.list`).then(t=>e&&u(t)).catch(()=>e&&u(e=>e??{automations:[],keepsDaemonAlive:!1})),()=>{e=!1}},[r,i]);let C=l?.automations??[],w=l?.lastRunStatus??{},T=l?.lastFailure??{},E=e=>{let t=w[e.id];return t!==void 0&&nB(t)},D=[{key:`pages.routinesNeedYou`,rows:C.filter(E)},{key:`pages.routinesActive`,rows:C.filter(e=>e.enabled&&!E(e))},{key:`pages.routinesPaused`,rows:C.filter(e=>!e.enabled&&!E(e))}],O=D.flatMap(e=>e.rows),k=Math.max(0,O.findIndex(e=>e.id===d)),A=O[k],j=e=>f(O[e]?.id??null),ee=D[0]?.rows.length??0,M=v(un);(0,g.useEffect)(()=>{M===null||!l||(l.automations.some(e=>e.id===M)&&f(M),un.set(null))},[M,l]);let N=MV(r,A?[A.id]:[],i),P=A?N[A.id]??[]:[];(0,g.useEffect)(()=>_(null),[A?.id]);let F=(0,g.useRef)(null),[I,te]=(0,g.useState)(0),L=(0,g.useRef)(0);(0,g.useEffect)(()=>{let e=S.current,t=I!==L.current;if(L.current=I,t&&e&&F.current&&e.offsetTop>F.current.offsetTop){e.scrollIntoView({block:`start`,behavior:`smooth`});return}F.current?.querySelector(`[data-row="${k}"]`)?.scrollIntoView({block:`nearest`})},[k,I]);let ne=Date.now(),re=e=>{let n=e?Date.parse(e):NaN;if(!Number.isFinite(n))return`—`;let r=n-ne,i=r>=0,a=Math.floor(Math.abs(r)/6e4),o=Math.floor(a/60);return a<1?i?t.when.now:t.when.justNow:a<60?xL(i?t.when.inMinutes:t.when.minutesAgo,{n:a}):o<24?xL(i?t.when.inHours:t.when.hoursAgo,{n:o}):new Date(n).toLocaleDateString()},ie=e=>o?.tasks.find(t=>t.id===e)?.label??e,R=t=>{ln.set(null),e.select(t)},ae=(e,t,n)=>G(xL(e,{name:t,error:CL(n)}),`error`),oe=async()=>{if(!(!A||p)){m(A.id);try{await r.request(`routine.setEnabled`,{id:A.id,enabled:!A.enabled}),a()}catch(e){ae(A.enabled?t.disableFailed:t.enableFailed,A.name,e)}finally{m(null)}}},se=async()=>{if(!(!A||p)){m(A.id),_(xL(t.running,{name:A.name}));try{let e=await r.request(`routine.runNow`,{id:A.id});_(xL(t.ranWith,{name:A.name,status:e.status})),a()}catch(e){ae(t.runFailed,A.name,e)}finally{m(null)}}},ce=async()=>{if(p)return;let e=EL(await r.request(`repos.list`).then(e=>e.repos).catch(()=>[]),s);W.set((0,V.jsx)(mV,{repos:e,tasks:(o?.tasks??[]).filter(e=>!e.deleting).map(e=>({id:e.id,title:e.label,repo:e.repo})),defaultRepo:c,onSubmit:e=>{(async()=>{m(`new`);try{await r.request(`routine.create`,{...e.repo===null?{}:{repo:e.repo},name:e.name,prompt:e.prompt,schedule:e.schedule,...e.target?{targetTask:e.target.taskId,targetTab:e.target.tabId}:{}}),a()}catch(e){G(xL(t.createFailed,{error:CL(e)}),`error`)}finally{m(null)}})()}}))},le=()=>{if(!A||p)return;let e=A;W.set((0,V.jsx)(ur,{title:t.deleteTitle,body:xL(t.deleteBody,{name:e.name}),confirmLabel:t.deleteButton,onConfirm:async()=>{m(e.id);try{await r.request(`routine.delete`,{id:e.id}),a()}catch(n){ae(t.deleteFailed,e.name,n)}finally{m(null)}}}))};jL(e=>{if(e.ctrlKey)return e.key===`c`&&(ln.set(null),!0);switch(e.key){case`Escape`:case`q`:return ln.set(null),!0;case`j`:case`ArrowDown`:return j(Math.min(O.length-1,k+1)),!0;case`k`:case`ArrowUp`:return j(Math.max(0,k-1)),!0;case`n`:return ce(),!0;case`r`:return a(),!0;case`e`:return oe(),!0;case`s`:return se(),!0;case`d`:return le(),!0;case`Enter`:{let e=P[0]?.taskId;return e?R(e):P.length>0&&_(t.latestRunNoTask),!0}default:return!1}});let ue=A?.target,de=A?PB(A.schedule,b):null,fe=e=>e===void 0?z(`rail.noProject`):TL(e,C.flatMap(e=>e.repo??[])),pe=A?.nextRunAt?Date.parse(A.nextRunAt):NaN;return(0,V.jsxs)(`div`,{className:`${vM} ${HB}`,tabIndex:0,ref:y,children:[(0,V.jsxs)(`div`,{className:xM,children:[(0,V.jsx)(`h1`,{className:bM,children:t.title}),(0,V.jsxs)(`span`,{className:`mono ${CM}`,children:[ee>0&&(0,V.jsx)(`span`,{className:`text-error`,children:xL(t.needAttention,{count:String(ee),total:String(O.length)})}),(0,V.jsx)(`span`,{className:`text-muted`,children:l?.keepsDaemonAlive?t.holdingDaemon:t.notHolding}),(0,V.jsx)(`button`,{type:`button`,className:`${$t} ${wM.header}`,onClick:()=>void ce(),children:z(`pages.new`)})]})]}),l===null?(0,V.jsx)(`p`,{className:`text-muted`,children:n.loading}):O.length===0?(0,V.jsxs)(`div`,{className:TM,children:[(0,V.jsx)(`p`,{className:`text-muted`,children:t.empty}),(0,V.jsx)(`p`,{className:`keys-only`,children:t.emptyHint})]}):(0,V.jsxs)(`div`,{className:UB,children:[(0,V.jsx)(`div`,{className:WB,ref:F,children:D.map(e=>e.rows.length===0?null:(0,V.jsxs)(`section`,{children:[(0,V.jsxs)(`h2`,{className:`${U} ${GB} ${e===D[0]?`text-error`:`text-muted`}`,children:[z(e.key),` `,(0,V.jsx)(`span`,{className:`mono`,children:e.rows.length})]}),e.rows.map(e=>{let n=O.indexOf(e),r=w[e.id],i=r?OV(r):null;return(0,V.jsxs)(`div`,{"data-row":n,className:KB(n===k),onClick:()=>{j(n),te(e=>e+1)},children:[(0,V.jsxs)(`span`,{className:qB,children:[(0,V.jsx)(`span`,{className:JB(!e.enabled),children:e.name}),(0,V.jsx)(`span`,{className:`mono text-muted ${YB}`,children:e.enabled?re(e.nextRunAt):t.paused}),(0,V.jsx)(`span`,{className:`mono ${i?EV[i]:`text-muted`}`,style:{width:`1ch`},children:i?DV[i]:` `})]}),(0,V.jsx)(`span`,{className:`mono text-muted ${XB}`,title:e.schedule,children:`${fe(e.repo)} · ${PB(e.schedule,b)??e.schedule}`}),T[e.id]?(0,V.jsx)(`span`,{className:`mono text-warning ${XB}`,title:T[e.id]?.reason,children:xL(t.lastFailed,{when:re(T[e.id]?.at),reason:T[e.id]?.reason??``})}):null]},e.id)})]},e.key))}),(0,V.jsx)(`div`,{className:ZB,ref:S,children:A?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:QB,children:[(0,V.jsx)(`h2`,{className:$B,children:A.name}),(0,V.jsxs)(`span`,{className:`mono ${CM}`,children:[(0,V.jsx)(`button`,{type:`button`,className:`${$t} ${wM.row}`,disabled:p===A.id,onClick:()=>void se(),children:t.runNow}),(0,V.jsx)(`button`,{type:`button`,className:`${$t} ${wM.row}`,disabled:p===A.id,onClick:()=>void oe(),children:z(A.enabled?`pages.routinePause`:`pages.routineEnable`)}),(0,V.jsx)(`button`,{type:`button`,className:`${$t} ${wM.row}`,disabled:p===A.id,onClick:le,children:z(`pages.delete`)})]})]}),(0,V.jsxs)(`dl`,{className:eV,children:[(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineSchedule`)}),(0,V.jsxs)(`dd`,{children:[de??(0,V.jsx)(`span`,{className:`mono`,children:A.schedule}),de&&(0,V.jsx)(`span`,{className:`mono text-muted`,children:` ${A.schedule}`})]}),(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineNext`)}),(0,V.jsx)(`dd`,{className:A.enabled?``:`text-warning`,children:A.enabled?Number.isFinite(pe)?`${re(A.nextRunAt)} · ${new Date(pe).toLocaleString(x,{weekday:`short`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}`:`—`:t.paused}),(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineProject`)}),(0,V.jsx)(`dd`,{children:fe(A.repo)}),!A.script&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`text-muted`,children:z(`pages.routineDelivers`)}),(0,V.jsx)(`dd`,{children:ue?xL(t.targetExisting,{task:ie(ue.taskId),tab:ue.tabId}):A.persistentSession?t.targetStanding:t.targetFresh})]})]}),A.precheck&&(0,V.jsx)(`p`,{className:`mono text-muted`,children:xL(t.precheck,{command:A.precheck.command})}),A.script?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`pages.routineScript`)}),(0,V.jsx)(`p`,{className:`mono ${tV}`,children:A.script.command})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted`,children:z(`pages.routinePrompt`)}),(0,V.jsx)(`p`,{className:tV,children:A.prompt})]}),(0,V.jsx)(NV,{c:r,tick:i,routines:C,followId:A.id,now:ne,when:re,openRun:R}),(0,V.jsx)(kV,{runs:P,when:re})]}):(0,V.jsx)(`p`,{className:`text-muted`,children:t.noSelection})})]}),h&&(0,V.jsx)(`p`,{className:`text-muted mx-0 mt-2 mb-0 text-meta leading-[inherit]`,children:h})]})}var IV=`flex min-w-0 items-baseline gap-2.5 font-mono text-meta whitespace-nowrap`,LV=`${IV} w-full cursor-pointer border-none bg-transparent p-0 text-left text-inherit [font:inherit] [&:hover]:underline`,RV=`w-[5ch] flex-none text-muted`,zV=`w-[16ch] flex-none overflow-hidden text-accent`,BV=`mt-3.5 mb-0.5`,VV=`min-w-0 flex-1 truncate`,HV=`flex-none text-right text-muted`,UV=`${HV} min-w-[5ch]`,WV=`${HV} min-w-[4ch]`,GV=`${HV} min-w-[5ch]`,KV=`w-[8ch] flex-none overflow-hidden text-accent`,qV=`flex flex-wrap gap-x-3 font-mono text-meta text-muted`,JV=`m-0 text-meta text-muted`,YV={turns:0,tokens:0,ms:0},XV=e=>(e.usage?.input_tokens??0)+(e.usage?.output_tokens??0),ZV=e=>Math.max(0,e.endedAt-e.startedAt),QV=(e,t)=>({turns:e.turns+1,tokens:e.tokens+XV(t),ms:e.ms+ZV(t)});function $V(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function eH(e,t,n,r){let i=[];for(let e=n-1;e>=0;e--){let n=new Date(t);n.setDate(n.getDate()-e),i.push($V(n.getTime()))}let a=new Map(i.map(e=>[e,{sum:YV,byEngine:{}}]));for(let t of e){let e=a.get($V(t.startedAt));if(!e)continue;let n=t.vendor??`unknown`;e.sum=QV(e.sum,t),e.byEngine[n]=(e.byEngine[n]??0)+XV(t)}let o=e.reduce((e,t)=>Math.min(e,t.startedAt),1/0),s=e.length>=r&&Number.isFinite(o)?{count:e.length,day:$V(o)}:null;return{cutoff:s,days:i.map(e=>{let t=a.get(e);return{day:e,...t?.sum??YV,byEngine:t?.byEngine??{},partial:s!==null&&e<=s.day}})}}function tH(e){let t=new Map;for(let n of e){let e=n.vendor??`unknown`,r=n.model??`unknown`,i=`${e}\0${r}`;t.set(i,{engine:e,model:r,...QV(t.get(i)??YV,n)})}return[...t.values()].sort((e,t)=>t.tokens-e.tokens||t.turns-e.turns)}function nH(e,t){let n=new Map;for(let t of e)n.set(t.taskId,{taskId:t.taskId,...QV(n.get(t.taskId)??YV,t)});return[...n.values()].sort((e,t)=>t.tokens-e.tokens||t.turns-e.turns).slice(0,t)}function rH(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4)).replace(/\.0$/,``)}k`:`${(e/1e6).toFixed(+(e<1e7)).replace(/\.0$/,``)}M`}var iH=[``,`▏`,`▎`,`▍`,`▌`,`▋`,`▊`,`▉`];function aH(e,t,n){if(e<=0||t<=0)return``;let r=Math.max(1,Math.round(e/t*n*8));return`${`█`.repeat(Math.floor(r/8))}${iH[r%8]}`}var oH=[`█`,`▓`,`▒`,`░`];function sH(e,t,n,r){return n<=0?``:t.map((t,i)=>{let a=e[t]??0,o=a<=0?0:Math.max(1,Math.round(a/n*r));return(oH[i%oH.length]??`█`).repeat(o)}).join(``)}var cH=.1,lH=/^(\d+)\s*(h|d)$/;function uH(e,t){let n=lH.exec(e.label.trim());if(!n||e.resetsAt===null||e.percent<=0)return null;let r=Number(n[1])*(n[2]===`d`?24:1)*36e5,i=r-(e.resetsAt-t);if(!(i>=r*cH)||i>r)return null;if(e.percent>=100)return{kind:`full`,at:t};let a=t+(100-e.percent)/e.percent*i;return a<e.resetsAt?{kind:`full`,at:a}:{kind:`lasts`}}var dH=14,fH=500,pH=3e4,mH=16,hH=8,gH=8;function _H(e,t,n,r){let i=Bs(e,t,n),[a,o]=(0,g.useState)(i?{kind:`ready`,value:i}:{kind:`loading`}),s=JSON.stringify(n);return(0,g.useEffect)(()=>{let r=!0;return Hs(e,t,n).then(e=>r&&o({kind:`ready`,value:e})).catch(e=>r&&o(t=>t.kind===`ready`?t:{kind:`failed`,error:CL(e)})),()=>{r=!1}},[e,t,s,r]),a}var vH=e=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`${UV}`,children:rH(e.tokens)}),(0,V.jsx)(`span`,{className:`${WV}`,children:`${e.turns}t`}),(0,V.jsx)(`span`,{className:`${GV}`,children:yV(e.ms)})]});function yH({usage:e,nameOf:t}){let n=Date.now(),r=e.flatMap(e=>e.windows.map(r=>{let i={engine:e.name||t(e.vendor),label:r.label,percent:Math.round(r.percent)},a=uH(r,n);if(a?.kind===`full`){let t=a.at-n<72e6,o=new Date(a.at).toLocaleString([],{...t?{}:{weekday:`short`},hour:`2-digit`,minute:`2-digit`});return{key:`${e.vendor}:${r.kind}`,text:xL(z(`usage.full`),{...i,time:o})}}return{key:`${e.vendor}:${r.kind}`,text:xL(z(a?`usage.lasts`:`usage.window`),i)}}));return r.length===0?null:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted ${BV}`,children:z(`usage.quota`)}),r.map(e=>(0,V.jsx)(`p`,{className:`mono ${JV}`,children:e.text},e.key))]})}function bH({row:e,title:t,open:n}){let r=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:VV,children:t}),vH(e)]});return n?(0,V.jsx)(H,{variant:`row`,className:LV,onClick:n,children:r}):(0,V.jsx)(`div`,{className:IV,children:r})}function xH({model:e}){B();let t=ML(),[n]=kL(pH),r=_H(e,`turns.list`,{sinceDays:dH,limit:fH},n),i=_H(e,`engines.list`,{},n),a=_H(e,`usage.get`,{},n),o=v(e.tasks),s=i.kind===`ready`?i.value.engines:[],c=e=>s.find(t=>t.id===e)?.name??e,l=e=>o?.tasks.find(t=>t.id===e)?.label??z(`usage.removedTask`);return(0,V.jsxs)(`div`,{className:yM,tabIndex:0,ref:t,onKeyDown:e=>{e.metaKey||e.ctrlKey||e.altKey||e.key!==`q`&&e.key!==`Escape`||(e.preventDefault(),ln.set(null))},children:[(0,V.jsx)(`h1`,{className:bM,children:z(`usage.title`)}),(()=>{if(r.kind===`loading`)return(0,V.jsx)(`p`,{className:`text-muted`,children:z(`usage.loading`)});if(r.kind===`failed`)return(0,V.jsx)(`p`,{className:`text-error`,children:xL(z(`usage.failed`),{error:r.error})});let t=r.value.turns,n=new Set(r.value.readers??[]),i=eH(t,Date.now(),dH,fH),s=new Map;for(let e of i.days)for(let[t,n]of Object.entries(e.byEngine))s.set(t,(s.get(t)??0)+n);let u=[...s].sort((e,t)=>t[1]-e[1]).map(([e])=>e),d=Math.max(0,...i.days.map(e=>e.tokens)),f=tH(t),p=Math.max(0,...f.map(e=>e.tokens)),m=[...new Set((o?.tasks??[]).flatMap(e=>e.engine?.id&&!n.has(e.engine.id)?[e.engine.id]:[]))];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:JV,children:xL(z(`usage.range`),{days:dH})}),t.length===0?(0,V.jsx)(`p`,{className:`text-muted`,children:z(`usage.empty`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h2`,{className:`${U} text-muted ${BV}`,children:z(`usage.perDay`)}),(0,V.jsx)(`div`,{className:qV,children:u.map((e,t)=>(0,V.jsx)(`span`,{children:`${oH[t%oH.length]} ${c(e)}`},e))}),i.days.map(e=>(0,V.jsxs)(`div`,{className:IV,children:[(0,V.jsx)(`span`,{className:RV,children:`${e.day.slice(5)}${e.partial?`~`:``}`}),(0,V.jsx)(`span`,{className:zV,children:sH(e.byEngine,u,d,mH)}),vH(e)]},e.day)),i.cutoff&&(0,V.jsx)(`p`,{className:`m-0 text-meta text-muted`,children:xL(z(`usage.cutoff`),{count:i.cutoff.count,day:i.cutoff.day.slice(5)})}),(0,V.jsx)(`h2`,{className:`${U} text-muted ${BV}`,children:z(`usage.byModel`)}),f.map(e=>(0,V.jsxs)(`div`,{className:IV,children:[(0,V.jsx)(`span`,{className:VV,title:`${c(e.engine)} · ${e.model}`,children:`${c(e.engine)} · ${e.model}`}),(0,V.jsx)(`span`,{className:KV,children:aH(e.tokens,p,hH)}),vH(e)]},`${e.engine}\0${e.model}`)),(0,V.jsx)(`h2`,{className:`${U} text-muted ${BV}`,children:z(`usage.topTasks`)}),nH(t,gH).map(t=>(0,V.jsx)(bH,{row:t,title:l(t.taskId),open:o?.tasks.some(e=>e.id===t.taskId)?()=>{ln.set(null),e.select(t.taskId)}:null},t.taskId))]}),m.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-meta text-muted`,children:xL(z(`usage.noReader`),{engines:m.map(c).join(`, `)})}),a.kind===`ready`&&a.value.usage&&(0,V.jsx)(yH,{usage:a.value.usage,nameOf:c})]})})()]})}var SH={id:`mods`,label:`mods`},CH=[{id:`kanban`,label:`kanban`,mod:`kanban`},{id:`routines`,label:`automations`},{id:`issues`,label:`issues`,mod:`issues`}];function wH({model:e}){let{nav:t}=bL(),n=v(ln),r=v(e.mods).length>0,i=v(e.installedMods),a=[...CH.filter(e=>!e.mod||i.has(e.mod)),...r?[SH]:[]];return(0,V.jsxs)(`div`,{className:jM,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rail-nav-row ${PM(!1)}`,onClick:()=>iO(),children:[z(`rail.newTask`),(0,V.jsx)(`span`,{className:FM,"aria-hidden":`true`,children:`+`})]}),a.map(e=>(0,V.jsx)(`button`,{type:`button`,className:`rail-nav-row ${PM(n===e.id)}`,"aria-current":n===e.id?`page`:void 0,onClick:()=>va(e.id),children:t[e.label]},e.id))]})}function TH({model:e,page:t}){(0,g.useEffect)(()=>e.selection.subscribe(()=>ln.set(null)),[e]);let n=v(e.installedMods);return t===`kanban`&&n.has(`kanban`)?(0,V.jsx)(Rz,{model:e}):t===`routines`?(0,V.jsx)(FV,{model:e}):t===`issues`&&n.has(`issues`)?(0,V.jsx)(kR,{model:e}):t===`mods`?(0,V.jsx)(tB,{model:e}):t===`compare`?(0,V.jsx)(_R,{model:e}):t===`usage`?(0,V.jsx)(xH,{model:e}):null}var EH=p();function DH(e){return e?.match(/^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/(?:pull|merge_requests|-\/merge_requests)\//)?.[1]}var OH=e=>e.charAt(0).toUpperCase()+e.slice(1);function kH(e){return[z(`rail.pr.state.${e.state}`),...e.checks?[z(`rail.pr.checks.${e.checks}`)]:[]].join(`, `)}function AH(e){let t=new Map;for(let n of e){let e=aI(n),r=[...e&&n.pr?[{pr:n.pr,mark:e}]:[],...(n.sessionPrs??[]).flatMap(e=>{let t=oI(e);return t?[{pr:e,mark:t}]:[]})];for(let{pr:e,mark:i}of r){let r=e.url??(e.number===void 0?n.id:`${n.repo}#${e.number}`),a=t.get(r),o=e.lifecycle===`unknown`,s=a?.pr.lifecycle===`unknown`;(!a||s&&!o||o===s&&sI([a.mark,i])!==a.mark)&&t.set(r,{task:n,pr:e,mark:i})}}return[...t.values()]}function jH({tasks:e,onOpen:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=(0,g.useRef)(null),l=$o();(0,g.useLayoutEffect)(()=>{let e=c.current;if(!e||!n)return;let t=e.getBoundingClientRect();t.right>window.innerWidth-8&&(e.style.left=`${Math.max(8,window.innerWidth-t.width-8)}px`,e.style.top=`${n.bottom+6}px`);let r=e.getBoundingClientRect().bottom-(window.innerHeight-8);r>0&&(e.style.top=`${Math.max(8,e.getBoundingClientRect().top-r)}px`)},[n]);let u=()=>{t?.(),s.current!==null&&window.clearTimeout(s.current),s.current=null,a(!1),o.current&&!n&&r(o.current.getBoundingClientRect())},d=()=>{a(!0),s.current=window.setTimeout(()=>r(null),140)};(0,g.useEffect)(()=>{if(!l||!n)return;let e=e=>{let t=e.target;o.current?.contains(t)||c.current?.contains(t)||(a(!0),s.current=window.setTimeout(()=>r(null),140))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[l,n]),(0,g.useEffect)(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);let f=AH(e),p=sI(f.map(e=>e.mark));if(!p)return null;let m=f.length===1?`PR #${f[0]?.pr.number??``}, ${kH(p)}`:z(`rail.pr.many`,{count:f.length});return(0,V.jsxs)(`span`,{ref:o,className:`chip ${tE} ${p.tone}`,"aria-label":m,onMouseEnter:l?void 0:u,onMouseLeave:l?void 0:d,onClick:e=>{l&&(e.stopPropagation(),n&&!i?d():u())},children:[p.glyph,f.length>1&&(0,V.jsx)(`span`,{className:`font-sans`,children:f.length}),n&&(0,EH.createPortal)((0,V.jsx)(`div`,{ref:c,className:nE(i),style:{top:n.top-6,left:n.right+8},onMouseEnter:l?void 0:u,onMouseLeave:l?void 0:d,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onContextMenu:e=>e.stopPropagation(),children:f.map(({task:e,pr:t,mark:n})=>{let r=DH(t?.url),i=t?.additions!==void 0&&t.deletions!==void 0;return(0,V.jsxs)(`button`,{type:`button`,className:`flex flex-col gap-1 rounded-[calc(var(--radius)-6px)] px-3 py-2 text-left font-sans enabled:hover:bg-hover`,disabled:!t?.url,onClick:()=>t?.url&&window.open(t.url,`_blank`,`noopener`),children:[(0,V.jsx)(`span`,{className:`truncate font-semibold text-ink`,children:t.title||e.label}),(0,V.jsxs)(`span`,{className:`flex items-baseline gap-0 text-meta leading-[inherit] whitespace-nowrap`,children:[(0,V.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.25 ${n.tone}`,children:[(0,V.jsx)(`span`,{className:`font-mono`,children:n.glyph}),OH(z(`rail.pr.state.${n.state}`))]}),(0,V.jsx)(`span`,{className:`overflow-hidden text-ellipsis whitespace-pre text-muted`,children:[...n.checks?[z(`rail.pr.checks.${n.checks}`)]:[],[r,t?.number===void 0?``:`#${t.number}`].filter(Boolean).join(` `)].filter(Boolean).map(e=>`, ${e}`).join(``)}),i&&(0,V.jsxs)(`span`,{className:`ml-auto flex gap-1.5 pl-3 tabular-nums`,children:[(0,V.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions]}),(0,V.jsxs)(`span`,{className:`text-error`,children:[`−`,t.deletions]})]})]})]},t.url??`${e.id}#${t.number??``}`)})}),document.body)]})}var MH=`~archived`;function NH(e,t,n,r){let i=t.filter(e=>!e.routine);if(i.length===0)return e;let a={id:MH,kind:`archived`,count:i.length,expanded:n};if(!n)return[...e,a];let o=xw([{repo:``,label:``,key:MH,tasks:i}],``,r,1,!1);return[...e,a,...o.filter(e=>e.kind!==`project`)]}function PH(e,t,n){let r=t.kind===`main`,i=e=>r?e.kind===`main`:e.kind!==`main`&&e.repo===t.repo&&!e.pinned==!t.pinned;if(t.id===n.id||!i(n))return null;let a=e.filter(i).sort((e,t)=>(e.order??e.rank)-(t.order??t.rank)).map(e=>e.id);return a.indexOf(n.id)-a.indexOf(t.id)}function FH(e,t,n,r){let i=PH(e,t,n);return i===null?null:r===`above`&&i>0?i-1:r===`below`&&i<0?i+1:i}function IH(e,t){return e.id===t.id?!1:e.kind===`main`?t.kind===`main`:t.kind!==`main`&&t.repo===e.repo}function LH(e,t,n,r,i){if(!IH(t,n))return null;if(t.kind===`main`){let i=FH(e,t,n,r);return i?{steps:i}:null}let a=n.pinned===!0||i&&r===`above`,o={...t,pinned:a},s=a===(n.pinned===!0)?FH(e.map(e=>e.id===t.id?o:e),o,n,r)??0:0,c=a===(t.pinned===!0)?{}:{pin:a};return`pin`in c||s!==0?{...c,steps:s}:null}var RH=e=>e===void 0||e.kind===`project`||e.kind===`state`?0:e.kind===`task`||e.kind===`pane`||e.kind===`round`?e.depth:1;function zH(e,t){let n=RH(e[t]),r=t+1;for(;r<e.length&&RH(e[r])>n;)r++;return r}function BH(e,t,n){let r=e.findIndex(e=>e.id===t),i=r<0?e:[...e.slice(0,r),...e.slice(zH(e,r))];for(let e=i.findIndex(e=>e.id===n)-1;e>=0;e--){let t=i[e];if(!t||t.kind===`project`||t.kind===`state`)return!0;if(t.kind===`task`&&t.depth===1&&t.task.kind!==`main`||t.kind===`round`&&t.depth===1)return!1}return!1}function VH(e,t){let n=RH(e[t]),r=[];for(let i=2;i<=n;i++){let a=t+1;for(;a<e.length&&RH(e[a])>i;)a++;let o=a<e.length&&RH(e[a])===i;r.push(i===n?o?`tee`:`elbow`:o?`pipe`:`blank`)}return r}function HH(e,t,n,r){let i=e.findIndex(e=>e.id===t);if(i<0||t===n)return e;let a=zH(e,i),o=e.slice(i,a),s=[...e.slice(0,i),...e.slice(a)],c=s.findIndex(e=>e.id===n);if(c<0)return e;let l=r===`above`?c:zH(s,c);return[...s.slice(0,l),...o,...s.slice(l)]}function UH(e,t,n,r,i){let[a,o]=(0,g.useState)(null),s=(0,g.useRef)(t);s.current=t;let[c,l]=(0,g.useState)(null),u=(0,g.useRef)(()=>o(null));(0,g.useEffect)(()=>{if(!c)return;let e=()=>{l(null),u.current()};if(t!==c)return e();let n=window.setTimeout(e,3e3);return()=>window.clearTimeout(n)},[t,c]);let d=(0,g.useRef)(null),f=(0,g.useRef)(null),p=()=>[...d.current?.querySelectorAll(`[data-row]`)??[]];(0,g.useLayoutEffect)(()=>{let e=f.current;if(!e||(f.current=null,window.matchMedia(`(prefers-reduced-motion: reduce)`).matches))return;let t=p().flatMap(t=>{let n=e.get(t.dataset.row??``),r=n===void 0?0:n-t.getBoundingClientRect().top;return r?[{el:t,dy:r}]:[]});for(let{el:e,dy:n}of t)e.style.transition=`none`,e.style.transform=`translateY(${n}px)`;d.current?.getBoundingClientRect();for(let{el:e}of t)e.style.transition=`transform 150ms ease-out`,e.style.transform=``,e.addEventListener(`transitionend`,()=>e.style.removeProperty(`transition`),{once:!0})});let m=(0,g.useRef)(null),h=(0,g.useRef)([]),_=(0,g.useRef)(new Map),v=(0,g.useRef)(0),y=(0,g.useRef)(0),b=e=>{m.current=e,o(e)},x=e=>!n||e.machine!==void 0?null:e.kind===`project`?t.find(t=>t.id===i(e.repo).mainTaskId)??null:e.kind===`task`&&e.depth===1&&e.task.kind!==`main`?e.task:null,S=e=>{let t=x(e);if(t)return{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,t.id),d.current=n.currentTarget.closest(`[data-rail-body]`),T(d.current);let r=h.current,i=r.findIndex(t=>t.id===e.id);v.current=r.slice(i,zH(r,i)).reduce((e,t,n)=>e+(_.current.get(t.id)?.height??0)+(n>0?_.current.get(t.id)?.gap??0:0),0),y.current=n.clientY,b({fromRow:e.id,from:t,toRow:e.id,to:t,side:`above`})},onDragEnd:()=>m.current&&b(null)}},C=(e,t,n)=>{let r=t;if(n.from.kind===`main`)for(;r>0&&e[r]?.kind!==`project`;)r--;let i=e[r],a=i&&x(i);return!i||!a||!IH(n.from,a)?null:{row:i.id,task:a}},w={onDragOver:e=>{let t=m.current;if(!t)return;e.preventDefault();let n=e.clientY-y.current;y.current=e.clientY;let r=e.target.closest(`[data-row]`)?.dataset.row,i=h.current,a=C(i,i.findIndex(e=>e.id===r),t);if(!a||a.row===t.fromRow)return;let o=e.currentTarget.querySelector(`[data-row="${CSS.escape(t.fromRow)}"]`)?.getBoundingClientRect().top;if(o===void 0||e.clientY>=o&&e.clientY<o+v.current)return;let s=e.clientY<o?`above`:`below`;(s===`above`?n>=0:n<=0)||(t.toRow!==a.row||t.side!==s)&&b({...t,toRow:a.row,to:a.task,side:s})},onDrop:n=>{let i=m.current;if(!i)return;n.preventDefault();let a=LH(t,i.from,i.to,i.side,BH(h.current,i.fromRow,i.toRow));m.current=null,r?u.current=()=>o(null):u.current=()=>{f.current=new Map(p().map(e=>[e.dataset.row??``,e.getBoundingClientRect().top])),o(null),HT(`default`),G(q(`tasks`,`sort.label`,{mode:q(`tasks`,`sort.modes.default`)}))},a?YT(e,i.from.id,a).finally(()=>l(s.current)):u.current()}},T=e=>{let t=[...e?.querySelectorAll(`[data-row]`)??[]];_.current=new Map(t.map((e,n)=>{let r=t[n-1],i=r?e.offsetTop-r.offsetTop-r.offsetHeight:0;return[e.dataset.row??``,{top:e.offsetTop,gap:i,height:e.offsetHeight}]}))},E=e=>{h.current=a?HH(e,a.fromRow,a.toRow,a.side):e;let t=new Map;if(!a)return t;let n=Math.min(...[..._.current.values()].map(e=>e.top));for(let[e,r]of h.current.entries()){let i=_.current.get(r.id);if(!i)return new Map;e>0&&(n+=i.gap),n!==i.top&&t.set(r.id,n-i.top),n+=i.height}return t};return{props:S,body:w,dragging:a?.fromRow??null,places:e=>{let t=E(e);return e=>{let n=t.get(e.id);return n?{"data-row":e.id,style:{transform:`translateY(${n}px)`}}:{"data-row":e.id}}}}}function WH({model:e,narrow:t,onSettings:n}){B();let r=v(e.selection),i=v(MN),a=$(`engines.skill.bannerHintWeb`,{engines:i.join(`, `)});return(0,V.jsxs)(`div`,{className:MM,children:[!t&&(0,V.jsx)(UP,{client:e.client,taskId:r.taskId,tabId:r.tabId}),(0,V.jsxs)(`div`,{className:NM,children:[(0,V.jsxs)(`button`,{type:`button`,className:`rail-nav-row ${PM(!1)}`,onClick:n,children:[(0,V.jsxs)(`svg`,{className:IM,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[(0,V.jsx)(`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),(0,V.jsx)(`span`,{children:z(`rail.settings`)}),i.length>0&&(0,V.jsx)(`span`,{className:`ml-2 min-w-0 truncate text-meta text-subtle`,title:a,children:z(`rail.skillCue`)})]}),(0,V.jsx)(NF,{model:e,bindingId:`settings.open`})]})]})}function GH(e,t,n,r,i=null){let a=e=>e.kind===`task`&&e.task.kind===`main`&&e.fold===void 0&&e.task.id!==n&&e.task.id!==i&&(r?t[e.task.id]?.length===0:(t[e.task.id]?.length??0)===0),o=e.filter(e=>!a(e));return o.filter((e,t)=>{if(e.kind!==`project`&&e.kind!==`state`)return!0;let n=o[t+1];return n!==void 0&&n.kind!==`project`&&n.kind!==`state`})}var KH=_({});function qH(e,t,n){let r=KH.get()[`${e}::${t.id}`];return r&&r.sig===Nw(n)&&Ew(n.root).some(e=>e.id===r.leaf)?r.leaf:n.activeLeafId}function JH(e,t,n,r){KH.set({...KH.get(),[`${e}::${t}`]:{sig:Nw(n),leaf:r}})}function YH(e,t,n,r){JH(e,t.id,n,r),sa(EC(e,t.id,r))?.focus()}function XH(e){let{taskId:t,tabId:n}=e.selection.get(),r=t?e.tabs.get()[t]?.find(e=>e.id===n):void 0;return t&&r?{taskId:t,tab:r}:null}async function ZH(e,t,n){try{let r=await e.client.request(`tab.split`,t);await e.refreshTabsNow(),n?.(r)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}function QH(e,t,n,r,i){let a=i??(n.split?qH(t,n,n.split):`leaf-1`),o=e.selection.get();(o.taskId!==t||o.tabId!==n.id)&&e.select(t,n.id);let s=sa(EC(t,n.id,a))?.size();ZH(e,{taskId:t,tabId:n.id,action:`open`,direction:r,leafId:a,...s},e=>{e.changed?e.split&&JH(t,n.id,e.split,e.leaf):G(z(`layout.splitTooSmall`),`error`)})}function $H(e,t,n,r){let i=n.split,a=i?qH(t,n,i):r,o=()=>ZH(e,{taskId:t,tabId:n.id,action:`close`,leafId:r},e=>{let i=e.split;if(!i)return;let o=a!==r&&Ew(i.root).some(e=>e.id===a);JH(t,n.id,i,o?a:i.activeLeafId)});if(!i||!jw(n,i,r)){o();return}W.set((0,V.jsx)(ur,{title:z(`confirm.closePaneTitle`,{pane:Aw(i,ww(n)).get(r)??r}),body:z(`confirm.closePaneBody`),confirmLabel:z(`menu.closePane`),onConfirm:o}))}function eU(e,t,n,r){let i=n.split;i&&W.set((0,V.jsx)(lr,{title:So(`split.renameTitle`),initial:Aw(i,ww(n)).get(r)??``,allowEmpty:!0,submitLabel:z(`dialog.save`),onSubmit:i=>ZH(e,{taskId:t,tabId:n.id,action:`rename`,leafId:r,title:i})}))}function tU(e,t,n,r){return[{label:z(`menu.renamePane`),section:`split`,key:ro(`workspace.split.rename`)??void 0,run:()=>eU(e,t,n,r)},{label:z(`menu.closePane`),section:`split`,key:ii(`workspace.split.close`)||void 0,run:()=>$H(e,t,n,r)}]}function nU(e,t,n,r){return[{label:z(`menu.splitRight`),section:`split`,key:ro(`workspace.split.right`)??void 0,run:()=>QH(e,t,n,`right`,r)},{label:z(`menu.splitDown`),section:`split`,key:ro(`workspace.split.down`)??void 0,run:()=>QH(e,t,n,`down`,r)}]}function rU(e,t,n,r){let i=n.split,a=r??(i?qH(t,n,i):`leaf-1`);return[...nU(e,t,n,a),...Dw(i)?tU(e,t,n,a):[]]}function iU(e,t){let n=e.tabs.get()[t]??[],r=e.selection.get(),i=(r.taskId===t?n.find(e=>e.id===r.tabId):void 0)??Bi(n);return!i||!Mw(i)?[]:nU(e,t,i,i.split?qH(t,i,i.split):`leaf-1`)}function aU(e,{task:t,tab:n,leaf:r}){n.split&&YH(t.id,n,n.split,r),e.select(t.id,n.id)}function oU(e){let{row:t}=e,n=v(e.model.selection);v(KH);let r=n.taskId===t.task.id&&n.tabId===t.tab.id&&!!t.tab.split&&qH(t.task.id,t.tab,t.tab.split)===t.leaf;return(0,V.jsxs)(`button`,{type:`button`,className:`${tr({size:`pane`})} ${e.cursor?mE:``}`,"aria-current":r||void 0,onClick:e.onClick,onContextMenu:e.onMenu,...e.place,children:[(0,V.jsx)(`span`,{className:XT,"aria-hidden":`true`,children:e.guides?.map((e,t)=>(0,V.jsx)(`span`,{className:$T(e)},t))}),(0,V.jsx)(`span`,{className:`${nr} text-(length:--fs-meta) ${r?`text-ink`:`text-muted`}`,children:t.label})]})}function sU(e,t){let n=t?.trim()??``;return n&&e?.effortLevels?.includes(n)?n:``}function cU({model:e,taskId:t}){let[n,r]=(0,g.useState)([]),[i,a]=(0,g.useState)({}),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(!1),{busy:m,error:h,submit:_}=cr();(0,g.useEffect)(()=>{Promise.all([e.client.request(`engines.list`),e.client.request(`task.get`,{taskId:t})]).then(([e,t])=>{let n=xs(e.engines,t.task.engine).filter(e=>e.ready!==!1||e.id===t.task.engine),i=n.find(e=>e.id===t.task.engine)??n[0];r(n),a(t.task),s(i?.id??``),l(sU(i,t.task.effort)),d(i?.id===t.task.engine?t.task.model??``:``),p(!0)})},[e,t]);let v=n.find(e=>e.id===o),y=v?.effortLevels??[],b=y.length>0?[``,...y]:[],x=(v?.models??[]).map(e=>e.id).filter(e=>e.toLowerCase().includes(u.trim().toLowerCase())&&e!==u.trim()).slice(0,6),S=e=>{s(e);let t=n.find(t=>t.id===e);l(sU(t,e===i.engine?i.effort:void 0)),d(e===i.engine?i.model??``:``)},C=e=>{let t=n.findIndex(e=>e.id===o),r=n[Math.max(0,Math.min(n.length-1,t+e))];r&&S(r.id)},w=e=>{if(b.length===0)return;let t=Math.max(0,b.indexOf(c));l(b[Math.max(0,Math.min(b.length-1,t+e))]??``)},T=e=>{let t=e.target instanceof HTMLInputElement;if(e.key===`ArrowUp`&&!t)C(-1);else if(e.key===`ArrowDown`&&!t)C(1);else if((e.key===`ArrowLeft`||e.key===`h`)&&!t)w(-1);else if((e.key===`ArrowRight`||e.key===`l`)&&!t)w(1);else return;e.preventDefault()},E=()=>_(async()=>{if(!v)return;let n=y.length>0?c:void 0,r=v.acceptsModel?u.trim():void 0;(v.id!==i.engine||n!==void 0&&n!==(i.effort??``)||r!==void 0&&r!==(i.model??``))&&(await e.client.request(`task.setEngine`,{taskId:t,engine:v.id,...n===void 0?{}:{effort:n},...r===void 0?{}:{model:r}}),G(q(`tasks`,`toast.engineSwitched`,{engine:v.name})))});return(0,V.jsx)(sr,{title:q(`tasks`,`changeEngine.title`),wide:!0,children:(0,V.jsxs)(`form`,{className:Ln,onKeyDown:T,onSubmit:e=>{e.preventDefault(),E()},children:[(0,V.jsx)(`ul`,{className:jn,"aria-label":q(`tasks`,`changeEngine.title`),children:n.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===o,className:tr({selected:e.id===o}),onClick:()=>S(e.id),children:[(0,V.jsx)(`span`,{className:`${ar} text-accent`,children:e.id===o?`●`:` `}),(0,V.jsx)(`span`,{className:nr,children:e.name}),e.id===i.engine&&(0,V.jsx)(`span`,{className:`text-muted`,children:q(`tasks`,`changeEngine.current`)})]})},e.id))}),f&&v&&v.acceptsModel&&(0,V.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`tasks`,`engineModel.label`)}),(0,V.jsx)(`input`,{className:tn,spellCheck:!1,placeholder:q(`tasks`,`engineModel.placeholder`),value:u,onChange:e=>d(e.target.value)}),x.length>0&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:x.map(e=>(0,V.jsx)(`button`,{type:`button`,className:An(),onClick:()=>d(e),children:e},e))})]}),b.length>0&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(`span`,{className:`m-0 font-sans text-meta font-medium normal-nums text-muted`,children:q(`tasks`,`changeEngine.effortLabel`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:b.map(e=>(0,V.jsx)(`button`,{type:`button`,"aria-pressed":e===c,className:An(e===c),onClick:()=>l(e),children:e===``?q(`tasks`,`changeEngine.noEffort`):e},e||`default`))})]}),(0,V.jsx)(`p`,{className:`keys-only ${Jt}`,children:(0,V.jsx)(kT,{text:[q(`tasks`,`changeEngine.footer.engine`),...v?.acceptsModel?[q(`tasks`,`changeEngine.footer.model`)]:[],...b.length>0?[q(`tasks`,`changeEngine.footer.effort`)]:[],q(`tasks`,`changeEngine.footer.set`),q(`tasks`,`changeEngine.footer.cancel`)].join(` · `)})}),h&&(0,V.jsx)(`p`,{className:`text-error`,children:h}),(0,V.jsx)(fr,{busy:m||!f,submitLabel:z(`taskops.set`)})]})})}function lU({model:e,task:t}){let[n,r]=(0,g.useState)(()=>Bs(e,`task.get`,{taskId:t.id})?.task??null),[i,a]=(0,g.useState)(null),{busy:o,error:s,submit:c}=cr();(0,g.useEffect)(()=>{Hs(e,`task.get`,{taskId:t.id}).then(e=>r(e.task)).catch(e=>a(K(e)))},[e,t.id]);let l=()=>c(async()=>{if(!n?.prompt)return;let t=(await e.client.request(`task.spawn`,{repo:n.repo,prompt:n.prompt,...n.engine?{engine:n.engine}:{},...n.baseRef?{baseBranch:n.baseRef}:{}})).taskIds[0];t&&e.selectWhenListed(t)});return(0,V.jsx)(sr,{title:q(`tasks`,`runAgain.title`),wide:!0,children:(0,V.jsxs)(`form`,{className:Ln,onSubmit:e=>{e.preventDefault(),l()},children:[(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`runAgain.source`,{title:t.label})}),(0,V.jsx)(`pre`,{className:Yt,children:n?.prompt??i??q(`tasks`,`fieldNotes.loading`)}),(0,V.jsx)(`p`,{className:Jt,children:q(`tasks`,`runAgain.hint`)}),s&&(0,V.jsx)(`p`,{className:`text-error`,children:s}),(0,V.jsx)(fr,{busy:o||!n?.prompt,submitLabel:q(`tasks`,`runAgain.confirm`)})]})})}function uU(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function dU({model:e,repo:t}){let[n,r]=(0,g.useState)({kind:`loading`}),[i,a]=(0,g.useState)(0),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=()=>e.client.request(`notes.list`,{repo:t}).then(e=>r({kind:`ready`,notes:e.notes})).catch(e=>r({kind:`error`,message:K(e)}));(0,g.useEffect)(()=>void d(),[]);let f=n.kind===`ready`?n.notes:[];(0,g.useEffect)(()=>a(e=>Math.max(0,Math.min(e,f.length-1))),[f.length]),(0,g.useEffect)(()=>{u.current?.querySelector(`.is-selected`)?.scrollIntoView({block:`nearest`})},[i]);let p=async n=>{if(n.id!==void 0){l(null);try{await e.client.request(`notes.delete`,{repo:t,id:n.id}),s(null),await d()}catch(e){l(K(e))}}};return(0,V.jsx)(sr,{title:q(`tasks`,`fieldNotes.title`),wide:!0,children:(0,V.jsxs)(`div`,{className:Ln,onKeyDown:e=>{if(!o){if(e.key===`ArrowDown`||e.key===`j`)a(e=>Math.min(f.length-1,e+1));else if(e.key===`ArrowUp`||e.key===`k`)a(e=>Math.max(0,e-1));else if(e.key===`d`&&f[i]?.id!==void 0)s(f[i]??null);else return;e.preventDefault()}},children:[(0,V.jsx)(`p`,{className:`font-mono text-meta break-all text-muted`,children:t}),n.kind===`loading`&&(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.loading`)}),n.kind===`error`&&(0,V.jsx)(`p`,{className:`text-error`,children:n.message}),n.kind===`ready`&&f.length===0&&(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.empty`)}),f.length>0&&(0,V.jsx)(`ul`,{className:`m-0 list-none p-0 flex max-h-[44vh] flex-col gap-2 overflow-y-auto`,ref:u,children:f.map((e,t)=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:Xt(t===i),onClick:()=>a(t),autoFocus:t===0,children:[(0,V.jsxs)(`span`,{className:`font-mono text-meta whitespace-pre text-accent`,children:[t===i?`▸ `:` `,uU(e.at),`, `,e.author]}),(0,V.jsx)(`span`,{className:`text-ink whitespace-pre-wrap wrap-anywhere`,children:e.text})]})},`${e.at}:${t}`))}),o&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-sm border-hairline border-line bg-paper px-3 py-2.5`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:q(`tasks`,`fieldNotes.confirmDelete.title`)})}),(0,V.jsx)(`p`,{className:`text-muted`,children:q(`tasks`,`fieldNotes.confirmDelete.body`,{text:o.text})}),c&&(0,V.jsx)(`p`,{className:`text-error`,children:c}),(0,V.jsxs)(`div`,{className:`actions flex items-center justify-end gap-3.5`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:()=>s(null),children:z(`dialog.cancel`)}),(0,V.jsx)(`button`,{type:`button`,className:Pe({danger:!0}),onClick:()=>void p(o),children:z(`taskops.retire`)})]})]}),!o&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`keys-only font-sans text-meta text-subtle`,children:q(`tasks`,`fieldNotes.footerDeletable`)}),(0,V.jsxs)(`div`,{className:`actions flex items-center justify-end gap-3.5`,children:[(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,disabled:f[i]?.id===void 0,onClick:()=>s(f[i]??null),children:z(`taskops.retire`)}),(0,V.jsx)(`button`,{type:`button`,className:`link text-accent [&:hover]:underline touch-hit`,onClick:Sn,children:z(`taskops.close`)})]})]})]})})}var fU=[`backlog`,`in_progress`,`in_review`,`done`,`canceled`,`error`],pU={backlog:`status.backlog`,in_progress:`status.inProgress`,in_review:`status.inReview`,done:`status.done`,canceled:`status.canceled`,error:`status.error`},mU=e=>({binding:e,key:ro(e)??void 0});async function hU(e,t){if(!e){G(z(`menu.nothingToCopy`,{what:t}),`error`);return}try{await navigator.clipboard.writeText(e),G(z(`menu.copied`,{text:e}))}catch{G(z(`menu.copyFailed`),`error`)}}function gU(e,t,n){let r=[{label:z(`menu.newTask`),section:`open`,run:()=>iO(t)}],i=n.mainTaskId;return i&&(n.first||r.push({label:q(`tasks`,`menu.moveToTop`),section:`edit`,run:()=>void e.client.request(`task.move`,{taskId:i,direction:`top`}).catch(e=>G(q(`tasks`,`toast.moveFailed`,{error:String(e)}),`error`))}),r.push({label:q(`tasks`,`menu.reorderProject`),section:`edit`,...mU(`sidebar.localMerge`),run:()=>vU(i)})),r.push({label:q(`tasks`,`menu.fieldNotes`),section:`notes`,run:()=>W.set((0,V.jsx)(dU,{model:e,repo:t}))}),i&&r.push({label:q(`tasks`,`menu.forgetProject`),section:`danger`,danger:!0,run:()=>W.set(fF(e,t,n.label))}),r}function _U(e){return[{label:z(`menu.newChatNoFolder`),section:`open`,run:()=>aO()},{label:z(`menu.newShell`),section:`open`,run:()=>void VC(e).catch(e=>G(String(e),`error`))}]}function vU(e){let t=!WT.get();t&&e!==void 0&&GT.set(e),KT(t),document.querySelector(`.rail`)?.focus()}function yU(e,t){let n=(e.tasks.get()?.tasks??[]).filter(e=>e.kind===`main`&&!e.machine&&e.repo!==t.repo).map(e=>e.repo),r=n.map(e=>{let t=e.slice(e.lastIndexOf(`/`)+1);return{value:e,label:n.filter(e=>e.endsWith(`/${t}`)).length>1?e:t}});return r.length===0?(G(q(`tasks`,`moveToProject.empty`),`error`),null):(0,V.jsx)(dr,{title:q(`tasks`,`moveToProject.title`),choices:r,onPick:async n=>{await e.client.request(`task.moveToProject`,{taskId:t.id,repo:n}),G(q(`tasks`,`toast.movedToProject`,{project:r.find(e=>e.value===n)?.label??n}))}})}function bU(e,t,n){let r=e.client,i=[];n&&(i.push({label:z(`menu.closeTab`),section:`tab`,run:()=>W.set((0,V.jsx)(ur,{title:z(`confirm.closeTabTitle`,{tab:n.title??n.engineName??n.id}),body:z(`confirm.closeTabBody`),confirmLabel:z(`menu.closeTab`),onConfirm:async()=>{await r.request(`tab.close`,{taskId:t.id,tabId:n.id}),await e.refreshTabsNow()}}))}),i.push(...rU(e,t.id,n))),i.push({label:z(`menu.newChat`),section:`open`,run:()=>void zC(e,t.id)}),i.push({label:z(`menu.newChatPick`),section:`open`,run:()=>W.set((0,V.jsx)(GC,{model:e,taskId:t.id}))}),i.push({label:z(`menu.continueEngine`),section:`open`,...mU(`chat.tab.fork`),run:()=>W.set((0,V.jsx)(GC,{model:e,taskId:t.id,context:`continue`,sourceTabId:n?.id}))}),i.push({label:z(`menu.newShell`),section:`open`,run:()=>void BC(e,t.id,{kind:`shell`}).catch(e=>G(String(e),`error`))}),t.startsAt&&(i.push({label:z(`menu.startNow`),section:`open`,run:()=>void e.client.request(`task.startScheduledNow`,{taskId:t.id}).catch(e=>G(String(e),`error`))}),i.push({label:z(`menu.cancelStart`),section:`open`,run:()=>void e.client.request(`task.cancelScheduledStart`,{taskId:t.id}).catch(e=>G(String(e),`error`))})),t.hasPrompt&&(i.push({label:q(`tasks`,`menu.runAgain`),section:`open`,run:()=>W.set((0,V.jsx)(lU,{model:e,task:t}))}),i.push({label:z(`menu.retryEdit`),section:`open`,run:()=>void WD(e,t)}));let a=!t.machine;if(a&&i.push({label:q(`tasks`,`menu.openEditor`),section:`open`,...mU(`tasks.openWorktree`),run:()=>void sF(e,t.id)}),t.groupId){let e=t.groupId;i.push({label:z(`compare.menu`),section:`open`,run:()=>ya(e)})}i.push({label:z(`menu.rename`),section:`edit`,...mU(`sidebar.rename`),run:()=>W.set((0,V.jsx)(lr,{title:z(`menu.rename`),initial:t.title,submitLabel:z(`dialog.save`),onSubmit:e=>r.request(`task.rename`,{taskId:t.id,title:e}).then(()=>{})}))}),t.kind!==`main`&&i.push({label:t.pinned?z(`menu.unpin`):z(`menu.pin`),section:`edit`,...mU(`sidebar.pin`),run:()=>void r.request(`task.pin`,{taskId:t.id,pinned:!t.pinned}).catch(e=>G(String(e),`error`))}),a&&i.push({label:q(`tasks`,`menu.reorder`),section:`edit`,...mU(`sidebar.localMerge`),run:()=>vU()}),i.push({label:z(`menu.setStatus`),section:`edit`,children:fU.map(e=>({label:z(pU[e]),checked:e===t.status,run:()=>void r.request(`task.setStatus`,{taskId:t.id,status:e}).catch(e=>G(String(e),`error`))}))}),a&&t.kind!==`main`&&!t.routine&&!t.parentTaskId&&!t.extraRepoCount&&i.push({label:q(`tasks`,`menu.moveToProject`),section:`edit`,run:()=>{let n=yU(e,t);n&&W.set(n)}}),a&&i.push({label:z(`menu.changeEngine`),section:`edit`,...mU(`tasks.cycleEngine`),run:()=>W.set((0,V.jsx)(cU,{model:e,taskId:t.id}))}),t.pr?.checkState===`failing`&&i.push({label:q(`tasks`,`menu.fixChecks`),section:`git`,key:ii(`files.fixChecks`),run:()=>void oF(e,t.id,z(`taskops.fixSent`))}),t.kind===`task`&&t.branch&&a&&i.push({label:q(`tasks`,`menu.syncBase`),section:`git`,key:ii(`files.syncBase`),run:()=>void iF(e,t.id)}),t.branch&&i.push({label:z(`menu.renameBranch`),section:`git`,...mU(`tasks.renameBranch`),run:()=>W.set((0,V.jsx)(lr,{title:z(`menu.renameBranch`),initial:t.branch,submitLabel:z(`dialog.save`),onSubmit:e=>r.request(`task.setBranch`,{taskId:t.id,branch:e}).then(()=>{})}))}),t.kind===`task`&&t.branch&&i.push({label:z(`menu.land`),section:`git`,run:()=>void nF(e,t)});let o=[{label:z(`menu.copyWhat.id`),run:()=>void hU(t.id,z(`menu.what.id`))}];return t.branch&&o.push({label:z(`menu.copyWhat.branch`),run:()=>void hU(t.branch,z(`menu.what.branch`))}),o.push({label:z(`menu.copyWhat.path`),run:()=>void r.request(`task.get`,{taskId:t.id}).then(e=>hU(e.task.worktreePath,z(`menu.what.path`))).catch(e=>G(String(e),`error`))}),i.push({label:z(`menu.copy`),section:`copy`,children:o}),t.kind!==`main`&&i.push({label:q(`tasks`,t.archived?`menu.unarchive`:`menu.archive`),section:`danger`,run:()=>void dF(e,t)}),i.push({label:z(`menu.removeSession`),section:`danger`,...mU(`sidebar.delete`),danger:!0,run:()=>W.set(t.kind===`main`?uF(e,t):lF(e,t))}),i}var xU=`rove.collapsedProjects`,SU=`rove.foldedTasks`,CU=`rove.openedTasks`,wU=600;function TU(e){try{let t=JSON.parse(localStorage.getItem(e)??`[]`);return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}}function EU(e,t){try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}var DU=(e,t)=>{let n=new Set(e);return n.delete(t)||n.add(t),n};function OU(){let e=v(VT),[t,n]=(0,g.useState)({active:!1,query:``}),[r,i]=(0,g.useState)(!1),a=()=>i(e=>!e),[o,s]=(0,g.useState)(()=>TU(xU)),c=e=>s(t=>{let n=DU(t,e);return EU(xU,n),n}),[l,u]=(0,g.useState)(()=>({folded:TU(SU),opened:TU(CU)}));return{sort:e,cycleSort:UT,search:t,setSearch:n,archivedOpen:r,toggleArchived:a,collapsed:o,toggleProject:c,hand:l,toggleTaskFold:(e,t)=>u(n=>{let r=new Set(n.folded),i=new Set(n.opened);return t?(r.delete(e),i.add(e)):(i.delete(e),r.add(e)),EU(SU,r),EU(CU,i),{folded:r,opened:i}})}}var kU=[`sidebar.nav`,`sidebar.goto`,`sidebar.select`,`sidebar.tree.open`,`sidebar.rename`,`sidebar.pin`,`sidebar.localMerge`,`sidebar.delete`,`sidebar.sort`,`sidebar.search.enter`,`tasks.renameBranch`,`tasks.cycleEngine`,`tasks.openWorktree`,`tasks.update`,`tasks.focusEngine`,`task.new`,`settings.open.sidebar`,`worktrees.open.sidebar`];function AU(e){for(let t of e)for(let e of kU){let n=ri(e).indexOf(t);if(n>=0)return{id:e,slot:n}}return null}function jU(e,t){let n=e.selection.get().taskId===t;e.select(t),ga(),n&&qi()}function MU(e,t,n,r){let{search:i,setSearch:a}=n,[o,s]=(0,g.useState)(null),c=(0,g.useRef)(0),l=t.filter(e=>e.kind!==`project`&&e.kind!==`state`),u=l.findIndex(e=>e.id===o);(0,g.useEffect)(()=>{u<0&&s(r.selectedId&&l.some(e=>e.id===r.selectedId)?r.selectedId:l[0]?.id??null)},[u,l,r.selectedId]);let d=l[u],f=d?.kind===`task`||d?.kind===`pane`?d.task.id:null;(0,g.useEffect)(()=>dA.set(f),[f]);let p=l[0]?.id??null;(0,g.useEffect)(()=>{i.query,i.active&&s(p)},[i.active,i.query,p]);let m=e=>{let t=l[Math.max(0,Math.min(l.length-1,e))];t&&s(t.id)},h=t=>{t?.kind===`archived`&&n.toggleArchived(),t?.kind===`task`&&e.select(t.task.id),t?.kind===`round`&&ya(t.groupId),t?.kind===`pane`&&aU(e,t),t&&t.kind!==`archived`&&ga()},_=(t,n)=>{t?.kind===`task`&&an(bU(e,t.task,null),n)?.run?.()},v=async t=>{if(t?.kind===`task`&&t.machine===void 0)try{let{engines:n}=await e.client.request(`engines.list`),r=xs(n).filter(e=>e.ready!==!1),i=r[(r.findIndex(e=>e.id===t.task.engine?.id)+1)%r.length];if(!i||i.id===t.task.engine?.id)return;await e.client.request(`task.setCommand`,{taskId:t.task.id,engine:i.id}),G(z(`rail.engineSwitched`,{engine:i.name}))}catch(e){G(z(`rail.engineSwitchFailed`,{error:e instanceof Error?e.message:String(e)}),`error`)}};return{cursor:o,setCursor:s,onKeyDown:t=>{let o=l[u],s=t.target instanceof HTMLInputElement;if(i.active){if(t.metaKey||t.ctrlKey||t.altKey)return;if(t.key===`Escape`)a({active:!1,query:``});else if(t.key===`Enter`)h(o),a({active:!1,query:``});else if(t.key===`ArrowDown`)m(u+1);else if(t.key===`ArrowUp`)m(u-1);else if(t.key===`Backspace`&&!s)a(e=>({...e,query:e.query.slice(0,-1)}));else if(t.key.length===1&&!s)a(e=>({...e,query:e.query+t.key}));else return;t.preventDefault();return}let d=AU(Za(t));if(WT.get()){let n=o?.kind===`task`&&o.machine===void 0;if(d?.id===`sidebar.nav`)n&&qT(e,o,d.slot%2==0?1:-1);else if(d?.id===`sidebar.localMerge`||t.key===`Enter`||t.key===`Escape`)KT(!1);else return;t.preventDefault();return}switch(d?.id){case`sidebar.nav`:m(d.slot%2==0?u+1:u-1);break;case`sidebar.goto`:d.slot%2==1?m(l.length-1):Date.now()-c.current<wU?(m(0),c.current=0):c.current=Date.now();break;case`sidebar.select`:case`sidebar.tree.open`:h(o);break;case`tasks.focusEngine`:qi();break;case`sidebar.rename`:case`sidebar.pin`:case`sidebar.delete`:case`tasks.renameBranch`:case`tasks.openWorktree`:_(o,d.id);break;case`tasks.cycleEngine`:v(o);break;case`sidebar.localMerge`:o?.machine===void 0&&KT(!0);break;case`sidebar.sort`:n.cycleSort(),G(q(`tasks`,`sort.label`,{mode:q(`tasks`,`sort.modes.${VT.get()}`)}));break;case`sidebar.search.enter`:a({active:!0,query:``});break;case`task.new`:r.onNewTask(o?.kind===`task`||o?.kind===`pane`?o.task.repo:void 0,o?.machine);break;case`settings.open.sidebar`:r.onSettings();break;case`worktrees.open.sidebar`:va(`worktrees`);break;case`tasks.update`:va(`update`);break;default:return}t.preventDefault()}}}var NU=(e,t,n)=>`~pane:${e}:${t}:${n}`;function PU(e,t){return e.flatMap(e=>e.kind===`task`?[e,...(t[e.task.id]??[]).flatMap(t=>{let n=t.split;if(!n||!Dw(n))return[];let r=Aw(n,ww(t));return Ew(n.root).map(n=>({id:NU(e.task.id,t.id,n.id),kind:`pane`,task:e.task,tab:t,leaf:n.id,label:r.get(n.id)??n.id,depth:e.depth+1,...e.machine===void 0?{}:{machine:e.machine}}))})]:[e])}function FU(e){let{row:t}=e;return(0,V.jsxs)(`button`,{type:`button`,className:`${tr({size:`pane`})} ${e.cursor?mE:``}`,title:z(`compare.menu`),onClick:()=>{e.onClick(),ya(t.groupId)},...e.place,children:[e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:$T(e)},t))}),(0,V.jsx)(`span`,{className:`${nr} text-(length:--fs-meta) text-muted`,children:t.title}),(0,V.jsxs)(`span`,{className:`${or} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),(0,V.jsx)(`span`,{className:`text-subtle`,children:t.tasks.length}),(0,V.jsx)(uR,{status:rI(t.tasks)})]})]})}function IU(e){let t=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let e=t.current;return()=>{e&&document.activeElement===e&&e.closest(`nav`)?.focus()}},[]),(0,V.jsxs)(`div`,{className:`${sE} mono items-center`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:`/`}),(0,V.jsx)(`input`,{ref:t,className:fE,type:`text`,autoFocus:!0,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,enterKeyHint:`go`,value:e.query,placeholder:z(`rail.searchPlaceholder`),"aria-label":z(`rail.searchPlaceholder`),onChange:t=>e.onChange(t.target.value)}),e.query&&(0,V.jsx)(`span`,{className:`ml-1.5 text-muted`,children:e.count})]})}var LU=450,RU=!1;typeof document<`u`&&(document.addEventListener(`keydown`,()=>{RU=!0},!0),document.addEventListener(`pointerdown`,()=>{RU=!1},!0));var zU=e=>{let t=e.querySelector(`.row-title`);return!!t&&t.scrollWidth>t.clientWidth};function BU(e,t){let[n,r]=(0,g.useState)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(null),o=()=>{i.current!==null&&window.clearTimeout(i.current),i.current=null},s=e=>{o(),i.current=window.setTimeout(()=>r(e.getBoundingClientRect()),LU)},c=()=>{o(),r(null)};return(0,g.useEffect)(()=>{let e=a.current,n=e?.closest(`.rail`);if(!t||!e||!n||!RU||!n.contains(document.activeElement)||!zU(e))return;let i=()=>{o(),r(null)},c=e=>{e.relatedTarget instanceof Node&&n.contains(e.relatedTarget)||i()};return s(e),n.addEventListener(`focusout`,c),()=>{n.removeEventListener(`focusout`,c),i()}},[t]),(0,g.useEffect)(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]),{ref:e=>{a.current=e},onPointerEnter:e=>{e.pointerType===`touch`||!zU(e.currentTarget)||s(e.currentTarget)},onPointerLeave:c,hide:c,tip:n?(0,EH.createPortal)((0,V.jsx)(`div`,{className:rE,role:`tooltip`,style:{top:n.top+n.height/2,left:n.right+8},children:e}),document.body):null}}function VU({at:e}){let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=DD(t);return(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.startsAt`,{time:t.toLocaleString()}),children:[`◷ `,n]})}var HU=150,UU=128,WU=0,GU=2,KU=[{reach:.96,grow:1.5,pulse:.9,done:104},{reach:.72,grow:1.1,pulse:1.2,done:84},{reach:1,grow:1.7,pulse:.7,done:116},{reach:.84,grow:1.3,pulse:1,done:96},{reach:.62,grow:1.2,pulse:1.3,done:80}],qU=`/-\\|`,JU=6,YU=(e,t,n,r)=>{let i=e[n];i&&t>=0&&t<i.length&&(i[t]=r)};function XU(e,t){let n=Math.min(64,Math.max(24,Math.floor(t))),r=(Math.floor(e)%HU+HU)%HU,i=Array.from({length:11},()=>Array(n).fill(` `)),a=Array.from({length:11},()=>Array(n).fill(` `));YU(a,WU,0,`o`);let o=GU+2*(KU.length-1),s=Math.min(o,Math.floor(r/2));for(let e=1;e<=s;e++)YU(i,WU,e,`|`);if(KU.forEach((e,t)=>{let o=GU+2*t,s=2*o;if(r<s)return;YU(i,WU,o,`+`);let c=n-1-1,l=1+Math.max(1,Math.floor(c*e.reach)),u=Math.min(l,1+Math.floor((r-s)*e.grow)),d=r>=e.done&&u===l;for(let t=1;t<u;t++)!d&&((t-Math.floor(r*e.pulse))%JU+JU)%JU===0?YU(a,t,o,`=`):YU(i,t,o,`-`);d?YU(a,u,o,`o`):u<l?YU(a,u,o,`>`):YU(a,u,o,qU[(Math.floor(r/2)+t)%4]??`-`)}),r>=UU){let e=Math.ceil((r-UU+1)/22*(n+1));for(let t of[i,a])for(let r of t)r.fill(` `,0,Math.min(n,e))}return{base:i.map(e=>e.join(``)).join(`
127
127
  `),accent:a.map(e=>e.join(``)).join(`
128
- `)}}var ZU=`min-h-0 w-full overflow-y-auto`,QU=`mx-auto mt-[min(16vh,8rem)] flex w-full max-w-130 flex-col gap-4 px-5 pb-7`,$U=`relative grid w-full select-none overflow-hidden font-mono text-(length:--fs-body) text-subtle [contain:layout_paint]`,eW=`col-start-1 row-start-1 m-0 whitespace-pre font-[inherit] leading-[inherit]`,tW=`invisible absolute top-0 left-0 whitespace-pre`,nW=1.3,rW=`0000000000`,iW=1e3/12;function aW(){let e=(0,g.useRef)(null),t=(0,g.useRef)(null),n=(0,g.useRef)(null),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let i=e.current,a=t.current,o=n.current,s=r.current;if(!i||!a||!o||!s)return;let c=window.matchMedia(`(prefers-reduced-motion: reduce)`),l=24,u=90,d=0,f=0,p=0,m=-1,h=!0,g=()=>{let e=XU(u,l);o.textContent=e.base,s.textContent=e.accent},_=()=>{let e=a.getBoundingClientRect().width/10;e>0&&(l=Math.min(64,Math.max(24,Math.floor(i.clientWidth/e)))),g()},v=e=>{d=requestAnimationFrame(v);let t=p+Math.floor((e-f)/iW);t!==m&&(m=t,u=t,g())},y=()=>{cancelAnimationFrame(d),d=0},b=()=>{y(),c.matches?(u=90,g()):h&&document.visibilityState===`visible`&&(f=performance.now(),p=u,m=-1,d=requestAnimationFrame(v))},x=new ResizeObserver(_);x.observe(i),_(),b();let S=new IntersectionObserver(e=>{h=e[e.length-1]?.isIntersecting??!0,b()});return S.observe(i),c.addEventListener(`change`,b),document.addEventListener(`visibilitychange`,b),()=>{y(),x.disconnect(),S.disconnect(),c.removeEventListener(`change`,b),document.removeEventListener(`visibilitychange`,b)}},[]),(0,V.jsxs)(`div`,{ref:e,"aria-hidden":`true`,"data-field":`first-run-art`,className:$U,style:{height:`${11*nW}em`,lineHeight:nW},children:[(0,V.jsx)(`span`,{ref:t,className:tW,children:rW}),(0,V.jsx)(`pre`,{ref:n,className:eW}),(0,V.jsx)(`pre`,{ref:r,className:`${eW} text-accent`})]})}function oW(e){let t=q(`doctor`,`fix.humanOnlyWhy`),n=[];if(e.git||n.push({id:`git`,label:q(`doctor`,`fix.git`),action:q(`doctor`,`fix.gitAction`),why:t}),e.engines.length===0){let r=e.signedOut.length>0;n.push({id:`engine`,label:q(`doctor`,r?`fix.noEngineLogin`:`fix.noEngine`),action:q(`doctor`,r?`fix.noEngineLoginAction`:`fix.noEngineAction`,{list:e.signedOut.map(e=>e.id).join(`, `)}),why:t})}return n}function sW({model:e}){B(),v(Yr);let[t,n]=(0,g.useState)(()=>Bs(e,`welcome.env`)??null);(0,g.useEffect)(()=>{let t=!0;return Hs(e,`welcome.env`).then(e=>t&&n(e)).catch(()=>{}),()=>{t=!1}},[e]);let r=t===null?null:t.engines.length>0?{key:`enginesFound`,warn:!1,list:t.engines.map(e=>e.name).join(`, `)}:t.signedOut.length>0?{key:`enginesSignedOut`,warn:!0,list:t.signedOut.map(e=>e.name).join(`, `)}:{key:`enginesMissing`,warn:!0,list:``},i=t!==null&&(t.engines.length===0||!t.git)?oW(t):[];return(0,V.jsx)(`div`,{className:ZU,"data-field":`welcome`,children:(0,V.jsxs)(`div`,{className:QU,children:[(0,V.jsx)(aW,{}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-title font-semibold text-ink`,children:z(`firstRun.title`)}),(0,V.jsx)(`p`,{className:`m-0 font-sans text-body text-muted`,children:z(`firstRun.body`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,className:Pe(),"data-field":`start-first-task`,onClick:()=>iO(t?.start?.repo),children:z(`firstRun.start`)}),(0,V.jsx)(`span`,{className:`keys-only mono text-meta text-subtle`,children:ii(`task.new.global`)})]}),t!==null&&r!==null&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-sans text-meta`,children:[(0,V.jsx)(`p`,{className:`m-0 ${r.warn?`text-warning`:`text-subtle`}`,children:q(`workspace`,`welcome.${r.key}`,{list:r.list})}),!t.git&&(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:q(`workspace`,`welcome.gitMissing`)}),i.map(e=>(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:e.label}),(0,V.jsx)(`p`,{className:`mono m-0 text-accent`,children:e.action}),(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:e.why})]},e.id)),i.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:q(`common`,`failureHint`,{command:`rove doctor`})})]})]})})}function cW(e,t){e.preventDefault(),on.set({x:e.clientX,y:e.clientY,items:t,target:e.currentTarget,fromKeyboard:e.button!==2})}function lW({model:e,narrow:t}){let n=B(),r=v(e.tasks),i=v(e.remote),a=EE(e),o=v(e.tabs),s=v(e.tabsSettled),c=v(e.selection),l=r?.tasks??[],u=r?.attention.filter(e=>e.unread).length??0,d=c.taskId,f=new Map([...l,...i].map(e=>[e.id,e])),p=OU(),m=v(WT),h=v(LT)===`state`,_=v(GT),y=e=>(h?mO:Cw)({tasks:l,remote:i,machines:a,sort:p.sort,query:e,fold:{...p.hand,selectedId:d??void 0}}),b=y(p.search.active?p.search.query:``),{groups:x}=b,S=p.search.active?b.rows:NH(Tw(PU(hO(GH(b.rows,o,c.taskId,s,_)),o),p.collapsed),r?.archived??[],p.archivedOpen,{...p.hand,selectedId:d??void 0}),C=e=>e.filter(e=>e.kind!==`project`&&e.kind!==`state`&&e.kind!==`round`),w=(n===`zh`?Ar:kr).machine,T=new Set(a.filter(e=>e.state!==`online`).map(e=>e.alias)),E=x.find(e=>e.tasks.some(e=>e.kind===`main`))?.repo,D=e=>({mainTaskId:x.find(t=>t.repo===e)?.tasks.find(e=>e.kind===`main`)?.id??null,label:KC(e),first:e===E}),O=UH(e,l,!p.search.active&&!h,p.sort==="default",D),k=O.places(S),A=()=>W.set((0,V.jsx)(JP,{model:e})),j=MU(e,S,p,{selectedId:d,onNewTask:iO,onSettings:A}),ee=_!==null&&S.some(e=>e.id===_),M=j.setCursor;(0,g.useEffect)(()=>{ee&&_!==null&&M(_)},[ee,_,M]);let N=C(y(``).rows).length,P=(0,g.useRef)(null),F=v(pI)&&!t,I=v(mI)&&F,te=t?l.find(e=>e.id===c.taskId&&!e.deleting)??null:null;return(0,V.jsxs)(`nav`,{className:`${aE} ${F?`is-folded`:``}`,ref:P,inert:F&&!I,"aria-hidden":F&&!I,onMouseEnter:F?()=>gI(!0):void 0,onMouseLeave:F?()=>gI(!1):void 0,tabIndex:0,onKeyDown:e=>{BF(`sidebar`),j.onKeyDown(e)},children:[(0,V.jsxs)(`header`,{className:oE,children:[(0,V.jsxs)(`span`,{className:`${Ht} mr-auto`,children:[(0,V.jsx)(`span`,{className:Ut,children:`[`}),` rove `,(0,V.jsx)(`span`,{className:Ut,children:`]`})]}),(0,V.jsxs)(`span`,{className:`relative`,children:[(0,V.jsx)(`button`,{type:`button`,className:`m-0 text-meta font-medium normal-nums inbox-chip relative ${$n} ${Ge} ${u>0?`text-accent`:`text-muted`}`,onClick:()=>W.set((0,V.jsx)(PT,{model:e})),children:z(`rail.inbox`,{count:u})}),(0,V.jsx)(NF,{model:e,bindingId:`inbox.show`,head:!0})]}),(0,V.jsx)(HM,{})]}),m&&(0,V.jsxs)(`div`,{className:`flex gap-1 px-3.5 pb-2 text-meta mono`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:q(`tasks`,`moveChip`).trim()}),(0,V.jsx)(`span`,{className:`keys-only ml-1.5 text-muted`,children:(0,V.jsx)(kT,{text:z(`taskops.moveHint`)})})]}),p.search.active&&(0,V.jsx)(IU,{query:p.search.query,count:`${C(S).length}/${N}`,onChange:e=>p.setSearch(t=>({...t,query:e}))}),(0,V.jsx)(oL,{model:e}),(0,V.jsx)(wH,{model:e}),(0,V.jsxs)(`div`,{"data-rail-body":!0,className:pE(O.dragging!==null),...O.body,children:[r&&l.length===0&&i.length===0&&t&&(0,V.jsx)(sW,{model:e}),r&&l.length===0&&i.length===0&&!t&&(0,V.jsx)(`p`,{className:`m-0 px-2 py-3 font-mono text-meta text-subtle`,children:z(`rail.empty`)}),te&&(0,V.jsx)(GI,{title:te.title}),S.map((t,n)=>t.kind===`round`?(0,V.jsx)(FU,{row:t,guides:t.depth>1?VH(S,n):void 0,repo:h&&t.depth===1?fO(t.tasks[0]):void 0,cursor:t.id===j.cursor,place:k(t),onClick:()=>j.setCursor(t.id)},t.id):t.kind===`pane`?(0,V.jsx)(oU,{model:e,row:t,guides:VH(S,n),cursor:t.id===j.cursor,place:k(t),onClick:()=>{j.setCursor(t.id),aU(e,t),ga()},onMenu:n=>{j.setCursor(t.id),cW(n,tU(e,t.task.id,t.tab,t.leaf))}},t.id):(0,V.jsx)(uW,{row:t,guides:t.kind===`task`&&t.depth>1?VH(S,n):void 0,cloud:CE(t,a,w),repo:h&&t.kind===`task`&&t.depth===1?fO(t.task):void 0,tabs:t.kind===`task`?o[t.task.id]:void 0,selected:t.id===d,cursor:t.id===j.cursor,stale:t.machine!==void 0&&T.has(t.machine),collapsed:(t.kind===`project`||t.kind===`state`)&&p.collapsed.has(t.id),drag:O.props(t),dragging:O.dragging===t.id,place:k(t),onNewTask:t.kind===`project`?t.noProject?aO:()=>iO(t.repo,t.machine):void 0,moving:m&&t.machine===void 0&&(t.kind===`project`?!t.noProject&&D(t.repo).mainTaskId===j.cursor:t.id===j.cursor&&(t.kind!==`task`||t.task.kind!==`main`)),prTasks:t.kind===`task`?[t.task,...(t.fold?.descendantIds??[]).flatMap(e=>f.get(e)??[])]:void 0,rollup:t.kind===`task`&&t.fold?.collapsed?rI([t.task,...t.fold.descendantIds.flatMap(e=>f.get(e)??[])]):void 0,onToggleFold:()=>{t.kind===`task`&&p.toggleTaskFold(t.id,t.fold?.collapsed===!0),t.kind===`archived`&&p.toggleArchived()},onClick:()=>{j.setCursor(t.id),t.kind===`archived`&&p.toggleArchived(),(t.kind===`project`||t.kind===`state`)&&p.toggleProject(t.id),t.kind===`task`&&jU(e,t.task.id)},onMenu:n=>{if(t.kind!==`project`||t.machine===void 0){if(t.kind===`project`&&t.noProject){cW(n,_U(e));return}if(t.kind===`project`){let r=D(t.repo);r.mainTaskId&&S.some(e=>e.id===r.mainTaskId)&&j.setCursor(r.mainTaskId),cW(n,gU(e,t.repo,r));return}t.kind===`task`&&(j.setCursor(t.id),cW(n,pW(fW(bU(e,t.task,null),t.fold,()=>p.toggleTaskFold(t.id,t.fold?.collapsed===!0)),iU(e,t.task.id))))}}},t.id))]}),(0,V.jsx)(WH,{model:e,narrow:t,onSettings:A}),(0,V.jsx)(KI,{pane:`sidebar`}),!t&&!F&&(0,V.jsx)(BI,{rail:P})]})}function uW(e){let{row:t}=e,n=BU(t.kind===`task`?t.task.label:``,e.cursor&&t.kind===`task`),r=e.cursor?mE:``;if(t.kind===`project`||t.kind===`state`)return(0,V.jsxs)(`h2`,{className:hE({moving:e.moving,dragging:e.dragging}),onContextMenu:e.onMenu,...e.place,...e.drag,children:[(0,V.jsxs)(`button`,{type:`button`,className:_E,title:t.kind===`project`&&!t.noProject?t.repo:void 0,"aria-expanded":!e.collapsed,onClick:e.onClick,children:[(0,V.jsx)(`span`,{className:`truncate`,children:t.label}),t.kind===`state`&&(0,V.jsx)(`span`,{className:`font-normal text-subtle`,children:t.count}),(0,V.jsx)(Fa,{right:e.collapsed,className:vE(!!e.collapsed)})]}),e.onNewTask&&t.kind===`project`&&(0,V.jsx)(`button`,{type:`button`,className:yE,title:z(`rail.newTask`),onClick:e.onNewTask,children:`+`})]});if(t.kind===`archived`)return(0,V.jsx)(`button`,{type:`button`,className:`${tr({moving:e.moving||e.dragging})} ${r}`,"aria-expanded":t.expanded,onClick:e.onClick,...e.place,children:(0,V.jsx)(`span`,{className:`${rr} ${e.stale?`text-subtle`:`text-muted`}`,children:q(`tasks`,`archivedRow`,{count:t.count})})});let i=t.task,a=i.rowStatus?.kind===`running`,o=YP(i);return(0,V.jsxs)(`button`,{type:`button`,ref:n.ref,className:`${tr({selected:e.selected,moving:e.moving||e.dragging})} ${r}`,onClick:e.onClick,onContextMenu:e.onMenu,onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,...e.place,...e.drag,children:[n.tip,e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:$T(e)},t))}),(0,V.jsx)(`span`,{className:`${rr} ${e.stale?`text-subtle`:``} ${a?ir:``}`,children:t.attempt??i.label}),(0,V.jsxs)(`span`,{className:`${or} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),t.level!==void 0&&(0,V.jsx)(`span`,{className:`text-subtle`,children:t.level}),(i.extraRepoCount??0)>0&&(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.extraRepos`,{count:i.extraRepoCount??0}),children:[`+`,i.extraRepoCount]}),o&&(0,V.jsxs)(`span`,{className:`text-subtle tabular-nums`,title:z(`rail.todos`,o),children:[o.done,`/`,o.total]}),t.fold?.collapsed&&(0,V.jsx)(dW,{count:t.fold.count,onUnfold:e.onToggleFold}),i.kept&&(0,V.jsx)(`span`,{className:`text-accent`,title:z(`compare.kept`),children:`✓`}),i.pinned&&(0,V.jsx)(`span`,{className:`text-subtle`,children:`▴`}),i.startsAt&&(0,V.jsx)(VU,{at:i.startsAt}),(0,V.jsx)(jH,{tasks:e.prTasks??[i],onOpen:n.hide}),(0,V.jsx)(uR,{status:t.fold?.collapsed?e.rollup:i.rowStatus}),e.cloud&&(0,V.jsx)(wE,{label:e.cloud})]})]})}function dW(e){let t=q(`tasks`,`menu.expandChildren`);return(0,V.jsxs)(`span`,{role:`button`,tabIndex:-1,"aria-label":t,"aria-expanded":!1,className:`chip text-muted ${eE}`,title:t,onClick:t=>{t.stopPropagation(),e.onUnfold()},children:[e.count,(0,V.jsx)(Fa,{right:!0})]})}function fW(e,t,n){if(!t)return e;let r={label:q(`tasks`,t.collapsed?`menu.expandChildren`:`menu.collapseChildren`),section:`open`,run:n},i=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,i+1),r,...e.slice(i+1)]}function pW(e,t){let n=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,n+1),...t,...e.slice(n+1)]}function mW(e){return e===`localhost`||e.endsWith(`.localhost`)||e===`[::1]`||/^127(\.\d{1,3}){3}$/.test(e)}var hW=/^(localhost|127(\.\d{1,3}){3}|\[::1\])(:\d+)?([/?#]|$)/i,gW=/^[a-z][a-z0-9+.-]*:(?!\d+([/?#]|$))/i;function _W(e){let t=e.trim();if(!t||/\s/.test(t)||gW.test(t)&&!/^https?:\/\//i.test(t))return null;let n=/^https?:\/\//i.test(t)?t:hW.test(t)?`http://${t}`:`https://${t.replace(/^\/\//,``)}`;try{let e=new URL(n);return e.hostname?e.href:null}catch{return null}}function vW(e,t,n=mW(t.hostname)){let r=new URL(e);return r.origin===t.origin?`self`:mW(r.hostname)?n?`yes`:`remote`:r.protocol===`https:`?`yes`:`unreachable`}function yW(e,t,n){let r=new URL(e).host;return t===`self`?{key:`self`,host:r}:t===`remote`?{key:`remote`,host:r}:t===`unreachable`?{key:`noFrame`,host:r}:n&&!n.reachable?{key:`unreachable`,host:r}:n&&!n.frameable?{key:`refuses`,host:r}:null}var bW=6e4,xW=new Map;function SW(e){let t=xW.get(e);return t&&Date.now()-t.at<bW?t:null}function CW(e,t,n){let[,r]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(!n||SW(t))return;let i=!0;return e.request(`browser.probe`,{url:t,origin:window.location.origin}).then(e=>xW.set(t,{probe:e,at:Date.now()}),()=>xW.set(t,{probe:null,at:Date.now()})).then(()=>i&&r(e=>e+1)),()=>{i=!1}},[e,t,n]);let i=n?SW(t):null;return{pending:n&&!i,probe:i?.probe??null}}function wW({d:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:e})})}var TW=`M6.5 3.5h-3v9h9v-3M9.5 3.5h3v3M12.5 3.5l-5 5`;function EW({model:e,tab:t,onNavigate:n,onStep:r}){B();let i=ak(t),[a,o]=(0,g.useState)(i),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(0),d=v(e.client.conn).hello?.peer?.local,f=i?vW(i,window.location,d):null;(0,g.useEffect)(()=>{o(i),c(!1)},[i]);let p=e=>{let t=_W(e);c(t===null&&e.trim()!==``),t!==null&&(o(t),t===i?u(l+1):n(t))},m=i?new URL(i).hostname:``,h=f===`yes`&&i.startsWith(`https:`)&&!mW(m),{pending:_,probe:y}=CW(e.client,i,h),b=i&&f?yW(i,f,y):null,x=f===`yes`&&!b&&!_,S=b?z(`browser.${b.key}`,{host:b.host}):f===null?z(s?`browser.invalid`:`browser.empty`):null;return(0,V.jsxs)(`div`,{className:PI,children:[(0,V.jsxs)(`form`,{className:FI,onSubmit:e=>{e.preventDefault(),p(a)},children:[(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:t.at<=0,title:z(`browser.back`),"aria-label":z(`browser.back`),onClick:()=>r(t.at-1),children:(0,V.jsx)(wW,{d:`M10 3.5 5.5 8l4.5 4.5`})}),(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:t.at>=t.urls.length-1,title:z(`browser.forward`),"aria-label":z(`browser.forward`),onClick:()=>r(t.at+1),children:(0,V.jsx)(wW,{d:`M6 3.5 10.5 8 6 12.5`})}),(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:!x,title:z(`browser.reload`),"aria-label":z(`browser.reload`),onClick:()=>u(l+1),children:(0,V.jsx)(wW,{d:`M12.5 8a4.5 4.5 0 1 1-1.4-3.3M12.5 2.5v2.7H9.8`})}),(0,V.jsx)(`input`,{className:`browser-url mono ${II}`,value:a,placeholder:z(`browser.placeholder`),"aria-label":z(`browser.address`),"aria-invalid":s,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,inputMode:`url`,onChange:e=>o(e.target.value)}),i?(0,V.jsx)(`a`,{className:yI({small:!0}),href:i,target:`_blank`,rel:`noopener noreferrer`,title:z(`browser.openTab`),"aria-label":z(`browser.openTab`),children:(0,V.jsx)(wW,{d:TW})}):(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:!0,"aria-label":z(`browser.openTab`),children:(0,V.jsx)(wW,{d:TW})})]}),x?(0,V.jsx)(`iframe`,{className:LI,src:i,title:i,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,referrerPolicy:`no-referrer`},`${i}#${l}`):S?(0,V.jsx)(`p`,{className:NI,children:S}):null]})}var DW=`scrollbar-none flex min-h-0 flex-1 flex-col overflow-y-auto p-2.5`,OW=`m-0 p-3 font-mono text-meta text-muted`,kW=`flex flex-col gap-1.5 rounded-sm border-hairline border-line px-3 py-2.5`,AW=`m-0 font-sans text-meta font-medium text-ink`,jW=`flex items-baseline justify-between gap-3 font-mono text-meta normal-nums`,MW=`flex h-1 w-full overflow-hidden rounded-full bg-inset`,NW=`h-full flex-none`,PW=`m-0 mt-1 flex list-none flex-col gap-1 p-0`,FW=`flex min-w-0 items-center gap-2 font-mono text-meta normal-nums`,IW=`size-2 flex-none rounded-xs bg-line`,LW=`min-w-0 flex-1 truncate text-muted`,RW=`flex-none text-right text-ink`,zW=`w-[6ch] flex-none text-right text-muted`,BW=1e4,VW=[`var(--info)`,`var(--accent)`,`var(--success)`,`var(--warning)`];function HW({model:e,task:t,active:n}){B();let r=v(e.client.conn),i=v(e.selection),a=v(e.tabs)[t.id]??[],o=i.taskId===t.id?a.find(e=>e.id===i.tabId):void 0,s=(o?.kind===`engine`?o:a.find(e=>e.kind===`engine`))?.id??null,[c,l]=(0,g.useState)({kind:`loading`});if((0,g.useEffect)(()=>{if(!n||r.state!==`open`)return;if(!s){l({kind:`ready`,meter:null});return}let i=!0,a=()=>e.client.request(`context.usage`,{taskId:t.id,tabId:s}).then(e=>i&&l({kind:`ready`,meter:e.meter})).catch(e=>i&&l(t=>t.kind===`ready`?t:{kind:`failed`,error:CL(e)}));a();let o=window.setInterval(a,BW);return()=>{i=!1,window.clearInterval(o)}},[e,n,r.state,t.id,s]),c.kind===`loading`)return(0,V.jsx)(`p`,{className:OW,children:z(`context.loading`)});if(c.kind===`failed`)return(0,V.jsx)(`p`,{className:OW,children:z(`context.failed`,{error:c.error})});if(!c.meter)return(0,V.jsx)(`p`,{className:OW,children:z(`context.none`)});let u=c.meter,d=u.rows.filter(e=>e.share!==void 0),f=e=>e.share===void 0?void 0:VW[d.indexOf(e)%VW.length];return(0,V.jsx)(`div`,{className:DW,children:(0,V.jsxs)(`section`,{className:kW,children:[(0,V.jsx)(`h3`,{className:AW,children:z(`context.title`)}),(0,V.jsxs)(`div`,{className:jW,children:[(0,V.jsx)(`span`,{className:`text-ink`,children:u.percent===null?z(`context.usedTokens`,{tokens:UW(u.used)}):z(`context.used`,{percent:WW(u.percent)})}),u.window!==null&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[UW(u.used),` / `,UW(u.window)]})]}),(0,V.jsx)(`div`,{className:MW,role:`meter`,"aria-valuenow":Math.round(u.percent??100),"aria-valuemin":0,"aria-valuemax":100,children:d.map(e=>(0,V.jsx)(`span`,{className:NW,style:{width:`${e.share}%`,background:f(e)}},e.key))}),(0,V.jsx)(`ul`,{className:PW,children:u.rows.map(e=>{let t=z(`context.part.${e.key}`),n=f(e);return(0,V.jsxs)(`li`,{className:FW,children:[(0,V.jsx)(`span`,{className:IW,style:n?{background:n}:void 0}),(0,V.jsx)(`span`,{className:LW,title:t,children:t}),(0,V.jsx)(`span`,{className:RW,children:UW(e.tokens)}),(0,V.jsx)(`span`,{className:zW,children:WW(e.tokens/(u.window??u.used)*100)})]},e.key)})}),u.approximate&&(0,V.jsx)(`p`,{className:`m-0 font-mono text-meta text-subtle`,children:z(`context.approximate`)})]})})}function UW(e){return e>=1e6?`${+(e/1e6).toFixed(1)}M`:e>=1e3?`${+(e/1e3).toFixed(1)}k`:String(e)}function WW(e){return e>0&&e<.1?`<0.1%`:`${e<10?+e.toFixed(1):Math.round(e)}%`}var GW=3;function KW({model:e,task:t}){B();let n=t.autoFixCi,r=n=>void e.client.request(`task.autoFixCi`,{taskId:t.id,enabled:n}).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsx)(`div`,{className:`flex items-center gap-3 px-2 pt-1 font-mono text-meta`,children:n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:n.stopped?AT.attention:`text-muted`,title:z(`files.autoFix.hint`),children:z(n.stopped?`files.autoFix.stopped`:`files.autoFix.count`,{n:n.attempts,max:GW})}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>r(!1),children:z(`files.autoFix.off`)})]}):(0,V.jsx)(H,{hit:`tight`,title:z(`files.autoFix.hint`),onClick:()=>r(!0),children:z(`files.autoFix.on`)})})}function qW(e){let t=e.pr;return!!t&&t.number!==void 0&&!e.machine&&(t.lifecycle===`open`||t.lifecycle===`ready_to_merge`)}function JW(e){let t={fail:0,pending:0,pass:0,skipped:0};for(let n of e)t[n.state]++;return t}function YW(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h${String(n%60).padStart(2,`0`)}m`}function XW(e){let t=[],n=e.mergeState.toUpperCase();e.draft&&t.push({key:`files.merge.draft`,tone:`warning`}),e.mergeable.toUpperCase()===`CONFLICTING`||n===`DIRTY`?t.push({key:`files.merge.conflicts`,tone:`attention`}):n===`BEHIND`?t.push({key:`files.merge.behind`,tone:`warning`}):n===`UNSTABLE`?t.push({key:`files.merge.unstable`,tone:`warning`}):n===`BLOCKED`?t.push({key:`files.merge.blocked`,tone:`warning`}):n===`CLEAN`&&!e.draft&&t.push({key:`files.merge.clean`,tone:`success`});let r=e.review.toUpperCase();return r===`APPROVED`?t.push({key:`files.merge.approved`,tone:`success`}):r===`CHANGES_REQUESTED`?t.push({key:`files.merge.changes`,tone:`attention`}):r===`REVIEW_REQUIRED`&&t.push({key:`files.merge.reviewRequired`,tone:`warning`}),t}var ZW=`flex flex-col gap-0.5 px-2 pb-2 font-mono text-meta`,QW=`flex items-start gap-2`,$W=`flex min-w-0 flex-1 flex-wrap items-center gap-x-2 text-left text-ink`,eG={pass:{glyph:`✓`,tone:`success`},fail:{glyph:`✗`,tone:`attention`},pending:{glyph:`●`,tone:`warning`},skipped:{glyph:`–`,tone:`muted`}};function tG({model:e,task:t}){B();let n=t.pr,r=t.id,[i,a]=(0,g.useState)(()=>Bs(e,`pr.checks`,{taskId:r})??null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)({}),[u,d]=(0,g.useState)(0),f=`${n?.number}:${n?.checkState}:${n?.mergeable}:${n?.reviewDecision}`;(0,g.useEffect)(()=>{let t=!0,n={taskId:r};return e.client.request(`pr.checks`,u>0?{...n,fresh:!0}:n).then(r=>{t&&(Vs(e,`pr.checks`,n,r),a(r))},e=>t&&a({outcome:`unavailable`,detail:e instanceof Error?e.message:String(e)})),()=>{t=!1}},[e,r,f,u]);let p=t=>{let n=`${t.runId}:${t.name}`;if(c[n]){l(({[n]:e,...t})=>t);return}l(e=>({...e,[n]:{state:`loading`}})),e.client.request(`pr.checkLog`,{taskId:r,runId:t.runId,job:t.name}).then(e=>e.outcome===`ok`?{state:`text`,text:e.tail}:e.outcome===`none`?{state:`note`,text:z(`files.checks.noLog`)}:{state:`note`,text:z(`files.checks.logUnavailable`,{detail:e.detail})}).catch(e=>({state:`note`,text:z(`files.checks.logUnavailable`,{detail:e instanceof Error?e.message:String(e)})})).then(e=>l(t=>n in t?{...t,[n]:e}:t))},m=(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>d(e=>e+1),children:z(`files.checks.refresh`)});if(!i)return(0,V.jsx)(`div`,{className:ZW,children:(0,V.jsx)(`div`,{className:QW,children:(0,V.jsxs)(`span`,{className:`flex-1 text-muted`,children:[z(`files.checks.title`),` `,z(`files.checks.loading`)]})})});if(i.outcome!==`ok`)return(0,V.jsx)(`div`,{className:ZW,children:(0,V.jsxs)(`div`,{className:QW,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 text-muted wrap-anywhere`,children:i.outcome===`none`?z(`files.checks.none`):z(`files.checks.unavailable`,{detail:i.detail})}),m]})});let h=JW(i.checks),_=o??(h.fail>0||h.pending>0),v=XW(i);return(0,V.jsxs)(`div`,{className:ZW,children:[(0,V.jsxs)(`div`,{className:QW,children:[(0,V.jsxs)(H,{variant:`row`,className:$W,"aria-expanded":_,disabled:i.total===0,onClick:()=>s(!_),children:[i.total>0&&(0,V.jsx)(Fa,{right:!_}),(0,V.jsx)(`span`,{children:i.total===0?z(`files.checks.none`):z(`files.checks.summary`,{pass:h.pass+h.skipped,total:i.total})}),h.fail>0&&(0,V.jsx)(`span`,{className:AT.attention,children:z(`files.checks.failed`,{count:h.fail})}),h.pending>0&&(0,V.jsx)(`span`,{className:AT.warning,children:z(`files.checks.running`,{count:h.pending})}),v.map(e=>(0,V.jsx)(`span`,{className:AT[e.tone],children:z(e.key)},e.key))]}),m]}),_&&i.checks.map(e=>{let{glyph:t,tone:n}=eG[e.state],r=`${e.runId}:${e.name}`,i=c[r];return(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 pl-4`,children:[(0,V.jsx)(`span`,{className:`w-[1ch] flex-none text-center ${AT[n]}`,children:t}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),e.durationMs!==null&&(0,V.jsx)(`span`,{className:`flex-none text-subtle`,children:YW(e.durationMs)}),e.state===`fail`&&e.runId&&(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>p(e),children:z(i?`files.checks.hideLog`:`files.checks.log`)})]}),i&&(0,V.jsx)(`pre`,{className:`m-0 ml-4 mb-1 max-h-40 overflow-y-auto rounded-sm border-hairline border-line bg-inset px-2 py-1.5 whitespace-pre-wrap wrap-anywhere text-muted`,children:i.state===`loading`?z(`files.checks.loading`):i.text})]},`${e.name}:${e.url}`)}),_&&i.total>i.checks.length&&(0,V.jsx)(`span`,{className:`pl-4 text-subtle`,children:z(`files.checks.more`,{count:i.total-i.checks.length})})]})}function nG({model:e,task:t}){return qW(t)?(0,V.jsxs)(`div`,{onKeyDown:e=>e.stopPropagation(),children:[(0,V.jsx)(tG,{model:e,task:t}),(0,V.jsx)(KW,{model:e,task:t})]}):null}function rG(e,t){let n={children:new Map,file:!1};for(let t of e){let e=n;for(let n of t.split(`/`)){let t=e.children.get(n);t||(t={children:new Map,file:!1},e.children.set(n,t)),e=t}e.file=!0}let r=[],i=(e,n,a)=>{let o=[...e.children].sort(([e,t],[n,r])=>{let i=t.children.size>0&&!t.file;return i===(r.children.size>0&&!r.file)?e.localeCompare(n):i?-1:1});for(let[e,s]of o){let o=s.children.size>0&&!s.file,c=o?`${n}${e}/`:`${n}${e}`,l=o&&t.has(c);r.push({path:c,name:e,depth:a,dir:o,open:l}),l&&i(s,c,a+1)}};return i(n,``,0),r}var iG={start:`\x1B[200~`,end:`\x1B[201~`};function aG(e,t){return e.engineTarget(t).tabId??e.tabs.get()[t]?.find(e=>e.kind===`engine`)?.id}async function oG(e,t,n){let r=aG(e,t);if(!r)return G(z(`files.stripNoEngine`),`error`),!1;try{return e.selection.get().tabId!==r&&e.select(t,r),await e.client.request(`term.input`,{stream:EC(t,r),data:`${iG.start}${n}${iG.end}`}),G(z(`files.stripFilled`)),!0}catch(e){return G(e instanceof Error?e.message:String(e),`error`),!1}}function sG(e){let t=e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived,n=e.changes;return t&&!!n&&`added`in n&&n.added+n.deleted>0}function cG(e){return[...sG(e)?[`commit`]:[],...lG(e)]}function lG(e){let t=e.pr;if(!t)return e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived&&!e.sessionPrs?.length?[`createPR`]:[];if(t.lifecycle===`merged`)return e.archived||e.kind===`main`?[]:[`archive`];if(t.lifecycle!==`open`&&t.lifecycle!==`ready_to_merge`)return[];let n=[];return((t.mergeable??``).toUpperCase()===`CONFLICTING`||e.prChip===`conflict`)&&n.push(`conflicts`),t.checkState===`failing`&&n.push(`fixCI`),(t.reviewDecision??``).toUpperCase()===`CHANGES_REQUESTED`&&n.push(`comments`),n}async function uG(e,t,n){try{let r=await e.client.request(`task.prompt`,{taskId:t.id,kind:n});r.outcome===`unavailable`?G(z(`files.stripUnavailable`,{detail:r.detail??``}),`error`):r.outcome===`none`||!r.prompt?G(z(`files.stripNothing`),`error`):await oG(e,t.id,r.prompt)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}var dG={commit:`files.stripCommit`,createPR:`files.stripCreate`,conflicts:`files.stripConflicts`,fixCI:`files.stripFixCi`,comments:`files.stripComments`,archive:`files.stripArchive`};function fG({model:e,task:t}){let n=cG(t);return n.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:n.map(n=>(0,V.jsx)(H,{onClick:()=>n===`archive`?void dF(e,t):void uG(e,t,n),children:z(dG[n])},n))})}var pG=2e3;function mG({model:e,task:t}){B();let n=t.id,r=!t.machine,[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),c=i?.running===!0;if((0,g.useEffect)(()=>{if(!r)return;let t=!0,i=()=>e.client.request(`run.status`,{taskId:n}).then(e=>t&&a(e),()=>{});i();let o=c?window.setInterval(()=>void i(),pG):0;return()=>{t=!1,window.clearInterval(o)}},[e,n,r,c]),!r||!i?.script)return null;let l=async t=>{s(!0);try{a(await e.client.request(t,{taskId:n}))}catch(e){G(e instanceof Error?e.message:String(e),`error`)}finally{s(!1)}};return(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:[i.url&&(0,V.jsx)(H,{onClick:()=>i.url&&eA(n,i.url),children:z(`files.run.open`,{port:i.port??``})}),(0,V.jsx)(H,{disabled:o,onClick:()=>void l(c?`run.stop`:`run.start`),children:z(c?`files.run.stop`:`files.run.run`)})]})}function hG({tabs:e,value:t,onChange:n,className:r}){return(0,V.jsx)(`div`,{className:Me(`flex gap-1`,r),role:`tablist`,children:e.map(e=>{let r=e.id===t;return(0,V.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:Me(`relative rounded-sm px-2.5 py-0.75 font-mono text-meta font-semibold`,`touch:after:absolute touch:after:content-[''] touch:after:-inset-x-0.5 touch:after:-top-2 touch:after:-bottom-1.5`,r?`bg-inset text-ink group-focus-within/pane:text-accent`:`text-muted`),onClick:()=>n(e.id),children:e.label},e.id)})})}var gG=[`all`,`changes`],_G={M:`text-warning`,A:`text-success`,"?":`text-success`,D:`text-error`,R:`text-accent`};function vG({model:e,task:t,narrow:n=!1}){let r=$o();B();let[i,a]=(0,g.useState)(`all`),[o,s]=(0,g.useState)(`working`),[c,l]=(0,g.useState)(()=>Bs(e,`files.list`,{taskId:t.id})?.files??null),[u,d]=(0,g.useState)(()=>Bs(e,`diff.files`,{taskId:t.id})??null),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(new Set),[_,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(0),S=(0,g.useRef)(null),C=v(fn),w=JSON.stringify(t.changes??null);(0,g.useEffect)(()=>{let n=!0,r=e=>n&&p(e instanceof Error?e.message:String(e));return Hs(e,`files.list`,{taskId:t.id}).then(e=>{n&&(l(e.files),p(null))},r),Hs(e,`diff.files`,{taskId:t.id}).then(e=>n&&d(e),r),()=>{n=!1}},[e,t.id,w,b]);let T=u?.base??null,E=i===`all`?c!==null:u!==null,D=o===`branch`&&T!=null,O=i===`all`?rG(c??[],m).map(e=>({path:e.path,label:e.name,depth:e.depth,dir:e.dir,open:e.open})):(u?.files??[]).filter(e=>e.scope===(D?`branch`:`working`)).map(e=>({path:e.path,label:e.path,depth:0,dir:!1,open:!1,status:e.status,added:e.added,deleted:e.deleted})),k=Math.min(_,Math.max(0,O.length-1)),A=O[k],j=(e,t)=>h(n=>{let r=new Set(n);return t??!r.has(e)?r.add(e):r.delete(e),r}),ee=e=>$k({taskId:t.id,path:e,scope:i===`changes`&&D?`branch`:`working`}),M=n=>{if(!C?.startsWith(`${t.id}::`)){G(z(`files.mentionNoEngine`),`error`);return}e.client.request(`term.input`,{stream:C,data:`@${n} `}).catch(e=>G(String(e),`error`))},N=n=>t.machine?G(z(`files.remoteNoExternal`,{host:t.machine.label}),`error`):void e.client.request(`file.openExternal`,{taskId:t.id,path:n}).then(()=>G(z(`taskops.openedExternal`))).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsxs)(`div`,{className:`group/pane flex min-h-0 min-w-0 flex-1 flex-col outline-none ${n?`px-1.5 pt-2.5 pb-2`:`pt-0.5 pr-1.5 pb-1.5 pl-0`}`,tabIndex:0,ref:S,onKeyDown:e=>{let t=e.key;if(t===`j`||t===`ArrowDown`)y(Math.min(O.length-1,k+1));else if(t===`k`||t===`ArrowUp`)y(Math.max(0,k-1));else if((t===`l`||t===`ArrowRight`)&&A?.dir)j(A.path,!0);else if((t===`h`||t===`ArrowLeft`)&&A?.dir)j(A.path,!1);else if(t===`[`||t===`]`)a(gG[(gG.indexOf(i)+(t===`]`?1:gG.length-1))%gG.length]??`all`);else if(t===`b`&&i===`changes`&&T!=null)s(o===`working`?`branch`:`working`);else if(t===`r`)x(e=>e+1);else if(t===`D`&&e.shiftKey)ee(`.`);else if(t===`d`&&A)ee(A.path);else if(t===`Enter`&&A)A.dir?j(A.path):ee(A.path);else if(t===`a`&&A)M(A.path);else if(t===`o`&&A&&!A.dir)N(A.path);else return;e.preventDefault()},children:[(0,V.jsx)(fG,{model:e,task:t}),(0,V.jsx)(nG,{model:e,task:t}),(0,V.jsx)(mG,{model:e,task:t}),(0,V.jsx)(hG,{className:`px-1 pb-1.5`,tabs:[{id:`all`,label:z(`files.all`)},{id:`changes`,label:z(`files.changes`)}],value:i,onChange:e=>{a(e),y(0)}}),i===`changes`&&(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-2.5 gap-y-1 px-2 pb-2 font-mono text-meta text-muted`,children:[(0,V.jsx)(`span`,{children:D?z(`files.scopeBranch`,{base:T??``}):z(`files.scopeWorking`)}),T==null?u&&(0,V.jsx)(`span`,{children:z(`files.noBase`)}):(0,V.jsx)(H,{hit:`tight`,onClick:()=>s(o===`working`?`branch`:`working`),children:z(r?`files.toggleScopeTouch`:`files.toggleScope`)}),(0,V.jsx)(kT,{text:z(`files.legend`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>ee(`.`),children:z(r?`files.diffAllTouch`:`files.diffAll`)})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f&&(0,V.jsx)(`p`,{className:`mono text-error`,children:f}),!f&&E&&O.length===0&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(i===`all`?`files.emptyAll`:`files.emptyChanges`)}),O.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:tr({selected:t===k,size:n?`file-narrow`:`file`}),style:{paddingLeft:8+e.depth*14},title:e.path,onClick:()=>{y(t),S.current?.focus(),e.dir?j(e.path):ee(e.path)},children:[e.status?(0,V.jsx)(`span`,{className:`${ar} ${_G[e.status]??``}`,children:e.status}):(0,V.jsx)(`span`,{className:`${ar} grid place-items-center text-subtle`,children:e.dir?(0,V.jsx)(Fa,{right:!e.open}):null}),(0,V.jsx)(`span`,{className:nr,children:e.label}),e.added?(0,V.jsxs)(NL,{tone:`added`,children:[`+`,e.added]}):null,e.deleted?(0,V.jsxs)(NL,{tone:`removed`,children:[`−`,e.deleted]}):null]},e.path))]})]})}function yG({children:e}){return(0,V.jsx)(`svg`,{className:`size-3.5 ${vI}`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:e})}var bG={chat:(0,V.jsx)(`path`,{d:`M3 3.5h10a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8l-3 2.5v-2.5H3a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1zM5 6.5h6M5 8.5h4`}),files:(0,V.jsx)(`path`,{d:`M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z`}),diff:(0,V.jsx)(`path`,{d:`M3.5 2.5h9a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zM8 5v4M6 7h4M6 11h4`}),browser:(0,V.jsx)(`path`,{d:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2zM2 8h12M8 2c2.2 2 2.2 10 0 12M8 2c-2.2 2-2.2 10 0 12`}),quota:(0,V.jsx)(`path`,{d:`M2.5 11.5a5.5 5.5 0 1 1 11 0M8 11.5l2.5-3.5M4.5 13.5h7`})};function xG(e){if(e.kind===`files`)return z(`panel.files`);if(e.kind===`chat`)return z(`panel.chat`);if(e.kind===`quota`)return z(`panel.quota`);if(e.kind===`diff`)return e.path===`.`?z(`panel.diff`):ok(e.path);let t=ak(e);return t?sk(t):z(`panel.browser`)}function SG(e){return e.kind===`diff`?e.path===`.`?z(`preview.whole`):e.path:e.kind===`browser`&&ak(e)||xG(e)}var CG=7.3,wG=51,TG=160;function EG(e,t){let n=0;for(let t of e){let e=0;for(let n of t)e+=(n.codePointAt(0)??0)>11903?2:1;n+=Math.min(TG,wG+e*CG)+2}return n<=t}var DG=null;function OG(e,t,n,r){let i=(t,r)=>({label:r,section:`move`,run:()=>Xk(e,e=>Ok(e,n.id,t))}),a=[];return!t.bottom&&t.top.tabs.length>1?a.push(i(`bottom`,z(`panel.splitDown`))):t.bottom&&a.push(r===`top`?i(`bottom`,z(`panel.moveBottom`)):i(`top`,z(`panel.moveTop`))),a.push({label:z(`panel.close`),section:`close`,run:()=>tA(e,n.id)}),t.top.tabs.length+(t.bottom?.tabs.length??0)>1&&a.push({label:z(`panel.closeOthers`),section:`close`,run:()=>Xk(e,e=>Dk(e,n.id))}),a}function kG(e,t){return[{label:z(`panel.newChat`),run:()=>Xk(e,e=>bk(e,`chat`))},{label:z(`panel.newFiles`),run:()=>Xk(e,e=>gk(e,t))},{label:z(`panel.newDiff`),run:()=>Xk(e,e=>vk(e,`.`,`working`))},{label:z(`panel.newBrowser`),run:()=>Xk(e,e=>_k(e,t))},{label:z(`panel.newQuota`),run:()=>Xk(e,e=>bk(e,`quota`))}]}function AG({taskId:e,panel:t,group:n,tabs:r,active:i,narrow:a,children:o}){B();let[s,c]=(0,g.useState)(null),l=()=>DG?.taskId===e,u=t=>{let r=DG;DG=null,c(null),r?.taskId===e&&Xk(e,e=>Ok(e,r.id,n,t))},d=t=>{let r=t.currentTarget.getBoundingClientRect();on.set({x:r.left,y:r.bottom+2,items:kG(e,n),target:t.currentTarget})},f=(e,t)=>{if(!l())return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();c({id:t,after:e.clientX>n.left+n.width/2})},p=(0,g.useRef)(null),[m,h]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(([e])=>h(e?.contentRect.width??0));return t.observe(e),()=>t.disconnect()},[]);let _=m>0&&!EG(r.map(xG),m);return(0,g.useEffect)(()=>{p.current?.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,r.length,_]),(0,V.jsxs)(`div`,{className:wI(a),style:{gridRow:n===`top`?1:4},onDragOver:e=>{l()&&(e.preventDefault(),c(null))},onDrop:e=>{e.preventDefault(),u()},children:[(0,V.jsx)(`div`,{className:TI,role:`tablist`,"aria-label":z(`panel.tabs`),ref:p,children:r.map((r,o)=>(0,V.jsxs)(`div`,{role:`presentation`,className:EI({active:r.id===i,compact:_}),"data-drop":s?.id===r.id?s.after?`after`:`before`:void 0,draggable:!a,onDragStart:()=>{DG={taskId:e,id:r.id}},onDragEnd:()=>{DG=null,c(null)},onDragOver:e=>f(e,r.id),onDrop:e=>{e.preventDefault(),e.stopPropagation(),u(o+(s?.id===r.id&&s.after?1:0))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),tA(e,r.id))},onContextMenu:i=>{a||cW(i,OG(e,t,r,n))},children:[(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r.id===i,className:DI(_&&r.id!==i),title:SG(r),onClick:()=>Xk(e,e=>fk(e,r.id)),children:[(0,V.jsx)(yG,{children:bG[r.kind]}),(0,V.jsx)(`span`,{className:OI,children:xG(r)})]}),(0,V.jsx)(`button`,{type:`button`,className:`${kI} ${_&&r.id!==i?`hidden`:``}`,"aria-label":z(`panel.close`),tabIndex:-1,onClick:()=>tA(e,r.id),children:`×`})]},r.id))}),!a&&(0,V.jsx)(`button`,{type:`button`,className:yI({tool:!0}),title:z(`panel.new`),"aria-label":z(`panel.new`),onClick:d,children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M8 3.5v9M3.5 8h9`})})}),o]})}var jG={md:`md`,markdown:`md`,html:`html`,htm:`html`,svg:`svg`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,pdf:`pdf`};function MG(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<0?null:jG[t.slice(n+1).toLowerCase()]??null}function NG(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var PG=e=>new TextDecoder().decode(NG(e));function FG(e,t){if(e===`svg`)return`image/svg+xml`;if(e===`pdf`)return`application/pdf`;let n=t.slice(t.lastIndexOf(`.`)+1).toLowerCase();return n===`jpg`||n===`jpeg`?`image/jpeg`:n===`gif`?`image/gif`:n===`webp`?`image/webp`:`image/png`}var IG=`default-src 'none'; img-src data:; style-src 'unsafe-inline'`;function LG(e){let t=`<meta http-equiv="Content-Security-Policy" content="${IG}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}var RG=/^\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/,zG=/^https?:\/\/[^\s<>)\]]+/,BG=/[\p{L}\p{N}]/u;function VG(e){let t=[],n=``,r=()=>{n&&t.push({t:`text`,v:n}),n=``},i=0;for(;i<e.length;){let a=e.slice(i),o=e[i]??``;if(o==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({t:`code`,v:e.slice(i+1,n)}),i=n+1;continue}}else if(a.startsWith(`**`)){let n=e.indexOf(`**`,i+2);if(n>i+2){r(),t.push({t:`bold`,c:VG(e.slice(i+2,n))}),i=n+2;continue}}else if(o===`*`||o===`_`&&!BG.test(e[i-1]??``)){let n=e.indexOf(o,i+1);if(n>i+1&&!/\s/.test(e[i+1]??` `)&&(o===`*`||!BG.test(e[n+1]??``))){r(),t.push({t:`em`,c:VG(e.slice(i+1,n))}),i=n+1;continue}}else if(o===`[`){let e=RG.exec(a);if(e){r(),t.push({t:`link`,href:e[2],c:VG(e[1])}),i+=e[0].length;continue}}else if(o===`h`&&!BG.test(e[i-1]??``)){let e=zG.exec(a);if(e){let n=e[0].replace(/[.,;:!?]+$/,``);r(),t.push({t:`link`,href:n,c:[{t:`text`,v:n}]}),i+=n.length;continue}}n+=o,i++}return r(),t}var HG=/^\s*(```+|~~~+)\s*([\w+#.-]*)\s*$/,UG=/^(#{1,6})\s+(.*?)\s*#*\s*$/,WG=/^(\s*)([-*+])\s+(.*)$/,GG=/^(\s*)\d+[.)]\s+(.*)$/,KG=/^\s*([-*_])(\s*\1){2,}\s*$/,qG=/^\s*\|.*\|\s*$/,JG=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/,YG=e=>e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());function XG(e){let t=e.replace(/\r\n?/g,`
128
+ `)}}var ZU=`min-h-0 w-full overflow-y-auto`,QU=`mx-auto mt-[min(16vh,8rem)] flex w-full max-w-130 flex-col gap-4 px-5 pb-7`,$U=`relative grid w-full select-none overflow-hidden font-mono text-(length:--fs-body) text-subtle [contain:layout_paint]`,eW=`col-start-1 row-start-1 m-0 whitespace-pre font-[inherit] leading-[inherit]`,tW=`invisible absolute top-0 left-0 whitespace-pre`,nW=1.3,rW=`0000000000`,iW=1e3/12;function aW(){let e=(0,g.useRef)(null),t=(0,g.useRef)(null),n=(0,g.useRef)(null),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let i=e.current,a=t.current,o=n.current,s=r.current;if(!i||!a||!o||!s)return;let c=window.matchMedia(`(prefers-reduced-motion: reduce)`),l=24,u=90,d=0,f=0,p=0,m=-1,h=!0,g=()=>{let e=XU(u,l);o.textContent=e.base,s.textContent=e.accent},_=()=>{let e=a.getBoundingClientRect().width/10;e>0&&(l=Math.min(64,Math.max(24,Math.floor(i.clientWidth/e)))),g()},v=e=>{d=requestAnimationFrame(v);let t=p+Math.floor((e-f)/iW);t!==m&&(m=t,u=t,g())},y=()=>{cancelAnimationFrame(d),d=0},b=()=>{y(),c.matches?(u=90,g()):h&&document.visibilityState===`visible`&&(f=performance.now(),p=u,m=-1,d=requestAnimationFrame(v))},x=new ResizeObserver(_);x.observe(i),_(),b();let S=new IntersectionObserver(e=>{h=e[e.length-1]?.isIntersecting??!0,b()});return S.observe(i),c.addEventListener(`change`,b),document.addEventListener(`visibilitychange`,b),()=>{y(),x.disconnect(),S.disconnect(),c.removeEventListener(`change`,b),document.removeEventListener(`visibilitychange`,b)}},[]),(0,V.jsxs)(`div`,{ref:e,"aria-hidden":`true`,"data-field":`first-run-art`,className:$U,style:{height:`${11*nW}em`,lineHeight:nW},children:[(0,V.jsx)(`span`,{ref:t,className:tW,children:rW}),(0,V.jsx)(`pre`,{ref:n,className:eW}),(0,V.jsx)(`pre`,{ref:r,className:`${eW} text-accent`})]})}function oW(e){let t=q(`doctor`,`fix.humanOnlyWhy`),n=[];if(e.git||n.push({id:`git`,label:q(`doctor`,`fix.git`),action:q(`doctor`,`fix.gitAction`),why:t}),e.engines.length===0){let r=e.signedOut.length>0;n.push({id:`engine`,label:q(`doctor`,r?`fix.noEngineLogin`:`fix.noEngine`),action:q(`doctor`,r?`fix.noEngineLoginAction`:`fix.noEngineAction`,{list:e.signedOut.map(e=>e.id).join(`, `)}),why:t})}return n}function sW({model:e}){B(),v(Yr);let[t,n]=(0,g.useState)(()=>Bs(e,`welcome.env`)??null);(0,g.useEffect)(()=>{let t=!0;return Hs(e,`welcome.env`).then(e=>t&&n(e)).catch(()=>{}),()=>{t=!1}},[e]);let r=t===null?null:t.engines.length>0?{key:`enginesFound`,warn:!1,list:t.engines.map(e=>e.name).join(`, `)}:t.signedOut.length>0?{key:`enginesSignedOut`,warn:!0,list:t.signedOut.map(e=>e.name).join(`, `)}:{key:`enginesMissing`,warn:!0,list:``},i=t!==null&&(t.engines.length===0||!t.git)?oW(t):[];return(0,V.jsx)(`div`,{className:ZU,"data-field":`welcome`,children:(0,V.jsxs)(`div`,{className:QU,children:[(0,V.jsx)(aW,{}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,V.jsx)(`h1`,{className:`m-0 font-sans text-title font-semibold text-ink`,children:z(`firstRun.title`)}),(0,V.jsx)(`p`,{className:`m-0 font-sans text-body text-muted`,children:z(`firstRun.body`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,className:Pe(),"data-field":`start-first-task`,onClick:()=>iO(t?.start?.repo),children:z(`firstRun.start`)}),(0,V.jsx)(`span`,{className:`keys-only mono text-meta text-subtle`,children:ii(`task.new.global`)})]}),t!==null&&r!==null&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5 font-sans text-meta`,children:[(0,V.jsx)(`p`,{className:`m-0 ${r.warn?`text-warning`:`text-subtle`}`,children:q(`workspace`,`welcome.${r.key}`,{list:r.list})}),!t.git&&(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:q(`workspace`,`welcome.gitMissing`)}),i.map(e=>(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsx)(`p`,{className:`m-0 text-warning`,children:e.label}),(0,V.jsx)(`p`,{className:`mono m-0 text-accent`,children:e.action}),(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:e.why})]},e.id)),i.length>0&&(0,V.jsx)(`p`,{className:`m-0 text-muted`,children:q(`common`,`failureHint`,{command:`rove doctor`})})]})]})})}function cW(e,t){e.preventDefault(),on.set({x:e.clientX,y:e.clientY,items:t,target:e.currentTarget,fromKeyboard:e.button!==2})}function lW({model:e,narrow:t}){let n=B(),r=v(e.tasks),i=v(e.remote),a=EE(e),o=v(e.tabs),s=v(e.tabsSettled),c=v(e.selection),l=r?.tasks??[],u=r?.attention.filter(e=>e.unread).length??0,d=c.taskId,f=new Map([...l,...i].map(e=>[e.id,e])),p=OU(),m=v(WT),h=v(LT)===`state`,_=v(GT),y=e=>(h?mO:Cw)({tasks:l,remote:i,machines:a,sort:p.sort,query:e,fold:{...p.hand,selectedId:d??void 0}}),b=y(p.search.active?p.search.query:``),{groups:x}=b,S=p.search.active?b.rows:NH(Tw(PU(hO(GH(b.rows,o,c.taskId,s,_)),o),p.collapsed),r?.archived??[],p.archivedOpen,{...p.hand,selectedId:d??void 0}),C=e=>e.filter(e=>e.kind!==`project`&&e.kind!==`state`&&e.kind!==`round`),w=(n===`zh`?Ar:kr).machine,T=new Set(a.filter(e=>e.state!==`online`).map(e=>e.alias)),E=x.find(e=>e.tasks.some(e=>e.kind===`main`))?.repo,D=e=>({mainTaskId:x.find(t=>t.repo===e)?.tasks.find(e=>e.kind===`main`)?.id??null,label:KC(e),first:e===E}),O=UH(e,l,!p.search.active&&!h,p.sort==="default",D),k=O.places(S),A=()=>W.set((0,V.jsx)(JP,{model:e})),j=MU(e,S,p,{selectedId:d,onNewTask:iO,onSettings:A}),ee=_!==null&&S.some(e=>e.id===_),M=j.setCursor;(0,g.useEffect)(()=>{ee&&_!==null&&M(_)},[ee,_,M]);let N=C(y(``).rows).length,P=(0,g.useRef)(null),F=v(pI)&&!t,I=v(mI)&&F,te=t?l.find(e=>e.id===c.taskId&&!e.deleting)??null:null;return(0,V.jsxs)(`nav`,{className:`${aE} ${F?`is-folded`:``}`,ref:P,inert:F&&!I,"aria-hidden":F&&!I,onMouseEnter:F?()=>gI(!0):void 0,onMouseLeave:F?()=>gI(!1):void 0,tabIndex:0,onKeyDown:e=>{BF(`sidebar`),j.onKeyDown(e)},children:[(0,V.jsxs)(`header`,{className:oE,children:[(0,V.jsxs)(`span`,{className:`${Ht} mr-auto`,children:[(0,V.jsx)(`span`,{className:Ut,children:`[`}),` rove `,(0,V.jsx)(`span`,{className:Ut,children:`]`})]}),(0,V.jsxs)(`span`,{className:`relative`,children:[(0,V.jsx)(`button`,{type:`button`,className:`m-0 text-meta font-medium normal-nums inbox-chip relative ${$n} ${Ge} ${u>0?`text-accent`:`text-muted`}`,onClick:()=>W.set((0,V.jsx)(PT,{model:e})),children:z(`rail.inbox`,{count:u})}),(0,V.jsx)(NF,{model:e,bindingId:`inbox.show`,head:!0})]}),(0,V.jsx)(HM,{})]}),m&&(0,V.jsxs)(`div`,{className:`flex gap-1 px-3.5 pb-2 text-meta mono`,children:[(0,V.jsx)(`span`,{className:`text-accent`,children:q(`tasks`,`moveChip`).trim()}),(0,V.jsx)(`span`,{className:`keys-only ml-1.5 text-muted`,children:(0,V.jsx)(kT,{text:z(`taskops.moveHint`)})})]}),p.search.active&&(0,V.jsx)(IU,{query:p.search.query,count:`${C(S).length}/${N}`,onChange:e=>p.setSearch(t=>({...t,query:e}))}),(0,V.jsx)(oL,{model:e}),(0,V.jsx)(wH,{model:e}),(0,V.jsxs)(`div`,{"data-rail-body":!0,className:pE(O.dragging!==null),...O.body,children:[r&&l.length===0&&i.length===0&&t&&(0,V.jsx)(sW,{model:e}),r&&l.length===0&&i.length===0&&!t&&(0,V.jsx)(`p`,{className:`m-0 px-2 py-3 font-mono text-meta text-subtle`,children:z(`rail.empty`)}),te&&(0,V.jsx)(GI,{title:te.title}),S.map((t,n)=>t.kind===`round`?(0,V.jsx)(FU,{row:t,guides:t.depth>1?VH(S,n):void 0,repo:h&&t.depth===1?fO(t.tasks[0]):void 0,cursor:t.id===j.cursor,place:k(t),onClick:()=>j.setCursor(t.id)},t.id):t.kind===`pane`?(0,V.jsx)(oU,{model:e,row:t,guides:VH(S,n),cursor:t.id===j.cursor,place:k(t),onClick:()=>{j.setCursor(t.id),aU(e,t),ga()},onMenu:n=>{j.setCursor(t.id),cW(n,tU(e,t.task.id,t.tab,t.leaf))}},t.id):(0,V.jsx)(uW,{row:t,guides:t.kind===`task`&&t.depth>1?VH(S,n):void 0,cloud:CE(t,a,w),repo:h&&t.kind===`task`&&t.depth===1?fO(t.task):void 0,tabs:t.kind===`task`?o[t.task.id]:void 0,selected:t.id===d,cursor:t.id===j.cursor,stale:t.machine!==void 0&&T.has(t.machine),collapsed:(t.kind===`project`||t.kind===`state`)&&p.collapsed.has(t.id),drag:O.props(t),dragging:O.dragging===t.id,place:k(t),onNewTask:t.kind===`project`?t.noProject?aO:()=>iO(t.repo,t.machine):void 0,moving:m&&t.machine===void 0&&(t.kind===`project`?!t.noProject&&D(t.repo).mainTaskId===j.cursor:t.id===j.cursor&&(t.kind!==`task`||t.task.kind!==`main`)),prTasks:t.kind===`task`?[t.task,...(t.fold?.descendantIds??[]).flatMap(e=>f.get(e)??[])]:void 0,rollup:t.kind===`task`&&t.fold?.collapsed?rI([t.task,...t.fold.descendantIds.flatMap(e=>f.get(e)??[])]):void 0,onToggleFold:()=>{t.kind===`task`&&p.toggleTaskFold(t.id,t.fold?.collapsed===!0),t.kind===`archived`&&p.toggleArchived()},onClick:()=>{j.setCursor(t.id),t.kind===`archived`&&p.toggleArchived(),(t.kind===`project`||t.kind===`state`)&&p.toggleProject(t.id),t.kind===`task`&&jU(e,t.task.id)},onMenu:n=>{if(t.kind!==`project`||t.machine===void 0){if(t.kind===`project`&&t.noProject){cW(n,_U(e));return}if(t.kind===`project`){let r=D(t.repo);r.mainTaskId&&S.some(e=>e.id===r.mainTaskId)&&j.setCursor(r.mainTaskId),cW(n,gU(e,t.repo,r));return}t.kind===`task`&&(j.setCursor(t.id),cW(n,pW(fW(bU(e,t.task,null),t.fold,()=>p.toggleTaskFold(t.id,t.fold?.collapsed===!0)),iU(e,t.task.id))))}}},t.id))]}),(0,V.jsx)(WH,{model:e,narrow:t,onSettings:A}),(0,V.jsx)(KI,{pane:`sidebar`}),!t&&!F&&(0,V.jsx)(BI,{rail:P})]})}function uW(e){let{row:t}=e,n=BU(t.kind===`task`?t.task.label:``,e.cursor&&t.kind===`task`),r=e.cursor?mE:``;if(t.kind===`project`||t.kind===`state`)return(0,V.jsxs)(`h2`,{className:hE({moving:e.moving,dragging:e.dragging}),onContextMenu:e.onMenu,...e.place,...e.drag,children:[(0,V.jsxs)(`button`,{type:`button`,className:_E,title:t.kind===`project`&&!t.noProject?t.repo:void 0,"aria-expanded":!e.collapsed,onClick:e.onClick,children:[(0,V.jsx)(`span`,{className:`truncate`,children:t.label}),t.kind===`state`&&(0,V.jsx)(`span`,{className:`font-normal text-subtle`,children:t.count}),(0,V.jsx)(Fa,{right:e.collapsed,className:vE(!!e.collapsed)})]}),e.onNewTask&&t.kind===`project`&&(0,V.jsx)(`button`,{type:`button`,className:yE,title:z(`rail.newTask`),onClick:e.onNewTask,children:`+`})]});if(t.kind===`archived`)return(0,V.jsx)(`button`,{type:`button`,className:`${tr({moving:e.moving||e.dragging})} ${r}`,"aria-expanded":t.expanded,onClick:e.onClick,...e.place,children:(0,V.jsx)(`span`,{className:`${rr} ${e.stale?`text-subtle`:`text-muted`}`,children:q(`tasks`,`archivedRow`,{count:t.count})})});let i=t.task,a=i.rowStatus?.kind===`running`,o=YP(i);return(0,V.jsxs)(`button`,{type:`button`,ref:n.ref,className:`${tr({selected:e.selected,moving:e.moving||e.dragging})} ${r}`,onClick:e.onClick,onContextMenu:e.onMenu,onPointerEnter:n.onPointerEnter,onPointerLeave:n.onPointerLeave,...e.place,...e.drag,children:[n.tip,e.guides&&(0,V.jsx)(`span`,{className:`-my-0.75 -mr-0.5 ml-0 flex flex-none self-stretch`,"aria-hidden":`true`,children:e.guides.map((e,t)=>(0,V.jsx)(`span`,{className:$T(e)},t))}),(0,V.jsx)(`span`,{className:`${rr} ${e.stale?`text-subtle`:``} ${a?ir:``}`,children:t.attempt??i.label}),(0,V.jsxs)(`span`,{className:`${or} ml-auto items-center`,children:[e.repo&&(0,V.jsx)(`span`,{className:`max-w-24 truncate text-subtle`,children:e.repo}),t.level!==void 0&&(0,V.jsx)(`span`,{className:`text-subtle`,children:t.level}),(i.extraRepoCount??0)>0&&(0,V.jsxs)(`span`,{className:`text-subtle`,title:z(`rail.extraRepos`,{count:i.extraRepoCount??0}),children:[`+`,i.extraRepoCount]}),o&&(0,V.jsxs)(`span`,{className:`text-subtle tabular-nums`,title:z(`rail.todos`,o),children:[o.done,`/`,o.total]}),t.fold?.collapsed&&(0,V.jsx)(dW,{count:t.fold.count,onUnfold:e.onToggleFold}),i.kept&&(0,V.jsx)(`span`,{className:`text-accent`,title:z(`compare.kept`),children:`✓`}),i.pinned&&(0,V.jsx)(`span`,{className:`text-subtle`,children:`▴`}),i.startsAt&&(0,V.jsx)(VU,{at:i.startsAt}),(0,V.jsx)(jH,{tasks:e.prTasks??[i],onOpen:n.hide}),(0,V.jsx)(uR,{status:t.fold?.collapsed?e.rollup:i.rowStatus}),e.cloud&&(0,V.jsx)(wE,{label:e.cloud})]})]})}function dW(e){let t=q(`tasks`,`menu.expandChildren`);return(0,V.jsxs)(`span`,{role:`button`,tabIndex:-1,"aria-label":t,"aria-expanded":!1,className:`chip text-muted ${eE}`,title:t,onClick:t=>{t.stopPropagation(),e.onUnfold()},children:[e.count,(0,V.jsx)(Fa,{right:!0})]})}function fW(e,t,n){if(!t)return e;let r={label:q(`tasks`,t.collapsed?`menu.expandChildren`:`menu.collapseChildren`),section:`open`,run:n},i=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,i+1),r,...e.slice(i+1)]}function pW(e,t){let n=e.map(e=>e.section).lastIndexOf(`open`);return[...e.slice(0,n+1),...t,...e.slice(n+1)]}function mW(e){return e===`localhost`||e.endsWith(`.localhost`)||e===`[::1]`||/^127(\.\d{1,3}){3}$/.test(e)}var hW=/^(localhost|127(\.\d{1,3}){3}|\[::1\])(:\d+)?([/?#]|$)/i,gW=/^[a-z][a-z0-9+.-]*:(?!\d+([/?#]|$))/i;function _W(e){let t=e.trim();if(!t||/\s/.test(t)||gW.test(t)&&!/^https?:\/\//i.test(t))return null;let n=/^https?:\/\//i.test(t)?t:hW.test(t)?`http://${t}`:`https://${t.replace(/^\/\//,``)}`;try{let e=new URL(n);return e.hostname?e.href:null}catch{return null}}function vW(e,t,n=mW(t.hostname)){let r=new URL(e);return r.origin===t.origin?`self`:mW(r.hostname)?n?`yes`:`remote`:r.protocol===`https:`?`yes`:`unreachable`}function yW(e,t,n){let r=new URL(e).host;return t===`self`?{key:`self`,host:r}:t===`remote`?{key:`remote`,host:r}:t===`unreachable`?{key:`noFrame`,host:r}:n&&!n.reachable?{key:`unreachable`,host:r}:n&&!n.frameable?{key:`refuses`,host:r}:null}var bW=6e4,xW=new Map;function SW(e){let t=xW.get(e);return t&&Date.now()-t.at<bW?t:null}function CW(e,t,n){let[,r]=(0,g.useState)(0);(0,g.useEffect)(()=>{if(!n||SW(t))return;let i=!0;return e.request(`browser.probe`,{url:t,origin:window.location.origin}).then(e=>xW.set(t,{probe:e,at:Date.now()}),()=>xW.set(t,{probe:null,at:Date.now()})).then(()=>i&&r(e=>e+1)),()=>{i=!1}},[e,t,n]);let i=n?SW(t):null;return{pending:n&&!i,probe:i?.probe??null}}function wW({d:e}){return(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:e})})}var TW=`M6.5 3.5h-3v9h9v-3M9.5 3.5h3v3M12.5 3.5l-5 5`;function EW({model:e,tab:t,onNavigate:n,onStep:r}){B();let i=ak(t),[a,o]=(0,g.useState)(i),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(0),d=v(e.client.conn).hello?.peer?.local,f=i?vW(i,window.location,d):null;(0,g.useEffect)(()=>{o(i),c(!1)},[i]);let p=e=>{let t=_W(e);c(t===null&&e.trim()!==``),t!==null&&(o(t),t===i?u(l+1):n(t))},m=i?new URL(i).hostname:``,h=f===`yes`&&i.startsWith(`https:`)&&!mW(m),{pending:_,probe:y}=CW(e.client,i,h),b=i&&f?yW(i,f,y):null,x=f===`yes`&&!b&&!_,S=b?z(`browser.${b.key}`,{host:b.host}):f===null?z(s?`browser.invalid`:`browser.empty`):null;return(0,V.jsxs)(`div`,{className:PI,children:[(0,V.jsxs)(`form`,{className:FI,onSubmit:e=>{e.preventDefault(),p(a)},children:[(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:t.at<=0,title:z(`browser.back`),"aria-label":z(`browser.back`),onClick:()=>r(t.at-1),children:(0,V.jsx)(wW,{d:`M10 3.5 5.5 8l4.5 4.5`})}),(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:t.at>=t.urls.length-1,title:z(`browser.forward`),"aria-label":z(`browser.forward`),onClick:()=>r(t.at+1),children:(0,V.jsx)(wW,{d:`M6 3.5 10.5 8 6 12.5`})}),(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:!x,title:z(`browser.reload`),"aria-label":z(`browser.reload`),onClick:()=>u(l+1),children:(0,V.jsx)(wW,{d:`M12.5 8a4.5 4.5 0 1 1-1.4-3.3M12.5 2.5v2.7H9.8`})}),(0,V.jsx)(`input`,{className:`browser-url mono ${II}`,value:a,placeholder:z(`browser.placeholder`),"aria-label":z(`browser.address`),"aria-invalid":s,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,inputMode:`url`,onChange:e=>o(e.target.value)}),i?(0,V.jsx)(`a`,{className:yI({small:!0}),href:i,target:`_blank`,rel:`noopener noreferrer`,title:z(`browser.openTab`),"aria-label":z(`browser.openTab`),children:(0,V.jsx)(wW,{d:TW})}):(0,V.jsx)(`button`,{type:`button`,className:yI({small:!0}),disabled:!0,"aria-label":z(`browser.openTab`),children:(0,V.jsx)(wW,{d:TW})})]}),x?(0,V.jsx)(`iframe`,{className:LI,src:i,title:i,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,referrerPolicy:`no-referrer`},`${i}#${l}`):S?(0,V.jsx)(`p`,{className:NI,children:S}):null]})}var DW=`scrollbar-none flex min-h-0 flex-1 flex-col overflow-y-auto p-2.5`,OW=`m-0 p-3 font-mono text-meta text-muted`,kW=`flex flex-col gap-1.5 rounded-sm border-hairline border-line px-3 py-2.5`,AW=`m-0 font-sans text-meta font-medium text-ink`,jW=`flex items-baseline justify-between gap-3 font-mono text-meta normal-nums`,MW=`flex h-1 w-full overflow-hidden rounded-full bg-inset`,NW=`h-full flex-none`,PW=`m-0 mt-1 flex list-none flex-col gap-1 p-0`,FW=`flex min-w-0 items-center gap-2 font-mono text-meta normal-nums`,IW=`size-2 flex-none rounded-xs bg-line`,LW=`min-w-0 flex-1 truncate text-muted`,RW=`flex-none text-right text-ink`,zW=`w-[6ch] flex-none text-right text-muted`,BW=1e4,VW=[`var(--info)`,`var(--accent)`,`var(--success)`,`var(--warning)`];function HW({model:e,task:t,active:n}){B();let r=v(e.client.conn),i=v(e.selection),a=v(e.tabs)[t.id]??[],o=i.taskId===t.id?a.find(e=>e.id===i.tabId):void 0,s=(o?.kind===`engine`?o:a.find(e=>e.kind===`engine`))?.id??null,[c,l]=(0,g.useState)({kind:`loading`});if((0,g.useEffect)(()=>{if(!n||r.state!==`open`)return;if(!s){l({kind:`ready`,meter:null});return}let i=!0,a=()=>e.client.request(`context.usage`,{taskId:t.id,tabId:s}).then(e=>i&&l({kind:`ready`,meter:e.meter})).catch(e=>i&&l(t=>t.kind===`ready`?t:{kind:`failed`,error:CL(e)}));a();let o=window.setInterval(a,BW);return()=>{i=!1,window.clearInterval(o)}},[e,n,r.state,t.id,s]),c.kind===`loading`)return(0,V.jsx)(`p`,{className:OW,children:z(`context.loading`)});if(c.kind===`failed`)return(0,V.jsx)(`p`,{className:OW,children:z(`context.failed`,{error:c.error})});if(!c.meter)return(0,V.jsx)(`p`,{className:OW,children:z(`context.none`)});let u=c.meter,d=u.rows.filter(e=>e.share!==void 0),f=e=>e.share===void 0?void 0:VW[d.indexOf(e)%VW.length];return(0,V.jsx)(`div`,{className:DW,children:(0,V.jsxs)(`section`,{className:kW,children:[(0,V.jsx)(`h3`,{className:AW,children:z(`context.title`)}),(0,V.jsxs)(`div`,{className:jW,children:[(0,V.jsx)(`span`,{className:`text-ink`,children:u.percent===null?z(`context.usedTokens`,{tokens:UW(u.used)}):z(`context.used`,{percent:WW(u.percent)})}),u.window!==null&&(0,V.jsxs)(`span`,{className:`text-muted`,children:[UW(u.used),` / `,UW(u.window)]})]}),(0,V.jsx)(`div`,{className:MW,role:`meter`,"aria-valuenow":Math.round(u.percent??100),"aria-valuemin":0,"aria-valuemax":100,children:d.map(e=>(0,V.jsx)(`span`,{className:NW,style:{width:`${e.share}%`,background:f(e)}},e.key))}),(0,V.jsx)(`ul`,{className:PW,children:u.rows.map(e=>{let t=z(`context.part.${e.key}`),n=f(e);return(0,V.jsxs)(`li`,{className:FW,children:[(0,V.jsx)(`span`,{className:IW,style:n?{background:n}:void 0}),(0,V.jsx)(`span`,{className:LW,title:t,children:t}),(0,V.jsx)(`span`,{className:RW,children:UW(e.tokens)}),(0,V.jsx)(`span`,{className:zW,children:WW(e.tokens/(u.window??u.used)*100)})]},e.key)})}),u.approximate&&(0,V.jsx)(`p`,{className:`m-0 font-mono text-meta text-subtle`,children:z(`context.approximate`)})]})})}function UW(e){return e>=1e6?`${+(e/1e6).toFixed(1)}M`:e>=1e3?`${+(e/1e3).toFixed(1)}k`:String(e)}function WW(e){return e>0&&e<.1?`<0.1%`:`${e<10?+e.toFixed(1):Math.round(e)}%`}var GW=3;function KW({model:e,task:t}){B();let n=t.autoFixCi,r=n=>void e.client.request(`task.autoFixCi`,{taskId:t.id,enabled:n}).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsx)(`div`,{className:`flex items-center gap-3 px-2 pt-1 font-mono text-meta`,children:n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:n.stopped?AT.attention:`text-muted`,title:z(`files.autoFix.hint`),children:z(n.stopped?`files.autoFix.stopped`:`files.autoFix.count`,{n:n.attempts,max:GW})}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>r(!1),children:z(`files.autoFix.off`)})]}):(0,V.jsx)(H,{hit:`tight`,title:z(`files.autoFix.hint`),onClick:()=>r(!0),children:z(`files.autoFix.on`)})})}function qW(e){let t=e.pr;return!!t&&t.number!==void 0&&!e.machine&&(t.lifecycle===`open`||t.lifecycle===`ready_to_merge`)}function JW(e){let t={fail:0,pending:0,pass:0,skipped:0};for(let n of e)t[n.state]++;return t}function YW(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h${String(n%60).padStart(2,`0`)}m`}function XW(e){let t=[],n=e.mergeState.toUpperCase();e.draft&&t.push({key:`files.merge.draft`,tone:`warning`}),e.mergeable.toUpperCase()===`CONFLICTING`||n===`DIRTY`?t.push({key:`files.merge.conflicts`,tone:`attention`}):n===`BEHIND`?t.push({key:`files.merge.behind`,tone:`warning`}):n===`UNSTABLE`?t.push({key:`files.merge.unstable`,tone:`warning`}):n===`BLOCKED`?t.push({key:`files.merge.blocked`,tone:`warning`}):n===`CLEAN`&&!e.draft&&t.push({key:`files.merge.clean`,tone:`success`});let r=e.review.toUpperCase();return r===`APPROVED`?t.push({key:`files.merge.approved`,tone:`success`}):r===`CHANGES_REQUESTED`?t.push({key:`files.merge.changes`,tone:`attention`}):r===`REVIEW_REQUIRED`&&t.push({key:`files.merge.reviewRequired`,tone:`warning`}),t}var ZW=`flex flex-col gap-0.5 px-2 pb-2 font-mono text-meta`,QW=`flex items-start gap-2`,$W=`flex min-w-0 flex-1 flex-wrap items-center gap-x-2 text-left text-ink`,eG={pass:{glyph:`✓`,tone:`success`},fail:{glyph:`✗`,tone:`attention`},pending:{glyph:`●`,tone:`warning`},skipped:{glyph:`–`,tone:`muted`}};function tG({model:e,task:t}){B();let n=t.pr,r=t.id,[i,a]=(0,g.useState)(()=>Bs(e,`pr.checks`,{taskId:r})??null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)({}),[u,d]=(0,g.useState)(0),f=`${n?.number}:${n?.checkState}:${n?.mergeable}:${n?.reviewDecision}`;(0,g.useEffect)(()=>{let t=!0,n={taskId:r};return e.client.request(`pr.checks`,u>0?{...n,fresh:!0}:n).then(r=>{t&&(Vs(e,`pr.checks`,n,r),a(r))},e=>t&&a({outcome:`unavailable`,detail:e instanceof Error?e.message:String(e)})),()=>{t=!1}},[e,r,f,u]);let p=t=>{let n=`${t.runId}:${t.name}`;if(c[n]){l(({[n]:e,...t})=>t);return}l(e=>({...e,[n]:{state:`loading`}})),e.client.request(`pr.checkLog`,{taskId:r,runId:t.runId,job:t.name}).then(e=>e.outcome===`ok`?{state:`text`,text:e.tail}:e.outcome===`none`?{state:`note`,text:z(`files.checks.noLog`)}:{state:`note`,text:z(`files.checks.logUnavailable`,{detail:e.detail})}).catch(e=>({state:`note`,text:z(`files.checks.logUnavailable`,{detail:e instanceof Error?e.message:String(e)})})).then(e=>l(t=>n in t?{...t,[n]:e}:t))},m=(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>d(e=>e+1),children:z(`files.checks.refresh`)});if(!i)return(0,V.jsx)(`div`,{className:ZW,children:(0,V.jsx)(`div`,{className:QW,children:(0,V.jsxs)(`span`,{className:`flex-1 text-muted`,children:[z(`files.checks.title`),` `,z(`files.checks.loading`)]})})});if(i.outcome!==`ok`)return(0,V.jsx)(`div`,{className:ZW,children:(0,V.jsxs)(`div`,{className:QW,children:[(0,V.jsx)(`span`,{className:`min-w-0 flex-1 text-muted wrap-anywhere`,children:i.outcome===`none`?z(`files.checks.none`):z(`files.checks.unavailable`,{detail:i.detail})}),m]})});let h=JW(i.checks),_=o??(h.fail>0||h.pending>0),v=XW(i);return(0,V.jsxs)(`div`,{className:ZW,children:[(0,V.jsxs)(`div`,{className:QW,children:[(0,V.jsxs)(H,{variant:`row`,className:$W,"aria-expanded":_,disabled:i.total===0,onClick:()=>s(!_),children:[i.total>0&&(0,V.jsx)(Fa,{right:!_}),(0,V.jsx)(`span`,{children:i.total===0?z(`files.checks.none`):z(`files.checks.summary`,{pass:h.pass+h.skipped,total:i.total})}),h.fail>0&&(0,V.jsx)(`span`,{className:AT.attention,children:z(`files.checks.failed`,{count:h.fail})}),h.pending>0&&(0,V.jsx)(`span`,{className:AT.warning,children:z(`files.checks.running`,{count:h.pending})}),v.map(e=>(0,V.jsx)(`span`,{className:AT[e.tone],children:z(e.key)},e.key))]}),m]}),_&&i.checks.map(e=>{let{glyph:t,tone:n}=eG[e.state],r=`${e.runId}:${e.name}`,i=c[r];return(0,V.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2 pl-4`,children:[(0,V.jsx)(`span`,{className:`w-[1ch] flex-none text-center ${AT[n]}`,children:t}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),e.durationMs!==null&&(0,V.jsx)(`span`,{className:`flex-none text-subtle`,children:YW(e.durationMs)}),e.state===`fail`&&e.runId&&(0,V.jsx)(H,{hit:`tight`,className:`flex-none whitespace-nowrap`,onClick:()=>p(e),children:z(i?`files.checks.hideLog`:`files.checks.log`)})]}),i&&(0,V.jsx)(`pre`,{className:`m-0 ml-4 mb-1 max-h-40 overflow-y-auto rounded-sm border-hairline border-line bg-inset px-2 py-1.5 whitespace-pre-wrap wrap-anywhere text-muted`,children:i.state===`loading`?z(`files.checks.loading`):i.text})]},`${e.name}:${e.url}`)}),_&&i.total>i.checks.length&&(0,V.jsx)(`span`,{className:`pl-4 text-subtle`,children:z(`files.checks.more`,{count:i.total-i.checks.length})})]})}function nG({model:e,task:t}){return qW(t)?(0,V.jsxs)(`div`,{onKeyDown:e=>e.stopPropagation(),children:[(0,V.jsx)(tG,{model:e,task:t}),(0,V.jsx)(KW,{model:e,task:t})]}):null}function rG(e,t){let n={children:new Map,file:!1};for(let t of e){let e=n;for(let n of t.split(`/`)){let t=e.children.get(n);t||(t={children:new Map,file:!1},e.children.set(n,t)),e=t}e.file=!0}let r=[],i=(e,n,a)=>{let o=[...e.children].sort(([e,t],[n,r])=>{let i=t.children.size>0&&!t.file;return i===(r.children.size>0&&!r.file)?e.localeCompare(n):i?-1:1});for(let[e,s]of o){let o=s.children.size>0&&!s.file,c=o?`${n}${e}/`:`${n}${e}`,l=o&&t.has(c);r.push({path:c,name:e,depth:a,dir:o,open:l}),l&&i(s,c,a+1)}};return i(n,``,0),r}var iG={start:`\x1B[200~`,end:`\x1B[201~`};function aG(e,t){return e.engineTarget(t).tabId??e.tabs.get()[t]?.find(e=>e.kind===`engine`)?.id}async function oG(e,t,n){let r=aG(e,t);if(!r)return G(z(`files.stripNoEngine`),`error`),!1;try{return e.selection.get().tabId!==r&&e.select(t,r),await e.client.request(`term.input`,{stream:EC(t,r),data:`${iG.start}${n}${iG.end}`}),G(z(`files.stripFilled`)),!0}catch(e){return G(e instanceof Error?e.message:String(e),`error`),!1}}function sG(e){let t=e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived,n=e.changes;return t&&!!n&&`added`in n&&n.added+n.deleted>0}function cG(e){return[...sG(e)?[`commit`]:[],...lG(e)]}function lG(e){let t=e.pr;if(!t)return e.kind===`task`&&!e.noWorktree&&!e.machine&&!e.archived&&!e.sessionPrs?.length?[`createPR`]:[];if(t.lifecycle===`merged`)return e.archived||e.kind===`main`?[]:[`archive`];if(t.lifecycle!==`open`&&t.lifecycle!==`ready_to_merge`)return[];let n=[];return((t.mergeable??``).toUpperCase()===`CONFLICTING`||e.prChip===`conflict`)&&n.push(`conflicts`),t.checkState===`failing`&&n.push(`fixCI`),(t.reviewDecision??``).toUpperCase()===`CHANGES_REQUESTED`&&n.push(`comments`),n}async function uG(e,t,n){try{let r=await e.client.request(`task.prompt`,{taskId:t.id,kind:n});r.outcome===`unavailable`?G(z(`files.stripUnavailable`,{detail:r.detail??``}),`error`):r.outcome===`none`||!r.prompt?G(z(`files.stripNothing`),`error`):await oG(e,t.id,r.prompt)}catch(e){G(e instanceof Error?e.message:String(e),`error`)}}var dG={commit:`files.stripCommit`,createPR:`files.stripCreate`,conflicts:`files.stripConflicts`,fixCI:`files.stripFixCi`,comments:`files.stripComments`,archive:`files.stripArchive`};function fG({model:e,task:t}){let n=cG(t);return n.length===0?null:(0,V.jsx)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:n.map(n=>(0,V.jsx)(H,{onClick:()=>n===`archive`?void dF(e,t):void uG(e,t,n),children:z(dG[n])},n))})}var pG=2e3;function mG({model:e,task:t}){B();let n=t.id,r=!t.machine,[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),c=i?.running===!0;if((0,g.useEffect)(()=>{if(!r)return;let t=!0,i=()=>e.client.request(`run.status`,{taskId:n}).then(e=>t&&a(e),()=>{});i();let o=c?window.setInterval(()=>void i(),pG):0;return()=>{t=!1,window.clearInterval(o)}},[e,n,r,c]),!r||!i?.script)return null;let l=async t=>{s(!0);try{a(await e.client.request(t,{taskId:n}))}catch(e){G(e instanceof Error?e.message:String(e),`error`)}finally{s(!1)}};return(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-x-3.5 gap-y-1 px-2 pb-2 font-mono text-meta whitespace-nowrap`,children:[i.url&&(0,V.jsx)(H,{onClick:()=>i.url&&eA(n,i.url),children:z(`files.run.open`,{port:i.port??``})}),(0,V.jsx)(H,{disabled:o,onClick:()=>void l(c?`run.stop`:`run.start`),children:z(c?`files.run.stop`:`files.run.run`)})]})}function hG({tabs:e,value:t,onChange:n,className:r}){return(0,V.jsx)(`div`,{className:Me(`flex gap-1`,r),role:`tablist`,children:e.map(e=>{let r=e.id===t;return(0,V.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,className:Me(`relative rounded-sm px-2.5 py-0.75 font-mono text-meta font-semibold`,`touch:after:absolute touch:after:content-[''] touch:after:-inset-x-0.5 touch:after:-top-2 touch:after:-bottom-1.5`,r?`bg-inset text-ink group-focus-within/pane:text-accent`:`text-muted`),onClick:()=>n(e.id),children:e.label},e.id)})})}var gG=[`all`,`changes`],_G={M:`text-warning`,A:`text-success`,"?":`text-success`,D:`text-error`,R:`text-accent`};function vG({model:e,task:t,narrow:n=!1}){let r=$o();B();let[i,a]=(0,g.useState)(`all`),[o,s]=(0,g.useState)(`working`),[c,l]=(0,g.useState)(()=>Bs(e,`files.list`,{taskId:t.id})?.files??null),[u,d]=(0,g.useState)(()=>Bs(e,`diff.files`,{taskId:t.id})??null),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(new Set),[_,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(0),S=(0,g.useRef)(null),C=v(fn),w=JSON.stringify(t.changes??null);(0,g.useEffect)(()=>{let n=!0,r=e=>n&&p(e instanceof Error?e.message:String(e));return Hs(e,`files.list`,{taskId:t.id}).then(e=>{n&&(l(e.files),p(null))},r),Hs(e,`diff.files`,{taskId:t.id}).then(e=>n&&d(e),r),()=>{n=!1}},[e,t.id,w,b]);let T=u?.base??null,E=i===`all`?c!==null:u!==null,D=o===`branch`&&T!=null,O=i===`all`?rG(c??[],m).map(e=>({path:e.path,label:e.name,depth:e.depth,dir:e.dir,open:e.open})):(u?.files??[]).filter(e=>e.scope===(D?`branch`:`working`)).map(e=>({path:e.path,label:e.path,depth:0,dir:!1,open:!1,status:e.status,added:e.added,deleted:e.deleted})),k=Math.min(_,Math.max(0,O.length-1)),A=O[k],j=(e,t)=>h(n=>{let r=new Set(n);return t??!r.has(e)?r.add(e):r.delete(e),r}),ee=e=>$k({taskId:t.id,path:e,scope:i===`changes`&&D?`branch`:`working`}),M=n=>{if(!C?.startsWith(`${t.id}::`)){G(z(`files.mentionNoEngine`),`error`);return}e.client.request(`term.input`,{stream:C,data:`@${n} `}).catch(e=>G(String(e),`error`))},N=n=>t.machine?G(z(`files.remoteNoExternal`,{host:t.machine.label}),`error`):void e.client.request(`file.openExternal`,{taskId:t.id,path:n}).then(()=>G(z(`taskops.openedExternal`))).catch(e=>G(e instanceof Error?e.message:String(e),`error`));return(0,V.jsxs)(`div`,{className:`group/pane flex min-h-0 min-w-0 flex-1 flex-col outline-none ${n?`px-1.5 pt-2.5 pb-2`:`pt-0.5 pr-1.5 pb-1.5 pl-0`}`,tabIndex:0,ref:S,onKeyDown:e=>{let t=e.key;if(t===`j`||t===`ArrowDown`)y(Math.min(O.length-1,k+1));else if(t===`k`||t===`ArrowUp`)y(Math.max(0,k-1));else if((t===`l`||t===`ArrowRight`)&&A?.dir)j(A.path,!0);else if((t===`h`||t===`ArrowLeft`)&&A?.dir)j(A.path,!1);else if(t===`[`||t===`]`)a(gG[(gG.indexOf(i)+(t===`]`?1:gG.length-1))%gG.length]??`all`);else if(t===`b`&&i===`changes`&&T!=null)s(o===`working`?`branch`:`working`);else if(t===`r`)x(e=>e+1);else if(t===`D`&&e.shiftKey)ee(`.`);else if(t===`d`&&A)ee(A.path);else if(t===`Enter`&&A)A.dir?j(A.path):ee(A.path);else if(t===`a`&&A)M(A.path);else if(t===`o`&&A&&!A.dir)N(A.path);else return;e.preventDefault()},children:[(0,V.jsx)(fG,{model:e,task:t}),(0,V.jsx)(nG,{model:e,task:t}),(0,V.jsx)(mG,{model:e,task:t}),(0,V.jsx)(hG,{className:`px-1 pb-1.5`,tabs:[{id:`all`,label:z(`files.all`)},{id:`changes`,label:z(`files.changes`)}],value:i,onChange:e=>{a(e),y(0)}}),i===`changes`&&(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-x-2.5 gap-y-1 px-2 pb-2 font-mono text-meta text-muted`,children:[(0,V.jsx)(`span`,{children:D?z(`files.scopeBranch`,{base:T??``}):z(`files.scopeWorking`)}),T==null?u&&(0,V.jsx)(`span`,{children:z(`files.noBase`)}):(0,V.jsx)(H,{hit:`tight`,onClick:()=>s(o===`working`?`branch`:`working`),children:z(r?`files.toggleScopeTouch`:`files.toggleScope`)}),(0,V.jsx)(kT,{text:z(`files.legend`)}),(0,V.jsx)(H,{hit:`tight`,onClick:()=>ee(`.`),children:z(r?`files.diffAllTouch`:`files.diffAll`)})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[f&&(0,V.jsx)(`p`,{className:`mono text-error`,children:f}),!f&&E&&O.length===0&&(0,V.jsx)(`p`,{className:`mx-2.5 my-3 font-mono text-meta text-subtle`,children:z(i===`all`?`files.emptyAll`:`files.emptyChanges`)}),O.map((e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:tr({selected:t===k,size:n?`file-narrow`:`file`}),style:{paddingLeft:8+e.depth*14},title:e.path,onClick:()=>{y(t),S.current?.focus(),e.dir?j(e.path):ee(e.path)},children:[e.status?(0,V.jsx)(`span`,{className:`${ar} ${_G[e.status]??``}`,children:e.status}):(0,V.jsx)(`span`,{className:`${ar} grid place-items-center text-subtle`,children:e.dir?(0,V.jsx)(Fa,{right:!e.open}):null}),(0,V.jsx)(`span`,{className:nr,children:e.label}),e.added?(0,V.jsxs)(NL,{tone:`added`,children:[`+`,e.added]}):null,e.deleted?(0,V.jsxs)(NL,{tone:`removed`,children:[`−`,e.deleted]}):null]},e.path))]})]})}function yG({children:e}){return(0,V.jsx)(`svg`,{className:`size-3.5 ${vI}`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:e})}var bG={chat:(0,V.jsx)(`path`,{d:`M3 3.5h10a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8l-3 2.5v-2.5H3a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1zM5 6.5h6M5 8.5h4`}),files:(0,V.jsx)(`path`,{d:`M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z`}),diff:(0,V.jsx)(`path`,{d:`M3.5 2.5h9a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zM8 5v4M6 7h4M6 11h4`}),browser:(0,V.jsx)(`path`,{d:`M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2zM2 8h12M8 2c2.2 2 2.2 10 0 12M8 2c-2.2 2-2.2 10 0 12`}),quota:(0,V.jsx)(`path`,{d:`M2 10a6 6 0 1 1 12 0M8 10l2.5-3.5M4 13h8`})};function xG(e){if(e.kind===`files`)return z(`panel.files`);if(e.kind===`chat`)return z(`panel.chat`);if(e.kind===`quota`)return z(`panel.quota`);if(e.kind===`diff`)return e.path===`.`?z(`panel.diff`):ok(e.path);let t=ak(e);return t?sk(t):z(`panel.browser`)}function SG(e){return e.kind===`diff`?e.path===`.`?z(`preview.whole`):e.path:e.kind===`browser`&&ak(e)||xG(e)}var CG=7.3,wG=51,TG=160;function EG(e,t){let n=0;for(let t of e){let e=0;for(let n of t)e+=(n.codePointAt(0)??0)>11903?2:1;n+=Math.min(TG,wG+e*CG)+2}return n<=t}var DG=null;function OG(e,t,n,r){let i=(t,r)=>({label:r,section:`move`,run:()=>Xk(e,e=>Ok(e,n.id,t))}),a=[];return!t.bottom&&t.top.tabs.length>1?a.push(i(`bottom`,z(`panel.splitDown`))):t.bottom&&a.push(r===`top`?i(`bottom`,z(`panel.moveBottom`)):i(`top`,z(`panel.moveTop`))),a.push({label:z(`panel.close`),section:`close`,run:()=>tA(e,n.id)}),t.top.tabs.length+(t.bottom?.tabs.length??0)>1&&a.push({label:z(`panel.closeOthers`),section:`close`,run:()=>Xk(e,e=>Dk(e,n.id))}),a}function kG(e,t){return[{label:z(`panel.newChat`),run:()=>Xk(e,e=>bk(e,`chat`))},{label:z(`panel.newFiles`),run:()=>Xk(e,e=>gk(e,t))},{label:z(`panel.newDiff`),run:()=>Xk(e,e=>vk(e,`.`,`working`))},{label:z(`panel.newBrowser`),run:()=>Xk(e,e=>_k(e,t))},{label:z(`panel.newQuota`),run:()=>Xk(e,e=>bk(e,`quota`))}]}function AG({taskId:e,panel:t,group:n,tabs:r,active:i,narrow:a,children:o}){B();let[s,c]=(0,g.useState)(null),l=()=>DG?.taskId===e,u=t=>{let r=DG;DG=null,c(null),r?.taskId===e&&Xk(e,e=>Ok(e,r.id,n,t))},d=t=>{let r=t.currentTarget.getBoundingClientRect();on.set({x:r.left,y:r.bottom+2,items:kG(e,n),target:t.currentTarget})},f=(e,t)=>{if(!l())return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect();c({id:t,after:e.clientX>n.left+n.width/2})},p=(0,g.useRef)(null),[m,h]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=p.current;if(!e)return;let t=new ResizeObserver(([e])=>h(e?.contentRect.width??0));return t.observe(e),()=>t.disconnect()},[]);let _=m>0&&!EG(r.map(xG),m);return(0,g.useEffect)(()=>{p.current?.querySelector(`.is-active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[i,r.length,_]),(0,V.jsxs)(`div`,{className:wI(a),style:{gridRow:n===`top`?1:4},onDragOver:e=>{l()&&(e.preventDefault(),c(null))},onDrop:e=>{e.preventDefault(),u()},children:[(0,V.jsx)(`div`,{className:TI,role:`tablist`,"aria-label":z(`panel.tabs`),ref:p,children:r.map((r,o)=>(0,V.jsxs)(`div`,{role:`presentation`,className:EI({active:r.id===i,compact:_}),"data-drop":s?.id===r.id?s.after?`after`:`before`:void 0,draggable:!a,onDragStart:()=>{DG={taskId:e,id:r.id}},onDragEnd:()=>{DG=null,c(null)},onDragOver:e=>f(e,r.id),onDrop:e=>{e.preventDefault(),e.stopPropagation(),u(o+(s?.id===r.id&&s.after?1:0))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onAuxClick:t=>{t.button===1&&(t.preventDefault(),tA(e,r.id))},onContextMenu:i=>{a||cW(i,OG(e,t,r,n))},children:[(0,V.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r.id===i,className:DI(_&&r.id!==i),title:SG(r),onClick:()=>Xk(e,e=>fk(e,r.id)),children:[(0,V.jsx)(yG,{children:bG[r.kind]}),(0,V.jsx)(`span`,{className:OI,children:xG(r)})]}),(0,V.jsx)(`button`,{type:`button`,className:`${kI} ${_&&r.id!==i?`hidden`:``}`,"aria-label":z(`panel.close`),tabIndex:-1,onClick:()=>tA(e,r.id),children:`×`})]},r.id))}),!a&&(0,V.jsx)(`button`,{type:`button`,className:yI({tool:!0}),title:z(`panel.new`),"aria-label":z(`panel.new`),onClick:d,children:(0,V.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,V.jsx)(`path`,{d:`M8 3.5v9M3.5 8h9`})})}),o]})}var jG={md:`md`,markdown:`md`,html:`html`,htm:`html`,svg:`svg`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,pdf:`pdf`};function MG(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<0?null:jG[t.slice(n+1).toLowerCase()]??null}function NG(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var PG=e=>new TextDecoder().decode(NG(e));function FG(e,t){if(e===`svg`)return`image/svg+xml`;if(e===`pdf`)return`application/pdf`;let n=t.slice(t.lastIndexOf(`.`)+1).toLowerCase();return n===`jpg`||n===`jpeg`?`image/jpeg`:n===`gif`?`image/gif`:n===`webp`?`image/webp`:`image/png`}var IG=`default-src 'none'; img-src data:; style-src 'unsafe-inline'`;function LG(e){let t=`<meta http-equiv="Content-Security-Policy" content="${IG}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}var RG=/^\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)/,zG=/^https?:\/\/[^\s<>)\]]+/,BG=/[\p{L}\p{N}]/u;function VG(e){let t=[],n=``,r=()=>{n&&t.push({t:`text`,v:n}),n=``},i=0;for(;i<e.length;){let a=e.slice(i),o=e[i]??``;if(o==="`"){let n=e.indexOf("`",i+1);if(n>i+1){r(),t.push({t:`code`,v:e.slice(i+1,n)}),i=n+1;continue}}else if(a.startsWith(`**`)){let n=e.indexOf(`**`,i+2);if(n>i+2){r(),t.push({t:`bold`,c:VG(e.slice(i+2,n))}),i=n+2;continue}}else if(o===`*`||o===`_`&&!BG.test(e[i-1]??``)){let n=e.indexOf(o,i+1);if(n>i+1&&!/\s/.test(e[i+1]??` `)&&(o===`*`||!BG.test(e[n+1]??``))){r(),t.push({t:`em`,c:VG(e.slice(i+1,n))}),i=n+1;continue}}else if(o===`[`){let e=RG.exec(a);if(e){r(),t.push({t:`link`,href:e[2],c:VG(e[1])}),i+=e[0].length;continue}}else if(o===`h`&&!BG.test(e[i-1]??``)){let e=zG.exec(a);if(e){let n=e[0].replace(/[.,;:!?]+$/,``);r(),t.push({t:`link`,href:n,c:[{t:`text`,v:n}]}),i+=n.length;continue}}n+=o,i++}return r(),t}var HG=/^\s*(```+|~~~+)\s*([\w+#.-]*)\s*$/,UG=/^(#{1,6})\s+(.*?)\s*#*\s*$/,WG=/^(\s*)([-*+])\s+(.*)$/,GG=/^(\s*)\d+[.)]\s+(.*)$/,KG=/^\s*([-*_])(\s*\1){2,}\s*$/,qG=/^\s*\|.*\|\s*$/,JG=/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/,YG=e=>e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());function XG(e){let t=e.replace(/\r\n?/g,`
129
129
  `).split(`
130
130
  `),n=[],r=[],i=()=>{r.length>0&&n.push({t:`para`,c:VG(r.join(`
131
131
  `))}),r=[]};for(let e=0;e<t.length;e++){let a=t[e],o=HG.exec(a);if(o){i();let r=o[1][0],a=[];for(e++;e<t.length&&!RegExp(`^\\s*${r}{3,}\\s*$`).test(t[e]);e++)a.push(t[e]);n.push({t:`code`,lang:o[2]??``,v:a.join(`
@@ -11,7 +11,7 @@
11
11
  <meta name="apple-mobile-web-app-capable" content="yes" />
12
12
  <meta name="apple-mobile-web-app-title" content="rove" />
13
13
  <title>rove</title>
14
- <script type="module" crossorigin src="/assets/index-DfOHWIkY.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-2EGYdYCP.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-DPumAcdt.css">
16
16
  </head>
17
17
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@sma1lboy/rove",
4
- "version": "0.9.278-next.17",
4
+ "version": "0.9.278-next.18",
5
5
  "description": "Rove — the agent multiplexer for your terminal. Run coding agents on parallel tasks with isolated worktrees and persistent sessions.",
6
6
  "keywords": [
7
7
  "terminal",