@pi-outpost/embed 0.20.0 → 0.20.1

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.
@@ -314,7 +314,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
314
314
  `).length)),className:`flex-1 resize-none bg-transparent px-2 py-1.5 text-[15px] outline-none placeholder:text-zinc-400 disabled:opacity-50 dark:placeholder:text-zinc-600`}),e&&(0,i.jsx)(`button`,{type:`button`,onClick:p,title:`stop`,"aria-label":`Stop the agent`,className:`rounded-lg bg-red-100 p-2 text-red-700 hover:bg-red-200 dark:bg-red-900/60 dark:text-red-200 dark:hover:bg-red-900`,children:(0,i.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,i.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>ae.current?.click(),disabled:!t,title:`attach files`,"aria-label":`Attach files`,className:`rounded-lg p-2 text-zinc-500 hover:bg-zinc-200 hover:text-zinc-700 disabled:opacity-30 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:(0,i.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,i.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`})})}),(0,i.jsx)(`input`,{ref:ae,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&l(Array.from(e.target.files)),e.target.value=``}}),(0,i.jsx)(`button`,{type:`button`,onClick:me,disabled:!t||de||!v.trim()&&s.length===0,title:de?`waiting for an attachment to finish uploading`:e?`steer`:`send`,"aria-label":e?`Steer the agent`:`Send message`,className:`rounded-lg bg-zinc-900 p-2 text-zinc-100 hover:bg-zinc-800 disabled:opacity-30 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:e?(0,i.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,i.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,i.jsx)(`path`,{strokeLinecap:`round`,d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`}),(0,i.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,i.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,i.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 12 3.27 3.13c6.6 1.9 12.83 4.9 18.43 8.87-5.6 3.97-11.83 6.97-18.43 8.87L6 12Zm0 0h7.5`})})})]})]})}var NA=`rounded-md border px-3 py-1.5 text-sm border-zinc-200 hover:bg-zinc-100 dark:border-zinc-800 dark:hover:bg-zinc-800`,PA=`rounded-md bg-zinc-900 px-3 py-1.5 text-sm text-zinc-100 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,FA=`w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`,IA=`mb-4 ${FA}`,LA=`1,3`,RA=` — `;function zA(e){let t=e.indexOf(`
315
315
  `);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function BA(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(RA);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function VA(e){if(e.method!==`input`||e.placeholder!==LA)return null;let{heading:t,body:n}=zA(e.title),r=[];for(let e of n.split(`
