@pi-outpost/embed 0.48.0 → 0.49.0
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.
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=requi
|
|
|
11
11
|
`:``}${e}`};for(let e of t)e.kind===`path`?Lt(n,e.data)||r(`@${e.data}`):e.kind===`text`&&r(`\`\`\`${e.name}\n${e.data}\n\`\`\``);return n}function Bt(e){return{name:e,kind:`path`,data:e,mimeType:`text/plain`,source:`manual`}}function Vt(e,t){return e.some(e=>e.kind===`path`&&e.data===t)?e:[...e,Bt(t)]}function Ht(e,t){return e.filter((e,n)=>n!==t)}function Ut(e,t){if(!t)return!1;let n=e.composedPath();if(n.length>0)return n.includes(t);let r=e.target;return r!==null&&t.contains(r)}function Wt(e){let t=(0,i.useRef)(null);return(0,i.useEffect)(()=>{function n(n){t.current&&!Ut(n,t.current)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}var Gt=100,Kt=new Intl.Collator(void 0,{sensitivity:`base`,numeric:!0}),qt={extension:`ext`,prompt:`prompt`,skill:`skill`};function Jt(e){return e===`directory`||e===`symlink-directory`}function Yt(e,t){let n=e.slice(0,t),r=/(?:^|\s)@([^\s@]*)$/.exec(n);return r?{start:t-r[1].length-1,query:r[1]}:null}function Xt({isStreaming:e,connected:t,commands:n,fileSearch:r,prefill:a,attachments:s,pendingUploads:c=[],onAttach:l,onMentionPaths:u,onRemoveAttachment:d,onSend:f,onAbort:p,onSearchFiles:m,onClearFileSearch:h,initialDraft:g,onDraftChange:_}){let[v,y]=(0,i.useState)(g??``);(0,i.useEffect)(()=>{_?.(v)},[v,_]);let[b,x]=(0,i.useState)(0),[S,C]=(0,i.useState)(0),[w,ee]=(0,i.useState)(!1),T=(0,i.useRef)(null),E=(0,i.useRef)(null),te=(0,i.useRef)(null),D=(0,i.useRef)(null),O=(0,i.useRef)(null);(0,i.useEffect)(()=>{a&&y(a.text)},[a?.nonce]),(0,i.useEffect)(()=>{O.current!==null&&(te.current?.focus(),te.current?.setSelectionRange(O.current,O.current),O.current=null)},[v]),(0,i.useLayoutEffect)(()=>{let e=te.current;if(!e)return;let t=-1,n=()=>{t=e.offsetWidth,e.style.overflowY=`hidden`,e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`,e.scrollHeight>e.clientHeight&&(e.style.overflowY=`auto`)};n();let r=typeof ResizeObserver>`u`?void 0:new ResizeObserver(()=>{e.offsetWidth!==t&&n()});return r?.observe(e,{box:`border-box`}),()=>r?.disconnect()},[v]);let k=(0,i.useMemo)(()=>Rt(v),[v]);(0,i.useEffect)(()=>{u(k)},[k.join(`
|
|
12
12
|
`)]);let A=(0,i.useMemo)(()=>{let e=/^\/(\S*)$/.exec(v);return e?e[1].toLowerCase():null},[v]),j=(0,i.useMemo)(()=>A===null?[]:n.filter(e=>e.name.toLowerCase().includes(A)).sort((e,t)=>{let n=e.name.toLowerCase().startsWith(A);return n===t.name.toLowerCase().startsWith(A)?Kt.compare(e.name,t.name):n?-1:1}).slice(0,Gt),[A,n]),M=A===null?Yt(v,b):null;(0,i.useEffect)(()=>{if(!M||M.query.length===0){h();return}let e=window.setTimeout(()=>m(M.query),150);return()=>clearTimeout(e)},[M?.query]);let N=(0,i.useMemo)(()=>{if(j.length>0)return{kind:`command`,items:j};let e=M&&r?.query===M.query?r.results:[];return e.length>0?{kind:`file`,items:e}:null},[j,M,r]),P=N!==null&&!w,ne=A===null?M?`file:${M.query}`:null:`cmd:${A}`;(0,i.useEffect)(()=>{C(0)},[ne]),(0,i.useEffect)(()=>{ee(!1)},[A===null?M?`file`:null:`command`]),(0,i.useEffect)(()=>{if(!P)return;let e=e=>{Ut(e,T.current)||ee(!0)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[P]),(0,i.useEffect)(()=>{E.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView({block:`nearest`})},[S]);let F=c.length>0,[I,L]=(0,i.useState)(!1);(0,i.useEffect)(()=>{F||L(!1)},[F]);function R(){if(F){L(!0);return}let e=zt(v,s),t=s.filter(e=>e.kind===`image`).map(e=>({data:e.data,mimeType:e.mimeType})),n=s.every(e=>e.kind===`path`);(v.trim()||!n&&e||t.length!==0)&&(f(e,t.length>0?t:void 0),y(``),h())}function z(e){let t=`/${e.name} `;y(t),O.current=t.length,x(t.length)}function B(e){if(!M)return;let t=v.slice(0,M.start),n=v.slice(b),r=`@${e.path}${Jt(e.type)?`/`:` `}`,i=`${t}${r}${n}`;y(i),h();let a=t.length+r.length;O.current=a,x(a)}function V(){if(N){if(N.kind===`command`){let e=N.items[S];e&&z(e)}else{let e=N.items[S];e&&B(e)}}}function H(e){if(P&&N){if(e.key===`ArrowDown`){e.preventDefault(),C(e=>(e+1)%N.items.length);return}if(e.key===`ArrowUp`){e.preventDefault(),C(e=>(e-1+N.items.length)%N.items.length);return}if(e.key===`Tab`||e.key===`Enter`){e.preventDefault(),V();return}if(e.key===`Escape`){e.preventDefault(),ee(!0);return}}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),R())}function re(e){x(e.currentTarget.selectionStart??0)}function U(e){let t=Array.from(e.clipboardData.files);t.length>0&&(e.preventDefault(),l(t))}return(0,o.jsxs)(`div`,{ref:T,className:`relative`,children:[(s.length>0||F)&&(0,o.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[c.map(e=>(0,o.jsxs)(`span`,{"data-pending-upload":e.name,title:`${e.name} — copying into the workspace`,className:`flex items-center gap-1.5 rounded-md border border-dashed border-zinc-300 bg-zinc-50 py-1 pl-1.5 pr-2 text-xs text-zinc-500 dark:border-zinc-600 dark:bg-zinc-800/40 dark:text-zinc-400`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`animate-pulse`,children:`⏳`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`sr-only`,children:`uploading`})]},e.id)),I&&(0,o.jsx)(`span`,{role:`status`,className:`flex items-center py-1 text-xs text-amber-600 dark:text-amber-400`,children:`waiting for the attachment to finish uploading…`}),s.map((e,t)=>(0,o.jsxs)(`span`,{title:e.kind===`path`?`${e.name} — sent as a reference; the agent reads the file itself`:e.name,className:`flex items-center gap-1.5 rounded-md border border-zinc-200 bg-zinc-50 py-1 pl-1.5 pr-1 text-xs text-zinc-600 dark:border-zinc-700 dark:bg-zinc-800/60 dark:text-zinc-300`,children:[e.kind===`image`?(0,o.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:e.name,className:`h-8 w-8 rounded object-cover`}):(0,o.jsx)(`span`,{"aria-hidden":!0,className:e.kind===`path`?`font-mono font-bold text-blue-600 dark:text-blue-400`:``,children:e.kind===`path`?`@`:`📄`}),(0,o.jsx)(`span`,{className:`max-w-40 truncate`,children:e.name}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>d(t),title:`remove attachment`,className:`rounded px-1 text-zinc-400 hover:bg-zinc-200 hover:text-zinc-700 dark:hover:bg-zinc-700 dark:hover:text-zinc-200`,children:`✕`})]},`${e.name}:${t}`))]}),P&&N&&(0,o.jsx)(`div`,{ref:E,className:`absolute bottom-full left-0 z-20 mb-2 max-h-72 w-full max-w-xl overflow-y-auto rounded-lg border border-zinc-200 bg-white py-1 shadow-xl dark:border-zinc-700 dark:bg-zinc-900`,children:N.kind===`command`?N.items.map((e,t)=>(0,o.jsxs)(`button`,{type:`button`,"data-selected":t===S,onMouseEnter:()=>C(t),onClick:()=>z(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===S?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:[(0,o.jsxs)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:[`/`,e.name]}),e.argumentHint&&(0,o.jsx)(`span`,{className:`font-mono text-xs text-zinc-500`,children:e.argumentHint}),e.description&&(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-zinc-500`,children:e.description}),(0,o.jsx)(`span`,{className:`ml-auto shrink-0 rounded bg-zinc-200 px-1 text-[10px] uppercase text-zinc-500 dark:bg-zinc-800`,children:qt[e.source]})]},e.name)):N.items.map((e,t)=>(0,o.jsx)(`button`,{type:`button`,"data-selected":t===S,onMouseEnter:()=>C(t),onClick:()=>B(e),className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm ${t===S?`bg-zinc-100 dark:bg-zinc-800`:``}`,children:(0,o.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-zinc-800 dark:text-zinc-200`,children:[e.path,Jt(e.type)?`/`:``]})},e.path))}),(0,o.jsxs)(`div`,{className:`flex items-end gap-2 rounded-xl border border-zinc-200 bg-zinc-50 p-2 focus-within:border-zinc-400 dark:border-zinc-800 dark:bg-zinc-900 dark:focus-within:border-zinc-600`,children:[(0,o.jsx)(`textarea`,{ref:te,value:v,onChange:e=>{y(e.target.value),x(e.target.selectionStart??e.target.value.length)},onKeyDown:H,onClick:re,onKeyUp:re,onPaste:U,placeholder:t?e?`steer the agent… (Enter to send)`:`message pi… (/ for commands, @ for files, Enter to send, Shift+Enter for newline)`:`connecting…`,disabled:!t,rows:1,className:`max-h-[min(40vh,20rem)] flex-1 resize-none overflow-y-hidden 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,o.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,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.jsx)(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>D.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,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.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,o.jsx)(`input`,{ref:D,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&l(Array.from(e.target.files)),e.target.value=``}}),(0,o.jsx)(`button`,{type:`button`,onClick:R,disabled:!t||F||!v.trim()&&s.length===0,title:F?`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,o.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:[(0,o.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,o.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,o.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]}):(0,o.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,"aria-hidden":!0,className:`h-4 w-4`,children:(0,o.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 Zt=`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`,Qt=`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`,$t=`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`,en=`mb-4 ${$t}`,tn=`1,3`,nn=` — `;function rn(e){let t=e.indexOf(`
|
|
13
13
|
`);return t===-1?{heading:e,body:``}:{heading:e.slice(0,t),body:e.slice(t+1).trim()}}function an(e){let t=/^(\d+)\.\s+(\S[\s\S]*)$/.exec(e.trim());if(!t)return null;let n=t[2],r=n.indexOf(nn);return{index:Number(t[1]),label:r===-1?n:n.slice(0,r),description:r===-1?``:n.slice(r+3)}}function on(e){if(e.method!==`input`||e.placeholder!==tn)return null;let{heading:t,body:n}=rn(e.title),r=[];for(let e of n.split(`
|
|
14
|
-
`)){let t=an(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function sn({request:e,onRespond:t}){let[n,r]=(0,i.useState)(e.method===`editor`?e.prefill??``:``),[a,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!1),u=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[d,f]=(0,i.useState)(u?Math.ceil(u/1e3):null),p=on(e),{heading:m,body:h}=rn(e.title);function g(){t({id:e.id,cancelled:!0})}function _(e){s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function v(){let r=n.trim();t({id:e.id,value:r.length>0?r:a.join(`,`)})}return(0,i.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),400);return()=>clearTimeout(e)},[c]),(0,i.useEffect)(()=>{if(d===null)return;if(d<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>f(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[d,e.id,t]),(0,o.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>l(!0),children:(0,o.jsxs)(`div`,{className:`w-full ${h?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${c?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,o.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none 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:`✕`})]}),h&&!p&&(0,o.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:h}),e.method===`select`&&(0,o.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=an(n);return(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${Zt}`,children:r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,o.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,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:Zt,children:`No`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:Qt,children:`Yes`})]})]}),p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:p.options.map(e=>(0,o.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,o.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>_(e.index),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,o.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&g()},className:`mb-1 ${$t}`}),(0,o.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:Zt,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:v,className:Qt,children:`OK`})]})]}),e.method===`input`&&!p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&g()},className:en}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:Zt,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Qt,children:`OK`})]})]}),e.method===`editor`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&g()},className:`resize-none font-mono ${en}`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:Zt,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Qt,children:`OK`})]})]}),d!==null&&(0,o.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,d,`s`]})]})})}var cn={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`},ln=6e3;function un({notification:e,onDismiss:t}){let n=(0,i.useRef)(t);return(0,i.useEffect)(()=>{n.current=t}),(0,i.useEffect)(()=>{let e=setTimeout(()=>n.current(),ln);return()=>clearTimeout(e)},[e.id]),(0,o.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${cn[e.notifyType??`info`]}`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function dn({notifications:e,onDismiss:t}){return e.length===0?null:(0,o.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,o.jsx)(un,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var fn={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`},pn=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function mn(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(fn[r]!==void 0)n.color=fn[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 hn(e){let t=[],n={},r=0;pn.lastIndex=0;for(let i=pn.exec(e);i!==null;i=pn.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=mn(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function gn(e){return e.replace(pn,``)}function _n({line:e}){let t=hn(e);return(0,o.jsx)(o.Fragment,{children:t.map((e,t)=>(0,o.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 vn({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,o.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,o.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,o.jsx)(`div`,{children:(0,o.jsx)(_n,{line:e})},t))},e))})}var yn=null,bn=null;function xn(){return bn??=Promise.resolve().then(()=>require("./CodeEditor-CIWnYOMo.cjs")).then(e=>e.t).then(e=>yn=e,e=>{throw bn=null,e}),bn}var Sn=(0,i.lazy)(()=>{if(yn!==null){let e=yn;return{then:t=>t({default:e.CodeEditor})}}return xn().then(e=>({default:e.CodeEditor}))});function Cn({text:e,path:t,serverUrl:n,token:r,workspace:a,template:s}){let[c,l]=(0,i.useState)(`idle`),[u,d]=(0,i.useState)(`plain`),[f,p]=(0,i.useState)(null),m=(0,i.useRef)(!1),h=(0,i.useRef)({plain:0,template:0});async function g(i){if(!(m.current||Date.now()-h.current[i]<750)){m.current=!0,h.current[i]=Date.now(),d(i),l(`working`),p(null);try{let{downloadDocx:o,downloadDocxInTemplate:s}=await Promise.resolve().then(()=>require("./docxExport-CrsGZa8E.cjs")),c=typeof e==`function`?e():e;await(i===`template`?s:o)(c,t,{serverUrl:n,token:r,workspace:a}),l(`idle`)}catch(e){l(`failed`),p(e instanceof Error?e.message:String(e))}finally{m.current=!1}}}let _=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,v=(e,t)=>c===`working`&&u===e?`… exporting`:c===`failed`&&u===e?`⚠ export failed`:t,y=(e,t)=>c===`failed`&&u===e?`Could not export: ${f??`unknown reason`}`:t;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>void g(`plain`),disabled:c===`working`,title:y(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:_,children:v(`plain`,`⤓ word`)}),s!==void 0&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>void g(`template`),disabled:c===`working`,title:y(`template`,`Download as a Word document in the template ${s}`),"aria-label":`Download as a Word document in the template ${s}`,className:_,children:v(`template`,`⤓ word · template`)})]})}var wn=`pi-outpost:open`,Tn=4,En={css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`},Dn=`(function () {
|
|
14
|
+
`)){let t=an(e);t&&r.push(t)}return r.length<2||r.some((e,t)=>e.index!==t+1)?null:{heading:t,options:r}}function sn({request:e,onRespond:t}){let[n,r]=(0,i.useState)(e.method===`editor`?e.prefill??``:``),[a,s]=(0,i.useState)([]),[c,l]=(0,i.useState)(!1),u=(e.method===`select`||e.method===`confirm`||e.method===`input`)&&e.timeout,[d,f]=(0,i.useState)(u?Math.ceil(u/1e3):null),p=on(e),{heading:m,body:h}=rn(e.title);function g(){t({id:e.id,cancelled:!0})}function _(e){s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].sort((e,t)=>e-t))}function v(){let r=n.trim();t({id:e.id,value:r.length>0?r:a.join(`,`)})}return(0,i.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),400);return()=>clearTimeout(e)},[c]),(0,i.useEffect)(()=>{if(d===null)return;if(d<=0){t({id:e.id,cancelled:!0});return}let n=setTimeout(()=>f(e=>e===null?null:e-1),1e3);return()=>clearTimeout(n)},[d,e.id,t]),(0,o.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>l(!0),children:(0,o.jsxs)(`div`,{className:`w-full ${h?`max-w-2xl`:`max-w-md`} rounded-xl border bg-white p-4 shadow-2xl transition-shadow dark:bg-zinc-900 ${c?`border-zinc-400 ring-2 ring-zinc-400/60 dark:border-zinc-500 dark:ring-zinc-500/60`:`border-zinc-200 dark:border-zinc-700`}`,onClick:e=>e.stopPropagation(),children:[(0,o.jsxs)(`div`,{className:`mb-3 flex items-start gap-3`,children:[(0,o.jsx)(`h2`,{className:`flex-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:m}),(0,o.jsx)(`button`,{type:`button`,onClick:g,"aria-label":`Refuse to answer`,title:`Refuse to answer`,className:`-mr-1 -mt-1 rounded-md px-1.5 py-0.5 text-sm leading-none 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:`✕`})]}),h&&!p&&(0,o.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:h}),e.method===`select`&&(0,o.jsx)(`div`,{className:`mb-1 flex flex-col gap-1`,children:e.options.map(n=>{let r=an(n);return(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:`text-left ${Zt}`,children:r?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:r.label}),r.description&&(0,o.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,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{className:`mb-4 text-sm text-zinc-600 dark:text-zinc-400`,children:e.message}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!1}),className:Zt,children:`No`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,confirmed:!0}),className:Qt,children:`Yes`})]})]}),p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`div`,{className:`mb-3 flex flex-col gap-1`,children:p.options.map(e=>(0,o.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,o.jsx)(`input`,{type:`checkbox`,checked:a.includes(e.index),onChange:()=>_(e.index),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-900 dark:text-zinc-100`,children:e.label}),e.description&&(0,o.jsx)(`span`,{className:`mt-0.5 block text-xs text-zinc-500 dark:text-zinc-400`,children:e.description})]})]},e.index))}),(0,o.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`…or type your own answer`,onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&g()},className:`mb-1 ${$t}`}),(0,o.jsx)(`p`,{className:`mb-4 text-xs text-zinc-400 dark:text-zinc-600`,children:`A typed answer replaces the selection above.`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:Zt,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:v,className:Qt,children:`OK`})]})]}),e.method===`input`&&!p&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),placeholder:e.placeholder,onKeyDown:r=>{r.key===`Enter`&&t({id:e.id,value:n}),r.key===`Escape`&&g()},className:en}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:Zt,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Qt,children:`OK`})]})]}),e.method===`editor`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`textarea`,{autoFocus:!0,value:n,onChange:e=>r(e.target.value),rows:8,onKeyDown:e=>{e.key===`Escape`&&g()},className:`resize-none font-mono ${en}`}),(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:g,className:Zt,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>t({id:e.id,value:n}),className:Qt,children:`OK`})]})]}),d!==null&&(0,o.jsxs)(`p`,{className:`mt-3 text-right text-xs text-zinc-400 dark:text-zinc-600`,children:[`auto-dismiss in `,d,`s`]})]})})}var cn={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`},ln=6e3;function un({notification:e,onDismiss:t}){let n=(0,i.useRef)(t);return(0,i.useEffect)(()=>{n.current=t}),(0,i.useEffect)(()=>{let e=setTimeout(()=>n.current(),ln);return()=>clearTimeout(e)},[e.id]),(0,o.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm shadow-lg ${cn[e.notifyType??`info`]}`,children:[(0,o.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>n.current(),className:`-mr-1 shrink-0 rounded px-1 leading-5 opacity-60 transition-opacity hover:opacity-100 focus-visible:opacity-100`,children:`×`})]})}function dn({notifications:e,onDismiss:t}){return e.length===0?null:(0,o.jsx)(`div`,{className:`fixed right-4 top-16 z-40 flex w-80 flex-col gap-2`,children:e.map(e=>(0,o.jsx)(un,{notification:e,onDismiss:()=>t(e.id)},e.id))})}var fn={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`},pn=/\u001B\[[0-9;:]*[A-Za-z]|\u001B[()][A-Za-z0-9]|\u001B[A-Za-z]/g;function mn(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(fn[r]!==void 0)n.color=fn[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 hn(e){let t=[],n={},r=0;pn.lastIndex=0;for(let i=pn.exec(e);i!==null;i=pn.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=mn(n,t)}}return r<e.length&&t.push({text:e.slice(r),...n}),t}function gn(e){return e.replace(pn,``)}function _n({text:e}){let t=hn(e);return(0,o.jsx)(o.Fragment,{children:t.map((e,t)=>(0,o.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 vn({widgets:e,placement:t}){let n=Object.entries(e).filter(([,e])=>e.placement===t);return n.length===0?null:(0,o.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,children:n.map(([e,t])=>(0,o.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,o.jsx)(`div`,{children:(0,o.jsx)(_n,{text:e})},t))},e))})}var yn=null,bn=null;function xn(){return bn??=Promise.resolve().then(()=>require("./CodeEditor-CIWnYOMo.cjs")).then(e=>e.t).then(e=>yn=e,e=>{throw bn=null,e}),bn}var Sn=(0,i.lazy)(()=>{if(yn!==null){let e=yn;return{then:t=>t({default:e.CodeEditor})}}return xn().then(e=>({default:e.CodeEditor}))});function Cn({text:e,path:t,serverUrl:n,token:r,workspace:a,template:s}){let[c,l]=(0,i.useState)(`idle`),[u,d]=(0,i.useState)(`plain`),[f,p]=(0,i.useState)(null),m=(0,i.useRef)(!1),h=(0,i.useRef)({plain:0,template:0});async function g(i){if(!(m.current||Date.now()-h.current[i]<750)){m.current=!0,h.current[i]=Date.now(),d(i),l(`working`),p(null);try{let{downloadDocx:o,downloadDocxInTemplate:s}=await Promise.resolve().then(()=>require("./docxExport-CrsGZa8E.cjs")),c=typeof e==`function`?e():e;await(i===`template`?s:o)(c,t,{serverUrl:n,token:r,workspace:a}),l(`idle`)}catch(e){l(`failed`),p(e instanceof Error?e.message:String(e))}finally{m.current=!1}}}let _=`shrink-0 rounded px-1.5 py-0.5 text-xs text-zinc-400 hover:bg-zinc-100 hover:text-zinc-700 disabled:opacity-50 dark:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-300`,v=(e,t)=>c===`working`&&u===e?`… exporting`:c===`failed`&&u===e?`⚠ export failed`:t,y=(e,t)=>c===`failed`&&u===e?`Could not export: ${f??`unknown reason`}`:t;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>void g(`plain`),disabled:c===`working`,title:y(`plain`,`Download as a Word document`),"aria-label":`Download as a Word document`,className:_,children:v(`plain`,`⤓ word`)}),s!==void 0&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>void g(`template`),disabled:c===`working`,title:y(`template`,`Download as a Word document in the template ${s}`),"aria-label":`Download as a Word document in the template ${s}`,className:_,children:v(`template`,`⤓ word · template`)})]})}var wn=`pi-outpost:open`,Tn=4,En={css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,svg:`image/svg+xml`,ico:`image/x-icon`,bmp:`image/bmp`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`},Dn=`(function () {
|
|
15
15
|
document.addEventListener("click", function (event) {
|
|
16
16
|
var link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
17
17
|
if (!link || event.defaultPrevented) return;
|
|
@@ -632,8 +632,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
632
632
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
633
633
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
634
634
|
SOFTWARE.
|
|
635
|
-
`,Vr=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],Hr=[{name:`pi-outpost`,license:`MIT`,text:Br},...zr];function Ur(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(null);return(0,i.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,o.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),Hr.map(e=>(0,o.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,o.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,o.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsxs)(`section`,{className:`pb-5`,children:[(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,o.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,o.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,o.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,o.jsx)(`dl`,{className:`mt-3 space-y-3`,children:Vr.map(([e,t])=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,o.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function Wr(e){if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function Gr({packages:e,update:t,locked:n,onCheck:r,onUpdate:a}){let[s,c]=(0,i.useState)(null);if(e===null||e.length===0)return null;let l=t?.status===`pending`?t.source:null;return(0,o.jsxs)(`div`,{className:`mt-3`,"data-testid":`pi-packages`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),(0,o.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),(0,o.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let r=e.check?.state===`newer`&&!e.restartNeeded?e.check.latest:void 0;return(0,o.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate font-mono text-zinc-700 dark:text-zinc-300`,title:e.source,children:e.name}),r&&!n&&s!==e.source&&(0,o.jsx)(`button`,{type:`button`,disabled:l!==null,onClick:()=>c(e.source),className:`shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,children:l===e.source?`updating…`:`Update`})]}),(0,o.jsx)(`div`,{className:`line-clamp-2 text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-package-status`,title:Wr(e),children:Wr(e)}),r&&s===e.source&&(0,o.jsxs)(`div`,{className:`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{c(null),a(e.source)},className:`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,children:[`Install `,r]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:`Cancel`})]})]}),t&&t.status!==`pending`&&t.source===e.source&&(0,o.jsx)(`p`,{"data-testid":`pi-package-result`,className:`mt-1 ${t.status===`installed`?`text-emerald-700 dark:text-emerald-400`:`text-amber-700 dark:text-amber-400`}`,children:t.message})]},e.source)})})]})}function Kr({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[a,s]=(0,i.useState)(!1);return e.length===0?null:(0,o.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,o.jsxs)(`p`,{children:[`Installed and waiting on a restart to run: `,e.join(`, `),`.`]}),t?n?(0,o.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):a?(0,o.jsxs)(`div`,{className:`mt-1`,children:[(0,o.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var qr=30,Jr={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function Yr({skills:e,groups:t,enabled:n,onChange:r,disabled:a=!1,bound:s}){let[c,l]=(0,i.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[u,d]=(0,i.useState)(``),[f,p]=(0,i.useState)(!1),m=u.trim().toLocaleLowerCase(),h=m!==``||f,g=e=>(!f||n.has(e.relativePath))&&(!m||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(m)),_=new Map;for(let t of e)_.set(t.group,[..._.get(t.group)??[],t]);let v=e.filter(e=>n.has(e.relativePath)).length,y=h?e.filter(g).length:e.length,b=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},x=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},S=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,v,` of `,e.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:a||v===e.length,onClick:()=>b(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,disabled:a||v===0,onClick:()=>b(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:s.kind===`count`?`This repository holds more skills than the ${s.limit} listed here.`:`Folders deeper than ${s.limit} levels were not searched for skills.`}):null,e.length>0?(0,o.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:u,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,o.jsxs)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${f?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,v,`)`]})]}):null,!h&&v>0&&v<=qr?(0,o.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,o.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,o.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,o.jsx)(Xr,{skill:e,checked:!0})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:a,onClick:()=>x(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,h&&y===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:f&&!m?`No skill is on.`:`No skill matches.`}):null,(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=_.get(e.path)??[],r=h?t.filter(g):t;if(h&&r.length===0)return null;let i=r.filter(e=>n.has(e.relativePath)).length,s=h||c.has(e.path);return(0,o.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,o.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>S(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,o.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[i,`/`,r.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,o.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:a||i===r.length,onClick:()=>b(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:a||i===0,onClick:()=>b(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,o.jsx)(`li`,{children:(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${a?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:a,onChange:()=>x(e.relativePath),className:`mt-0.5`}),(0,o.jsxs)(`span`,{className:`min-w-0`,children:[(0,o.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,o.jsx)(`span`,{title:e.description,style:Jr,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,o.jsx)(Xr,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function Xr({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,o.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,o.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function Zr(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function Qr(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function $r(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function ei(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var ti={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function ni(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function ri(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function ii(e){let t=ri(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function ai(e,t){let n=ri(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${ri(e)}/${i||`agent-resources`}`}function oi({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,o.jsxs)(`span`,{children:[e,`s`]}),(0,o.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,o.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,o.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function si({preview:e,busy:t,error:n,onApply:r,onCancel:a}){let[s,c]=(0,i.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(()=>new Set),p=e.mode===`collection`,m=(0,i.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),h=(0,i.useMemo)(()=>Zr(e.skills,e.repositoryName),[e.skills,e.repositoryName]),g=e.roots.filter(e=>e.kind===`extension`&&s.has(`extension:${e.path}`)),_=g.length>0&&!l,v=t||!p&&s.size===0||_,y=()=>{let t=g.map(e=>e.path);p?r([],t,[...d]):r(e.roots.filter(e=>e.kind===`skill`&&s.has(`skill:${e.path}`)).map(e=>e.path),t)},b=e=>{u(!1),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,o.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:v,onClick:y,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),_?(0,o.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,p?(0,o.jsx)(Yr,{skills:m,groups:h,enabled:d,onChange:f,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:s.has(t),disabled:e.locked,onChange:()=>b(t)}),(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,o.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),g.length>0?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function ci(e){let t=(0,i.useRef)(null),n=(0,i.useRef)(e.onClose),r=(0,i.useRef)(!1),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(``),[u,d]=(0,i.useState)(`all`),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)(`skill`),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)(!1),[w,ee]=(0,i.useState)(``),[T,E]=(0,i.useState)(``),[te,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(``),[A,j]=(0,i.useState)(null),[M,N]=(0,i.useState)({}),[P,ne]=(0,i.useState)(null),[F,I]=(0,i.useState)(null),L=(0,i.useMemo)(()=>ni(e.inventory),[e.inventory]),R=(0,i.useMemo)(()=>{let e=c.trim().toLocaleLowerCase();return L.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=u===`all`?r:r.filter(e=>e.kind===u),a=n&&u!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&u===`all`)||f&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),c=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...c===void 0?{}:{onCount:c}}]:[]})},[L,f,u,c]),z=R.find(e=>e.id===a)??R[0]??null;if((0,i.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,i.useEffect)(()=>{N(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||$r(a,Qr(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,i.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,i.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,i.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!te&&E(t.path)},[te,e.operations.clonePath]),(0,i.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&h(null)},[e.operations.enrollment]),(0,i.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,h(null),_(null),C(!1))},[e.applyState]),!e.open)return null;let B=z&&`repository`in z?z.repository:null,V=B?e.operations.updates[B.id]:void 0,H=B?.assessment,re=H?.status===`updateable`&&H.token&&H.localRevision&&H.upstreamRevision,U=()=>{let t=b.trim();t&&(v===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},ie=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},ae=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},W=B?.collection,oe=W?Qr(W):[],se=new Set(B&&M[B.id]?M[B.id]:oe),ce=W?[...new Set([...se,...oe])].filter(e=>se.has(e)!==oe.includes(e)).length:0,G=B?e.operations.skills?.[B.id]:void 0,le=e=>{if(!B)return;let t=B.id;N(n=>{let r={...n};return $r(e,oe)?delete r[t]:r[t]=[...e],r})},ue=()=>{if(!B)return;let e=B.id;N(t=>{let n={...t};return delete n[e],n})},de=()=>{if(!B||!W)return;let t=new Set(W.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(B.id,[...se].filter(e=>t.has(e)))},fe=F?e.operations.removals?.[F.id]:void 0,pe=fe?.status===`error`||fe?.result?.status===`removed-delete-failed`;return(0,o.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,o.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,o.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,o.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,o.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,o.jsx)(`input`,{"aria-label":`Search resources`,value:c,onChange:e=>l(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,o.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded px-2 py-1 text-[11px] ${u===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,o.jsx)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded px-2 py-1 text-[11px] ${f?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,o.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[R.map(e=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${z?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,o.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,o.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?ti[e.repository.assessment.status]:e.reason})]},e.id)),R.length===0?(0,o.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,o.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(`local`),_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,o.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[F&&fe?(0,o.jsxs)(`div`,{role:pe?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${pe?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,o.jsx)(`p`,{className:`min-w-0 break-words`,children:ei(F.name,fe)}),fe.status===`loading`?null:(0,o.jsx)(`button`,{type:`button`,onClick:()=>I(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,m===`local`?(0,o.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,o.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":v===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{y(t),C(!1)},className:`rounded-md px-3 py-1.5 text-xs ${v===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local resource folder`,value:b,onChange:e=>{C(!1),x(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),g===`local`?(0,o.jsx)(Nr,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{C(!1),x(t),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,v===`extension`?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!b.trim()||e.applyState?.status===`applying`||v===`extension`&&(!S||e.extensionLock),onClick:U,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):m===`git`?(0,o.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,o.jsx)(si,{onCancel:()=>{h(null),_(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,o.jsx)(`input`,{"aria-label":`Repository address`,value:w,onChange:e=>ee(e.target.value),onBlur:()=>{let t=w.trim();t&&(D(!1),k(t),e.onSuggestClonePath(w))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local clone folder`,value:T,onChange:e=>{D(!0),E(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`clone-parent`),e.onBrowseServerPath(ii(T))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&w.trim()===O?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,g===`clone-parent`?(0,o.jsx)(Nr,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{E(ai(t,T)),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!w.trim()||!T.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(w,T),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):z?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`h3`,{className:`text-xl font-semibold`,children:z.name}),B?(0,o.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:ti[B.assessment.status]}):null]}),(0,o.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in z?z.path:z.reason}),H?.branch?(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[H.branch,H.upstream?` → ${H.upstream}`:``]}):null,B?.removal&&!B.removal.allowed?(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:B.removal.reason}):null]}),B?(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[B.removal?.allowed?(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[B.id]?.status===`loading`,onClick:()=>ne(B),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(B.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),re||V?.status===`loading`?(0,o.jsx)(`button`,{type:`button`,disabled:V?.status===`loading`,onClick:()=>B.containsExtensions?j(B):ae(B),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:V?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),H?.reason?(0,o.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${H.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[H.reason,H.status===`dirty`?(0,o.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,H?.hasSubmodules?(0,o.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,V?.status===`ready`?(0,o.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:V.result?.status===`updated`&&V.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:V.result?.status===`updated`?`Repository updated and runtimes reloaded.`:V.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:V.result?.reason}):null,V?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:V.message}):null,W&&B&&u!==`extension`?(0,o.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[ce>0||G?.status===`loading`?(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsx)(`span`,{children:G?.status===`loading`?`Applying…`:`${ce} pending change${ce===1?``:`s`} — applying replaces the session`}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:G?.status===`loading`,onClick:ue,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,o.jsx)(`button`,{type:`button`,disabled:G?.status===`loading`||ce===0,onClick:de,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,G?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:G.message}):null,(0,o.jsx)(Yr,{skills:W.skills,groups:W.groups,enabled:se,onChange:le,disabled:G?.status===`loading`,...W.bound?{bound:W.bound}:{}},B.id),z.resources.some(e=>e.kind===`extension`)?(0,o.jsx)(oi,{kind:`extension`,resources:z.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ie}):null]}):(0,o.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,o.jsx)(oi,{kind:`skill`,resources:z.resources.filter(e=>e.kind===`skill`),onRemove:ie}),(0,o.jsx)(oi,{kind:`extension`,resources:z.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ie})]})]}):(0,o.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),A?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,o.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[A.name,` contains extensions that run with the agent's privileges. Confirm updating `,A.assessment.localRevision?.slice(0,8),` to `,A.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>j(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{ae(A,!0),j(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,P?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,P.name,`?`]}),(0,o.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:P.removal?.deletesFiles?(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,P.name,` and deletes `,(0,o.jsx)(`span`,{className:`font-mono`,children:P.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,P.name,`. pi-outpost does not manage `,(0,o.jsx)(`span`,{className:`font-mono`,children:P.removal?.path??P.path}),`, so its files will be kept.`]})}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>ne(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(P.id),I({id:P.id,name:P.name}),ne(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:P.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var li=`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`,ui=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function di({event:e}){switch(e.type){case`auth_url`:return(0,o.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,o.jsx)(`button`,{type:`button`,className:ui,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,o.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,o.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,o.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function fi({prompt:e,onAnswer:t}){let[n,r]=(0,i.useState)(``),a=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,o.jsx)(`button`,{type:`button`,className:ui,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,o.jsx)(`input`,{className:`${li} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),a&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,o.jsx)(`button`,{type:`button`,className:ui,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function pi({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,o.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,o.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,o.jsx)(di,{event:e},t)),e.prompt&&(0,o.jsx)(fi,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,o.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,o.jsx)(`button`,{type:`button`,className:ui,onClick:i,children:`Close`})]}):(0,o.jsx)(`button`,{type:`button`,className:ui,onClick:r,children:`Cancel`})]})]})}function mi(e){return[...e].sort((e,t)=>e.localeCompare(t))}function hi(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function gi(e,t){return e===`models_json_key`?`models.json`:t??e}function _i({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:a,onDismissLogin:s,onLogoutProvider:c,extensionPaths:l,configuredExtensionPaths:u,userExtensionPaths:d,extensionLock:f,piPackages:p=null,piPackageUpdate:m=null,canRestartServer:h=!1,serverRestarting:g=!1,onCheckPiPackages:_,onUpdatePiPackage:v,onRestartServer:y,onRestartSession:b,restartNeeded:x=[],tools:S,commands:C,sandbox:w,showRoots:ee=!0,gitUnavailable:T,userSkillPaths:E,serverBrowse:te,pickerBlocked:D=!1,onPickerOpened:O,applyState:k,agentResources:A=null,agentResourceOperations:j={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:M,onBrowseServerPath:N,onCloseServerBrowser:P,onUpdateConfig:ne,onSuggestAgentResourceClonePath:F=()=>{},onCloneAgentResourceRepository:I=()=>{},onEnrollAgentResourceRepository:L=()=>{},onSetAgentResourceSkills:R=()=>{},onRemoveAgentResourceRepository:z=()=>{},onRefreshAgentResourceRepositories:B=()=>{},onUpdateAgentResourceRepository:V=()=>{}}){let[H,re]=(0,i.useState)(!1),[U,ie]=(0,i.useState)(!1),ae=(0,i.useRef)(new Map),[W,oe]=(0,i.useState)(!1),se=(0,i.useRef)(null),[ce,G]=(0,i.useState)(``),[le,ue]=(0,i.useState)(``),[de,fe]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),[he,ge]=(0,i.useState)(null),_e=(e,r)=>{if(t&&!t.done){a?.(),s?.();let e=ae.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,i.useEffect)(()=>{D&&he!==null&&ge(null)},[D,he]);let ve=Wt(()=>{(H||he!==null)&&Ee()}),ye=S.filter(e=>e.active),be=S.filter(e=>!e.active),xe=C.filter(e=>e.source===`skill`),Se=[...S].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Ce=k?.status===`applying`,we=k?.status===`error`?k.message:null;(0,i.useEffect)(()=>{w&&(G(w.root),ue(w.writableRoot??``),fe(w.allowWrite),me(w.allowBash))},[w]);let Te=(0,i.useRef)(!1);(0,i.useEffect)(()=>{Te.current&&k===null&&Ee(),Te.current=Ce},[k,Ce]);function Ee(){ie(!1),re(!1),ge(null),P()}function De(e,t){O?.(),ge(e),N(t.trim()||`/`)}function Oe(e){he===`root`?G(e):he===`writableRoot`&&ue(e),ge(null),P()}let ke=w!==null&&(ce!==w.root||(le.trim()||void 0)!==(w.writableRoot||void 0)||de!==w.allowWrite||pe!==w.allowBash);function Ae(){w&&ke&&ne({sandbox:{root:ce,allowWrite:de,allowBash:pe,writableRoot:le.trim()||void 0}})}let je=ee&&w?.rootEditable!==!1,Me=he!==null&&!D&&(0,o.jsx)(Nr,{label:he===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:te,onBrowse:N,onSelect:Oe,onCancel:()=>{ge(null),P()}});return(0,o.jsxs)(`div`,{className:`relative`,ref:ve,children:[(0,o.jsx)(`button`,{ref:se,type:`button`,onClick:()=>{ie(!1),H?Ee():re(!0)},title:`Settings`,"aria-label":`Settings`,className:`${Tr} 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:`⚙`}),H&&(0,o.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,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[U&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>ie(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,o.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:U?`Credits`:`Settings`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:U?(0,o.jsx)(Ur,{}):(0,o.jsxs)(o.Fragment,{children:[T&&(0,o.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),T.reason===`no-repository`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,o.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,o.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:T.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,o.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:T.message}),T.reason===`no-executable`&&(0,o.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,o.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,o.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,o.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[(0,o.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,o.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,o.jsxs)(`details`,{ref:e=>{e?ae.current.set(n.id,e):ae.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,o.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${gi(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,o.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:hi(n.source,n.label)}),!e.locked&&(0,o.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>c?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,o.jsx)(`div`,{className:`mt-2`,children:(0,o.jsx)(pi,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>a?.(),onDismiss:()=>s?.()})})]})]})},n.id))}),e.locked&&(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),S.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,o.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ye.length,` tools active`,be.length?` · ${be.length} inactive`:``]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Se.map(e=>(0,o.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,o.jsx)(`span`,{children:e.name}),(0,o.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),xe.length===0?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[xe.length,` skills loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:mi(xe.map(e=>e.name)).map(e=>(0,o.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,o.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{re(!1),oe(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage resources…`})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),l===null?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):l.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,o.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[l.length,` `,l.length===1?`extension`:`extensions`,` loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:mi(l).map(e=>(0,o.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))})]}),u.length>0&&(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[u.length,` configured by this deployment`]}),(0,o.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,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:mi(u).map(e=>(0,o.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))})]}),f?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,o.jsx)(Gr,{packages:p,update:m,locked:f,onCheck:()=>_?.(),onUpdate:e=>v?.(e)}),(0,o.jsx)(Kr,{reasons:x,canRestart:h,restarting:g,onRestart:()=>y?.()})]}),w&&(0,o.jsxs)(`section`,{children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:je?`Sandbox`:`Agent permissions`}),(0,o.jsxs)(`div`,{className:`space-y-3`,children:[!je&&(0,o.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,o.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:w.projectRoot??w.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),je&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,w.locks?.root?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:ce,onChange:e=>G(e.target.value),disabled:w.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,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:w.locks?.root,onClick:()=>De(`root`,ce),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…`})]})]}),he===`root`&&Me,(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,w.locks?.writableRoot?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:le,onChange:e=>ue(e.target.value),disabled:w.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,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:w.locks?.writableRoot,onClick:()=>De(`writableRoot`,le||ce),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…`})]})]}),he===`writableRoot`&&Me]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.target.checked),disabled:w.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,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,w.locks?.allowWrite?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:pe,onChange:e=>me(e.target.checked),disabled:w.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,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,w.locks?.allowBash?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!w&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,o.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[we&&(0,o.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:we}),(0,o.jsx)(`button`,{type:`button`,disabled:Ce||ke&&!ce.trim(),onClick:ke?Ae:b,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:Ce?`Restarting…`:ke?`Apply & restart session`:`Restart session`}),(0,o.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:ke?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),M&&(0,o.jsxs)(`section`,{className:`mt-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,o.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsxs)(`p`,{children:[`pi-outpost: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:M.piOutpost})]}),M.piSdk&&(0,o.jsxs)(`p`,{children:[`pi SDK: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:M.piSdk})]}),M.agent&&(0,o.jsxs)(`p`,{children:[`agent: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:M.agent})]})]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>ie(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,o.jsx)(ci,{open:W,inventory:A,operations:j,extensionLock:f,userSkillPaths:E,userExtensionPaths:d,serverBrowse:te,applyState:k,onClose:()=>{oe(!1),P(),se.current?.focus()},onBrowseServerPath:e=>{O?.(),N(e)},onCloseServerBrowser:P,onUpdateConfig:ne,onSuggestClonePath:F,onCloneRepository:I,onEnrollRepository:L,onSetSkills:R,onRemoveRepository:z,onRefresh:B,onUpdate:V})]})}function vi(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);else{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 yi(e){return e.flatMap(e=>[e,...yi(e.children)])}function bi({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,o.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var xi=`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 Si({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:s}=e,c=s.tipId??s.entryId;return(0,o.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,o.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),a()},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,o.jsx)(ur,{row:e,laneCount:t,colorOf:sr}),(0,o.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,o.jsxs)(bi,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,o.jsxs)(bi,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,o.jsx)(bi,{tone:`current`,children:`current`}),s.label&&(0,o.jsx)(bi,{tone:`label`,children:s.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:xi,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{i(s.entryId),a()},title:`fork a new session from this point`,className:xi,children:`⑂ fork`})]})}function Ci({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:a}){let[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),d=Wt(()=>c(!1));(0,i.useEffect)(()=>{s&&e===null&&n()},[s,e]);let f=(0,i.useMemo)(()=>e&&e.length>0?vi(e):null,[e]),p=(0,i.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return yi(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,o.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${Tr} 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:`tree`}),s&&(0,o.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,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,o.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,o.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,o.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,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,o.jsx)(Si,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:r,onFork:a,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(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,o.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,o.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,o.jsx)(bi,{tone:`current`,children:`on current branch`}),e.label&&(0,o.jsx)(bi,{tone:`label`,children:e.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(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:xi,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{a(e.entryId),c(!1)},title:`fork a new session from this point`,className:xi,children:`⑂ fork`})]},e.entryId))})]})]})]})}var wi=200;function Ti({initial:e,onCommit:t,onCancel:n}){let[r,a]=(0,i.useState)(e);return(0,o.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},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 Ei({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:s,onCancelRename:c}){return n?(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsx)(Ti,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,o.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,o.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,o.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,o.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,o.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`:``,!t&&e.liveIn?(0,o.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:a,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&&!e.liveIn&&(0,o.jsx)(`button`,{type:`button`,onClick:i,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 Di({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:a,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(null),_=Wt(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,i.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),wi);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,o.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{d?b():(f(!0),m(``),g(null),u(),s())},className:`${Tr} 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:`sessions`}),d&&(0,o.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,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.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,o.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,o.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[S===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),S?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),S?.map(e=>(0,o.jsx)(Ei,{session:e,isCurrent:e.id===n,renaming:h===e.path,onSwitch:()=>{r(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&a(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function Oi({filters:e,onFilterChange:t}){let[n,r]=(0,i.useState)(!1),a=Wt(()=>r(!1)),s=vt(e),c=s>0?`Filter · ${s} hidden`:`Filter`;return(0,o.jsxs)(`div`,{className:`relative`,ref:a,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${Tr} ${s>0?`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:c}),n&&(0,o.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:pt.map(n=>(0,o.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,o.jsx)(`span`,{children:mt[n]})]},n))})]})}function ki({statuses:e,bar:t}){let n=Object.entries(e).map(([e,t])=>[e,gn(t)]).filter(([,e])=>e.trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=(0,i.useRef)(null),[u,d]=(0,i.useState)(!1),f=Wt(()=>d(!1));if((0,i.useLayoutEffect)(()=>{c.current=null,s(!1),d(!1)},[r]),(0,i.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{c.current===null?(Array.from(l.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1)||e.scrollWidth>e.clientWidth+1)&&(c.current=e.clientWidth,s(!0)):e.clientWidth>c.current+64&&(c.current=null,s(!1),d(!1))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,a,r]),n.length===0)return null;if(!a)return(0,o.jsx)(`div`,{ref:l,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,o.jsx)(`span`,{title:t,className:`${Tr} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,o.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:t})},e))});let p=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,o.jsxs)(`div`,{ref:f,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&u&&(e.stopPropagation(),d(!1))},children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),"aria-expanded":u,title:n.map(([,e])=>e).join(`
|
|
636
|
-
`),className:`${Tr} border-zinc-200 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:[p,` ▾`]}),u&&(0,o.jsx)(`ul`,{"aria-label":`Extension statuses`,className:`absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:n.map(([e,t])=>(0,o.jsx)(`li`,{className:`break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300`,children:t},e))})]})}function Ai({theme:e,preference:t=e,onToggle:n,onSetTheme:r}){let[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=Wt(()=>s(!1));(0,i.useEffect)(()=>{a&&l.current?.querySelector(`[aria-checked="true"]`)?.focus()},[a]);let u={light:`Light`,dark:`Dark`,system:`System`}[t];return(0,o.jsxs)(`div`,{ref:l,className:`relative`,onKeyDown:e=>{if(e.key===`Escape`&&(e.stopPropagation(),s(!1),c.current?.focus()),a&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)){e.preventDefault();let t=Array.from(l.current?.querySelectorAll(`[role="menuitemradio"]`)??[]),n=t.findIndex(e=>e.matches(`:focus`));t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}},children:[(0,o.jsx)(`button`,{ref:c,type:`button`,onClick:()=>s(e=>!e),title:`Theme: ${u}`,"aria-label":`Theme: ${u}`,"aria-haspopup":`menu`,"aria-expanded":a,className:`${Tr} 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:t===`system`?`◐`:e===`dark`?`☾`:`☀`}),a&&(0,o.jsx)(`div`,{role:`menu`,"aria-label":`Theme`,className:`absolute right-0 top-full z-40 mt-2 min-w-32 rounded-lg border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[`light`,`dark`,`system`].map(i=>(0,o.jsx)(`button`,{role:`menuitemradio`,"aria-checked":t===i,type:`button`,className:`block w-full rounded px-3 py-1.5 text-left text-xs text-zinc-700 hover:bg-zinc-100 focus:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-800 dark:focus:bg-zinc-800`,onClick:()=>{r?r(i):i!==e&&n(),s(!1),c.current?.focus()},children:i===`light`?`Light`:i===`dark`?`Dark`:`System`},i))})]})}function ji(e){let{isStreaming:t,connected:n}=e,[r,a]=(0,i.useState)(null);return(0,o.jsxs)(`header`,{ref:a,className:`relative z-30 flex min-w-0 items-center gap-1.5 border-b border-zinc-200 px-4 py-2 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,o.jsx)(Mr,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,o.jsx)(Fr,{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,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`${Tr} ${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,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`${Tr} ${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,o.jsx)(Rr,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,o.jsx)(`span`,{title:e.title??void 0,className:`min-w-[2.25rem] shrink-[4] truncate whitespace-nowrap text-lg font-semibold leading-tight tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),(0,o.jsx)(ki,{statuses:e.statuses,bar:r}),(0,o.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,o.jsx)(Oi,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onExportConversation,disabled:!!e.exportProgress,"aria-busy":!!e.exportProgress,title:`Save the whole conversation as one HTML file`,"aria-label":`Export the conversation as HTML`,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-progress disabled:opacity-60 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e.exportProgress??`↓ html`}),e.onToggleTerminal&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none ${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,o.jsx)(Ai,{theme:e.theme,preference:e.themePreference,onSetTheme:e.onSetTheme,onToggle:e.onToggleTheme}),(0,o.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`${Tr} border-emerald-300 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,o.jsx)(Ci,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,o.jsx)(Di,{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,o.jsx)(_i,{credentials:e.credentials,login:e.login,onStartLogin:e.onStartLogin,onAnswerLogin:e.onAnswerLogin,onCancelLogin:e.onCancelLogin,onDismissLogin:e.onDismissLogin,onLogoutProvider:e.onLogoutProvider,extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onRestartSession:e.onRestartSession,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,o.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Mi(e,t){let n=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>je(e)!==t);for(let e of[...n.current.keys()])r.some(t=>je(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&(typeof document>`u`||document.visibilityState!==`visible`)){for(let e of i)if(n.current.get(je(e))!==e.activity){n.current.set(je(e),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:${je(e)}`})}catch{}}}},[e,t])}var Ni={"agent-directory":`read the agent directory (the provider keys)`,"beside-root":`read a file beside the root`,"write-beside-root":`write beside the root`,"signal-process":`signal another process of the server's user`,"server-environment":`inherit the server's environment`,"server-process-environment":`read the server's process environment (/proc)`,"unlisted-host":`reach a host not in sandbox.allowedHosts`,"direct-connection":`connect around the proxy`},Pi=e=>e.map(e=>Ni[e]??e),Fi=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()};function Ii(e,t){let n=t===`shell`?`The agent's shell`:`This terminal`;switch(e.state){case`checking`:return`${n} runs under ${e.runner||`a sandbox runner`}; its confinement is being checked.`;case`verified`:return[`${n} is confined by ${e.runner}, checked at ${Fi(e.checkedAt)}. A command could not:`,...Pi(e.refused).map(e=>`• ${e}`),...e.environmentReadable?[`The server's process environment is readable, and holds no secret.`]:[],...e.notChecked.length?[`Not checked:`,...e.notChecked.map(e=>`• ${Ni[e.attempt]??e.attempt} — ${e.why}`)]:[]].join(`
|
|
635
|
+
`,Vr=[[`draw.io / diagrams.net`,`Diagram viewer and editor`],[`React`,`User interface`],[`CodeMirror · xterm.js · node-pty`,`Code editor and terminal`],[`PDF.js · docx`,`Document tools`],[`Mermaid · KaTeX`,`Diagrams and mathematical notation`]],Hr=[{name:`pi-outpost`,license:`MIT`,text:Br},...zr];function Ur(){let[e,t]=(0,i.useState)(!1),n=(0,i.useRef)(null);return(0,i.useLayoutEffect)(()=>{n.current?.focus({preventScroll:!0});let e=n.current?.closest(`.overflow-y-auto`);e&&(e.scrollTop=0)},[e]),e?(0,o.jsxs)(`div`,{className:`text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`mb-3 text-xs text-zinc-500 hover:underline dark:text-zinc-400`,children:`← Back to credits`}),(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-sm font-semibold outline-none`,children:`Third-party notices`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`License texts and attributions for pi-outpost and the components acknowledged here.`}),Hr.map(e=>(0,o.jsxs)(`section`,{className:`mt-5 border-t border-zinc-200 pt-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[e.name,` `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500 dark:text-zinc-400`,children:[`· `,e.license]})]}),(0,o.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed`,children:e.text})]},e.name))]}):(0,o.jsxs)(`div`,{className:`text-sm text-zinc-700 dark:text-zinc-300`,children:[(0,o.jsxs)(`section`,{className:`pb-5`,children:[(0,o.jsx)(`h3`,{ref:n,tabIndex:-1,className:`text-xl font-semibold tracking-tight outline-none`,children:`pi-outpost`}),(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Created by Laurent Francoise · MIT license`}),(0,o.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-2 text-xs underline underline-offset-4`,href:`https://laurentftech.github.io/pi-outpost/`,target:`_blank`,rel:`noopener noreferrer`,children:[`Project website `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]})]}),(0,o.jsxs)(`section`,{className:`border-t border-zinc-200 pt-4 dark:border-zinc-700`,children:[(0,o.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Open-source acknowledgements`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Thanks to the authors and contributors of these projects.`}),(0,o.jsx)(`dl`,{className:`mt-3 space-y-3`,children:Vr.map(([e,t])=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`dt`,{className:`text-xs font-medium`,children:e}),(0,o.jsx)(`dd`,{className:`mt-0.5 text-xs text-zinc-500 dark:text-zinc-400`,children:t})]},e))}),(0,o.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),className:`mt-4 flex w-full items-center justify-between rounded-md border border-zinc-300 px-3 py-2 text-xs hover:bg-zinc-100 dark:border-zinc-700 dark:hover:bg-zinc-800`,children:[`Third-party notices `,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:`→`})]})]})]})}function Wr(e){if(e.installed===void 0)return`not installed`;if(e.restartNeeded)return`${e.installed} installed — restart to use it`;if(e.pinned!==void 0)return`${e.installed}, pinned`;let t=e.check;if(!t)return e.installed;switch(t.state){case`checking`:return`${e.installed}, checking…`;case`newer`:return`${e.installed} — ${t.latest} available`;case`current`:return`${e.installed}, up to date`;case`failed`:return`${e.installed}, not checked: ${t.reason}`;case`off`:return`${e.installed}, not checked: ${t.reason}`}}function Gr({packages:e,update:t,locked:n,onCheck:r,onUpdate:a}){let[s,c]=(0,i.useState)(null);if(e===null||e.length===0)return null;let l=t?.status===`pending`?t.source:null;return(0,o.jsxs)(`div`,{className:`mt-3`,"data-testid":`pi-packages`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-600 dark:text-zinc-400`,children:`Packages`}),(0,o.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200`,children:`check for updates`})]}),(0,o.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let r=e.check?.state===`newer`&&!e.restartNeeded?e.check.latest:void 0;return(0,o.jsxs)(`li`,{"data-testid":`pi-package`,className:`rounded bg-zinc-50 px-2 py-1 text-xs dark:bg-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`min-w-0 truncate font-mono text-zinc-700 dark:text-zinc-300`,title:e.source,children:e.name}),r&&!n&&s!==e.source&&(0,o.jsx)(`button`,{type:`button`,disabled:l!==null,onClick:()=>c(e.source),className:`shrink-0 rounded border border-zinc-300 px-1.5 py-0.5 text-zinc-700 hover:bg-zinc-100 disabled:opacity-50 dark:border-zinc-600 dark:text-zinc-200 dark:hover:bg-zinc-700`,children:l===e.source?`updating…`:`Update`})]}),(0,o.jsx)(`div`,{className:`line-clamp-2 text-zinc-500 dark:text-zinc-400`,"data-testid":`pi-package-status`,title:Wr(e),children:Wr(e)}),r&&s===e.source&&(0,o.jsxs)(`div`,{className:`mt-1 rounded border border-amber-300 bg-amber-50 p-2 text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`pi-package-confirm`,children:[(0,o.jsxs)(`p`,{children:[`This replaces code that runs with the agent's privileges: `,e.name,` `,e.installed,` → `,r,`. It takes effect when pi-outpost restarts.`]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{c(null),a(e.source)},className:`rounded bg-amber-600 px-2 py-0.5 text-white hover:bg-amber-700`,children:[`Install `,r]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded px-2 py-0.5 hover:bg-amber-100 dark:hover:bg-amber-900/40`,children:`Cancel`})]})]}),t&&t.status!==`pending`&&t.source===e.source&&(0,o.jsx)(`p`,{"data-testid":`pi-package-result`,className:`mt-1 ${t.status===`installed`?`text-emerald-700 dark:text-emerald-400`:`text-amber-700 dark:text-amber-400`}`,children:t.message})]},e.source)})})]})}function Kr({reasons:e,canRestart:t,restarting:n,onRestart:r}){let[a,s]=(0,i.useState)(!1);return e.length===0?null:(0,o.jsxs)(`div`,{className:`mt-3 rounded border border-sky-200 bg-sky-50 p-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,"data-testid":`restart-needed`,children:[(0,o.jsxs)(`p`,{children:[`Installed and waiting on a restart to run: `,e.join(`, `),`.`]}),t?n?(0,o.jsx)(`p`,{className:`mt-1`,children:`Restarting pi-outpost…`}):a?(0,o.jsxs)(`div`,{className:`mt-1`,children:[(0,o.jsx)(`p`,{children:`pi-outpost stops and starts again in the same terminal. Every open window reconnects by itself, and conversations are kept.`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),r()},className:`rounded bg-sky-700 px-2 py-0.5 text-white hover:bg-sky-800`,children:`Restart now`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded px-2 py-0.5 hover:bg-sky-100 dark:hover:bg-sky-900/50`,children:`Cancel`})]})]}):(0,o.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-1 rounded border border-sky-300 px-2 py-0.5 hover:bg-sky-100 dark:border-sky-700 dark:hover:bg-sky-900/50`,children:`Restart pi-outpost`}):null]})}var qr=30,Jr={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function Yr({skills:e,groups:t,enabled:n,onChange:r,disabled:a=!1,bound:s}){let[c,l]=(0,i.useState)(()=>e.length>40?new Set(e.filter(e=>n.has(e.relativePath)).map(e=>e.group)):new Set(t.map(e=>e.path))),[u,d]=(0,i.useState)(``),[f,p]=(0,i.useState)(!1),m=u.trim().toLocaleLowerCase(),h=m!==``||f,g=e=>(!f||n.has(e.relativePath))&&(!m||`${e.name} ${e.relativePath} ${e.description??``}`.toLocaleLowerCase().includes(m)),_=new Map;for(let t of e)_.set(t.group,[..._.get(t.group)??[],t]);let v=e.filter(e=>n.has(e.relativePath)).length,y=h?e.filter(g).length:e.length,b=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n.relativePath):i.delete(n.relativePath);r(i)},x=e=>{let t=new Set(n);t.has(e)?t.delete(e):t.add(e),r(t)},S=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,"aria-label":`Collection skills`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,o.jsxs)(`h3`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:[`Skills `,(0,o.jsxs)(`span`,{className:`font-normal text-zinc-500`,children:[`· `,v,` of `,e.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:a||v===e.length,onClick:()=>b(e,!0),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,disabled:a||v===0,onClick:()=>b(e,!1),className:`rounded-md border px-2.5 py-1 text-xs disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`p`,{className:`mt-2 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:s.kind===`count`?`This repository holds more skills than the ${s.limit} listed here.`:`Folders deeper than ${s.limit} levels were not searched for skills.`}):null,e.length>0?(0,o.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`search`,"aria-label":`Search skills`,placeholder:`Search skills by name or folder`,value:u,onChange:e=>d(e.target.value),className:`min-w-0 flex-1 rounded-md border bg-transparent px-2.5 py-1 text-xs`}),(0,o.jsxs)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded-md px-2.5 py-1 text-xs ${f?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:[`Only on (`,v,`)`]})]}):null,!h&&v>0&&v<=qr?(0,o.jsxs)(`div`,{role:`region`,"aria-label":`Skills that are on`,className:`mt-3 rounded-lg border border-emerald-200 bg-emerald-50/60 p-2 dark:border-emerald-900 dark:bg-emerald-950/30`,children:[(0,o.jsx)(`p`,{className:`px-1 text-[11px] font-medium text-emerald-800 dark:text-emerald-300`,children:`Turned on`}),(0,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.filter(e=>n.has(e.relativePath)).map(e=>(0,o.jsxs)(`li`,{className:`flex items-start justify-between gap-2 px-1`,children:[(0,o.jsxs)(`span`,{className:`min-w-0 text-xs`,children:[(0,o.jsx)(`span`,{className:`font-medium text-zinc-800 dark:text-zinc-100`,children:e.name}),` `,(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.group||`(repository root)`}),(0,o.jsx)(Xr,{skill:e,checked:!0})]}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`Turn off ${e.name} (${e.relativePath})`,disabled:a,onClick:()=>x(e.relativePath),className:`shrink-0 rounded border bg-white px-2 py-0.5 text-[11px] disabled:opacity-50 dark:bg-zinc-900`,children:`Turn off`})]},e.relativePath))})]}):null,e.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`This repository holds no skills.`}):null,h&&y===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:f&&!m?`No skill is on.`:`No skill matches.`}):null,(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>{let t=_.get(e.path)??[],r=h?t.filter(g):t;if(h&&r.length===0)return null;let i=r.filter(e=>n.has(e.relativePath)).length,s=h||c.has(e.path);return(0,o.jsxs)(`li`,{className:`rounded-lg border border-zinc-100 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2`,children:[(0,o.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>S(e.path),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-zinc-400`,children:s?`▾`:`▸`}),(0,o.jsx)(`span`,{className:`truncate font-mono text-xs font-medium text-zinc-700 dark:text-zinc-200`,children:e.label}),(0,o.jsxs)(`span`,{className:`shrink-0 text-[11px] text-zinc-500`,children:[i,`/`,r.length,` on`]})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,o.jsx)(`button`,{type:`button`,"aria-label":`All on in ${e.label}`,disabled:a||i===r.length,onClick:()=>b(r,!0),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All on`}),(0,o.jsx)(`button`,{type:`button`,"aria-label":`All off in ${e.label}`,disabled:a||i===0,onClick:()=>b(r,!1),className:`rounded border px-2 py-0.5 text-[11px] disabled:opacity-50`,children:`All off`})]})]}),s?(0,o.jsx)(`ul`,{className:`space-y-1 border-t border-zinc-100 px-3 py-2 dark:border-zinc-800`,children:r.map(e=>{let t=n.has(e.relativePath);return(0,o.jsx)(`li`,{children:(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded px-1 py-1 ${a?`opacity-60`:`cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800/60`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":t,"aria-label":`${e.name} (${e.relativePath})`,checked:t,disabled:a,onChange:()=>x(e.relativePath),className:`mt-0.5`}),(0,o.jsxs)(`span`,{className:`min-w-0`,children:[(0,o.jsx)(`span`,{className:`block truncate text-sm text-zinc-800 dark:text-zinc-100`,children:e.name}),e.description?(0,o.jsx)(`span`,{title:e.description,style:Jr,className:`text-[11px] text-zinc-500`,children:e.description}):null,(0,o.jsx)(Xr,{skill:e,checked:t})]})]})},e.relativePath)})}):null]},e.path)})})]})}function Xr({skill:e,checked:t}){return t===(e.state!==`off`)?e.state===`on-loaded`?(0,o.jsx)(`span`,{className:`block text-[11px] text-emerald-700 dark:text-emerald-400`,children:`Loaded`}):e.state===`on-not-loaded`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-amber-700 dark:text-amber-400`,children:[`Not loaded — `,e.reason]}):e.state===`on-missing`?(0,o.jsxs)(`span`,{className:`block text-[11px] text-rose-700 dark:text-rose-400`,children:[`Missing — `,e.reason]}):null:(0,o.jsx)(`span`,{className:`block text-[11px] font-medium text-sky-700 dark:text-sky-300`,children:t?`Pending: on`:`Pending: off`})}function Zr(e,t){return[...new Set(e.map(e=>e.group))].sort().map(e=>({path:e,label:e||t}))}function Qr(e){return e.skills.filter(e=>e.state!==`off`).map(e=>e.relativePath)}function $r(e,t){let n=new Set(e),r=new Set(t);return n.size===r.size&&[...n].every(e=>r.has(e))}function ei(e,t){if(t.status===`loading`)return`Removing ${e}…`;if(t.status===`error`)return t.message??`Could not remove ${e}`;let n=t.result;return n?n.status===`removed`?`Removed ${e} and deleted ${n.path}.`:n.status===`removed-files-kept`?`Removed ${e}. ${n.reason??`Its files were kept`} (${n.path}).`:`Removed ${e}, but not every file could be deleted${n.reason?` — ${n.reason}`:``}. What remains is at ${n.path}.`:`Removed ${e}.`}var ti={unchecked:`Not checked`,checking:`Checking…`,current:`Up to date`,updateable:`Update available`,dirty:`Local changes`,detached:`Detached HEAD`,ahead:`Local branch ahead`,diverged:`Histories diverged`,"no-upstream":`No upstream`,locked:`Locked`,busy:`Workspace busy`,unavailable:`Unavailable`,failed:`Check failed`};function ni(e){if(!e)return[];let t=new Map(e.resources.map(e=>[e.id,e])),n=new Set(e.repositories.flatMap(e=>e.resourceIds)),r=e.repositories.map(e=>({id:e.id,name:e.name,path:e.path,repository:e,resources:e.resourceIds.flatMap(e=>t.get(e)?[t.get(e)]:[])})),i=e.resources.filter(e=>!n.has(e.id)),a=i.filter(e=>e.unavailableReason),o=i.filter(e=>!e.unavailableReason);return o.length&&r.push({id:`local`,name:`Local and built in`,reason:`Not backed by an updateable Git repository`,resources:o}),a.length&&r.push({id:`unavailable`,name:`Provenance unavailable`,reason:`The active runtime did not report enough filesystem provenance`,resources:a}),r}function ri(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)--t;return t===e.length?e:e.slice(0,t)}function ii(e){let t=ri(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<=0?`/`:t.slice(0,n)}function ai(e,t){let n=ri(t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`)),i=r>=0?n.slice(r+1):n;return`${ri(e)}/${i||`agent-resources`}`}function oi({kind:e,resources:t,removalLocked:n=!1,onRemove:r}){return(0,o.jsxs)(`section`,{className:`rounded-xl border border-zinc-200 p-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`h3`,{className:`flex items-center justify-between text-sm font-semibold capitalize text-zinc-800 dark:text-zinc-200`,children:[(0,o.jsxs)(`span`,{children:[e,`s`]}),(0,o.jsx)(`span`,{className:`text-xs font-normal text-zinc-400`,children:t.length})]}),t.length===0?(0,o.jsx)(`p`,{className:`mt-4 text-xs text-zinc-400`,children:`None in this group`}):(0,o.jsx)(`ul`,{className:`mt-3 space-y-2`,children:t.map(e=>(0,o.jsxs)(`li`,{className:`rounded-lg bg-zinc-50 px-3 py-2 dark:bg-zinc-800/70`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm font-medium text-zinc-700 dark:text-zinc-200`,children:e.name}),e.userRoot&&!n?(0,o.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.userRoot}`,onClick:()=>r(e),className:`text-xs text-zinc-500 hover:text-red-600`,children:`Remove`}):null]}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-400`,title:e.path,children:e.path??e.unavailableReason??`Path unavailable`})]},e.id))})]})}function si({preview:e,busy:t,error:n,onApply:r,onCancel:a}){let[s,c]=(0,i.useState)(()=>new Set(e.roots.filter(e=>!e.locked).map(e=>`${e.kind}:${e.path}`))),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(()=>new Set),p=e.mode===`collection`,m=(0,i.useMemo)(()=>e.skills.map(e=>({...e,state:`off`})),[e.skills]),h=(0,i.useMemo)(()=>Zr(e.skills,e.repositoryName),[e.skills,e.repositoryName]),g=e.roots.filter(e=>e.kind===`extension`&&s.has(`extension:${e.path}`)),_=g.length>0&&!l,v=t||!p&&s.size===0||_,y=()=>{let t=g.map(e=>e.path);p?r([],t,[...d]):r(e.roots.filter(e=>e.kind===`skill`&&s.has(`skill:${e.path}`)).map(e=>e.path),t)},b=e=>{u(!1),c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,o.jsxs)(`div`,{className:`space-y-3`,"data-testid":`resource-preview`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`h3`,{className:`truncate text-xl font-semibold text-zinc-900 dark:text-zinc-100`,children:e.repositoryName}),(0,o.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[11px] text-zinc-500`,title:e.repositoryPath,children:e.repositoryPath})]}),(0,o.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:v,onClick:y,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:t?`Saving…`:`Save`})]})]}),_?(0,o.jsx)(`p`,{className:`text-xs text-amber-700`,children:`Confirm the extension warning below to save.`}):null,n?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:n}):null,p?(0,o.jsx)(Yr,{skills:m,groups:h,enabled:d,onChange:f,disabled:t,...e.bound?{bound:e.bound}:{}}):null,e.roots.map(e=>{let t=`${e.kind}:${e.path}`;return(0,o.jsxs)(`label`,{className:`flex items-start gap-2 rounded border p-2 ${e.locked?`opacity-50`:`cursor-pointer`}`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:s.has(t),disabled:e.locked,onChange:()=>b(t)}),(0,o.jsxs)(`span`,{children:[(0,o.jsxs)(`span`,{className:`block text-sm`,children:[e.name,` · `,e.kind]}),(0,o.jsx)(`span`,{className:`font-mono text-[11px] text-zinc-500`,children:e.path}),e.locked?(0,o.jsx)(`span`,{className:`block text-xs text-amber-700`,children:`Extension paths are locked`}):null]})]},t)}),g.length>0?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust the selected extension roots in this repository.`})]}):null]})}function ci(e){let t=(0,i.useRef)(null),n=(0,i.useRef)(e.onClose),r=(0,i.useRef)(!1),[a,s]=(0,i.useState)(null),[c,l]=(0,i.useState)(``),[u,d]=(0,i.useState)(`all`),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)(`skill`),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)(!1),[w,ee]=(0,i.useState)(``),[T,E]=(0,i.useState)(``),[te,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(``),[A,j]=(0,i.useState)(null),[M,N]=(0,i.useState)({}),[P,ne]=(0,i.useState)(null),[F,I]=(0,i.useState)(null),L=(0,i.useMemo)(()=>ni(e.inventory),[e.inventory]),R=(0,i.useMemo)(()=>{let e=c.trim().toLocaleLowerCase();return L.flatMap(t=>{let n=`repository`in t?t.repository.collection:void 0,r=n?t.resources.filter(e=>e.kind!==`skill`):t.resources,i=u===`all`?r:r.filter(e=>e.kind===u),a=n&&u!==`extension`?n.skills:[],o=i.length+a.length;if(o===0&&!(n&&u===`all`)||f&&(!(`repository`in t)||![`updateable`,`dirty`,`failed`,`unavailable`,`busy`].includes(t.repository.assessment.status)))return[];let s=`${t.name} ${`path`in t?t.path??``:``} ${i.map(e=>`${e.name} ${e.path??``}`).join(` `)} ${a.map(e=>`${e.name} ${e.relativePath}`).join(` `)}`.toLocaleLowerCase(),c=n?n.skills.filter(e=>e.state!==`off`).length:void 0;return!e||s.includes(e)?[{...t,resources:i,count:o,...c===void 0?{}:{onCount:c}}]:[]})},[L,f,u,c]),z=R.find(e=>e.id===a)??R[0]??null;if((0,i.useEffect)(()=>{n.current=e.onClose},[e.onClose]),(0,i.useEffect)(()=>{N(t=>{let n={},r=!1;for(let[i,a]of Object.entries(t)){let t=e.inventory?.repositories.find(e=>e.id===i)?.collection;!t||$r(a,Qr(t))?r=!0:n[i]=a}return r?n:t})},[e.inventory]),(0,i.useEffect)(()=>{e.open&&t.current?.focus()},[e.open]),(0,i.useEffect)(()=>{if(!e.open)return;let t=e=>{e.key===`Escape`&&n.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.open]),(0,i.useEffect)(()=>{let t=e.operations.clonePath;t?.status===`ready`&&t.path&&!te&&E(t.path)},[te,e.operations.clonePath]),(0,i.useEffect)(()=>{e.operations.enrollment?.status===`ready`&&h(null)},[e.operations.enrollment]),(0,i.useEffect)(()=>{e.applyState?.status===`applying`?r.current=!0:r.current&&e.applyState===null&&(r.current=!1,h(null),_(null),C(!1))},[e.applyState]),!e.open)return null;let B=z&&`repository`in z?z.repository:null,V=B?e.operations.updates[B.id]:void 0,H=B?.assessment,re=H?.status===`updateable`&&H.token&&H.localRevision&&H.upstreamRevision,U=()=>{let t=b.trim();t&&(v===`skill`?e.onUpdateConfig({userSkillPaths:[...new Set([...e.userSkillPaths,t])]}):e.onUpdateConfig({userExtensionPaths:[...new Set([...e.userExtensionPaths,t])]}))},ie=t=>{t.userRoot&&(t.kind===`skill`?e.onUpdateConfig({userSkillPaths:e.userSkillPaths.filter(e=>e!==t.userRoot)}):e.onUpdateConfig({userExtensionPaths:e.userExtensionPaths.filter(e=>e!==t.userRoot)}))},ae=(t,n=!1)=>{let r=t.assessment;r.token&&r.localRevision&&r.upstreamRevision&&e.onUpdate(t.id,r.token,r.localRevision,r.upstreamRevision,n)},W=B?.collection,oe=W?Qr(W):[],se=new Set(B&&M[B.id]?M[B.id]:oe),ce=W?[...new Set([...se,...oe])].filter(e=>se.has(e)!==oe.includes(e)).length:0,G=B?e.operations.skills?.[B.id]:void 0,le=e=>{if(!B)return;let t=B.id;N(n=>{let r={...n};return $r(e,oe)?delete r[t]:r[t]=[...e],r})},ue=()=>{if(!B)return;let e=B.id;N(t=>{let n={...t};return delete n[e],n})},de=()=>{if(!B||!W)return;let t=new Set(W.skills.filter(e=>e.state!==`on-missing`).map(e=>e.relativePath));e.onSetSkills(B.id,[...se].filter(e=>t.has(e)))},fe=F?e.operations.removals?.[F.id]:void 0,pe=fe?.status===`error`||fe?.result?.status===`removed-delete-failed`;return(0,o.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/45 p-4`,role:`presentation`,onMouseDown:t=>{t.currentTarget===t.target&&e.onClose()},children:[(0,o.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`agent-resources-title`,className:`flex h-[min(760px,92vh)] w-[min(1120px,96vw)] flex-col overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-2xl dark:border-zinc-700 dark:bg-zinc-900`,children:[(0,o.jsxs)(`header`,{className:`flex items-center justify-between border-b border-zinc-200 px-5 py-4 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h2`,{id:`agent-resources-title`,className:`text-lg font-semibold text-zinc-900 dark:text-zinc-100`,children:`Agent resources`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Skills and extensions, grouped by repository`})]}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(),className:`rounded-md border px-3 py-1.5 text-xs disabled:opacity-50`,children:`Refresh all`}),(0,o.jsx)(`button`,{ref:t,type:`button`,"aria-label":`Close agent resources`,onClick:e.onClose,className:`rounded-md border px-2 py-1 text-sm`,children:`✕`})]})]}),(0,o.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[300px_1fr]`,children:[(0,o.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r border-zinc-200 bg-zinc-50/80 p-3 dark:border-zinc-800 dark:bg-zinc-950/40`,children:[(0,o.jsx)(`input`,{"aria-label":`Search resources`,value:c,onChange:e=>l(e.target.value),placeholder:`Search repositories or resources`,className:`rounded-md border bg-white px-3 py-2 text-xs dark:bg-zinc-900`}),(0,o.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[[`all`,`skill`,`extension`].map(e=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:`rounded px-2 py-1 text-[11px] ${u===e?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:e===`all`?`All`:`${e}s`},e)),(0,o.jsx)(`button`,{type:`button`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`rounded px-2 py-1 text-[11px] ${f?`bg-amber-600 text-white`:`border`}`,children:`Needs attention`})]}),(0,o.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:[R.map(e=>(0,o.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:`w-full rounded-lg px-3 py-2.5 text-left ${z?.id===e.id?`bg-white shadow-sm ring-1 ring-zinc-200 dark:bg-zinc-800 dark:ring-zinc-700`:`hover:bg-white/70 dark:hover:bg-zinc-900`}`,children:[(0,o.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-sm font-medium`,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.name}),(0,o.jsx)(`span`,{className:`shrink-0 text-xs text-zinc-400`,children:e.onCount===void 0?e.count??e.resources.length:`${e.onCount} on · ${e.count}`})]}),(0,o.jsx)(`span`,{className:`mt-1 block text-xs text-zinc-500`,children:`repository`in e?ti[e.repository.assessment.status]:e.reason})]},e.id)),R.length===0?(0,o.jsx)(`p`,{className:`px-2 py-4 text-xs text-zinc-500`,children:`No matching resources`}):null]}),(0,o.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t pt-3`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(`local`),_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border bg-white px-3 py-2 text-xs font-medium dark:bg-zinc-900`,children:`Add local folder…`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>h(`git`),className:`rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white dark:bg-zinc-100 dark:text-zinc-900`,children:`Add Git repository…`})]})]}),(0,o.jsxs)(`main`,{className:`min-w-0 overflow-y-auto p-6`,children:[F&&fe?(0,o.jsxs)(`div`,{role:pe?`alert`:`status`,className:`mb-4 flex items-start justify-between gap-3 rounded-lg border p-3 text-sm ${pe?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[(0,o.jsx)(`p`,{className:`min-w-0 break-words`,children:ei(F.name,fe)}),fe.status===`loading`?null:(0,o.jsx)(`button`,{type:`button`,onClick:()=>I(null),className:`shrink-0 text-xs underline`,children:`Dismiss`})]}):null,m===`local`?(0,o.jsxs)(`div`,{className:`max-w-xl space-y-4`,"data-testid":`add-local-folder`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add local folder`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Choose an existing folder on the server and how the agent should load it.`})]}),(0,o.jsx)(`div`,{className:`flex gap-2`,children:[`skill`,`extension`].map(t=>(0,o.jsx)(`button`,{type:`button`,"aria-pressed":v===t,disabled:t===`extension`&&e.extensionLock,onClick:()=>{y(t),C(!1)},className:`rounded-md px-3 py-1.5 text-xs ${v===t?`bg-zinc-900 text-white dark:bg-zinc-100 dark:text-zinc-900`:`border`}`,children:t===`skill`?`Skill folder`:`Extension folder`},t))}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local resource folder`,value:b,onChange:e=>{C(!1),x(e.target.value)},className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`local`),e.onBrowseServerPath(b||`/`)},className:`rounded-md border px-3 text-xs`,children:`Browse…`})]}),g===`local`?(0,o.jsx)(Nr,{label:`Choose a local resource folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{C(!1),x(t),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,v===`extension`?(0,o.jsxs)(`label`,{className:`flex gap-2 rounded-md border border-amber-300 bg-amber-50 p-3 text-xs text-amber-900`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked)}),(0,o.jsx)(`span`,{children:`Extensions execute code with the agent's privileges. I trust every extension in this folder.`})]}):null,e.extensionLock?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Extension paths are locked by this deployment.`}):null,e.applyState?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.applyState.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!b.trim()||e.applyState?.status===`applying`||v===`extension`&&(!S||e.extensionLock),onClick:U,className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.applyState?.status===`applying`?`Applying…`:`Add folder`})]})]}):m===`git`?(0,o.jsx)(`div`,{className:`max-w-2xl space-y-4`,"data-testid":`add-git-repository`,children:e.operations.preview?.status===`ready`&&e.operations.preview.preview?(0,o.jsx)(si,{onCancel:()=>{h(null),_(null),e.onCloseServerBrowser()},preview:e.operations.preview.preview,busy:e.operations.enrollment?.status===`loading`,error:e.operations.enrollment?.status===`error`?e.operations.enrollment.message:void 0,onApply:(t,n,r)=>r?e.onEnrollRepository(e.operations.preview.preview.token,t,n,r):e.onEnrollRepository(e.operations.preview.preview.token,t,n)}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Add Git repository`}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Clone it to a local folder, then choose what to turn on.`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Repository address`}),(0,o.jsx)(`input`,{"aria-label":`Repository address`,value:w,onChange:e=>ee(e.target.value),onBlur:()=>{let t=w.trim();t&&(D(!1),k(t),e.onSuggestClonePath(w))},placeholder:`https://github.com/team/resources.git`,className:`mt-1 w-full rounded-md border bg-transparent px-3 py-2 text-sm`})]}),(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium`,children:`Local folder`}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Local clone folder`,value:T,onChange:e=>{D(!0),E(e.target.value)},placeholder:`/path/to/resource-repositories/team-resources-ab12cd`,className:`min-w-0 flex-1 rounded-md border bg-transparent px-3 py-2 text-sm`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{_(`clone-parent`),e.onBrowseServerPath(ii(T))},className:`rounded-md border px-3 text-xs`,children:`Choose parent…`})]})]}),e.operations.clonePath?.status===`loading`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500`,children:`Suggesting a managed folder…`}):null,e.operations.clonePath?.status===`error`&&w.trim()===O?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.clonePath.message}):null,g===`clone-parent`?(0,o.jsx)(Nr,{label:`Choose the clone's parent folder`,browse:e.serverBrowse,onBrowse:e.onBrowseServerPath,onSelect:t=>{E(ai(t,T)),_(null),e.onCloseServerBrowser()},onCancel:()=>{_(null),e.onCloseServerBrowser()}}):null,e.operations.preview?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:e.operations.preview.message}):null,(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{h(null),_(null),e.onCloseServerBrowser()},className:`rounded-md border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,disabled:!w.trim()||!T.trim()||e.operations.preview?.status===`loading`,onClick:()=>e.onCloneRepository(w,T),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:e.operations.preview?.status===`loading`?`Cloning…`:`Clone and inspect`})]})]})}):z?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`h3`,{className:`text-xl font-semibold`,children:z.name}),B?(0,o.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[11px]`,children:ti[B.assessment.status]}):null]}),(0,o.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-zinc-500`,children:`repository`in z?z.path:z.reason}),H?.branch?(0,o.jsxs)(`p`,{className:`mt-1 text-xs text-zinc-400`,children:[H.branch,H.upstream?` → ${H.upstream}`:``]}):null,B?.removal&&!B.removal.allowed?(0,o.jsx)(`p`,{className:`mt-1 text-xs text-zinc-500`,children:B.removal.reason}):null]}),B?(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[B.removal?.allowed?(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.removals?.[B.id]?.status===`loading`,onClick:()=>ne(B),className:`rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-700 disabled:opacity-50 dark:border-red-900 dark:text-red-400`,children:`Remove repository`}):null,(0,o.jsx)(`button`,{type:`button`,disabled:e.operations.refresh?.status===`loading`,onClick:()=>e.onRefresh(B.id),className:`rounded-md border px-3 py-1.5 text-xs`,children:`Check`}),re||V?.status===`loading`?(0,o.jsx)(`button`,{type:`button`,disabled:V?.status===`loading`,onClick:()=>B.containsExtensions?j(B):ae(B),className:`rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:V?.status===`loading`?`Updating…`:`Update repository`}):null]}):null]}),H?.reason?(0,o.jsxs)(`div`,{className:`mt-5 rounded-lg border p-3 text-sm ${H.status===`dirty`?`border-rose-200 bg-rose-50 text-rose-800`:`border-zinc-200 bg-zinc-50 text-zinc-700`}`,children:[H.reason,H.status===`dirty`?(0,o.jsx)(`p`,{className:`mt-1 text-xs`,children:`Review and resolve these local changes in an external terminal, then check again. This updater never commits, stashes, discards, rebases, or merges them.`}):null]}):null,H?.hasSubmodules?(0,o.jsx)(`p`,{className:`mt-3 rounded border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800`,children:`This repository declares submodules. Their working trees will not be initialized or updated.`}):null,V?.status===`ready`?(0,o.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-zinc-600`,children:V.result?.status===`updated`&&V.result.reloads.some(e=>e.status===`restart-required`)?`Repository updated. Its skills are reloaded; its extension code runs after pi-outpost restarts — restart it from Settings.`:V.result?.status===`updated`?`Repository updated and runtimes reloaded.`:V.result?.status===`updated-reload-failed`?`Repository updated on disk, but at least one runtime failed to reload.`:V.result?.reason}):null,V?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-red-600`,children:V.message}):null,W&&B&&u!==`extension`?(0,o.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[ce>0||G?.status===`loading`?(0,o.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-sky-200 bg-sky-50 px-3 py-2 text-xs text-sky-900 dark:border-sky-900 dark:bg-sky-950/40 dark:text-sky-200`,children:[(0,o.jsx)(`span`,{children:G?.status===`loading`?`Applying…`:`${ce} pending change${ce===1?``:`s`} — applying replaces the session`}),(0,o.jsxs)(`div`,{className:`flex gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:G?.status===`loading`,onClick:ue,className:`rounded border bg-white px-2.5 py-1 disabled:opacity-50 dark:bg-zinc-900`,children:`Discard`}),(0,o.jsx)(`button`,{type:`button`,disabled:G?.status===`loading`||ce===0,onClick:de,className:`rounded bg-zinc-900 px-2.5 py-1 font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900`,children:`Apply`})]})]}):null,G?.status===`error`?(0,o.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:G.message}):null,(0,o.jsx)(Yr,{skills:W.skills,groups:W.groups,enabled:se,onChange:le,disabled:G?.status===`loading`,...W.bound?{bound:W.bound}:{}},B.id),z.resources.some(e=>e.kind===`extension`)?(0,o.jsx)(oi,{kind:`extension`,resources:z.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ie}):null]}):(0,o.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4`,children:[(0,o.jsx)(oi,{kind:`skill`,resources:z.resources.filter(e=>e.kind===`skill`),onRemove:ie}),(0,o.jsx)(oi,{kind:`extension`,resources:z.resources.filter(e=>e.kind===`extension`),removalLocked:e.extensionLock,onRemove:ie})]})]}):(0,o.jsx)(`p`,{className:`text-sm text-zinc-500`,children:`No resources are reported by this runtime.`})]})]})]}),A?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`extension-update-title`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsx)(`h3`,{id:`extension-update-title`,className:`font-semibold`,children:`Update executable extensions?`}),(0,o.jsxs)(`p`,{className:`mt-2 text-sm text-zinc-600 dark:text-zinc-300`,children:[A.name,` contains extensions that run with the agent's privileges. Confirm updating `,A.assessment.localRevision?.slice(0,8),` to `,A.assessment.upstreamRevision?.slice(0,8),`.`]}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>j(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{ae(A,!0),j(null)},className:`rounded bg-amber-600 px-3 py-1.5 text-xs font-medium text-white`,children:`Confirm executable update`})]})]})}):null,P?(0,o.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/55 p-4`,children:(0,o.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`remove-repository-title`,"aria-describedby":`remove-repository-detail`,className:`w-full max-w-md rounded-xl bg-white p-5 shadow-2xl dark:bg-zinc-900`,children:[(0,o.jsxs)(`h3`,{id:`remove-repository-title`,className:`font-semibold`,children:[`Remove `,P.name,`?`]}),(0,o.jsx)(`p`,{id:`remove-repository-detail`,className:`mt-2 break-words text-sm text-zinc-600 dark:text-zinc-300`,children:P.removal?.deletesFiles?(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,P.name,` and deletes `,(0,o.jsx)(`span`,{className:`font-mono`,children:P.removal.path}),` from disk, with any local changes in it. This cannot be undone.`]}):(0,o.jsxs)(o.Fragment,{children:[`This stops loading everything from `,P.name,`. pi-outpost does not manage `,(0,o.jsx)(`span`,{className:`font-mono`,children:P.removal?.path??P.path}),`, so its files will be kept.`]})}),(0,o.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>ne(null),className:`rounded border px-3 py-1.5 text-xs`,children:`Cancel`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{e.onRemoveRepository(P.id),I({id:P.id,name:P.name}),ne(null)},className:`rounded bg-red-600 px-3 py-1.5 text-xs font-medium text-white`,children:P.removal?.deletesFiles?`Delete and remove`:`Remove repository`})]})]})}):null]})}var li=`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`,ui=`rounded-md border border-zinc-300 px-3 py-1.5 text-xs font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`;function di({event:e}){switch(e.type){case`auth_url`:return(0,o.jsxs)(`div`,{"data-testid":`login-auth-url`,className:`space-y-1`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.instructions??`Open this page to sign in:`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`truncate text-sm text-sky-700 underline dark:text-sky-400`,children:e.url}),(0,o.jsx)(`button`,{type:`button`,className:ui,onClick:()=>void navigator.clipboard?.writeText(e.url),children:`Copy`})]})]});case`device_code`:return(0,o.jsxs)(`div`,{"data-testid":`login-device-code`,className:`space-y-1`,children:[(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[`Enter this code at`,` `,(0,o.jsx)(`a`,{href:e.verificationUri,target:`_blank`,rel:`noopener noreferrer`,className:`text-sky-700 underline dark:text-sky-400`,children:e.verificationUri}),`:`]}),(0,o.jsx)(`p`,{className:`select-all font-mono text-2xl tracking-widest text-zinc-900 dark:text-zinc-50`,children:e.userCode})]});case`info`:return(0,o.jsxs)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:[e.message,e.links?.map(e=>(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`ml-2 text-sky-700 underline dark:text-sky-400`,children:e.label??e.url},e.url))]});case`progress`:return(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:e.message})}}function fi({prompt:e,onAnswer:t}){let[n,r]=(0,i.useState)(``),a=e.type===`manual_code`&&/^http:\/\/(?:localhost|127\.0\.0\.1):1455\/auth\/callback\/?$/.test(e.placeholder??``);return e.type===`select`?(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm text-zinc-700 dark:text-zinc-200`,children:e.message}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(e=>(0,o.jsx)(`button`,{type:`button`,className:ui,title:e.description,onClick:()=>t(e.id),children:e.label},e.id))})]}):(0,o.jsxs)(`div`,{"data-testid":`login-prompt`,className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`block text-sm text-zinc-700 dark:text-zinc-200`,children:[e.type===`manual_code`?`${e.message} — or the whole address the browser was sent to`:e.message,(0,o.jsx)(`input`,{className:`${li} mt-1`,type:e.type===`secret`?`password`:`text`,name:`provider-auth-response`,placeholder:e.placeholder,autoComplete:`off`,spellCheck:e.type!==`manual_code`,autoFocus:!0,value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),n.trim()&&t(n.trim()))}})]}),a&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-300`,children:`If Pi Outpost runs on another computer, your browser may say it cannot connect to localhost. Copy the full address from that browser page and paste it above to finish signing in.`}),(0,o.jsx)(`button`,{type:`button`,className:ui,disabled:!n.trim(),onClick:()=>t(n.trim()),children:`Continue`})]})}function pi({login:e,providerName:t,onAnswer:n,onCancel:r,onDismiss:i}){return(0,o.jsxs)(`div`,{"data-testid":`login-flow`,className:`space-y-3 rounded-md border border-zinc-200 p-3 dark:border-zinc-700`,children:[(0,o.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Signing in to `,t]}),(0,o.jsxs)(`div`,{"aria-live":`polite`,"aria-atomic":`false`,children:[e.events.map((e,t)=>(0,o.jsx)(di,{event:e},t)),e.prompt&&(0,o.jsx)(fi,{prompt:e.prompt.prompt,onAnswer:n},e.prompt.promptId),!e.done&&!e.prompt&&e.events.length===0&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`Starting…`}),e.done?(0,o.jsxs)(`div`,{"data-testid":`login-done`,"data-ok":e.done.ok?`true`:`false`,className:`space-y-2`,children:[(0,o.jsx)(`p`,{className:`text-sm ${e.done.ok?`text-emerald-700 dark:text-emerald-400`:`text-red-700 dark:text-red-400`}`,children:e.done.ok?`Signed in to ${t}.`:e.done.cancelled?`Sign-in cancelled.`:`Sign-in failed: ${e.done.message??`unknown error`}`}),(0,o.jsx)(`button`,{type:`button`,className:ui,onClick:i,children:`Close`})]}):(0,o.jsx)(`button`,{type:`button`,className:ui,onClick:r,children:`Cancel`})]})]})}function mi(e){return[...e].sort((e,t)=>e.localeCompare(t))}function hi(e,t){return e===`models_json_key`?`This key is managed in models.json. Remove it from that provider configuration.`:e===`environment`?`This key comes from ${t??`the server environment`}. Remove it from there.`:`This key is managed by ${t??e??`the provider runtime`}. Remove it from that source.`}function gi(e,t){return e===`models_json_key`?`models.json`:t??e}function _i({credentials:e,login:t,onStartLogin:n,onAnswerLogin:r,onCancelLogin:a,onDismissLogin:s,onLogoutProvider:c,extensionPaths:l,configuredExtensionPaths:u,userExtensionPaths:d,extensionLock:f,piPackages:p=null,piPackageUpdate:m=null,canRestartServer:h=!1,serverRestarting:g=!1,onCheckPiPackages:_,onUpdatePiPackage:v,onRestartServer:y,onRestartSession:b,restartNeeded:x=[],tools:S,commands:C,sandbox:w,showRoots:ee=!0,gitUnavailable:T,userSkillPaths:E,serverBrowse:te,pickerBlocked:D=!1,onPickerOpened:O,applyState:k,agentResources:A=null,agentResourceOperations:j={clonePath:null,preview:null,enrollment:null,refresh:null,updates:{},skills:{},removals:{}},versions:M,onBrowseServerPath:N,onCloseServerBrowser:P,onUpdateConfig:ne,onSuggestAgentResourceClonePath:F=()=>{},onCloneAgentResourceRepository:I=()=>{},onEnrollAgentResourceRepository:L=()=>{},onSetAgentResourceSkills:R=()=>{},onRemoveAgentResourceRepository:z=()=>{},onRefreshAgentResourceRepositories:B=()=>{},onUpdateAgentResourceRepository:V=()=>{}}){let[H,re]=(0,i.useState)(!1),[U,ie]=(0,i.useState)(!1),ae=(0,i.useRef)(new Map),[W,oe]=(0,i.useState)(!1),se=(0,i.useRef)(null),[ce,G]=(0,i.useState)(``),[le,ue]=(0,i.useState)(``),[de,fe]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),[he,ge]=(0,i.useState)(null),_e=(e,r)=>{if(t&&!t.done){a?.(),s?.();let e=ae.current.get(t.provider);e&&(e.open=!1)}else n?.(e,r)};(0,i.useEffect)(()=>{D&&he!==null&&ge(null)},[D,he]);let ve=Wt(()=>{(H||he!==null)&&Ee()}),ye=S.filter(e=>e.active),be=S.filter(e=>!e.active),xe=C.filter(e=>e.source===`skill`),Se=[...S].sort((e,t)=>e.name.localeCompare(t.name)||Number(t.active)-Number(e.active)),Ce=k?.status===`applying`,we=k?.status===`error`?k.message:null;(0,i.useEffect)(()=>{w&&(G(w.root),ue(w.writableRoot??``),fe(w.allowWrite),me(w.allowBash))},[w]);let Te=(0,i.useRef)(!1);(0,i.useEffect)(()=>{Te.current&&k===null&&Ee(),Te.current=Ce},[k,Ce]);function Ee(){ie(!1),re(!1),ge(null),P()}function De(e,t){O?.(),ge(e),N(t.trim()||`/`)}function Oe(e){he===`root`?G(e):he===`writableRoot`&&ue(e),ge(null),P()}let ke=w!==null&&(ce!==w.root||(le.trim()||void 0)!==(w.writableRoot||void 0)||de!==w.allowWrite||pe!==w.allowBash);function Ae(){w&&ke&&ne({sandbox:{root:ce,allowWrite:de,allowBash:pe,writableRoot:le.trim()||void 0}})}let je=ee&&w?.rootEditable!==!1,Me=he!==null&&!D&&(0,o.jsx)(Nr,{label:he===`root`?`Choose the sandbox root`:`Choose the writable root`,browse:te,onBrowse:N,onSelect:Oe,onCancel:()=>{ge(null),P()}});return(0,o.jsxs)(`div`,{className:`relative`,ref:ve,children:[(0,o.jsx)(`button`,{ref:se,type:`button`,onClick:()=>{ie(!1),H?Ee():re(!0)},title:`Settings`,"aria-label":`Settings`,className:`${Tr} 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:`⚙`}),H&&(0,o.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,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-4 py-3 dark:border-zinc-800`,children:[U&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>ie(!1),className:`mb-2 text-xs text-zinc-600 hover:underline dark:text-zinc-400`,children:`← Back to settings`}),(0,o.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:U?`Credits`:`Settings`})]}),(0,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto p-4`,children:U?(0,o.jsx)(Ur,{}):(0,o.jsxs)(o.Fragment,{children:[T&&(0,o.jsxs)(`section`,{className:`mb-4`,"data-testid":`git-unavailable`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Version control`}),T.reason===`no-repository`?(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-400`,children:`This project is not in a git repository.`}):(0,o.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,o.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-300`,children:T.reason===`no-executable`?`Git is unavailable: its executable could not be run.`:`Git is unavailable: it refused this repository.`}),(0,o.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-amber-700 dark:text-amber-400`,children:T.message}),T.reason===`no-executable`&&(0,o.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,o.jsx)(`span`,{className:`font-mono`,children:`gitPath`}),` in the configuration.`]})]})]}),e&&(0,o.jsxs)(`details`,{className:`mb-4`,"data-testid":`accounts-panel`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:[`Accounts · `,(0,o.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:[e.providers.filter(e=>e.configured).length,` providers configured`]})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[(0,o.jsx)(`ul`,{className:`space-y-2`,children:e.providers.map(n=>(0,o.jsx)(`li`,{className:`rounded border border-zinc-200 p-2 dark:border-zinc-700`,children:(0,o.jsxs)(`details`,{ref:e=>{e?ae.current.set(n.id,e):ae.current.delete(n.id)},"data-testid":`account-${n.id}`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-zinc-800 dark:text-zinc-200`,children:n.name}),(0,o.jsx)(`span`,{className:`ml-2 text-[11px] ${n.configured?`text-emerald-700 dark:text-emerald-400`:`text-zinc-500 dark:text-zinc-400`}`,children:n.configured?`${n.auth??`Authenticated`}${n.source?` · ${gi(n.source,n.label)}`:``}`:`Not signed in`})]}),(0,o.jsxs)(`div`,{className:`mt-2`,children:[n.configured&&n.auth===`api_key`&&n.source!==`stored`&&(0,o.jsx)(`p`,{className:`mb-2 text-[11px] text-zinc-500 dark:text-zinc-400`,children:hi(n.source,n.label)}),!e.locked&&(0,o.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.methods?.includes(`oauth`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`oauth`),children:`Sign in`}),n.methods?.includes(`api_key`)&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>_e(n.id,`api_key`),children:`API key`}),n.configured&&n.source===`stored`&&(0,o.jsx)(`button`,{type:`button`,className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>c?.(n.id),children:n.auth===`api_key`?`Remove API key`:`Sign out`})]}),t?.provider===n.id&&(0,o.jsx)(`div`,{className:`mt-2`,children:(0,o.jsx)(pi,{login:t,providerName:n.name,onAnswer:e=>r?.(e),onCancel:()=>a?.(),onDismiss:()=>s?.()})})]})]})},n.id))}),e.locked&&(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-500 dark:text-zinc-400`,children:`Credentials are locked by this server.`})]})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Agent resources`}),S.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`Tool inventory unavailable for this runtime`}):(0,o.jsxs)(`details`,{"data-testid":`tools-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[ye.length,` tools active`,be.length?` · ${be.length} inactive`:``]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:Se.map(e=>(0,o.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,o.jsx)(`span`,{children:e.name}),(0,o.jsx)(`span`,{children:e.active?`active`:`inactive`})]},e.name))})]}),xe.length===0?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,children:`No skills loaded`}):(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`skills-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[xe.length,` skills loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:mi(xe.map(e=>e.name)).map(e=>(0,o.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,o.jsx)(`button`,{type:`button`,"aria-label":`Manage agent resources`,onClick:()=>{re(!1),oe(!0)},className:`mt-3 w-full rounded-md border border-zinc-300 px-3 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-800`,children:`Manage resources…`})]}),(0,o.jsxs)(`section`,{className:`mb-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Extensions`}),l===null?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-unknown`,children:`Not reported by this runtime`}):l.length===0?(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No extensions loaded`}):(0,o.jsxs)(`details`,{"data-testid":`extensions-loaded`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[l.length,` `,l.length===1?`extension`:`extensions`,` loaded`]}),(0,o.jsx)(`ul`,{className:`mt-2 space-y-1`,children:mi(l).map(e=>(0,o.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))})]}),u.length>0&&(0,o.jsxs)(`details`,{className:`mt-2`,"data-testid":`extensions-configured`,children:[(0,o.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400`,children:[u.length,` configured by this deployment`]}),(0,o.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,o.jsx)(`ul`,{className:`mt-1 space-y-1`,children:mi(u).map(e=>(0,o.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))})]}),f?(0,o.jsx)(`p`,{className:`mt-2 text-xs text-zinc-400 dark:text-zinc-500`,"data-testid":`extensions-locked`,children:`Extension paths and repository updates that contain extensions are locked by this deployment.`}):null,(0,o.jsx)(Gr,{packages:p,update:m,locked:f,onCheck:()=>_?.(),onUpdate:e=>v?.(e)}),(0,o.jsx)(Kr,{reasons:x,canRestart:h,restarting:g,onRestart:()=>y?.()})]}),w&&(0,o.jsxs)(`section`,{children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:je?`Sandbox`:`Agent permissions`}),(0,o.jsxs)(`div`,{className:`space-y-3`,children:[!je&&(0,o.jsxs)(`p`,{"data-testid":`sandbox-project-root`,className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This project is confined to its own folder,`,` `,(0,o.jsx)(`span`,{className:`break-all font-mono text-zinc-800 dark:text-zinc-200`,children:w.projectRoot??w.root}),`. Each open project is confined to its own. A change here applies to this project now, and to projects opened after.`]}),je&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Root `,w.locks?.root?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:ce,onChange:e=>G(e.target.value),disabled:w.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,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for sandbox root`,disabled:w.locks?.root,onClick:()=>De(`root`,ce),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…`})]})]}),he===`root`&&Me,(0,o.jsxs)(`label`,{className:`block`,children:[(0,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Writable root (optional) `,w.locks?.writableRoot?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]}),(0,o.jsxs)(`div`,{className:`mt-1 flex gap-2`,children:[(0,o.jsx)(`input`,{type:`text`,value:le,onChange:e=>ue(e.target.value),disabled:w.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,o.jsx)(`button`,{type:`button`,"aria-label":`Browse for writable root`,disabled:w.locks?.writableRoot,onClick:()=>De(`writableRoot`,le||ce),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…`})]})]}),he===`writableRoot`&&Me]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.target.checked),disabled:w.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,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow write `,w.locks?.allowWrite?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]}),(0,o.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:pe,onChange:e=>me(e.target.checked),disabled:w.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,o.jsxs)(`span`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`Allow bash `,w.locks?.allowBash?(0,o.jsx)(`span`,{className:`text-zinc-400`,children:`(locked)`}):null]})]})]})]}),!w&&(0,o.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-500`,children:`No sandbox configured`}),(0,o.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[we&&(0,o.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:we}),(0,o.jsx)(`button`,{type:`button`,disabled:Ce||ke&&!ce.trim(),onClick:ke?Ae:b,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:Ce?`Restarting…`:ke?`Apply & restart session`:`Restart session`}),(0,o.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-500`,children:ke?`Saved to the server's configuration file, then the session is rebuilt — the change survives a restart.`:`Start a fresh session to reload extensions and MCP connections. Settings are kept.`})]}),M&&(0,o.jsxs)(`section`,{className:`mt-4`,children:[(0,o.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-zinc-500 dark:text-zinc-400`,children:`Versions`}),(0,o.jsxs)(`div`,{className:`space-y-1 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsxs)(`p`,{children:[`pi-outpost: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:M.piOutpost})]}),M.piSdk&&(0,o.jsxs)(`p`,{children:[`pi SDK: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:M.piSdk})]}),M.agent&&(0,o.jsxs)(`p`,{children:[`agent: `,(0,o.jsx)(`span`,{className:`font-mono text-zinc-800 dark:text-zinc-200`,children:M.agent})]})]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>ie(!0),className:`mt-4 w-full border-t border-zinc-200 pt-3 text-left text-sm text-zinc-600 hover:text-zinc-900 dark:border-zinc-700 dark:text-zinc-400 dark:hover:text-zinc-100`,children:`Credits →`})]})})]}),(0,o.jsx)(ci,{open:W,inventory:A,operations:j,extensionLock:f,userSkillPaths:E,userExtensionPaths:d,serverBrowse:te,applyState:k,onClose:()=>{oe(!1),P(),se.current?.focus()},onBrowseServerPath:e=>{O?.(),N(e)},onCloseServerBrowser:P,onUpdateConfig:ne,onSuggestClonePath:F,onCloneRepository:I,onEnrollRepository:L,onSetSkills:R,onRemoveRepository:z,onRefresh:B,onUpdate:V})]})}function vi(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);else{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 yi(e){return e.flatMap(e=>[e,...yi(e.children)])}function bi({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,o.jsx)(`span`,{className:`shrink-0 rounded-full border px-1.5 py-px text-[10px] leading-4 ${n}`,children:e})}var xi=`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 Si({row:e,laneCount:t,isStreaming:n,onNavigate:r,onFork:i,onClose:a}){let{node:s}=e,c=s.tipId??s.entryId;return(0,o.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,o.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>{r(c),a()},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,o.jsx)(ur,{row:e,laneCount:t,colorOf:sr}),(0,o.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,o.jsxs)(bi,{tone:`branch`,children:[e.forkTo.length+1,` branches`]}),e.branchIndex!==void 0&&(0,o.jsxs)(bi,{tone:`branch`,children:[`branch `,e.branchIndex,s.onPath&&!e.isCurrent?` · current`:``]}),e.isCurrent&&(0,o.jsx)(bi,{tone:`current`,children:`current`}),s.label&&(0,o.jsx)(bi,{tone:`label`,children:s.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>{r(s.entryId),a()},title:`rewind to just before this message (its text comes back in the composer)`,"aria-label":`Rewind to before this message`,className:xi,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{i(s.entryId),a()},title:`fork a new session from this point`,className:xi,children:`⑂ fork`})]})}function Ci({tree:e,isStreaming:t,onListTree:n,onNavigate:r,onFork:a}){let[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),d=Wt(()=>c(!1));(0,i.useEffect)(()=>{s&&e===null&&n()},[s,e]);let f=(0,i.useMemo)(()=>e&&e.length>0?vi(e):null,[e]),p=(0,i.useMemo)(()=>{if(!e||!l.trim())return null;let t=l.trim().toLowerCase();return yi(e).filter(e=>e.text.toLowerCase().includes(t)||e.label?.toLowerCase().includes(t))},[e,l]);return(0,o.jsxs)(`div`,{className:`relative`,ref:d,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{c(!s),s||(u(``),n())},title:`conversation tree: go back to an earlier point or fork`,className:`${Tr} 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:`tree`}),s&&(0,o.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,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),e?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no messages yet`}),e&&e.length>0&&f&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-200`,children:`Conversation tree`}),(0,o.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,o.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,o.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,o.jsx)(`div`,{className:`min-h-0 overflow-y-auto py-1`,children:p===null?f.rows.map(e=>(0,o.jsx)(Si,{row:e,laneCount:f.laneCount,isStreaming:t,onNavigate:r,onFork:a,onClose:()=>c(!1)},e.node.entryId)):p.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`no matches`}):p.map(e=>(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 pr-2 hover:bg-zinc-100 dark:hover:bg-zinc-800/70`,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{r(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,o.jsx)(`span`,{"aria-hidden":!0,className:e.onPath?`text-emerald-500`:`text-zinc-300 dark:text-zinc-600`,children:`●`}),(0,o.jsx)(`span`,{className:`min-w-0 truncate text-zinc-700 dark:text-zinc-300`,children:e.text||`(empty)`}),e.onPath&&(0,o.jsx)(bi,{tone:`current`,children:`on current branch`}),e.label&&(0,o.jsx)(bi,{tone:`label`,children:e.label})]}),(0,o.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>{r(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:xi,children:`↺ redo`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>{a(e.entryId),c(!1)},title:`fork a new session from this point`,className:xi,children:`⑂ fork`})]},e.entryId))})]})]})]})}var wi=200;function Ti({initial:e,onCommit:t,onCancel:n}){let[r,a]=(0,i.useState)(e);return(0,o.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>a(e.target.value),onBlur:n,onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()},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 Ei({session:e,isCurrent:t,renaming:n,onSwitch:r,onDelete:i,onStartRename:a,onRename:s,onCancelRename:c}){return n?(0,o.jsx)(`div`,{className:`px-3 py-2`,children:(0,o.jsx)(Ti,{initial:e.name??``,onCommit:s,onCancel:c})}):(0,o.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,o.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 px-3 py-2 text-left text-sm`,children:[(0,o.jsx)(`div`,{className:`truncate text-zinc-700 dark:text-zinc-300`,children:e.name||e.firstMessage||`(empty)`}),e.snippet&&(0,o.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-zinc-500 dark:text-zinc-500`,children:e.snippet}),(0,o.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`:``,!t&&e.liveIn?(0,o.jsxs)(`span`,{"data-testid":`session-live-in`,children:[` · open in `,e.liveIn]}):null]})]}),(0,o.jsx)(`button`,{type:`button`,onClick:a,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&&!e.liveIn&&(0,o.jsx)(`button`,{type:`button`,onClick:i,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 Di({sessions:e,sessionSearch:t,sessionId:n,onSwitchSession:r,onDeleteSession:a,onListSessions:s,onRenameSession:c,onSearchSessions:l,onClearSessionSearch:u}){let[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(null),_=Wt(()=>f(!1)),v=p.trim(),y=v.length>=2;(0,i.useEffect)(()=>{if(!d)return;if(!y){u();return}let e=setTimeout(()=>l(v),wi);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,o.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>{d?b():(f(!0),m(``),g(null),u(),s())},className:`${Tr} 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:`sessions`}),d&&(0,o.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,o.jsxs)(`div`,{className:`border-b border-zinc-200 px-3 py-2 dark:border-zinc-800`,children:[(0,o.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,o.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,o.jsxs)(`div`,{className:`min-h-0 overflow-y-auto`,children:[S===null&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:`loading…`}),S?.length===0&&(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-zinc-500`,children:y?`no matches`:`no saved sessions`}),S?.map(e=>(0,o.jsx)(Ei,{session:e,isCurrent:e.id===n,renaming:h===e.path,onSwitch:()=>{r(e.path),b()},onDelete:()=>{window.confirm(`Delete this session?`)&&a(e.path)},onStartRename:()=>g(e.path),onRename:t=>{c(e.path,t),g(null),y&&l(p.trim())},onCancelRename:()=>g(null)},e.path))]})]})]})}function Oi({filters:e,onFilterChange:t}){let[n,r]=(0,i.useState)(!1),a=Wt(()=>r(!1)),s=vt(e),c=s>0?`Filter · ${s} hidden`:`Filter`;return(0,o.jsxs)(`div`,{className:`relative`,ref:a,onKeyDown:e=>{e.key===`Escape`&&n&&(e.stopPropagation(),r(!1))},children:[(0,o.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-haspopup":`menu`,"aria-expanded":n,title:`Choose what the conversation shows`,className:`${Tr} ${s>0?`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:c}),n&&(0,o.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-30 mt-1 w-48 rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:pt.map(n=>(0,o.jsxs)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":e[n],onClick:()=>t(n,!e[n]),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-zinc-600 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800`,children:[(0,o.jsx)(`span`,{"aria-hidden":!0,className:`w-3`,children:e[n]?`✓`:``}),(0,o.jsx)(`span`,{children:mt[n]})]},n))})]})}function ki({statuses:e,bar:t}){let n=Object.entries(e).filter(([,e])=>gn(e).trim()!==``),r=n.map(([e,t])=>`${e}\u0000${t}`).join(``),[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=(0,i.useRef)(null),[u,d]=(0,i.useState)(!1),f=Wt(()=>d(!1));if((0,i.useLayoutEffect)(()=>{c.current=null,s(!1),d(!1)},[r]),(0,i.useLayoutEffect)(()=>{let e=t;if(e===null)return;let n=()=>{c.current===null?(Array.from(l.current?.querySelectorAll(`[data-status-text]`)??[]).some(e=>e.scrollWidth>e.clientWidth+1)||e.scrollWidth>e.clientWidth+1)&&(c.current=e.clientWidth,s(!0)):e.clientWidth>c.current+64&&(c.current=null,s(!1),d(!1))};if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,a,r]),n.length===0)return null;if(!a)return(0,o.jsx)(`div`,{ref:l,className:`flex shrink-0 items-center gap-1.5`,children:n.map(([e,t])=>(0,o.jsx)(`span`,{title:gn(t),className:`${Tr} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,children:(0,o.jsx)(`span`,{"data-status-text":!0,className:`truncate`,children:(0,o.jsx)(_n,{text:t})})},e))});let p=`${n.length} ${n.length===1?`status`:`statuses`}`;return(0,o.jsxs)(`div`,{ref:f,className:`relative shrink-0`,onKeyDown:e=>{e.key===`Escape`&&u&&(e.stopPropagation(),d(!1))},children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),"aria-expanded":u,title:n.map(([,e])=>gn(e)).join(`
|
|
636
|
+
`),className:`${Tr} border-zinc-200 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:[p,` ▾`]}),u&&(0,o.jsx)(`ul`,{"aria-label":`Extension statuses`,className:`absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:n.map(([e,t])=>(0,o.jsx)(`li`,{className:`break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300`,children:(0,o.jsx)(_n,{text:t})},e))})]})}function Ai({theme:e,preference:t=e,onToggle:n,onSetTheme:r}){let[a,s]=(0,i.useState)(!1),c=(0,i.useRef)(null),l=Wt(()=>s(!1));(0,i.useEffect)(()=>{a&&l.current?.querySelector(`[aria-checked="true"]`)?.focus()},[a]);let u={light:`Light`,dark:`Dark`,system:`System`}[t];return(0,o.jsxs)(`div`,{ref:l,className:`relative`,onKeyDown:e=>{if(e.key===`Escape`&&(e.stopPropagation(),s(!1),c.current?.focus()),a&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)){e.preventDefault();let t=Array.from(l.current?.querySelectorAll(`[role="menuitemradio"]`)??[]),n=t.findIndex(e=>e.matches(`:focus`));t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()}},children:[(0,o.jsx)(`button`,{ref:c,type:`button`,onClick:()=>s(e=>!e),title:`Theme: ${u}`,"aria-label":`Theme: ${u}`,"aria-haspopup":`menu`,"aria-expanded":a,className:`${Tr} 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:t===`system`?`◐`:e===`dark`?`☾`:`☀`}),a&&(0,o.jsx)(`div`,{role:`menu`,"aria-label":`Theme`,className:`absolute right-0 top-full z-40 mt-2 min-w-32 rounded-lg border border-zinc-300 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900`,children:[`light`,`dark`,`system`].map(i=>(0,o.jsx)(`button`,{role:`menuitemradio`,"aria-checked":t===i,type:`button`,className:`block w-full rounded px-3 py-1.5 text-left text-xs text-zinc-700 hover:bg-zinc-100 focus:bg-zinc-100 dark:text-zinc-200 dark:hover:bg-zinc-800 dark:focus:bg-zinc-800`,onClick:()=>{r?r(i):i!==e&&n(),s(!1),c.current?.focus()},children:i===`light`?`Light`:i===`dark`?`Dark`:`System`},i))})]})}function ji(e){let{isStreaming:t,connected:n}=e,[r,a]=(0,i.useState)(null);return(0,o.jsxs)(`header`,{ref:a,className:`relative z-30 flex min-w-0 items-center gap-1.5 border-b border-zinc-200 px-4 py-2 dark:border-zinc-800`,children:[e.workspaceControl===`projects`&&(0,o.jsx)(Mr,{workspace:e.workspace,workspaces:e.workspaces,locked:e.workspaceLocked,onSwitch:e.onSwitchWorkspace,onOpen:e.onOpenProject,onClose:e.onCloseProject,onOpenSide:e.onOpenSideSession}),e.workspaceControl===`root`&&e.rootControl&&(0,o.jsx)(Fr,{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,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleSidebar,title:e.sidebarOpen?`Hide files (panel opens on the left)`:`Show files`,"aria-pressed":e.sidebarOpen,className:`${Tr} ${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,o.jsxs)(`button`,{type:`button`,onClick:e.onToggleOutcome,"aria-pressed":e.outcomeOpen,title:`Review structured workspace Outcome`,className:`${Tr} ${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,o.jsx)(Rr,{status:e.gitStatus,selected:e.gitSelectedPath,log:e.gitLog,onFetchLog:e.onFetchGitLog,onShowCommit:e.onShowCommit}),(0,o.jsx)(`span`,{title:e.title??void 0,className:`min-w-[2.25rem] shrink-[4] truncate whitespace-nowrap text-lg font-semibold leading-tight tracking-tight`,style:{color:`var(--accent, inherit)`},children:e.title??`π`}),(0,o.jsx)(ki,{statuses:e.statuses,bar:r}),(0,o.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,o.jsx)(Oi,{filters:e.filters,onFilterChange:e.onFilterChange}),e.onExportConversation&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onExportConversation,disabled:!!e.exportProgress,"aria-busy":!!e.exportProgress,title:`Save the whole conversation as one HTML file`,"aria-label":`Export the conversation as HTML`,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none border-zinc-300 text-zinc-500 hover:border-zinc-400 hover:text-zinc-700 disabled:cursor-progress disabled:opacity-60 dark:border-zinc-800 dark:text-zinc-400 dark:hover:border-zinc-600 dark:hover:text-zinc-200`,children:e.exportProgress??`↓ html`}),e.onToggleTerminal&&(0,o.jsx)(`button`,{type:`button`,onClick:e.onToggleTerminal,title:e.terminalOpen?"Close Terminal (Ctrl+`)":"Open Terminal (Ctrl+`)","aria-pressed":e.terminalOpen,className:`inline-flex h-7 shrink-0 items-center gap-1 whitespace-nowrap rounded-md border px-2 text-xs leading-none ${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,o.jsx)(Ai,{theme:e.theme,preference:e.themePreference,onSetTheme:e.onSetTheme,onToggle:e.onToggleTheme}),(0,o.jsx)(`button`,{type:`button`,onClick:e.onNewSession,title:`new session`,className:`${Tr} border-emerald-300 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,o.jsx)(Ci,{tree:e.tree,isStreaming:t,onListTree:e.onListTree,onNavigate:e.onNavigateTree,onFork:e.onForkSession}),(0,o.jsx)(Di,{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,o.jsx)(_i,{credentials:e.credentials,login:e.login,onStartLogin:e.onStartLogin,onAnswerLogin:e.onAnswerLogin,onCancelLogin:e.onCancelLogin,onDismissLogin:e.onDismissLogin,onLogoutProvider:e.onLogoutProvider,extensionPaths:e.extensionPaths,configuredExtensionPaths:e.configuredExtensionPaths,userExtensionPaths:e.userExtensionPaths,extensionLock:e.extensionLock,piPackages:e.piPackages??null,piPackageUpdate:e.piPackageUpdate??null,canRestartServer:e.canRestartServer??!1,serverRestarting:e.serverRestarting??!1,...e.onCheckPiPackages?{onCheckPiPackages:e.onCheckPiPackages}:{},...e.onUpdatePiPackage?{onUpdatePiPackage:e.onUpdatePiPackage}:{},...e.onRestartServer?{onRestartServer:e.onRestartServer}:{},restartNeeded:e.restartNeeded??[],tools:e.tools??[],commands:e.commands??[],sandbox:e.sandbox,showRoots:!(e.workspaceControl===`projects`&&e.workspaces.filter(e=>!e.sideOf).length>1),gitUnavailable:e.gitUnavailable,userSkillPaths:e.userSkillPaths,serverBrowse:e.serverBrowse,applyState:e.settingsApply,agentResources:e.agentResources,agentResourceOperations:e.agentResourceOperations,versions:e.versions,onBrowseServerPath:e.onBrowseServerPath,onCloseServerBrowser:e.onCloseServerBrowser,pickerBlocked:e.settingsPickerBlocked,onPickerOpened:e.onSettingsPickerOpened,onRestartSession:e.onRestartSession,onUpdateConfig:e.onUpdateConfig,onSuggestAgentResourceClonePath:e.onSuggestAgentResourceClonePath,onCloneAgentResourceRepository:e.onCloneAgentResourceRepository,onEnrollAgentResourceRepository:e.onEnrollAgentResourceRepository,onSetAgentResourceSkills:e.onSetAgentResourceSkills,onRemoveAgentResourceRepository:e.onRemoveAgentResourceRepository,onRefreshAgentResourceRepositories:e.onRefreshAgentResourceRepositories,onUpdateAgentResourceRepository:e.onUpdateAgentResourceRepository}),(0,o.jsx)(`span`,{className:`h-2 w-2 rounded-full ${n?`bg-emerald-500`:`bg-red-500`}`,title:n?`connected`:`disconnected`})]})]})}function Mi(e,t){let n=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{if(typeof Notification>`u`)return;let r=e.filter(e=>e.needsAttention),i=r.filter(e=>je(e)!==t);for(let e of[...n.current.keys()])r.some(t=>je(t)===e)||n.current.delete(e);if(Notification.permission===`granted`&&(typeof document>`u`||document.visibilityState!==`visible`)){for(let e of i)if(n.current.get(je(e))!==e.activity){n.current.set(je(e),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:${je(e)}`})}catch{}}}},[e,t])}var Ni={"agent-directory":`read the agent directory (the provider keys)`,"beside-root":`read a file beside the root`,"write-beside-root":`write beside the root`,"signal-process":`signal another process of the server's user`,"server-environment":`inherit the server's environment`,"server-process-environment":`read the server's process environment (/proc)`,"unlisted-host":`reach a host not in sandbox.allowedHosts`,"direct-connection":`connect around the proxy`},Pi=e=>e.map(e=>Ni[e]??e),Fi=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()};function Ii(e,t){let n=t===`shell`?`The agent's shell`:`This terminal`;switch(e.state){case`checking`:return`${n} runs under ${e.runner||`a sandbox runner`}; its confinement is being checked.`;case`verified`:return[`${n} is confined by ${e.runner}, checked at ${Fi(e.checkedAt)}. A command could not:`,...Pi(e.refused).map(e=>`• ${e}`),...e.environmentReadable?[`The server's process environment is readable, and holds no secret.`]:[],...e.notChecked.length?[`Not checked:`,...e.notChecked.map(e=>`• ${Ni[e.attempt]??e.attempt} — ${e.why}`)]:[]].join(`
|
|
637
637
|
`);case`partial`:return[`${n} is confined by ${e.runner}, checked at ${Fi(e.checkedAt)}, except one thing: a command can read the server's process environment, which holds ${e.exposed.join(`, `)}.`,`Move these out of the server's environment — provider keys belong in the agent directory.`,`A command could not:`,...Pi(e.refused).map(e=>`• ${e}`)].join(`
|
|
638
638
|
`);case`leaking`:return[`${n} is NOT confined as configured: under ${e.runner}, checked at ${Fi(e.checkedAt)}, a command could:`,...Pi(e.reached).map(e=>`• ${e}`),`The configuration is unchanged: fix the runner or its host, or stop using it.`].join(`
|
|
639
639
|
`);case`failed`:return`${n}'s confinement could not be checked (${e.runner}, ${Fi(e.checkedAt)}): ${e.reason}`}}function Li({verdict:e,surface:t,root:n}){let r=n?` to ${n}`:``,i=e.state===`verified`?{icon:`🔒`,text:`confined${r}`,tone:`bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200`}:e.state===`partial`?{icon:`🔐`,text:`partly confined`,tone:`bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200`}:e.state===`leaking`?{icon:`🔓`,text:`not confined`,tone:`bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-200`}:e.state===`failed`?{icon:`⚠`,text:`confinement unchecked`,tone:`bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200`}:{icon:`…`,text:`checking confinement`,tone:`bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300`};return(0,o.jsxs)(`span`,{"data-testid":t===`shell`?`shell-confinement`:`terminal-confined`,"data-state":e.state,title:Ii(e,t),className:`shrink-0 whitespace-nowrap rounded px-1.5 py-0.5 font-sans text-[11px] ${i.tone}`,children:[i.icon,` `,t===`shell`?`shell ${i.text}`:i.text]})}function Ri(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 zi({usage:e,analysisOpen:t,onToggleAnalysis:n}){if(e.turns===0)return null;let r=e.turns-e.unpriced,i=[`${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(` · `),a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`span`,{children:[Re(e.totalTokens),` tok`]}),r>0&&(0,o.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[Le(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,o.jsx)(`button`,{type:`button`,onClick:n,title:`${i} — 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:a}):(0,o.jsx)(`span`,{title:i,className:`${s} border-zinc-300 dark:border-zinc-800`,children:a})}function Bi({usage:e}){let t=15.9155,n=2*Math.PI*t,r=e?.percent??0,i=Math.min(100,Math.max(0,r))/100*n;return(0,o.jsxs)(`svg`,{width:18,height:18,viewBox:`0 0 36 36`,className:`-rotate-90 shrink-0`,children:[(0,o.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,o.jsx)(`circle`,{cx:`18`,cy:`18`,r:t,fill:`none`,stroke:`currentColor`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:`${i} ${n-i}`,className:Ri(e)})]})}function Vi({thinkingLevel:t,thinkingLevels:n,isStreaming:r,onSetThinking:a}){let[s,c]=(0,i.useState)(!1),l=(0,i.useRef)(null),u=t!==`off`,d=n&&n.length>0?n:e.r,f=d.indexOf(t),p=d.length>1;return(0,i.useEffect)(()=>{if(!s)return;function e(e){l.current&&!Ut(e,l.current)&&c(!1)}function t(e){e.key===`Escape`&&c(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]),(0,o.jsxs)(`div`,{className:`relative`,ref:l,children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),disabled:r,title:`thinking level`,"aria-haspopup":`true`,"aria-expanded":s,className:`flex items-center gap-1.5 rounded-md border px-2 py-1 font-mono text-xs disabled:opacity-50 ${u?`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,o.jsx)(`span`,{"aria-hidden":!0,className:`text-sm leading-none ${u?``:`opacity-40 grayscale`}`,children:`🧠`}),t]}),s&&(0,o.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,o.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between text-xs`,children:[(0,o.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`thinking`}),(0,o.jsx)(`span`,{className:`font-mono text-zinc-700 dark:text-zinc-200`,children:t})]}),p?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`input`,{type:`range`,min:0,max:d.length-1,step:1,value:f===-1?0:f,onChange:e=>a(d[Number(e.target.value)]),"aria-label":`Thinking level`,"aria-valuetext":t,className:`w-full accent-amber-500`}),(0,o.jsxs)(`div`,{className:`mt-0.5 flex justify-between font-mono text-[9px] text-zinc-400 dark:text-zinc-600`,children:[(0,o.jsx)(`span`,{children:d[0]}),(0,o.jsx)(`span`,{children:d[d.length-1]})]})]}):(0,o.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:[`this model accepts `,(0,o.jsx)(`span`,{className:`font-mono`,children:d[0]}),` only`]})]})]})}function Hi(e){let{model:t,models:n,thinkingLevel:r,modelSupportsReasoning:i,isStreaming:a,contextUsage:s,sessionUsage:c,isCompacting:l}=e;return(0,o.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,o.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:a,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,o.jsx)(`option`,{value:t,children:t}),n.map(e=>(0,o.jsxs)(`option`,{value:`${e.provider}/${e.id}`,children:[e.provider,`/`,e.id]},`${e.provider}/${e.id}`))]}),i&&(0,o.jsx)(Vi,{thinkingLevel:r,thinkingLevels:e.thinkingLevels,isStreaming:a,onSetThinking:e.onSetThinking}),e.shellConfinement&&(0,o.jsx)(`span`,{className:`ml-auto`,children:(0,o.jsx)(Li,{verdict:e.shellConfinement,surface:`shell`})}),(0,o.jsxs)(`button`,{type:`button`,onClick:e.onCompact,disabled:a||l,title:s?.tokens==null?`Click to compact the conversation context`:`${s.tokens.toLocaleString()} / ${s.contextWindow.toLocaleString()} tokens — click to compact`,className:`${e.shellConfinement?``:`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,o.jsx)(Bi,{usage:s}),l?`compacting…`:s?.percent==null?`context`:`${Math.round(s.percent)}%`]}),(0,o.jsx)(zi,{usage:c,analysisOpen:e.analysisOpen,onToggleAnalysis:e.onToggleAnalysis})]})}var Ui=`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`,Wi=`mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400`;function Gi({title:e,credentials:t,onSetCredential:n,onStartLogin:r,login:a,onAnswerLogin:s,onCancelLogin:c,onDismissLogin:l,onDeclareProvider:u,errors:d}){let f=t.providers,[p,m]=(0,i.useState)(f.length>0?`known`:`custom`),[h,g]=(0,i.useState)(f[0]?.id??``),[_,v]=(0,i.useState)(``),[y,b]=(0,i.useState)(``),[x,S]=(0,i.useState)(``),[C,w]=(0,i.useState)(``),[ee,T]=(0,i.useState)(!0),[E,te]=(0,i.useState)(!0);function D(e){a?.provider===e?(a.done||c(),l()):(a&&(a.done||c(),l()),r(e,`oauth`))}let O=f.some(e=>e.configured)&&!t.usableModel;function k(e){e.preventDefault(),!O&&(p===`known`?h&&_.trim()&&n(h,_.trim()):y.trim()&&x.trim()&&_.trim()&&C.trim()&&u({provider:y.trim(),baseUrl:x.trim(),apiKey:_.trim(),models:[C.trim()],compat:{supportsDeveloperRole:ee,supportsReasoningEffort:E}}))}return(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto p-6`,children:(0,o.jsxs)(`form`,{onSubmit:k,className:`w-full max-w-md rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),O?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`h1`,{className:`mb-3 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`No model is available.`}),(0,o.jsxs)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:[`Credentials are configured, so this is not a missing key: `,(0,o.jsx)(`code`,{children:`allowedModels`}),` in your configuration leaves nothing to choose from. Widen it, or remove it, then restart.`]})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.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,o.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,o.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`flex-1 rounded-md px-2 py-1.5 ${p===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))}),t.signIn&&f.some(e=>e.methods?.includes(`oauth`))&&(0,o.jsxs)(`section`,{className:`mb-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,"data-testid":`onboarding-account-signin`,children:[(0,o.jsx)(`h2`,{className:`mb-2 text-xs font-medium text-zinc-700 dark:text-zinc-300`,children:`Sign in with an account`}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.filter(e=>e.methods?.includes(`oauth`)).map(e=>{let t=a?.provider===e.id;return(0,o.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":`onboarding-login-flow-${e.id}`,className:`rounded border px-3 py-2 text-xs ${t?`border-sky-500 bg-sky-50 text-sky-800 dark:bg-sky-950/40 dark:text-sky-200`:``}`,onClick:()=>D(e.id),children:e.name},e.id)})}),a&&(0,o.jsx)(`div`,{id:`onboarding-login-flow-${a.provider}`,className:`mt-3`,children:(0,o.jsx)(pi,{login:a,providerName:f.find(e=>e.id===a.provider)?.name??a.provider,onAnswer:s,onCancel:c,onDismiss:l})})]}),p===`known`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`label`,{htmlFor:`onboarding-provider`,className:Wi,children:`Provider`}),(0,o.jsx)(`select`,{id:`onboarding-provider`,value:h,onChange:e=>g(e.target.value),className:`${Ui} mb-3`,children:f.map(e=>(0,o.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?` (already configured)`:``]},e.id))})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`label`,{htmlFor:`onboarding-name`,className:Wi,children:`Name`}),(0,o.jsx)(`input`,{id:`onboarding-name`,value:y,onChange:e=>b(e.target.value),placeholder:`corp`,className:`${Ui} mb-3`}),(0,o.jsx)(`label`,{htmlFor:`onboarding-url`,className:Wi,children:`Base URL`}),(0,o.jsx)(`input`,{id:`onboarding-url`,value:x,onChange:e=>S(e.target.value),placeholder:`https://llm.corp.example/v1`,className:`${Ui} mb-3`}),(0,o.jsx)(`label`,{htmlFor:`onboarding-model`,className:Wi,children:`Model id`}),(0,o.jsx)(`input`,{id:`onboarding-model`,value:C,onChange:e=>w(e.target.value),placeholder:`gpt-oss-120b`,className:`${Ui} mb-3`})]}),(0,o.jsx)(`label`,{htmlFor:`onboarding-key`,className:Wi,children:`API key`}),(0,o.jsx)(`input`,{id:`onboarding-key`,type:`password`,autoComplete:`off`,value:_,onChange:e=>v(e.target.value),placeholder:`sk-…`,className:Ui}),p===`custom`&&(0,o.jsxs)(`fieldset`,{className:`mt-4 rounded-lg border border-zinc-200 p-3 dark:border-zinc-800`,children:[(0,o.jsx)(`legend`,{className:`px-1 text-xs text-zinc-500 dark:text-zinc-400`,children:`Compatibility`}),(0,o.jsxs)(`label`,{className:`flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:ee,onChange:e=>T(e.target.checked),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[`Server understands the `,(0,o.jsx)(`code`,{children:`developer`}),` role. Uncheck for vLLM, SGLang and most corporate gateways — the system prompt is then sent as a `,(0,o.jsx)(`code`,{children:`system`}),` message.`]})]}),(0,o.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>te(e.target.checked),className:`mt-0.5`}),(0,o.jsxs)(`span`,{children:[`Server accepts `,(0,o.jsx)(`code`,{children:`reasoning_effort`}),`. Uncheck if it rejects unknown fields.`]})]})]}),(0,o.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`})]}),d.map((e,t)=>(0,o.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,o.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,o.jsx)(`code`,{children:`pi-outpost login`}),`.`]})]})})}var Ki=`application/x-pi-outpost-file`,qi=`application/x-pi-outpost-read-only-file`,Ji=`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`,Yi={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 Xi(e,t){return t?Object.keys(t).filter(t=>t.startsWith(`${e}/`)).length:0}function Zi(e){return e===`directory`||e===`symlink-directory`}function Qi(e,t){return t===void 0?!1:t===null||t!==``&&e!==t&&!e.startsWith(`${t}/`)}function $i({dir:e,depth:t,creation:n}){let[r,a]=(0,i.useState)(``),s=(0,i.useRef)(null),c=n.localError??n.serverError;return(0,i.useEffect)(()=>{s.current?.focus()},[]),(0,o.jsxs)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5`,children:[(0,o.jsx)(`input`,{ref:s,value:r,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit(e,r)):t.key===`Escape`&&(t.preventDefault(),n.cancel())},onBlur:()=>{c===null&&n.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,o.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:c})]})}function ea({path:e,name:t,depth:n,rename:r}){let[a,s]=(0,i.useState)(t),c=(0,i.useRef)(null),l=r.localError??r.serverError;return(0,i.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]),(0,o.jsxs)(`div`,{style:{paddingLeft:n*12+16},className:`py-0.5`,children:[(0,o.jsx)(`input`,{ref:c,value:a,disabled:r.pending,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!r.pending?(t.preventDefault(),r.submit(e,a)):t.key===`Escape`&&(t.preventDefault(),r.cancel())},onBlur:()=>{l===null&&r.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,o.jsx)(`p`,{className:`px-1 pt-0.5 text-xs text-red-600 dark:text-red-400`,children:l})]})}function ta({path:e,depth:t,...n}){let r=n.tree[e],i=n.creation?.openIn===e?(0,o.jsx)($i,{dir:e,depth:t,creation:n.creation}):null;return r===void 0?i:r===`loading`?(0,o.jsxs)(o.Fragment,{children:[i,(0,o.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,o.jsxs)(o.Fragment,{children:[i,(0,o.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,o.jsxs)(o.Fragment,{children:[i,i===null&&(0,o.jsx)(`div`,{style:{paddingLeft:t*12+4},className:`py-0.5 text-xs text-zinc-400 dark:text-zinc-600`,children:`empty`})]}):(0,o.jsxs)(o.Fragment,{children:[i,r.map(r=>(0,o.jsx)(na,{parentPath:e,entry:r,depth:t,...n},r.name))]})}function na({parentPath:e,entry:t,depth:n,...r}){let[a,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),u=e?`${e}/${t.name}`:t.name,d=Qi(u,r.writableRoot),f=r.fileOperation?.status===`pending`;if(Zi(t.type)){let e=!d&&!f,i=e=>e.includes(qi)?r.onCopyFile===void 0?null:`copy`:r.onMoveFile===void 0?null:`move`;return(0,o.jsxs)(`div`,{children:[(0,o.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(Ki))return;let n=i(Array.from(t.dataTransfer.types));n!==null&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n,l(!0))},onDragLeave:()=>l(!1),onDrop:t=>{if(!e)return;let n=t.dataTransfer.getData(Ki),a=n?i(Array.from(t.dataTransfer.types)):null;a!==null&&(t.preventDefault(),t.stopPropagation(),l(!1),a===`copy`?r.onCopyFile?.(n,u):r.onMoveFile?.(n,u))},children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!a;s(e),e&&r.tree[u]===void 0&&r.onExpand(u),r.onSelectDirectory?.(u)},style:{paddingLeft:n*12},className:`flex min-w-0 flex-1 items-center gap-1 rounded py-0.5 text-left`,children:[(0,o.jsx)(`span`,{className:`w-3 shrink-0 text-xs text-zinc-400 dark:text-zinc-600`,children:a?`▾`:`▸`}),(0,o.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}),!a&&Xi(u,r.gitFiles)>0&&(0,o.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:`${Xi(u,r.gitFiles)} changed file(s) inside`,children:Xi(u,r.gitFiles)})]}),r.onRevealNative&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>r.onRevealNative?.(u),title:`Show in the file manager`,"aria-label":`Show ${t.name} in the file manager`,className:Ji,children:`⌂`}),r.creation&&!d&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>{s(!0),r.tree[u]===void 0&&r.onExpand(u),r.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:`+`})]}),a&&(0,o.jsx)(ta,{path:u,depth:n+1,...r})]})}let p=u===r.openFilePath,m=r.gitFiles?.[u],h=r.attachedPaths?.includes(u)??!1,g=t.type===`file`,_=g||t.type===`symlink-file`,v=g&&!d,y=g&&(d?r.onCopyFile!==void 0:r.onMoveFile!==void 0);return r.rename?.path===u?(0,o.jsx)(ea,{path:u,name:t.name,depth:n,rename:r.rename}):(0,o.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,o.jsx)(`button`,{type:`button`,draggable:y&&!f,onDragStart:e=>{y&&!f&&(e.dataTransfer.effectAllowed=d?`copy`:`move`,e.dataTransfer.setData(Ki,u),d&&e.dataTransfer.setData(qi,`copy`))},onClick:()=>r.onSelectFile(u),style:{paddingLeft:n*12+16},className:`flex min-w-0 flex-1 items-center py-0.5 text-left`,children:(0,o.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})}),_&&r.onOpenNative&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>r.onOpenNative?.(u),title:`Open with the associated application`,"aria-label":`Open ${t.name} with the associated application`,className:Ji,children:`↗`}),r.onRevealNative&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>r.onRevealNative?.(u),title:`Show in the file manager`,"aria-label":`Show ${t.name} in the file manager`,className:Ji,children:`⌂`}),v&&r.onRenameFile&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>r.rename?.start(u),title:`Rename file`,"aria-label":`Rename ${t.name}`,className:Ji,children:`✎`}),v&&r.onDeleteFile&&(0,o.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{window.confirm(`Delete "${t.name}" permanently?`)&&r.onDeleteFile?.(u)},title:`Delete file`,"aria-label":`Delete ${t.name}`,className:`${Ji} hover:text-red-600 dark:hover:text-red-400`,children:`×`}),r.onToggleAttachPath&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>r.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,o.jsx)(`button`,{type:`button`,onClick:()=>(r.onSelectDiff??r.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 ${Yi[m].className}`,children:Yi[m].label})]})}function ra(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 ia(e){let t=ra(e);return`error`in t?t:t.kind===`directory`?{error:`That is a folder name`}:{name:t.name}}function aa(e){let[t,n]=(0,i.useState)(null),[r,a]=(0,i.useState)(null),[s,c]=(0,i.useState)(null),[l,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null),h=e.onCreateFile!==void 0||e.onCreateDirectory!==void 0,g=e.createError&&s&&e.createError.path===oa(s.dir,s.name)?e.createError.message:null,_=e.created??null;(0,i.useEffect)(()=>{s!==null&&_!==null&&_===oa(s.dir,s.name)&&(n(null),c(null),a(null))},[s,_]);let v=e.fileOperation?.status===`error`&&e.fileOperation.operation===`rename_file`&&p===e.fileOperation.path?e.fileOperation.message:null;(0,i.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:r,serverError:g,start:e=>{n(e),a(null),c(null)},cancel:()=>{n(null),a(null),c(null)},submit:(t,n)=>{let r=ra(n);if(`error`in r){a(r.error);return}a(null),c({dir:t,name:r.name});let i=oa(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=ia(n);`error`in r?f(r.error):(f(null),m(t),e.onRenameFile?.(t,r.name))}}:void 0,x=!Qi(``,e.writableRoot);return(0,o.jsxs)(`div`,{className:`text-sm`,children:[e.fileOperation?.status===`error`&&e.fileOperation.operation!==`rename_file`&&(0,o.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,o.jsxs)(`div`,{className:`mb-1 flex items-center`,children:[y&&x&&(0,o.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,o.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,o.jsx)(ta,{path:``,depth:0,...e,...y?{creation:y}:{},...b?{rename:b}:{}})]})}function oa(e,t){return e===``?t:`${e}/${t}`}function sa({tree:e,openFile:t,writableRoot:n,gitFiles:r,attachedPaths:a,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRevealNative:g,onRenameFile:_,onDeleteFile:v,onMoveFile:y,onCopyFile:b,fileOperation:x,createError:S,created:C}){let w=nr(Yn);return(0,i.useEffect)(()=>{e[``]===void 0&&s(``)},[]),(0,o.jsxs)(`aside`,{"aria-label":`Files`,style:{width:w.width},className:`relative flex shrink-0 flex-col border-r border-zinc-200 dark:border-zinc-800`,children:[(0,o.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,o.jsx)(`div`,{className:`flex-1 overflow-auto p-2`,children:(0,o.jsx)(aa,{tree:e,openFilePath:t?.path,writableRoot:n,gitFiles:r,attachedPaths:a,onExpand:s,onSelectDirectory:c,onRefresh:l,onSelectFile:u,onSelectDiff:d,onToggleAttachPath:f,onCreateFile:p,onCreateDirectory:m,onOpenNative:h,onRevealNative:g,onRenameFile:_,onDeleteFile:v,onMoveFile:y,onCopyFile:b,fileOperation:x,createError:S,created:C})}),(0,o.jsx)(rr,{label:`Resize Files sidebar`,width:w.width,config:Yn,separatorProps:w.separatorProps})]})}function ca({title:e,onSubmit:t}){let[n,r]=(0,i.useState)(``);return(0,o.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,o.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n.trim()&&t(n.trim())},className:`w-full max-w-sm rounded-xl border border-zinc-200 p-6 shadow-sm dark:border-zinc-800`,children:[(0,o.jsx)(`div`,{className:`mb-1 text-center text-3xl`,children:e??`π`}),(0,o.jsx)(`h1`,{className:`mb-4 text-center text-sm text-zinc-500 dark:text-zinc-400`,children:`This server requires an access token.`}),(0,o.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,o.jsx)(`input`,{id:`pi-outpost-token`,name:`token`,type:`password`,autoComplete:`off`,spellCheck:!1,value:n,onChange:e=>r(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,o.jsx)(`button`,{type:`submit`,disabled:!n.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,o.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,o.jsx)(`code`,{children:`?token=…`})]})]})})}var la={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`}},ua=8;function da(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 fa({plan:e,open:t,onToggle:n,onOpenWorkspace:r,requestedTaskId:a,onTaskRequestHandled:s}){let c=(0,i.useId)(),[l,u]=(0,i.useState)(!1),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null);(0,i.useEffect)(()=>{a&&(e.tasks.some(e=>e.id===a)?(f(a),m(null)):(f(null),m(a)),s?.())},[e.tasks,a,s]),(0,i.useEffect)(()=>{d!==null&&!e.tasks.some(e=>e.id===d)&&f(null)},[e,d]),(0,i.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,i.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,i.useMemo)(()=>new Map(e.tasks.map(e=>[e.id,e])),[e.tasks]),_=(0,i.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,ua)},[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=la[e.status];return[(0,o.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,o.jsx)(`span`,{className:`mt-px w-4 shrink-0 text-center font-semibold ${n.className}`,"aria-label":n.label,children:n.icon}),(0,o.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,o.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,o.jsxs)(`header`,{className:`border-b border-zinc-200 px-3 py-3 dark:border-zinc-800`,children:[(0,o.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-zinc-500`,children:`Work Plan`}),(0,o.jsx)(`h2`,{className:`truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:e.title})]}),(0,o.jsx)(`button`,{type:`button`,onClick:n,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,o.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-500`,children:[`Progress: `,y,` / `,e.tasks.length]}),(0,o.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-800`,"aria-hidden":!0,children:(0,o.jsx)(`div`,{className:`h-full bg-emerald-500`,style:{width:`${e.tasks.length===0?0:y/e.tasks.length*100}%`}})})]}),(0,o.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,o.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,o.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,o.jsx)(`div`,{className:`font-semibold ${la[v.status].className}`,children:la[v.status].label}),(0,o.jsx)(`h3`,{className:`mt-1 text-sm font-semibold text-zinc-900 dark:text-zinc-100`,children:v.title}),v.description&&(0,o.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-zinc-600 dark:text-zinc-300`,children:v.description}),v.statusReason&&(0,o.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,o.jsxs)(`div`,{className:`mt-3`,children:[(0,o.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),` `,v.dependsOn.map(e=>g.get(e)?.title??e).join(`, `)]}),v.resources.length>0&&(0,o.jsxs)(`div`,{className:`mt-3 space-y-1`,children:[(0,o.jsx)(`div`,{className:`font-semibold`,children:`Resources`}),v.resources.map(e=>{let t=da(e),n=e.label??e.uri;return t===null?/^https?:/i.test(e.uri)?(0,o.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,o.jsx)(`span`,{className:`block truncate text-zinc-500`,title:`No navigator is available for this resource`,children:n},e.uri):(0,o.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-blue-600 hover:underline dark:text-blue-400`,onClick:()=>r(t),children:n},e.uri)})]})]})]}):(0,o.jsxs)(`div`,{className:`absolute right-3 top-3 z-20`,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocusCapture:()=>u(!0),onBlurCapture:()=>u(!1),children:[(0,o.jsxs)(`button`,{type:`button`,onClick:()=>{u(!1),n()},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,o.jsx)(`div`,{id:c,role:`tooltip`,className:`absolute right-0 top-full w-72 pt-2 ${l?`block`:`hidden`}`,children:(0,o.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,o.jsx)(`ul`,{className:`space-y-1`,children:_.map(({task:e,depth:t})=>(0,o.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5 text-xs`,style:{paddingLeft:`${t*.75}rem`},children:[(0,o.jsx)(`span`,{"aria-label":la[e.status].label,className:`shrink-0 font-semibold ${la[e.status].className}`,children:e.status===`done`?`☑`:`☐`}),(0,o.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,o.jsxs)(`div`,{className:`mt-1 text-[11px] text-zinc-500`,children:[`+`,e.tasks.length-_.length,` more`]})]})})]})}var pa=Object.defineProperty,ma=Object.getOwnPropertyDescriptor,ha=(e,t)=>{for(var n in t)pa(e,n,{get:t[n],enumerable:!0})},ga=(e,t,n,r)=>{for(var i=r>1?void 0:r?ma(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&&pa(t,n,i),i},K=(e,t)=>(n,r)=>t(n,r,e),_a=`Terminal input`,va={get:()=>_a,set:e=>_a=e},ya=`Too much output to announce, navigate to rows manually to read`,ba={get:()=>ya,set:e=>ya=e};function xa(e){return e.replace(/\r?\n/g,`\r`)}function Sa(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Ca(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function wa(e,t,n,r){e.stopPropagation(),e.clipboardData&&Ta(e.clipboardData.getData(`text/plain`),t,n,r)}function Ta(e,t,n,r){e=xa(e),e=Sa(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Ea(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 Da(e,t,n,r,i){Ea(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Oa(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ka(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 Aa=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)}else i!==65279&&(t[r++]=i)}return r}},ja=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||(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}},Ma=``,Na=` `,Pa=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Fa}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}},Fa=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}},Ia=class e extends Pa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Fa,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?Oa(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()]}},La=`di$target`,Ra=`di$dependencies`,za=new Map;function Ba(e){return e[Ra]||[]}function Va(e){if(za.has(e))return za.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ha(t,e,r)};return t._id=e,za.set(e,t),t}function Ha(e,t,n){t[La]===t?t[Ra].push({id:e,index:n}):(t[Ra]=[{id:e,index:n}],t[La]=t)}var Ua=Va(`BufferService`),Wa=Va(`CoreMouseService`),Ga=Va(`CoreService`),Ka=Va(`CharsetService`),qa=Va(`InstantiationService`),Ja=Va(`LogService`),Ya=Va(`OptionsService`),Xa=Va(`OscLinkService`),Za=Va(`UnicodeService`),Qa=Va(`DecorationService`),$a=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 Ia,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):eo(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)}};$a=ga([K(0,Ua),K(1,Ya),K(2,Xa)],$a);function eo(e,t){if(confirm(`Do you want to navigate to ${t}?
|
package/dist/pi-outpost-embed.js
CHANGED
|
@@ -2739,8 +2739,8 @@ function ar(e) {
|
|
|
2739
2739
|
return e.replace(nr, "");
|
|
2740
2740
|
}
|
|
2741
2741
|
//#endregion
|
|
2742
|
-
//#region ../ui/src/components/
|
|
2743
|
-
function or({
|
|
2742
|
+
//#region ../ui/src/components/AnsiText.tsx
|
|
2743
|
+
function or({ text: e }) {
|
|
2744
2744
|
let t = ir(e);
|
|
2745
2745
|
return /* @__PURE__ */ V(B, { children: t.map((e, t) => /* @__PURE__ */ V("span", {
|
|
2746
2746
|
style: {
|
|
@@ -2753,13 +2753,15 @@ function or({ line: e }) {
|
|
|
2753
2753
|
children: e.text
|
|
2754
2754
|
}, t)) });
|
|
2755
2755
|
}
|
|
2756
|
+
//#endregion
|
|
2757
|
+
//#region ../ui/src/components/ExtensionWidgets.tsx
|
|
2756
2758
|
function sr({ widgets: e, placement: t }) {
|
|
2757
2759
|
let n = Object.entries(e).filter(([, e]) => e.placement === t);
|
|
2758
2760
|
return n.length === 0 ? null : /* @__PURE__ */ V("div", {
|
|
2759
2761
|
className: "mb-2 flex flex-col gap-1",
|
|
2760
2762
|
children: n.map(([e, t]) => /* @__PURE__ */ V("div", {
|
|
2761
2763
|
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",
|
|
2762
|
-
children: t.lines.map((e, t) => /* @__PURE__ */ V("div", { children: /* @__PURE__ */ V(or, {
|
|
2764
|
+
children: t.lines.map((e, t) => /* @__PURE__ */ V("div", { children: /* @__PURE__ */ V(or, { text: e }) }, t))
|
|
2763
2765
|
}, e))
|
|
2764
2766
|
});
|
|
2765
2767
|
}
|
|
@@ -7435,7 +7437,7 @@ function _a({ filters: e, onFilterChange: t }) {
|
|
|
7435
7437
|
});
|
|
7436
7438
|
}
|
|
7437
7439
|
function va({ statuses: e, bar: t }) {
|
|
7438
|
-
let n = Object.entries(e).
|
|
7440
|
+
let n = Object.entries(e).filter(([, e]) => ar(e).trim() !== ""), r = n.map(([e, t]) => `${e}\u0000${t}`).join(""), [i, a] = z(!1), o = R(null), s = R(null), [c, l] = z(!1), u = Pn(() => l(!1));
|
|
7439
7441
|
if (F(() => {
|
|
7440
7442
|
o.current = null, a(!1), l(!1);
|
|
7441
7443
|
}, [r]), F(() => {
|
|
@@ -7456,12 +7458,12 @@ function va({ statuses: e, bar: t }) {
|
|
|
7456
7458
|
ref: s,
|
|
7457
7459
|
className: "flex shrink-0 items-center gap-1.5",
|
|
7458
7460
|
children: n.map(([e, t]) => /* @__PURE__ */ V("span", {
|
|
7459
|
-
title: t,
|
|
7461
|
+
title: ar(t),
|
|
7460
7462
|
className: `${mi} max-w-[16rem] border-zinc-200 text-zinc-500 dark:border-zinc-800 dark:text-zinc-400`,
|
|
7461
7463
|
children: /* @__PURE__ */ V("span", {
|
|
7462
7464
|
"data-status-text": !0,
|
|
7463
7465
|
className: "truncate",
|
|
7464
|
-
children: t
|
|
7466
|
+
children: /* @__PURE__ */ V(or, { text: t })
|
|
7465
7467
|
})
|
|
7466
7468
|
}, e))
|
|
7467
7469
|
});
|
|
@@ -7476,7 +7478,7 @@ function va({ statuses: e, bar: t }) {
|
|
|
7476
7478
|
type: "button",
|
|
7477
7479
|
onClick: () => l(!c),
|
|
7478
7480
|
"aria-expanded": c,
|
|
7479
|
-
title: n.map(([, e]) => e).join("\n"),
|
|
7481
|
+
title: n.map(([, e]) => ar(e)).join("\n"),
|
|
7480
7482
|
className: `${mi} border-zinc-200 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`,
|
|
7481
7483
|
children: [d, " ▾"]
|
|
7482
7484
|
}), c && /* @__PURE__ */ V("ul", {
|
|
@@ -7484,7 +7486,7 @@ function va({ statuses: e, bar: t }) {
|
|
|
7484
7486
|
className: "absolute left-0 top-full z-20 mt-1 w-max max-w-[24rem] rounded-md border border-zinc-200 bg-white py-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-900",
|
|
7485
7487
|
children: n.map(([e, t]) => /* @__PURE__ */ V("li", {
|
|
7486
7488
|
className: "break-words px-3 py-1.5 text-xs text-zinc-600 dark:text-zinc-300",
|
|
7487
|
-
children: t
|
|
7489
|
+
children: /* @__PURE__ */ V(or, { text: t })
|
|
7488
7490
|
}, e))
|
|
7489
7491
|
})]
|
|
7490
7492
|
});
|