@a-t-h-i/bot-lobby 0.6.39 → 0.6.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -6
- package/package.json +1 -1
- package/prompts/global.md +12 -0
- package/prompts/master.md +8 -1
- package/prompts/quickfix.md +5 -3
- package/prompts/scout.md +8 -4
- package/prompts/worker.md +4 -3
- package/src/classifier/chat.ts +122 -0
- package/src/classifier/classifier.ts +46 -11
- package/src/classifier/files.ts +91 -23
- package/src/classifier/instance.ts +35 -2
- package/src/classifier/models.ts +115 -0
- package/src/execution/git.ts +45 -2
- package/src/index.ts +3 -0
- package/src/knowledge/file-notes.ts +104 -0
- package/src/knowledge/repo-map.ts +165 -0
- package/src/lobby/host.ts +2 -0
- package/src/lobby/service.ts +2 -1
- package/src/master/master.ts +39 -3
- package/src/master/scout-cache.ts +70 -0
- package/src/master/synthesis.ts +10 -2
- package/src/pi/model-settings.ts +5 -3
- package/src/pi/tool-budget.ts +66 -0
- package/src/roles/markdown.ts +12 -4
- package/src/roles/scout.ts +2 -1
- package/src/schemas/configuration.ts +21 -2
- package/src/schemas/findings.ts +2 -0
- package/src/webui/api/settings.ts +2 -1
- package/src/webui/dev/fake-service.ts +1 -0
- package/src/webui/protocol.ts +8 -0
- package/webui/dist/assets/{index-D8TuTAMK.js → index-DXDrQbgq.js} +10 -10
- package/webui/dist/assets/index-Glz3FAPp.css +2 -0
- package/webui/dist/build.json +10 -6
- package/webui/dist/index.html +2 -2
- package/webui/dist/assets/index-uTndyUfm.css +0 -2
|
@@ -88,22 +88,22 @@ Error generating stack: `+e.message+`
|
|
|
88
88
|
`)),n=[]),n.push(i);return t.push(n.join(`
|
|
89
89
|
`)),t}function bH(e,t,n=!1){let r=t?.start?.offset,i=t?.end?.offset;if(r===void 0||i===void 0)return;let a=e.slice(r,i);if(!n){let e=a.match(/^`+/)?.[0];return e&&a.endsWith(e)?a.slice(e.length,-e.length):a}let o=a.match(/^ {0,3}(`{3,}|~{3,})[^\r\n]*(?:\r\n|\n|\r)/);if(!o)return a;let s=a.slice(o[0].length),c=RegExp(`^ {0,3}${o[1][0]}{${o[1].length},}[ \\t]*$`,`m`).exec(s);return c?s.slice(0,c.index):s}function xH(e,t){return!e&&!t}async function SH(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var CH=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function wH(e){let t=e.lastIndexOf(`${tj}\n`);if(t<0||t>0&&e[t-1]!==`
|
|
90
90
|
`)return{body:e,files:[]};let n=e.slice(t+tj.length+1).split(`
|
|
91
|
-
`).filter(Boolean),r=[];for(let t of n){let n=CH.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var TH=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function EH({files:e}){return e.length===0?null:(0,R.jsx)(`ul`,{className:`mt-2 flex min-w-0 max-w-full flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,R.jsx)(`li`,{children:TH.has(e.mime)?(0,R.jsx)(`a`,{href:F(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,className:`block max-w-full overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02] focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,children:(0,R.jsx)(`img`,{src:F(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,R.jsxs)(`span`,{className:`inline-flex max-w-[min(16rem,100%)] min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var DH=!1,OH=[],kH=0,AH=900;function jH(){DH=!0,window.clearTimeout(kH),kH=window.setTimeout(MH,AH)}function MH(){DH=!1,window.clearTimeout(kH);let e=OH;OH=[];for(let t of e)t()}function NH(e){if(!DH)return e(),()=>{};let t=()=>e();return OH.push(t),()=>{OH=OH.filter(e=>e!==t)}}var PH=8;function FH(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=NH(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Hv.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*PH/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function IH(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(IH).join(``)}function LH(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),LH(t,n)}function RH(){return e=>LH(e)}function zH(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await SH(e,navigator.clipboard),n(!0),H.success(`Code copied.`)}catch{H.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function BH({text:e,children:t,block:n=!1}){let{copy:r}=zH(e),i=(0,m.useRef)(void 0);return(0,R.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:q(`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,!n&&`max-md:break-words max-md:[overflow-wrap:anywhere]`),onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),xH(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),xH(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,R.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function VH({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=zH(bH(n,r?.position,!0)??IH(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,R.jsxs)(`div`,{className:`relative my-3 max-md:min-w-0 max-md:max-w-full rounded-lg bg-muted`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,R.jsx)(X,{label:i?`Copied`:`Copy the code`,icon:i?Vp:Cm,iconOnly:!0,onClick:()=>void a()})]}),(0,R.jsx)(`pre`,{className:`!my-0 max-md:max-w-full overflow-x-auto max-md:overscroll-x-contain !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function HH(e){return{pre:t=>(0,R.jsx)(VH,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,R.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,R.jsx)(BH,{text:bH(e,r?.position,i)??IH(r),block:i,children:n})},a:({href:e,children:t})=>(0,R.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,R.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,R.jsx)(`div`,{className:`my-3 w-full max-md:min-w-0 max-md:max-w-full overflow-x-auto max-md:overscroll-x-contain`,children:(0,R.jsx)(`table`,{className:`w-full max-md:min-w-max border-collapse text-sm`,children:e})})}}var UH=(0,m.memo)(function({text:e}){return(0,R.jsx)(oz,{remarkPlugins:[fH],rehypePlugins:[RH],urlTransform:mH,components:HH(e),children:e})}),WH=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=wH(e),i=n?yH(n):[],a=FH(i.length,3);return(0,R.jsxs)(`div`,{className:q(`md-body max-md:min-w-0 max-md:max-w-full max-md:break-words max-md:[overflow-wrap:anywhere]`,t),children:[i.slice(0,a).map((e,t)=>(0,R.jsx)(UH,{text:e},t)),(0,R.jsx)(EH,{files:r})]})});function GH({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,R.jsxs)(`section`,{className:q(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,R.jsxs)(`div`,{className:q(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,R.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,R.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none max-md:h-11 max-md:min-w-11 max-md:justify-center`,children:[o?(0,R.jsx)(rA,{chord:o,className:`kbd-hint max-md:hidden`}):null,(0,R.jsx)(Up,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function KH({title:e,right:t,className:n}){return(0,R.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,R.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function qH({title:e,right:t,prominent:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs max-md:rounded-lg max-md:p-3`),children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,R.jsx)(KH,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var JH=`Pull requests`,YH=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,XH=`nothing is posted to GitHub`,ZH=`Refresh to load open pull requests with the GitHub CLI (gh).`,QH=`No open pull requests.`,$H=`loading pull requests from GitHub…`,eU=`reading the diff…`,tU=`the pull request has new commits since this review — review it again`,nU=`(no description)`,rU=`Review with a focus (optional)`,iU=`Leave it empty for a full review.`;function aU(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function oU(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function sU(e,t){return`+${e} −${t}`}function cU(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function lU(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function uU(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function dU(e,t){if(e.status===`running`)return fU(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?fU(e,t):e.status;return[uU(e.verdict),n].filter(Boolean).join(` · `)}function fU(e,t){let n=Math.max(0,Math.round(((e.finishedAt??t)-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function pU(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${dM(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function mU(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${sU(e.additions,e.deletions)} · ${t}`}function hU(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,cU(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function gU(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function _U(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function vU(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function yU({pull:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pU(e,t)}),(0,R.jsx)(`p`,{className:`text-sm tabular-nums`,children:mU(e)}),hU(e)?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:hU(e)}):null,e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4 max-md:min-h-11 max-md:items-center`,children:e.url}):null]})}function bU({read:e}){return(0,R.jsxs)(qH,{title:`Jev's read`,right:_U(e),children:[e.status===`running`?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`}),eU]}):null,e.status===`failed`?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,R.jsx)(WH,{text:e.line}):null]})}function xU({review:e,now:t}){return(0,R.jsxs)(R.Fragment,{children:[e.model?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,dM(t-e.startedAt)]}):null,e.stale?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:tU}):null,e.status===`running`?(0,R.jsx)(SU,{steps:e.steps}):null,e.status===`cancelled`?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,R.jsx)(WH,{text:e.text}):null]})}function SU({steps:e}){return(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,R.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function CU({number:e,focus:t,onChange:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:rU}),(0,R.jsx)(sM,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,className:`max-md:min-h-11`,onChange:e=>n(e.target.value)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:iU})]})}function wU({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,R.jsxs)(qH,{title:`Review`,right:t?dU(t,n):void 0,children:[t?(0,R.jsx)(xU,{review:t,now:n}):null,(0,R.jsx)(CU,{number:e,focus:r,onChange:i}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,XH,`.`]})]})}function TU({files:e}){return(0,R.jsx)(qH,{title:`Files`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,R.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:sU(e.additions,e.deletions)})]},e.path))})})})})}function EU({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?dM(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,R.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,R.jsx)(WH,{text:e.body.trim()}):null]})}function DU({notes:e,now:t}){return e.length===0?null:(0,R.jsx)(qH,{title:`Discussion`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(EU,{note:e,now:t},n))})})}function OU({number:e,error:t}){return t?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`}),`loading #`,e,`…`]})}function kU({number:e,onChanged:t}){let n=xj(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=vU(a);if(!n.data)return(0,R.jsx)(OU,{number:e,error:n.error});let{pull:s,review:c,read:l}=n.data,u=()=>{n.reload(),t?.()},d=async()=>{let t=r.trim();i(``),await U(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await U(`git.jev`,{number:e}),u()},p=async()=>{await U(`git.cancelReview`,{number:e}),u()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Review`,icon:Uh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,R.jsx)(X,{label:`Jev's read`,icon:Fp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,R.jsx)(SM,{icon:dm,label:`Stop the review`,text:`Stop`,shortcut:`X`,title:`Stop this review?`,description:`The agent stops reading the pull request. Nothing is posted to GitHub.`,confirmLabel:`Stop review`,variant:`destructive`,onConfirm:()=>void p()}):null]}),(0,R.jsx)(yU,{pull:s,now:o}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:YH}),l?(0,R.jsx)(bU,{read:l}):null,(0,R.jsx)(wU,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,R.jsx)(TU,{files:s.files}):null,(0,R.jsx)(qH,{title:`Description`,children:s.body.trim()?(0,R.jsx)(WH,{text:s.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:nU})}),(0,R.jsx)(DU,{notes:s.notes,now:o})]})}var AU=Jg([`relative inline-flex shrink-0 items-center justify-center w-fit border border-transparent font-medium whitespace-nowrap outline-none transition-shadow`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3`],{variants:{variant:{default:`bg-primary text-primary-foreground`,outline:`border-border bg-transparent dark:bg-input/32`,secondary:`bg-secondary text-secondary-foreground`,info:`bg-info text-white`,success:`bg-success text-white`,warning:`bg-warning text-white`,destructive:`bg-destructive text-white`,focus:`bg-focus text-focus-foreground`,invert:`bg-invert text-invert-foreground`,"primary-light":`border-primary/10 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/15 dark:text-primary`,"warning-light":`border-warning/15 bg-warning/10 text-warning-foreground dark:border-warning/25 dark:bg-warning/15 dark:text-warning`,"success-light":`border-success/15 bg-success/10 text-success-foreground dark:border-success/25 dark:bg-success/15 dark:text-success`,"info-light":`border-info/15 bg-info/10 text-info-foreground dark:border-info/25 dark:bg-info/15 dark:text-info`,"destructive-light":`border-destructive/15 bg-destructive/10 text-destructive-foreground dark:border-destructive/25 dark:bg-destructive/15 dark:text-destructive`,"invert-light":`border-invert/15 bg-invert/10 text-foreground dark:border-invert/45 dark:bg-invert/35 dark:text-invert-foreground`,"focus-light":`border-focus/15 bg-focus/10 text-focus-foreground dark:border-focus/25 dark:bg-focus/15 dark:text-focus`,"primary-outline":`bg-background border-border text-primary dark:bg-input/30`,"warning-outline":`bg-background border-border text-warning-foreground dark:bg-input/30`,"success-outline":`bg-background border-border text-success-foreground dark:bg-input/30`,"info-outline":`bg-background border-border text-info-foreground dark:bg-input/30`,"destructive-outline":`bg-background border-border text-destructive-foreground dark:bg-input/30`,"invert-outline":`bg-background border-border text-invert-foreground dark:bg-input/30`,"focus-outline":`bg-background border-border text-focus-foreground dark:bg-input/30`},size:{xs:`px-1 py-0.25 text-[0.6rem] leading-none h-4 min-w-4 gap-1`,sm:`px-1 py-0.25 text-[0.625rem] leading-none h-4.5 min-w-4.5 gap-1`,default:`px-1.25 py-0.5 text-xs h-5 min-w-5 gap-1`,lg:`px-1.5 py-0.5 text-xs h-5.5 min-w-5.5 gap-1`,xl:`px-2 py-0.75 text-sm h-6 min-w-6 gap-1.5`},radius:{default:`rounded-sm`,full:`rounded-full`}},defaultVariants:{variant:`default`,size:`default`,radius:`default`}});function jU({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?kv:`span`;return(0,R.jsx)(o,{"data-slot":`badge`,className:q(AU({variant:t,size:n,radius:r,className:e})),...a})}var MU=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 aria-[current=true]:border-primary/40 aria-[current=true]:bg-accent`,NU=`flex flex-col gap-1 px-2 pb-3`,PU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function FU({checks:e}){let t=aU(e);return t?(0,R.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,oU(e)),"aria-hidden":`true`,children:t}):(0,R.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function IU({pull:e,selected:t,onSelect:n}){let r=lU(e.review);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.number),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(FU,{checks:e.checks}),e.draft?(0,R.jsx)(jU,{variant:`secondary`,children:`draft`}):null,(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:gU(e)}),(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,R.jsx)(`span`,{children:r}):null,(0,R.jsx)(`span`,{className:`tabular-nums`,children:sU(e.additions,e.deletions)})]})]})]})})}function LU({pulls:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(IU,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var RU=()=>aj(ij(`git`)),zU=e=>aj(ij(`git`,String(e)));function BU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function VU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?QH:e?$H:ZH;return(0,R.jsxs)(sj,{className:`m-4 flex-1`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(Um,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,children:`Retry`}):null]})}function HU({rest:e}){let t=eM(),n=xj(`git.pulls`,{},[`git`]),r=BU(e),i=n.data?.pulls??[],a=(0,m.useCallback)(()=>{U(`git.pulls`,{refresh:!0}).then(()=>n.reload())},[n]);if(!n.data&&n.error)return(0,R.jsx)(yj,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,R.jsx)(VU,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:JH,count:n.data?`${i.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,R.jsx)(LU,{pulls:i,selectedId:r,onSelect:zU}):(0,R.jsx)(oM,{})]}),c=r===void 0?null:(0,R.jsx)(kU,{number:r,onChanged:n.reload},r);return(0,R.jsx)(iM,{wide:t,list:s,detail:c,open:r!==void 0,onClose:RU,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function UU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function WU({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,R.jsx)(sM,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{UU(e)&&(e.preventDefault(),l())}}),t?(0,R.jsx)(`p`,{id:`${i}-hint`,className:q(`text-xs text-muted-foreground`,/(?:Enter|Esc)/.test(t)&&`max-md:hidden`),children:t}):null,(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:n,icon:s?rh:Np,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var GU=`Issues`,KU=`Issue`,qU=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,JU=`Refresh to load open issues with the GitHub CLI (gh).`,YU=`No open issues. File one with New issue.`,XU=`loading issues from GitHub…`,ZU=`issues are off (lobby.issues)`,QU=`(no description)`;function $U(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${dM(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function eW(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?dM(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function tW(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function nW({issue:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:$U(e,t)}),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4 max-md:min-h-11 max-md:items-center`,children:e.url}):null]})}function rW({comment:e,now:t}){return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,R.jsx)(`span`,{children:dM(t-Date.parse(e.createdAt))}):null]}),(0,R.jsx)(WH,{text:e.body.trim()})]})}function iW({comments:e,now:t}){return e.length===0?null:(0,R.jsx)(qH,{title:`Comments`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(rW,{comment:e,now:t},n))})})}function aW({issue:e}){let t=async()=>{await U(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&aj(ij(`plan`))};return(0,R.jsx)(SM,{icon:zg,label:`Plan #${e.number} with the panel`,text:`Plan it`,shortcut:`N`,title:`Plan #${e.number} with the panel?`,description:`A new planning session starts from this issue. A plan already under way waits under Plan → Previous.`,confirmLabel:`Plan it`,onConfirm:()=>void t()})}function oW({number:e}){let t=xj(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${KU} #${e}`,children:[(0,R.jsx)(Gj,{children:(0,R.jsx)(aW,{issue:r})}),(0,R.jsx)(nW,{issue:r,now:n}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:qU}),(0,R.jsx)(qH,{title:`Description`,children:r.body.trim()?(0,R.jsx)(WH,{text:r.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:QU})}),(0,R.jsx)(iW,{comments:r.comments,now:n})]})}function sW({issue:e,selected:t,now:n,onSelect:r}){let i=tW(e.labels);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.number),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,R.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,R.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:eW(e,n)})]})})}function cW({issues:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(sW,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var lW=()=>aj(ij(`issues`)),uW=e=>aj(ij(`issues`,String(e)));function dW(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function fW(){return(0,R.jsx)(sj,{className:`m-4 flex-1`,children:(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(dj,{children:`Issues are off`}),(0,R.jsx)(fj,{className:`font-mono`,children:ZU})]})})}function pW({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?YU:e?XU:JU;return(0,R.jsxs)(sj,{className:`m-4 flex-1`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,children:`Retry`}):null]})}function mW({onCreate:e}){return(0,R.jsx)(tM,{className:`shrink-0 border-t border-border p-4`,children:(0,R.jsx)(WU,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function hW({rest:e}){let t=eM(),n=sA(`status`).data?.issuesEnabled??!0,r=xj(`issues.list`,{},[`issues`],n),i=dW(e),a=r.data?.issues??[],o=Date.now(),s=(0,m.useCallback)(()=>{U(`issues.list`,{refresh:!0}).then(()=>r.reload())},[r]),c=async e=>await U(`issues.create`,{text:e})?(r.reload(),!0):!1;if(!n)return(0,R.jsx)(fW,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,R.jsx)(fW,{}):(0,R.jsx)(yj,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:GU,count:r.data?`${a.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,R.jsx)(cW,{issues:a,selectedId:i,now:o,onSelect:uW}):(0,R.jsx)(oM,{}),(0,R.jsx)(mW,{onCreate:c})]}),d=i===void 0?null:(0,R.jsx)(oW,{number:i},i),f=r.data&&a.length===0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pW,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,R.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,R.jsx)(mW,{onCreate:c})})]}):(0,R.jsx)(iM,{wide:t,list:u,detail:d,open:i!==void 0,onClose:lW,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}function gW(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var _W={DEV:ym,DESIGN:Dh,QA:lg,RESEARCH:xg,"QUICK FIX":Ug,SCOUT:xm,PLANNER:tg,CLASSIFIER:yg,LOBBY:hh,LINT:$m};function vW(e){return e?_W[e.toUpperCase()]??Lp:zp}function yW(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function bW({source:e,className:t,strokeWidth:n}){if(yW(e))return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=vW(e);return(0,R.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var xW={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,"QUICK FIX":`text-source-quickfix`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function SW(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function CW(e){return xW[e]??`text-muted-foreground`}var wW={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,"QUICK FIX":`var(--source-quickfix)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function TW(e){return wW[e]??`var(--muted-foreground)`}function EW(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function DW(e){return e?.runs??[]}function OW(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function kW({source:e,live:t}){let n=yW(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":TW(e)},children:(0,R.jsx)(bW,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function AW({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,R.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,R.jsx)(`div`,{className:`chat-gutter`,children:r?(0,R.jsx)(kW,{source:e,live:i}):n?(0,R.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,R.jsxs)(`p`,{className:`chat-speaker`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,R.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,R.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,R.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":TW(e)},children:a}):a]})]})}function jW({time:e,head:t,note:n,children:r,below:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,R.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,R.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,R.jsx)(`span`,{children:n}):null]}):null,(0,R.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function MW({failed:e,children:t}){return(0,R.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,R.jsx)(`span`,{children:t})})}function NW({className:e}){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{})]})}function PW({onClick:e,className:t}){return(0,R.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:q(`jump-latest btn-raised grid size-9 place-items-center rounded-full border bg-card text-foreground shadow-card outline-none focus-visible:ring-3 focus-visible:ring-ring/40 max-md:size-11`,t),children:(0,R.jsx)(Dp,{"aria-hidden":`true`,className:`size-4`})})}var FW=3e5,IW=`No task is running in this session.`,LW=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,RW=`Nothing said yet. Type below to talk to the oracle about this task.`;function zW({entry:e}){return(0,R.jsxs)(MW,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${lM(e.at)}`:``]})}function BW({entry:e,head:t}){if(e.role===`you`)return(0,R.jsx)(jW,{time:lM(e.at),head:t,children:(0,R.jsx)(WH,{text:e.text})});let n=e.role===`panel`;return(0,R.jsx)(AW,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:lM(e.at),head:t,children:(0,R.jsx)(WH,{text:e.text})})}var VW=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,R.jsx)(B.div,{initial:n?{opacity:0,y:10}:!1,animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:420,damping:32},children:e.role===`note`?(0,R.jsx)(zW,{entry:e}):(0,R.jsx)(BW,{entry:e,head:t})})},(e,t)=>e.head===t.head&&e.entry.id===t.entry.id&&e.entry.text===t.entry.text&&e.entry.at===t.entry.at);function HW({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,R.jsx)(AW,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,R.jsx)(WH,{text:e??``}):(0,R.jsx)(NW,{className:`mt-1`})})}function UW({hasTask:e}){return(0,R.jsxs)(sj,{className:`h-full border-0`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(ph,{"aria-hidden":`true`})}),e?null:(0,R.jsx)(dj,{children:IW}),(0,R.jsx)(fj,{children:e?RW:LW})]}),e?null:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,R.jsx)(rA,{chord:`3`}),` Plan`]}),(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,R.jsx)(rA,{chord:`4`}),` Quick fix`]})]})]})}async function WW(e){let t=await Te(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function GW(e,t,n){let[r,i]=(0,m.useState)([]),[a,o]=(0,m.useState)(t),[s,c]=(0,m.useState)(!1),l=(0,m.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...r.filter(e=>!t.has(e.id)),...e]},[r,e]);return{merged:l,more:a,loading:s,load:(0,m.useCallback)(async()=>{let e=l[0]?.id;if(e===void 0||s||!a)return;c(!0);let t=n.current,r=t?.scrollHeight??0,u=t?.scrollTop??0;try{let t=await WW(e);i(e=>[...t.entries,...e]),o(t.hasOlder),window.requestAnimationFrame(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight-r+u)})}catch{o(!1)}finally{c(!1)}},[l,s,a,n])}}function KW({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i}){let{ref:a,atBottom:o,stick:s,onScroll:c}=gW(e.length+(t?.length??0)),{merged:l,more:u,loading:d,load:f}=GW(e,r,a),p=(0,m.useCallback)(()=>{c();let e=a.current;e&&e.scrollTop<80&&u&&!d&&f()},[c,a,u,d,f]),h=l.length===0&&!t?.trim()&&!n,[g,_]=(0,m.useState)(!1);return(0,m.useEffect)(()=>_(!0),[]),(0,R.jsxs)(GH,{"aria-label":`Conversation`,className:`flex-1`,children:[(0,R.jsx)(`div`,{ref:a,onScroll:p,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-4 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Conversation`,tabIndex:0,children:h?(0,R.jsx)(UW,{hasTask:i}):(0,R.jsxs)(`div`,{className:`chat-column`,children:[u?(0,R.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,l.map((e,t)=>{let n=l[t-1],r=!n||n.role!==e.role||e.at-n.at>FW;return(0,R.jsx)(VW,{entry:e,head:r,fresh:g},e.id)}),(0,R.jsx)(HW,{text:t,busy:n})]})}),o?null:(0,R.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,R.jsx)(PW,{onClick:s})})]})}function qW(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function JW(e,t){let{agent:n,file:r}=qW(e);return ij(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var YW=[`master`,`designer`,`backend`,`qa`],XW={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},ZW={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},QW=`Every write archives the version before it.`;function $W(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function eG(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function tG(e){return{text:e.text,occurrence:e.occurrence}}function nG(e){return YW.map(t=>{let n=e.filter(e=>e.agent===t);return{agent:t,files:n,notes:n.reduce((e,t)=>e+t.notes,0)}}).filter(e=>e.files.length>0)}function rG(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function iG({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,R.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,R.jsx)(sM,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{rG(e)&&(e.preventDefault(),o())}}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:QW}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,disabled:t,children:`Cancel`}),(0,R.jsxs)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:o,disabled:t||!i.trim(),children:[t?(0,R.jsx)(pj,{}):null,`Save`]})]})]})]})}function aG({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=XA(e,YA.confirm);return(0,R.jsx)(HA,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:QW,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:QW})]}),(0,R.jsx)(sM,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:i,disabled:r,children:`Cancel`}),(0,R.jsxs)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:()=>a(o),disabled:r,children:[r?(0,R.jsx)(pj,{}):null,`Save file`]})]})]})})}function oG({note:e,about:t,onTakeBack:n,busy:r}){let i=t?`about "${t.replace(/\s+/g,` `).trim().slice(0,50)}": ${e.text}`:e.text;return(0,R.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Lh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,R.jsx)(X,{label:`Take the note back`,icon:Dg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function sG({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,R.jsxs)(`li`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:s,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},className:n?`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-primary/30 bg-accent px-3 py-2.5 outline-none focus-visible:ring-3 focus-visible:ring-ring/40 max-md:min-h-11`:`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-border px-3 py-2.5 outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 max-md:min-h-11`,children:[(0,R.jsx)(`div`,{className:`flex gap-2`,children:(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(WH,{text:e.text})})}),r.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,R.jsx)(oG,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function cG({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,R.jsx)(qH,{title:`Notes on entries that changed`,right:String(e.length),children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,R.jsx)(oG,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function lG({view:e}){let t=e.entries.length;return(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[ZW[e.agent],` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,$W(e.chars),` chars`]}),e.over?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:eG(e.file)}):null]})}function uG({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Edit the entry`,text:`Edit`,icon:Vh,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,R.jsx)(X,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:Gh,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,R.jsx)(X,{label:`Comment on the entry`,text:`Comment`,icon:dh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,R.jsx)(X,{label:`Edit the whole file`,text:`Edit file`,icon:jm,shortcut:`F`,disabled:a,onClick:r}),(0,R.jsx)(SM,{icon:Cg,label:`Delete the entry`,text:`Delete`,shortcut:`Delete`,title:`Delete this entry?`,description:`The entry and its notes are removed. The version before is archived.`,confirmLabel:`Delete entry`,variant:`destructive`,disabled:a||!t,onConfirm:i})]})}function dG({agent:e,file:t,onChanged:n}){let r=xj(`knowledge.open`,{agent:e,file:t},[`knowledge`]),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=r.data?.view,p=f?.entries??[],h=p[Math.min(i,Math.max(0,p.length-1))],g=async e=>{d(!0),await e(),s(void 0),r.reload(),n(),d(!1)},_=e=>void g(()=>U(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>U(`knowledge.remove`,{agent:e,file:t,ref:tG(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:tG(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:tG(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:tG(h)}:{},text:n}))};return f?(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${ZW[e]} ${t}`,children:[(0,R.jsx)(uG,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,R.jsx)(lG,{view:f}),p.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,R.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,R.jsx)(sG,{entry:e,index:t,selected:t===i,notes:f.attached.filter(t=>t.entry===e.text),onPick:a,onTakeBack:_,busy:u},`${t}-${e.text}`))}),o?.kind===`edit`?(0,R.jsx)(iG,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,R.jsx)(WU,{label:`Comment on this entry`,hint:QW,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,R.jsx)(WU,{label:`Add an entry`,hint:QW,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{}),` saving…`]}):null,(0,R.jsx)(cG,{notes:f.detached,onTakeBack:_,busy:u}),(0,R.jsx)(aG,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>U(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function fG(e){return`${e.agent}/${e.file}`}var pG={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},mG=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function hG({info:e}){return(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(`span`,{children:$W(e.chars)}),e.over?(0,R.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,R.jsx)(`span`,{className:`text-primary`,children:mG(e.notes,`note`)}):null]})}function gG({info:e,selected:t,onSelect:n}){return(0,R.jsx)(`li`,{className:`ktree-leaf`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(fG(e)),className:q(MU,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5 max-md:min-h-11`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,R.jsx)(hG,{info:e})]})})}var _G=`bot-lobby.knowledge.folded`;function vG(){try{let e=JSON.parse(window.localStorage.getItem(_G)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function yG({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(vG),o=nG(e),s=e.reduce((e,t)=>e+t.notes,0);function c(e,t){a(n=>{let r=t?n.filter(t=>t!==e):[...new Set([...n,e])];try{window.localStorage.setItem(_G,JSON.stringify(r))}catch{}return r})}return(0,R.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,R.jsxs)(`p`,{className:`ktree-root`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,R.jsx)(Fp,{className:`size-4`})}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[mG(e.length,`file`),` · `,mG(o.length,`agent`),s>0?` · ${mG(s,`note`)}`:``]})]})]}),(0,R.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=pG[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,R.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":TW(o)},children:[(0,R.jsx)(`h3`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":a,"aria-controls":s,onClick:()=>c(e.agent,!a),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`h`?(t.preventDefault(),t.stopPropagation(),c(e.agent,!1)):(t.key===`ArrowRight`||t.key===`l`)&&(t.preventDefault(),t.stopPropagation(),a||c(e.agent,!0))},className:`ktree-node max-md:min-h-11`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,R.jsx)(bW,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:XW[e.agent]}),l?(0,R.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,R.jsxs)(`span`,{className:`text-primary`,children:[mG(e.notes,`note`),` · `]}):null,mG(e.files.length,`file`)]}),(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-snap`,a&&`rotate-90`)})]})}),(0,R.jsx)(Du,{initial:!1,children:a?(0,R.jsx)(B.ul,{id:s,"aria-label":`${XW[e.agent]}'s knowledge`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:520,damping:42},className:`ktree-leaves`,children:e.files.map(e=>(0,R.jsx)(gG,{info:e,selected:fG(e)===n,onSelect:r},fG(e)))},`files`):null})]},e.agent)})})]})}var bG=()=>aj(ij(`knowledge`)),xG=e=>{let[t,n]=e.split(`/`);aj(ij(`knowledge`,t??``,n??``))};function SG(){return(0,R.jsx)(sj,{className:`m-4 flex-1`,children:(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(Fp,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{children:`No knowledge files yet.`})]})})}function CG(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,R.jsx)(dG,{agent:i.agent,file:i.file,onChanged:r},fG(i)):t&&n?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function wG(){let e=sA(`lobby`),t=sA(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,R.jsx)(`p`,{className:`m-auto max-w-md px-5 pb-dock text-center text-sm text-muted-foreground`,children:`Ask about this project below. The oracle checks saved knowledge, searches the codebase for missing information, and saves verified findings.`}):(0,R.jsx)(KW,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function TG({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,R.jsx)(EG,{read:e,selected:t})]})}function EG({read:e,selected:t}){return!e.data&&e.error?(0,R.jsx)(yj,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,R.jsx)(yG,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:xG}):(0,R.jsx)(SG,{}):(0,R.jsx)(oM,{})}function DG({rest:e}){let{chat:t,agent:n,file:r}=qW(e),i=eM(),a=xj(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,R.jsx)(iM,{wide:i,inlineDetail:!0,list:(0,R.jsx)(TG,{read:a,selected:s?fG(s):void 0}),detail:t?(0,R.jsx)(wG,{}):CG(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:bG,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function OG(e){let t=e[0]===`board`,n=e[+!!t];try{return{board:t,id:n?decodeURIComponent(n):void 0}}catch{return{board:t,id:n}}}function kG({className:e,...t}){return(0,R.jsx)(yC,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:q(`peer relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-[5px] border border-input bg-background text-primary-foreground transition-colors duration-150 outline-none before:absolute before:-inset-3 before:content-[''] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary`,e),...t,children:(0,R.jsx)(xC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var AG=`Sessions`,jG=`No sessions yet.`,MG=`Up to 5 sessions; each can be assigned to one agent or several.`,NG=`A session is a live Excalidraw room that you and your agents draw in together.`,PG=[{title:`Start a live room`,text:`In Excalidraw: Share → Live collaboration → Start session.`},{title:`Add it here`,text:`Paste the room link, or make a new room and open it in Excalidraw.`},{title:`Assign agents`,text:`They read the board and draw on it, under their own name.`}],FG=`Sessions`,IG=`Pick a session on the left to see its link, its room and its agents.`,LG=`Room link`,RG=`Masked until revealed. A revealed link stays in this tab and is never saved.`,zG=`Room`,BG=`Drawing`,VG=`Last check`,HG=`not checked yet`,UG=`Add a session`,WG=`https://excalidraw.com/#room=…`,GG=`Optional name`;function KG(e){return`${e} of 5 in use`}var qG=`Agents may draw here.`,JG=`Agents may only look.`,YG=`checking the room…`,XG=`Check that the room can be reached.`,ZG=`Assigned to`,QG=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,$G=`Add or rename`,eK=`Add by link`,tK=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,nK=`New room`,rK=`Makes a fresh room link to open in Excalidraw; the name is optional.`,iK=`Rename`,aK=`draw`,oK=`look only`,sK=`Copied to the clipboard`,cK=`Could not reveal the link.`,lK=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],uK={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function dK(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function fK(e){return e?e.ok?`✓`:`!`:``}function pK({title:e,right:t,className:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,R.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function mK({row:e=!1}){return(0,R.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:PG.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function hK({label:e,hint:t,buttonLabel:n,placeholder:r,initial:i=``,required:a,mono:o,primary:s,onSubmit:c}){let l=(0,m.useId)(),[u,d]=(0,m.useState)(i),[f,p]=(0,m.useState)(!1),h=a&&!u.trim(),g=async()=>{h||f||(p(!0),await c(u)&&d(i),p(!1))};return(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,R.jsxs)(`div`,{className:`flex gap-2 max-md:flex-wrap`,children:[(0,R.jsx)(`input`,{id:l,value:u,maxLength:o?2e3:80,placeholder:r,"aria-describedby":t?`${l}-hint`:void 0,onChange:e=>d(e.target.value),className:q(`h-8 min-w-0 flex-1 rounded-lg border border-input bg-background px-3 text-sm outline-none transition-[border-color,box-shadow] placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 max-md:min-h-11`,o&&`font-mono text-[0.8125rem]`)}),(0,R.jsx)(X,{type:`submit`,label:n,icon:f?rh:Gh,tone:s?`primary`:`neutral`,shortcut:`Enter`,disabled:h||f,className:f?`[&_svg]:animate-spin`:void 0})]}),t?(0,R.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function gK({onChanged:e,primary:t}){return(0,R.jsx)(hK,{label:eK,hint:tK,buttonLabel:`Add`,placeholder:WG,required:!0,mono:!0,primary:t,onSubmit:async t=>await U(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function _K({onChanged:e,primary:t}){return(0,R.jsx)(hK,{label:nK,hint:rK,buttonLabel:`Create`,placeholder:GG,primary:t,onSubmit:async t=>{let n=t.trim();return await U(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function vK({onChanged:e,stacked:t=!1}){return(0,R.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,R.jsx)(gK,{onChanged:e,primary:!0}),(0,R.jsx)(_K,{onChanged:e,primary:!0})]})}function yK({session:e,onChanged:t}){return(0,R.jsx)(hK,{label:iK,initial:e.name,required:!0,buttonLabel:iK,onSubmit:async n=>await U(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function bK({icon:e,tone:t=`muted`,children:n}){return(0,R.jsxs)(`span`,{className:q(`inline-flex h-6 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium`,t===`primary`?`bg-accent text-primary`:t===`warning`?`bg-warning/10 text-warning`:`bg-muted text-muted-foreground`),children:[(0,R.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function xK({check:e,checking:t}){return t?(0,R.jsx)(bK,{icon:rh,children:YG}):e?e.ok?(0,R.jsx)(bK,{icon:rm,tone:`primary`,children:`reachable`}):(0,R.jsx)(bK,{icon:tm,tone:`warning`,children:`unreachable`}):(0,R.jsx)(bK,{icon:am,children:HG})}function SK({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] items-baseline gap-3 text-sm max-md:grid-cols-[minmax(5rem,6rem)_minmax(0,1fr)]`,children:[(0,R.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]})}function CK({check:e,checking:t}){return t?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`,"aria-hidden":`true`}),YG]}):e?(0,R.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:XG})}function wK({agent:e,on:t,onToggle:n}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(`flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-lg border px-2.5 text-sm transition-[background-color,border-color,color] max-md:min-h-11`,t?`border-primary/25 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(kG,{checked:t,onCheckedChange:()=>n(e)}),(0,R.jsx)(`span`,{className:`truncate`,children:uK[e]})]})})}function TK({session:e,onChanged:t}){let n=async n=>{await U(`excalidraw.toggleAgent`,{id:e.id,agent:n})&&t()},r=async()=>{await U(`excalidraw.toggleAll`,{id:e.id})&&t()},i=e.agents.length===lK.length;return(0,R.jsxs)(pK,{title:ZG,right:dK(e.agents.length),children:[(0,R.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:lK.map(t=>(0,R.jsx)(wK,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:QG}),(0,R.jsx)(X,{label:i?`Take every agent off`:`Assign every agent`,icon:$m,onClick:()=>void r()})]})]})}function EK({session:e,check:t,checking:n,onCheck:r,onChanged:i,onRemove:a}){let[o,s]=(0,m.useState)(),c=async()=>{try{s((await Te(`excalidraw.reveal`,{id:e.id})).link)}catch(e){H.error(e instanceof Error?e.message:cK)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>H(sK)).catch(()=>void 0),u=async()=>{await U(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,R.jsxs)(Gj,{children:[o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{label:`Copy the link`,text:`Copy`,icon:Cm,shortcut:`C`,onClick:l}),(0,R.jsx)(X,{label:`Open board`,icon:Dm,tone:`primary`,shortcut:`O`,href:o})]}):(0,R.jsx)(X,{label:`Reveal the link`,text:`Reveal`,icon:km,shortcut:`R`,onClick:()=>void c()}),(0,R.jsx)(X,{label:e.contribute?`Look only: agents stop drawing`:`Let agents draw`,text:e.contribute?`Look only`:`Let agents draw`,icon:e.contribute?zh:Vh,shortcut:`W`,pressed:e.contribute,onClick:()=>void u()}),(0,R.jsx)(X,{label:`Check the room`,text:`Check`,icon:n?rh:lg,shortcut:`T`,disabled:n,onClick:r}),(0,R.jsx)(SM,{icon:Cg,label:`Remove the session`,text:`Remove`,shortcut:`Delete`,title:`Remove "${e.name}"?`,description:`Agents lose this session at once; the Excalidraw room itself is not touched.`,confirmLabel:`Remove session`,variant:`destructive`,onConfirm:a})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(bK,{icon:e.contribute?Vh:km,tone:e.contribute?`primary`:`muted`,children:e.contribute?aK:oK}),(0,R.jsx)(bK,{icon:jg,children:dK(e.agents.length)}),(0,R.jsx)(xK,{check:t,checking:n})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,R.jsxs)(pK,{title:LG,children:[(0,R.jsx)(`p`,{className:`rounded-lg border border-border bg-muted px-3 py-2 font-mono text-[0.8125rem] break-all text-foreground`,children:o??e.masked}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:RG})]}),(0,R.jsx)(pK,{title:zG,children:(0,R.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(SK,{label:BG,children:(0,R.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?qG:JG})}),(0,R.jsx)(SK,{label:VG,children:(0,R.jsx)(CK,{check:t,checking:n})})]})})]}),(0,R.jsx)(TK,{session:e,onChanged:i})]}),(0,R.jsx)(pK,{title:$G,children:(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,R.jsx)(yK,{session:e,onChanged:i}),(0,R.jsx)(gK,{onChanged:i}),(0,R.jsx)(_K,{onChanged:i})]})})]})}function DK({check:e,checking:t}){if(t)return(0,R.jsx)(pj,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=fK(e);return n?(0,R.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,R.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function OK({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":r?`true`:void 0,onClick:()=>i(e.id),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(DK,{check:t,checking:n}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:dK(e.agents.length)})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,R.jsx)(jU,{variant:`secondary`,children:e.contribute?aK:oK})]})]})})}function kK({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(OK,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var AK=()=>aj(ij(`excalidraw`)),jK=e=>aj(ij(`excalidraw`,e));function MK({count:e}){return(0,R.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:KG(e)})]})}function NK({count:e,onChanged:t}){return(0,R.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:FG}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:IG})]}),(0,R.jsx)(MK,{count:e})]}),(0,R.jsx)(mK,{row:!0}),e<5?(0,R.jsx)(pK,{title:UG,children:(0,R.jsx)(vK,{onChanged:t})}):null,(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,R.jsx)(iA,{chord:`ArrowDown`,children:`next session`}),(0,R.jsx)(iA,{chord:`ArrowRight`,children:`into its detail`})]})]})}function PK({onChanged:e}){return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock md:px-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(Fh,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:jG}),(0,R.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:NG})]}),(0,R.jsx)(mK,{}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:MG})]}),(0,R.jsx)(pK,{title:UG,className:`self-start`,children:(0,R.jsx)(vK,{onChanged:e,stacked:!0})})]})})}function FK({id:e}){let t=eM(),n=xj(`excalidraw.list`,{},[`excalidraw`]),[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),s=n.data?.sessions??[],c=s.find(t=>t.id===e),l=async e=>{o(t=>[...t,e]);let t=await U(`excalidraw.check`,{id:e});o(t=>t.filter(t=>t!==e)),t&&i(n=>({...n,[e]:t}))},u=async()=>{c&&await U(`excalidraw.remove`,{id:c.id})&&(n.reload(),AK())};if(!n.data&&n.error)return(0,R.jsx)(yj,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,R.jsx)(PK,{onChanged:n.reload});let d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:AG,count:n.data?`${s.length}/5`:void 0}),n.data?(0,R.jsx)(kK,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:jK}):(0,R.jsx)(oM,{})]}),f=c?(0,R.jsx)(EK,{session:c,check:r[c.id],checking:a.includes(c.id),onCheck:()=>void l(c.id),onChanged:n.reload,onRemove:()=>void u()}):t&&n.data?(0,R.jsx)(NK,{count:s.length,onChanged:n.reload}):null;return(0,R.jsx)(iM,{wide:t,list:d,detail:f,open:c!==void 0,onClose:AK,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function IK(e,t){return e===`lobby.thinking`||t===`1`}var LK=`bot-lobby.collapsed.`,RK=new Set,zK=new Map;function BK(e){if(zK.has(e))return zK.get(e);if(e===`lobby.thinking`)return IK(e);try{return IK(e,localStorage.getItem(LK+e))}catch{return!1}}function VK(e,t){zK.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(LK+e,t?`1`:`0`)}catch{}for(let e of[...RK])e()}function HK(e){return RK.add(e),()=>{RK.delete(e)}}function UK(e){VK(e,!BK(e))}function WK(e){return[(0,m.useSyncExternalStore)(HK,()=>BK(e),()=>IK(e)),(0,m.useCallback)(()=>VK(e,!BK(e)),[e])]}function GK({entry:e}){return e.pending?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,R.jsx)(Vg,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,R.jsx)(Tg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function KK({entry:e}){return(0,R.jsxs)(`li`,{className:`grid grid-cols-[2.75rem_5rem_1rem_minmax(0,1fr)] items-baseline gap-x-2 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-muted`,children:[(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:lM(e.at)}),(0,R.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,CW(e.source)),children:SW(e.source)}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,R.jsx)(GK,{entry:e})}),(0,R.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,R.jsx)(`span`,{className:q(`min-w-0 break-words`,e.kind===`error`?`text-destructive`:e.pending?``:`text-muted-foreground`),children:e.pending?`${e.text}…`:e.text})]})}function qK({entries:e,collapsed:t,onToggle:n,shortcut:r,bare:i}){let a=e.slice(-400),o=a.filter(e=>e.pending).length,{ref:s,atBottom:c,stick:l,onScroll:u}=gW(JSON.stringify(a));return(0,R.jsxs)(GH,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,R.jsx)(`div`,{ref:s,onScroll:u,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-2 pt-2 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Activity`,tabIndex:0,children:a.length===0?(0,R.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,R.jsx)(`ul`,{children:a.map(e=>(0,R.jsx)(KK,{entry:e},e.id))})}),c?null:(0,R.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,R.jsx)(PW,{onClick:l})})]})}var JK=(e,t)=>e?.keys.find(e=>e.action===t)?.label,YK=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function XK({name:e,icon:t,shortcut:n,onClick:r}){return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Expand ${e}`,"aria-expanded":!1,"aria-keyshortcuts":n,onClick:r,className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`,children:(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(Tj,{side:`left`,children:[`Expand `,e,n?(0,R.jsx)(rA,{chord:n}):null]})]})}function ZK(e){let t=YK(e.status);return(0,R.jsx)(`aside`,{"aria-label":`Minimized panes`,className:`flex w-12 shrink-0 flex-col items-center gap-1 border-l border-border py-2`,children:t.activity&&e.activityFolded?(0,R.jsx)(XK,{name:`Activity`,icon:xp,shortcut:JK(e.status,`activity`),onClick:e.toggleActivity}):null})}function QK(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=YK(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,R.jsxs)(`div`,{className:q(`grid min-h-0 flex-1 gap-3 p-3`,s?`grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]`:`grid-cols-1`),children:[a.conversation?(0,R.jsx)(KW,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task}):null,o?(0,R.jsx)(qK,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:JK(n,`activity`)}):null]})}function $K(e){let{status:t}=e,n=YK(t).activity&&e.activityFolded;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,R.jsx)(QK,{...e})}),n?(0,R.jsx)(ZK,{...e}):null]})}function eq({data:e,status:t}){let n=YK(t),r=[...n.conversation?[{id:`conversation`,label:`Conversation`,icon:ph}]:[],...n.activity?[{id:`activity`,label:`Activity`,icon:xp}]:[]],[i,a]=(0,m.useState)(`conversation`),o=r.find(e=>e.id===i)??r[0],s=(e?.activity??[]).filter(e=>e.pending).length;return o?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Pane`,className:`flex shrink-0 items-center gap-0.5 border-b border-border px-3 py-2`,children:r.map(e=>{let t=e.id===o.id,n=e.icon;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>a(e.id),className:q(`inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2.5 text-[0.8125rem] font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40`,t?`btn-raised bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,R.jsx)(KW,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task}):null,o.id===`activity`?(0,R.jsx)(qK,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function tq(e){let t=eM();return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:t?(0,R.jsx)($K,{...e}):(0,R.jsx)(eq,{...e})})}function nq(){let e=sA(`lobby`),t=sA(`status`),[n,r]=WK(`lobby.activity`);return!e.data&&e.loading?(0,R.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{}),(0,R.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,R.jsx)(yj,{message:e.error,onRetry:()=>fe.onHello({})}):(0,R.jsx)(tq,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var rq=Jg([`relative flex flex-col bg-muted/50 gap-(--frame-gap) px-(--frame-px) py-(--frame-py) rounded-(--frame-radius)`,`[--frame-radius:var(--radius-xl)]`,`[--frame-gap:--spacing(0.75)] [--frame-px:--spacing(0.75)] [--frame-py:--spacing(0.75)] [--frame-panel-header-gap:0rem] [--frame-panel-footer-gap:--spacing(1)]`,`[--frame-panel-px-adjust:0px] [--frame-panel-py-adjust:0px] [--frame-panel-header-px-adjust:0px] [--frame-panel-header-py-adjust:0px] [--frame-panel-footer-px-adjust:0px] [--frame-panel-footer-py-adjust:0px]`,`[--frame-panel-px:calc(var(--frame-panel-px-base)+var(--frame-panel-px-adjust))] [--frame-panel-py:calc(var(--frame-panel-py-base)+var(--frame-panel-py-adjust))] [--frame-panel-header-px:calc(var(--frame-panel-header-px-base)+var(--frame-panel-header-px-adjust))] [--frame-panel-header-py:calc(var(--frame-panel-header-py-base)+var(--frame-panel-header-py-adjust))] [--frame-panel-footer-px:calc(var(--frame-panel-footer-px-base)+var(--frame-panel-footer-px-adjust))] [--frame-panel-footer-py:calc(var(--frame-panel-footer-py-base)+var(--frame-panel-footer-py-adjust))]`,``,`[--frame-panel-bg:var(--workspace-card)] [--frame-panel-border-color:var(--workspace-border)] [--frame-border-color:var(--workspace-border)]`,`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px)-1px)]`],{variants:{variant:{default:`border border-[var(--frame-border-color)] bg-clip-padding`,inverse:`[--frame-panel-bg:color-mix(in_oklch,var(--color-muted)_40%,transparent)] border border-[var(--frame-border-color)] bg-background bg-clip-padding`,ghost:`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px))]`},spacing:{xs:`[--frame-panel-px-base:--spacing(2)] [--frame-panel-py-base:--spacing(2)] [--frame-panel-header-px-base:--spacing(2)] [--frame-panel-header-py-base:--spacing(0.5)] [--frame-panel-footer-px-base:--spacing(2)] [--frame-panel-footer-py-base:--spacing(0.5)]`,sm:`[--frame-panel-px-base:--spacing(3)] [--frame-panel-py-base:--spacing(3.5)] [--frame-panel-header-px-base:--spacing(3)] [--frame-panel-header-py-base:--spacing(1.5)] [--frame-panel-footer-px-base:--spacing(3)] [--frame-panel-footer-py-base:--spacing(1.5)]`,default:`[--frame-panel-px-base:--spacing(4)] [--frame-panel-py-base:--spacing(4)] [--frame-panel-header-px-base:--spacing(4)] [--frame-panel-header-py-base:--spacing(2)] [--frame-panel-footer-px-base:--spacing(4)] [--frame-panel-footer-py-base:--spacing(2)]`,lg:`[--frame-panel-px-base:--spacing(5)] [--frame-panel-py-base:--spacing(5)] [--frame-panel-header-px-base:--spacing(5)] [--frame-panel-header-py-base:--spacing(2.5)] [--frame-panel-footer-px-base:--spacing(5)] [--frame-panel-footer-py-base:--spacing(2.5)]`},stacked:{true:[`gap-0 *:has-[+[data-slot=frame-panel]]:rounded-b-none`,`*:has-[+[data-slot=frame-panel]]:before:hidden`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:rounded-t-none`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:border-t-0`],false:[`data-[spacing=sm]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-0.5`,`data-[spacing=default]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-1`,`data-[spacing=lg]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-2`]},dense:{true:`p-0 gap-0 border-[var(--frame-border-color)] [--frame-panel-radius:var(--frame-radius)] [&_[data-slot=frame-panel]]:-mx-px [&_[data-slot=frame-panel]]:before:hidden [&_[data-slot=frame-panel]:last-child]:-mb-px [&:not(:has([data-slot=frame-panel-header]))_[data-slot=frame-panel]:is(:first-child)]:-mt-px`,false:``}},defaultVariants:{variant:`default`,spacing:`default`,stacked:!1,dense:!1}});function iq({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,R.jsx)(`div`,{className:q(rq({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function aq({className:e,fit:t,...n}){return(0,R.jsx)(`div`,{className:q(`relative overflow-hidden rounded-(--frame-panel-radius) border border-(--frame-panel-border-color) bg-(--frame-panel-bg) bg-clip-padding shadow-xs`,!t&&`grow`,`before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--frame-panel-radius)-1px)] before:shadow-black/5`,`dark:bg-clip-border dark:before:shadow-white/5`,`px-(--frame-panel-px) py-(--frame-panel-py)`,e),"data-slot":`frame-panel`,...n})}function oq({className:e,...t}){return(0,R.jsx)(`header`,{className:q(`flex flex-col gap-(--frame-panel-header-gap) px-(--frame-panel-header-px) py-(--frame-panel-header-py)`,e),"data-slot":`frame-panel-header`,...t})}var sq={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function cq(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e/1e3)):0,n=Math.floor(t/60);if(n===0)return`${t}s`;let r=t%60;return r===0?`${n}m`:`${n}m ${String(r).padStart(2,`0`)}s`}function lq(e){return e>0?cq(e):`—`}function uq(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function dq(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function fq(e){return!Number.isFinite(e)||e<1e3?String(Math.max(0,Math.round(e||0))):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}function pq(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function mq(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function hq(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function gq(e,t){let n=t===`model-kind`?sq[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var _q=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],vq={MASTER:`bg-primary`,ORACLE:`bg-primary`,DEV:`bg-source-dev`,DESIGN:`bg-source-design`,QA:`bg-source-qa`,RESEARCH:`bg-source-research`,"QUICK FIX":`bg-source-quickfix`};function yq(e){let t=vq[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%_q.length;return _q[n]??_q[0]}function bq(e){return sq[e]??e}var xq=6;function Sq({daily:e,cost:t}){let n=(0,m.useId)().replace(/:/g,``),r=xf(),[i,a]=(0,m.useState)(null),o=t?`Daily cost`:`Daily runs`,s=e.map(e=>t?e.cost:e.runs),c=Math.max(...s,t?.01:1),l=t?[0,c/2,c]:[...new Set([0,Math.ceil(c/2),c])],u=Date.parse(e[0]?.date??`1970-01-01`),d=Date.parse(e.at(-1)?.date??`1970-01-01`),f=Math.max(1,(d-u)/864e5),p=e=>52+(Date.parse(e)-u)/(f*864e5)*424,h=Math.max(.5,Math.min(28,424/(f+1)*.65)),g=e=>t?`$${e.toFixed(2)}`:String(Math.round(e)),_=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),v=[...new Set([e[0]?.date,e[Math.floor(e.length/2)]?.date,e.at(-1)?.date])].filter(e=>!!e);return(0,R.jsxs)(wq,{title:o,right:t?`USD · per day`:`all runs · successful runs`,children:[(0,R.jsx)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2 text-xs`,"aria-live":`polite`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:_(i.date)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t?g(i.cost):`${i.runs} runs · ${i.successes} successful`})]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Hover or focus a day to inspect it.`})}),(0,R.jsxs)(`svg`,{viewBox:`0 0 512 220`,className:`w-full overflow-visible`,role:`group`,"aria-label":o,children:[(0,R.jsx)(`defs`,{children:(0,R.jsxs)(`linearGradient`,{id:`${n}-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--primary)`,stopOpacity:`0.5`})]})}),l.map(e=>(0,R.jsxs)(`g`,{"aria-hidden":`true`,children:[(0,R.jsx)(`line`,{x1:`36`,x2:`494`,y1:180-e/c*144,y2:180-e/c*144,stroke:`var(--workspace-border)`,strokeDasharray:`3 5`,opacity:`0.6`}),(0,R.jsx)(`text`,{x:`29`,y:184-e/c*144,textAnchor:`end`,fill:`var(--muted-foreground)`,fontSize:`10`,children:g(e)})]},e)),e.map((e,o)=>{let s=(t?e.cost:e.runs)/c*144,l=u===d?264:p(e.date),f=`${e.date}: ${t?g(e.cost):`${e.runs} runs, ${e.successes} successful`}`;return(0,R.jsxs)(`g`,{role:`img`,"aria-label":f,tabIndex:0,className:`outline-none`,onFocus:()=>a(e),onBlur:()=>a(null),onPointerEnter:()=>a(e),onPointerLeave:()=>a(null),children:[(0,R.jsx)(`title`,{children:f}),(0,R.jsx)(`rect`,{x:l-Math.max(h,12)/2,y:`26`,width:Math.max(h,12),height:`156`,rx:`4`,fill:`var(--accent)`,opacity:+(i?.date===e.date)}),(0,R.jsx)(B.rect,{"data-trend-bar":!0,x:l-h/2,width:h,rx:`3`,fill:`url(#${n}-fill)`,initial:!r&&{height:0,y:180},animate:{height:s,y:180-s},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3),ease:[.22,1,.36,1]}}),t?null:(0,R.jsx)(B.rect,{x:l-h/2,width:h,rx:`3`,fill:`var(--success)`,initial:!r&&{height:0,y:180},animate:{height:e.successes/c*144,y:180-e.successes/c*144},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3)}})]},e.date)}),v.map(e=>(0,R.jsx)(`text`,{"aria-hidden":`true`,x:u===d?264:p(e),y:`205`,textAnchor:`middle`,fill:`var(--muted-foreground)`,fontSize:`11`,children:_(e)},e))]}),t?null:(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-primary`,"aria-hidden":`true`}),`All runs`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-success`,"aria-hidden":`true`}),`Successful`]})]})]})}function Cq({daily:e}){return(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(Sq,{daily:e}),(0,R.jsx)(Sq,{daily:e,cost:!0})]})}function wq({title:e,right:t,children:n}){return(0,R.jsxs)(iq,{role:`region`,className:`min-w-0`,"aria-label":e,children:[(0,R.jsx)(oq,{className:`py-2.5`,children:(0,R.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-semibold`,children:[(0,R.jsx)(`span`,{children:e}),t?(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]})}),(0,R.jsx)(aq,{className:`flex min-w-0 flex-col gap-3`,children:n})]})}function Tq({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,xq);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>xq?(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`h-6 self-start rounded-lg text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30`,children:n?`Show fewer`:`Show all ${e.length}`}):null]})}function Eq({width:e,className:t,title:n}){let r=xf();return(0,R.jsx)(B.div,{"data-chart-bar":!0,title:n,className:`h-full ${t}`,initial:!r&&{width:0},animate:{width:`${e}%`},transition:{duration:r?0:.7,ease:[.22,1,.36,1]}})}function Dq(e,t){return t>0?Math.max(1.5,e/t*100):0}function Oq({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,R.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,R.jsxs)(`div`,{className:`relative h-5 overflow-hidden rounded-md border border-border bg-muted chart-track`,role:`img`,"aria-label":`${e}: ${i}`,children:[(0,R.jsx)(Eq,{className:`rounded-r-md bg-linear-to-r from-primary/65 to-primary`,width:Dq(t,r)}),n?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-full bg-foreground/40`,style:{left:`${Math.min(99.5,Dq(n,r))}%`}}):null]})]})}function kq({groups:e,label:t}){let n=e.filter(e=>e.avgMs>0).sort((e,t)=>t.avgMs-e.avgMs),r=Math.max(...n.map(e=>Math.max(e.avgMs,e.p90Ms)),1);return(0,R.jsx)(wq,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsx)(Tq,{rows:n,render:e=>(0,R.jsx)(Oq,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:lq(e.avgMs),sub:`p90 ${lq(e.p90Ms)}`},t(e))})})}var Aq={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},jq={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function Mq({label:e,rate:t,runs:n}){let r=mq(t),i=`${Math.round(t*100)}%`;return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 ${jq[r.tone]}`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${Aq[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,R.jsxs)(`div`,{className:`flex h-5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`${e}: ${r.word}, ${i} of ${n} runs`,children:[(0,R.jsx)(Eq,{className:`bg-success/80`,width:t*100}),(0,R.jsx)(Eq,{className:`bg-destructive/60`,width:(1-t)*100})]})]})}function Nq({groups:e,label:t}){let n=e.filter(e=>e.runs>0).sort((e,t)=>e.successes/e.runs-t.successes/t.runs);return(0,R.jsx)(wq,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,R.jsx)(Tq,{rows:n,render:e=>(0,R.jsx)(Mq,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function Pq({share:e}){return(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${yq(e.agent)}`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`text-[0.8125rem]`,children:SW(e.agent)}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,R.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,cq(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function Fq({share:e}){return(0,R.jsx)(`div`,{className:`flex h-6 gap-0.5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`Share of run time by agent`,children:e.map(e=>(0,R.jsx)(Eq,{className:`${yq(e.agent)} opacity-85`,width:e.share*100,title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function Iq({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,R.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,R.jsx)(Tq,{rows:e,render:e=>(0,R.jsx)(Oq,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:cq(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function Lq({timeShare:e}){let t=e.byAgent;return(0,R.jsxs)(wq,{title:`Where the time goes`,right:`share of run time by agent`,children:[t.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(Fq,{share:t}),(0,R.jsx)(Pq,{share:t})]}),(0,R.jsx)(Iq,{times:e.taskTimes})]})}function Rq(e){return(0,R.jsx)(FD,{...e})}function zq(e){return(0,R.jsx)(zD,{"data-slot":`select-value`,...e})}function Bq({className:e,children:t,...n}){return(0,R.jsxs)(LD,{"data-slot":`select-trigger`,className:q(`reui-select flex h-9 min-w-36 items-center justify-between gap-3 rounded-lg border px-3 text-xs outline-none focus-visible:ring-3 focus-visible:ring-ring/30 disabled:opacity-50`,e),...n,children:[t,(0,R.jsx)(BD,{asChild:!0,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]})}function Vq({className:e,children:t,position:n=`popper`,align:r=`start`,...i}){return(0,R.jsx)(UD,{children:(0,R.jsxs)(GD,{"data-slot":`select-content`,position:n,align:r,sideOffset:4,className:q(`reui-menu z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) origin-(--radix-select-content-transform-origin) overflow-hidden rounded-xl border p-1 shadow-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 motion-reduce:animate-none`,e),...i,children:[(0,R.jsx)(hO,{className:`flex justify-center py-1`,children:(0,R.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})}),(0,R.jsx)(rO,{children:t}),(0,R.jsx)(_O,{className:`flex justify-center py-1`,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})})]})})}function Hq({className:e,children:t,...n}){return(0,R.jsxs)(lO,{"data-slot":`select-item`,className:q(`relative flex cursor-default items-center gap-2 rounded-lg py-2 pr-8 pl-3 text-xs outline-none select-none data-highlighted:bg-accent data-disabled:opacity-50`,e),...n,children:[(0,R.jsx)(dO,{children:t}),(0,R.jsx)(pO,{className:`absolute right-2`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`})})]})}function Uq({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`flex h-8 w-full rounded-lg border border-input bg-background px-3 py-1 text-base transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:disabled:bg-input/80`,e),...n})}var Wq=[{value:`all`,label:`All time`},{value:`today`,label:`Today`},{value:`week`,label:`Past 7 days`},{value:`range`,label:`Date range`}];function Gq(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Kq({onChange:e}){let[t,n]=(0,m.useState)(`all`),r=Gq(new Date),[i,a]=(0,m.useState)(r),[o,s]=(0,m.useState)(r),[c,l]=(0,m.useState)(``);function u(t){if(n(t),l(``),t===`all`)e({});else if(t===`range`)i&&o&&i<=o&&e({from:i,to:o});else{let n=new Date;t===`week`&&n.setDate(n.getDate()-6),e({from:Gq(n),to:r})}}return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Period`}),(0,R.jsxs)(Rq,{value:t,onValueChange:u,children:[(0,R.jsx)(Bq,{"aria-label":`Metrics period`,children:(0,R.jsx)(zq,{})}),(0,R.jsx)(Vq,{children:Wq.map(e=>(0,R.jsx)(Hq,{value:e.value,children:e.label},e.value))})]})]}),t===`range`?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-wrap items-end gap-2`,onSubmit:t=>{if(t.preventDefault(),!i||!o||i>o){l(`Choose an end date on or after the start date.`);return}l(``),e({from:i,to:o})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`Start date`,(0,R.jsx)(Uq,{type:`date`,required:!0,value:i,onChange:e=>a(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`End date`,(0,R.jsx)(Uq,{type:`date`,required:!0,value:o,onChange:e=>s(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsx)(Y,{type:`submit`,size:`sm`,className:`h-9`,children:`Apply`}),c?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:c}):null]}):null]})}function qq({label:e,value:t,sub:n}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var Jq=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Yq({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,R.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,R.jsx)(qq,{label:`Calls`,value:Jq(e.calls,`call`),sub:`${uq(e.ok,e.calls)} ok`}),(0,R.jsx)(qq,{label:`Speed`,value:`p50 ${pq(e.p50Ms)}`,sub:`p90 ${pq(e.p90Ms)}`}),(0,R.jsx)(qq,{label:`Read`,value:e.input>0?`${fq(e.input)} tokens`:`—`}),(0,R.jsx)(qq,{label:`Routed down`,value:e.routed>0?Jq(e.routed,`run`):`none`,sub:e.routed>0?`${uq(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,Jq(e.seatRunsSkipped,`seat run`),` skipped · `,Jq(e.questionsAnswered,`question`),` answered · `,Jq(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,R.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var Xq=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function Zq(e,t=0){return e>0?e.toFixed(t):`—`}function Qq(e){return[String(e.runs),uq(e.successes,e.runs),lq(e.avgMs),lq(e.p50Ms),lq(e.p90Ms),Zq(e.avgTurns,1),Zq(e.avgTools,1),e.avgTokens>0?fq(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,dq(e.avgCost),dq(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function $q(e,t){return t===`model-kind`?bq(e.kinds[0]??``):e.kinds.map(bq).join(`, `)}function eJ({groups:e,groupBy:t}){return(0,R.jsxs)(`section`,{className:`card-raised flex min-h-0 flex-col gap-2 overflow-hidden rounded-xl border pt-4`,"aria-label":`All models`,children:[(0,R.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,R.jsx)(`span`,{children:`All models`}),(0,R.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-auto outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,tabIndex:0,role:`region`,"aria-label":`All model metrics, scroll horizontally to see all columns`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),Xq.map(e=>(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,R.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:$q(e,t)||`—`}),Qq(e).map((e,t)=>(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},Xq[t]))]},gq(e,t)))})]})})]})}var tJ={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function nJ({label:e,value:t,sub:n,dot:r}){return(0,R.jsxs)(`div`,{className:`workspace-section flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-4 shadow-xs`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${tJ[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function rJ({tiles:e}){let t=mq(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-5 [&>:last-child]:col-span-2 sm:[&>:last-child]:col-span-1`,children:[(0,R.jsx)(nJ,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,R.jsx)(nJ,{label:`Success`,value:uq(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,R.jsx)(nJ,{label:`Avg run`,value:lq(e.avgMs),sub:`p90 ${lq(e.p90Ms)}`}),(0,R.jsx)(nJ,{label:`Cost`,value:dq(e.cost),sub:e.runs>0?`${dq(e.cost/e.runs)} per run`:`—`}),(0,R.jsx)(nJ,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${cq(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var iJ=`No runs recorded yet. Every Master turn, subagent run, quick fix and planning round lands here with its model, thinking level, time, tokens and cost.`;function aJ({groupBy:e,onGroup:t}){return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group by`,className:`flex max-w-full flex-wrap gap-0.5 rounded-lg bg-muted p-0.5`,onKeyDown:n=>{let r=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!r)return;n.preventDefault();let i=[`model`,`model-kind`],a=i[(i.indexOf(e)+r+i.length)%i.length];t(a),requestAnimationFrame(()=>n.currentTarget.querySelector(`[aria-checked='true']`)?.focus())},children:[`model`,`model-kind`].map(n=>(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,role:`radio`,tabIndex:e===n?0:-1,className:e===n?`bg-card text-foreground shadow-card hover:bg-card`:`text-muted-foreground`,"aria-checked":e===n,onClick:()=>t(n),children:hq(n)},n))})}function oJ({query:e,onQuery:t}){return(0,R.jsxs)(`label`,{className:`relative flex max-w-full items-center`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,R.jsx)(ag,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{id:`metrics-search`,type:`search`,value:e,maxLength:500,placeholder:`Search runs: model, agent, tool…`,onChange:e=>t(e.target.value),className:`h-8 w-64 max-w-full rounded-lg border border-input bg-background pr-9 pl-8 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`}),(0,R.jsx)(rA,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function sJ({data:e,groupBy:t,query:n}){let r=e=>gq(e,t);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(rJ,{tiles:e.tiles}),e.tiles.runs===0?(0,R.jsx)(`p`,{className:`card-raised rounded-xl border p-4 text-sm text-muted-foreground`,children:n?`No run matches "${n}" in this period.`:`No runs in this period. ${iJ}`}):null,e.daily.length>0?(0,R.jsx)(Cq,{daily:e.daily}):null,e.classifier?(0,R.jsx)(Yq,{summary:e.classifier}):null,e.tiles.runs>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(kq,{groups:e.groups,label:r}),(0,R.jsx)(Nq,{groups:e.groups,label:r})]}),(0,R.jsx)(eJ,{groups:e.groups,groupBy:t})]}):null,e.tiles.runs>0||e.timeShare.taskTimes.length>0?(0,R.jsx)(Lq,{timeShare:e.timeShare}):null]})}function cJ(){return(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,role:`status`,"aria-label":`Loading metrics`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function lJ(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)({}),o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=xj(`metrics.get`,{groupBy:e,query:n,...i,timeZone:o},[`metrics`]);return!s.data&&s.error?(0,R.jsx)(yj,{message:`Could not load metrics. ${s.error}`,onRetry:s.reload}):(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Daily trends and model performance`})]}),s.loading&&s.data?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`})]}),(0,R.jsxs)(`section`,{"aria-label":`Metrics filters`,className:`workspace-section flex flex-wrap items-end gap-4 rounded-xl border p-4`,children:[(0,R.jsx)(Kq,{onChange:a}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-end gap-3 lg:w-auto lg:flex-1 lg:justify-end`,children:[(0,R.jsx)(aJ,{groupBy:e,onGroup:t}),(0,R.jsx)(oJ,{query:n,onQuery:r})]}),(0,R.jsxs)(`p`,{className:`w-full text-xs text-muted-foreground`,children:[i.from?`${i.from} – ${i.to}`:`All recorded dates`,` · `,o,`. Runs and active tasks use their start date; completed tasks use their completion date.`]})]}),s.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not refresh metrics. `,s.error]}):null,(0,R.jsx)(`div`,{"aria-busy":s.loading,className:s.loading&&s.data?`opacity-60`:void 0,children:s.data?(0,R.jsx)(sJ,{data:s.data,groupBy:e,query:n},JSON.stringify([s.data,e])):(0,R.jsx)(cJ,{})})]})}var uJ=class{seen=new Set;initialized=new Set;storage;constructor(e){this.storage=e;try{let t=JSON.parse(e?.getItem(`bot-lobby.prompt-seen`)??`[]`);Array.isArray(t)&&(this.seen=new Set(t.filter(e=>typeof e==`string`)))}catch{}}observe(e,t,n=!1){let r=this.initialized.has(e)&&!n?t.filter(e=>!this.seen.has(e)):[];this.initialized.add(e);for(let e of t)this.seen.add(e);try{this.storage?.setItem(`bot-lobby.prompt-seen`,JSON.stringify([...this.seen]))}catch{}return r}};function dJ(e,t){return JSON.stringify([e,`prompt`,t])}function fJ(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function pJ(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var mJ=`bot-lobby.prompt-sound-muted`,hJ=new Set,gJ,_J=!1;function vJ(){try{return localStorage.getItem(mJ)===`on`}catch{return _J}}function yJ(e){_J=e;try{localStorage.setItem(mJ,e?`on`:`off`)}catch{}for(let e of hJ)e()}function bJ(e){return hJ.add(e),()=>{hJ.delete(e)}}function xJ(){return(0,m.useSyncExternalStore)(bJ,vJ,()=>!1)}function SJ(){(0,m.useEffect)(()=>{let e=()=>{try{gJ??=new AudioContext,gJ.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function CJ(){if(!vJ()&&gJ&&gJ.state===`running`)try{let e=gJ.currentTime,t=gJ.createOscillator(),n=gJ.createGain();t.frequency.setValueAtTime(960,e),t.frequency.exponentialRampToValueAtTime(360,e+.16),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.12,e+.012),n.gain.exponentialRampToValueAtTime(1e-4,e+.22),t.connect(n),n.connect(gJ.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}function wJ(){if(!vJ()&&gJ&&gJ.state===`running`)try{let e=gJ.currentTime,t=gJ.createOscillator(),n=gJ.createGain();t.frequency.setValueAtTime(1500,e),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.045,e+.004),n.gain.exponentialRampToValueAtTime(1e-4,e+.028),t.connect(n),n.connect(gJ.destination),t.start(e),t.stop(e+.03),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var TJ=`bot-lobby.notifications`,EJ=`/icon-192.png`,DJ=new Set;function OJ(){for(let e of[...DJ])e()}function kJ(){try{return localStorage.getItem(TJ)===`on`}catch{return!1}}function AJ(e){return DJ.add(e),()=>{DJ.delete(e)}}function jJ(e){try{localStorage.setItem(TJ,e?`on`:`off`)}catch{}OJ()}function MJ(){return(0,m.useSyncExternalStore)(AJ,kJ,()=>!1)}async function NJ(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(jJ(!0),`granted`):`denied`)}function PJ(){jJ(!1)}function FJ(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function IJ(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function LJ(e){try{new Notification(`bot-lobby`,{body:e,icon:EJ,tag:`bot-lobby`})}catch{}}function RJ(){try{return new uJ(sessionStorage)}catch{return new uJ}}function zJ(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?fJ(e,t.sessionId??n.key??t.from,n.dialog.id):dJ(e,t.id)}function BJ(){let e=MJ();SJ(),aA();let t=xj(`tasks.list`,{},[`tasks`]),n=xj(`sessions.list`,{},[`sessions`]),r=fe.get(`prompts`),i=fe.get(`lobby`).data,a=(0,m.useRef)(RJ()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=P()??`current`,l=fe.status().connection;return{enabled:e,tasks:t,sessions:n,prompts:r,lobby:i,seen:a,quiet:o,previousState:s,project:c,connection:l,lastConnection:(0,m.useRef)(l)}}function VJ(e,t,n,r,i){if(!i)return;let{seen:a,project:o,quiet:s,enabled:c}=e,l=a.current.observe(`${o}:${t}`,n,s.current.has(t));s.current.delete(t),l.length&&(l.forEach(()=>CJ()),c&&IJ()&&LJ(r),t===`delivery`&&H.info(r,{action:{label:`Review tasks`,onClick:()=>aj(`#/tasks`)}}))}function HJ(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;VJ(e,`prompts`,(a??[]).map(e=>zJ(i,e)),`A question is waiting for you.`,!!a&&!t.loading),VJ(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>fJ(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),VJ(e,`delivery`,r.data?.rows.filter(e=>e.delivery&&(e.delivery.status===`pending_approval`||e.delivery.status===`deferred`||e.delivery.status===`recoverable_failure`)).map(e=>pJ(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function UJ(e){let{lastConnection:t,connection:n,quiet:r,previousState:i,lobby:a,enabled:o}=e;if(t.current!==n||n!==`live`){t.current=n,r.current=new Set([`prompts`,`sessions`,`delivery`]),i.current=void 0;return}HJ(e);let s=a?.task?.state??``,c=FJ(s);i.current&&c&&s!==i.current&&o&&IJ()&&LJ(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function WJ(){let e=BJ(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>UJ(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function GJ({className:e,thumbClassName:t,...n}){return(0,R.jsx)(IO,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:q(`peer relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors duration-150 outline-none before:absolute before:-inset-x-2 before:-inset-y-3 before:content-[''] focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,R.jsx)(RO,{"data-slot":`switch-thumb`,className:q(`pointer-events-none block size-4 rounded-full bg-white shadow-sm ring-0 transition-transform duration-200 ease-snap data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`,t)})})}var KJ=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],qJ=`M32 17 C28 10 19 12 17 19 C10 19 7 26 10 32 C5 38 9 46 15 47 C16 54 25 56 32 50 C39 56 48 54 49 47 C55 46 59 38 54 32 C57 26 54 19 47 19 C45 12 36 10 32 17Z`,JJ=`M32 17 C28 12 21 12 18 19 C12 19 9 25 11 31 C7 36 9 44 15 46 C16 53 26 55 32 50 C38 55 48 53 49 46 C55 44 57 36 53 31 C55 25 52 19 46 19 C43 12 36 12 32 17Z`,YJ=[`M19 22 C16 25 17 29 22 29 C27 29 28 33 25 36`,`M12 35 C16 32 20 35 18 39 C16 43 20 47 24 45`,`M25 17 C22 20 26 22 28 22 C31 23 29 27 26 27`,`M11 42 C13 44 16 42 15 39 M22 49 C26 49 29 45 27 41`,`M15 25 C12 27 14 31 17 31 M21 32 C22 35 20 37 22 39 C24 41 28 38 29 35`,`M20 18 C22 18 23 20 21 22 M24 24 C21 23 20 25 21 27 M12 37 C14 36 16 38 15 40 M20 43 C23 44 25 42 24 40 M28 29 C30 30 30 32 28 33`];function XJ({level:e,className:t}){let n=xf(),r=Math.max(0,KJ.indexOf(e)),i=[0,1,2,2,3,4,6][r],a=r===KJ.length-1,o=`brain-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,R.jsxs)(`svg`,{viewBox:`0 0 64 72`,"data-slot":`effort-mascot`,"data-level":e,"data-folds":i*2,"data-elevated":a||void 0,"aria-hidden":`true`,focusable:`false`,className:q(`size-16 shrink-0 overflow-visible`,t),children:[(0,R.jsxs)(`defs`,{children:[(0,R.jsxs)(`linearGradient`,{id:`${o}-ink`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:a?`var(--rainbow-5)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:a?`var(--rainbow-6)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:a?`var(--rainbow-7)`:`var(--primary)`})]}),(0,R.jsxs)(`radialGradient`,{id:`${o}-halo`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--rainbow-6)`,stopOpacity:`0.38`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:`var(--rainbow-7)`,stopOpacity:`0.18`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-5)`,stopOpacity:`0`})]}),(0,R.jsxs)(`linearGradient`,{id:`${o}-shine`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--card)`,stopOpacity:`0`}),(0,R.jsx)(`stop`,{offset:`0.5`,stopColor:`var(--primary)`,stopOpacity:`0.6`}),(0,R.jsx)(`stop`,{offset:`0.6`,stopColor:`var(--card)`,stopOpacity:`0.9`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--card)`,stopOpacity:`0`})]}),(0,R.jsxs)(`filter`,{id:`${o}-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:[(0,R.jsx)(`feGaussianBlur`,{stdDeviation:`1.4`}),(0,R.jsxs)(`feMerge`,{children:[(0,R.jsx)(`feMergeNode`,{}),(0,R.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,R.jsx)(`clipPath`,{id:`${o}-silhouette`,children:(0,R.jsx)(`path`,{d:qJ})}),(0,R.jsx)(`pattern`,{id:`${o}-hologram`,width:`4`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,R.jsx)(`path`,{d:`M0 1.5H4`,stroke:`var(--rainbow-5)`,strokeWidth:`0.4`,opacity:`0.4`})})]}),(0,R.jsx)(`ellipse`,{cx:`32`,cy:`63`,rx:a?14:19,ry:`2.5`,className:`fill-primary/10`}),a?(0,R.jsx)(B.circle,{"data-brain-halo":!0,cx:`32`,cy:`32`,r:`33`,fill:`url(#${o}-halo)`,initial:!1,animate:{opacity:n?.8:[.65,1,.65]},transition:{duration:n?0:3,repeat:n?0:1/0}}):null,(0,R.jsxs)(B.g,{"data-brain-body":!0,initial:!1,animate:{y:a?n?-5:[-5,-7,-5]:0},transition:{duration:n?0:a?3:.3,repeat:a&&!n?1/0:0,ease:`easeInOut`},stroke:`url(#${o}-ink)`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,filter:a?`url(#${o}-glow)`:void 0,children:[a?[`cyan`,`magenta`].map(e=>(0,R.jsx)(`use`,{href:`#${o}-shape`,"data-brain-phase":e,className:`brain-phase-echo`,stroke:`currentColor`},e)):null,(0,R.jsxs)(`g`,{id:`${o}-shape`,"data-brain-shape":!0,className:`brain-shape`,children:[(0,R.jsx)(`path`,{d:`M30 49 L30 56 Q32 59 35 57 L35 51`,className:`fill-primary/15`}),(0,R.jsx)(`path`,{d:r<=3?JJ:qJ,className:r===0?`fill-muted`:r<=3?`fill-primary/15`:`fill-primary/10`}),(0,R.jsx)(`path`,{d:`M32 17 C29 24 34 28 32 34 C30 40 34 45 32 50`,fill:`none`,opacity:r===0?.35:.8}),[!1,!0].map(e=>(0,R.jsx)(`g`,{transform:e?`translate(64 0) scale(-1 1)`:void 0,fill:`none`,children:YJ.slice(0,i).map((e,t)=>(0,R.jsx)(B.path,{"data-brain-fold":!0,d:e,initial:!n&&{opacity:0,pathLength:0},animate:{opacity:.85,pathLength:1},transition:{duration:n?0:.3,delay:n?0:t*.025}},e))},String(e))),r>0&&r<5?(0,R.jsx)(`g`,{stroke:`none`,fill:`var(--primary)`,children:[[20,27],[43,36],[25,44]].slice(0,Math.min(r,3)).map(([e,t],n)=>(0,R.jsx)(`circle`,{cx:e,cy:t,r:`1.4`,className:`brain-spark`,style:{animationDelay:`${n*-.7}s`}},e))}):null,r>=5?(0,R.jsx)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:(0,R.jsx)(`rect`,{"data-brain-shimmer":!0,className:`brain-shimmer`,x:`-24`,y:`10`,width:`18`,height:`48`,fill:`url(#${o}-shine)`})}):null]}),a?(0,R.jsxs)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:[(0,R.jsx)(`path`,{d:qJ,fill:`url(#${o}-hologram)`}),(0,R.jsx)(`rect`,{"data-brain-scan":!0,className:`brain-phase-scan`,x:`7`,y:`14`,width:`50`,height:`2`,fill:`var(--rainbow-5)`,opacity:`0.45`})]}):null]}),a?(0,R.jsx)(`g`,{fill:`url(#${o}-ink)`,children:[[8,14],[56,12],[5,49],[58,46]].map(([e,t])=>(0,R.jsx)(`path`,{d:`M0 -3 L0.8 -0.8 L3 0 L0.8 0.8 L0 3 L-0.8 0.8 L-3 0 L-0.8 -0.8Z`,transform:`translate(${e} ${t})`},e))}):null]})}var ZJ={minimal:`min`,medium:`med`},QJ={off:`No extra reasoning: the quickest, cheapest answer.`,minimal:`A moment of reasoning, barely.`,low:`Light reasoning for simple work.`,medium:`Balanced reasoning for most work.`,high:`Careful reasoning: slower, better on hard problems.`,xhigh:`Very deep reasoning: slow and costly.`,max:`As deep as the model goes.`};function $J(e,t,n){let r=-1;for(let i=0;i<e.length;i+=1)t.includes(e[i])&&(r<0||Math.abs(i-n)<Math.abs(r-n))&&(r=i);return r}function eY(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.includes(e[i]))return i;return n}function tY({value:e,levels:t,supported:n,model:r,label:i,disabled:a,onChange:o}){let s=(0,m.useRef)(null),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),f=(0,m.useRef)(void 0),p=(0,m.useRef)(0),h=(0,m.useCallback)(()=>{f.current=void 0,p.current=0,d(void 0)},[]),g=Math.max(t.length-1,1),_=$J(t,n,Math.max(0,t.indexOf(e))),v=c??u??_,y=v<0?0:v/g*100,b=t[v]??e,x=v>=0&&b!==e;(0,m.useEffect)(()=>{if(u===void 0)return;let e=window.setTimeout(h,1e4);return()=>window.clearTimeout(e)},[u,h]);let S=(0,m.useCallback)(e=>{let r=s.current?.getBoundingClientRect();if(!r||r.width===0)return _;let i=Math.min(1,Math.max(0,(e-r.left)/r.width));return $J(t,n,Math.round(i*g))},[g,t,_,n]);function C(e){a||n.length===0||(e.currentTarget.setPointerCapture(e.pointerId),l(S(e.clientX)))}function w(e){if(c===void 0)return;let t=S(e.clientX);t!==c&&l(t)}function T(){if(c===void 0)return;let n=t[c];l(void 0),n&&n!==e&&o(n)}function E(e){if(a||v<0)return;let r=f.current??v,i={ArrowRight:eY(t,n,r,1),ArrowUp:eY(t,n,r,1),ArrowLeft:eY(t,n,r,-1),ArrowDown:eY(t,n,r,-1),Home:$J(t,n,0),End:$J(t,n,g)}[e.key];if(i===void 0)return;e.preventDefault();let s=t[i];s&&i!==r&&(f.current=i,d(i),p.current+=1,Promise.resolve(o(s)).catch(()=>void 0).then(()=>{--p.current,p.current<=0&&h()}))}return(0,R.jsxs)(`div`,{className:q(`flex min-w-0 flex-col items-center gap-3 min-[360px]:flex-row`,a&&`opacity-60`),children:[(0,R.jsx)(XJ,{level:b}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:QJ[b]??``})]}),(0,R.jsxs)(`div`,{ref:s,role:`slider`,tabIndex:a?-1:0,"aria-label":i,"aria-valuemin":0,"aria-valuemax":t.length-1,"aria-valuenow":Math.max(v,0),"aria-valuetext":b,"aria-disabled":a||void 0,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:()=>l(void 0),onKeyDown:E,className:`relative mx-2.5 h-6 touch-none cursor-pointer rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-muted`}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:`absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-primary`,animate:{width:`${y}%`},transition:{type:`spring`,stiffness:520,damping:34}}),t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,title:i?e:`${r??`This model`} does not support ${e}`,className:q(`absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full`,i?t<=v?`bg-primary-foreground/80`:`bg-muted-foreground/40`:`bg-transparent ring-1 ring-muted-foreground/30`),style:{left:`${t/g*100}%`}},e)}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:q(`absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm`,c!==void 0&&`scale-110`),animate:{left:`${y}%`},transition:{type:`spring`,stiffness:520,damping:28}})]}),(0,R.jsx)(`div`,{className:`relative mx-2.5 h-3.5 text-[0.68rem] text-muted-foreground`,"aria-hidden":`true`,children:t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{title:i?void 0:`${r??`This model`} does not support ${e}`,className:q(`absolute -translate-x-1/2 whitespace-nowrap`,t===v&&`font-medium text-foreground`,!i&&`opacity-40`),style:{left:`${t/g*100}%`},children:ZJ[e]??e},e)})}),x?(0,R.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})]})}function nY(e){return(0,R.jsx)(hD,{...e})}function rY(e){return(0,R.jsx)(gD,{"data-slot":`popover-trigger`,...e})}function iY({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,R.jsx)(_D,{children:(0,R.jsx)(vD,{"data-slot":`popover-content`,align:t,sideOffset:n,className:q(`reui-menu z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-xl border p-1 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 motion-reduce:animate-none`,e),...r})})}function aY(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function oY({value:e,options:t,onChange:n,label:r,className:i,disabled:a}){let[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),p=(0,m.useId)(),h=(0,m.useMemo)(()=>t.filter(e=>aY(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(Math.max(0,t.findIndex(t=>t.value===e))))},[o]),(0,m.useEffect)(()=>{c&&d(0)},[c]),(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function _(t){t&&(s(!1),t.value!==e&&n(t.value))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(h.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(0,e-1))):e.key===`Home`&&!c?(e.preventDefault(),d(0)):e.key===`End`&&!c?(e.preventDefault(),d(Math.max(0,h.length-1))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_(h[u]))}return(0,R.jsxs)(nY,{open:o,onOpenChange:s,children:[(0,R.jsxs)(rY,{type:`button`,role:`combobox`,"aria-label":r,"aria-keyshortcuts":`Enter Space ArrowDown ArrowUp`,"aria-description":`When focused, press Enter, Space or an arrow key to choose. Type to search.`,"aria-expanded":o,"aria-haspopup":`listbox`,"aria-controls":o?p:void 0,disabled:a,onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),s(!0))},"data-slot":`select-trigger`,className:q(`reui-select flex h-8 w-full min-w-0 items-center justify-between gap-2 overflow-hidden rounded-lg border bg-card px-2.5 text-[0.8125rem] whitespace-nowrap outline-none transition-[border-color,box-shadow] duration-150 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50`,i),children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(iY,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`p-0 flex max-h-[min(20rem,var(--radix-popover-content-available-height))] w-[max(var(--radix-popover-trigger-width),17rem)] max-w-(--radix-popover-content-available-width) flex-col overflow-hidden rounded-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,R.jsx)(ag,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,role:`searchbox`,"aria-label":`Search ${r}`,"aria-controls":p,"aria-activedescendant":h[u]?`${p}-${u}`:void 0,placeholder:`Search…`,autoComplete:`off`,spellCheck:!1,className:`h-8 min-w-0 flex-1 bg-transparent text-[0.8125rem] outline-none placeholder:text-muted-foreground`})]}),(0,R.jsxs)(`div`,{ref:f,id:p,role:`listbox`,"aria-label":r,className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[h.length===0?(0,R.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,R.jsxs)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"data-index":n,onPointerMove:()=>d(n),onClick:()=>_(t),className:q(`flex cursor-default items-center gap-2 rounded-lg px-2.5 py-1.5 text-[0.8125rem] select-none`,n===u&&`bg-accent`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,R.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})]})}function sY({label:e,help:t,children:n,stacked:r}){return(0,R.jsxs)(`div`,{className:r?`grid gap-1.5`:`grid gap-1.5 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)] md:items-center md:gap-6`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,R.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,R.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,R.jsx)(`div`,{className:`min-w-0`,children:n})]})}function cY({children:e}){return(0,R.jsx)(iq,{dense:!0,children:(0,R.jsx)(aq,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-3`,children:e})})}function lY({value:e,items:t,label:n,onChange:r}){return(0,R.jsx)(oY,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r,className:`max-md:h-auto max-md:min-h-11 max-md:items-start max-md:py-2 max-md:[&>span:first-child]:overflow-visible max-md:[&>span:first-child]:text-clip max-md:[&>span:first-child]:whitespace-normal max-md:[&>span:first-child]:break-words`})}var uY=`(prefers-color-scheme: dark)`,dY=[`dark`,`light`,`system`],fY=m.createContext(void 0);function pY(e){return e!==null&&dY.includes(e)}function mY(){return window.matchMedia(uY).matches?`dark`:`light`}function hY(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.remove()})})}}function gY(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function _Y({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return pY(e)?e:t}),s=m.useCallback(e=>{localStorage.setItem(n,e),o(e)},[n]),c=m.useCallback(e=>{let t=document.documentElement,n=e===`system`?mY():e,i=r?hY():null;t.classList.remove(`light`,`dark`),t.classList.add(n),i&&i()},[r]);m.useEffect(()=>{if(c(a),a!==`system`)return;let e=window.matchMedia(uY),t=()=>{c(`system`)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},[a,c]),m.useEffect(()=>{let e=e=>{e.repeat||e.metaKey||e.ctrlKey||e.altKey||gY(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:mY()===`dark`?`light`:`dark`;return localStorage.setItem(n,t),t})};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),m.useEffect(()=>{let e=e=>{if(e.storageArea===localStorage&&e.key===n){if(pY(e.newValue)){o(e.newValue);return}o(t)}};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[t,n]);let l=m.useMemo(()=>({theme:a,setTheme:s}),[a,s]);return(0,R.jsx)(fY.Provider,{...i,value:l,children:e})}var vY=()=>{let e=m.useContext(fY);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},yY=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],bY={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},xY={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},SY=`inherit`,CY=`inherit`,wY=`Use the session's current model`,TY=`__custom__`,EY=`custom…`,DY=`Type a provider/model id`,OY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],kY={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},AY=[{id:`startOn`,label:`On when pi starts`,help:`off: pi starts as plain pi, and ctrl+shift+m or /bot-lobby on turns bot-lobby on (a session that owns a task under way always starts on)`},{id:`issues`,label:`Issues tab`,help:`the GitHub Issues tab`}],jY=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],MY=`shown on the Lobby tab`,NY=`Planning rounds`,PY=`how many rounds the panel gets before the oracle settles the rest alone`,FY=[2,3,5,8,0],IY=`Split long plans`,LY=`saving a plan with more steps offers to split it into up to 5 tasks`,RY=[6,8,10,12,0],zY=`Port`,BY=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,VY=`Open browser`,HY=`open this page in the browser when pi starts`,UY=[{id:`off`,label:`off`,help:`tasks work in the folder you started them in`},{id:`branch`,label:`branch`,help:`each new task gets a git branch named after it, checked out in the working folder`},{id:`worktree`,label:`worktree`,help:`each new task gets its own worktree and branch, named after it: every agent runs there, apart from your checkout`}],WY=`Git isolation`,GY=[{id:`off`,label:`off`,help:`agents' work is never linted`},{id:`advise`,label:`advise`,help:`the oracle and QA are told what the project's linter finds on the lines a task changed; nothing is held`},{id:`block`,label:`block`,help:`new lint errors also hold a task's completion until they are fixed, or you accept the work as it is`}],KY={intro:`After every worker step, before QA and at completion, bot-lobby lints only the files the task's agents touched. Problems on the lines the task changed are the task's; anything already there is shown but never holds it. Suppressions and lint-config changes the task adds go to QA to judge.`,mode:`Lint gate`,command:`Command`,commandHelp:`empty runs the linters the project configures (ESLint, Biome, Oxlint, Ruff), each from its own folder; a command runs without a shell from the repository's top, with {files} standing for the touched files`,commandPlaceholder:`found from the project`,extensions:`File types`,extensionsHelp:`which touched files the command is given, such as .ts .tsx .py`,extensionsPlaceholder:`every touched file`,timeout:`Time limit`,timeoutHelp:`for one linter run; one that runs over reads as could not run, and holds nothing`,found:`Found in this project`,foundHelp:`config files in the project and the folders a few levels below it`,foundNone:`No linter config found. Add one to the project, or set a command above.`,foundReplaced:`The command replaces these.`,installed:`installed`,missing:`not installed`,missingHelp:`install the project's dependencies there, or lint cannot run`,top:`project root`},qY=[{id:`auto`,label:`Auto (OpenCode's free Jev, else TypeSafe)`},{id:`opencode`,label:`OpenCode Zen`},{id:`typesafe`,label:`TypeSafe`},{id:`openrouter`,label:`OpenRouter`},{id:`vercel`,label:`Vercel AI Gateway`}],JY=[{id:`seats`,label:`Planning seats`,help:`each round, only the seats your idea or latest answers touch sit; 1-4 in the Plan tab pins one`},{id:`answers`,label:`Obvious answers`,help:`a panel question whose recommended option the conversation already makes clearly right is answered for you (listed under Assumptions)`},{id:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints; a quick fix that is really a task is held for you`},{id:`effort`,label:`Effort routing`,help:`a simple step runs one thinking level lower, a trivial one on the cheaper model below; a routed run that falls short runs again on your settings`},{id:`qa`,label:`QA risk`,help:`once a task's work is in, Jev reads the diff and sizes QA to it: no QA agent for a change with nothing that runs, a light check for a small one, deep review where a defect would spread; with it off the engine's rules decide`},{id:`review`,label:`Pull request read`,help:`the Git tab's quick read of a pull request: its size, and how likely it is risky, security-relevant, breaking or untested, before an agent reviews it`},{id:`knowledge`,label:`Relevant knowledge`,help:`when an agent's knowledge, standards or decisions file is too long for its prompt, Jev picks the sections that bear on the step, and the agent is told where the rest is`},{id:`scripts`,label:`Shared scripts`,help:`Jev matches each step to the shared scripts that do part of it, and the agent is told to run them instead of redoing the work`},{id:`files`,label:`File hints`,help:`scouts, workers, quick fixes and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],YY={enabled:`Classifier`,enabledHelp:`Jev makes the obvious decisions so large models spend fewer tokens on them`,host:`Host`,model:`Model`,modelHelp:`empty uses the host's default`,key:`API key`,keyNote:`the key pi already holds for this host; it is never read by this page`,cheap:`Cheaper model`,cheapNone:`none: trivial steps keep their model and drop a thinking level`,cheapHelp:`what effort routing runs trivial steps on`},XY={title:`Settings`,intro:`Each agent's model and effort, the workflow and its lint gate, the lobby and the classifier. Changes save as you make them.`,loading:`Loading settings…`,loadFailed:`Could not load settings.`,saved:`Settings saved`,saving:`Saving…`,appearanceHelp:`Light, dark, or follow your system. Kept in this browser only.`,themeLabel:`Mode`,themeItems:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],notificationsLabel:`Browser notifications`,notificationsHelp:`While this page is hidden, tell me when a question waits, a task finishes or a background session asks something.`,notificationsBlocked:`Notifications are blocked in your browser. Allow them for this site and try again.`,notificationsUnsupported:`This browser does not offer notifications.`,notificationsOn:`Browser notifications are on.`,notificationsOff:`Browser notifications are off.`,installLabel:`Install bot-lobby`,installHelp:`Opens in its own fullscreen window, with the shell cached so it starts when Pi is not running.`,installButton:`Install as fullscreen app`,installUnavailable:`Your browser has not offered to install it. Use its menu: “Install app” (Chrome, Edge) or Share, then “Add to Home Screen” (Safari).`,installDone:`bot-lobby is installed.`,installedNow:`Running as an installed app.`,fullscreenLabel:`Fullscreen`,fullscreenHelp:`Hide the browser's own bars for this tab (F11 does the same).`,fullscreenOn:`Exit fullscreen`,fullscreenOff:`Go fullscreen`},ZY=`https://tweakcn.com/editor/theme`;function QY(){let{theme:e}=vY();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function $Y({palette:e,dark:t}){let n=se(e,t);return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border px-2`,style:{background:n.background},children:[(0,R.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,R.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,R.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function eX(){let e=Ue(),t=QY(),n=(0,m.useRef)(null);function r(t){let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!r)return;t.preventDefault(),t.stopPropagation();let i=Math.max(0,e.all.findIndex(t=>t.id===e.active.id)),a=e.all[(i+r+e.all.length)%e.all.length];e.choose(a.id),window.requestAnimationFrame(()=>n.current?.querySelector(`[data-theme-id="${a.id}"]`)?.focus())}return(0,R.jsx)(`div`,{ref:n,role:`radiogroup`,"aria-label":`Colour theme`,onKeyDown:r,className:`grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-4`,children:e.all.map(n=>{let r=n.id===e.active.id;return(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"aria-checked":r,"data-theme-id":n.id,tabIndex:r?0:-1,onClick:()=>e.choose(n.id),className:q(`grid gap-1.5 rounded-lg border p-2 text-left outline-none transition-[border-color,box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40`,r?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-border hover:bg-accent/50`),children:[(0,R.jsx)($Y,{palette:n,dark:t}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,R.jsxs)(`span`,{className:`truncate max-md:break-words max-md:overflow-visible max-md:text-clip max-md:whitespace-normal`,children:[n.name,e.isSaved(n.id)?(0,R.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function tX({entry:e}){let t=Ue(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(e.name),[o,s]=(0,m.useState)();async function c(){let n=i.trim();if(!n||n===e.name)return r(!1);try{await t.rename(e.id,n),r(!1),s(void 0),H.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,R.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1 max-md:flex-wrap`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,R.jsx)(Uq,{autoFocus:!0,value:i,maxLength:40,"aria-label":`New name for ${e.name}`,"aria-invalid":o?!0:void 0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),a(e.name),r(!1))},className:`h-8 max-w-64 max-md:h-11 max-md:min-h-11 max-md:min-w-0 max-md:flex-1`}),(0,R.jsx)(X,{label:`Save the name`,text:`Save`,icon:Vp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,R.jsx)(X,{label:`Keep the old name`,icon:Vg,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium max-md:break-words max-md:overflow-visible max-md:text-clip max-md:whitespace-normal`,children:e.name}),(0,R.jsx)(X,{label:`Rename ${e.name}`,text:`Rename`,icon:Vh,onClick:()=>{a(e.name),r(!0)}}),(0,R.jsx)(SM,{label:`Remove ${e.name}`,text:`Remove`,title:`Remove ${e.name}?`,description:`It is removed for every pi session. Keep a copy of its CSS if you want to use it again.`,confirmLabel:`Remove theme`,icon:Cg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>H.error(e.message))})]}),o?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function nX(){let e=Ue();return e.saved.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,R.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,R.jsx)(tX,{entry:e},e.id))})}function rX(){let e=Ue(),[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(!1),l=(0,m.useRef)(null);async function u(t,a){let s=ee(t);if(`error`in s){o(s.error);return}o(void 0),c(!0);try{let t=await e.adopt(s,r.trim()||s.name||a);n(``),i(``);let o=s.light?s.dark?void 0:`dark`:`light`;H.success(o?`${t.name} saved and applied. It has no ${o} colours, so ${o} mode keeps the default ones.`:`${t.name} saved and applied.`)}catch(e){o(e.message)}finally{c(!1)}}async function d(e){if(e){if(e.size>2e5){o(`That file is too large to be a theme.`);return}await u(await e.text(),e.name.replace(/\.[^.]+$/,``)||`Custom theme`)}}return(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,R.jsxs)(`a`,{href:ZY,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,R.jsx)(Dm,{"aria-hidden":`true`,className:`size-3`})]}),`, press Code, copy it, and paste it here, or save it as a file and upload that. Colours and fonts are used; corners stay the page's own.`]}),(0,R.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,R.jsx)(Uq,{value:r,maxLength:40,placeholder:`the theme's own name, or the file's`,onChange:e=>i(e.target.value),className:`h-8 max-w-80 text-foreground max-md:h-11 max-md:min-h-11`})]}),(0,R.jsx)(sM,{value:t,onChange:e=>{n(e.target.value),o(void 0)},rows:4,spellCheck:!1,"aria-label":`Theme CSS from tweakcn`,"aria-invalid":a?!0:void 0,placeholder:`:root {
|
|
91
|
+
`).filter(Boolean),r=[];for(let t of n){let n=CH.exec(t);if(!n)return{body:e,files:[]};let i=n[1].split(/[\\/]/).pop()??``;if(!/^[\w.-]+$/.test(i))return{body:e,files:[]};r.push({id:i,name:i.replace(/^[a-z0-9]+-/,``),mime:n[2]})}return r.length>0?{body:e.slice(0,t).trimEnd(),files:r}:{body:e,files:[]}}var TH=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function EH({files:e}){return e.length===0?null:(0,R.jsx)(`ul`,{className:`mt-2 flex min-w-0 max-w-full flex-wrap gap-2`,"aria-label":`Attached files`,children:e.map(e=>(0,R.jsx)(`li`,{children:TH.has(e.mime)?(0,R.jsx)(`a`,{href:F(`/files/preview/attachments/${e.id}`),target:`_blank`,rel:`noopener noreferrer`,className:`block max-w-full overflow-hidden rounded-lg border border-border bg-muted/40 transition-transform duration-150 ease-snap hover:scale-[1.02] focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,children:(0,R.jsx)(`img`,{src:F(`/files/preview/attachments/${e.id}`),alt:e.name,loading:`lazy`,className:`max-h-40 max-w-[min(14rem,100%)] object-cover`})}):(0,R.jsxs)(`span`,{className:`inline-flex max-w-[min(16rem,100%)] min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground`,children:[e.mime===`application/pdf`?(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var DH=!1,OH=[],kH=0,AH=900;function jH(){DH=!0,window.clearTimeout(kH),kH=window.setTimeout(MH,AH)}function MH(){DH=!1,window.clearTimeout(kH);let e=OH;OH=[];for(let t of e)t()}function NH(e){if(!DH)return e(),()=>{};let t=()=>e();return OH.push(t),()=>{OH=OH.filter(e=>e!==t)}}var PH=8;function FH(e,t=24){let[n,r]=(0,m.useState)(t),i=(0,m.useRef)(8),a=n<e;return(0,m.useEffect)(()=>{if(!a)return;let e=0,t=NH(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Hv.flushSync)(()=>r(e=>e+i.current));let t=Math.max(1,performance.now()-e);i.current=Math.max(2,Math.min(400,Math.round(i.current*PH/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function IH(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(IH).join(``)}function LH(e,t=!1){let n=t||e.tagName===`a`;e.tagName===`code`&&(e.properties={...e.properties,copyBlocked:n,blockCode:t===!1&&e.properties?.blockCode});for(let t of e.children??[])e.tagName===`pre`&&(t.properties={...t.properties,blockCode:!0}),LH(t,n)}function RH(){return e=>LH(e)}function zH(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await SH(e,navigator.clipboard),n(!0),H.success(`Code copied.`)}catch{H.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function BH({text:e,children:t,block:n=!1}){let{copy:r}=zH(e),i=(0,m.useRef)(void 0);return(0,R.jsxs)(`code`,{role:`button`,tabIndex:0,"aria-label":`Copy code`,"aria-keyshortcuts":`Enter Space`,title:`Copy code · Enter / Space`,className:q(`cursor-copy focus-visible:outline-2 focus-visible:outline-ring`,!n&&`max-md:break-words max-md:[overflow-wrap:anywhere]`),onPointerDown:e=>{i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>4&&(t.moved=!0)},onClick:e=>{e.stopPropagation(),xH(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),xH(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,R.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function VH({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=zH(bH(n,r?.position,!0)??IH(r)),o=r?.children?.find(e=>e.tagName===`code`)?.properties?.className,s=(Array.isArray(o)?o:[]).map(String).find(e=>e.startsWith(`language-`))?.slice(9);return(0,R.jsxs)(`div`,{className:`relative my-3 max-md:min-w-0 max-md:max-w-full rounded-lg bg-muted`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,R.jsx)(X,{label:i?`Copied`:`Copy the code`,icon:i?Vp:Cm,iconOnly:!0,onClick:()=>void a()})]}),(0,R.jsx)(`pre`,{className:`!my-0 max-md:max-w-full overflow-x-auto max-md:overscroll-x-contain !rounded-t-none !bg-transparent px-3 pb-3 text-sm leading-relaxed [&>code]:block`,children:t})]})}function HH(e){return{pre:t=>(0,R.jsx)(VH,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,R.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,R.jsx)(BH,{text:bH(e,r?.position,i)??IH(r),block:i,children:n})},a:({href:e,children:t})=>(0,R.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,R.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,R.jsx)(`div`,{className:`my-3 w-full max-md:min-w-0 max-md:max-w-full overflow-x-auto max-md:overscroll-x-contain`,children:(0,R.jsx)(`table`,{className:`w-full max-md:min-w-max border-collapse text-sm`,children:e})})}}var UH=(0,m.memo)(function({text:e}){return(0,R.jsx)(oz,{remarkPlugins:[fH],rehypePlugins:[RH],urlTransform:mH,components:HH(e),children:e})}),WH=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=wH(e),i=n?yH(n):[],a=FH(i.length,3);return(0,R.jsxs)(`div`,{className:q(`md-body max-md:min-w-0 max-md:max-w-full max-md:break-words max-md:[overflow-wrap:anywhere]`,t),children:[i.slice(0,a).map((e,t)=>(0,R.jsx)(UH,{text:e},t)),(0,R.jsx)(EH,{files:r})]})});function GH({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,R.jsxs)(`section`,{className:q(`workspace-frame group/frame relative flex min-h-0 min-w-0 flex-col rounded-xl border shadow-xs`,i&&`flex-none`,n),...s,children:[e||t||a?(0,R.jsxs)(`div`,{className:q(`flex min-h-12 shrink-0 items-center justify-between gap-3 px-4`,!i&&`border-b border-border`),children:[e?(0,R.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,R.jsx)(`span`,{}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,R.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":!i,"aria-label":i?`Expand ${c}`:`Minimize ${c}`,title:`${i?`Expand`:`Minimize`}${o?` · ${o}`:``}`,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,"aria-describedby":`focused-action-help`,onClick:a,className:`btn-ghost -mr-1.5 inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2 text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none max-md:h-11 max-md:min-w-11 max-md:justify-center`,children:[o?(0,R.jsx)(rA,{chord:o,className:`kbd-hint max-md:hidden`}):null,(0,R.jsx)(Up,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function KH({title:e,right:t,className:n}){return(0,R.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,R.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,R.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function qH({title:e,right:t,prominent:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`flex min-w-0 flex-col`,n?`gap-4`:`workspace-section gap-3 rounded-xl border p-4 shadow-xs max-md:rounded-lg max-md:p-3`),children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,R.jsx)(KH,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var JH=`Pull requests`,YH=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,XH=`nothing is posted to GitHub`,ZH=`Refresh to load open pull requests with the GitHub CLI (gh).`,QH=`No open pull requests.`,$H=`loading pull requests from GitHub…`,eU=`reading the diff…`,tU=`the pull request has new commits since this review — review it again`,nU=`(no description)`,rU=`Review with a focus (optional)`,iU=`Leave it empty for a full review.`;function aU(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function oU(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function sU(e,t){return`+${e} −${t}`}function cU(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function lU(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function uU(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function dU(e,t){if(e.status===`running`)return fU(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?fU(e,t):e.status;return[uU(e.verdict),n].filter(Boolean).join(` · `)}function fU(e,t){let n=Math.max(0,Math.round(((e.finishedAt??t)-e.startedAt)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,`0`)}s`}function pU(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${dM(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function mU(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${sU(e.additions,e.deletions)} · ${t}`}function hU(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,cU(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function gU(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function _U(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function vU(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function yU({pull:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:pU(e,t)}),(0,R.jsx)(`p`,{className:`text-sm tabular-nums`,children:mU(e)}),hU(e)?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:hU(e)}):null,e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4 max-md:min-h-11 max-md:items-center`,children:e.url}):null]})}function bU({read:e}){return(0,R.jsxs)(qH,{title:`Jev's read`,right:_U(e),children:[e.status===`running`?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`}),eU]}):null,e.status===`failed`?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,R.jsx)(WH,{text:e.line}):null]})}function xU({review:e,now:t}){return(0,R.jsxs)(R.Fragment,{children:[e.model?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,dM(t-e.startedAt)]}):null,e.stale?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:tU}):null,e.status===`running`?(0,R.jsx)(SU,{steps:e.steps}):null,e.status===`cancelled`?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,R.jsx)(WH,{text:e.text}):null]})}function SU({steps:e}){return(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,R.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function CU({number:e,focus:t,onChange:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:rU}),(0,R.jsx)(sM,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,className:`max-md:min-h-11`,onChange:e=>n(e.target.value)}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:iU})]})}function wU({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,R.jsxs)(qH,{title:`Review`,right:t?dU(t,n):void 0,children:[t?(0,R.jsx)(xU,{review:t,now:n}):null,(0,R.jsx)(CU,{number:e,focus:r,onChange:i}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,XH,`.`]})]})}function TU({files:e}){return(0,R.jsx)(qH,{title:`Files`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,R.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:sU(e.additions,e.deletions)})]},e.path))})})})})}function EU({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?dM(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,R.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,R.jsx)(WH,{text:e.body.trim()}):null]})}function DU({notes:e,now:t}){return e.length===0?null:(0,R.jsx)(qH,{title:`Discussion`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(EU,{note:e,now:t},n))})})}function OU({number:e,error:t}){return t?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`}),`loading #`,e,`…`]})}function kU({number:e,onChanged:t}){let n=xj(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=vU(a);if(!n.data)return(0,R.jsx)(OU,{number:e,error:n.error});let{pull:s,review:c,read:l}=n.data,u=()=>{n.reload(),t?.()},d=async()=>{let t=r.trim();i(``),await U(`git.review`,{number:e,...t?{focus:t}:{}}),u()},f=async()=>{await U(`git.jev`,{number:e}),u()},p=async()=>{await U(`git.cancelReview`,{number:e}),u()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Review`,icon:Uh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,R.jsx)(X,{label:`Jev's read`,icon:Fp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,R.jsx)(SM,{icon:dm,label:`Stop the review`,text:`Stop`,shortcut:`X`,title:`Stop this review?`,description:`The agent stops reading the pull request. Nothing is posted to GitHub.`,confirmLabel:`Stop review`,variant:`destructive`,onConfirm:()=>void p()}):null]}),(0,R.jsx)(yU,{pull:s,now:o}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:YH}),l?(0,R.jsx)(bU,{read:l}):null,(0,R.jsx)(wU,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,R.jsx)(TU,{files:s.files}):null,(0,R.jsx)(qH,{title:`Description`,children:s.body.trim()?(0,R.jsx)(WH,{text:s.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:nU})}),(0,R.jsx)(DU,{notes:s.notes,now:o})]})}var AU=Jg([`relative inline-flex shrink-0 items-center justify-center w-fit border border-transparent font-medium whitespace-nowrap outline-none transition-shadow`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50`,`[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-3`],{variants:{variant:{default:`bg-primary text-primary-foreground`,outline:`border-border bg-transparent dark:bg-input/32`,secondary:`bg-secondary text-secondary-foreground`,info:`bg-info text-white`,success:`bg-success text-white`,warning:`bg-warning text-white`,destructive:`bg-destructive text-white`,focus:`bg-focus text-focus-foreground`,invert:`bg-invert text-invert-foreground`,"primary-light":`border-primary/10 bg-primary/10 text-primary dark:border-primary/25 dark:bg-primary/15 dark:text-primary`,"warning-light":`border-warning/15 bg-warning/10 text-warning-foreground dark:border-warning/25 dark:bg-warning/15 dark:text-warning`,"success-light":`border-success/15 bg-success/10 text-success-foreground dark:border-success/25 dark:bg-success/15 dark:text-success`,"info-light":`border-info/15 bg-info/10 text-info-foreground dark:border-info/25 dark:bg-info/15 dark:text-info`,"destructive-light":`border-destructive/15 bg-destructive/10 text-destructive-foreground dark:border-destructive/25 dark:bg-destructive/15 dark:text-destructive`,"invert-light":`border-invert/15 bg-invert/10 text-foreground dark:border-invert/45 dark:bg-invert/35 dark:text-invert-foreground`,"focus-light":`border-focus/15 bg-focus/10 text-focus-foreground dark:border-focus/25 dark:bg-focus/15 dark:text-focus`,"primary-outline":`bg-background border-border text-primary dark:bg-input/30`,"warning-outline":`bg-background border-border text-warning-foreground dark:bg-input/30`,"success-outline":`bg-background border-border text-success-foreground dark:bg-input/30`,"info-outline":`bg-background border-border text-info-foreground dark:bg-input/30`,"destructive-outline":`bg-background border-border text-destructive-foreground dark:bg-input/30`,"invert-outline":`bg-background border-border text-invert-foreground dark:bg-input/30`,"focus-outline":`bg-background border-border text-focus-foreground dark:bg-input/30`},size:{xs:`px-1 py-0.25 text-[0.6rem] leading-none h-4 min-w-4 gap-1`,sm:`px-1 py-0.25 text-[0.625rem] leading-none h-4.5 min-w-4.5 gap-1`,default:`px-1.25 py-0.5 text-xs h-5 min-w-5 gap-1`,lg:`px-1.5 py-0.5 text-xs h-5.5 min-w-5.5 gap-1`,xl:`px-2 py-0.75 text-sm h-6 min-w-6 gap-1.5`},radius:{default:`rounded-sm`,full:`rounded-full`}},defaultVariants:{variant:`default`,size:`default`,radius:`default`}});function jU({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?kv:`span`;return(0,R.jsx)(o,{"data-slot":`badge`,className:q(AU({variant:t,size:n,radius:r,className:e})),...a})}var MU=`flex min-h-10 w-full flex-col gap-1 rounded-lg border border-transparent px-3 py-2.5 text-left outline-none transition-colors duration-150 hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 aria-[current=true]:border-primary/40 aria-[current=true]:bg-accent`,NU=`flex flex-col gap-1 px-2 pb-3`,PU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function FU({checks:e}){let t=aU(e);return t?(0,R.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,oU(e)),"aria-hidden":`true`,children:t}):(0,R.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function IU({pull:e,selected:t,onSelect:n}){let r=lU(e.review);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.number),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(FU,{checks:e.checks}),e.draft?(0,R.jsx)(jU,{variant:`secondary`,children:`draft`}):null,(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:gU(e)}),(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,R.jsx)(`span`,{children:r}):null,(0,R.jsx)(`span`,{className:`tabular-nums`,children:sU(e.additions,e.deletions)})]})]})]})})}function LU({pulls:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(IU,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var RU=()=>aj(ij(`git`)),zU=e=>aj(ij(`git`,String(e)));function BU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function VU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?QH:e?$H:ZH;return(0,R.jsxs)(sj,{className:`m-4 flex-1`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(Um,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,children:`Retry`}):null]})}function HU({rest:e}){let t=eM(),n=xj(`git.pulls`,{},[`git`]),r=BU(e),i=n.data?.pulls??[],a=(0,m.useCallback)(()=>{U(`git.pulls`,{refresh:!0}).then(()=>n.reload())},[n]);if(!n.data&&n.error)return(0,R.jsx)(yj,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,R.jsx)(VU,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:JH,count:n.data?`${i.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,R.jsx)(LU,{pulls:i,selectedId:r,onSelect:zU}):(0,R.jsx)(oM,{})]}),c=r===void 0?null:(0,R.jsx)(kU,{number:r,onChanged:n.reload},r);return(0,R.jsx)(iM,{wide:t,list:s,detail:c,open:r!==void 0,onClose:RU,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function UU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function WU({label:e,hint:t,buttonLabel:n=`Send`,onSend:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(!1),l=async()=>{a.trim()&&!s&&(c(!0),await r(a)&&o(``),c(!1))};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,R.jsx)(sM,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{UU(e)&&(e.preventDefault(),l())}}),t?(0,R.jsx)(`p`,{id:`${i}-hint`,className:q(`text-xs text-muted-foreground`,/(?:Enter|Esc)/.test(t)&&`max-md:hidden`),children:t}):null,(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:n,icon:s?rh:Np,tone:`primary`,shortcut:`Enter`,className:s?`[&_svg]:animate-spin`:void 0,onClick:()=>void l(),disabled:!a.trim()||s})})]})}var GU=`Issues`,KU=`Issue`,qU=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,JU=`Refresh to load open issues with the GitHub CLI (gh).`,YU=`No open issues. File one with New issue.`,XU=`loading issues from GitHub…`,ZU=`issues are off (lobby.issues)`,QU=`(no description)`;function $U(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${dM(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function eW(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?dM(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function tW(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function nW({issue:e,now:t}){return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:$U(e,t)}),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`inline-flex max-w-full break-all text-xs text-primary underline underline-offset-4 max-md:min-h-11 max-md:items-center`,children:e.url}):null]})}function rW({comment:e,now:t}){return(0,R.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,R.jsx)(`span`,{children:dM(t-Date.parse(e.createdAt))}):null]}),(0,R.jsx)(WH,{text:e.body.trim()})]})}function iW({comments:e,now:t}){return e.length===0?null:(0,R.jsx)(qH,{title:`Comments`,right:String(e.length),children:(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,R.jsx)(rW,{comment:e,now:t},n))})})}function aW({issue:e}){let t=async()=>{await U(`planner.new`,{seed:{issue:{number:e.number,title:e.title,...e.url?{url:e.url}:{}},body:e.body}})&&aj(ij(`plan`))};return(0,R.jsx)(SM,{icon:zg,label:`Plan #${e.number} with the panel`,text:`Plan it`,shortcut:`N`,title:`Plan #${e.number} with the panel?`,description:`A new planning session starts from this issue. A plan already under way waits under Plan → Previous.`,confirmLabel:`Plan it`,onConfirm:()=>void t()})}function oW({number:e}){let t=xj(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${KU} #${e}`,children:[(0,R.jsx)(Gj,{children:(0,R.jsx)(aW,{issue:r})}),(0,R.jsx)(nW,{issue:r,now:n}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:qU}),(0,R.jsx)(qH,{title:`Description`,children:r.body.trim()?(0,R.jsx)(WH,{text:r.body.trim()}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:QU})}),(0,R.jsx)(iW,{comments:r.comments,now:n})]})}function sW({issue:e,selected:t,now:n,onSelect:r}){let i=tW(e.labels);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.number),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,R.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,R.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:eW(e,n)})]})})}function cW({issues:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(sW,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var lW=()=>aj(ij(`issues`)),uW=e=>aj(ij(`issues`,String(e)));function dW(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function fW(){return(0,R.jsx)(sj,{className:`m-4 flex-1`,children:(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(dj,{children:`Issues are off`}),(0,R.jsx)(fj,{className:`font-mono`,children:ZU})]})})}function pW({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?YU:e?XU:JU;return(0,R.jsxs)(sj,{className:`m-4 flex-1`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(sm,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,children:`Retry`}):null]})}function mW({onCreate:e}){return(0,R.jsx)(tM,{className:`shrink-0 border-t border-border p-4`,children:(0,R.jsx)(WU,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function hW({rest:e}){let t=eM(),n=sA(`status`).data?.issuesEnabled??!0,r=xj(`issues.list`,{},[`issues`],n),i=dW(e),a=r.data?.issues??[],o=Date.now(),s=(0,m.useCallback)(()=>{U(`issues.list`,{refresh:!0}).then(()=>r.reload())},[r]),c=async e=>await U(`issues.create`,{text:e})?(r.reload(),!0):!1;if(!n)return(0,R.jsx)(fW,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,R.jsx)(fW,{}):(0,R.jsx)(yj,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:GU,count:r.data?`${a.length} open`:void 0,children:(0,R.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,R.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,R.jsx)(cW,{issues:a,selectedId:i,now:o,onSelect:uW}):(0,R.jsx)(oM,{}),(0,R.jsx)(mW,{onCreate:c})]}),d=i===void 0?null:(0,R.jsx)(oW,{number:i},i),f=r.data&&a.length===0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pW,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,R.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,R.jsx)(mW,{onCreate:c})})]}):(0,R.jsx)(iM,{wide:t,list:u,detail:d,open:i!==void 0,onClose:lW,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}function gW(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(!0),[r,i]=(0,m.useState)(!0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{n.current=!0,i(!0);let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]);return(0,m.useLayoutEffect)(()=>{n.current&&s()},[e,s]),(0,m.useLayoutEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{n.current&&(e.scrollTop=e.scrollHeight)});return r.observe(e),a.current=r,()=>{r.disconnect(),a.current=void 0,o.current=null}},[]),(0,m.useLayoutEffect)(()=>{let e=a.current,n=t.current?.firstElementChild??null;e&&n!==o.current&&(o.current&&e.unobserve(o.current),n&&e.observe(n),o.current=n)},[e]),{ref:t,atBottom:r,stick:s,onScroll:(0,m.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<48,i(n.current))},[])}}var _W={DEV:ym,DESIGN:Dh,QA:lg,RESEARCH:xg,"QUICK FIX":Ug,SCOUT:xm,PLANNER:tg,CLASSIFIER:yg,LOBBY:hh,LINT:$m};function vW(e){return e?_W[e.toUpperCase()]??Lp:zp}function yW(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function bW({source:e,className:t,strokeWidth:n}){if(yW(e))return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=vW(e);return(0,R.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var xW={MASTER:`text-primary`,DEV:`text-source-dev`,DESIGN:`text-source-design`,QA:`text-source-qa`,RESEARCH:`text-source-research`,"QUICK FIX":`text-source-quickfix`,ORACLE:`text-primary`,LOBBY:`text-muted-foreground`};function SW(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function CW(e){return xW[e]??`text-muted-foreground`}var wW={MASTER:`var(--primary)`,DEV:`var(--source-dev)`,DESIGN:`var(--source-design)`,QA:`var(--source-qa)`,RESEARCH:`var(--source-research)`,"QUICK FIX":`var(--source-quickfix)`,ORACLE:`var(--primary)`,LOBBY:`var(--muted-foreground)`};function TW(e){return wW[e]??`var(--muted-foreground)`}function EW(e){if(e.role===`researcher`)return`RESEARCH`;let t=e.domain??e.role;return t===`backend`||t===`dev`?`DEV`:t===`designer`||t===`design`?`DESIGN`:t===`researcher`||t===`research`?`RESEARCH`:t===`qa`?`QA`:t?String(t).toUpperCase():`AGENT`}function DW(e){return e?.runs??[]}function OW(e,t=40){let n=new Map;for(let t of e)n.set(t.source,t);return[...n.values()].sort((e,t)=>e.at-t.at).slice(-t)}function kW({source:e,live:t}){let n=yW(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":TW(e)},children:(0,R.jsx)(bW,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function AW({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,R.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,R.jsx)(`div`,{className:`chat-gutter`,children:r?(0,R.jsx)(kW,{source:e,live:i}):n?(0,R.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,R.jsxs)(`p`,{className:`chat-speaker`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,R.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,R.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,R.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":TW(e)},children:a}):a]})]})}function jW({time:e,head:t,note:n,children:r,below:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,R.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,R.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,R.jsx)(`span`,{children:n}):null]}):null,(0,R.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function MW({failed:e,children:t}){return(0,R.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,R.jsx)(`span`,{children:t})})}function NW({className:e}){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{}),(0,R.jsx)(`span`,{})]})}function PW({onClick:e,className:t}){return(0,R.jsx)(`button`,{type:`button`,"aria-label":`Jump to latest`,title:`Jump to latest`,onClick:e,className:q(`jump-latest btn-raised grid size-9 place-items-center rounded-full border bg-card text-foreground shadow-card outline-none focus-visible:ring-3 focus-visible:ring-ring/40 max-md:size-11`,t),children:(0,R.jsx)(Dp,{"aria-hidden":`true`,className:`size-4`})})}var FW=3e5,IW=`No task is running in this session.`,LW=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,RW=`Nothing said yet. Type below to talk to the oracle about this task.`;function zW({entry:e}){return(0,R.jsxs)(MW,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${lM(e.at)}`:``]})}function BW({entry:e,head:t}){if(e.role===`you`)return(0,R.jsx)(jW,{time:lM(e.at),head:t,children:(0,R.jsx)(WH,{text:e.text})});let n=e.role===`panel`;return(0,R.jsx)(AW,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:lM(e.at),head:t,children:(0,R.jsx)(WH,{text:e.text})})}var VW=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,R.jsx)(B.div,{initial:n?{opacity:0,y:10}:!1,animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:420,damping:32},children:e.role===`note`?(0,R.jsx)(zW,{entry:e}):(0,R.jsx)(BW,{entry:e,head:t})})},(e,t)=>e.head===t.head&&e.entry.id===t.entry.id&&e.entry.text===t.entry.text&&e.entry.at===t.entry.at);function HW({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,R.jsx)(AW,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,R.jsx)(WH,{text:e??``}):(0,R.jsx)(NW,{className:`mt-1`})})}function UW({hasTask:e}){return(0,R.jsxs)(sj,{className:`h-full border-0`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(ph,{"aria-hidden":`true`})}),e?null:(0,R.jsx)(dj,{children:IW}),(0,R.jsx)(fj,{children:e?RW:LW})]}),e?null:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,R.jsx)(rA,{chord:`3`}),` Plan`]}),(0,R.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,R.jsx)(rA,{chord:`4`}),` Quick fix`]})]})]})}async function WW(e){let t=await Te(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function GW(e,t,n){let[r,i]=(0,m.useState)([]),[a,o]=(0,m.useState)(t),[s,c]=(0,m.useState)(!1),l=(0,m.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...r.filter(e=>!t.has(e.id)),...e]},[r,e]);return{merged:l,more:a,loading:s,load:(0,m.useCallback)(async()=>{let e=l[0]?.id;if(e===void 0||s||!a)return;c(!0);let t=n.current,r=t?.scrollHeight??0,u=t?.scrollTop??0;try{let t=await WW(e);i(e=>[...t.entries,...e]),o(t.hasOlder),window.requestAnimationFrame(()=>{let e=n.current;e&&(e.scrollTop=e.scrollHeight-r+u)})}catch{o(!1)}finally{c(!1)}},[l,s,a,n])}}function KW({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i}){let{ref:a,atBottom:o,stick:s,onScroll:c}=gW(e.length+(t?.length??0)),{merged:l,more:u,loading:d,load:f}=GW(e,r,a),p=(0,m.useCallback)(()=>{c();let e=a.current;e&&e.scrollTop<80&&u&&!d&&f()},[c,a,u,d,f]),h=l.length===0&&!t?.trim()&&!n,[g,_]=(0,m.useState)(!1);return(0,m.useEffect)(()=>_(!0),[]),(0,R.jsxs)(GH,{"aria-label":`Conversation`,className:`flex-1`,children:[(0,R.jsx)(`div`,{ref:a,onScroll:p,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-5 pt-4 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Conversation`,tabIndex:0,children:h?(0,R.jsx)(UW,{hasTask:i}):(0,R.jsxs)(`div`,{className:`chat-column`,children:[u?(0,R.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,l.map((e,t)=>{let n=l[t-1],r=!n||n.role!==e.role||e.at-n.at>FW;return(0,R.jsx)(VW,{entry:e,head:r,fresh:g},e.id)}),(0,R.jsx)(HW,{text:t,busy:n})]})}),o?null:(0,R.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,R.jsx)(PW,{onClick:s})})]})}function qW(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function JW(e,t){let{agent:n,file:r}=qW(e);return ij(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var YW=[`master`,`designer`,`backend`,`qa`],XW={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},ZW={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},QW=`Every write archives the version before it.`;function $W(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function eG(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function tG(e){return{text:e.text,occurrence:e.occurrence}}function nG(e){return YW.map(t=>{let n=e.filter(e=>e.agent===t);return{agent:t,files:n,notes:n.reduce((e,t)=>e+t.notes,0)}}).filter(e=>e.files.length>0)}function rG(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function iG({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,R.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,R.jsx)(sM,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{rG(e)&&(e.preventDefault(),o())}}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:QW}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,disabled:t,children:`Cancel`}),(0,R.jsxs)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:o,disabled:t||!i.trim(),children:[t?(0,R.jsx)(pj,{}):null,`Save`]})]})]})]})}function aG({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=XA(e,YA.confirm);return(0,R.jsx)(HA,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:QW,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:QW})]}),(0,R.jsx)(sM,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:i,disabled:r,children:`Cancel`}),(0,R.jsxs)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:()=>a(o),disabled:r,children:[r?(0,R.jsx)(pj,{}):null,`Save file`]})]})]})})}function oG({note:e,about:t,onTakeBack:n,busy:r}){let i=t?`about "${t.replace(/\s+/g,` `).trim().slice(0,50)}": ${e.text}`:e.text;return(0,R.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Lh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,R.jsx)(X,{label:`Take the note back`,icon:Dg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function sG({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,R.jsxs)(`li`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:s,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},className:n?`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-primary/30 bg-accent px-3 py-2.5 outline-none focus-visible:ring-3 focus-visible:ring-ring/40 max-md:min-h-11`:`flex min-h-9 cursor-pointer flex-col gap-1 rounded-lg border border-border px-3 py-2.5 outline-none transition-colors hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/40 max-md:min-h-11`,children:[(0,R.jsx)(`div`,{className:`flex gap-2`,children:(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(WH,{text:e.text})})}),r.length>0?(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,R.jsx)(oG,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function cG({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,R.jsx)(qH,{title:`Notes on entries that changed`,right:String(e.length),children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,R.jsx)(oG,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function lG({view:e}){let t=e.entries.length;return(0,R.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[ZW[e.agent],` `,(0,R.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,$W(e.chars),` chars`]}),e.over?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:eG(e.file)}):null]})}function uG({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Edit the entry`,text:`Edit`,icon:Vh,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,R.jsx)(X,{label:t?`Add an entry after it`:`Add an entry`,text:`Add`,icon:Gh,shortcut:`A`,disabled:a,onClick:()=>n({kind:`add`,entry:t})}),(0,R.jsx)(X,{label:`Comment on the entry`,text:`Comment`,icon:dh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,R.jsx)(X,{label:`Edit the whole file`,text:`Edit file`,icon:jm,shortcut:`F`,disabled:a,onClick:r}),(0,R.jsx)(SM,{icon:Cg,label:`Delete the entry`,text:`Delete`,shortcut:`Delete`,title:`Delete this entry?`,description:`The entry and its notes are removed. The version before is archived.`,confirmLabel:`Delete entry`,variant:`destructive`,disabled:a||!t,onConfirm:i})]})}function dG({agent:e,file:t,onChanged:n}){let r=xj(`knowledge.open`,{agent:e,file:t},[`knowledge`]),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=r.data?.view,p=f?.entries??[],h=p[Math.min(i,Math.max(0,p.length-1))],g=async e=>{d(!0),await e(),s(void 0),r.reload(),n(),d(!1)},_=e=>void g(()=>U(`knowledge.unnote`,{id:e})),v=()=>{h&&g(()=>U(`knowledge.remove`,{agent:e,file:t,ref:tG(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:tG(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:tG(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:tG(h)}:{},text:n}))};return f?(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${ZW[e]} ${t}`,children:[(0,R.jsx)(uG,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,R.jsx)(lG,{view:f}),p.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,R.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,R.jsx)(sG,{entry:e,index:t,selected:t===i,notes:f.attached.filter(t=>t.entry===e.text),onPick:a,onTakeBack:_,busy:u},`${t}-${e.text}`))}),o?.kind===`edit`?(0,R.jsx)(iG,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,R.jsx)(WU,{label:`Comment on this entry`,hint:QW,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,R.jsx)(WU,{label:`Add an entry`,hint:QW,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{}),` saving…`]}):null,(0,R.jsx)(cG,{notes:f.detached,onTakeBack:_,busy:u}),(0,R.jsx)(aG,{open:c,file:t,initial:f.content,busy:u,onClose:()=>l(!1),onSave:n=>{l(!1),g(()=>U(`knowledge.replaceFile`,{agent:e,file:t,text:n}))}})]}):r.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function fG(e){return`${e.agent}/${e.file}`}var pG={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},mG=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function hG({info:e}){return(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(`span`,{children:$W(e.chars)}),e.over?(0,R.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,R.jsx)(`span`,{className:`text-primary`,children:mG(e.notes,`note`)}):null]})}function gG({info:e,selected:t,onSelect:n}){return(0,R.jsx)(`li`,{className:`ktree-leaf`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(fG(e)),className:q(MU,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5 max-md:min-h-11`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,R.jsx)(hG,{info:e})]})})}var _G=`bot-lobby.knowledge.folded`;function vG(){try{let e=JSON.parse(window.localStorage.getItem(_G)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function yG({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(vG),o=nG(e),s=e.reduce((e,t)=>e+t.notes,0);function c(e,t){a(n=>{let r=t?n.filter(t=>t!==e):[...new Set([...n,e])];try{window.localStorage.setItem(_G,JSON.stringify(r))}catch{}return r})}return(0,R.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,R.jsxs)(`p`,{className:`ktree-root`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,R.jsx)(Fp,{className:`size-4`})}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[mG(e.length,`file`),` · `,mG(o.length,`agent`),s>0?` · ${mG(s,`note`)}`:``]})]})]}),(0,R.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=pG[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,R.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":TW(o)},children:[(0,R.jsx)(`h3`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":a,"aria-controls":s,onClick:()=>c(e.agent,!a),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`h`?(t.preventDefault(),t.stopPropagation(),c(e.agent,!1)):(t.key===`ArrowRight`||t.key===`l`)&&(t.preventDefault(),t.stopPropagation(),a||c(e.agent,!0))},className:`ktree-node max-md:min-h-11`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,R.jsx)(bW,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:XW[e.agent]}),l?(0,R.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,R.jsxs)(`span`,{className:`text-primary`,children:[mG(e.notes,`note`),` · `]}):null,mG(e.files.length,`file`)]}),(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-snap`,a&&`rotate-90`)})]})}),(0,R.jsx)(Du,{initial:!1,children:a?(0,R.jsx)(B.ul,{id:s,"aria-label":`${XW[e.agent]}'s knowledge`,initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:520,damping:42},className:`ktree-leaves`,children:e.files.map(e=>(0,R.jsx)(gG,{info:e,selected:fG(e)===n,onSelect:r},fG(e)))},`files`):null})]},e.agent)})})]})}var bG=()=>aj(ij(`knowledge`)),xG=e=>{let[t,n]=e.split(`/`);aj(ij(`knowledge`,t??``,n??``))};function SG(){return(0,R.jsx)(sj,{className:`m-4 flex-1`,children:(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(Fp,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{children:`No knowledge files yet.`})]})})}function CG(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,R.jsx)(dG,{agent:i.agent,file:i.file,onChanged:r},fG(i)):t&&n?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function wG(){let e=sA(`lobby`),t=sA(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,R.jsx)(`p`,{className:`m-auto max-w-md px-5 pb-dock text-center text-sm text-muted-foreground`,children:`Ask about this project below. The oracle checks saved knowledge, searches the codebase for missing information, and saves verified findings.`}):(0,R.jsx)(KW,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function TG({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,R.jsx)(EG,{read:e,selected:t})]})}function EG({read:e,selected:t}){return!e.data&&e.error?(0,R.jsx)(yj,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,R.jsx)(yG,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:xG}):(0,R.jsx)(SG,{}):(0,R.jsx)(oM,{})}function DG({rest:e}){let{chat:t,agent:n,file:r}=qW(e),i=eM(),a=xj(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,R.jsx)(iM,{wide:i,inlineDetail:!0,list:(0,R.jsx)(TG,{read:a,selected:s?fG(s):void 0}),detail:t?(0,R.jsx)(wG,{}):CG(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:bG,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function OG(e){let t=e[0]===`board`,n=e[+!!t];try{return{board:t,id:n?decodeURIComponent(n):void 0}}catch{return{board:t,id:n}}}function kG({className:e,...t}){return(0,R.jsx)(yC,{"aria-keyshortcuts":`Space`,"aria-description":`When focused, press Space to toggle.`,"data-slot":`checkbox`,className:q(`peer relative flex size-[1.125rem] shrink-0 items-center justify-center rounded-[5px] border border-input bg-background text-primary-foreground transition-colors duration-150 outline-none before:absolute before:-inset-3 before:content-[''] focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary`,e),...t,children:(0,R.jsx)(xC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var AG=`Sessions`,jG=`No sessions yet.`,MG=`Up to 5 sessions; each can be assigned to one agent or several.`,NG=`A session is a live Excalidraw room that you and your agents draw in together.`,PG=[{title:`Start a live room`,text:`In Excalidraw: Share → Live collaboration → Start session.`},{title:`Add it here`,text:`Paste the room link, or make a new room and open it in Excalidraw.`},{title:`Assign agents`,text:`They read the board and draw on it, under their own name.`}],FG=`Sessions`,IG=`Pick a session on the left to see its link, its room and its agents.`,LG=`Room link`,RG=`Masked until revealed. A revealed link stays in this tab and is never saved.`,zG=`Room`,BG=`Drawing`,VG=`Last check`,HG=`not checked yet`,UG=`Add a session`,WG=`https://excalidraw.com/#room=…`,GG=`Optional name`;function KG(e){return`${e} of 5 in use`}var qG=`Agents may draw here.`,JG=`Agents may only look.`,YG=`checking the room…`,XG=`Check that the room can be reached.`,ZG=`Assigned to`,QG=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,$G=`Add or rename`,eK=`Add by link`,tK=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,nK=`New room`,rK=`Makes a fresh room link to open in Excalidraw; the name is optional.`,iK=`Rename`,aK=`draw`,oK=`look only`,sK=`Copied to the clipboard`,cK=`Could not reveal the link.`,lK=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],uK={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function dK(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function fK(e){return e?e.ok?`✓`:`!`:``}function pK({title:e,right:t,className:n,children:r}){return(0,R.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,R.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function mK({row:e=!1}){return(0,R.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:PG.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function hK({label:e,hint:t,buttonLabel:n,placeholder:r,initial:i=``,required:a,mono:o,primary:s,onSubmit:c}){let l=(0,m.useId)(),[u,d]=(0,m.useState)(i),[f,p]=(0,m.useState)(!1),h=a&&!u.trim(),g=async()=>{h||f||(p(!0),await c(u)&&d(i),p(!1))};return(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,R.jsxs)(`div`,{className:`flex gap-2 max-md:flex-wrap`,children:[(0,R.jsx)(`input`,{id:l,value:u,maxLength:o?2e3:80,placeholder:r,"aria-describedby":t?`${l}-hint`:void 0,onChange:e=>d(e.target.value),className:q(`h-8 min-w-0 flex-1 rounded-lg border border-input bg-background px-3 text-sm outline-none transition-[border-color,box-shadow] placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 max-md:min-h-11`,o&&`font-mono text-[0.8125rem]`)}),(0,R.jsx)(X,{type:`submit`,label:n,icon:f?rh:Gh,tone:s?`primary`:`neutral`,shortcut:`Enter`,disabled:h||f,className:f?`[&_svg]:animate-spin`:void 0})]}),t?(0,R.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function gK({onChanged:e,primary:t}){return(0,R.jsx)(hK,{label:eK,hint:tK,buttonLabel:`Add`,placeholder:WG,required:!0,mono:!0,primary:t,onSubmit:async t=>await U(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function _K({onChanged:e,primary:t}){return(0,R.jsx)(hK,{label:nK,hint:rK,buttonLabel:`Create`,placeholder:GG,primary:t,onSubmit:async t=>{let n=t.trim();return await U(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function vK({onChanged:e,stacked:t=!1}){return(0,R.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,R.jsx)(gK,{onChanged:e,primary:!0}),(0,R.jsx)(_K,{onChanged:e,primary:!0})]})}function yK({session:e,onChanged:t}){return(0,R.jsx)(hK,{label:iK,initial:e.name,required:!0,buttonLabel:iK,onSubmit:async n=>await U(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function bK({icon:e,tone:t=`muted`,children:n}){return(0,R.jsxs)(`span`,{className:q(`inline-flex h-6 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium`,t===`primary`?`bg-accent text-primary`:t===`warning`?`bg-warning/10 text-warning`:`bg-muted text-muted-foreground`),children:[(0,R.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function xK({check:e,checking:t}){return t?(0,R.jsx)(bK,{icon:rh,children:YG}):e?e.ok?(0,R.jsx)(bK,{icon:rm,tone:`primary`,children:`reachable`}):(0,R.jsx)(bK,{icon:tm,tone:`warning`,children:`unreachable`}):(0,R.jsx)(bK,{icon:am,children:HG})}function SK({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] items-baseline gap-3 text-sm max-md:grid-cols-[minmax(5rem,6rem)_minmax(0,1fr)]`,children:[(0,R.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]})}function CK({check:e,checking:t}){return t?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3.5`,"aria-hidden":`true`}),YG]}):e?(0,R.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:XG})}function wK({agent:e,on:t,onToggle:n}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(`flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-lg border px-2.5 text-sm transition-[background-color,border-color,color] max-md:min-h-11`,t?`border-primary/25 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(kG,{checked:t,onCheckedChange:()=>n(e)}),(0,R.jsx)(`span`,{className:`truncate`,children:uK[e]})]})})}function TK({session:e,onChanged:t}){let n=async n=>{await U(`excalidraw.toggleAgent`,{id:e.id,agent:n})&&t()},r=async()=>{await U(`excalidraw.toggleAll`,{id:e.id})&&t()},i=e.agents.length===lK.length;return(0,R.jsxs)(pK,{title:ZG,right:dK(e.agents.length),children:[(0,R.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:lK.map(t=>(0,R.jsx)(wK,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:QG}),(0,R.jsx)(X,{label:i?`Take every agent off`:`Assign every agent`,icon:$m,onClick:()=>void r()})]})]})}function EK({session:e,check:t,checking:n,onCheck:r,onChanged:i,onRemove:a}){let[o,s]=(0,m.useState)(),c=async()=>{try{s((await Te(`excalidraw.reveal`,{id:e.id})).link)}catch(e){H.error(e instanceof Error?e.message:cK)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>H(sK)).catch(()=>void 0),u=async()=>{await U(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,R.jsxs)(Gj,{children:[o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{label:`Copy the link`,text:`Copy`,icon:Cm,shortcut:`C`,onClick:l}),(0,R.jsx)(X,{label:`Open board`,icon:Dm,tone:`primary`,shortcut:`O`,href:o})]}):(0,R.jsx)(X,{label:`Reveal the link`,text:`Reveal`,icon:km,shortcut:`R`,onClick:()=>void c()}),(0,R.jsx)(X,{label:e.contribute?`Look only: agents stop drawing`:`Let agents draw`,text:e.contribute?`Look only`:`Let agents draw`,icon:e.contribute?zh:Vh,shortcut:`W`,pressed:e.contribute,onClick:()=>void u()}),(0,R.jsx)(X,{label:`Check the room`,text:`Check`,icon:n?rh:lg,shortcut:`T`,disabled:n,onClick:r}),(0,R.jsx)(SM,{icon:Cg,label:`Remove the session`,text:`Remove`,shortcut:`Delete`,title:`Remove "${e.name}"?`,description:`Agents lose this session at once; the Excalidraw room itself is not touched.`,confirmLabel:`Remove session`,variant:`destructive`,onConfirm:a})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(bK,{icon:e.contribute?Vh:km,tone:e.contribute?`primary`:`muted`,children:e.contribute?aK:oK}),(0,R.jsx)(bK,{icon:jg,children:dK(e.agents.length)}),(0,R.jsx)(xK,{check:t,checking:n})]})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,R.jsxs)(pK,{title:LG,children:[(0,R.jsx)(`p`,{className:`rounded-lg border border-border bg-muted px-3 py-2 font-mono text-[0.8125rem] break-all text-foreground`,children:o??e.masked}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:RG})]}),(0,R.jsx)(pK,{title:zG,children:(0,R.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(SK,{label:BG,children:(0,R.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?qG:JG})}),(0,R.jsx)(SK,{label:VG,children:(0,R.jsx)(CK,{check:t,checking:n})})]})})]}),(0,R.jsx)(TK,{session:e,onChanged:i})]}),(0,R.jsx)(pK,{title:$G,children:(0,R.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,R.jsx)(yK,{session:e,onChanged:i}),(0,R.jsx)(gK,{onChanged:i}),(0,R.jsx)(_K,{onChanged:i})]})})]})}function DK({check:e,checking:t}){if(t)return(0,R.jsx)(pj,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=fK(e);return n?(0,R.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,R.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function OK({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":r?`true`:void 0,onClick:()=>i(e.id),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(DK,{check:t,checking:n}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:dK(e.agents.length)})]}),(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,R.jsx)(jU,{variant:`secondary`,children:e.contribute?aK:oK})]})]})})}function kK({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(OK,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var AK=()=>aj(ij(`excalidraw`)),jK=e=>aj(ij(`excalidraw`,e));function MK({count:e}){return(0,R.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:KG(e)})]})}function NK({count:e,onChanged:t}){return(0,R.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:FG}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:IG})]}),(0,R.jsx)(MK,{count:e})]}),(0,R.jsx)(mK,{row:!0}),e<5?(0,R.jsx)(pK,{title:UG,children:(0,R.jsx)(vK,{onChanged:t})}):null,(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,R.jsx)(iA,{chord:`ArrowDown`,children:`next session`}),(0,R.jsx)(iA,{chord:`ArrowRight`,children:`into its detail`})]})]})}function PK({onChanged:e}){return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock md:px-8`,children:(0,R.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(Fh,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:jG}),(0,R.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:NG})]}),(0,R.jsx)(mK,{}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:MG})]}),(0,R.jsx)(pK,{title:UG,className:`self-start`,children:(0,R.jsx)(vK,{onChanged:e,stacked:!0})})]})})}function FK({id:e}){let t=eM(),n=xj(`excalidraw.list`,{},[`excalidraw`]),[r,i]=(0,m.useState)({}),[a,o]=(0,m.useState)([]),s=n.data?.sessions??[],c=s.find(t=>t.id===e),l=async e=>{o(t=>[...t,e]);let t=await U(`excalidraw.check`,{id:e});o(t=>t.filter(t=>t!==e)),t&&i(n=>({...n,[e]:t}))},u=async()=>{c&&await U(`excalidraw.remove`,{id:c.id})&&(n.reload(),AK())};if(!n.data&&n.error)return(0,R.jsx)(yj,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,R.jsx)(PK,{onChanged:n.reload});let d=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:AG,count:n.data?`${s.length}/5`:void 0}),n.data?(0,R.jsx)(kK,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:jK}):(0,R.jsx)(oM,{})]}),f=c?(0,R.jsx)(EK,{session:c,check:r[c.id],checking:a.includes(c.id),onCheck:()=>void l(c.id),onChanged:n.reload,onRemove:()=>void u()}):t&&n.data?(0,R.jsx)(NK,{count:s.length,onChanged:n.reload}):null;return(0,R.jsx)(iM,{wide:t,list:d,detail:f,open:c!==void 0,onClose:AK,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function IK(e,t){return e===`lobby.thinking`||t===`1`}var LK=`bot-lobby.collapsed.`,RK=new Set,zK=new Map;function BK(e){if(zK.has(e))return zK.get(e);if(e===`lobby.thinking`)return IK(e);try{return IK(e,localStorage.getItem(LK+e))}catch{return!1}}function VK(e,t){zK.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(LK+e,t?`1`:`0`)}catch{}for(let e of[...RK])e()}function HK(e){return RK.add(e),()=>{RK.delete(e)}}function UK(e){VK(e,!BK(e))}function WK(e){return[(0,m.useSyncExternalStore)(HK,()=>BK(e),()=>IK(e)),(0,m.useCallback)(()=>VK(e,!BK(e)),[e])]}function GK({entry:e}){return e.pending?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,R.jsx)(Vg,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,R.jsx)(Tg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function KK({entry:e}){return(0,R.jsxs)(`li`,{className:`grid grid-cols-[2.75rem_5rem_1rem_minmax(0,1fr)] items-baseline gap-x-2 rounded-lg px-2 py-1.5 text-sm transition-colors hover:bg-muted`,children:[(0,R.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:lM(e.at)}),(0,R.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,CW(e.source)),children:SW(e.source)}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,R.jsx)(GK,{entry:e})}),(0,R.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,R.jsx)(`span`,{className:q(`min-w-0 break-words`,e.kind===`error`?`text-destructive`:e.pending?``:`text-muted-foreground`),children:e.pending?`${e.text}…`:e.text})]})}function qK({entries:e,collapsed:t,onToggle:n,shortcut:r,bare:i}){let a=e.slice(-400),o=a.filter(e=>e.pending).length,{ref:s,atBottom:c,stick:l,onScroll:u}=gW(JSON.stringify(a));return(0,R.jsxs)(GH,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,R.jsx)(`div`,{ref:s,onScroll:u,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-2 pt-2 pb-dock outline-none focus-visible:bg-muted/30`,role:`log`,"aria-label":`Activity`,tabIndex:0,children:a.length===0?(0,R.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,R.jsx)(`ul`,{children:a.map(e=>(0,R.jsx)(KK,{entry:e},e.id))})}),c?null:(0,R.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,R.jsx)(PW,{onClick:l})})]})}var JK=(e,t)=>e?.keys.find(e=>e.action===t)?.label,YK=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function XK({name:e,icon:t,shortcut:n,onClick:r}){return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Expand ${e}`,"aria-expanded":!1,"aria-keyshortcuts":n,onClick:r,className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-[box-shadow,color,translate] duration-150 ease-snap outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`,children:(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(Tj,{side:`left`,children:[`Expand `,e,n?(0,R.jsx)(rA,{chord:n}):null]})]})}function ZK(e){let t=YK(e.status);return(0,R.jsx)(`aside`,{"aria-label":`Minimized panes`,className:`flex w-12 shrink-0 flex-col items-center gap-1 border-l border-border py-2`,children:t.activity&&e.activityFolded?(0,R.jsx)(XK,{name:`Activity`,icon:xp,shortcut:JK(e.status,`activity`),onClick:e.toggleActivity}):null})}function QK(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=YK(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,R.jsxs)(`div`,{className:q(`grid min-h-0 flex-1 gap-3 p-3`,s?`grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]`:`grid-cols-1`),children:[a.conversation?(0,R.jsx)(KW,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task}):null,o?(0,R.jsx)(qK,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:JK(n,`activity`)}):null]})}function $K(e){let{status:t}=e,n=YK(t).activity&&e.activityFolded;return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,R.jsx)(QK,{...e})}),n?(0,R.jsx)(ZK,{...e}):null]})}function eq({data:e,status:t}){let n=YK(t),r=[...n.conversation?[{id:`conversation`,label:`Conversation`,icon:ph}]:[],...n.activity?[{id:`activity`,label:`Activity`,icon:xp}]:[]],[i,a]=(0,m.useState)(`conversation`),o=r.find(e=>e.id===i)??r[0],s=(e?.activity??[]).filter(e=>e.pending).length;return o?(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Pane`,className:`flex shrink-0 items-center gap-0.5 border-b border-border px-3 py-2`,children:r.map(e=>{let t=e.id===o.id,n=e.icon;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>a(e.id),className:q(`inline-flex h-8 items-center gap-1.5 rounded-lg border border-transparent px-2.5 text-[0.8125rem] font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40`,t?`btn-raised bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,R.jsx)(KW,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task}):null,o.id===`activity`?(0,R.jsx)(qK,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function tq(e){let t=eM();return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:t?(0,R.jsx)($K,{...e}):(0,R.jsx)(eq,{...e})})}function nq(){let e=sA(`lobby`),t=sA(`status`),[n,r]=WK(`lobby.activity`);return!e.data&&e.loading?(0,R.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(pj,{}),(0,R.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,R.jsx)(yj,{message:e.error,onRetry:()=>fe.onHello({})}):(0,R.jsx)(tq,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var rq=Jg([`relative flex flex-col bg-muted/50 gap-(--frame-gap) px-(--frame-px) py-(--frame-py) rounded-(--frame-radius)`,`[--frame-radius:var(--radius-xl)]`,`[--frame-gap:--spacing(0.75)] [--frame-px:--spacing(0.75)] [--frame-py:--spacing(0.75)] [--frame-panel-header-gap:0rem] [--frame-panel-footer-gap:--spacing(1)]`,`[--frame-panel-px-adjust:0px] [--frame-panel-py-adjust:0px] [--frame-panel-header-px-adjust:0px] [--frame-panel-header-py-adjust:0px] [--frame-panel-footer-px-adjust:0px] [--frame-panel-footer-py-adjust:0px]`,`[--frame-panel-px:calc(var(--frame-panel-px-base)+var(--frame-panel-px-adjust))] [--frame-panel-py:calc(var(--frame-panel-py-base)+var(--frame-panel-py-adjust))] [--frame-panel-header-px:calc(var(--frame-panel-header-px-base)+var(--frame-panel-header-px-adjust))] [--frame-panel-header-py:calc(var(--frame-panel-header-py-base)+var(--frame-panel-header-py-adjust))] [--frame-panel-footer-px:calc(var(--frame-panel-footer-px-base)+var(--frame-panel-footer-px-adjust))] [--frame-panel-footer-py:calc(var(--frame-panel-footer-py-base)+var(--frame-panel-footer-py-adjust))]`,``,`[--frame-panel-bg:var(--workspace-card)] [--frame-panel-border-color:var(--workspace-border)] [--frame-border-color:var(--workspace-border)]`,`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px)-1px)]`],{variants:{variant:{default:`border border-[var(--frame-border-color)] bg-clip-padding`,inverse:`[--frame-panel-bg:color-mix(in_oklch,var(--color-muted)_40%,transparent)] border border-[var(--frame-border-color)] bg-background bg-clip-padding`,ghost:`[--frame-panel-radius:calc(var(--frame-radius)-var(--frame-px))]`},spacing:{xs:`[--frame-panel-px-base:--spacing(2)] [--frame-panel-py-base:--spacing(2)] [--frame-panel-header-px-base:--spacing(2)] [--frame-panel-header-py-base:--spacing(0.5)] [--frame-panel-footer-px-base:--spacing(2)] [--frame-panel-footer-py-base:--spacing(0.5)]`,sm:`[--frame-panel-px-base:--spacing(3)] [--frame-panel-py-base:--spacing(3.5)] [--frame-panel-header-px-base:--spacing(3)] [--frame-panel-header-py-base:--spacing(1.5)] [--frame-panel-footer-px-base:--spacing(3)] [--frame-panel-footer-py-base:--spacing(1.5)]`,default:`[--frame-panel-px-base:--spacing(4)] [--frame-panel-py-base:--spacing(4)] [--frame-panel-header-px-base:--spacing(4)] [--frame-panel-header-py-base:--spacing(2)] [--frame-panel-footer-px-base:--spacing(4)] [--frame-panel-footer-py-base:--spacing(2)]`,lg:`[--frame-panel-px-base:--spacing(5)] [--frame-panel-py-base:--spacing(5)] [--frame-panel-header-px-base:--spacing(5)] [--frame-panel-header-py-base:--spacing(2.5)] [--frame-panel-footer-px-base:--spacing(5)] [--frame-panel-footer-py-base:--spacing(2.5)]`},stacked:{true:[`gap-0 *:has-[+[data-slot=frame-panel]]:rounded-b-none`,`*:has-[+[data-slot=frame-panel]]:before:hidden`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:rounded-t-none`,`*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:border-t-0`],false:[`data-[spacing=sm]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-0.5`,`data-[spacing=default]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-1`,`data-[spacing=lg]:*:[[data-slot=frame-panel]+[data-slot=frame-panel]]:mt-2`]},dense:{true:`p-0 gap-0 border-[var(--frame-border-color)] [--frame-panel-radius:var(--frame-radius)] [&_[data-slot=frame-panel]]:-mx-px [&_[data-slot=frame-panel]]:before:hidden [&_[data-slot=frame-panel]:last-child]:-mb-px [&:not(:has([data-slot=frame-panel-header]))_[data-slot=frame-panel]:is(:first-child)]:-mt-px`,false:``}},defaultVariants:{variant:`default`,spacing:`default`,stacked:!1,dense:!1}});function iq({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,R.jsx)(`div`,{className:q(rq({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function aq({className:e,fit:t,...n}){return(0,R.jsx)(`div`,{className:q(`relative overflow-hidden rounded-(--frame-panel-radius) border border-(--frame-panel-border-color) bg-(--frame-panel-bg) bg-clip-padding shadow-xs`,!t&&`grow`,`before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--frame-panel-radius)-1px)] before:shadow-black/5`,`dark:bg-clip-border dark:before:shadow-white/5`,`px-(--frame-panel-px) py-(--frame-panel-py)`,e),"data-slot":`frame-panel`,...n})}function oq({className:e,...t}){return(0,R.jsx)(`header`,{className:q(`flex flex-col gap-(--frame-panel-header-gap) px-(--frame-panel-header-px) py-(--frame-panel-header-py)`,e),"data-slot":`frame-panel-header`,...t})}var sq={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function cq(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e/1e3)):0,n=Math.floor(t/60);if(n===0)return`${t}s`;let r=t%60;return r===0?`${n}m`:`${n}m ${String(r).padStart(2,`0`)}s`}function lq(e){return e>0?cq(e):`—`}function uq(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function dq(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function fq(e){return!Number.isFinite(e)||e<1e3?String(Math.max(0,Math.round(e||0))):e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1)}M`}function pq(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function mq(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function hq(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function gq(e,t){let n=t===`model-kind`?sq[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var _q=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],vq={MASTER:`bg-primary`,ORACLE:`bg-primary`,DEV:`bg-source-dev`,DESIGN:`bg-source-design`,QA:`bg-source-qa`,RESEARCH:`bg-source-research`,"QUICK FIX":`bg-source-quickfix`};function yq(e){let t=vq[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%_q.length;return _q[n]??_q[0]}function bq(e){return sq[e]??e}var xq=6;function Sq({daily:e,cost:t}){let n=(0,m.useId)().replace(/:/g,``),r=xf(),[i,a]=(0,m.useState)(null),o=t?`Daily cost`:`Daily runs`,s=e.map(e=>t?e.cost:e.runs),c=Math.max(...s,t?.01:1),l=t?[0,c/2,c]:[...new Set([0,Math.ceil(c/2),c])],u=Date.parse(e[0]?.date??`1970-01-01`),d=Date.parse(e.at(-1)?.date??`1970-01-01`),f=Math.max(1,(d-u)/864e5),p=e=>52+(Date.parse(e)-u)/(f*864e5)*424,h=Math.max(.5,Math.min(28,424/(f+1)*.65)),g=e=>t?`$${e.toFixed(2)}`:String(Math.round(e)),_=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),v=[...new Set([e[0]?.date,e[Math.floor(e.length/2)]?.date,e.at(-1)?.date])].filter(e=>!!e);return(0,R.jsxs)(wq,{title:o,right:t?`USD · per day`:`all runs · successful runs`,children:[(0,R.jsx)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2 text-xs`,"aria-live":`polite`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:_(i.date)}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t?g(i.cost):`${i.runs} runs · ${i.successes} successful`})]}):(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Hover or focus a day to inspect it.`})}),(0,R.jsxs)(`svg`,{viewBox:`0 0 512 220`,className:`w-full overflow-visible`,role:`group`,"aria-label":o,children:[(0,R.jsx)(`defs`,{children:(0,R.jsxs)(`linearGradient`,{id:`${n}-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--primary)`,stopOpacity:`0.5`})]})}),l.map(e=>(0,R.jsxs)(`g`,{"aria-hidden":`true`,children:[(0,R.jsx)(`line`,{x1:`36`,x2:`494`,y1:180-e/c*144,y2:180-e/c*144,stroke:`var(--workspace-border)`,strokeDasharray:`3 5`,opacity:`0.6`}),(0,R.jsx)(`text`,{x:`29`,y:184-e/c*144,textAnchor:`end`,fill:`var(--muted-foreground)`,fontSize:`10`,children:g(e)})]},e)),e.map((e,o)=>{let s=(t?e.cost:e.runs)/c*144,l=u===d?264:p(e.date),f=`${e.date}: ${t?g(e.cost):`${e.runs} runs, ${e.successes} successful`}`;return(0,R.jsxs)(`g`,{role:`img`,"aria-label":f,tabIndex:0,className:`outline-none`,onFocus:()=>a(e),onBlur:()=>a(null),onPointerEnter:()=>a(e),onPointerLeave:()=>a(null),children:[(0,R.jsx)(`title`,{children:f}),(0,R.jsx)(`rect`,{x:l-Math.max(h,12)/2,y:`26`,width:Math.max(h,12),height:`156`,rx:`4`,fill:`var(--accent)`,opacity:+(i?.date===e.date)}),(0,R.jsx)(B.rect,{"data-trend-bar":!0,x:l-h/2,width:h,rx:`3`,fill:`url(#${n}-fill)`,initial:!r&&{height:0,y:180},animate:{height:s,y:180-s},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3),ease:[.22,1,.36,1]}}),t?null:(0,R.jsx)(B.rect,{x:l-h/2,width:h,rx:`3`,fill:`var(--success)`,initial:!r&&{height:0,y:180},animate:{height:e.successes/c*144,y:180-e.successes/c*144},transition:{duration:r?0:.65,delay:r?0:Math.min(o*.04,.3)}})]},e.date)}),v.map(e=>(0,R.jsx)(`text`,{"aria-hidden":`true`,x:u===d?264:p(e),y:`205`,textAnchor:`middle`,fill:`var(--muted-foreground)`,fontSize:`11`,children:_(e)},e))]}),t?null:(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-primary`,"aria-hidden":`true`}),`All runs`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-sm bg-success`,"aria-hidden":`true`}),`Successful`]})]})]})}function Cq({daily:e}){return(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(Sq,{daily:e}),(0,R.jsx)(Sq,{daily:e,cost:!0})]})}function wq({title:e,right:t,children:n}){return(0,R.jsxs)(iq,{role:`region`,className:`min-w-0`,"aria-label":e,children:[(0,R.jsx)(oq,{className:`py-2.5`,children:(0,R.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-semibold`,children:[(0,R.jsx)(`span`,{children:e}),t?(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]})}),(0,R.jsx)(aq,{className:`flex min-w-0 flex-col gap-3`,children:n})]})}function Tq({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,xq);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>xq?(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`h-6 self-start rounded-lg text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30`,children:n?`Show fewer`:`Show all ${e.length}`}):null]})}function Eq({width:e,className:t,title:n}){let r=xf();return(0,R.jsx)(B.div,{"data-chart-bar":!0,title:n,className:`h-full ${t}`,initial:!r&&{width:0},animate:{width:`${e}%`},transition:{duration:r?0:.7,ease:[.22,1,.36,1]}})}function Dq(e,t){return t>0?Math.max(1.5,e/t*100):0}function Oq({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,R.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,R.jsxs)(`div`,{className:`relative h-5 overflow-hidden rounded-md border border-border bg-muted chart-track`,role:`img`,"aria-label":`${e}: ${i}`,children:[(0,R.jsx)(Eq,{className:`rounded-r-md bg-linear-to-r from-primary/65 to-primary`,width:Dq(t,r)}),n?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1/2 h-3 w-0.5 -translate-y-1/2 rounded-full bg-foreground/40`,style:{left:`${Math.min(99.5,Dq(n,r))}%`}}):null]})]})}function kq({groups:e,label:t}){let n=e.filter(e=>e.avgMs>0).sort((e,t)=>t.avgMs-e.avgMs),r=Math.max(...n.map(e=>Math.max(e.avgMs,e.p90Ms)),1);return(0,R.jsx)(wq,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsx)(Tq,{rows:n,render:e=>(0,R.jsx)(Oq,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:lq(e.avgMs),sub:`p90 ${lq(e.p90Ms)}`},t(e))})})}var Aq={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},jq={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function Mq({label:e,rate:t,runs:n}){let r=mq(t),i=`${Math.round(t*100)}%`;return(0,R.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 ${jq[r.tone]}`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${Aq[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,R.jsxs)(`div`,{className:`flex h-5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`${e}: ${r.word}, ${i} of ${n} runs`,children:[(0,R.jsx)(Eq,{className:`bg-success/80`,width:t*100}),(0,R.jsx)(Eq,{className:`bg-destructive/60`,width:(1-t)*100})]})]})}function Nq({groups:e,label:t}){let n=e.filter(e=>e.runs>0).sort((e,t)=>e.successes/e.runs-t.successes/t.runs);return(0,R.jsx)(wq,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,R.jsx)(Tq,{rows:n,render:e=>(0,R.jsx)(Mq,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function Pq({share:e}){return(0,R.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${yq(e.agent)}`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`text-[0.8125rem]`,children:SW(e.agent)}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,R.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,cq(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function Fq({share:e}){return(0,R.jsx)(`div`,{className:`flex h-6 gap-0.5 overflow-hidden rounded-md border border-border bg-muted`,role:`img`,"aria-label":`Share of run time by agent`,children:e.map(e=>(0,R.jsx)(Eq,{className:`${yq(e.agent)} opacity-85`,width:e.share*100,title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function Iq({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,R.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,R.jsx)(Tq,{rows:e,render:e=>(0,R.jsx)(Oq,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:cq(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function Lq({timeShare:e}){let t=e.byAgent;return(0,R.jsxs)(wq,{title:`Where the time goes`,right:`share of run time by agent`,children:[t.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsx)(Fq,{share:t}),(0,R.jsx)(Pq,{share:t})]}),(0,R.jsx)(Iq,{times:e.taskTimes})]})}function Rq(e){return(0,R.jsx)(FD,{...e})}function zq(e){return(0,R.jsx)(zD,{"data-slot":`select-value`,...e})}function Bq({className:e,children:t,...n}){return(0,R.jsxs)(LD,{"data-slot":`select-trigger`,className:q(`reui-select flex h-9 min-w-36 items-center justify-between gap-3 rounded-lg border px-3 text-xs outline-none focus-visible:ring-3 focus-visible:ring-ring/30 disabled:opacity-50`,e),...n,children:[t,(0,R.jsx)(BD,{asChild:!0,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]})}function Vq({className:e,children:t,position:n=`popper`,align:r=`start`,...i}){return(0,R.jsx)(UD,{children:(0,R.jsxs)(GD,{"data-slot":`select-content`,position:n,align:r,sideOffset:4,className:q(`reui-menu z-50 max-h-(--radix-select-content-available-height) min-w-(--radix-select-trigger-width) origin-(--radix-select-content-transform-origin) overflow-hidden rounded-xl border p-1 shadow-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 motion-reduce:animate-none`,e),...i,children:[(0,R.jsx)(hO,{className:`flex justify-center py-1`,children:(0,R.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})}),(0,R.jsx)(rO,{children:t}),(0,R.jsx)(_O,{className:`flex justify-center py-1`,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})})]})})}function Hq({className:e,children:t,...n}){return(0,R.jsxs)(lO,{"data-slot":`select-item`,className:q(`relative flex cursor-default items-center gap-2 rounded-lg py-2 pr-8 pl-3 text-xs outline-none select-none data-highlighted:bg-accent data-disabled:opacity-50`,e),...n,children:[(0,R.jsx)(dO,{children:t}),(0,R.jsx)(pO,{className:`absolute right-2`,children:(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`})})]})}function Uq({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`flex h-8 w-full rounded-lg border border-input bg-background px-3 py-1 text-base transition-[border-color,box-shadow] duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:disabled:bg-input/80`,e),...n})}var Wq=[{value:`all`,label:`All time`},{value:`today`,label:`Today`},{value:`week`,label:`Past 7 days`},{value:`range`,label:`Date range`}];function Gq(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function Kq({onChange:e}){let[t,n]=(0,m.useState)(`all`),r=Gq(new Date),[i,a]=(0,m.useState)(r),[o,s]=(0,m.useState)(r),[c,l]=(0,m.useState)(``);function u(t){if(n(t),l(``),t===`all`)e({});else if(t===`range`)i&&o&&i<=o&&e({from:i,to:o});else{let n=new Date;t===`week`&&n.setDate(n.getDate()-6),e({from:Gq(n),to:r})}}return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Period`}),(0,R.jsxs)(Rq,{value:t,onValueChange:u,children:[(0,R.jsx)(Bq,{"aria-label":`Metrics period`,children:(0,R.jsx)(zq,{})}),(0,R.jsx)(Vq,{children:Wq.map(e=>(0,R.jsx)(Hq,{value:e.value,children:e.label},e.value))})]})]}),t===`range`?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-wrap items-end gap-2`,onSubmit:t=>{if(t.preventDefault(),!i||!o||i>o){l(`Choose an end date on or after the start date.`);return}l(``),e({from:i,to:o})},children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`Start date`,(0,R.jsx)(Uq,{type:`date`,required:!0,value:i,onChange:e=>a(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`End date`,(0,R.jsx)(Uq,{type:`date`,required:!0,value:o,onChange:e=>s(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,R.jsx)(Y,{type:`submit`,size:`sm`,className:`h-9`,children:`Apply`}),c?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:c}):null]}):null]})}function qq({label:e,value:t,sub:n}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var Jq=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function Yq({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,R.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,R.jsx)(qq,{label:`Calls`,value:Jq(e.calls,`call`),sub:`${uq(e.ok,e.calls)} ok`}),(0,R.jsx)(qq,{label:`Speed`,value:`p50 ${pq(e.p50Ms)}`,sub:`p90 ${pq(e.p90Ms)}`}),(0,R.jsx)(qq,{label:`Read`,value:e.input>0?`${fq(e.input)} tokens`:`—`}),(0,R.jsx)(qq,{label:`Routed down`,value:e.routed>0?Jq(e.routed,`run`):`none`,sub:e.routed>0?`${uq(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,Jq(e.seatRunsSkipped,`seat run`),` skipped · `,Jq(e.questionsAnswered,`question`),` answered · `,Jq(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,R.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var Xq=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function Zq(e,t=0){return e>0?e.toFixed(t):`—`}function Qq(e){return[String(e.runs),uq(e.successes,e.runs),lq(e.avgMs),lq(e.p50Ms),lq(e.p90Ms),Zq(e.avgTurns,1),Zq(e.avgTools,1),e.avgTokens>0?fq(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,dq(e.avgCost),dq(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function $q(e,t){return t===`model-kind`?bq(e.kinds[0]??``):e.kinds.map(bq).join(`, `)}function eJ({groups:e,groupBy:t}){return(0,R.jsxs)(`section`,{className:`card-raised flex min-h-0 flex-col gap-2 overflow-hidden rounded-xl border pt-4`,"aria-label":`All models`,children:[(0,R.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,R.jsx)(`span`,{children:`All models`}),(0,R.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-auto outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,tabIndex:0,role:`region`,"aria-label":`All model metrics, scroll horizontally to see all columns`,children:(0,R.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,R.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),Xq.map(e=>(0,R.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,R.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,R.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:$q(e,t)||`—`}),Qq(e).map((e,t)=>(0,R.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},Xq[t]))]},gq(e,t)))})]})})]})}var tJ={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function nJ({label:e,value:t,sub:n,dot:r}){return(0,R.jsxs)(`div`,{className:`workspace-section flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-4 shadow-xs`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${tJ[r.tone]}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,R.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function rJ({tiles:e}){let t=mq(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-5 [&>:last-child]:col-span-2 sm:[&>:last-child]:col-span-1`,children:[(0,R.jsx)(nJ,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,R.jsx)(nJ,{label:`Success`,value:uq(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,R.jsx)(nJ,{label:`Avg run`,value:lq(e.avgMs),sub:`p90 ${lq(e.p90Ms)}`}),(0,R.jsx)(nJ,{label:`Cost`,value:dq(e.cost),sub:e.runs>0?`${dq(e.cost/e.runs)} per run`:`—`}),(0,R.jsx)(nJ,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${cq(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var iJ=`No runs recorded yet. Every Master turn, subagent run, quick fix and planning round lands here with its model, thinking level, time, tokens and cost.`;function aJ({groupBy:e,onGroup:t}){return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Group by`,className:`flex max-w-full flex-wrap gap-0.5 rounded-lg bg-muted p-0.5`,onKeyDown:n=>{let r=n.key===`ArrowRight`||n.key===`ArrowDown`?1:n.key===`ArrowLeft`||n.key===`ArrowUp`?-1:0;if(!r)return;n.preventDefault();let i=[`model`,`model-kind`],a=i[(i.indexOf(e)+r+i.length)%i.length];t(a),requestAnimationFrame(()=>n.currentTarget.querySelector(`[aria-checked='true']`)?.focus())},children:[`model`,`model-kind`].map(n=>(0,R.jsx)(Y,{variant:`ghost`,size:`sm`,role:`radio`,tabIndex:e===n?0:-1,className:e===n?`bg-card text-foreground shadow-card hover:bg-card`:`text-muted-foreground`,"aria-checked":e===n,onClick:()=>t(n),children:hq(n)},n))})}function oJ({query:e,onQuery:t}){return(0,R.jsxs)(`label`,{className:`relative flex max-w-full items-center`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,R.jsx)(ag,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{id:`metrics-search`,type:`search`,value:e,maxLength:500,placeholder:`Search runs: model, agent, tool…`,onChange:e=>t(e.target.value),className:`h-8 w-64 max-w-full rounded-lg border border-input bg-background pr-9 pl-8 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30`}),(0,R.jsx)(rA,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function sJ({data:e,groupBy:t,query:n}){let r=e=>gq(e,t);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsx)(rJ,{tiles:e.tiles}),e.tiles.runs===0?(0,R.jsx)(`p`,{className:`card-raised rounded-xl border p-4 text-sm text-muted-foreground`,children:n?`No run matches "${n}" in this period.`:`No runs in this period. ${iJ}`}):null,e.daily.length>0?(0,R.jsx)(Cq,{daily:e.daily}):null,e.classifier?(0,R.jsx)(Yq,{summary:e.classifier}):null,e.tiles.runs>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,R.jsx)(kq,{groups:e.groups,label:r}),(0,R.jsx)(Nq,{groups:e.groups,label:r})]}),(0,R.jsx)(eJ,{groups:e.groups,groupBy:t})]}):null,e.tiles.runs>0||e.timeShare.taskTimes.length>0?(0,R.jsx)(Lq,{timeShare:e.timeShare}):null]})}function cJ(){return(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,role:`status`,"aria-label":`Loading metrics`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function lJ(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)({}),o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=xj(`metrics.get`,{groupBy:e,query:n,...i,timeZone:o},[`metrics`]);return!s.data&&s.error?(0,R.jsx)(yj,{message:`Could not load metrics. ${s.error}`,onRetry:s.reload}):(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Daily trends and model performance`})]}),s.loading&&s.data?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(pj,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`})]}),(0,R.jsxs)(`section`,{"aria-label":`Metrics filters`,className:`workspace-section flex flex-wrap items-end gap-4 rounded-xl border p-4`,children:[(0,R.jsx)(Kq,{onChange:a}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-end gap-3 lg:w-auto lg:flex-1 lg:justify-end`,children:[(0,R.jsx)(aJ,{groupBy:e,onGroup:t}),(0,R.jsx)(oJ,{query:n,onQuery:r})]}),(0,R.jsxs)(`p`,{className:`w-full text-xs text-muted-foreground`,children:[i.from?`${i.from} – ${i.to}`:`All recorded dates`,` · `,o,`. Runs and active tasks use their start date; completed tasks use their completion date.`]})]}),s.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not refresh metrics. `,s.error]}):null,(0,R.jsx)(`div`,{"aria-busy":s.loading,className:s.loading&&s.data?`opacity-60`:void 0,children:s.data?(0,R.jsx)(sJ,{data:s.data,groupBy:e,query:n},JSON.stringify([s.data,e])):(0,R.jsx)(cJ,{})})]})}var uJ=class{seen=new Set;initialized=new Set;storage;constructor(e){this.storage=e;try{let t=JSON.parse(e?.getItem(`bot-lobby.prompt-seen`)??`[]`);Array.isArray(t)&&(this.seen=new Set(t.filter(e=>typeof e==`string`)))}catch{}}observe(e,t,n=!1){let r=this.initialized.has(e)&&!n?t.filter(e=>!this.seen.has(e)):[];this.initialized.add(e);for(let e of t)this.seen.add(e);try{this.storage?.setItem(`bot-lobby.prompt-seen`,JSON.stringify([...this.seen]))}catch{}return r}};function dJ(e,t){return JSON.stringify([e,`prompt`,t])}function fJ(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function pJ(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var mJ=`bot-lobby.prompt-sound-muted`,hJ=new Set,gJ,_J=!1;function vJ(){try{return localStorage.getItem(mJ)===`on`}catch{return _J}}function yJ(e){_J=e;try{localStorage.setItem(mJ,e?`on`:`off`)}catch{}for(let e of hJ)e()}function bJ(e){return hJ.add(e),()=>{hJ.delete(e)}}function xJ(){return(0,m.useSyncExternalStore)(bJ,vJ,()=>!1)}function SJ(){(0,m.useEffect)(()=>{let e=()=>{try{gJ??=new AudioContext,gJ.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function CJ(){if(!vJ()&&gJ&&gJ.state===`running`)try{let e=gJ.currentTime,t=gJ.createOscillator(),n=gJ.createGain();t.frequency.setValueAtTime(960,e),t.frequency.exponentialRampToValueAtTime(360,e+.16),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.12,e+.012),n.gain.exponentialRampToValueAtTime(1e-4,e+.22),t.connect(n),n.connect(gJ.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}function wJ(){if(!vJ()&&gJ&&gJ.state===`running`)try{let e=gJ.currentTime,t=gJ.createOscillator(),n=gJ.createGain();t.frequency.setValueAtTime(1500,e),n.gain.setValueAtTime(1e-4,e),n.gain.exponentialRampToValueAtTime(.045,e+.004),n.gain.exponentialRampToValueAtTime(1e-4,e+.028),t.connect(n),n.connect(gJ.destination),t.start(e),t.stop(e+.03),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var TJ=`bot-lobby.notifications`,EJ=`/icon-192.png`,DJ=new Set;function OJ(){for(let e of[...DJ])e()}function kJ(){try{return localStorage.getItem(TJ)===`on`}catch{return!1}}function AJ(e){return DJ.add(e),()=>{DJ.delete(e)}}function jJ(e){try{localStorage.setItem(TJ,e?`on`:`off`)}catch{}OJ()}function MJ(){return(0,m.useSyncExternalStore)(AJ,kJ,()=>!1)}async function NJ(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(jJ(!0),`granted`):`denied`)}function PJ(){jJ(!1)}function FJ(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function IJ(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function LJ(e){try{new Notification(`bot-lobby`,{body:e,icon:EJ,tag:`bot-lobby`})}catch{}}function RJ(){try{return new uJ(sessionStorage)}catch{return new uJ}}function zJ(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?fJ(e,t.sessionId??n.key??t.from,n.dialog.id):dJ(e,t.id)}function BJ(){let e=MJ();SJ(),aA();let t=xj(`tasks.list`,{},[`tasks`]),n=xj(`sessions.list`,{},[`sessions`]),r=fe.get(`prompts`),i=fe.get(`lobby`).data,a=(0,m.useRef)(RJ()),o=(0,m.useRef)(new Set([`prompts`,`sessions`,`delivery`])),s=(0,m.useRef)(void 0),c=P()??`current`,l=fe.status().connection;return{enabled:e,tasks:t,sessions:n,prompts:r,lobby:i,seen:a,quiet:o,previousState:s,project:c,connection:l,lastConnection:(0,m.useRef)(l)}}function VJ(e,t,n,r,i){if(!i)return;let{seen:a,project:o,quiet:s,enabled:c}=e,l=a.current.observe(`${o}:${t}`,n,s.current.has(t));s.current.delete(t),l.length&&(l.forEach(()=>CJ()),c&&IJ()&&LJ(r),t===`delivery`&&H.info(r,{action:{label:`Review tasks`,onClick:()=>aj(`#/tasks`)}}))}function HJ(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;VJ(e,`prompts`,(a??[]).map(e=>zJ(i,e)),`A question is waiting for you.`,!!a&&!t.loading),VJ(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>fJ(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),VJ(e,`delivery`,r.data?.rows.filter(e=>e.delivery&&(e.delivery.status===`pending_approval`||e.delivery.status===`deferred`||e.delivery.status===`recoverable_failure`)).map(e=>pJ(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function UJ(e){let{lastConnection:t,connection:n,quiet:r,previousState:i,lobby:a,enabled:o}=e;if(t.current!==n||n!==`live`){t.current=n,r.current=new Set([`prompts`,`sessions`,`delivery`]),i.current=void 0;return}HJ(e);let s=a?.task?.state??``,c=FJ(s);i.current&&c&&s!==i.current&&o&&IJ()&&LJ(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function WJ(){let e=BJ(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>UJ(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function GJ({className:e,thumbClassName:t,...n}){return(0,R.jsx)(IO,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to toggle.`,"data-slot":`switch`,className:q(`peer relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors duration-150 outline-none before:absolute before:-inset-x-2 before:-inset-y-3 before:content-[''] focus-visible:ring-3 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,R.jsx)(RO,{"data-slot":`switch-thumb`,className:q(`pointer-events-none block size-4 rounded-full bg-white shadow-sm ring-0 transition-transform duration-200 ease-snap data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`,t)})})}var KJ=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],qJ=`M32 17 C28 10 19 12 17 19 C10 19 7 26 10 32 C5 38 9 46 15 47 C16 54 25 56 32 50 C39 56 48 54 49 47 C55 46 59 38 54 32 C57 26 54 19 47 19 C45 12 36 10 32 17Z`,JJ=`M32 17 C28 12 21 12 18 19 C12 19 9 25 11 31 C7 36 9 44 15 46 C16 53 26 55 32 50 C38 55 48 53 49 46 C55 44 57 36 53 31 C55 25 52 19 46 19 C43 12 36 12 32 17Z`,YJ=[`M19 22 C16 25 17 29 22 29 C27 29 28 33 25 36`,`M12 35 C16 32 20 35 18 39 C16 43 20 47 24 45`,`M25 17 C22 20 26 22 28 22 C31 23 29 27 26 27`,`M11 42 C13 44 16 42 15 39 M22 49 C26 49 29 45 27 41`,`M15 25 C12 27 14 31 17 31 M21 32 C22 35 20 37 22 39 C24 41 28 38 29 35`,`M20 18 C22 18 23 20 21 22 M24 24 C21 23 20 25 21 27 M12 37 C14 36 16 38 15 40 M20 43 C23 44 25 42 24 40 M28 29 C30 30 30 32 28 33`];function XJ({level:e,className:t}){let n=xf(),r=Math.max(0,KJ.indexOf(e)),i=[0,1,2,2,3,4,6][r],a=r===KJ.length-1,o=`brain-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,R.jsxs)(`svg`,{viewBox:`0 0 64 72`,"data-slot":`effort-mascot`,"data-level":e,"data-folds":i*2,"data-elevated":a||void 0,"aria-hidden":`true`,focusable:`false`,className:q(`size-16 shrink-0 overflow-visible`,t),children:[(0,R.jsxs)(`defs`,{children:[(0,R.jsxs)(`linearGradient`,{id:`${o}-ink`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,R.jsx)(`stop`,{stopColor:a?`var(--rainbow-5)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:a?`var(--rainbow-6)`:`var(--primary)`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:a?`var(--rainbow-7)`:`var(--primary)`})]}),(0,R.jsxs)(`radialGradient`,{id:`${o}-halo`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--rainbow-6)`,stopOpacity:`0.38`}),(0,R.jsx)(`stop`,{offset:`0.55`,stopColor:`var(--rainbow-7)`,stopOpacity:`0.18`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-5)`,stopOpacity:`0`})]}),(0,R.jsxs)(`linearGradient`,{id:`${o}-shine`,children:[(0,R.jsx)(`stop`,{stopColor:`var(--card)`,stopOpacity:`0`}),(0,R.jsx)(`stop`,{offset:`0.5`,stopColor:`var(--primary)`,stopOpacity:`0.6`}),(0,R.jsx)(`stop`,{offset:`0.6`,stopColor:`var(--card)`,stopOpacity:`0.9`}),(0,R.jsx)(`stop`,{offset:`1`,stopColor:`var(--card)`,stopOpacity:`0`})]}),(0,R.jsxs)(`filter`,{id:`${o}-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:[(0,R.jsx)(`feGaussianBlur`,{stdDeviation:`1.4`}),(0,R.jsxs)(`feMerge`,{children:[(0,R.jsx)(`feMergeNode`,{}),(0,R.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,R.jsx)(`clipPath`,{id:`${o}-silhouette`,children:(0,R.jsx)(`path`,{d:qJ})}),(0,R.jsx)(`pattern`,{id:`${o}-hologram`,width:`4`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,R.jsx)(`path`,{d:`M0 1.5H4`,stroke:`var(--rainbow-5)`,strokeWidth:`0.4`,opacity:`0.4`})})]}),(0,R.jsx)(`ellipse`,{cx:`32`,cy:`63`,rx:a?14:19,ry:`2.5`,className:`fill-primary/10`}),a?(0,R.jsx)(B.circle,{"data-brain-halo":!0,cx:`32`,cy:`32`,r:`33`,fill:`url(#${o}-halo)`,initial:!1,animate:{opacity:n?.8:[.65,1,.65]},transition:{duration:n?0:3,repeat:n?0:1/0}}):null,(0,R.jsxs)(B.g,{"data-brain-body":!0,initial:!1,animate:{y:a?n?-5:[-5,-7,-5]:0},transition:{duration:n?0:a?3:.3,repeat:a&&!n?1/0:0,ease:`easeInOut`},stroke:`url(#${o}-ink)`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,filter:a?`url(#${o}-glow)`:void 0,children:[a?[`cyan`,`magenta`].map(e=>(0,R.jsx)(`use`,{href:`#${o}-shape`,"data-brain-phase":e,className:`brain-phase-echo`,stroke:`currentColor`},e)):null,(0,R.jsxs)(`g`,{id:`${o}-shape`,"data-brain-shape":!0,className:`brain-shape`,children:[(0,R.jsx)(`path`,{d:`M30 49 L30 56 Q32 59 35 57 L35 51`,className:`fill-primary/15`}),(0,R.jsx)(`path`,{d:r<=3?JJ:qJ,className:r===0?`fill-muted`:r<=3?`fill-primary/15`:`fill-primary/10`}),(0,R.jsx)(`path`,{d:`M32 17 C29 24 34 28 32 34 C30 40 34 45 32 50`,fill:`none`,opacity:r===0?.35:.8}),[!1,!0].map(e=>(0,R.jsx)(`g`,{transform:e?`translate(64 0) scale(-1 1)`:void 0,fill:`none`,children:YJ.slice(0,i).map((e,t)=>(0,R.jsx)(B.path,{"data-brain-fold":!0,d:e,initial:!n&&{opacity:0,pathLength:0},animate:{opacity:.85,pathLength:1},transition:{duration:n?0:.3,delay:n?0:t*.025}},e))},String(e))),r>0&&r<5?(0,R.jsx)(`g`,{stroke:`none`,fill:`var(--primary)`,children:[[20,27],[43,36],[25,44]].slice(0,Math.min(r,3)).map(([e,t],n)=>(0,R.jsx)(`circle`,{cx:e,cy:t,r:`1.4`,className:`brain-spark`,style:{animationDelay:`${n*-.7}s`}},e))}):null,r>=5?(0,R.jsx)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:(0,R.jsx)(`rect`,{"data-brain-shimmer":!0,className:`brain-shimmer`,x:`-24`,y:`10`,width:`18`,height:`48`,fill:`url(#${o}-shine)`})}):null]}),a?(0,R.jsxs)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:[(0,R.jsx)(`path`,{d:qJ,fill:`url(#${o}-hologram)`}),(0,R.jsx)(`rect`,{"data-brain-scan":!0,className:`brain-phase-scan`,x:`7`,y:`14`,width:`50`,height:`2`,fill:`var(--rainbow-5)`,opacity:`0.45`})]}):null]}),a?(0,R.jsx)(`g`,{fill:`url(#${o}-ink)`,children:[[8,14],[56,12],[5,49],[58,46]].map(([e,t])=>(0,R.jsx)(`path`,{d:`M0 -3 L0.8 -0.8 L3 0 L0.8 0.8 L0 3 L-0.8 0.8 L-3 0 L-0.8 -0.8Z`,transform:`translate(${e} ${t})`},e))}):null]})}var ZJ={minimal:`min`,medium:`med`},QJ={off:`No extra reasoning: the quickest, cheapest answer.`,minimal:`A moment of reasoning, barely.`,low:`Light reasoning for simple work.`,medium:`Balanced reasoning for most work.`,high:`Careful reasoning: slower, better on hard problems.`,xhigh:`Very deep reasoning: slow and costly.`,max:`As deep as the model goes.`};function $J(e,t,n){let r=-1;for(let i=0;i<e.length;i+=1)t.includes(e[i])&&(r<0||Math.abs(i-n)<Math.abs(r-n))&&(r=i);return r}function eY(e,t,n,r){for(let i=n+r;i>=0&&i<e.length;i+=r)if(t.includes(e[i]))return i;return n}function tY({value:e,levels:t,supported:n,model:r,label:i,disabled:a,onChange:o}){let s=(0,m.useRef)(null),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),f=(0,m.useRef)(void 0),p=(0,m.useRef)(0),h=(0,m.useCallback)(()=>{f.current=void 0,p.current=0,d(void 0)},[]),g=Math.max(t.length-1,1),_=$J(t,n,Math.max(0,t.indexOf(e))),v=c??u??_,y=v<0?0:v/g*100,b=t[v]??e,x=v>=0&&b!==e;(0,m.useEffect)(()=>{if(u===void 0)return;let e=window.setTimeout(h,1e4);return()=>window.clearTimeout(e)},[u,h]);let S=(0,m.useCallback)(e=>{let r=s.current?.getBoundingClientRect();if(!r||r.width===0)return _;let i=Math.min(1,Math.max(0,(e-r.left)/r.width));return $J(t,n,Math.round(i*g))},[g,t,_,n]);function C(e){a||n.length===0||(e.currentTarget.setPointerCapture(e.pointerId),l(S(e.clientX)))}function w(e){if(c===void 0)return;let t=S(e.clientX);t!==c&&l(t)}function T(){if(c===void 0)return;let n=t[c];l(void 0),n&&n!==e&&o(n)}function E(e){if(a||v<0)return;let r=f.current??v,i={ArrowRight:eY(t,n,r,1),ArrowUp:eY(t,n,r,1),ArrowLeft:eY(t,n,r,-1),ArrowDown:eY(t,n,r,-1),Home:$J(t,n,0),End:$J(t,n,g)}[e.key];if(i===void 0)return;e.preventDefault();let s=t[i];s&&i!==r&&(f.current=i,d(i),p.current+=1,Promise.resolve(o(s)).catch(()=>void 0).then(()=>{--p.current,p.current<=0&&h()}))}return(0,R.jsxs)(`div`,{className:q(`flex min-w-0 flex-col items-center gap-3 min-[360px]:flex-row`,a&&`opacity-60`),children:[(0,R.jsx)(XJ,{level:b}),(0,R.jsxs)(`div`,{className:`flex w-full min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:QJ[b]??``})]}),(0,R.jsxs)(`div`,{ref:s,role:`slider`,tabIndex:a?-1:0,"aria-label":i,"aria-valuemin":0,"aria-valuemax":t.length-1,"aria-valuenow":Math.max(v,0),"aria-valuetext":b,"aria-disabled":a||void 0,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:()=>l(void 0),onKeyDown:E,className:`relative mx-2.5 h-6 touch-none cursor-pointer rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-1/2 h-1.5 -translate-y-1/2 rounded-full bg-muted`}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:`absolute top-1/2 left-0 h-1.5 -translate-y-1/2 rounded-full bg-primary`,animate:{width:`${y}%`},transition:{type:`spring`,stiffness:520,damping:34}}),t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,title:i?e:`${r??`This model`} does not support ${e}`,className:q(`absolute top-1/2 size-1 -translate-x-1/2 -translate-y-1/2 rounded-full`,i?t<=v?`bg-primary-foreground/80`:`bg-muted-foreground/40`:`bg-transparent ring-1 ring-muted-foreground/30`),style:{left:`${t/g*100}%`}},e)}),(0,R.jsx)(B.span,{"aria-hidden":`true`,className:q(`absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-primary bg-white shadow-sm`,c!==void 0&&`scale-110`),animate:{left:`${y}%`},transition:{type:`spring`,stiffness:520,damping:28}})]}),(0,R.jsx)(`div`,{className:`relative mx-2.5 h-3.5 text-[0.68rem] text-muted-foreground`,"aria-hidden":`true`,children:t.map((e,t)=>{let i=n.includes(e);return(0,R.jsx)(`span`,{title:i?void 0:`${r??`This model`} does not support ${e}`,className:q(`absolute -translate-x-1/2 whitespace-nowrap`,t===v&&`font-medium text-foreground`,!i&&`opacity-40`),style:{left:`${t/g*100}%`},children:ZJ[e]??e},e)})}),x?(0,R.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})]})}function nY(e){return(0,R.jsx)(hD,{...e})}function rY(e){return(0,R.jsx)(gD,{"data-slot":`popover-trigger`,...e})}function iY({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,R.jsx)(_D,{children:(0,R.jsx)(vD,{"data-slot":`popover-content`,align:t,sideOffset:n,className:q(`reui-menu z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-xl border p-1 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 motion-reduce:animate-none`,e),...r})})}function aY(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function oY({value:e,options:t,onChange:n,label:r,className:i,disabled:a}){let[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),p=(0,m.useId)(),h=(0,m.useMemo)(()=>t.filter(e=>aY(e,c)),[t,c]),g=t.find(t=>t.value===e);(0,m.useEffect)(()=>{o&&(l(``),d(Math.max(0,t.findIndex(t=>t.value===e))))},[o]),(0,m.useEffect)(()=>{c&&d(0)},[c]),(0,m.useEffect)(()=>{f.current?.querySelector(`[data-index="${u}"]`)?.scrollIntoView({block:`nearest`})},[u,o,h.length]);function _(t){t&&(s(!1),t.value!==e&&n(t.value))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),d(e=>Math.min(h.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),d(e=>Math.max(0,e-1))):e.key===`Home`&&!c?(e.preventDefault(),d(0)):e.key===`End`&&!c?(e.preventDefault(),d(Math.max(0,h.length-1))):e.key===`Tab`?s(!1):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),_(h[u]))}return(0,R.jsxs)(nY,{open:o,onOpenChange:s,children:[(0,R.jsxs)(rY,{type:`button`,role:`combobox`,"aria-label":r,"aria-keyshortcuts":`Enter Space ArrowDown ArrowUp`,"aria-description":`When focused, press Enter, Space or an arrow key to choose. Type to search.`,"aria-expanded":o,"aria-haspopup":`listbox`,"aria-controls":o?p:void 0,disabled:a,onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),s(!0))},"data-slot":`select-trigger`,className:q(`reui-select flex h-8 w-full min-w-0 items-center justify-between gap-2 overflow-hidden rounded-lg border bg-card px-2.5 text-[0.8125rem] whitespace-nowrap outline-none transition-[border-color,box-shadow] duration-150 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:pointer-events-none disabled:opacity-50`,i),children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(iY,{align:`start`,sideOffset:4,collisionPadding:8,onOpenAutoFocus:e=>{e.preventDefault(),e.currentTarget.querySelector(`input`)?.focus()},className:`p-0 flex max-h-[min(20rem,var(--radix-popover-content-available-height))] w-[max(var(--radix-popover-trigger-width),17rem)] max-w-(--radix-popover-content-available-width) flex-col overflow-hidden rounded-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,R.jsx)(ag,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:v,role:`searchbox`,"aria-label":`Search ${r}`,"aria-controls":p,"aria-activedescendant":h[u]?`${p}-${u}`:void 0,placeholder:`Search…`,autoComplete:`off`,spellCheck:!1,className:`h-8 min-w-0 flex-1 bg-transparent text-[0.8125rem] outline-none placeholder:text-muted-foreground`})]}),(0,R.jsxs)(`div`,{ref:f,id:p,role:`listbox`,"aria-label":r,className:`min-h-0 flex-1 overflow-y-auto p-1`,children:[h.length===0?(0,R.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,R.jsxs)(`div`,{id:`${p}-${n}`,role:`option`,"aria-selected":t.value===e,"data-index":n,onPointerMove:()=>d(n),onClick:()=>_(t),className:q(`flex cursor-default items-center gap-2 rounded-lg px-2.5 py-1.5 text-[0.8125rem] select-none`,n===u&&`bg-accent`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,R.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})]})}function sY({label:e,help:t,children:n,stacked:r}){return(0,R.jsxs)(`div`,{className:r?`grid gap-1.5`:`grid gap-1.5 md:grid-cols-[minmax(0,1fr)_minmax(0,18rem)] md:items-center md:gap-6`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,R.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,R.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,R.jsx)(`div`,{className:`min-w-0`,children:n})]})}function cY({children:e}){return(0,R.jsx)(iq,{dense:!0,children:(0,R.jsx)(aq,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-3`,children:e})})}function lY({value:e,items:t,label:n,onChange:r}){return(0,R.jsx)(oY,{value:e,options:t.map(e=>({value:e.value,label:e.label,...e.help?{hint:e.help}:{}})),label:n,onChange:r,className:`max-md:h-auto max-md:min-h-11 max-md:items-start max-md:py-2 max-md:[&>span:first-child]:overflow-visible max-md:[&>span:first-child]:text-clip max-md:[&>span:first-child]:whitespace-normal max-md:[&>span:first-child]:break-words`})}var uY=`(prefers-color-scheme: dark)`,dY=[`dark`,`light`,`system`],fY=m.createContext(void 0);function pY(e){return e!==null&&dY.includes(e)}function mY(){return window.matchMedia(uY).matches?`dark`:`light`}function hY(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.remove()})})}}function gY(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function _Y({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return pY(e)?e:t}),s=m.useCallback(e=>{localStorage.setItem(n,e),o(e)},[n]),c=m.useCallback(e=>{let t=document.documentElement,n=e===`system`?mY():e,i=r?hY():null;t.classList.remove(`light`,`dark`),t.classList.add(n),i&&i()},[r]);m.useEffect(()=>{if(c(a),a!==`system`)return;let e=window.matchMedia(uY),t=()=>{c(`system`)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},[a,c]),m.useEffect(()=>{let e=e=>{e.repeat||e.metaKey||e.ctrlKey||e.altKey||gY(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:mY()===`dark`?`light`:`dark`;return localStorage.setItem(n,t),t})};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n]),m.useEffect(()=>{let e=e=>{if(e.storageArea===localStorage&&e.key===n){if(pY(e.newValue)){o(e.newValue);return}o(t)}};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[t,n]);let l=m.useMemo(()=>({theme:a,setTheme:s}),[a,s]);return(0,R.jsx)(fY.Provider,{...i,value:l,children:e})}var vY=()=>{let e=m.useContext(fY);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},yY=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],bY={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},xY={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},SY=`inherit`,CY=`inherit`,wY=`Use the session's current model`,TY=`__custom__`,EY=`custom…`,DY=`Type a provider/model id`,OY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],kY={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},AY=[{id:`startOn`,label:`On when pi starts`,help:`off: pi starts as plain pi, and ctrl+shift+m or /bot-lobby on turns bot-lobby on (a session that owns a task under way always starts on)`},{id:`issues`,label:`Issues tab`,help:`the GitHub Issues tab`}],jY=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],MY=`shown on the Lobby tab`,NY=`Planning rounds`,PY=`how many rounds the panel gets before the oracle settles the rest alone`,FY=[2,3,5,8,0],IY=`Split long plans`,LY=`saving a plan with more steps offers to split it into up to 5 tasks`,RY=[6,8,10,12,0],zY=`Port`,BY=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,VY=`Open browser`,HY=`open this page in the browser when pi starts`,UY=[{id:`off`,label:`off`,help:`tasks work in the folder you started them in`},{id:`branch`,label:`branch`,help:`each new task gets a git branch named after it, checked out in the working folder`},{id:`worktree`,label:`worktree`,help:`each new task gets its own worktree and branch, named after it: every agent runs there, apart from your checkout`}],WY=`Git isolation`,GY=[{id:`off`,label:`off`,help:`agents' work is never linted`},{id:`advise`,label:`advise`,help:`the oracle and QA are told what the project's linter finds on the lines a task changed; nothing is held`},{id:`block`,label:`block`,help:`new lint errors also hold a task's completion until they are fixed, or you accept the work as it is`}],KY={intro:`After every worker step, before QA and at completion, bot-lobby lints only the files the task's agents touched. Problems on the lines the task changed are the task's; anything already there is shown but never holds it. Suppressions and lint-config changes the task adds go to QA to judge.`,mode:`Lint gate`,command:`Command`,commandHelp:`empty runs the linters the project configures (ESLint, Biome, Oxlint, Ruff), each from its own folder; a command runs without a shell from the repository's top, with {files} standing for the touched files`,commandPlaceholder:`found from the project`,extensions:`File types`,extensionsHelp:`which touched files the command is given, such as .ts .tsx .py`,extensionsPlaceholder:`every touched file`,timeout:`Time limit`,timeoutHelp:`for one linter run; one that runs over reads as could not run, and holds nothing`,found:`Found in this project`,foundHelp:`config files in the project and the folders a few levels below it`,foundNone:`No linter config found. Add one to the project, or set a command above.`,foundReplaced:`The command replaces these.`,installed:`installed`,missing:`not installed`,missingHelp:`install the project's dependencies there, or lint cannot run`,top:`project root`},qY=[{id:`auto`,label:`Auto (OpenCode's free Jev, else TypeSafe)`},{id:`opencode`,label:`OpenCode Zen`},{id:`typesafe`,label:`TypeSafe`},{id:`openrouter`,label:`OpenRouter`},{id:`vercel`,label:`Vercel AI Gateway`}],JY=[{id:`seats`,label:`Planning seats`,help:`each round, only the seats your idea or latest answers touch sit; 1-4 in the Plan tab pins one`},{id:`answers`,label:`Obvious answers`,help:`a panel question whose recommended option the conversation already makes clearly right is answered for you (listed under Assumptions)`},{id:`triage`,label:`Task triage`,help:`a new task's size, domains and research need reach the Master as hints; a quick fix that is really a task is held for you`},{id:`effort`,label:`Effort routing`,help:`a simple step runs one thinking level lower, a trivial one on the cheaper model below; a routed run that falls short runs again on your settings`},{id:`qa`,label:`QA risk`,help:`once a task's work is in, the classifier reads the diff and sizes QA to it: no QA agent for a change with nothing that runs, a light check for a small one, deep review where a defect would spread; with it off the engine's rules decide`},{id:`review`,label:`Pull request read`,help:`the Git tab's quick read of a pull request: its size, and how likely it is risky, security-relevant, breaking or untested, before an agent reviews it`},{id:`knowledge`,label:`Relevant knowledge`,help:`when an agent's knowledge, standards or decisions file is too long for its prompt, the classifier picks the sections that bear on the step, and the agent is told where the rest is`},{id:`scripts`,label:`Shared scripts`,help:`the classifier matches each step to the shared scripts that do part of it, and the agent is told to run them instead of redoing the work`},{id:`files`,label:`File hints`,help:`scouts, workers, quick fixes and the planning panel start with the files most likely needed, and can look more up with find_relevant_files`}],YY={enabled:`Classifier`,enabledHelp:`a fast model makes the obvious decisions so large models spend fewer tokens on them`,engine:`Answered by`,engineHelp:`Jev, another classifier model, or any chat model your pi logins offer (OpenAI, Anthropic, Google, …); a small, fast one works best`,engineJev:`Jev on a host`,engineJevHelp:`TypeSafe's classifier, on the host below`,engineClassifier:`classifier model`,engineChat:`chat model, answers as JSON`,host:`Host`,model:`Model`,modelHelp:`empty uses the host's default`,key:`API key`,keyNote:`the key pi already holds for this host; it is never read by this page`,cheap:`Cheaper model`,cheapNone:`none: trivial steps keep their model and drop a thinking level`,cheapHelp:`what effort routing runs trivial steps on`},XY={title:`Settings`,intro:`Each agent's model and effort, the workflow and its lint gate, the lobby and the classifier. Changes save as you make them.`,loading:`Loading settings…`,loadFailed:`Could not load settings.`,saved:`Settings saved`,saving:`Saving…`,appearanceHelp:`Light, dark, or follow your system. Kept in this browser only.`,themeLabel:`Mode`,themeItems:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],notificationsLabel:`Browser notifications`,notificationsHelp:`While this page is hidden, tell me when a question waits, a task finishes or a background session asks something.`,notificationsBlocked:`Notifications are blocked in your browser. Allow them for this site and try again.`,notificationsUnsupported:`This browser does not offer notifications.`,notificationsOn:`Browser notifications are on.`,notificationsOff:`Browser notifications are off.`,installLabel:`Install bot-lobby`,installHelp:`Opens in its own fullscreen window, with the shell cached so it starts when Pi is not running.`,installButton:`Install as fullscreen app`,installUnavailable:`Your browser has not offered to install it. Use its menu: “Install app” (Chrome, Edge) or Share, then “Add to Home Screen” (Safari).`,installDone:`bot-lobby is installed.`,installedNow:`Running as an installed app.`,fullscreenLabel:`Fullscreen`,fullscreenHelp:`Hide the browser's own bars for this tab (F11 does the same).`,fullscreenOn:`Exit fullscreen`,fullscreenOff:`Go fullscreen`},ZY=`https://tweakcn.com/editor/theme`;function QY(){let{theme:e}=vY();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function $Y({palette:e,dark:t}){let n=se(e,t);return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border px-2`,style:{background:n.background},children:[(0,R.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,R.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,R.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function eX(){let e=Ue(),t=QY(),n=(0,m.useRef)(null);function r(t){let r=t.key===`ArrowRight`||t.key===`ArrowDown`?1:t.key===`ArrowLeft`||t.key===`ArrowUp`?-1:0;if(!r)return;t.preventDefault(),t.stopPropagation();let i=Math.max(0,e.all.findIndex(t=>t.id===e.active.id)),a=e.all[(i+r+e.all.length)%e.all.length];e.choose(a.id),window.requestAnimationFrame(()=>n.current?.querySelector(`[data-theme-id="${a.id}"]`)?.focus())}return(0,R.jsx)(`div`,{ref:n,role:`radiogroup`,"aria-label":`Colour theme`,onKeyDown:r,className:`grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-4`,children:e.all.map(n=>{let r=n.id===e.active.id;return(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space ArrowLeft ArrowRight`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"aria-checked":r,"data-theme-id":n.id,tabIndex:r?0:-1,onClick:()=>e.choose(n.id),className:q(`grid gap-1.5 rounded-lg border p-2 text-left outline-none transition-[border-color,box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40`,r?`border-primary bg-accent shadow-[0_0_0_1px_var(--primary)]`:`border-border hover:bg-accent/50`),children:[(0,R.jsx)($Y,{palette:n,dark:t}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,R.jsxs)(`span`,{className:`truncate max-md:break-words max-md:overflow-visible max-md:text-clip max-md:whitespace-normal`,children:[n.name,e.isSaved(n.id)?(0,R.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function tX({entry:e}){let t=Ue(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(e.name),[o,s]=(0,m.useState)();async function c(){let n=i.trim();if(!n||n===e.name)return r(!1);try{await t.rename(e.id,n),r(!1),s(void 0),H.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,R.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1 max-md:flex-wrap`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,R.jsx)(Uq,{autoFocus:!0,value:i,maxLength:40,"aria-label":`New name for ${e.name}`,"aria-invalid":o?!0:void 0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),a(e.name),r(!1))},className:`h-8 max-w-64 max-md:h-11 max-md:min-h-11 max-md:min-w-0 max-md:flex-1`}),(0,R.jsx)(X,{label:`Save the name`,text:`Save`,icon:Vp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,R.jsx)(X,{label:`Keep the old name`,icon:Vg,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium max-md:break-words max-md:overflow-visible max-md:text-clip max-md:whitespace-normal`,children:e.name}),(0,R.jsx)(X,{label:`Rename ${e.name}`,text:`Rename`,icon:Vh,onClick:()=>{a(e.name),r(!0)}}),(0,R.jsx)(SM,{label:`Remove ${e.name}`,text:`Remove`,title:`Remove ${e.name}?`,description:`It is removed for every pi session. Keep a copy of its CSS if you want to use it again.`,confirmLabel:`Remove theme`,icon:Cg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>H.error(e.message))})]}),o?(0,R.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function nX(){let e=Ue();return e.saved.length===0?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,R.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,R.jsx)(tX,{entry:e},e.id))})}function rX(){let e=Ue(),[t,n]=(0,m.useState)(``),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(!1),l=(0,m.useRef)(null);async function u(t,a){let s=ee(t);if(`error`in s){o(s.error);return}o(void 0),c(!0);try{let t=await e.adopt(s,r.trim()||s.name||a);n(``),i(``);let o=s.light?s.dark?void 0:`dark`:`light`;H.success(o?`${t.name} saved and applied. It has no ${o} colours, so ${o} mode keeps the default ones.`:`${t.name} saved and applied.`)}catch(e){o(e.message)}finally{c(!1)}}async function d(e){if(e){if(e.size>2e5){o(`That file is too large to be a theme.`);return}await u(await e.text(),e.name.replace(/\.[^.]+$/,``)||`Custom theme`)}}return(0,R.jsxs)(`div`,{className:`grid gap-2`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,R.jsxs)(`a`,{href:ZY,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,R.jsx)(Dm,{"aria-hidden":`true`,className:`size-3`})]}),`, press Code, copy it, and paste it here, or save it as a file and upload that. Colours and fonts are used; corners stay the page's own.`]}),(0,R.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,R.jsx)(Uq,{value:r,maxLength:40,placeholder:`the theme's own name, or the file's`,onChange:e=>i(e.target.value),className:`h-8 max-w-80 text-foreground max-md:h-11 max-md:min-h-11`})]}),(0,R.jsx)(sM,{value:t,onChange:e=>{n(e.target.value),o(void 0)},rows:4,spellCheck:!1,"aria-label":`Theme CSS from tweakcn`,"aria-invalid":a?!0:void 0,placeholder:`:root {
|
|
92
92
|
--background: oklch(0.98 0 0);
|
|
93
93
|
--primary: oklch(0.55 0.2 260);
|
|
94
94
|
…
|
|
95
95
|
}
|
|
96
96
|
.dark { … }`,className:`max-h-56 font-mono text-xs md:text-xs`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 max-md:flex-wrap`,children:[(0,R.jsx)(`input`,{ref:l,type:`file`,accept:`.css,.json,text/css,application/json`,hidden:!0,tabIndex:-1,"aria-label":`Upload a theme file`,onChange:e=>{d(e.target.files?.[0]),e.target.value=``}}),(0,R.jsx)(X,{label:`Save and apply the pasted theme`,text:`Save theme`,icon:Vp,tone:`primary`,disabled:!t.trim()||s,onClick:()=>void u(t,`Custom theme`)}),(0,R.jsx)(X,{label:`Upload a .css or .json theme file`,text:`Upload file`,icon:kg,disabled:s,onClick:()=>l.current?.click()}),a?(0,R.jsx)(`p`,{role:`alert`,className:`ml-2 min-w-0 text-xs text-destructive max-md:ml-0 max-md:basis-full`,children:a}):null]})]})}function iX(){let{theme:e,setTheme:t}=vY(),n=xJ();return(0,R.jsx)(qH,{prominent:!0,title:kY.appearance,children:(0,R.jsxs)(cY,{children:[(0,R.jsx)(sY,{label:`Prompt sounds`,help:`A droplet for each new actionable prompt or delivery review. Kept in this browser; sound starts after interaction. Desktop notifications remain separate.`,children:(0,R.jsx)(GJ,{checked:!n,onCheckedChange:e=>yJ(!e),"aria-label":`Prompt sounds`})}),(0,R.jsx)(sY,{label:XY.themeLabel,help:XY.appearanceHelp,children:(0,R.jsx)(lY,{value:e,items:XY.themeItems.map(e=>({value:e.id,label:e.label})),label:XY.themeLabel,onChange:e=>t(e)})}),(0,R.jsx)(sY,{label:`Colour theme`,help:`The page's colours, the same in every pi session.`,stacked:!0,children:(0,R.jsx)(eX,{})}),(0,R.jsx)(sY,{label:`Saved themes`,help:`Themes you imported, kept with pi for every session and project.`,stacked:!0,children:(0,R.jsx)(nX,{})}),(0,R.jsx)(sY,{label:`Import a theme`,stacked:!0,children:(0,R.jsx)(rX,{})})]})})}var aX={master:[`master`],designer:[`agents`,`designer`],backend:[`agents`,`backend`],qa:[`agents`,`qa`],scout:[`scout`],researcher:[`researcher`],quickfix:[`quickFix`],planner:[`planner`]},oX=[...AY,...jY.map(e=>({id:`panel:${e.id}`,label:e.label,help:MY}))];function sX(e,t){switch(t){case`master`:return e.master;case`scout`:return{model:e.scout.model,thinking:`low`,timeoutMs:e.scout.timeoutMs,mcpTools:e.scout.mcpTools};case`researcher`:return e.researcher;case`quickfix`:return e.quickFix;case`planner`:return e.planner;default:return e.agents[t]}}function cX(e,t){return aX[e].reduceRight((e,t)=>({[t]:e}),t)}function lX(e,t){return e.find(e=>e.id===t)?.thinkingLevels??OY}function uX(e,t){return OY[$J(OY,e,Math.max(0,OY.indexOf(t)))]??t}var dX=e=>e>0?`${e} round${e===1?``:`s`}`:`unlimited`,fX=e=>e>0?`over ${e} steps`:`never`;function pX({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),t]})}function mX(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(``),a=e.models.some(t=>t.id===e.value),o=[...e.inherit?[{value:SY,label:CY,help:wY}]:[],...e.none?[{value:SY,label:`none`,help:`Use the primary model`}]:[],...!e.inherit&&!e.none&&e.value===`inherit`?[{value:SY,label:CY,help:wY}]:[],...e.models.map(e=>({value:e.id,label:e.id,...e.label&&e.label!==e.id?{help:e.label}:{}})),...!a&&e.value!==`inherit`?[{value:e.value,label:e.value,help:DY}]:[],{value:TY,label:EY,help:DY}],s=t=>{if(t!==`__custom__`)return e.onChange(t);i(a?``:e.value),n(!0)},c=()=>{let t=r.trim();n(!1),t&&t!==e.value&&e.onChange(t)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(lY,{value:e.value,items:o,label:e.label,onChange:s}),t?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,R.jsx)(Uq,{autoFocus:!0,value:r,placeholder:`provider/model`,"aria-label":`Model id`,className:`min-w-0 flex-1 max-md:h-11 max-md:min-h-11`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),(0,R.jsx)(X,{label:`Use this model`,icon:Vp,tone:`primary`,onClick:c})]}):null]})}function hX({label:e,help:t,checked:n,onChange:r}){return(0,R.jsxs)(`div`,{className:`flex min-h-0 items-center justify-between gap-4 max-md:min-h-11 max-md:items-start`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,R.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,R.jsx)(GJ,{checked:n,onCheckedChange:r,"aria-label":e})]})}function gX({value:e,onSave:t,placeholder:n,label:r}){let[i,a]=(0,m.useState)(e);(0,m.useEffect)(()=>a(e),[e]);let o=()=>{let n=i.trim();n!==e&&t(n)};return(0,R.jsx)(Uq,{value:i,placeholder:n,"aria-label":r,className:`max-md:h-11 max-md:min-h-11`,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())}})}function _X({value:e,label:t,onSave:n}){let r=Math.round(e/6e4);return(0,R.jsx)(yX,{label:t,value:String(r),min:1,suffix:`min`,onSave:e=>{let t=Number(e);return!Number.isFinite(t)||t<=0?(H.error(`"${e}" is not a positive number of minutes.`),!1):(n(Math.round(t*6e4)),!0)}})}function vX({value:e,onSave:t}){return(0,R.jsx)(yX,{label:zY,value:String(e),min:0,max:65535,onSave:e=>!/^\d+$/.test(e)||Number(e)>65535?(H.error(`"${e}" is not a port (0, or 1-65535).`),!1):(t(Number(e)),!0)})}function yX({label:e,value:t,min:n,max:r,suffix:i,onSave:a}){let[o,s]=(0,m.useState)(t);(0,m.useEffect)(()=>s(t),[t]);let c=()=>{o!==t&&(a(o.trim())||s(t))};return(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(Uq,{type:`number`,inputMode:`numeric`,min:n,max:r,value:o,"aria-label":e,className:q(i?`pr-10`:void 0,`max-md:h-11 max-md:min-h-11`),onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),i?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:i}):null]})}function bX({value:e,label:t,onSave:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(sM,{rows:2,value:r,"aria-label":t,onChange:e=>i(e.target.value),onBlur:()=>{r.trim()!==e&&n(r.trim())}}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Saved when you leave the field.`})]})}function xX({kind:e,config:t,models:n,save:r}){let i=sX(t,e),a=t=>r(cX(e,t)),o=bY[e],s=lX(n,i.model),c=t=>{let r={model:t};e!==`scout`&&!lX(n,t).includes(i.thinking)&&(r.thinking=uX(lX(n,t),i.thinking)),a(r)},l=e===`scout`?`low`:uX(s,i.thinking),u=e!==`scout`&&e!==`researcher`,[d,f]=(0,m.useState)(!!i.instructions);return(0,R.jsxs)(`section`,{className:q(rq({spacing:`default`}),`glass min-w-0`),children:[(0,R.jsxs)(oq,{className:`flex-row items-baseline justify-between gap-3 py-3 max-md:flex-col max-md:items-start`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-semibold max-md:max-w-full max-md:break-words`,children:o}),(0,R.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground max-md:min-w-0 max-md:max-w-full max-md:break-words max-md:overflow-visible max-md:text-clip max-md:whitespace-normal`,children:[i.model===`inherit`?`session model`:i.model,` · `,e===`scout`?`low`:i.thinking]})]}),(0,R.jsxs)(aq,{className:`flex min-w-0 flex-col gap-3`,children:[(0,R.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-1`,children:(0,R.jsx)(pX,{label:xY.model,children:(0,R.jsx)(mX,{value:i.model,models:n,label:`${o} model`,inherit:e===`master`,onChange:c})})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-muted p-3 max-md:items-start max-md:[&_[role=slider]]:h-11`,children:[e===`scout`?(0,R.jsx)(XJ,{level:l}):null,(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:e===`scout`?(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:xY.thinking}),(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`low`,` (fixed for scouts)`]})]}):(0,R.jsx)(tY,{value:i.thinking,levels:OY,supported:s,model:i.model===`inherit`?`the session model`:i.model,label:`${o} effort`,onChange:e=>a({thinking:e})})})]}),(0,R.jsxs)(`div`,{className:`flex min-h-7 items-center justify-between gap-3 max-md:flex-wrap max-md:items-start`,children:[u?(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"aria-expanded":d,onClick:()=>f(e=>!e),className:`flex min-h-8 max-w-full items-center gap-1 rounded-md text-left text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/30 max-md:h-auto max-md:min-h-11`,children:[(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-3.5 transition-transform duration-200 ease-snap`,d&&`rotate-90`)}),xY.instructions,!d&&i.instructions?(0,R.jsx)(`span`,{className:`text-primary`,children:`· set`}):null]}):(0,R.jsx)(`span`,{}),e===`master`?null:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 max-md:flex-wrap`,children:[(0,R.jsx)(`span`,{className:`break-words text-xs text-muted-foreground`,children:`Time limit`}),(0,R.jsx)(`div`,{className:`w-24`,children:(0,R.jsx)(_X,{value:i.timeoutMs??t.workflow.agentTimeoutMs,label:`${o} time limit`,onSave:e=>a({timeoutMs:e})})})]})]}),u&&d?(0,R.jsx)(bX,{value:i.instructions??``,label:`${o} instructions`,onSave:e=>a({instructions:e})}):null,(0,R.jsx)(bX,{value:(i.mcpTools??[]).join(`
|
|
97
|
-
`),label:`${o} MCP tool grants (one exact tool name per line)`,onSave:e=>a({mcpTools:e.split(/\s+/).filter(Boolean)})}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Grant exact names such as mcp__github__get_issue. Children inherit these grants; read-only agents also require read-only tools.`})]})]})}function SX(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function CX({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,R.jsx)(hX,{label:t.label,help:t.help,checked:SX(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function wX({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,R.jsx)(qH,{prominent:!0,title:kY.workflow,children:(0,R.jsx)(cY,{children:(0,R.jsx)(sY,{label:WY,help:UY.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,R.jsx)(lY,{value:n,items:UY.map(e=>({value:e.id,label:e.label})),label:WY,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var TX=e=>e?`${e}/`:KY.top;function EX(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function DX({replaced:e}){let t=xj(`settings.linters`,{},[]),n=t.data?.linters;return(0,R.jsx)(sY,{label:KY.found,help:e?KY.foundReplaced:KY.foundHelp,children:n?n.length===0?(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground md:text-right`,children:KY.foundNone}):(0,R.jsx)(`ul`,{"aria-label":KY.found,className:q(`flex flex-col gap-1.5 md:items-end`,e&&`opacity-60`),children:n.map(e=>(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,R.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:TX(e.folder)}),(0,R.jsxs)(`span`,{title:e.installed?void 0:KY.missingHelp,className:q(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,R.jsx)(rm,{"aria-hidden":`true`,className:`size-3.5`}):(0,R.jsx)(tm,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?KY.installed:KY.missing]})]},`${e.tool}:${e.folder}`))}):(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground md:text-right`,children:t.error?t.error:`Looking…`})})}function OX({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,R.jsxs)(qH,{prominent:!0,title:kY.lint,children:[(0,R.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:KY.intro}),(0,R.jsxs)(cY,{children:[(0,R.jsx)(sY,{label:KY.mode,help:GY.find(e=>e.id===n.mode)?.help,children:(0,R.jsx)(lY,{value:n.mode,items:GY.map(e=>({value:e.id,label:e.label})),label:KY.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,R.jsxs)(`div`,{className:q(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,R.jsx)(sY,{label:KY.command,help:KY.commandHelp,children:(0,R.jsx)(gX,{value:n.command,label:KY.command,placeholder:KY.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,R.jsx)(sY,{label:KY.extensions,help:KY.extensionsHelp,children:(0,R.jsx)(gX,{value:n.extensions.join(` `),label:KY.extensions,placeholder:KY.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:EX(e)}})})}):null,(0,R.jsx)(sY,{label:KY.timeout,help:KY.timeoutHelp,children:(0,R.jsx)(_X,{value:n.timeoutMs,label:`Lint ${KY.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,R.jsx)(DX,{replaced:i})]})]})]})}function kX({config:e,save:t}){let n=e.lobby.web;return(0,R.jsx)(qH,{prominent:!0,title:kY.lobby,children:(0,R.jsxs)(cY,{children:[oX.map(n=>(0,R.jsx)(CX,{config:e,item:n,save:t},n.id)),(0,R.jsx)(sY,{label:NY,help:PY,children:(0,R.jsx)(lY,{value:String(e.lobby.maxPlanningRounds),items:FY.map(e=>({value:String(e),label:dX(e)})),label:NY,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,R.jsx)(sY,{label:IY,help:LY,children:(0,R.jsx)(lY,{value:String(e.lobby.splitPlanAbove),items:RY.map(e=>({value:String(e),label:fX(e)})),label:IY,onChange:e=>void t({lobby:{splitPlanAbove:Number(e)}})})}),(0,R.jsx)(sY,{label:zY,help:BY,children:(0,R.jsx)(vX,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,R.jsx)(hX,{label:VY,help:HY,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})})]})})}function AX({config:e,models:t,save:n}){let r=e.classifier,i=qY.find(e=>e.id===r.provider)?.label;return(0,R.jsx)(qH,{prominent:!0,title:kY.classifier,children:(0,R.jsxs)(cY,{children:[(0,R.jsx)(hX,{label:YY.enabled,help:YY.enabledHelp,checked:r.enabled,onChange:e=>void n({classifier:{enabled:e}})}),(0,R.jsx)(sY,{label:YY.host,children:(0,R.jsx)(lY,{value:r.provider,items:qY.map(e=>({value:e.id,label:e.label})),label:YY.host,onChange:e=>void n({classifier:{provider:e}})})}),(0,R.jsx)(sY,{label:YY.model,help:YY.modelHelp,children:(0,R.jsx)(gX,{value:r.model,label:YY.model,placeholder:`the host's default`,onSave:e=>void n({classifier:{model:e}})})}),(0,R.jsx)(sY,{label:YY.key,help:YY.keyNote,children:(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground md:text-right`,children:i??r.provider})}),JY.map(e=>(0,R.jsx)(hX,{label:e.label,help:e.help,checked:r.features[e.id],onChange:t=>void n({classifier:{features:{[e.id]:t}}})},e.id)),(0,R.jsx)(sY,{label:YY.cheap,help:YY.cheapHelp,children:(0,R.jsx)(mX,{value:r.effort.cheapModel,models:t,label:YY.cheap,none:!0,onChange:e=>void n({classifier:{effort:{cheapModel:e}}})})})]})})}function jX(){let e=MJ(),t=async e=>{if(!e)return PJ();let t=await NJ();t===`granted`?H.success(XY.notificationsOn):H.error(t===`unsupported`?XY.notificationsUnsupported:XY.notificationsBlocked)};return(0,R.jsx)(qH,{prominent:!0,title:kY.notifications,children:(0,R.jsx)(cY,{children:(0,R.jsx)(hX,{label:XY.notificationsLabel,help:XY.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function MX(){let{available:e,install:t}=y(),n=b(),r=x();return(0,R.jsx)(qH,{prominent:!0,title:kY.install,children:(0,R.jsxs)(cY,{children:[(0,R.jsx)(sY,{label:XY.installLabel,help:n?XY.installedNow:XY.installHelp,children:n?null:(0,R.jsx)(`div`,{className:`flex md:justify-end`,children:(0,R.jsx)(X,{label:XY.installButton,icon:Tm,tone:`primary`,onClick:()=>e?void t().then(()=>H.success(XY.installDone)):H.warning(XY.installUnavailable)})})}),r.supported?(0,R.jsx)(sY,{label:XY.fullscreenLabel,help:XY.fullscreenHelp,children:(0,R.jsx)(`div`,{className:`flex md:justify-end`,children:(0,R.jsx)(X,{label:r.on?XY.fullscreenOn:XY.fullscreenOff,icon:r.on?yh:sh,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var NX=[`Agents`,`Workflow`,`Linting`,`Lobby`,`Classifier`,`Appearance & notifications`];function PX({config:e,models:t,onConfig:n}){let[r,i]=(0,m.useState)(`Agents`),a=(0,m.useRef)(Promise.resolve()),o=e=>{let t=async()=>{try{return n((await Te(`settings.set`,{patch:e})).config),H.success(XY.saved),!0}catch(e){return H.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},r=a.current.then(t,t);return a.current=r,r};return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-6 px-5 pt-5 pb-dock md:px-8 md:pt-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:XY.title}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:XY.intro})]}),(0,R.jsx)(`nav`,{"aria-label":`Settings sections`,className:`-mx-1 min-w-0 flex flex-wrap gap-1 border-b border-border pb-3 max-md:flex-nowrap max-md:overflow-x-auto max-md:overscroll-x-contain max-md:pb-2`,children:NX.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-current":r===e?`page`:void 0,"aria-controls":`settings-${e.split(` `)[0]}`,onClick:()=>i(e),className:q(`h-8 rounded-lg border border-transparent px-3 text-sm font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40 max-md:min-h-11 max-md:h-auto max-md:shrink-0 max-md:whitespace-nowrap`,r===e?`btn-raised bg-card text-foreground`:`text-muted-foreground hover:text-foreground`),children:e},e))}),(0,R.jsx)(`div`,{id:`settings-Agents`,hidden:r!==`Agents`,"aria-hidden":r!==`Agents`,children:(0,R.jsx)(qH,{prominent:!0,title:kY.agents,children:(0,R.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:yY.map(n=>(0,R.jsx)(xX,{kind:n,config:e,models:t,save:o},n))})})}),(0,R.jsx)(`div`,{id:`settings-Workflow`,hidden:r!==`Workflow`,"aria-hidden":r!==`Workflow`,children:(0,R.jsx)(wX,{config:e,save:o})}),(0,R.jsx)(`div`,{id:`settings-Linting`,hidden:r!==`Linting`,"aria-hidden":r!==`Linting`,children:(0,R.jsx)(OX,{config:e,save:o})}),(0,R.jsx)(`div`,{id:`settings-Lobby`,hidden:r!==`Lobby`,"aria-hidden":r!==`Lobby`,children:(0,R.jsx)(kX,{config:e,save:o})}),(0,R.jsx)(`div`,{id:`settings-Classifier`,hidden:r!==`Classifier`,"aria-hidden":r!==`Classifier`,children:(0,R.jsx)(AX,{config:e,models:t,save:o})}),(0,R.jsx)(`div`,{id:`settings-Appearance`,hidden:r!==`Appearance & notifications`,"aria-hidden":r!==`Appearance & notifications`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,R.jsx)(iX,{}),(0,R.jsx)(jX,{}),(0,R.jsx)(MX,{})]})})]})}function FX(){return(0,R.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-5 pt-5 pb-dock md:px-8 md:pt-8`,role:`status`,"aria-label":XY.loading,children:[0,1,2,3].map(e=>(0,R.jsx)(`div`,{className:`h-48 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function IX(){let e=xj(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,R.jsx)(yj,{message:`${XY.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,R.jsx)(PX,{config:t,models:e.data?.models??[],onConfig:i}):(0,R.jsx)(FX,{})}function LX(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var RX=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,zX=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style`.split(` `)),BX=new Set(`class id title role aria-label aria-hidden colspan rowspan scope`.split(` `));function VX(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>5e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function HX(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function UX(e){if(!zX.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,HX(t.value)):BX.has(t.name)||e.removeAttribute(t.name);e.localName===`style`&&(e.textContent=HX(e.textContent??``));for(let t of[...e.children])UX(t)}function WX(e,t){try{return GX(e,t??LX())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${RX}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function GX(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])UX(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${RX}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${HX(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function KX({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>WX(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,R.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:q(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,R.jsxs)(`div`,{ref:s,className:q(`group/mock relative h-80 w-full max-w-full overflow-hidden rounded-lg border bg-background max-md:min-h-0 max-md:max-h-full max-md:overflow-x-hidden max-md:overflow-y-auto max-md:overscroll-contain`,n),children:[(0,R.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,tabIndex:a?-1:void 0,className:q(`absolute top-0 left-0 origin-top-left border-0`,a&&`pointer-events-none`),style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,R.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,className:`absolute inset-0 flex items-end justify-end p-2 outline-none focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:ring-inset max-md:p-3`,children:(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-card/90 px-1.5 py-0.5 text-[0.6875rem] font-medium text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity group-hover/mock:opacity-100 group-focus-within/mock:opacity-100`,children:[(0,R.jsx)(ah,{"aria-hidden":`true`,className:`size-3`}),`Expand`]})}):null]})}var qX=/\s*\(recommended\)\s*$/i,JX=1024,YX=`(max-width: 767.98px)`,XX=`max-md:hidden`,ZX=e=>e.replace(qX,``);function QX(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function $X({option:e}){let t=ZX(e.label);return QX(e)?(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,R.jsx)(KX,{preview:e.htmlPreview,label:t,minWidth:JX,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,R.jsx)(`img`,{src:F(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,R.jsx)(WH,{text:e.preview,className:q(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,R.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function eZ({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=xf(),l=cA(YX),{keyboardOpen:u,keyboardInset:d}=BA(),f=(0,m.useRef)(null),p=(0,m.useRef)(null),[h,g]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),_=e[h],v=e.length-1;(0,m.useEffect)(()=>s?.(h),[h,s]),(0,m.useLayoutEffect)(()=>{let e=f.current;e&&(e.scrollLeft=h*e.clientWidth),p.current?.focus()},[]);let y=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),v),n=f.current;g(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[v,c]);(0,m.useEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=h*e.clientWidth});return t.observe(e),()=>t.disconnect()},[h]);function b(){let e=f.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==h&&t>=0&&t<=v&&g(t)}function x(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),y(h+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),y(t.key===`Home`?0:v);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),y(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(h))}let S=r.includes(h),C=l&&u?{height:`calc(100vh - ${d}px - 1.5rem)`,maxHeight:`calc(100vh - ${d}px - 1.5rem)`}:void 0;return(0,R.jsxs)(`div`,{ref:p,tabIndex:-1,"data-autofocus":``,onKeyDown:x,style:C,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none max-md:h-[calc(100svh-1.5rem)] max-md:max-h-[calc(100svh-1.5rem)]`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3 sm:px-5`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:l?`Back to the question`:`Back · Esc`,onClick:()=>o(h),className:`max-md:size-11`,children:(0,R.jsx)(_h,{"aria-hidden":`true`})}),(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[h+1,` of `,e.length]}),(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===h,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>y(t),className:q(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/40 max-md:h-11 max-md:min-w-11`,t===h?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,R.jsx)(`span`,{className:`truncate`,children:ZX(e.label)}),r.includes(t)?(0,R.jsx)(Vp,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{ref:f,onScroll:b,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,R.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${ZX(t.label)}`,"aria-hidden":n!==h,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 overflow-y-hidden px-4 py-4 sm:px-14 max-md:overflow-y-auto max-md:overscroll-contain`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,R.jsx)(`span`,{className:`font-medium`,children:ZX(t.label)}),qX.test(t.label)?(0,R.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,R.jsx)(WH,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)($X,{option:t})})]},n))}),h>0?(0,R.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:l?`Previous option`:`Previous · ←`,onClick:()=>y(h-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full max-md:hidden max-md:size-11`,children:(0,R.jsx)(Gp,{"aria-hidden":`true`})}):null,h<v?(0,R.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:l?`Next option`:`Next · →`,onClick:()=>y(h+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full max-md:hidden max-md:size-11`,children:(0,R.jsx)(qp,{"aria-hidden":`true`})}):null]}),(0,R.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3 sm:px-5`,children:[(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`←→`,className:XX,children:`option`}),a?(0,R.jsx)(iA,{chord:`Enter`,className:XX,children:i?S?`unpick`:`pick`:`choose`}):null,(0,R.jsx)(iA,{chord:`Esc`,className:XX,children:`back`})]}),a&&_?(0,R.jsxs)(Y,{type:`button`,onClick:()=>a(h),className:`max-w-full max-md:min-h-11 max-md:min-w-11`,children:[i&&S?`Unpick`:i?`Pick`:`Choose`,(0,R.jsx)(`span`,{className:`truncate`,children:ZX(_.label)})]}):null]})]})}function tZ(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function nZ({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,R.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>tZ(e,()=>void d(),()=>{o||r()}),children:[(0,R.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,R.jsx)(sM,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24 max-md:min-h-28`})]}),c?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{size:`sm`,className:`max-md:min-h-11`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,className:`max-md:min-h-11`,disabled:o,onClick:r,children:`Cancel`})]})]})}var rZ=1200;function iZ({question:e}){let[t,n]=(0,m.useState)(),r=XA(t!==void 0,YA.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{"aria-label":`Mockups`,className:`grid grid-cols-2 gap-2 md:grid-cols-3`,children:i.map(({option:e,index:t,mockup:r})=>(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsx)(KX,{preview:r,label:ZX(e.label),frameWidth:rZ,onOpen:()=>n(t),className:`aspect-[3/2] h-auto`}),(0,R.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,ZX(e.label)]})]},t))}),(0,R.jsx)(HA,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,R.jsx)(eZ,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function aZ({questions:e}){return(0,R.jsx)(`ol`,{className:`mt-1 flex flex-col gap-2`,children:e.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised flex min-w-0 flex-col gap-2 rounded-xl border p-3 text-sm`,style:{"--orb":TW(e.from)},children:[(0,R.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,R.jsxs)(`span`,{className:`mt-px inline-flex shrink-0 items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--orb)_12%,transparent)] px-2 py-0.5 text-xs font-medium text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,children:[(0,R.jsx)(bW,{source:e.from,className:`size-3`}),SW(e.from)]}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,R.jsx)(`ul`,{"aria-label":`Options`,className:`flex flex-wrap gap-1.5`,children:e.options.map(e=>(0,R.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/60 px-2 py-1 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,R.jsx)(iZ,{question:e})]},t))})}function oZ({message:e}){let t=e.decided??[];return t.length?(0,R.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1.5`,children:t.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2 rounded-lg bg-muted/60 px-2.5 py-1.5 text-sm`,children:[(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-success`}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:q(`font-medium`,CW(e.from)),children:SW(e.from)}),` `,e.question,` → `,(0,R.jsx)(`strong`,{children:e.answer}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`decided by the classifier (`,e.probability.toFixed(2),`); comment on the plan to overrule`]})]})]},t))}):null}function sZ({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await Te(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,R.jsxs)(Y,{size:`xs`,variant:`ghost`,disabled:l,onClick:()=>a(!0),className:`text-muted-foreground max-md:min-h-11 max-md:whitespace-normal`,children:[(0,R.jsx)(Vh,{"aria-hidden":`true`}),`Edit`]}):null;return(0,R.jsx)(jW,{time:e.at>0?lM(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,below:d,children:i?(0,R.jsx)(nZ,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,R.jsx)(WH,{text:c.text})})}function cZ({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,R.jsx)(sZ,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,R.jsxs)(AW,{source:`PLANNER`,name:`Panel`,time:e.at>0?lM(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,R.jsx)(aZ,{questions:i}):(0,R.jsx)(WH,{text:e.text}),(0,R.jsx)(oZ,{message:e})]})}function lZ({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,R.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,R.jsx)(MW,{children:t}):null,e.map((e,t)=>(0,R.jsx)(cZ,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,R.jsx)(AW,{source:`PLANNER`,name:`Panel`,head:!0,live:!0,aside:`the panel is thinking`,children:(0,R.jsx)(NW,{className:`mt-1`})}):null]})}var uZ=`ORACLE`,dZ=`No draft yet.`,fZ=`The draft appears after the panel's first round.`,pZ=`What each seat needs`,mZ=[`backend`,`designer`,`qa`,`researcher`],hZ={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},gZ=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,_Z={ORACLE:`Chairs the panel, and settles the last round alone.`,DEV:`Code, data and the APIs it touches.`,DESIGN:`Screens, flows and the words on them.`,QA:`Tests, edge cases and what could break.`,RESEARCH:`Prior art, docs and sources.`},vZ=[{title:`Describe it`,text:`Say what you want in the box below.`},{title:`The panel asks`,text:`Each seat asks what it needs to know.`},{title:`A draft forms`,text:`Answer, comment on lines, go another round.`},{title:`Save the plan`,text:`Keep it, or start it as a task.`}];function yZ(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function bZ(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function xZ(e,t){return`${e} ${t}${e===1?``:`s`}`}function SZ(e){return e.round===0&&e.messages.length===0&&!e.busy}function CZ(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${hZ[t.member]} failed`).split(`
|
|
98
|
-
`)[0]}function
|
|
99
|
-
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function OZ({notes:e}){return(0,R.jsx)(R.Fragment,{children:e.map((e,t)=>(0,R.jsx)(`p`,{className:`ml-6 rounded-lg border border-primary/15 bg-accent px-3 py-1.5 text-sm text-foreground italic`,children:e},t))})}var kZ=[],AZ=(0,m.memo)(function({row:e,notes:t,onComment:n}){let r=e.text.trim(),i=()=>n(r);return(0,R.jsxs)(`li`,{className:`group/line [contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[(0,R.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:t.length>0?(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,R.jsx)(`div`,{className:q(`min-w-0 flex-1 cursor-pointer rounded-lg px-2 py-1.5 transition-colors hover:bg-muted`,e.fenced&&`font-mono text-sm whitespace-pre-wrap break-words`),onClick:e=>!e.target.closest(`a`)&&i(),children:e.fenced?e.text:(0,R.jsx)(WH,{text:e.text})}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 text-muted-foreground max-md:size-11 opacity-0 transition-opacity group-hover/line:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":`Comment on this line: ${r}`,onClick:i,children:(0,R.jsx)(dh,{"aria-hidden":`true`})})]}),(0,R.jsx)(OZ,{notes:t})]})});function jZ({draft:e,comments:t,onComment:n}){let r=(0,m.useMemo)(()=>DZ(e),[e]),i=FH(r.length);return(0,R.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:r.slice(0,i).map((e,r)=>e.text.trim()?(0,R.jsx)(AZ,{row:e,notes:t.get(e.text.trim())??kZ,onComment:n},r):(0,R.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},r))})}function MZ({notes:e}){return e.length===0?null:(0,R.jsx)(qH,{title:pZ,children:(0,R.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-w-0 gap-3 max-md:flex-wrap`,children:[(0,R.jsx)(`dt`,{className:q(`w-20 shrink-0 font-medium`,CW(e.from)),children:SW(e.from)}),(0,R.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(WH,{text:e.text})})]},t))})})}function NZ({cell:e,intro:t}){let n=t?e.member?e.seated?`seated`:`not seated`:`chairs`:e.text;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:q(`inline-flex items-center gap-1.5 font-medium`,e.seated?CW(e.label):`text-muted-foreground`),children:[(0,R.jsx)(bW,{source:e.label,className:`size-3.5`}),SW(e.label)]}),e.working&&!t?(0,R.jsx)(pj,{className:`size-3.5`,"aria-hidden":`true`}):null,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function PZ({cell:e,intro:t,onToggled:n}){let{member:r}=e,i=`inline-flex min-h-8 items-center gap-2 rounded-lg border border-border px-3 text-[0.8125rem] max-md:min-h-11`;if(!r)return(0,R.jsx)(`li`,{className:q(i,`bg-muted`),children:(0,R.jsx)(NZ,{cell:e,intro:t})});let a=async()=>{await U(`planner.toggleSeat`,{member:r})&&n()};return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(i,`cursor-pointer transition-colors`,e.seated?`btn-raised bg-card`:`border-dashed text-muted-foreground hover:bg-muted`),children:[(0,R.jsx)(kG,{checked:e.seated,onCheckedChange:()=>void a(),"aria-label":`${SW(e.label)} sits on the panel`}),(0,R.jsx)(NZ,{cell:e,intro:t})]})})}function FZ({cells:e,intro:t,onToggled:n}){return(0,R.jsx)(`ul`,{"aria-label":`Panel`,className:`flex flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(PZ,{cell:e,intro:t,onToggled:n},e.label))})}function IZ({cell:e,onToggled:t}){let{member:n}=e,r=SW(e.label),i=q(`flex h-full flex-col gap-2 rounded-xl border p-3.5 transition-[background-color,border-color,box-shadow]`,e.seated?`border-[color-mix(in_oklab,var(--orb)_26%,var(--border))] bg-[color-mix(in_oklab,var(--orb)_5%,var(--card))] shadow-card`:`border-dashed border-input bg-transparent`),a=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid size-6 place-items-center rounded-lg bg-[color-mix(in_oklab,var(--orb)_14%,transparent)] text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,!e.seated&&`opacity-50 grayscale`),children:(0,R.jsx)(bW,{source:e.label,className:`size-3.5`})}),(0,R.jsx)(`span`,{className:q(`truncate text-sm font-semibold`,e.seated?CW(e.label):`text-muted-foreground`),children:r})]}),n?(0,R.jsx)(kG,{checked:e.seated,onCheckedChange:()=>void LZ(n,t),"aria-label":`${r} sits on the panel`}):null]}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:_Z[e.label]}),(0,R.jsx)(`span`,{className:q(`mt-auto text-xs font-medium`,e.seated?`text-foreground`:`text-muted-foreground`),children:n?e.seated?`seated`:`sits this one out`:`always chairs`})]}),o={"--orb":TW(e.label)};return n?(0,R.jsx)(`li`,{style:o,children:(0,R.jsx)(`label`,{className:q(i,`cursor-pointer`,e.seated?`hover:shadow-[0_0_0_3px_color-mix(in_oklab,var(--orb)_10%,transparent)]`:`hover:bg-muted`),children:a})}):(0,R.jsx)(`li`,{style:o,children:(0,R.jsx)(`div`,{className:i,children:a})})}async function LZ(e,t){await U(`planner.toggleSeat`,{member:e})&&t()}function RZ({cells:e,onToggled:t}){return(0,R.jsx)(`ul`,{"aria-label":`Panel`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-5`,children:e.map(e=>(0,R.jsx)(IZ,{cell:e,onToggled:t},e.label))})}function zZ({snap:e}){let t=wZ(e),n=!e.busy&&CZ(e)!==void 0;return(0,R.jsxs)(`p`,{role:`status`,className:n?`flex items-center gap-2 text-sm text-destructive`:`flex items-center gap-2 text-sm text-muted-foreground`,children:[e.busy?(0,R.jsx)(pj,{className:`size-3.5`,"aria-hidden":`true`}):null,t.join(` · `)]})}function BZ(){return(0,R.jsx)(X,{label:`Previous plans`,text:`Previous`,icon:Yh,shortcut:`H`,onClick:()=>aj(ij(`plan`,`previous`))})}function VZ({snap:e,onDone:t}){let n=sA(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await U(e,{})&&t()};return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e.questions.length>0&&!e.busy?(0,R.jsx)(X,{label:`Answer questions`,icon:lh,tone:`primary`,shortcut:`A`,onClick:()=>void r(`planner.answer`)()}):null,e.retryable?(0,R.jsx)(X,{label:`Retry`,icon:$h,shortcut:`R`,onClick:()=>void r(`planner.retry`)()}):null,(0,R.jsx)(BZ,{}),(0,R.jsx)(X,{"data-plan-save":!0,label:`Save the plan`,text:`Save`,icon:rg,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()}),(0,R.jsx)(SM,{icon:Nm,label:`New plan`,shortcut:`N`,title:`Start a new plan?`,description:`The conversation and the draft are left behind. Saved plans are not touched.`,confirmLabel:`New plan`,onConfirm:()=>void U(`planner.new`,{}).then(t)})]})}function HZ({snap:e,onDone:t}){return(0,R.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border px-5 py-3 max-md:shrink max-md:px-4 max-md:py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Planning`}),(0,R.jsx)(zZ,{snap:e})]}),(0,R.jsx)(VZ,{snap:e,onDone:t})]}),(0,R.jsx)(FZ,{cells:EZ(e),intro:!1,onToggled:t})]})}var UZ=()=>aj(ij(`plan`,`previous`)),WZ=e=>aj(ij(`plan`,`previous`,e));function GZ(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?dM(Math.max(0,t)):``}function KZ(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,GZ(e.updatedAt)].filter(Boolean).join(` · `)}function qZ({plan:e,selected:t}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>WZ(e.id),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,R.jsx)(jU,{variant:`secondary`,children:`draft`}):null]}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:KZ(e,e.messages)})]})})}function JZ({id:e,onGone:t}){let n=xj(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,R.jsx)(yj,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await U(`planner.previousOpen`,{id:e})&&aj(ij(`plan`))},o=async()=>{await U(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await U(`planner.previousDelete`,{id:e})&&t()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Carry on planning`,text:`Carry on`,icon:Uh,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,R.jsx)(X,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?Cp:Tp,shortcut:`E`,onClick:()=>void o()}),(0,R.jsx)(SM,{icon:Cg,label:`Delete`,shortcut:`Delete`,title:`Delete "${r.title}"?`,description:`The conversation and the draft are removed for good.`,confirmLabel:`Delete plan`,variant:`destructive`,onConfirm:()=>void s()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,KZ(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(qH,{title:`Draft plan`,children:[r.draft?(0,R.jsx)(WH,{text:r.draft}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,R.jsx)(MZ,{notes:r.notes})]}),(0,R.jsx)(qH,{title:`Conversation`,children:(0,R.jsx)(lZ,{messages:r.messages,readOnly:!0})})]})}function YZ({id:e}){let t=eM(),[n,r]=(0,m.useState)(!1),i=xj(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,R.jsx)(yj,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,R.jsxs)(aM,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,R.jsx)(X,{label:`Back to the current plan`,icon:kp,iconOnly:!0,onClick:()=>aj(ij(`plan`))}),(0,R.jsx)(X,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?Yh:Tp,pressed:n,onClick:()=>{r(e=>!e),UZ()}})]}),s=i.data?a.length===0?(0,R.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:n?`No archived plans.`:`No previous plans. A plan you leave without saving it as a task waits here; one saved as a task is in the Tasks tab.`}):(0,R.jsx)(`ul`,{className:q(NU,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,R.jsx)(qZ,{plan:t,selected:t.id===e},t.id))}):(0,R.jsx)(oM,{});return(0,R.jsx)(iM,{wide:t,list:(0,R.jsxs)(R.Fragment,{children:[o,s]}),detail:e?(0,R.jsx)(JZ,{id:e,onGone:()=>{i.reload(),UZ()}},e):null,open:e!==void 0,onClose:UZ,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function XZ({line:e,onClose:t,onSent:n}){let r=XA(e!==void 0,YA.confirm);return(0,R.jsx)(HA,{open:e!==void 0&&r,onOpenChange:e=>!e&&t(),label:`Comment on this line`,className:`max-w-xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6 max-md:p-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-medium`,children:`Comment on this line`}),(0,R.jsx)(`p`,{className:`mt-1 line-clamp-3 text-sm break-words text-muted-foreground`,children:e})]}),(0,R.jsx)(WU,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async r=>e===void 0||!await U(`planner.commentLine`,{line:e,text:r.trim()})?!1:(n(e,r.trim()),t(),!0)})]})})}function ZZ({limit:e}){return e<=0?null:(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,R.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function QZ({snap:e,onDone:t}){let n=EZ(e);return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-8 pb-dock max-md:px-4 max-md:pt-5 md:px-8 md:pt-10`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(tg,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,R.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:gZ})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,R.jsx)(BZ,{}),(0,R.jsx)(ZZ,{limit:e.limit})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,R.jsx)(KH,{title:`The panel`,right:yZ(n)})}),(0,R.jsx)(RZ,{cells:n,onToggled:t})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,R.jsx)(KH,{title:`How a plan comes together`})}),(0,R.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:vZ.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised relative flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Dp,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,R.jsx)(iA,{chord:`/`,className:`max-md:hidden`,children:`write`}),(0,R.jsx)(iA,{chord:`Enter`,className:`max-md:hidden`,children:`send to the panel`})]})]})})}function $Z({snap:e,wide:t}){let{ref:n,onScroll:r}=gW(JSON.stringify(e.messages));return(0,R.jsxs)(tM,{className:`workspace-pane flex flex-col rounded-xl border shadow-xs`,children:[(0,R.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,R.jsx)(KH,{title:`Conversation`,className:`w-full`})}),(0,R.jsx)(`div`,{ref:n,onScroll:r,className:q(`min-h-0 overflow-y-auto overscroll-y-contain`,t?`flex-1 px-5 pt-5 pb-dock`:`max-h-[45svh] p-5`),children:(0,R.jsx)(lZ,{messages:e.messages,busy:e.busy})})]})}function eQ({snap:e,comments:t,onComment:n,wide:r}){return(0,R.jsxs)(tM,{className:`workspace-pane flex flex-col rounded-xl border shadow-xs`,children:[(0,R.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,R.jsx)(KH,{title:`Draft plan`,className:`w-full`})}),(0,R.jsxs)(`div`,{className:q(`flex min-h-0 flex-col gap-5 overflow-y-auto overscroll-y-contain px-5 pt-5 pb-dock`,r&&`flex-1`),children:[e.draft?(0,R.jsx)(jZ,{draft:e.draft,comments:t,onComment:n}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.busy?fZ:dZ}),(0,R.jsx)(MZ,{notes:e.notes})]})]})}function tQ({snap:e,reload:t}){let n=eM(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(new Map);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(HZ,{snap:e,onDone:t}),(0,R.jsxs)(`div`,{className:q(n?`grid min-h-0 flex-1 grid-cols-[minmax(0,46fr)_minmax(0,54fr)] grid-rows-[minmax(0,1fr)] gap-3 p-3`:`flex flex-col gap-3 p-3`,`min-w-0`),children:[(0,R.jsx)($Z,{snap:e,wide:n}),(0,R.jsx)(eQ,{snap:e,comments:a,onComment:i,wide:n})]}),(0,R.jsx)(XZ,{line:r,onClose:()=>i(void 0),onSent:(e,t)=>o(n=>new Map(n).set(e,[...n.get(e)??[],t]))})]})}function nQ({rest:e=[]}){return e[0]===`previous`?(0,R.jsx)(YZ,{id:e[1]}):(0,R.jsx)(rQ,{})}function rQ(){let e=xj(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,R.jsx)(yj,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,R.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=SZ(t);return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,R.jsx)(QZ,{snap:t,onDone:e.reload}):(0,R.jsx)(tQ,{snap:t,reload:e.reload})})}var iQ=`Describe a small change in the box below and one agent makes it now, beside any running task.`;function aQ(e){return e.prompt.split(`
|
|
100
|
-
`).find(e=>e.trim())?.trim()??`(empty)`}function
|
|
101
|
-
`)?(0,R.jsx)(WH,{text:e.prompt}):null,(0,R.jsx)(dQ,{job:e}),(0,R.jsx)(qH,{title:`Steps`,children:(0,R.jsx)(fQ,{job:e})}),e.files?.length?(0,R.jsx)(qH,{title:`Edited`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,R.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,R.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:e.error}):null,e.report?(0,R.jsx)(qH,{title:`Report`,children:(0,R.jsx)(WH,{text:e.report})}):null]})}function hQ({status:e}){if(e===`running`)return(0,R.jsx)(pj,{className:`size-3.5`,"aria-label":`running`});let t={queued:_m,success:Vp,failed:Vg,timeout:Vg,cancelled:xh,held:Nh,running:_m}[e];return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4 ${e===`success`?`text-success`:e===`failed`||e===`timeout`?`text-destructive`:e===`held`?`text-warning`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:e})]})}function gQ({job:e,selected:t,now:n,onSelect:r}){let i=cQ(e,n);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.id),className:q(MU,`flex-row items-start gap-2.5 text-sm max-md:min-h-11`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,R.jsx)(hQ,{status:e.status})}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:aQ(e)}),i?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function _Q({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(gQ,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var vQ=()=>aj(ij(`quickfix`)),yQ=e=>aj(ij(`quickfix`,e));function bQ(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function xQ(){return(0,R.jsx)(sj,{className:`m-4 flex-1`,children:(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(Ug,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{className:`font-medium text-foreground`,children:iQ})]})})}function SQ({id:e}){let t=eM(),n=xj(`quickfix.list`,{},[`quickfix`]),r=oQ(n.data?.jobs??[]),i=bQ(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,R.jsx)(yj,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,R.jsx)(xQ,{}):(0,R.jsx)(CQ,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function CQ({id:e,wide:t,loaded:n,jobs:r,now:i}){let a=e??(t?r[0]?.id:void 0),o=r.find(e=>e.id===a),s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Quick fixes`,count:String(r.length)}),n?(0,R.jsx)(_Q,{jobs:r,selectedId:a,now:i,onSelect:yQ}):(0,R.jsx)(oM,{})]});return(0,R.jsx)(iM,{wide:t,list:s,detail:o?(0,R.jsx)(mQ,{job:o,now:i}):e?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:vQ,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var wQ={},TQ=new Set;function EQ(e){wQ=e;for(let e of[...TQ])e()}function DQ(e){wQ.taskId!==e&&EQ({...wQ,taskId:e})}function OQ(e){(wQ.session?.name!==e?.name||JSON.stringify(wQ.session?.address)!==JSON.stringify(e?.address))&&EQ({...wQ,session:e})}function kQ(e){return TQ.add(e),()=>{TQ.delete(e)}}function AQ(){return(0,m.useSyncExternalStore)(kQ,()=>wQ,()=>wQ)}var jQ=8;function MQ(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function NQ(e,t){let n=Math.min(t,jQ);if(n<=0)return[];let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return Array.from({length:n},(e,t)=>t<r)}function PQ({done:e,total:t}){return(0,R.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:NQ(e,t).map((e,t)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function FQ({check:e,className:t}){return(0,R.jsx)(e===`done`?rm:e===`dropped`?pm:hm,{"aria-hidden":`true`,className:q(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}function IQ({entry:e}){let t=e.at?lM(e.at):``;return e.role===`note`?(0,R.jsxs)(`li`,{className:`break-words text-center text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[e.text,t?` · ${t}`:``]}):e.role===`you`?(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col items-end gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[t,` `,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`})]}),(0,R.jsx)(`div`,{className:`max-w-[85%] rounded-xl rounded-tr-sm border border-primary/10 bg-you px-3.5 py-2`,children:(0,R.jsx)(WH,{text:e.text})})]}):(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-primary`}),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`Oracle`}),` `,t]}),(0,R.jsx)(`div`,{className:`max-w-[90%] pl-4`,children:(0,R.jsx)(WH,{text:e.text})})]})}function LQ({entries:e,more:t,loading:n,onMore:r,empty:i}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-col gap-3`,children:[t?(0,R.jsx)(`div`,{className:`flex self-center`,children:(0,R.jsx)(X,{label:`Load earlier messages`,icon:$p,disabled:n,onClick:r??(()=>void 0)})}):null,e.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i}):(0,R.jsx)(`ol`,{"aria-label":`Conversation`,className:`flex min-w-0 flex-col gap-4`,children:e.map(e=>(0,R.jsx)(IQ,{entry:e},e.id))})]})}function RQ({address:e,empty:t}){let n=xj(`sessions.chat`,e,[`sessions`]),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=n.data?.entries??[],c=new Set(s.map(e=>e.id)),l=[...(r?.entries??[]).filter(e=>!c.has(e.id)),...s],u=async()=>{let t=l[0];if(!t)return;o(!0);let n=await U(`sessions.chat`,{...e,before:t.id});n&&i({entries:[...n.entries,...r?.entries??[]],more:n.hasOlder}),o(!1)},d=r?.more??n.data?.hasOlder??!1;return(0,R.jsx)(LQ,{entries:l,more:d,loading:a,onMore:()=>void u(),empty:n.loading&&!n.data?`Loading the conversation…`:t})}var zQ={"this window":`This window`,background:`Background`,"other terminal":`Other terminals`},BQ=[`this window`,`background`,`other terminal`],VQ=`Nothing said yet.`,HQ=`This session runs in another terminal: its conversation shows here and your messages reach its oracle within seconds, but live activity only streams from sessions started in this window.`,UQ=`No other sessions. Start one below.`;function WQ(e,t,n){let r=t?.task;return{id:`here`,where:`this window`,name:e?.sessionName??r?.title??`unnamed session`,status:e?.busy?`working`:r?.state??`no task`,waiting:n,alive:!0,dialogs:[],...r?{task:r}:{}}}function GQ(e){let t=e.status===`exited`?`ended`:e.status===`starting`?`starting`:e.busy?`working`:`idle`;return{id:e.key,where:`background`,name:e.name,status:t,waiting:e.dialogs.length,key:e.key,alive:e.alive,dialogs:e.dialogs,...e.sessionId?{sessionId:e.sessionId}:{}}}function KQ(e){return{id:e.sessionId,where:`other terminal`,name:e.name??`unnamed session`,status:`running`,waiting:0,pid:e.pid,sessionId:e.sessionId,alive:!0,dialogs:[]}}function qQ(e,t,n,r,i){let a=new Set([e?.sessionId,...r.map(e=>e.sessionId)].filter(e=>!!e)),o=i.filter(e=>!a.has(e.sessionId));return[WQ(e,t,n),...r.map(GQ),...o.map(KQ)]}function JQ(e){return`${e} question${e===1?``:`s`} waiting for you`}function YQ(e){return e.status===`starting`?`starting ${e.name}…`:e.alive?`${e.name} has not said anything yet.`:`${e.name} has ended.`}function XQ(e){return[e.where,e.status.replace(/_/g,` `),e.pid?`pid ${e.pid}`:``].filter(Boolean).join(` · `)}function ZQ(e){return e.key?{key:e.key}:e.sessionId?{sessionId:e.sessionId}:void 0}function QQ({options:e,send:t}){return(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(Y,{variant:`outline`,className:`max-w-full min-w-0 whitespace-normal break-words text-left max-md:h-auto max-md:min-h-11`,onClick:()=>void t({value:e}),children:e},e))})}function $Q({dialog:e,send:t}){let n=(0,m.useId)(),[r,i]=(0,m.useState)(e.prefill??``);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`sr-only`,children:e.title}),(0,R.jsx)(sM,{id:n,rows:e.method===`editor`?4:2,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value)}),(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:`Send the answer`,text:`Send`,icon:Np,tone:`primary`,disabled:!r.trim(),onClick:()=>void t({value:r.trim()})})})]})}function e$({dialog:e,send:t}){return e.method===`select`?(0,R.jsx)(QQ,{options:e.options??[],send:t}):e.method===`confirm`?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,R.jsx)(Y,{className:`max-md:h-auto max-md:min-h-11`,onClick:()=>void t({confirmed:!0}),children:`Yes`}),(0,R.jsx)(Y,{variant:`outline`,className:`max-md:h-auto max-md:min-h-11`,onClick:()=>void t({confirmed:!1}),children:`No`})]}):(0,R.jsx)($Q,{dialog:e,send:t})}function t$({sessionKey:e,dialog:t,onAnswered:n}){let r=async r=>{await U(`sessions.answer`,{key:e,dialogId:t.id,answer:r})&&n()};return(0,R.jsxs)(`div`,{className:`card-raised flex min-w-0 flex-col gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsx)(`p`,{className:`break-words text-sm font-medium text-foreground`,children:t.title}),t.message?(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:t.message}):null]}),(0,R.jsx)(e$,{dialog:t,send:r}),(0,R.jsx)(`div`,{className:`flex self-start`,children:(0,R.jsx)(X,{label:`Put it away`,text:`Put away`,icon:Vg,onClick:()=>void r({cancelled:!0})})})]})}function n$({sessionKey:e,dialogs:t,onAnswered:n}){return t.length===0?null:(0,R.jsxs)(`section`,{"aria-label":`Questions waiting`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-foreground`,children:JQ(t.length)}),t.map(t=>(0,R.jsx)(t$,{sessionKey:e,dialog:t,onAnswered:n},t.id))]})}var r$={"this window":Ch,background:Zm,"other terminal":pg};function i$({where:e,className:t}){let n=r$[e];return(0,R.jsx)(n,{"aria-hidden":`true`,className:q(`size-4 shrink-0 text-muted-foreground`,t)})}function a$({task:e}){let t=e.progress;return(0,R.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`break-all`,children:e.id}),t&&t.total>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(PQ,{done:t.done,total:t.total}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[t.done,`/`,t.total]})]}):null]})}function o$({entry:e}){let{key:t}=e;return e.where===`this window`?(0,R.jsx)(Gj,{children:(0,R.jsx)(X,{label:`Back to this window`,text:`Back to the Lobby`,icon:kp,tone:`primary`,shortcut:`B`,onClick:()=>aj(`#/lobby`)})}):t?(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Move here`,icon:jp,tone:`primary`,shortcut:`M`,onClick:()=>void U(`sessions.switch`,{key:t})}),(0,R.jsx)(SM,{icon:dm,label:`Stop the session`,text:`Stop`,shortcut:`S`,title:`Stop ${e.name}?`,description:`Its process ends. The task keeps its state and can be resumed in this window.`,confirmLabel:`Stop session`,variant:`destructive`,disabled:!e.alive,onConfirm:()=>void U(`sessions.stop`,{key:t})})]}):null}function s$({entry:e,lobby:t}){let n=ZQ(e);return e.where===`this window`?(0,R.jsx)(LQ,{entries:t?.chat??[],more:!1,empty:VQ}):n?(0,R.jsx)(RQ,{address:n,empty:e.where===`other terminal`?`Nothing said in this session yet.`:YQ(e)},e.id):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:VQ})}function c$({entry:e,lobby:t,onChanged:n}){return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`flex min-w-0 max-w-full flex-col gap-4 max-md:pb-dock`,children:[(0,R.jsx)(o$,{entry:e}),(0,R.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,R.jsxs)(`h3`,{className:`flex min-w-0 max-w-full flex-wrap items-center gap-2.5 text-lg font-semibold tracking-tight text-foreground`,children:[(0,R.jsx)(i$,{where:e.where,className:`size-[1.1rem]`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.name})]}),(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:XQ(e)}),e.task?(0,R.jsx)(a$,{task:e.task}):null,e.where!==`background`&&e.waiting>0?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:JQ(e.waiting)}):null]}),e.where===`other terminal`?(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:HQ}):null,e.key?(0,R.jsx)(n$,{sessionKey:e.key,dialogs:e.dialogs,onAnswered:n}):null,(0,R.jsx)(qH,{title:`Conversation`,children:(0,R.jsx)(s$,{entry:e,lobby:t})})]})}function l$({entry:e,selected:t,onSelect:n}){let r=xf();return(0,R.jsx)(B.li,{layout:!r&&`position`,initial:!1,"data-slot":`active-session`,className:`min-w-0 border-t border-border first:border-t-0`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:q(MU,`min-w-0 flex-row items-start gap-3 rounded-none px-4 py-3 text-sm focus-visible:ring-inset max-md:min-h-11 max-md:h-auto`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg bg-foreground/4 text-foreground/75 shadow-[inset_0_0_0_1px_var(--border)]`,children:(0,R.jsx)(i$,{where:e.where})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:q(`flex min-w-0 flex-wrap items-center gap-2 text-foreground`,t&&`font-medium`),children:[(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.name}),e.where===`this window`?(0,R.jsx)(jU,{variant:`secondary`,radius:`full`,size:`sm`,children:`This window`}):null]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 break-words text-xs text-muted-foreground`,children:[e.status===`working`||e.status===`starting`?(0,R.jsx)(pj,{className:`size-3`,"aria-hidden":`true`}):null,e.status.replace(/_/g,` `),e.waiting>0?(0,R.jsxs)(jU,{variant:`warning-light`,radius:`full`,className:`text-warning tabular-nums`,children:[e.waiting,` waiting`]}):null]})]})]})})}function u$({where:e,entries:t,selectedId:n,onSelect:r}){return(0,R.jsxs)(`section`,{"aria-label":zQ[e],className:`flex flex-col`,children:[(0,R.jsx)(`h3`,{className:PU,children:(0,R.jsx)(KH,{title:zQ[e],right:String(t.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:`workspace-section mx-3 mb-2 flex flex-col overflow-hidden rounded-xl border shadow-xs`,children:t.map(e=>(0,R.jsx)(l$,{entry:e,selected:e.id===n,onSelect:r},e.id))})]})}function d$({entries:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:BQ.map(r=>{let i=e.filter(e=>e.where===r);return i.length>0?(0,R.jsx)(u$,{where:r,entries:i,selectedId:t,onSelect:n},r):null})})}var f$=()=>aj(`#/sessions`),p$=e=>aj(`#/sessions/${encodeURIComponent(e)}`);function m$({windows:e}){return e.length===0?null:(0,R.jsx)(`div`,{className:`px-4 pb-4 pt-2`,children:(0,R.jsx)(qH,{title:`Other windows`,children:(0,R.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-h-8 min-w-0 max-w-full items-center rounded-lg px-2.5 text-sm text-foreground break-words underline-offset-4 transition-colors hover:bg-muted hover:underline max-md:min-h-11 max-md:h-auto`,children:e.name})},e.url))})})})}function h$(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That session is not on the list any more.`})}function g$({id:e}){let t=eM(),n=sA(`status`).data,r=sA(`lobby`).data,i=sA(`prompts`).data?.prompts.length??0,a=xj(`sessions.list`,{},[`sessions`]);if(!a.data&&a.error)return(0,R.jsx)(yj,{message:`Could not load sessions. ${a.error}`,onRetry:a.reload});let o=qQ(n,r,i,a.data?.background??[],a.data?.live??[]),s=e??(t?o[0]?.id:void 0),c=o.find(e=>e.id===s),l=c&&c.where!==`this window`&&c.alive?ZQ(c):void 0,u=l?JSON.stringify(l):``,d=c?.name;(0,m.useEffect)(()=>(OQ(l&&d?{name:d,address:l}:void 0),()=>OQ(void 0)),[u,d]);let f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Sessions`,count:String(o.length)}),a.data?(0,R.jsx)(d$,{entries:o,selectedId:s,onSelect:p$}):(0,R.jsx)(oM,{}),a.data&&o.length===1?(0,R.jsx)(`p`,{className:`px-4 pb-3 text-sm text-muted-foreground`,children:UQ}):null,(0,R.jsx)(m$,{windows:n?.windows??[]})]}),p=c?(0,R.jsx)(c$,{entry:c,lobby:r,onChanged:a.reload},c.id):e?(0,R.jsx)(h$,{}):null;return(0,R.jsx)(iM,{wide:t,list:f,detail:p,open:!!e,onClose:f$,hint:`Select a session to see its conversation.`,describe:`Session detail`})}function _$(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function v$(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function y$(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}function b$({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,R.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,v$(_$(e,n,t)),` execution`]})}function x$({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=y$(r,e);return(0,R.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,v$(e.workedMs+i)]})}function S$({timing:e,work:t,stopped:n=!1}){return t?(0,R.jsx)(x$,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,R.jsx)(b$,{timing:e,stopped:n},JSON.stringify(e)):(0,R.jsx)(`span`,{children:`Timing unavailable`})}var C$=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,w$={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function T$({delivery:e,title:t}){return(0,R.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,R.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,R.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,R.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,R.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function E$({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,R.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11 max-md:whitespace-normal`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function D$(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?Te(`tasks.deliveryReview`,{taskId:t}):e===`defer`?Te(`tasks.deliveryDefer`,r):Te(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function O$({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=P(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function k$(e){return e.scope.current===e.identity&&e.project===P()}function A$(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await D$(r,t.taskId,e.current.reviewId);k$(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){k$(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function j$(e){let t=O$(e),n=A$(t,e),r=XA(t.confirm,YA.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function M$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,R.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:w$[e.current.status]}),e.current.error||e.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,R.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,R.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,R.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function N$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 max-md:grid-cols-1 md:grid-cols-2`,children:[(0,R.jsx)(E$,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,R.jsx)(E$,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{variant:`ghost`,className:`max-md:min-h-11`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,R.jsx)(Y,{variant:`ghost`,className:`max-md:min-h-11`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function P$({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:C$;return(0,R.jsx)(HA,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,R.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,R.jsx)(`p`,{className:`text-sm`,children:n}),(0,R.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,R.jsx)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function F$({title:e,review:t}){return(0,R.jsxs)(qH,{title:`Completed work · delivery review`,right:w$[t.current.status],children:[(0,R.jsx)(T$,{delivery:t.current,title:e}),(0,R.jsx)(M$,{review:t}),(0,R.jsx)(N$,{review:t}),(0,R.jsx)(P$,{review:t})]})}function I$(e){let t=j$(e);return(0,R.jsx)(F$,{title:e.title,review:t})}var L$={open:hm,delivered:sm,addressed:rm},R$={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function z$({comment:e}){let t=dM(Date.now()-Date.parse(e.createdAt)),n=L$[e.status];return(0,R.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),R$[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function B$({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,R.jsxs)(`li`,{className:`card-raised min-w-0 rounded-lg border px-3.5 py-2.5`,children:[r?(0,R.jsx)(nZ,{text:s.text,onSave:async n=>{let r=await Te(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,R.jsx)(WH,{text:s.text}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(z$,{comment:s}),n&&!r?(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,className:`max-md:min-h-11`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function V$({taskId:e,finished:t,canComment:n}){let r=xj(`tasks.comments`,{taskId:e},[`tasks`]),i=sA(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,R.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,R.jsx)(KH,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,R.jsx)(B$,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var H$={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},U$={open:`open`,done:`done`,dropped:`abandoned`},W$={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:`bg-accent text-muted-foreground`},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`bg-success/10 text-success`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`bg-warning/10 text-warning`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bg-destructive/10 text-destructive`}};function G$(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var K$=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function q$(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function J$(e){return e===`now`?`just now`:`${e} ago`}function Y$(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[q$(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function X$(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}function Z$(e){let t=e.filter(e=>e.kind!==`archived`),n=t.filter(e=>e.check===`open`).length,r=t.length-n,i=e.length-t.length;return[n?`${n} open`:``,r?`${r} finished`:``,i?`${i} archived`:``].filter(Boolean).join(` · `)||`0`}function Q$({step:e,stopped:t}){let n=y$(!t,e);return(0,R.jsx)(`span`,{className:`tabular-nums`,children:v$((e.workedMs??0)+n)})}function $$(){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,R.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-ping`}),(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function e1({id:e,agents:t}){let[n,r]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let i=t.filter(e=>!e.parentRunId||!t.some(t=>t.runId===e.parentRunId)).flatMap(e=>[e,...t.filter(t=>t.parentRunId===e.runId)]);return(0,R.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`mt-1.5 flex flex-col gap-1 rounded-lg border border-border bg-muted/30 px-3 py-2`,children:i.map(e=>{let r=EW({domain:e.domain}),i=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),a=Date.parse(e.startedAt);return(0,R.jsxs)(`li`,{className:q(`flex min-w-0 items-baseline gap-2 text-xs`,i&&`ml-4 border-l border-border pl-3`),children:[(0,R.jsx)(`span`,{className:q(`shrink-0 font-medium`,CW(r)),children:SW(r)}),i?(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`child`}):null,(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,title:e.instruction,children:e.instruction||`Working`}),Number.isFinite(a)?(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:v$(Math.max(0,n-a))}):null]},e.runId)})})}function t1({step:e,index:t,stopped:n}){let r=!!e.active&&!n,i=r?e.agents??[]:[],a=i.length||(e.activeAgentCount??1),[o,s]=(0,m.useState)(!1),c=(0,m.useId)(),l=e.status===`done`,u=l?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,d=l?rm:hm,f=`${a} ${a===1?`agent working`:`agents working`}`;return(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col`,"data-step":r?`active`:e.status,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm max-md:flex-wrap`,children:[r?(0,R.jsx)($$,{}):(0,R.jsx)(d,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${u}`}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,R.jsx)(`span`,{className:q(`min-w-0 break-words`,r||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),r&&i.length>0?(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,onClick:()=>s(e=>!e),className:`btn-ghost inline-flex h-5 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-primary outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,children:[`(`,f,`)`,(0,R.jsx)(Up,{"aria-hidden":`true`,className:q(`size-3 transition-transform`,o&&`rotate-180`)})]}):r?(0,R.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-primary`,children:[`(`,f,`)`]}):null,r?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:[`active · `,(0,R.jsx)(Q$,{step:e,stopped:n}),(0,R.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,R.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null]}),o&&i.length>0?(0,R.jsx)(`div`,{className:`pl-[3.25rem] max-md:pl-0`,children:(0,R.jsx)(e1,{id:c,agents:i})}):null]})}function n1({steps:e,stopped:t}){let n=e.filter(e=>e.status===`done`).length;return(0,R.jsx)(qH,{title:`Steps`,right:`${n}/${e.length} done`,children:(0,R.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,n)=>(0,R.jsx)(t1,{step:e,index:n,stopped:t},`${n}-${e.text}`))})})}function r1({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,R.jsxs)(qH,{title:`Full plan`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`inline-flex min-h-11 w-fit items-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,R.jsx)(`div`,{id:r,children:(0,R.jsx)(WH,{text:e})}):null]})}function i1({detail:e,finished:t}){return e.plan&&e.planDetails?(0,R.jsx)(r1,{text:e.planDetails}):e.plan?(0,R.jsx)(qH,{title:`Approved plan`,children:(0,R.jsx)(WH,{text:e.plan})}):e.proposal?(0,R.jsx)(qH,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,R.jsx)(WH,{text:e.proposal})}):(0,R.jsx)(qH,{title:`Plan`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function a1({amendments:e}){return e.length===0?null:(0,R.jsx)(qH,{title:`Amendments`,children:(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))})})}function o1({detail:e}){return e.waiting.length===0&&e.blockers.length===0?null:(0,R.jsx)(qH,{title:`Waiting on`,children:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.waiting.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(tm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.kind,` `,e.detail]})]},`${t}-${e.kind}`)),e.blockers.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(pm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))]})})}function s1({risk:e}){let t=W$[e.risk];return(0,R.jsxs)(qH,{title:`QA risk`,right:G$(e),children:[(0,R.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,R.jsx)(`span`,{className:q(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,R.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function c1({runs:e}){return e.length===0?null:(0,R.jsx)(qH,{title:`Recent runs`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,R.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function l1({detail:e,finished:t}){return(0,R.jsxs)(R.Fragment,{children:[e.steps.length>0?(0,R.jsx)(n1,{steps:e.steps,stopped:t}):null,e.request?(0,R.jsx)(qH,{title:`Request`,children:(0,R.jsx)(WH,{text:e.request})}):null,(0,R.jsx)(i1,{detail:e,finished:t})]})}function u1({detail:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(a1,{amendments:e.amendments}),(0,R.jsx)(o1,{detail:e}),e.qaRisk?(0,R.jsx)(s1,{risk:e.qaRisk}):null,(0,R.jsx)(c1,{runs:e.runs})]})}function d1({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return aj(`#/lobby`);let t=P(),r=()=>n.current&&P()===t;try{let t=await Te(`tasks.open`,{taskId:e.id});if(!r())return;let n=await Te(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return aj(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&aj(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,R.jsx)(X,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:jp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function f1({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,R.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,R.jsxs)(`span`,{children:[n>0?(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,R.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function p1({planId:e}){let t=xj(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,R.jsxs)(R.Fragment,{children:[n.issue?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,R.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,R.jsx)(f1,{split:n.split}):null,(0,R.jsx)(qH,{title:`Agreed plan`,children:(0,R.jsx)(WH,{text:n.brief})})]}):t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function m1({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,R.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":e.title,children:[(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Start here`,icon:Uh,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,R.jsx)(X,{label:`Start in a new session`,text:`New session`,icon:dg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,R.jsx)(SM,{icon:Cg,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,R.jsx)(FQ,{check:`open`,className:`mt-1.5`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${J$(e.age)}`:``]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,R.jsx)(p1,{planId:e.id})]})}function h1({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=P();r(!0);try{let r=await Te(`tasks.resume`,{taskId:e.id});if(P()!==n)return;let i=r.key;H(r.notice,i?{action:{label:`Watch`,onClick:()=>aj(`#/sessions/${encodeURIComponent(i)}`)}}:void 0),t()}catch(e){P()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,R.jsx)(X,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Uh,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function g1(e){if(e.kind===`archived`)return{state:`archived`,rest:J$(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${J$(e.age)}`:``;return{state:q$(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function _1(e){return e?[MQ(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function v1({row:e}){return e.progress?(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(PQ,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function y1({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=g1(e);return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,R.jsx)(FQ,{check:e.check,className:`mt-1.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[U$[e.check],`:`]}),(0,R.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,R.jsx)(`span`,{children:i}):null]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,_1(t),n].filter(Boolean).join(` · `)}),(0,R.jsx)(v1,{row:e})]})}function b1({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function x1({row:e,archive:t}){return e.check===`open`?(0,R.jsx)(SM,{label:`Archive`,icon:Tp,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,R.jsx)(X,{label:`Archive`,icon:Tp,shortcut:`E`,onClick:()=>void t()})}function S1({on:e,toggle:t}){return Uj(`a`,t),(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsxs)(`label`,{className:`flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-[0.8125rem] font-medium transition-colors hover:bg-accent max-md:min-h-11`,children:[(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,R.jsx)(`span`,{children:`Auto`}),(0,R.jsx)(GJ,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,R.jsx)(rA,{chord:`A`,className:`kbd-hint`})]})}),(0,R.jsx)(Tj,{children:`Auto mode: the oracle decides without asking`})]})}function C1(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=b1(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,R.jsxs)(Gj,{children:[s?(0,R.jsx)(h1,{row:t,onResumed:e.onChanged}):null,t.kind===`task`&&t.check===`open`?(0,R.jsx)(d1,{row:t,quiet:s}):null,t.kind===`task`?(0,R.jsx)(w1,{taskId:t.id}):null,o?(0,R.jsx)(X,{label:`Restore`,icon:Zh,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,R.jsx)(S1,{on:!!t.auto,toggle:a}):null,o?null:(0,R.jsx)(x1,{row:t,archive:r}),(0,R.jsx)(SM,{icon:Cg,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function w1({taskId:e}){let t=(0,m.useRef)(!0);(0,m.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]);async function n(){let n=P();try{let r=await Te(`tasks.open`,{taskId:e});if(!t.current||P()!==n)return;r.notice&&H.info(r.notice);let i=await Te(`status.get`,{});if(!t.current||P()!==n)return;let a=r.key??(r.sessionId===i.sessionId?`here`:r.sessionId);a?aj(`#/sessions/${encodeURIComponent(a)}`):r.notice||H.info(`This task has no active session. No replacement session was created.`)}catch(e){t.current&&P()===n&&H.error(e instanceof Error?e.message:String(e))}}return(0,R.jsx)(X,{label:`Open task conversation`,text:`Conversation`,icon:ph,shortcut:`O`,onClick:()=>void n()})}function T1(e){let{row:t}=e,n=t.kind===`plan`,r=xj(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=sA(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,R.jsx)(m1,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,R.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-5`,"aria-label":t.title,children:[(0,R.jsx)(C1,{...e}),(0,R.jsx)(y1,{row:t,task:a}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,R.jsx)(S$,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,R.jsx)(I$,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,R.jsx)(l1,{detail:r.data,finished:!o}):null,(0,R.jsx)(V$,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,R.jsx)(u1,{detail:r.data}):null,r.error&&!r.data?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function E1({row:e}){return e.check===`open`&&e.progress?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(PQ,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function D1(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function O1({row:e,card:t}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:e.status.replaceAll(`_`,` `)}):null,e.check===`open`?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:Y$(e)}):null,e.kind===`plan`?null:(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,R.jsx)(S$,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,R.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function k1({row:e,selected:t,onSelect:n,card:r=!1}){return(0,R.jsx)(`li`,{className:r?`overflow-hidden rounded-lg border border-input bg-card shadow-sm`:void 0,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsx)(FQ,{check:e.check,className:`mt-0.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[U$[e.check],`:`]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,D1(e),t&&`font-medium text-foreground`),children:e.title}),(0,R.jsx)(E1,{row:e})]}),(0,R.jsx)(O1,{row:e,card:r})]})})}function A1({rows:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:X$(e).map(({section:e,rows:r})=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:PU,children:(0,R.jsx)(KH,{title:H$[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:NU,children:r.map(e=>(0,R.jsx)(k1,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var j1=()=>aj(ij(`tasks`,`board`)),M1=e=>aj(ij(`tasks`,`board`,e)),N1=[`Backlog`,`In progress`,`Completed`];function P1(e){if(e.kind!==`archived`&&e.section!==`archived`)return e.check===`done`?`Completed`:e.kind===`plan`||e.status===`created`||e.check===`dropped`?`Backlog`:`In progress`}function F1({title:e,rows:t,id:n}){return(0,R.jsxs)(iq,{role:`region`,"aria-label":e,spacing:`sm`,className:`min-w-0 max-md:rounded-lg`,children:[(0,R.jsx)(oq,{className:`py-2`,children:(0,R.jsxs)(`h2`,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[e,(0,R.jsx)(jU,{variant:`secondary`,radius:`full`,children:t.length})]})}),(0,R.jsxs)(aq,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,R.jsx)(k1,{row:e,selected:e.id===n,onSelect:M1,card:!0},`${e.kind}-${e.id}`))}),t.length?null:(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tasks here.`})]})]})}function I1({rows:e,id:t}){return(0,R.jsx)(`div`,{className:`grid min-w-0 items-start gap-4 p-4 max-md:gap-3 max-md:p-3 md:grid-cols-3`,"aria-label":`Task board`,children:N1.map(n=>(0,R.jsx)(F1,{title:n,rows:e.filter(e=>P1(e)===n),id:t},n))})}function L1({id:e}){let t=xj(`tasks.list`,{},[`tasks`,`plans`]),n=t.data?.rows??[],r=n.find(t=>t.id===e&&P1(t)!==void 0),i=r?.kind===`task`?r.id:void 0;if((0,m.useEffect)(()=>(DQ(i),()=>DQ(void 0)),[i]),!t.data&&t.error)return(0,R.jsx)(yj,{message:`Could not load tasks. ${t.error}`,onRetry:t.reload});let a=r?(0,R.jsx)(T1,{row:r,onGone:j1,onChanged:t.reload},r.id):null;return(0,R.jsx)(iM,{wide:!1,list:t.data?(0,R.jsx)(I1,{rows:n,id:e}):(0,R.jsx)(oM,{}),detail:a,open:!!r,onClose:j1,hint:`Select a task to see its detail.`,describe:`Task detail`})}var R1=()=>aj(ij(`tasks`)),z1=e=>aj(ij(`tasks`,e));function B1(){return(0,R.jsxs)(sj,{className:`m-4 flex-1`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)($m,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{children:K$})]}),(0,R.jsx)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:()=>aj(ij(`plan`)),children:`Plan a task`})]})}function V1({shown:e,count:t,onToggle:n}){return(0,R.jsxs)(`label`,{className:`btn-raised flex h-7 min-w-0 cursor-pointer items-center gap-2 rounded-lg border bg-card px-2 text-xs font-medium transition-[box-shadow] max-md:h-11 max-md:min-w-11`,children:[(0,R.jsx)(kG,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,R.jsx)(jU,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function H1({id:e,board:t=!1}){return(0,R.jsxs)(ok,{value:t?`board`:`list`,onValueChange:e=>aj(ij(`tasks`,...e===`board`?[`board`]:[])),className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(sk,{"aria-label":`Task views`,className:`flex gap-1 border-b border-border px-4 py-2 max-md:px-3 max-md:py-1.5`,children:[(0,R.jsx)(ck,{value:`list`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`List`}),(0,R.jsx)(ck,{value:`board`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`Board`})]}),(0,R.jsx)(lk,{value:`list`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(U1,{id:e})}),(0,R.jsx)(lk,{value:`board`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(L1,{id:e})})]})}function U1({id:e}){let t=eM(),[n,r]=(0,m.useState)(!1),i=xj(`tasks.list`,{},[`tasks`,`plans`]),a=xj(`tasks.archived`,{},[`tasks`]),o=i.data?.rows??[],s=a.data?.rows??[],c=n?[...o,...s]:o,l=e??(t?c[0]?.id:void 0),u=[...c,...s].find(e=>e.id===l&&e.kind===`task`)?.id;if((0,m.useEffect)(()=>(DQ(u),()=>DQ(void 0)),[u]),!i.data&&i.error)return(0,R.jsx)(yj,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,R.jsx)(B1,{});let d=[...c,...s].find(e=>e.id===l),f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Tasks`,count:Z$(c),children:(0,R.jsx)(V1,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:K$}):(0,R.jsx)(A1,{rows:c,selectedId:l,onSelect:z1}):(0,R.jsx)(oM,{})]}),p=d?(0,R.jsx)(T1,{row:d,onGone:R1,onChanged:i.reload},d.id):e?(0,R.jsx)(W1,{}):null;return(0,R.jsx)(iM,{wide:t,list:f,detail:p,open:!!e,onClose:R1,hint:`Select a task to see its detail.`,describe:`Task detail`})}function W1(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var G1={l:`lobby`,p:`plan`,t:`tasks`,i:`issues`,u:`git`,s:`sessions`,n:`knowledge`,q:`quickfix`,m:`metrics`,e:`settings`,x:`excalidraw`};function K1(){return cA(`(max-width: 767.98px)`)?(0,R.jsxs)(`section`,{className:`flex min-h-full flex-1 flex-col items-center justify-center gap-4 px-6 py-12 text-center`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-medium`,children:`Metrics is unavailable on phones.`}),(0,R.jsx)(`a`,{href:`#/lobby`,className:`btn-tint inline-flex min-h-11 items-center justify-center rounded-lg border px-5 text-sm font-medium focus-visible:ring-3 focus-visible:ring-ring/40`,children:`Lobby`})]}):(0,R.jsx)(lJ,{})}function q1(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function J1(e){if(e.kind===`settings`)return(0,R.jsx)(IX,{});if(e.kind===`sessions`)return(0,R.jsx)(g$,{id:q1(e.key?[e.key]:[])});switch(e.tab){case`lobby`:return(0,R.jsx)(nq,{});case`tasks`:return(0,R.jsx)(H1,{...OG(e.rest)});case`plan`:return(0,R.jsx)(nQ,{rest:e.rest});case`quickfix`:return(0,R.jsx)(SQ,{id:q1(e.rest)});case`issues`:return(0,R.jsx)(hW,{rest:e.rest});case`metrics`:return(0,R.jsx)(K1,{});case`git`:return(0,R.jsx)(HU,{rest:e.rest});case`knowledge`:return(0,R.jsx)(DG,{rest:e.rest});case`excalidraw`:return(0,R.jsx)(FK,{id:q1(e.rest)})}}function Y1(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var X1={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,home:`Home`,end:`End`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function Z1(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:X1[e]}function Q1(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=Z1(n);if(!e)return;t.code=e}return t.code?t:void 0}function $1(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function e0(e,t){let n=Q1(t);return n?$1(e,n):!1}function t0(e,t){for(let n of t)if(e0(e,n.key))return n.action}function n0(e,t){for(let n of t)if(e0(e,n.key))return n.id}function r0(e){return Oj(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||ZA()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function i0(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)Pj(e.key===`j`?1:-1);else return!1;return!0}function a0(e,t){let n=n0(e,t.tabs),r=t0(e,t.keys);return!n&&!r?!1:Y1(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||ZA(),typing:Oj(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function o0(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=G1[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(i0(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function s0(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(!e.insideApp()){t0(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&r0(n)){t=0;return}if(a0(n,e)){t=0;return}t=r?o0(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var c0=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],l0=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(G1).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],u0=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`quickfix`,page:`Quick fix`,keys:[[`R`,`run anyway`],[`T`,`make a task`],[`C`,`cancel`]]},{id:`git`,page:`Git`,keys:[[`R`,`refresh`],[`V`,`review`],[`Q`,`Jev's read`],[`X`,`stop`]]},{id:`issues`,page:`Issues`,keys:[[`R`,`refresh`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`excalidraw`,page:`Excalidraw`,keys:[[`R`,`reveal`],[`C`,`copy`],[`O`,`open`],[`W`,`draw`],[`T`,`check`],[`Delete`,`remove`]]},{id:`sessions`,page:`Sessions`,keys:[[`M`,`move here`],[`S`,`stop`],[`B`,`back`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],d0=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],f0=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function p0({line:e}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,R.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,R.jsx)(Zk,{children:e},e))}):(0,R.jsx)(rA,{chord:e.label??``})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function m0(){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),u0.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(rA,{chord:e}),t]},e))})]},e.id))]})}function h0({title:e,lines:t}){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,R.jsx)(p0,{line:e},e.id))]})}function g0(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function _0(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function v0({open:e,onOpenChange:t,keys:n,tabs:r}){let i=cA(`(max-width: 767.98px)`),a=e&&!i,o=XA(a,YA.help);return(0,m.useEffect)(()=>{i&&e&&t(!1)},[i,e,t]),(0,m.useEffect)(()=>{if(!a||!o)return;let e=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&e0(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,o,a]),i?null:(0,R.jsxs)(HA,{open:a&&o,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-6 py-4`,children:[(0,R.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(rA,{chord:`Esc`}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,R.jsx)(Vg,{"aria-hidden":`true`})})]})]}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-10 gap-y-6 overflow-y-auto px-6 py-5 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(h0,{title:`Everywhere`,lines:g0(n)}),(0,R.jsx)(h0,{title:`Jump to a tab`,lines:_0(r)}),(0,R.jsx)(h0,{title:`Navigation and editing`,lines:l0}),(0,R.jsx)(h0,{title:`Message box`,lines:c0})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(h0,{title:`Lists and panes`,lines:d0}),(0,R.jsx)(m0,{}),(0,R.jsx)(h0,{title:`Questions`,lines:f0})]})]})]})}function y0(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function b0(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new Ce(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Ce(r.error,r.code,n.status);return r.result}function x0(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function S0(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var C0=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function w0(e,t){let n=e.lastIndexOf(`
|
|
97
|
+
`),label:`${o} MCP tool grants (one exact tool name per line)`,onSave:e=>a({mcpTools:e.split(/\s+/).filter(Boolean)})}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Grant exact names such as mcp__github__get_issue. Children inherit these grants; read-only agents also require read-only tools.`})]})]})}function SX(e,t){return t.startsWith(`panel:`)?e.lobby.panels[t.slice(6)]:e.lobby[t]}function CX({config:e,item:t,save:n}){let r=t.id.startsWith(`panel:`);return(0,R.jsx)(hX,{label:t.label,help:t.help,checked:SX(e,t.id),onChange:e=>{n(r?{lobby:{panels:{[t.id.slice(6)]:e}}}:{lobby:{[t.id]:e}})}})}function wX({config:e,save:t}){let n=e.workflow.gitIsolation;return(0,R.jsx)(qH,{prominent:!0,title:kY.workflow,children:(0,R.jsx)(cY,{children:(0,R.jsx)(sY,{label:WY,help:UY.find(e=>e.id===n)?.help??`enter cycles off, branch, worktree`,children:(0,R.jsx)(lY,{value:n,items:UY.map(e=>({value:e.id,label:e.label})),label:WY,onChange:e=>void t({workflow:{gitIsolation:e}})})})})})}var TX=e=>e?`${e}/`:KY.top;function EX(e){return e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}function DX({replaced:e}){let t=xj(`settings.linters`,{},[]),n=t.data?.linters;return(0,R.jsx)(sY,{label:KY.found,help:e?KY.foundReplaced:KY.foundHelp,children:n?n.length===0?(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground md:text-right`,children:KY.foundNone}):(0,R.jsx)(`ul`,{"aria-label":KY.found,className:q(`flex flex-col gap-1.5 md:items-end`,e&&`opacity-60`),children:n.map(e=>(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.tool}),(0,R.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:TX(e.folder)}),(0,R.jsxs)(`span`,{title:e.installed?void 0:KY.missingHelp,className:q(`inline-flex shrink-0 items-center gap-1 text-xs`,e.installed?`text-success`:`text-warning`),children:[e.installed?(0,R.jsx)(rm,{"aria-hidden":`true`,className:`size-3.5`}):(0,R.jsx)(tm,{"aria-hidden":`true`,className:`size-3.5`}),e.installed?KY.installed:KY.missing]})]},`${e.tool}:${e.folder}`))}):(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground md:text-right`,children:t.error?t.error:`Looking…`})})}function OX({config:e,save:t}){let n=e.lint,r=n.mode===`off`,i=n.command.trim().length>0;return(0,R.jsxs)(qH,{prominent:!0,title:kY.lint,children:[(0,R.jsx)(`p`,{className:`max-w-3xl text-sm text-muted-foreground`,children:KY.intro}),(0,R.jsxs)(cY,{children:[(0,R.jsx)(sY,{label:KY.mode,help:GY.find(e=>e.id===n.mode)?.help,children:(0,R.jsx)(lY,{value:n.mode,items:GY.map(e=>({value:e.id,label:e.label})),label:KY.mode,onChange:e=>void t({lint:{mode:e}})})}),(0,R.jsxs)(`div`,{className:q(`flex flex-col divide-y divide-border [&>*]:py-3 [&>*:first-child]:pt-0 [&>*:last-child]:pb-0`,r&&`opacity-60`),"aria-disabled":r||void 0,children:[(0,R.jsx)(sY,{label:KY.command,help:KY.commandHelp,children:(0,R.jsx)(gX,{value:n.command,label:KY.command,placeholder:KY.commandPlaceholder,onSave:e=>void t({lint:{command:e}})})}),i?(0,R.jsx)(sY,{label:KY.extensions,help:KY.extensionsHelp,children:(0,R.jsx)(gX,{value:n.extensions.join(` `),label:KY.extensions,placeholder:KY.extensionsPlaceholder,onSave:e=>void t({lint:{extensions:EX(e)}})})}):null,(0,R.jsx)(sY,{label:KY.timeout,help:KY.timeoutHelp,children:(0,R.jsx)(_X,{value:n.timeoutMs,label:`Lint ${KY.timeout.toLowerCase()}`,onSave:e=>void t({lint:{timeoutMs:e}})})}),(0,R.jsx)(DX,{replaced:i})]})]})]})}function kX({config:e,save:t}){let n=e.lobby.web;return(0,R.jsx)(qH,{prominent:!0,title:kY.lobby,children:(0,R.jsxs)(cY,{children:[oX.map(n=>(0,R.jsx)(CX,{config:e,item:n,save:t},n.id)),(0,R.jsx)(sY,{label:NY,help:PY,children:(0,R.jsx)(lY,{value:String(e.lobby.maxPlanningRounds),items:FY.map(e=>({value:String(e),label:dX(e)})),label:NY,onChange:e=>void t({lobby:{maxPlanningRounds:Number(e)}})})}),(0,R.jsx)(sY,{label:IY,help:LY,children:(0,R.jsx)(lY,{value:String(e.lobby.splitPlanAbove),items:RY.map(e=>({value:String(e),label:fX(e)})),label:IY,onChange:e=>void t({lobby:{splitPlanAbove:Number(e)}})})}),(0,R.jsx)(sY,{label:zY,help:BY,children:(0,R.jsx)(vX,{value:n.port,onSave:e=>void t({lobby:{web:{port:e}}})})}),(0,R.jsx)(hX,{label:VY,help:HY,checked:n.openBrowser,onChange:e=>void t({lobby:{web:{openBrowser:e}}})})]})})}function AX({value:e,models:t,classifiers:n,onChange:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=new Set([...n.map(e=>e.id),...t.map(e=>e.id)]),l=[{value:``,label:YY.engineJev,help:YY.engineJevHelp},...n.map(e=>({value:e.id,label:e.id,help:`${YY.engineClassifier}${e.label===e.id?``:` · ${e.label}`}`})),...t.map(e=>({value:e.id,label:e.id,help:`${YY.engineChat}${e.label&&e.label!==e.id?` · ${e.label}`:``}`})),...e&&!c.has(e)?[{value:e,label:e,help:DY}]:[],{value:TY,label:EY,help:DY}],u=t=>{if(t!==`__custom__`)return r(t);s(c.has(e)?``:e),a(!0)},d=()=>{let t=o.trim();a(!1),t!==e&&r(t)};return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(lY,{value:e,items:l,label:YY.engine,onChange:u}),i?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,R.jsx)(Uq,{autoFocus:!0,value:o,placeholder:`provider/model`,"aria-label":`Classifier model id`,className:`min-w-0 flex-1 max-md:h-11 max-md:min-h-11`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())}}),(0,R.jsx)(X,{label:`Use this model`,icon:Vp,tone:`primary`,onClick:d})]}):null]})}function jX({config:e,models:t,classifiers:n,save:r}){let i=e.classifier,a=qY.find(e=>e.id===i.provider)?.label,o=!i.engine;return(0,R.jsx)(qH,{prominent:!0,title:kY.classifier,children:(0,R.jsxs)(cY,{children:[(0,R.jsx)(hX,{label:YY.enabled,help:YY.enabledHelp,checked:i.enabled,onChange:e=>void r({classifier:{enabled:e}})}),(0,R.jsx)(sY,{label:YY.engine,help:YY.engineHelp,children:(0,R.jsx)(AX,{value:i.engine,models:t,classifiers:n,onChange:e=>void r({classifier:{engine:e}})})}),o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(sY,{label:YY.host,children:(0,R.jsx)(lY,{value:i.provider,items:qY.map(e=>({value:e.id,label:e.label})),label:YY.host,onChange:e=>void r({classifier:{provider:e}})})}),(0,R.jsx)(sY,{label:YY.model,help:YY.modelHelp,children:(0,R.jsx)(gX,{value:i.model,label:YY.model,placeholder:`the host's default`,onSave:e=>void r({classifier:{model:e}})})}),(0,R.jsx)(sY,{label:YY.key,help:YY.keyNote,children:(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground md:text-right`,children:a??i.provider})})]}):null,JY.map(e=>(0,R.jsx)(hX,{label:e.label,help:e.help,checked:i.features[e.id],onChange:t=>void r({classifier:{features:{[e.id]:t}}})},e.id)),(0,R.jsx)(sY,{label:YY.cheap,help:YY.cheapHelp,children:(0,R.jsx)(mX,{value:i.effort.cheapModel,models:t,label:YY.cheap,none:!0,onChange:e=>void r({classifier:{effort:{cheapModel:e}}})})})]})})}function MX(){let e=MJ(),t=async e=>{if(!e)return PJ();let t=await NJ();t===`granted`?H.success(XY.notificationsOn):H.error(t===`unsupported`?XY.notificationsUnsupported:XY.notificationsBlocked)};return(0,R.jsx)(qH,{prominent:!0,title:kY.notifications,children:(0,R.jsx)(cY,{children:(0,R.jsx)(hX,{label:XY.notificationsLabel,help:XY.notificationsHelp,checked:e,onChange:e=>void t(e)})})})}function NX(){let{available:e,install:t}=y(),n=b(),r=x();return(0,R.jsx)(qH,{prominent:!0,title:kY.install,children:(0,R.jsxs)(cY,{children:[(0,R.jsx)(sY,{label:XY.installLabel,help:n?XY.installedNow:XY.installHelp,children:n?null:(0,R.jsx)(`div`,{className:`flex md:justify-end`,children:(0,R.jsx)(X,{label:XY.installButton,icon:Tm,tone:`primary`,onClick:()=>e?void t().then(()=>H.success(XY.installDone)):H.warning(XY.installUnavailable)})})}),r.supported?(0,R.jsx)(sY,{label:XY.fullscreenLabel,help:XY.fullscreenHelp,children:(0,R.jsx)(`div`,{className:`flex md:justify-end`,children:(0,R.jsx)(X,{label:r.on?XY.fullscreenOn:XY.fullscreenOff,icon:r.on?yh:sh,pressed:r.on,onClick:()=>void r.toggle()})})}):null]})})}var PX=[`Agents`,`Workflow`,`Linting`,`Lobby`,`Classifier`,`Appearance & notifications`];function FX({config:e,models:t,classifierModels:n=[],onConfig:r}){let[i,a]=(0,m.useState)(`Agents`),o=(0,m.useRef)(Promise.resolve()),s=e=>{let t=async()=>{try{return r((await Te(`settings.set`,{patch:e})).config),H.success(XY.saved),!0}catch(e){return H.error(e instanceof Error?e.message:`That did not work. Try again.`),!1}},n=o.current.then(t,t);return o.current=n,n};return(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-6 px-5 pt-5 pb-dock md:px-8 md:pt-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:XY.title}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:XY.intro})]}),(0,R.jsx)(`nav`,{"aria-label":`Settings sections`,className:`-mx-1 min-w-0 flex flex-wrap gap-1 border-b border-border pb-3 max-md:flex-nowrap max-md:overflow-x-auto max-md:overscroll-x-contain max-md:pb-2`,children:PX.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-current":i===e?`page`:void 0,"aria-controls":`settings-${e.split(` `)[0]}`,onClick:()=>a(e),className:q(`h-8 rounded-lg border border-transparent px-3 text-sm font-medium outline-none transition-[box-shadow,color] focus-visible:ring-3 focus-visible:ring-ring/40 max-md:min-h-11 max-md:h-auto max-md:shrink-0 max-md:whitespace-nowrap`,i===e?`btn-raised bg-card text-foreground`:`text-muted-foreground hover:text-foreground`),children:e},e))}),(0,R.jsx)(`div`,{id:`settings-Agents`,hidden:i!==`Agents`,"aria-hidden":i!==`Agents`,children:(0,R.jsx)(qH,{prominent:!0,title:kY.agents,children:(0,R.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:yY.map(n=>(0,R.jsx)(xX,{kind:n,config:e,models:t,save:s},n))})})}),(0,R.jsx)(`div`,{id:`settings-Workflow`,hidden:i!==`Workflow`,"aria-hidden":i!==`Workflow`,children:(0,R.jsx)(wX,{config:e,save:s})}),(0,R.jsx)(`div`,{id:`settings-Linting`,hidden:i!==`Linting`,"aria-hidden":i!==`Linting`,children:(0,R.jsx)(OX,{config:e,save:s})}),(0,R.jsx)(`div`,{id:`settings-Lobby`,hidden:i!==`Lobby`,"aria-hidden":i!==`Lobby`,children:(0,R.jsx)(kX,{config:e,save:s})}),(0,R.jsx)(`div`,{id:`settings-Classifier`,hidden:i!==`Classifier`,"aria-hidden":i!==`Classifier`,children:(0,R.jsx)(jX,{config:e,models:t,classifiers:n,save:s})}),(0,R.jsx)(`div`,{id:`settings-Appearance`,hidden:i!==`Appearance & notifications`,"aria-hidden":i!==`Appearance & notifications`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,R.jsx)(iX,{}),(0,R.jsx)(MX,{}),(0,R.jsx)(NX,{})]})})]})}function IX(){return(0,R.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-4 px-5 pt-5 pb-dock md:px-8 md:pt-8`,role:`status`,"aria-label":XY.loading,children:[0,1,2,3].map(e=>(0,R.jsx)(`div`,{className:`h-48 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function LX(){let e=xj(`settings.get`,{},[`status`]),[t,n]=(0,m.useState)(),r=(0,m.useRef)(0),i=(0,m.useCallback)(e=>{r.current=performance.now(),n(e)},[]);return(0,m.useEffect)(()=>{e.data&&e.requestedAt>r.current&&n(e.data.config)},[e.data,e.requestedAt]),!t&&e.error?(0,R.jsx)(yj,{message:`${XY.loadFailed} ${e.error}`,onRetry:e.reload}):t?(0,R.jsx)(FX,{config:t,models:e.data?.models??[],classifierModels:e.data?.classifierModels??[],onConfig:i}):(0,R.jsx)(IX,{})}function RX(){let e=globalThis.DOMParser;if(!e)throw Error(`DOMParser is unavailable`);return new e}var zX=`default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src 'none'; font-src 'none'; connect-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'`,BX=new Set(`div span p br hr h1 h2 h3 h4 h5 h6 section article header footer main aside nav ul ol li dl dt dd strong em b i u s small sub sup blockquote pre code table thead tbody tfoot tr th td caption colgroup col figure figcaption style`.split(` `)),VX=new Set(`class id title role aria-label aria-hidden colspan rowspan scope`.split(` `));function HX(e){if(!e||typeof e!=`object`)return;let t=e;if(!(typeof t.html!=`string`||t.html.length>1e5)&&!(t.css!==void 0&&(typeof t.css!=`string`||t.css.length>5e4)))return{html:t.html,...typeof t.css==`string`?{css:t.css}:{}}}function UX(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``);return/\\|@import|url\s*\(|image-set\s*\(|expression\s*\(|behavior\s*:|-moz-binding/i.test(t)?``:t.replace(/<\/?style/gi,``)}function WX(e){if(!BX.has(e.localName)||e.namespaceURI!==`http://www.w3.org/1999/xhtml`){e.remove();return}for(let t of[...e.attributes])t.name===`style`?e.setAttribute(`style`,UX(t.value)):VX.has(t.name)||e.removeAttribute(t.name);e.localName===`style`&&(e.textContent=UX(e.textContent??``));for(let t of[...e.children])WX(t)}function GX(e,t){try{return KX(e,t??RX())}catch{return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${zX}"><meta name="referrer" content="no-referrer"></head><body><p role="status">Static mockup unavailable. The preview could not be safely rendered.</p></body></html>`}}function KX(e,t){let n=t.parseFromString(e.html,`text/html`);for(let e of[...n.head.children,...n.body.children])WX(e);let r=[...n.head.querySelectorAll(`style`)].map(e=>e.outerHTML).join(``);return`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="${zX}"><meta name="referrer" content="no-referrer"><style>body{margin:16px;overflow-wrap:anywhere}*{box-sizing:border-box}${UX(e.css??``).replace(/</g,`\\3c `)}</style>${r}</head><body>${n.body.innerHTML}</body></html>`}function qX({preview:e,label:t,className:n,frameWidth:r,minWidth:i,onOpen:a}){let o=(0,m.useMemo)(()=>GX(e),[e]),s=(0,m.useRef)(null),[c,l]=(0,m.useState)();if((0,m.useLayoutEffect)(()=>{let e=s.current;if(!r&&!i||!e)return;let t=()=>l({width:e.clientWidth,height:e.clientHeight});if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,i]),!r&&!i)return(0,R.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,className:q(`h-80 w-full rounded-lg border bg-background`,n)});let u=r??Math.max(c?.width??0,i??0),d=c&&c.width>0&&u>0?Math.min(1,c.width/u):1;return(0,R.jsxs)(`div`,{ref:s,className:q(`group/mock relative h-80 w-full max-w-full overflow-hidden rounded-lg border bg-background max-md:min-h-0 max-md:max-h-full max-md:overflow-x-hidden max-md:overflow-y-auto max-md:overscroll-contain`,n),children:[(0,R.jsx)(`iframe`,{title:`Static mockup: ${t}`,sandbox:``,referrerPolicy:`no-referrer`,srcDoc:o,tabIndex:a?-1:void 0,className:q(`absolute top-0 left-0 origin-top-left border-0`,a&&`pointer-events-none`),style:{width:u||`100%`,height:c?c.height/d:`100%`,transform:`scale(${d})`}}),a?(0,R.jsx)(`button`,{type:`button`,"data-compact":``,onClick:a,"aria-label":`Expand the mockup: ${t}`,className:`absolute inset-0 flex items-end justify-end p-2 outline-none focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:ring-inset max-md:p-3`,children:(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border bg-card/90 px-1.5 py-0.5 text-[0.6875rem] font-medium text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-opacity group-hover/mock:opacity-100 group-focus-within/mock:opacity-100`,children:[(0,R.jsx)(ah,{"aria-hidden":`true`,className:`size-3`}),`Expand`]})}):null]})}var JX=/\s*\(recommended\)\s*$/i,YX=1024,XX=`(max-width: 767.98px)`,ZX=`max-md:hidden`,QX=e=>e.replace(JX,``);function $X(e){return!!(e&&(e.htmlPreview||e.image||e.preview))}function eZ({option:e}){let t=QX(e.label);return $X(e)?(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[e.htmlPreview?(0,R.jsx)(qX,{preview:e.htmlPreview,label:t,minWidth:YX,className:`h-auto min-h-[18rem] flex-1`}):null,e.image?(0,R.jsx)(`img`,{src:F(e.image),alt:`Mockup: ${t}`,className:`min-h-0 w-full flex-1 rounded-lg border bg-background object-contain`}):null,e.preview?(0,R.jsx)(WH,{text:e.preview,className:q(`overflow-auto rounded-lg border bg-background p-4 text-sm`,!e.htmlPreview&&!e.image&&`flex-1`)}):null]}):(0,R.jsx)(`p`,{className:`grid h-full place-items-center p-6 text-sm text-muted-foreground`,children:`No mockup for this option.`})}function tZ({options:e,start:t,title:n,picked:r=[],multi:i=!1,onChoose:a,onClose:o,onIndex:s}){let c=xf(),l=cA(XX),{keyboardOpen:u,keyboardInset:d}=BA(),f=(0,m.useRef)(null),p=(0,m.useRef)(null),[h,g]=(0,m.useState)(()=>Math.min(Math.max(0,t),e.length-1)),_=e[h],v=e.length-1;(0,m.useEffect)(()=>s?.(h),[h,s]),(0,m.useLayoutEffect)(()=>{let e=f.current;e&&(e.scrollLeft=h*e.clientWidth),p.current?.focus()},[]);let y=(0,m.useCallback)(e=>{let t=Math.min(Math.max(0,e),v),n=f.current;g(t),n?.scrollTo({left:t*n.clientWidth,behavior:c?`auto`:`smooth`})},[v,c]);(0,m.useEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{e.scrollLeft=h*e.clientWidth});return t.observe(e),()=>t.disconnect()},[h]);function b(){let e=f.current;if(!e||e.clientWidth===0)return;let t=Math.round(e.scrollLeft/e.clientWidth);t!==h&&t>=0&&t<=v&&g(t)}function x(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=t.target;if(n.closest(`input, textarea, [contenteditable='true']`))return;let r={ArrowLeft:-1,ArrowRight:1,PageUp:-1,PageDown:1}[t.key];if(r){t.preventDefault(),y(h+r);return}if(t.key===`Home`||t.key===`End`){t.preventDefault(),y(t.key===`Home`?0:v);return}let i=Number(t.key);if(Number.isInteger(i)&&i>=1&&i<=e.length){t.preventDefault(),y(i-1);return}t.key===`Enter`&&a&&!(n instanceof HTMLButtonElement)&&(t.preventDefault(),a(h))}let S=r.includes(h),C=l&&u?{height:`calc(100vh - ${d}px - 1.5rem)`,maxHeight:`calc(100vh - ${d}px - 1.5rem)`}:void 0;return(0,R.jsxs)(`div`,{ref:p,tabIndex:-1,"data-autofocus":``,onKeyDown:x,style:C,className:`mockup-viewer flex h-full min-h-0 flex-col outline-none max-md:h-[calc(100svh-1.5rem)] max-md:max-h-[calc(100svh-1.5rem)]`,role:`region`,"aria-label":`Mockups: ${n}`,"aria-roledescription":`carousel`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-4 py-3 sm:px-5`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to the question`,title:l?`Back to the question`:`Back · Esc`,onClick:()=>o(h),className:`max-md:size-11`,children:(0,R.jsx)(_h,{"aria-hidden":`true`})}),(0,R.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:n}),(0,R.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,"aria-live":`polite`,children:[h+1,` of `,e.length]}),(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`Options`,className:`flex w-full flex-wrap gap-1.5 sm:w-auto`,children:e.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===h,"aria-controls":`mockup-slide-${t}`,"data-compact":``,onClick:()=>y(t),className:q(`inline-flex h-7 max-w-48 items-center gap-1 rounded-lg border px-2.5 text-xs font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/40 max-md:h-11 max-md:min-w-11`,t===h?`border-primary/50 bg-accent text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,R.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:t+1}),(0,R.jsx)(`span`,{className:`truncate`,children:QX(e.label)}),r.includes(t)?(0,R.jsx)(Vp,{"aria-label":`picked`,className:`size-3 text-primary`}):null]},t))})]}),(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{ref:f,onScroll:b,className:`mockup-track flex h-full snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:e.map((t,n)=>(0,R.jsxs)(`section`,{id:`mockup-slide-${n}`,role:`tabpanel`,"aria-roledescription":`slide`,"aria-label":`${n+1} of ${e.length}: ${QX(t.label)}`,"aria-hidden":n!==h,className:`flex h-full w-full shrink-0 snap-center snap-always flex-col gap-2 overflow-y-hidden px-4 py-4 sm:px-14 max-md:overflow-y-auto max-md:overscroll-contain`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 text-sm`,children:[(0,R.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[n+1,`.`]}),(0,R.jsx)(`span`,{className:`font-medium`,children:QX(t.label)}),JX.test(t.label)?(0,R.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Recommended`}):null,r.includes(n)?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-primary`,children:[(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`}),`picked`]}):null]}),t.description?(0,R.jsx)(WH,{text:t.description,className:`text-sm text-muted-foreground`}):null,(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(eZ,{option:t})})]},n))}),h>0?(0,R.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Previous option`,title:l?`Previous option`:`Previous · ←`,onClick:()=>y(h-1),className:`absolute top-1/2 left-2 -translate-y-1/2 rounded-full max-md:hidden max-md:size-11`,children:(0,R.jsx)(Gp,{"aria-hidden":`true`})}):null,h<v?(0,R.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Next option`,title:l?`Next option`:`Next · →`,onClick:()=>y(h+1),className:`absolute top-1/2 right-2 -translate-y-1/2 rounded-full max-md:hidden max-md:size-11`,children:(0,R.jsx)(qp,{"aria-hidden":`true`})}):null]}),(0,R.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 border-t border-border px-4 py-3 sm:px-5`,children:[(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`←→`,className:ZX,children:`option`}),a?(0,R.jsx)(iA,{chord:`Enter`,className:ZX,children:i?S?`unpick`:`pick`:`choose`}):null,(0,R.jsx)(iA,{chord:`Esc`,className:ZX,children:`back`})]}),a&&_?(0,R.jsxs)(Y,{type:`button`,onClick:()=>a(h),className:`max-w-full max-md:min-h-11 max-md:min-w-11`,children:[i&&S?`Unpick`:i?`Pick`:`Choose`,(0,R.jsx)(`span`,{className:`truncate`,children:QX(_.label)})]}):null]})]})}function nZ(e,t,n){e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n()),e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),t()))}function rZ({text:e,disabled:t=!1,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(``),u=(0,m.useRef)(null);(0,m.useEffect)(()=>{u.current?.focus({preventScroll:!0}),u.current?.select()},[]);let d=async()=>{if(!(t||o||!i.trim())){s(!0),l(``);try{await n(i.trim()),r()}catch(e){l(e instanceof Error?e.message:String(e)),s(!1)}}};return(0,R.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>nZ(e,()=>void d(),()=>{o||r()}),children:[(0,R.jsxs)(`label`,{className:`text-sm`,children:[`Edit message`,(0,R.jsx)(sM,{ref:u,value:i,onChange:e=>a(e.target.value),disabled:o,className:`mt-2 max-h-[40vh] min-h-24 max-md:min-h-28`})]}),c?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not save. `,c]}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{size:`sm`,className:`max-md:min-h-11`,onClick:()=>void d(),disabled:t||o||!i.trim(),children:o?`Saving…`:`Save`}),(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,className:`max-md:min-h-11`,disabled:o,onClick:r,children:`Cancel`})]})]})}var iZ=1200;function aZ({question:e}){let[t,n]=(0,m.useState)(),r=XA(t!==void 0,YA.sheet),i=e.options.flatMap((e,t)=>e.mockup?[{option:e,index:t,mockup:e.mockup}]:[]);if(i.length===0)return null;let a=e.options.map(e=>({label:e.label,description:e.description,...e.mockup?{htmlPreview:e.mockup}:{}}));return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{"aria-label":`Mockups`,className:`grid grid-cols-2 gap-2 md:grid-cols-3`,children:i.map(({option:e,index:t,mockup:r})=>(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsx)(qX,{preview:r,label:QX(e.label),frameWidth:iZ,onOpen:()=>n(t),className:`aspect-[3/2] h-auto`}),(0,R.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[t+1,`.`]}),` `,QX(e.label)]})]},t))}),(0,R.jsx)(HA,{open:t!==void 0&&r,onOpenChange:e=>{e||n(void 0)},label:`Mockups: ${e.text}`,className:`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`,children:t===void 0?null:(0,R.jsx)(tZ,{options:a,start:t,title:e.text,onClose:()=>n(void 0)})})]})}function oZ({questions:e}){return(0,R.jsx)(`ol`,{className:`mt-1 flex flex-col gap-2`,children:e.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised flex min-w-0 flex-col gap-2 rounded-xl border p-3 text-sm`,style:{"--orb":TW(e.from)},children:[(0,R.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,R.jsxs)(`span`,{className:`mt-px inline-flex shrink-0 items-center gap-1 rounded-full bg-[color-mix(in_oklab,var(--orb)_12%,transparent)] px-2 py-0.5 text-xs font-medium text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,children:[(0,R.jsx)(bW,{source:e.from,className:`size-3`}),SW(e.from)]}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsxs)(`span`,{className:`sr-only`,children:[`Question `,t+1,`: `]}),e.text]})]}),e.options.length?(0,R.jsx)(`ul`,{"aria-label":`Options`,className:`flex flex-wrap gap-1.5`,children:e.options.map(e=>(0,R.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/60 px-2 py-1 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.description?` — ${e.description}`:``]},e.label))}):null,(0,R.jsx)(aZ,{question:e})]},t))})}function sZ({message:e}){let t=e.decided??[];return t.length?(0,R.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1.5`,children:t.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2 rounded-lg bg-muted/60 px-2.5 py-1.5 text-sm`,children:[(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-success`}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:q(`font-medium`,CW(e.from)),children:SW(e.from)}),` `,e.question,` → `,(0,R.jsx)(`strong`,{children:e.answer}),(0,R.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[`decided by the classifier (`,e.probability.toFixed(2),`); comment on the plan to overrule`]})]})]},t))}):null}function cZ({message:e,index:t,busy:n,readOnly:r}){let[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),c=o&&(o.editedAt??0)>(e.editedAt??0)?o:e,l=n||c!==e,u=async n=>{let r=await Te(`planner.editMessage`,{messageIndex:t,at:e.at,text:n});s(r.message)},d=!r&&!e.settled?.length&&!i?(0,R.jsxs)(Y,{size:`xs`,variant:`ghost`,disabled:l,onClick:()=>a(!0),className:`text-muted-foreground max-md:min-h-11 max-md:whitespace-normal`,children:[(0,R.jsx)(Vh,{"aria-hidden":`true`}),`Edit`]}):null;return(0,R.jsx)(jW,{time:e.at>0?lM(e.at):void 0,head:!0,note:c.editedAt?`(edited)`:void 0,below:d,children:i?(0,R.jsx)(rZ,{text:c.text,disabled:n,onSave:u,onCancel:()=>a(!1)}):(0,R.jsx)(WH,{text:c.text})})}function lZ({message:e,index:t,busy:n,readOnly:r}){if(e.role===`you`)return(0,R.jsx)(cZ,{message:e,index:t,busy:n,readOnly:r});let i=e.questions??[];return(0,R.jsxs)(AW,{source:`PLANNER`,name:`Panel`,time:e.at>0?lM(e.at):void 0,head:!0,bubble:i.length===0,aside:i.length?`${i.length} question${i.length===1?``:`s`}`:void 0,children:[i.length>0?(0,R.jsx)(oZ,{questions:i}):(0,R.jsx)(WH,{text:e.text}),(0,R.jsx)(sZ,{message:e})]})}function uZ({messages:e,seed:t,busy:n=!1,readOnly:r=!1}){return(0,R.jsxs)(`div`,{className:`chat-column`,role:`log`,"aria-label":`Panel conversation`,children:[t?(0,R.jsx)(MW,{children:t}):null,e.map((e,t)=>(0,R.jsx)(lZ,{message:e,index:t,busy:n,readOnly:r},`${e.at}-${t}`)),n?(0,R.jsx)(AW,{source:`PLANNER`,name:`Panel`,head:!0,live:!0,aside:`the panel is thinking`,children:(0,R.jsx)(NW,{className:`mt-1`})}):null]})}var dZ=`ORACLE`,fZ=`No draft yet.`,pZ=`The draft appears after the panel's first round.`,mZ=`What each seat needs`,hZ=[`backend`,`designer`,`qa`,`researcher`],gZ={backend:`DEV`,designer:`DESIGN`,qa:`QA`,researcher:`RESEARCH`},_Z=`Describe a task in the box below. The panel asks what it needs to know, round by round, until the plan is clear.`,vZ={ORACLE:`Chairs the panel, and settles the last round alone.`,DEV:`Code, data and the APIs it touches.`,DESIGN:`Screens, flows and the words on them.`,QA:`Tests, edge cases and what could break.`,RESEARCH:`Prior art, docs and sources.`},yZ=[{title:`Describe it`,text:`Say what you want in the box below.`},{title:`The panel asks`,text:`Each seat asks what it needs to know.`},{title:`A draft forms`,text:`Answer, comment on lines, go another round.`},{title:`Save the plan`,text:`Keep it, or start it as a task.`}];function bZ(e){let t=e.filter(e=>e.member);return`${t.filter(e=>e.seated).length} of ${t.length} seated`}function xZ(e,t=0){return t<=0?`round ${e}`:e>t?`round ${e} · past the limit, revising`:e===t?`final round ${e}/${t}`:`round ${e}/${t}`}function SZ(e,t){return`${e} ${t}${e===1?``:`s`}`}function CZ(e){return e.round===0&&e.messages.length===0&&!e.busy}function wZ(e){let t=e.members.find(e=>e.status===`failed`);if(t)return(t.error??`${gZ[t.member]} failed`).split(`
|
|
98
|
+
`)[0]}function TZ(e){let t=[],n=wZ(e);return e.busy?t.push(xZ(e.round,e.limit)):n?t.push(`${n} — Retry runs the round again`):e.questions.length>0&&t.push(`${SZ(e.questions.length,`question`)} waiting`),!e.busy&&e.round>0&&t.push(xZ(e.round,e.limit)),!e.busy&&e.limit>0&&e.round+1===e.limit&&t.push(`the next round is the last: the oracle settles the rest`),t}function EZ(e,t){let n=gZ[e],r=t.seats.includes(e),i=t.members.find(t=>t.member===e),a={member:e,label:n,seated:r,working:!1};if(!r)return{...a,text:`off`};if(i?.status===`thinking`)return{...a,working:!0,text:i.step??`thinking`};if(i?.status===`failed`)return{...a,text:`failed — Retry`};if(!i)return{...a,text:`·`};if(i.reply?.status===`ready`)return{...a,text:`ready`};let o=t.questions.filter(e=>e.from===n).length;return{...a,text:o===0?`done`:SZ(o,`question`)}}function DZ(e){let t=e.questions.filter(e=>e.from===dZ).length;return[{label:dZ,seated:!0,working:e.busy,text:e.busy?`chairing`:t?SZ(t,`question`):`·`},...hZ.map(t=>EZ(t,e))]}function OZ(e){let t=!1;return e.split(`
|
|
99
|
+
`).map(e=>{let n=e.trimStart().startsWith("```");return n&&(t=!t),{text:e,fenced:t||n}})}function kZ({notes:e}){return(0,R.jsx)(R.Fragment,{children:e.map((e,t)=>(0,R.jsx)(`p`,{className:`ml-6 rounded-lg border border-primary/15 bg-accent px-3 py-1.5 text-sm text-foreground italic`,children:e},t))})}var AZ=[],jZ=(0,m.memo)(function({row:e,notes:t,onComment:n}){let r=e.text.trim(),i=()=>n(r);return(0,R.jsxs)(`li`,{className:`group/line [contain-intrinsic-size:auto_2.75rem] [content-visibility:auto]`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[(0,R.jsx)(`span`,{className:`flex w-4 shrink-0 justify-center pt-3.5`,"aria-hidden":`true`,children:t.length>0?(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`}):null}),(0,R.jsx)(`div`,{className:q(`min-w-0 flex-1 cursor-pointer rounded-lg px-2 py-1.5 transition-colors hover:bg-muted`,e.fenced&&`font-mono text-sm whitespace-pre-wrap break-words`),onClick:e=>!e.target.closest(`a`)&&i(),children:e.fenced?e.text:(0,R.jsx)(WH,{text:e.text})}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 text-muted-foreground max-md:size-11 opacity-0 transition-opacity group-hover/line:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":`Comment on this line: ${r}`,onClick:i,children:(0,R.jsx)(dh,{"aria-hidden":`true`})})]}),(0,R.jsx)(kZ,{notes:t})]})});function MZ({draft:e,comments:t,onComment:n}){let r=(0,m.useMemo)(()=>OZ(e),[e]),i=FH(r.length);return(0,R.jsx)(`ul`,{className:`flex flex-col`,"aria-label":`Draft plan lines`,children:r.slice(0,i).map((e,r)=>e.text.trim()?(0,R.jsx)(jZ,{row:e,notes:t.get(e.text.trim())??AZ,onComment:n},r):(0,R.jsx)(`li`,{"aria-hidden":`true`,className:`h-2`},r))})}function NZ({notes:e}){return e.length===0?null:(0,R.jsx)(qH,{title:mZ,children:(0,R.jsx)(`dl`,{className:`flex flex-col gap-2 text-sm`,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex min-w-0 gap-3 max-md:flex-wrap`,children:[(0,R.jsx)(`dt`,{className:q(`w-20 shrink-0 font-medium`,CW(e.from)),children:SW(e.from)}),(0,R.jsx)(`dd`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(WH,{text:e.text})})]},t))})})}function PZ({cell:e,intro:t}){let n=t?e.member?e.seated?`seated`:`not seated`:`chairs`:e.text;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:q(`inline-flex items-center gap-1.5 font-medium`,e.seated?CW(e.label):`text-muted-foreground`),children:[(0,R.jsx)(bW,{source:e.label,className:`size-3.5`}),SW(e.label)]}),e.working&&!t?(0,R.jsx)(pj,{className:`size-3.5`,"aria-hidden":`true`}):null,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function FZ({cell:e,intro:t,onToggled:n}){let{member:r}=e,i=`inline-flex min-h-8 items-center gap-2 rounded-lg border border-border px-3 text-[0.8125rem] max-md:min-h-11`;if(!r)return(0,R.jsx)(`li`,{className:q(i,`bg-muted`),children:(0,R.jsx)(PZ,{cell:e,intro:t})});let a=async()=>{await U(`planner.toggleSeat`,{member:r})&&n()};return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`label`,{className:q(i,`cursor-pointer transition-colors`,e.seated?`btn-raised bg-card`:`border-dashed text-muted-foreground hover:bg-muted`),children:[(0,R.jsx)(kG,{checked:e.seated,onCheckedChange:()=>void a(),"aria-label":`${SW(e.label)} sits on the panel`}),(0,R.jsx)(PZ,{cell:e,intro:t})]})})}function IZ({cells:e,intro:t,onToggled:n}){return(0,R.jsx)(`ul`,{"aria-label":`Panel`,className:`flex flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(FZ,{cell:e,intro:t,onToggled:n},e.label))})}function LZ({cell:e,onToggled:t}){let{member:n}=e,r=SW(e.label),i=q(`flex h-full flex-col gap-2 rounded-xl border p-3.5 transition-[background-color,border-color,box-shadow]`,e.seated?`border-[color-mix(in_oklab,var(--orb)_26%,var(--border))] bg-[color-mix(in_oklab,var(--orb)_5%,var(--card))] shadow-card`:`border-dashed border-input bg-transparent`),a=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`grid size-6 place-items-center rounded-lg bg-[color-mix(in_oklab,var(--orb)_14%,transparent)] text-[color-mix(in_oklab,var(--orb)_85%,var(--foreground))]`,!e.seated&&`opacity-50 grayscale`),children:(0,R.jsx)(bW,{source:e.label,className:`size-3.5`})}),(0,R.jsx)(`span`,{className:q(`truncate text-sm font-semibold`,e.seated?CW(e.label):`text-muted-foreground`),children:r})]}),n?(0,R.jsx)(kG,{checked:e.seated,onCheckedChange:()=>void RZ(n,t),"aria-label":`${r} sits on the panel`}):null]}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:vZ[e.label]}),(0,R.jsx)(`span`,{className:q(`mt-auto text-xs font-medium`,e.seated?`text-foreground`:`text-muted-foreground`),children:n?e.seated?`seated`:`sits this one out`:`always chairs`})]}),o={"--orb":TW(e.label)};return n?(0,R.jsx)(`li`,{style:o,children:(0,R.jsx)(`label`,{className:q(i,`cursor-pointer`,e.seated?`hover:shadow-[0_0_0_3px_color-mix(in_oklab,var(--orb)_10%,transparent)]`:`hover:bg-muted`),children:a})}):(0,R.jsx)(`li`,{style:o,children:(0,R.jsx)(`div`,{className:i,children:a})})}async function RZ(e,t){await U(`planner.toggleSeat`,{member:e})&&t()}function zZ({cells:e,onToggled:t}){return(0,R.jsx)(`ul`,{"aria-label":`Panel`,className:`grid grid-cols-1 gap-3 @lg:grid-cols-2 @4xl:grid-cols-5`,children:e.map(e=>(0,R.jsx)(LZ,{cell:e,onToggled:t},e.label))})}function BZ({snap:e}){let t=TZ(e),n=!e.busy&&wZ(e)!==void 0;return(0,R.jsxs)(`p`,{role:`status`,className:n?`flex items-center gap-2 text-sm text-destructive`:`flex items-center gap-2 text-sm text-muted-foreground`,children:[e.busy?(0,R.jsx)(pj,{className:`size-3.5`,"aria-hidden":`true`}):null,t.join(` · `)]})}function VZ(){return(0,R.jsx)(X,{label:`Previous plans`,text:`Previous`,icon:Yh,shortcut:`H`,onClick:()=>aj(ij(`plan`,`previous`))})}function HZ({snap:e,onDone:t}){let n=sA(`status`).data?.keys.find(e=>e.action===`savePlan`)?.label,r=e=>async()=>{await U(e,{})&&t()};return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e.questions.length>0&&!e.busy?(0,R.jsx)(X,{label:`Answer questions`,icon:lh,tone:`primary`,shortcut:`A`,onClick:()=>void r(`planner.answer`)()}):null,e.retryable?(0,R.jsx)(X,{label:`Retry`,icon:$h,shortcut:`R`,onClick:()=>void r(`planner.retry`)()}):null,(0,R.jsx)(VZ,{}),(0,R.jsx)(X,{"data-plan-save":!0,label:`Save the plan`,text:`Save`,icon:rg,shortcut:n??`Ctrl+S`,disabled:!e.draft||e.busy,onClick:()=>void r(`planner.save`)()}),(0,R.jsx)(SM,{icon:Nm,label:`New plan`,shortcut:`N`,title:`Start a new plan?`,description:`The conversation and the draft are left behind. Saved plans are not touched.`,confirmLabel:`New plan`,onConfirm:()=>void U(`planner.new`,{}).then(t)})]})}function UZ({snap:e,onDone:t}){return(0,R.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-3 border-b border-border px-5 py-3 max-md:shrink max-md:px-4 max-md:py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Planning`}),(0,R.jsx)(BZ,{snap:e})]}),(0,R.jsx)(HZ,{snap:e,onDone:t})]}),(0,R.jsx)(IZ,{cells:DZ(e),intro:!1,onToggled:t})]})}var WZ=()=>aj(ij(`plan`,`previous`)),GZ=e=>aj(ij(`plan`,`previous`,e));function KZ(e){let t=Date.now()-Date.parse(e);return Number.isFinite(t)?dM(Math.max(0,t)):``}function qZ(e,t){return[`${t} message${t===1?``:`s`}`,`round ${e.rounds}`,KZ(e.updatedAt)].filter(Boolean).join(` · `)}function JZ({plan:e,selected:t}){return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>GZ(e.id),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),e.hasDraft?(0,R.jsx)(jU,{variant:`secondary`,children:`draft`}):null]}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:qZ(e,e.messages)})]})})}function YZ({id:e,onGone:t}){let n=xj(`planner.previousGet`,{id:e},[`planner`]),r=n.data;if(!r)return n.error?(0,R.jsx)(yj,{message:`Could not load that plan. ${n.error}`,onRetry:n.reload}):null;let i=!!r.archivedAt,a=async()=>{await U(`planner.previousOpen`,{id:e})&&aj(ij(`plan`))},o=async()=>{await U(`planner.previousArchive`,{id:e,archived:!i})&&t()},s=async()=>{await U(`planner.previousDelete`,{id:e})&&t()};return(0,R.jsxs)(`article`,{className:`flex flex-col gap-5`,"aria-label":r.title,children:[(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Carry on planning`,text:`Carry on`,icon:Uh,tone:`primary`,shortcut:`C`,onClick:()=>void a()}),(0,R.jsx)(X,{label:i?`Bring it back from the archive`:`Archive`,text:i?`Unarchive`:`Archive`,icon:i?Cp:Tp,shortcut:`E`,onClick:()=>void o()}),(0,R.jsx)(SM,{icon:Cg,label:`Delete`,shortcut:`Delete`,title:`Delete "${r.title}"?`,description:`The conversation and the draft are removed for good.`,confirmLabel:`Delete plan`,variant:`destructive`,onConfirm:()=>void s()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:[i?`archived`:``,qZ(r,r.messages.length),r.seed??``].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(qH,{title:`Draft plan`,children:[r.draft?(0,R.jsx)(WH,{text:r.draft}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The panel had not written a draft yet.`}),(0,R.jsx)(NZ,{notes:r.notes})]}),(0,R.jsx)(qH,{title:`Conversation`,children:(0,R.jsx)(uZ,{messages:r.messages,readOnly:!0})})]})}function XZ({id:e}){let t=eM(),[n,r]=(0,m.useState)(!1),i=xj(`planner.previous`,n?{archived:!0}:{},[`planner`]),a=i.data?.plans??[];if(!i.data&&i.error)return(0,R.jsx)(yj,{message:`Could not load the previous plans. ${i.error}`,onRetry:i.reload});let o=(0,R.jsxs)(aM,{title:n?`Archived plans`:`Previous plans`,count:i.data?String(a.length):void 0,children:[(0,R.jsx)(X,{label:`Back to the current plan`,icon:kp,iconOnly:!0,onClick:()=>aj(ij(`plan`))}),(0,R.jsx)(X,{label:n?`Show the previous plans`:`Show the archived plans`,text:n?`Previous`:`Archived`,icon:n?Yh:Tp,pressed:n,onClick:()=>{r(e=>!e),WZ()}})]}),s=i.data?a.length===0?(0,R.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted-foreground`,children:n?`No archived plans.`:`No previous plans. A plan you leave without saving it as a task waits here; one saved as a task is in the Tasks tab.`}):(0,R.jsx)(`ul`,{className:q(NU,`pt-2`),"aria-label":n?`Archived plans`:`Previous plans`,children:a.map(t=>(0,R.jsx)(JZ,{plan:t,selected:t.id===e},t.id))}):(0,R.jsx)(oM,{});return(0,R.jsx)(iM,{wide:t,list:(0,R.jsxs)(R.Fragment,{children:[o,s]}),detail:e?(0,R.jsx)(YZ,{id:e,onGone:()=>{i.reload(),WZ()}},e):null,open:e!==void 0,onClose:WZ,hint:`Pick a plan to read it, carry it on, archive it or delete it.`,describe:`A previous plan`})}function ZZ({line:e,onClose:t,onSent:n}){let r=XA(e!==void 0,YA.confirm);return(0,R.jsx)(HA,{open:e!==void 0&&r,onOpenChange:e=>!e&&t(),label:`Comment on this line`,className:`max-w-xl`,children:(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6 max-md:p-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-base font-medium`,children:`Comment on this line`}),(0,R.jsx)(`p`,{className:`mt-1 line-clamp-3 text-sm break-words text-muted-foreground`,children:e})]}),(0,R.jsx)(WU,{label:`Your comment`,hint:`Enter adds the comment · Esc cancels`,buttonLabel:`Add comment`,onSend:async r=>e===void 0||!await U(`planner.commentLine`,{line:e,text:r.trim()})?!1:(n(e,r.trim()),t(),!0)})]})})}function QZ({limit:e}){return e<=0?null:(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:e},(t,n)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-4 rounded-full`,n===e-1?`bg-primary`:`bg-border`)},n))}),(0,R.jsxs)(`span`,{children:[`up to `,e,` rounds, the last the oracle's`]})]})}function $Z({snap:e,onDone:t}){let n=DZ(e);return(0,R.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-8 pb-dock max-md:px-4 max-md:pt-5 md:px-8 md:pt-10`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-8`,children:[(0,R.jsxs)(`header`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 shrink-0 place-items-center rounded-xl border text-primary`,children:(0,R.jsx)(tg,{className:`size-5`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:`Plan with the panel`}),(0,R.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:_Z})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col items-start gap-2 @3xl:items-end`,children:[(0,R.jsx)(VZ,{}),(0,R.jsx)(QZ,{limit:e.limit})]})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`plan-panel`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`plan-panel`,className:`text-xs text-muted-foreground`,children:(0,R.jsx)(KH,{title:`The panel`,right:bZ(n)})}),(0,R.jsx)(zZ,{cells:n,onToggled:t})]}),(0,R.jsxs)(`section`,{"aria-labelledby":`plan-steps`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`plan-steps`,className:`text-xs text-muted-foreground`,children:(0,R.jsx)(KH,{title:`How a plan comes together`})}),(0,R.jsx)(`ol`,{className:`grid gap-3 @2xl:grid-cols-2 @4xl:grid-cols-4`,children:yZ.map((e,t)=>(0,R.jsxs)(`li`,{className:`card-raised relative flex gap-3 rounded-xl border p-3.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-6 shrink-0 place-items-center rounded-full bg-accent text-xs font-semibold text-primary tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,R.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(Dp,{"aria-hidden":`true`,className:`size-4 text-primary motion-safe:animate-bounce`}),`Start in the box below.`,(0,R.jsx)(iA,{chord:`/`,className:`max-md:hidden`,children:`write`}),(0,R.jsx)(iA,{chord:`Enter`,className:`max-md:hidden`,children:`send to the panel`})]})]})})}function eQ({snap:e,wide:t}){let{ref:n,onScroll:r}=gW(JSON.stringify(e.messages));return(0,R.jsxs)(tM,{className:`workspace-pane flex flex-col rounded-xl border shadow-xs`,children:[(0,R.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,R.jsx)(KH,{title:`Conversation`,className:`w-full`})}),(0,R.jsx)(`div`,{ref:n,onScroll:r,className:q(`min-h-0 overflow-y-auto overscroll-y-contain`,t?`flex-1 px-5 pt-5 pb-dock`:`max-h-[45svh] p-5`),children:(0,R.jsx)(uZ,{messages:e.messages,busy:e.busy})})]})}function tQ({snap:e,comments:t,onComment:n,wide:r}){return(0,R.jsxs)(tM,{className:`workspace-pane flex flex-col rounded-xl border shadow-xs`,children:[(0,R.jsx)(`h2`,{className:`flex min-h-12 shrink-0 items-center border-b border-border px-4 text-sm font-medium`,children:(0,R.jsx)(KH,{title:`Draft plan`,className:`w-full`})}),(0,R.jsxs)(`div`,{className:q(`flex min-h-0 flex-col gap-5 overflow-y-auto overscroll-y-contain px-5 pt-5 pb-dock`,r&&`flex-1`),children:[e.draft?(0,R.jsx)(MZ,{draft:e.draft,comments:t,onComment:n}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.busy?pZ:fZ}),(0,R.jsx)(NZ,{notes:e.notes})]})]})}function nQ({snap:e,reload:t}){let n=eM(),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(new Map);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(UZ,{snap:e,onDone:t}),(0,R.jsxs)(`div`,{className:q(n?`grid min-h-0 flex-1 grid-cols-[minmax(0,46fr)_minmax(0,54fr)] grid-rows-[minmax(0,1fr)] gap-3 p-3`:`flex flex-col gap-3 p-3`,`min-w-0`),children:[(0,R.jsx)(eQ,{snap:e,wide:n}),(0,R.jsx)(tQ,{snap:e,comments:a,onComment:i,wide:n})]}),(0,R.jsx)(ZZ,{line:r,onClose:()=>i(void 0),onSent:(e,t)=>o(n=>new Map(n).set(e,[...n.get(e)??[],t]))})]})}function rQ({rest:e=[]}){return e[0]===`previous`?(0,R.jsx)(XZ,{id:e[1]}):(0,R.jsx)(iQ,{})}function iQ(){let e=xj(`planner.get`,{},[`planner`]),t=e.data;if(!t&&e.error)return(0,R.jsx)(yj,{message:`Could not load the plan. ${e.error}`,onRetry:e.reload});if(!t)return(0,R.jsx)(`p`,{role:`status`,className:`p-5 text-sm text-muted-foreground`,children:`Loading the plan…`});let n=CZ(t);return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:n?(0,R.jsx)($Z,{snap:t,onDone:e.reload}):(0,R.jsx)(nQ,{snap:t,reload:e.reload})})}var aQ=`Describe a small change in the box below and one agent makes it now, beside any running task.`;function oQ(e){return e.prompt.split(`
|
|
100
|
+
`).find(e=>e.trim())?.trim()??`(empty)`}function sQ(e){return[...e].reverse()}function cQ(e){let t=Number.isFinite(e)?Math.max(0,Math.round(e/1e3)):0,n=Math.floor(t/60);if(n===0)return`${t}s`;let r=t%60;return r===0?`${n}m`:`${n}m ${String(r).padStart(2,`0`)}s`}function lQ(e,t){return e.startedAt?cQ((e.finishedAt??t)-e.startedAt):``}function uQ(e,t){let n=e.model?`${e.model}${e.thinking?` · ${e.thinking}`:``}`:e.thinking??``;return[lQ(e,t),n,e.tools?`${e.tools} tool${e.tools===1?``:`s`}`:``,e.usage?.cost?`$${e.usage.cost.toFixed(2)}`:``].filter(Boolean).join(` · `)}function dQ(e){return e===`queued`?`Waiting for the quick fix ahead of it.`:e===`running`?`starting…`:e===`held`?`Not started.`:`No tool calls.`}function fQ({job:e}){let t=e.status===`held`;return(0,R.jsxs)(R.Fragment,{children:[e.route?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Routed `,e.route]}):null,e.note&&t?(0,R.jsxs)(`p`,{className:`flex items-start gap-2 rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-sm text-foreground`,children:[(0,R.jsx)(Tg,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{children:[`Held: `,e.note,`.`]})]}):null,e.note&&!t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.routed?`Routed here by the oracle — ${e.note}`:e.note}):null,e.routed&&!e.note?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Routed here by the oracle.`}):null]})}function pQ({job:e}){let t=e.status===`running`;return e.steps.length===0?(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[t?(0,R.jsx)(pj,{className:`size-3.5`}):null,dQ(e.status)]}):(0,R.jsx)(`ol`,{className:`flex flex-col gap-1 text-sm`,children:e.steps.map((e,n)=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:lM(e.at)}),(0,R.jsx)(`span`,{className:`flex h-5 w-3.5 shrink-0 items-center justify-center`,"aria-hidden":`true`,children:e.pending&&t?(0,R.jsx)(pj,{className:`size-3.5`}):(0,R.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}),(0,R.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:e.pending&&t?`${e.text}…`:e.text})]},n))})}function mQ({job:e}){return e.status===`held`?(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Run anyway`,icon:Uh,tone:`primary`,shortcut:`R`,onClick:()=>void U(`quickfix.runAnyway`,{id:e.id})}),(0,R.jsx)(X,{label:`Turn it into a task`,text:`Make it a task`,icon:th,shortcut:`T`,onClick:()=>void U(`quickfix.movedToTask`,{id:e.id})})]}):e.status!==`queued`&&e.status!==`running`?null:(0,R.jsx)(Gj,{children:(0,R.jsx)(SM,{icon:dm,label:`Cancel the quick fix`,text:`Cancel`,shortcut:`C`,title:`Cancel this quick fix?`,description:`The agent stops. Files it already edited stay as they are.`,confirmLabel:`Cancel quick fix`,variant:`destructive`,onConfirm:()=>void U(`quickfix.cancel`,{id:e.id})})})}function hQ({job:e,now:t}){return(0,R.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Quick fix detail`,children:[(0,R.jsx)(mQ,{job:e}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:oQ(e)}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:e.status}),uQ(e,t)?(0,R.jsx)(`span`,{children:uQ(e,t)}):null]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),e.prompt.trim().includes(`
|
|
101
|
+
`)?(0,R.jsx)(WH,{text:e.prompt}):null,(0,R.jsx)(fQ,{job:e}),(0,R.jsx)(qH,{title:`Steps`,children:(0,R.jsx)(pQ,{job:e})}),e.files?.length?(0,R.jsx)(qH,{title:`Edited`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.files.map(e=>(0,R.jsxs)(`li`,{className:`break-all`,children:[`· `,e]},e))})}):null,e.error?(0,R.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:e.error}):null,e.report?(0,R.jsx)(qH,{title:`Report`,children:(0,R.jsx)(WH,{text:e.report})}):null]})}function gQ({status:e}){if(e===`running`)return(0,R.jsx)(pj,{className:`size-3.5`,"aria-label":`running`});let t={queued:_m,success:Vp,failed:Vg,timeout:Vg,cancelled:xh,held:Nh,running:_m}[e];return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(t,{"aria-hidden":`true`,className:`size-4 ${e===`success`?`text-success`:e===`failed`||e===`timeout`?`text-destructive`:e===`held`?`text-warning`:`text-muted-foreground`}`}),(0,R.jsx)(`span`,{className:`sr-only`,children:e})]})}function _Q({job:e,selected:t,now:n,onSelect:r}){let i=lQ(e,n);return(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>r(e.id),className:q(MU,`flex-row items-start gap-2.5 text-sm max-md:min-h-11`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:(0,R.jsx)(gQ,{status:e.status})}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,t?`font-medium text-foreground`:`text-foreground`),children:oQ(e)}),i?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:i}):null]})})}function vQ({jobs:e,selectedId:t,now:n,onSelect:r}){return(0,R.jsx)(`ul`,{className:NU,children:e.map(e=>(0,R.jsx)(_Q,{job:e,selected:e.id===t,now:n,onSelect:r},e.id))})}var yQ=()=>aj(ij(`quickfix`)),bQ=e=>aj(ij(`quickfix`,e));function xQ(e){let[t,n]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),e?t:Date.now()}function SQ(){return(0,R.jsx)(sj,{className:`m-4 flex-1`,children:(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)(Ug,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{className:`font-medium text-foreground`,children:aQ})]})})}function CQ({id:e}){let t=eM(),n=xj(`quickfix.list`,{},[`quickfix`]),r=sQ(n.data?.jobs??[]),i=xQ(r.some(e=>e.status===`running`));if(!n.data&&n.error)return(0,R.jsx)(yj,{message:`Could not load quick fixes. ${n.error}`,onRetry:n.reload});let a=n.data&&r.length===0?(0,R.jsx)(SQ,{}):(0,R.jsx)(wQ,{id:e,wide:t,loaded:!!n.data,jobs:r,now:i});return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:a})}function wQ({id:e,wide:t,loaded:n,jobs:r,now:i}){let a=e??(t?r[0]?.id:void 0),o=r.find(e=>e.id===a),s=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Quick fixes`,count:String(r.length)}),n?(0,R.jsx)(vQ,{jobs:r,selectedId:a,now:i,onSelect:bQ}):(0,R.jsx)(oM,{})]});return(0,R.jsx)(iM,{wide:t,list:s,detail:o?(0,R.jsx)(hQ,{job:o,now:i}):e?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That quick fix is not on the list any more.`}):null,open:!!e,onClose:yQ,hint:`Select a quick fix to see its steps.`,describe:`Quick fix detail`})}var TQ={},EQ=new Set;function DQ(e){TQ=e;for(let e of[...EQ])e()}function OQ(e){TQ.taskId!==e&&DQ({...TQ,taskId:e})}function kQ(e){(TQ.session?.name!==e?.name||JSON.stringify(TQ.session?.address)!==JSON.stringify(e?.address))&&DQ({...TQ,session:e})}function AQ(e){return EQ.add(e),()=>{EQ.delete(e)}}function jQ(){return(0,m.useSyncExternalStore)(AQ,()=>TQ,()=>TQ)}var MQ=8;function NQ(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function PQ(e,t){let n=Math.min(t,MQ);if(n<=0)return[];let r=Math.min(n,Math.round(Math.max(0,e)/t*n));return Array.from({length:n},(e,t)=>t<r)}function FQ({done:e,total:t}){return(0,R.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:PQ(e,t).map((e,t)=>(0,R.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function IQ({check:e,className:t}){return(0,R.jsx)(e===`done`?rm:e===`dropped`?pm:hm,{"aria-hidden":`true`,className:q(`size-4 shrink-0`,e===`done`?`text-success`:`text-muted-foreground`,t)})}function LQ({entry:e}){let t=e.at?lM(e.at):``;return e.role===`note`?(0,R.jsxs)(`li`,{className:`break-words text-center text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[e.text,t?` · ${t}`:``]}):e.role===`you`?(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col items-end gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[t,` `,(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`})]}),(0,R.jsx)(`div`,{className:`max-w-[85%] rounded-xl rounded-tr-sm border border-primary/10 bg-you px-3.5 py-2`,children:(0,R.jsx)(WH,{text:e.text})})]}):(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full bg-primary`}),(0,R.jsx)(`span`,{className:`font-medium text-foreground`,children:`Oracle`}),` `,t]}),(0,R.jsx)(`div`,{className:`max-w-[90%] pl-4`,children:(0,R.jsx)(WH,{text:e.text})})]})}function RQ({entries:e,more:t,loading:n,onMore:r,empty:i}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-col gap-3`,children:[t?(0,R.jsx)(`div`,{className:`flex self-center`,children:(0,R.jsx)(X,{label:`Load earlier messages`,icon:$p,disabled:n,onClick:r??(()=>void 0)})}):null,e.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i}):(0,R.jsx)(`ol`,{"aria-label":`Conversation`,className:`flex min-w-0 flex-col gap-4`,children:e.map(e=>(0,R.jsx)(LQ,{entry:e},e.id))})]})}function zQ({address:e,empty:t}){let n=xj(`sessions.chat`,e,[`sessions`]),[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),s=n.data?.entries??[],c=new Set(s.map(e=>e.id)),l=[...(r?.entries??[]).filter(e=>!c.has(e.id)),...s],u=async()=>{let t=l[0];if(!t)return;o(!0);let n=await U(`sessions.chat`,{...e,before:t.id});n&&i({entries:[...n.entries,...r?.entries??[]],more:n.hasOlder}),o(!1)},d=r?.more??n.data?.hasOlder??!1;return(0,R.jsx)(RQ,{entries:l,more:d,loading:a,onMore:()=>void u(),empty:n.loading&&!n.data?`Loading the conversation…`:t})}var BQ={"this window":`This window`,background:`Background`,"other terminal":`Other terminals`},VQ=[`this window`,`background`,`other terminal`],HQ=`Nothing said yet.`,UQ=`This session runs in another terminal: its conversation shows here and your messages reach its oracle within seconds, but live activity only streams from sessions started in this window.`,WQ=`No other sessions. Start one below.`;function GQ(e,t,n){let r=t?.task;return{id:`here`,where:`this window`,name:e?.sessionName??r?.title??`unnamed session`,status:e?.busy?`working`:r?.state??`no task`,waiting:n,alive:!0,dialogs:[],...r?{task:r}:{}}}function KQ(e){let t=e.status===`exited`?`ended`:e.status===`starting`?`starting`:e.busy?`working`:`idle`;return{id:e.key,where:`background`,name:e.name,status:t,waiting:e.dialogs.length,key:e.key,alive:e.alive,dialogs:e.dialogs,...e.sessionId?{sessionId:e.sessionId}:{}}}function qQ(e){return{id:e.sessionId,where:`other terminal`,name:e.name??`unnamed session`,status:`running`,waiting:0,pid:e.pid,sessionId:e.sessionId,alive:!0,dialogs:[]}}function JQ(e,t,n,r,i){let a=new Set([e?.sessionId,...r.map(e=>e.sessionId)].filter(e=>!!e)),o=i.filter(e=>!a.has(e.sessionId));return[GQ(e,t,n),...r.map(KQ),...o.map(qQ)]}function YQ(e){return`${e} question${e===1?``:`s`} waiting for you`}function XQ(e){return e.status===`starting`?`starting ${e.name}…`:e.alive?`${e.name} has not said anything yet.`:`${e.name} has ended.`}function ZQ(e){return[e.where,e.status.replace(/_/g,` `),e.pid?`pid ${e.pid}`:``].filter(Boolean).join(` · `)}function QQ(e){return e.key?{key:e.key}:e.sessionId?{sessionId:e.sessionId}:void 0}function $Q({options:e,send:t}){return(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:e.map(e=>(0,R.jsx)(Y,{variant:`outline`,className:`max-w-full min-w-0 whitespace-normal break-words text-left max-md:h-auto max-md:min-h-11`,onClick:()=>void t({value:e}),children:e},e))})}function e$({dialog:e,send:t}){let n=(0,m.useId)(),[r,i]=(0,m.useState)(e.prefill??``);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`sr-only`,children:e.title}),(0,R.jsx)(sM,{id:n,rows:e.method===`editor`?4:2,value:r,placeholder:e.placeholder,onChange:e=>i(e.target.value)}),(0,R.jsx)(`div`,{className:`flex self-end`,children:(0,R.jsx)(X,{label:`Send the answer`,text:`Send`,icon:Np,tone:`primary`,disabled:!r.trim(),onClick:()=>void t({value:r.trim()})})})]})}function t$({dialog:e,send:t}){return e.method===`select`?(0,R.jsx)($Q,{options:e.options??[],send:t}):e.method===`confirm`?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-2`,children:[(0,R.jsx)(Y,{className:`max-md:h-auto max-md:min-h-11`,onClick:()=>void t({confirmed:!0}),children:`Yes`}),(0,R.jsx)(Y,{variant:`outline`,className:`max-md:h-auto max-md:min-h-11`,onClick:()=>void t({confirmed:!1}),children:`No`})]}):(0,R.jsx)(e$,{dialog:e,send:t})}function n$({sessionKey:e,dialog:t,onAnswered:n}){let r=async r=>{await U(`sessions.answer`,{key:e,dialogId:t.id,answer:r})&&n()};return(0,R.jsxs)(`div`,{className:`card-raised flex min-w-0 flex-col gap-3 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,R.jsx)(`p`,{className:`break-words text-sm font-medium text-foreground`,children:t.title}),t.message?(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:t.message}):null]}),(0,R.jsx)(t$,{dialog:t,send:r}),(0,R.jsx)(`div`,{className:`flex self-start`,children:(0,R.jsx)(X,{label:`Put it away`,text:`Put away`,icon:Vg,onClick:()=>void r({cancelled:!0})})})]})}function r$({sessionKey:e,dialogs:t,onAnswered:n}){return t.length===0?null:(0,R.jsxs)(`section`,{"aria-label":`Questions waiting`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`p`,{role:`status`,className:`text-sm font-medium text-foreground`,children:YQ(t.length)}),t.map(t=>(0,R.jsx)(n$,{sessionKey:e,dialog:t,onAnswered:n},t.id))]})}var i$={"this window":Ch,background:Zm,"other terminal":pg};function a$({where:e,className:t}){let n=i$[e];return(0,R.jsx)(n,{"aria-hidden":`true`,className:q(`size-4 shrink-0 text-muted-foreground`,t)})}function o$({task:e}){let t=e.progress;return(0,R.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`break-all`,children:e.id}),t&&t.total>0?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(FQ,{done:t.done,total:t.total}),(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[t.done,`/`,t.total]})]}):null]})}function s$({entry:e}){let{key:t}=e;return e.where===`this window`?(0,R.jsx)(Gj,{children:(0,R.jsx)(X,{label:`Back to this window`,text:`Back to the Lobby`,icon:kp,tone:`primary`,shortcut:`B`,onClick:()=>aj(`#/lobby`)})}):t?(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Move here`,icon:jp,tone:`primary`,shortcut:`M`,onClick:()=>void U(`sessions.switch`,{key:t})}),(0,R.jsx)(SM,{icon:dm,label:`Stop the session`,text:`Stop`,shortcut:`S`,title:`Stop ${e.name}?`,description:`Its process ends. The task keeps its state and can be resumed in this window.`,confirmLabel:`Stop session`,variant:`destructive`,disabled:!e.alive,onConfirm:()=>void U(`sessions.stop`,{key:t})})]}):null}function c$({entry:e,lobby:t}){let n=QQ(e);return e.where===`this window`?(0,R.jsx)(RQ,{entries:t?.chat??[],more:!1,empty:HQ}):n?(0,R.jsx)(zQ,{address:n,empty:e.where===`other terminal`?`Nothing said in this session yet.`:XQ(e)},e.id):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:HQ})}function l$({entry:e,lobby:t,onChanged:n}){return(0,R.jsxs)(`article`,{"aria-label":`Session detail`,className:`flex min-w-0 max-w-full flex-col gap-4 max-md:pb-dock`,children:[(0,R.jsx)(s$,{entry:e}),(0,R.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,R.jsxs)(`h3`,{className:`flex min-w-0 max-w-full flex-wrap items-center gap-2.5 text-lg font-semibold tracking-tight text-foreground`,children:[(0,R.jsx)(a$,{where:e.where,className:`size-[1.1rem]`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.name})]}),(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:ZQ(e)}),e.task?(0,R.jsx)(o$,{task:e.task}):null,e.where!==`background`&&e.waiting>0?(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:YQ(e.waiting)}):null]}),e.where===`other terminal`?(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:UQ}):null,e.key?(0,R.jsx)(r$,{sessionKey:e.key,dialogs:e.dialogs,onAnswered:n}):null,(0,R.jsx)(qH,{title:`Conversation`,children:(0,R.jsx)(c$,{entry:e,lobby:t})})]})}function u$({entry:e,selected:t,onSelect:n}){let r=xf();return(0,R.jsx)(B.li,{layout:!r&&`position`,initial:!1,"data-slot":`active-session`,className:`min-w-0 border-t border-border first:border-t-0`,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:q(MU,`min-w-0 flex-row items-start gap-3 rounded-none px-4 py-3 text-sm focus-visible:ring-inset max-md:min-h-11 max-md:h-auto`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid size-8 shrink-0 place-items-center rounded-lg bg-foreground/4 text-foreground/75 shadow-[inset_0_0_0_1px_var(--border)]`,children:(0,R.jsx)(a$,{where:e.where})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:q(`flex min-w-0 flex-wrap items-center gap-2 text-foreground`,t&&`font-medium`),children:[(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.name}),e.where===`this window`?(0,R.jsx)(jU,{variant:`secondary`,radius:`full`,size:`sm`,children:`This window`}):null]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 break-words text-xs text-muted-foreground`,children:[e.status===`working`||e.status===`starting`?(0,R.jsx)(pj,{className:`size-3`,"aria-hidden":`true`}):null,e.status.replace(/_/g,` `),e.waiting>0?(0,R.jsxs)(jU,{variant:`warning-light`,radius:`full`,className:`text-warning tabular-nums`,children:[e.waiting,` waiting`]}):null]})]})]})})}function d$({where:e,entries:t,selectedId:n,onSelect:r}){return(0,R.jsxs)(`section`,{"aria-label":BQ[e],className:`flex flex-col`,children:[(0,R.jsx)(`h3`,{className:PU,children:(0,R.jsx)(KH,{title:BQ[e],right:String(t.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:`workspace-section mx-3 mb-2 flex flex-col overflow-hidden rounded-xl border shadow-xs`,children:t.map(e=>(0,R.jsx)(u$,{entry:e,selected:e.id===n,onSelect:r},e.id))})]})}function f$({entries:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:VQ.map(r=>{let i=e.filter(e=>e.where===r);return i.length>0?(0,R.jsx)(d$,{where:r,entries:i,selectedId:t,onSelect:n},r):null})})}var p$=()=>aj(`#/sessions`),m$=e=>aj(`#/sessions/${encodeURIComponent(e)}`);function h$({windows:e}){return e.length===0?null:(0,R.jsx)(`div`,{className:`px-4 pb-4 pt-2`,children:(0,R.jsx)(qH,{title:`Other windows`,children:(0,R.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-h-8 min-w-0 max-w-full items-center rounded-lg px-2.5 text-sm text-foreground break-words underline-offset-4 transition-colors hover:bg-muted hover:underline max-md:min-h-11 max-md:h-auto`,children:e.name})},e.url))})})})}function g$(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That session is not on the list any more.`})}function _$({id:e}){let t=eM(),n=sA(`status`).data,r=sA(`lobby`).data,i=sA(`prompts`).data?.prompts.length??0,a=xj(`sessions.list`,{},[`sessions`]);if(!a.data&&a.error)return(0,R.jsx)(yj,{message:`Could not load sessions. ${a.error}`,onRetry:a.reload});let o=JQ(n,r,i,a.data?.background??[],a.data?.live??[]),s=e??(t?o[0]?.id:void 0),c=o.find(e=>e.id===s),l=c&&c.where!==`this window`&&c.alive?QQ(c):void 0,u=l?JSON.stringify(l):``,d=c?.name;(0,m.useEffect)(()=>(kQ(l&&d?{name:d,address:l}:void 0),()=>kQ(void 0)),[u,d]);let f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Sessions`,count:String(o.length)}),a.data?(0,R.jsx)(f$,{entries:o,selectedId:s,onSelect:m$}):(0,R.jsx)(oM,{}),a.data&&o.length===1?(0,R.jsx)(`p`,{className:`px-4 pb-3 text-sm text-muted-foreground`,children:WQ}):null,(0,R.jsx)(h$,{windows:n?.windows??[]})]}),p=c?(0,R.jsx)(l$,{entry:c,lobby:r,onChanged:a.reload},c.id):e?(0,R.jsx)(g$,{}):null;return(0,R.jsx)(iM,{wide:t,list:f,detail:p,open:!!e,onClose:p$,hint:`Select a session to see its conversation.`,describe:`Session detail`})}function v$(e,t=0,n=!1){let r=!n&&!e.waiting&&!!e.runningSince,i=r?Date.parse(e.serverNow)-Date.parse(e.runningSince):0;return Math.max(0,e.elapsedMs)+(Number.isFinite(i)?Math.max(0,i):0)+(r?Math.max(0,t):0)}function y$(e){let t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function b$(e,t){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),!e)return;let t=performance.now(),n=window.setInterval(()=>r(performance.now()-t),1e3);return()=>window.clearInterval(n)},[e,t]),e?n:0}function x$({timing:e,stopped:t}){let[n,r]=(0,m.useState)(0);return(0,m.useEffect)(()=>{if(r(0),t||e.waiting||!e.runningSince)return;let n=performance.now(),i=window.setInterval(()=>r(performance.now()-n),1e3);return()=>window.clearInterval(i)},[e,t]),(0,R.jsxs)(`span`,{className:`tabular-nums break-words`,children:[e.waiting?`Waiting for you · `:``,e.phase.replaceAll(`_`,` `),` · `,y$(v$(e,n,t)),` execution`]})}function S$({work:e,timing:t,stopped:n}){let r=e.running&&!n&&!t?.waiting,i=b$(r,e);return(0,R.jsxs)(`span`,{className:`tabular-nums break-words`,"data-work-clock":r?`running`:`stopped`,children:[t?.waiting?`Waiting for you · `:``,t?`${t.phase.replaceAll(`_`,` `)} · `:``,`worked `,y$(e.workedMs+i)]})}function C$({timing:e,work:t,stopped:n=!1}){return t?(0,R.jsx)(S$,{work:t,...e?{timing:e}:{},stopped:n}):e?(0,R.jsx)(x$,{timing:e,stopped:n},JSON.stringify(e)):(0,R.jsx)(`span`,{children:`Timing unavailable`})}var w$=`This merges the reviewed commit into main and pushes main, then removes the task worktree after verifying the merge. The task branch is kept.`,T$={pending_approval:`Ready for your review`,deferred:`Saved for later`,in_progress:`Delivery in progress`,successful:`Delivered`,recoverable_failure:`Delivery needs attention`};function E$({delivery:e,title:t}){return(0,R.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,R.jsx)(`p`,{className:`font-medium break-words`,children:t}),(0,R.jsxs)(`dl`,{className:`grid gap-1 break-all text-muted-foreground`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Project: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.project})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Repository: `}),(0,R.jsx)(`dd`,{className:`inline`,children:e.repository??`Unavailable — refresh review`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Source: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[e.sourceBranch,` · `,e.sourceCommit??`Commit unavailable`]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`inline`,children:`Target: `}),(0,R.jsxs)(`dd`,{className:`inline`,children:[`main`,e.targetCommit?` · ${e.targetCommit}`:``]})]})]}),(0,R.jsxs)(`p`,{children:[`Checks: `,e.verification?.checks??`unavailable`]}),(0,R.jsx)(`p`,{children:e.verification?.summary??`Verification unavailable. Refresh the review before delivery.`}),e.verification?(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Local completion/QA: `,e.verification.localVerified?`passed`:`not verified`,` · Repository rules: `,e.verification.rulesKnown?`known`:`unavailable`,e.verification.requiredChecks.length?` · Required: ${e.verification.requiredChecks.join(`, `)}`:``]}):null]})}function D$({action:e,delivery:t,busy:n,onAction:r}){let i=t.blocked[e],a=e===`merge_main`&&t.status===`successful`&&!!t.cleanupError,o=n||t.status===`in_progress`||t.status===`successful`&&!a||!!i;return(0,R.jsxs)(`div`,{className:`grid min-w-0 gap-1`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11 max-md:whitespace-normal`,disabled:o,onClick:()=>r(e),children:e===`create_pr`?`Create PR`:a?`Retry worktree cleanup`:`Merge to main`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e===`create_pr`?`Pushes the task branch and opens a PR targeting main. Does not merge.`:a?`Main was delivered. Removes the retained worktree after confirmation.`:`Updates and pushes main, then removes the task worktree. Requires confirmation.`}),i?(0,R.jsxs)(`p`,{className:`text-sm text-destructive`,children:[i,` Refresh review after resolving this restriction, then choose the action again.`]}):null]})}async function O$(e,t,n){let r={taskId:t,reviewId:n};return e===`refresh`?Te(`tasks.deliveryReview`,{taskId:t}):e===`defer`?Te(`tasks.deliveryDefer`,r):Te(`tasks.deliver`,{...r,action:e,...e===`merge_main`?{confirmMain:!0}:{}})}function k$({taskId:e,delivery:t}){let[n,r]=(0,m.useState)(t),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(!1),u=(0,m.useRef)(null),d=P(),f=`${d}:${e}`,p=(0,m.useRef)(f);return p.current=f,(0,m.useEffect)(()=>(p.current=f,()=>{p.current=``}),[f]),(0,m.useEffect)(()=>{r(t),l(!1)},[t,e]),{current:n,setCurrent:r,busy:i,setBusy:a,error:o,setError:s,confirm:c,setConfirm:l,trigger:u,project:d,identity:f,scope:p}}function A$(e){return e.scope.current===e.identity&&e.project===P()}function j$(e,t){let n=(0,m.useRef)(!1);async function r(r){if(!(n.current||r===`merge_main`&&!e.confirm)){n.current=!0,e.setBusy(!0),e.setError(void 0),e.setConfirm(!1);try{let n=await O$(r,t.taskId,e.current.reviewId);A$(e)&&(e.setCurrent(n.delivery),t.onChanged())}catch(t){A$(e)&&e.setError(t instanceof Error?t.message:String(t))}finally{n.current=!1,e.scope.current&&e.setBusy(!1)}}}return r}function M$(e){let t=k$(e),n=j$(t,e),r=XA(t.confirm,YA.confirm),i=t.current.status===`successful`||t.current.status===`in_progress`;function a(){t.trigger.current=document.activeElement,t.setConfirm(!0)}return{...t,request:n,slot:r,terminal:i,reviewMerge:a}}function N$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Task completion is recorded separately. Nothing is published without your approval.`}),(0,R.jsx)(`p`,{role:`status`,className:`text-sm`,children:e.busy?`Updating delivery…`:e.current.operation?`Operation: ${e.current.operation.stage}`:T$[e.current.status]}),e.current.error||e.error?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.error??e.current.error,` Completed work is retained. Refresh review to reconcile the result before retrying.`]}):null,e.current.cleanupError?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[e.current.cleanupError,` Retry cleanup after resolving it.`]}):null,e.current.operation?.worktreeRemoved?(0,R.jsx)(`p`,{className:`text-sm`,children:`Task worktree removed.`}):null,e.current.result?(0,R.jsxs)(`p`,{className:`text-sm break-all`,children:[e.current.result.action===`create_pr`?`PR #${e.current.result.pullNumber??``} created`:`main pushed · ${e.current.result.commit??``}`,e.current.result.pullUrl?(0,R.jsxs)(`span`,{children:[` · `,e.current.result.pullUrl]}):null]}):null]})}function P$({review:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 max-md:grid-cols-1 md:grid-cols-2`,children:[(0,R.jsx)(D$,{action:`create_pr`,delivery:e.current,busy:e.busy,onAction:()=>void e.request(`create_pr`)}),(0,R.jsx)(D$,{action:`merge_main`,delivery:e.current,busy:e.busy,onAction:e.reviewMerge})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(Y,{variant:`ghost`,className:`max-md:min-h-11`,disabled:e.busy,onClick:()=>void e.request(`refresh`),children:`Refresh review`}),(0,R.jsx)(Y,{variant:`ghost`,className:`max-md:min-h-11`,disabled:e.busy||e.terminal,onClick:()=>void e.request(`defer`),children:`Not now`})]})]})}function F$({review:e}){let t=e.current.status===`successful`&&!!e.current.cleanupError,n=t?`Main was already delivered. Remove the task worktree if it still contains only the reviewed commit. The task branch is kept.`:w$;return(0,R.jsx)(HA,{open:e.slot,onOpenChange:e.setConfirm,label:t?`Confirm worktree removal`:`Confirm merge to main`,description:n,onCloseAutoFocus:t=>{t.preventDefault(),requestAnimationFrame(()=>e.trigger.current?.focus())},children:(0,R.jsxs)(`div`,{className:`grid gap-4 p-4`,children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:t?`Remove task worktree?`:`Merge to main?`}),(0,R.jsx)(`p`,{className:`text-sm`,children:n}),(0,R.jsxs)(`p`,{className:`break-all text-sm text-muted-foreground`,children:[e.current.repository,` · `,e.current.sourceCommit,` → main`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:()=>e.setConfirm(!1),children:`Cancel`}),(0,R.jsx)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,disabled:e.busy||!!e.current.blocked.merge_main||e.terminal&&!t,onClick:()=>void e.request(`merge_main`),children:t?`Confirm worktree removal`:`Confirm merge and push main`})]})]})})}function I$({title:e,review:t}){return(0,R.jsxs)(qH,{title:`Completed work · delivery review`,right:T$[t.current.status],children:[(0,R.jsx)(E$,{delivery:t.current,title:e}),(0,R.jsx)(N$,{review:t}),(0,R.jsx)(P$,{review:t}),(0,R.jsx)(F$,{review:t})]})}function L$(e){let t=M$(e);return(0,R.jsx)(I$,{title:e.title,review:t})}var R$={open:hm,delivered:sm,addressed:rm},z$={open:`waiting for the owning session`,delivered:`sent to the oracle`,addressed:`plan amended`};function B$({comment:e}){let t=dM(Date.now()-Date.parse(e.createdAt)),n=R$[e.status];return(0,R.jsxs)(`p`,{className:`mt-1 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(n,{"aria-hidden":`true`,className:e.status===`addressed`?`size-3.5 text-success`:`size-3.5`}),z$[e.status],`, `,t,e.editedAt?` (edited)`:``]})}function V$({comment:e,taskId:t,own:n}){let[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(),s=a&&(a.editedAt??``)>(e.editedAt??``)?a:e;return(0,R.jsxs)(`li`,{className:`card-raised min-w-0 rounded-lg border px-3.5 py-2.5`,children:[r?(0,R.jsx)(rZ,{text:s.text,onSave:async n=>{let r=await Te(`tasks.editComment`,{taskId:t,commentId:e.id,text:n});o(r.comment)},onCancel:()=>i(!1)}):(0,R.jsx)(WH,{text:s.text}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(B$,{comment:s}),n&&!r?(0,R.jsx)(Y,{size:`sm`,variant:`ghost`,className:`max-md:min-h-11`,onClick:()=>i(!0),children:`Edit`}):null]})]})}function H$({taskId:e,finished:t,canComment:n}){let r=xj(`tasks.comments`,{taskId:e},[`tasks`]),i=sA(`status`),a=r.data?.comments??[],o=a.filter(e=>e.status!==`addressed`).length;return(0,R.jsxs)(`section`,{"aria-labelledby":`comments-${e}`,className:`flex flex-col gap-3`,children:[(0,R.jsx)(`h3`,{id:`comments-${e}`,className:`text-sm`,children:(0,R.jsx)(KH,{title:`Comments`,right:o>0?`${o} open`:void 0})}),a.length===0?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`No comments.`:n?`No comments yet. Comment on the plan in the box below (Markdown and images work); the oracle amends it.`:`No comments yet.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(t=>(0,R.jsx)(V$,{taskId:e,comment:t,own:!!(t.by&&t.by===i.data?.sessionId)},`${e}-${t.id}`))})]})}var U$={mine:`This session`,others:`Other sessions`,pending:`Pending`,recent:`Finished`,archived:`Archived`},W$={open:`open`,done:`done`,dropped:`abandoned`},G$={none:{label:`None`,depth:`nothing that runs changed: the engine's checks decide, no QA agent`,tone:`bg-accent text-muted-foreground`},low:{label:`Low`,depth:`a light check: the diff, the nearest tests, done once confident`,tone:`bg-success/10 text-success`},medium:{label:`Medium`,depth:`a standard check: the acceptance criteria and realistic regressions`,tone:`bg-warning/10 text-warning`},high:{label:`High`,depth:`a deep, adversarial review: invariants, recovery and everything the change reaches`,tone:`bg-destructive/10 text-destructive`}};function K$(e){let t=e.source===`classifier`?`Jev`:`rules`;if(!e.qaRequired)return`${t} · no QA agent`;let{min:n,max:r}=e.testBudget;return`${t} · ${n===r?r:`${n}-${r}`} new tests at most`}var q$=`No tasks yet. Start one from the Lobby tab, or plan one in the Plan tab.`;function J$(e,t){return`${e.replace(/_/g,` `)}${t?` · paused`:``}`}function Y$(e){return e===`now`?`just now`:`${e} ago`}function X$(e){if(e.kind===`plan`)return[`planned`,e.age?e.age===`now`?`saved just now`:`saved ${e.age} ago`:``,e.issue?`#${e.issue}`:``].filter(Boolean).join(` · `);let t=e.owner??(e.section===`mine`?`this session`:``);return[J$(e.status,e.paused),e.auto?`auto`:``,t].filter(Boolean).join(` · `)}function Z$(e){let t=[];for(let n of e){let e=t.at(-1);e&&e.section===n.section?e.rows.push(n):t.push({section:n.section,rows:[n]})}return t}function Q$(e){let t=e.filter(e=>e.kind!==`archived`),n=t.filter(e=>e.check===`open`).length,r=t.length-n,i=e.length-t.length;return[n?`${n} open`:``,r?`${r} finished`:``,i?`${i} archived`:``].filter(Boolean).join(` · `)||`0`}function $$({step:e,stopped:t}){let n=b$(!t,e);return(0,R.jsx)(`span`,{className:`tabular-nums`,children:y$((e.workedMs??0)+n)})}function e1(){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`relative mt-[0.3125rem] grid size-4 shrink-0 place-items-center`,children:[(0,R.jsx)(`span`,{className:`absolute size-2.5 rounded-full bg-primary/30 motion-safe:animate-ping`}),(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary`})]})}function t1({id:e,agents:t}){let[n,r]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let i=t.filter(e=>!e.parentRunId||!t.some(t=>t.runId===e.parentRunId)).flatMap(e=>[e,...t.filter(t=>t.parentRunId===e.runId)]);return(0,R.jsx)(`ul`,{id:e,"aria-label":`Agents on this step`,className:`mt-1.5 flex flex-col gap-1 rounded-lg border border-border bg-muted/30 px-3 py-2`,children:i.map(e=>{let r=EW({domain:e.domain}),i=!!e.parentRunId&&t.some(t=>t.runId===e.parentRunId),a=Date.parse(e.startedAt);return(0,R.jsxs)(`li`,{className:q(`flex min-w-0 items-baseline gap-2 text-xs`,i&&`ml-4 border-l border-border pl-3`),children:[(0,R.jsx)(`span`,{className:q(`shrink-0 font-medium`,CW(r)),children:SW(r)}),i?(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`child`}):null,(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,title:e.instruction,children:e.instruction||`Working`}),Number.isFinite(a)?(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:y$(Math.max(0,n-a))}):null]},e.runId)})})}function n1({step:e,index:t,stopped:n}){let r=!!e.active&&!n,i=r?e.agents??[]:[],a=i.length||(e.activeAgentCount??1),[o,s]=(0,m.useState)(!1),c=(0,m.useId)(),l=e.status===`done`,u=l?`text-success`:e.status===`current`?`text-primary`:`text-muted-foreground`,d=l?rm:hm,f=`${a} ${a===1?`agent working`:`agents working`}`;return(0,R.jsxs)(`li`,{className:`flex min-w-0 flex-col`,"data-step":r?`active`:e.status,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2.5 text-sm max-md:flex-wrap`,children:[r?(0,R.jsx)(e1,{}):(0,R.jsx)(d,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 ${u}`}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,R.jsx)(`span`,{className:q(`min-w-0 break-words`,r||e.status===`current`?`text-foreground`:`text-muted-foreground`),children:e.text}),r&&i.length>0?(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":o,"aria-controls":c,onClick:()=>s(e=>!e),className:`btn-ghost inline-flex h-5 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-primary outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,children:[`(`,f,`)`,(0,R.jsx)(Up,{"aria-hidden":`true`,className:q(`size-3 transition-transform`,o&&`rotate-180`)})]}):r?(0,R.jsxs)(`span`,{className:`shrink-0 text-xs leading-5 text-primary`,children:[`(`,f,`)`]}):null,r?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary`,children:[`active · `,(0,R.jsx)($$,{step:e,stopped:n}),(0,R.jsx)(`span`,{className:`sr-only`,children:` (being worked on now)`})]}):e.status===`current`&&!n?(0,R.jsxs)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:[`next`,(0,R.jsx)(`span`,{className:`sr-only`,children:` (the step up next)`})]}):null]}),o&&i.length>0?(0,R.jsx)(`div`,{className:`pl-[3.25rem] max-md:pl-0`,children:(0,R.jsx)(t1,{id:c,agents:i})}):null]})}function r1({steps:e,stopped:t}){let n=e.filter(e=>e.status===`done`).length;return(0,R.jsx)(qH,{title:`Steps`,right:`${n}/${e.length} done`,children:(0,R.jsx)(`ol`,{className:`flex flex-col gap-2`,"aria-label":`Steps`,children:e.map((e,n)=>(0,R.jsx)(n1,{step:e,index:n,stopped:t},`${n}-${e.text}`))})})}function i1({text:e}){let[t,n]=(0,m.useState)(!1),r=(0,m.useId)();return(0,R.jsxs)(qH,{title:`Full plan`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`inline-flex min-h-11 w-fit items-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(qp,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,t&&`rotate-90`)}),t?`Hide the details`:`Read the details of each step`]}),t?(0,R.jsx)(`div`,{id:r,children:(0,R.jsx)(WH,{text:e})}):null]})}function a1({detail:e,finished:t}){return e.plan&&e.planDetails?(0,R.jsx)(i1,{text:e.planDetails}):e.plan?(0,R.jsx)(qH,{title:`Approved plan`,children:(0,R.jsx)(WH,{text:e.plan})}):e.proposal?(0,R.jsx)(qH,{title:t?`Proposal`:`Proposal (no plan yet)`,children:(0,R.jsx)(WH,{text:e.proposal})}):(0,R.jsx)(qH,{title:`Plan`,children:(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t?`It ended before a plan was made.`:`No proposal or plan yet — the oracle is still clarifying or scouting.`})})}function o1({amendments:e}){return e.length===0?null:(0,R.jsx)(qH,{title:`Amendments`,children:(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,children:e.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))})})}function s1({detail:e}){return e.waiting.length===0&&e.blockers.length===0?null:(0,R.jsx)(qH,{title:`Waiting on`,children:(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:[e.waiting.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(tm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-warning`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.kind,` `,e.detail]})]},`${t}-${e.kind}`)),e.blockers.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(pm,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-destructive`}),(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:[e.reason,` (needs: `,e.need,`)`]})]},`${t}-${e.reason}`))]})})}function c1({risk:e}){let t=G$[e.risk];return(0,R.jsxs)(qH,{title:`QA risk`,right:K$(e),children:[(0,R.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1 text-sm`,"data-qa-risk":e.risk,children:[(0,R.jsx)(`span`,{className:q(`rounded-md px-2 py-0.5 text-xs font-medium`,t.tone),children:t.label}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:t.depth})]}),e.focusAreas.length>0?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-1 pl-5 text-sm text-muted-foreground`,"aria-label":`What QA looks at first`,children:e.focusAreas.map(e=>(0,R.jsx)(`li`,{className:`break-words`,children:e},e))}):null,(0,R.jsxs)(`p`,{className:`text-xs break-words text-muted-foreground`,children:[e.riskFactors.join(` · `),e.qaRequired?` · existing tests ${e.existingTestsLikelySufficient?`likely enough`:`likely not enough`}`:``]})]})}function l1({runs:e}){return e.length===0?null:(0,R.jsx)(qH,{title:`Recent runs`,children:(0,R.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.map((e,t)=>(0,R.jsx)(`li`,{className:`break-words`,children:e},`${t}-${e}`))})})}function u1({detail:e,finished:t}){return(0,R.jsxs)(R.Fragment,{children:[e.steps.length>0?(0,R.jsx)(r1,{steps:e.steps,stopped:t}):null,e.request?(0,R.jsx)(qH,{title:`Request`,children:(0,R.jsx)(WH,{text:e.request})}):null,(0,R.jsx)(a1,{detail:e,finished:t})]})}function d1({detail:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(o1,{amendments:e.amendments}),(0,R.jsx)(s1,{detail:e}),e.qaRisk?(0,R.jsx)(c1,{risk:e.qaRisk}):null,(0,R.jsx)(l1,{runs:e.runs})]})}function f1({row:e,quiet:t=!1}){let n=(0,m.useRef)(!0);(0,m.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);async function r(){if(e.section===`mine`)return aj(`#/lobby`);let t=P(),r=()=>n.current&&P()===t;try{let t=await Te(`tasks.open`,{taskId:e.id});if(!r())return;let n=await Te(`status.get`,{});if(!r())return;if(t.sessionId&&t.sessionId===n.sessionId)return aj(`#/lobby`);if(t.sessionId&&!t.key)return H.info(`This task runs in another terminal. Switch to that terminal to work on it.`);if(n.busy)return H.info(`The oracle is working in this window. Stop it first, then open the task in its session.`);await U(`sessions.switch`,t.key?{key:t.key}:{claimTaskId:e.id})&&r()&&aj(`#/lobby`)}catch(e){r()&&H.error(e instanceof Error?e.message:String(e))}}let i=e.section===`mine`;return(0,R.jsx)(X,{label:i?`Open in its session: this window`:`Open in its session`,text:`Open in session`,icon:jp,tone:t?`neutral`:`primary`,shortcut:`S`,onClick:()=>void r()})}function p1({split:e}){let t=e.after.length>0?`, after ${e.after.map(e=>`part ${e}`).join(` and `)}`:``;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`font-medium text-primary`,children:[`part `,e.part,` of `,e.of]}),` of one plan that was split into tasks`,t?(0,R.jsx)(`span`,{className:`text-foreground`,children:t}):null]}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.titles.map((t,n)=>(0,R.jsxs)(`span`,{children:[n>0?(0,R.jsx)(`span`,{className:`text-muted-foreground/60`,children:` · `}):null,(0,R.jsxs)(`span`,{className:n+1===e.part?`font-medium text-foreground`:void 0,children:[n+1,`. `,t]})]},`${n}-${t}`))})]})}function m1({planId:e}){let t=xj(`plans.get`,{planId:e},[`plans`]),n=t.data;return n?(0,R.jsxs)(R.Fragment,{children:[n.issue?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`from issue #`,n.issue.number,` — `,n.issue.title,n.issue.url?(0,R.jsxs)(`span`,{className:`break-all`,children:[` `,n.issue.url]}):null]}):null,n.split?(0,R.jsx)(p1,{split:n.split}):null,(0,R.jsx)(qH,{title:`Agreed plan`,children:(0,R.jsx)(WH,{text:n.brief})})]}):t.error?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the agreed plan. `,t.error]}):null}function h1({row:e,onGone:t}){let n=async n=>{await U(`plans.start`,{planId:e.id,where:n})&&t()},r=async()=>{await U(`plans.discard`,{planId:e.id})&&t()};return(0,R.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-4`,"aria-label":e.title,children:[(0,R.jsxs)(Gj,{children:[(0,R.jsx)(X,{label:`Start here`,icon:Uh,tone:`primary`,shortcut:`S`,onClick:()=>void n(`here`)}),(0,R.jsx)(X,{label:`Start in a new session`,text:`New session`,icon:dg,shortcut:`N`,onClick:()=>void n(`session`)}),(0,R.jsx)(SM,{icon:Cg,label:`Discard`,shortcut:`Delete`,title:`Discard "${e.title}"?`,description:`The saved plan is removed from the list. This cannot be undone.`,confirmLabel:`Discard`,variant:`destructive`,onConfirm:()=>void r()})]}),(0,R.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-medium`,children:[(0,R.jsx)(IQ,{check:`open`,className:`mt-1.5`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`pending`,e.age?` · saved ${Y$(e.age)}`:``]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:e.id})]}),(0,R.jsx)(m1,{planId:e.id})]})}function g1({row:e,onResumed:t}){let[n,r]=(0,m.useState)(!1),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);async function a(){let n=P();r(!0);try{let r=await Te(`tasks.resume`,{taskId:e.id});if(P()!==n)return;let i=r.key;H(r.notice,i?{action:{label:`Watch`,onClick:()=>aj(`#/sessions/${encodeURIComponent(i)}`)}}:void 0),t()}catch(e){P()===n&&H.error(e instanceof Error?e.message:String(e))}finally{i.current&&r(!1)}}let o=e.owner===`not running`;return(0,R.jsx)(X,{label:o?`Resume: carry it on in a background session`:`Resume: unpause it where it runs`,text:`Resume`,icon:Uh,tone:`primary`,shortcut:`R`,disabled:n,onClick:()=>void a()})}function _1(e){if(e.kind===`archived`)return{state:`archived`,rest:Y$(e.age??`now`)};let t=e.check!==`open`,n=e.owner??(e.section===`mine`?`this session`:``),r=t&&e.age?`${e.check===`dropped`?`dropped`:`done`} ${Y$(e.age)}`:``;return{state:J$(e.status,e.paused),rest:[t?``:n,r].filter(Boolean).join(` · `)}}function v1(e){return e?[NQ(e.track),e.domains.join(`, `)].filter(Boolean).join(` · `):``}function y1({row:e}){return e.progress?(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(FQ,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,` of `,e.progress.total,` steps`]})]}):null}function b1({row:e,task:t}){let n=t?.git?`branch ${t.git.branch}${t.git.from?` · from ${t.git.from}`:``}`:``,{state:r,rest:i}=_1(e);return(0,R.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`h2`,{className:`flex items-start gap-2.5 text-lg font-semibold tracking-tight`,children:[(0,R.jsx)(IQ,{check:e.check,className:`mt-1.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[W$[e.check],`:`]}),(0,R.jsx)(`span`,{className:e.check===`dropped`?`min-w-0 break-words line-through`:`min-w-0 break-words`,children:e.title})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`rounded-md bg-accent px-2 py-0.5 text-xs font-medium text-foreground`,children:r}),i?(0,R.jsx)(`span`,{children:i}):null]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[e.id,v1(t),n].filter(Boolean).join(` · `)}),(0,R.jsx)(y1,{row:e})]})}function x1({row:e,onGone:t,onChanged:n}){let r=e.id;return{restore:async()=>{await U(`tasks.restore`,{taskId:r},{undo:()=>void U(`tasks.archive`,{taskId:r})})&&t()},archive:async()=>{await U(`tasks.archive`,{taskId:r},{undo:()=>void U(`tasks.restore`,{taskId:r})})&&t()},remove:async()=>{await U(`tasks.delete`,{taskId:r,where:e.kind===`archived`?`archive`:`list`})&&t()},toggleAuto:()=>void U(`tasks.auto`,{taskId:r,on:!e.auto}).then(n)}}function S1({row:e,archive:t}){return e.check===`open`?(0,R.jsx)(SM,{label:`Archive`,icon:Tp,shortcut:`E`,title:`Archive "${e.title}"?`,description:`A task still under way is abandoned first, then moved to the archive. Restore brings it back.`,confirmLabel:`Archive`,onConfirm:()=>void t()}):(0,R.jsx)(X,{label:`Archive`,icon:Tp,shortcut:`E`,onClick:()=>void t()})}function C1({on:e,toggle:t}){return Uj(`a`,t),(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsxs)(`label`,{className:`flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2.5 text-[0.8125rem] font-medium transition-colors hover:bg-accent max-md:min-h-11`,children:[(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,R.jsx)(`span`,{children:`Auto`}),(0,R.jsx)(GJ,{checked:e,onCheckedChange:t,"aria-label":`Auto mode`,"aria-keyshortcuts":`A`}),(0,R.jsx)(rA,{chord:`A`,className:`kbd-hint`})]})}),(0,R.jsx)(Tj,{children:`Auto mode: the oracle decides without asking`})]})}function w1(e){let{row:t}=e,{restore:n,archive:r,remove:i,toggleAuto:a}=x1(e),o=t.kind===`archived`,s=t.kind===`task`&&t.check===`open`&&!!t.resumable;return(0,R.jsxs)(Gj,{children:[s?(0,R.jsx)(g1,{row:t,onResumed:e.onChanged}):null,t.kind===`task`&&t.check===`open`?(0,R.jsx)(f1,{row:t,quiet:s}):null,t.kind===`task`?(0,R.jsx)(T1,{taskId:t.id}):null,o?(0,R.jsx)(X,{label:`Restore`,icon:Zh,shortcut:`R`,onClick:()=>void n()}):null,t.check===`open`&&!o?(0,R.jsx)(C1,{on:!!t.auto,toggle:a}):null,o?null:(0,R.jsx)(S1,{row:t,archive:r}),(0,R.jsx)(SM,{icon:Cg,label:o?`Delete for good`:`Delete`,text:`Delete`,shortcut:`Delete`,title:`Delete "${t.title}" for good?`,description:`This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:()=>void i()})]})}function T1({taskId:e}){let t=(0,m.useRef)(!0);(0,m.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]);async function n(){let n=P();try{let r=await Te(`tasks.open`,{taskId:e});if(!t.current||P()!==n)return;r.notice&&H.info(r.notice);let i=await Te(`status.get`,{});if(!t.current||P()!==n)return;let a=r.key??(r.sessionId===i.sessionId?`here`:r.sessionId);a?aj(`#/sessions/${encodeURIComponent(a)}`):r.notice||H.info(`This task has no active session. No replacement session was created.`)}catch(e){t.current&&P()===n&&H.error(e instanceof Error?e.message:String(e))}}return(0,R.jsx)(X,{label:`Open task conversation`,text:`Conversation`,icon:ph,shortcut:`O`,onClick:()=>void n()})}function E1(e){let{row:t}=e,n=t.kind===`plan`,r=xj(`tasks.get`,{taskId:t.id},[`tasks`],!n),i=sA(`lobby`).data?.task,a=i?.id===t.id?i:void 0;if(n)return(0,R.jsx)(h1,{row:t,onGone:e.onGone});let o=t.check===`open`&&t.kind===`task`,s=r.data?r.data.work:t.work;return(0,R.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-5`,"aria-label":t.title,children:[(0,R.jsx)(w1,{...e}),(0,R.jsx)(b1,{row:t,task:a}),(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,R.jsx)(C$,{timing:r.data?.timing??t.timing,...s?{work:s}:{},stopped:t.check!==`open`})}),r.data?.delivery?(0,R.jsx)(L$,{taskId:t.id,title:t.title,delivery:r.data.delivery,onChanged:r.reload},t.id):null,r.data?(0,R.jsx)(u1,{detail:r.data,finished:!o}):null,(0,R.jsx)(H$,{taskId:t.id,finished:!o,canComment:o}),r.data?(0,R.jsx)(d1,{detail:r.data}):null,r.error&&!r.data?(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load the plan detail. `,r.error]}):null]})}function D1({row:e}){return e.check===`open`&&e.progress?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,R.jsx)(FQ,{done:e.progress.done,total:e.progress.total}),(0,R.jsxs)(`span`,{children:[e.progress.done,`/`,e.progress.total]})]}):e.age&&e.check!==`open`?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.age}):null}function O1(e){return e.check===`dropped`?`text-muted-foreground line-through`:e.kind===`archived`||e.check===`done`?`text-muted-foreground`:`text-foreground`}function k1({row:e,card:t}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:e.status.replaceAll(`_`,` `)}):null,e.check===`open`?(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:X$(e)}):null,e.kind===`plan`?null:(0,R.jsx)(`span`,{className:`pl-6 text-xs text-muted-foreground`,children:(0,R.jsx)(C$,{timing:e.timing,...e.work?{work:e.work}:{},stopped:e.check!==`open`})}),e.delivery?(0,R.jsxs)(`span`,{className:`pl-6 text-xs text-foreground`,children:[`Delivery: `,e.delivery.status.replaceAll(`_`,` `),` · open task to review`]}):null]})}function A1({row:e,selected:t,onSelect:n,card:r=!1}){return(0,R.jsx)(`li`,{className:r?`overflow-hidden rounded-lg border border-input bg-card shadow-sm`:void 0,children:(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(e.id),className:q(MU,`max-md:min-h-11`),children:[(0,R.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,R.jsx)(IQ,{check:e.check,className:`mt-0.5`}),(0,R.jsxs)(`span`,{className:`sr-only`,children:[W$[e.check],`:`]}),(0,R.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words`,O1(e),t&&`font-medium text-foreground`),children:e.title}),(0,R.jsx)(D1,{row:e})]}),(0,R.jsx)(k1,{row:e,card:r})]})})}function j1({rows:e,selectedId:t,onSelect:n}){return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:Z$(e).map(({section:e,rows:r})=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:PU,children:(0,R.jsx)(KH,{title:U$[e],right:String(r.length),className:`[&>span:first-child]:font-medium [&>span:first-child]:text-muted-foreground`})}),(0,R.jsx)(`ul`,{className:NU,children:r.map(e=>(0,R.jsx)(A1,{row:e,selected:e.id===t,onSelect:n},`${e.kind}-${e.id}`))})]},e))})}var M1=()=>aj(ij(`tasks`,`board`)),N1=e=>aj(ij(`tasks`,`board`,e)),P1=[`Backlog`,`In progress`,`Completed`];function F1(e){if(e.kind!==`archived`&&e.section!==`archived`)return e.check===`done`?`Completed`:e.kind===`plan`||e.status===`created`||e.check===`dropped`?`Backlog`:`In progress`}function I1({title:e,rows:t,id:n}){return(0,R.jsxs)(iq,{role:`region`,"aria-label":e,spacing:`sm`,className:`min-w-0 max-md:rounded-lg`,children:[(0,R.jsx)(oq,{className:`py-2`,children:(0,R.jsxs)(`h2`,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[e,(0,R.jsx)(jU,{variant:`secondary`,radius:`full`,children:t.length})]})}),(0,R.jsxs)(aq,{children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-3`,children:t.map(e=>(0,R.jsx)(A1,{row:e,selected:e.id===n,onSelect:N1,card:!0},`${e.kind}-${e.id}`))}),t.length?null:(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No tasks here.`})]})]})}function L1({rows:e,id:t}){return(0,R.jsx)(`div`,{className:`grid min-w-0 items-start gap-4 p-4 max-md:gap-3 max-md:p-3 md:grid-cols-3`,"aria-label":`Task board`,children:P1.map(n=>(0,R.jsx)(I1,{title:n,rows:e.filter(e=>F1(e)===n),id:t},n))})}function R1({id:e}){let t=xj(`tasks.list`,{},[`tasks`,`plans`]),n=t.data?.rows??[],r=n.find(t=>t.id===e&&F1(t)!==void 0),i=r?.kind===`task`?r.id:void 0;if((0,m.useEffect)(()=>(OQ(i),()=>OQ(void 0)),[i]),!t.data&&t.error)return(0,R.jsx)(yj,{message:`Could not load tasks. ${t.error}`,onRetry:t.reload});let a=r?(0,R.jsx)(E1,{row:r,onGone:M1,onChanged:t.reload},r.id):null;return(0,R.jsx)(iM,{wide:!1,list:t.data?(0,R.jsx)(L1,{rows:n,id:e}):(0,R.jsx)(oM,{}),detail:a,open:!!r,onClose:M1,hint:`Select a task to see its detail.`,describe:`Task detail`})}var z1=()=>aj(ij(`tasks`)),B1=e=>aj(ij(`tasks`,e));function V1(){return(0,R.jsxs)(sj,{className:`m-4 flex-1`,children:[(0,R.jsxs)(cj,{children:[(0,R.jsx)(uj,{variant:`icon`,children:(0,R.jsx)($m,{"aria-hidden":`true`})}),(0,R.jsx)(fj,{children:q$})]}),(0,R.jsx)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:()=>aj(ij(`plan`)),children:`Plan a task`})]})}function H1({shown:e,count:t,onToggle:n}){return(0,R.jsxs)(`label`,{className:`btn-raised flex h-7 min-w-0 cursor-pointer items-center gap-2 rounded-lg border bg-card px-2 text-xs font-medium transition-[box-shadow] max-md:h-11 max-md:min-w-11`,children:[(0,R.jsx)(kG,{checked:e,onCheckedChange:n,"aria-label":`Show archived tasks`,className:`size-4`}),`Archived`,(0,R.jsx)(jU,{variant:`secondary`,className:`h-5 px-1.5`,children:t})]})}function U1({id:e,board:t=!1}){return(0,R.jsxs)(ok,{value:t?`board`:`list`,onValueChange:e=>aj(ij(`tasks`,...e===`board`?[`board`]:[])),className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(sk,{"aria-label":`Task views`,className:`flex gap-1 border-b border-border px-4 py-2 max-md:px-3 max-md:py-1.5`,children:[(0,R.jsx)(ck,{value:`list`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`List`}),(0,R.jsx)(ck,{value:`board`,className:`rounded-lg border border-input px-3 py-1.5 text-sm text-muted-foreground data-[state=active]:bg-tab-fill data-[state=active]:text-foreground focus-visible:ring-3 focus-visible:ring-ring`,children:`Board`})]}),(0,R.jsx)(lk,{value:`list`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(W1,{id:e})}),(0,R.jsx)(lk,{value:`board`,className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(R1,{id:e})})]})}function W1({id:e}){let t=eM(),[n,r]=(0,m.useState)(!1),i=xj(`tasks.list`,{},[`tasks`,`plans`]),a=xj(`tasks.archived`,{},[`tasks`]),o=i.data?.rows??[],s=a.data?.rows??[],c=n?[...o,...s]:o,l=e??(t?c[0]?.id:void 0),u=[...c,...s].find(e=>e.id===l&&e.kind===`task`)?.id;if((0,m.useEffect)(()=>(OQ(u),()=>OQ(void 0)),[u]),!i.data&&i.error)return(0,R.jsx)(yj,{message:`Could not load tasks. ${i.error}`,onRetry:i.reload});if(i.data&&o.length===0&&s.length===0)return(0,R.jsx)(V1,{});let d=[...c,...s].find(e=>e.id===l),f=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(aM,{title:`Tasks`,count:Q$(c),children:(0,R.jsx)(H1,{shown:n,count:s.length,onToggle:()=>r(e=>!e)})}),i.data?c.length===0?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:q$}):(0,R.jsx)(j1,{rows:c,selectedId:l,onSelect:B1}):(0,R.jsx)(oM,{})]}),p=d?(0,R.jsx)(E1,{row:d,onGone:z1,onChanged:i.reload},d.id):e?(0,R.jsx)(G1,{}):null;return(0,R.jsx)(iM,{wide:t,list:f,detail:p,open:!!e,onClose:z1,hint:`Select a task to see its detail.`,describe:`Task detail`})}function G1(){return(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That task is not on the list any more.`})}var K1={l:`lobby`,p:`plan`,t:`tasks`,i:`issues`,u:`git`,s:`sessions`,n:`knowledge`,q:`quickfix`,m:`metrics`,e:`settings`,x:`excalidraw`};function q1(){return cA(`(max-width: 767.98px)`)?(0,R.jsxs)(`section`,{className:`flex min-h-full flex-1 flex-col items-center justify-center gap-4 px-6 py-12 text-center`,children:[(0,R.jsx)(`h1`,{className:`text-lg font-medium`,children:`Metrics is unavailable on phones.`}),(0,R.jsx)(`a`,{href:`#/lobby`,className:`btn-tint inline-flex min-h-11 items-center justify-center rounded-lg border px-5 text-sm font-medium focus-visible:ring-3 focus-visible:ring-ring/40`,children:`Lobby`})]}):(0,R.jsx)(lJ,{})}function J1(e){let t=e[0];if(t)try{return decodeURIComponent(t)}catch{return t}}function Y1(e){if(e.kind===`settings`)return(0,R.jsx)(LX,{});if(e.kind===`sessions`)return(0,R.jsx)(_$,{id:J1(e.key?[e.key]:[])});switch(e.tab){case`lobby`:return(0,R.jsx)(nq,{});case`tasks`:return(0,R.jsx)(U1,{...OG(e.rest)});case`plan`:return(0,R.jsx)(rQ,{rest:e.rest});case`quickfix`:return(0,R.jsx)(CQ,{id:J1(e.rest)});case`issues`:return(0,R.jsx)(hW,{rest:e.rest});case`metrics`:return(0,R.jsx)(q1,{});case`git`:return(0,R.jsx)(HU,{rest:e.rest});case`knowledge`:return(0,R.jsx)(DG,{rest:e.rest});case`excalidraw`:return(0,R.jsx)(FK,{id:J1(e.rest)})}}function X1(e,t){return t.overlay?!0:e===`savePlan`&&!t.saveAvailable}var Z1={tab:`Tab`,esc:`Escape`,escape:`Escape`,enter:`Enter`,space:`Space`,pageup:`PageUp`,pagedown:`PageDown`,home:`Home`,end:`End`,"]":`BracketRight`,"[":`BracketLeft`,"/":`Slash`,"?":`Slash`,",":`Comma`,".":`Period`};function Q1(e){return e.length===1&&/[a-z]/i.test(e)?`Key${e.toUpperCase()}`:e.length===1&&/[0-9]/.test(e)?`Digit${e}`:Z1[e]}function $1(e){let t={alt:!1,ctrl:!1,shift:!1,meta:!1,code:``};for(let n of e.toLowerCase().split(`+`))if(n===`alt`)t.alt=!0;else if(n===`ctrl`||n===`control`)t.ctrl=!0;else if(n===`shift`)t.shift=!0;else if(n===`meta`||n===`cmd`)t.meta=!0;else{let e=Q1(n);if(!e)return;t.code=e}return t.code?t:void 0}function e0(e,t){return e.code===t.code&&e.altKey===t.alt&&e.ctrlKey===t.ctrl&&e.shiftKey===t.shift&&e.metaKey===t.meta}function t0(e,t){let n=$1(t);return n?e0(e,n):!1}function n0(e,t){for(let n of t)if(t0(e,n.key))return n.action}function r0(e,t){for(let n of t)if(t0(e,n.key))return n.id}function i0(e){return Oj(e.target)||e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||ZA()||!!document.querySelector(`[role='dialog'], [role='menu'], [role='listbox']`)}function a0(e,t,n,r){let i=!e.shiftKey&&/^[1-9]$/.test(e.key)?t[Number(e.key)-1]:void 0;if(i)r(i.id);else if(e.key===`/`)n(`search`);else if(e.key===`?`)n(`help`);else if(e.key===`j`||e.key===`k`)Pj(e.key===`j`?1:-1);else return!1;return!0}function o0(e,t){let n=r0(e,t.tabs),r=n0(e,t.keys);return!n&&!r?!1:X1(r,{overlay:!!document.querySelector(`[role='dialog']:not([data-state='closed']), [role='menu']:not([data-state='closed']), [role='listbox']`)||ZA(),typing:Oj(e.target)||e.target instanceof HTMLInputElement,saveAvailable:!!document.querySelector(`[data-plan-save]:not([disabled])`)})||(r===`search`||r===`savePlan`)&&!t.insideApp()?!0:(e.preventDefault(),n?t.onTab(n):r&&t.onAction(r),!0)}function s0(e,t,n){if(e.key===`Escape`)return Date.now()<n&&e.preventDefault(),0;if(Date.now()<n){let n=K1[e.key];return n&&(e.preventDefault(),t.onTab(n)),0}return e.key===`g`?Date.now()+1500:(a0(e,t.tabs,t.onAction,t.onTab)&&e.preventDefault(),0)}function c0(e){(0,m.useEffect)(()=>{if(!e.enabled)return;let t=0,n=n=>{if(n.defaultPrevented||n.isComposing)return;if(!e.insideApp()){n0(n,e.keys)===`help`&&(n.preventDefault(),e.onAction(`help`));return}let r=!n.altKey&&!n.ctrlKey&&!n.metaKey;if(r&&i0(n)){t=0;return}if(o0(n,e)){t=0;return}t=r?s0(n,e,t):0};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e.enabled,e.keys,e.tabs,e.insideApp,e.onAction,e.onTab])}var l0=[{id:`focus`,caps:[`/`],help:`focus search, or the message box`},{id:`send`,label:`Enter`,help:`send the message`},{id:`newline`,label:`Shift+Enter`,help:`a new line (lists carry on)`},{id:`format`,label:`Ctrl+B`,help:`bold; Ctrl+I italic, Ctrl+E code, Ctrl+K link`},{id:`leave`,label:`Esc`,help:`leave the box for the tab bar`}],u0=[{id:`digits`,caps:[`1`,`…`,`9`],help:`jump to a tab in current order`},{id:`help`,caps:[`?`],help:`keyboard shortcuts`},...Object.entries(K1).map(([e,t])=>({id:`go.${t}`,caps:[`g`,e],help:`jump to ${t}`})),{id:`project`,caps:[`P`],help:`open the project switcher`},{id:`theme`,caps:[`D`],help:`switch between light and dark`},{id:`edit`,label:`Ctrl+Enter`,help:`save an edited message; Esc cancels`}],d0=[{id:`tasks`,page:`Tasks`,keys:[[`E`,`archive`],[`R`,`restore`],[`A`,`auto mode`],[`Delete`,`delete`]]},{id:`saved`,page:`Saved plan`,keys:[[`S`,`start here`],[`N`,`new session`],[`Delete`,`discard`]]},{id:`plan`,page:`Plan`,keys:[[`A`,`answer`],[`R`,`retry`],[`Ctrl+S`,`save`],[`N`,`new plan`]]},{id:`quickfix`,page:`Quick fix`,keys:[[`R`,`run anyway`],[`T`,`make a task`],[`C`,`cancel`]]},{id:`git`,page:`Git`,keys:[[`R`,`refresh`],[`V`,`review`],[`Q`,`Jev's read`],[`X`,`stop`]]},{id:`issues`,page:`Issues`,keys:[[`R`,`refresh`]]},{id:`knowledge`,page:`Knowledge`,keys:[[`E`,`edit`],[`A`,`add`],[`C`,`comment`],[`F`,`edit file`],[`Delete`,`delete`]]},{id:`excalidraw`,page:`Excalidraw`,keys:[[`R`,`reveal`],[`C`,`copy`],[`O`,`open`],[`W`,`draw`],[`T`,`check`],[`Delete`,`remove`]]},{id:`sessions`,page:`Sessions`,keys:[[`M`,`move here`],[`S`,`stop`],[`B`,`back`]]},{id:`confirm`,page:`Asked to confirm`,keys:[[`Y`,`yes, do it`],[`Esc`,`keep it`]]}],f0=[{id:`enter`,caps:[`↓`],help:`from the tab bar, into the page`},{id:`rows`,caps:[`↑`,`↓`],help:`move through a list (j and k work too)`},{id:`pane`,caps:[`←`,`→`],help:`between a list and its detail (h and l)`},{id:`ends`,caps:[`Home`,`End`],help:`first and last row`},{id:`open`,caps:[`Enter`,`Space`],help:`activate the focused button or row (links: Enter; checkboxes: Space)`},{id:`back`,label:`Esc`,help:`back up to the tab bar`}],p0=[{id:`qmove`,caps:[`↑`,`↓`],help:`move between the options`},{id:`qpick`,label:`Space`,help:`pick an option (several when allowed)`},{id:`qchoose`,label:`Enter`,help:`choose and go on; in your own answer, send it`},{id:`qacross`,caps:[`←`,`→`],help:`previous and next question`},{id:`qdigit`,caps:[`1`,`2`,`…`],help:`pick that option`},{id:`qesc`,label:`Esc`,help:`put the question away for later`}];function m0({line:e}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`flex w-28 shrink-0 items-center`,children:e.caps?(0,R.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e.caps.map(e=>(0,R.jsx)(Zk,{children:e},e))}):(0,R.jsx)(rA,{chord:e.label??``})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.help})]})}function h0(){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Buttons on a page`}),d0.map(e=>(0,R.jsxs)(`div`,{className:`flex items-start gap-3 py-1`,children:[(0,R.jsx)(`span`,{className:`w-28 shrink-0 pt-0.5 text-sm font-medium`,children:e.page}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground`,children:e.keys.map(([e,t])=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(rA,{chord:e}),t]},e))})]},e.id))]})}function g0({title:e,lines:t}){return(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`h3`,{className:`mb-1 text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e}),t.map(e=>(0,R.jsx)(m0,{line:e},e.id))]})}function _0(e){return e.map(e=>({id:e.action,label:e.label,help:e.help}))}function v0(e){return e.map(e=>({id:`tab.${e.id}`,label:e.key,help:`jump to the ${e.label} tab`}))}function y0({open:e,onOpenChange:t,keys:n,tabs:r}){let i=cA(`(max-width: 767.98px)`),a=e&&!i,o=XA(a,YA.help);return(0,m.useEffect)(()=>{i&&e&&t(!1)},[i,e,t]),(0,m.useEffect)(()=>{if(!a||!o)return;let e=e=>{let r=n.find(e=>e.action===`help`)?.key;(e.key===`Escape`||r&&t0(e,r))&&(e.preventDefault(),t(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t,o,a]),i?null:(0,R.jsxs)(HA,{open:a&&o,onOpenChange:t,label:`Keys`,className:`max-w-4xl`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-border px-6 py-4`,children:[(0,R.jsx)(`h2`,{"aria-hidden":`true`,className:`text-base font-semibold tracking-tight`,children:`Keyboard shortcuts`}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(rA,{chord:`Esc`}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,onClick:()=>t(!1),children:(0,R.jsx)(Vg,{"aria-hidden":`true`})})]})]}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-x-10 gap-y-6 overflow-y-auto px-6 py-5 md:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(g0,{title:`Everywhere`,lines:_0(n)}),(0,R.jsx)(g0,{title:`Jump to a tab`,lines:v0(r)}),(0,R.jsx)(g0,{title:`Navigation and editing`,lines:u0}),(0,R.jsx)(g0,{title:`Message box`,lines:l0})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(g0,{title:`Lists and panes`,lines:f0}),(0,R.jsx)(h0,{}),(0,R.jsx)(g0,{title:`Questions`,lines:p0})]})]})]})}function b0(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}async function x0(e){if(e.size===0)throw Error(`${e.name||`That file`} is empty.`);if(e.size>20971520)throw Error(`${e.name||`That file`} is larger than 20 MB.`);let t=new URLSearchParams({name:e.name||`pasted-file`,type:e.type}),n=await fetch(F(`/api/files.upload?${t}`),{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e,credentials:`same-origin`}),r=await n.json().catch(()=>void 0);if(!r)throw new Ce(`the lobby answered ${n.status}`,`failed`,n.status);if(!r.ok)throw new Ce(r.error,r.code,n.status);return r.result}function S0(e,t,n,r){let i=e.slice(0,t),a=e.slice(t,n),o=e.slice(n);if(a.length>=r.length*2&&a.startsWith(r)&&a.endsWith(r)){let e=a.slice(r.length,a.length-r.length);return{value:i+e+o,start:t,end:t+e.length}}return i.endsWith(r)&&o.startsWith(r)?{value:i.slice(0,i.length-r.length)+a+o.slice(r.length),start:t-r.length,end:n-r.length}:{value:i+r+a+r+o,start:t+r.length,end:n+r.length}}function C0(e,t,n){let r=e.slice(t,n)||`text`,i=`[${r}](url)`,a=t+r.length+3;return{value:e.slice(0,t)+i+e.slice(n),start:a,end:a+3}}var w0=/^(\s*)(?:([-*+])|(\d+)([.)]))\s+(\[[ xX]\]\s+)?/;function T0(e,t){let n=e.lastIndexOf(`
|
|
102
102
|
`,t-1)+1,r=e.indexOf(`
|
|
103
|
-
`,t),i=e.slice(n,r<0?e.length:r),a=C0.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function T0({rest:e}){let{chat:t}=qW(e);return(0,R.jsx)(`div`,{role:`group`,"aria-label":`Knowledge pane`,className:`flex items-center gap-0.5 rounded-lg bg-muted p-0.5`,children:[`Chat`,`Docs`].map(n=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>aj(JW(e,n===`Chat`)),className:q(`h-6 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,t===(n===`Chat`)?`btn-raised btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:n},n))})}var E0={id:`oracle`,pill:`Oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`};function D0(e,t,n){if(e.kind===`sessions`){let e={id:`newsession`,pill:`New session`,label:`Start a task in a new session`,placeholder:`Describe a task for a new session…`};return n?[{id:`session`,pill:`Message`,label:`Message ${n.name}`,placeholder:`Message ${n.name}…`,session:n},e,E0]:[e,E0]}if(e.kind!==`tab`)return[E0];if(e.tab===`knowledge`)return[{id:`knowledge`,pill:`Oracle`,label:`Ask the oracle about this project`,placeholder:`Ask about this project — the oracle searches the code and learns what is missing…`}];if(e.tab===`plan`)return[{id:`panel`,pill:`Panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`},E0];if(e.tab===`quickfix`)return[{id:`quickfix`,pill:`Quick fix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`},E0];let r=e.tab===`tasks`?OG(e.rest).id??t:void 0;return r?[{id:`comment`,pill:`Comment`,label:`Comment on ${r}`,placeholder:`Comment on ${r}'s plan…`,taskId:r},{id:`task`,pill:`Task's oracle`,label:`Message ${r}'s oracle`,placeholder:`Leave a message for ${r}'s oracle…`,taskId:r},E0]:[E0]}var O0=0,k0=`toolbar-button relative inline-flex size-8 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,translate] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`;function A0(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function j0({file:e,onRemove:t}){let n=(0,R.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:q(`btn-ghost flex shrink-0 items-center justify-center rounded-lg border text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,e.image?`absolute top-1 right-1 size-5 bg-background/80 text-foreground backdrop-blur-sm`:`size-7`),children:(0,R.jsx)(Vg,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,R.jsxs)(B.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:520,damping:32},title:`${e.name} · ${y0(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border bg-muted`,children:[(0,R.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-background/60`,children:(0,R.jsx)(pj,{className:`size-4`,"aria-hidden":`true`,role:`presentation`})}):null,n]}):(0,R.jsxs)(B.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:520,damping:32},className:`flex h-9 min-w-0 items-center gap-2 rounded-lg border border-border bg-muted pr-1 pl-2.5`,children:[(0,R.jsxs)(`span`,{className:`relative flex shrink-0 items-center justify-center text-muted-foreground`,children:[(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4`}),e.state===`uploading`?(0,R.jsx)(pj,{className:`absolute -right-1 -bottom-1 size-2.5`,"aria-hidden":`true`,role:`presentation`}):null]}),(0,R.jsxs)(`span`,{className:`min-w-0 max-w-40`,children:[(0,R.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:e.name}),(0,R.jsx)(`span`,{className:`block text-[0.65rem] leading-tight text-muted-foreground`,children:e.state===`uploading`?`uploading…`:y0(e.size)})]}),n]})}function M0({route:e,keys:t,onHelp:n,dockNav:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(),_=sA(`status`),v=sA(`lobby`),y=QA(),b=(_.data?.busy??!1)||!!v.data?.reply?.trim(),x=lA(),S=cA(`(max-width: 767.98px)`),{keyboardOpen:C,keyboardInset:w}=BA(),{taskId:T,session:E}=AQ(),D=(0,m.useMemo)(()=>D0(e,T,E),[e,T,E]),O=D.map(e=>`${e.id}:${e.taskId??e.session?.name??``}`).join(`|`),k=D.find(e=>e.id===h)??D[0];(0,m.useEffect)(()=>g(void 0),[O]);let A=(0,m.useRef)(null),ee=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(o);M.current=o;let te=(0,m.useRef)(void 0);(0,m.useLayoutEffect)(()=>{let e=te.current,t=ee.current;e&&t&&(te.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let ne=(0,m.useCallback)(e=>{te.current={start:e.start,end:e.end},a(e.value)},[]);(0,m.useEffect)(()=>{let e=A.current;if(!e)return;let t=document.documentElement,n=()=>t.style.setProperty(`--composer-h`,y?`0px`:`${Math.ceil(e.getBoundingClientRect().height+(S?w:0))}px`);n();let r=new ResizeObserver(n);return r.observe(e),()=>{r.disconnect(),t.style.setProperty(`--composer-h`,`0px`)}},[y,w,C,S]);let N=(0,m.useCallback)(e=>{let t=[...e],n=8-M.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++O0}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),b0(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),re=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),ie=o.some(e=>e.state===`uploading`),ae=o.flatMap(e=>e.info?[e.info.id]:[]),oe=(i.trim().length>0||ae.length>0)&&!ie&&!u,se=(0,m.useCallback)(async()=>{if(!oe)return;d(!0);let t=ae.length>0?ae:void 0,n={text:i,...t?{attachments:t}:{}};try{let r=!0;if(k.id===`oracle`){let e=await Te(`lobby.send`,n);e.notice&&H(e.notice)}else if(k.id===`knowledge`)r=await U(`knowledge.ask`,n)!==void 0,r&&e.kind===`tab`&&aj(JW(e.rest,!0));else if(k.id===`panel`)r=await U(`planner.send`,n)!==void 0;else if(k.id===`quickfix`)r=await U(`quickfix.submit`,n)!==void 0;else if(k.id===`task`)r=await U(`tasks.message`,{taskId:k.taskId,...n})!==void 0;else if(k.id===`session`)r=await U(`sessions.message`,{...k.session.address,...n})!==void 0;else if(k.id===`newsession`){let e=await U(`sessions.start`,{request:i,...t?{attachments:t}:{}});r=e!==void 0,e?.key&&aj(`#/sessions/${encodeURIComponent(e.key)}`)}else r=await U(`tasks.comment`,{taskId:k.taskId,...n})!==void 0;if(r){a(``);for(let e of M.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{d(!1)}},[oe,ae,k,i,e]),ce=(0,m.useCallback)(async()=>{try{await Te(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]);return(0,R.jsxs)(`div`,{id:`app-dock`,ref:A,style:S&&C?{bottom:`${w}px`}:void 0,className:q(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(1.25rem,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap max-md:px-2`,S&&C?`max-md:pb-2`:`max-md:pb-[max(0.5rem,env(safe-area-inset-bottom))]`,y&&`opacity-0`),inert:y,children:[r?(0,R.jsx)(`div`,{className:`pointer-events-auto mx-auto mb-1.5 w-full max-w-3xl`,children:r}):null,(0,R.jsx)(`div`,{className:`pointer-events-auto mx-auto w-full max-w-3xl`,children:(0,R.jsxs)(`div`,{className:q(`group/composer relative rounded-2xl border border-dock-border bg-dock shadow-dock transition-[border-color,box-shadow] duration-300 ease-snap focus-within:border-ring focus-within:shadow-dock-focus`,x&&`min-[500px]:max-md:grid min-[500px]:max-md:grid-cols-[minmax(0,1fr)_auto] min-[500px]:max-md:min-w-0`,f&&`border-primary shadow-[0_0_0_3px_color-mix(in_oklab,var(--ring)_30%,transparent)]`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),p(!0))},onDragLeave:()=>p(!1),onDrop:e=>{e.preventDefault(),p(!1),e.dataTransfer.files.length>0&&N(e.dataTransfer.files)},children:[(0,R.jsx)(Du,{initial:!1,children:o.length>0?(0,R.jsx)(B.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:420,damping:36},"aria-label":`Attachments`,className:q(`flex flex-wrap items-end gap-2 overflow-hidden px-3 pt-3`,x&&`min-[500px]:max-md:col-span-full min-[500px]:max-md:min-w-0 min-[500px]:max-md:max-w-full`),children:o.map(e=>(0,R.jsx)(j0,{file:e,onRemove:()=>re(e.key)},e.key))},`files`):null}),c?(0,R.jsx)(`div`,{"aria-label":`Markdown preview`,role:`region`,className:q(`max-h-48 overflow-y-auto border-b border-border px-4 py-3`,x&&`min-[500px]:max-md:col-span-full min-[500px]:max-md:min-w-0 min-[500px]:max-md:max-w-full`),children:i.trim()?(0,R.jsx)(WH,{text:i}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing to preview yet.`})}):null,(0,R.jsx)(`div`,{className:q(`flex px-4 pt-3 pb-1`,x&&`min-[500px]:max-md:col-start-1 min-[500px]:max-md:min-w-0 min-[500px]:max-md:max-w-full min-[500px]:max-md:pt-1 min-[500px]:max-md:pb-1`),children:(0,R.jsx)(`textarea`,{ref:ee,id:`composer-text`,"aria-label":k.label,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),Lj();return}let t=e.currentTarget,n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(n)){e.preventDefault();let{selectionStart:r,selectionEnd:i,value:a}=t;ne(n===`k`?S0(a,r,i):x0(a,r,i,n===`b`?`**`:n===`i`?`_`:"`"));return}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&n===`p`){e.preventDefault(),l(e=>!e);return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=w0(t.value,t.selectionStart);n&&(e.preventDefault(),ne(n));return}if(e.key===`Backspace`&&t.value===``&&M.current.length>0){e.preventDefault(),re(M.current.at(-1).key);return}(A0(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),se())},onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),N(t))},placeholder:b&&k.id===`oracle`?`The oracle is working. Enter steers it…`:k.placeholder,rows:1,className:q(`field-sizing-content max-h-[min(45vh,20rem)] min-h-[1.75rem] w-full min-w-0 flex-1 resize-none bg-transparent text-base leading-relaxed caret-primary outline-none placeholder:text-muted-foreground md:text-[0.9375rem] md:leading-relaxed`,x&&`min-[500px]:max-md:max-h-[44px] min-[500px]:max-md:overflow-y-auto`)})}),(0,R.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-x-2 gap-y-2 px-2 pt-1 pb-2`,x&&`min-[500px]:max-md:col-start-2 min-[500px]:max-md:min-w-0 min-[500px]:max-md:flex-nowrap min-[500px]:max-md:gap-y-0 min-[500px]:max-md:pt-1 min-[500px]:max-md:pb-1`),children:[(0,R.jsx)(`input`,{ref:j,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{N(e.target.files??[]),e.target.value=``}}),(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onClick:()=>j.current?.click(),className:k0,children:(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsx)(Tj,{children:`Attach images, PDFs or files`})]}),(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Preview the Markdown`,"aria-pressed":c,"aria-keyshortcuts":`Alt+P`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>l(e=>!e),className:k0,children:(0,R.jsx)(km,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(Tj,{children:[`Preview `,(0,R.jsx)(rA,{chord:`Alt+P`})]})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-4 w-px bg-border`}),(0,R.jsx)(`div`,{className:q(`contents`,S&&!x&&`max-md:block max-md:w-full max-md:order-last`),children:e.kind===`tab`&&e.tab===`knowledge`?(0,R.jsx)(T0,{rest:e.rest}):x&&D.length>1?(0,R.jsxs)(Rq,{value:k.id,onValueChange:e=>g(e),children:[(0,R.jsx)(Bq,{"aria-label":`Send to`,className:`h-7 min-w-0 gap-1.5 px-2 text-xs`,children:(0,R.jsx)(zq,{})}),(0,R.jsx)(Vq,{children:D.map(e=>(0,R.jsx)(Hq,{value:e.id,children:e.pill},e.id))})]}):D.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Send to`,className:`flex max-md:flex-wrap items-center gap-0.5 rounded-lg bg-muted p-0.5 shadow-[inset_0_1px_2px_rgb(0_0_0/0.07)]`,children:D.map(e=>(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"data-compact":!0,"aria-checked":e.id===k.id,onClick:()=>g(e.id),className:q(`h-6 rounded-md border border-transparent px-2.5 text-xs font-medium transition-[background-color,color,box-shadow] duration-150 outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,e.id===k.id?`btn-raised btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:e.pill},e.id))}):(0,R.jsxs)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:[`To the `,k.pill.toLowerCase()]})}),(0,R.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end overflow-hidden px-2 max-md:hidden`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3.5`,children:[e.kind===`tab`&&e.tab===`plan`?(0,R.jsx)(iA,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[34rem]:inline-flex`,children:`save plan`}):null,(0,R.jsx)(iA,{chord:`/`,className:`hidden group-focus-within/composer:!hidden @[28rem]:inline-flex`,children:`write`}),(0,R.jsx)(iA,{chord:`Esc`,className:`hidden group-[:not(:focus-within)]/composer:!hidden @[28rem]:inline-flex`,children:`tabs`}),(0,R.jsx)(iA,{chord:`Shift+Enter`,className:`hidden @[22rem]:inline-flex`,children:`new line`}),(0,R.jsx)(iA,{chord:`Enter`,className:`hidden @[11rem]:inline-flex`,children:`send`}),(0,R.jsxs)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"data-compact":!0,onClick:n,className:`kbd-hint btn-ghost inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border px-1.5 text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(rA,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,R.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})}),(0,R.jsxs)(`div`,{className:`contents max-md:ml-auto max-md:flex max-md:items-center max-md:gap-2`,children:[b&&k.id===`oracle`?(0,R.jsx)(SM,{label:`Stop`,icon:hg,iconOnly:!0,compact:!0,title:`Stop the oracle?`,description:`The current response stops. Work already recorded is kept.`,confirmLabel:`Stop`,variant:`destructive`,onConfirm:()=>void ce()}):null,(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Send`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>void se(),disabled:!oe,className:`btn-tint relative inline-flex size-8 items-center justify-center rounded-lg border [--tint:var(--primary)] before:absolute before:-inset-1 before:content-[''] text-primary-foreground transition-[background-color,color,box-shadow,translate,filter] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none disabled:text-muted-foreground`,children:u?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5 text-primary-foreground`}):(0,R.jsx)(Np,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.25})})}),(0,R.jsxs)(Tj,{children:[`Send `,(0,R.jsx)(rA,{chord:`Enter`})]})]})]})]}),f?(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center justify-center rounded-xl bg-card/90 text-sm font-medium text-primary backdrop-blur-[2px]`,children:`Drop to attach`}):null]})})]})}function N0(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await Te(`projects.open`,{path:r});be([t]),he(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function P0({path:e,busy:t,browse:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,R.jsxs)(`form`,{className:`flex min-w-0 gap-2`,onSubmit:e=>{e.preventDefault(),n(r)},children:[(0,R.jsx)(Uq,{className:`min-w-0 flex-1 max-md:h-11`,"aria-label":`Folder path`,value:r,disabled:t,onChange:e=>i(e.target.value)}),(0,R.jsx)(Y,{type:`submit`,disabled:t||!r.trim(),className:`max-md:min-h-11`,children:`Go`})]})}function F0({data:e,busy:t,browse:n}){return(0,R.jsxs)(`div`,{className:`min-h-24 max-h-64 overflow-y-auto overscroll-contain rounded-lg border border-border max-md:max-h-[min(40vh,16rem)]`,"aria-label":`Folders`,role:`group`,children:[e?.parent?(0,R.jsxs)(Y,{variant:`ghost`,className:`h-auto min-h-11 w-full justify-start py-3 text-left max-md:min-h-12`,disabled:t,onClick:()=>n(e.parent),children:[(0,R.jsx)(Np,{}),` Parent folder`]}):null,e?.folders.map(e=>(0,R.jsxs)(Y,{variant:`ghost`,className:`h-auto min-h-11 w-full justify-start py-3 text-left max-md:min-h-12`,disabled:t,onClick:()=>n(e.path),children:[(0,R.jsx)(zm,{className:`shrink-0`}),(0,R.jsx)(`span`,{className:`whitespace-normal break-words`,children:e.name})]},e.path)),e&&!e.folders.length?(0,R.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No subfolders. You can open this folder.`}):null,e?.truncated?(0,R.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`Listing limited to 2,000 entries. Enter a path to browse further.`}):null]})}function I0({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=xj(`projects.browse`,r===void 0?{}:{path:r},[]),o=N0(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,R.jsxs)(`div`,{className:`flex min-h-0 max-h-full flex-col gap-4 overflow-y-auto p-5 max-md:max-h-[calc(100svh-2rem)] max-md:p-4`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Open project folder`}),(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:`Browse folders on the machine running bot-lobby. Opening starts a separate session; your current project keeps running. Project-local extensions are not enabled automatically.`}),(0,R.jsx)(P0,{path:a.data?.path??r??``,busy:o.opening,browse:i}),(0,R.jsx)(F0,{data:a.data,busy:a.loading||o.opening,browse:i}),a.loading?(0,R.jsx)(`p`,{role:`status`,children:`Loading folders…`}):null,a.error||o.error?(0,R.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:a.error??o.error}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[a.error?(0,R.jsx)(Y,{variant:`outline`,onClick:a.reload,disabled:a.loading,className:`max-md:min-h-11`,children:`Retry`}):null,(0,R.jsx)(Y,{variant:`outline`,onClick:t,disabled:o.opening,className:`max-md:min-h-11`,children:`Cancel`}),(0,R.jsx)(Y,{disabled:!a.data||a.loading||!!a.error||o.opening,onClick:()=>void o.open(a.data.path),className:`max-md:min-h-11`,children:o.opening?`Opening project…`:`Open this folder`})]})]})}function L0({open:e,onClose:t,tab:n}){let r=XA(e,YA.help),[i,a]=(0,m.useState)(!1);return(0,R.jsx)(HA,{open:r,label:`Open project folder`,className:`max-md:max-h-[calc(100svh-2rem)] max-md:max-w-[calc(100vw-2rem)]`,onOpenChange:e=>{!e&&!i&&t()},dismissOnBackdrop:!i,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[role="combobox"][aria-label="Project"]`)?.focus()},children:e?(0,R.jsx)(I0,{tab:n,close:t,busyChanged:a}):null})}function R0(){try{return{id:P()}}catch(e){return{error:e.message}}}function z0(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function B0(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await Te(`projects.list`,{});be(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function V0({data:e,error:t}){let n=R0();return n.error??t??z0(e,n.id)}function H0({projects:e}){let t=V0(e);return t?(0,R.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,R.jsx)(Tg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,R.jsx)(`span`,{children:t})]}):null}function U0(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option']`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}function W0({projects:e,tab:t,name:n,branch:r}){let{data:i,busy:a,slow:o,refresh:s}=e,[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=R0(),p=V0(e),h=f.error?`invalid`:f.id??i?.currentId??``;Uj(`p`,()=>l(!0)),Uj(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&he(e,t)}return(0,R.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsxs)(nY,{open:c,onOpenChange:l,children:[(0,R.jsxs)(rY,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c,"aria-keyshortcuts":`P ArrowDown`,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),l(!0))},className:`btn-ghost group flex h-8 min-w-0 items-center gap-2 rounded-lg border border-transparent px-2.5 text-sm font-medium outline-none transition-[box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40 disabled:pointer-events-none max-md:h-11`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2.5 shrink-0 rounded-full`,p?`bg-destructive`:`bg-primary`)}),(0,R.jsx)(`span`,{className:`truncate`,children:n}),(0,R.jsx)(Zp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(iY,{align:`start`,sideOffset:6,"aria-label":`Projects`,onKeyDown:U0,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`p-0 flex max-h-[calc(100svh-2rem)] w-[min(26rem,calc(100vw-1.5rem))] origin-(--radix-popover-content-transform-origin) flex-col overflow-hidden rounded-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 max-md:w-[calc(100vw-2rem)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`inline-flex h-7 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 disabled:opacity-60 max-md:h-11`,children:[a?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,R.jsx)(rA,{chord:`R`,className:`kbd-hint`})]})]}),(0,R.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`flex max-h-72 flex-col overflow-y-auto overscroll-contain p-1 max-md:max-h-[calc(100svh-12rem)]`,children:i?.projects.map(e=>{let t=e.id===h;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:q(`flex min-h-10 w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-3 focus-visible:ring-ring/30 max-md:min-h-11`,t&&`bg-accent`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`block whitespace-normal break-all text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,R.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-t border-border px-3 py-3 text-sm font-medium outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/40`,onClick:()=>{l(!1),d(!0)},children:[(0,R.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,R.jsx)(L0,{open:u,onClose:()=>d(!1),tab:t}),r?(0,R.jsxs)(`span`,{className:`hidden min-w-0 items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground sm:inline-flex`,children:[(0,R.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:r})]}):null,o||p?(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground outline-none transition-[box-shadow,color,translate] hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px disabled:opacity-60 max-md:size-11`,children:a?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-4`}):(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsx)(Tj,{side:`bottom`,children:`Refresh projects`})]}):null]})}function G0({state:e}){return e===`live`?(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,R.jsx)(Tj,{children:`Connected`})]}):e===`connecting`?(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),`reconnecting…`]}):(0,R.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}var K0=`toolbar-button inline-flex size-8 shrink-0 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,translate] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`;function q0({label:e,hint:t,href:n,active:r,children:i}){return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`a`,{href:n,"aria-label":e,"aria-current":r?`page`:void 0,"aria-keyshortcuts":t,"aria-describedby":`focused-action-help`,className:K0,children:i})}),(0,R.jsxs)(Tj,{side:`bottom`,children:[e,` `,(0,R.jsx)(`span`,{className:`max-md:hidden`,children:(0,R.jsx)(rA,{chord:t})})]})]})}function J0({hint:e,onHelp:t}){return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:K0,children:(0,R.jsx)(Ym,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsxs)(Tj,{side:`bottom`,children:[`Keyboard shortcuts `,(0,R.jsx)(rA,{chord:e})]})]})}function Y0(){let e=xJ(),t=cA(`(max-width: 767.98px)`),n=t?`App sounds`:e?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":e,"aria-describedby":t?`app-sounds-help focused-action-help`:`focused-action-help`,className:K0,onClick:()=>yJ(!e),children:e?(0,R.jsx)(Fg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,R.jsx)(Ng,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsx)(Tj,{side:`bottom`,children:n})]}),t?(0,R.jsx)(`span`,{id:`app-sounds-help`,className:`sr-only`,children:`App sounds controls prompt tones and navigation ticks.`}):null]})}function X0(){let{theme:e,setTheme:t}=vY(),n=e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>t(n?`light`:`dark`),className:K0,children:n?(0,R.jsx)(_g,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,R.jsx)(Th,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsxs)(Tj,{side:`bottom`,children:[n?`Light mode`:`Dark mode`,` `,(0,R.jsx)(`span`,{className:`max-md:hidden`,children:(0,R.jsx)(rA,{chord:`D`})})]})]})}function Z0({busy:e,task:t,sessionName:n}){return(0,R.jsxs)(`div`,{className:`mr-1 flex min-w-0 items-center gap-2 text-[0.8125rem]`,children:[e?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):null,t?(0,R.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate md:inline`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,R.jsxs)(`span`,{className:`hidden text-muted-foreground min-[1500px]:inline`,children:[` · `,t.state.replace(/_/g,` `)]})]}):(0,R.jsx)(`span`,{className:`hidden max-w-[10rem] truncate text-muted-foreground min-[1500px]:inline`,children:n??`no task in this session`})]})}function Q0(e){if(!e)return 0;let t=[...e.children].filter(e=>e instanceof HTMLElement&&e.offsetParent!==null&&getComputedStyle(e).position!==`absolute`);if(!t.length)return 0;let n=Math.min(...t.map(e=>e.getBoundingClientRect().left)),r=Math.max(...t.map(e=>e.getBoundingClientRect().right)),i=0;for(let t of e.querySelectorAll(`*`))t.clientWidth<=1||t.offsetParent===null||t.scrollWidth<=t.clientWidth+1||getComputedStyle(t).textOverflow===`ellipsis`&&(i+=t.scrollWidth-t.clientWidth);return r-n+i}var $0=24;function e2(){let e=(0,m.useRef)(null),[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(()=>{});return r.current=()=>{let t=e.current;if(!t)return;let r=t.querySelector(`[role="tablist"]`),i=getComputedStyle(t),a=parseFloat(i.columnGap)||0,o=t.clientWidth-(parseFloat(i.paddingLeft)||0)-(parseFloat(i.paddingRight)||0),s=Q0(t.querySelector(`.where`))+(r?.offsetWidth??0)+Q0(t.querySelector(`.tools`))+a*2;n(s+$0<=o)},(0,m.useLayoutEffect)(()=>r.current()),(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r.current());n.observe(t);for(let e of t.querySelectorAll(`[role="tablist"], .where, .tools`))n.observe(e);return()=>n.disconnect()},[]),{header:e,one:t}}function t2({status:e,task:t,connection:n,route:r,tabs:i,extra:a,keys:o,onHelp:s}){let c=e?.workspace.name??`bot-lobby`,l=e?.branch??e?.workspace.branch,u=e?.busy??!1,d=B0(),{header:f,one:p}=e2(),m=cA(`(max-width: 767.98px)`);return(0,R.jsxs)(`header`,{ref:f,className:`app-header shrink-0`,"data-one-row":p||void 0,children:[(0,R.jsx)(`div`,{className:`where flex min-w-0 items-center`,children:(0,R.jsx)(W0,{projects:d,tab:r.kind===`tab`?r.tab:r.kind,name:c,branch:l})}),m?(0,R.jsxs)(`div`,{className:`phone-status flex min-w-0 items-center justify-end gap-2`,children:[(0,R.jsx)(Z0,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,R.jsx)(G0,{state:n})]}):null,(0,R.jsx)(`div`,{className:`tabs min-w-0`,children:i}),(0,R.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[a,m?null:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(Z0,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,R.jsx)(G0,{state:n})]}),(0,R.jsx)(q0,{label:`Sessions`,hint:o.sessions??`Alt+O`,href:`#/sessions`,active:r.kind===`sessions`,children:(0,R.jsx)(Zm,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,R.jsx)(q0,{label:`Settings`,hint:o.settings??`Alt+S`,href:`#/settings`,active:r.kind===`settings`,children:(0,R.jsx)(sg,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),m?null:(0,R.jsx)(J0,{hint:o.help??`Alt+H`,onHelp:s}),(0,R.jsx)(X0,{}),(0,R.jsx)(Y0,{}),(0,R.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,R.jsx)(H0,{projects:d})]})}function n2(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function r2(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await De()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(n2(e))}return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6 max-md:items-start max-md:p-4`,children:(0,R.jsxs)(`form`,{onSubmit:s,className:`glass flex min-h-0 w-full max-w-md flex-col gap-4 rounded-xl p-6 max-md:max-h-[calc(100svh-2rem)] max-md:max-w-[28rem] max-md:overflow-y-auto max-md:p-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(qm,{className:`size-5`,"aria-hidden":`true`}),(0,R.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,R.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,R.jsx)(`code`,{className:`rounded-lg bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`/bot-lobby web`}),`to see it again). Paste it here.`]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,R.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:`http://127.0.0.1:7347/#token=…`,className:`h-8 min-w-0 rounded-lg border border-input bg-background px-3.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 max-md:h-11`})]}),n?(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),className:`max-md:min-h-11`,children:`Retry`}),(0,R.jsx)(Y,{type:`submit`,disabled:i||!e.trim(),className:`max-md:min-h-11`,children:`Sign in`})]})]})})}var i2=.6;function a2(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:i2,...n}}}var o2=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function s2(e,t=0,n=1){return a2(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:i2,times:o2(t,n),ease:`easeInOut`},strokeOpacity:{duration:i2,times:o2(t,t+.02)}})}function c2(e,t){return a2(e,{scale:[0,0,1.3,1]},{times:o2(t,t+.18),ease:`easeOut`})}function l2(e,t,n=1.3){return a2(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var u2=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function d2({play:e}){return(0,R.jsxs)(B.g,{style:u2(.1,.9),...a2(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,R.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,R.jsx)(B.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...a2(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function f2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.path,{d:`M13 5h8`,...s2(e,.15,.45)}),(0,R.jsx)(B.path,{d:`M13 12h8`,...s2(e,.3,.6)}),(0,R.jsx)(B.path,{d:`M13 19h8`,...s2(e,.45,.75)}),(0,R.jsx)(B.path,{d:`m3 17 2 2 4-4`,...s2(e,.35,.7)}),(0,R.jsx)(B.path,{d:`m3 7 2 2 4-4`,...s2(e,0,.35)})]})}function p2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:6,cy:19,r:3,style:u2(),...l2(e,0)}),(0,R.jsx)(B.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...s2(e,.1,.7)}),(0,R.jsx)(B.circle,{cx:18,cy:5,r:3,style:u2(),...c2(e,.62)})]})}function m2({play:e}){return(0,R.jsx)(B.g,{style:u2(),...a2(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,R.jsx)(B.path,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,fill:`currentColor`,...a2(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function h2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:12,cy:12,r:10,style:u2(),...a2(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,R.jsx)(B.circle,{cx:12,cy:12,r:10,style:u2(),...a2(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,R.jsx)(B.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:u2(),...a2(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function g2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}),[`M8 17v-3`,`M13 17V5`,`M18 17V9`].map((t,n)=>(0,R.jsx)(B.path,{d:t,style:u2(.5,1),...a2(e,{scaleY:[0,0,1.18,1]},{times:o2(.08+n*.14,.4+n*.14),ease:`easeOut`})},t))]})}function _2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:6,cy:6,r:3,style:u2(),...l2(e,0)}),(0,R.jsx)(B.line,{x1:6,x2:6,y1:9,y2:21,...s2(e,.05,.45)}),(0,R.jsx)(B.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...s2(e,.2,.62)}),(0,R.jsx)(B.circle,{cx:18,cy:18,r:3,style:u2(),...c2(e,.58)})]})}function v2({play:e}){return(0,R.jsxs)(B.g,{style:u2(),...a2(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,R.jsx)(B.path,{d:`M12 5v16`,style:u2(),...a2(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,R.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]})}function y2({play:e}){return(0,R.jsxs)(B.g,{style:u2(.6,.6),...a2(e,{x:[0,1.5,-1.5,1,0],y:[0,-1,.5,-.5,0],rotate:[0,-8,6,-3,0]},{ease:`easeInOut`}),children:[(0,R.jsx)(`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`}),(0,R.jsx)(`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`}),(0,R.jsx)(B.path,{d:`m2.3 2.3 7.286 7.286`,...s2(e,.1,.6)}),(0,R.jsx)(B.circle,{cx:11,cy:11,r:2,style:u2(),...l2(e,.5,1.5)})]})}var b2={lobby:d2,tasks:f2,plan:p2,quickfix:m2,issues:h2,metrics:g2,git:_2,knowledge:v2,excalidraw:y2};function x2({id:e,play:t,className:n}){let r=b2[e];return r?(0,R.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:q(`overflow-visible`,n),children:(0,R.jsx)(r,{play:t})},t):null}function S2(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0||n<2)return e;let r=Math.floor(n/2),i=(r-.75)*t,a=(r+1.75)*t;return e<i?e+Math.ceil((i-e)/t)*t:e>a?e-Math.ceil((e-a)/t)*t:e}function C2(e){return/(\d)$/.exec(e)?.[1]}function w2(e){return e.filter(e=>e.id!==`metrics`)}function T2(e,t,n=5){return S2(e,t,n)}function E2(e,t,n){let r=t.find(t=>t.id===e);if(r)return r.label;let i=n.replace(/^#\/?/,``).split(`/`)[0];return i===`settings`?`Settings`:i===`sessions`?`Sessions`:i===`metrics`?`Metrics`:i?i.charAt(0).toUpperCase()+i.slice(1):`Lobby`}var D2=`phone-tab-card inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-xl border px-2.5 text-sm font-medium whitespace-nowrap outline-none focus-visible:ring-3 focus-visible:ring-ring/40`;function O2(e){let t=C2(e.key);return t?`${t}. ${e.label}`:e.label}function k2(e,t){let n=C2(e.key);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(x2,{id:e.id,play:+!!t,className:`size-4 shrink-0`}),n?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-[0.7rem] font-semibold tabular-nums text-muted-foreground`,children:n}):null,t?(0,R.jsx)(`span`,{className:`max-w-[8.5rem] truncate`,children:e.label}):null]})}function A2(e){return e?{duration:0}:{type:`spring`,stiffness:520,damping:30,mass:.5}}function j2({tab:e,selected:t,reduced:n}){return(0,R.jsx)(B.span,{className:`inline-flex items-center gap-1.5`,animate:{scale:t?1.04:1},transition:A2(n),children:k2(e,t)})}function M2({tab:e,selected:t,canonical:n,reduced:r,onClick:i,roving:a}){let o=O2(e);return n?(0,R.jsx)(`button`,{type:`button`,role:`tab`,id:`tab-${e.id}`,"data-phone-tab-id":e.id,"aria-controls":`main`,"aria-label":o,"aria-keyshortcuts":e.key,"aria-selected":t,tabIndex:t||a?0:-1,onClick:i,className:D2,children:(0,R.jsx)(j2,{tab:e,selected:t,reduced:r})}):(0,R.jsx)(`span`,{"data-phone-tab-id":e.id,"data-active":t?`true`:`false`,className:D2,"aria-hidden":`true`,children:(0,R.jsx)(j2,{tab:e,selected:t,reduced:r})})}function N2({tabs:e,activeId:t,canonical:n,reduced:r,onClick:i,canonicalRef:a}){let o=t??e[0]?.id;return(0,R.jsx)(`div`,{ref:n?a:void 0,"data-phone-period":n?`canonical`:`copy`,"aria-hidden":!n||void 0,role:n?`tablist`:void 0,"aria-label":n?`Lobby tabs`:void 0,className:`phone-tabs-period`,children:e.map(e=>(0,R.jsx)(M2,{tab:e,selected:e.id===t,canonical:n,reduced:r,roving:e.id===o,onClick:t=>i(e.id,t)},e.id))})}function P2(e){return e<=0?0:e===1?1:5}function F2({tabs:e,activeId:t,reduced:n,onClick:r,canonicalRef:i}){let a=P2(e.length),o=Math.floor(a/2);return a?(0,R.jsx)(R.Fragment,{children:Array.from({length:a},(a,s)=>(0,R.jsx)(N2,{tabs:e,activeId:t,canonical:s===o,reduced:n,onClick:r,canonicalRef:s===o?i:void 0},s))}):null}function I2(e){e.current!==void 0&&window.clearTimeout(e.current),e.current=void 0}function L2(e){return e?.closest(`[data-phone-tab-id]`)?.dataset.phoneTabId}function R2(e){return L2(e.target instanceof Element?e.target:null)}function z2(e){return L2(document.elementFromPoint(e.clientX,e.clientY))??L2(e.target instanceof Element?e.target:null)}function B2(e,t){let n=e.dataset.phoneTabId;if(!n)return;let r=e.getBoundingClientRect();if(Number.isFinite(r.width))return{id:n,element:e,distance:Math.abs(r.left+r.width/2-t)}}function V2(e,t){return[...e.querySelectorAll(`[data-phone-tab-id]`)].map(e=>B2(e,t)).filter(e=>e!==void 0)}function H2(e){return e.reduce((e,t)=>!e||t.distance<e.distance?t:e,void 0)}function U2(e,t){return H2(V2(t,e.getBoundingClientRect().left+e.clientWidth/2))}function W2(e,t){if(e&&t)return[...e.querySelectorAll(`[data-phone-tab-id]`)].find(e=>e.dataset.phoneTabId===t)}function G2(e){let t=Number.parseFloat(getComputedStyle(e.parentElement??e).columnGap)||6;return e.offsetWidth+t}function K2(e,t,n){let r=Math.max(0,n.findIndex(e=>e.id===t));if(e===`Home`)return n[0]?.id;if(e===`End`)return n.at(-1)?.id;if(e===`ArrowRight`)return n[(r+1)%n.length]?.id;if(e===`ArrowLeft`)return n[(r-1+n.length)%n.length]?.id}function q2(e,t){return Math.abs(e-t)<=2}function J2(){let e=(0,m.useRef)(null),t=(0,m.useRef)(null),n=(0,m.useRef)(null),r=(0,m.useRef)(void 0),i=(0,m.useRef)(void 0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(void 0),s=(0,m.useRef)(void 0),c=(0,m.useRef)(void 0),l=(0,m.useRef)(0),u=(0,m.useRef)(0),d=(0,m.useRef)(void 0);return(0,m.useMemo)(()=>({scroller:e,track:t,canonical:n,gesture:r,candidate:i,crossed:a,settleTimer:o,commitTimer:s,clickGuard:c,generation:l,scrollGeneration:u,programmatic:d}),[])}function Y2(e){return{clearPending:(0,m.useCallback)(()=>{I2(e.settleTimer),I2(e.commitTimer),e.candidate.current=void 0,e.generation.current+=1},[e])}}function X2(e){let t=(0,m.useCallback)(t=>{let n=e.scroller.current;if(!n)return;let r=e.scrollGeneration.current+1;e.scrollGeneration.current=r;let i={value:Math.max(0,t),generation:r};e.programmatic.current=i,n.scrollLeft=i.value,i.value=n.scrollLeft},[e]),n=(0,m.useCallback)(n=>{let r=e.scroller.current;if(!r||!n||r.clientWidth<=0)return;let i=r.getBoundingClientRect(),a=n.getBoundingClientRect(),o=r.scrollLeft+a.left+a.width/2-(i.left+r.clientWidth/2);t(o)},[e,t]);return{centre:n,centreCanonical:(0,m.useCallback)(t=>{let r=W2(e.canonical.current,t);r&&(e.crossed.current=r),n(r)},[n,e]),rebase:(0,m.useCallback)((n,r)=>{let i=T2(n.scrollLeft,G2(r));if(q2(i,n.scrollLeft))return!1;let a=i-n.scrollLeft;return e.gesture.current&&(e.gesture.current.originScrollLeft+=a),t(i),!0},[e,t])}}function Z2(e){let t=(0,m.useCallback)(()=>{e.clickGuard.current=void 0},[e]);return{clearGuard:t,guardClick:(0,m.useCallback)(n=>{t(),e.clickGuard.current={kind:n}},[t,e]),consumeGuard:(0,m.useCallback)(n=>!n||!e.clickGuard.current?!1:(t(),!0),[t,e])}}function Q2(e){return(0,m.useCallback)(()=>{let t=e.scroller.current,n=e.track.current;if(!t||!n)return;let r=U2(t,n);return r&&r.element!==e.crossed.current&&(e.crossed.current=r.element,wJ()),e.candidate.current=r,r},[e])}function $2(e,t,n,r,i){let a=(0,m.useCallback)((r,i)=>{r&&r.id!==e.activeId&&(I2(t.commitTimer),t.commitTimer.current=window.setTimeout(()=>{i!==t.generation.current||t.candidate.current?.element!==r.element||e.blocked||(n(),e.onSelect(r.id))},500))},[n,e,t]);return(0,m.useCallback)(()=>{I2(t.settleTimer),I2(t.commitTimer);let e=++t.generation.current;t.settleTimer.current=window.setTimeout(()=>{if(e!==t.generation.current||t.gesture.current)return;let n=r();n&&(i(n.element),a(n,e))},120)},[a,i,r,t])}function e4(e,t,n){return(0,m.useCallback)(r=>e.tabs.some(e=>e.id===r)?(t(),e.onSelect(r),n(r),!0):!1,[n,t,e])}function t4(e,t,n,r){return(0,m.useCallback)(()=>{let i=e.scroller.current,a=e.canonical.current;if(!i||!a)return;let o=e.programmatic.current;if(o&&o.generation===e.scrollGeneration.current&&q2(i.scrollLeft,o.value)){e.programmatic.current=void 0;return}if(e.programmatic.current=void 0,I2(e.commitTimer),I2(e.settleTimer),e.candidate.current=void 0,e.generation.current+=1,t(i,a)){e.gesture.current||r();return}n(),e.gesture.current||r()},[n,t,e,r])}function n4(e,t,n,r){let i=(0,m.useRef)({clearPending:t,settle:n});i.current={clearPending:t,settle:n},(0,m.useEffect)(()=>{let t=e.scroller.current;if(!r||!t)return;let n=n=>{let r=n.deltaX||(n.shiftKey?n.deltaY:0);r&&(n.preventDefault(),e.programmatic.current=void 0,i.current.clearPending(),t.scrollLeft+=r,i.current.settle())};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[r,e])}function r4(e,t,n){return(0,m.useCallback)(r=>{t(),n(),e.programmatic.current=void 0,e.gesture.current={id:r.pointerId,x:r.clientX,y:r.clientY,moved:!1,originScrollLeft:r.currentTarget.scrollLeft,downTabId:R2(r)},r.currentTarget.setPointerCapture?.(r.pointerId)},[n,t,e])}function i4(e,t){return(0,m.useCallback)(n=>{let r=e.gesture.current;r&&r.id===n.pointerId&&(Math.hypot(n.clientX-r.x,n.clientY-r.y)<8||(r.moved=!0,t(),(n.pointerType===`mouse`||n.pointerType===`pen`)&&(n.currentTarget.scrollLeft=r.originScrollLeft+r.x-n.clientX,n.preventDefault())))},[t,e])}function a4(e,t,n,r){return(0,m.useCallback)(i=>{let a=e.gesture.current;if(!a||a.id!==i.pointerId)return;e.gesture.current=void 0;let o=z2(i),s=a.downTabId;if(s&&!a.moved&&(!o||o===s)){n.guardClick(`committed`),t(s);return}(a.moved||s&&o&&o!==s)&&n.guardClick(`drag`),a.moved&&r()},[t,n,e,r])}function o4(e,t,n){return(0,m.useCallback)(()=>{let r=e.gesture.current?.moved;e.gesture.current=void 0,r&&t.guardClick(`drag`),r&&n()},[t,e,n])}function s4(e,t,n,r,i){return{onPointerDown:r4(e,i,n.clearGuard),onPointerMove:i4(e,i),onPointerUp:a4(e,t,n,r),onPointerCancel:o4(e,n,r)}}function c4(e,t){return(0,m.useCallback)((n,r)=>{t.consumeGuard(r.detail!==0)||e(n)},[e,t])}function l4(e,t){return(0,m.useCallback)(n=>{if(t.consumeGuard(n.detail!==0))return;let r=n.target instanceof Element?n.target.closest(`[data-phone-tab-id]`):null;if(!r||r.closest(`button`))return;let i=r.dataset.phoneTabId;i&&e(i)},[e,t])}function u4(e,t,n){return(0,m.useCallback)(r=>{if(r.key===`ArrowDown`&&!r.altKey){Ij()&&r.preventDefault();return}if(!e.tabs.length)return;let i=r.target.closest(`[role='tab']`)?.dataset.phoneTabId??e.activeId??e.tabs[0].id,a=K2(r.key,i,e.tabs);a?(r.preventDefault(),Rj.active=!0,Rj.to=a,n(a),W2(t.canonical.current,a)?.focus({preventScroll:!0})):(r.key===`Enter`||r.key===` `)&&i&&(r.preventDefault(),n(i))},[n,e,t])}function d4(e){let[t,n]=(0,m.useState)(0),[r,i]=(0,m.useState)(!1);return{sidePad:t,peek:r,setPeek:i,updatePad:(0,m.useCallback)(()=>{let t=e.scroller.current;if(!t||t.clientWidth<=0)return;let r=Math.max(22,t.clientWidth/2);n(e=>Math.abs(e-r)<.5?e:r)},[e])}}function f4(e,t){return e.find(e=>e.id===t)?.id??e[0]?.id}function p4(e,t,n,r){let{activeId:i,keyboardOpen:a,tabs:o}=e;(0,m.useLayoutEffect)(()=>{n(),t(f4(o,i))},[i,t,a,o,n,r])}function m4(e,t,n,r,i){let{activeId:a,tabs:o}=e;(0,m.useEffect)(()=>{let e=t.scroller.current;if(!e||typeof ResizeObserver>`u`)return;let s=new ResizeObserver(()=>{e.clientWidth<=0||(n(),i(),r(f4(o,a)))});return s.observe(e),t.track.current&&s.observe(t.track.current),()=>s.disconnect()},[a,r,n,t,o,i])}function h4(e){(0,m.useEffect)(()=>{let t=()=>e();return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},[e])}function g4(e,t,n,r){(0,m.useEffect)(()=>{n(),t.crossed.current=void 0},[n,e.activeId,e.blocked,e.keyboardOpen,t,r])}function _4(e,t,n){(0,m.useEffect)(()=>()=>{t(),n(),e.programmatic.current=void 0},[n,t,e])}function v4(e,t,n){(0,m.useEffect)(()=>{e.keyboardOpen||n(!1),t()},[t,e.blocked,e.keyboardOpen,n])}function y4(e){let t=J2(),{clearPending:n}=Y2(t),r=X2(t),i=Z2(t),a=d4(t),o=Q2(t),s=$2(e,t,n,o,r.centre),c=e4(e,n,r.centreCanonical),l=t4(t,r.rebase,o,s),u=s4(t,c,i,s,n);n4(t,n,s,e.tabs.length>0);let d=u4(e,t,c),f=l4(c,i),p=c4(c,i),m=e.tabs.map(e=>e.id).join(`\0`);return p4(e,r.centreCanonical,a.updatePad,!e.keyboardOpen||a.peek),m4(e,t,n,r.centreCanonical,a.updatePad),g4(e,t,n,m),h4(n),_4(t,n,i.clearGuard),v4(e,n,a.setPeek),{scroller:t.scroller,track:t.track,canonical:t.canonical,sidePad:a.sidePad,periods:P2(e.tabs.length),peek:a.peek,setPeek:a.setPeek,onScroll:l,...u,onSurfaceClick:f,onCardClick:p,onKeyDown:d}}function b4(e,t){return E2(e,t,window.location.hash)}function x4({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useMemo)(()=>w2(e),[e]),i=QA(),{keyboardOpen:a}=BA(),o=!!xf(),s=b4(t,e),c=y4({tabs:r,activeId:t,blocked:i,keyboardOpen:a,reduced:o,onSelect:n});if(!r.length)return null;let l=a&&!c.peek;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{"aria-hidden":l?`true`:void 0,inert:l,hidden:l,children:(0,R.jsx)(C4,{tabs:r,activeId:t,label:s,reduced:o,carousel:c,keyboardOpen:a})}),l?(0,R.jsx)(S4,{label:s,onOpen:()=>c.setPeek(!0)}):null]})}function S4({label:e,onOpen:t}){return(0,R.jsx)(`div`,{className:`phone-tabs phone-tabs-handle`,children:(0,R.jsxs)(`button`,{type:`button`,"data-phone-tabs-handle":!0,"aria-expanded":`false`,"aria-label":`Open tabs, current page ${e}`,onPointerDown:e=>e.preventDefault(),onClick:t,className:`phone-tabs-current inline-flex min-h-11 items-center gap-2 rounded-xl border px-4 text-sm font-medium focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})]})})}function C4({tabs:e,activeId:t,label:n,reduced:r,carousel:i,keyboardOpen:a}){return(0,R.jsxs)(`div`,{className:`phone-tabs`,"data-phone-tabs":!0,"data-periods":i.periods,children:[t&&!e.some(e=>e.id===t)?(0,R.jsx)(`span`,{"data-phone-page-handle":!0,className:`phone-tabs-page-handle`,children:n}):null,(0,R.jsx)(`div`,{ref:i.scroller,className:`phone-tabs-scroller`,onScroll:i.onScroll,onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp,onPointerCancel:i.onPointerCancel,onClick:i.onSurfaceClick,children:(0,R.jsx)(`div`,{ref:i.track,className:`phone-tabs-track`,style:{"--phone-period-pad":`${i.sidePad}px`},onKeyDown:i.onKeyDown,children:(0,R.jsx)(F2,{tabs:e,activeId:t,reduced:r,onClick:i.onCardClick,canonicalRef:i.canonical})})}),a&&i.peek?(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close tabs`,onPointerDown:e=>e.preventDefault(),onClick:()=>i.setPeek(!1),className:`phone-tabs-close`,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})}):null]})}function w4(e){return/(\d)$/.exec(e)?.[1]}var T4=160;function E4(e){let t=xf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+i2*1e3,r(e=>e+1))},[t]),o=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let t=e&&!o.current;if(o.current=e,!t)return;let n=window.setTimeout(a,T4);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var D4=(0,m.forwardRef)(function({tab:e,active:t},n){let r=w4(e.key),{play:i,onPointerEnter:a}=E4(t);return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsxs)(`a`,{ref:n,role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":t,"aria-keyshortcuts":e.key,tabIndex:t?0:-1,onPointerEnter:a,className:q(`relative z-10 inline-flex h-7.5 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tab-outline)] px-2.5 text-[0.8125rem] leading-none font-medium whitespace-nowrap outline-none`,`transition-colors duration-200 ease-snap focus-visible:ring-3 focus-visible:ring-ring/40`,t?`text-foreground`:`bg-[var(--tab-idle)] text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(x2,{id:e.id,play:i,className:q(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,R.jsx)(`span`,{children:e.label})]})}),(0,R.jsxs)(Tj,{children:[e.label,` `,(0,R.jsx)(rA,{chord:e.key})]})]})}),O4=1.5;function k4(e,t,n=t?.left??0,r=t?.right??0,i=1){if(e){if(!t||r-n<.5){e.style.opacity=`0`;return}e.style.opacity=String(Math.min(1,(r-n)/14)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${r-n}px`,e.style.transform=`translateX(${n}px)`,e.style.scale=i===1?``:`1 ${i}`}}function A4(e,t){let n=e.right-e.left,{height:r}=e,i=O4/2,a=Math.max(0,Math.min(e.radius-i,r/2-i,n/2-i)),o=r/2,s=e=>+(t===`left`?e:n-e).toFixed(2),c=+(t===`left`),l=1-c,u=i,d=n-i,f=r-i;return[`M${s(u)} ${o}L${s(u)} ${i+a}A${a} ${a} 0 0 ${c} ${s(u+a)} ${i}L${s(d-a)} ${i}A${a} ${a} 0 0 ${c} ${s(d)} ${i+a}L${s(d)} ${o}`,`M${s(u)} ${o}L${s(u)} ${f-a}A${a} ${a} 0 0 ${l} ${s(u+a)} ${f}L${s(d-a)} ${f}A${a} ${a} 0 0 ${l} ${s(d)} ${f-a}L${s(d)} ${o}`]}function j4(e,t,n,r){if(!e)return;if(!t||r<=.002){e.style.opacity=`0`;return}let i=t.right-t.left,a=`${i}x${t.height}r${t.radius}${n}`;e.dataset.shape!==a&&(e.dataset.shape=a,e.dataset.port=n,e.setAttribute(`viewBox`,`0 0 ${i} ${t.height}`),A4(t,n).forEach((t,n)=>e.children[n]?.setAttribute(`d`,t))),e.style.opacity=String(Math.min(1,r*12)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${i}px`,e.style.transform=`translateX(${t.left}px)`;let o=`${Math.min(1,r)} 2`;for(let t of e.children)t.style.strokeDasharray=o}var M4={type:`spring`,visualDuration:.12,bounce:0},N4={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},P4={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},F4={type:`spring`,visualDuration:.22,bounce:.25},I4={type:`spring`,visualDuration:.2,bounce:0},L4={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},R4=(()=>{let e=Sr({keyframes:[0,1],visualDuration:F4.visualDuration,bounce:F4.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),z4={type:`spring`,visualDuration:.28,bounce:.6};function B4(e,t){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)({}),c=(0,m.useRef)([]),l=(0,m.useRef)(void 0),u=(0,m.useRef)([]),d=(0,m.useRef)(1),f=(0,m.useRef)(1),p=(0,m.useCallback)(e=>{let t=e?s.current[e]:void 0;if(!t)return;let n=parseFloat(getComputedStyle(t).borderTopLeftRadius)||0;return{left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,top:t.offsetTop,height:t.offsetHeight,radius:n}},[]),h=(0,m.useCallback)(()=>{for(let e of u.current)e.stop();u.current=[];for(let e of Object.values(s.current))e?.style.translate&&(e.style.translate=``)},[]),g=(0,m.useCallback)(e=>{h(),l.current=e,d.current=1,f.current=1;let t=p(e);k4(r.current,t),k4(i.current,void 0),j4(a.current,t,`left`,1),j4(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);MH()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),jH(),l.current=t;let _=m.left>n.left?1:-1,v=_>0?n.right:n.left,y=_>0?m.left:m.right,b=Math.abs(y-v),x=_>0?`right`:`left`,S=_>0?`left`:`right`,C=c.current.map(e=>{let t=e?.parentElement;return t?{liquid:e,from:t.offsetLeft,to:t.offsetLeft+t.offsetWidth}:void 0}),w=b>4?1-4/b:0,T={drained:1-Math.min(1,d.current),unrung:1-Math.min(1,f.current),head:0,tail:0,filled:0,rung:0,squash:1,budge:0},E=s.current[t];d.current=0,f.current=0;let D=()=>{let e=(n.right-n.left)*Math.min(1,T.drained);k4(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),j4(o.current,n,x,1-T.unrung);let t=v+_*b*T.head,s=v+_*b*T.tail,c=Math.min(t,s),l=Math.max(t,s);for(let e of C){if(!e?.liquid)continue;let t=Math.max(c,e.from),n=Math.min(l,e.to);e.liquid.style.width=`${Math.max(0,n-t)}px`,e.liquid.style.transform=`translateX(${Math.max(0,t-e.from)}px)`}let u=_*T.budge,d=u?{...m,left:m.left+u,right:m.right+u}:m;E&&(E.style.translate=Math.abs(u)>.01?`${u.toFixed(2)}px`:``);let f=(d.right-d.left)*Math.min(1,Math.max(0,T.filled));k4(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),j4(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Wf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,A=()=>{if(k)return;k=!0;let e=O(`filled`,0,F4,e=>{d.current=e});e.then(()=>{l.current===t&&MH()}),O(`squash`,.8,z4),O(`rung`,0,I4,e=>{f.current=e}),O(`budge`,0,{...L4,delay:R4},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,M4),O(`unrung`,T.unrung,M4),O(`head`,0,N4,e=>{e>=w&&A()}),O(`tail`,0,P4),D()},[p,g,h]);(0,m.useLayoutEffect)(()=>{let t=l.current,n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;!t||!e||t===e||n?g(e):_(t,e)},[e,t,_,g]);let v=(0,m.useRef)(e);return v.current=e,(0,m.useEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=!0,r=new ResizeObserver(()=>{if(t){t=!1;return}g(v.current)});return r.observe(e),()=>{r.disconnect(),h()}},[g,h]),{track:n,fill:r,drain:i,ring:a,unring:o,cells:s,liquids:c}}var V4=(0,m.forwardRef)(function({which:e},t){return(0,R.jsxs)(`svg`,{ref:t,"aria-hidden":`true`,[`data-tab-${e}`]:``,className:`pointer-events-none absolute left-0 z-20 overflow-visible opacity-0 will-change-transform`,fill:`none`,children:[(0,R.jsx)(`path`,{pathLength:1,strokeWidth:O4,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,R.jsx)(`path`,{pathLength:1,strokeWidth:O4,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function H4(e){if(e.left||e.right)return`linear-gradient(to right, ${e.left?`transparent 0, black 28px`:`black 0`}, ${e.right?`black calc(100% - 28px), transparent 100%`:`black 100%`})`}function U4({tabs:e,activeId:t,onSelect:n}){let r=cA(`(max-width: 767.98px)`),{track:i,fill:a,drain:o,ring:s,unring:c,cells:l,liquids:u}=B4(t,e.length),d=(0,m.useRef)(null),[f,p]=(0,m.useState)({left:!1,right:!1}),h=(0,m.useCallback)(()=>{let e=d.current;if(!e)return;let t=e.scrollLeft>2,n=e.scrollLeft+e.clientWidth<e.scrollWidth-2;p(e=>e.left===t&&e.right===n?e:{left:t,right:n})},[]);(0,m.useEffect)(()=>{let e=d.current;if(!e||typeof ResizeObserver>`u`)return;h();let t=new ResizeObserver(h);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[h,e.length]),(0,m.useEffect)(()=>{let e=d.current,n=t?l.current[t]:void 0;e&&n&&(n.offsetLeft<e.scrollLeft?e.scrollLeft=n.offsetLeft-8:n.offsetLeft+n.offsetWidth>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n.offsetLeft+n.offsetWidth-e.clientWidth+8))},[t,l]);function g(r){if(r.key===`ArrowDown`&&!r.altKey){Ij()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;r.preventDefault();let a=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];Rj.active=!0,Rj.to=o.id,window.setTimeout(()=>{Rj.active=!1,Rj.to=void 0},3e3),n(o.id),l.current[o.id]?.focus({preventScroll:!0})}return r?(0,R.jsx)(x4,{tabs:e,activeId:t,onSelect:n}):(0,R.jsx)(`div`,{ref:d,onScroll:h,style:{maskImage:H4(f),WebkitMaskImage:H4(f)},className:`min-w-0 max-w-full overflow-x-auto [scrollbar-width:none] pointer-coarse:-my-1.5 pointer-coarse:py-1.5 [&::-webkit-scrollbar]:hidden`,children:(0,R.jsxs)(`div`,{ref:i,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:g,className:`relative mx-auto flex w-max items-center py-0.5`,children:[(0,R.jsx)(`span`,{ref:o,"aria-hidden":`true`,"data-tab-drain":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,R.jsx)(`span`,{ref:a,"aria-hidden":`true`,"data-tab-fill":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,R.jsx)(V4,{ref:c,which:`unring`}),(0,R.jsx)(V4,{ref:s,which:`ring`}),e.map((e,n)=>(0,R.jsxs)(m.Fragment,{children:[n>0?(0,R.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,R.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,R.jsx)(`span`,{ref:e=>{u.current[n-1]=e},"data-tab-liquid":!0,className:`absolute top-0 left-0 h-[2px] w-0 rounded-full bg-tab-liquid shadow-[0_0_6px_var(--tab-liquid)] will-change-transform`})]}):null,(0,R.jsx)(D4,{ref:t=>{l.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function W4({oracleBusy:e,runs:t,activity:n,background:r}){let i=new Set;e&&i.add(`Oracle`);for(let e of t)e.status===`running`&&i.add(SW(EW(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:SW(e.source));let a=r.filter(e=>e.alive&&e.busy).length;return a&&i.add(a===1?`1 in the background`:`${a} in the background`),[...i]}function G4(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function K4(...e){let t=e.filter(e=>!!e);if(!t.length)return;let n=Math.max(...t.map(e=>e.left)),r=Math.max(...t.map(e=>e.top)),i=Math.min(...t.map(e=>e.left+e.width)),a=Math.min(...t.map(e=>e.top+e.height));return i>n&&a>r?{left:n,top:r,width:i-n,height:a-r}:void 0}function q4(e,t){return K4(e,{left:e.left,top:e.top,width:e.width,height:Math.max(0,t-e.top)})}var J4=6,Y4=`bot-lobby.orb`,X4=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function Z4(e,t,n,r){let i=e=>e+J4,a=(e,t)=>Math.max(e+J4,e+t-r-J4);return{x:Math.min(a(n.left,n.width),Math.max(i(n.left),e)),y:Math.min(a(n.top,n.height),Math.max(i(n.top),t))}}function Q4(e,t,n,r){let i=e=>Math.max(1,e-r),a=Z4(e,t,n,r);return{fx:Math.min(1,Math.max(0,(a.x-n.left)/i(n.width))),fy:Math.min(1,Math.max(0,(a.y-n.top)/i(n.height)))}}function $4(e,t,n){return Z4(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function e3(e){if(e)try{let t=JSON.parse(e);return X4(t.fx)&&X4(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function t3(){try{return e3(localStorage.getItem(Y4))}catch{return}}function n3(e){try{localStorage.setItem(Y4,JSON.stringify(e))}catch{}}var r3=5,i3=16,a3={fx:1,fy:1};function o3(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function s3(e){let t=document.getElementById(`main`)?.getBoundingClientRect();if(!t)return;if(!e)return o3(t);let n=window.visualViewport,r=o3({left:n?.offsetLeft??0,top:n?.offsetTop??0,width:n?.width??window.innerWidth,height:n?.height??window.innerHeight}),i=K4(o3(t),r);if(!i)return;let a=document.getElementById(`app-dock`)?.getBoundingClientRect().top;return a===void 0?i:q4(i,a)}function c3(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function l3(e){let[t,n]=(0,m.useState)(()=>s3(e));return(0,m.useEffect)(()=>{let t=()=>{let t=s3(e);n(e=>c3(e,t)?e:t)},r=document.getElementById(`main`),i=document.getElementById(`app-dock`),a=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);r&&a?.observe(r),i&&a?.observe(i);let o=window.visualViewport;return window.addEventListener(`resize`,t),window.addEventListener(`orientationchange`,t),o?.addEventListener(`resize`,t),o?.addEventListener(`scroll`,t),t(),()=>{a?.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`orientationchange`,t),o?.removeEventListener(`resize`,t),o?.removeEventListener(`scroll`,t)}},[e]),t}var u3=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=cA(`(max-width: 767.98px)`),u=l3(l),[d,f]=(0,m.useState)(t3),[p,h]=(0,m.useState)(),[g,_]=(0,m.useState)(!1),v=(0,m.useRef)(void 0),y=(0,m.useRef)(!1),b=(0,m.useRef)(44),x=d??(l?a3:void 0),S=p??(x&&u?$4(x,u,b.current):void 0),C=(0,m.useCallback)((e,t)=>{let n=s3(l);if(!n)return;let r=Q4(e,t,n,b.current);f(r),n3(r)},[l]);(0,m.useEffect)(()=>{u&&h(e=>e&&Z4(e.x,e.y,u,b.current))},[u]);function w(e){if(e.button!==0)return;let t=e.currentTarget.getBoundingClientRect();b.current=t.width,v.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,ox:t.left,oy:t.top,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId)}function T(e){let t=v.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.sx,r=e.clientY-t.sy;if(!t.moved&&Math.hypot(n,r)<r3)return;t.moved=!0;let i=s3(l);i&&h(Z4(t.ox+n,t.oy+r,i,b.current))}function E(e){let t=v.current;v.current=void 0,t?.moved&&(y.current=!0,C(t.ox+e.clientX-t.sx,t.oy+e.clientY-t.sy),h(void 0))}function D(e){let t=e.shiftKey?64:i3,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];if(!n||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let r=e.currentTarget.getBoundingClientRect();b.current=r.width,C(r.left+n[0],r.top+n[1])}let O=!e&&n.length>0,k=e?SW(e):O?G4(n):void 0,A=e?`${t.map(SW).join(`, `)} thinking. `:O?`${n.join(`, `)} at work. `:``,ee=S&&u?S.x-u.left<140:!1,j={"--orb":r,...S?{left:S.x,top:S.y,right:`auto`,bottom:`auto`}:{}};return(0,R.jsxs)(Cj,{open:g&&!p,onOpenChange:_,children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${A}Drag, or use the arrow keys, to move it.`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,onClick:e=>{if(y.current){y.current=!1,e.preventDefault();return}s()},onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:()=>{v.current=void 0,h(void 0)},onKeyDown:D,style:j,"data-thinking":e?``:void 0,"data-busy":O?``:void 0,"data-dragging":p?``:void 0,"data-placed":S?``:void 0,"data-flip":ee||void 0,className:q(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,a&&`invisible`),children:[(0,R.jsx)(Du,{initial:!1,children:k?(0,R.jsx)(B.span,{className:`orb-label`,initial:{opacity:0,x:ee?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:ee?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,R.jsx)(Du,{mode:`popLayout`,initial:!1,children:(0,R.jsx)(B.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:k},k)})},`label`):null}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,R.jsx)(`span`,{className:`orb-icon`,children:(0,R.jsx)(bW,{source:e,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,R.jsxs)(Tj,{side:`top`,children:[`Thinking `,!l&&o?(0,R.jsx)(rA,{chord:o}):null,(0,R.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),d3=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,f3=260,p3=200,m3=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function h3(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
103
|
+
`,t),i=e.slice(n,r<0?e.length:r),a=w0.exec(i);if(!a||t-n<a[0].length)return;let[o,s=``,c,l,u=`.`,d]=a;if(i.slice(o.length).trim()===``)return{value:e.slice(0,n)+e.slice(r<0?e.length:r),start:n,end:n};let f=`\n${s}${c??`${Number(l)+1}${u}`} ${d?`[ ] `:``}`;return{value:e.slice(0,t)+f+e.slice(t),start:t+f.length,end:t+f.length}}function E0({rest:e}){let{chat:t}=qW(e);return(0,R.jsx)(`div`,{role:`group`,"aria-label":`Knowledge pane`,className:`flex items-center gap-0.5 rounded-lg bg-muted p-0.5`,children:[`Chat`,`Docs`].map(n=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":t===(n===`Chat`),onClick:()=>aj(JW(e,n===`Chat`)),className:q(`h-6 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,t===(n===`Chat`)?`btn-raised btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:n},n))})}var D0={id:`oracle`,pill:`Oracle`,label:`Message the oracle`,placeholder:`Message the oracle…`};function O0(e,t,n){if(e.kind===`sessions`){let e={id:`newsession`,pill:`New session`,label:`Start a task in a new session`,placeholder:`Describe a task for a new session…`};return n?[{id:`session`,pill:`Message`,label:`Message ${n.name}`,placeholder:`Message ${n.name}…`,session:n},e,D0]:[e,D0]}if(e.kind!==`tab`)return[D0];if(e.tab===`knowledge`)return[{id:`knowledge`,pill:`Oracle`,label:`Ask the oracle about this project`,placeholder:`Ask about this project — the oracle searches the code and learns what is missing…`}];if(e.tab===`plan`)return[{id:`panel`,pill:`Panel`,label:`Message the panel`,placeholder:`Describe a task, or answer the panel…`},D0];if(e.tab===`quickfix`)return[{id:`quickfix`,pill:`Quick fix`,label:`Describe a quick fix`,placeholder:`Describe a small change…`},D0];let r=e.tab===`tasks`?OG(e.rest).id??t:void 0;return r?[{id:`comment`,pill:`Comment`,label:`Comment on ${r}`,placeholder:`Comment on ${r}'s plan…`,taskId:r},{id:`task`,pill:`Task's oracle`,label:`Message ${r}'s oracle`,placeholder:`Leave a message for ${r}'s oracle…`,taskId:r},D0]:[D0]}var k0=0,A0=`toolbar-button relative inline-flex size-8 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,translate] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`;function j0(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function M0({file:e,onRemove:t}){let n=(0,R.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,onClick:t,className:q(`btn-ghost flex shrink-0 items-center justify-center rounded-lg border text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,e.image?`absolute top-1 right-1 size-5 bg-background/80 text-foreground backdrop-blur-sm`:`size-7`),children:(0,R.jsx)(Vg,{"aria-hidden":`true`,className:`size-3.5`})});return e.image?(0,R.jsxs)(B.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:520,damping:32},title:`${e.name} · ${b0(e.size)}`,className:`relative size-16 shrink-0 overflow-hidden rounded-lg border border-border bg-muted`,children:[(0,R.jsx)(`img`,{src:F(e.image),alt:e.name,className:`size-full object-cover`}),e.state===`uploading`?(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-background/60`,children:(0,R.jsx)(pj,{className:`size-4`,"aria-hidden":`true`,role:`presentation`})}):null,n]}):(0,R.jsxs)(B.li,{layout:!0,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:520,damping:32},className:`flex h-9 min-w-0 items-center gap-2 rounded-lg border border-border bg-muted pr-1 pl-2.5`,children:[(0,R.jsxs)(`span`,{className:`relative flex shrink-0 items-center justify-center text-muted-foreground`,children:[(0,R.jsx)(Fm,{"aria-hidden":`true`,className:`size-4`}),e.state===`uploading`?(0,R.jsx)(pj,{className:`absolute -right-1 -bottom-1 size-2.5`,"aria-hidden":`true`,role:`presentation`}):null]}),(0,R.jsxs)(`span`,{className:`min-w-0 max-w-40`,children:[(0,R.jsx)(`span`,{className:`block truncate text-xs font-medium`,children:e.name}),(0,R.jsx)(`span`,{className:`block text-[0.65rem] leading-tight text-muted-foreground`,children:e.state===`uploading`?`uploading…`:b0(e.size)})]}),n]})}function N0({route:e,keys:t,onHelp:n,dockNav:r}){let[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(),_=sA(`status`),v=sA(`lobby`),y=QA(),b=(_.data?.busy??!1)||!!v.data?.reply?.trim(),x=lA(),S=cA(`(max-width: 767.98px)`),{keyboardOpen:C,keyboardInset:w}=BA(),{taskId:T,session:E}=jQ(),D=(0,m.useMemo)(()=>O0(e,T,E),[e,T,E]),O=D.map(e=>`${e.id}:${e.taskId??e.session?.name??``}`).join(`|`),k=D.find(e=>e.id===h)??D[0];(0,m.useEffect)(()=>g(void 0),[O]);let A=(0,m.useRef)(null),ee=(0,m.useRef)(null),j=(0,m.useRef)(null),M=(0,m.useRef)(o);M.current=o;let te=(0,m.useRef)(void 0);(0,m.useLayoutEffect)(()=>{let e=te.current,t=ee.current;e&&t&&(te.current=void 0,t.setSelectionRange(e.start,e.end))},[i]);let ne=(0,m.useCallback)(e=>{te.current={start:e.start,end:e.end},a(e.value)},[]);(0,m.useEffect)(()=>{let e=A.current;if(!e)return;let t=document.documentElement,n=()=>t.style.setProperty(`--composer-h`,y?`0px`:`${Math.ceil(e.getBoundingClientRect().height+(S?w:0))}px`);n();let r=new ResizeObserver(n);return r.observe(e),()=>{r.disconnect(),t.style.setProperty(`--composer-h`,`0px`)}},[y,w,C,S]);let N=(0,m.useCallback)(e=>{let t=[...e],n=8-M.current.length;t.length>n&&H.warning(`At most 8 files go with one message.`);for(let e of t.slice(0,Math.max(0,n))){let t=`f${++k0}`,n=e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0;s(r=>[...r,{key:t,name:e.name||(n?`image.png`:`file`),size:e.size,...n?{image:n}:{},state:`uploading`}]),x0(e).then(e=>s(n=>n.map(n=>n.key===t?{...n,state:`ready`,info:e}:n))).catch(e=>{H.error(e instanceof Error?e.message:`That file did not upload.`),s(e=>e.filter(e=>e.key!==t))})}},[]),re=(0,m.useCallback)(e=>{s(t=>{let n=t.find(t=>t.key===e);return n?.image&&URL.revokeObjectURL(n.image),t.filter(t=>t.key!==e)})},[]),ie=o.some(e=>e.state===`uploading`),ae=o.flatMap(e=>e.info?[e.info.id]:[]),oe=(i.trim().length>0||ae.length>0)&&!ie&&!u,se=(0,m.useCallback)(async()=>{if(!oe)return;d(!0);let t=ae.length>0?ae:void 0,n={text:i,...t?{attachments:t}:{}};try{let r=!0;if(k.id===`oracle`){let e=await Te(`lobby.send`,n);e.notice&&H(e.notice)}else if(k.id===`knowledge`)r=await U(`knowledge.ask`,n)!==void 0,r&&e.kind===`tab`&&aj(JW(e.rest,!0));else if(k.id===`panel`)r=await U(`planner.send`,n)!==void 0;else if(k.id===`quickfix`)r=await U(`quickfix.submit`,n)!==void 0;else if(k.id===`task`)r=await U(`tasks.message`,{taskId:k.taskId,...n})!==void 0;else if(k.id===`session`)r=await U(`sessions.message`,{...k.session.address,...n})!==void 0;else if(k.id===`newsession`){let e=await U(`sessions.start`,{request:i,...t?{attachments:t}:{}});r=e!==void 0,e?.key&&aj(`#/sessions/${encodeURIComponent(e.key)}`)}else r=await U(`tasks.comment`,{taskId:k.taskId,...n})!==void 0;if(r){a(``);for(let e of M.current)e.image&&URL.revokeObjectURL(e.image);s([])}}catch(e){H.error(e instanceof Error?e.message:`Could not send`)}finally{d(!1)}},[oe,ae,k,i,e]),ce=(0,m.useCallback)(async()=>{try{await Te(`lobby.abort`,{})}catch(e){H.error(e instanceof Error?e.message:`Could not stop`)}},[]);return(0,R.jsxs)(`div`,{id:`app-dock`,ref:A,style:S&&C?{bottom:`${w}px`}:void 0,className:q(`dock pointer-events-none absolute inset-x-0 bottom-0 z-30 px-6 pb-[max(1.25rem,env(safe-area-inset-bottom))] transition-opacity duration-200 ease-snap max-md:px-2`,S&&C?`max-md:pb-2`:`max-md:pb-[max(0.5rem,env(safe-area-inset-bottom))]`,y&&`opacity-0`),inert:y,children:[r?(0,R.jsx)(`div`,{className:`pointer-events-auto mx-auto mb-1.5 w-full max-w-3xl`,children:r}):null,(0,R.jsx)(`div`,{className:`pointer-events-auto mx-auto w-full max-w-3xl`,children:(0,R.jsxs)(`div`,{className:q(`group/composer relative rounded-2xl border border-dock-border bg-dock shadow-dock transition-[border-color,box-shadow] duration-300 ease-snap focus-within:border-ring focus-within:shadow-dock-focus`,x&&`min-[500px]:max-md:grid min-[500px]:max-md:grid-cols-[minmax(0,1fr)_auto] min-[500px]:max-md:min-w-0`,f&&`border-primary shadow-[0_0_0_3px_color-mix(in_oklab,var(--ring)_30%,transparent)]`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),p(!0))},onDragLeave:()=>p(!1),onDrop:e=>{e.preventDefault(),p(!1),e.dataTransfer.files.length>0&&N(e.dataTransfer.files)},children:[(0,R.jsx)(Du,{initial:!1,children:o.length>0?(0,R.jsx)(B.ul,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{type:`spring`,stiffness:420,damping:36},"aria-label":`Attachments`,className:q(`flex flex-wrap items-end gap-2 overflow-hidden px-3 pt-3`,x&&`min-[500px]:max-md:col-span-full min-[500px]:max-md:min-w-0 min-[500px]:max-md:max-w-full`),children:o.map(e=>(0,R.jsx)(M0,{file:e,onRemove:()=>re(e.key)},e.key))},`files`):null}),c?(0,R.jsx)(`div`,{"aria-label":`Markdown preview`,role:`region`,className:q(`max-h-48 overflow-y-auto border-b border-border px-4 py-3`,x&&`min-[500px]:max-md:col-span-full min-[500px]:max-md:min-w-0 min-[500px]:max-md:max-w-full`),children:i.trim()?(0,R.jsx)(WH,{text:i}):(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing to preview yet.`})}):null,(0,R.jsx)(`div`,{className:q(`flex px-4 pt-3 pb-1`,x&&`min-[500px]:max-md:col-start-1 min-[500px]:max-md:min-w-0 min-[500px]:max-md:max-w-full min-[500px]:max-md:pt-1 min-[500px]:max-md:pb-1`),children:(0,R.jsx)(`textarea`,{ref:ee,id:`composer-text`,"aria-label":k.label,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`Escape`&&!e.nativeEvent.isComposing){e.preventDefault(),Lj();return}let t=e.currentTarget,n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&!e.altKey&&!e.shiftKey&&[`b`,`i`,`e`,`k`].includes(n)){e.preventDefault();let{selectionStart:r,selectionEnd:i,value:a}=t;ne(n===`k`?C0(a,r,i):S0(a,r,i,n===`b`?`**`:n===`i`?`_`:"`"));return}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&n===`p`){e.preventDefault(),l(e=>!e);return}if(e.key===`Enter`&&e.shiftKey&&!e.nativeEvent.isComposing&&t.selectionStart===t.selectionEnd){let n=T0(t.value,t.selectionStart);n&&(e.preventDefault(),ne(n));return}if(e.key===`Backspace`&&t.value===``&&M.current.length>0){e.preventDefault(),re(M.current.at(-1).key);return}(j0(e)||e.key===`Enter`&&(e.metaKey||e.ctrlKey))&&(e.preventDefault(),se())},onPaste:e=>{let t=[...e.clipboardData.files];t.length!==0&&(e.preventDefault(),N(t))},placeholder:b&&k.id===`oracle`?`The oracle is working. Enter steers it…`:k.placeholder,rows:1,className:q(`field-sizing-content max-h-[min(45vh,20rem)] min-h-[1.75rem] w-full min-w-0 flex-1 resize-none bg-transparent text-base leading-relaxed caret-primary outline-none placeholder:text-muted-foreground md:text-[0.9375rem] md:leading-relaxed`,x&&`min-[500px]:max-md:max-h-[44px] min-[500px]:max-md:overflow-y-auto`)})}),(0,R.jsxs)(`div`,{className:q(`flex flex-wrap items-center gap-x-2 gap-y-2 px-2 pt-1 pb-2`,x&&`min-[500px]:max-md:col-start-2 min-[500px]:max-md:min-w-0 min-[500px]:max-md:flex-nowrap min-[500px]:max-md:gap-y-0 min-[500px]:max-md:pt-1 min-[500px]:max-md:pb-1`),children:[(0,R.jsx)(`input`,{ref:j,type:`file`,multiple:!0,hidden:!0,tabIndex:-1,"aria-label":`Attach files`,onChange:e=>{N(e.target.files??[]),e.target.value=``}}),(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Attach images, PDFs or files`,"data-compact":!0,onClick:()=>j.current?.click(),className:A0,children:(0,R.jsx)(jh,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsx)(Tj,{children:`Attach images, PDFs or files`})]}),(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Preview the Markdown`,"aria-pressed":c,"aria-keyshortcuts":`Alt+P`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>l(e=>!e),className:A0,children:(0,R.jsx)(km,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsxs)(Tj,{children:[`Preview `,(0,R.jsx)(rA,{chord:`Alt+P`})]})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mx-1.5 h-4 w-px bg-border`}),(0,R.jsx)(`div`,{className:q(`contents`,S&&!x&&`max-md:block max-md:w-full max-md:order-last`),children:e.kind===`tab`&&e.tab===`knowledge`?(0,R.jsx)(E0,{rest:e.rest}):x&&D.length>1?(0,R.jsxs)(Rq,{value:k.id,onValueChange:e=>g(e),children:[(0,R.jsx)(Bq,{"aria-label":`Send to`,className:`h-7 min-w-0 gap-1.5 px-2 text-xs`,children:(0,R.jsx)(zq,{})}),(0,R.jsx)(Vq,{children:D.map(e=>(0,R.jsx)(Hq,{value:e.id,children:e.pill},e.id))})]}):D.length>1?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Send to`,className:`flex max-md:flex-wrap items-center gap-0.5 rounded-lg bg-muted p-0.5 shadow-[inset_0_1px_2px_rgb(0_0_0/0.07)]`,children:D.map(e=>(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,role:`radio`,"data-compact":!0,"aria-checked":e.id===k.id,onClick:()=>g(e.id),className:q(`h-6 rounded-md border border-transparent px-2.5 text-xs font-medium transition-[background-color,color,box-shadow] duration-150 outline-none focus-visible:ring-3 focus-visible:ring-ring/40`,e.id===k.id?`btn-raised btn-soft bg-card text-foreground`:`btn-ghost text-muted-foreground hover:text-foreground`),children:e.pill},e.id))}):(0,R.jsxs)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:[`To the `,k.pill.toLowerCase()]})}),(0,R.jsx)(`div`,{className:`@container ml-auto flex min-w-0 flex-1 items-center justify-end overflow-hidden px-2 max-md:hidden`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-3.5`,children:[e.kind===`tab`&&e.tab===`plan`?(0,R.jsx)(iA,{chord:t.savePlan??`Ctrl+S`,className:`hidden @[34rem]:inline-flex`,children:`save plan`}):null,(0,R.jsx)(iA,{chord:`/`,className:`hidden group-focus-within/composer:!hidden @[28rem]:inline-flex`,children:`write`}),(0,R.jsx)(iA,{chord:`Esc`,className:`hidden group-[:not(:focus-within)]/composer:!hidden @[28rem]:inline-flex`,children:`tabs`}),(0,R.jsx)(iA,{chord:`Shift+Enter`,className:`hidden @[22rem]:inline-flex`,children:`new line`}),(0,R.jsx)(iA,{chord:`Enter`,className:`hidden @[11rem]:inline-flex`,children:`send`}),(0,R.jsxs)(`button`,{type:`button`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"data-compact":!0,onClick:n,className:`kbd-hint btn-ghost inline-flex h-7 shrink-0 items-center gap-1.5 rounded-lg border px-1.5 text-xs text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(rA,{chord:t.help??`Alt+H`,className:`kbd-hint`}),(0,R.jsx)(`span`,{className:`hidden @[8rem]:inline`,children:`shortcuts`})]})]})}),(0,R.jsxs)(`div`,{className:`contents max-md:ml-auto max-md:flex max-md:items-center max-md:gap-2`,children:[b&&k.id===`oracle`?(0,R.jsx)(SM,{label:`Stop`,icon:hg,iconOnly:!0,compact:!0,title:`Stop the oracle?`,description:`The current response stops. Work already recorded is kept.`,confirmLabel:`Stop`,variant:`destructive`,onConfirm:()=>void ce()}):null,(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Send`,"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,"data-compact":!0,onClick:()=>void se(),disabled:!oe,className:`btn-tint relative inline-flex size-8 items-center justify-center rounded-lg border [--tint:var(--primary)] before:absolute before:-inset-1 before:content-[''] text-primary-foreground transition-[background-color,color,box-shadow,translate,filter] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none disabled:text-muted-foreground`,children:u?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5 text-primary-foreground`}):(0,R.jsx)(Np,{"aria-hidden":`true`,className:`size-4`,strokeWidth:2.25})})}),(0,R.jsxs)(Tj,{children:[`Send `,(0,R.jsx)(rA,{chord:`Enter`})]})]})]})]}),f?(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 flex items-center justify-center rounded-xl bg-card/90 text-sm font-medium text-primary backdrop-blur-[2px]`,children:`Drop to attach`}):null]})})]})}function P0(e){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)();async function a(r){if(!t){n(!0),i(void 0);try{let{project:t}=await Te(`projects.open`,{path:r});be([t]),he(t.id,e)}catch(e){i(e.message)}finally{n(!1)}}}return{opening:t,error:r,open:a}}function F0({path:e,busy:t,browse:n}){let[r,i]=(0,m.useState)(e);return(0,m.useEffect)(()=>i(e),[e]),(0,R.jsxs)(`form`,{className:`flex min-w-0 gap-2`,onSubmit:e=>{e.preventDefault(),n(r)},children:[(0,R.jsx)(Uq,{className:`min-w-0 flex-1 max-md:h-11`,"aria-label":`Folder path`,value:r,disabled:t,onChange:e=>i(e.target.value)}),(0,R.jsx)(Y,{type:`submit`,disabled:t||!r.trim(),className:`max-md:min-h-11`,children:`Go`})]})}function I0({data:e,busy:t,browse:n}){return(0,R.jsxs)(`div`,{className:`min-h-24 max-h-64 overflow-y-auto overscroll-contain rounded-lg border border-border max-md:max-h-[min(40vh,16rem)]`,"aria-label":`Folders`,role:`group`,children:[e?.parent?(0,R.jsxs)(Y,{variant:`ghost`,className:`h-auto min-h-11 w-full justify-start py-3 text-left max-md:min-h-12`,disabled:t,onClick:()=>n(e.parent),children:[(0,R.jsx)(Np,{}),` Parent folder`]}):null,e?.folders.map(e=>(0,R.jsxs)(Y,{variant:`ghost`,className:`h-auto min-h-11 w-full justify-start py-3 text-left max-md:min-h-12`,disabled:t,onClick:()=>n(e.path),children:[(0,R.jsx)(zm,{className:`shrink-0`}),(0,R.jsx)(`span`,{className:`whitespace-normal break-words`,children:e.name})]},e.path)),e&&!e.folders.length?(0,R.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`No subfolders. You can open this folder.`}):null,e?.truncated?(0,R.jsx)(`p`,{className:`p-3 text-sm text-muted-foreground`,children:`Listing limited to 2,000 entries. Enter a path to browse further.`}):null]})}function L0({tab:e,close:t,busyChanged:n}){let[r,i]=(0,m.useState)(),a=xj(`projects.browse`,r===void 0?{}:{path:r},[]),o=P0(e);return(0,m.useEffect)(()=>n(o.opening),[o.opening,n]),(0,R.jsxs)(`div`,{className:`flex min-h-0 max-h-full flex-col gap-4 overflow-y-auto p-5 max-md:max-h-[calc(100svh-2rem)] max-md:p-4`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Open project folder`}),(0,R.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:`Browse folders on the machine running bot-lobby. Opening starts a separate session; your current project keeps running. Project-local extensions are not enabled automatically.`}),(0,R.jsx)(F0,{path:a.data?.path??r??``,busy:o.opening,browse:i}),(0,R.jsx)(I0,{data:a.data,busy:a.loading||o.opening,browse:i}),a.loading?(0,R.jsx)(`p`,{role:`status`,children:`Loading folders…`}):null,a.error||o.error?(0,R.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:a.error??o.error}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[a.error?(0,R.jsx)(Y,{variant:`outline`,onClick:a.reload,disabled:a.loading,className:`max-md:min-h-11`,children:`Retry`}):null,(0,R.jsx)(Y,{variant:`outline`,onClick:t,disabled:o.opening,className:`max-md:min-h-11`,children:`Cancel`}),(0,R.jsx)(Y,{disabled:!a.data||a.loading||!!a.error||o.opening,onClick:()=>void o.open(a.data.path),className:`max-md:min-h-11`,children:o.opening?`Opening project…`:`Open this folder`})]})]})}function R0({open:e,onClose:t,tab:n}){let r=XA(e,YA.help),[i,a]=(0,m.useState)(!1);return(0,R.jsx)(HA,{open:r,label:`Open project folder`,className:`max-md:max-h-[calc(100svh-2rem)] max-md:max-w-[calc(100vw-2rem)]`,onOpenChange:e=>{!e&&!i&&t()},dismissOnBackdrop:!i,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[role="combobox"][aria-label="Project"]`)?.focus()},children:e?(0,R.jsx)(L0,{tab:n,close:t,busyChanged:a}):null})}function z0(){try{return{id:P()}}catch(e){return{error:e.message}}}function B0(e,t){if(e){if(t&&!e.projects.some(e=>e.id===t))return`Selected project is unknown or offline. Refresh or choose a running project.`;if(!e.projects.length)return`No authorized running projects found. Open a folder from the Project menu, or refresh.`}}function V0(){let[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(0);async function s(){let e=++o.current;a(!0),r(void 0);try{let n=await Te(`projects.list`,{});be(n.projects),e===o.current&&t(n)}catch(t){e===o.current&&r(t.message)}finally{e===o.current&&a(!1)}}(0,m.useEffect)(()=>(s(),()=>{o.current++}),[]);let[c,l]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!i)return l(!1);let e=setTimeout(()=>l(!0),300);return()=>clearTimeout(e)},[i]),{data:e,error:n,busy:i,slow:c,refresh:s}}function H0({data:e,error:t}){let n=z0();return n.error??t??B0(e,n.id)}function U0({projects:e}){let t=H0(e);return t?(0,R.jsxs)(`p`,{role:`alert`,className:`notice flex min-w-0 items-start gap-2 pt-1 pb-0.5 text-xs break-words text-destructive`,children:[(0,R.jsx)(Tg,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,R.jsx)(`span`,{children:t})]}):null}function W0(e){let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0,n=e.key===`Home`?`first`:e.key===`End`?`last`:void 0;if(!t&&!n)return;let r=[...e.currentTarget.querySelectorAll(`[role='option']`)];if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[n===`first`?0:n===`last`?r.length-1:Math.max(0,Math.min(r.length-1,(i<0?t>0?-1:r.length:i)+t))]?.focus()}function G0({projects:e,tab:t,name:n,branch:r}){let{data:i,busy:a,slow:o,refresh:s}=e,[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=z0(),p=H0(e),h=f.error?`invalid`:f.id??i?.currentId??``;Uj(`p`,()=>l(!0)),Uj(`r`,()=>void s(),{enabled:c,inDialog:!0});function g(e){l(!1),e!==h&&he(e,t)}return(0,R.jsxs)(`div`,{"aria-busy":a,className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsxs)(nY,{open:c,onOpenChange:l,children:[(0,R.jsxs)(rY,{type:`button`,role:`combobox`,"aria-label":`Project`,"aria-description":`${n}${r?`, branch ${r}`:``}`,"aria-haspopup":`listbox`,"aria-expanded":c,"aria-keyshortcuts":`P ArrowDown`,onKeyDown:e=>{e.key!==`ArrowDown`||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),l(!0))},className:`btn-ghost group flex h-8 min-w-0 items-center gap-2 rounded-lg border border-transparent px-2.5 text-sm font-medium outline-none transition-[box-shadow,background-color] duration-150 focus-visible:ring-3 focus-visible:ring-ring/40 disabled:pointer-events-none max-md:h-11`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`size-2.5 shrink-0 rounded-full`,p?`bg-destructive`:`bg-primary`)}),(0,R.jsx)(`span`,{className:`truncate`,children:n}),(0,R.jsx)(Zp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,R.jsxs)(iY,{align:`start`,sideOffset:6,"aria-label":`Projects`,onKeyDown:W0,onOpenAutoFocus:e=>{let t=e.currentTarget?.querySelector(`[role='option'][aria-selected='true']`)??e.currentTarget?.querySelector(`[role='option']`);t&&(e.preventDefault(),t.focus())},className:`p-0 flex max-h-[calc(100svh-2rem)] w-[min(26rem,calc(100vw-1.5rem))] origin-(--radix-popover-content-transform-origin) flex-col overflow-hidden rounded-xl outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 max-md:w-[calc(100vw-2rem)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Running projects`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-label":`Refresh list`,"aria-keyshortcuts":`R`,className:`inline-flex h-7 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 disabled:opacity-60 max-md:h-11`,children:[a?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-3`}),`Refresh`,(0,R.jsx)(rA,{chord:`R`,className:`kbd-hint`})]})]}),(0,R.jsx)(`div`,{role:`listbox`,"aria-label":`Projects`,className:`flex max-h-72 flex-col overflow-y-auto overscroll-contain p-1 max-md:max-h-[calc(100svh-12rem)]`,children:i?.projects.map(e=>{let t=e.id===h;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>g(e.id),className:q(`flex min-h-10 w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-3 focus-visible:ring-ring/30 max-md:min-h-11`,t&&`bg-accent`),children:[(0,R.jsx)(`span`,{className:`flex h-5 w-4 shrink-0 items-center justify-center`,children:t?(0,R.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):null}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block whitespace-normal break-words text-sm font-medium`,children:e.name}),(0,R.jsxs)(`span`,{className:`block whitespace-normal break-all text-xs text-muted-foreground`,children:[e.cwd,` · :`,e.port]})]})]},e.id)})}),(0,R.jsxs)(`button`,{type:`button`,className:`flex min-h-11 items-center gap-2 border-t border-border px-3 py-3 text-sm font-medium outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/40`,onClick:()=>{l(!1),d(!0)},children:[(0,R.jsx)(Lm,{"aria-hidden":`true`,className:`size-4`}),`Open folder…`]})]})]}),(0,R.jsx)(R0,{open:u,onClose:()=>d(!1),tab:t}),r?(0,R.jsxs)(`span`,{className:`hidden min-w-0 items-center gap-1 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground sm:inline-flex`,children:[(0,R.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:r})]}):null,o||p?(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Refresh projects`,disabled:a,onClick:()=>void s(),className:`btn-ghost inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground outline-none transition-[box-shadow,color,translate] hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px disabled:opacity-60 max-md:size-11`,children:a?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-4`}):(0,R.jsx)(qh,{"aria-hidden":`true`,className:`size-4`})})}),(0,R.jsx)(Tj,{side:`bottom`,children:`Refresh projects`})]}):null]})}function K0({state:e}){return e===`live`?(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`span`,{role:`img`,"aria-label":`Connected`,className:`grid size-6 place-items-center`,children:(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-success`})})}),(0,R.jsx)(Tj,{children:`Connected`})]}):e===`connecting`?(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),`reconnecting…`]}):(0,R.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Connection lost`})}var q0=`toolbar-button inline-flex size-8 shrink-0 items-center justify-center rounded-lg border text-foreground transition-[background-color,border-color,translate] duration-150 ease-snap outline-none focus-visible:ring-3 focus-visible:ring-ring/40 active:translate-y-px motion-reduce:active:translate-none`;function J0({label:e,hint:t,href:n,active:r,children:i}){return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`a`,{href:n,"aria-label":e,"aria-current":r?`page`:void 0,"aria-keyshortcuts":t,"aria-describedby":`focused-action-help`,className:q0,children:i})}),(0,R.jsxs)(Tj,{side:`bottom`,children:[e,` `,(0,R.jsx)(`span`,{className:`max-md:hidden`,children:(0,R.jsx)(rA,{chord:t})})]})]})}function Y0({hint:e,onHelp:t}){return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,"aria-haspopup":`dialog`,"aria-keyshortcuts":e,"aria-describedby":`focused-action-help`,onClick:t,className:q0,children:(0,R.jsx)(Ym,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsxs)(Tj,{side:`bottom`,children:[`Keyboard shortcuts `,(0,R.jsx)(rA,{chord:e})]})]})}function X0(){let e=xJ(),t=cA(`(max-width: 767.98px)`),n=t?`App sounds`:e?`Unmute prompt sounds`:`Mute prompt sounds`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":n,"aria-pressed":e,"aria-describedby":t?`app-sounds-help focused-action-help`:`focused-action-help`,className:q0,onClick:()=>yJ(!e),children:e?(0,R.jsx)(Fg,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,R.jsx)(Ng,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsx)(Tj,{side:`bottom`,children:n})]}),t?(0,R.jsx)(`span`,{id:`app-sounds-help`,className:`sr-only`,children:`App sounds controls prompt tones and navigation ticks.`}):null]})}function Z0(){let{theme:e,setTheme:t}=vY(),n=e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":n?`Switch to light mode`:`Switch to dark mode`,"aria-keyshortcuts":`D`,"aria-describedby":`focused-action-help`,onClick:()=>t(n?`light`:`dark`),className:q0,children:n?(0,R.jsx)(_g,{"aria-hidden":`true`,className:`size-[1.05rem]`}):(0,R.jsx)(Th,{"aria-hidden":`true`,className:`size-[1.05rem]`})})}),(0,R.jsxs)(Tj,{side:`bottom`,children:[n?`Light mode`:`Dark mode`,` `,(0,R.jsx)(`span`,{className:`max-md:hidden`,children:(0,R.jsx)(rA,{chord:`D`})})]})]})}function Q0({busy:e,task:t,sessionName:n}){return(0,R.jsxs)(`div`,{className:`mr-1 flex min-w-0 items-center gap-2 text-[0.8125rem]`,children:[e?(0,R.jsx)(pj,{"aria-hidden":`true`,role:`presentation`,className:`size-3.5`}):null,t?(0,R.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate md:inline`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.id}),(0,R.jsxs)(`span`,{className:`hidden text-muted-foreground min-[1500px]:inline`,children:[` · `,t.state.replace(/_/g,` `)]})]}):(0,R.jsx)(`span`,{className:`hidden max-w-[10rem] truncate text-muted-foreground min-[1500px]:inline`,children:n??`no task in this session`})]})}function $0(e){if(!e)return 0;let t=[...e.children].filter(e=>e instanceof HTMLElement&&e.offsetParent!==null&&getComputedStyle(e).position!==`absolute`);if(!t.length)return 0;let n=Math.min(...t.map(e=>e.getBoundingClientRect().left)),r=Math.max(...t.map(e=>e.getBoundingClientRect().right)),i=0;for(let t of e.querySelectorAll(`*`))t.clientWidth<=1||t.offsetParent===null||t.scrollWidth<=t.clientWidth+1||getComputedStyle(t).textOverflow===`ellipsis`&&(i+=t.scrollWidth-t.clientWidth);return r-n+i}var e2=24;function t2(){let e=(0,m.useRef)(null),[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(()=>{});return r.current=()=>{let t=e.current;if(!t)return;let r=t.querySelector(`[role="tablist"]`),i=getComputedStyle(t),a=parseFloat(i.columnGap)||0,o=t.clientWidth-(parseFloat(i.paddingLeft)||0)-(parseFloat(i.paddingRight)||0),s=$0(t.querySelector(`.where`))+(r?.offsetWidth??0)+$0(t.querySelector(`.tools`))+a*2;n(s+e2<=o)},(0,m.useLayoutEffect)(()=>r.current()),(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>r.current());n.observe(t);for(let e of t.querySelectorAll(`[role="tablist"], .where, .tools`))n.observe(e);return()=>n.disconnect()},[]),{header:e,one:t}}function n2({status:e,task:t,connection:n,route:r,tabs:i,extra:a,keys:o,onHelp:s}){let c=e?.workspace.name??`bot-lobby`,l=e?.branch??e?.workspace.branch,u=e?.busy??!1,d=V0(),{header:f,one:p}=t2(),m=cA(`(max-width: 767.98px)`);return(0,R.jsxs)(`header`,{ref:f,className:`app-header shrink-0`,"data-one-row":p||void 0,children:[(0,R.jsx)(`div`,{className:`where flex min-w-0 items-center`,children:(0,R.jsx)(G0,{projects:d,tab:r.kind===`tab`?r.tab:r.kind,name:c,branch:l})}),m?(0,R.jsxs)(`div`,{className:`phone-status flex min-w-0 items-center justify-end gap-2`,children:[(0,R.jsx)(Q0,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,R.jsx)(K0,{state:n})]}):null,(0,R.jsx)(`div`,{className:`tabs min-w-0`,children:i}),(0,R.jsxs)(`div`,{className:`tools flex min-w-0 items-center justify-end gap-2`,children:[a,m?null:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(Q0,{busy:u,...t?{task:t}:{},...e?.sessionName?{sessionName:e.sessionName}:{}}),(0,R.jsx)(K0,{state:n})]}),(0,R.jsx)(J0,{label:`Sessions`,hint:o.sessions??`Alt+O`,href:`#/sessions`,active:r.kind===`sessions`,children:(0,R.jsx)(Zm,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),(0,R.jsx)(J0,{label:`Settings`,hint:o.settings??`Alt+S`,href:`#/settings`,active:r.kind===`settings`,children:(0,R.jsx)(sg,{"aria-hidden":`true`,className:`size-[1.05rem]`})}),m?null:(0,R.jsx)(Y0,{hint:o.help??`Alt+H`,onHelp:s}),(0,R.jsx)(Z0,{}),(0,R.jsx)(X0,{}),(0,R.jsx)(`span`,{id:`focused-action-help`,className:`sr-only`,children:`Focused buttons: Enter or Space. Links: Enter. Checkboxes: Space.`})]}),(0,R.jsx)(U0,{projects:d})]})}function r2(e){let t=e.match(/[#&?]?token=([^&\s#]+)/i);if(t?.[1])return decodeURIComponent(t[1]);let n=e.trim();return n&&!n.includes(`/`)&&!n.includes(` `)?n:void 0}function i2(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(!1);async function o(e){a(!0),r(void 0),e&&(window.location.hash=`token=${encodeURIComponent(e)}`),await De()?window.location.reload():(r(e?`That link did not sign in. Copy the link from Pi and try again.`:`Paste the link from Pi below.`),a(!1))}function s(t){t.preventDefault(),o(r2(e))}return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6 max-md:items-start max-md:p-4`,children:(0,R.jsxs)(`form`,{onSubmit:s,className:`glass flex min-h-0 w-full max-w-md flex-col gap-4 rounded-xl p-6 max-md:max-h-[calc(100svh-2rem)] max-md:max-w-[28rem] max-md:overflow-y-auto max-md:p-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(qm,{className:`size-5`,"aria-hidden":`true`}),(0,R.jsx)(`h1`,{className:`text-base font-medium`,children:`Sign in to bot-lobby`})]}),(0,R.jsxs)(`p`,{className:`break-words text-sm text-muted-foreground`,children:[`Pi printed a link when it started (or run `,(0,R.jsx)(`code`,{className:`rounded-lg bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`/bot-lobby web`}),`to see it again). Paste it here.`]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Lobby link or token`}),(0,R.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),autoComplete:`off`,spellCheck:!1,placeholder:`http://127.0.0.1:7347/#token=…`,className:`h-8 min-w-0 rounded-lg border border-input bg-background px-3.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 max-md:h-11`})]}),n?(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:n}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void o(void 0),className:`max-md:min-h-11`,children:`Retry`}),(0,R.jsx)(Y,{type:`submit`,disabled:i||!e.trim(),className:`max-md:min-h-11`,children:`Sign in`})]})]})})}var a2=.6;function o2(e,t,n={}){return{initial:e?void 0:!1,animate:t,transition:{duration:a2,...n}}}var s2=(e,t)=>[0,Math.max(e,.001),Math.min(Math.max(t,e+.01),.999),1];function c2(e,t=0,n=1){return o2(e,{pathLength:[0,0,1,1],strokeOpacity:[0,0,1,1]},{pathLength:{duration:a2,times:s2(t,n),ease:`easeInOut`},strokeOpacity:{duration:a2,times:s2(t,t+.02)}})}function l2(e,t){return o2(e,{scale:[0,0,1.3,1]},{times:s2(t,t+.18),ease:`easeOut`})}function u2(e,t,n=1.3){return o2(e,{scale:[1,1,n,1,1]},{times:[0,Math.max(t,.001),Math.min(t+.15,.9),Math.min(t+.35,.99),1],ease:`easeInOut`})}var d2=(e=.5,t=.5)=>({transformBox:`fill-box`,originX:e,originY:t});function f2({play:e}){return(0,R.jsxs)(B.g,{style:d2(.1,.9),...o2(e,{rotate:[0,-12,8,-4,0],scale:[1,1.12,.96,1.02,1]},{ease:`easeInOut`}),children:[(0,R.jsx)(`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`}),[8,12,16].map((t,n)=>(0,R.jsx)(B.circle,{cx:t,cy:11,r:1.15,fill:`currentColor`,stroke:`none`,...o2(e,{fillOpacity:[0,0,1,1,0],y:[0,0,-1.5,0,0]},{times:[0,.12+n*.12,.24+n*.12,.72,1]})},t))]})}function p2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.path,{d:`M13 5h8`,...c2(e,.15,.45)}),(0,R.jsx)(B.path,{d:`M13 12h8`,...c2(e,.3,.6)}),(0,R.jsx)(B.path,{d:`M13 19h8`,...c2(e,.45,.75)}),(0,R.jsx)(B.path,{d:`m3 17 2 2 4-4`,...c2(e,.35,.7)}),(0,R.jsx)(B.path,{d:`m3 7 2 2 4-4`,...c2(e,0,.35)})]})}function m2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:6,cy:19,r:3,style:d2(),...u2(e,0)}),(0,R.jsx)(B.path,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,...c2(e,.1,.7)}),(0,R.jsx)(B.circle,{cx:18,cy:5,r:3,style:d2(),...l2(e,.62)})]})}function h2({play:e}){return(0,R.jsx)(B.g,{style:d2(),...o2(e,{rotate:[0,-14,10,-6,0],scale:[1,1.18,.94,1.04,1]},{duration:.5,ease:`easeInOut`}),children:(0,R.jsx)(B.path,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,fill:`currentColor`,...o2(e,{fillOpacity:[0,.85,0]},{duration:.5,times:[0,.2,1]})})})}function g2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:12,cy:12,r:10,style:d2(),...o2(e,{scale:[1,1,1.4],strokeOpacity:[0,.5,0]},{times:[0,.25,1],ease:`easeOut`})}),(0,R.jsx)(B.circle,{cx:12,cy:12,r:10,style:d2(),...o2(e,{scale:[1,.86,1.06,1]},{times:[0,.25,.55,1],ease:`easeInOut`})}),(0,R.jsx)(B.circle,{cx:12,cy:12,r:1,fill:`currentColor`,style:d2(),...o2(e,{scale:[1,2.4,.8,1]},{times:[0,.3,.6,1],ease:`easeInOut`})})]})}function _2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`}),[`M8 17v-3`,`M13 17V5`,`M18 17V9`].map((t,n)=>(0,R.jsx)(B.path,{d:t,style:d2(.5,1),...o2(e,{scaleY:[0,0,1.18,1]},{times:s2(.08+n*.14,.4+n*.14),ease:`easeOut`})},t))]})}function v2({play:e}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B.circle,{cx:6,cy:6,r:3,style:d2(),...u2(e,0)}),(0,R.jsx)(B.line,{x1:6,x2:6,y1:9,y2:21,...c2(e,.05,.45)}),(0,R.jsx)(B.path,{d:`M13 6h3a2 2 0 0 1 2 2v7`,...c2(e,.2,.62)}),(0,R.jsx)(B.circle,{cx:18,cy:18,r:3,style:d2(),...l2(e,.58)})]})}function y2({play:e}){return(0,R.jsxs)(B.g,{style:d2(),...o2(e,{scaleX:[1,.55,1.08,1],y:[0,-1,0,0]},{times:[0,.35,.65,1],ease:`easeInOut`}),children:[(0,R.jsx)(B.path,{d:`M12 5v16`,style:d2(),...o2(e,{scaleY:[1,1.12,1,1]},{times:[0,.35,.65,1]})}),(0,R.jsx)(`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`})]})}function b2({play:e}){return(0,R.jsxs)(B.g,{style:d2(.6,.6),...o2(e,{x:[0,1.5,-1.5,1,0],y:[0,-1,.5,-.5,0],rotate:[0,-8,6,-3,0]},{ease:`easeInOut`}),children:[(0,R.jsx)(`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`}),(0,R.jsx)(`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`}),(0,R.jsx)(B.path,{d:`m2.3 2.3 7.286 7.286`,...c2(e,.1,.6)}),(0,R.jsx)(B.circle,{cx:11,cy:11,r:2,style:d2(),...u2(e,.5,1.5)})]})}var x2={lobby:f2,tasks:p2,plan:m2,quickfix:h2,issues:g2,metrics:_2,git:v2,knowledge:y2,excalidraw:b2};function S2({id:e,play:t,className:n}){let r=x2[e];return r?(0,R.jsx)(`svg`,{"aria-hidden":`true`,"data-tab-icon":e,"data-play":t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:q(`overflow-visible`,n),children:(0,R.jsx)(r,{play:t})},t):null}function C2(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0||n<2)return e;let r=Math.floor(n/2),i=(r-.75)*t,a=(r+1.75)*t;return e<i?e+Math.ceil((i-e)/t)*t:e>a?e-Math.ceil((e-a)/t)*t:e}function w2(e){return/(\d)$/.exec(e)?.[1]}function T2(e){return e.filter(e=>e.id!==`metrics`)}function E2(e,t,n=5){return C2(e,t,n)}function D2(e,t,n){let r=t.find(t=>t.id===e);if(r)return r.label;let i=n.replace(/^#\/?/,``).split(`/`)[0];return i===`settings`?`Settings`:i===`sessions`?`Sessions`:i===`metrics`?`Metrics`:i?i.charAt(0).toUpperCase()+i.slice(1):`Lobby`}var O2=`phone-tab-card inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-xl border px-2.5 text-sm font-medium whitespace-nowrap outline-none focus-visible:ring-3 focus-visible:ring-ring/40`;function k2(e){let t=w2(e.key);return t?`${t}. ${e.label}`:e.label}function A2(e,t){let n=w2(e.key);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(S2,{id:e.id,play:+!!t,className:`size-4 shrink-0`}),n?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`text-[0.7rem] font-semibold tabular-nums text-muted-foreground`,children:n}):null,t?(0,R.jsx)(`span`,{className:`max-w-[8.5rem] truncate`,children:e.label}):null]})}function j2(e){return e?{duration:0}:{type:`spring`,stiffness:520,damping:30,mass:.5}}function M2({tab:e,selected:t,reduced:n}){return(0,R.jsx)(B.span,{className:`inline-flex items-center gap-1.5`,animate:{scale:t?1.04:1},transition:j2(n),children:A2(e,t)})}function N2({tab:e,selected:t,canonical:n,reduced:r,onClick:i,roving:a}){let o=k2(e);return n?(0,R.jsx)(`button`,{type:`button`,role:`tab`,id:`tab-${e.id}`,"data-phone-tab-id":e.id,"aria-controls":`main`,"aria-label":o,"aria-keyshortcuts":e.key,"aria-selected":t,tabIndex:t||a?0:-1,onClick:i,className:O2,children:(0,R.jsx)(M2,{tab:e,selected:t,reduced:r})}):(0,R.jsx)(`span`,{"data-phone-tab-id":e.id,"data-active":t?`true`:`false`,className:O2,"aria-hidden":`true`,children:(0,R.jsx)(M2,{tab:e,selected:t,reduced:r})})}function P2({tabs:e,activeId:t,canonical:n,reduced:r,onClick:i,canonicalRef:a}){let o=t??e[0]?.id;return(0,R.jsx)(`div`,{ref:n?a:void 0,"data-phone-period":n?`canonical`:`copy`,"aria-hidden":!n||void 0,role:n?`tablist`:void 0,"aria-label":n?`Lobby tabs`:void 0,className:`phone-tabs-period`,children:e.map(e=>(0,R.jsx)(N2,{tab:e,selected:e.id===t,canonical:n,reduced:r,roving:e.id===o,onClick:t=>i(e.id,t)},e.id))})}function F2(e){return e<=0?0:e===1?1:5}function I2({tabs:e,activeId:t,reduced:n,onClick:r,canonicalRef:i}){let a=F2(e.length),o=Math.floor(a/2);return a?(0,R.jsx)(R.Fragment,{children:Array.from({length:a},(a,s)=>(0,R.jsx)(P2,{tabs:e,activeId:t,canonical:s===o,reduced:n,onClick:r,canonicalRef:s===o?i:void 0},s))}):null}function L2(e){e.current!==void 0&&window.clearTimeout(e.current),e.current=void 0}function R2(e){return e?.closest(`[data-phone-tab-id]`)?.dataset.phoneTabId}function z2(e){return R2(e.target instanceof Element?e.target:null)}function B2(e){return R2(document.elementFromPoint(e.clientX,e.clientY))??R2(e.target instanceof Element?e.target:null)}function V2(e,t){let n=e.dataset.phoneTabId;if(!n)return;let r=e.getBoundingClientRect();if(Number.isFinite(r.width))return{id:n,element:e,distance:Math.abs(r.left+r.width/2-t)}}function H2(e,t){return[...e.querySelectorAll(`[data-phone-tab-id]`)].map(e=>V2(e,t)).filter(e=>e!==void 0)}function U2(e){return e.reduce((e,t)=>!e||t.distance<e.distance?t:e,void 0)}function W2(e,t){return U2(H2(t,e.getBoundingClientRect().left+e.clientWidth/2))}function G2(e,t){if(e&&t)return[...e.querySelectorAll(`[data-phone-tab-id]`)].find(e=>e.dataset.phoneTabId===t)}function K2(e){let t=Number.parseFloat(getComputedStyle(e.parentElement??e).columnGap)||6;return e.offsetWidth+t}function q2(e,t,n){let r=Math.max(0,n.findIndex(e=>e.id===t));if(e===`Home`)return n[0]?.id;if(e===`End`)return n.at(-1)?.id;if(e===`ArrowRight`)return n[(r+1)%n.length]?.id;if(e===`ArrowLeft`)return n[(r-1+n.length)%n.length]?.id}function J2(e,t){return Math.abs(e-t)<=2}function Y2(){let e=(0,m.useRef)(null),t=(0,m.useRef)(null),n=(0,m.useRef)(null),r=(0,m.useRef)(void 0),i=(0,m.useRef)(void 0),a=(0,m.useRef)(void 0),o=(0,m.useRef)(void 0),s=(0,m.useRef)(void 0),c=(0,m.useRef)(void 0),l=(0,m.useRef)(0),u=(0,m.useRef)(0),d=(0,m.useRef)(void 0);return(0,m.useMemo)(()=>({scroller:e,track:t,canonical:n,gesture:r,candidate:i,crossed:a,settleTimer:o,commitTimer:s,clickGuard:c,generation:l,scrollGeneration:u,programmatic:d}),[])}function X2(e){return{clearPending:(0,m.useCallback)(()=>{L2(e.settleTimer),L2(e.commitTimer),e.candidate.current=void 0,e.generation.current+=1},[e])}}function Z2(e){let t=(0,m.useCallback)(t=>{let n=e.scroller.current;if(!n)return;let r=e.scrollGeneration.current+1;e.scrollGeneration.current=r;let i={value:Math.max(0,t),generation:r};e.programmatic.current=i,n.scrollLeft=i.value,i.value=n.scrollLeft},[e]),n=(0,m.useCallback)(n=>{let r=e.scroller.current;if(!r||!n||r.clientWidth<=0)return;let i=r.getBoundingClientRect(),a=n.getBoundingClientRect(),o=r.scrollLeft+a.left+a.width/2-(i.left+r.clientWidth/2);t(o)},[e,t]);return{centre:n,centreCanonical:(0,m.useCallback)(t=>{let r=G2(e.canonical.current,t);r&&(e.crossed.current=r),n(r)},[n,e]),rebase:(0,m.useCallback)((n,r)=>{let i=E2(n.scrollLeft,K2(r));if(J2(i,n.scrollLeft))return!1;let a=i-n.scrollLeft;return e.gesture.current&&(e.gesture.current.originScrollLeft+=a),t(i),!0},[e,t])}}function Q2(e){let t=(0,m.useCallback)(()=>{e.clickGuard.current=void 0},[e]);return{clearGuard:t,guardClick:(0,m.useCallback)(n=>{t(),e.clickGuard.current={kind:n}},[t,e]),consumeGuard:(0,m.useCallback)(n=>!n||!e.clickGuard.current?!1:(t(),!0),[t,e])}}function $2(e){return(0,m.useCallback)(()=>{let t=e.scroller.current,n=e.track.current;if(!t||!n)return;let r=W2(t,n);return r&&r.element!==e.crossed.current&&(e.crossed.current=r.element,wJ()),e.candidate.current=r,r},[e])}function e4(e,t,n,r,i){let a=(0,m.useCallback)((r,i)=>{r&&r.id!==e.activeId&&(L2(t.commitTimer),t.commitTimer.current=window.setTimeout(()=>{i!==t.generation.current||t.candidate.current?.element!==r.element||e.blocked||(n(),e.onSelect(r.id))},500))},[n,e,t]);return(0,m.useCallback)(()=>{L2(t.settleTimer),L2(t.commitTimer);let e=++t.generation.current;t.settleTimer.current=window.setTimeout(()=>{if(e!==t.generation.current||t.gesture.current)return;let n=r();n&&(i(n.element),a(n,e))},120)},[a,i,r,t])}function t4(e,t,n){return(0,m.useCallback)(r=>e.tabs.some(e=>e.id===r)?(t(),e.onSelect(r),n(r),!0):!1,[n,t,e])}function n4(e,t,n,r){return(0,m.useCallback)(()=>{let i=e.scroller.current,a=e.canonical.current;if(!i||!a)return;let o=e.programmatic.current;if(o&&o.generation===e.scrollGeneration.current&&J2(i.scrollLeft,o.value)){e.programmatic.current=void 0;return}if(e.programmatic.current=void 0,L2(e.commitTimer),L2(e.settleTimer),e.candidate.current=void 0,e.generation.current+=1,t(i,a)){e.gesture.current||r();return}n(),e.gesture.current||r()},[n,t,e,r])}function r4(e,t,n,r){let i=(0,m.useRef)({clearPending:t,settle:n});i.current={clearPending:t,settle:n},(0,m.useEffect)(()=>{let t=e.scroller.current;if(!r||!t)return;let n=n=>{let r=n.deltaX||(n.shiftKey?n.deltaY:0);r&&(n.preventDefault(),e.programmatic.current=void 0,i.current.clearPending(),t.scrollLeft+=r,i.current.settle())};return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[r,e])}function i4(e,t,n){return(0,m.useCallback)(r=>{t(),n(),e.programmatic.current=void 0,e.gesture.current={id:r.pointerId,x:r.clientX,y:r.clientY,moved:!1,originScrollLeft:r.currentTarget.scrollLeft,downTabId:z2(r)},r.currentTarget.setPointerCapture?.(r.pointerId)},[n,t,e])}function a4(e,t){return(0,m.useCallback)(n=>{let r=e.gesture.current;r&&r.id===n.pointerId&&(Math.hypot(n.clientX-r.x,n.clientY-r.y)<8||(r.moved=!0,t(),(n.pointerType===`mouse`||n.pointerType===`pen`)&&(n.currentTarget.scrollLeft=r.originScrollLeft+r.x-n.clientX,n.preventDefault())))},[t,e])}function o4(e,t,n,r){return(0,m.useCallback)(i=>{let a=e.gesture.current;if(!a||a.id!==i.pointerId)return;e.gesture.current=void 0;let o=B2(i),s=a.downTabId;if(s&&!a.moved&&(!o||o===s)){n.guardClick(`committed`),t(s);return}(a.moved||s&&o&&o!==s)&&n.guardClick(`drag`),a.moved&&r()},[t,n,e,r])}function s4(e,t,n){return(0,m.useCallback)(()=>{let r=e.gesture.current?.moved;e.gesture.current=void 0,r&&t.guardClick(`drag`),r&&n()},[t,e,n])}function c4(e,t,n,r,i){return{onPointerDown:i4(e,i,n.clearGuard),onPointerMove:a4(e,i),onPointerUp:o4(e,t,n,r),onPointerCancel:s4(e,n,r)}}function l4(e,t){return(0,m.useCallback)((n,r)=>{t.consumeGuard(r.detail!==0)||e(n)},[e,t])}function u4(e,t){return(0,m.useCallback)(n=>{if(t.consumeGuard(n.detail!==0))return;let r=n.target instanceof Element?n.target.closest(`[data-phone-tab-id]`):null;if(!r||r.closest(`button`))return;let i=r.dataset.phoneTabId;i&&e(i)},[e,t])}function d4(e,t,n){return(0,m.useCallback)(r=>{if(r.key===`ArrowDown`&&!r.altKey){Ij()&&r.preventDefault();return}if(!e.tabs.length)return;let i=r.target.closest(`[role='tab']`)?.dataset.phoneTabId??e.activeId??e.tabs[0].id,a=q2(r.key,i,e.tabs);a?(r.preventDefault(),Rj.active=!0,Rj.to=a,n(a),G2(t.canonical.current,a)?.focus({preventScroll:!0})):(r.key===`Enter`||r.key===` `)&&i&&(r.preventDefault(),n(i))},[n,e,t])}function f4(e){let[t,n]=(0,m.useState)(0),[r,i]=(0,m.useState)(!1);return{sidePad:t,peek:r,setPeek:i,updatePad:(0,m.useCallback)(()=>{let t=e.scroller.current;if(!t||t.clientWidth<=0)return;let r=Math.max(22,t.clientWidth/2);n(e=>Math.abs(e-r)<.5?e:r)},[e])}}function p4(e,t){return e.find(e=>e.id===t)?.id??e[0]?.id}function m4(e,t,n,r){let{activeId:i,keyboardOpen:a,tabs:o}=e;(0,m.useLayoutEffect)(()=>{n(),t(p4(o,i))},[i,t,a,o,n,r])}function h4(e,t,n,r,i){let{activeId:a,tabs:o}=e;(0,m.useEffect)(()=>{let e=t.scroller.current;if(!e||typeof ResizeObserver>`u`)return;let s=new ResizeObserver(()=>{e.clientWidth<=0||(n(),i(),r(p4(o,a)))});return s.observe(e),t.track.current&&s.observe(t.track.current),()=>s.disconnect()},[a,r,n,t,o,i])}function g4(e){(0,m.useEffect)(()=>{let t=()=>e();return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},[e])}function _4(e,t,n,r){(0,m.useEffect)(()=>{n(),t.crossed.current=void 0},[n,e.activeId,e.blocked,e.keyboardOpen,t,r])}function v4(e,t,n){(0,m.useEffect)(()=>()=>{t(),n(),e.programmatic.current=void 0},[n,t,e])}function y4(e,t,n){(0,m.useEffect)(()=>{e.keyboardOpen||n(!1),t()},[t,e.blocked,e.keyboardOpen,n])}function b4(e){let t=Y2(),{clearPending:n}=X2(t),r=Z2(t),i=Q2(t),a=f4(t),o=$2(t),s=e4(e,t,n,o,r.centre),c=t4(e,n,r.centreCanonical),l=n4(t,r.rebase,o,s),u=c4(t,c,i,s,n);r4(t,n,s,e.tabs.length>0);let d=d4(e,t,c),f=u4(c,i),p=l4(c,i),m=e.tabs.map(e=>e.id).join(`\0`);return m4(e,r.centreCanonical,a.updatePad,!e.keyboardOpen||a.peek),h4(e,t,n,r.centreCanonical,a.updatePad),_4(e,t,n,m),g4(n),v4(t,n,i.clearGuard),y4(e,n,a.setPeek),{scroller:t.scroller,track:t.track,canonical:t.canonical,sidePad:a.sidePad,periods:F2(e.tabs.length),peek:a.peek,setPeek:a.setPeek,onScroll:l,...u,onSurfaceClick:f,onCardClick:p,onKeyDown:d}}function x4(e,t){return D2(e,t,window.location.hash)}function S4({tabs:e,activeId:t,onSelect:n}){let r=(0,m.useMemo)(()=>T2(e),[e]),i=QA(),{keyboardOpen:a}=BA(),o=!!xf(),s=x4(t,e),c=b4({tabs:r,activeId:t,blocked:i,keyboardOpen:a,reduced:o,onSelect:n});if(!r.length)return null;let l=a&&!c.peek;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{"aria-hidden":l?`true`:void 0,inert:l,hidden:l,children:(0,R.jsx)(w4,{tabs:r,activeId:t,label:s,reduced:o,carousel:c,keyboardOpen:a})}),l?(0,R.jsx)(C4,{label:s,onOpen:()=>c.setPeek(!0)}):null]})}function C4({label:e,onOpen:t}){return(0,R.jsx)(`div`,{className:`phone-tabs phone-tabs-handle`,children:(0,R.jsxs)(`button`,{type:`button`,"data-phone-tabs-handle":!0,"aria-expanded":`false`,"aria-label":`Open tabs, current page ${e}`,onPointerDown:e=>e.preventDefault(),onClick:t,className:`phone-tabs-current inline-flex min-h-11 items-center gap-2 rounded-xl border px-4 text-sm font-medium focus-visible:ring-3 focus-visible:ring-ring/40`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})]})})}function w4({tabs:e,activeId:t,label:n,reduced:r,carousel:i,keyboardOpen:a}){return(0,R.jsxs)(`div`,{className:`phone-tabs`,"data-phone-tabs":!0,"data-periods":i.periods,children:[t&&!e.some(e=>e.id===t)?(0,R.jsx)(`span`,{"data-phone-page-handle":!0,className:`phone-tabs-page-handle`,children:n}):null,(0,R.jsx)(`div`,{ref:i.scroller,className:`phone-tabs-scroller`,onScroll:i.onScroll,onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp,onPointerCancel:i.onPointerCancel,onClick:i.onSurfaceClick,children:(0,R.jsx)(`div`,{ref:i.track,className:`phone-tabs-track`,style:{"--phone-period-pad":`${i.sidePad}px`},onKeyDown:i.onKeyDown,children:(0,R.jsx)(I2,{tabs:e,activeId:t,reduced:r,onClick:i.onCardClick,canonicalRef:i.canonical})})}),a&&i.peek?(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close tabs`,onPointerDown:e=>e.preventDefault(),onClick:()=>i.setPeek(!1),className:`phone-tabs-close`,children:(0,R.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})}):null]})}function T4(e){return/(\d)$/.exec(e)?.[1]}var E4=160;function D4(e){let t=xf(),[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useCallback)(()=>{t||performance.now()<i.current||(i.current=performance.now()+a2*1e3,r(e=>e+1))},[t]),o=(0,m.useRef)(e);return(0,m.useEffect)(()=>{let t=e&&!o.current;if(o.current=e,!t)return;let n=window.setTimeout(a,E4);return()=>window.clearTimeout(n)},[e,a]),{play:n,onPointerEnter:(0,m.useCallback)(e=>{e.pointerType!==`touch`&&a()},[a])}}var O4=(0,m.forwardRef)(function({tab:e,active:t},n){let r=T4(e.key),{play:i,onPointerEnter:a}=D4(t);return(0,R.jsxs)(Cj,{children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsxs)(`a`,{ref:n,role:`tab`,id:`tab-${e.id}`,href:`#/${e.id}`,"aria-selected":t,"aria-keyshortcuts":e.key,tabIndex:t?0:-1,onPointerEnter:a,className:q(`relative z-10 inline-flex h-7.5 shrink-0 items-center gap-1.5 rounded-lg border border-[var(--tab-outline)] px-2.5 text-[0.8125rem] leading-none font-medium whitespace-nowrap outline-none`,`transition-colors duration-200 ease-snap focus-visible:ring-3 focus-visible:ring-ring/40`,t?`text-foreground`:`bg-[var(--tab-idle)] text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(S2,{id:e.id,play:i,className:q(`size-3.5 shrink-0 transition-colors duration-200`,t&&`text-primary`)}),r?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:q(`text-[0.72rem] font-semibold tabular-nums transition-colors duration-200`,t?`text-primary`:`text-muted-foreground/75`),children:r}):null,(0,R.jsx)(`span`,{children:e.label})]})}),(0,R.jsxs)(Tj,{children:[e.label,` `,(0,R.jsx)(rA,{chord:e.key})]})]})}),k4=1.5;function A4(e,t,n=t?.left??0,r=t?.right??0,i=1){if(e){if(!t||r-n<.5){e.style.opacity=`0`;return}e.style.opacity=String(Math.min(1,(r-n)/14)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${r-n}px`,e.style.transform=`translateX(${n}px)`,e.style.scale=i===1?``:`1 ${i}`}}function j4(e,t){let n=e.right-e.left,{height:r}=e,i=k4/2,a=Math.max(0,Math.min(e.radius-i,r/2-i,n/2-i)),o=r/2,s=e=>+(t===`left`?e:n-e).toFixed(2),c=+(t===`left`),l=1-c,u=i,d=n-i,f=r-i;return[`M${s(u)} ${o}L${s(u)} ${i+a}A${a} ${a} 0 0 ${c} ${s(u+a)} ${i}L${s(d-a)} ${i}A${a} ${a} 0 0 ${c} ${s(d)} ${i+a}L${s(d)} ${o}`,`M${s(u)} ${o}L${s(u)} ${f-a}A${a} ${a} 0 0 ${l} ${s(u+a)} ${f}L${s(d-a)} ${f}A${a} ${a} 0 0 ${l} ${s(d)} ${f-a}L${s(d)} ${o}`]}function M4(e,t,n,r){if(!e)return;if(!t||r<=.002){e.style.opacity=`0`;return}let i=t.right-t.left,a=`${i}x${t.height}r${t.radius}${n}`;e.dataset.shape!==a&&(e.dataset.shape=a,e.dataset.port=n,e.setAttribute(`viewBox`,`0 0 ${i} ${t.height}`),j4(t,n).forEach((t,n)=>e.children[n]?.setAttribute(`d`,t))),e.style.opacity=String(Math.min(1,r*12)),e.style.top=`${t.top}px`,e.style.height=`${t.height}px`,e.style.width=`${i}px`,e.style.transform=`translateX(${t.left}px)`;let o=`${Math.min(1,r)} 2`;for(let t of e.children)t.style.strokeDasharray=o}var N4={type:`spring`,visualDuration:.12,bounce:0},P4={type:`spring`,visualDuration:.17,bounce:.15,delay:.015},F4={type:`spring`,visualDuration:.17,bounce:.05,delay:.07},I4={type:`spring`,visualDuration:.22,bounce:.25},L4={type:`spring`,visualDuration:.2,bounce:0},R4={type:`spring`,stiffness:900,damping:18,velocity:45,restDelta:.02,restSpeed:1},z4=(()=>{let e=Sr({keyframes:[0,1],visualDuration:I4.visualDuration,bounce:I4.bounce}),t=0;for(;t<1e3&&e.next(t).value<.97;)t+=4;return t/1e3})(),B4={type:`spring`,visualDuration:.28,bounce:.6};function V4(e,t){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(null),a=(0,m.useRef)(null),o=(0,m.useRef)(null),s=(0,m.useRef)({}),c=(0,m.useRef)([]),l=(0,m.useRef)(void 0),u=(0,m.useRef)([]),d=(0,m.useRef)(1),f=(0,m.useRef)(1),p=(0,m.useCallback)(e=>{let t=e?s.current[e]:void 0;if(!t)return;let n=parseFloat(getComputedStyle(t).borderTopLeftRadius)||0;return{left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,top:t.offsetTop,height:t.offsetHeight,radius:n}},[]),h=(0,m.useCallback)(()=>{for(let e of u.current)e.stop();u.current=[];for(let e of Object.values(s.current))e?.style.translate&&(e.style.translate=``)},[]),g=(0,m.useCallback)(e=>{h(),l.current=e,d.current=1,f.current=1;let t=p(e);A4(r.current,t),A4(i.current,void 0),M4(a.current,t,`left`,1),M4(o.current,void 0,`left`,0);for(let e of c.current)e&&(e.style.width=`0px`);MH()},[p,h]),_=(0,m.useCallback)((e,t)=>{let n=p(e),m=p(t);if(!n||!m)return g(t);h(),jH(),l.current=t;let _=m.left>n.left?1:-1,v=_>0?n.right:n.left,y=_>0?m.left:m.right,b=Math.abs(y-v),x=_>0?`right`:`left`,S=_>0?`left`:`right`,C=c.current.map(e=>{let t=e?.parentElement;return t?{liquid:e,from:t.offsetLeft,to:t.offsetLeft+t.offsetWidth}:void 0}),w=b>4?1-4/b:0,T={drained:1-Math.min(1,d.current),unrung:1-Math.min(1,f.current),head:0,tail:0,filled:0,rung:0,squash:1,budge:0},E=s.current[t];d.current=0,f.current=0;let D=()=>{let e=(n.right-n.left)*Math.min(1,T.drained);A4(i.current,n,_>0?n.left+e:n.left,_>0?n.right:n.right-e),M4(o.current,n,x,1-T.unrung);let t=v+_*b*T.head,s=v+_*b*T.tail,c=Math.min(t,s),l=Math.max(t,s);for(let e of C){if(!e?.liquid)continue;let t=Math.max(c,e.from),n=Math.min(l,e.to);e.liquid.style.width=`${Math.max(0,n-t)}px`,e.liquid.style.transform=`translateX(${Math.max(0,t-e.from)}px)`}let u=_*T.budge,d=u?{...m,left:m.left+u,right:m.right+u}:m;E&&(E.style.translate=Math.abs(u)>.01?`${u.toFixed(2)}px`:``);let f=(d.right-d.left)*Math.min(1,Math.max(0,T.filled));A4(r.current,d,_>0?d.left:d.right-f,_>0?d.left+f:d.right,Math.min(1,T.squash)),M4(a.current,d,S,T.rung)},O=(e,t,n,r,i=1)=>{let a=Wf(t,i,{...n,onUpdate:t=>{T[e]=t,r?.(t),D()}});return u.current.push(a),a},k=!1,A=()=>{if(k)return;k=!0;let e=O(`filled`,0,I4,e=>{d.current=e});e.then(()=>{l.current===t&&MH()}),O(`squash`,.8,B4),O(`rung`,0,L4,e=>{f.current=e}),O(`budge`,0,{...R4,delay:z4},void 0,0),Promise.all([e,...u.current]).then(()=>{l.current===t&&u.current.includes(e)&&g(t)})};O(`drained`,T.drained,N4),O(`unrung`,T.unrung,N4),O(`head`,0,P4,e=>{e>=w&&A()}),O(`tail`,0,F4),D()},[p,g,h]);(0,m.useLayoutEffect)(()=>{let t=l.current,n=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;!t||!e||t===e||n?g(e):_(t,e)},[e,t,_,g]);let v=(0,m.useRef)(e);return v.current=e,(0,m.useEffect)(()=>{let e=n.current;if(!e||typeof ResizeObserver>`u`)return;let t=!0,r=new ResizeObserver(()=>{if(t){t=!1;return}g(v.current)});return r.observe(e),()=>{r.disconnect(),h()}},[g,h]),{track:n,fill:r,drain:i,ring:a,unring:o,cells:s,liquids:c}}var H4=(0,m.forwardRef)(function({which:e},t){return(0,R.jsxs)(`svg`,{ref:t,"aria-hidden":`true`,[`data-tab-${e}`]:``,className:`pointer-events-none absolute left-0 z-20 overflow-visible opacity-0 will-change-transform`,fill:`none`,children:[(0,R.jsx)(`path`,{pathLength:1,strokeWidth:k4,strokeLinecap:`round`,className:`stroke-tab-rim`}),(0,R.jsx)(`path`,{pathLength:1,strokeWidth:k4,strokeLinecap:`round`,className:`stroke-tab-rim`})]})});function U4(e){if(e.left||e.right)return`linear-gradient(to right, ${e.left?`transparent 0, black 28px`:`black 0`}, ${e.right?`black calc(100% - 28px), transparent 100%`:`black 100%`})`}function W4({tabs:e,activeId:t,onSelect:n}){let r=cA(`(max-width: 767.98px)`),{track:i,fill:a,drain:o,ring:s,unring:c,cells:l,liquids:u}=V4(t,e.length),d=(0,m.useRef)(null),[f,p]=(0,m.useState)({left:!1,right:!1}),h=(0,m.useCallback)(()=>{let e=d.current;if(!e)return;let t=e.scrollLeft>2,n=e.scrollLeft+e.clientWidth<e.scrollWidth-2;p(e=>e.left===t&&e.right===n?e:{left:t,right:n})},[]);(0,m.useEffect)(()=>{let e=d.current;if(!e||typeof ResizeObserver>`u`)return;h();let t=new ResizeObserver(h);return t.observe(e),e.firstElementChild&&t.observe(e.firstElementChild),()=>t.disconnect()},[h,e.length]),(0,m.useEffect)(()=>{let e=d.current,n=t?l.current[t]:void 0;e&&n&&(n.offsetLeft<e.scrollLeft?e.scrollLeft=n.offsetLeft-8:n.offsetLeft+n.offsetWidth>e.scrollLeft+e.clientWidth&&(e.scrollLeft=n.offsetLeft+n.offsetWidth-e.clientWidth+8))},[t,l]);function g(r){if(r.key===`ArrowDown`&&!r.altKey){Ij()&&r.preventDefault();return}let i=r.key===`ArrowRight`?1:r.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;r.preventDefault();let a=r.target.closest(`[role='tab']`)?.id.replace(/^tab-/,``)??t,o=e[(Math.max(0,e.findIndex(e=>e.id===a))+i+e.length)%e.length];Rj.active=!0,Rj.to=o.id,window.setTimeout(()=>{Rj.active=!1,Rj.to=void 0},3e3),n(o.id),l.current[o.id]?.focus({preventScroll:!0})}return r?(0,R.jsx)(S4,{tabs:e,activeId:t,onSelect:n}):(0,R.jsx)(`div`,{ref:d,onScroll:h,style:{maskImage:U4(f),WebkitMaskImage:U4(f)},className:`min-w-0 max-w-full overflow-x-auto [scrollbar-width:none] pointer-coarse:-my-1.5 pointer-coarse:py-1.5 [&::-webkit-scrollbar]:hidden`,children:(0,R.jsxs)(`div`,{ref:i,role:`tablist`,"aria-label":`Lobby tabs`,onKeyDown:g,className:`relative mx-auto flex w-max items-center py-0.5`,children:[(0,R.jsx)(`span`,{ref:o,"aria-hidden":`true`,"data-tab-drain":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,R.jsx)(`span`,{ref:a,"aria-hidden":`true`,"data-tab-fill":!0,className:`pointer-events-none absolute left-0 z-0 rounded-lg bg-tab-fill opacity-0 will-change-transform`}),(0,R.jsx)(H4,{ref:c,which:`unring`}),(0,R.jsx)(H4,{ref:s,which:`ring`}),e.map((e,n)=>(0,R.jsxs)(m.Fragment,{children:[n>0?(0,R.jsxs)(`span`,{"aria-hidden":`true`,"data-tab-link":!0,className:`relative h-[2px] w-3.5 shrink-0 sm:w-4`,children:[(0,R.jsx)(`span`,{className:`absolute inset-0 border-t-2 border-dotted border-input`}),(0,R.jsx)(`span`,{ref:e=>{u.current[n-1]=e},"data-tab-liquid":!0,className:`absolute top-0 left-0 h-[2px] w-0 rounded-full bg-tab-liquid shadow-[0_0_6px_var(--tab-liquid)] will-change-transform`})]}):null,(0,R.jsx)(O4,{ref:t=>{l.current[e.id]=t},tab:e,active:e.id===t})]},e.id))]})})}function G4({oracleBusy:e,runs:t,activity:n,background:r}){let i=new Set;e&&i.add(`Oracle`);for(let e of t)e.status===`running`&&i.add(SW(EW(e)));for(let e of n)e.pending&&e.source!==`LOBBY`&&i.add(e.source===`MASTER`?`Oracle`:SW(e.source));let a=r.filter(e=>e.alive&&e.busy).length;return a&&i.add(a===1?`1 in the background`:`${a} in the background`),[...i]}function K4(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function q4(...e){let t=e.filter(e=>!!e);if(!t.length)return;let n=Math.max(...t.map(e=>e.left)),r=Math.max(...t.map(e=>e.top)),i=Math.min(...t.map(e=>e.left+e.width)),a=Math.min(...t.map(e=>e.top+e.height));return i>n&&a>r?{left:n,top:r,width:i-n,height:a-r}:void 0}function J4(e,t){return q4(e,{left:e.left,top:e.top,width:e.width,height:Math.max(0,t-e.top)})}var Y4=6,X4=`bot-lobby.orb`,Z4=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function Q4(e,t,n,r){let i=e=>e+Y4,a=(e,t)=>Math.max(e+Y4,e+t-r-Y4);return{x:Math.min(a(n.left,n.width),Math.max(i(n.left),e)),y:Math.min(a(n.top,n.height),Math.max(i(n.top),t))}}function $4(e,t,n,r){let i=e=>Math.max(1,e-r),a=Q4(e,t,n,r);return{fx:Math.min(1,Math.max(0,(a.x-n.left)/i(n.width))),fy:Math.min(1,Math.max(0,(a.y-n.top)/i(n.height)))}}function e3(e,t,n){return Q4(t.left+e.fx*Math.max(0,t.width-n),t.top+e.fy*Math.max(0,t.height-n),t,n)}function t3(e){if(e)try{let t=JSON.parse(e);return Z4(t.fx)&&Z4(t.fy)?{fx:t.fx,fy:t.fy}:void 0}catch{return}}function n3(){try{return t3(localStorage.getItem(X4))}catch{return}}function r3(e){try{localStorage.setItem(X4,JSON.stringify(e))}catch{}}var i3=5,a3=16,o3={fx:1,fy:1};function s3(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function c3(e){let t=document.getElementById(`main`)?.getBoundingClientRect();if(!t)return;if(!e)return s3(t);let n=window.visualViewport,r=s3({left:n?.offsetLeft??0,top:n?.offsetTop??0,width:n?.width??window.innerWidth,height:n?.height??window.innerHeight}),i=q4(s3(t),r);if(!i)return;let a=document.getElementById(`app-dock`)?.getBoundingClientRect().top;return a===void 0?i:J4(i,a)}function l3(e,t){return!e||!t?e===t:e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function u3(e){let[t,n]=(0,m.useState)(()=>c3(e));return(0,m.useEffect)(()=>{let t=()=>{let t=c3(e);n(e=>l3(e,t)?e:t)},r=document.getElementById(`main`),i=document.getElementById(`app-dock`),a=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);r&&a?.observe(r),i&&a?.observe(i);let o=window.visualViewport;return window.addEventListener(`resize`,t),window.addEventListener(`orientationchange`,t),o?.addEventListener(`resize`,t),o?.addEventListener(`scroll`,t),t(),()=>{a?.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`orientationchange`,t),o?.removeEventListener(`resize`,t),o?.removeEventListener(`scroll`,t)}},[e]),t}var d3=(0,m.forwardRef)(function({spotlight:e,thinking:t,busy:n=[],tone:r,expanded:i,hidden:a,shortcut:o,onOpen:s},c){let l=cA(`(max-width: 767.98px)`),u=u3(l),[d,f]=(0,m.useState)(n3),[p,h]=(0,m.useState)(),[g,_]=(0,m.useState)(!1),v=(0,m.useRef)(void 0),y=(0,m.useRef)(!1),b=(0,m.useRef)(44),x=d??(l?o3:void 0),S=p??(x&&u?e3(x,u,b.current):void 0),C=(0,m.useCallback)((e,t)=>{let n=c3(l);if(!n)return;let r=$4(e,t,n,b.current);f(r),r3(r)},[l]);(0,m.useEffect)(()=>{u&&h(e=>e&&Q4(e.x,e.y,u,b.current))},[u]);function w(e){if(e.button!==0)return;let t=e.currentTarget.getBoundingClientRect();b.current=t.width,v.current={id:e.pointerId,sx:e.clientX,sy:e.clientY,ox:t.left,oy:t.top,moved:!1},e.currentTarget.setPointerCapture?.(e.pointerId)}function T(e){let t=v.current;if(!t||t.id!==e.pointerId)return;let n=e.clientX-t.sx,r=e.clientY-t.sy;if(!t.moved&&Math.hypot(n,r)<i3)return;t.moved=!0;let i=c3(l);i&&h(Q4(t.ox+n,t.oy+r,i,b.current))}function E(e){let t=v.current;v.current=void 0,t?.moved&&(y.current=!0,C(t.ox+e.clientX-t.sx,t.oy+e.clientY-t.sy),h(void 0))}function D(e){let t=e.shiftKey?64:a3,n={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];if(!n||e.altKey||e.ctrlKey||e.metaKey)return;e.preventDefault();let r=e.currentTarget.getBoundingClientRect();b.current=r.width,C(r.left+n[0],r.top+n[1])}let O=!e&&n.length>0,k=e?SW(e):O?K4(n):void 0,A=e?`${t.map(SW).join(`, `)} thinking. `:O?`${n.join(`, `)} at work. `:``,ee=S&&u?S.x-u.left<140:!1,j={"--orb":r,...S?{left:S.x,top:S.y,right:`auto`,bottom:`auto`}:{}};return(0,R.jsxs)(Cj,{open:g&&!p,onOpenChange:_,children:[(0,R.jsx)(wj,{asChild:!0,children:(0,R.jsxs)(`button`,{ref:c,type:`button`,"aria-label":`Open Thinking`,"aria-description":`${A}Drag, or use the arrow keys, to move it.`,"aria-haspopup":`dialog`,"aria-expanded":i,"aria-keyshortcuts":o?`${o} Enter Space`:`Enter Space`,onClick:e=>{if(y.current){y.current=!1,e.preventDefault();return}s()},onPointerDown:w,onPointerMove:T,onPointerUp:E,onPointerCancel:()=>{v.current=void 0,h(void 0)},onKeyDown:D,style:j,"data-thinking":e?``:void 0,"data-busy":O?``:void 0,"data-dragging":p?``:void 0,"data-placed":S?``:void 0,"data-flip":ee||void 0,className:q(`thinking-bubble fixed z-20 touch-none rounded-full outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/40`,a&&`invisible`),children:[(0,R.jsx)(Du,{initial:!1,children:k?(0,R.jsx)(B.span,{className:`orb-label`,initial:{opacity:0,x:ee?-8:8,scale:.9},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:ee?-8:8,scale:.9},transition:{type:`spring`,visualDuration:.3,bounce:.35},children:(0,R.jsx)(Du,{mode:`popLayout`,initial:!1,children:(0,R.jsx)(B.span,{className:`inline-flex items-center gap-1`,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{type:`spring`,visualDuration:.28,bounce:.3},children:k},k)})},`label`):null}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`orb orb-float`,children:(0,R.jsx)(`span`,{className:`orb-icon`,children:(0,R.jsx)(bW,{source:e,strokeWidth:2.25,className:`size-3.5`})})})]})}),(0,R.jsxs)(Tj,{side:`top`,children:[`Thinking `,!l&&o?(0,R.jsx)(rA,{chord:o}):null,(0,R.jsx)(`span`,{className:`text-background/70`,children:` · drag to move`})]})]})}),f3=/^\s*(?:#{1,6}\s+(.+?)\s*#*|\*\*([^*\n]{2,90}?):?\*\*:?|__([^_\n]{2,90}?):?__:?)\s*$/,p3=260,m3=200,h3=/^\s*(?:[-*+]\s|\d+[.)]\s|>|```|~~~|\|)/m;function g3(e){let t=[],n=[],r=!1;for(let i of e){if(/^\s*(```|~~~)/.test(i)&&(r=!r),!r&&!i.trim()){n.length&&t.push(n.join(`
|
|
104
104
|
`).trim()),n=[];continue}n.push(i)}return n.length&&t.push(n.join(`
|
|
105
|
-
`).trim()),t.filter(Boolean)}function
|
|
105
|
+
`).trim()),t.filter(Boolean)}function _3(e){let t=e.split(/(?<=[.!?…])\s+(?=[A-Z"'“‘`(\[])/),n=[];for(let e of t){let t=n.at(-1);t!==void 0&&(t.split("`").length-1)%2==1?n[n.length-1]=`${t} ${e}`:n.push(e)}return n}function v3(e){if(e.length<=p3||h3.test(e))return[e];let t=[],n=``;for(let r of _3(e.replace(/\s*\n\s*/g,` `)))n&&n.length+r.length+1>m3?(t.push(n),n=r):n=n?`${n} ${r}`:r;return n&&t.push(n),t}function y3(e){let t=e.replace(/\r\n?/g,`
|
|
106
106
|
`).trim().split(`
|
|
107
|
-
`),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null:
|
|
107
|
+
`),n=[{lines:[]}],r=!1;for(let e of t){/^\s*(```|~~~)/.test(e)&&(r=!r);let t=r?null:f3.exec(e),i=t?(t[1]??t[2]??t[3])?.trim():void 0;i?n.push({title:i,lines:[]}):n.at(-1).lines.push(e)}let i=[];for(let e of n){let t=g3(e.lines);if(e.title)i.push({title:e.title,text:t.join(`
|
|
108
108
|
|
|
109
|
-
`)});else for(let e of t)for(let t of _3(e))i.push({text:t})}return i}var y3=4,b3=1800,x3=e=>({"--orb":e});function S3(e){let[t,n]=(0,m.useState)(0),r=e.join(`|`);return(0,m.useEffect)(()=>{if(n(0),e.length<2)return;let t=window.setInterval(()=>n(e=>e+1),b3);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function C3({thought:e}){let t=(0,m.useMemo)(()=>v3(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-y3),a=t.slice(i),o=SW(e.source);return(0,R.jsxs)(`li`,{className:`thought`,style:x3(TW(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`thought-label`,children:[(0,R.jsx)(bW,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,R.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):dM(Date.now()-e.at)}),t.length>1?(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,R.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,R.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,R.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,R.jsx)(WH,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function w3(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!e0(e,t)||e.target?.closest(`input, textarea, [contenteditable='true']`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,n])}function T3(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function E3({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=T3(OW(e)),o=a.filter(e=>e.live).map(e=>e.source),s=S3(o),c=s?TW(s):i.length?`var(--primary)`:`var(--orb-idle)`,l=s?`thinking`:i.length?`busy`:void 0,u=(0,m.useRef)(null),d=(0,m.useRef)(t);d.current=t,(0,m.useEffect)(()=>()=>{d.current||n()},[n]);let f=XA(!t,YA.sheet),p=QA();w3(f,r,n);let h=a.length>0||i.length>0;return(0,R.jsxs)(R.Fragment,{children:[h&&(0,Hv.createPortal)((0,R.jsx)(u3,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:p,shortcut:r,onOpen:n}),document.body),(0,R.jsxs)(HA,{open:f,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:q(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:x3(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,R.jsx)(`div`,{className:`relative min-h-0 overflow-y-auto p-3 outline-none sm:p-4`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,R.jsx)(C3,{thought:e},e.id))}):(0,R.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})})]})]})}var D3=`(max-width: 767.98px)`,O3=32;function k3(e){e.style.removeProperty(`max-height`),e.removeAttribute(`data-phone-fit`);let t=e.querySelector(`[role='log'][data-phone-fit]`);t&&(t.style.removeProperty(`min-height`),t.style.removeProperty(`overflow-y`),t.removeAttribute(`data-phone-fit`))}function A3(){let e=document.querySelector(`.thought-pane`);if(!e)return;if(!window.matchMedia(D3).matches){k3(e);return}let t=window.visualViewport,n=t?.offsetTop??0,r=n+(t?.height??window.innerHeight),i=document.getElementById(`app-dock`)?.getBoundingClientRect().top??r;e.style.maxHeight=`${Math.max(0,Math.min(r,i)-n-O3)}px`,e.dataset.phoneFit=``;let a=e.querySelector(`[role='log']`);a&&(a.style.minHeight=`0`,a.style.overflowY=`auto`,a.dataset.phoneFit=``)}function j3(e){(0,m.useEffect)(()=>{if(!e)return;let t=()=>A3(),n=typeof MutationObserver>`u`?void 0:new MutationObserver(t);n?.observe(document.body,{childList:!0,subtree:!0});let r=document.getElementById(`app-dock`),i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);r&&i?.observe(r);let a=window.visualViewport;return window.addEventListener(`resize`,t),window.addEventListener(`orientationchange`,t),a?.addEventListener(`resize`,t),t(),()=>{n?.disconnect(),i?.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`orientationchange`,t),a?.removeEventListener(`resize`,t),document.querySelectorAll(`.thought-pane[data-phone-fit]`).forEach(k3)}},[e])}function M3({status:e,lobby:t}){j3(!!(e&&e.panels?.thinking!==!1));let[n,r]=WK(`lobby.thinking`),i=xj(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=W4({oracleBusy:e.busy,runs:DW(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,R.jsx)(E3,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var N3=/\s*\(recommended\)\s*$/i,P3=1200,F3=`Type something.`,I3=`(max-width: 767.98px)`,L3=`max-md:hidden`;function R3(e){return{text:e.replace(N3,``),recommended:N3.test(e)}}function z3({label:e}){let{text:t,recommended:n}=R3(e);return(0,R.jsxs)(`span`,{className:`leading-snug break-words`,children:[t,n?(0,R.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function B3({multi:e,on:t}){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:q(`relative mt-0.5 flex size-4 shrink-0 items-center justify-center border`,e?`rounded-lg`:`rounded-full`,t?`border-primary bg-primary text-primary-foreground`:`border-input`),children:[t?(0,R.jsx)(Vp,{className:q(e?`size-3`:`hidden`)}):null,t&&!e?(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function V3({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsxs)(`label`,{className:q(`flex min-h-9 cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-start text-sm transition-[background-color,border-color,transform] duration-150 ease-snap active:scale-[0.99] max-md:min-h-11`,i?`border-primary/50 bg-accent`:`border-input bg-background hover:bg-accent/60`,`has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/30`),children:[(0,R.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,R.jsx)(B3,{multi:n,on:i}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,R.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,R.jsx)(z3,{label:e.label})]})})]}),e.description?(0,R.jsx)(WH,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function H3({option:e,onExpand:t}){let n=cA(I3);return!e||!QX(e)?null:(0,R.jsxs)(`div`,{className:`card-raised flex min-w-0 max-w-full flex-col gap-2 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,R3(e.label).text]}),(0,R.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:n?`Expand mockup`:`Expand · E`,className:`-my-1 shrink-0 max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:[(0,R.jsx)(ah,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,R.jsx)(`img`,{src:F(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,R.jsx)(KX,{preview:e.htmlPreview,label:R3(e.label).text,frameWidth:P3,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,R.jsx)(WH,{text:e.preview,className:`text-xs`}):null]})}function U3({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i}){return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,onClick:i,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Cancel`}),(0,R.jsx)(Y,{type:e,disabled:n||r,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:r?`Sending…`:t})]})}function W3(e,t,n,r){let i=e[r];if(!i)return;let a=n[r]?.trim();if(a)return{questionIndex:r,question:i.question,kind:`custom`,answer:a};let o=(t[r]??[]).map(e=>i.options[e]?.label).filter(e=>!!e);if(o.length!==0)return i.multiSelect?{questionIndex:r,question:i.question,kind:`multi`,answer:o.join(`, `),selected:o}:{questionIndex:r,question:i.question,kind:`option`,answer:o[0]??null}}function G3({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map((e,a)=>{let o=!!n[a]?.trim()||(t[a]?.length??0)>0;return(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to open this question.`,type:`button`,onClick:()=>i(a),"aria-current":a===r,className:q(`inline-flex min-h-8 min-w-0 items-center gap-1 rounded-lg border px-3 text-xs font-medium transition-colors max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,a===r?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-start`,children:[a+1,` `,e.header]}),o?(0,R.jsx)(Vp,{className:`size-3 shrink-0`,"aria-hidden":`true`}):null]},a)})})}function K3({questions:e,submitting:t,onAnswer:n,onCancel:r,expanded:i,onExpand:a}){let[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(!1),u=i??c,d=e=>a?a(e):l(e),[f,p]=(0,m.useState)(0),h=(0,m.useRef)(0),g=(0,m.useRef)(!1),[_,v]=(0,m.useState)({}),[y,b]=(0,m.useState)({}),[x,S]=(0,m.useState)({}),C=(0,m.useRef)(null),w=e[o],T=_[o]??[],E=y[o]??``,D=w?.options[x[o]??T[0]??0],O=W3(e,_,y,o),k=w?.multiSelect===!0;if((0,m.useEffect)(()=>{let e=C.current;e&&(e.querySelector(`[data-option="${_[o]?.[0]??0}"]`)??e.querySelector(`[data-nav]`))?.focus()},[o]),(0,m.useEffect)(()=>{let e=g.current&&!u;g.current=u,e&&(S(e=>({...e,[o]:h.current})),C.current?.querySelector(`[data-option="${h.current}"]`)?.focus())},[u]),!w)return null;let A=w.options.some(QX);function ee(e){p(Math.max(0,e)),h.current=Math.max(0,e),d(!0)}function j(e){h.current=e,d(!1)}if(u&&A)return(0,R.jsx)(eZ,{options:w.options,start:f,title:w.header||w.question,picked:T,multi:k,onChoose:e=>{M(e),k||j(e)},onClose:j,onIndex:e=>{h.current=e}},o);function M(e){let t=k?T.includes(e)?T.filter(t=>t!==e):[...T,e]:[e];v({..._,[o]:t}),k||b({...y,[o]:``}),S({...x,[o]:e})}function te(t,r){if(W3(e,t,r,o)){if(o<e.length-1){s(o+1);return}n({answers:e.map((n,i)=>W3(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function ne(e){e.preventDefault(),t||te(_,y)}function N(t){t>=0&&t<e.length&&s(t)}function re(e){let n=e.target,r=C.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||te(_,y);return}if(n instanceof HTMLTextAreaElement){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),t||te(_,y)):e.key===`ArrowUp`&&n.selectionStart===0&&n.selectionEnd===0&&(e.preventDefault(),Dj(r,n,-1));return}let i=kj(e.key);if(i){e.preventDefault(),Dj(r,n,i);return}if(e.key===`Home`||e.key===`End`){e.preventDefault(),Dj(r,n,e.key===`Home`?`first`:`last`);return}let a=Aj(e.key);if(a&&!(n instanceof HTMLButtonElement)){e.preventDefault(),N(o+a);return}let s=n instanceof HTMLInputElement&&n.dataset.option!==void 0?Number(n.dataset.option):-1;if(e.key===`Enter`&&s>=0){if(e.preventDefault(),k)T.length>0&&T.includes(s)?te(_,y):M(s);else{let e={..._,[o]:[s]},t={...y,[o]:``};v(e),b(t),te(e,t)}return}if(e.key===` `&&s>=0){e.preventDefault(),M(s);return}let c=Number(e.key);if(Number.isInteger(c)&&c>=1&&c<=w.options.length){e.preventDefault(),M(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&A&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),ee(s>=0?s:x[o]??T[0]??0))}return(0,R.jsxs)(`form`,{ref:C,className:`flex min-w-0 flex-col gap-3`,onSubmit:ne,onKeyDown:re,children:[(0,R.jsx)(G3,{questions:e,picks:_,own:y,index:o,onGo:s}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.length>1?`Question ${o+1} of ${e.length}`:`Question`}),(0,R.jsx)(WH,{text:w.question,className:`mt-1 text-base`})]}),(0,R.jsxs)(`div`,{className:q(`grid min-w-0 gap-4`,D?.preview||D?.image||D?.htmlPreview?`lg:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]`:``),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[w.options.map((e,t)=>(0,R.jsx)(V3,{option:e,index:t,multi:k,name:`question-${o}`,selected:T.includes(t),onToggle:()=>M(t),onFocusOption:()=>S({...x,[o]:t})},t)),(0,R.jsxs)(`label`,{className:`flex min-h-9 min-w-0 flex-col gap-1 rounded-lg border border-input px-3 py-1.5 text-sm focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/30 max-md:min-h-11`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Your own answer`}),(0,R.jsx)(sM,{"data-nav":``,value:E,onChange:e=>{b({...y,[o]:e.target.value}),e.target.value&&v({..._,[o]:[]})},placeholder:F3,"aria-label":`Your own answer`,rows:2,className:`min-h-9 resize-none border-0 bg-transparent p-0 text-sm shadow-none focus-visible:ring-0 md:text-sm max-md:min-h-11`})]})]}),(0,R.jsx)(H3,{option:D,onExpand:()=>ee(w.options.indexOf(D))})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:k?`Pick several`:`Pick one`}),(0,R.jsx)(iA,{chord:`↑↓`,className:L3,children:`move`}),(0,R.jsx)(iA,{chord:k?`Space`:`Enter`,className:L3,children:k?`pick`:`choose`}),k?(0,R.jsx)(iA,{chord:`Enter`,className:L3,children:`next`}):null,e.length>1?(0,R.jsx)(iA,{chord:`←→`,className:L3,children:`question`}):null,A?(0,R.jsx)(iA,{chord:`E`,className:L3,children:`expand mockups`}):null,(0,R.jsx)(iA,{chord:`Esc`,className:L3,children:`later`})]}),(0,R.jsx)(U3,{primary:`submit`,primaryLabel:o<e.length-1?`Next`:`Answer`,disabled:!O,submitting:t,onCancel:r})]})}function q3(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||Oj(i))return;let a=kj(e.key);if(a){e.preventDefault(),Dj(r,i,a);return}let o=i instanceof HTMLInputElement&&i.dataset.option!==void 0?Number(i.dataset.option):-1;if((e.key===`Enter`||e.key===` `)&&o>=0){e.preventDefault(),n(o,e.key===`Enter`);return}let s=Number(e.key);Number.isInteger(s)&&s>=1&&s<=t&&(e.preventDefault(),n(s-1,!1),r.querySelector(`[data-option="${s-1}"]`)?.focus())}function J3({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.querySelector(`[data-nav]`)?.focus()},[]),(0,R.jsxs)(`form`,{ref:o,className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>q3(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,R.jsx)(WH,{text:e.title,className:`text-base`}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,R.jsx)(V3,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`↑↓`,className:L3,children:`move`}),(0,R.jsx)(iA,{chord:`Enter`,className:L3,children:`choose`}),(0,R.jsx)(iA,{chord:`Esc`,className:L3,children:`later`})]}),(0,R.jsx)(U3,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function Y3({view:e,submitting:t,onAnswer:n}){let r=(0,m.useRef)(null);(0,m.useEffect)(()=>r.current?.focus(),[]);function i(e){if(e.altKey||e.ctrlKey||e.metaKey||t)return;let r=e.key.toLowerCase();r===`y`?n(!0):r===`n`&&n(!1)}return(0,R.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex min-w-0 flex-col gap-3 outline-none`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(WH,{text:e.question,className:`text-base`}),e.detail?(0,R.jsx)(WH,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`Y`,className:L3,children:`yes`}),(0,R.jsx)(iA,{chord:`N`,className:L3,children:`no`}),(0,R.jsx)(iA,{chord:`Esc`,className:L3,children:`later`})]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`No`}),(0,R.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n(!0),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:t?`Sending…`:`Yes`})]})]})]})}function X3({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,R.jsx)(WH,{text:e.question,className:`text-base`}),(0,R.jsx)(sM,{autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},value:i,onChange:e=>a(e.target.value),placeholder:e.placeholder??F3,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm md:text-sm max-md:min-h-11`}),(0,R.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`Enter`,className:L3,children:`answer`}),(0,R.jsx)(iA,{chord:`Shift+Enter`,className:L3,children:`new line`}),(0,R.jsx)(iA,{chord:`Esc`,className:L3,children:`later`})]}),(0,R.jsx)(U3,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function Z3({dialog:e,submitting:t,onAnswer:n}){let[r,i]=(0,m.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,m.useState)(``),s=e.options??[],c=e.method===`select`?a!==``:r.trim()!==``,l=(0,m.useRef)(null);(0,m.useEffect)(()=>{l.current?.querySelector(`[data-nav], textarea`)?.focus()},[]);function u(t){t.preventDefault(),e.method===`select`?n({value:a}):e.method===`confirm`?n({confirmed:!0}):(e.method===`input`||e.method===`editor`)&&n({value:r.trim()})}return(0,R.jsxs)(`form`,{ref:l,className:`flex min-w-0 flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&q3(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,R.jsx)(WH,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,R.jsx)(V3,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,R.jsx)(sM,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??F3,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm md:text-sm max-md:min-h-11`}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Cancel`}),e.method===`confirm`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`No`}),(0,R.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:t?`Sending…`:`Yes`})]}):(0,R.jsx)(Y,{type:`submit`,disabled:!c||t,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:t?`Sending…`:`Answer`})]})]})}function Q3(e){let{view:t}=e;return t.kind===`questionnaire`?(0,R.jsx)(K3,{questions:t.questions,submitting:e.submitting,onAnswer:e.onAnswer,onCancel:e.onCancel,...e.onExpand?{expanded:e.expanded??!1,onExpand:e.onExpand}:{}}):t.kind===`choose`?(0,R.jsx)(J3,{...e,view:t}):t.kind===`confirm`?(0,R.jsx)(Y3,{...e,view:t}):t.kind===`text`?(0,R.jsx)(X3,{...e,view:t}):(0,R.jsx)(Z3,{...e,dialog:t.dialog})}function $3(e){return typeof e==`object`&&e?e:{}}function e6(e){return typeof e==`string`?e.trim():``}function t6(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function n6(e){let t=$3(e),n=e6(t.label);if(!n)return;let r=e6(t.description),i=e6(t.preview),a=e6(t.image),o=VX(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function r6(e){let t=$3(e),n=e6(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(n6).filter(e=>!!e);return{question:n,header:e6(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function i6(e){let t=$3(e),n=e6(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=e6(t.message),i=t6(t.options),a=e6(t.placeholder),o=e6(t.prefill);return{id:e6(t.id),method:n,title:e6(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function a6(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(r6).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function o6(e){return{kind:`choose`,title:e6(e.title)||`Choose an option`,options:t6(e.options)}}function s6(e){let t=e6(e.question)||e6(e.title)||`Continue?`,n=e6(e.detail)||e6(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function c6(e){let t=e6(e.question)||e6(e.title)||`Type an answer`,n=e6(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function l6(e){let t=$3(e.payload);if(e.kind===`questionnaire`)return a6(t);if(e.kind===`choose`)return o6(t);if(e.kind===`confirm`)return s6(t);if(e.kind===`text`)return c6(t);let n=i6(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var u6=`(max-width: 767.98px)`;function d6({submitting:e,onKeep:t,onLeave:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`alert`,children:[(0,R.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,onClick:t,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Keep answering`}),(0,R.jsx)(Y,{type:`button`,disabled:e,onClick:n,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:e?`Leaving…`:`Leave`})]})]})}function f6({count:e,onOpen:t}){return(0,R.jsxs)(Y,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:[(0,R.jsx)(lm,{"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,R.jsx)(`span`,{className:`hidden md:inline`,children:`waiting`})]})}function p6({prompts:e,answer:t,dismiss:n,minimized:r,onMinimize:i}){let[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=cA(u6),{keyboardOpen:f,keyboardInset:p}=BA(),h=e.length,g=e[0],_=g?l6(g):void 0,v=h>0&&!r,y=XA(v,YA.question);(0,m.useEffect)(()=>{h===0&&(o(!1),i(!1))},[h,i]);let b=g?.id;(0,m.useEffect)(()=>u(!1),[b]);async function x(e,t){c(!0);try{await e,o(!1)}catch(e){e instanceof Ce&&e.code===`question_withdrawn`?H(ej):H.error(e instanceof Error?e.message:t)}finally{c(!1)}}let S=g?.from?`${g.from} asks`:`A question`;return(0,R.jsx)(HA,{open:v&&y&&!!g,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},style:d&&f?{maxHeight:`calc(100vh - ${p}px - 1.5rem)`}:void 0,className:q(l?`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`:`max-w-3xl`,`max-md:w-[calc(100vw-2rem)] max-md:max-w-[calc(100vw-2rem)] max-md:max-h-[calc(100svh-1.5rem)]`,l&&`max-md:h-[calc(100svh-1.5rem)]`),children:g?(0,R.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsxs)(`header`,{className:q(`flex items-center gap-3 px-6 pt-5 pb-3 max-md:px-4 max-md:pt-4 max-md:pb-2`,l&&`hidden`),children:[(0,R.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground first-letter:uppercase`,children:[S,h>1?` · 1 of ${h}`:``]}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:d?`Later`:`Later · Esc`,onClick:()=>i(!0),className:`max-md:size-11`,children:(0,R.jsx)(Vg,{"aria-hidden":`true`})})]}),(0,R.jsx)(`div`,{className:l?`flex min-h-0 min-w-0 flex-1 flex-col`:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-6 pb-6 max-md:px-4 max-md:pb-4`,children:_?a?(0,R.jsx)(d6,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void x(n(g.id),`Could not leave the question`)}):(0,R.jsx)(Q3,{view:_,submitting:s,onAnswer:e=>void x(t(g.id,e),`Could not send the answer`),onCancel:()=>o(!0),expanded:l,onExpand:u},g.id):(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(`p`,{className:`max-md:min-w-0 max-md:flex-1 text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,R.jsx)(Y,{type:`button`,disabled:s,onClick:()=>void x(n(g.id),`Could not dismiss the question`),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Dismiss`})]})})]}):null})}var m6=2;function h6(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function g6(e){try{return JSON.parse(e)}catch{return}}function _6(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function v6(e,t=h6){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===m6?`offline`:`connecting`),n.onmessage=t=>{let n=g6(t.data);n&&_6(n,e)},()=>n.close()}var y6=2e3,b6=()=>Te(`projects.list`,{});async function x6(){let e;try{e=P()}catch{return}if(e&&!xe(e))try{be((await b6()).projects)}catch{}}function S6(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{P()}catch{fe.onStatus({connection:`offline`});return}e.current=v6({onHello:e=>{fe.onHello(e),x6()},onChanged:(e,t)=>fe.onChanged(e,t),onFeed:e=>fe.onFeedDelta(e),onReply:e=>fe.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{fe.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{Se(b6).catch(()=>!1).finally(n)},y6))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var C6=`bot-lobby.recoveredAt`,w6;function T6(e,t=E6()){try{w6===void 0&&(w6=Number(t?.getItem(C6)??0))}catch{w6??=0}if(w6!==void 0&&e<=w6)return!1;w6=e;try{t?.setItem(C6,String(e))}catch{}return!0}function E6(){try{return globalThis.sessionStorage}catch{return}}function D6(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&T6(t)&&H.success(n)},[t,n])}function O6(){let e=sA(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await Te(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await Te(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function k6(e,t,n,r){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?aj(`#/settings`):e===`sessions`?aj(`#/sessions`):e===`thinking`?UK(`lobby.thinking`):e===`activity`?t.kind===`tab`&&t.tab===`lobby`?UK(`lobby.activity`):aj(ij(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var A6=2500;function j6(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),A6);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function M6({connection:e,onRetry:t}){return j6(e)?(0,R.jsx)(bj,{onRetry:t}):null}var N6={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{N6.route=++N6.tick}),document.addEventListener(`focusin`,()=>{N6.focus=++N6.tick});var P6=()=>N6.focus>N6.route;function F6(e){return e.kind===`tab`?e.tab:e.kind}function I6(){let e=oj(),t=sA(`status`),n=sA(`lobby`),{prompts:r,answer:i,dismiss:a}=O6(),{connection:o,signedOut:s}=oA(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=S6();WJ();let h=t.data;D6(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Ve()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>aj(ij(e)),[]),x=(0,R.jsx)(U4,{tabs:_,activeId:y,onSelect:b}),S=cA(`(max-width: 767.98px)`),C=(0,m.useCallback)(e=>{let t=S?_.filter(e=>e.id!==`metrics`):_;if(t.length===0)return;let n=t[(Math.max(0,t.findIndex(e=>e.id===y))+e+t.length)%t.length];n&&aj(ij(n.id))},[_,y,S]),w=(0,m.useCallback)(()=>l(e=>!e),[]),T=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&k6(t,rj(window.location.hash)??e,w,C)},[e,w,C,h?.panels]),E=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||f.current?.contains(e)===!0||e.closest(`.thinking-bubble`)?!0:e.closest(`[data-state='closed']`)!==null},[]);s0({enabled:!!h,keys:v,tabs:_,insideApp:E,onAction:T,onTab:b});let D=(0,m.useCallback)(()=>fe.onHello({}),[]),O=e.kind===`tab`?e.tab:e.kind,k=!!h;(0,m.useEffect)(()=>{if(!k)return;let e=Rj.active&&Rj.to===O;if(Rj.active=!1,Rj.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(P6()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`),t=window.matchMedia(`(max-width: 767.98px)`).matches,n=window.matchMedia(`(pointer: coarse)`).matches;!t&&!n&&e&&!e.disabled?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[O,k]);let A=Object.fromEntries(v.map(e=>[e.action,e.label])),ee=(0,R.jsx)(t2,{status:h,task:n.data?.task,connection:o,route:e,keys:A,onHelp:w,tabs:S?null:x,extra:u&&r.length>0?(0,R.jsx)(f6,{count:r.length,onOpen:()=>d(!1)}):null});return s||!h?(0,R.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[ee,(0,R.jsx)(`main`,{className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto max-md:mx-0 max-md:mb-0`,children:s?(0,R.jsx)(r2,{}):t.error?(0,R.jsx)(yj,{message:t.error,onRetry:D}):(0,R.jsx)(vj,{})})]}):(0,R.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[ee,(0,R.jsx)(M6,{connection:o,onRetry:p}),(0,R.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||Oj(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||Lj()&&e.preventDefault()},role:y?`tabpanel`:void 0,"aria-labelledby":y?`tab-${y}`:void 0,className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto outline-none max-md:mx-0 max-md:mb-0`,children:(0,R.jsx)(B.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.2,.8,.2,1]},className:`flex min-h-0 flex-1 flex-col`,children:J1(e)},F6(e))}),(0,R.jsx)(M0,{route:e,keys:A,onHelp:w,dockNav:S?x:null}),(0,R.jsx)(M3,{status:h,lobby:n.data}),(0,R.jsx)(p6,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,R.jsx)(v0,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function L6(e){switch(e){case`status`:return Te(`status.get`,{});case`lobby`:return Te(`lobby.snapshot`,{});case`prompts`:return Te(`prompts.list`,{});default:return}}var R6=[`status`,`lobby`,`prompts`];function z6(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await De(),e&&(fe.markUsed(R6,L6),t(!0))})(),()=>{e=!1}},[]),e}function B6(){return z6()?(0,R.jsx)(I6,{}):(0,R.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,R.jsx)(vj,{})})}var V6={info:Gm,success:rm,warning:Tg,error:pm},H6={info:`text-primary`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function U6(){let{item:e,waiting:t}=ap(),n=QA(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>rp(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed inset-x-0 z-40 flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + 0.25rem)`},children:(0,R.jsx)(Du,{mode:`wait`,children:r?(0,R.jsxs)(B.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-3 rounded-xl border border-glass-border bg-popover/80 px-4 py-2.5 text-sm text-popover-foreground shadow-glass backdrop-blur-xs`,children:[(0,R.jsx)(W6,{kind:e.kind}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.message}),e.action?(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-raised -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border bg-card px-2.5 font-medium text-primary transition-[box-shadow,translate] active:translate-y-px focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none`,onClick:()=>{e.action?.onClick(),rp(e.id)},children:e.action.label}):null]},e.id):null})})}function W6({kind:e}){let t=V6[e];return(0,R.jsx)(t,{"aria-hidden":`true`,className:q(`size-5 shrink-0`,H6[e])})}(0,Xf.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(m.StrictMode,{children:(0,R.jsx)(_Y,{children:(0,R.jsx)(Pu,{reducedMotion:`user`,children:(0,R.jsxs)(Sj,{children:[(0,R.jsx)(B6,{}),(0,R.jsx)(U6,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});
|
|
109
|
+
`)});else for(let e of t)for(let t of v3(e))i.push({text:t})}return i}var b3=4,x3=1800,S3=e=>({"--orb":e});function C3(e){let[t,n]=(0,m.useState)(0),r=e.join(`|`);return(0,m.useEffect)(()=>{if(n(0),e.length<2)return;let t=window.setInterval(()=>n(e=>e+1),x3);return()=>window.clearInterval(t)},[r,e.length]),e.length?e[t%e.length]:void 0}function w3({thought:e}){let t=(0,m.useMemo)(()=>y3(e.text),[e.text]),[n,r]=(0,m.useState)(!1),i=n?0:Math.max(0,t.length-b3),a=t.slice(i),o=SW(e.source);return(0,R.jsxs)(`li`,{className:`thought`,style:S3(TW(e.source)),"data-live":e.live||void 0,"aria-label":`${o}${e.live?`, thinking`:``}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`thought-label`,children:[(0,R.jsx)(bW,{source:e.source,strokeWidth:2.25,className:`size-3.5`}),o]}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.live?(0,R.jsxs)(`span`,{className:`thought-live`,children:[`thinking`,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`thought-ellipsis`})]}):dM(Date.now()-e.at)}),t.length>1?(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:[t.length,` steps`]}):null]}),i?(0,R.jsxs)(`button`,{type:`button`,"data-compact":!0,className:`thought-more`,onClick:()=>r(!0),children:[i,` earlier `,i===1?`step`:`steps`]}):null,(0,R.jsx)(`ol`,{className:`thought-steps`,"data-single":a.length===1||void 0,children:a.map((t,n)=>(0,R.jsxs)(`li`,{"data-current":e.live&&n===a.length-1||void 0,children:[t.title?(0,R.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t.title}):null,t.text?(0,R.jsx)(WH,{text:t.text,className:`thought-text`}):null]},i+n))})]})}function T3(e,t,n){(0,m.useEffect)(()=>{if(!e||!t)return;let r=e=>{e.defaultPrevented||e.isComposing||!t0(e,t)||e.target?.closest(`input, textarea, [contenteditable='true']`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,n])}function E3(e){return[...e].sort((e,t)=>Number(t.live)-Number(e.live)||t.at-e.at||t.id-e.id)}function D3({thoughts:e,collapsed:t,onToggle:n,shortcut:r,busy:i=[]}){let a=E3(OW(e)),o=a.filter(e=>e.live).map(e=>e.source),s=C3(o),c=s?TW(s):i.length?`var(--primary)`:`var(--orb-idle)`,l=s?`thinking`:i.length?`busy`:void 0,u=(0,m.useRef)(null),d=(0,m.useRef)(t);d.current=t,(0,m.useEffect)(()=>()=>{d.current||n()},[n]);let f=XA(!t,YA.sheet),p=QA();T3(f,r,n);let h=a.length>0||i.length>0;return(0,R.jsxs)(R.Fragment,{children:[h&&(0,Hv.createPortal)((0,R.jsx)(d3,{ref:u,spotlight:s,thinking:o,busy:i,tone:c,expanded:!t,hidden:p,shortcut:r,onOpen:n}),document.body),(0,R.jsxs)(HA,{open:f,onOpenChange:e=>{!e&&!t&&n()},label:`Thinking`,className:q(`thought-pane max-w-xl`,l&&`thought-pane-live`),style:S3(c),onCloseAutoFocus:e=>{e.preventDefault(),requestAnimationFrame(()=>{document.querySelector(`[role='dialog']`)||u.current?.focus()})},children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`thought-aura`,"data-working":l}),(0,R.jsx)(`div`,{className:`relative min-h-0 overflow-y-auto p-3 outline-none sm:p-4`,role:`log`,"aria-label":`Latest thoughts`,tabIndex:0,children:a.length?(0,R.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:a.map(e=>(0,R.jsx)(w3,{thought:e},e.id))}):(0,R.jsx)(`p`,{className:`px-2 py-6 text-center text-sm text-muted-foreground`,children:`Thoughts from the oracle and every agent appear here, and only here.`})})]})]})}var O3=`(max-width: 767.98px)`,k3=32;function A3(e){e.style.removeProperty(`max-height`),e.removeAttribute(`data-phone-fit`);let t=e.querySelector(`[role='log'][data-phone-fit]`);t&&(t.style.removeProperty(`min-height`),t.style.removeProperty(`overflow-y`),t.removeAttribute(`data-phone-fit`))}function j3(){let e=document.querySelector(`.thought-pane`);if(!e)return;if(!window.matchMedia(O3).matches){A3(e);return}let t=window.visualViewport,n=t?.offsetTop??0,r=n+(t?.height??window.innerHeight),i=document.getElementById(`app-dock`)?.getBoundingClientRect().top??r;e.style.maxHeight=`${Math.max(0,Math.min(r,i)-n-k3)}px`,e.dataset.phoneFit=``;let a=e.querySelector(`[role='log']`);a&&(a.style.minHeight=`0`,a.style.overflowY=`auto`,a.dataset.phoneFit=``)}function M3(e){(0,m.useEffect)(()=>{if(!e)return;let t=()=>j3(),n=typeof MutationObserver>`u`?void 0:new MutationObserver(t);n?.observe(document.body,{childList:!0,subtree:!0});let r=document.getElementById(`app-dock`),i=typeof ResizeObserver>`u`?void 0:new ResizeObserver(t);r&&i?.observe(r);let a=window.visualViewport;return window.addEventListener(`resize`,t),window.addEventListener(`orientationchange`,t),a?.addEventListener(`resize`,t),t(),()=>{n?.disconnect(),i?.disconnect(),window.removeEventListener(`resize`,t),window.removeEventListener(`orientationchange`,t),a?.removeEventListener(`resize`,t),document.querySelectorAll(`.thought-pane[data-phone-fit]`).forEach(A3)}},[e])}function N3({status:e,lobby:t}){M3(!!(e&&e.panels?.thinking!==!1));let[n,r]=WK(`lobby.thinking`),i=xj(`sessions.list`,{},[`sessions`]);if(!e||e.panels?.thinking===!1)return null;let a=G4({oracleBusy:e.busy,runs:DW(t),activity:t?.activity??[],background:i.data?.background??[]}),o=e.keys.find(e=>e.action===`thinking`)?.label;return(0,R.jsx)(D3,{thoughts:t?.thoughts??[],collapsed:n,onToggle:r,shortcut:o,busy:a})}var P3=/\s*\(recommended\)\s*$/i,F3=1200,I3=`Type something.`,L3=`(max-width: 767.98px)`,R3=`max-md:hidden`;function z3(e){return{text:e.replace(P3,``),recommended:P3.test(e)}}function B3({label:e}){let{text:t,recommended:n}=z3(e);return(0,R.jsxs)(`span`,{className:`leading-snug break-words`,children:[t,n?(0,R.jsx)(`span`,{className:`ms-1 font-medium text-primary`,children:`(Recommended)`}):null]})}function V3({multi:e,on:t}){return(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:q(`relative mt-0.5 flex size-4 shrink-0 items-center justify-center border`,e?`rounded-lg`:`rounded-full`,t?`border-primary bg-primary text-primary-foreground`:`border-input`),children:[t?(0,R.jsx)(Vp,{className:q(e?`size-3`:`hidden`)}):null,t&&!e?(0,R.jsx)(`span`,{className:`size-2 rounded-full bg-primary-foreground`}):null]})}function H3({option:e,index:t,multi:n,name:r,selected:i,onToggle:a,onFocusOption:o}){return(0,R.jsxs)(`div`,{className:`grid gap-1`,children:[(0,R.jsxs)(`label`,{className:q(`flex min-h-9 cursor-pointer items-start gap-2.5 rounded-lg border px-3 py-2 text-start text-sm transition-[background-color,border-color,transform] duration-150 ease-snap active:scale-[0.99] max-md:min-h-11`,i?`border-primary/50 bg-accent`:`border-input bg-background hover:bg-accent/60`,`has-[:focus-visible]:border-ring has-[:focus-visible]:ring-3 has-[:focus-visible]:ring-ring/30`),children:[(0,R.jsx)(`input`,{type:n?`checkbox`:`radio`,name:r,"data-nav":``,"data-option":t,className:`sr-only`,checked:i,onChange:a,onFocus:o}),(0,R.jsx)(V3,{multi:n,on:i}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:(0,R.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,R.jsxs)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,R.jsx)(B3,{label:e.label})]})})]}),e.description?(0,R.jsx)(WH,{text:e.description,className:`px-3 text-muted-foreground`}):null]})}function U3({option:e,onExpand:t}){let n=cA(L3);return!e||!$X(e)?null:(0,R.jsxs)(`div`,{className:`card-raised flex min-w-0 max-w-full flex-col gap-2 rounded-lg border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`p`,{className:`min-w-0 truncate text-xs font-medium text-muted-foreground`,children:[`Preview · `,z3(e.label).text]}),(0,R.jsxs)(Y,{type:`button`,variant:`ghost`,size:`xs`,onClick:t,"aria-keyshortcuts":`E`,title:n?`Expand mockup`:`Expand · E`,className:`-my-1 shrink-0 max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:[(0,R.jsx)(ah,{"aria-hidden":`true`}),`Expand`]})]}),e.image?(0,R.jsx)(`img`,{src:F(e.image),alt:``,loading:`lazy`,className:`max-h-64 w-full rounded-lg border object-contain`}):null,e.htmlPreview?(0,R.jsx)(qX,{preview:e.htmlPreview,label:z3(e.label).text,frameWidth:F3,onOpen:t,className:`h-auto aspect-[3/2]`}):null,e.preview?(0,R.jsx)(WH,{text:e.preview,className:`text-xs`}):null]})}function W3({primary:e,primaryLabel:t,disabled:n,submitting:r,onCancel:i}){return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(Y,{type:`button`,variant:`ghost`,onClick:i,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Cancel`}),(0,R.jsx)(Y,{type:e,disabled:n||r,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:r?`Sending…`:t})]})}function G3(e,t,n,r){let i=e[r];if(!i)return;let a=n[r]?.trim();if(a)return{questionIndex:r,question:i.question,kind:`custom`,answer:a};let o=(t[r]??[]).map(e=>i.options[e]?.label).filter(e=>!!e);if(o.length!==0)return i.multiSelect?{questionIndex:r,question:i.question,kind:`multi`,answer:o.join(`, `),selected:o}:{questionIndex:r,question:i.question,kind:`option`,answer:o[0]??null}}function K3({questions:e,picks:t,own:n,index:r,onGo:i}){return e.length===1?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e[0]?.header}):(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map((e,a)=>{let o=!!n[a]?.trim()||(t[a]?.length??0)>0;return(0,R.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-description":`When focused, press Enter or Space to open this question.`,type:`button`,onClick:()=>i(a),"aria-current":a===r,className:q(`inline-flex min-h-8 min-w-0 items-center gap-1 rounded-lg border px-3 text-xs font-medium transition-colors max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,a===r?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,R.jsxs)(`span`,{className:`min-w-0 break-words text-start`,children:[a+1,` `,e.header]}),o?(0,R.jsx)(Vp,{className:`size-3 shrink-0`,"aria-hidden":`true`}):null]},a)})})}function q3({questions:e,submitting:t,onAnswer:n,onCancel:r,expanded:i,onExpand:a}){let[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(!1),u=i??c,d=e=>a?a(e):l(e),[f,p]=(0,m.useState)(0),h=(0,m.useRef)(0),g=(0,m.useRef)(!1),[_,v]=(0,m.useState)({}),[y,b]=(0,m.useState)({}),[x,S]=(0,m.useState)({}),C=(0,m.useRef)(null),w=e[o],T=_[o]??[],E=y[o]??``,D=w?.options[x[o]??T[0]??0],O=G3(e,_,y,o),k=w?.multiSelect===!0;if((0,m.useEffect)(()=>{let e=C.current;e&&(e.querySelector(`[data-option="${_[o]?.[0]??0}"]`)??e.querySelector(`[data-nav]`))?.focus()},[o]),(0,m.useEffect)(()=>{let e=g.current&&!u;g.current=u,e&&(S(e=>({...e,[o]:h.current})),C.current?.querySelector(`[data-option="${h.current}"]`)?.focus())},[u]),!w)return null;let A=w.options.some($X);function ee(e){p(Math.max(0,e)),h.current=Math.max(0,e),d(!0)}function j(e){h.current=e,d(!1)}if(u&&A)return(0,R.jsx)(tZ,{options:w.options,start:f,title:w.header||w.question,picked:T,multi:k,onChoose:e=>{M(e),k||j(e)},onClose:j,onIndex:e=>{h.current=e}},o);function M(e){let t=k?T.includes(e)?T.filter(t=>t!==e):[...T,e]:[e];v({..._,[o]:t}),k||b({...y,[o]:``}),S({...x,[o]:e})}function te(t,r){if(G3(e,t,r,o)){if(o<e.length-1){s(o+1);return}n({answers:e.map((n,i)=>G3(e,t,r,i)).filter(e=>!!e),cancelled:!1})}}function ne(e){e.preventDefault(),t||te(_,y)}function N(t){t>=0&&t<e.length&&s(t)}function re(e){let n=e.target,r=C.current;if(!r||e.altKey)return;if(e.key===`Enter`&&(e.ctrlKey||e.metaKey)){e.preventDefault(),t||te(_,y);return}if(n instanceof HTMLTextAreaElement){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing?(e.preventDefault(),t||te(_,y)):e.key===`ArrowUp`&&n.selectionStart===0&&n.selectionEnd===0&&(e.preventDefault(),Dj(r,n,-1));return}let i=kj(e.key);if(i){e.preventDefault(),Dj(r,n,i);return}if(e.key===`Home`||e.key===`End`){e.preventDefault(),Dj(r,n,e.key===`Home`?`first`:`last`);return}let a=Aj(e.key);if(a&&!(n instanceof HTMLButtonElement)){e.preventDefault(),N(o+a);return}let s=n instanceof HTMLInputElement&&n.dataset.option!==void 0?Number(n.dataset.option):-1;if(e.key===`Enter`&&s>=0){if(e.preventDefault(),k)T.length>0&&T.includes(s)?te(_,y):M(s);else{let e={..._,[o]:[s]},t={...y,[o]:``};v(e),b(t),te(e,t)}return}if(e.key===` `&&s>=0){e.preventDefault(),M(s);return}let c=Number(e.key);if(Number.isInteger(c)&&c>=1&&c<=w.options.length){e.preventDefault(),M(c-1),r.querySelector(`[data-option="${c-1}"]`)?.focus();return}e.key.toLowerCase()===`e`&&A&&!e.ctrlKey&&!e.metaKey&&(e.preventDefault(),ee(s>=0?s:x[o]??T[0]??0))}return(0,R.jsxs)(`form`,{ref:C,className:`flex min-w-0 flex-col gap-3`,onSubmit:ne,onKeyDown:re,children:[(0,R.jsx)(K3,{questions:e,picks:_,own:y,index:o,onGo:s}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.length>1?`Question ${o+1} of ${e.length}`:`Question`}),(0,R.jsx)(WH,{text:w.question,className:`mt-1 text-base`})]}),(0,R.jsxs)(`div`,{className:q(`grid min-w-0 gap-4`,D?.preview||D?.image||D?.htmlPreview?`lg:grid-cols-[minmax(0,1.1fr)_minmax(0,1fr)]`:``),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[w.options.map((e,t)=>(0,R.jsx)(H3,{option:e,index:t,multi:k,name:`question-${o}`,selected:T.includes(t),onToggle:()=>M(t),onFocusOption:()=>S({...x,[o]:t})},t)),(0,R.jsxs)(`label`,{className:`flex min-h-9 min-w-0 flex-col gap-1 rounded-lg border border-input px-3 py-1.5 text-sm focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/30 max-md:min-h-11`,children:[(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Your own answer`}),(0,R.jsx)(sM,{"data-nav":``,value:E,onChange:e=>{b({...y,[o]:e.target.value}),e.target.value&&v({..._,[o]:[]})},placeholder:I3,"aria-label":`Your own answer`,rows:2,className:`min-h-9 resize-none border-0 bg-transparent p-0 text-sm shadow-none focus-visible:ring-0 md:text-sm max-md:min-h-11`})]})]}),(0,R.jsx)(U3,{option:D,onExpand:()=>ee(w.options.indexOf(D))})]}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:k?`Pick several`:`Pick one`}),(0,R.jsx)(iA,{chord:`↑↓`,className:R3,children:`move`}),(0,R.jsx)(iA,{chord:k?`Space`:`Enter`,className:R3,children:k?`pick`:`choose`}),k?(0,R.jsx)(iA,{chord:`Enter`,className:R3,children:`next`}):null,e.length>1?(0,R.jsx)(iA,{chord:`←→`,className:R3,children:`question`}):null,A?(0,R.jsx)(iA,{chord:`E`,className:R3,children:`expand mockups`}):null,(0,R.jsx)(iA,{chord:`Esc`,className:R3,children:`later`})]}),(0,R.jsx)(W3,{primary:`submit`,primaryLabel:o<e.length-1?`Next`:`Answer`,disabled:!O,submitting:t,onCancel:r})]})}function J3(e,t,n){let r=e.currentTarget,i=e.target;if(e.altKey||Oj(i))return;let a=kj(e.key);if(a){e.preventDefault(),Dj(r,i,a);return}let o=i instanceof HTMLInputElement&&i.dataset.option!==void 0?Number(i.dataset.option):-1;if((e.key===`Enter`||e.key===` `)&&o>=0){e.preventDefault(),n(o,e.key===`Enter`);return}let s=Number(e.key);Number.isInteger(s)&&s>=1&&s<=t&&(e.preventDefault(),n(s-1,!1),r.querySelector(`[data-option="${s-1}"]`)?.focus())}function Y3({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``),o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.querySelector(`[data-nav]`)?.focus()},[]),(0,R.jsxs)(`form`,{ref:o,className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i&&n(i)},onKeyDown:r=>J3(r,e.options.length,(r,i)=>{let o=e.options[r];o!==void 0&&(a(o),i&&!t&&n(o))}),children:[(0,R.jsx)(WH,{text:e.title,className:`text-base`}),(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map((e,t)=>(0,R.jsx)(H3,{option:{label:e},index:t,multi:!1,name:`choice`,selected:i===e,onToggle:()=>a(e)},e))}),(0,R.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`↑↓`,className:R3,children:`move`}),(0,R.jsx)(iA,{chord:`Enter`,className:R3,children:`choose`}),(0,R.jsx)(iA,{chord:`Esc`,className:R3,children:`later`})]}),(0,R.jsx)(W3,{primary:`submit`,primaryLabel:`Choose`,disabled:!i,submitting:t,onCancel:r})]})}function X3({view:e,submitting:t,onAnswer:n}){let r=(0,m.useRef)(null);(0,m.useEffect)(()=>r.current?.focus(),[]);function i(e){if(e.altKey||e.ctrlKey||e.metaKey||t)return;let r=e.key.toLowerCase();r===`y`?n(!0):r===`n`&&n(!1)}return(0,R.jsxs)(`div`,{ref:r,tabIndex:-1,"data-autofocus":``,onKeyDown:i,className:`flex min-w-0 flex-col gap-3 outline-none`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(WH,{text:e.question,className:`text-base`}),e.detail?(0,R.jsx)(WH,{text:e.detail,className:`mt-1 text-muted-foreground`}):null]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`Y`,className:R3,children:`yes`}),(0,R.jsx)(iA,{chord:`N`,className:R3,children:`no`}),(0,R.jsx)(iA,{chord:`Esc`,className:R3,children:`later`})]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n(!1),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`No`}),(0,R.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n(!0),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:t?`Sending…`:`Yes`})]})]})]})}function Z3({view:e,submitting:t,onAnswer:n,onCancel:r}){let[i,a]=(0,m.useState)(``);return(0,R.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-3`,onSubmit:e=>{e.preventDefault(),i.trim()&&n(i.trim())},children:[(0,R.jsx)(WH,{text:e.question,className:`text-base`}),(0,R.jsx)(sM,{autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},value:i,onChange:e=>a(e.target.value),placeholder:e.placeholder??I3,"aria-label":e.question,rows:3,className:`min-h-9 resize-none text-sm md:text-sm max-md:min-h-11`}),(0,R.jsxs)(`p`,{className:`flex items-center gap-x-4 text-xs text-muted-foreground`,children:[(0,R.jsx)(iA,{chord:`Enter`,className:R3,children:`answer`}),(0,R.jsx)(iA,{chord:`Shift+Enter`,className:R3,children:`new line`}),(0,R.jsx)(iA,{chord:`Esc`,className:R3,children:`later`})]}),(0,R.jsx)(W3,{primary:`submit`,primaryLabel:`Answer`,disabled:!i.trim(),submitting:t,onCancel:r})]})}function Q3({dialog:e,submitting:t,onAnswer:n}){let[r,i]=(0,m.useState)(e.method===`editor`?e.prefill??``:``),[a,o]=(0,m.useState)(``),s=e.options??[],c=e.method===`select`?a!==``:r.trim()!==``,l=(0,m.useRef)(null);(0,m.useEffect)(()=>{l.current?.querySelector(`[data-nav], textarea`)?.focus()},[]);function u(t){t.preventDefault(),e.method===`select`?n({value:a}):e.method===`confirm`?n({confirmed:!0}):(e.method===`input`||e.method===`editor`)&&n({value:r.trim()})}return(0,R.jsxs)(`form`,{ref:l,className:`flex min-w-0 flex-col gap-3`,onSubmit:u,onKeyDown:r=>{e.method===`select`&&J3(r,s.length,(e,r)=>{let i=s[e];i!==void 0&&(o(i),r&&!t&&n({value:i}))})},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.title}),e.message?(0,R.jsx)(WH,{text:e.message,className:`mt-1 text-base`}):null]}),e.method===`select`?(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:s.map((e,t)=>(0,R.jsx)(H3,{option:{label:e},index:t,multi:!1,name:`dialog`,selected:a===e,onToggle:()=>o(e)},e))}):null,e.method===`input`||e.method===`editor`?(0,R.jsx)(sM,{value:r,onChange:e=>i(e.target.value),placeholder:e.placeholder??I3,"aria-label":e.title,rows:e.method===`editor`?4:2,className:`min-h-9 resize-none text-sm md:text-sm max-md:min-h-11`}):null,(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({cancelled:!0}),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Cancel`}),e.method===`confirm`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,disabled:t,onClick:()=>n({confirmed:!1}),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`No`}),(0,R.jsx)(Y,{type:`button`,disabled:t,onClick:()=>n({confirmed:!0}),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:t?`Sending…`:`Yes`})]}):(0,R.jsx)(Y,{type:`submit`,disabled:!c||t,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:t?`Sending…`:`Answer`})]})]})}function $3(e){let{view:t}=e;return t.kind===`questionnaire`?(0,R.jsx)(q3,{questions:t.questions,submitting:e.submitting,onAnswer:e.onAnswer,onCancel:e.onCancel,...e.onExpand?{expanded:e.expanded??!1,onExpand:e.onExpand}:{}}):t.kind===`choose`?(0,R.jsx)(Y3,{...e,view:t}):t.kind===`confirm`?(0,R.jsx)(X3,{...e,view:t}):t.kind===`text`?(0,R.jsx)(Z3,{...e,view:t}):(0,R.jsx)(Q3,{...e,dialog:t.dialog})}function e6(e){return typeof e==`object`&&e?e:{}}function t6(e){return typeof e==`string`?e.trim():``}function n6(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function r6(e){let t=e6(e),n=t6(t.label);if(!n)return;let r=t6(t.description),i=t6(t.preview),a=t6(t.image),o=HX(t.htmlPreview);return{label:n,...r?{description:r}:{},...i?{preview:i}:{},...a?{image:a}:{},...o?{htmlPreview:o}:{}}}function i6(e){let t=e6(e),n=t6(t.question);if(!n)return;let r=(Array.isArray(t.options)?t.options:[]).map(r6).filter(e=>!!e);return{question:n,header:t6(t.header)||`Question`,options:r,...t.multiSelect===!0?{multiSelect:!0}:{}}}function a6(e){let t=e6(e),n=t6(t.method);if(n!==`select`&&n!==`confirm`&&n!==`input`&&n!==`editor`)return;let r=t6(t.message),i=n6(t.options),a=t6(t.placeholder),o=t6(t.prefill);return{id:t6(t.id),method:n,title:t6(t.title)||`Answer`,...r?{message:r}:{},...i.length>0?{options:i}:{},...a?{placeholder:a}:{},...o?{prefill:o}:{}}}function o6(e){let t=(Array.isArray(e.questions)?e.questions:[]).map(i6).filter(e=>!!e);return t.length>0?{kind:`questionnaire`,questions:t}:void 0}function s6(e){return{kind:`choose`,title:t6(e.title)||`Choose an option`,options:n6(e.options)}}function c6(e){let t=t6(e.question)||t6(e.title)||`Continue?`,n=t6(e.detail)||t6(e.message);return{kind:`confirm`,question:t,...n?{detail:n}:{}}}function l6(e){let t=t6(e.question)||t6(e.title)||`Type an answer`,n=t6(e.placeholder);return{kind:`text`,question:t,...n?{placeholder:n}:{}}}function u6(e){let t=e6(e.payload);if(e.kind===`questionnaire`)return o6(t);if(e.kind===`choose`)return s6(t);if(e.kind===`confirm`)return c6(t);if(e.kind===`text`)return l6(t);let n=a6(t.dialog);return n?{kind:`sessionDialog`,dialog:n}:void 0}var d6=`(max-width: 767.98px)`;function f6({submitting:e,onKeep:t,onLeave:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,role:`alert`,children:[(0,R.jsx)(`p`,{className:`text-sm`,children:`Leave without answering? The oracle will not guess for you.`}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(Y,{type:`button`,variant:`outline`,onClick:t,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Keep answering`}),(0,R.jsx)(Y,{type:`button`,disabled:e,onClick:n,className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:e?`Leaving…`:`Leave`})]})]})}function p6({count:e,onOpen:t}){return(0,R.jsxs)(Y,{type:`button`,variant:`soft`,onClick:t,"aria-label":`${e} question${e===1?``:`s`} waiting — open`,className:`gap-1.5 text-warning max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:[(0,R.jsx)(lm,{"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:e}),(0,R.jsx)(`span`,{className:`hidden md:inline`,children:`waiting`})]})}function m6({prompts:e,answer:t,dismiss:n,minimized:r,onMinimize:i}){let[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=cA(d6),{keyboardOpen:f,keyboardInset:p}=BA(),h=e.length,g=e[0],_=g?u6(g):void 0,v=h>0&&!r,y=XA(v,YA.question);(0,m.useEffect)(()=>{h===0&&(o(!1),i(!1))},[h,i]);let b=g?.id;(0,m.useEffect)(()=>u(!1),[b]);async function x(e,t){c(!0);try{await e,o(!1)}catch(e){e instanceof Ce&&e.code===`question_withdrawn`?H(ej):H.error(e instanceof Error?e.message:t)}finally{c(!1)}}let S=g?.from?`${g.from} asks`:`A question`;return(0,R.jsx)(HA,{open:v&&y&&!!g,label:`Question from the lobby`,dismissOnBackdrop:!1,onOpenChange:e=>{e||(l?u(!1):a?o(!1):i(!0))},style:d&&f?{maxHeight:`calc(100vh - ${p}px - 1.5rem)`}:void 0,className:q(l?`h-[min(92svh,60rem)] max-h-[min(92svh,60rem)] max-w-6xl`:`max-w-3xl`,`max-md:w-[calc(100vw-2rem)] max-md:max-w-[calc(100vw-2rem)] max-md:max-h-[calc(100svh-1.5rem)]`,l&&`max-md:h-[calc(100svh-1.5rem)]`),children:g?(0,R.jsxs)(`section`,{"aria-label":`Question from the lobby`,className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsxs)(`header`,{className:q(`flex items-center gap-3 px-6 pt-5 pb-3 max-md:px-4 max-md:pt-4 max-md:pb-2`,l&&`hidden`),children:[(0,R.jsxs)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-muted-foreground first-letter:uppercase`,children:[S,h>1?` · 1 of ${h}`:``]}),(0,R.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Later: put the question away`,title:d?`Later`:`Later · Esc`,onClick:()=>i(!0),className:`max-md:size-11`,children:(0,R.jsx)(Vg,{"aria-hidden":`true`})})]}),(0,R.jsx)(`div`,{className:l?`flex min-h-0 min-w-0 flex-1 flex-col`:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-6 pb-6 max-md:px-4 max-md:pb-4`,children:_?a?(0,R.jsx)(f6,{submitting:s,onKeep:()=>o(!1),onLeave:()=>void x(n(g.id),`Could not leave the question`)}):(0,R.jsx)($3,{view:_,submitting:s,onAnswer:e=>void x(t(g.id,e),`Could not send the answer`),onCancel:()=>o(!0),expanded:l,onExpand:u},g.id):(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 max-md:flex-wrap max-md:justify-start`,children:[(0,R.jsx)(`p`,{className:`max-md:min-w-0 max-md:flex-1 text-sm text-muted-foreground`,children:`This question cannot be shown here.`}),(0,R.jsx)(Y,{type:`button`,disabled:s,onClick:()=>void x(n(g.id),`Could not dismiss the question`),className:`max-md:h-auto max-md:min-h-11 max-md:min-w-11 max-md:whitespace-normal`,children:`Dismiss`})]})})]}):null})}var h6=2;function g6(e){let t=globalThis.EventSource;if(!t)throw Error(`EventSource is not available in this environment`);return new t(e)}function _6(e){try{return JSON.parse(e)}catch{return}}function v6(e,t){switch(e.type){case`hello`:t.onHello?.(e.versions);return;case`changed`:t.onChanged?.(e.topic,e.version);return;case`feed`:t.onFeed?.({activity:e.activity,thoughts:e.thoughts,chat:e.chat});return;case`reply`:t.onReply?.(e.text);return;case`notice`:t.onNotice?.(e.text,e.level)}}function y6(e,t=g6){let n=t(F(`/api/events`));return e.onConnection?.(`connecting`),n.onopen=()=>e.onConnection?.(`live`),n.onerror=()=>e.onConnection?.(n.readyState===h6?`offline`:`connecting`),n.onmessage=t=>{let n=_6(t.data);n&&v6(n,e)},()=>n.close()}var b6=2e3,x6=()=>Te(`projects.list`,{});async function S6(){let e;try{e=P()}catch{return}if(e&&!xe(e))try{be((await x6()).projects)}catch{}}function C6(){let e=(0,m.useRef)(void 0),t=(0,m.useRef)(void 0),n=(0,m.useCallback)(()=>{clearTimeout(t.current),e.current?.();try{P()}catch{fe.onStatus({connection:`offline`});return}e.current=y6({onHello:e=>{fe.onHello(e),S6()},onChanged:(e,t)=>fe.onChanged(e,t),onFeed:e=>fe.onFeedDelta(e),onReply:e=>fe.onReplyDelta(e),onNotice:(e,t)=>H[t](e),onConnection:e=>{fe.onStatus({connection:e}),e===`offline`&&(clearTimeout(t.current),t.current=setTimeout(()=>{Se(x6).catch(()=>!1).finally(n)},b6))}})},[]);return(0,m.useEffect)(()=>(n(),()=>{clearTimeout(t.current),e.current?.()}),[n]),n}var w6=`bot-lobby.recoveredAt`,T6;function E6(e,t=D6()){try{T6===void 0&&(T6=Number(t?.getItem(w6)??0))}catch{T6??=0}if(T6!==void 0&&e<=T6)return!1;T6=e;try{t?.setItem(w6,String(e))}catch{}return!0}function D6(){try{return globalThis.sessionStorage}catch{return}}function O6(e){let t=e?.recovered?.at,n=e?.recovered?.text;(0,m.useEffect)(()=>{t!==void 0&&n&&E6(t)&&H.success(n)},[t,n])}function k6(){let e=sA(`prompts`),t=(0,m.useCallback)(async(e,t)=>{await Te(`prompts.answer`,{id:e,answer:t})},[]),n=(0,m.useCallback)(async e=>{await Te(`prompts.dismiss`,{id:e})},[]);return{prompts:e.data?.prompts??[],loading:e.loading,error:e.error,answer:t,dismiss:n}}function A6(e,t,n,r){e===`search`?(document.querySelector(`#main input[type='search']`)??document.getElementById(`composer-text`))?.focus():e===`help`?n():e===`settings`?aj(`#/settings`):e===`sessions`?aj(`#/sessions`):e===`thinking`?UK(`lobby.thinking`):e===`activity`?t.kind===`tab`&&t.tab===`lobby`?UK(`lobby.activity`):aj(ij(`lobby`)):e===`nextTab`?r(1):e===`prevTab`?r(-1):e===`savePlan`&&t.kind===`tab`&&t.tab===`plan`&&U(`planner.save`,{})}var j6=2500;function M6(e){let[t,n]=(0,m.useState)(!1),r=(0,m.useRef)(!1);return e===`live`&&(r.current=!0),(0,m.useEffect)(()=>{if(e!==`connecting`||!r.current)return n(!1);let t=setTimeout(()=>n(!0),j6);return()=>clearTimeout(t)},[e]),e===`offline`||e===`connecting`&&t}function N6({connection:e,onRetry:t}){return M6(e)?(0,R.jsx)(bj,{onRetry:t}):null}var P6={tick:0,route:0,focus:0};window.addEventListener(`hashchange`,()=>{P6.route=++P6.tick}),document.addEventListener(`focusin`,()=>{P6.focus=++P6.tick});var F6=()=>P6.focus>P6.route;function I6(e){return e.kind===`tab`?e.tab:e.kind}function L6(){let e=oj(),t=sA(`status`),n=sA(`lobby`),{prompts:r,answer:i,dismiss:a}=k6(),{connection:o,signedOut:s}=oA(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(null),p=C6();WJ();let h=t.data;O6(h);let g=!!h&&!s;(0,m.useEffect)(()=>{g&&Ve()},[g]);let _=h?.tabs??[],v=h?.keys??[],y=e.kind===`tab`?e.tab:void 0,b=(0,m.useCallback)(e=>aj(ij(e)),[]),x=(0,R.jsx)(W4,{tabs:_,activeId:y,onSelect:b}),S=cA(`(max-width: 767.98px)`),C=(0,m.useCallback)(e=>{let t=S?_.filter(e=>e.id!==`metrics`):_;if(t.length===0)return;let n=t[(Math.max(0,t.findIndex(e=>e.id===y))+e+t.length)%t.length];n&&aj(ij(n.id))},[_,y,S]),w=(0,m.useCallback)(()=>l(e=>!e),[]),T=(0,m.useCallback)(t=>{(t!==`thinking`&&t!==`activity`||h?.panels?.[t]!==!1)&&A6(t,rj(window.location.hash)??e,w,C)},[e,w,C,h?.panels]),E=(0,m.useCallback)(()=>{let e=document.activeElement;return!e||e===document.body||f.current?.contains(e)===!0||e.closest(`.thinking-bubble`)?!0:e.closest(`[data-state='closed']`)!==null},[]);c0({enabled:!!h,keys:v,tabs:_,insideApp:E,onAction:T,onTab:b});let D=(0,m.useCallback)(()=>fe.onHello({}),[]),O=e.kind===`tab`?e.tab:e.kind,k=!!h;(0,m.useEffect)(()=>{if(!k)return;let e=Rj.active&&Rj.to===O;if(Rj.active=!1,Rj.to=void 0,e)return;let t=requestAnimationFrame(()=>{if(F6()||document.querySelector(`[role='dialog']:not([data-state='closed'])`))return;let e=document.getElementById(`composer-text`),t=window.matchMedia(`(max-width: 767.98px)`).matches,n=window.matchMedia(`(pointer: coarse)`).matches;!t&&!n&&e&&!e.disabled?e.focus({preventScroll:!0}):document.activeElement?.id!==`composer-text`&&document.getElementById(`main`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[O,k]);let A=Object.fromEntries(v.map(e=>[e.action,e.label])),ee=(0,R.jsx)(n2,{status:h,task:n.data?.task,connection:o,route:e,keys:A,onHelp:w,tabs:S?null:x,extra:u&&r.length>0?(0,R.jsx)(p6,{count:r.length,onOpen:()=>d(!1)}):null});return s||!h?(0,R.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[ee,(0,R.jsx)(`main`,{className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto max-md:mx-0 max-md:mb-0`,children:s?(0,R.jsx)(i2,{}):t.error?(0,R.jsx)(yj,{message:t.error,onRetry:D}):(0,R.jsx)(vj,{})})]}):(0,R.jsxs)(`div`,{ref:f,className:`fixed inset-0 flex flex-col`,children:[ee,(0,R.jsx)(N6,{connection:o,onRetry:p}),(0,R.jsx)(`main`,{id:`main`,tabIndex:-1,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||Oj(e.target)||e.target.closest(`[role='dialog'], [role='menu'], [role='listbox']`)||Lj()&&e.preventDefault()},role:y?`tabpanel`:void 0,"aria-labelledby":y?`tab-${y}`:void 0,className:`surface mx-3 mb-3 flex min-h-0 flex-1 flex-col overflow-y-auto outline-none max-md:mx-0 max-md:mb-0`,children:(0,R.jsx)(B.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:[.2,.8,.2,1]},className:`flex min-h-0 flex-1 flex-col`,children:Y1(e)},I6(e))}),(0,R.jsx)(N0,{route:e,keys:A,onHelp:w,dockNav:S?x:null}),(0,R.jsx)(N3,{status:h,lobby:n.data}),(0,R.jsx)(m6,{prompts:r,answer:i,dismiss:a,minimized:u,onMinimize:d}),(0,R.jsx)(y0,{open:c,onOpenChange:l,keys:v,tabs:_})]})}async function R6(e){switch(e){case`status`:return Te(`status.get`,{});case`lobby`:return Te(`lobby.snapshot`,{});case`prompts`:return Te(`prompts.list`,{});default:return}}var z6=[`status`,`lobby`,`prompts`];function B6(){let[e,t]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{let e=!0;return(async()=>{await De(),e&&(fe.markUsed(z6,R6),t(!0))})(),()=>{e=!1}},[]),e}function V6(){return B6()?(0,R.jsx)(L6,{}):(0,R.jsx)(`div`,{className:`fixed inset-0 flex`,children:(0,R.jsx)(vj,{})})}var H6={info:Gm,success:rm,warning:Tg,error:pm},U6={info:`text-primary`,success:`text-success`,warning:`text-warning`,error:`text-destructive`};function W6(){let{item:e,waiting:t}=ap(),n=QA(),r=e&&!n;return(0,m.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>rp(e.id),t>0?Math.min(e.duration,1600):e.duration);return()=>window.clearTimeout(r)},[e,n,t]),(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`pointer-events-none fixed inset-x-0 z-40 flex justify-center px-4`,style:{bottom:`calc(var(--composer-h, 0px) + 0.25rem)`},children:(0,R.jsx)(Du,{mode:`wait`,children:r?(0,R.jsxs)(B.div,{initial:{opacity:0,scale:.55,y:18},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:6,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,stiffness:560,damping:15,mass:.8},className:`pointer-events-auto flex max-w-[min(32rem,100%)] items-center gap-3 rounded-xl border border-glass-border bg-popover/80 px-4 py-2.5 text-sm text-popover-foreground shadow-glass backdrop-blur-xs`,children:[(0,R.jsx)(G6,{kind:e.kind}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.message}),e.action?(0,R.jsx)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,className:`btn-raised -my-1.5 -mr-1 h-7 shrink-0 rounded-lg border bg-card px-2.5 font-medium text-primary transition-[box-shadow,translate] active:translate-y-px focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none`,onClick:()=>{e.action?.onClick(),rp(e.id)},children:e.action.label}):null]},e.id):null})})}function G6({kind:e}){let t=H6[e];return(0,R.jsx)(t,{"aria-hidden":`true`,className:q(`size-5 shrink-0`,U6[e])})}(0,Xf.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(m.StrictMode,{children:(0,R.jsx)(_Y,{children:(0,R.jsx)(Pu,{reducedMotion:`user`,children:(0,R.jsxs)(Sj,{children:[(0,R.jsx)(V6,{}),(0,R.jsx)(W6,{})]})})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/sw.js`,{updateViaCache:`none`}).catch(()=>void 0)});
|