316
316
  `)){let t=BA(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function HA({request:e,onRespond:t}){let[r,a]=(0,n.useState)(e.method===`editor`?e.prefill??``:``),[o,s]=(0,n.useState)([]),c=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[l,u]=(0,n.useState)(c?Math.ceil(c/1e3):null),d=VA(e),{heading:f,body:p}=zA(e.title);function m(){t({id:e.id,cancelled:!0})}function h(e){s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function g(){let n=r.trim();t({id:e.id,value:n.length>0?n:o.join(`,`)})}return(0,n.useEffect)(()=>{if(l===null)return;if(l<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>u(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[l,e.id,t]),(0,i.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:m,children:(0,i.jsxs)(`div`,{className:`w-full ${p?`max-w-2xl`:`max-w-md`} rounded-xl border border-zinc-200 bg-white p-4 shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,onClick:e=>e.stopPropagation(),children:[(0,i.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:f}),p&&!d&&(0,i.jsx)(`pre`,{className:`mb-3 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-zinc-50 p-2 font-mono text-xs text-zinc-600 dark:bg-zinc-950 dark:text-zinc-400`,children:p}),e.method===`select`&&(0,i.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=BA(n);return(0,i.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${NA}`,children:r?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,i.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:r.description})]}):n},n)})}),e.method===`confirm`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,i.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:NA,children:`No`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:PA,children:`Yes`})]})]}),d&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:d.options.map(e=>(0,i.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:o.includes(e.index),onChange:()=>h(e.index),className:`mt-0.5`}),(0,i.jsxs)(`span`,{children:[(0,i.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,i.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,i.jsx)(`input`,{value:r,onChange:e=>a(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&g(),e.key===`Escape`&&m()},className:`mb-1 ${FA}`}),(0,i.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,i.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:m,className:NA,children:`Cancel`}),(0,i.jsx)(`button`,{type:`button`,onClick:g,className:PA,children:`OK`})]})]}),e.method===`input`&&!d&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),placeholder:e.placeholder,onKeyDown:n=>{n.key===`Enter`&&t({id:e.id,value:r}),n.key===`Escape`&&m()},className:IA}),(0,i.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:m,className:NA,children:`Cancel`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:r}),className:PA,children:`OK`})]})]}),e.method===`editor`&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`textarea`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&m()},className:`resize-none font-mono ${IA}`}),(0,i.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:m,className:NA,children:`Cancel`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:r}),className:PA,children:`OK`})]})]}),l!==null&&(0,i.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,l,`s`]})]})})}var UA={info:`border-blue-300 bg-blue-50 text-blue-800 dark:border-blue-900 dark:bg-blue-950/60 dark:text-blue-200`,warning:`border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,error:`border-red-300 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/60 dark:text-red-200`},WA=6e3;function GA({notification:e,onDismiss:t}){let r=(0,n.useRef)(t);return(0,n.useEffect)(()=>{r.current=t}),(0,n.useEffect)(()=>{let e=setTimeout(()=>r.current(),WA);return()=>clearTimeout(e)},[e.id]),(0,i.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${UA[e.notifyType??`info`]}`,children:[(0,i.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>r.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function KA({notifications:e,onDismiss:t}){return e.length===0?null:(0,i.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,i.jsx)(GA,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var qA={30:`#3f3f46`,31:`#dc2626`,32:`#16a34a`,33:`#ca8a04`,34:`#2563eb`,35:`#9333ea`,36:`#0891b2`,37:`#71717a`,90:`#a1a1aa`,91:`#ef4444`,92:`#22c55e`,93:`#eab308`,94:`#3b82f6`,95:`#a855f7`,96:`#06b6d4`,97:`#d4d4d8`},JA=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function YA(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];if(r===0)for(let e of Object.keys(n))delete n[e];else if(r===1)n.bold=!0;else if(r===2)n.dim=!0;else if(r===3)n.italic=!0;else if(r===4)n.underline=!0;else if(r===22)delete n.bold,delete n.dim;else if(r===23)delete n.italic;else if(r===24)delete n.underline;else if(r===39)delete n.color;else if(qA[r]!==void 0)n.color=qA[r];else if(r===38){if(t[e+1]===2){let[r,i,a]=[t[e+2],t[e+3],t[e+4]];[r,i,a].every(e=>Number.isFinite(e))&&(n.color=`rgb(${r} ${i} ${a})`),e+=4}else t[e+1]===5&&(e+=2)}}return n}function XA(e){let t=[],n={},r=0;JA.lastIndex=0;for(let i=JA.exec(e);i!==null;i=JA.exec(e)){i.index>r&&t.push({text:e.slice(r,i.index),...n}),r=i.index+i[0].length;let a=i[0];if(a.endsWith(`m`)){let e=a.slice(2,-1),t=e===``?[0]:e.split(/[;:]/).map(e=>e===``?0:Number(e));n=YA(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function ZA(e){return e.replace(JA,``)}function QA({line:e}){let t=XA(e);return(0,i.jsx)(i.Fragment,{children:t.map((e,t)=>(0,i.jsx)(`span`,{style:{...e.color?{color:e.color}:{},...e.bold?{fontWeight:600}:{},...e.dim?{opacity:.7}:{},...e.italic?{fontStyle:`italic`}:{},...e.underline?{textDecoration:`underline`}:{}},children:e.text},t))})}function $A({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,i.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,i.jsx)(`div`,{className:`whitespace-pre-wrap rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 font-mono text-xs text-zinc-600 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-400`,children:t.lines.map((e,t)=>(0,i.jsx)(`div`,{children:(0,i.jsx)(QA,{line:e})},t))},e))})}var ej=class extends n.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`[pi-outpost] viewer crashed:`,e,t.componentStack)}render(){return this.state.failed?(0,i.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,i.jsxs)(`p`,{className:`max-w-md text-center text-sm text-zinc-600 dark:text-zinc-400`,children:[this.props.label??`This file`,` could not be displayed. Close and reopen it to try again.`]})}):this.props.children}},tj=(0,n.lazy)(()=>Promise.resolve().then(()=>require("./PdfViewer-BEdoeHbS.cjs"))),nj=250,rj=`(min-width: 768px)`;function ij(){let[e,t]=(0,n.useState)(()=>window.matchMedia?.(rj).matches??!0);return(0,n.useEffect)(()=>{let e=window.matchMedia?.(rj);if(e===void 0)return;let n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function aj(e,t){let[r,i]=(0,n.useState)(e);return(0,n.useEffect)(()=>{let n=window.setTimeout(()=>i(e),t);return()=>window.clearTimeout(n)},[e,t]),r}function oj(e){let t=mO(e);return t.status===`valid`?t.envelope:void 0}function sj(e){return/\.(md|markdown)$/i.test(e)}function cj(e,t){return t===void 0?!0:t===null?!1:t===``||e===t||e.startsWith(`${t}/`)}function lj({file:e,writableRoot:r,isStreaming:a,onDirtyChange:o,gitState:s,initialShowGitDiff:c=!1,gitDiff:l,onFetchGitDiff:u,onClearGitDiff:d,inRepository:f,onOpenGitHistory:p,onClose:m,onReload:g,onSave:_,serverUrl:v=``,token:y=null,onImageLoad:x,onPdfLoad:S,rawRevision:te=0}){let[C,ne]=(0,n.useState)(`rendered`),[re,ie]=(0,n.useState)(c),[w,oe]=(0,n.useState)(e.status===`loaded`&&e.justCreated?{draft:e.content,baseContent:e.content,baseMtimeMs:e.mtimeMs}:null),[se,T]=(0,n.useState)(`idle`),ce=(0,n.useRef)(null),le=(0,n.useRef)(null),E=e.status===`loaded`?e:null,de=E!==null&&sj(e.path),fe=t.r(e.path),me=t.i(e.path),he=(0,n.useMemo)(()=>E===null?void 0:mO(E.content),[E?.content]),ge=he?.status===`valid`,_e=he?.status===`valid`||he?.status===`invalid`,ve=_e||de,ye=C===`source`,be=ij(),xe=cj(e.path,r)&&!me,Se=w!==null&&w.draft!==w.baseContent,Ce=E?.pendingSave!==void 0,we=w!==null&&E!==null&&E.mtimeMs!==w.baseMtimeMs,Te=E?.saveError?.conflict===!0||we,Ee=w?.draft??E?.content??``,De=aj(Ee,nj),Oe=(0,n.useMemo)(()=>E===null?void 0:mO(De),[De,E===null]),[ke,Ae]=(0,n.useState)(()=>e.status===`loaded`?oj(e.content):void 0);(0,n.useEffect)(()=>{Oe?.status===`valid`&&Ae(Oe.envelope)},[Oe]);let je=Oe!==void 0&&Oe.status!==`valid`&&ke!==void 0,Me=Oe?.status===`invalid`?De===E?.content&&E.documentIssues!==void 0?E.documentIssues:Oe.issues:void 0,Ne=Oe?.status===`not-a-document`?Oe.why===`unparseable`?`This is not parseable JSON yet.`:"This no longer declares a structured-exchange `schema`.":Oe?.status===`unsupported-version`?`This declares ${Oe.schema}, which this version does not render.`:void 0,D=C===`split`&&ve&&!re&&E!==null&&be,Pe=w===null?null:(0,i.jsx)(`textarea`,{ref:ce,value:w.draft,onChange:e=>oe({...w,draft:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),Se&&!Ce&&!Te&&ze())},spellCheck:!1,className:`h-full w-full resize-none bg-transparent p-4 font-mono text-[13px] leading-relaxed text-zinc-800 outline-none ring-inset focus-visible:ring-1 focus-visible:ring-zinc-300 dark:text-zinc-200 dark:focus-visible:ring-zinc-700`});function Fe(n){return(0,i.jsx)(`div`,{className:`prose-chat mx-auto max-w-3xl p-4 text-zinc-700 dark:text-zinc-300`,children:(0,i.jsx)(rs,{remarkPlugins:[zx,Zx],rehypePlugins:[zv],components:{pre:ue,a:({href:n,children:r,...a})=>!n||/^[a-z][a-z0-9+.-]*:/i.test(n)?(0,i.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,...a,children:r}):n.startsWith(`#`)?(0,i.jsx)(`a`,{href:n,...a,children:r}):(0,i.jsx)(`a`,{href:n,onClick:r=>{r.preventDefault(),g(t.o(e.path,n))},...a,children:r}),img:({src:n,alt:r,...a})=>{let o=typeof n==`string`&&n!==``&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`)?t.a(v,t.o(e.path,n),y):n;return(0,i.jsx)(`img`,{...a,src:o,alt:r??``,loading:`lazy`,className:`max-w-full rounded-lg`})}},children:b(n)})})}function Ie(e){C===`split`&&e!==`split`&&Se&&!window.confirm(`Discard unsaved changes?`)||(C===`split`&&e!==`split`&&oe(null),ne(e))}function Le(){Se&&!window.confirm(`Discard unsaved changes?`)||m()}function Re(){E&&oe({draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs})}function ze(t=!1){!E||w===null||Ce||(le.current=w.draft,_(e.path,w.draft,w.baseMtimeMs,t))}function Be(){oe(null),g(e.path)}function Ve(){let t=!re;ie(t),t?u(e.path):d()}return(0,n.useEffect)(()=>{if(w!==null&&E!==null&&le.current!==null&&E.content===le.current&&E.mtimeMs!==w.baseMtimeMs){let e=le.current;le.current=null,w.draft===e?oe(null):oe({...w,baseContent:E.content,baseMtimeMs:E.mtimeMs})}},[E?.mtimeMs]),(0,n.useEffect)(()=>{function e(e){e.key===`Escape`&&Le()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)}),(0,n.useEffect)(()=>{D&&xe&&w===null&&E!==null&&oe({draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs})},[D,xe,E?.mtimeMs]),(0,n.useEffect)(()=>{T(a?`streaming`:e=>e===`streaming`?`done`:e)},[a]),(0,n.useEffect)(()=>(o(Se),()=>o(!1)),[Se]),(0,n.useEffect)(()=>(c&&u(e.path),()=>d()),[]),(0,i.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[ve&&!re&&(0,i.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`How to show this document`,children:[[`rendered`,`⚏ rendered`,`Show the rendering`],[`split`,`⇹ split`,`Edit the file beside its rendering`],[`source`,`⌗ source`,`Show the file as written`]].map(([e,t,n])=>(0,i.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),"aria-pressed":C===e,title:n,className:`rounded px-1.5 py-0.5 text-xs ${C===e?`bg-zinc-100 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-200`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:t},e))}),s!==void 0&&w===null&&(0,i.jsx)(`button`,{type:`button`,onClick:Ve,"aria-pressed":re,title:re?`Show file content`:`Show uncommitted changes (vs HEAD)`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs ${re?`bg-amber-100 text-amber-800 dark:bg-amber-950/60 dark:text-amber-300`:`text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`}`,children:`± diff`}),f&&w===null&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>p(e.path),title:`Show this file's history`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,children:`⎇ history`}),(0,i.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:[e.path,Se&&(0,i.jsx)(`span`,{className:`ml-1 text-amber-500`,children:`●`})]}),E&&w===null&&(0,i.jsx)(ee,{text:E.content}),E&&w===null&&!re&&xe&&(0,i.jsx)(`button`,{type:`button`,onClick:Re,className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500 dark:hover:text-zinc-200`,children:`✎ edit`}),E&&w===null&&!xe&&(0,i.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,title:`Outside the writable zone`,children:`🔒 read-only`}),w!==null&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>ze(),disabled:!Se||Ce||Te,className:`shrink-0 rounded border border-emerald-300 px-2 py-0.5 text-xs text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:Ce?`saving…`:`save`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{Se&&!window.confirm(`Discard unsaved changes?`)||oe(D&&E!==null?{draft:E.content,baseContent:E.content,baseMtimeMs:E.mtimeMs}:null)},className:`shrink-0 rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-500 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-400 dark:hover:border-zinc-500`,children:`cancel`})]}),(0,i.jsx)(`button`,{type:`button`,onClick:Le,title:`Close (Esc)`,"aria-label":`Close file viewer`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),Te&&w!==null&&(0,i.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:[(0,i.jsx)(`span`,{className:`min-w-0 flex-1`,children:`File changed on disk since you started editing.`}),(0,i.jsx)(`button`,{type:`button`,onClick:Be,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`reload (discard my edits)`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>ze(!0),disabled:Ce,className:`shrink-0 rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:hover:bg-amber-950/60`,children:`overwrite with my version`})]}),w!==null&&E?.saveError&&!E.saveError.conflict&&(0,i.jsx)(`div`,{className:`border-b border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:E.saveError.message}),(0,i.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[re&&w===null&&(0,i.jsxs)(`div`,{className:`p-4`,children:[l?.path===e.path&&`error`in l&&(0,i.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:l.error}),l?.path===e.path&&`before`in l&&(0,i.jsx)(pe,{fill:!0,lines:h(l.before,l.after)}),l?.path!==e.path&&(0,i.jsx)(`div`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`loading diff…`})]}),me&&w===null&&!re&&(0,i.jsx)(ej,{label:`This PDF`,children:(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),children:(0,i.jsx)(tj,{path:e.path,serverUrl:v,token:y,revision:te,...S?{onLoaded:S}:{}})})}),fe&&w===null&&!re&&(0,i.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,i.jsx)(`img`,{src:t.a(v,e.path,y,te),alt:e.path,onLoad:()=>x(e.path),className:`max-h-full max-w-full rounded object-contain`})}),e.status===`loading`&&w===null&&!re&&!fe&&!me&&(0,i.jsx)(`div`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,children:`loading…`}),e.status===`error`&&!fe&&!me&&(0,i.jsx)(`div`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:e.message}),w!==null&&!D&&Pe,E&&w===null&&!D&&!re&&de&&!ye&&Fe(E.content),D&&(0,i.jsxs)(`div`,{className:`flex h-full min-h-0`,"data-testid":`file-split`,children:[(0,i.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto border-r border-zinc-200 dark:border-zinc-800`,children:Pe??(0,i.jsx)(`div`,{className:`p-4`,children:(0,i.jsx)(ae,{code:E.content,path:e.path})})}),(0,i.jsx)(`div`,{className:`min-w-0 flex-1 overflow-auto`,"data-testid":`file-split-rendering`,children:de&&!_e?(0,i.jsx)(`div`,{className:`prose-chat p-4 text-zinc-700 dark:text-zinc-300`,children:Fe(De)}):(0,i.jsxs)(i.Fragment,{children:[je&&(0,i.jsx)(`p`,{"data-testid":`file-split-stale`,className:`flex flex-wrap items-center gap-2 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,children:(0,i.jsxs)(`span`,{children:[`Showing the document as it last stood.`,` `,Ne??`The text beside it does not satisfy the schema it declares.`]})}),Me!==void 0&&(0,i.jsxs)(`ul`,{"data-testid":`file-split-issues`,className:`space-y-0.5 border-b border-zinc-200 px-3 py-1.5 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:[Me.slice(0,6).map((e,t)=>(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),Me.length>6&&(0,i.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,Me.length-6,` more`]})]}),ke===void 0?(0,i.jsxs)(`p`,{className:`p-4 text-sm text-zinc-400 dark:text-zinc-600`,"data-testid":`file-split-nothing`,children:[`Nothing to draw yet. `,Ne??`This document does not satisfy the schema it declares.`]}):(0,i.jsx)(ej,{label:`This diagram`,children:(0,i.jsx)(`div`,{className:`p-4`,"data-testid":`file-structured-exchange`,children:(0,i.jsx)(dk,{envelope:ke,source:Ee})})})]})})]}),E&&w===null&&!D&&!re&&ge&&!ye&&he?.status===`valid`&&(0,i.jsx)(ej,{label:`This diagram`,children:(0,i.jsx)(`div`,{className:`mx-auto max-w-5xl p-4`,"data-testid":`file-structured-exchange`,children:(0,i.jsx)(dk,{envelope:he.envelope,source:E.content})})}),E&&w===null&&!D&&!re&&he?.status===`invalid`&&(0,i.jsxs)(`div`,{"data-testid":`file-structured-exchange-invalid`,className:`mx-4 mt-4 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200`,children:[(0,i.jsx)(`p`,{className:`font-medium`,children:`This declares a structured-exchange document and does not satisfy the schema.`}),(0,i.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:[(E.documentIssues??he.issues).slice(0,8).map((e,t)=>(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`span`,{className:`font-mono opacity-70`,children:e.path===``?`(document)`:e.path}),` `,e.message]},t)),(E.documentIssues??he.issues).length>8&&(0,i.jsxs)(`li`,{className:`opacity-70`,children:[`…and `,(E.documentIssues??he.issues).length-8,` more`]})]})]}),E&&w===null&&!D&&!re&&he?.status===`unsupported-version`&&(0,i.jsxs)(`div`,{"data-testid":`file-structured-exchange-unsupported`,className:`mx-4 mt-4 rounded-lg border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm text-zinc-600 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-400`,children:[`This document declares `,(0,i.jsx)(`span`,{className:`font-mono`,children:he.schema}),`, which this version does not render. Shown as text.`]}),E&&w===null&&!D&&!re&&(!de||ye)&&(!ge||ye)&&(0,i.jsx)(`div`,{className:`p-4`,children:(0,i.jsx)(ae,{code:E.content,path:e.path})})]}),se!==`idle`&&(0,i.jsxs)(`button`,{type:`button`,onClick:Le,"aria-live":`polite`,className:`flex items-center gap-2 border-t border-zinc-200 px-3 py-2 text-left text-sm hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900`,children:[se===`streaming`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 animate-pulse motion-reduce:animate-none rounded-full bg-amber-500`}),(0,i.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400`,children:`π is replying…`})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-emerald-500`}),(0,i.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:`π replied`})]}),(0,i.jsx)(`span`,{className:`ml-auto text-xs text-zinc-400 dark:text-zinc-500`,children:`show conversation →`})]})]})}function uj(e){return e.split(`
317
- `).map(e=>e.startsWith(`diff --git `)?{kind:`file`,text:e.slice(11)}:e.startsWith(`@@`)||e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`index `)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1)}:{kind:`context`,text:e.startsWith(` `)?e.slice(1):e})}function dj({show:e,onClose:t}){return(0,n.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,i.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,i.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,i.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,i.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:uj(e.patch).map((e,t)=>(0,i.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var fj=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],pj=`worktree`,mj={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},hj={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function gj(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function _j(e,t){return e===null||e.trim()===``?t.defaultWidth:gj(Number(e),t)}function vj(e,t){try{return _j((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function yj(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(gj(e,t)))}catch{}}function bj(e){let[t,r]=(0,n.useState)(()=>vj(e)),i=(0,n.useRef)(t),a=(0,n.useRef)(null),o=(0,n.useCallback)(t=>{let n=gj(t,e);return i.current=n,r(n),n},[e]),s=(0,n.useCallback)(()=>{a.current!==null&&(a.current=null,yj(i.current,e))},[e]);return{width:t,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),a.current={pointerId:e.pointerId,startX:e.clientX,startWidth:i.current})},onPointerMove:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&o(t.startWidth+e.clientX-t.startX)},onPointerUp:e=>{a.current?.pointerId===e.pointerId&&s()},onPointerCancel:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&(a.current=null,o(t.startWidth))},onLostPointerCapture:s,onKeyDown:t=>{let n=null;t.key===`ArrowLeft`?n=i.current-e.keyboardStep:t.key===`ArrowRight`?n=i.current+e.keyboardStep:t.key===`Home`&&(n=e.defaultWidth),n!==null&&(t.preventDefault(),yj(o(n),e))}}}}function xj({label:e,width:t,config:n,separatorProps:r,className:a=``}){return(0,i.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${a}`,children:(0,i.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 left-1/2 w-px bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var Sj=`#10b981`,Cj=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function wj(e){return e===0?Sj:Cj[(e-1)%Cj.length]}function Tj(e){return Cj[e%Cj.length]}function Ej(e){return e*14+7+1}function Dj(e){return e*14+2}function Oj({row:e,laneCount:t,colorOf:n=wj}){let r=Dj(t),a=Ej(e.lane),o=e.highlight?Sj:n(e.lane),s=e.dashed?`3 3`:void 0;return(0,i.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,i.jsx)(`line`,{x1:Ej(e),y1:0,x2:Ej(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,i.jsx)(`line`,{x1:a,y1:0,x2:a,y2:18,stroke:o,strokeWidth:2,strokeDasharray:s}),e.lineBelow&&(0,i.jsx)(`line`,{x1:a,y1:18,x2:a,y2:36,stroke:o,strokeWidth:2,strokeDasharray:s}),e.forkTo.map(e=>(0,i.jsx)(`path`,{d:`M ${a} 18 C ${a} 36, ${Ej(e)} 18, ${Ej(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,i.jsx)(`path`,{d:`M ${a} 18 C ${a} 0, ${Ej(e)} 18, ${Ej(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`circle`,{cx:a,cy:18,r:6,fill:`none`,stroke:o,strokeWidth:2}),(0,i.jsx)(`circle`,{cx:a,cy:18,r:2.5,fill:o})]}):(0,i.jsx)(`circle`,{cx:a,cy:18,r:4,fill:e.emphasis===`filled`?o:`var(--tree-off, #d4d4d8)`,stroke:o,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function kj(e,t={}){let n=[],r=[],i=0,a=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let t of e){let e=r.reduce((e,n,r)=>n===t.sha?[...e,r]:e,[]),o=e[0]??a(),s=e.slice(1);for(let e of s)r[e]=null;i=Math.max(i,o+1);let[c,...l]=t.parents;r[o]=c??null;let u=l.map(e=>{let t=a();return r[t]=e,t});n.push({rev:t.sha,path:t.path,entry:t,lane:o,through:r.reduce((e,t,n)=>t!==null&&n!==o&&!u.includes(n)?[...e,n]:e,[]),forkTo:u,mergeFrom:s,lineAbove:!0,lineBelow:t.parents.length>0,emphasis:`filled`})}let o=n[0];return n.unshift({rev:pj,path:o?.path??``,lane:o?.lane??0,through:o?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:n.length>0,emphasis:`current`,dashed:!t.dirty}),n[1]&&(n[1].lineAbove=!0),{rows:n,laneCount:Math.max(i,1)}}var Aj=20;function jj(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function Mj(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function Nj(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function Pj(e){return{rev:e.rev,path:e.path}}function Fj({history:e,diff:t,dirty:r,onFetchDiff:a,onClearDiff:o,onClose:s}){let[c,l]=(0,n.useState)({base:null,target:null}),{base:u,target:d}=c,[f,p]=(0,n.useState)(0),m=(0,n.useRef)([]),h=bj(hj),{rows:g,laneCount:_}=(0,n.useMemo)(()=>kj(e.entries,{dirty:r}),[e.entries,r]),v=(0,n.useRef)({onFetchDiff:a,onClose:s});v.current={onFetchDiff:a,onClose:s},(0,n.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),v.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,n.useEffect)(()=>{u===null||d===null||Nj(u,d)||v.current.onFetchDiff(u,d)},[u,d]);let y=(0,n.useCallback)((e,t)=>{let n=Pj(e);l(r=>{if(t===`base`)return{base:n,target:Nj(n,r.target)?r.base:r.target};if(t===`target`)return{base:Nj(n,r.base)?r.target:r.base,target:n};if(r.base===null&&r.target===null){let t=e.entry?.parents[0],r=t===void 0?void 0:g.find(e=>e.rev===t);return{base:r?Pj(r):null,target:n}}return{base:Nj(n,r.base)?r.target:r.base,target:n}})},[g]),b=(0,n.useCallback)(()=>{l({base:null,target:null}),o()},[o]),x=(0,n.useCallback)(()=>l(e=>({base:e.target,target:e.base})),[]),S=(0,n.useCallback)(e=>{p(t=>{let n=Math.max(0,Math.min(g.length-1,t+e));return m.current[n]?.focus(),n})},[g.length]),ee=e=>{let t=Pj(e);return Nj(t,u)?`base`:Nj(t,d)?`target`:null},te=g.findIndex(e=>Nj(Pj(e),u)),C=g.findIndex(e=>Nj(Pj(e),d)),ne=te>=0&&C>=0?{top:Math.min(te,C)*36+18,height:Math.abs(C-te)*36}:null;return(0,i.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),u!==null&&d!==null&&(0,i.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${Mj(u)} to ${Mj(d)}`,children:[(0,i.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:Mj(u)}),` → `,(0,i.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:Mj(d)})]}),u!==null&&d!==null&&(0,i.jsx)(`button`,{type:`button`,onClick:x,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(u!==null||d!==null)&&(0,i.jsx)(`button`,{type:`button`,onClick:b,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,i.jsx)(`button`,{type:`button`,onClick:s,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,i.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,i.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${h.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,i.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),S(1)):e.key===`ArrowUp`&&(e.preventDefault(),S(-1))},children:[e.status===`loading`&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,i.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,i.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[ne&&(0,i.jsx)(Ij,{top:ne.top,height:ne.height,baseFirst:te<C}),g.map((e,t)=>(0,i.jsx)(zj,{ref:e=>{m.current[t]=e},row:e,laneCount:_,role:ee(e),isFocused:t===f,onSelect:t=>y(e,t),onFocus:()=>p(t)},e.rev))]})]}),(0,i.jsx)(xj,{label:`Resize History commit list`,width:h.width,config:hj,separatorProps:h.separatorProps,className:`hidden md:block`})]}),(0,i.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,i.jsx)(Bj,{diff:t,base:u,target:d})})]})]})}function Ij({top:e,height:t,baseFirst:n}){return(0,i.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:Aj},children:[(0,i.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,i.jsx)(Lj,{label:n?`base`:`target`,className:`top-0`}),(0,i.jsx)(Lj,{label:n?`target`:`base`,className:`bottom-0`})]})}function Lj({label:e,className:t}){return(0,i.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,i.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var Rj=`shrink-0 rounded px-1 py-0.5 text-[10px] text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 aria-disabled:cursor-default aria-disabled:opacity-30 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function zj({row:e,laneCount:t,role:n,isFocused:r,onSelect:a,onFocus:o,ref:s}){let c=e.entry,l=c?`${c.sha.slice(0,7)} ${c.subject}`:`Working tree`;return(0,i.jsxs)(`div`,{ref:s,role:`button`,tabIndex:r?0:-1,"aria-label":l,"aria-current":n===null?void 0:`true`,onFocus:o,onClick:()=>a(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),a()):e.key===`b`?a(`base`):e.key===`t`&&a(`target`))},style:{height:36,paddingLeft:Aj},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,i.jsx)(Oj,{row:e,laneCount:t}),c?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:c.sha.slice(0,7)}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:c.subject,children:c.subject}),(0,i.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[c.author,` · `,jj(c.date)]}),(0,i.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${c.added} lines added, ${c.deleted} removed`,children:[(0,i.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,c.added]}),` `,(0,i.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,c.deleted]})]})]}):(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,i.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,i.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),a(`base`)},className:Rj,children:`base`}),(0,i.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),a(`target`)},className:Rj,children:`target`})]})]})}function Bj({diff:e,base:t,target:n}){return t===null&&n===null?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,i.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):e.status===`loaded`&&m(e.beforeText,e.afterText)?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,i.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,i.jsx)(pe,{fill:!0,lines:h(e.beforeText,e.afterText)})})}var Vj={stopped:`stopped`,starting:`starting…`,idle:`idle`,working:`working`,waiting:`waiting for you`,"ready-for-review":`ready for review`};function Hj({activity:e}){switch(e){case`stopped`:return(0,i.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full border border-dashed border-zinc-400 dark:border-zinc-600`});case`starting`:return(0,i.jsx)(`svg`,{className:`h-2.5 w-2.5 shrink-0 animate-spin text-zinc-500 dark:text-zinc-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.5`,strokeLinecap:`round`,children:(0,i.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`})});case`working`:return(0,i.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0 items-center justify-center`,children:[(0,i.jsx)(`span`,{className:`absolute h-2 w-2 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,i.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-700 dark:bg-blue-400`})]});case`waiting`:return(0,i.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-amber-500`});case`ready-for-review`:return(0,i.jsx)(`span`,{className:`h-2 w-2 shrink-0 rotate-45 rounded-[1px] border-2 border-violet-600 bg-violet-100 dark:border-violet-400 dark:bg-violet-950`});default:return(0,i.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-zinc-400 dark:bg-zinc-600`})}}function Uj({className:e}){return(0,i.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,i.jsx)(`path`,{d:`M12 6v7`}),(0,i.jsx)(`path`,{d:`M12 18h.01`})]})}function Wj({className:e}){return(0,i.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,i.jsx)(`path`,{d:`M7 3h10v18H7z`}),(0,i.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.5-3.7`})]})}function Gj(e){let{workspace:t,workspaces:r,locked:a}=e,[o,s]=(0,n.useState)(!1),c=(0,n.useRef)(null);if((0,n.useEffect)(()=>{if(!o)return;let e=e=>{TA(e,c.current)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),a||!t)return null;let l=r.filter(e=>e.root!==t.root),u=r.filter(e=>e.needsAttention);return(0,i.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,"aria-haspopup":`menu`,title:`Project: ${t.name} (${Vj[t.activity]})`,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${u.length>0?`border-amber-500 bg-amber-50 text-zinc-700 dark:bg-amber-950/40 dark:text-zinc-200`:`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`}`,children:[(0,i.jsx)(Hj,{activity:t.activity}),(0,i.jsx)(`span`,{className:`font-medium`,children:t.name}),u.length>0?(0,i.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-600 dark:text-amber-500`,children:[(0,i.jsx)(Uj,{className:`h-3 w-3`}),(0,i.jsx)(`span`,{className:`font-semibold`,children:u.length})]}):l.some(e=>e.activity===`working`)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`h-3 w-px bg-zinc-300 dark:bg-zinc-600`}),(0,i.jsx)(`span`,{className:`flex items-center gap-1`,children:l.map(e=>e.activity===`working`?(0,i.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 items-center justify-center`,children:[(0,i.jsx)(`span`,{className:`absolute h-1.5 w-1.5 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,i.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-blue-700 dark:bg-blue-400`})]},e.root):(0,i.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-zinc-300 dark:bg-zinc-600`},e.root))})]}),(0,i.jsx)(`svg`,{className:`h-3 w-3 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),o&&(0,i.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-full z-40 mt-1 w-87 rounded-md border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[r.map(n=>{let a=n.root===t.root;return(0,i.jsxs)(`div`,{className:`group flex items-center gap-2.5 rounded-md px-2.5 py-2 ${a?`bg-zinc-100 dark:bg-zinc-800`:`hover:bg-zinc-50 dark:hover:bg-zinc-800/50`}`,children:[(0,i.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(!1),a||e.onSwitch(n.root)},className:`flex min-w-0 flex-1 items-center gap-2.5 text-left`,children:[(0,i.jsx)(Hj,{activity:n.activity}),(0,i.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,i.jsx)(`span`,{className:`truncate text-[13px] ${a?`font-semibold text-zinc-900 dark:text-zinc-100`:`font-medium text-zinc-900 dark:text-zinc-100`}`,children:n.name}),(0,i.jsx)(`span`,{className:`truncate font-mono text-[11px] text-zinc-400 dark:text-zinc-500`,children:n.root})]})]}),(0,i.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[n.needsAttention?(0,i.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium ${n.activity===`ready-for-review`?`text-violet-700 dark:text-violet-400`:`text-amber-600 dark:text-amber-500`}`,children:[n.activity===`ready-for-review`?(0,i.jsx)(Wj,{className:`h-3 w-3`}):(0,i.jsx)(Uj,{className:`h-3 w-3`}),Vj[n.activity]]}):(0,i.jsx)(`span`,{className:`text-[11px] ${n.activity===`working`?`text-blue-700 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-500`}`,children:Vj[n.activity]}),r.length>1&&(0,i.jsx)(`button`,{type:`button`,title:`Close ${n.name}`,"aria-label":`Close ${n.name}`,onClick:t=>{t.stopPropagation(),e.onClose(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-transparent text-zinc-400 opacity-0 group-hover:border-zinc-300 group-hover:opacity-100 hover:text-zinc-700 dark:group-hover:border-zinc-600 dark:hover:text-zinc-200`,children:(0,i.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,i.jsx)(`path`,{d:`M18 6 6 18`}),(0,i.jsx)(`path`,{d:`m6 6 12 12`})]})})]})]},n.root)}),(0,i.jsx)(`div`,{className:`my-1 h-px bg-zinc-200 dark:bg-zinc-700`}),(0,i.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(!1),e.onOpen()},className:`flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-[13px] text-zinc-700 hover:bg-zinc-50 dark:text-zinc-300 dark:hover:bg-zinc-800/50`,children:[(0,i.jsxs)(`svg`,{className:`h-3.5 w-3.5 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,i.jsx)(`path`,{d:`M12 5v14`}),(0,i.jsx)(`path`,{d:`M5 12h14`})]}),`Open a project…`]})]})]})}function Kj({label:e,browse:t,onBrowse:r,onSelect:a,onCancel:o}){let s=t?.path??`/`,c=t?.entries??[],l=t?.status===`loading`,[u,d]=(0,n.useState)(s);return(0,n.useEffect)(()=>{d(s)},[s]),(0,i.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,i.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,i.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,i.jsx)(`button`,{type:`button`,onClick:o,className:`text-xs text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,children:`Cancel`})]}),(0,i.jsxs)(`form`,{className:`mb-2 flex gap-1`,onSubmit:e=>{e.preventDefault();let t=u.trim();t&&r(t)},children:[(0,i.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),d(s))},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Current directory`,"data-testid":`picker-path`,className:`min-w-0 flex-1 rounded border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-700 focus:border-zinc-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),(0,i.jsx)(`button`,{type:`submit`,disabled:u.trim()===``||u===s,className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Go`})]}),t?.status===`error`&&(0,i.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,i.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,disabled:!t?.parent,onClick:()=>t?.parent&&r(t.parent),className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Up`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>a(s),className:`rounded bg-zinc-800 px-2 py-1 text-xs font-medium text-white hover:bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-900`,children:`Use this directory`})]}),(0,i.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[l&&c.length===0&&(0,i.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!l&&c.length===0&&t?.status!==`error`&&(0,i.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),c.map(e=>(0,i.jsx)(`li`,{children:(0,i.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),className:`w-full truncate rounded px-2 py-1 text-left font-mono text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,title:e.path,children:[e.name,e.name.endsWith(`:`)?`\\`:`/`]})},e.path))]})]})}function qj(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Jj(e){let{sandbox:t,applyState:r,blocked:a=!1,onCloseBrowser:o}=e,[s,c]=(0,n.useState)(!1),l=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{a&&s&&(l.current=!1,c(!1))},[a,s]),(0,n.useEffect)(()=>{if(l.current&&r?.status!==`applying`){if(r?.status===`error`){l.current=!1;return}l.current=!1,c(!1),o()}},[r,o]),!t)return(0,i.jsx)(`span`,{className:`rounded-md border border-dashed border-zinc-300 px-2 py-1 text-xs text-zinc-400 dark:border-zinc-700 dark:text-zinc-500`,title:`This server runs without a sandbox, so there is no root to move`,children:`No sandbox`});let u=t.locks?.root===!0,d=qj(t.root);return(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsxs)(`button`,{type:`button`,disabled:u,"aria-label":u?`Sandbox root: ${t.root} (locked)`:`Sandbox root: ${t.root}`,title:u?`${t.root} — locked by the server's configuration`:t.root,onClick:()=>{e.onOpened(),c(!0),e.onBrowse(t.root)},className:`flex max-w-[14rem] items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${u?`cursor-not-allowed border-zinc-200 text-zinc-400 dark:border-zinc-800 dark:text-zinc-500`:`border-zinc-300 text-zinc-600 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`}`,children:[(0,i.jsx)(`span`,{className:`truncate font-mono`,children:d}),u?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):(0,i.jsx)(`span`,{"aria-hidden":`true`,children:`▾`})]}),s&&(0,i.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 w-[380px] rounded-lg border border-zinc-200 bg-white p-2 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[r?.status===`error`&&(0,i.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:r.message}),(0,i.jsx)(Kj,{label:`Choose the sandbox root`,browse:e.browse,onBrowse:e.onBrowse,onSelect:t=>{l.current=!0,e.onSelect(t)},onCancel:()=>{l.current=!1,c(!1),o()}})]})]})}function Yj(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function Xj(e){return e.slice(e.lastIndexOf(`/`)+1)}function Zj({status:e,selected:t,log:r,onFetchLog:a,onShowCommit:o}){let[s,c]=(0,n.useState)(!1),l=EA(()=>c(!1)),u=e?.repos??[],d=(t===null?null:Xk(u,t))??(t===null&&u.length===1?u[0]:null),f=d&&(d.ahead>0||d.behind>0)?` ${d.ahead>0?`↑${d.ahead}`:``}${d.behind>0?`↓${d.behind}`:``}`:``,p=u.length>1&&d!==null&&d.repo!==``?`${Xj(d.repo)} `:``,m=e===null?`…`:d?.branch??`—`,h=d!==null&&r?.repo===d.repo?r.entries:null;return(0,n.useEffect)(()=>{s&&d!==null&&r?.repo!==d.repo&&a(d.repo)},[s,d?.repo,a]),(0,i.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,i.jsxs)(`button`,{type:`button`,disabled:d===null,onClick:()=>{d!==null&&(c(!s),s||a(d.repo))},title:d===null?`no repository selected`:`git history — ${d.repo===``?`this project`:d.repo}`,className:`rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-default disabled:hover:border-zinc-300 disabled:hover:text-zinc-500 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200 dark:disabled:hover:border-zinc-800 dark:disabled:hover:text-zinc-400`,children:[p,`⎇ `,m,f]}),s&&d!==null&&(0,i.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[h===null&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),h?.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),h?.map(e=>(0,i.jsxs)(`button`,{type:`button`,onClick:()=>{o(d.repo,e.sha),c(!1)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,i.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,i.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,Yj(e.date)]})]},e.sha))]})]})}function Qj(e){return[...e].sort((e,t)=>e.localeCompare(t))}function $j({extensionPaths:e,configuredExtensionPaths:t,userExtensionPaths:r,extensionLock:a,tools:o,commands:s,sandbox:c,gitUnavailable:l,userSkillPaths:u,serverBrowse:d,pickerBlocked:f=!1,onPickerOpened:p,applyState:m,versions:h,onBrowseServerPath:g,onCloseServerBrowser:_,onUpdateConfig:v}){let[y,b]=(0,n.useState)(!1),[x,S]=(0,n.useState)(``),[ee,te]=(0,n.useState)(``),[C,ne]=(0,n.useState)(!1),[re,ie]=(0,n.useState)(!1),[ae,w]=(0,n.useState)(u),[oe,se]=(0,n.useState)(r),[T,ce]=(0,n.useState)(null);(0,n.useEffect)(()=>{f&&T!==null&&ce(null)},[f,T]);let le=EA(()=>{(y||T!==null)&&ge()}),E=o.filter(e=>e.active),ue=o.filter(e=>!e.active),de=s.filter(e=>e.source===`skill`),fe=[...o].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),pe=m?.status===`applying`,me=m?.status===`error`?m.message:null;(0,n.useEffect)(()=>{c&&(S(c.root),te(c.writableRoot??``),ne(c.allowWrite),ie(c.allowBash))},[c]),(0,n.useEffect)(()=>{w(u)},[u]),(0,n.useEffect)(()=>{se(r)},[r]);let he=(0,n.useRef)(!1);(0,n.useEffect)(()=>{he.current&&m===null&&ge(),he.current=pe},[m,pe]);function ge(){b(!1),ce(null),_()}function _e(e,t){p?.(),ce(e),g(t.trim()||`/`)}function ve(e){T===`root`?S(e):T===`writableRoot`?te(e):T===`skill`&&!ae.includes(e)?w([...ae,e]):T===`extension`&&!oe.includes(e)&&se([...oe,e]),ce(null),_()}function ye(){let e=c?{root:x,allowWrite:C,allowBash:re,writableRoot:ee.trim()||void 0}:void 0;v({...e?{sandbox:e}:{},userSkillPaths:ae,...a?{}:{userExtensionPaths:oe}})}let be=T!==null&&(0,i.jsx)(Kj,{label:T===`skill`?`Choose a skills directory`:T===`extension`?`Choose an extensions directory`:T===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:d,onBrowse:g,onSelect:ve,onCancel:()=>{ce(null),_()}});return(0,i.jsxs)(`div`,{className:`relative`,ref:le,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>b(!y),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),y&&(0,i.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,i.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,i.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[l&&(0,i.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),l.reason===`no-repository`?(0,i.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,i.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,i.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:l.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,i.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:l.message}),l.reason===`no-executable`&&(0,i.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,i.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),(0,i.jsxs)(`section`,{className:`mb-4`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),o.length===0?(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,i.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[E.length,` tools active`,ue.length?` · ${ue.length} inactive`:``]}),(0,i.jsx)(`ul`,{className:`mt-2 space-y-1`,children:fe.map(e=>(0,i.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,i.jsx)(`span`,{children:e.name}),(0,i.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),de.length===0?(0,i.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,i.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[de.length,` skills loaded`]}),(0,i.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Qj(de.map(e=>e.name)).map(e=>(0,i.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,i.jsxs)(`div`,{className:`mt-3`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,i.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User skill paths`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>_e(`skill`,ae[ae.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add skills directory…`})]}),ae.length===0?(0,i.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skill directories added`}):(0,i.jsx)(`ul`,{className:`mt-1 space-y-1`,children:Qj(ae).map(e=>(0,i.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,i.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>w(ae.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),T===`skill`&&(0,i.jsx)(`div`,{className:`mt-2`,children:be})]})]}),(0,i.jsxs)(`section`,{className:`mb-4`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e===null?(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):e.length===0?(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,i.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[e.length,` `,e.length===1?`extension`:`extensions`,` loaded`]}),(0,i.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Qj(e).map(e=>(0,i.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),t.length>0&&(0,i.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[t.length,` configured by this deployment`]}),(0,i.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,i.jsx)(`ul`,{className:`mt-1 space-y-1`,children:Qj(t).map(e=>(0,i.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),a?(0,i.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths are locked by this deployment.`}):(0,i.jsxs)(`div`,{className:`mt-3`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,i.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User extension paths`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>_e(`extension`,oe[oe.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add extensions directory…`})]}),T===`extension`&&(0,i.jsx)(`p`,{className:`mt-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`extension-warning`,role:`note`,children:`Extensions are code, and they run with the agent's privileges. Every extension in the directory you choose is loaded.`}),oe.length===0?(0,i.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No extension directories added`}):(0,i.jsx)(`ul`,{className:`mt-1 space-y-1`,children:Qj(oe).map(e=>(0,i.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,i.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>se(oe.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),T===`extension`&&(0,i.jsx)(`div`,{className:`mt-2`,children:be})]})]}),c&&(0,i.jsxs)(`section`,{children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,i.jsxs)(`div`,{className:`space-y-3`,children:[(0,i.jsxs)(`label`,{className:`block`,children:[(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,c.locks?.root?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,i.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,i.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),disabled:c.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:c.locks?.root,onClick:()=>_e(`root`,x),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),T===`root`&&be,(0,i.jsxs)(`label`,{className:`block`,children:[(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,c.locks?.writableRoot?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,i.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,i.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),disabled:c.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:c.locks?.writableRoot,onClick:()=>_e(`writableRoot`,ee||x),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),T===`writableRoot`&&be,(0,i.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>ne(e.target.checked),disabled:c.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,c.locks?.allowWrite?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,i.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:re,onChange:e=>ie(e.target.checked),disabled:c.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,c.locks?.allowBash?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!c&&(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,i.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[me&&(0,i.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:me}),(0,i.jsx)(`button`,{type:`button`,disabled:pe||c!==null&&!x.trim(),onClick:ye,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:pe?`Applying…`:`Apply & restart session`}),(0,i.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`})]}),h&&(0,i.jsxs)(`section`,{className:`mt-4`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,i.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,i.jsxs)(`p`,{children:[`pi-outpost: `,(0,i.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:h.piOutpost})]}),h.piSdk&&(0,i.jsxs)(`p`,{children:[`pi SDK: `,(0,i.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:h.piSdk})]}),h.agent&&(0,i.jsxs)(`p`,{children:[`agent: `,(0,i.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:h.agent})]})]})]})]})]})]})}function eM(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0){n.delete(o);return}for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function tM(e){return e.flatMap(e=>[e,...tM(e.children)])}function nM({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,i.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var rM=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function iM({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:a,onClose:o}){let{node:s}=e,c=s.tipId??s.entryId;return(0,i.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,i.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),o()},title:n?`unavailable while the agent is running`:s.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,i.jsx)(Oj,{row:e,laneCount:t,colorOf:Tj}),(0,i.jsx)(`span`,{className:`min-w-0 truncate ${s.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:s.text||`(empty)`}),e.forkTo.length>0&&(0,i.jsxs)(nM,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,i.jsxs)(nM,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,i.jsx)(nM,{tone:`current`,children:`current`}),s.label&&(0,i.jsx)(nM,{tone:`label`,children:s.label})]}),(0,i.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),o()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:rM,children:`↺ redo`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{a(s.entryId),o()},title:`fork a new session from this point`,className:rM,children:`⑂ fork`})]})}function aM({tree:e,isStreaming:t,onListTree:r,onNavigate:a,onFork:o}){let[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)(``),d=EA(()=>c(!1));(0,n.useEffect)(()=>{s&&e===null&&r()},[s,e]);let f=(0,n.useMemo)(()=>e&&e.length>0?eM(e):null,[e]),p=(0,n.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return tM(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,i.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),r())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),s&&(0,i.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,i.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,i.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[f.rows.length,` turn`,f.rows.length===1?``:`s`,` · `,f.branchPoints,` branch point`,f.branchPoints===1?``:`s`]})]}),(0,i.jsx)(`input`,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,i.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,i.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,i.jsx)(iM,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:a,onFork:o,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,i.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,i.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{a(e.tipId??e.entryId),c(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,i.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,i.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,i.jsx)(nM,{tone:`current`,children:`on current branch`}),e.label&&(0,i.jsx)(nM,{tone:`label`,children:e.label})]}),(0,i.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{a(e.entryId),c(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:rM,children:`↺ redo`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{o(e.entryId),c(!1)},title:`fork a new session from this point`,className:rM,children:`⑂ fork`})]},e.entryId))})]})]})]})}var oM=200;function sM({initial:e,onCommit:t,onCancel:r}){let[a,o]=(0,n.useState)(e);return(0,i.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`?t(a):e.key===`Escape`&&r()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function cM({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:a,onStartRename:o,onRename:s,onCancelRename:c}){return n?(0,i.jsx)(`div`,{className:`px-3 py-2`,children:(0,i.jsx)(sM,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,i.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,i.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,i.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,i.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,i.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``]})]}),(0,i.jsx)(`button`,{type:`button`,onClick:o,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&(0,i.jsx)(`button`,{type:`button`,onClick:a,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function lM({sessions:e,sessionSearch:t,sessionId:r,onSwitchSession:a,onDeleteSession:o,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(``),[h,g]=(0,n.useState)(null),_=EA(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,n.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),oM);return()=>clearTimeout(e)},[d,v,y]);function b(){f(!1),g(null)}let x=y&&(t?.status!==`loaded`||t.query!==v),S=y?x?null:t?.results??null:e;return(0,i.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>{if(d){b();return}f(!0),m(``),g(null),u(),s()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),d&&(0,i.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsx)(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,i.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,i.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[S===null&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),S?.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),S?.map(e=>(0,i.jsx)(cM,{session:e,isCurrent:e.id===r,renaming:h===e.path,onSwitch:()=>{a(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&o(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function uM({theme:e,onToggle:t}){return(0,i.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e===`dark`?`☀`:`☾`})}function dM(e){let{isStreaming:t,connected:n}=e;return(0,i.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,i.jsx)(Gj,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject}),e.workspaceControl===`root`&&e.rootControl&&(0,i.jsx)(Jj,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,i.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,i.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`rounded-md border px-2 py-1 text-xs ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,i.jsx)(Zj,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,i.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,i.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:ZA(t)},e)),(0,i.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:e.onToggleHideTools,title:e.hideTools?`Show tool cards in the conversation`:`Hide tool cards (long sessions read better without them)`,"aria-pressed":e.hideTools,className:`rounded-md border px-2 py-1 text-xs ${e.hideTools?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`⚒ tools`}),e.onToggleTerminal&&(0,i.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`rounded-md border px-2 py-1 text-xs ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,i.jsx)(uM,{theme:e.theme,onToggle:e.onToggleTheme}),(0,i.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,i.jsx)(aM,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,i.jsx)(lM,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,i.jsx)($j,{extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onUpdateConfig:e.onUpdateConfig}),(0,i.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function fM(e,t){let r=(0,n.useRef)(new Map);(0,n.useEffect)(()=>{if(typeof Notification>`u`)return;let n=e.filter(e=>e.needsAttention),i=n.filter(e=>e.root!==t);for(let e of[...r.current.keys()])n.some(t=>t.root===e)||r.current.delete(e);if(Notification.permission===`granted`&&!(typeof document<`u`&&document.visibilityState===`visible`)){for(let e of i)if(r.current.get(e.root)!==e.activity){r.current.set(e.root,e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${e.root}`})}catch{}}}},[e,t])}function pM(e){return!e||e.percent===null?`text-zinc-400 dark:text-zinc-600`:e.percent>=85?`text-red-500`:e.percent>=60?`text-amber-500 dark:text-amber-400`:`text-emerald-500`}function mM({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,a=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),o=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`span`,{children:[Sk(e.totalTokens),` tok`]}),r>0&&(0,i.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[xk(e.cost),e.unpriced>0&&`*`]})]}),s=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,i.jsx)(`button`,{type:`button`,onClick:n,title:`${a} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${s} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:o}):(0,i.jsx)(`span`,{title:a,className:`${s} border-zinc-300 dark:border-zinc-800`,children:o})}function hM({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,a=Math.min(100,Math.max(0,r))/100*n;return(0,i.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,i.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,i.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${a} ${n-a}`,className:pM(e)})]})}function gM({thinkingLevel:e,thinkingLevels:t,isStreaming:r,onSetThinking:a}){let[o,s]=(0,n.useState)(!1),c=(0,n.useRef)(null),l=e!==`off`,u=t&&t.length>0?t:fj,d=Math.max(0,u.indexOf(e));return(0,n.useEffect)(()=>{if(!o)return;function e(e){c.current&&!TA(e,c.current)&&s(!1)}function t(e){e.key===`Escape`&&s(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,i.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),disabled:r,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":o,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${l?`border-amber-300 text-amber-700 hover:border-amber-400 dark:border-amber-900 dark:text-amber-400 dark:hover:border-amber-700`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`}`,children:[(0,i.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${l?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),o&&(0,i.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,i.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,i.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),(0,i.jsx)(`input`,{type:`range`,min:0,max:u.length-1,step:1,value:d,onChange:e=>a(u[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,i.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,i.jsx)(`span`,{children:u[0]}),(0,i.jsx)(`span`,{children:u[u.length-1]})]})]})]})}function _M(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:a,isStreaming:o,contextUsage:s,sessionUsage:c,isCompacting:l}=e;return(0,i.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,i.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:o,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,i.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,i.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),a&&(0,i.jsx)(gM,{thinkingLevel:r,thinkingLevels:e.thinkingLevels,isStreaming:o,onSetThinking:e.onSetThinking}),(0,i.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:o||l,title:s?.tokens==null?`Click to compact the conversation context`:`${s.tokens.toLocaleString()} / ${s.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,i.jsx)(hM,{usage:s}),l?`compacting…`:s?.percent==null?`context`:`${Math.round(s.percent)}%`]}),(0,i.jsx)(mM,{usage:c,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var vM=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,yM=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function bM({title:e,credentials:t,onSetCredential:r,onDeclareProvider:a,errors:o}){let s=t.providers,[c,l]=(0,n.useState)(s.length>0?`known`:`custom`),[u,d]=(0,n.useState)(s[0]?.id??``),[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)(``),[g,_]=(0,n.useState)(``),[v,y]=(0,n.useState)(``),[b,x]=(0,n.useState)(!0),[S,ee]=(0,n.useState)(!0),te=s.some(e=>e.configured)&&!t.usableModel;function C(e){if(e.preventDefault(),!te){if(c===`known`){u&&f.trim()&&r(u,f.trim());return}!m.trim()||!g.trim()||!f.trim()||!v.trim()||a({provider:m.trim(),baseUrl:g.trim(),apiKey:f.trim(),models:[v.trim()],compat:{supportsDeveloperRole:b,supportsReasoningEffort:S}})}}return(0,i.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,i.jsxs)(`form`,{onSubmit:C,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),te?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,i.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,i.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,i.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,i.jsx)(`button`,{type:`button`,onClick:()=>l(e),className:`flex-1 rounded-md px-2 py-1.5 ${c===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),c===`known`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`label`,{htmlFor:`onboarding-provider`,className:yM,children:`Provider`}),(0,i.jsx)(`select`,{id:`onboarding-provider`,value:u,onChange:e=>d(e.target.value),className:`${vM} mb-3`,children:s.map(e=>(0,i.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`label`,{htmlFor:`onboarding-name`,className:yM,children:`Name`}),(0,i.jsx)(`input`,{id:`onboarding-name`,value:m,onChange:e=>h(e.target.value),placeholder:`corp`,className:`${vM} mb-3`}),(0,i.jsx)(`label`,{htmlFor:`onboarding-url`,className:yM,children:`Base URL`}),(0,i.jsx)(`input`,{id:`onboarding-url`,value:g,onChange:e=>_(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${vM} mb-3`}),(0,i.jsx)(`label`,{htmlFor:`onboarding-model`,className:yM,children:`Model id`}),(0,i.jsx)(`input`,{id:`onboarding-model`,value:v,onChange:e=>y(e.target.value),placeholder:`gpt-oss-120b`,className:`${vM} mb-3`})]}),(0,i.jsx)(`label`,{htmlFor:`onboarding-key`,className:yM,children:`API key`}),(0,i.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:f,onChange:e=>p(e.target.value),placeholder:`sk-…`,className:vM}),c===`custom`&&(0,i.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,i.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,i.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`mt-0.5`}),(0,i.jsxs)(`span`,{children:[`Server understands the `,(0,i.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,i.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,i.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>ee(e.target.checked),className:`mt-0.5`}),(0,i.jsxs)(`span`,{children:[`Server accepts `,(0,i.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,i.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),o.map((e,t)=>(0,i.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,i.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,i.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var xM=`application/x-pi-outpost-file`,SM=`application/x-pi-outpost-read-only-file`,CM=`mr-1 shrink-0 rounded px-1 text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,wM={modified:{label:`M`,className:`text-amber-600 dark:text-amber-400`},added:{label:`A`,className:`text-emerald-600 dark:text-emerald-400`},untracked:{label:`U`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`D`,className:`text-red-600 dark:text-red-400`},conflicted:{label:`C`,className:`text-purple-600 dark:text-purple-400`}};function TM(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function EM(e){return e===`directory`||e===`symlink-directory`}function DM(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function OM({dir:e,depth:t,creation:r}){let[a,o]=(0,n.useState)(``),s=(0,n.useRef)(null),c=r.localError??r.serverError;return(0,n.useEffect)(()=>{s.current?.focus()},[]),(0,i.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,i.jsx)(`input`,{ref:s,value:a,onChange:e=>o(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),r.submit(e,a)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{c===null&&r.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),c!==null&&(0,i.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:c})]})}function kM({path:e,name:t,depth:r,rename:a}){let[o,s]=(0,n.useState)(t),c=(0,n.useRef)(null),l=a.localError??a.serverError;return(0,n.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]),(0,i.jsxs)(`div`,{style:{paddingLeft:r*12+16},className:`py-0.5`,children:[(0,i.jsx)(`input`,{ref:c,value:o,disabled:a.pending,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!a.pending?(t.preventDefault(),a.submit(e,o)):t.key===`Escape`&&(t.preventDefault(),a.cancel())},onBlur:()=>{l===null&&a.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),l!==null&&(0,i.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:l})]})}function AM({path:e,depth:t,...n}){let r=n.tree[e],a=n.creation?.openIn===e?(0,i.jsx)(OM,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?a:r===`loading`?(0,i.jsxs)(i.Fragment,{children:[a,(0,i.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,i.jsxs)(i.Fragment,{children:[a,(0,i.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,i.jsxs)(i.Fragment,{children:[a,a===null&&(0,i.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,i.jsxs)(i.Fragment,{children:[a,r.map(r=>(0,i.jsx)(jM,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function jM({parentPath:e,entry:t,depth:r,...a}){let[o,s]=(0,n.useState)(!1),[c,l]=(0,n.useState)(!1),u=e?`${e}/${t.name}`:t.name,d=DM(u,a.writableRoot),f=a.fileOperation?.status===`pending`;if(EM(t.type)){let e=!d&&!f,n=e=>e.includes(SM)?a.onCopyFile===void 0?null:`copy`:a.onMoveFile===void 0?null:`move`;return(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${c?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(xM))return;let r=n(Array.from(t.dataTransfer.types));r!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=r,l(!0))},onDragLeave:()=>l(!1),onDrop:t=>{if(!e)return;let r=t.dataTransfer.getData(xM),i=r?n(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),l(!1),i===`copy`?a.onCopyFile?.(r,u):a.onMoveFile?.(r,u))},children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!o;s(e),e&&a.tree[u]===void 0&&a.onExpand(u),a.onSelectDirectory?.(u)},style:{paddingLeft:r*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,i.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:o?`▾`:`▸`}),(0,i.jsx)(`span`,{title:t.name,className:`truncate ${d?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!o&&TM(u,a.gitFiles)>0&&(0,i.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${TM(u,a.gitFiles)} changed file(s) inside`,children:TM(u,a.gitFiles)})]}),a.creation&&!d&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>{s(!0),a.tree[u]===void 0&&a.onExpand(u),a.creation?.start(u)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),o&&(0,i.jsx)(AM,{path:u,depth:r+1,...a})]})}let p=u===a.openFilePath,m=a.gitFiles?.[u],h=a.attachedPaths?.includes(u)??!1,g=t.type===`file`,_=g||t.type===`symlink-file`,v=g&&!d,y=g&&(d?a.onCopyFile!==void 0:a.onMoveFile!==void 0);return a.rename?.path===u?(0,i.jsx)(kM,{path:u,name:t.name,depth:r,rename:a.rename}):(0,i.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${p?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,i.jsx)(`button`,{type:`button`,draggable:y&&!f,onDragStart:e=>{!y||f||(e.dataTransfer.effectAllowed=d?`copy`:`move`,e.dataTransfer.setData(xM,u),d&&e.dataTransfer.setData(SM,`copy`))},onClick:()=>a.onSelectFile(u),style:{paddingLeft:r*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,i.jsx)(`span`,{title:t.name,className:`truncate ${d?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),_&&a.onOpenNative&&(0,i.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>a.onOpenNative?.(u),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:CM,children:`↗`}),v&&a.onRenameFile&&(0,i.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>a.rename?.start(u),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:CM,children:`✎`}),v&&a.onDeleteFile&&(0,i.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&a.onDeleteFile?.(u)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${CM} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),a.onToggleAttachPath&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>a.onToggleAttachPath?.(u),title:h?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${h?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":h,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${h?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),m&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>(a.onSelectDiff??a.onSelectFile)(u),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${wM[m].className}`,children:wM[m].label})]})}function MM(e){let t=e.trim();if(t===``)return{error:`A name is required`};let n=t.endsWith(`/`),r=n?t.slice(0,-1).trim():t;return r===``?{error:`A name is required`}:r.includes(`/`)||r.includes(`\\`)?{error:`That is a path, not a name`}:r===`.`||r===`..`?{error:`"${r}" is not a name`}:{kind:n?`directory`:`file`,name:r}}function NM(e){let t=MM(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function PM(e){let[t,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[s,c]=(0,n.useState)(null),[l,u]=(0,n.useState)(null),[d,f]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),h=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,g=e.createError&&s&&e.createError.path===FM(s.dir,s.name)?e.createError.message:null,_=e.created??null;(0,n.useEffect)(()=>{s!==null&&_!==null&&_===FM(s.dir,s.name)&&(r(null),c(null),o(null))},[s,_]);let v=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&p===e.fileOperation.path?e.fileOperation.message:null;(0,n.useEffect)(()=>{let t=e.fileOperation;t?.status===`succeeded`&&t.operation===`rename_file`&&p===t.path&&(u(null),m(null),f(null))},[p,e.fileOperation]);let y=h?{openIn:t,localError:a,serverError:g,start:e=>{r(e),o(null),c(null)},cancel:()=>{r(null),o(null),c(null)},submit:(t,n)=>{let r=MM(n);if(`error`in r){o(r.error);return}o(null),c({dir:t,name:r.name});let i=FM(t,r.name);r.kind===`directory`?e.onCreateDirectory?.(i):e.onCreateFile?.(i)}}:void 0,b=e.onRenameFile?{path:l,pending:p!==null&&e.fileOperation?.status===`pending`&&e.fileOperation.operation===`rename_file`&&e.fileOperation.path===p,localError:d,serverError:v,start:e=>{u(e),m(null),f(null)},cancel:()=>{u(null),m(null),f(null)},submit:(t,n)=>{if(n.trim()===``){u(null),m(null),f(null);return}let r=NM(n);if(`error`in r){f(r.error);return}f(null),m(t),e.onRenameFile?.(t,r.name)}}:void 0,x=!DM(``,e.writableRoot);return(0,i.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,i.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),(y&&x||e.onRefresh)&&(0,i.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[y&&x&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>y.start(``),"aria-label":`New file or folder in the workspace root`,className:`rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`+ new`}),e.onRefresh&&(0,i.jsx)(`button`,{type:`button`,onClick:e.onRefresh,title:`Refresh the file tree`,"aria-label":`Refresh the file tree`,className:`ml-auto rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`↻`})]}),(0,i.jsx)(AM,{path:``,depth:0,...e,...y?{creation:y}:{},...b?{rename:b}:{}})]})}function FM(e,t){return e===``?t:`${e}/${t}`}function IM({tree:e,openFile:t,writableRoot:r,gitFiles:a,attachedPaths:o,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:S}){let ee=bj(mj);return(0,n.useEffect)(()=>{e[``]===void 0&&s(``)},[]),(0,i.jsxs)(`aside`,{"aria-label":`Files`,style:{width:ee.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,i.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,i.jsx)(PM,{tree:e,openFilePath:t?.path,writableRoot:r,gitFiles:a,attachedPaths:o,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:S})}),(0,i.jsx)(xj,{label:`Resize Files sidebar`,width:ee.width,config:mj,separatorProps:ee.separatorProps})]})}function LM({title:e,onSubmit:t}){let[r,a]=(0,n.useState)(``);return(0,i.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,i.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&t(r.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,i.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,i.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,i.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>a(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,i.jsx)(`button`,{type:`submit`,disabled:!r.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,i.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,i.jsx)(`code`,{children:`?token=…`})]})]})})}var RM={todo:{icon:`○`,label:`To do`,className:`text-zinc-500`},in_progress:{icon:`●`,label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{icon:`✓`,label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{icon:`!`,label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{icon:`?`,label:`Needs review`,className:`text-amber-600 dark:text-amber-400`}},zM=8;function BM(e){let t=e.uri.startsWith(`workspace:`)?e.uri.slice(10):/^[a-z][a-z0-9+.-]*:/i.test(e.uri)?null:e.uri;return t===null||t===``||/^(?:[\\/]|[a-z]:[\\/])/i.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`)?null:t}function VM({plan:e,open:t,onToggle:r,onOpenWorkspace:a,requestedTaskId:o,onTaskRequestHandled:s}){let c=(0,n.useId)(),[l,u]=(0,n.useState)(!1),[d,f]=(0,n.useState)(null),[p,m]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&(e.tasks.some(e=>e.id===o)?(f(o),m(null)):(f(null),m(o)),s?.())},[e.tasks,o,s]),(0,n.useEffect)(()=>{d!==null&&!e.tasks.some(e=>e.id===d)&&f(null)},[e,d]),(0,n.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l]);let h=(0,n.useMemo)(()=>{let t=new Map;for(let n of e.tasks)t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t},[e.tasks]),g=(0,n.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),_=(0,n.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of h.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,zM)},[h]),v=d?g.get(d):void 0,y=e.tasks.filter(e=>e.status===`done`).length,b=(e,t=0)=>(h.get(e)??[]).flatMap(e=>{let n=RM[e.status];return[(0,i.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":d===e.id,onClick:()=>f(e.id),"aria-current":e.status===`in_progress`?`step`:void 0,className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 ${d===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,i.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,i.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...b(e.id,t+1)]});return t?(0,i.jsxs)(`aside`,{"aria-label":`Work Plan`,className:`absolute inset-y-0 right-0 z-10 flex w-full flex-col border-l border-zinc-200 bg-white/95 shadow-lg backdrop-blur md:w-[23rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,i.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,i.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,i.jsxs)(`div`,{className:`min-w-0`,children:[(0,i.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,i.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,i.jsx)(`button`,{type:`button`,onClick:r,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,"aria-label":`Close Work Plan`,children:`×`})]}),(0,i.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,y,` / `,e.tasks.length]}),(0,i.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,i.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:y/e.tasks.length*100}%`}})})]}),(0,i.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:b(void 0)}),p&&(0,i.jsx)(`div`,{role:`status`,className:`border-t border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300`,children:`That Outcome task no longer exists in the current Work Plan.`}),v&&(0,i.jsxs)(`section`,{"aria-label":`Task details`,className:`max-h-[45%] overflow-y-auto border-t border-zinc-200 p-3 text-xs dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`font-semibold ${RM[v.status].className}`,children:RM[v.status].label}),(0,i.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:v.title}),v.description&&(0,i.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:v.description}),v.statusReason&&(0,i.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:v.statusReason}),v.dependsOn.length>0&&(0,i.jsxs)(`div`,{className:`mt-3`,children:[(0,i.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,v.dependsOn.map(e=>g.get(e)?.title??e).join(`, `)]}),v.resources.length>0&&(0,i.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,i.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),v.resources.map(e=>{let t=BM(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,i.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`block truncate text-blue-600 hover:underline dark:text-blue-400`,children:n},e.uri):(0,i.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,i.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>a(t),children:n},e.uri)})]})]})]}):(0,i.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:()=>u(!1),children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>{u(!1),r()},className:`rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs shadow-sm dark:border-zinc-700 dark:bg-zinc-900`,"aria-label":`Open Work Plan`,"aria-describedby":c,children:[`Plan `,y,`/`,e.tasks.length]}),(0,i.jsx)(`div`,{id:c,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${l?`block`:`hidden`}`,children:(0,i.jsxs)(`div`,{className:`rounded-md border border-zinc-200 bg-white p-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsx)(`ul`,{className:`space-y-1`,children:_.map(({task:e,depth:t})=>(0,i.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,i.jsx)(`span`,{"aria-label":RM[e.status].label,className:`shrink-0 font-semibold ${RM[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,i.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`}`,children:e.title})]},e.id))}),e.tasks.length>_.length&&(0,i.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-_.length,` more`]})]})})]})}var HM=Object.defineProperty,UM=Object.getOwnPropertyDescriptor,WM=(e,t)=>{for(var n in t)HM(e,n,{get:t[n],enumerable:!0})},GM=(e,t,n,r)=>{for(var i=r>1?void 0:r?UM(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&HM(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),KM=`Terminal input`,qM={get:()=>KM,set:e=>KM=e},JM=`Too much output to announce, navigate to rows manually to read`,YM={get:()=>JM,set:e=>JM=e};function XM(e){return e.replace(/\r?\n/g,`\r`)}function ZM(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function QM(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function $M(e,t,n,r){e.stopPropagation(),e.clipboardData&&eN(e.clipboardData.getData(`text/plain`),t,n,r)}function eN(e,t,n,r){e=XM(e),e=ZM(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function tN(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function nN(e,t,n,r,i){tN(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function rN(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function iN(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var aN=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},oN=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},sN=``,cN=` `,lN=class e{constructor(){this.fg=0,this.bg=0,this.extended=new uN}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},uN=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dN=class e extends lN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new uN,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?rN(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fN=`di$target`,pN=`di$dependencies`,mN=new Map;function hN(e){return e[pN]||[]}function gN(e){if(mN.has(e))return mN.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);_N(t,e,r)};return t._id=e,mN.set(e,t),t}function _N(e,t,n){t[fN]===t?t[pN].push({id:e,index:n}):(t[pN]=[{id:e,index:n}],t[fN]=t)}var vN=gN(`BufferService`),yN=gN(`CoreMouseService`),bN=gN(`CoreService`),xN=gN(`CharsetService`),SN=gN(`InstantiationService`),CN=gN(`LogService`),wN=gN(`OptionsService`),TN=gN(`OscLinkService`),EN=gN(`UnicodeService`),DN=gN(`DecorationService`),ON=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new dN,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):kN(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ON=GM([Z(0,vN),Z(1,wN),Z(2,TN)],ON);function kN(e,t){if(confirm(`Do you want to navigate to ${t}?
317
+ `).map(e=>e.startsWith(`diff --git `)?{kind:`file`,text:e.slice(11)}:e.startsWith(`@@`)||e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`index `)?{kind:`hunk`,text:e}:e.startsWith(`+`)?{kind:`add`,text:e.slice(1)}:e.startsWith(`-`)?{kind:`del`,text:e.slice(1)}:{kind:`context`,text:e.startsWith(` `)?e.slice(1):e})}function dj({show:e,onClose:t}){return(0,n.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),t())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,i.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsx)(`span`,{className:`font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,12)}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`commit diff`}),(0,i.jsx)(`button`,{type:`button`,onClick:t,title:`Close (Esc)`,"aria-label":`Close commit diff`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),e.truncated&&(0,i.jsx)(`div`,{className:`border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:`Patch truncated — showing the first 256 KiB.`}),(0,i.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed`,children:uj(e.patch).map((e,t)=>(0,i.jsxs)(`div`,{className:e.kind===`file`?`mt-3 border-t border-zinc-200 pt-2 font-bold text-zinc-700 first:mt-0 first:border-t-0 first:pt-0 dark:border-zinc-800 dark:text-zinc-200`:e.kind===`hunk`?`text-sky-600 dark:text-sky-400`:e.kind===`add`?`bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300`:e.kind===`del`?`bg-red-50 text-red-700 dark:bg-red-950/40 dark:text-red-300`:`text-zinc-500 dark:text-zinc-500`,children:[e.kind===`add`?`+ `:e.kind===`del`?`− `:``,e.text||` `]},t))})]})}var fj=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`],pj=`worktree`,mj={defaultWidth:288,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.files-sidebar-width.v1`},hj={defaultWidth:416,minWidth:224,maxWidth:640,keyboardStep:16,storageKey:`pi-outpost.history-list-width.v1`};function gj(e,t){return Number.isFinite(e)?Math.min(t.maxWidth,Math.max(t.minWidth,Math.round(e))):t.defaultWidth}function _j(e,t){return e===null||e.trim()===``?t.defaultWidth:gj(Number(e),t)}function vj(e,t){try{return _j((t??window.localStorage).getItem(e.storageKey),e)}catch{return e.defaultWidth}}function yj(e,t,n){try{(n??window.localStorage).setItem(t.storageKey,String(gj(e,t)))}catch{}}function bj(e){let[t,r]=(0,n.useState)(()=>vj(e)),i=(0,n.useRef)(t),a=(0,n.useRef)(null),o=(0,n.useCallback)(t=>{let n=gj(t,e);return i.current=n,r(n),n},[e]),s=(0,n.useCallback)(()=>{a.current!==null&&(a.current=null,yj(i.current,e))},[e]);return{width:t,separatorProps:{onPointerDown:e=>{e.isPrimary!==!1&&(e.button??0)===0&&(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),a.current={pointerId:e.pointerId,startX:e.clientX,startWidth:i.current})},onPointerMove:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&o(t.startWidth+e.clientX-t.startX)},onPointerUp:e=>{a.current?.pointerId===e.pointerId&&s()},onPointerCancel:e=>{let t=a.current;t!==null&&t.pointerId===e.pointerId&&(a.current=null,o(t.startWidth))},onLostPointerCapture:s,onKeyDown:t=>{let n=null;t.key===`ArrowLeft`?n=i.current-e.keyboardStep:t.key===`ArrowRight`?n=i.current+e.keyboardStep:t.key===`Home`&&(n=e.defaultWidth),n!==null&&(t.preventDefault(),yj(o(n),e))}}}}function xj({label:e,width:t,config:n,separatorProps:r,className:a=``}){return(0,i.jsx)(`div`,{...r,role:`separator`,"aria-label":e,"aria-orientation":`vertical`,"aria-valuemin":n.minWidth,"aria-valuemax":n.maxWidth,"aria-valuenow":t,tabIndex:0,title:e,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize touch-none outline-none ${a}`,children:(0,i.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 left-1/2 w-px bg-transparent transition-colors group-hover:bg-blue-400 group-focus-visible:bg-blue-500 group-active:bg-blue-500 dark:group-hover:bg-blue-500`})})}var Sj=`#10b981`,Cj=[`#8b5cf6`,`#f59e0b`,`#0ea5e9`,`#f43f5e`,`#14b8a6`,`#d946ef`];function wj(e){return e===0?Sj:Cj[(e-1)%Cj.length]}function Tj(e){return Cj[e%Cj.length]}function Ej(e){return e*14+7+1}function Dj(e){return e*14+2}function Oj({row:e,laneCount:t,colorOf:n=wj}){let r=Dj(t),a=Ej(e.lane),o=e.highlight?Sj:n(e.lane),s=e.dashed?`3 3`:void 0;return(0,i.jsxs)(`svg`,{width:r,height:36,viewBox:`0 0 ${r} 36`,"aria-hidden":!0,className:`shrink-0`,children:[e.through.map(e=>(0,i.jsx)(`line`,{x1:Ej(e),y1:0,x2:Ej(e),y2:36,stroke:n(e),strokeWidth:2,opacity:.55},e)),e.lineAbove&&(0,i.jsx)(`line`,{x1:a,y1:0,x2:a,y2:18,stroke:o,strokeWidth:2,strokeDasharray:s}),e.lineBelow&&(0,i.jsx)(`line`,{x1:a,y1:18,x2:a,y2:36,stroke:o,strokeWidth:2,strokeDasharray:s}),e.forkTo.map(e=>(0,i.jsx)(`path`,{d:`M ${a} 18 C ${a} 36, ${Ej(e)} 18, ${Ej(e)} 36`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`fork-${e}`)),(e.mergeFrom??[]).map(e=>(0,i.jsx)(`path`,{d:`M ${a} 18 C ${a} 0, ${Ej(e)} 18, ${Ej(e)} 0`,fill:`none`,stroke:n(e),strokeWidth:2,opacity:.75},`merge-${e}`)),e.emphasis===`current`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`circle`,{cx:a,cy:18,r:6,fill:`none`,stroke:o,strokeWidth:2}),(0,i.jsx)(`circle`,{cx:a,cy:18,r:2.5,fill:o})]}):(0,i.jsx)(`circle`,{cx:a,cy:18,r:4,fill:e.emphasis===`filled`?o:`var(--tree-off, #d4d4d8)`,stroke:o,strokeWidth:e.emphasis===`filled`?0:1.5})]})}function kj(e,t={}){let n=[],r=[],i=0,a=()=>{let e=r.indexOf(null);return e===-1?(r.push(null),i=Math.max(i,r.length),r.length-1):e};for(let t of e){let e=r.reduce((e,n,r)=>n===t.sha?[...e,r]:e,[]),o=e[0]??a(),s=e.slice(1);for(let e of s)r[e]=null;i=Math.max(i,o+1);let[c,...l]=t.parents;r[o]=c??null;let u=l.map(e=>{let t=a();return r[t]=e,t});n.push({rev:t.sha,path:t.path,entry:t,lane:o,through:r.reduce((e,t,n)=>t!==null&&n!==o&&!u.includes(n)?[...e,n]:e,[]),forkTo:u,mergeFrom:s,lineAbove:!0,lineBelow:t.parents.length>0,emphasis:`filled`})}let o=n[0];return n.unshift({rev:pj,path:o?.path??``,lane:o?.lane??0,through:o?.through??[],forkTo:[],mergeFrom:[],lineAbove:!1,lineBelow:n.length>0,emphasis:`current`,dashed:!t.dirty}),n[1]&&(n[1].lineAbove=!0),{rows:n,laneCount:Math.max(i,1)}}var Aj=20;function jj(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function Mj(e){return e.rev===`worktree`?`working tree`:e.rev.slice(0,7)}function Nj(e,t){return e!==null&&t!==null&&e.rev===t.rev&&e.path===t.path}function Pj(e){return{rev:e.rev,path:e.path}}function Fj({history:e,diff:t,dirty:r,onFetchDiff:a,onClearDiff:o,onClose:s}){let[c,l]=(0,n.useState)({base:null,target:null}),{base:u,target:d}=c,[f,p]=(0,n.useState)(0),m=(0,n.useRef)([]),h=bj(hj),{rows:g,laneCount:_}=(0,n.useMemo)(()=>kj(e.entries,{dirty:r}),[e.entries,r]),v=(0,n.useRef)({onFetchDiff:a,onClose:s});v.current={onFetchDiff:a,onClose:s},(0,n.useEffect)(()=>{function e(e){e.key===`Escape`&&(e.stopImmediatePropagation(),v.current.onClose())}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,n.useEffect)(()=>{u===null||d===null||Nj(u,d)||v.current.onFetchDiff(u,d)},[u,d]);let y=(0,n.useCallback)((e,t)=>{let n=Pj(e);l(r=>{if(t===`base`)return{base:n,target:Nj(n,r.target)?r.base:r.target};if(t===`target`)return{base:Nj(n,r.base)?r.target:r.base,target:n};if(r.base===null&&r.target===null){let t=e.entry?.parents[0],r=t===void 0?void 0:g.find(e=>e.rev===t);return{base:r?Pj(r):null,target:n}}return{base:Nj(n,r.base)?r.target:r.base,target:n}})},[g]),b=(0,n.useCallback)(()=>{l({base:null,target:null}),o()},[o]),x=(0,n.useCallback)(()=>l(e=>({base:e.target,target:e.base})),[]),S=(0,n.useCallback)(e=>{p(t=>{let n=Math.max(0,Math.min(g.length-1,t+e));return m.current[n]?.focus(),n})},[g.length]),ee=e=>{let t=Pj(e);return Nj(t,u)?`base`:Nj(t,d)?`target`:null},te=g.findIndex(e=>Nj(Pj(e),u)),C=g.findIndex(e=>Nj(Pj(e),d)),ne=te>=0&&C>=0?{top:Math.min(te,C)*36+18,height:Math.abs(C-te)*36}:null;return(0,i.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col bg-white dark:bg-zinc-950`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-zinc-500 dark:text-zinc-400`,title:e.path,children:e.path}),u!==null&&d!==null&&(0,i.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-zinc-500 dark:text-zinc-400`,"aria-label":`Comparing ${Mj(u)} to ${Mj(d)}`,children:[(0,i.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:Mj(u)}),` → `,(0,i.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:Mj(d)})]}),u!==null&&d!==null&&(0,i.jsx)(`button`,{type:`button`,onClick:x,title:`Compare the other way round`,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`⇄ swap`}),(u!==null||d!==null)&&(0,i.jsx)(`button`,{type:`button`,onClick:b,className:`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-200`,children:`clear`}),(0,i.jsx)(`button`,{type:`button`,onClick:s,title:`Close (Esc)`,"aria-label":`Close file history`,className:`shrink-0 px-1 text-sm text-zinc-400 hover:text-zinc-600 dark:text-zinc-600 dark:hover:text-zinc-300`,children:`✕`})]}),(0,i.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,i.jsxs)(`div`,{role:`region`,"aria-label":`Commit history`,style:{"--history-list-width":`${h.width}px`},className:`relative flex max-h-[40%] w-full shrink-0 flex-col border-b border-zinc-200 md:max-h-none md:w-[var(--history-list-width)] md:border-b-0 md:border-r dark:border-zinc-800`,children:[(0,i.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),S(1)):e.key===`ArrowUp`&&(e.preventDefault(),S(-1))},children:[e.status===`loading`&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`Reading history…`}),e.status===`error`&&(0,i.jsx)(`div`,{className:`m-3 rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}),e.status===`loaded`&&e.entries.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`No commits touch this file yet.`}),e.status===`loaded`&&e.entries.length>0&&(0,i.jsxs)(`div`,{className:`relative`,role:`group`,"aria-label":`Commits`,children:[ne&&(0,i.jsx)(Ij,{top:ne.top,height:ne.height,baseFirst:te<C}),g.map((e,t)=>(0,i.jsx)(zj,{ref:e=>{m.current[t]=e},row:e,laneCount:_,role:ee(e),isFocused:t===f,onSelect:t=>y(e,t),onFocus:()=>p(t)},e.rev))]})]}),(0,i.jsx)(xj,{label:`Resize History commit list`,width:h.width,config:hj,separatorProps:h.separatorProps,className:`hidden md:block`})]}),(0,i.jsx)(`div`,{role:`region`,"aria-label":`History diff`,className:`min-h-0 min-w-0 flex-1 overflow-auto p-3`,children:(0,i.jsx)(Bj,{diff:t,base:u,target:d})})]})]})}function Ij({top:e,height:t,baseFirst:n}){return(0,i.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute left-0 z-10 motion-safe:transition-all motion-safe:duration-150 motion-safe:ease-out`,style:{top:e,height:t,width:Aj},children:[(0,i.jsx)(`div`,{className:`absolute inset-y-0 left-2 w-px bg-zinc-400 dark:bg-zinc-500`}),(0,i.jsx)(Lj,{label:n?`base`:`target`,className:`top-0`}),(0,i.jsx)(Lj,{label:n?`target`:`base`,className:`bottom-0`})]})}function Lj({label:e,className:t}){return(0,i.jsx)(`div`,{className:`absolute left-2 flex h-px w-2.5 items-center bg-zinc-400 dark:bg-zinc-500 ${t}`,children:(0,i.jsx)(`span`,{className:`absolute -left-1 -top-1.5 rotate-180 text-[9px] leading-none text-zinc-500 [writing-mode:vertical-rl] dark:text-zinc-400`,children:e})})}var Rj=`shrink-0 rounded px-1 py-0.5 text-[10px] text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 aria-disabled:cursor-default aria-disabled:opacity-30 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function zj({row:e,laneCount:t,role:n,isFocused:r,onSelect:a,onFocus:o,ref:s}){let c=e.entry,l=c?`${c.sha.slice(0,7)} ${c.subject}`:`Working tree`;return(0,i.jsxs)(`div`,{ref:s,role:`button`,tabIndex:r?0:-1,"aria-label":l,"aria-current":n===null?void 0:`true`,onFocus:o,onClick:()=>a(),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `?(e.preventDefault(),a()):e.key===`b`?a(`base`):e.key===`t`&&a(`target`))},style:{height:36,paddingLeft:Aj},className:`group flex cursor-pointer items-center gap-2 pr-2 focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${n===null?``:`bg-zinc-100 dark:bg-zinc-800/60`}`,children:[(0,i.jsx)(Oj,{row:e,laneCount:t}),c?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:c.sha.slice(0,7)}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-700 dark:text-zinc-300`,title:c.subject,children:c.subject}),(0,i.jsxs)(`span`,{className:`shrink-0 text-[10px] text-zinc-400 dark:text-zinc-600`,children:[c.author,` · `,jj(c.date)]}),(0,i.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums`,"aria-label":`${c.added} lines added, ${c.deleted} removed`,children:[(0,i.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,c.added]}),` `,(0,i.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`−`,c.deleted]})]})]}):(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-zinc-500 dark:text-zinc-400`,children:`working tree`}),(0,i.jsxs)(`span`,{className:`flex shrink-0 gap-0.5`,children:[(0,i.jsx)(`button`,{type:`button`,title:n===`target`?`Make this the base (swaps the two)`:`Compare from this version`,onClick:e=>{e.stopPropagation(),a(`base`)},className:Rj,children:`base`}),(0,i.jsx)(`button`,{type:`button`,title:n===`base`?`Make this the target (swaps the two)`:`Compare to this version`,onClick:e=>{e.stopPropagation(),a(`target`)},className:Rj,children:`target`})]})]})}function Bj({diff:e,base:t,target:n}){return t===null&&n===null?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Pick a commit to see what changed.`}):t===null||n===null?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Now pick the version to compare it against.`}):e?.status===`error`?(0,i.jsx)(`div`,{className:`rounded-lg border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:e.error}):e===null?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`Loading…`}):e.status===`loaded`&&e.beforeText===e.afterText?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions are identical.`}):e.status===`loaded`&&m(e.beforeText,e.afterText)?(0,i.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-600`,children:`These two versions differ only in their line endings.`}):(0,i.jsx)(`div`,{className:e.status===`loading`?`opacity-40`:void 0,children:(0,i.jsx)(pe,{fill:!0,lines:h(e.beforeText,e.afterText)})})}var Vj={stopped:`stopped`,starting:`starting…`,idle:`idle`,working:`working`,waiting:`waiting for you`,"ready-for-review":`ready for review`};function Hj({activity:e}){switch(e){case`stopped`:return(0,i.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full border border-dashed border-zinc-400 dark:border-zinc-600`});case`starting`:return(0,i.jsx)(`svg`,{className:`h-2.5 w-2.5 shrink-0 animate-spin text-zinc-500 dark:text-zinc-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`3.5`,strokeLinecap:`round`,children:(0,i.jsx)(`path`,{d:`M12 3a9 9 0 0 1 9 9`})});case`working`:return(0,i.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0 items-center justify-center`,children:[(0,i.jsx)(`span`,{className:`absolute h-2 w-2 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,i.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-700 dark:bg-blue-400`})]});case`waiting`:return(0,i.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-amber-500`});case`ready-for-review`:return(0,i.jsx)(`span`,{className:`h-2 w-2 shrink-0 rotate-45 rounded-[1px] border-2 border-violet-600 bg-violet-100 dark:border-violet-400 dark:bg-violet-950`});default:return(0,i.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-zinc-400 dark:bg-zinc-600`})}}function Uj({className:e}){return(0,i.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,i.jsx)(`path`,{d:`M12 6v7`}),(0,i.jsx)(`path`,{d:`M12 18h.01`})]})}function Wj({className:e}){return(0,i.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,i.jsx)(`path`,{d:`M7 3h10v18H7z`}),(0,i.jsx)(`path`,{d:`m9.5 12 1.7 1.7 3.5-3.7`})]})}function Gj(e){let{workspace:t,workspaces:r,locked:a}=e,[o,s]=(0,n.useState)(!1),c=(0,n.useRef)(null);if((0,n.useEffect)(()=>{if(!o)return;let e=e=>{TA(e,c.current)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),a||!t)return null;let l=r.filter(e=>e.root!==t.root),u=r.filter(e=>e.needsAttention);return(0,i.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,"aria-haspopup":`menu`,title:`Project: ${t.name} (${Vj[t.activity]})`,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${u.length>0?`border-amber-500 bg-amber-50 text-zinc-700 dark:bg-amber-950/40 dark:text-zinc-200`:`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`}`,children:[(0,i.jsx)(Hj,{activity:t.activity}),(0,i.jsx)(`span`,{className:`font-medium`,children:t.name}),u.length>0?(0,i.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-600 dark:text-amber-500`,children:[(0,i.jsx)(Uj,{className:`h-3 w-3`}),(0,i.jsx)(`span`,{className:`font-semibold`,children:u.length})]}):l.some(e=>e.activity===`working`)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`h-3 w-px bg-zinc-300 dark:bg-zinc-600`}),(0,i.jsx)(`span`,{className:`flex items-center gap-1`,children:l.map(e=>e.activity===`working`?(0,i.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 items-center justify-center`,children:[(0,i.jsx)(`span`,{className:`absolute h-1.5 w-1.5 animate-ping rounded-full bg-blue-700 opacity-60 dark:bg-blue-400`}),(0,i.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-blue-700 dark:bg-blue-400`})]},e.root):(0,i.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-zinc-300 dark:bg-zinc-600`},e.root))})]}),(0,i.jsx)(`svg`,{className:`h-3 w-3 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),o&&(0,i.jsxs)(`div`,{role:`menu`,className:`absolute left-0 top-full z-40 mt-1 w-87 rounded-md border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[r.map(n=>{let a=n.root===t.root;return(0,i.jsxs)(`div`,{className:`group flex items-center gap-2.5 rounded-md px-2.5 py-2 ${a?`bg-zinc-100 dark:bg-zinc-800`:`hover:bg-zinc-50 dark:hover:bg-zinc-800/50`}`,children:[(0,i.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(!1),a||e.onSwitch(n.root)},className:`flex min-w-0 flex-1 items-center gap-2.5 text-left`,children:[(0,i.jsx)(Hj,{activity:n.activity}),(0,i.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,i.jsx)(`span`,{className:`truncate text-[13px] ${a?`font-semibold text-zinc-900 dark:text-zinc-100`:`font-medium text-zinc-900 dark:text-zinc-100`}`,children:n.name}),(0,i.jsx)(`span`,{className:`truncate font-mono text-[11px] text-zinc-400 dark:text-zinc-500`,children:n.root})]})]}),(0,i.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[n.needsAttention?(0,i.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium ${n.activity===`ready-for-review`?`text-violet-700 dark:text-violet-400`:`text-amber-600 dark:text-amber-500`}`,children:[n.activity===`ready-for-review`?(0,i.jsx)(Wj,{className:`h-3 w-3`}):(0,i.jsx)(Uj,{className:`h-3 w-3`}),Vj[n.activity]]}):(0,i.jsx)(`span`,{className:`text-[11px] ${n.activity===`working`?`text-blue-700 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-500`}`,children:Vj[n.activity]}),r.length>1&&(0,i.jsx)(`button`,{type:`button`,title:`Close ${n.name}`,"aria-label":`Close ${n.name}`,onClick:t=>{t.stopPropagation(),e.onClose(n.root)},className:`flex h-5 w-5 items-center justify-center rounded border border-transparent text-zinc-400 opacity-0 group-hover:border-zinc-300 group-hover:opacity-100 hover:text-zinc-700 dark:group-hover:border-zinc-600 dark:hover:text-zinc-200`,children:(0,i.jsxs)(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,i.jsx)(`path`,{d:`M18 6 6 18`}),(0,i.jsx)(`path`,{d:`m6 6 12 12`})]})})]})]},n.root)}),(0,i.jsx)(`div`,{className:`my-1 h-px bg-zinc-200 dark:bg-zinc-700`}),(0,i.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(!1),e.onOpen()},className:`flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-[13px] text-zinc-700 hover:bg-zinc-50 dark:text-zinc-300 dark:hover:bg-zinc-800/50`,children:[(0,i.jsxs)(`svg`,{className:`h-3.5 w-3.5 text-zinc-500`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,i.jsx)(`path`,{d:`M12 5v14`}),(0,i.jsx)(`path`,{d:`M5 12h14`})]}),`Open a project…`]})]})]})}function Kj({label:e,browse:t,onBrowse:r,onSelect:a,onCancel:o}){let s=t?.path??`/`,c=t?.entries??[],l=t?.status===`loading`,[u,d]=(0,n.useState)(s);return(0,n.useEffect)(()=>{d(s)},[s]),(0,i.jsxs)(`div`,{className:`rounded-md border border-zinc-300 p-2 dark:border-zinc-700`,"data-testid":`server-path-picker`,children:[(0,i.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,i.jsx)(`span`,{className:`text-xs font-semibold text-zinc-600 dark:text-zinc-300`,children:e}),(0,i.jsx)(`button`,{type:`button`,onClick:o,className:`text-xs text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,children:`Cancel`})]}),(0,i.jsxs)(`form`,{className:`mb-2 flex gap-1`,onSubmit:e=>{e.preventDefault();let t=u.trim();t&&r(t)},children:[(0,i.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),d(s))},spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,"aria-label":`Current directory`,"data-testid":`picker-path`,className:`min-w-0 flex-1 rounded border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-700 focus:border-zinc-500 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),(0,i.jsx)(`button`,{type:`submit`,disabled:u.trim()===``||u===s,className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Go`})]}),t?.status===`error`&&(0,i.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:t.error}),(0,i.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,disabled:!t?.parent,onClick:()=>t?.parent&&r(t.parent),className:`rounded border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-zinc-700 dark:text-zinc-300`,children:`Up`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>a(s),className:`rounded bg-zinc-800 px-2 py-1 text-xs font-medium text-white hover:bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-900`,children:`Use this directory`})]}),(0,i.jsxs)(`ul`,{className:`max-h-40 overflow-y-auto`,children:[l&&c.length===0&&(0,i.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400`,children:`Loading…`}),!l&&c.length===0&&t?.status!==`error`&&(0,i.jsx)(`li`,{className:`px-2 py-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No subdirectories`}),c.map(e=>(0,i.jsx)(`li`,{children:(0,i.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),className:`w-full truncate rounded px-2 py-1 text-left font-mono text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,title:e.path,children:[e.name,e.name.endsWith(`:`)?`\\`:`/`]})},e.path))]})]})}function qj(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Jj(e){let{sandbox:t,applyState:r,blocked:a=!1,onCloseBrowser:o}=e,[s,c]=(0,n.useState)(!1),l=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{a&&s&&(l.current=!1,c(!1))},[a,s]),(0,n.useEffect)(()=>{if(l.current&&r?.status!==`applying`){if(r?.status===`error`){l.current=!1;return}l.current=!1,c(!1),o()}},[r,o]),!t)return(0,i.jsx)(`span`,{className:`rounded-md border border-dashed border-zinc-300 px-2 py-1 text-xs text-zinc-400 dark:border-zinc-700 dark:text-zinc-500`,title:`This server runs without a sandbox, so there is no root to move`,children:`No sandbox`});let u=t.locks?.root===!0,d=qj(t.root);return(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsxs)(`button`,{type:`button`,disabled:u,"aria-label":u?`Sandbox root: ${t.root} (locked)`:`Sandbox root: ${t.root}`,title:u?`${t.root} — locked by the server's configuration`:t.root,onClick:()=>{e.onOpened(),c(!0),e.onBrowse(t.root)},className:`flex max-w-[14rem] items-center gap-1.5 rounded-md border px-2 py-1 text-xs ${u?`cursor-not-allowed border-zinc-200 text-zinc-400 dark:border-zinc-800 dark:text-zinc-500`:`border-zinc-300 text-zinc-600 hover:border-zinc-400 hover:text-zinc-800 dark:border-zinc-700 dark:text-zinc-300 dark:hover:border-zinc-500 dark:hover:text-zinc-100`}`,children:[(0,i.jsx)(`span`,{className:`truncate font-mono`,children:d}),u?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):(0,i.jsx)(`span`,{"aria-hidden":`true`,children:`▾`})]}),s&&(0,i.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 w-[380px] rounded-lg border border-zinc-200 bg-white p-2 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[r?.status===`error`&&(0,i.jsx)(`p`,{role:`alert`,className:`mb-2 text-xs text-red-600 dark:text-red-400`,children:r.message}),(0,i.jsx)(Kj,{label:`Choose the sandbox root`,browse:e.browse,onBrowse:e.onBrowse,onSelect:t=>{l.current=!0,e.onSelect(t)},onCancel:()=>{l.current=!1,c(!1),o()}})]})]})}function Yj(e){let t=(Date.now()-new Date(e).getTime())/1e3;return t<90?`now`:t<3600?`${Math.round(t/60)}m ago`:t<86400?`${Math.round(t/3600)}h ago`:`${Math.round(t/86400)}d ago`}function Xj(e){return e.slice(e.lastIndexOf(`/`)+1)}function Zj({status:e,selected:t,log:r,onFetchLog:a,onShowCommit:o}){let[s,c]=(0,n.useState)(!1),l=EA(()=>c(!1)),u=e?.repos??[],d=(t===null?null:Xk(u,t))??(t===null&&u.length===1?u[0]:null),f=d&&(d.ahead>0||d.behind>0)?` ${d.ahead>0?`↑${d.ahead}`:``}${d.behind>0?`↓${d.behind}`:``}`:``,p=u.length>1&&d!==null&&d.repo!==``?`${Xj(d.repo)} `:``,m=e===null?`…`:d?.branch??`—`,h=d!==null&&r?.repo===d.repo?r.entries:null;return(0,n.useEffect)(()=>{s&&d!==null&&r?.repo!==d.repo&&a(d.repo)},[s,d?.repo,a]),(0,i.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,i.jsxs)(`button`,{type:`button`,disabled:d===null,onClick:()=>{d!==null&&(c(!s),s||a(d.repo))},title:d===null?`no repository selected`:`git history — ${d.repo===``?`this project`:d.repo}`,className:`rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-default disabled:hover:border-zinc-300 disabled:hover:text-zinc-500 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200 dark:disabled:hover:border-zinc-800 dark:disabled:hover:text-zinc-400`,children:[p,`⎇ `,m,f]}),s&&d!==null&&(0,i.jsxs)(`div`,{className:`absolute left-0 top-full z-20 mt-1 max-h-96 w-[26rem] max-w-[80vw] overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[h===null&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),h?.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no commits`}),h?.map(e=>(0,i.jsxs)(`button`,{type:`button`,onClick:()=>{o(d.repo,e.sha),c(!1)},className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800`,children:[(0,i.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-amber-600 dark:text-amber-500`,children:e.sha.slice(0,7)}),(0,i.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-zinc-700 dark:text-zinc-300`,title:e.subject,children:e.subject}),(0,i.jsxs)(`span`,{className:`shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:[e.author,` · `,Yj(e.date)]})]},e.sha))]})]})}function Qj(e){return[...e].sort((e,t)=>e.localeCompare(t))}function $j({extensionPaths:e,configuredExtensionPaths:t,userExtensionPaths:r,extensionLock:a,tools:o,commands:s,sandbox:c,gitUnavailable:l,userSkillPaths:u,serverBrowse:d,pickerBlocked:f=!1,onPickerOpened:p,applyState:m,versions:h,onBrowseServerPath:g,onCloseServerBrowser:_,onUpdateConfig:v}){let[y,b]=(0,n.useState)(!1),[x,S]=(0,n.useState)(``),[ee,te]=(0,n.useState)(``),[C,ne]=(0,n.useState)(!1),[re,ie]=(0,n.useState)(!1),[ae,w]=(0,n.useState)(u),[oe,se]=(0,n.useState)(r),[T,ce]=(0,n.useState)(null);(0,n.useEffect)(()=>{f&&T!==null&&ce(null)},[f,T]);let le=EA(()=>{(y||T!==null)&&ge()}),E=o.filter(e=>e.active),ue=o.filter(e=>!e.active),de=s.filter(e=>e.source===`skill`),fe=[...o].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),pe=m?.status===`applying`,me=m?.status===`error`?m.message:null;(0,n.useEffect)(()=>{c&&(S(c.root),te(c.writableRoot??``),ne(c.allowWrite),ie(c.allowBash))},[c]),(0,n.useEffect)(()=>{w(u)},[u]),(0,n.useEffect)(()=>{se(r)},[r]);let he=(0,n.useRef)(!1);(0,n.useEffect)(()=>{he.current&&m===null&&ge(),he.current=pe},[m,pe]);function ge(){b(!1),ce(null),_()}function _e(e,t){p?.(),ce(e),g(t.trim()||`/`)}function ve(e){T===`root`?S(e):T===`writableRoot`?te(e):T===`skill`&&!ae.includes(e)?w([...ae,e]):T===`extension`&&!oe.includes(e)&&se([...oe,e]),ce(null),_()}function ye(){let e=c?{root:x,allowWrite:C,allowBash:re,writableRoot:ee.trim()||void 0}:void 0;v({...e?{sandbox:e}:{},userSkillPaths:ae,...a?{}:{userExtensionPaths:oe}})}let be=T!==null&&(0,i.jsx)(Kj,{label:T===`skill`?`Choose a skills directory`:T===`extension`?`Choose an extensions directory`:T===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:d,onBrowse:g,onSelect:ve,onCancel:()=>{ce(null),_()}});return(0,i.jsxs)(`div`,{className:`relative`,ref:le,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>b(!y),title:`Settings`,"aria-label":`Settings`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`⚙`}),y&&(0,i.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[80vh] w-[380px] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsx)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:(0,i.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Settings`})}),(0,i.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:[l&&(0,i.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),l.reason===`no-repository`?(0,i.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,i.jsxs)(`div`,{className:`rounded border border-amber-300 bg-amber-50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/40`,children:[(0,i.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:l.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,i.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:l.message}),l.reason===`no-executable`&&(0,i.jsxs)(`p`,{className:`mt-1 text-xs text-amber-700 dark:text-amber-400`,children:[`Install git, add it to PATH, or name it with `,(0,i.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),(0,i.jsxs)(`section`,{className:`mb-4`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),o.length===0?(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,i.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[E.length,` tools active`,ue.length?` · ${ue.length} inactive`:``]}),(0,i.jsx)(`ul`,{className:`mt-2 space-y-1`,children:fe.map(e=>(0,i.jsxs)(`li`,{className:`flex justify-between rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:[(0,i.jsx)(`span`,{children:e.name}),(0,i.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),de.length===0?(0,i.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,i.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[de.length,` skills loaded`]}),(0,i.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Qj(de.map(e=>e.name)).map(e=>(0,i.jsx)(`li`,{className:`rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,children:e},e))})]}),(0,i.jsxs)(`div`,{className:`mt-3`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,i.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User skill paths`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>_e(`skill`,ae[ae.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add skills directory…`})]}),ae.length===0?(0,i.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skill directories added`}):(0,i.jsx)(`ul`,{className:`mt-1 space-y-1`,children:Qj(ae).map(e=>(0,i.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,i.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>w(ae.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),T===`skill`&&(0,i.jsx)(`div`,{className:`mt-2`,children:be})]})]}),(0,i.jsxs)(`section`,{className:`mb-4`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),e===null?(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):e.length===0?(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,i.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[e.length,` `,e.length===1?`extension`:`extensions`,` loaded`]}),(0,i.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Qj(e).map(e=>(0,i.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),t.length>0&&(0,i.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,i.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[t.length,` configured by this deployment`]}),(0,i.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`Declared in the configuration file. They load either way, and nothing here can remove them.`}),(0,i.jsx)(`ul`,{className:`mt-1 space-y-1`,children:Qj(t).map(e=>(0,i.jsx)(`li`,{className:`truncate rounded bg-zinc-50 px-2 py-1 font-mono text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`,title:e,children:e},e))})]}),a?(0,i.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths are locked by this deployment.`}):(0,i.jsxs)(`div`,{className:`mt-3`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,i.jsx)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:`User extension paths`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>_e(`extension`,oe[oe.length-1]??`/`),className:`rounded border border-zinc-300 px-2 py-0.5 text-xs text-zinc-600 hover:border-zinc-400 dark:border-zinc-700 dark:text-zinc-300`,children:`Add extensions directory…`})]}),T===`extension`&&(0,i.jsx)(`p`,{className:`mt-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`extension-warning`,role:`note`,children:`Extensions are code, and they run with the agent's privileges. Every extension in the directory you choose is loaded.`}),oe.length===0?(0,i.jsx)(`p`,{className:`mt-1 text-xs text-zinc-400 dark:text-zinc-500`,children:`No extension directories added`}):(0,i.jsx)(`ul`,{className:`mt-1 space-y-1`,children:Qj(oe).map(e=>(0,i.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded bg-zinc-50 px-2 py-1 dark:bg-zinc-800`,children:[(0,i.jsx)(`span`,{className:`truncate font-mono text-xs text-zinc-600 dark:text-zinc-400`,title:e,children:e}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>se(oe.filter(t=>t!==e)),className:`shrink-0 text-xs text-zinc-500 hover:text-red-600 dark:text-zinc-400 dark:hover:text-red-400`,children:`Remove`})]},e))}),T===`extension`&&(0,i.jsx)(`div`,{className:`mt-2`,children:be})]})]}),c&&(0,i.jsxs)(`section`,{children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Sandbox`}),(0,i.jsxs)(`div`,{className:`space-y-3`,children:[(0,i.jsxs)(`label`,{className:`block`,children:[(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,c.locks?.root?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,i.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,i.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),disabled:c.locks?.root,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:focus:border-zinc-500`}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:c.locks?.root,onClick:()=>_e(`root`,x),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),T===`root`&&be,(0,i.jsxs)(`label`,{className:`block`,children:[(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,c.locks?.writableRoot?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,i.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,i.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),disabled:c.locks?.writableRoot,placeholder:`Same as root`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,i.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:c.locks?.writableRoot,onClick:()=>_e(`writableRoot`,ee||x),className:`shrink-0 rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-600 hover:border-zinc-400 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300`,children:`Browse…`})]})]}),T===`writableRoot`&&be,(0,i.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>ne(e.target.checked),disabled:c.locks?.allowWrite,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,c.locks?.allowWrite?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,i.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:re,onChange:e=>ie(e.target.checked),disabled:c.locks?.allowBash,className:`rounded border-zinc-300 text-zinc-700 focus:ring-zinc-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}),(0,i.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,c.locks?.allowBash?(0,i.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!c&&(0,i.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,i.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[me&&(0,i.jsx)(`p`,{role:`alert`,className:`rounded-md border border-red-300 bg-red-50 px-2 py-1 text-xs text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300`,children:me}),(0,i.jsx)(`button`,{type:`button`,disabled:pe||c!==null&&!x.trim(),onClick:ye,className:`w-full rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-zinc-200 dark:text-zinc-900 dark:hover:bg-zinc-300`,children:pe?`Applying…`:`Apply & restart session`}),(0,i.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`})]}),h&&(0,i.jsxs)(`section`,{className:`mt-4`,children:[(0,i.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,i.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,i.jsxs)(`p`,{children:[`pi-outpost: `,(0,i.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:h.piOutpost})]}),h.piSdk&&(0,i.jsxs)(`p`,{children:[`pi SDK: `,(0,i.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:h.piSdk})]}),h.agent&&(0,i.jsxs)(`p`,{children:[`agent: `,(0,i.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:h.agent})]})]})]})]})]})]})}function eM(e){let t=[],n=new Set,r=0,i=0;function a(e,o,s,c){let l=e.children,u=l.slice(1).map(e=>[e,r++]);u.length>0&&i++;let d=e.onPath&&!l.some(e=>e.onPath);if(t.push({node:e,lane:o,through:[...n].filter(e=>e!==o),forkTo:u.map(([,e])=>e),lineAbove:s,lineBelow:l.length>0,branchIndex:c,isCurrent:d,emphasis:d?`current`:e.onPath?`filled`:`hollow`,highlight:e.onPath}),l.length===0){n.delete(o);return}for(let[,e]of u)n.add(e);a(l[0],o,!0,u.length>0?1:void 0),u.forEach(([e,t],n)=>a(e,t,!0,n+2))}return e.length>1&&i++,e.forEach((t,i)=>{let o=r++;n.add(o),a(t,o,!1,e.length>1?i+1:void 0)}),{rows:t,laneCount:r,branchPoints:i}}function tM(e){return e.flatMap(e=>[e,...tM(e.children)])}function nM({children:e,tone:t}){let n={current:`border-emerald-300 bg-emerald-50 text-emerald-700 dark:border-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-300`,branch:`border-zinc-300 text-zinc-500 dark:border-zinc-700 dark:text-zinc-400`,label:`border-violet-300 bg-violet-50 text-violet-700 dark:border-violet-900 dark:bg-violet-950/50 dark:text-violet-300`}[t];return(0,i.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var rM=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-500 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`;function iM({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:a,onClose:o}){let{node:s}=e,c=s.tipId??s.entryId;return(0,i.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70 ${e.isCurrent?`bg-emerald-50/60 dark:bg-emerald-950/20`:``}`,style:{height:36},children:[(0,i.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),o()},title:n?`unavailable while the agent is running`:s.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex h-full min-w-0 flex-1 items-center gap-2 pl-2 text-left text-sm disabled:opacity-50`,children:[(0,i.jsx)(Oj,{row:e,laneCount:t,colorOf:Tj}),(0,i.jsx)(`span`,{className:`min-w-0 truncate ${s.onPath?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-400`}`,children:s.text||`(empty)`}),e.forkTo.length>0&&(0,i.jsxs)(nM,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,i.jsxs)(nM,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,i.jsx)(nM,{tone:`current`,children:`current`}),s.label&&(0,i.jsx)(nM,{tone:`label`,children:s.label})]}),(0,i.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),o()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:rM,children:`↺ redo`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{a(s.entryId),o()},title:`fork a new session from this point`,className:rM,children:`⑂ fork`})]})}function aM({tree:e,isStreaming:t,onListTree:r,onNavigate:a,onFork:o}){let[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)(``),d=EA(()=>c(!1));(0,n.useEffect)(()=>{s&&e===null&&r()},[s,e]);let f=(0,n.useMemo)(()=>e&&e.length>0?eM(e):null,[e]),p=(0,n.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return tM(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,i.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),r())},title:`conversation tree: go back to an earlier point or fork`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`tree`}),s&&(0,i.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-[70vh] w-[32rem] max-w-[90vw] flex-col rounded-lg border border-zinc-200 bg-white shadow-xl [--tree-off:#e4e4e7] dark:border-zinc-700 dark:bg-zinc-900 dark:[--tree-off:#3f3f46]`,children:[e===null&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,i.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,i.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:[f.rows.length,` turn`,f.rows.length===1?``:`s`,` · `,f.branchPoints,` branch point`,f.branchPoints===1?``:`s`]})]}),(0,i.jsx)(`input`,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:`Search tree`,"aria-label":`Search conversation tree`,className:`mt-2 w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,i.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Follow the colored lines — the current branch is highlighted. Click a turn to restore the conversation there · ↺ to send it again · ⑂ to fork a session`})]}),(0,i.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,i.jsx)(iM,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:a,onFork:o,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,i.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,i.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{a(e.tipId??e.entryId),c(!1)},title:e.tipId?`restore the conversation at this point (reply included)`:`go back to this point`,className:`flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-sm disabled:opacity-50`,children:[(0,i.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,i.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,i.jsx)(nM,{tone:`current`,children:`on current branch`}),e.label&&(0,i.jsx)(nM,{tone:`label`,children:e.label})]}),(0,i.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{a(e.entryId),c(!1)},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:rM,children:`↺ redo`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{o(e.entryId),c(!1)},title:`fork a new session from this point`,className:rM,children:`⑂ fork`})]},e.entryId))})]})]})]})}var oM=200;function sM({initial:e,onCommit:t,onCancel:r}){let[a,o]=(0,n.useState)(e);return(0,i.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`?t(a):e.key===`Escape`&&r()},placeholder:`Session name (empty to clear)`,"aria-label":`Session name`,className:`w-full rounded-md border border-zinc-400 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 dark:border-zinc-600 dark:placeholder:text-zinc-600`})}function cM({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:a,onStartRename:o,onRename:s,onCancelRename:c}){return n?(0,i.jsx)(`div`,{className:`px-3 py-2`,children:(0,i.jsx)(sM,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,i.jsxs)(`div`,{className:`group flex items-start gap-1 hover:bg-zinc-100 dark:hover:bg-zinc-800 ${t?`bg-zinc-100 dark:bg-zinc-800/60`:``}`,children:[(0,i.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,i.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,i.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,i.jsxs)(`div`,{className:`mt-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:[new Date(e.modified).toLocaleString(),` · `,e.messageCount,` messages`,t?` · current`:``]})]}),(0,i.jsx)(`button`,{type:`button`,onClick:o,title:`rename session`,"aria-label":`Rename session`,className:`mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-zinc-200 hover:text-zinc-700 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✎`}),!t&&(0,i.jsx)(`button`,{type:`button`,onClick:a,title:`delete session`,"aria-label":`Delete session`,className:`mr-2 mt-2 rounded px-1.5 py-0.5 text-xs text-zinc-400 opacity-0 hover:bg-red-100 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:text-zinc-600 dark:hover:bg-red-950/60 dark:hover:text-red-400`,children:`✕`})]})}function lM({sessions:e,sessionSearch:t,sessionId:r,onSwitchSession:a,onDeleteSession:o,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,n.useState)(!1),[p,m]=(0,n.useState)(``),[h,g]=(0,n.useState)(null),_=EA(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,n.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),oM);return()=>clearTimeout(e)},[d,v,y]);function b(){f(!1),g(null)}let x=y&&(t?.status!==`loaded`||t.query!==v),S=y?x?null:t?.results??null:e;return(0,i.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,i.jsx)(`button`,{type:`button`,onClick:()=>{if(d){b();return}f(!0),m(``),g(null),u(),s()},className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:`sessions`}),d&&(0,i.jsxs)(`div`,{className:`absolute right-0 top-full z-20 mt-1 flex max-h-96 w-96 flex-col rounded-lg border border-zinc-200 bg-white shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,i.jsx)(`input`,{type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Search sessions`,"aria-label":`Search sessions`,className:`w-full rounded-md border border-zinc-300 bg-transparent px-2 py-1 text-sm outline-none placeholder:text-zinc-400 focus:border-zinc-500 dark:border-zinc-700 dark:placeholder:text-zinc-600 dark:focus:border-zinc-500`}),(0,i.jsx)(`p`,{className:`mt-1.5 text-[11px] text-zinc-400 dark:text-zinc-500`,children:`Searches names and everything said in a session · ✎ to rename`})]}),(0,i.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[S===null&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),S?.length===0&&(0,i.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),S?.map(e=>(0,i.jsx)(cM,{session:e,isCurrent:e.id===r,renaming:h===e.path,onSwitch:()=>{a(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&o(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function uM({theme:e,onToggle:t}){return(0,i.jsx)(`button`,{type:`button`,onClick:t,title:e===`dark`?`Switch to light theme`:`Switch to dark theme`,"aria-label":e===`dark`?`Switch to light theme`:`Switch to dark theme`,className:`rounded-md border border-zinc-300 px-2 py-1 text-xs text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e===`dark`?`☀`:`☾`})}function dM(e){let{isStreaming:t,connected:n}=e;return(0,i.jsxs)(`header`,{className:`relative z-30 flex items-center gap-3 border-b border-zinc-200 px-4 py-2.5 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,i.jsx)(Gj,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject}),e.workspaceControl===`root`&&e.rootControl&&(0,i.jsx)(Jj,{sandbox:e.rootControl.sandbox,browse:e.rootControl.browse,applyState:e.rootControl.applyState,blocked:e.rootControl.blocked,onBrowse:e.rootControl.onBrowse,onCloseBrowser:e.rootControl.onCloseBrowser,onOpened:e.rootControl.onOpened,onSelect:e.rootControl.onSelect}),(0,i.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`rounded-md border px-2 py-1 text-xs ${e.sidebarOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:[e.sidebarOpen?`◧`:`◨`,` files`]}),(0,i.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`rounded-md border px-2 py-1 text-xs ${e.outcomeOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:e.workspace?.activity===`ready-for-review`?`border-amber-400 text-amber-700 dark:text-amber-300`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400`}`,children:[`Outcome`,e.workspace?.activity===`ready-for-review`?` •`:``]}),e.gitAvailable&&(0,i.jsx)(Zj,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,i.jsx)(`span`,{className:`text-lg font-semibold tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),Object.entries(e.statuses).map(([e,t])=>(0,i.jsx)(`span`,{className:`rounded-md border border-zinc-200 px-2 py-1 text-xs text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:ZA(t)},e)),(0,i.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:e.onToggleHideTools,title:e.hideTools?`Show tool cards in the conversation`:`Hide tool cards (long sessions read better without them)`,"aria-pressed":e.hideTools,className:`rounded-md border px-2 py-1 text-xs ${e.hideTools?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`⚒ tools`}),e.onToggleTerminal&&(0,i.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`rounded-md border px-2 py-1 text-xs ${e.terminalOpen?`border-zinc-400 bg-zinc-100 text-zinc-700 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-200`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`}`,children:`>_ terminal`}),e.showThemeToggle&&(0,i.jsx)(uM,{theme:e.theme,onToggle:e.onToggleTheme}),(0,i.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`rounded-md border border-emerald-300 px-2 py-1 text-xs text-emerald-700 hover:border-emerald-500 hover:text-emerald-600 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600 dark:hover:text-emerald-300`,children:`+ new`}),(0,i.jsx)(aM,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,i.jsx)(lM,{sessions:e.sessions,sessionSearch:e.sessionSearch,sessionId:e.sessionId,onSwitchSession:e.onSwitchSession,onDeleteSession:e.onDeleteSession,onListSessions:e.onListSessions,onRenameSession:e.onRenameSession,onSearchSessions:e.onSearchSessions,onClearSessionSearch:e.onClearSessionSearch}),(0,i.jsx)($j,{extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onUpdateConfig:e.onUpdateConfig}),(0,i.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function fM(e,t){let r=(0,n.useRef)(new Map);(0,n.useEffect)(()=>{if(typeof Notification>`u`)return;let n=e.filter(e=>e.needsAttention),i=n.filter(e=>e.root!==t);for(let e of[...r.current.keys()])n.some(t=>t.root===e)||r.current.delete(e);if(Notification.permission===`granted`&&!(typeof document<`u`&&document.visibilityState===`visible`)){for(let e of i)if(r.current.get(e.root)!==e.activity){r.current.set(e.root,e.activity);try{let t=e.activity===`ready-for-review`;new Notification(t?`${e.name} is ready for review`:`${e.name} needs you`,{body:t?`Background work is ready for review.`:`The agent needs an answer to continue.`,tag:`pi-outpost:${e.root}`})}catch{}}}},[e,t])}function pM(e){return!e||e.percent===null?`text-zinc-400 dark:text-zinc-600`:e.percent>=85?`text-red-500`:e.percent>=60?`text-amber-500 dark:text-amber-400`:`text-emerald-500`}function mM({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,a=[`${e.turns} turn${e.turns===1?``:`s`}`,`input ${e.input.toLocaleString()}`,`output ${e.output.toLocaleString()}`,`cache read ${e.cacheRead.toLocaleString()}`,`cache write ${e.cacheWrite.toLocaleString()}`,...e.unpriced>0&&r>0?[`${e.unpriced} unpriced`]:[]].join(` · `),o=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(`span`,{children:[Sk(e.totalTokens),` tok`]}),r>0&&(0,i.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[xk(e.cost),e.unpriced>0&&`*`]})]}),s=`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs text-zinc-500 dark:text-zinc-400`;return n?(0,i.jsx)(`button`,{type:`button`,onClick:n,title:`${a} — click for the session analysis`,"aria-haspopup":`dialog`,"aria-expanded":t??!1,className:`${s} ${t?`border-zinc-400 dark:border-zinc-600`:`border-zinc-300 hover:border-zinc-400 dark:border-zinc-800 dark:hover:border-zinc-600`}`,children:o}):(0,i.jsx)(`span`,{title:a,className:`${s} border-zinc-300 dark:border-zinc-800`,children:o})}function hM({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,a=Math.min(100,Math.max(0,r))/100*n;return(0,i.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,i.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,className:`text-zinc-200 dark:text-zinc-800`}),e&&e.percent!==null&&(0,i.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${a} ${n-a}`,className:pM(e)})]})}function gM({thinkingLevel:e,thinkingLevels:t,isStreaming:r,onSetThinking:a}){let[o,s]=(0,n.useState)(!1),c=(0,n.useRef)(null),l=e!==`off`,u=t&&t.length>0?t:fj,d=u.indexOf(e),f=u.length>1;return(0,n.useEffect)(()=>{if(!o)return;function e(e){c.current&&!TA(e,c.current)&&s(!1)}function t(e){e.key===`Escape`&&s(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,i.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),disabled:r,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":o,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${l?`border-amber-300 text-amber-700 hover:border-amber-400 dark:border-amber-900 dark:text-amber-400 dark:hover:border-amber-700`:`border-zinc-300 text-zinc-500 hover:border-zinc-400 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`}`,children:[(0,i.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${l?``:`opacity-40 grayscale`}`,children:`🧠`}),e]}),o&&(0,i.jsxs)(`div`,{className:`absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,i.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,i.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:e})]}),f?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`input`,{type:`range`,min:0,max:u.length-1,step:1,value:d===-1?0:d,onChange:e=>a(u[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":e,className:`w-full accent-amber-500`}),(0,i.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,i.jsx)(`span`,{children:u[0]}),(0,i.jsx)(`span`,{children:u[u.length-1]})]})]}):(0,i.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:[`this model accepts `,(0,i.jsx)(`span`,{className:`font-mono`,children:u[0]}),` only`]})]})]})}function _M(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:a,isStreaming:o,contextUsage:s,sessionUsage:c,isCompacting:l}=e;return(0,i.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,i.jsxs)(`select`,{value:t,onChange:t=>{let r=n.find(e=>`${e.provider}/${e.id}`===t.target.value);r&&e.onSetModel(r.provider,r.id)},disabled:o,className:`max-w-64 rounded-md border border-zinc-300 bg-white px-2 py-1 font-mono text-xs text-zinc-700 outline-none hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-300 dark:hover:border-zinc-600`,children:[!n.some(e=>`${e.provider}/${e.id}`===t)&&(0,i.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,i.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),a&&(0,i.jsx)(gM,{thinkingLevel:r,thinkingLevels:e.thinkingLevels,isStreaming:o,onSetThinking:e.onSetThinking}),(0,i.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:o||l,title:s?.tokens==null?`Click to compact the conversation context`:`${s.tokens.toLocaleString()} / ${s.contextWindow.toLocaleString()} tokens — click to compact`,className:`ml-auto flex items-center gap-1.5 rounded-md border border-zinc-300 px-2 py-1 font-mono text-xs text-zinc-500 hover:border-zinc-400 disabled:opacity-50 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600`,children:[(0,i.jsx)(hM,{usage:s}),l?`compacting…`:s?.percent==null?`context`:`${Math.round(s.percent)}%`]}),(0,i.jsx)(mM,{usage:c,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var vM=`w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-sm text-zinc-800 placeholder:text-zinc-400 focus:border-zinc-400 focus:outline-none dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600`,yM=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function bM({title:e,credentials:t,onSetCredential:r,onDeclareProvider:a,errors:o}){let s=t.providers,[c,l]=(0,n.useState)(s.length>0?`known`:`custom`),[u,d]=(0,n.useState)(s[0]?.id??``),[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)(``),[g,_]=(0,n.useState)(``),[v,y]=(0,n.useState)(``),[b,x]=(0,n.useState)(!0),[S,ee]=(0,n.useState)(!0),te=s.some(e=>e.configured)&&!t.usableModel;function C(e){if(e.preventDefault(),!te){if(c===`known`){u&&f.trim()&&r(u,f.trim());return}!m.trim()||!g.trim()||!f.trim()||!v.trim()||a({provider:m.trim(),baseUrl:g.trim(),apiKey:f.trim(),models:[v.trim()],compat:{supportsDeveloperRole:b,supportsReasoningEffort:S}})}}return(0,i.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,i.jsxs)(`form`,{onSubmit:C,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),te?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,i.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,i.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model provider is set up yet. Add one to start chatting.`}),(0,i.jsx)(`div`,{className:`mb-4 flex gap-1 rounded-lg bg-zinc-100 p-1 text-xs dark:bg-zinc-800`,children:[`known`,`custom`].map(e=>(0,i.jsx)(`button`,{type:`button`,onClick:()=>l(e),className:`flex-1 rounded-md px-2 py-1.5 ${c===e?`bg-white font-medium text-zinc-800 shadow-sm dark:bg-zinc-900 dark:text-zinc-100`:`text-zinc-500 dark:text-zinc-400`}`,children:e===`known`?`Provider API key`:`OpenAI-compatible endpoint`},e))}),c===`known`?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`label`,{htmlFor:`onboarding-provider`,className:yM,children:`Provider`}),(0,i.jsx)(`select`,{id:`onboarding-provider`,value:u,onChange:e=>d(e.target.value),className:`${vM} mb-3`,children:s.map(e=>(0,i.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`label`,{htmlFor:`onboarding-name`,className:yM,children:`Name`}),(0,i.jsx)(`input`,{id:`onboarding-name`,value:m,onChange:e=>h(e.target.value),placeholder:`corp`,className:`${vM} mb-3`}),(0,i.jsx)(`label`,{htmlFor:`onboarding-url`,className:yM,children:`Base URL`}),(0,i.jsx)(`input`,{id:`onboarding-url`,value:g,onChange:e=>_(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${vM} mb-3`}),(0,i.jsx)(`label`,{htmlFor:`onboarding-model`,className:yM,children:`Model id`}),(0,i.jsx)(`input`,{id:`onboarding-model`,value:v,onChange:e=>y(e.target.value),placeholder:`gpt-oss-120b`,className:`${vM} mb-3`})]}),(0,i.jsx)(`label`,{htmlFor:`onboarding-key`,className:yM,children:`API key`}),(0,i.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:f,onChange:e=>p(e.target.value),placeholder:`sk-…`,className:vM}),c===`custom`&&(0,i.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,i.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,i.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`mt-0.5`}),(0,i.jsxs)(`span`,{children:[`Server understands the `,(0,i.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,i.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,i.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,i.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>ee(e.target.checked),className:`mt-0.5`}),(0,i.jsxs)(`span`,{children:[`Server accepts `,(0,i.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,i.jsx)(`button`,{type:`submit`,className:`mt-4 w-full rounded-md bg-zinc-800 px-3 py-2 text-sm font-medium text-white hover:bg-zinc-700 dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-white`,children:`Save and start`})]}),o.map((e,t)=>(0,i.jsx)(`p`,{className:`mt-3 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300`,children:e},t)),(0,i.jsxs)(`p`,{className:`mt-4 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[t.agentDir?`Stored in ${t.agentDir}. `:``,`Provider environment variables work too, as does `,(0,i.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var xM=`application/x-pi-outpost-file`,SM=`application/x-pi-outpost-read-only-file`,CM=`mr-1 shrink-0 rounded px-1 text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,wM={modified:{label:`M`,className:`text-amber-600 dark:text-amber-400`},added:{label:`A`,className:`text-emerald-600 dark:text-emerald-400`},untracked:{label:`U`,className:`text-emerald-600 dark:text-emerald-400`},deleted:{label:`D`,className:`text-red-600 dark:text-red-400`},conflicted:{label:`C`,className:`text-purple-600 dark:text-purple-400`}};function TM(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function EM(e){return e===`directory`||e===`symlink-directory`}function DM(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function OM({dir:e,depth:t,creation:r}){let[a,o]=(0,n.useState)(``),s=(0,n.useRef)(null),c=r.localError??r.serverError;return(0,n.useEffect)(()=>{s.current?.focus()},[]),(0,i.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,i.jsx)(`input`,{ref:s,value:a,onChange:e=>o(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),r.submit(e,a)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{c===null&&r.cancel()},placeholder:`name, or name/ for a folder`,"aria-label":`New file or folder in ${e===``?`the workspace root`:e}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),c!==null&&(0,i.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:c})]})}function kM({path:e,name:t,depth:r,rename:a}){let[o,s]=(0,n.useState)(t),c=(0,n.useRef)(null),l=a.localError??a.serverError;return(0,n.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]),(0,i.jsxs)(`div`,{style:{paddingLeft:r*12+16},className:`py-0.5`,children:[(0,i.jsx)(`input`,{ref:c,value:o,disabled:a.pending,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!a.pending?(t.preventDefault(),a.submit(e,o)):t.key===`Escape`&&(t.preventDefault(),a.cancel())},onBlur:()=>{l===null&&a.cancel()},"aria-label":`Rename ${t}`,spellCheck:!1,className:`w-full rounded border border-zinc-300 bg-white px-1 py-0.5 text-xs text-zinc-800 outline-none focus:border-zinc-400 dark:border-zinc-700 dark:bg-zinc-900 dark:text-zinc-200`}),l!==null&&(0,i.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:l})]})}function AM({path:e,depth:t,...n}){let r=n.tree[e],a=n.creation?.openIn===e?(0,i.jsx)(OM,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?a:r===`loading`?(0,i.jsxs)(i.Fragment,{children:[a,(0,i.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`loading…`})]}):`error`in r?(0,i.jsxs)(i.Fragment,{children:[a,(0,i.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-red-600 dark:text-red-400`,children:r.error})]}):r.length===0?(0,i.jsxs)(i.Fragment,{children:[a,a===null&&(0,i.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,i.jsxs)(i.Fragment,{children:[a,r.map(r=>(0,i.jsx)(jM,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function jM({parentPath:e,entry:t,depth:r,...a}){let[o,s]=(0,n.useState)(!1),[c,l]=(0,n.useState)(!1),u=e?`${e}/${t.name}`:t.name,d=DM(u,a.writableRoot),f=a.fileOperation?.status===`pending`;if(EM(t.type)){let e=!d&&!f,n=e=>e.includes(SM)?a.onCopyFile===void 0?null:`copy`:a.onMoveFile===void 0?null:`move`;return(0,i.jsxs)(`div`,{children:[(0,i.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${c?`bg-blue-50 ring-1 ring-blue-400 dark:bg-blue-950/40`:``}`,onDragOver:t=>{if(!e||!Array.from(t.dataTransfer.types).includes(xM))return;let r=n(Array.from(t.dataTransfer.types));r!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=r,l(!0))},onDragLeave:()=>l(!1),onDrop:t=>{if(!e)return;let r=t.dataTransfer.getData(xM),i=r?n(Array.from(t.dataTransfer.types)):null;i!==null&&(t.preventDefault(),t.stopPropagation(),l(!1),i===`copy`?a.onCopyFile?.(r,u):a.onMoveFile?.(r,u))},children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!o;s(e),e&&a.tree[u]===void 0&&a.onExpand(u),a.onSelectDirectory?.(u)},style:{paddingLeft:r*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,i.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:o?`▾`:`▸`}),(0,i.jsx)(`span`,{title:t.name,className:`truncate ${d?`text-zinc-400 dark:text-zinc-600`:`text-zinc-700 dark:text-zinc-300`}`,children:t.name}),!o&&TM(u,a.gitFiles)>0&&(0,i.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-amber-100 px-1 font-mono text-[10px] font-bold text-amber-700 dark:bg-amber-950/60 dark:text-amber-400`,title:`${TM(u,a.gitFiles)} changed file(s) inside`,children:TM(u,a.gitFiles)})]}),a.creation&&!d&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>{s(!0),a.tree[u]===void 0&&a.onExpand(u),a.creation?.start(u)},title:`New file or folder here`,"aria-label":`New file or folder in ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs text-zinc-400 hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:text-zinc-600 dark:hover:bg-zinc-700 [@media(hover:hover)]:opacity-0`,children:`+`})]}),o&&(0,i.jsx)(AM,{path:u,depth:r+1,...a})]})}let p=u===a.openFilePath,m=a.gitFiles?.[u],h=a.attachedPaths?.includes(u)??!1,g=t.type===`file`,_=g||t.type===`symlink-file`,v=g&&!d,y=g&&(d?a.onCopyFile!==void 0:a.onMoveFile!==void 0);return a.rename?.path===u?(0,i.jsx)(kM,{path:u,name:t.name,depth:r,rename:a.rename}):(0,i.jsxs)(`div`,{className:`group flex w-full items-center rounded hover:bg-zinc-100 dark:hover:bg-zinc-800 ${p?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,i.jsx)(`button`,{type:`button`,draggable:y&&!f,onDragStart:e=>{!y||f||(e.dataTransfer.effectAllowed=d?`copy`:`move`,e.dataTransfer.setData(xM,u),d&&e.dataTransfer.setData(SM,`copy`))},onClick:()=>a.onSelectFile(u),style:{paddingLeft:r*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,i.jsx)(`span`,{title:t.name,className:`truncate ${d?`text-zinc-400 dark:text-zinc-600`:`text-zinc-600 dark:text-zinc-400`}`,children:t.name})}),_&&a.onOpenNative&&(0,i.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>a.onOpenNative?.(u),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:CM,children:`↗`}),v&&a.onRenameFile&&(0,i.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>a.rename?.start(u),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:CM,children:`✎`}),v&&a.onDeleteFile&&(0,i.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&a.onDeleteFile?.(u)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${CM} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),a.onToggleAttachPath&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>a.onToggleAttachPath?.(u),title:h?`Remove this file from the prompt`:`Reference this file in the prompt`,"aria-label":`${h?`Remove`:`Reference`} ${t.name} in the prompt`,"aria-pressed":h,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs hover:bg-zinc-200 group-hover:opacity-100 focus-visible:opacity-100 dark:hover:bg-zinc-700 ${h?`font-bold text-blue-600 dark:text-blue-400`:`text-zinc-400 dark:text-zinc-600 [@media(hover:hover)]:opacity-0`}`,children:`@`}),m&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>(a.onSelectDiff??a.onSelectFile)(u),title:`Show uncommitted diff`,"aria-label":`Show diff of ${t.name}`,className:`mr-1 shrink-0 rounded px-1 font-mono text-xs font-bold hover:bg-zinc-200 dark:hover:bg-zinc-700 ${wM[m].className}`,children:wM[m].label})]})}function MM(e){let t=e.trim();if(t===``)return{error:`A name is required`};let n=t.endsWith(`/`),r=n?t.slice(0,-1).trim():t;return r===``?{error:`A name is required`}:r.includes(`/`)||r.includes(`\\`)?{error:`That is a path, not a name`}:r===`.`||r===`..`?{error:`"${r}" is not a name`}:{kind:n?`directory`:`file`,name:r}}function NM(e){let t=MM(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function PM(e){let[t,r]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[s,c]=(0,n.useState)(null),[l,u]=(0,n.useState)(null),[d,f]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),h=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,g=e.createError&&s&&e.createError.path===FM(s.dir,s.name)?e.createError.message:null,_=e.created??null;(0,n.useEffect)(()=>{s!==null&&_!==null&&_===FM(s.dir,s.name)&&(r(null),c(null),o(null))},[s,_]);let v=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&p===e.fileOperation.path?e.fileOperation.message:null;(0,n.useEffect)(()=>{let t=e.fileOperation;t?.status===`succeeded`&&t.operation===`rename_file`&&p===t.path&&(u(null),m(null),f(null))},[p,e.fileOperation]);let y=h?{openIn:t,localError:a,serverError:g,start:e=>{r(e),o(null),c(null)},cancel:()=>{r(null),o(null),c(null)},submit:(t,n)=>{let r=MM(n);if(`error`in r){o(r.error);return}o(null),c({dir:t,name:r.name});let i=FM(t,r.name);r.kind===`directory`?e.onCreateDirectory?.(i):e.onCreateFile?.(i)}}:void 0,b=e.onRenameFile?{path:l,pending:p!==null&&e.fileOperation?.status===`pending`&&e.fileOperation.operation===`rename_file`&&e.fileOperation.path===p,localError:d,serverError:v,start:e=>{u(e),m(null),f(null)},cancel:()=>{u(null),m(null),f(null)},submit:(t,n)=>{if(n.trim()===``){u(null),m(null),f(null);return}let r=NM(n);if(`error`in r){f(r.error);return}f(null),m(t),e.onRenameFile?.(t,r.name)}}:void 0,x=!DM(``,e.writableRoot);return(0,i.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,i.jsx)(`p`,{role:`alert`,className:`mb-1 rounded bg-red-50 px-2 py-1 text-xs text-red-700 dark:bg-red-950/40 dark:text-red-300`,children:e.fileOperation.message}),(y&&x||e.onRefresh)&&(0,i.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[y&&x&&(0,i.jsx)(`button`,{type:`button`,onClick:()=>y.start(``),"aria-label":`New file or folder in the workspace root`,className:`rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`+ new`}),e.onRefresh&&(0,i.jsx)(`button`,{type:`button`,onClick:e.onRefresh,title:`Refresh the file tree`,"aria-label":`Refresh the file tree`,className:`ml-auto rounded px-1 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-400`,children:`↻`})]}),(0,i.jsx)(AM,{path:``,depth:0,...e,...y?{creation:y}:{},...b?{rename:b}:{}})]})}function FM(e,t){return e===``?t:`${e}/${t}`}function IM({tree:e,openFile:t,writableRoot:r,gitFiles:a,attachedPaths:o,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:S}){let ee=bj(mj);return(0,n.useEffect)(()=>{e[``]===void 0&&s(``)},[]),(0,i.jsxs)(`aside`,{"aria-label":`Files`,style:{width:ee.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`border-b border-zinc-200 px-3 py-2 text-xs font-semibold uppercase text-zinc-400 dark:border-zinc-800 dark:text-zinc-600`,children:`Files`}),(0,i.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,i.jsx)(PM,{tree:e,openFilePath:t?.path,writableRoot:r,gitFiles:a,attachedPaths:o,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRenameFile:g,onDeleteFile:_,onMoveFile:v,onCopyFile:y,fileOperation:b,createError:x,created:S})}),(0,i.jsx)(xj,{label:`Resize Files sidebar`,width:ee.width,config:mj,separatorProps:ee.separatorProps})]})}function LM({title:e,onSubmit:t}){let[r,a]=(0,n.useState)(``);return(0,i.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,i.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&t(r.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,i.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,i.jsx)(`label`,{htmlFor:`pi-outpost-token`,className:`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Access token`}),(0,i.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>a(e.target.value),placeholder:`paste the token…`,className:`mb-3 w-full rounded-md border border-zinc-300 bg-white px-2 py-1.5 font-mono text-sm outline-none focus:border-zinc-500 dark:border-zinc-700 dark:bg-zinc-950 dark:focus:border-zinc-500`}),(0,i.jsx)(`button`,{type:`submit`,disabled:!r.trim(),className:`w-full rounded-md border border-emerald-300 px-2 py-1.5 text-sm text-emerald-700 hover:border-emerald-500 disabled:opacity-50 dark:border-emerald-900 dark:text-emerald-400 dark:hover:border-emerald-600`,children:`Connect`}),(0,i.jsxs)(`p`,{className:`mt-3 text-center text-xs text-zinc-400 dark:text-zinc-600`,children:[`Ask the operator for the token, or open the link containing `,(0,i.jsx)(`code`,{children:`?token=…`})]})]})})}var RM={todo:{icon:`○`,label:`To do`,className:`text-zinc-500`},in_progress:{icon:`●`,label:`In progress`,className:`text-blue-600 dark:text-blue-400`},done:{icon:`✓`,label:`Done`,className:`text-emerald-600 dark:text-emerald-400`},blocked:{icon:`!`,label:`Blocked`,className:`text-red-600 dark:text-red-400`},needs_review:{icon:`?`,label:`Needs review`,className:`text-amber-600 dark:text-amber-400`}},zM=8;function BM(e){let t=e.uri.startsWith(`workspace:`)?e.uri.slice(10):/^[a-z][a-z0-9+.-]*:/i.test(e.uri)?null:e.uri;return t===null||t===``||/^(?:[\\/]|[a-z]:[\\/])/i.test(t)||t.replaceAll(`\\`,`/`).split(`/`).includes(`..`)?null:t}function VM({plan:e,open:t,onToggle:r,onOpenWorkspace:a,requestedTaskId:o,onTaskRequestHandled:s}){let c=(0,n.useId)(),[l,u]=(0,n.useState)(!1),[d,f]=(0,n.useState)(null),[p,m]=(0,n.useState)(null);(0,n.useEffect)(()=>{o&&(e.tasks.some(e=>e.id===o)?(f(o),m(null)):(f(null),m(o)),s?.())},[e.tasks,o,s]),(0,n.useEffect)(()=>{d!==null&&!e.tasks.some(e=>e.id===d)&&f(null)},[e,d]),(0,n.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l]);let h=(0,n.useMemo)(()=>{let t=new Map;for(let n of e.tasks)t.set(n.parentId,[...t.get(n.parentId)??[],n]);return t},[e.tasks]),g=(0,n.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),_=(0,n.useMemo)(()=>{let e=[],t=(n,r)=>{for(let i of h.get(n)??[])e.push({task:i,depth:r}),t(i.id,r+1)};return t(void 0,0),e.slice(0,zM)},[h]),v=d?g.get(d):void 0,y=e.tasks.filter(e=>e.status===`done`).length,b=(e,t=0)=>(h.get(e)??[]).flatMap(e=>{let n=RM[e.status];return[(0,i.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":d===e.id,onClick:()=>f(e.id),"aria-current":e.status===`in_progress`?`step`:void 0,className:`flex w-full items-start gap-2 rounded px-2 py-1.5 text-left text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800 ${d===e.id?`bg-zinc-100 dark:bg-zinc-800`:``}`,style:{paddingLeft:`${.5+t*.85}rem`},children:[(0,i.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,i.jsx)(`span`,{className:e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`,children:e.title})]},e.id),...b(e.id,t+1)]});return t?(0,i.jsxs)(`aside`,{"aria-label":`Work Plan`,className:`absolute inset-y-0 right-0 z-10 flex w-full flex-col border-l border-zinc-200 bg-white/95 shadow-lg backdrop-blur md:w-[23rem] dark:border-zinc-800 dark:bg-zinc-950/95`,children:[(0,i.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,i.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,i.jsxs)(`div`,{className:`min-w-0`,children:[(0,i.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,i.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,i.jsx)(`button`,{type:`button`,onClick:r,className:`rounded px-2 py-1 text-xs text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800`,"aria-label":`Close Work Plan`,children:`×`})]}),(0,i.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,y,` / `,e.tasks.length]}),(0,i.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,i.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:y/e.tasks.length*100}%`}})})]}),(0,i.jsx)(`div`,{role:`tree`,"aria-label":`Work Plan tasks`,className:`min-h-0 flex-1 overflow-y-auto p-2`,children:b(void 0)}),p&&(0,i.jsx)(`div`,{role:`status`,className:`border-t border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-300`,children:`That Outcome task no longer exists in the current Work Plan.`}),v&&(0,i.jsxs)(`section`,{"aria-label":`Task details`,className:`max-h-[45%] overflow-y-auto border-t border-zinc-200 p-3 text-xs dark:border-zinc-800`,children:[(0,i.jsx)(`div`,{className:`font-semibold ${RM[v.status].className}`,children:RM[v.status].label}),(0,i.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:v.title}),v.description&&(0,i.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:v.description}),v.statusReason&&(0,i.jsx)(`p`,{className:`mt-2 rounded bg-zinc-100 p-2 text-zinc-700 dark:bg-zinc-900 dark:text-zinc-300`,children:v.statusReason}),v.dependsOn.length>0&&(0,i.jsxs)(`div`,{className:`mt-3`,children:[(0,i.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,v.dependsOn.map(e=>g.get(e)?.title??e).join(`, `)]}),v.resources.length>0&&(0,i.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,i.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),v.resources.map(e=>{let t=BM(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,i.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`block truncate text-blue-600 hover:underline dark:text-blue-400`,children:n},e.uri):(0,i.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,i.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>a(t),children:n},e.uri)})]})]})]}):(0,i.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:()=>u(!1),children:[(0,i.jsxs)(`button`,{type:`button`,onClick:()=>{u(!1),r()},className:`rounded-md border border-zinc-300 bg-white px-2 py-1 text-xs shadow-sm dark:border-zinc-700 dark:bg-zinc-900`,"aria-label":`Open Work Plan`,"aria-describedby":c,children:[`Plan `,y,`/`,e.tasks.length]}),(0,i.jsx)(`div`,{id:c,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${l?`block`:`hidden`}`,children:(0,i.jsxs)(`div`,{className:`rounded-md border border-zinc-200 bg-white p-2 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,i.jsx)(`ul`,{className:`space-y-1`,children:_.map(({task:e,depth:t})=>(0,i.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,i.jsx)(`span`,{"aria-label":RM[e.status].label,className:`shrink-0 font-semibold ${RM[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,i.jsx)(`span`,{className:`truncate ${e.status===`done`?`text-zinc-500 line-through`:`text-zinc-800 dark:text-zinc-200`}`,children:e.title})]},e.id))}),e.tasks.length>_.length&&(0,i.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-_.length,` more`]})]})})]})}var HM=Object.defineProperty,UM=Object.getOwnPropertyDescriptor,WM=(e,t)=>{for(var n in t)HM(e,n,{get:t[n],enumerable:!0})},GM=(e,t,n,r)=>{for(var i=r>1?void 0:r?UM(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&HM(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),KM=`Terminal input`,qM={get:()=>KM,set:e=>KM=e},JM=`Too much output to announce, navigate to rows manually to read`,YM={get:()=>JM,set:e=>JM=e};function XM(e){return e.replace(/\r?\n/g,`\r`)}function ZM(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function QM(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function $M(e,t,n,r){e.stopPropagation(),e.clipboardData&&eN(e.clipboardData.getData(`text/plain`),t,n,r)}function eN(e,t,n,r){e=XM(e),e=ZM(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function tN(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function nN(e,t,n,r,i){tN(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function rN(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function iN(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var aN=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},oN=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},sN=``,cN=` `,lN=class e{constructor(){this.fg=0,this.bg=0,this.extended=new uN}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},uN=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dN=class e extends lN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new uN,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?rN(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fN=`di$target`,pN=`di$dependencies`,mN=new Map;function hN(e){return e[pN]||[]}function gN(e){if(mN.has(e))return mN.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);_N(t,e,r)};return t._id=e,mN.set(e,t),t}function _N(e,t,n){t[fN]===t?t[pN].push({id:e,index:n}):(t[pN]=[{id:e,index:n}],t[fN]=t)}var vN=gN(`BufferService`),yN=gN(`CoreMouseService`),bN=gN(`CoreService`),xN=gN(`CharsetService`),SN=gN(`InstantiationService`),CN=gN(`LogService`),wN=gN(`OptionsService`),TN=gN(`OscLinkService`),EN=gN(`UnicodeService`),DN=gN(`DecorationService`),ON=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new dN,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):kN(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ON=GM([Z(0,vN),Z(1,wN),Z(2,TN)],ON);function kN(e,t){if(confirm(`Do you want to navigate to ${t}?
318
318
 
319
319
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var AN=gN(`CharSizeService`),jN=gN(`CoreBrowserService`),MN=gN(`MouseService`),NN=gN(`RenderService`),PN=gN(`SelectionService`),FN=gN(`CharacterJoinerService`),IN=gN(`ThemeService`),LN=gN(`LinkProviderService`),RN=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?WN.isErrorNoTelemetry(e)?new WN(e.message+`
320
320
 
@@ -47287,7 +47287,7 @@ function BM({ usage: e }) {
47287
47287
  });
47288
47288
  }
47289
47289
  function VM({ thinkingLevel: e, thinkingLevels: t, isStreaming: n, onSetThinking: r }) {
47290
- let [i, a] = C(!1), o = S(null), s = e !== "off", c = t && t.length > 0 ? t : Lj, l = Math.max(0, c.indexOf(e));
47290
+ let [i, a] = C(!1), o = S(null), s = e !== "off", c = t && t.length > 0 ? t : Lj, l = c.indexOf(e), u = c.length > 1;
47291
47291
  return v(() => {
47292
47292
  if (!i) return;
47293
47293
  function e(e) {
@@ -47317,33 +47317,39 @@ function VM({ thinkingLevel: e, thinkingLevels: t, isStreaming: n, onSetThinking
47317
47317
  }), e]
47318
47318
  }), i && /* @__PURE__ */ E("div", {
47319
47319
  className: "absolute bottom-full left-0 z-20 mb-1 w-48 rounded-lg border border-zinc-200 bg-white p-3 shadow-xl dark:border-zinc-700 dark:bg-zinc-900",
47320
- children: [
47321
- /* @__PURE__ */ E("div", {
47322
- className: "mb-1 flex items-baseline justify-between text-xs",
47323
- children: [/* @__PURE__ */ T("span", {
47324
- className: "text-zinc-500 dark:text-zinc-400",
47325
- children: "thinking"
47326
- }), /* @__PURE__ */ T("span", {
47327
- className: "font-mono text-zinc-700 dark:text-zinc-200",
47328
- children: e
47329
- })]
47330
- }),
47331
- /* @__PURE__ */ T("input", {
47332
- type: "range",
47333
- min: 0,
47334
- max: c.length - 1,
47335
- step: 1,
47336
- value: l,
47337
- onChange: (e) => r(c[Number(e.target.value)]),
47338
- "aria-label": "Thinking level",
47339
- "aria-valuetext": e,
47340
- className: "w-full accent-amber-500"
47341
- }),
47342
- /* @__PURE__ */ E("div", {
47343
- className: "mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600",
47344
- children: [/* @__PURE__ */ T("span", { children: c[0] }), /* @__PURE__ */ T("span", { children: c[c.length - 1] })]
47345
- })
47346
- ]
47320
+ children: [/* @__PURE__ */ E("div", {
47321
+ className: "mb-1 flex items-baseline justify-between text-xs",
47322
+ children: [/* @__PURE__ */ T("span", {
47323
+ className: "text-zinc-500 dark:text-zinc-400",
47324
+ children: "thinking"
47325
+ }), /* @__PURE__ */ T("span", {
47326
+ className: "font-mono text-zinc-700 dark:text-zinc-200",
47327
+ children: e
47328
+ })]
47329
+ }), u ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("input", {
47330
+ type: "range",
47331
+ min: 0,
47332
+ max: c.length - 1,
47333
+ step: 1,
47334
+ value: l === -1 ? 0 : l,
47335
+ onChange: (e) => r(c[Number(e.target.value)]),
47336
+ "aria-label": "Thinking level",
47337
+ "aria-valuetext": e,
47338
+ className: "w-full accent-amber-500"
47339
+ }), /* @__PURE__ */ E("div", {
47340
+ className: "mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600",
47341
+ children: [/* @__PURE__ */ T("span", { children: c[0] }), /* @__PURE__ */ T("span", { children: c[c.length - 1] })]
47342
+ })] }) : /* @__PURE__ */ E("p", {
47343
+ className: "text-[11px] text-zinc-500 dark:text-zinc-400",
47344
+ children: [
47345
+ "this model accepts ",
47346
+ /* @__PURE__ */ T("span", {
47347
+ className: "font-mono",
47348
+ children: c[0]
47349
+ }),
47350
+ " only"
47351
+ ]
47352
+ })]
47347
47353
  })]
47348
47354
  });
47349
47355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-outpost/embed",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "type": "module",
5
5
  "description": "Mount pi-outpost as a Shadow-DOM-isolated widget inside another web app.",
6
6
  "license": "MIT",