@a-t-h-i/bot-lobby 0.6.37 → 0.6.38

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.
@@ -89,7 +89,7 @@ Error generating stack: `+e.message+`
89
89
  `)),t}function CH(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 wH(e,t){return!e&&!t}async function TH(e,t){if(!t)throw Error(`Clipboard is unavailable. Select the code and copy it manually.`);await t.writeText(e)}var EH=/^-\s+(.+?)\s+\(([^()\s]+\/[^()\s]+)\)\s*$/;function DH(e){let t=e.lastIndexOf(`${rj}\n`);if(t<0||t>0&&e[t-1]!==`
90
90
  `)return{body:e,files:[]};let n=e.slice(t+rj.length+1).split(`
91
91
  `).filter(Boolean),r=[];for(let t of n){let n=EH.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 OH=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function kH({files:e}){return e.length===0?null:(0,z.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,z.jsx)(`li`,{children:OH.has(e.mime)?(0,z.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,z.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,z.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,z.jsx)(Fm,{"aria-hidden":`true`,className:`size-4 shrink-0`}):(0,z.jsx)(jh,{"aria-hidden":`true`,className:`size-4 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))})}var AH=!1,jH=[],MH=0,NH=900;function PH(){AH=!0,window.clearTimeout(MH),MH=window.setTimeout(FH,NH)}function FH(){AH=!1,window.clearTimeout(MH);let e=jH;jH=[];for(let t of e)t()}function IH(e){if(!AH)return e(),()=>{};let t=()=>e();return jH.push(t),()=>{jH=jH.filter(e=>e!==t)}}var LH=8;function RH(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=IH(()=>{e=requestAnimationFrame(()=>{let e=performance.now();(0,Wv.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*LH/t)))})});return()=>{t(),cancelAnimationFrame(e)}},[a,n]),Math.min(n,e)}function zH(e){return e?.type===`text`?e.value??``:(e?.children??[]).map(zH).join(``)}function BH(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}),BH(t,n)}function VH(){return e=>BH(e)}function HH(e){let[t,n]=(0,m.useState)(!1);async function r(){try{await TH(e,navigator.clipboard),n(!0),rp.success(`Code copied.`)}catch{rp.error(`Could not copy code. Select it and copy manually, or allow clipboard access.`)}}return{copied:t,copy:r}}function UH({text:e,children:t,block:n=!1}){let{copy:r}=HH(e),i=(0,m.useRef)(void 0);return(0,z.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(),wH(window.getSelection()?.toString()??``,i.current?.moved??!1)&&r(),i.current=void 0},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),wH(window.getSelection()?.toString()??``,!1)&&r())},children:[t,n?null:(0,z.jsx)(`span`,{className:`sr-only`,children:` (activate to copy)`})]})}function WH({node:e,children:t,source:n}){let r=e,{copied:i,copy:a}=HH(CH(n,r?.position,!0)??zH(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,z.jsxs)(`div`,{className:`relative my-3 max-md:min-w-0 max-md:max-w-full rounded-lg bg-muted`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between pl-3`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[s&&/^[\w+#.-]{1,20}$/.test(s)?s:`code`,` · tap to copy`]}),(0,z.jsx)(X,{label:i?`Copied`:`Copy the code`,icon:i?Vp:Cm,iconOnly:!0,onClick:()=>void a()})]}),(0,z.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 GH(e){return{pre:t=>(0,z.jsx)(WH,{...t,source:e}),code:({node:t,children:n})=>{let r=t;if(r?.properties?.copyBlocked)return(0,z.jsx)(`code`,{children:n});let i=!!r?.properties?.blockCode;return(0,z.jsx)(UH,{text:CH(e,r?.position,i)??zH(r),block:i,children:n})},a:({href:e,children:t})=>(0,z.jsx)(`a`,{href:e?F(e):void 0,target:`_blank`,rel:`noopener noreferrer nofollow`,children:t}),img:({src:e,alt:t})=>(0,z.jsx)(`img`,{src:e?F(e):void 0,alt:t??``,loading:`lazy`}),table:({children:e})=>(0,z.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,z.jsx)(`table`,{className:`w-full max-md:min-w-max border-collapse text-sm`,children:e})})}}var KH=(0,m.memo)(function({text:e}){return(0,z.jsx)(lz,{remarkPlugins:[hH],rehypePlugins:[VH],urlTransform:_H,components:GH(e),children:e})}),qH=(0,m.memo)(function({text:e,className:t}){let{body:n,files:r}=DH(e),i=n?SH(n):[],a=RH(i.length,3);return(0,z.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,z.jsx)(KH,{text:e},t)),(0,z.jsx)(kH,{files:r})]})});function JH({title:e,note:t,className:n,children:r,collapsed:i,onToggle:a,shortcut:o,...s}){let c=typeof e==`string`?e:`pane`;return(0,z.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,z.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,z.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-medium`,children:e}):(0,z.jsx)(`span`,{}),(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[t?(0,z.jsx)(`span`,{className:`flex items-center gap-2 truncate text-xs text-muted-foreground`,children:t}):null,a?(0,z.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,z.jsx)(aA,{chord:o,className:`kbd-hint max-md:hidden`}):null,(0,z.jsx)(Up,{"aria-hidden":`true`,className:q(`size-4 transition-transform duration-200 ease-snap`,i&&`-rotate-90`)})]}):null]})]}):null,i?null:r]})}function YH({title:e,right:t,className:n}){return(0,z.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-3`,n),children:[(0,z.jsx)(`span`,{className:`truncate font-medium`,children:e}),(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`}),t?(0,z.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-muted-foreground`,children:t}):null]})}function XH({title:e,right:t,prominent:n,children:r}){return(0,z.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,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:(0,z.jsx)(YH,{title:e,right:t,className:n?`[&>span:first-child]:font-semibold`:void 0})}),r]})}var ZH=`Pull requests`,QH=`An agent reviews it, optionally with a focus you type; Jev's quick read sizes it up first.`,$H=`nothing is posted to GitHub`,eU=`Refresh to load open pull requests with the GitHub CLI (gh).`,tU=`No open pull requests.`,nU=`loading pull requests from GitHub…`,rU=`reading the diff…`,iU=`the pull request has new commits since this review — review it again`,aU=`(no description)`,oU=`Review with a focus (optional)`,sU=`Leave it empty for a full review.`;function cU(e){return e===`passing`?`✓`:e===`failing`?`✗`:e===`pending`?`…`:``}function lU(e){return e===`passing`?`text-success`:e===`failing`?`text-destructive`:`text-muted-foreground`}function uU(e,t){return`+${e} −${t}`}function dU(e){return e===`APPROVED`?`approved`:e===`CHANGES_REQUESTED`?`changes requested`:e===`REVIEW_REQUIRED`?`review required`:``}function fU(e){return e?e.status===`running`?`reviewing`:e.status!==`done`||!e.verdict?``:e.verdict===`approve`?`approved`:e.verdict===`changes`?`changes found`:`commented`:``}function pU(e){return e===`approve`?`approve`:e===`changes`?`request changes`:e===`comment`?`comment`:``}function mU(e,t){if(e.status===`running`)return hU(e,t);if(e.status===`cancelled`)return`stopped`;let n=e.status===`done`?hU(e,t):e.status;return[pU(e.verdict),n].filter(Boolean).join(` · `)}function hU(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 gU(e,t){return[e.state?e.draft?`draft`:e.state.toLowerCase():e.draft?`draft`:``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${mM(t-Date.parse(e.updatedAt))}`:``].filter(Boolean).join(` · `)}function _U(e){let t=`${e.changedFiles} file${e.changedFiles===1?``:`s`}`;return`${e.headRef||`?`} → ${e.baseRef||`?`} · ${uU(e.additions,e.deletions)} · ${t}`}function vU(e){let t=e.mergeable===`CONFLICTING`?`conflicts`:e.mergeable===`MERGEABLE`?`mergeable`:``;return[e.checks?`checks ${e.checks} (${e.checkCount})`:``,dU(e.decision),t,e.labels.join(`, `)].filter(Boolean).join(` · `)}function yU(e){return[`${e.changedFiles} file${e.changedFiles===1?``:`s`}`,e.labels.join(`, `),e.review?.stale?`stale`:``].filter(Boolean).join(` · `)}function bU(e){return e.read?`${e.read.model} · ${e.read.ms} ms`:``}function xU(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 SU({pull:e,now:t}){return(0,z.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,z.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:gU(e,t)}),(0,z.jsx)(`p`,{className:`text-sm tabular-nums`,children:_U(e)}),vU(e)?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:vU(e)}):null,e.url?(0,z.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 CU({read:e}){return(0,z.jsxs)(XH,{title:`Jev's read`,right:bU(e),children:[e.status===`running`?(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(hj,{className:`size-3.5`}),rU]}):null,e.status===`failed`?(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:e.error??`Jev could not read it`}):null,e.status===`done`&&e.line?(0,z.jsx)(qH,{text:e.line}):null]})}function wU({review:e,now:t}){return(0,z.jsxs)(z.Fragment,{children:[e.model?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:[e.model,e.thinking].filter(Boolean).join(` · `)}):null,e.focus?(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`focus: `,e.focus]}):null,e.saved?(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`kept from `,mM(t-e.startedAt)]}):null,e.stale?(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:iU}):null,e.status===`running`?(0,z.jsx)(TU,{steps:e.steps}):null,e.status===`cancelled`?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`stopped`}):null,e.status===`failed`||e.status===`timeout`?(0,z.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`✗ `,e.error??e.status]}):null,e.text?(0,z.jsx)(qH,{text:e.text}):null]})}function TU({steps:e}){return(0,z.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm text-muted-foreground`,children:e.slice(-6).map((e,t)=>(0,z.jsxs)(`li`,{className:`break-words`,children:[`· `,e]},t))})}function EU({number:e,focus:t,onChange:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`label`,{htmlFor:`focus-${e}`,className:`text-[0.8125rem] font-medium text-foreground`,children:oU}),(0,z.jsx)(lM,{id:`focus-${e}`,value:t,rows:2,maxLength:2e3,className:`max-md:min-h-11`,onChange:e=>n(e.target.value)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:sU})]})}function DU({number:e,review:t,now:n,focus:r,onFocus:i}){return(0,z.jsxs)(XH,{title:`Review`,right:t?mU(t,n):void 0,children:[t?(0,z.jsx)(wU,{review:t,now:n}):null,(0,z.jsx)(EU,{number:e,focus:r,onChange:i}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`A read-only agent reviews it — `,$H,`.`]})]})}function OU({files:e}){return(0,z.jsx)(XH,{title:`Files`,right:String(e.length),children:(0,z.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-border`,children:(0,z.jsx)(`table`,{className:`w-full border-collapse text-sm tabular-nums`,children:(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,z.jsx)(`td`,{className:`max-w-0 px-3 py-1.5 break-all`,children:e.path}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right text-xs whitespace-nowrap text-muted-foreground`,children:uU(e.additions,e.deletions)})]},e.path))})})})})}function kU({note:e,now:t}){let n=[e.state&&e.state!==`COMMENTED`?e.state.toLowerCase().replace(/_/g,` `):``,e.at?mM(t-Date.parse(e.at)):``].filter(Boolean).join(` · `);return(0,z.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),n?(0,z.jsx)(`span`,{children:n}):null]}),e.body.trim()?(0,z.jsx)(qH,{text:e.body.trim()}):null]})}function AU({notes:e,now:t}){return e.length===0?null:(0,z.jsx)(XH,{title:`Discussion`,right:String(e.length),children:(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,z.jsx)(kU,{note:e,now:t},n))})})}function jU({number:e,error:t}){return t?(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t]}):(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(hj,{className:`size-3.5`}),`loading #`,e,`…`]})}function MU({number:e,onChanged:t}){let n=Cj(`git.pull`,{number:e},[`git`]),[r,i]=(0,m.useState)(``),a=n.data?.review?.status===`running`,o=xU(a);if(!n.data)return(0,z.jsx)(jU,{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,z.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`Pull request #${e}`,children:[(0,z.jsxs)(qj,{children:[(0,z.jsx)(X,{label:`Review`,icon:Uh,tone:`primary`,shortcut:`V`,disabled:a,onClick:()=>void d()}),(0,z.jsx)(X,{label:`Jev's read`,icon:Fp,shortcut:`Q`,disabled:a,onClick:()=>void f()}),a?(0,z.jsx)(TM,{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,z.jsx)(SU,{pull:s,now:o}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:QH}),l?(0,z.jsx)(CU,{read:l}):null,(0,z.jsx)(DU,{number:e,review:c,now:o,focus:r,onFocus:i}),s.files.length>0?(0,z.jsx)(OU,{files:s.files}):null,(0,z.jsx)(XH,{title:`Description`,children:s.body.trim()?(0,z.jsx)(qH,{text:s.body.trim()}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:aU})}),(0,z.jsx)(AU,{notes:s.notes,now:o})]})}var NU=Xg([`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 PU({className:e,variant:t,size:n,radius:r,asChild:i=!1,...a}){let o=i?jv:`span`;return(0,z.jsx)(o,{"data-slot":`badge`,className:q(NU({variant:t,size:n,radius:r,className:e})),...a})}var FU=`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`,IU=`flex flex-col gap-1 px-2 pb-3`,LU=`px-4 pt-4 pb-1 text-xs font-medium text-muted-foreground`;function RU({checks:e}){let t=cU(e);return t?(0,z.jsx)(`span`,{className:q(`w-4 shrink-0 text-center`,lU(e)),"aria-hidden":`true`,children:t}):(0,z.jsx)(`span`,{className:`w-4 shrink-0`,"aria-hidden":`true`})}function zU({pull:e,selected:t,onSelect:n}){let r=fU(e.review);return(0,z.jsx)(`li`,{children:(0,z.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(FU,`max-md:min-h-11`),children:[(0,z.jsxs)(`span`,{className:`flex items-start gap-2 text-sm`,children:[(0,z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,z.jsx)(RU,{checks:e.checks}),e.draft?(0,z.jsx)(PU,{variant:`secondary`,children:`draft`}):null,(0,z.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title})]}),(0,z.jsxs)(`span`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:yU(e)}),(0,z.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[r?(0,z.jsx)(`span`,{children:r}):null,(0,z.jsx)(`span`,{className:`tabular-nums`,children:uU(e.additions,e.deletions)})]})]})]})})}function BU({pulls:e,selectedId:t,onSelect:n}){return(0,z.jsx)(`ul`,{className:IU,children:e.map(e=>(0,z.jsx)(zU,{pull:e,selected:e.number===t,onSelect:n},e.number))})}var VU=()=>sj(oj(`git`)),HU=e=>sj(oj(`git`,String(e)));function UU(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function WU({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?tU:e?nU:eU;return(0,z.jsxs)(lj,{className:`m-4 flex-1`,children:[(0,z.jsxs)(uj,{children:[(0,z.jsx)(fj,{variant:`icon`,children:(0,z.jsx)(Um,{"aria-hidden":`true`})}),(0,z.jsx)(mj,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,z.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,children:`Retry`}):null]})}function GU({rest:e}){let t=nM(),n=Cj(`git.pulls`,{},[`git`]),r=UU(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,z.jsx)(xj,{message:`Could not load pull requests. ${n.error}`,onRetry:n.reload});if(n.data&&i.length===0)return(0,z.jsx)(WU,{loading:n.data.loading,loaded:n.data.loaded,error:n.data.error,onRetry:n.reload});let o=n.loading||!!n.data?.loading,s=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(sM,{title:ZH,count:n.data?`${i.length} open`:void 0,children:(0,z.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:o,className:q(`h-7`,o&&`[&_svg]:animate-spin`),onClick:a})}),n.data?.error?(0,z.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,n.data.error]}):null,n.data?(0,z.jsx)(BU,{pulls:i,selectedId:r,onSelect:HU}):(0,z.jsx)(cM,{})]}),c=r===void 0?null:(0,z.jsx)(MU,{number:r,onChanged:n.reload},r);return(0,z.jsx)(oM,{wide:t,list:s,detail:c,open:r!==void 0,onClose:VU,hint:`Select a pull request to see its detail.`,describe:`Pull request detail`})}function KU(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function qU({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,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium text-foreground`,children:e}),(0,z.jsx)(lM,{id:i,value:a,rows:2,"aria-describedby":t?`${i}-hint`:void 0,onChange:e=>o(e.target.value),onKeyDown:e=>{KU(e)&&(e.preventDefault(),l())}}),t?(0,z.jsx)(`p`,{id:`${i}-hint`,className:q(`text-xs text-muted-foreground`,/(?:Enter|Esc)/.test(t)&&`max-md:hidden`),children:t}):null,(0,z.jsx)(`div`,{className:`flex self-end`,children:(0,z.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 JU=`Issues`,YU=`Issue`,XU=`Plan it opens a planning session on this issue; save the plan as a task once the panel agrees it.`,ZU=`Refresh to load open issues with the GitHub CLI (gh).`,QU=`No open issues. File one with New issue.`,$U=`loading issues from GitHub…`,eW=`issues are off (lobby.issues)`,tW=`(no description)`;function nW(e,t){return[e.state?e.state.toLowerCase():``,e.author?`by ${e.author}`:``,e.updatedAt?`updated ${mM(t-Date.parse(e.updatedAt))}`:``,e.labels.join(`, `)].filter(Boolean).join(` · `)}function rW(e,t){return[e.author?`by ${e.author}`:``,e.updatedAt?mM(t-Date.parse(e.updatedAt)):``].filter(Boolean).join(` · `)}function iW(e){return e.length>0?`[${e.slice(0,2).join(`, `)}]`:``}function aW({issue:e,now:t}){return(0,z.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:[(0,z.jsxs)(`span`,{className:`font-normal text-muted-foreground tabular-nums`,children:[`#`,e.number]}),` `,e.title]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:nW(e,t)}),e.url?(0,z.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 oW({comment:e,now:t}){return(0,z.jsxs)(`article`,{className:`card-raised flex flex-col gap-1.5 rounded-lg border px-3.5 py-2.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e.author??`comment`}),e.createdAt?(0,z.jsx)(`span`,{children:mM(t-Date.parse(e.createdAt))}):null]}),(0,z.jsx)(qH,{text:e.body.trim()})]})}function sW({comments:e,now:t}){return e.length===0?null:(0,z.jsx)(XH,{title:`Comments`,right:String(e.length),children:(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,z.jsx)(oW,{comment:e,now:t},n))})})}function cW({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}})&&sj(oj(`plan`))};return(0,z.jsx)(TM,{icon:Vg,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 lW({number:e}){let t=Cj(`issues.get`,{number:e},[`issues`]),n=Date.now();if(!t.data)return t.error?(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not load #`,e,`. `,t.error]}):(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(hj,{className:`size-3.5`}),`loading #`,e,`…`]});let r=t.data.issue;return(0,z.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${YU} #${e}`,children:[(0,z.jsx)(qj,{children:(0,z.jsx)(cW,{issue:r})}),(0,z.jsx)(aW,{issue:r,now:n}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:XU}),(0,z.jsx)(XH,{title:`Description`,children:r.body.trim()?(0,z.jsx)(qH,{text:r.body.trim()}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:tW})}),(0,z.jsx)(sW,{comments:r.comments,now:n})]})}function uW({issue:e,selected:t,now:n,onSelect:r}){let i=iW(e.labels);return(0,z.jsx)(`li`,{children:(0,z.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(FU,`max-md:min-h-11`),children:[(0,z.jsxs)(`span`,{className:`flex flex-wrap items-start gap-2 text-sm`,children:[(0,z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:[`#`,e.number]}),(0,z.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,t&&`font-medium`),children:e.title}),i?(0,z.jsx)(`span`,{className:`max-w-full break-words text-xs text-muted-foreground`,children:i}):null]}),(0,z.jsx)(`span`,{className:`pl-9 text-xs text-muted-foreground`,children:rW(e,n)})]})})}function dW({issues:e,selectedId:t,now:n,onSelect:r}){return(0,z.jsx)(`ul`,{className:IU,children:e.map(e=>(0,z.jsx)(uW,{issue:e,selected:e.number===t,now:n,onSelect:r},e.number))})}var fW=()=>sj(oj(`issues`)),pW=e=>sj(oj(`issues`,String(e)));function mW(e){let t=Number(e[0]);return Number.isInteger(t)&&t>0?t:void 0}function hW(){return(0,z.jsx)(lj,{className:`m-4 flex-1`,children:(0,z.jsxs)(uj,{children:[(0,z.jsx)(fj,{variant:`icon`,children:(0,z.jsx)(sm,{"aria-hidden":`true`})}),(0,z.jsx)(pj,{children:`Issues are off`}),(0,z.jsx)(mj,{className:`font-mono`,children:eW})]})})}function gW({loading:e,loaded:t,error:n,onRetry:r}){let i=n?`✗ ${n}`:t?QU:e?$U:ZU;return(0,z.jsxs)(lj,{className:`m-4 flex-1`,children:[(0,z.jsxs)(uj,{children:[(0,z.jsx)(fj,{variant:`icon`,children:(0,z.jsx)(sm,{"aria-hidden":`true`})}),(0,z.jsx)(mj,{className:n?`text-destructive`:void 0,children:i})]}),n?(0,z.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,children:`Retry`}):null]})}function _W({onCreate:e}){return(0,z.jsx)(rM,{className:`shrink-0 border-t border-border p-4`,children:(0,z.jsx)(qU,{label:`New issue`,hint:`The first line becomes the title; the rest is the body. Enter files it.`,buttonLabel:`File issue`,onSend:e})})}function vW({rest:e}){let t=nM(),n=lA(`status`).data?.issuesEnabled??!0,r=Cj(`issues.list`,{},[`issues`],n),i=mW(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,z.jsx)(hW,{});if(!r.data&&r.error)return r.error.includes(`issues are off`)?(0,z.jsx)(hW,{}):(0,z.jsx)(xj,{message:`Could not load issues. ${r.error}`,onRetry:r.reload});let l=r.loading||!!r.data?.loading,u=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(sM,{title:JU,count:r.data?`${a.length} open`:void 0,children:(0,z.jsx)(X,{label:`Refresh`,icon:qh,shortcut:`R`,disabled:l,className:q(`h-7`,l&&`[&_svg]:animate-spin`),onClick:s})}),r.data?.error?(0,z.jsxs)(`p`,{className:`px-3 pt-2 text-sm text-destructive`,children:[`✗ `,r.data.error]}):null,r.data?(0,z.jsx)(dW,{issues:a,selectedId:i,now:o,onSelect:pW}):(0,z.jsx)(cM,{}),(0,z.jsx)(_W,{onCreate:c})]}),d=i===void 0?null:(0,z.jsx)(lW,{number:i},i),f=r.data&&a.length===0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(gW,{loading:r.data.loading,loaded:r.data.loaded,error:r.data.error,onRetry:r.reload}),(0,z.jsx)(`div`,{className:`shrink-0 pb-dock`,children:(0,z.jsx)(_W,{onCreate:c})})]}):(0,z.jsx)(oM,{wide:t,list:u,detail:d,open:i!==void 0,onClose:fW,hint:`Select an issue to read it.`,describe:`Issue detail`});return(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:f})}function yW(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 bW={DEV:ym,DESIGN:Dh,QA:lg,RESEARCH:xg,"QUICK FIX":Gg,SCOUT:xm,PLANNER:tg,CLASSIFIER:yg,LOBBY:hh,LINT:$m};function xW(e){return e?bW[e.toUpperCase()]??Lp:zp}function SW(e){let t=e?.toUpperCase();return t===`ORACLE`||t===`MASTER`}function CW({source:e,className:t,strokeWidth:n}){if(SW(e))return(0,z.jsx)(`span`,{"aria-hidden":`true`,"data-agent-icon":e,className:q(`agent-oracle shrink-0`,t)});let r=xW(e);return(0,z.jsx)(r,{"aria-hidden":`true`,"data-agent-icon":e??`thinking`,strokeWidth:n,className:q(`shrink-0`,t)})}var wW={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 TW(e){return e.length<=2?e:e.charAt(0)+e.slice(1).toLowerCase()}function EW(e){return wW[e]??`text-muted-foreground`}var DW={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 OW(e){return DW[e]??`var(--muted-foreground)`}function kW(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 AW(e){return e?.runs??[]}function jW(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 MW({source:e,live:t}){let n=SW(e);return(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`chat-avatar`,"data-live":t||void 0,"data-oracle":n||void 0,style:{"--orb":OW(e)},children:(0,z.jsx)(CW,{source:e,strokeWidth:2.25,className:n?`size-7`:`size-3.5`})})}function NW({source:e,name:t,time:n,head:r,live:i,children:a,aside:o,bubble:s=!0}){return(0,z.jsxs)(`div`,{className:`chat-row group/msg`,children:[(0,z.jsx)(`div`,{className:`chat-gutter`,children:r?(0,z.jsx)(MW,{source:e,live:i}):n?(0,z.jsx)(`time`,{className:`chat-hover-time`,children:n}):null}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[r?(0,z.jsxs)(`p`,{className:`chat-speaker`,children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),n?(0,z.jsx)(`time`,{className:`text-xs text-muted-foreground tabular-nums`,children:n}):null,o?(0,z.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:o}):null]}):null,s?(0,z.jsx)(`div`,{className:`chat-bubble-agent`,style:{"--orb":OW(e)},children:a}):a]})]})}function PW({time:e,head:t,note:n,children:r,below:i}){return(0,z.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[t?(0,z.jsxs)(`p`,{className:`flex items-baseline gap-2 text-xs text-muted-foreground`,children:[e?(0,z.jsx)(`time`,{className:`tabular-nums`,children:e}):null,(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:`You`}),n?(0,z.jsx)(`span`,{children:n}):null]}):null,(0,z.jsx)(`div`,{className:`chat-bubble`,children:r}),i]})}function FW({failed:e,children:t}){return(0,z.jsx)(`div`,{role:`note`,className:q(`chat-note`,e&&`text-destructive`),children:(0,z.jsx)(`span`,{children:t})})}function IW({className:e}){return(0,z.jsxs)(`span`,{"aria-hidden":`true`,className:q(`typing-dots`,e),children:[(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{}),(0,z.jsx)(`span`,{})]})}var LW=3e5,RW=`No task is running in this session.`,zW=`Type a request below and press enter to start one: the oracle scouts, proposes, plans and delegates.`,BW=`Nothing said yet. Type below to talk to the oracle about this task.`;function VW({entry:e}){return(0,z.jsxs)(FW,{failed:e.text.startsWith(`✗`),children:[e.text,e.at?` · ${dM(e.at)}`:``]})}function HW({entry:e,head:t}){if(e.role===`you`)return(0,z.jsx)(PW,{time:dM(e.at),head:t,children:(0,z.jsx)(qH,{text:e.text})});let n=e.role===`panel`;return(0,z.jsx)(NW,{source:n?`PLANNER`:`ORACLE`,name:n?`Panel`:`Oracle`,time:dM(e.at),head:t,children:(0,z.jsx)(qH,{text:e.text})})}var UW=(0,m.memo)(function({entry:e,head:t,fresh:n}){return(0,z.jsx)(V.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,z.jsx)(VW,{entry:e}):(0,z.jsx)(HW,{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 WW({text:e,busy:t}){let n=!!e?.trim();return!n&&!t?null:(0,z.jsx)(NW,{source:`ORACLE`,name:`Oracle`,head:!0,live:t,aside:t&&n?`writing…`:void 0,children:n?(0,z.jsx)(qH,{text:e??``}):(0,z.jsx)(IW,{className:`mt-1`})})}function GW({hasTask:e}){return(0,z.jsxs)(lj,{className:`h-full border-0`,children:[(0,z.jsxs)(uj,{children:[(0,z.jsx)(fj,{variant:`icon`,children:(0,z.jsx)(ph,{"aria-hidden":`true`})}),e?null:(0,z.jsx)(pj,{children:RW}),(0,z.jsx)(mj,{children:e?BW:zW})]}),e?null:(0,z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,z.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`Or plan it first with the whole panel in `,(0,z.jsx)(aA,{chord:`3`}),` Plan`]}),(0,z.jsxs)(`li`,{className:`flex items-center justify-center gap-2`,children:[`or make a direct change in `,(0,z.jsx)(aA,{chord:`4`}),` Quick fix`]})]})]})}async function KW(e){let t=await Te(`lobby.history`,{before:e});return{entries:t.entries,hasOlder:t.hasOlder}}function qW(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 KW(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 JW({chat:e,reply:t,busy:n,hasOlder:r,hasTask:i,work:a}){let{ref:o,atBottom:s,stick:c,onScroll:l}=yW(e.length+(t?.length??0)),{merged:u,more:d,loading:f,load:p}=qW(e,r,o),h=(0,m.useCallback)(()=>{l();let e=o.current;e&&e.scrollTop<80&&d&&!f&&p()},[l,o,d,f,p]),g=u.length===0&&!t?.trim()&&!n,[_,v]=(0,m.useState)(!1);return(0,m.useEffect)(()=>v(!0),[]),(0,z.jsxs)(JH,{"aria-label":`Conversation`,className:`flex-1`,children:[a,(0,z.jsx)(`div`,{ref:o,onScroll:h,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:g?(0,z.jsx)(GW,{hasTask:i}):(0,z.jsxs)(`div`,{className:`chat-column`,children:[d?(0,z.jsx)(`p`,{className:`mb-4 text-center text-xs text-muted-foreground`,children:`Earlier messages load as you scroll up.`}):null,u.map((e,t)=>{let n=u[t-1],r=!n||n.role!==e.role||e.at-n.at>LW;return(0,z.jsx)(UW,{entry:e,head:r,fresh:_},e.id)}),(0,z.jsx)(WW,{text:t,busy:n})]})}),s?null:(0,z.jsx)(`div`,{className:`absolute right-4 bottom-dock z-10`,children:(0,z.jsx)(X,{label:`Jump to latest`,text:`Latest`,icon:Dp,tone:`primary`,className:`rounded-full shadow-sm`,onClick:c})})]})}function YW(e){let t=e[0]===`ask`,[n,r]=t?e.slice(1):e;return{chat:t,agent:n,file:r}}function XW(e,t){let{agent:n,file:r}=YW(e);return oj(`knowledge`,...t?[`ask`]:[],n??``,r??``)}var ZW=[`master`,`designer`,`backend`,`qa`],QW={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`},$W={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`},eG=`Every write archives the version before it.`;function tG(e){if(e<1e3)return String(e);let t=e/1e3;return`${t>=10?Math.round(t):t.toFixed(1)}k`}function nG(e){return`over the compaction threshold — ask the oracle to compact ${e}`}function rG(e){return{text:e.text,occurrence:e.occurrence}}function iG(e){return ZW.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 aG(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing}function oG({initial:e,busy:t,onSave:n,onCancel:r}){let[i,a]=(0,m.useState)(e),o=()=>{!t&&i.trim()&&n(i)};return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-input p-3`,children:[(0,z.jsx)(`label`,{htmlFor:`knowledge-entry`,className:`text-sm font-medium text-foreground`,children:`Edit entry`}),(0,z.jsx)(lM,{id:`knowledge-entry`,value:i,rows:4,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:e=>{aG(e)&&(e.preventDefault(),o())}}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:eG}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:r,disabled:t,children:`Cancel`}),(0,z.jsxs)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:o,disabled:t||!i.trim(),children:[t?(0,z.jsx)(hj,{}):null,`Save`]})]})]})]})}function sG({open:e,file:t,initial:n,busy:r,onClose:i,onSave:a}){let[o,s]=(0,m.useState)(n),c=QA(e,ZA.confirm);return(0,z.jsx)(WA,{open:e&&c,onOpenChange:e=>!e&&i(),label:`Edit ${t}`,description:eG,dismissOnBackdrop:!1,className:`max-w-3xl`,children:(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-6`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h2`,{className:`text-base font-medium`,children:[`Edit `,t]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:eG})]}),(0,z.jsx)(lM,{value:o,rows:14,className:`min-h-0 flex-1 font-mono text-sm`,onChange:e=>s(e.target.value)}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(Y,{variant:`outline`,className:`max-md:min-h-11`,onClick:i,disabled:r,children:`Cancel`}),(0,z.jsxs)(Y,{className:`max-md:min-h-11 max-md:whitespace-normal`,onClick:()=>a(o),disabled:r,children:[r?(0,z.jsx)(hj,{}):null,`Save file`]})]})]})})}function cG({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,z.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(Lh,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-primary`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:i}),(0,z.jsx)(X,{label:`Take the note back`,icon:kg,iconOnly:!0,className:`-my-1 size-7`,disabled:r,onClick:()=>n(e.id)})]})}function lG({entry:e,index:t,selected:n,notes:r,onPick:i,onTakeBack:a,busy:o}){let s=()=>i(t);return(0,z.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,z.jsx)(`div`,{className:`flex gap-2`,children:(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(qH,{text:e.text})})}),r.length>0?(0,z.jsx)(`ul`,{className:`flex flex-col gap-1 pl-1`,children:r.map(e=>(0,z.jsx)(cG,{note:e,onTakeBack:a,busy:o},e.id))}):null]})}function uG({notes:e,onTakeBack:t,busy:n}){return e.length===0?null:(0,z.jsx)(XH,{title:`Notes on entries that changed`,right:String(e.length),children:(0,z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,z.jsx)(cG,{note:e,about:e.entry,onTakeBack:t,busy:n},e.id))})})}function dG({view:e}){let t=e.entries.length;return(0,z.jsxs)(`header`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsxs)(`h2`,{className:`min-w-0 break-words text-lg font-semibold tracking-tight`,children:[$W[e.agent],` `,(0,z.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e.file]})]}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` `,t===1?`entry`:`entries`,` · `,tG(e.chars),` chars`]}),e.over?(0,z.jsx)(`p`,{className:`text-sm text-foreground`,children:nG(e.file)}):null]})}function fG({draft:e,picked:t,setDraft:n,onEditFile:r,onDelete:i}){let a=!!e;return(0,z.jsxs)(qj,{children:[(0,z.jsx)(X,{label:`Edit the entry`,text:`Edit`,icon:Vh,shortcut:`E`,disabled:a||!t,onClick:()=>n({kind:`edit`,entry:t})}),(0,z.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,z.jsx)(X,{label:`Comment on the entry`,text:`Comment`,icon:dh,shortcut:`C`,disabled:a||!t,onClick:()=>n({kind:`comment`,entry:t})}),(0,z.jsx)(X,{label:`Edit the whole file`,text:`Edit file`,icon:jm,shortcut:`F`,disabled:a,onClick:r}),(0,z.jsx)(TM,{icon:Tg,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 pG({agent:e,file:t,onChanged:n}){let r=Cj(`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:rG(h)}))},y=n=>{let r=o?.entry;if(o?.kind===`edit`&&r)return void g(()=>U(`knowledge.edit`,{agent:e,file:t,ref:rG(r),text:n}));if(o?.kind===`comment`&&r)return void g(()=>U(`knowledge.comment`,{agent:e,file:t,ref:rG(r),text:n}));g(()=>U(`knowledge.add`,{agent:e,file:t,...h?{ref:rG(h)}:{},text:n}))};return f?(0,z.jsxs)(`article`,{className:`flex flex-col gap-4`,"aria-label":`${$W[e]} ${t}`,children:[(0,z.jsx)(fG,{draft:o,picked:h,setDraft:s,onEditFile:()=>l(!0),onDelete:v}),(0,z.jsx)(dG,{view:f}),p.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing here yet. Add the first entry below.`}):null,(0,z.jsx)(`ul`,{className:`workspace-section flex flex-col gap-2 rounded-xl border p-3 shadow-xs`,children:p.map((e,t)=>(0,z.jsx)(lG,{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,z.jsx)(oG,{initial:o.entry.text,busy:u,onSave:y,onCancel:()=>s(void 0)}):null,o?.kind===`comment`?(0,z.jsx)(qU,{label:`Comment on this entry`,hint:eG,buttonLabel:`Add note`,onSend:async e=>(y(e),!0)}):null,o?.kind===`add`?(0,z.jsx)(qU,{label:`Add an entry`,hint:eG,buttonLabel:`Add entry`,onSend:async e=>(y(e),!0)}):null,u&&!o?(0,z.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(hj,{}),` saving…`]}):null,(0,z.jsx)(uG,{notes:f.detached,onTakeBack:_,busy:u}),(0,z.jsx)(sG,{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,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Could not read the file. `,r.error]}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`reading…`})}function mG(e){return`${e.agent}/${e.file}`}var hG={master:`ORACLE`,designer:`DESIGN`,backend:`DEV`,qa:`QA`},gG=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function _G({info:e}){return(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground tabular-nums`,children:[(0,z.jsx)(`span`,{children:tG(e.chars)}),e.over?(0,z.jsx)(`span`,{className:`text-foreground`,children:`· over`}):null,e.notes>0?(0,z.jsx)(`span`,{className:`text-primary`,children:gG(e.notes,`note`)}):null]})}function vG({info:e,selected:t,onSelect:n}){return(0,z.jsx)(`li`,{className:`ktree-leaf`,children:(0,z.jsxs)(`button`,{"aria-keyshortcuts":`Enter Space`,"aria-describedby":`focused-action-help`,type:`button`,"data-row":!0,"aria-current":t?`true`:void 0,onClick:()=>n(mG(e)),className:q(FU,`ktree-file min-h-9 flex-row items-center gap-2 py-1.5 max-md:min-h-11`),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-bud`}),(0,z.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-sm text-foreground`,t&&`font-medium`),children:e.label}),(0,z.jsx)(_G,{info:e})]})})}var yG=`bot-lobby.knowledge.folded`;function bG(){try{let e=JSON.parse(window.localStorage.getItem(yG)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function xG({files:e,models:t={},selectedKey:n,onSelect:r}){let[i,a]=(0,m.useState)(bG),o=iG(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(yG,JSON.stringify(r))}catch{}return r})}return(0,z.jsxs)(`div`,{className:`ktree px-3 pt-1 pb-3`,children:[(0,z.jsxs)(`p`,{className:`ktree-root`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-8 shrink-0 place-items-center rounded-lg border text-primary`,children:(0,z.jsx)(Fp,{className:`size-4`})}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block text-sm font-medium`,children:`Project knowledge`}),(0,z.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[gG(e.length,`file`),` · `,gG(o.length,`agent`),s>0?` · ${gG(s,`note`)}`:``]})]})]}),(0,z.jsx)(`ul`,{className:`ktree-branches`,"aria-label":`Agents and their knowledge`,children:o.map(e=>{let a=!i.includes(e.agent),o=hG[e.agent],s=`knowledge-${e.agent}`,l=t[e.agent];return(0,z.jsxs)(`li`,{className:`ktree-branch`,style:{"--orb":OW(o)},children:[(0,z.jsx)(`h3`,{children:(0,z.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,z.jsx)(`span`,{"aria-hidden":`true`,className:`ktree-tile`,children:(0,z.jsx)(CW,{source:o,strokeWidth:2.25,className:o===`ORACLE`?`size-5`:`size-3.5`})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:QW[e.agent]}),l?(0,z.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`runs on `}),l]}):null]}),(0,z.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[e.notes>0?(0,z.jsxs)(`span`,{className:`text-primary`,children:[gG(e.notes,`note`),` · `]}):null,gG(e.files.length,`file`)]}),(0,z.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,z.jsx)(Eu,{initial:!1,children:a?(0,z.jsx)(V.ul,{id:s,"aria-label":`${QW[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,z.jsx)(vG,{info:e,selected:mG(e)===n,onSelect:r},mG(e)))},`files`):null})]},e.agent)})})]})}var SG=()=>sj(oj(`knowledge`)),CG=e=>{let[t,n]=e.split(`/`);sj(oj(`knowledge`,t??``,n??``))};function wG(){return(0,z.jsx)(lj,{className:`m-4 flex-1`,children:(0,z.jsxs)(uj,{children:[(0,z.jsx)(fj,{variant:`icon`,children:(0,z.jsx)(Fp,{"aria-hidden":`true`})}),(0,z.jsx)(mj,{children:`No knowledge files yet.`})]})})}function TG(e,t,n,r){let i=e.find(e=>e.agent===t&&e.file===n);return i?(0,z.jsx)(pG,{agent:i.agent,file:i.file,onChanged:r},mG(i)):t&&n?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`That file is not on the list any more.`}):null}function EG(){let e=lA(`lobby`),t=lA(`status`),n=e.data,r=t.data?.busy??!1;return!n?.chat.length&&!n?.reply&&!r?(0,z.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,z.jsx)(JW,{chat:n?.chat??[],reply:n?.reply,busy:r,hasOlder:n?.hasOlderChat??!1,hasTask:!!n?.task})}function DG({read:e,selected:t}){let n=e.data?.files.reduce((e,t)=>e+t.notes,0)??0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(sM,{title:`Knowledge`,count:n>0?`${n} note${n===1?``:`s`}`:void 0}),(0,z.jsx)(OG,{read:e,selected:t})]})}function OG({read:e,selected:t}){return!e.data&&e.error?(0,z.jsx)(xj,{message:`Could not load the knowledge files. ${e.error}`,onRetry:e.reload}):e.data?e.data.files.length?(0,z.jsx)(xG,{files:e.data.files,models:e.data.models??{},selectedKey:t,onSelect:CG}):(0,z.jsx)(wG,{}):(0,z.jsx)(cM,{})}function kG({rest:e}){let{chat:t,agent:n,file:r}=YW(e),i=nM(),a=Cj(`knowledge.files`,{},[`knowledge`]),o=a.data?.files??[],s=o.find(e=>e.agent===n&&e.file===r);return(0,z.jsx)(oM,{wide:i,inlineDetail:!0,list:(0,z.jsx)(DG,{read:a,selected:s?mG(s):void 0}),detail:t?(0,z.jsx)(EG,{}):TG(o,n,r,a.reload),detailClassName:t?`flex flex-col overflow-hidden p-0`:void 0,open:t||!!(n&&r),onClose:SG,hint:`Select a file to read its entries, or ask about the project below.`,describe:t?`Knowledge chat`:`Knowledge file`})}function AG(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 jG({className:e,...t}){return(0,z.jsx)(xC,{"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,z.jsx)(CC,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center`,children:(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3`,strokeWidth:3})})})}var MG=`Sessions`,NG=`No sessions yet.`,PG=`Up to 5 sessions; each can be assigned to one agent or several.`,FG=`A session is a live Excalidraw room that you and your agents draw in together.`,IG=[{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.`}],LG=`Sessions`,RG=`Pick a session on the left to see its link, its room and its agents.`,zG=`Room link`,BG=`Masked until revealed. A revealed link stays in this tab and is never saved.`,VG=`Room`,HG=`Drawing`,UG=`Last check`,WG=`not checked yet`,GG=`Add a session`,KG=`https://excalidraw.com/#room=…`,qG=`Optional name`;function JG(e){return`${e} of 5 in use`}var YG=`Agents may draw here.`,XG=`Agents may only look.`,ZG=`checking the room…`,QG=`Check that the room can be reached.`,$G=`Assigned to`,eK=`Assigned agents read the board and draw on it with excalidraw_read and excalidraw_draw, and appear in the room under their own name.`,tK=`Add or rename`,nK=`Add by link`,rK=`In Excalidraw, Share → Live collaboration → Start session, then paste the link. Enter adds it.`,iK=`New room`,aK=`Makes a fresh room link to open in Excalidraw; the name is optional.`,oK=`Rename`,sK=`draw`,cK=`look only`,lK=`Copied to the clipboard`,uK=`Could not reveal the link.`,dK=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],fK={master:`Master (oracle)`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scouts`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`};function pK(e){return e===0?`no agents`:`${e} agent${e===1?``:`s`}`}function mK(e){return e?e.ok?`✓`:`!`:``}function hK({title:e,right:t,className:n,children:r}){return(0,z.jsxs)(`section`,{className:q(`card-raised flex min-w-0 flex-col gap-3 rounded-xl border p-4`,n),children:[(0,z.jsxs)(`header`,{className:`flex items-baseline justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:e}),t?(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:t}):null]}),r]})}function gK({row:e=!1}){return(0,z.jsx)(`ol`,{className:q(`grid gap-3`,e&&`@2xl:grid-cols-3`),children:IG.map((e,t)=>(0,z.jsxs)(`li`,{className:`card-raised flex gap-3 rounded-xl border p-3.5`,children:[(0,z.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,z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,z.jsx)(`span`,{className:`text-xs leading-relaxed text-muted-foreground`,children:e.text})]})]},e.title))})}function _K({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,z.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,z.jsx)(`label`,{htmlFor:l,className:`text-xs font-medium text-muted-foreground`,children:e}),(0,z.jsxs)(`div`,{className:`flex gap-2 max-md:flex-wrap`,children:[(0,z.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,z.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,z.jsx)(`p`,{id:`${l}-hint`,className:`text-xs leading-relaxed text-muted-foreground`,children:t}):null]})}function vK({onChanged:e,primary:t}){return(0,z.jsx)(_K,{label:nK,hint:rK,buttonLabel:`Add`,placeholder:KG,required:!0,mono:!0,primary:t,onSubmit:async t=>await U(`excalidraw.add`,{link:t.trim()})?(e(),!0):!1})}function yK({onChanged:e,primary:t}){return(0,z.jsx)(_K,{label:iK,hint:aK,buttonLabel:`Create`,placeholder:qG,primary:t,onSubmit:async t=>{let n=t.trim();return await U(`excalidraw.create`,n?{name:n}:{})?(e(),!0):!1}})}function bK({onChanged:e,stacked:t=!1}){return(0,z.jsxs)(`div`,{className:q(`grid gap-4`,!t&&`@2xl:grid-cols-2`),children:[(0,z.jsx)(vK,{onChanged:e,primary:!0}),(0,z.jsx)(yK,{onChanged:e,primary:!0})]})}function xK({session:e,onChanged:t}){return(0,z.jsx)(_K,{label:oK,initial:e.name,required:!0,buttonLabel:oK,onSubmit:async n=>await U(`excalidraw.rename`,{id:e.id,name:n.trim()})?(t(),!0):!1},e.name)}function SK({icon:e,tone:t=`muted`,children:n}){return(0,z.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,z.jsx)(e,{"aria-hidden":`true`,className:`size-3.5`}),n]})}function CK({check:e,checking:t}){return t?(0,z.jsx)(SK,{icon:rh,children:ZG}):e?e.ok?(0,z.jsx)(SK,{icon:rm,tone:`primary`,children:`reachable`}):(0,z.jsx)(SK,{icon:tm,tone:`warning`,children:`unreachable`}):(0,z.jsx)(SK,{icon:am,children:WG})}function wK({label:e,children:t}){return(0,z.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,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]})}function TK({check:e,checking:t}){return t?(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,z.jsx)(hj,{className:`size-3.5`,"aria-hidden":`true`}),ZG]}):e?(0,z.jsxs)(`span`,{className:e.ok?`text-primary`:`text-foreground`,children:[e.ok?`✓`:`!`,` `,e.text]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:QG})}function EK({agent:e,on:t,onToggle:n}){return(0,z.jsx)(`li`,{children:(0,z.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,z.jsx)(jG,{checked:t,onCheckedChange:()=>n(e)}),(0,z.jsx)(`span`,{className:`truncate`,children:fK[e]})]})})}function DK({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===dK.length;return(0,z.jsxs)(hK,{title:$G,right:pK(e.agents.length),children:[(0,z.jsx)(`ul`,{className:`grid grid-cols-1 gap-1.5 @md:grid-cols-2`,children:dK.map(t=>(0,z.jsx)(EK,{agent:t,on:e.agents.includes(t),onToggle:n},t))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-muted-foreground`,children:eK}),(0,z.jsx)(X,{label:i?`Take every agent off`:`Assign every agent`,icon:$m,onClick:()=>void r()})]})]})}function OK({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){rp.error(e instanceof Error?e.message:uK)}},l=()=>void navigator.clipboard?.writeText(o??``).then(()=>rp(lK)).catch(()=>void 0),u=async()=>{await U(`excalidraw.toggleContribute`,{id:e.id})&&i()};return(0,z.jsxs)(`article`,{"aria-label":`Session detail`,className:`@container flex flex-col gap-4`,children:[(0,z.jsxs)(qj,{children:[o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(X,{label:`Copy the link`,text:`Copy`,icon:Cm,shortcut:`C`,onClick:l}),(0,z.jsx)(X,{label:`Open board`,icon:Dm,tone:`primary`,shortcut:`O`,href:o})]}):(0,z.jsx)(X,{label:`Reveal the link`,text:`Reveal`,icon:km,shortcut:`R`,onClick:()=>void c()}),(0,z.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,z.jsx)(X,{label:`Check the room`,text:`Check`,icon:n?rh:lg,shortcut:`T`,disabled:n,onClick:r}),(0,z.jsx)(TM,{icon:Tg,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,z.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight break-words`,children:e.name}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(SK,{icon:e.contribute?Vh:km,tone:e.contribute?`primary`:`muted`,children:e.contribute?sK:cK}),(0,z.jsx)(SK,{icon:Ng,children:pK(e.agents.length)}),(0,z.jsx)(CK,{check:t,checking:n})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,z.jsxs)(hK,{title:zG,children:[(0,z.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,z.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:BG})]}),(0,z.jsx)(hK,{title:VG,children:(0,z.jsxs)(`dl`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(wK,{label:HG,children:(0,z.jsx)(`span`,{className:e.contribute?`text-primary`:`text-muted-foreground`,children:e.contribute?YG:XG})}),(0,z.jsx)(wK,{label:UG,children:(0,z.jsx)(TK,{check:t,checking:n})})]})})]}),(0,z.jsx)(DK,{session:e,onChanged:i})]}),(0,z.jsx)(hK,{title:tK,children:(0,z.jsxs)(`div`,{className:`grid gap-4 @3xl:grid-cols-3`,children:[(0,z.jsx)(xK,{session:e,onChanged:i}),(0,z.jsx)(vK,{onChanged:i}),(0,z.jsx)(yK,{onChanged:i})]})})]})}function kK({check:e,checking:t}){if(t)return(0,z.jsx)(hj,{className:`size-3.5 shrink-0 text-muted-foreground`});let n=mK(e);return n?(0,z.jsx)(`span`,{className:q(`w-3.5 shrink-0 text-center`,e?.ok?`text-primary`:`text-foreground`),"aria-hidden":`true`,children:n}):(0,z.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`})}function AK({session:e,check:t,checking:n,selected:r,onSelect:i}){return(0,z.jsx)(`li`,{children:(0,z.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(FU,`max-md:min-h-11`),children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(kK,{check:t,checking:n}),(0,z.jsx)(`span`,{className:q(`min-w-0 flex-1 break-words text-foreground`,r&&`font-medium`),children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:pK(e.agents.length)})]}),(0,z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 pl-[1.375rem] text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono break-all`,children:e.masked}),(0,z.jsx)(PU,{variant:`secondary`,children:e.contribute?sK:cK})]})]})})}function jK({sessions:e,checks:t,checking:n,selectedId:r,onSelect:i}){return(0,z.jsx)(`ul`,{className:IU,children:e.map(e=>(0,z.jsx)(AK,{session:e,check:t[e.id],checking:n.includes(e.id),selected:e.id===r,onSelect:i},e.id))})}var MK=()=>sj(oj(`excalidraw`)),NK=e=>sj(oj(`excalidraw`,e));function PK({count:e}){return(0,z.jsxs)(`span`,{className:`flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`flex gap-1`,children:Array.from({length:5},(t,n)=>(0,z.jsx)(`span`,{className:q(`h-1.5 w-5 rounded-full`,n<e?`bg-primary`:`bg-border`)},n))}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:JG(e)})]})}function FK({count:e,onChanged:t}){return(0,z.jsxs)(`div`,{className:`@container flex max-w-4xl flex-col gap-5`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:LG}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:RG})]}),(0,z.jsx)(PK,{count:e})]}),(0,z.jsx)(gK,{row:!0}),e<5?(0,z.jsx)(hK,{title:GG,children:(0,z.jsx)(bK,{onChanged:t})}):null,(0,z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-4`,children:[(0,z.jsx)(oA,{chord:`ArrowDown`,children:`next session`}),(0,z.jsx)(oA,{chord:`ArrowRight`,children:`into its detail`})]})]})}function IK({onChanged:e}){return(0,z.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-5 pt-10 pb-dock md:px-8`,children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-5xl gap-8 @4xl:grid-cols-[minmax(0,1fr)_minmax(0,24rem)]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`card-raised grid size-11 place-items-center rounded-xl border text-primary`,children:(0,z.jsx)(Fh,{className:`size-5`})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:NG}),(0,z.jsx)(`p`,{className:`max-w-prose text-sm leading-relaxed text-muted-foreground`,children:FG})]}),(0,z.jsx)(gK,{}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:PG})]}),(0,z.jsx)(hK,{title:GG,className:`self-start`,children:(0,z.jsx)(bK,{onChanged:e,stacked:!0})})]})})}function LK({id:e}){let t=nM(),n=Cj(`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(),MK())};if(!n.data&&n.error)return(0,z.jsx)(xj,{message:`Could not load sessions. ${n.error}`,onRetry:n.reload});if(n.data&&s.length===0)return(0,z.jsx)(IK,{onChanged:n.reload});let d=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(sM,{title:MG,count:n.data?`${s.length}/5`:void 0}),n.data?(0,z.jsx)(jK,{sessions:s,checks:r,checking:a,selectedId:e,onSelect:NK}):(0,z.jsx)(cM,{})]}),f=c?(0,z.jsx)(OK,{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,z.jsx)(FK,{count:s.length,onChanged:n.reload}):null;return(0,z.jsx)(oM,{wide:t,list:d,detail:f,open:c!==void 0,onClose:MK,hint:`Select a session to see its link and agents.`,describe:`Session detail`})}function RK(e,t){return e===`lobby.thinking`||t===`1`}var zK=`bot-lobby.collapsed.`,BK=new Set,VK=new Map;function HK(e){if(VK.has(e))return VK.get(e);if(e===`lobby.thinking`)return RK(e);try{return RK(e,localStorage.getItem(zK+e))}catch{return!1}}function UK(e,t){VK.set(e,t);try{e!==`lobby.thinking`&&localStorage.setItem(zK+e,t?`1`:`0`)}catch{}for(let e of[...BK])e()}function WK(e){return BK.add(e),()=>{BK.delete(e)}}function GK(e){UK(e,!HK(e))}function KK(e){return[(0,m.useSyncExternalStore)(WK,()=>HK(e),()=>RK(e)),(0,m.useCallback)(()=>UK(e,!HK(e)),[e])]}function qK({entry:e}){return e.pending?(0,z.jsx)(hj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):e.kind===`error`?(0,z.jsx)(Ug,{"aria-hidden":`true`,className:`size-3.5 text-destructive`}):e.kind===`warning`?(0,z.jsx)(Dg,{"aria-hidden":`true`,className:`size-3.5 text-warning`}):e.kind===`success`?(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-success`}):(0,z.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/40`})}function JK({entry:e}){return(0,z.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,z.jsx)(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:dM(e.at)}),(0,z.jsx)(`span`,{className:q(`overflow-hidden text-xs font-medium whitespace-nowrap`,EW(e.source)),children:TW(e.source)}),(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center justify-center self-center`,children:(0,z.jsx)(qK,{entry:e})}),(0,z.jsx)(`span`,{className:`sr-only`,children:e.pending?`pending`:e.kind}),(0,z.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 YK({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}=yW(JSON.stringify(a));return(0,z.jsxs)(JH,{"aria-label":`Activity`,...i?{}:{title:`Activity`},collapsed:t,...n?{onToggle:n}:{},shortcut:r,className:`flex-1`,note:o?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(hj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}),` `,o,` running`]}):void 0,children:[(0,z.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,z.jsx)(`p`,{className:`px-2 py-1 text-sm text-muted-foreground`,children:`No activity yet.`}):(0,z.jsx)(`ul`,{children:a.map(e=>(0,z.jsx)(JK,{entry:e},e.id))})}),c?null:(0,z.jsx)(`div`,{className:`absolute inset-x-0 bottom-dock z-10 flex justify-center`,children:(0,z.jsx)(X,{label:`Jump to latest`,text:`Latest`,icon:Dp,className:`rounded-full bg-card shadow-card`,onClick:l})})]})}function XK(e,t){let n=[...new Map(t.map((e,t)=>[e.runId??String(t),e])).values()].filter(e=>e.status===`running`&&!e.finishedAt),r=new Set,i=[];for(let t of e?.activeSteps??[]){let a=n.filter(n=>t.runIds?.includes(n.runId??``)||!t.runIds&&e?.activeSteps?.length===1&&n.role===`worker`);if(a.length){for(let e of a)e.runId&&r.add(e.runId);i.push({text:t.text,runs:a})}}let a={scout:`Scouting`,researcher:`Research`,reviewer:`Review`,worker:`Implementation`};for(let e of n){if(e.runId&&r.has(e.runId))continue;let t=a[e.role??``]??`Current work`,n=i.find(e=>e.text===t);n?n.runs.push(e):i.push({text:t,runs:[e]})}return i}function ZK({run:e,now:t}){let n=e.note?.startsWith(`waiting on you`),r=e.activeMs===void 0?t-Date.parse(e.startedAt??``):e.activeMs+(n?0:Math.max(0,t-(e.lastEventAt??t)));return(0,z.jsxs)(`li`,{className:q(`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 py-1.5 text-xs`,e.parentRunId&&`ml-4 border-l border-border pl-3`),children:[(0,z.jsx)(hj,{"aria-hidden":`true`,role:`presentation`,className:`size-3 shrink-0`}),(0,z.jsx)(`span`,{className:q(`font-medium`,EW(kW(e))),children:TW(kW(e))}),e.parentRunId?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`child`}):null,(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.instruction,children:e.instruction?.split(`
92
- `)[0]??e.step??`Working`}),(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:fM(r)}),e.endsAt!==void 0&&!n?(0,z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[fM(Math.max(0,e.endsAt-t)),` left`]}):null,(0,z.jsx)(`span`,{className:`basis-full pl-5 text-muted-foreground`,children:e.note??([e.activity,e.detail].filter(Boolean).join(` `)||`Starting…`)})]})}function QK({task:e,runs:t}){let n=XK(e,t),r=n.length>0,[i,a]=(0,m.useState)(Date.now);return(0,m.useEffect)(()=>{if(!r)return;a(Date.now());let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[r]),r?(0,z.jsx)(`section`,{"aria-label":`Current step agents`,className:`max-h-[40%] shrink-0 overflow-y-auto border-b border-border bg-muted/20 px-5 py-3`,children:n.map((e,t)=>(0,z.jsxs)(`details`,{open:!0,className:`py-1`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.text,` `,(0,z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-muted-foreground`,children:[e.runs.length,` working`]})]}),(0,z.jsx)(`ul`,{"aria-label":`Agents working on ${e.text}`,className:`mt-1`,children:e.runs.filter(t=>!t.parentRunId||!e.runs.some(e=>e.runId===t.parentRunId)).flatMap(t=>[t,...e.runs.filter(e=>e.parentRunId===t.runId)]).map((e,t)=>(0,z.jsx)(ZK,{run:e,now:i},e.runId??t))})]},`${t}:${e.text}`))}):null}function $K(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 eq(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 tq(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}var nq=8;function rq(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function iq(e,t){let n=Math.min(t,nq);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 aq({done:e,total:t}){return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:iq(e,t).map((e,t)=>(0,z.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function oq({check:e,className:t}){return(0,z.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 sq({children:e}){return(0,z.jsx)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,children:e})}function cq({ms:e,running:t,sample:n}){let r=tq(t,n);return(0,z.jsx)(`span`,{className:`tabular-nums`,children:eq(e+r)})}function lq({work:e}){return(0,z.jsxs)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,title:`How long the agents have worked on this task (idle time left out)`,children:[(0,z.jsx)(Cg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),`worked `,(0,z.jsx)(cq,{ms:e.workedMs,running:e.running,sample:e})]})}function uq({active:e,current:t}){let n=e?.[0];if(n){let t=n.activeAgentCount??1;return(0,z.jsxs)(`span`,{className:`hidden max-w-[20rem] min-w-0 items-center gap-1.5 xl:inline-flex`,children:[(0,z.jsx)(`span`,{className:`truncate text-foreground`,title:n.text,children:n.text}),(0,z.jsxs)(`span`,{className:`shrink-0 text-primary`,children:[`(`,t,` `,t===1?`agent working`:`agents working`,`)`]}),(0,z.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-1.5 py-px font-medium text-primary`,children:[`active · `,(0,z.jsx)(cq,{ms:n.workedMs,running:!0,sample:n})]}),e.length>1?(0,z.jsxs)(`span`,{className:`shrink-0`,children:[`+`,e.length-1]}):null]})}return t?(0,z.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate xl:inline`,children:[`next: `,(0,z.jsx)(`span`,{className:`text-foreground`,children:t})]}):null}function dq({done:e,total:t,current:n,active:r}){let i=t>0?Math.min(100,Math.round(e/t*100)):0;return(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[e,` of `,t,` steps`]}),(0,z.jsx)(`div`,{className:`h-1.5 w-16 overflow-hidden rounded-full bg-border`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":e,"aria-label":`Plan progress`,children:(0,z.jsx)(V.div,{className:`h-full rounded-full bg-primary`,initial:!1,animate:{width:`${i}%`},transition:{type:`spring`,stiffness:260,damping:30}})}),(0,z.jsx)(uq,{...r?{active:r}:{},...n?{current:n}:{}})]})}function fq({task:e,status:t}){let n=t?.branch??t?.workspace.branch,r=e?.git?.branch??n;return(0,z.jsxs)(`section`,{className:`flex h-12 shrink-0 items-center gap-3 px-4`,"aria-label":`Task`,role:`group`,children:[(0,z.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] font-medium`,title:e?.title,children:[e?.title??`No task yet`,e?null:(0,z.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:t?.sessionName??`Type a request below to start one.`})]}),e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:e.state.replace(/_/g,` `)}),(0,z.jsx)(sq,{children:e.id}),e.track?(0,z.jsx)(sq,{children:rq(e.track)}):null,(e.domains??[]).length>0?(0,z.jsx)(sq,{children:e.domains.join(`, `)}):null,r?(0,z.jsxs)(`span`,{className:`hidden max-w-48 shrink-0 items-center gap-1 text-xs text-muted-foreground lg:inline-flex`,children:[(0,z.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,z.jsxs)(`span`,{className:`truncate`,children:[r,e.git?.from?` · from ${e.git.from}`:``]})]}):null,e.work?(0,z.jsx)(lq,{work:e.work}):null,e.progress?(0,z.jsx)(dq,{done:e.progress.done,total:e.progress.total,...e.currentStep?{current:e.currentStep}:{},...e.activeSteps?{active:e.activeSteps}:{}}):null]}):null]})}var pq=(e,t)=>e?.keys.find(e=>e.action===t)?.label,mq=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function hq({name:e,icon:t,shortcut:n,onClick:r}){return(0,z.jsxs)(Tj,{children:[(0,z.jsx)(Ej,{asChild:!0,children:(0,z.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,z.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,z.jsxs)(Dj,{side:`left`,children:[`Expand `,e,n?(0,z.jsx)(aA,{chord:n}):null]})]})}function gq(e){let t=mq(e.status);return(0,z.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,z.jsx)(hq,{name:`Activity`,icon:xp,shortcut:pq(e.status,`activity`),onClick:e.toggleActivity}):null})}function _q(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=mq(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,z.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,z.jsx)(JW,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task,work:(0,z.jsx)(QK,{task:t?.task,runs:AW(t)})}):null,o?(0,z.jsx)(YK,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:pq(n,`activity`)}):null]})}function vq(e){let{status:t}=e,n=mq(t).activity&&e.activityFolded;return(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,z.jsx)(_q,{...e})}),n?(0,z.jsx)(gq,{...e}):null]})}function yq({data:e,status:t}){let n=mq(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,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,z.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,z.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,z.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,z.jsx)(hj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,z.jsx)(JW,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task,work:(0,z.jsx)(QK,{task:e?.task,runs:AW(e)})}):null,o.id===`activity`?(0,z.jsx)(YK,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function bq(e){let{data:t,status:n}=e,r=nM();return(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 border-b border-border`,children:(0,z.jsx)(fq,{task:t?.task,status:n})}),r?(0,z.jsx)(vq,{...e}):(0,z.jsx)(yq,{...e})]})}function xq(){let e=lA(`lobby`),t=lA(`status`),[n,r]=KK(`lobby.activity`);return!e.data&&e.loading?(0,z.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(hj,{}),(0,z.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,z.jsx)(xj,{message:e.error,onRetry:()=>fe.onHello({})}):(0,z.jsx)(bq,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var Sq=Xg([`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 Cq({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,z.jsx)(`div`,{className:q(Sq({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function wq({className:e,fit:t,...n}){return(0,z.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 Tq({className:e,...t}){return(0,z.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 Eq={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function Dq(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 Oq(e){return e>0?Dq(e):`—`}function kq(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function Aq(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function jq(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 Mq(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function Nq(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function Pq(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function Fq(e,t){let n=t===`model-kind`?Eq[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var Iq=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],Lq={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 Rq(e){let t=Lq[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%Iq.length;return Iq[n]??Iq[0]}function zq(e){return Eq[e]??e}var Bq=6;function Vq({daily:e,cost:t}){let n=(0,m.useId)().replace(/:/g,``),r=bf(),[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,z.jsxs)(Uq,{title:o,right:t?`USD · per day`:`all runs · successful runs`,children:[(0,z.jsx)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2 text-xs`,"aria-live":`polite`,children:i?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:_(i.date)}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:t?g(i.cost):`${i.runs} runs · ${i.successes} successful`})]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Hover or focus a day to inspect it.`})}),(0,z.jsxs)(`svg`,{viewBox:`0 0 512 220`,className:`w-full overflow-visible`,role:`group`,"aria-label":o,children:[(0,z.jsx)(`defs`,{children:(0,z.jsxs)(`linearGradient`,{id:`${n}-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,z.jsx)(`stop`,{stopColor:`var(--primary)`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:`var(--primary)`,stopOpacity:`0.5`})]})}),l.map(e=>(0,z.jsxs)(`g`,{"aria-hidden":`true`,children:[(0,z.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,z.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,z.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,z.jsx)(`title`,{children:f}),(0,z.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,z.jsx)(V.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,z.jsx)(V.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,z.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,z.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`i`,{className:`size-2 rounded-sm bg-primary`,"aria-hidden":`true`}),`All runs`]}),(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`i`,{className:`size-2 rounded-sm bg-success`,"aria-hidden":`true`}),`Successful`]})]})]})}function Hq({daily:e}){return(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,z.jsx)(Vq,{daily:e}),(0,z.jsx)(Vq,{daily:e,cost:!0})]})}function Uq({title:e,right:t,children:n}){return(0,z.jsxs)(Cq,{role:`region`,className:`min-w-0`,"aria-label":e,children:[(0,z.jsx)(Tq,{className:`py-2.5`,children:(0,z.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-semibold`,children:[(0,z.jsx)(`span`,{children:e}),t?(0,z.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]})}),(0,z.jsx)(wq,{className:`flex min-w-0 flex-col gap-3`,children:n})]})}function Wq({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,Bq);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>Bq?(0,z.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 Gq({width:e,className:t,title:n}){let r=bf();return(0,z.jsx)(V.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 Kq(e,t){return t>0?Math.max(1.5,e/t*100):0}function qq({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,z.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,z.jsx)(Gq,{className:`rounded-r-md bg-linear-to-r from-primary/65 to-primary`,width:Kq(t,r)}),n?(0,z.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,Kq(n,r))}%`}}):null]})]})}function Jq({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,z.jsx)(Uq,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,z.jsx)(Wq,{rows:n,render:e=>(0,z.jsx)(qq,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:Oq(e.avgMs),sub:`p90 ${Oq(e.p90Ms)}`},t(e))})})}var Yq={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},Xq={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function Zq({label:e,rate:t,runs:n}){let r=Nq(t),i=`${Math.round(t*100)}%`;return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 ${Xq[r.tone]}`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${Yq[r.tone]}`}),(0,z.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,z.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,z.jsx)(Gq,{className:`bg-success/80`,width:t*100}),(0,z.jsx)(Gq,{className:`bg-destructive/60`,width:(1-t)*100})]})]})}function Qq({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,z.jsx)(Uq,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,z.jsx)(Wq,{rows:n,render:e=>(0,z.jsx)(Zq,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function $q({share:e}){return(0,z.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${Rq(e.agent)}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`text-[0.8125rem]`,children:TW(e.agent)}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,z.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,Dq(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function eJ({share:e}){return(0,z.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,z.jsx)(Gq,{className:`${Rq(e.agent)} opacity-85`,width:e.share*100,title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function tJ({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,z.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,z.jsx)(Wq,{rows:e,render:e=>(0,z.jsx)(qq,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:Dq(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function nJ({timeShare:e}){let t=e.byAgent;return(0,z.jsxs)(Uq,{title:`Where the time goes`,right:`share of run time by agent`,children:[t.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(eJ,{share:t}),(0,z.jsx)($q,{share:t})]}),(0,z.jsx)(tJ,{times:e.taskTimes})]})}function rJ(e){return(0,z.jsx)(LD,{...e})}function iJ(e){return(0,z.jsx)(VD,{"data-slot":`select-value`,...e})}function aJ({className:e,children:t,...n}){return(0,z.jsxs)(zD,{"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,z.jsx)(HD,{asChild:!0,children:(0,z.jsx)(Up,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]})}function oJ({className:e,children:t,position:n=`popper`,align:r=`start`,...i}){return(0,z.jsx)(GD,{children:(0,z.jsxs)(qD,{"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,z.jsx)(_O,{className:`flex justify-center py-1`,children:(0,z.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})}),(0,z.jsx)(aO,{children:t}),(0,z.jsx)(yO,{className:`flex justify-center py-1`,children:(0,z.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})})]})})}function sJ({className:e,children:t,...n}){return(0,z.jsxs)(dO,{"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,z.jsx)(pO,{children:t}),(0,z.jsx)(hO,{className:`absolute right-2`,children:(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`})})]})}function cJ({className:e,type:t,...n}){return(0,z.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 lJ=[{value:`all`,label:`All time`},{value:`today`,label:`Today`},{value:`week`,label:`Past 7 days`},{value:`range`,label:`Date range`}];function uJ(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function dJ({onChange:e}){let[t,n]=(0,m.useState)(`all`),r=uJ(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:uJ(n),to:r})}}return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Period`}),(0,z.jsxs)(rJ,{value:t,onValueChange:u,children:[(0,z.jsx)(aJ,{"aria-label":`Metrics period`,children:(0,z.jsx)(iJ,{})}),(0,z.jsx)(oJ,{children:lJ.map(e=>(0,z.jsx)(sJ,{value:e.value,children:e.label},e.value))})]})]}),t===`range`?(0,z.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,z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`Start date`,(0,z.jsx)(cJ,{type:`date`,required:!0,value:i,onChange:e=>a(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`End date`,(0,z.jsx)(cJ,{type:`date`,required:!0,value:o,onChange:e=>s(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,z.jsx)(Y,{type:`submit`,size:`sm`,className:`h-9`,children:`Apply`}),c?(0,z.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:c}):null]}):null]})}function fJ({label:e,value:t,sub:n}){return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var pJ=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function mJ({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,z.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,z.jsx)(fJ,{label:`Calls`,value:pJ(e.calls,`call`),sub:`${kq(e.ok,e.calls)} ok`}),(0,z.jsx)(fJ,{label:`Speed`,value:`p50 ${Mq(e.p50Ms)}`,sub:`p90 ${Mq(e.p90Ms)}`}),(0,z.jsx)(fJ,{label:`Read`,value:e.input>0?`${jq(e.input)} tokens`:`—`}),(0,z.jsx)(fJ,{label:`Routed down`,value:e.routed>0?pJ(e.routed,`run`):`none`,sub:e.routed>0?`${kq(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,pJ(e.seatRunsSkipped,`seat run`),` skipped · `,pJ(e.questionsAnswered,`question`),` answered · `,pJ(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,z.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var hJ=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function gJ(e,t=0){return e>0?e.toFixed(t):`—`}function _J(e){return[String(e.runs),kq(e.successes,e.runs),Oq(e.avgMs),Oq(e.p50Ms),Oq(e.p90Ms),gJ(e.avgTurns,1),gJ(e.avgTools,1),e.avgTokens>0?jq(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,Aq(e.avgCost),Aq(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function vJ(e,t){return t===`model-kind`?zq(e.kinds[0]??``):e.kinds.map(zq).join(`, `)}function yJ({groups:e,groupBy:t}){return(0,z.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,z.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,z.jsx)(`span`,{children:`All models`}),(0,z.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,z.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,z.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,z.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),hJ.map(e=>(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,z.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:vJ(e,t)||`—`}),_J(e).map((e,t)=>(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},hJ[t]))]},Fq(e,t)))})]})})]})}var bJ={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function xJ({label:e,value:t,sub:n,dot:r}){return(0,z.jsxs)(`div`,{className:`workspace-section flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-4 shadow-xs`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${bJ[r.tone]}`}),(0,z.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function SJ({tiles:e}){let t=Nq(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,z.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,z.jsx)(xJ,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,z.jsx)(xJ,{label:`Success`,value:kq(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,z.jsx)(xJ,{label:`Avg run`,value:Oq(e.avgMs),sub:`p90 ${Oq(e.p90Ms)}`}),(0,z.jsx)(xJ,{label:`Cost`,value:Aq(e.cost),sub:e.runs>0?`${Aq(e.cost/e.runs)} per run`:`—`}),(0,z.jsx)(xJ,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${Dq(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var CJ=`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 wJ({groupBy:e,onGroup:t}){return(0,z.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,z.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:Pq(n)},n))})}function TJ({query:e,onQuery:t}){return(0,z.jsxs)(`label`,{className:`relative flex max-w-full items-center`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,z.jsx)(ag,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,z.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,z.jsx)(aA,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function EJ({data:e,groupBy:t,query:n}){let r=e=>Fq(e,t);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(SJ,{tiles:e.tiles}),e.tiles.runs===0?(0,z.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. ${CJ}`}):null,e.daily.length>0?(0,z.jsx)(Hq,{daily:e.daily}):null,e.classifier?(0,z.jsx)(mJ,{summary:e.classifier}):null,e.tiles.runs>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,z.jsx)(Jq,{groups:e.groups,label:r}),(0,z.jsx)(Qq,{groups:e.groups,label:r})]}),(0,z.jsx)(yJ,{groups:e.groups,groupBy:t})]}):null,e.tiles.runs>0||e.timeShare.taskTimes.length>0?(0,z.jsx)(nJ,{timeShare:e.timeShare}):null]})}function DJ(){return(0,z.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,z.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function OJ(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)({}),o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=Cj(`metrics.get`,{groupBy:e,query:n,...i,timeZone:o},[`metrics`]);return!s.data&&s.error?(0,z.jsx)(xj,{message:`Could not load metrics. ${s.error}`,onRetry:s.reload}):(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Daily trends and model performance`})]}),s.loading&&s.data?(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(hj,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`})]}),(0,z.jsxs)(`section`,{"aria-label":`Metrics filters`,className:`workspace-section flex flex-wrap items-end gap-4 rounded-xl border p-4`,children:[(0,z.jsx)(dJ,{onChange:a}),(0,z.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,z.jsx)(wJ,{groupBy:e,onGroup:t}),(0,z.jsx)(TJ,{query:n,onQuery:r})]}),(0,z.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,z.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not refresh metrics. `,s.error]}):null,(0,z.jsx)(`div`,{"aria-busy":s.loading,className:s.loading&&s.data?`opacity-60`:void 0,children:s.data?(0,z.jsx)(EJ,{data:s.data,groupBy:e,query:n},JSON.stringify([s.data,e])):(0,z.jsx)(DJ,{})})]})}var kJ=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 AJ(e,t){return JSON.stringify([e,`prompt`,t])}function jJ(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function MJ(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var NJ=`bot-lobby.prompt-sound-muted`,PJ=new Set,FJ,IJ=!1;function LJ(){try{return localStorage.getItem(NJ)===`on`}catch{return IJ}}function RJ(e){IJ=e;try{localStorage.setItem(NJ,e?`on`:`off`)}catch{}for(let e of PJ)e()}function zJ(e){return PJ.add(e),()=>{PJ.delete(e)}}function BJ(){return(0,m.useSyncExternalStore)(zJ,LJ,()=>!1)}function VJ(){(0,m.useEffect)(()=>{let e=()=>{try{FJ??=new AudioContext,FJ.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function HJ(){if(!LJ()&&FJ&&FJ.state===`running`)try{let e=FJ.currentTime,t=FJ.createOscillator(),n=FJ.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(FJ.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}function UJ(){if(!LJ()&&FJ&&FJ.state===`running`)try{let e=FJ.currentTime,t=FJ.createOscillator(),n=FJ.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(FJ.destination),t.start(e),t.stop(e+.03),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var WJ=`bot-lobby.notifications`,GJ=`/icon-192.png`,KJ=new Set;function qJ(){for(let e of[...KJ])e()}function JJ(){try{return localStorage.getItem(WJ)===`on`}catch{return!1}}function YJ(e){return KJ.add(e),()=>{KJ.delete(e)}}function XJ(e){try{localStorage.setItem(WJ,e?`on`:`off`)}catch{}qJ()}function ZJ(){return(0,m.useSyncExternalStore)(YJ,JJ,()=>!1)}async function QJ(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(XJ(!0),`granted`):`denied`)}function $J(){XJ(!1)}function eY(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function tY(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function nY(e){try{new Notification(`bot-lobby`,{body:e,icon:GJ,tag:`bot-lobby`})}catch{}}function rY(){try{return new kJ(sessionStorage)}catch{return new kJ}}function iY(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?jJ(e,t.sessionId??n.key??t.from,n.dialog.id):AJ(e,t.id)}function aY(){let e=ZJ();VJ(),sA();let t=Cj(`tasks.list`,{},[`tasks`]),n=Cj(`sessions.list`,{},[`sessions`]),r=fe.get(`prompts`),i=fe.get(`lobby`).data,a=(0,m.useRef)(rY()),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 oY(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(()=>HJ()),c&&tY()&&nY(r),t===`delivery`&&rp.info(r,{action:{label:`Review tasks`,onClick:()=>sj(`#/tasks`)}}))}function sY(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;oY(e,`prompts`,(a??[]).map(e=>iY(i,e)),`A question is waiting for you.`,!!a&&!t.loading),oY(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>jJ(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),oY(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=>MJ(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function cY(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}sY(e);let s=a?.task?.state??``,c=eY(s);i.current&&c&&s!==i.current&&o&&tY()&&nY(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function lY(){let e=aY(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>cY(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function uY({className:e,thumbClassName:t,...n}){return(0,z.jsx)(RO,{"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,z.jsx)(BO,{"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 dY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],fY=`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`,pY=`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`,mY=[`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 hY({level:e,className:t}){let n=bf(),r=Math.max(0,dY.indexOf(e)),i=[0,1,2,2,3,4,6][r],a=r===dY.length-1,o=`brain-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,z.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,z.jsxs)(`defs`,{children:[(0,z.jsxs)(`linearGradient`,{id:`${o}-ink`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,z.jsx)(`stop`,{stopColor:a?`var(--rainbow-5)`:`var(--primary)`}),(0,z.jsx)(`stop`,{offset:`0.55`,stopColor:a?`var(--rainbow-6)`:`var(--primary)`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:a?`var(--rainbow-7)`:`var(--primary)`})]}),(0,z.jsxs)(`radialGradient`,{id:`${o}-halo`,children:[(0,z.jsx)(`stop`,{stopColor:`var(--rainbow-6)`,stopOpacity:`0.38`}),(0,z.jsx)(`stop`,{offset:`0.55`,stopColor:`var(--rainbow-7)`,stopOpacity:`0.18`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-5)`,stopOpacity:`0`})]}),(0,z.jsxs)(`linearGradient`,{id:`${o}-shine`,children:[(0,z.jsx)(`stop`,{stopColor:`var(--card)`,stopOpacity:`0`}),(0,z.jsx)(`stop`,{offset:`0.5`,stopColor:`var(--primary)`,stopOpacity:`0.6`}),(0,z.jsx)(`stop`,{offset:`0.6`,stopColor:`var(--card)`,stopOpacity:`0.9`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:`var(--card)`,stopOpacity:`0`})]}),(0,z.jsxs)(`filter`,{id:`${o}-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:[(0,z.jsx)(`feGaussianBlur`,{stdDeviation:`1.4`}),(0,z.jsxs)(`feMerge`,{children:[(0,z.jsx)(`feMergeNode`,{}),(0,z.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,z.jsx)(`clipPath`,{id:`${o}-silhouette`,children:(0,z.jsx)(`path`,{d:fY})}),(0,z.jsx)(`pattern`,{id:`${o}-hologram`,width:`4`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,z.jsx)(`path`,{d:`M0 1.5H4`,stroke:`var(--rainbow-5)`,strokeWidth:`0.4`,opacity:`0.4`})})]}),(0,z.jsx)(`ellipse`,{cx:`32`,cy:`63`,rx:a?14:19,ry:`2.5`,className:`fill-primary/10`}),a?(0,z.jsx)(V.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,z.jsxs)(V.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,z.jsx)(`use`,{href:`#${o}-shape`,"data-brain-phase":e,className:`brain-phase-echo`,stroke:`currentColor`},e)):null,(0,z.jsxs)(`g`,{id:`${o}-shape`,"data-brain-shape":!0,className:`brain-shape`,children:[(0,z.jsx)(`path`,{d:`M30 49 L30 56 Q32 59 35 57 L35 51`,className:`fill-primary/15`}),(0,z.jsx)(`path`,{d:r<=3?pY:fY,className:r===0?`fill-muted`:r<=3?`fill-primary/15`:`fill-primary/10`}),(0,z.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,z.jsx)(`g`,{transform:e?`translate(64 0) scale(-1 1)`:void 0,fill:`none`,children:mY.slice(0,i).map((e,t)=>(0,z.jsx)(V.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,z.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,z.jsx)(`circle`,{cx:e,cy:t,r:`1.4`,className:`brain-spark`,style:{animationDelay:`${n*-.7}s`}},e))}):null,r>=5?(0,z.jsx)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:(0,z.jsx)(`rect`,{"data-brain-shimmer":!0,className:`brain-shimmer`,x:`-24`,y:`10`,width:`18`,height:`48`,fill:`url(#${o}-shine)`})}):null]}),a?(0,z.jsxs)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:[(0,z.jsx)(`path`,{d:fY,fill:`url(#${o}-hologram)`}),(0,z.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,z.jsx)(`g`,{fill:`url(#${o}-ink)`,children:[[8,14],[56,12],[5,49],[58,46]].map(([e,t])=>(0,z.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 gY={minimal:`min`,medium:`med`},_Y={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 vY(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 yY(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 bY({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),_=vY(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 vY(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:yY(t,n,r,1),ArrowUp:yY(t,n,r,1),ArrowLeft:yY(t,n,r,-1),ArrowDown:yY(t,n,r,-1),Home:vY(t,n,0),End:vY(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,z.jsxs)(`div`,{className:q(`flex min-w-0 flex-col items-center gap-3 min-[360px]:flex-row`,a&&`opacity-60`),children:[(0,z.jsx)(hY,{level:b}),(0,z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-1 flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,z.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:_Y[b]??``})]}),(0,z.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,z.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,z.jsx)(V.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,z.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,z.jsx)(V.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,z.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,z.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:gY[e]??e},e)})}),x?(0,z.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})]})}function xY(e){return(0,z.jsx)(_D,{...e})}function SY(e){return(0,z.jsx)(vD,{"data-slot":`popover-trigger`,...e})}function CY({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,z.jsx)(yD,{children:(0,z.jsx)(bD,{"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 wY(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function TY({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=>wY(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,z.jsxs)(xY,{open:o,onOpenChange:s,children:[(0,z.jsxs)(SY,{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,z.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,z.jsx)(Up,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,z.jsxs)(CY,{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,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,z.jsx)(ag,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.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,z.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,z.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,z.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,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})]})}function EY({label:e,help:t,children:n,stacked:r}){return(0,z.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,z.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,z.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,z.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,z.jsx)(`div`,{className:`min-w-0`,children:n})]})}function DY({children:e}){return(0,z.jsx)(Cq,{dense:!0,children:(0,z.jsx)(wq,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-3`,children:e})})}function OY({value:e,items:t,label:n,onChange:r}){return(0,z.jsx)(TY,{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 kY=`(prefers-color-scheme: dark)`,AY=[`dark`,`light`,`system`],jY=m.createContext(void 0);function MY(e){return e!==null&&AY.includes(e)}function NY(){return window.matchMedia(kY).matches?`dark`:`light`}function PY(){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 FY(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function IY({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return MY(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`?NY():e,i=r?PY():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(kY),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||FY(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:NY()===`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(MY(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,z.jsx)(jY.Provider,{...i,value:l,children:e})}var LY=()=>{let e=m.useContext(jY);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},RY=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],zY={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},BY={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},VY=`inherit`,HY=`inherit`,UY=`Use the session's current model`,WY=`__custom__`,GY=`custom…`,KY=`Type a provider/model id`,qY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],JY={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},YY=[{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`}],XY=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],ZY=`shown on the Lobby tab`,QY=`Planning rounds`,$Y=`how many rounds the panel gets before the oracle settles the rest alone`,eX=[2,3,5,8,0],tX=`Split long plans`,nX=`saving a plan with more steps offers to split it into up to 5 tasks`,rX=[6,8,10,12,0],iX=`Port`,aX=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,oX=`Open browser`,sX=`open this page in the browser when pi starts`,cX=[{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`}],lX=`Git isolation`,uX=[{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`}],dX={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`},fX=[{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`}],pX=[{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:`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`}],mX={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`},hX={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`},gX=`https://tweakcn.com/editor/theme`;function _X(){let{theme:e}=LY();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function vX({palette:e,dark:t}){let n=se(e,t);return(0,z.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,z.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,z.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,z.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function yX(){let e=Ue(),t=_X(),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,z.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,z.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,z.jsx)(vX,{palette:n,dark:t}),(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,z.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,z.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function bX({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),rp.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,z.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,z.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1 max-md:flex-wrap`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,z.jsx)(cJ,{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,z.jsx)(X,{label:`Save the name`,text:`Save`,icon:Vp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,z.jsx)(X,{label:`Keep the old name`,icon:Ug,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.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,z.jsx)(X,{label:`Rename ${e.name}`,text:`Rename`,icon:Vh,onClick:()=>{a(e.name),r(!0)}}),(0,z.jsx)(TM,{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:Tg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>rp.error(e.message))})]}),o?(0,z.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function xX(){let e=Ue();return e.saved.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,z.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,z.jsx)(bX,{entry:e},e.id))})}function SX(){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`;rp.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,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,z.jsxs)(`a`,{href:gX,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,z.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,z.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,z.jsx)(cJ,{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,z.jsx)(lM,{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
+ `)[0]??e.step??`Working`}),(0,z.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:fM(r)}),e.endsAt!==void 0&&!n?(0,z.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[fM(Math.max(0,e.endsAt-t)),` left`]}):null,(0,z.jsx)(`span`,{className:`basis-full pl-5 text-muted-foreground`,children:e.note??([e.activity,e.detail].filter(Boolean).join(` `)||`Starting…`)})]})}function QK({task:e,runs:t}){let n=XK(e,t),r=n.length>0,[i,a]=(0,m.useState)(Date.now);return(0,m.useEffect)(()=>{if(!r)return;a(Date.now());let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[r]),r?(0,z.jsx)(`section`,{"aria-label":`Current step agents`,className:`max-h-[40%] shrink-0 overflow-y-auto border-b border-border bg-muted/20 px-5 py-3`,children:n.map((e,t)=>(0,z.jsxs)(`details`,{open:!0,className:`py-1`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[e.text,` `,(0,z.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-muted-foreground`,children:[e.runs.length,` working`]})]}),(0,z.jsx)(`ul`,{"aria-label":`Agents working on ${e.text}`,className:`mt-1`,children:e.runs.filter(t=>!t.parentRunId||!e.runs.some(e=>e.runId===t.parentRunId)).flatMap(t=>[t,...e.runs.filter(e=>e.parentRunId===t.runId)]).map((e,t)=>(0,z.jsx)(ZK,{run:e,now:i},e.runId??t))})]},`${t}:${e.text}`))}):null}function $K(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 eq(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 tq(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}var nq=8;function rq(e){return e?e.path===`fast`?`fast track (${e.size})`:`full workflow (${e.size})`:``}function iq(e,t){let n=Math.min(t,nq);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 aq({done:e,total:t}){return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,"aria-hidden":`true`,children:iq(e,t).map((e,t)=>(0,z.jsx)(`span`,{className:q(`h-1.5 w-3 rounded-full`,e?`bg-primary`:`bg-muted-foreground/25`)},t))})}function oq({check:e,className:t}){return(0,z.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 sq({children:e}){return(0,z.jsx)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,children:e})}function cq({ms:e,running:t,sample:n}){let r=tq(t,n);return(0,z.jsx)(`span`,{className:`tabular-nums`,children:eq(e+r)})}function lq({work:e}){return(0,z.jsxs)(`span`,{className:`hidden shrink-0 items-center gap-1 text-xs text-muted-foreground md:inline-flex`,title:`How long the agents have worked on this task (idle time left out)`,children:[(0,z.jsx)(Cg,{"aria-hidden":`true`,className:`size-3 shrink-0`}),`worked `,(0,z.jsx)(cq,{ms:e.workedMs,running:e.running,sample:e})]})}function uq({active:e,current:t}){let n=e?.[0];if(n){let t=n.activeAgentCount??1;return(0,z.jsxs)(`span`,{className:`hidden max-w-[20rem] min-w-0 items-center gap-1.5 xl:inline-flex`,children:[(0,z.jsx)(`span`,{className:`truncate text-foreground`,title:n.text,children:n.text}),(0,z.jsxs)(`span`,{className:`shrink-0 text-primary`,children:[`(`,t,` `,t===1?`agent working`:`agents working`,`)`]}),(0,z.jsxs)(`span`,{className:`shrink-0 rounded-md bg-primary/10 px-1.5 py-px font-medium text-primary`,children:[`active · `,(0,z.jsx)(cq,{ms:n.workedMs,running:!0,sample:n})]}),e.length>1?(0,z.jsxs)(`span`,{className:`shrink-0`,children:[`+`,e.length-1]}):null]})}return t?(0,z.jsxs)(`span`,{className:`hidden max-w-[16rem] truncate xl:inline`,children:[`next: `,(0,z.jsx)(`span`,{className:`text-foreground`,children:t})]}):null}function dq({done:e,total:t,current:n,active:r}){let i=t>0?Math.min(100,Math.round(e/t*100)):0;return(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[e,` of `,t,` steps`]}),(0,z.jsx)(`div`,{className:`h-1.5 w-16 overflow-hidden rounded-full bg-border`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":t,"aria-valuenow":e,"aria-label":`Plan progress`,children:(0,z.jsx)(V.div,{className:`h-full rounded-full bg-primary`,initial:!1,animate:{width:`${i}%`},transition:{type:`spring`,stiffness:260,damping:30}})}),(0,z.jsx)(uq,{...r?{active:r}:{},...n?{current:n}:{}})]})}function fq({task:e,status:t}){let n=t?.branch??t?.workspace.branch,r=e?.git?.branch??n;return(0,z.jsxs)(`section`,{className:`flex h-12 shrink-0 items-center gap-3 px-4`,"aria-label":`Task`,role:`group`,children:[(0,z.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-[0.8125rem] font-medium`,title:e?.title,children:[e?.title??`No task yet`,e?null:(0,z.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground`,children:t?.sessionName??`Type a request below to start one.`})]}),e?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent px-2 py-0.5 text-xs font-medium`,children:e.state.replace(/_/g,` `)}),(0,z.jsx)(sq,{children:e.id}),e.track?(0,z.jsx)(sq,{children:rq(e.track)}):null,(e.domains??[]).length>0?(0,z.jsx)(sq,{children:e.domains.join(`, `)}):null,r?(0,z.jsxs)(`span`,{className:`hidden max-w-48 shrink-0 items-center gap-1 text-xs text-muted-foreground lg:inline-flex`,children:[(0,z.jsx)(Vm,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,z.jsxs)(`span`,{className:`truncate`,children:[r,e.git?.from?` · from ${e.git.from}`:``]})]}):null,e.work?(0,z.jsx)(lq,{work:e.work}):null,e.progress?(0,z.jsx)(dq,{done:e.progress.done,total:e.progress.total,...e.currentStep?{current:e.currentStep}:{},...e.activeSteps?{active:e.activeSteps}:{}}):null]}):null]})}var pq=(e,t)=>e?.keys.find(e=>e.action===t)?.label,mq=e=>e?.panels??{conversation:!0,activity:!0,thinking:!0};function hq({name:e,icon:t,shortcut:n,onClick:r}){return(0,z.jsxs)(Tj,{children:[(0,z.jsx)(Ej,{asChild:!0,children:(0,z.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,z.jsx)(t,{"aria-hidden":`true`,className:`size-4`})})}),(0,z.jsxs)(Dj,{side:`left`,children:[`Expand `,e,n?(0,z.jsx)(aA,{chord:n}):null]})]})}function gq(e){let t=mq(e.status);return(0,z.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,z.jsx)(hq,{name:`Activity`,icon:xp,shortcut:pq(e.status,`activity`),onClick:e.toggleActivity}):null})}function _q(e){let{data:t,status:n,activityFolded:r,toggleActivity:i}=e,a=mq(n),o=a.activity&&!r;if(!a.conversation&&!o)return null;let s=a.conversation&&o;return(0,z.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,z.jsx)(JW,{chat:t?.chat??[],reply:t?.reply,busy:n?.busy??!1,hasOlder:t?.hasOlderChat??!1,hasTask:!!t?.task,work:(0,z.jsx)(QK,{task:t?.task,runs:AW(t)})}):null,o?(0,z.jsx)(YK,{entries:t?.activity??[],collapsed:!1,onToggle:i,shortcut:pq(n,`activity`)}):null]})}function vq(e){let{status:t}=e,n=mq(t).activity&&e.activityFolded;return(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,z.jsx)(_q,{...e})}),n?(0,z.jsx)(gq,{...e}):null]})}function yq({data:e,status:t}){let n=mq(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,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[r.length>1?(0,z.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,z.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,z.jsx)(n,{"aria-hidden":`true`,className:`size-4`}),e.label,e.id===`activity`&&s>0?(0,z.jsx)(hj,{"aria-hidden":`true`,role:`presentation`,className:`size-3`}):null]},e.id)})}):null,o.id===`conversation`?(0,z.jsx)(JW,{chat:e?.chat??[],reply:e?.reply,busy:t?.busy??!1,hasOlder:e?.hasOlderChat??!1,hasTask:!!e?.task,work:(0,z.jsx)(QK,{task:e?.task,runs:AW(e)})}):null,o.id===`activity`?(0,z.jsx)(YK,{entries:e?.activity??[],collapsed:!1,bare:!0}):null]}):null}function bq(e){let{data:t,status:n}=e,r=nM();return(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,z.jsx)(`div`,{className:`shrink-0 border-b border-border`,children:(0,z.jsx)(fq,{task:t?.task,status:n})}),r?(0,z.jsx)(vq,{...e}):(0,z.jsx)(yq,{...e})]})}function xq(){let e=lA(`lobby`),t=lA(`status`),[n,r]=KK(`lobby.activity`);return!e.data&&e.loading?(0,z.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(hj,{}),(0,z.jsx)(`span`,{children:`Connecting…`})]}):!e.data&&e.error?(0,z.jsx)(xj,{message:e.error,onRetry:()=>fe.onHello({})}):(0,z.jsx)(bq,{data:e.data,status:t.data,activityFolded:n,toggleActivity:r})}var Sq=Xg([`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 Cq({className:e,variant:t,spacing:n,stacked:r,dense:i,...a}){return(0,z.jsx)(`div`,{className:q(Sq({variant:t,spacing:n,stacked:r,dense:i}),e),"data-slot":`frame`,"data-spacing":n,...a})}function wq({className:e,fit:t,...n}){return(0,z.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 Tq({className:e,...t}){return(0,z.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 Eq={master:`master`,scout:`scout`,worker:`worker`,reviewer:`QA gate`,researcher:`research`,quickfix:`quick fix`,planner:`oracle (plan)`,panel:`panel`};function Dq(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 Oq(e){return e>0?Dq(e):`—`}function kq(e,t){return t>0?`${Math.round(e/t*100)}%`:`—`}function Aq(e){return e<=0?`—`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function jq(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 Mq(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(1)}s`}function Nq(e){return e>=.9?{icon:`✓`,word:`healthy`,tone:`healthy`}:e>=.7?{icon:`!`,word:`shaky`,tone:`shaky`}:{icon:`✗`,word:`failing`,tone:`failing`}}function Pq(e){return e===`model`?`by model · thinking`:`by model · thinking · agent`}function Fq(e,t){let n=t===`model-kind`?Eq[e.kinds[0]??``]??e.kinds[0]??``:``;return[e.model,e.thinking,n].filter(Boolean).join(` · `)}var Iq=[`bg-chart-1`,`bg-chart-2`,`bg-chart-3`,`bg-chart-4`,`bg-chart-5`],Lq={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 Rq(e){let t=Lq[e.toUpperCase()];if(t)return t;let n=0;for(let t of e)n=(n*31+t.charCodeAt(0))%Iq.length;return Iq[n]??Iq[0]}function zq(e){return Eq[e]??e}var Bq=6;function Vq({daily:e,cost:t}){let n=(0,m.useId)().replace(/:/g,``),r=bf(),[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,z.jsxs)(Uq,{title:o,right:t?`USD · per day`:`all runs · successful runs`,children:[(0,z.jsx)(`div`,{className:`flex min-h-5 flex-wrap items-baseline gap-x-2 text-xs`,"aria-live":`polite`,children:i?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-medium`,children:_(i.date)}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:t?g(i.cost):`${i.runs} runs · ${i.successes} successful`})]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Hover or focus a day to inspect it.`})}),(0,z.jsxs)(`svg`,{viewBox:`0 0 512 220`,className:`w-full overflow-visible`,role:`group`,"aria-label":o,children:[(0,z.jsx)(`defs`,{children:(0,z.jsxs)(`linearGradient`,{id:`${n}-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,z.jsx)(`stop`,{stopColor:`var(--primary)`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:`var(--primary)`,stopOpacity:`0.5`})]})}),l.map(e=>(0,z.jsxs)(`g`,{"aria-hidden":`true`,children:[(0,z.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,z.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,z.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,z.jsx)(`title`,{children:f}),(0,z.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,z.jsx)(V.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,z.jsx)(V.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,z.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,z.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`i`,{className:`size-2 rounded-sm bg-primary`,"aria-hidden":`true`}),`All runs`]}),(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`i`,{className:`size-2 rounded-sm bg-success`,"aria-hidden":`true`}),`Successful`]})]})]})}function Hq({daily:e}){return(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,z.jsx)(Vq,{daily:e}),(0,z.jsx)(Vq,{daily:e,cost:!0})]})}function Uq({title:e,right:t,children:n}){return(0,z.jsxs)(Cq,{role:`region`,className:`min-w-0`,"aria-label":e,children:[(0,z.jsx)(Tq,{className:`py-2.5`,children:(0,z.jsxs)(`h2`,{className:`flex items-baseline justify-between gap-3 text-sm font-semibold`,children:[(0,z.jsx)(`span`,{children:e}),t?(0,z.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:t}):null]})}),(0,z.jsx)(wq,{className:`flex min-w-0 flex-col gap-3`,children:n})]})}function Wq({rows:e,render:t}){let[n,r]=(0,m.useState)(!1),i=n?e:e.slice(0,Bq);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:i.map(t)}),e.length>Bq?(0,z.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 Gq({width:e,className:t,title:n}){let r=bf();return(0,z.jsx)(V.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 Kq(e,t){return t>0?Math.max(1.5,e/t*100):0}function qq({label:e,value:t,marker:n,max:r,valueText:i,sub:a}){return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[i,a?(0,z.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:a}):null]})]}),(0,z.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,z.jsx)(Gq,{className:`rounded-r-md bg-linear-to-r from-primary/65 to-primary`,width:Kq(t,r)}),n?(0,z.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,Kq(n,r))}%`}}):null]})]})}function Jq({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,z.jsx)(Uq,{title:`Average run time`,right:`per model · thinking · tick is p90`,children:n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,z.jsx)(Wq,{rows:n,render:e=>(0,z.jsx)(qq,{label:t(e),value:e.avgMs,marker:e.p90Ms,max:r,valueText:Oq(e.avgMs),sub:`p90 ${Oq(e.p90Ms)}`},t(e))})})}var Yq={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`},Xq={healthy:`text-success`,shaky:`text-warning`,failing:`text-destructive`};function Zq({label:e,rate:t,runs:n}){let r=Nq(t),i=`${Math.round(t*100)}%`;return(0,z.jsxs)(`li`,{className:`flex flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-[0.8125rem]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e,children:e}),(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 tabular-nums`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 ${Xq[r.tone]}`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full ${Yq[r.tone]}`}),(0,z.jsx)(`span`,{className:`sr-only`,children:r.word}),i]}),(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n,` run`,n===1?``:`s`]})]})]}),(0,z.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,z.jsx)(Gq,{className:`bg-success/80`,width:t*100}),(0,z.jsx)(Gq,{className:`bg-destructive/60`,width:(1-t)*100})]})]})}function Qq({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,z.jsx)(Uq,{title:`Success rate`,right:`green worked · red failed`,children:n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet.`}):(0,z.jsx)(Wq,{rows:n,render:e=>(0,z.jsx)(Zq,{label:t(e),rate:e.successes/e.runs,runs:e.runs},t(e))})})}function $q({share:e}){return(0,z.jsx)(`ul`,{className:`flex flex-wrap gap-x-6 gap-y-1.5 text-xs`,children:e.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${Rq(e.agent)}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`text-[0.8125rem]`,children:TW(e.agent)}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[Math.round(e.share*100),`%`]}),(0,z.jsxs)(`span`,{className:`text-muted-foreground tabular-nums`,children:[`avg `,Dq(e.ms/Math.max(1,e.runs)),` ×`,e.runs]})]},e.agent))})}function eJ({share:e}){return(0,z.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,z.jsx)(Gq,{className:`${Rq(e.agent)} opacity-85`,width:e.share*100,title:`${e.agent} ${Math.round(e.share*100)}%`},e.agent))})}function tJ({times:e}){if(e.length===0)return null;let t=Math.max(...e.map(e=>e.avgMs),1);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1`,children:[(0,z.jsx)(`h3`,{className:`text-xs text-muted-foreground`,children:`Request to done, by the oracle's model`}),(0,z.jsx)(Wq,{rows:e,render:e=>(0,z.jsx)(qq,{label:[e.model,e.thinking].filter(Boolean).join(` · `),value:e.avgMs,max:t,valueText:Dq(e.avgMs),sub:`×${e.tasks}`},`${e.model}-${e.thinking}`)})]})}function nJ({timeShare:e}){let t=e.byAgent;return(0,z.jsxs)(Uq,{title:`Where the time goes`,right:`share of run time by agent`,children:[t.length===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No timed runs yet.`}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,z.jsx)(eJ,{share:t}),(0,z.jsx)($q,{share:t})]}),(0,z.jsx)(tJ,{times:e.taskTimes})]})}function rJ(e){return(0,z.jsx)(LD,{...e})}function iJ(e){return(0,z.jsx)(VD,{"data-slot":`select-value`,...e})}function aJ({className:e,children:t,...n}){return(0,z.jsxs)(zD,{"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,z.jsx)(HD,{asChild:!0,children:(0,z.jsx)(Up,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`})})]})}function oJ({className:e,children:t,position:n=`popper`,align:r=`start`,...i}){return(0,z.jsx)(GD,{children:(0,z.jsxs)(qD,{"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,z.jsx)(_O,{className:`flex justify-center py-1`,children:(0,z.jsx)(Yp,{"aria-hidden":`true`,className:`size-4`})}),(0,z.jsx)(aO,{children:t}),(0,z.jsx)(yO,{className:`flex justify-center py-1`,children:(0,z.jsx)(Up,{"aria-hidden":`true`,className:`size-4`})})]})})}function sJ({className:e,children:t,...n}){return(0,z.jsxs)(dO,{"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,z.jsx)(pO,{children:t}),(0,z.jsx)(hO,{className:`absolute right-2`,children:(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 text-primary`})})]})}function cJ({className:e,type:t,...n}){return(0,z.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 lJ=[{value:`all`,label:`All time`},{value:`today`,label:`Today`},{value:`week`,label:`Past 7 days`},{value:`range`,label:`Date range`}];function uJ(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function dJ({onChange:e}){let[t,n]=(0,m.useState)(`all`),r=uJ(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:uJ(n),to:r})}}return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Period`}),(0,z.jsxs)(rJ,{value:t,onValueChange:u,children:[(0,z.jsx)(aJ,{"aria-label":`Metrics period`,children:(0,z.jsx)(iJ,{})}),(0,z.jsx)(oJ,{children:lJ.map(e=>(0,z.jsx)(sJ,{value:e.value,children:e.label},e.value))})]})]}),t===`range`?(0,z.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,z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`Start date`,(0,z.jsx)(cJ,{type:`date`,required:!0,value:i,onChange:e=>a(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5 text-xs text-muted-foreground`,children:[`End date`,(0,z.jsx)(cJ,{type:`date`,required:!0,value:o,onChange:e=>s(e.target.value),className:`h-9 w-36 max-w-full text-xs`})]}),(0,z.jsx)(Y,{type:`submit`,size:`sm`,className:`h-9`,children:`Apply`}),c?(0,z.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:c}):null]}):null]})}function fJ({label:e,value:t,sub:n}){return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:t}),n?(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n}):null]})}var pJ=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function mJ({summary:e}){let t=Object.entries(e.byPurpose).sort((e,t)=>t[1]-e[1]);return(0,z.jsxs)(`section`,{className:`card-raised flex flex-col gap-3 rounded-xl border p-4`,"aria-label":`Classifier (Jev)`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-medium`,children:`Classifier (Jev)`}),e.calls===0?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`no calls recorded`}):(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-4`,children:[(0,z.jsx)(fJ,{label:`Calls`,value:pJ(e.calls,`call`),sub:`${kq(e.ok,e.calls)} ok`}),(0,z.jsx)(fJ,{label:`Speed`,value:`p50 ${Mq(e.p50Ms)}`,sub:`p90 ${Mq(e.p90Ms)}`}),(0,z.jsx)(fJ,{label:`Read`,value:e.input>0?`${jq(e.input)} tokens`:`—`}),(0,z.jsx)(fJ,{label:`Routed down`,value:e.routed>0?pJ(e.routed,`run`):`none`,sub:e.routed>0?`${kq(e.routedOk,e.routed)} ok`:`no runs routed`})]}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`text-primary`,children:`spared`}),` `,pJ(e.seatRunsSkipped,`seat run`),` skipped · `,pJ(e.questionsAnswered,`question`),` answered · `,pJ(e.quickFixesHeld,`quick fix`,`quick fixes`),` held`,t.length>0?(0,z.jsx)(`span`,{className:`ml-3 border-l border-border pl-3`,children:t.map(([e,t])=>`${e} ${t}`).join(` · `)}):null]})]})}var hJ=[`Runs`,`OK`,`Avg`,`p50`,`p90`,`Turns`,`Tools`,`Tokens`,`tok/s`,`$/run`,`$ total`,`Stalls`];function gJ(e,t=0){return e>0?e.toFixed(t):`—`}function _J(e){return[String(e.runs),kq(e.successes,e.runs),Oq(e.avgMs),Oq(e.p50Ms),Oq(e.p90Ms),gJ(e.avgTurns,1),gJ(e.avgTools,1),e.avgTokens>0?jq(e.avgTokens):`—`,e.tokensPerSecond>0?e.tokensPerSecond.toFixed(0):`—`,Aq(e.avgCost),Aq(e.totalCost),e.timeouts>0?String(e.timeouts):`—`]}function vJ(e,t){return t===`model-kind`?zq(e.kinds[0]??``):e.kinds.map(zq).join(`, `)}function yJ({groups:e,groupBy:t}){return(0,z.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,z.jsxs)(`h2`,{className:`flex flex-wrap items-baseline justify-between gap-3 px-4 text-sm font-medium`,children:[(0,z.jsx)(`span`,{children:`All models`}),(0,z.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[t===`model`?`by model · thinking`:`by model · thinking · agent`,` · sorted by runs`]})]}),(0,z.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,z.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,z.jsx)(`thead`,{className:`sticky top-0 bg-card text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Model`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:`Think`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-left font-medium`,children:t===`model-kind`?`Agent`:`Agents`}),hJ.map(e=>(0,z.jsx)(`th`,{scope:`col`,className:`px-3 py-1.5 text-right font-medium whitespace-nowrap`,children:e},e))]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{className:`border-t border-border/70 transition-colors hover:bg-muted`,children:[(0,z.jsx)(`th`,{scope:`row`,className:`px-3 py-1.5 text-left font-normal text-foreground`,children:e.model}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:e.thinking||`—`}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 whitespace-nowrap text-muted-foreground`,children:vJ(e,t)||`—`}),_J(e).map((e,t)=>(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right tabular-nums whitespace-nowrap text-foreground`,children:e},hJ[t]))]},Fq(e,t)))})]})})]})}var bJ={healthy:`bg-success`,shaky:`bg-warning`,failing:`bg-destructive`};function xJ({label:e,value:t,sub:n,dot:r}){return(0,z.jsxs)(`div`,{className:`workspace-section flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-4 shadow-xs`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e}),(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl leading-tight font-semibold tracking-tight tabular-nums`,children:[r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full ${bJ[r.tone]}`}),(0,z.jsx)(`span`,{className:`sr-only`,children:r.word})]}):null,t]}),(0,z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:n||`\xA0`})]})}function SJ({tiles:e}){let t=Nq(e.runs>0?e.successes/e.runs:0),n=e.runs-e.successes;return(0,z.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,z.jsx)(xJ,{label:`Runs`,value:String(e.runs),sub:e.runs===0?`no runs yet`:``}),(0,z.jsx)(xJ,{label:`Success`,value:kq(e.successes,e.runs),sub:`${n} failed${e.stalls>0?` · ${e.stalls} stalled`:``}`,dot:{tone:t.tone,word:t.word}}),(0,z.jsx)(xJ,{label:`Avg run`,value:Oq(e.avgMs),sub:`p90 ${Oq(e.p90Ms)}`}),(0,z.jsx)(xJ,{label:`Cost`,value:Aq(e.cost),sub:e.runs>0?`${Aq(e.cost/e.runs)} per run`:`—`}),(0,z.jsx)(xJ,{label:`Tasks`,value:`${e.completed} done`,sub:e.avgCompleteMs>0?`avg ${Dq(e.avgCompleteMs)} · ${e.active} active`:`${e.active} active`})]})}var CJ=`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 wJ({groupBy:e,onGroup:t}){return(0,z.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,z.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:Pq(n)},n))})}function TJ({query:e,onQuery:t}){return(0,z.jsxs)(`label`,{className:`relative flex max-w-full items-center`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Search runs`}),(0,z.jsx)(ag,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 size-3.5 text-muted-foreground`}),(0,z.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,z.jsx)(aA,{chord:`/`,className:`kbd-hint pointer-events-none absolute right-2`})]})}function EJ({data:e,groupBy:t,query:n}){let r=e=>Fq(e,t);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsx)(SJ,{tiles:e.tiles}),e.tiles.runs===0?(0,z.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. ${CJ}`}):null,e.daily.length>0?(0,z.jsx)(Hq,{daily:e.daily}):null,e.classifier?(0,z.jsx)(mJ,{summary:e.classifier}):null,e.tiles.runs>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,z.jsx)(Jq,{groups:e.groups,label:r}),(0,z.jsx)(Qq,{groups:e.groups,label:r})]}),(0,z.jsx)(yJ,{groups:e.groups,groupBy:t})]}):null,e.tiles.runs>0||e.timeShare.taskTimes.length>0?(0,z.jsx)(nJ,{timeShare:e.timeShare}):null]})}function DJ(){return(0,z.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,z.jsx)(`div`,{className:`h-20 rounded-lg bg-muted motion-safe:animate-pulse`},e))})}function OJ(){let[e,t]=(0,m.useState)(`model`),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)({}),o=Intl.DateTimeFormat().resolvedOptions().timeZone,s=Cj(`metrics.get`,{groupBy:e,query:n,...i,timeZone:o},[`metrics`]);return!s.data&&s.error?(0,z.jsx)(xj,{message:`Could not load metrics. ${s.error}`,onRetry:s.reload}):(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-5 pt-5 pb-dock`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Metrics`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Daily trends and model performance`})]}),s.loading&&s.data?(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(hj,{className:`size-3`,"aria-hidden":`true`,role:`presentation`}),` refreshing`]}):null,(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`min-w-4 flex-1`})]}),(0,z.jsxs)(`section`,{"aria-label":`Metrics filters`,className:`workspace-section flex flex-wrap items-end gap-4 rounded-xl border p-4`,children:[(0,z.jsx)(dJ,{onChange:a}),(0,z.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,z.jsx)(wJ,{groupBy:e,onGroup:t}),(0,z.jsx)(TJ,{query:n,onQuery:r})]}),(0,z.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,z.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Could not refresh metrics. `,s.error]}):null,(0,z.jsx)(`div`,{"aria-busy":s.loading,className:s.loading&&s.data?`opacity-60`:void 0,children:s.data?(0,z.jsx)(EJ,{data:s.data,groupBy:e,query:n},JSON.stringify([s.data,e])):(0,z.jsx)(DJ,{})})]})}var kJ=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 AJ(e,t){return JSON.stringify([e,`prompt`,t])}function jJ(e,t,n){return JSON.stringify([e,`dialog`,t,n])}function MJ(e,t,n){return JSON.stringify([e,`delivery`,t,n])}var NJ=`bot-lobby.prompt-sound-muted`,PJ=new Set,FJ,IJ=!1;function LJ(){try{return localStorage.getItem(NJ)===`on`}catch{return IJ}}function RJ(e){IJ=e;try{localStorage.setItem(NJ,e?`on`:`off`)}catch{}for(let e of PJ)e()}function zJ(e){return PJ.add(e),()=>{PJ.delete(e)}}function BJ(){return(0,m.useSyncExternalStore)(zJ,LJ,()=>!1)}function VJ(){(0,m.useEffect)(()=>{let e=()=>{try{FJ??=new AudioContext,FJ.resume().catch(()=>void 0)}catch{}};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,e)}},[])}function HJ(){if(!LJ()&&FJ&&FJ.state===`running`)try{let e=FJ.currentTime,t=FJ.createOscillator(),n=FJ.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(FJ.destination),t.start(e),t.stop(e+.24),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}function UJ(){if(!LJ()&&FJ&&FJ.state===`running`)try{let e=FJ.currentTime,t=FJ.createOscillator(),n=FJ.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(FJ.destination),t.start(e),t.stop(e+.03),t.onended=()=>{t.disconnect(),n.disconnect()}}catch{}}var WJ=`bot-lobby.notifications`,GJ=`/icon-192.png`,KJ=new Set;function qJ(){for(let e of[...KJ])e()}function JJ(){try{return localStorage.getItem(WJ)===`on`}catch{return!1}}function YJ(e){return KJ.add(e),()=>{KJ.delete(e)}}function XJ(e){try{localStorage.setItem(WJ,e?`on`:`off`)}catch{}qJ()}function ZJ(){return(0,m.useSyncExternalStore)(YJ,JJ,()=>!1)}async function QJ(){return typeof Notification>`u`?`unsupported`:(Notification.permission==="default"&&await Notification.requestPermission().catch(()=>void 0),Notification.permission===`granted`?(XJ(!0),`granted`):`denied`)}function $J(){XJ(!1)}function eY(e){if(e===`completed`)return`finished`;if(e===`abandoned`)return`dropped`}function tY(){return typeof Notification<`u`&&Notification.permission===`granted`&&document.hidden}function nY(e){try{new Notification(`bot-lobby`,{body:e,icon:GJ,tag:`bot-lobby`})}catch{}}function rY(){try{return new kJ(sessionStorage)}catch{return new kJ}}function iY(e,t){let n=t.payload;return t.kind===`sessionDialog`&&n?.dialog?.id?jJ(e,t.sessionId??n.key??t.from,n.dialog.id):AJ(e,t.id)}function aY(){let e=ZJ();VJ(),sA();let t=Cj(`tasks.list`,{},[`tasks`]),n=Cj(`sessions.list`,{},[`sessions`]),r=fe.get(`prompts`),i=fe.get(`lobby`).data,a=(0,m.useRef)(rY()),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 oY(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(()=>HJ()),c&&tY()&&nY(r),t===`delivery`&&rp.info(r,{action:{label:`Review tasks`,onClick:()=>sj(`#/tasks`)}}))}function sY(e){let{prompts:t,sessions:n,tasks:r,project:i}=e,a=t.data?.prompts;oY(e,`prompts`,(a??[]).map(e=>iY(i,e)),`A question is waiting for you.`,!!a&&!t.loading),oY(e,`sessions`,n.data?.background.flatMap(e=>e.dialogs.map(t=>jJ(i,e.sessionId??e.key,t.id)))??[],`A background session is asking something.`,!!n.data&&!n.loading),oY(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=>MJ(i,e.id,e.delivery.reviewId))??[],`Completed work is ready for delivery review in Tasks.`,!!r.data&&!r.loading)}function cY(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}sY(e);let s=a?.task?.state??``,c=eY(s);i.current&&c&&s!==i.current&&o&&tY()&&nY(`${a?.task?.title??`The task`} ${c}.`),i.current=s}function lY(){let e=aY(),{connection:t,enabled:n,project:r,prompts:i,sessions:a,tasks:o,lobby:s}=e;(0,m.useEffect)(()=>cY(e),[t,n,r,i.data,i.loading,a.data,a.loading,o.data,o.loading,s])}function uY({className:e,thumbClassName:t,...n}){return(0,z.jsx)(RO,{"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,z.jsx)(BO,{"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 dY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],fY=`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`,pY=`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`,mY=[`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 hY({level:e,className:t}){let n=bf(),r=Math.max(0,dY.indexOf(e)),i=[0,1,2,2,3,4,6][r],a=r===dY.length-1,o=`brain-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`;return(0,z.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,z.jsxs)(`defs`,{children:[(0,z.jsxs)(`linearGradient`,{id:`${o}-ink`,x1:`0`,y1:`0`,x2:`1`,y2:`1`,children:[(0,z.jsx)(`stop`,{stopColor:a?`var(--rainbow-5)`:`var(--primary)`}),(0,z.jsx)(`stop`,{offset:`0.55`,stopColor:a?`var(--rainbow-6)`:`var(--primary)`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:a?`var(--rainbow-7)`:`var(--primary)`})]}),(0,z.jsxs)(`radialGradient`,{id:`${o}-halo`,children:[(0,z.jsx)(`stop`,{stopColor:`var(--rainbow-6)`,stopOpacity:`0.38`}),(0,z.jsx)(`stop`,{offset:`0.55`,stopColor:`var(--rainbow-7)`,stopOpacity:`0.18`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:`var(--rainbow-5)`,stopOpacity:`0`})]}),(0,z.jsxs)(`linearGradient`,{id:`${o}-shine`,children:[(0,z.jsx)(`stop`,{stopColor:`var(--card)`,stopOpacity:`0`}),(0,z.jsx)(`stop`,{offset:`0.5`,stopColor:`var(--primary)`,stopOpacity:`0.6`}),(0,z.jsx)(`stop`,{offset:`0.6`,stopColor:`var(--card)`,stopOpacity:`0.9`}),(0,z.jsx)(`stop`,{offset:`1`,stopColor:`var(--card)`,stopOpacity:`0`})]}),(0,z.jsxs)(`filter`,{id:`${o}-glow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:[(0,z.jsx)(`feGaussianBlur`,{stdDeviation:`1.4`}),(0,z.jsxs)(`feMerge`,{children:[(0,z.jsx)(`feMergeNode`,{}),(0,z.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]}),(0,z.jsx)(`clipPath`,{id:`${o}-silhouette`,children:(0,z.jsx)(`path`,{d:fY})}),(0,z.jsx)(`pattern`,{id:`${o}-hologram`,width:`4`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,z.jsx)(`path`,{d:`M0 1.5H4`,stroke:`var(--rainbow-5)`,strokeWidth:`0.4`,opacity:`0.4`})})]}),(0,z.jsx)(`ellipse`,{cx:`32`,cy:`63`,rx:a?14:19,ry:`2.5`,className:`fill-primary/10`}),a?(0,z.jsx)(V.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,z.jsxs)(V.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,z.jsx)(`use`,{href:`#${o}-shape`,"data-brain-phase":e,className:`brain-phase-echo`,stroke:`currentColor`},e)):null,(0,z.jsxs)(`g`,{id:`${o}-shape`,"data-brain-shape":!0,className:`brain-shape`,children:[(0,z.jsx)(`path`,{d:`M30 49 L30 56 Q32 59 35 57 L35 51`,className:`fill-primary/15`}),(0,z.jsx)(`path`,{d:r<=3?pY:fY,className:r===0?`fill-muted`:r<=3?`fill-primary/15`:`fill-primary/10`}),(0,z.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,z.jsx)(`g`,{transform:e?`translate(64 0) scale(-1 1)`:void 0,fill:`none`,children:mY.slice(0,i).map((e,t)=>(0,z.jsx)(V.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,z.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,z.jsx)(`circle`,{cx:e,cy:t,r:`1.4`,className:`brain-spark`,style:{animationDelay:`${n*-.7}s`}},e))}):null,r>=5?(0,z.jsx)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:(0,z.jsx)(`rect`,{"data-brain-shimmer":!0,className:`brain-shimmer`,x:`-24`,y:`10`,width:`18`,height:`48`,fill:`url(#${o}-shine)`})}):null]}),a?(0,z.jsxs)(`g`,{clipPath:`url(#${o}-silhouette)`,stroke:`none`,children:[(0,z.jsx)(`path`,{d:fY,fill:`url(#${o}-hologram)`}),(0,z.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,z.jsx)(`g`,{fill:`url(#${o}-ink)`,children:[[8,14],[56,12],[5,49],[58,46]].map(([e,t])=>(0,z.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 gY={minimal:`min`,medium:`med`},_Y={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 vY(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 yY(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 bY({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),_=vY(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 vY(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:yY(t,n,r,1),ArrowUp:yY(t,n,r,1),ArrowLeft:yY(t,n,r,-1),ArrowDown:yY(t,n,r,-1),Home:vY(t,n,0),End:vY(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,z.jsxs)(`div`,{className:q(`flex min-w-0 flex-col items-center gap-3 min-[360px]:flex-row`,a&&`opacity-60`),children:[(0,z.jsx)(hY,{level:b}),(0,z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-1 flex-col gap-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,z.jsx)(`span`,{"data-level":b,className:`effort-word text-[0.8125rem] font-medium capitalize`,"aria-hidden":`true`,children:b}),(0,z.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,children:_Y[b]??``})]}),(0,z.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,z.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,z.jsx)(V.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,z.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,z.jsx)(V.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,z.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,z.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:gY[e]??e},e)})}),x?(0,z.jsxs)(`p`,{className:`text-xs text-warning`,children:[e,` is not supported by `,r??`this model`,`, so it runs at `,b,`.`]}):null]})]})}function xY(e){return(0,z.jsx)(_D,{...e})}function SY(e){return(0,z.jsx)(vD,{"data-slot":`popover-trigger`,...e})}function CY({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,z.jsx)(yD,{children:(0,z.jsx)(bD,{"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 wY(e,t){let n=`${e.label} ${e.hint??``} ${e.value}`.toLowerCase();return t.toLowerCase().split(/\s+/).filter(Boolean).every(e=>n.includes(e))}function TY({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=>wY(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,z.jsxs)(xY,{open:o,onOpenChange:s,children:[(0,z.jsxs)(SY,{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,z.jsx)(`span`,{className:`min-w-0 truncate`,children:g?.label??e}),(0,z.jsx)(Up,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]}),(0,z.jsxs)(CY,{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,z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-2.5`,children:[(0,z.jsx)(ag,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.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,z.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,z.jsxs)(`p`,{className:`px-2.5 py-2 text-xs text-muted-foreground`,children:[`Nothing matches “`,c,`”.`]}):null,h.map((t,n)=>(0,z.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,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:t.label}),t.hint?(0,z.jsx)(`span`,{className:`line-clamp-2 text-xs text-muted-foreground`,children:t.hint}):null]}),t.value===e?(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},t.value))]})]})]})}function EY({label:e,help:t,children:n,stacked:r}){return(0,z.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,z.jsxs)(`div`,{className:`min-w-0 break-words`,children:[(0,z.jsx)(`div`,{className:`break-words text-[0.8125rem] font-medium`,children:e}),t?(0,z.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:t}):null]}),(0,z.jsx)(`div`,{className:`min-w-0`,children:n})]})}function DY({children:e}){return(0,z.jsx)(Cq,{dense:!0,children:(0,z.jsx)(wq,{className:`flex flex-col divide-y divide-border py-0 [&>*]:py-3`,children:e})})}function OY({value:e,items:t,label:n,onChange:r}){return(0,z.jsx)(TY,{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 kY=`(prefers-color-scheme: dark)`,AY=[`dark`,`light`,`system`],jY=m.createContext(void 0);function MY(e){return e!==null&&AY.includes(e)}function NY(){return window.matchMedia(kY).matches?`dark`:`light`}function PY(){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 FY(e){return e instanceof HTMLElement&&!!(e.isContentEditable||e.closest(`input, textarea, select, [contenteditable='true']`))}function IY({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,disableTransitionOnChange:r=!0,...i}){let[a,o]=m.useState(()=>{let e=localStorage.getItem(n);return MY(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`?NY():e,i=r?PY():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(kY),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||FY(e.target)||e.key.toLowerCase()===`d`&&o(e=>{let t=e===`dark`?`light`:e===`light`?`dark`:NY()===`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(MY(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,z.jsx)(jY.Provider,{...i,value:l,children:e})}var LY=()=>{let e=m.useContext(jY);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e},RY=[`master`,`designer`,`backend`,`qa`,`scout`,`researcher`,`quickfix`,`planner`],zY={master:`Master`,designer:`Designer`,backend:`Backend`,qa:`QA`,scout:`Scout`,researcher:`Researcher`,quickfix:`Quick fix`,planner:`Planner`},BY={model:`Model`,thinking:`Effort`,timeout:`Time limit`,instructions:`Instructions`},VY=`inherit`,HY=`inherit`,UY=`Use the session's current model`,WY=`__custom__`,GY=`custom…`,KY=`Type a provider/model id`,qY=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],JY={agents:`Agents`,workflow:`Workflow`,lint:`Linting`,lobby:`Lobby`,classifier:`Classifier`,appearance:`Appearance`,notifications:`Notifications`,install:`Install as app`},YY=[{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`}],XY=[{id:`conversation`,label:`Conversation pane`},{id:`activity`,label:`Activity log pane`},{id:`thinking`,label:`Thinking bubble`}],ZY=`shown on the Lobby tab`,QY=`Planning rounds`,$Y=`how many rounds the panel gets before the oracle settles the rest alone`,eX=[2,3,5,8,0],tX=`Split long plans`,nX=`saving a plan with more steps offers to split it into up to 5 tasks`,rX=[6,8,10,12,0],iX=`Port`,aX=`the base port (then the next free up to +20); 0 means any free port; applies the next time pi starts`,oX=`Open browser`,sX=`open this page in the browser when pi starts`,cX=[{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`}],lX=`Git isolation`,uX=[{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`}],dX={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`},fX=[{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`}],pX=[{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`}],mX={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`},hX={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`},gX=`https://tweakcn.com/editor/theme`;function _X(){let{theme:e}=LY();return e===`dark`||e===`system`&&typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches}function vX({palette:e,dark:t}){let n=se(e,t);return(0,z.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,z.jsx)(`span`,{className:`size-4 rounded-full border border-black/10`,style:{background:n.card}}),(0,z.jsx)(`span`,{className:`size-4 rounded-full`,style:{background:n.primary}}),(0,z.jsx)(`span`,{className:`h-2 flex-1 rounded-full`,style:{background:n.accent}})]})}function yX(){let e=Ue(),t=_X(),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,z.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,z.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,z.jsx)(vX,{palette:n,dark:t}),(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center justify-between gap-2 px-0.5 text-[0.8125rem] font-medium`,children:[(0,z.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,z.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:`saved`}):null]}),r?(0,z.jsx)(Vp,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]})]},n.id)})})}function bX({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),rp.success(`Renamed to ${n}.`)}catch(e){s(e.message)}}return(0,z.jsxs)(`li`,{className:`flex min-h-10 flex-wrap items-center gap-2 py-1.5`,children:[n?(0,z.jsxs)(`form`,{className:`flex min-w-0 flex-1 items-center gap-1 max-md:flex-wrap`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,z.jsx)(cJ,{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,z.jsx)(X,{label:`Save the name`,text:`Save`,icon:Vp,tone:`primary`,type:`submit`,disabled:!i.trim()}),(0,z.jsx)(X,{label:`Keep the old name`,icon:Ug,iconOnly:!0,onClick:()=>{a(e.name),r(!1)}})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.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,z.jsx)(X,{label:`Rename ${e.name}`,text:`Rename`,icon:Vh,onClick:()=>{a(e.name),r(!0)}}),(0,z.jsx)(TM,{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:Tg,variant:`destructive`,onConfirm:()=>void t.remove(e.id).catch(e=>rp.error(e.message))})]}),o?(0,z.jsx)(`p`,{role:`alert`,className:`w-full text-xs text-destructive`,children:o}):null]})}function xX(){let e=Ue();return e.saved.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No saved themes yet. Import one below and give it a name.`}):(0,z.jsx)(`ul`,{"aria-label":`Saved themes`,className:`divide-y divide-border`,children:e.saved.map(e=>(0,z.jsx)(bX,{entry:e},e.id))})}function SX(){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`;rp.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,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Pick or build a theme in the`,` `,(0,z.jsxs)(`a`,{href:gX,target:`_blank`,rel:`noreferrer noopener`,className:`inline-flex items-center gap-0.5 text-link underline-offset-2 hover:underline`,children:[`tweakcn editor `,(0,z.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,z.jsxs)(`label`,{className:`grid gap-1 text-xs text-muted-foreground`,children:[`Name`,(0,z.jsx)(cJ,{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,z.jsx)(lM,{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 {
93
93
  --background: oklch(0.98 0 0);
94
94
  --primary: oklch(0.55 0.2 260);
95
95
  …