opencode-webui 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{index-DmEJZk-g.js → index-BBldSR-0.js} +2 -2
- package/dist/assets/{report-mXoOsBOG.js → report-Yer97DOV.js} +1 -1
- package/dist/assets/runtime-status-DDyLoT2y.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/index.ts +13 -2
- package/skills/webui/SKILL.md +7 -7
- package/dist/assets/runtime-status-CnqERypy.js +0 -1
|
@@ -100,7 +100,7 @@ Error generating stack: `+e.message+`
|
|
|
100
100
|
`):[];for(let e of t)e in i.current||(i.current[e]=gF);for(let e of Object.keys(i.current))t.includes(e)||delete i.current[e];if(t.length===0){r({});return}let n=Date.now(),o=setInterval(()=>{let a=Date.now(),o=a-n;if(n=a,typeof document<`u`&&document.hidden)return;let s={},c=[];for(let e of t){let t=Math.max(0,(i.current[e]??gF)-o);i.current[e]=t,s[e]=gF-t,t===0&&c.push(e)}r(s);for(let t of c)G_(e,t)},_F);return()=>clearInterval(o)},[a,e]),n}function SF({sessionID:e}){let t=J(t=>t.runNotices[e]);bF(!!t&&t.length>0);let n=xF(e,t);return!t||t.length===0?null:(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-1 pt-2`,children:(0,R.jsx)(`div`,{className:`mx-auto flex max-h-32 max-w-3xl flex-col gap-1 overflow-y-auto`,children:t.map(t=>{let r=vF[t.kind],i=Math.min(100,(n[t.id]??0)/gF*100);return(0,R.jsxs)(`div`,{className:`relative flex items-start gap-2 rounded-md border-l-2 py-1 pl-2.5 pr-2 pb-1.5 text-xs text-[var(--text-base)] ${r.rowClass}`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 ${r.iconClass}`,children:r.icon}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:r.labelClass,children:r.label}),`: `,t.text]}),(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[var(--text-weaker)]`,children:yF(t.at)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>G_(e,t.id),title:`Dismiss`,className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:`✕`}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-[2px] opacity-40 ${r.barClass}`,style:{width:`${i}%`}})]},t.id)})})})}function CF({sessionID:e}){let t=J(t=>t.sendErrors[e]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(SF,{sessionID:e}),t?(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-start gap-2 rounded-md border-l-2 border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)] py-1.5 pl-2.5 pr-2 text-xs text-[var(--text-base)]`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-[color:var(--surface-warning-strong)]`,children:`⚠`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--surface-critical-strong)]`,children:t.type}),`: `,t.message]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>vy(e),title:`Dismiss`,className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:`✕`})]})}):null]})}function wF({sessionID:e,onNavigate:t}){let n=J(t=>Ov(t.sessions,e)),r=J(e=>e.running),i=J(e=>e.activeIDs),[a,o]=(0,E.useState)(()=>{try{return localStorage.getItem(`webui.subagentStripCollapsed`)!==`1`}catch{return!1}}),s=e=>t?t(e):void Pv(e);if(n.length===0)return null;let c=n.filter(e=>r[e.id]||i.includes(e.id)).length;return(0,R.jsxs)(`div`,{className:`border-b border-[color:var(--border-weak-base)] px-4 py-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>{o(e=>{let t=!e;try{localStorage.setItem(`webui.subagentStripCollapsed`,t?`0`:`1`)}catch{}return t})},className:`flex cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 text-[11px] text-[color:var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`,title:`Subagent sessions of this session`,children:[a?(0,R.jsx)(I,{className:`size-3`}):(0,R.jsx)(L,{className:`size-3`}),(0,R.jsxs)(`span`,{className:`font-medium`,children:[`Subagents (`,n.length,`)`]}),c>0&&(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-[color:var(--surface-brand-base)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-brand-base)]`}),c,` running`]})]}),a&&(0,R.jsx)(`div`,{className:`mt-0.5 mb-1 flex flex-col gap-0.5`,children:n.map(e=>(0,R.jsx)(TF,{id:e.id,title:e.title,agent:e.agent,running:!!r[e.id]||i.includes(e.id),onOpen:()=>s(e.id)},e.id))})]})}function TF({id:e,title:t,agent:n,running:r,onOpen:i}){let[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(``),l=()=>{let t=s.trim();t&&(ey(e,t),c(``),o(!1))};return(0,R.jsxs)(`div`,{className:`rounded-md px-1 py-0.5 transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-[color:var(--surface-success-strong)]`:`bg-[color:var(--border-base)]`}`,title:r?`Running`:`Idle`}),(0,R.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 cursor-pointer truncate text-left text-xs text-[color:var(--text-weak)] hover:text-[color:var(--text-strong)]`,title:`Open ${t??e}`,children:[n&&t?`${n} — ${t}`:t||n||`subagent`,(0,R.jsx)(`span`,{className:`ml-2 hidden font-mono text-[10px] text-[color:var(--text-weaker)] sm:inline`,children:e.slice(0,12)})]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:()=>{o(e=>!e),c(``)},title:a?`Cancel`:`Message this subagent`,children:[(0,R.jsx)(Ne,{}),`Message`]}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:i,title:`Open session`,children:`Open`})]}),a&&(0,R.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(e.preventDefault(),o(!1))},placeholder:`message this subagent… (enter to send)`,className:`mt-1 w-full rounded-md border border-[color:var(--border-base)] bg-[color:var(--input-base)] px-2 py-1 font-mono text-xs text-[color:var(--text-strong)] outline-none placeholder:text-[color:var(--text-weaker)] focus:border-[color:var(--border-selected)]`})]})}var EF=`webui.theme`,DF=`oc-theme`,OF=[{id:`opencode`,label:`Opencode`,vars:{}},{id:`catppuccin`,label:`Catppuccin`,vars:{"--background-base":`#1e1e2e`,"--surface-float-base":`#181825`,"--background-weak":`#11111b`,"--text-strong":`#cdd6f4`,"--text-weak":`#9399b2`,"--border-selected":`#89b4fa`,"--surface-brand-base":`#f5c2e7`,"--surface-success-strong":`#a6e3a1`,"--surface-critical-strong":`#f38ba8`,"--surface-warning-strong":`#f9e2af`,"--surface-info-strong":`#94e2d5`}},{id:`nord`,label:`Nord`,vars:{"--background-base":`#2e3440`,"--surface-float-base":`#3b4252`,"--background-weak":`#434c5e`,"--text-strong":`#eceff4`,"--text-weak":`#8b95a7`,"--border-selected":`#88c0d0`,"--surface-brand-base":`#8fbcbb`,"--surface-success-strong":`#a3be8c`,"--surface-critical-strong":`#bf616a`,"--surface-warning-strong":`#d08770`,"--surface-info-strong":`#88c0d0`}},{id:`tokyonight`,label:`Tokyo Night`,vars:{"--background-base":`#1a1b26`,"--surface-float-base":`#1e2030`,"--background-weak":`#222436`,"--text-strong":`#c8d3f5`,"--text-weak":`#828bb8`,"--border-selected":`#82aaff`,"--surface-brand-base":`#ff966c`,"--surface-success-strong":`#c3e88d`,"--surface-critical-strong":`#ff757f`,"--surface-warning-strong":`#ffc777`,"--surface-info-strong":`#82aaff`}},{id:`dracula`,label:`Dracula`,vars:{"--background-base":`#282a36`,"--surface-float-base":`#21222c`,"--background-weak":`#44475a`,"--text-strong":`#f8f8f2`,"--text-weak":`#6272a4`,"--border-selected":`#bd93f9`,"--surface-brand-base":`#8be9fd`,"--surface-success-strong":`#50fa7b`,"--surface-critical-strong":`#ff5555`,"--surface-warning-strong":`#f1fa8c`,"--surface-info-strong":`#ffb86c`}},{id:`gruvbox`,label:`Gruvbox`,vars:{"--background-base":`#282828`,"--surface-float-base":`#3c3836`,"--background-weak":`#504945`,"--text-strong":`#ebdbb2`,"--text-weak":`#928374`,"--border-selected":`#83a598`,"--surface-brand-base":`#8ec07c`,"--surface-success-strong":`#b8bb26`,"--surface-critical-strong":`#fb4934`,"--surface-warning-strong":`#fe8019`,"--surface-info-strong":`#fabd2f`}},{id:`github`,label:`GitHub`,vars:{"--background-base":`#0d1117`,"--surface-float-base":`#010409`,"--background-weak":`#161b22`,"--text-strong":`#c9d1d9`,"--text-weak":`#8b949e`,"--border-selected":`#58a6ff`,"--surface-brand-base":`#39c5cf`,"--surface-success-strong":`#3fb950`,"--surface-critical-strong":`#f85149`,"--surface-warning-strong":`#e3b341`,"--surface-info-strong":`#d29922`}}];function kF(){let e=localStorage.getItem(EF);return OF.find(t=>t.id===e)??OF[0]}function AF(e){let t=OF.find(t=>t.id===e)??OF[0],n=document.getElementById(DF);n||(n=document.createElement(`style`),n.id=DF,document.head.appendChild(n));let r=Object.entries(t.vars);return n.textContent=r.length>0?`:root:root {\n ${r.map(([e,t])=>`${e}: ${t};`).join(`
|
|
101
101
|
`)}\n}`:``,localStorage.setItem(EF,t.id),t}AF(kF().id);function jF(){let[e,t]=(0,E.useState)(kF().id),n=J(e=>e.uiSignals.themes),[r,i]=(0,E.useState)(!1);(0,E.useEffect)(()=>{n&&i(!0)},[n]);let a=OF.find(t=>t.id===e)?.label??OF[0].label;return(0,R.jsxs)(_C,{open:r,onOpenChange:i,children:[(0,R.jsx)(vC,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(Pe,{}),a]})}),(0,R.jsx)(yC,{align:`end`,className:`min-w-40`,children:OF.map(n=>(0,R.jsxs)(bC,{className:`justify-between`,onSelect:()=>t(AF(n.id).id),children:[(0,R.jsx)(`span`,{children:n.label}),n.id===e&&(0,R.jsx)(ae,{className:`size-3.5`})]},n.id))})]})}function MF({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`skeleton`,className:V(`animate-pulse rounded-md bg-muted`,e),...t})}function NF(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function PF(e){let t=NF(e.directory??e.canonical);return t&&t!==`/`?t:e.id}function FF({sessionID:e}){let t=J(t=>t.sessions.find(t=>t.id===e)),[n,r]=(0,E.useState)(null),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)([]),[c,l]=(0,E.useState)(!1),u=t?.location.directory??n?.directory;function d(){l(!0),Promise.all([G.locationInfo(),G.projectCurrent(),G.projectList()]).then(([e,t,n])=>{r(e),a(t),s(n)}).catch(()=>void 0).finally(()=>l(!1))}return(0,R.jsxs)(_C,{onOpenChange:e=>e&&d(),children:[(0,R.jsx)(vC,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,title:u,className:`max-w-44 text-xs text-muted-foreground`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:u||`workspace`})]})}),(0,R.jsxs)(yC,{align:`end`,className:`min-w-56`,children:[(0,R.jsx)(xC,{children:`Location`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1 text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(Ee,{className:`size-3.5 shrink-0 text-[var(--text-weak)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs`,children:n?.directory??u??`…`})]}),n?.workspaceID&&(0,R.jsx)(`div`,{className:`px-1.5 pb-1 font-mono text-[11px] text-[var(--text-weaker)]`,children:n.workspaceID}),(0,R.jsx)(SC,{}),(0,R.jsx)(xC,{children:`Project`}),c&&o.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-1.5 py-1`,children:[(0,R.jsx)(MF,{className:`h-6 w-full`}),(0,R.jsx)(MF,{className:`h-6 w-full`}),(0,R.jsx)(MF,{className:`h-6 w-3/4`})]}):o.length===0?(0,R.jsx)(`div`,{className:`px-1.5 py-1 text-xs text-[var(--text-weaker)]`,children:`No projects`}):o.map(e=>{let t=i?.id===e.id;return(0,R.jsxs)(bC,{className:`justify-between font-mono text-xs`,onSelect:e=>e.preventDefault(),children:[(0,R.jsx)(`span`,{className:`truncate`,children:PF(e)}),t&&(0,R.jsx)(ae,{className:`size-3.5 text-[var(--text-interactive-base)]`})]},e.id)})]})]})}function IF({sessionID:e,paneKey:t=`main`,focused:n=!0,onClose:r,onNavigate:i}){let a=e=>i?i(e):void Pv(e),o=J(t=>t.sessions.find(t=>t.id===e)??t.sessionDetails[e]),s=J(t=>t.messages[e]??[]),c=J(t=>t.live.filter(t=>t.sessionID===e)),l=J(t=>t.running[e]??!1),u=J(t=>!!t.queued[e]),d=J(e=>e.runsPanelOpen),f=J(e=>e.subagentComposerOpen),p=J(t=>n?Sg(t).some(t=>t.req.sessionID===e):!1),m=J(t=>jv(t,e)),h=(0,E.useMemo)(()=>Av(s,m),[s,m]);(0,E.useEffect)(()=>{Qg(e)},[e]);let g=J(e=>e.highlightMessageID),_=J(e=>e.highlightSessionID);return(0,E.useEffect)(()=>{if(!g||_!==e)return;let t=0,n=()=>{let e=document.getElementById(`msg-${g}`);return e?(e.scrollIntoView({behavior:`smooth`,block:`center`}),e.classList.add(`ring-2`,`ring-[var(--border-selected)]`,`rounded-md`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-[var(--border-selected)]`,`rounded-md`),2e3),!0):!1};if(n())return;let r=setInterval(()=>{t+=1,(n()||t>20)&&clearInterval(r)},150);return()=>clearInterval(r)},[e,g,_,h]),(0,R.jsxs)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(KF,{title:o?.title,sessionID:e,running:l,queued:u,parentID:o?.parentID,go:a,onClose:r}),!Eg(e)&&(0,R.jsx)(wF,{sessionID:e,onNavigate:i}),(0,R.jsx)(Nt,{region:`transcript.above`,sessionID:e}),(0,R.jsx)(bx,{defaultScrollPosition:`end`,autoScroll:!0,children:(0,R.jsxs)(`div`,{className:`relative flex flex-1 flex-col overflow-hidden`,children:[(0,R.jsxs)(xx,{className:`flex-1`,children:[(0,R.jsx)(Sx,{children:(0,R.jsx)(UF,{sessionID:e,messages:h,live:c,running:l})}),(0,R.jsx)(Tx,{direction:`end`}),(0,R.jsx)(LF,{sessionID:e,messages:h})]}),(0,R.jsx)(JF,{messages:s})]})}),(0,R.jsx)(Nt,{region:`transcript.below`,sessionID:e}),(0,R.jsx)(CF,{sessionID:e}),(0,R.jsx)(uF,{sessionID:e}),n?p?(0,R.jsx)(nF,{sessionID:e}):d?(0,R.jsx)(pF,{sessionID:e,paneKey:t}):o?.parentID&&!f?(0,R.jsx)(RF,{sessionID:e,parentID:o.parentID,go:a}):(0,R.jsx)(Nt,{region:`composer.replace`,sessionID:e,fallback:(0,R.jsx)(HC,{sessionID:e,paneKey:t})}):(0,R.jsx)(Nt,{region:`composer.replace`,sessionID:e,fallback:(0,R.jsx)(HC,{sessionID:e,paneKey:t})})]})}function LF({sessionID:e,messages:t}){let{scrollToEnd:n}=fx(),r=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let i=t[t.length-1],a=i?.id??null,o=r.current;r.current={sessionID:e,id:a},!(!o||o.sessionID!==e||o.id===a)&&i?.type===`user`&&n({behavior:`smooth`})},[e,t,n]),null}function RF({sessionID:e,parentID:t,go:n}){let r=J(e=>e.sessions),i=J(e=>e.running),a=J(e=>e.activeIDs),o=J(e=>e.sessions.find(e=>e.id===t)?.title??e.sessionDetails[t]?.title),s=e=>i[e]||a.includes(e),c=[...Ov(r,t)].sort((e,t)=>e.id<t.id?-1:1);return(0,R.jsx)(`div`,{className:`border-t border-[var(--border-base)] px-4 py-1.5`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-1`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-0.5`,children:c.map(t=>(0,R.jsx)(zF,{id:t.id,label:t.title||t.agent||t.id,current:t.id===e,running:s(t.id),go:n},t.id))}),(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ev(),className:`cursor-pointer rounded-md border border-dashed border-[var(--border-weak-base)] px-1.5 py-0.5 font-mono transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,title:`Show the message composer`,children:`enter`}),(0,R.jsx)(`span`,{children:`to message this subagent`}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(t),title:`Back to parent${o?`: ${o}`:``}`,className:`flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(P,{className:`size-3`}),`back to parent`]}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsx)(`span`,{className:`font-mono text-[10px]`,children:`←/→ switch`})]})]})})}function zF({id:e,label:t,current:n,running:r,go:i}){let a=(0,E.useRef)(null);return(0,E.useEffect)(()=>{n&&a.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n]),(0,R.jsxs)(`button`,{ref:a,type:`button`,onClick:()=>i(e),title:n?`Currently open — ←/→ to switch`:t,className:`flex cursor-pointer items-center gap-1 rounded-full px-1.5 py-0.5 font-mono text-[11px] transition-colors ${n?`bg-[color:var(--surface-raised-base-active)] font-medium text-[color:var(--text-strong)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-emerald-500`:`bg-[color:var(--border-base)]`}`}),(0,R.jsx)(`span`,{className:`max-w-44 truncate`,children:t})]})}function BF(e,t){let n=[],r=e=>n.push(String(e));for(let t of e)if(r(t.id),t.type===`assistant`){r(t.content.length),r(t.finish??``);for(let e of t.content)e.type===`tool`?(r(`t${e.id}:${e.state.status}`),e.state.status===`streaming`?r(e.state.input.length):(r(VF(e.state.input)),`metadata`in e.state&&r(VF(e.state.metadata)),`content`in e.state&&e.state.content&&r(e.state.content.length),e.state.status===`error`&&r(VF(e.state.error)))):r(`${e.type}:${e.text.length}`)}else`text`in t&&typeof t.text==`string`?(r(t.text.length),`files`in t&&t.files&&r(t.files.length)):r(VF(t));for(let e of t){r(`live:${e.id}:${e.content.length}`),r(e.error?`${e.error.type}:${VF(e.error.message)}`:``);for(let t of e.content)t.type===`tool`?r(`t${t.tool.id}:${t.tool.status}:${+!!t.tool.executed}:${VF(t.tool.inputText)}:${VF(t.tool.metadata)}:${t.tool.content?.length??0}:${t.tool.error?VF(t.tool.error.message):0}`):r(`${t.type}:${t.ordinal}:${t.text.length}`)}return n.join(`|`)}function VF(e){if(e==null)return 0;if(typeof e==`string`)return e.length;try{return JSON.stringify(e)?.length??0}catch{return-1}}function HF(e,t){return e.sessionID===t.sessionID&&e.running===t.running&&BF(e.messages,e.live)===BF(t.messages,t.live)}var UF=E.memo(function({sessionID:e,messages:t,live:n,running:r}){return(0,R.jsxs)(Cx,{className:`mx-auto w-full max-w-3xl px-4 py-6`,children:[t.length===0&&n.length===0&&!r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wx,{children:(0,R.jsx)(WF,{})}),(0,R.jsx)(Nt,{region:`transcript.empty`,sessionID:e})]}),(()=>{let i=!1,a=[];for(let n of t){let t=n.type===`assistant`,r=t&&i;i=t,a.push((0,R.jsx)(wx,{messageId:n.id,id:`msg-${n.id}`,children:(0,R.jsx)(MP,{message:n,compact:r,sessionID:e})},n.id))}return n.length>0&&a.push((0,R.jsx)(wx,{children:(0,R.jsx)(qF,{assistants:n,running:r})},`live`)),a})()]})},HF);function WF(){return(0,R.jsx)(`div`,{className:`flex justify-center pt-16`,children:(0,R.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-1.5 rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-weak)] px-8 py-10 text-center`,children:[(0,R.jsx)(`h1`,{className:`text-[var(--font-size-large)] font-medium text-[var(--text-base)]`,children:`Start a conversation`}),(0,R.jsx)(`p`,{className:`text-[var(--font-size-base)] text-[var(--text-weaker)]`,children:`The agent can read, edit, and run commands in the session workspace.`})]})})}function GF(e){return e.replace(/\/+$/,``).replace(/^\/(home|Users)\/[^/]+/,`~`)}function KF({title:e,sessionID:t,running:n,queued:r,parentID:i,go:a,onClose:o}){let s=J(e=>e.sessionDetails[i??``]?.title),c=Eg(t),l=J(e=>e.draftWorkspace);return(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border-base)] px-4 py-2.5`,children:[(0,R.jsx)(Nt,{region:`header.session.before`,sessionID:t}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>a(i),title:`Back to parent session${s?`: ${s}`:``}`,className:`cursor-pointer rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:`↑ Parent`}),(0,R.jsx)(`button`,{type:`button`,className:`mr-1 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)] lg:hidden`,onClick:()=>o?o():a(null),children:`←`}),(0,R.jsx)(`span`,{className:`truncate text-[var(--font-size-base)] font-medium text-[var(--text-strong)]`,children:c?`New session`:e??`Untitled session`}),c?(0,R.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-[var(--text-weaker)] sm:inline`,children:l?GF(l):`default workspace`}):(0,R.jsx)(`span`,{className:`hidden font-mono text-xs text-[var(--text-weaker)] sm:inline`,children:t.slice(0,12)}),r&&!n&&(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-warning-weak)] text-[var(--surface-warning-strong)]`,title:`Message sent — waiting for the agent to start responding`,children:`waiting`}),n&&(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-interactive-weak)] text-[var(--text-interactive-base)]`,children:`working`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Nt,{region:`header.session.actions`,sessionID:t}),o&&(0,R.jsx)(`button`,{type:`button`,onClick:o,title:`Close split`,className:`flex size-6 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-3.5`})}),(0,R.jsx)(FF,{sessionID:t}),(0,R.jsx)(jF,{}),(0,R.jsx)(CC,{sessionID:t})]})]})}function qF({assistants:e,running:t}){let n=e.flatMap(e=>e.content.map(t=>({key:YF(e.id,t),part:t}))),r=e.filter(e=>e.error).map(e=>({id:e.id,error:e.error}));return n.length===0&&!t&&r.length===0?null:(0,R.jsxs)(`div`,{children:[r.map(({id:e,error:t})=>(0,R.jsxs)(`div`,{className:`mb-2 rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_40%,transparent)] bg-[var(--surface-critical-weak)] px-3 py-2 text-xs text-[var(--text-on-critical-strong)]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.type}),(0,R.jsx)(`div`,{className:`mt-0.5`,children:t.message})]},e)),n.length===0&&t&&r.length===0&&(0,R.jsx)(`div`,{className:`flex items-center gap-2 py-1 text-[var(--font-size-base)] text-[var(--text-weak)] animate-pulse`,children:`thinking…`}),n.map(({key:e,part:t})=>(0,R.jsx)(KP,{stateKey:e,part:t.type===`tool`?A_(t.tool):t},e))]})}function JF({messages:e}){let t=(0,E.useMemo)(()=>e.filter(e=>e.type===`user`),[e]),[n,r]=(0,E.useState)(null);if((0,E.useEffect)(()=>{if(t.length===0)return;let e=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>t.intersectionRatio-e.intersectionRatio);if(t[0]?.target){let e=t[0].target.id.replace(/^msg-/,``);r(e)}},{root:null,rootMargin:`-30% 0px -60% 0px`,threshold:[0,.25,.5,1]}),n=[];for(let r of t){let t=document.getElementById(`msg-${r.id}`);t&&(e.observe(t),n.push(t))}return()=>{for(let t of n)e.unobserve(t);e.disconnect()}},[t]),t.length<3)return null;let i=e=>{let t=document.getElementById(`msg-${e}`);if(t)t.scrollIntoView({behavior:`smooth`,block:`start`});else try{let t=`[data-message-id="${CSS.escape(e)}"]`;document.querySelector(t)?.scrollIntoView({behavior:`smooth`,block:`start`})}catch{}};return(0,R.jsx)(`div`,{className:`pointer-events-none absolute top-1/2 right-3 hidden -translate-y-1/2 flex-col items-center justify-center md:flex`,style:{maxHeight:`min(70vh, 560px)`},children:(0,R.jsxs)(`div`,{className:`pointer-events-auto flex flex-col items-center gap-2 rounded-full border border-[var(--border-weak-base)] bg-[var(--background-base)]/95 px-2 py-3 shadow-md backdrop-blur`,children:[(0,R.jsx)(`div`,{className:`absolute inset-y-3 w-px bg-[var(--border-weak-base)]`}),t.map(e=>{let t=(e.text??``).replace(/\s+/g,` `).slice(0,400)||e.id.slice(0,8),r=e.id===n;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:t,className:`group relative flex size-4 items-center justify-center`,children:[(0,R.jsx)(`span`,{className:`rounded-full ring-1 transition-all ${r?`size-3 bg-[var(--surface-brand-base)] ring-[var(--surface-brand-base)] shadow-sm`:`size-2 bg-[var(--text-weaker)] ring-[var(--border-weak-base)] group-hover:size-2.5 group-hover:bg-[var(--text-strong)]`}`}),(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-full mr-4 hidden max-w-[560px] whitespace-pre-wrap rounded-xl border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] px-4 py-3 text-sm leading-relaxed text-[var(--text-weak)] shadow-xl group-hover:block`,children:t})]},e.id)})]})})}function YF(e,t){return t.type===`tool`?`${e}:tool:${t.tool.id}`:`${e}:${t.type}:${t.ordinal}`}var XF=[[`Enter`,`Send · queue while the agent works`],[`Esc`,`Interrupt the running agent`],[`Tab / Shift+Tab`,`Next / previous agent`],[`↑ / ↓ (input at start/end)`,`Prompt history`],[`↓ (outside input)`,`Subagents & shells dialog`],[`← / → (outside input)`,`Cycle subagent sessions`],[`↑ (outside input)`,`Parent session`],[`Ctrl+B`,`Background synchronous subagents`],[`Ctrl+P`,`Command palette`],[`Ctrl+N`,`New session`],[`⌘F / Ctrl+F`,`Search sessions`],[`/`,`Slash commands & skills`],[`@`,`Reference files`],[`!`,`Shell mode`]];function ZF(){let e=J(e=>e.uiSignals.help),[t,n]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{e&&n(!0)},[e]),(0,R.jsx)(Km,{open:t,onOpenChange:n,children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/40`}),(0,R.jsxs)(fs,{className:`fixed top-1/2 left-1/2 z-50 max-h-[80vh] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 shadow-xl outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95`,children:[(0,R.jsx)(eh,{className:`mb-3 text-sm font-medium text-[var(--text-strong)]`,children:`Keybinds`}),(0,R.jsx)(`dl`,{className:`space-y-1.5 text-xs`,children:XF.map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`dt`,{className:`shrink-0 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--text-base)]`,children:e}),(0,R.jsx)(`dd`,{className:`text-right text-[var(--text-weak)]`,children:t})]},e))})]})]})})}var QF=300,$F=4,eI=40,tI=new Map;function nI(e){switch(e.type){case`user`:case`system`:case`synthetic`:case`skill`:return e.text??``;case`shell`:return e.command??``;case`compaction`:return e.summary??``;case`assistant`:{let t=``;for(let n of e.content??[])n?.type===`text`&&(t+=n.text+`
|
|
102
102
|
`);return t}default:return``}}function rI(e,t,n){let r=e.toLowerCase().indexOf(t);if(r===-1)return null;let i=Math.max(0,r-eI),a=Math.min(e.length,r+n+eI),o=e.slice(i,a).replace(/\s+/g,` `),s=o.toLowerCase().indexOf(t),c=s===-1?r-i:s,l=c+n;c<0&&(c=0),l>o.length&&(l=o.length);let u=i>0?`… `:``,d=a<e.length?` …`:``;return u&&(o=u+o,c+=u.length,l+=u.length),d&&(o+=d),{snippet:o,matchStart:c,matchEnd:l}}async function iI(e){try{let t=(await G.messages(e,100)).data.map(e=>{let t=nI(e);return t?{id:e.id,text:t,lower:t.toLowerCase()}:null}).filter(e=>!!e),n=t.map(e=>e.lower).join(`
|
|
103
|
-
`);tI.set(e,{messages:t,combinedLower:n})}catch{tI.set(e,{messages:[],combinedLower:``})}}function aI(e){let t=new Map,n=e.length;for(let[r,i]of tI){if(!i.combinedLower.includes(e))continue;let a=[];for(let t of i.messages){if(!t.lower.includes(e))continue;let r=rI(t.text,e,n);r&&a.push({messageID:t.id,snippet:r.snippet,matchStart:r.matchStart,matchEnd:r.matchEnd})}a.length>0&&t.set(r,a)}return t}function oI(e,t,n){let r=e.trim().toLowerCase();if(!r)return Promise.resolve(new Map);let i=[...t].sort((e,t)=>t.time.updated-e.time.updated).slice(0,QF).map(e=>e.id).filter(e=>!tI.has(e));return(async()=>{for(let e=0;e<i.length;e+=$F){let t=i.slice(e,e+$F);await Promise.all(t.map(iI)),n?.(aI(r))}return aI(r)})()}var sI=/mac|iphone|ipad|ipod/i.test(typeof navigator>`u`?``:navigator.userAgent),cI=sI?`⌘F`:`Ctrl F`;function lI({...e}){return(0,R.jsx)(es,{"data-slot":`sheet`,...e})}function uI({...e}){return(0,R.jsx)(os,{"data-slot":`sheet-portal`,...e})}function dI({className:e,...t}){return(0,R.jsx)(cs,{"data-slot":`sheet-overlay`,className:V(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function fI({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(uI,{children:[(0,R.jsx)(dI,{}),(0,R.jsxs)(fs,{"data-slot":`sheet-content`,"data-side":n,className:V(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,R.jsx)(xs,{"data-slot":`sheet-close`,asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function pI({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:V(`flex flex-col gap-0.5 p-4`,e),...t})}function mI({className:e,...t}){return(0,R.jsx)(_s,{"data-slot":`sheet-title`,className:V(`font-heading text-base font-medium text-foreground`,e),...t})}function hI({className:e,...t}){return(0,R.jsx)(ys,{"data-slot":`sheet-description`,className:V(`text-sm text-muted-foreground`,e),...t})}var gI=e=>e.replace(/\/+$/,``),_I=e=>gI(e).split(`/`).filter(Boolean).pop()??e,vI=e=>e instanceof Error?e.message:String(e);function yI(e,t){let n=gI(e.replace(/^\.\//,``)),r=gI(t.replace(/^\.\//,``));return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function bI(e){return[...e].sort((e,t)=>e.type===t.type?gI(e.path).localeCompare(gI(t.path)):e.type===`directory`?-1:1)}function xI(e){let t=e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,n=`size-3.5 shrink-0 text-[var(--text-weaker)]`;return[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`,`avif`].includes(t)?(0,R.jsx)(be,{className:n}):[`json`,`jsonc`,`yaml`,`yml`,`toml`].includes(t)?(0,R.jsx)(_e,{className:n}):[`zip`,`tar`,`gz`,`tgz`,`bz2`,`xz`,`7z`].includes(t)?(0,R.jsx)(ge,{className:n}):[`txt`,`log`,`csv`,`tsv`,`ini`,`env`,`conf`,`lock`,`gitignore`].includes(t)?(0,R.jsx)(Se,{className:n}):`ts.tsx.js.jsx.mjs.cjs.go.rs.py.rb.java.c.h.hpp.cc.cpp.css.scss.html.vue.svelte.sh.bash.zsh.sql.graphql.gql.md.mdx.zig`.split(`.`).includes(t)?(0,R.jsx)(ye,{className:n}):(0,R.jsx)(Ce,{className:n})}function SI({entry:e,depth:t,nodes:n,selectedPath:r,onToggle:i,onOpen:a}){let o=e.type===`directory`,s=gI(e.path),c=n[s],l=_I(e.path),u=r===s,d=6+t*13,f=()=>o?i(e):a(e);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:f,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},className:V(`flex cursor-pointer items-center gap-1 rounded-sm py-[3px] pr-2`,u?`bg-[var(--surface-raised-base)] text-[var(--text-strong)]`:`text-[var(--text-base)] hover:bg-[var(--surface-base-hover)]`),style:{paddingLeft:d},children:[o?(0,R.jsx)(L,{className:V(`size-3 shrink-0 text-[var(--text-weaker)] transition-transform`,c?.expanded&&`rotate-90`)}):(0,R.jsx)(`span`,{className:`w-3 shrink-0`}),o?(0,R.jsx)(Ee,{className:V(`size-3.5 shrink-0`,c?.expanded?`text-[var(--text-interactive-base)]`:`text-[var(--text-weak)]`)}):xI(l),(0,R.jsx)(`span`,{className:V(`truncate font-mono text-xs`,o?`text-[var(--text-strong)]`:`text-[var(--text-base)]`),children:l}),c?.loading&&(0,R.jsx)(Me,{className:`ml-auto size-3 shrink-0 animate-spin text-[var(--text-weaker)]`}),c?.error&&(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-[var(--text-on-critical-base)]`,children:`!`})]}),o&&c?.expanded&&(0,R.jsx)(`div`,{children:c.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 py-1`,style:{paddingLeft:d+13},children:[(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-1/2`})]}):c.error?(0,R.jsx)(`div`,{className:`py-1 text-[11px] text-[var(--text-on-critical-base)]`,style:{paddingLeft:d+13},children:c.error}):c.children&&c.children.length===0?(0,R.jsx)(`div`,{className:`py-0.5 text-[11px] italic text-[var(--text-weaker)]`,style:{paddingLeft:d+13},children:`empty`}):c.children?.map(e=>(0,R.jsx)(SI,{entry:e,depth:t+1,nodes:n,selectedPath:r,onToggle:i,onOpen:a},gI(e.path)))})]})}function CI({count:e,error:t}){return t?(0,R.jsx)(Dx,{variant:`outline`,title:t,className:`border-border/50 text-[var(--text-weaker)]`,children:`vcs n/a`}):e===null?null:e===0?(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`clean`}):(0,R.jsxs)(Dx,{className:`border-transparent bg-[var(--surface-critical-base)] text-[var(--text-on-critical-base)]`,children:[e,` changed`]})}function wI({open:e,onOpenChange:t}){let n=J(e=>e.sessions.find(t=>t.id===e.currentSessionID)?.location?.directory),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),[l,u]=(0,E.useState)({}),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)({loading:!1}),[h,g]=(0,E.useState)({loading:!1}),[_,v]=(0,E.useState)(null),[y,b]=(0,E.useState)(null),x=(0,E.useRef)(null),S=(0,E.useRef)(null);(0,E.useEffect)(()=>{if(!e)return;let t=!1,r=e=>{t||(S.current!==e&&(S.current=e,o(null),c(null),u({}),v(null),b(null),f(null),x.current=null),i(e),G.fsList({location:e}).then(e=>{t||(o(e.data),c(null))}).catch(e=>{t||c(vI(e))}),G.vcsStatus({directory:e}).then(e=>{t||v(e.data.length)}).catch(e=>{t||b(vI(e))}))};return n?r(n):G.location().then(e=>{t||r(e.directory)}).catch(e=>{t||c(vI(e))}),()=>{t=!0}},[e,n]),(0,E.useEffect)(()=>{e||(f(null),x.current=null,m({loading:!1}),g({loading:!1}))},[e]);let C=e=>{let t=gI(e.path),n=l[t];if(n?.expanded){u(e=>{let n={...e};return delete n[t],n});return}u(e=>({...e,[t]:{expanded:!0,loading:!e[t]?.children,children:e[t]?.children}})),n?.children||G.fsList({location:r??void 0,path:t}).then(e=>u(n=>n[t]?{...n,[t]:{...n[t],children:e.data,loading:!1}}:n)).catch(e=>u(n=>n[t]?{...n,[t]:{...n[t],error:vI(e),loading:!1}}:n))},w=e=>{x.current=e,f(e),m({loading:!0}),g({loading:!0}),G.fsRead(e.path,r??void 0).then(t=>{x.current?.path===e.path&&m({content:t,loading:!1})}).catch(t=>{x.current?.path===e.path&&m({error:vI(t),loading:!1})}),G.vcsBase(r?{directory:r}:void 0).then(e=>e.data).catch(()=>null).then(e=>G.vcsDiff(`working`,r?{directory:r}:void 0,3,e?.ref??null)).then(t=>{if(x.current?.path!==e.path)return;let n=t.data.find(t=>yI(t.file,e.path));g({patch:n?.patch,loading:!1})}).catch(t=>{x.current?.path===e.path&&g({error:vI(t),loading:!1})})};return(0,R.jsx)(lI,{open:e,onOpenChange:t,children:(0,R.jsxs)(fI,{side:`left`,className:`w-[min(44rem,calc(100vw-0.5rem))]! gap-0 p-0 sm:max-w-[44rem]!`,children:[(0,R.jsxs)(pI,{className:`border-b border-border px-4 py-3 pr-12`,children:[(0,R.jsxs)(mI,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(Te,{className:`size-4 text-[var(--text-weak)]`}),`Files`,(0,R.jsx)(CI,{count:_,error:y})]}),r&&(0,R.jsx)(hI,{className:`truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:r})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex w-[40%] min-w-56 shrink-0 flex-col border-r border-border`,children:(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`div`,{className:`p-1.5`,children:s?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-on-critical-base)]`,children:s}):a===null?(0,R.jsx)(`div`,{className:`space-y-1.5 p-1`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(MF,{className:`h-4 w-full`},e))}):a.length===0?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-weak)]`,children:`Empty directory`}):bI(a).map(e=>(0,R.jsx)(SI,{entry:e,depth:0,nodes:l,selectedPath:d?gI(d.path):null,onToggle:C,onOpen:w},gI(e.path)))})})}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:d?(0,R.jsxs)(Xx,{defaultValue:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:d.path}),(0,R.jsxs)(Qx,{variant:`line`,className:`h-6 shrink-0`,children:[(0,R.jsx)($x,{value:`preview`,className:`text-xs`,children:`Preview`}),(0,R.jsx)($x,{value:`diff`,className:`text-xs`,children:`Diff`})]})]}),(0,R.jsx)(eS,{value:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:p.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-2/3`}),(0,R.jsx)(MF,{className:`h-3 w-5/6`}),(0,R.jsx)(MF,{className:`h-3 w-1/2`})]}):p.error?(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:p.error}):(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`pre`,{className:`p-3 font-mono text-xs leading-[1.6] whitespace-pre text-[var(--text-base)]`,children:p.content??``})})}),(0,R.jsx)(eS,{value:`diff`,className:`flex min-h-0 flex-1 flex-col`,children:h.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(MF,{className:`h-3 w-11/12`}),(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-2/3`}),(0,R.jsx)(MF,{className:`h-3 w-5/6`})]}):h.error?(0,R.jsxs)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:[`Diff unavailable: `,h.error]}):h.patch?(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(MN,{diff:h.patch,className:`p-3`})}):(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-weak)]`,children:`No uncommitted changes for this file.`})})]}):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-xs text-[var(--text-weak)]`,children:`Select a file to preview`})})]})]})})}var TI=3,EI=20,DI=2,OI=`webui:navigate`,kI=288,AI=240,jI=480,MI=56,NI=0,PI=new Set,FI=!1;function II(){FI||(FI=!0,pt(()=>{NI++;for(let e of PI)e()}))}function LI(e){return II(),PI.add(e),()=>PI.delete(e)}function RI(){return NI}function zI(){return 0}function BI(){return(0,E.useSyncExternalStore)(LI,RI,zI)}function VI({sessionID:e,children:t}){let n=BI(),r=(0,E.useMemo)(()=>Ot(`session`),[n]);return r.length===0?(0,R.jsx)(R.Fragment,{children:t}):(0,R.jsxs)(mP,{children:[(0,R.jsx)(hP,{asChild:!0,children:t}),(0,R.jsx)(gP,{className:`min-w-36`,children:r.map(t=>(0,R.jsx)(_P,{onSelect:()=>{try{t.run({sessionID:e})}catch(e){console.error(`[extensions] contextMenu "${t.id}" crashed:`,e)}},children:t.label},t.id))})]})}function HI(e){return/^\/home\/[^/]+$/.test(e)||/^\/Users\/[^/]+$/.test(e)}function UI(e){let t=new Map;for(let n of e){if(!n)continue;let e=n.replace(/\/+$/,``);HI(e)&&t.set(e,(t.get(e)??0)+1)}let n,r=0;for(let[e,i]of t)i>r&&(n=e,r=i);return n}function WI(e,t){if(!e)return`Other`;let n=e.replace(/\/+$/,``);return t&&HI(t)&&n===t?`~`:t&&HI(t)&&n.startsWith(t+`/`)?`~/`+n.slice(t.length+1):n}function GI(e,t){return!!e&&!!t&&e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function KI(){let e=J(e=>e.sessions),t=J(e=>e.sessionsCursor),n=J(e=>e.activeIDs),r=J(e=>e.currentSessionID),i=J(e=>e.connected),a=J(e=>e.pendingWorkspace),o=J(e=>e.running),s=J(e=>e.queued),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)([]),[f,p]=(0,E.useState)(new Map),[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(new Set),v=(0,E.useRef)(null),[y,b]=(0,E.useState)({}),[x,S]=(0,E.useState)({}),[C,w]=(0,E.useState)(!1),[T,D]=(0,E.useState)(kI),[O,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(!1),M=J(e=>e.uiSignals.explorer);(0,E.useEffect)(()=>{M&&j(!0)},[M]);let N=(0,E.useMemo)(()=>UI(e.map(e=>e.location?.directory)),[e]),ee=e=>!!o[e]||!!s[e],te=(0,E.useMemo)(()=>{let t=new Set;for(let n of e)n.parentID&&ee(n.id)&&t.add(n.parentID);return t},[e,o,s]),P=c.trim(),F=P.toLowerCase();(0,E.useEffect)(()=>{if(P.length<2){d([]);return}let e=!1,t=setTimeout(()=>{G.listSessions({search:P,limit:100}).then(t=>{e||d(t.data.filter(e=>!e.parentID))}).catch(()=>{e||d([])})},250);return()=>{e=!0,clearTimeout(t)}},[P]),(0,E.useEffect)(()=>{if(P.length<2){p(new Map),h(!1);return}let t=!1;h(!0);let n=setTimeout(()=>{oI(P,e,e=>{t||p(new Map(e))}).catch(()=>new Map).then(e=>{t||(p(new Map(e)),h(!1))})},250);return()=>{t=!0,clearTimeout(n)}},[P,e]),(0,E.useEffect)(()=>{if(!a)return;let e=e=>{v.current&&!v.current.contains(e.target)&&Gy(null)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[a]);let ne=(0,E.useMemo)(()=>{let t=new Map,r=new Set;for(let n of e){if(n.parentID||F&&!(n.title??`Untitled session`).toLowerCase().includes(F)&&!WI(n.location?.directory,N).toLowerCase().includes(F)&&!(n.location?.directory??``).toLowerCase().includes(F))continue;r.add(n.id);let e=WI(n.location?.directory,N),i=t.get(e)??[];i.push(n),t.set(e,i)}for(let e of u){if(r.has(e.id))continue;r.add(e.id);let n=WI(e.location?.directory,N),i=t.get(n)??[];i.push(e),t.set(n,i)}let i=e=>!!(o[e]||n.includes(e)),a=[...t.entries()].map(([e,t])=>({name:e,list:[...t].sort((e,t)=>{let n=i(e.id),r=i(t.id);return n===r?t.time.updated-e.time.updated:Number(r)-Number(n)})}));return a.sort((e,n)=>{let r=t.get(e.name)?.some(e=>i(e.id))??!1,a=t.get(n.name)?.some(e=>i(e.id))??!1;return r===a?0:Number(a)-Number(r)}),a},[e,u,F,N,o,n]),re=(0,E.useMemo)(()=>{if(!F||f.size===0)return[];let t=new Set(ne.flatMap(e=>e.list.map(e=>e.id))),n=new Map(e.map(e=>[e.id,e])),r=[];for(let e of f.keys()){if(t.has(e))continue;let i=n.get(e);i&&r.push(i)}return r.sort((e,t)=>t.time.updated-e.time.updated).slice(0,EI)},[e,ne,f,F]),ie=ne.reduce((e,t)=>e+t.list.length,0)+re.length,ae=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},L=(e,t)=>{Ky(e,t),Pv(e)},oe=t!=null,se=e=>{let t=!x[e];S(n=>({...n,[e]:t})),t&&b(t=>({...t,[e]:!1}))},ce=e=>{let t=e??null;Gy(t),r===`__draft__`&&Wy(t)},le=e=>b(t=>({...t,[e]:!t[e]})),ue=e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),k(!0))},de=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&D(Math.min(jI,Math.max(AI,e.clientX)))},fe=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),k(!1)},pe=()=>w(e=>!e);return(0,R.jsxs)(`aside`,{ref:v,className:`relative flex min-w-0 shrink-0 flex-col overflow-hidden border-r border-border bg-background ${O?`select-none`:``}`,style:{width:C?MI:T},children:[(0,R.jsxs)(`div`,{className:`border-b border-border ${C?`flex flex-col items-center gap-2 px-2 py-2.5`:`flex items-center justify-between gap-2 px-3 py-2.5`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${i?`bg-[var(--surface-success-strong)]`:`bg-[var(--surface-warning-strong)]`}`}),C?(0,R.jsx)(`span`,{className:`font-mono text-xs font-semibold text-foreground`,title:`OpenCode`,children:`OC`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:`OpenCode`}),(0,R.jsx)(qI,{})]})]}),C?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(JI,{collapsed:!0}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Expand sidebar`,children:(0,R.jsx)(Ie,{})})]}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Collapse sidebar`,children:(0,R.jsx)(Fe,{})}),(0,R.jsx)(JI,{})]})]}),C?(0,R.jsx)(YI,{groups:ne,current:r,activeIDs:n,onExpand:pe}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`border-b border-border p-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(qe,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(nh,{id:`session-search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search sessions`,className:`h-7 pl-7 ${sI?`pr-8`:`pr-12`}`}),(0,R.jsx)(`kbd`,{"aria-hidden":!0,title:`Focus session search (${sI?`Cmd+F`:`Ctrl+F`})`,className:`pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1 py-px font-mono text-[9px] leading-[1.4] text-[var(--text-weaker)]`,children:cI})]}),P.length>=DI&&(0,R.jsxs)(`p`,{className:`mt-1 px-1 text-[10px] text-[var(--text-weaker)]`,"aria-live":`polite`,children:[ie,` matched`,m?` · searching messages…`:``]})]}),(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`w-full min-w-0 max-w-full p-2`,children:[re.length>0&&(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex min-w-0 items-center gap-2 border-b border-[var(--border-weak-base)] px-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-medium tracking-wide text-[var(--text-weaker)] uppercase`,children:`Content matches`}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:re.length})]}),re.map(e=>{let t=f.get(e.id)??[],i=g.has(e.id);return(0,R.jsxs)(`div`,{className:`mb-1`,children:[(0,R.jsx)(tL,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:n.includes(e.id),selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),t.length>0&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${i?`-rotate-90`:``}`}),t.length,` `,t.length===1?`message`:`messages`,` match`,t.length===1?``:`es`]}),!i&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[t.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),t.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,t.length-5,` more in this session`]})]})]})]},e.id)})]}),ne.length===0&&re.length===0&&(0,R.jsx)(`p`,{className:`px-2.5 py-4 text-xs text-[var(--text-weak)]`,children:e.length===0?`No sessions yet.`:`No matches.`}),ne.map(e=>{let t=!!x[e.name],i=!!y[e.name],o=t?[]:i?e.list:e.list.filter((e,t)=>t<TI||ee(e.id)),s=e.list.length-o.length,c=e.list.find(e=>e.location?.directory)?.location?.directory??null,l=!!a&&!!c&&GI(a,c);return(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{onClick:()=>l?se(e.name):ce(c??void 0),"aria-pressed":l,title:l?`Collapse / expand workspace`:`New session here`,className:`mb-1 flex min-w-0 cursor-pointer select-none items-center gap-2 border-b px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide transition-colors ${l?`ring-1 ring-inset ring-[var(--border-selected)] bg-[var(--surface-raised-base)]`:``} ${l?``:`border-[var(--border-weak-base)]`}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate ${l?`text-[var(--text-weak)]`:`text-[var(--text-weaker)]`}`,children:e.name}),(0,R.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand ${e.name}`:`Collapse ${e.name}`,onClick:t=>{t.stopPropagation(),se(e.name)},title:t?`Expand workspace`:`Collapse workspace`,className:`ml-auto inline-flex shrink-0 cursor-pointer items-center justify-center rounded-sm p-0.5 hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:(0,R.jsx)(I,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${t?`-rotate-90`:``}`})}),l&&(0,R.jsx)(`span`,{className:`shrink-0 cursor-pointer text-[var(--text-weaker)] hover:text-foreground`,title:`New session here`,onClick:e=>{e.stopPropagation(),Wy(c)},children:(0,R.jsx)(He,{className:`size-3.5`})}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.list.length})]}),o.map(e=>{let t=n.includes(e.id),i=f.get(e.id)??[],a=g.has(e.id),o=i.length>0&&P.length>=DI;return(0,R.jsxs)(`div`,{className:`mb-0.5`,children:[(0,R.jsx)(tL,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:t,selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),o&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${a?`-rotate-90`:``}`}),i.length,` `,i.length===1?`message`:`messages`,` match`,i.length===1?``:`es`]}),!a&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[i.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),i.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,i.length-5,` more in this session`]})]})]})]},e.id)}),!t&&s>0&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>le(e.name),className:`mt-1 w-full cursor-pointer rounded-md px-2.5 py-1.5 text-left text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:i?`Show less`:`Show ${s} more…`})]},e.name)}),oe&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void Xg(),className:`w-full cursor-pointer rounded-md px-2.5 py-2 text-center text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:`Load more sessions`})]})}),(0,R.jsx)(XI,{onFiles:()=>j(!0)})]}),C&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-1 border-t border-border p-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>j(!0),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Files`,children:(0,R.jsx)(Te,{className:`size-4`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>XS(),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Settings`,children:(0,R.jsx)(Xe,{className:`size-4`})})]}),(0,R.jsx)(Nt,{region:`sidebar`}),(0,R.jsx)(wI,{open:A,onOpenChange:j}),(0,R.jsx)($S,{}),!C&&(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuemin":AI,"aria-valuemax":jI,"aria-valuenow":T,tabIndex:0,onPointerDown:ue,onPointerMove:de,onPointerUp:fe,onPointerCancel:fe,onDoubleClick:()=>D(kI),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.key===`ArrowRight`?16:-16;D(e=>Math.min(jI,Math.max(AI,e+t)))},className:`absolute top-0 right-0 z-20 h-full w-1 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--border-hover)] focus:bg-[var(--border-selected)] focus:outline-none`})]})}function qI(){let[e,t]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let e=!1;return fetch(`/api/webui/config`).then(e=>e.ok?e.json():null).then(n=>{!e&&n?.version&&t(n.version)}).catch(()=>{}),()=>{e=!0}},[]),e?(0,R.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,title:`webui v${e}`,children:[`v`,e]}):null}function JI({collapsed:e=!1}){return(0,R.jsx)(U,{asChild:!0,variant:`default`,size:e?`icon`:`sm`,children:(0,R.jsxs)(`a`,{href:Pg,"aria-label":`New session`,title:e?`New session`:void 0,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Wy(null))},children:[(0,R.jsx)(He,{}),!e&&(0,R.jsx)(`span`,{className:`truncate`,children:`New session`})]})})}function YI({groups:e,current:t,activeIDs:n,onExpand:r}){return(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center gap-3 p-2`,children:e.map(e=>(0,R.jsxs)(`section`,{className:`flex w-full flex-col items-center gap-1.5 border-b border-[var(--border-weak-base)] pb-3 last:border-b-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:r,title:`${e.name} (${e.list.length} sessions)`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:(0,R.jsx)(Te,{className:`size-4`})}),e.list.slice(0,TI).map(e=>(0,R.jsx)($I,{id:e.id,title:e.title??`Untitled session`,selected:e.id===t,active:n.includes(e.id),onSelect:()=>void Pv(e.id)},e.id)),e.list.length>TI&&(0,R.jsxs)(`button`,{type:`button`,onClick:r,title:`Open workspace to see ${e.list.length-TI} more sessions`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[10px] text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:[`+`,e.list.length-TI]})]},e.name))})})}function XI({onFiles:e}){return(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-border px-3 py-2 text-xs text-[var(--text-weak)]`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Te,{className:`size-3`}),`Files`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>XS(),className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Xe,{className:`size-3`}),`Settings`]}),(0,R.jsx)(QI,{})]})})}function ZI(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}function QI(){let e=ZI(),t=(0,E.useMemo)(()=>Tt(),[e]);return t.length===0?null:(0,R.jsx)(R.Fragment,{children:t.map(e=>(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description?`${e.title} — ${e.description}`:e.title,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),window.history.pushState({},``,`/ext/${e.id}`),window.dispatchEvent(new Event(OI)))},className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(We,{className:`size-3`}),e.title]},e.id))})}function $I({id:e,title:t,selected:n,active:r,onSelect:i}){return(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-label":t,"aria-current":n?`page`:void 0,onClick:e=>eL(e,i),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`relative inline-flex size-8 items-center justify-center rounded-md text-xs font-medium transition-colors ${n?`bg-[var(--surface-raised-base)] text-foreground`:`text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`}`,children:[(t.trim()[0]??`S`).toUpperCase(),r&&(0,R.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 size-1.5 rounded-full bg-[var(--surface-success-strong)]`})]})}function eL(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t())}function tL({id:e,title:t,updated:n,active:r,selected:i,subagentsActive:a,onSelect:o}){let[s,c]=(0,E.useState)(!1);return(0,R.jsxs)(VI,{sessionID:e,children:[(0,R.jsx)(Nt,{region:`sidebar.session.before`,sessionID:e}),(0,R.jsxs)(`div`,{className:`group relative mb-0.5 w-full min-w-0 max-w-full`,children:[(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-current":i?`page`:void 0,onClick:e=>eL(e,o),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`block w-full min-w-0 max-w-full overflow-hidden rounded-md px-2.5 py-2 pr-12 transition-colors ${i?`bg-[var(--surface-raised-base)]`:`hover:bg-[var(--surface-base-hover)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[a&&(0,R.jsx)(`span`,{title:`Subagents running`,"aria-label":`Subagents running`,className:`size-1.5 shrink-0 animate-pulse rounded-full bg-[var(--surface-success-strong)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:t}),r&&(0,R.jsx)(Dx,{className:`shrink-0 border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`run`})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 max-w-full items-center gap-2 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:e.slice(0,12)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:pS(n)})]})]}),(0,R.jsx)(`div`,{className:`invisible absolute right-2 bottom-1.5 flex items-center gap-1 group-hover:visible group-focus-within:visible`,children:s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-on-critical-strong)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>{G.deleteSession(e).then(Yg),i&&Pv(null)},children:`yes`}),(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-weak)] hover:text-foreground`,onClick:()=>c(!1),children:`no`})]}):(0,R.jsx)(`button`,{type:`button`,title:`Delete session`,"aria-label":`Delete ${t}`,className:`cursor-pointer text-[var(--text-weaker)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>c(!0),children:(0,R.jsx)(at,{className:`size-3.5`})})})]}),(0,R.jsx)(Nt,{region:`sidebar.session.after`,sessionID:e})]})}function nL({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(rm,{"data-slot":`separator`,decorative:n,orientation:t,className:V(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}var rL=Object.defineProperty,iL=Object.getOwnPropertyDescriptor,aL=(e,t)=>{for(var n in t)rL(e,n,{get:t[n],enumerable:!0})},oL=(e,t,n,r)=>{for(var i=r>1?void 0:r?iL(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&&rL(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),sL=`Terminal input`,cL={get:()=>sL,set:e=>sL=e},lL=`Too much output to announce, navigate to rows manually to read`,uL={get:()=>lL,set:e=>lL=e};function dL(e){return e.replace(/\r?\n/g,`\r`)}function fL(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function pL(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function mL(e,t,n,r){e.stopPropagation(),e.clipboardData&&hL(e.clipboardData.getData(`text/plain`),t,n,r)}function hL(e,t,n,r){e=dL(e),e=fL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function gL(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 _L(e,t,n,r,i){gL(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function vL(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function yL(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 bL=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},xL=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},SL=``,CL=` `,wL=class e{constructor(){this.fg=0,this.bg=0,this.extended=new TL}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}},TL=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}},EL=class e extends wL{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new TL,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?vL(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()]}},DL=`di$target`,OL=`di$dependencies`,kL=new Map;function AL(e){return e[OL]||[]}function jL(e){if(kL.has(e))return kL.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ML(t,e,r)};return t._id=e,kL.set(e,t),t}function ML(e,t,n){t[DL]===t?t[OL].push({id:e,index:n}):(t[OL]=[{id:e,index:n}],t[DL]=t)}var NL=jL(`BufferService`),PL=jL(`CoreMouseService`),FL=jL(`CoreService`),IL=jL(`CharsetService`),LL=jL(`InstantiationService`),RL=jL(`LogService`),zL=jL(`OptionsService`),BL=jL(`OscLinkService`),VL=jL(`UnicodeService`),HL=jL(`DecorationService`),UL=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 EL,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):WL(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)}};UL=oL([Z(0,NL),Z(1,zL),Z(2,BL)],UL);function WL(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
103
|
+
`);tI.set(e,{messages:t,combinedLower:n})}catch{tI.set(e,{messages:[],combinedLower:``})}}function aI(e){let t=new Map,n=e.length;for(let[r,i]of tI){if(!i.combinedLower.includes(e))continue;let a=[];for(let t of i.messages){if(!t.lower.includes(e))continue;let r=rI(t.text,e,n);r&&a.push({messageID:t.id,snippet:r.snippet,matchStart:r.matchStart,matchEnd:r.matchEnd})}a.length>0&&t.set(r,a)}return t}function oI(e,t,n){let r=e.trim().toLowerCase();if(!r)return Promise.resolve(new Map);let i=[...t].sort((e,t)=>t.time.updated-e.time.updated).slice(0,QF).map(e=>e.id).filter(e=>!tI.has(e));return(async()=>{for(let e=0;e<i.length;e+=$F){let t=i.slice(e,e+$F);await Promise.all(t.map(iI)),n?.(aI(r))}return aI(r)})()}var sI=/mac|iphone|ipad|ipod/i.test(typeof navigator>`u`?``:navigator.userAgent),cI=sI?`⌘F`:`Ctrl F`;function lI({...e}){return(0,R.jsx)(es,{"data-slot":`sheet`,...e})}function uI({...e}){return(0,R.jsx)(os,{"data-slot":`sheet-portal`,...e})}function dI({className:e,...t}){return(0,R.jsx)(cs,{"data-slot":`sheet-overlay`,className:V(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function fI({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(uI,{children:[(0,R.jsx)(dI,{}),(0,R.jsxs)(fs,{"data-slot":`sheet-content`,"data-side":n,className:V(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,R.jsx)(xs,{"data-slot":`sheet-close`,asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function pI({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:V(`flex flex-col gap-0.5 p-4`,e),...t})}function mI({className:e,...t}){return(0,R.jsx)(_s,{"data-slot":`sheet-title`,className:V(`font-heading text-base font-medium text-foreground`,e),...t})}function hI({className:e,...t}){return(0,R.jsx)(ys,{"data-slot":`sheet-description`,className:V(`text-sm text-muted-foreground`,e),...t})}var gI=e=>e.replace(/\/+$/,``),_I=e=>gI(e).split(`/`).filter(Boolean).pop()??e,vI=e=>e instanceof Error?e.message:String(e);function yI(e,t){let n=gI(e.replace(/^\.\//,``)),r=gI(t.replace(/^\.\//,``));return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function bI(e){return[...e].sort((e,t)=>e.type===t.type?gI(e.path).localeCompare(gI(t.path)):e.type===`directory`?-1:1)}function xI(e){let t=e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,n=`size-3.5 shrink-0 text-[var(--text-weaker)]`;return[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`,`avif`].includes(t)?(0,R.jsx)(be,{className:n}):[`json`,`jsonc`,`yaml`,`yml`,`toml`].includes(t)?(0,R.jsx)(_e,{className:n}):[`zip`,`tar`,`gz`,`tgz`,`bz2`,`xz`,`7z`].includes(t)?(0,R.jsx)(ge,{className:n}):[`txt`,`log`,`csv`,`tsv`,`ini`,`env`,`conf`,`lock`,`gitignore`].includes(t)?(0,R.jsx)(Se,{className:n}):`ts.tsx.js.jsx.mjs.cjs.go.rs.py.rb.java.c.h.hpp.cc.cpp.css.scss.html.vue.svelte.sh.bash.zsh.sql.graphql.gql.md.mdx.zig`.split(`.`).includes(t)?(0,R.jsx)(ye,{className:n}):(0,R.jsx)(Ce,{className:n})}function SI({entry:e,depth:t,nodes:n,selectedPath:r,onToggle:i,onOpen:a}){let o=e.type===`directory`,s=gI(e.path),c=n[s],l=_I(e.path),u=r===s,d=6+t*13,f=()=>o?i(e):a(e);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:f,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},className:V(`flex cursor-pointer items-center gap-1 rounded-sm py-[3px] pr-2`,u?`bg-[var(--surface-raised-base)] text-[var(--text-strong)]`:`text-[var(--text-base)] hover:bg-[var(--surface-base-hover)]`),style:{paddingLeft:d},children:[o?(0,R.jsx)(L,{className:V(`size-3 shrink-0 text-[var(--text-weaker)] transition-transform`,c?.expanded&&`rotate-90`)}):(0,R.jsx)(`span`,{className:`w-3 shrink-0`}),o?(0,R.jsx)(Ee,{className:V(`size-3.5 shrink-0`,c?.expanded?`text-[var(--text-interactive-base)]`:`text-[var(--text-weak)]`)}):xI(l),(0,R.jsx)(`span`,{className:V(`truncate font-mono text-xs`,o?`text-[var(--text-strong)]`:`text-[var(--text-base)]`),children:l}),c?.loading&&(0,R.jsx)(Me,{className:`ml-auto size-3 shrink-0 animate-spin text-[var(--text-weaker)]`}),c?.error&&(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-[var(--text-on-critical-base)]`,children:`!`})]}),o&&c?.expanded&&(0,R.jsx)(`div`,{children:c.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 py-1`,style:{paddingLeft:d+13},children:[(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-1/2`})]}):c.error?(0,R.jsx)(`div`,{className:`py-1 text-[11px] text-[var(--text-on-critical-base)]`,style:{paddingLeft:d+13},children:c.error}):c.children&&c.children.length===0?(0,R.jsx)(`div`,{className:`py-0.5 text-[11px] italic text-[var(--text-weaker)]`,style:{paddingLeft:d+13},children:`empty`}):c.children?.map(e=>(0,R.jsx)(SI,{entry:e,depth:t+1,nodes:n,selectedPath:r,onToggle:i,onOpen:a},gI(e.path)))})]})}function CI({count:e,error:t}){return t?(0,R.jsx)(Dx,{variant:`outline`,title:t,className:`border-border/50 text-[var(--text-weaker)]`,children:`vcs n/a`}):e===null?null:e===0?(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`clean`}):(0,R.jsxs)(Dx,{className:`border-transparent bg-[var(--surface-critical-base)] text-[var(--text-on-critical-base)]`,children:[e,` changed`]})}function wI({open:e,onOpenChange:t}){let n=J(e=>e.sessions.find(t=>t.id===e.currentSessionID)?.location?.directory),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),[l,u]=(0,E.useState)({}),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)({loading:!1}),[h,g]=(0,E.useState)({loading:!1}),[_,v]=(0,E.useState)(null),[y,b]=(0,E.useState)(null),x=(0,E.useRef)(null),S=(0,E.useRef)(null);(0,E.useEffect)(()=>{if(!e)return;let t=!1,r=e=>{t||(S.current!==e&&(S.current=e,o(null),c(null),u({}),v(null),b(null),f(null),x.current=null),i(e),G.fsList({location:e}).then(e=>{t||(o(e.data),c(null))}).catch(e=>{t||c(vI(e))}),G.vcsStatus({directory:e}).then(e=>{t||v(e.data.length)}).catch(e=>{t||b(vI(e))}))};return n?r(n):G.location().then(e=>{t||r(e.directory)}).catch(e=>{t||c(vI(e))}),()=>{t=!0}},[e,n]),(0,E.useEffect)(()=>{e||(f(null),x.current=null,m({loading:!1}),g({loading:!1}))},[e]);let C=e=>{let t=gI(e.path),n=l[t];if(n?.expanded){u(e=>{let n={...e};return delete n[t],n});return}u(e=>({...e,[t]:{expanded:!0,loading:!e[t]?.children,children:e[t]?.children}})),n?.children||G.fsList({location:r??void 0,path:t}).then(e=>u(n=>n[t]?{...n,[t]:{...n[t],children:e.data,loading:!1}}:n)).catch(e=>u(n=>n[t]?{...n,[t]:{...n[t],error:vI(e),loading:!1}}:n))},w=e=>{x.current=e,f(e),m({loading:!0}),g({loading:!0}),G.fsRead(e.path,r??void 0).then(t=>{x.current?.path===e.path&&m({content:t,loading:!1})}).catch(t=>{x.current?.path===e.path&&m({error:vI(t),loading:!1})}),G.vcsBase(r?{directory:r}:void 0).then(e=>e.data).catch(()=>null).then(e=>G.vcsDiff(`working`,r?{directory:r}:void 0,3,e?.ref??null)).then(t=>{if(x.current?.path!==e.path)return;let n=t.data.find(t=>yI(t.file,e.path));g({patch:n?.patch,loading:!1})}).catch(t=>{x.current?.path===e.path&&g({error:vI(t),loading:!1})})};return(0,R.jsx)(lI,{open:e,onOpenChange:t,children:(0,R.jsxs)(fI,{side:`left`,className:`w-[min(44rem,calc(100vw-0.5rem))]! gap-0 p-0 sm:max-w-[44rem]!`,children:[(0,R.jsxs)(pI,{className:`border-b border-border px-4 py-3 pr-12`,children:[(0,R.jsxs)(mI,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(Te,{className:`size-4 text-[var(--text-weak)]`}),`Files`,(0,R.jsx)(CI,{count:_,error:y})]}),r&&(0,R.jsx)(hI,{className:`truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:r})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex w-[40%] min-w-56 shrink-0 flex-col border-r border-border`,children:(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`div`,{className:`p-1.5`,children:s?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-on-critical-base)]`,children:s}):a===null?(0,R.jsx)(`div`,{className:`space-y-1.5 p-1`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(MF,{className:`h-4 w-full`},e))}):a.length===0?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-weak)]`,children:`Empty directory`}):bI(a).map(e=>(0,R.jsx)(SI,{entry:e,depth:0,nodes:l,selectedPath:d?gI(d.path):null,onToggle:C,onOpen:w},gI(e.path)))})})}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:d?(0,R.jsxs)(Xx,{defaultValue:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:d.path}),(0,R.jsxs)(Qx,{variant:`line`,className:`h-6 shrink-0`,children:[(0,R.jsx)($x,{value:`preview`,className:`text-xs`,children:`Preview`}),(0,R.jsx)($x,{value:`diff`,className:`text-xs`,children:`Diff`})]})]}),(0,R.jsx)(eS,{value:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:p.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-2/3`}),(0,R.jsx)(MF,{className:`h-3 w-5/6`}),(0,R.jsx)(MF,{className:`h-3 w-1/2`})]}):p.error?(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:p.error}):(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`pre`,{className:`p-3 font-mono text-xs leading-[1.6] whitespace-pre text-[var(--text-base)]`,children:p.content??``})})}),(0,R.jsx)(eS,{value:`diff`,className:`flex min-h-0 flex-1 flex-col`,children:h.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(MF,{className:`h-3 w-11/12`}),(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-2/3`}),(0,R.jsx)(MF,{className:`h-3 w-5/6`})]}):h.error?(0,R.jsxs)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:[`Diff unavailable: `,h.error]}):h.patch?(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(MN,{diff:h.patch,className:`p-3`})}):(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-weak)]`,children:`No uncommitted changes for this file.`})})]}):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-xs text-[var(--text-weak)]`,children:`Select a file to preview`})})]})]})})}var TI=3,EI=20,DI=2,OI=`webui:navigate`,kI=288,AI=240,jI=480,MI=56,NI=0,PI=new Set,FI=!1;function II(){FI||(FI=!0,pt(()=>{NI++;for(let e of PI)e()}))}function LI(e){return II(),PI.add(e),()=>PI.delete(e)}function RI(){return NI}function zI(){return 0}function BI(){return(0,E.useSyncExternalStore)(LI,RI,zI)}function VI({sessionID:e,children:t}){let n=BI(),r=(0,E.useMemo)(()=>Ot(`session`),[n]);return r.length===0?(0,R.jsx)(R.Fragment,{children:t}):(0,R.jsxs)(mP,{children:[(0,R.jsx)(hP,{asChild:!0,children:t}),(0,R.jsx)(gP,{className:`min-w-36`,children:r.map(t=>(0,R.jsx)(_P,{onSelect:()=>{try{t.run({sessionID:e})}catch(e){console.error(`[extensions] contextMenu "${t.id}" crashed:`,e)}},children:t.label},t.id))})]})}function HI(e){return/^\/home\/[^/]+$/.test(e)||/^\/Users\/[^/]+$/.test(e)}function UI(e){let t=new Map;for(let n of e){if(!n)continue;let e=n.replace(/\/+$/,``);HI(e)&&t.set(e,(t.get(e)??0)+1)}let n,r=0;for(let[e,i]of t)i>r&&(n=e,r=i);return n}function WI(e,t){if(!e)return`Other`;let n=e.replace(/\/+$/,``);return t&&HI(t)&&n===t?`~`:t&&HI(t)&&n.startsWith(t+`/`)?`~/`+n.slice(t.length+1):n}function GI(e,t){return!!e&&!!t&&e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function KI(){let e=J(e=>e.sessions),t=J(e=>e.sessionsCursor),n=J(e=>e.activeIDs),r=J(e=>e.currentSessionID),i=J(e=>e.connected),a=J(e=>e.pendingWorkspace),o=J(e=>e.running),s=J(e=>e.queued),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)([]),[f,p]=(0,E.useState)(new Map),[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(new Set),v=(0,E.useRef)(null),[y,b]=(0,E.useState)({}),[x,S]=(0,E.useState)({}),[C,w]=(0,E.useState)(!1),[T,D]=(0,E.useState)(kI),[O,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(!1),M=J(e=>e.uiSignals.explorer);(0,E.useEffect)(()=>{M&&j(!0)},[M]);let N=(0,E.useMemo)(()=>UI(e.map(e=>e.location?.directory)),[e]),ee=e=>!!o[e]||!!s[e],te=(0,E.useMemo)(()=>{let t=new Set;for(let n of e)n.parentID&&ee(n.id)&&t.add(n.parentID);return t},[e,o,s]),P=c.trim(),F=P.toLowerCase();(0,E.useEffect)(()=>{if(P.length<2){d([]);return}let e=!1,t=setTimeout(()=>{G.listSessions({search:P,limit:100}).then(t=>{e||d(t.data.filter(e=>!e.parentID))}).catch(()=>{e||d([])})},250);return()=>{e=!0,clearTimeout(t)}},[P]),(0,E.useEffect)(()=>{if(P.length<2){p(new Map),h(!1);return}let t=!1;h(!0);let n=setTimeout(()=>{oI(P,e,e=>{t||p(new Map(e))}).catch(()=>new Map).then(e=>{t||(p(new Map(e)),h(!1))})},250);return()=>{t=!0,clearTimeout(n)}},[P,e]),(0,E.useEffect)(()=>{if(!a)return;let e=e=>{v.current&&!v.current.contains(e.target)&&Gy(null)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[a]);let ne=(0,E.useMemo)(()=>{let t=new Map,r=new Set;for(let n of e){if(n.parentID||F&&!(n.title??`Untitled session`).toLowerCase().includes(F)&&!WI(n.location?.directory,N).toLowerCase().includes(F)&&!(n.location?.directory??``).toLowerCase().includes(F))continue;r.add(n.id);let e=WI(n.location?.directory,N),i=t.get(e)??[];i.push(n),t.set(e,i)}for(let e of u){if(r.has(e.id))continue;r.add(e.id);let n=WI(e.location?.directory,N),i=t.get(n)??[];i.push(e),t.set(n,i)}let i=e=>!!(o[e]||n.includes(e)),a=[...t.entries()].map(([e,t])=>({name:e,list:[...t].sort((e,t)=>{let n=i(e.id),r=i(t.id);return n===r?t.time.updated-e.time.updated:Number(r)-Number(n)})}));return a.sort((e,n)=>{let r=t.get(e.name)?.some(e=>i(e.id))??!1,a=t.get(n.name)?.some(e=>i(e.id))??!1;return r===a?0:Number(a)-Number(r)}),a},[e,u,F,N,o,n]),re=(0,E.useMemo)(()=>{if(!F||f.size===0)return[];let t=new Set(ne.flatMap(e=>e.list.map(e=>e.id))),n=new Map(e.map(e=>[e.id,e])),r=[];for(let e of f.keys()){if(t.has(e))continue;let i=n.get(e);i&&r.push(i)}return r.sort((e,t)=>t.time.updated-e.time.updated).slice(0,EI)},[e,ne,f,F]),ie=ne.reduce((e,t)=>e+t.list.length,0)+re.length,ae=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},L=(e,t)=>{Ky(e,t),Pv(e)},oe=t!=null,se=e=>{let t=!x[e];S(n=>({...n,[e]:t})),t&&b(t=>({...t,[e]:!1}))},ce=e=>{let t=e??null;Gy(t),r===`__draft__`&&Wy(t)},le=e=>b(t=>({...t,[e]:!t[e]})),ue=e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),k(!0))},de=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&D(Math.min(jI,Math.max(AI,e.clientX)))},fe=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),k(!1)},pe=()=>w(e=>!e);return(0,R.jsxs)(`aside`,{ref:v,className:`relative flex min-w-0 shrink-0 flex-col overflow-hidden border-r border-border bg-background ${O?`select-none`:``}`,style:{width:C?MI:T},children:[(0,R.jsxs)(`div`,{className:`border-b border-border ${C?`flex flex-col items-center gap-2 px-2 py-2.5`:`flex items-center justify-between gap-2 px-3 py-2.5`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${i?`bg-[var(--surface-success-strong)]`:`bg-[var(--surface-warning-strong)]`}`}),C?(0,R.jsx)(`span`,{className:`font-mono text-xs font-semibold text-foreground`,title:`OpenCode`,children:`OC`}):(0,R.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:`OpenCode`})]}),C?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(JI,{collapsed:!0}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Expand sidebar`,children:(0,R.jsx)(Ie,{})})]}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Collapse sidebar`,children:(0,R.jsx)(Fe,{})}),(0,R.jsx)(JI,{})]})]}),C?(0,R.jsx)(YI,{groups:ne,current:r,activeIDs:n,onExpand:pe}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`border-b border-border p-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(qe,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(nh,{id:`session-search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search sessions`,className:`h-7 pl-7 ${sI?`pr-8`:`pr-12`}`}),(0,R.jsx)(`kbd`,{"aria-hidden":!0,title:`Focus session search (${sI?`Cmd+F`:`Ctrl+F`})`,className:`pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1 py-px font-mono text-[9px] leading-[1.4] text-[var(--text-weaker)]`,children:cI})]}),P.length>=DI&&(0,R.jsxs)(`p`,{className:`mt-1 px-1 text-[10px] text-[var(--text-weaker)]`,"aria-live":`polite`,children:[ie,` matched`,m?` · searching messages…`:``]})]}),(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`w-full min-w-0 max-w-full p-2`,children:[re.length>0&&(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex min-w-0 items-center gap-2 border-b border-[var(--border-weak-base)] px-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-medium tracking-wide text-[var(--text-weaker)] uppercase`,children:`Content matches`}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:re.length})]}),re.map(e=>{let t=f.get(e.id)??[],i=g.has(e.id);return(0,R.jsxs)(`div`,{className:`mb-1`,children:[(0,R.jsx)(tL,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:n.includes(e.id),selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),t.length>0&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${i?`-rotate-90`:``}`}),t.length,` `,t.length===1?`message`:`messages`,` match`,t.length===1?``:`es`]}),!i&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[t.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),t.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,t.length-5,` more in this session`]})]})]})]},e.id)})]}),ne.length===0&&re.length===0&&(0,R.jsx)(`p`,{className:`px-2.5 py-4 text-xs text-[var(--text-weak)]`,children:e.length===0?`No sessions yet.`:`No matches.`}),ne.map(e=>{let t=!!x[e.name],i=!!y[e.name],o=t?[]:i?e.list:e.list.filter((e,t)=>t<TI||ee(e.id)),s=e.list.length-o.length,c=e.list.find(e=>e.location?.directory)?.location?.directory??null,l=!!a&&!!c&&GI(a,c);return(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{onClick:()=>l?se(e.name):ce(c??void 0),"aria-pressed":l,title:l?`Collapse / expand workspace`:`New session here`,className:`mb-1 flex min-w-0 cursor-pointer select-none items-center gap-2 border-b px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide transition-colors ${l?`ring-1 ring-inset ring-[var(--border-selected)] bg-[var(--surface-raised-base)]`:``} ${l?``:`border-[var(--border-weak-base)]`}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate ${l?`text-[var(--text-weak)]`:`text-[var(--text-weaker)]`}`,children:e.name}),(0,R.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand ${e.name}`:`Collapse ${e.name}`,onClick:t=>{t.stopPropagation(),se(e.name)},title:t?`Expand workspace`:`Collapse workspace`,className:`ml-auto inline-flex shrink-0 cursor-pointer items-center justify-center rounded-sm p-0.5 hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:(0,R.jsx)(I,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${t?`-rotate-90`:``}`})}),l&&(0,R.jsx)(`span`,{className:`shrink-0 cursor-pointer text-[var(--text-weaker)] hover:text-foreground`,title:`New session here`,onClick:e=>{e.stopPropagation(),Wy(c)},children:(0,R.jsx)(He,{className:`size-3.5`})}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.list.length})]}),o.map(e=>{let t=n.includes(e.id),i=f.get(e.id)??[],a=g.has(e.id),o=i.length>0&&P.length>=DI;return(0,R.jsxs)(`div`,{className:`mb-0.5`,children:[(0,R.jsx)(tL,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:t,selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),o&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${a?`-rotate-90`:``}`}),i.length,` `,i.length===1?`message`:`messages`,` match`,i.length===1?``:`es`]}),!a&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[i.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),i.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,i.length-5,` more in this session`]})]})]})]},e.id)}),!t&&s>0&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>le(e.name),className:`mt-1 w-full cursor-pointer rounded-md px-2.5 py-1.5 text-left text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:i?`Show less`:`Show ${s} more…`})]},e.name)}),oe&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void Xg(),className:`w-full cursor-pointer rounded-md px-2.5 py-2 text-center text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:`Load more sessions`})]})}),(0,R.jsx)(XI,{onFiles:()=>j(!0)})]}),C&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-1 border-t border-border p-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>j(!0),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Files`,children:(0,R.jsx)(Te,{className:`size-4`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>XS(),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Settings`,children:(0,R.jsx)(Xe,{className:`size-4`})})]}),(0,R.jsx)(Nt,{region:`sidebar`}),(0,R.jsx)(wI,{open:A,onOpenChange:j}),(0,R.jsx)($S,{}),!C&&(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuemin":AI,"aria-valuemax":jI,"aria-valuenow":T,tabIndex:0,onPointerDown:ue,onPointerMove:de,onPointerUp:fe,onPointerCancel:fe,onDoubleClick:()=>D(kI),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.key===`ArrowRight`?16:-16;D(e=>Math.min(jI,Math.max(AI,e+t)))},className:`absolute top-0 right-0 z-20 h-full w-1 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--border-hover)] focus:bg-[var(--border-selected)] focus:outline-none`})]})}function qI(){let[e,t]=(0,E.useState)(null);return(0,E.useEffect)(()=>{let e=!1;return fetch(`/api/webui/config`).then(e=>e.ok?e.json():null).then(n=>{!e&&n?.version&&t(n.version)}).catch(()=>{}),()=>{e=!0}},[]),e?(0,R.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,title:`webui v${e}`,children:[`v`,e]}):null}function JI({collapsed:e=!1}){return(0,R.jsx)(U,{asChild:!0,variant:`default`,size:e?`icon`:`sm`,children:(0,R.jsxs)(`a`,{href:Pg,"aria-label":`New session`,title:e?`New session`:void 0,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Wy(null))},children:[(0,R.jsx)(He,{}),!e&&(0,R.jsx)(`span`,{className:`truncate`,children:`New session`})]})})}function YI({groups:e,current:t,activeIDs:n,onExpand:r}){return(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center gap-3 p-2`,children:e.map(e=>(0,R.jsxs)(`section`,{className:`flex w-full flex-col items-center gap-1.5 border-b border-[var(--border-weak-base)] pb-3 last:border-b-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:r,title:`${e.name} (${e.list.length} sessions)`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:(0,R.jsx)(Te,{className:`size-4`})}),e.list.slice(0,TI).map(e=>(0,R.jsx)($I,{id:e.id,title:e.title??`Untitled session`,selected:e.id===t,active:n.includes(e.id),onSelect:()=>void Pv(e.id)},e.id)),e.list.length>TI&&(0,R.jsxs)(`button`,{type:`button`,onClick:r,title:`Open workspace to see ${e.list.length-TI} more sessions`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[10px] text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:[`+`,e.list.length-TI]})]},e.name))})})}function XI({onFiles:e}){return(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-border px-3 py-2 text-xs text-[var(--text-weak)]`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Te,{className:`size-3`}),`Files`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>XS(),className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Xe,{className:`size-3`}),`Settings`]}),(0,R.jsx)(qI,{}),(0,R.jsx)(QI,{})]})})}function ZI(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}function QI(){let e=ZI(),t=(0,E.useMemo)(()=>Tt(),[e]);return t.length===0?null:(0,R.jsx)(R.Fragment,{children:t.map(e=>(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description?`${e.title} — ${e.description}`:e.title,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),window.history.pushState({},``,`/ext/${e.id}`),window.dispatchEvent(new Event(OI)))},className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(We,{className:`size-3`}),e.title]},e.id))})}function $I({id:e,title:t,selected:n,active:r,onSelect:i}){return(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-label":t,"aria-current":n?`page`:void 0,onClick:e=>eL(e,i),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`relative inline-flex size-8 items-center justify-center rounded-md text-xs font-medium transition-colors ${n?`bg-[var(--surface-raised-base)] text-foreground`:`text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`}`,children:[(t.trim()[0]??`S`).toUpperCase(),r&&(0,R.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 size-1.5 rounded-full bg-[var(--surface-success-strong)]`})]})}function eL(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t())}function tL({id:e,title:t,updated:n,active:r,selected:i,subagentsActive:a,onSelect:o}){let[s,c]=(0,E.useState)(!1);return(0,R.jsxs)(VI,{sessionID:e,children:[(0,R.jsx)(Nt,{region:`sidebar.session.before`,sessionID:e}),(0,R.jsxs)(`div`,{className:`group relative mb-0.5 w-full min-w-0 max-w-full`,children:[(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-current":i?`page`:void 0,onClick:e=>eL(e,o),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`block w-full min-w-0 max-w-full overflow-hidden rounded-md px-2.5 py-2 pr-12 transition-colors ${i?`bg-[var(--surface-raised-base)]`:`hover:bg-[var(--surface-base-hover)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[a&&(0,R.jsx)(`span`,{title:`Subagents running`,"aria-label":`Subagents running`,className:`size-1.5 shrink-0 animate-pulse rounded-full bg-[var(--surface-success-strong)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:t}),r&&(0,R.jsx)(Dx,{className:`shrink-0 border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`run`})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 max-w-full items-center gap-2 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:e.slice(0,12)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:pS(n)})]})]}),(0,R.jsx)(`div`,{className:`invisible absolute right-2 bottom-1.5 flex items-center gap-1 group-hover:visible group-focus-within:visible`,children:s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-on-critical-strong)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>{G.deleteSession(e).then(Yg),i&&Pv(null)},children:`yes`}),(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-weak)] hover:text-foreground`,onClick:()=>c(!1),children:`no`})]}):(0,R.jsx)(`button`,{type:`button`,title:`Delete session`,"aria-label":`Delete ${t}`,className:`cursor-pointer text-[var(--text-weaker)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>c(!0),children:(0,R.jsx)(at,{className:`size-3.5`})})})]}),(0,R.jsx)(Nt,{region:`sidebar.session.after`,sessionID:e})]})}function nL({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(rm,{"data-slot":`separator`,decorative:n,orientation:t,className:V(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}var rL=Object.defineProperty,iL=Object.getOwnPropertyDescriptor,aL=(e,t)=>{for(var n in t)rL(e,n,{get:t[n],enumerable:!0})},oL=(e,t,n,r)=>{for(var i=r>1?void 0:r?iL(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&&rL(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),sL=`Terminal input`,cL={get:()=>sL,set:e=>sL=e},lL=`Too much output to announce, navigate to rows manually to read`,uL={get:()=>lL,set:e=>lL=e};function dL(e){return e.replace(/\r?\n/g,`\r`)}function fL(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function pL(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function mL(e,t,n,r){e.stopPropagation(),e.clipboardData&&hL(e.clipboardData.getData(`text/plain`),t,n,r)}function hL(e,t,n,r){e=dL(e),e=fL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function gL(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 _L(e,t,n,r,i){gL(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function vL(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function yL(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 bL=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},xL=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},SL=``,CL=` `,wL=class e{constructor(){this.fg=0,this.bg=0,this.extended=new TL}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}},TL=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}},EL=class e extends wL{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new TL,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?vL(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()]}},DL=`di$target`,OL=`di$dependencies`,kL=new Map;function AL(e){return e[OL]||[]}function jL(e){if(kL.has(e))return kL.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ML(t,e,r)};return t._id=e,kL.set(e,t),t}function ML(e,t,n){t[DL]===t?t[OL].push({id:e,index:n}):(t[OL]=[{id:e,index:n}],t[DL]=t)}var NL=jL(`BufferService`),PL=jL(`CoreMouseService`),FL=jL(`CoreService`),IL=jL(`CharsetService`),LL=jL(`InstantiationService`),RL=jL(`LogService`),zL=jL(`OptionsService`),BL=jL(`OscLinkService`),VL=jL(`UnicodeService`),HL=jL(`DecorationService`),UL=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 EL,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):WL(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)}};UL=oL([Z(0,NL),Z(1,zL),Z(2,BL)],UL);function WL(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
104
104
|
|
|
105
105
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var GL=jL(`CharSizeService`),KL=jL(`CoreBrowserService`),qL=jL(`MouseService`),JL=jL(`RenderService`),YL=jL(`SelectionService`),XL=jL(`CharacterJoinerService`),ZL=jL(`ThemeService`),QL=jL(`LinkProviderService`),$L=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?aR.isErrorNoTelemetry(e)?new aR(e.message+`
|
|
106
106
|
|
|
@@ -119,4 +119,4 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
119
119
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===BW+1&&(this._liveRegion.textContent+=uL.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};VW=oL([Z(1,LL),Z(2,KL),Z(3,JL)],VW);var HW=class extends SR{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(yR(()=>{_R(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(pB(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(pB(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(pB(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(pB(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&UW(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,_R(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};HW=oL([Z(1,qL),Z(2,JL),Z(3,NL),Z(4,QL)],HW);function UW(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var WW=class extends kW{constructor(e={}){super(e),this._linkifier=this._register(new CR),this.browser=nH,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new CR),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(IW),this._instantiationService.setService(HL,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ZV),this._instantiationService.setService(QL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(UL)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(AR.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(AR.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(AR.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(AR.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(yR(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=yV.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${pW(r)}${dV.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=vV.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=vV.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(VW,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(pB(this.element,`copy`,e=>{this.hasSelection()&&pL(e,this._selectionService)}));let e=e=>mL(e,this.textarea,this.coreService,this.optionsService);this._register(pB(this.textarea,`paste`,e)),this._register(pB(this.element,`paste`,e)),oH?this._register(pB(this.element,`mousedown`,e=>{e.button===2&&_L(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(pB(this.element,`contextmenu`,e=>{_L(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),mH&&this._register(pB(this.element,`auxclick`,e=>{e.button===1&&gL(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(pB(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(pB(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(pB(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(pB(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(pB(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(pB(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(pB(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(pB(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,cL.get()),hH||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(YV,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(KL,this._coreBrowserService),this._register(pB(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(pB(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(GV,this._document,this._helperContainer),this._instantiationService.setService(GL,this._charSizeService),this._themeService=this._instantiationService.createInstance($H),this._instantiationService.setService(ZL,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(EV),this._instantiationService.setService(XL,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(xH,this.rows,this.screenElement)),this._instantiationService.setService(JL,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(fV,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(eH),this._instantiationService.setService(qL,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(HW,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(rV,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(UH,this.element,this.screenElement,r)),this._instantiationService.setService(YL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(AR.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(iV,this.screenElement)),this._register(pB(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(VW,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(lV,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(lV,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(WV,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(pB(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(pB(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){hL(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=jW(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(GW(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(lU));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function GW(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var KW=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},qW=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new EL)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},JW=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new qW(t)}getNullCell(){return new EL}},YW=class extends SR{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new JW(this._core.buffers.normal,`normal`),this._alternate=new JW(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},XW=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},ZW=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},QW=[`cols`,`rows`],$W=0,eG=class extends SR{constructor(e){super(),this._core=this._register(new WW(e)),this._addonManager=this._register(new KW),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(QW.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new XW(this._core),this._parser}get unicode(){return this._checkProposedApi(),new ZW(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new YW(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
120
120
|
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return cL.get()},set promptLabel(e){cL.set(e)},get tooMuchOutput(){return uL.get()},set tooMuchOutput(e){uL.set(e)}}}_verifyIntegers(...e){for($W of e)if($W===1/0||isNaN($W)||$W%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for($W of e)if($W&&($W===1/0||isNaN($W)||$W%1!=0||$W<0))throw Error(`This API only accepts positive integers`)}},tG=2,nG=1,rG=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(tG,Math.floor(u/e.css.cell.width)),rows:Math.max(nG,Math.floor(l/e.css.cell.height))}}},iG={background:`#101010`,foreground:`#e6e6e6`,cursor:`#9dbefe`,cursorAccent:`#101010`,selectionBackground:`rgba(157, 190, 254, 0.25)`,black:`#101010`,red:`#fc533a`,green:`#12c905`,yellow:`#fcd53a`,blue:`#9dbefe`,magenta:`#edb2f1`,cyan:`#94e2d5`,white:`#e6e6e6`,brightBlack:`#555555`,brightRed:`#ff8a77`,brightGreen:`#6bff5c`,brightYellow:`#ffe57a`,brightBlue:`#c6dcff`,brightMagenta:`#ffd3f8`,brightCyan:`#b9fff2`,brightWhite:`#ffffff`};function aG({ptyID:e,onClose:t,onError:n}){let r=(0,E.useRef)(null),i=(0,E.useRef)(null),a=(0,E.useRef)(null),o=(0,E.useRef)(null),s=(0,E.useRef)(e);s.current=e;let[c,l]=(0,E.useState)(!1),u=async()=>{if(!c){l(!0);try{await G.ptyDelete(e),a.current?.close()}catch(e){l(!1),n?.(e instanceof Error?e.message:String(e))}}};return(0,E.useEffect)(()=>{let e=r.current;if(!e)return;let c=new eG({fontFamily:`"JetBrainsMono Nerd Font Mono", monospace`,fontSize:13,lineHeight:1.3,cursorBlink:!0,theme:iG,scrollback:5e3}),l=new rG;c.loadAddon(l),c.open(e);try{l.fit()}catch{}i.current=c,o.current=l,c.focus();let u=()=>{try{l.fit()}catch{return}let e=c.cols>0&&c.rows>0?{cols:c.cols,rows:c.rows}:null;e&&G.ptyUpdate(s.current,{size:e}).catch(()=>{})},d=new ResizeObserver(u);d.observe(e);let f=null,p=!1,m=!1,h=async()=>{try{let e=await G.ptyConnectToken(s.current),r=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/api/pty/${s.current}/connect?ticket=${e.data.ticket}`;if(p)return;f=new WebSocket(r),a.current=f,f.onopen=()=>u(),f.onmessage=e=>{typeof e.data==`string`?c.write(e.data):e.data instanceof Blob?e.data.arrayBuffer().then(e=>g(new Uint8Array(e),c)):g(new Uint8Array(e.data),c)},f.onclose=()=>{p||t()},f.onerror=()=>{n?.(`Terminal connection lost`)}}catch(e){n?.(e instanceof Error?e.message:String(e))}},g=(e,t)=>{if(e[0]===0){let t=new TextDecoder().decode(e.subarray(1));try{typeof JSON.parse(t).cursor==`number`&&!m&&(m=!0,u())}catch{}return}t.write(new Uint8Array(e))},_=c.onData(e=>{a.current?.readyState===WebSocket.OPEN&&a.current.send(e)});return h(),()=>{p=!0,_.dispose(),d.disconnect(),a.current?.close(),c.dispose(),i.current=null}},[e]),(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-[var(--text-weak)]`,children:e}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>void u(),disabled:c,title:`Kill process`,"aria-label":`Kill terminal`,className:`text-[color:var(--surface-critical-strong)]`,children:[(0,R.jsx)(et,{}),`Kill`]}),(0,R.jsx)(U,{variant:`ghost`,size:`sm`,onClick:t,children:`Close`})]})]}),(0,R.jsx)(`div`,{ref:r,className:`min-h-0 flex-1 bg-[var(--background-base)] p-2`})]})}var oG=12e4,sG={running:`blue`,exited:`green`,timeout:`amber`,killed:`red`};function cG(e){let t=e.time.completed??Date.now(),n=Math.max(0,Math.floor((t-e.time.started)/1e3));if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function lG({trigger:e}){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(`shell`),a=J(e=>e.shellPanelTick);return(0,E.useEffect)(()=>{a>0&&n(!0)},[a]),(0,R.jsxs)(Km,{open:t,onOpenChange:n,children:[e===void 0?(0,R.jsx)(qm,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,children:[(0,R.jsx)(tt,{}),`Shell`]})}):(0,R.jsx)(qm,{asChild:!0,children:e}),(0,R.jsxs)(Zm,{className:`flex max-h-[85vh] flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl md:max-w-3xl`,children:[(0,R.jsxs)(Qm,{className:`border-b border-(--border-weak-base) px-4 py-3`,children:[(0,R.jsxs)(eh,{className:`flex items-center gap-2`,children:[(0,R.jsx)(tt,{className:`size-4 text-(color:--text-interactive-base)`}),`Shell & Terminals`]}),(0,R.jsx)(th,{children:`Run shell commands and manage PTY sessions.`})]}),(0,R.jsxs)(Xx,{value:r,onValueChange:i,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(Qx,{variant:`line`,className:`mx-4 mt-3`,children:[(0,R.jsx)($x,{value:`shell`,children:`Shell`}),(0,R.jsx)($x,{value:`terminals`,children:`Terminals`})]}),(0,R.jsx)(eS,{value:`shell`,forceMount:!0,className:V(`min-h-0`,r!==`shell`&&`hidden`),children:(0,R.jsx)(uG,{active:r===`shell`})}),(0,R.jsx)(eS,{value:`terminals`,forceMount:!0,className:V(`min-h-0`,r!==`terminals`&&`hidden`),children:(0,R.jsx)(fG,{active:r===`terminals`})})]})]})]})}function uG({active:e}){let[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!0),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(String(oG)),[d,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)({}),_=(0,E.useRef)({}),v=(0,E.useCallback)(async()=>{try{let e=await G.shellList();n(e.data),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);(0,E.useEffect)(()=>{if(e)return v(),og({name:`shell-panel-list`,minInterval:5e3,run:()=>v()})},[e,v]);let y=(0,E.useCallback)(async e=>{try{let t=(await G.shellOutput(e,{cursor:_.current[e]})).data,n=t.truncated||_.current[e]===void 0;g(r=>({...r,[e]:(n?``:r[e]??``)+t.output})),_.current[e]=t.cursor}catch{g(t=>({...t,[e]:(t[e]??``)+`
|
|
121
121
|
[output stream unavailable]`}))}},[]);(0,E.useEffect)(()=>{if(!e||!p)return;let n=t.find(e=>e.id===p);if(!(!n||n.status!==`running`))return og({name:`shell-panel-output`,minInterval:1200,run:()=>y(p)})},[e,p,t,y]);let b=async()=>{if(!(!s.trim()||d)){f(!0),o(null);try{let e=Number(l),t=await G.shellCreate({command:s.trim(),timeout:Number.isFinite(e)&&e>0?e:oG});c(``),await v(),m(t.data.id)}catch(e){o(e instanceof Error?e.message:String(e))}finally{f(!1)}}},x=async e=>{try{await G.shellDelete(e),g(t=>{let n={...t};return delete n[e],n}),delete _.current[e],p===e&&m(null),await v()}catch(e){o(e instanceof Error?e.message:String(e))}},S=async(e,t)=>{let n=Number(t);if(!(!Number.isFinite(n)||n<0))try{await G.shellTimeout(e,n),await v()}catch(e){o(e instanceof Error?e.message:String(e))}};return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(nh,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:`command to run`,className:`flex-1 font-mono text-xs`}),(0,R.jsx)(nh,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:`timeout ms`,title:`Timeout in milliseconds`,className:`w-24 font-mono text-xs`}),(0,R.jsxs)(U,{onClick:()=>void b(),disabled:!s.trim()||d,children:[(0,R.jsx)(Be,{}),`Run`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Refresh`,onClick:()=>void v(),children:(0,R.jsx)(Ke,{})})]}),a&&(0,R.jsx)(`p`,{className:`text-xs text-(color:--surface-critical-strong)`,children:a}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto`,children:r?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-(color:--text-weaker)`,children:[(0,R.jsx)(uS,{}),` Loading shells…`]}):t.length===0?(0,R.jsx)(`p`,{className:`px-1 py-2 text-xs text-(color:--text-weaker)`,children:`No shell sessions yet — run a command above.`}):t.map(e=>(0,R.jsx)(dG,{shell:e,expanded:p===e.id,output:h[e.id]??``,onToggle:()=>{m(t=>t===e.id?null:e.id),_.current[e.id]||y(e.id)},onKill:()=>void x(e.id),onSetTimeout:t=>void S(e.id,t)},e.id))})]})}function dG({shell:e,expanded:t,output:n,onToggle:r,onKill:i,onSetTimeout:a}){let[o,s]=(0,E.useState)(``),c=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[n]),(0,R.jsxs)(`div`,{className:`rounded-md border border-(--border-weak-base) bg-(--surface-base)`,children:[(0,R.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-2 px-2.5 py-1.5 hover:bg-(--surface-base-hover)`,onClick:r,children:[t?(0,R.jsx)(I,{className:`size-3.5 shrink-0 text-(color:--text-weaker)`}):(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-(color:--text-weaker)`}),(0,R.jsx)(fS,{tone:sG[e.status],children:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-(color:--text-strong)`,children:e.command}),(0,R.jsx)(`span`,{className:`hidden max-w-40 truncate font-mono text-xs text-(color:--text-weaker) sm:inline`,children:e.cwd}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-(color:--text-weak)`,children:[mS(e.time.started),` · `,cG(e)]}),e.status===`running`&&(0,R.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Kill`,"aria-label":`Kill`,onClick:e=>{e.stopPropagation(),i()},className:`text-(color:--surface-critical-strong)`,children:(0,R.jsx)(et,{})})]}),t&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-(--border-weak-base) p-2.5`,children:[(0,R.jsx)(`pre`,{ref:c,className:V(`max-h-56 min-h-10 overflow-auto rounded-md border border-(--border-weak-base) bg-(--surface-inset-base) p-2 font-mono text-xs whitespace-pre-wrap text-(color:--text-base)`,!n&&`text-(color:--text-weaker)`),children:n||`No output yet…`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(nt,{className:`size-3.5 text-(color:--text-weaker)`}),(0,R.jsx)(nh,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(a(o),s(``))},placeholder:`set timeout (ms)`,className:`h-6 w-36 font-mono text-xs`}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,disabled:!o.trim(),onClick:()=>{a(o),s(``)},children:`Apply`})]})]})]})}function fG({active:e}){let[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!0),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(``),[d,f]=(0,E.useState)(``),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)({}),[_,v]=(0,E.useState)(Date.now()),[y,b]=(0,E.useState)(null),x=(0,E.useCallback)(async()=>{try{let e=await G.ptyList();n(e.data),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);(0,E.useEffect)(()=>{if(e)return x(),og({name:`pty-panel-list`,minInterval:5e3,run:()=>{x(),v(Date.now())}})},[e,x]);let S=async()=>{if(!(!l.trim()||p)){m(!0),o(null);try{await G.ptyCreate({command:l.trim(),cwd:d.trim()||void 0,title:s.trim()||void 0}),c(``),u(``),f(``),await x()}catch(e){o(e instanceof Error?e.message:String(e))}finally{m(!1)}}},C=async e=>{try{await G.ptyDelete(e),g(t=>{let n={...t};return delete n[e],n}),await x()}catch(e){o(e instanceof Error?e.message:String(e))}},w=async e=>{try{let t=await G.ptyConnectToken(e);g(n=>({...n,[e]:{kind:`connected`,ticket:t.data.ticket,expiresAt:Date.now()+t.data.expires_in*1e3}})),o(null)}catch(t){g(n=>({...n,[e]:{kind:`error`,message:t instanceof Error?t.message:String(t)}}))}};return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:y?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(aG,{ptyID:y,onClose:()=>b(null),onError:e=>o(e)})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(nh,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`title`,className:`w-28 text-xs`}),(0,R.jsx)(nh,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`command (e.g. bash)`,className:`flex-1 font-mono text-xs`}),(0,R.jsx)(nh,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`cwd (optional)`,className:`w-36 font-mono text-xs`}),(0,R.jsxs)(U,{onClick:()=>void S(),disabled:!l.trim()||p,children:[(0,R.jsx)(tt,{}),`Create`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Refresh`,onClick:()=>void x(),children:(0,R.jsx)(Ke,{})})]}),a&&(0,R.jsx)(`p`,{className:`text-xs text-(color:--surface-critical-strong)`,children:a}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto`,children:r?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-(color:--text-weaker)`,children:[(0,R.jsx)(uS,{}),` Loading terminals…`]}):t.length===0?(0,R.jsx)(`p`,{className:`px-1 py-2 text-xs text-(color:--text-weaker)`,children:`No PTY sessions yet — create one above.`}):t.map(e=>(0,R.jsx)(pG,{pty:e,connection:h[e.id],now:_,onConnect:()=>void w(e.id),onOpen:()=>b(e.id),onDelete:()=>void C(e.id)},e.id))}),(0,R.jsx)(nL,{className:`bg-(--border-weak-base)`}),(0,R.jsx)(`p`,{className:`text-xs text-(color:--text-weaker)`,children:`Live terminals stream over a websocket — open one to interact.`})]})})}function pG({pty:e,connection:t,now:n,onConnect:r,onOpen:i,onDelete:a}){let o=e.args.length>0?` ${e.args.join(` `)}`:``,s=t?.kind===`connected`?Math.max(0,Math.ceil((t.expiresAt-n)/1e3)):0;return(0,R.jsxs)(`div`,{className:`rounded-md border border-(--border-weak-base) bg-(--surface-base) px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(fS,{tone:e.status===`running`?`blue`:`neutral`,children:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-(color:--text-strong)`,children:e.title||e.command}),(0,R.jsxs)(`span`,{className:`hidden shrink-0 text-xs text-(color:--text-weaker) md:inline`,children:[`pid `,e.pid,e.exitCode===void 0?``:` · exit ${e.exitCode}`]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:i,disabled:e.status!==`running`,children:[(0,R.jsx)($e,{}),`Open`]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:r,disabled:e.status!==`running`,children:[(0,R.jsx)(ie,{}),`Connect`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:e.status===`running`?`Kill`:`Delete`,"aria-label":e.status===`running`?`Kill terminal`:`Delete terminal record`,onClick:a,className:`text-(color:--surface-critical-strong)`,children:e.status===`running`?(0,R.jsx)(et,{}):(0,R.jsx)(rt,{})})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 pl-5`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-(color:--text-weak)`,children:[e.command,o,e.cwd?` — ${e.cwd}`:``]}),t?.kind===`connected`?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,children:[(0,R.jsx)(Ve,{className:`size-3 text-(color:--surface-success-strong)`}),(0,R.jsx)(fS,{tone:`green`,children:`connected`}),(0,R.jsxs)(`span`,{className:`hidden font-mono text-(color:--text-weaker) sm:inline`,children:[t.ticket.slice(0,10),`… · `,s,`s`]})]}):t?.kind===`error`?(0,R.jsx)(`span`,{className:`max-w-56 shrink-0 truncate`,title:t.message,children:(0,R.jsx)(fS,{tone:`red`,children:t.message})}):(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-(color:--text-weaker)`,children:`disconnected`})]})]})}var mG=`fixed top-1/2 left-1/2 z-50 flex w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-2 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,hG=`w-full rounded-md border border-[var(--border-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)]`,gG=`flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors text-[color:var(--text-base)] hover:bg-[color:var(--surface-base-hover)]`,_G=`flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors bg-[color:var(--surface-raised-base-active)] text-[color:var(--text-strong)]`;function vG(){return J(e=>e.splitPickerOpen)?(0,R.jsx)(yG,{}):null}function yG(){let e=J(e=>e.sessions),t=J(e=>e.panes),n=J(e=>e.running),r=J(e=>e.queued),i=J(e=>e.activeIDs),a=J(e=>e.currentSessionID&&!Eg(e.currentSessionID)?e.sessions.find(t=>t.id===e.currentSessionID)??e.sessionDetails[e.currentSessionID]:void 0),[o,s]=(0,E.useState)(`sessions`),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(0),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)([]),[g,_]=(0,E.useState)(!1),[v,y]=(0,E.useState)(null),[b,x]=(0,E.useState)(null),S=(0,E.useRef)(null),C=(0,E.useRef)(!1),w=(0,E.useMemo)(()=>new Set(t.map(e=>e.sessionID)),[t]),T=c.trim().toLowerCase(),D=(0,E.useMemo)(()=>e.filter(e=>!w.has(e.id)&&!e.parentID&&(!T||(e.title??``).toLowerCase().includes(T)||e.id.toLowerCase().includes(T)||e.location.directory.toLowerCase().includes(T))).sort((e,t)=>t.time.updated-e.time.updated),[e,w,T]),O=Math.min(u,Math.max(0,D.length-1));(0,E.useEffect)(()=>d(0),[T]);let k=a?.location?.directory;function A(){s(`workspace`),x(null),!C.current&&(C.current=!0,_(!0),Promise.all([G.locationInfo(),G.projectList()]).then(([e,t])=>{p(e),h(t)}).catch(()=>x(`Could not load workspaces`)).finally(()=>_(!1)))}function j(){s(`sessions`),x(null)}function M(e){Gv(e).then(e=>{e||x(`Already open in a pane, or no free slots`)})}async function N(e,t){if(!v){y(e),x(null);try{await Gv(await Jy(t))||x(`No free split slots`)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(null)}}}let te=(0,E.useMemo)(()=>{let e=new Set;for(let t of m)t.directory&&e.add(t.directory);return[...e]},[m]);return(0,R.jsx)(es,{open:!0,onOpenChange:e=>{e||Wv()},children:(0,R.jsxs)(os,{children:[(0,R.jsx)(cs,{className:`bg-black/60`}),(0,R.jsxs)(fs,{tabIndex:-1,"data-slot":`dialog-content`,className:mG,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),S.current?.focus()},children:[(0,R.jsxs)(_s,{className:`flex items-center gap-2 text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:[(0,R.jsx)(Qe,{className:`size-4 shrink-0 text-[var(--text-interactive-base)]`,"aria-hidden":!0}),`Split view`,(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-[var(--text-weaker)]`,children:`open a session beside this one`})]}),o===`sessions`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:S,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),d(Math.min(O+1,D.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),d(Math.max(O-1,0));else if(e.key===`Enter`){e.preventDefault();let t=D[O];t&&M(t.id)}},placeholder:`Filter sessions… (title, id, workspace)`,className:hG,autoComplete:`off`,spellCheck:!1}),(0,R.jsxs)(`button`,{type:`button`,onClick:A,disabled:v!==null,className:`flex w-full cursor-pointer items-center gap-2 rounded-md border border-dashed border-[var(--border-weak-base)] px-2 py-1.5 text-left text-sm text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)] disabled:pointer-events-none disabled:opacity-50`,children:[(0,R.jsx)(He,{className:`size-3.5 shrink-0`}),`Start new session`]}),(0,R.jsx)(`div`,{className:`-mx-1 max-h-72 overflow-y-auto px-1`,children:D.length===0?(0,R.jsx)(`p`,{className:`px-2 py-6 text-center text-xs text-[var(--text-weaker)]`,children:T?`No matching sessions`:`Every session is already in a pane`}):D.map((e,t)=>(0,R.jsx)(xG,{title:e.title||`session ${e.id.slice(0,8)}…`,dir:e.location.directory,at:e.time.updated,running:!!n[e.id]||!!r[e.id]||i.includes(e.id),highlighted:t===O,onHover:()=>d(t),onPick:()=>M(e.id)},e.id))})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:j,className:`flex cursor-pointer items-center gap-1 self-start rounded-md px-1 py-0.5 text-xs text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),` all sessions`]}),(0,R.jsx)(`div`,{className:`-mx-1 max-h-80 overflow-y-auto px-1`,children:g?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-6 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),` Loading workspaces…`]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(SG,{label:`Default workspace`,sub:f?.directory,busy:v==="default",disabled:v!==null,onChoose:()=>N(`default`,null)}),k&&a&&(0,R.jsx)(SG,{label:`same as ${a.title??`current session`}`,sub:k,busy:v===`focused`,disabled:v!==null,onChoose:()=>N(`focused`,k)}),te.map(e=>(0,R.jsx)(SG,{label:bG(e),sub:e,busy:v===e,disabled:v!==null,onChoose:()=>N(e,e)},e)),te.length===0&&!k&&(0,R.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-[var(--text-weaker)]`,children:`No workspaces`})]})})]}),b&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--surface-critical-strong)]`,children:b}),(0,R.jsxs)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`↑↓`}),` select · `,(0,R.jsx)(`span`,{className:`font-mono`,children:`↵`}),` open ·`,` `,(0,R.jsx)(`span`,{className:`font-mono`,children:`esc`}),` close`]}),(0,R.jsx)(xs,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close`,className:`absolute top-2 right-2 flex size-7 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-4`})})})]})]})})}function bG(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function xG({title:e,dir:t,at:n,running:r,highlighted:i,onHover:a,onPick:o}){let s=(0,E.useRef)(null);return(0,E.useEffect)(()=>{i&&s.current?.scrollIntoView({block:`nearest`})},[i]),(0,R.jsxs)(`button`,{ref:s,type:`button`,onMouseMove:a,onClick:o,title:t,className:i?_G:gG,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-emerald-500`:`bg-[color:var(--border-base)]`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),(0,R.jsx)(`span`,{className:`max-w-44 shrink-0 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:t}),r&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:`running`}),(0,R.jsx)(`span`,{className:`w-8 shrink-0 text-right font-mono text-[10px] text-[var(--text-weaker)]`,children:pS(n)})]})}function SG({label:e,sub:t,busy:n,disabled:r,onChoose:i}){return(0,R.jsxs)(`button`,{type:`button`,onClick:i,disabled:r,className:n?_G:gG,children:[n?(0,R.jsx)(uS,{className:`size-3.5 shrink-0`}):(0,R.jsx)(Ee,{className:`size-3.5 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`min-w-0 shrink truncate`,children:e}),t&&(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:t})]})}var CG=`webui.activityStrip.collapsed`,wG=15e3;function TG(e){return e?e.replace(/\/+$/,``).replace(/^\/(home|Users)\/[^/]+/,`~`):``}function EG(e){let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r?`${n}m ${r}s`:`${n}m`}function DG(e){let t=e.name||`tool`;if(e.status===`streaming`&&e.inputText){let n=e.inputText.replace(/\s+/g,` `).trim().slice(0,80);return n?`${t} ${n}…`:t}let n=e.input;if(n){if(typeof n.path==`string`)return`${t} ${String(n.path).split(`/`).pop()}`;if(typeof n.command==`string`)return`${t} ${String(n.command).slice(0,48)}`;if(typeof n.pattern==`string`)return`${t} "${String(n.pattern).slice(0,32)}"`;if(typeof n.description==`string`)return`${t} ${n.description.slice(0,40)}`;if(typeof n.agent==`string`&&typeof n.description==`string`)return`${t} ${String(n.agent)} — ${String(n.description).slice(0,24)}`}if(e.inputText){try{let n=JSON.parse(e.inputText);if(typeof n.path==`string`)return`${t} ${String(n.path).split(`/`).pop()}`;if(typeof n.command==`string`)return`${t} ${String(n.command).slice(0,48)}`}catch{}let n=e.inputText.replace(/\s+/g,` `).trim().slice(0,80);if(n&&n!==`{}`&&n!==`[]`)return`${t} ${n}`}return t}function OG(e){document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(t=>{e.document.head.appendChild(t.cloneNode(!0))});try{document.adoptedStyleSheets?.length&&(e.document.adoptedStyleSheets=document.adoptedStyleSheets)}catch{}}function kG({tool:e}){let t=e.status===`running`||e.status===`streaming`,n=e.status===`error`,r=n?`✗`:t?`⠋`:e.name===`subagent`?`→`:e.name===`shell`||e.name===`bash`?`$`:e.name===`edit`?`←`:`·`;return(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate py-0.5 text-[11px] ${n?`text-[var(--surface-critical-strong)]`:t?`text-[var(--text-base)]`:`text-[var(--text-weak)]`}`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono text-[10px] ${t?`animate-pulse`:``}`,children:t?`●`:r}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:DG(e)}),t&&(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 animate-pulse rounded-full bg-emerald-500`,"aria-hidden":!0})]})}function AG({assistants:e}){if(e.length===0)return(0,R.jsx)(`span`,{className:`text-[11px] italic text-[var(--text-weaker)]`,children:`waiting…`});let t=e.flatMap(e=>e.content),n=t.filter(e=>e.type===`reasoning`).slice(-1),r=t.filter(e=>e.type===`text`).slice(-2),i=t.filter(e=>e.type===`tool`).slice(-6),a=i.filter(e=>e.tool.status===`running`||e.tool.status===`streaming`),o=[...i.filter(e=>e.tool.status!==`running`&&e.tool.status!==`streaming`).slice(-3),...a];return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[n.length>0&&(0,R.jsx)(`div`,{className:`line-clamp-1 truncate text-[11px] italic text-[var(--text-weaker)]`,children:(()=>{let e=n[0].text.replace(/\s+/g,` `).trim();return`thought: ${e.length>140?`…${e.slice(-140)}`:e}`})()}),r.map(e=>{let t=e.text.replace(/\s+/g,` `).trim();if(!t)return null;let n=t.length>220?`…${t.slice(-220)}`:t;return(0,R.jsx)(`div`,{className:`line-clamp-2 break-words text-xs leading-snug text-[var(--text-base)]`,children:n},`t-${e.ordinal}`)}),o.map(e=>(0,R.jsx)(kG,{tool:e.tool},e.tool.id)),t.length===0&&(0,R.jsx)(`span`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`working…`})]})}function jG({session:e,assistants:t,running:n,queued:r,onOpen:i}){let[a,o]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(n)return og({name:`activity-row-elapsed`,minInterval:1e3,run:()=>o(e=>e+1)})},[n]);let s=t[0]?.started??e.time?.updated??Date.now(),c=n?`running`:r?`queued`:`idle`;return(0,R.jsxs)(`div`,{className:`group flex min-w-0 flex-col gap-1 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2 py-1.5 hover:border-[var(--border-base)]`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${c===`running`?`bg-emerald-500 animate-pulse`:c===`queued`?`bg-amber-500 animate-pulse`:`bg-[var(--border-base)]`}`,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-[var(--text-strong)]`,title:e.title??e.id,children:e.title||`Untitled session`}),e.location?.directory&&(0,R.jsx)(`span`,{className:`hidden max-w-[14ch] truncate font-mono text-[10px] text-[var(--text-weaker)] sm:inline`,title:e.location.directory,children:TG(e.location.directory)}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:n?EG(s):r?`queued`:``}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:`Open session`,className:`inline-flex shrink-0 cursor-pointer items-center gap-1 rounded-md border border-transparent px-1 py-0.5 text-[11px] text-[var(--text-weaker)] hover:border-[var(--border-weak-base)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(pe,{className:`size-3`}),` open`]})]}),(0,R.jsx)(`div`,{className:`min-w-0 pl-3`,children:(0,R.jsx)(AG,{assistants:t})})]})}function MG({onOpen:e}){let t=J(e=>e.sessions),n=J(e=>e.running),r=J(e=>e.queued),i=J(e=>e.activeIDs),a=J(e=>e.live),o=(0,E.useMemo)(()=>{let e=new Map;for(let t of a){let n=e.get(t.sessionID)??[];n.push(t),e.set(t.sessionID,n)}for(let t of e.values())t.sort((e,t)=>e.started-t.started);return e},[a]),s=e=>n[e]||r[e]||(o.get(e)??[]).some(e=>e.finish===void 0)?!0:i.includes(e)&&Date.now()-Jg(e)<wG,c=(0,E.useMemo)(()=>{let e=t.filter(e=>!e.parentID),r=[];for(let n of e){let e=Ov(t,n.id).filter(e=>s(e.id)),i=s(n.id);(i||e.length>0)&&r.push({parent:n,parentLive:i,children:e})}let i=new Set(r.flatMap(e=>e.children.map(e=>e.id))),a=t.filter(e=>!!e.parentID&&s(e.id)&&!i.has(e.id));for(let e of a){let n=t.find(t=>t.id===e.parentID)??{id:e.parentID,title:`Parent`,time:{updated:0}};r.find(t=>t.parent.id===e.parentID)||r.push({parent:n,parentLive:!1,children:[e]})}return r.sort((e,t)=>{let r=e.parentLive&&n[e.parent.id]?1:+!!e.children.some(e=>!!n[e.id]),i=t.parentLive&&n[t.parent.id]?1:+!!t.children.some(e=>!!n[e.id]);return r===i?(t.parent.time?.updated??0)-(e.parent.time?.updated??0):i-r}),r},[t,n,r,i,a,o]);return c.length===0?(0,R.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--text-weaker)]`,children:`No active agents.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(t=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.parentLive?(0,R.jsx)(jG,{session:t.parent,assistants:o.get(t.parent.id)??[],running:!!n[t.parent.id],queued:!!r[t.parent.id],onOpen:e}):(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1 text-[11px] font-medium text-[var(--text-weaker)]`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.parent.title||TG(t.parent.location?.directory)||t.parent.id.slice(0,8)}),(0,R.jsxs)(`span`,{className:`font-mono text-[10px]`,children:[`· `,t.children.length,` subagent`,t.children.length===1?``:`s`]})]}),t.children.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-1 border-l border-[var(--border-weak-base)] pl-2`,children:t.children.map(t=>(0,R.jsx)(jG,{session:t,assistants:o.get(t.id)??[],running:!!n[t.id],queued:!!r[t.id],onOpen:e},t.id))})]},t.parent.id))})}function NG(){let e=J(e=>e.running),t=J(e=>e.queued),n=J(e=>e.live),r=J(e=>e.activeIDs),[,i]=(0,E.useState)(0),a=(0,E.useMemo)(()=>{let e=new Map;for(let t of n){let n=e.get(t.sessionID)??[];n.push(t),e.set(t.sessionID,n)}return e},[n]),o=n=>e[n]||t[n]||(a.get(n)??[]).some(e=>e.finish===void 0)?!0:r.includes(n)&&Date.now()-Jg(n)<wG,s=(0,E.useMemo)(()=>{let i=new Set([...Object.keys(e),...Object.keys(t),...r,...n.map(e=>e.sessionID)]);for(let e of i)if(o(e))return!0;return!1},[e,t,r,n,a]);(0,E.useEffect)(()=>{if(s)return og({name:`activity-strip-tick`,minInterval:1e3,run:()=>i(e=>e+1)})},[s]);let[c,l]=(0,E.useState)(()=>{try{return localStorage.getItem(CG)===`1`}catch{return!1}}),[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null),m=typeof window<`u`&&`documentPictureInPicture`in window;(0,E.useEffect)(()=>{try{localStorage.setItem(CG,c?`1`:`0`)}catch{}},[c]);let h=(0,E.useMemo)(()=>{let i=new Set([...Object.keys(e),...Object.keys(t),...r,...n.map(e=>e.sessionID)]),a=0;for(let e of i)o(e)&&a++;return a},[e,t,r,n,a]);if(!s)return null;let g=e=>void Jv(e),_=async()=>{if(u){u.close(),d(null),p(null);return}try{let e=await window.documentPictureInPicture.requestWindow({width:380,height:560});OG(e),e.document.body.style.margin=`0`,e.document.documentElement.style.background=`var(--background-base)`,e.document.body.style.background=`var(--background-base)`,e.document.body.style.fontFamily=getComputedStyle(document.body).fontFamily;let t=e.document.createElement(`div`);t.id=`activity-strip-pip-root`,t.style.height=`100vh`,t.style.overflow=`auto`,t.style.background=`var(--background-base)`,e.document.body.appendChild(t),p(t),d(e),e.addEventListener(`pagehide`,()=>{d(null),p(null)})}catch(e){console.warn(`PiP failed`,e)}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-[var(--border-base)] bg-[var(--background-base)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-500`,"aria-hidden":!0}),h,` active`,(0,R.jsx)(`span`,{className:`font-normal text-[var(--text-weaker)]`,children:`· streaming`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[m&&(0,R.jsxs)(`button`,{type:`button`,onClick:_,title:u?`Close picture-in-picture`:`Pop out — always on top outside Chrome`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] ${u?`border-[var(--border-selected)] bg-[var(--surface-interactive-weak)] text-[var(--text-interactive-base)]`:`border-[var(--border-weak-base)] text-[var(--text-weaker)] hover:text-[var(--text-strong)]`}`,children:[(0,R.jsx)(ze,{className:`size-3`}),` `,u?`popped`:`pop out`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),title:c?`Expand`:`Collapse`,className:`flex size-6 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:c?(0,R.jsx)(I,{className:`size-3.5`}):(0,R.jsx)(oe,{className:`size-3.5`})})]})]}),c?null:(0,R.jsx)(`div`,{className:`max-h-[42vh] overflow-auto px-2 pb-2`,children:(0,R.jsx)(MG,{onOpen:g})})]}),u&&f?(0,jr.createPortal)((0,R.jsxs)(`div`,{className:`min-h-screen bg-[var(--background-base)] p-2`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium text-[var(--text-strong)]`,children:[`Live — `,h,` active`]}),(0,R.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-[11px] text-[var(--text-weaker)]`,children:`close`})]}),(0,R.jsx)(MG,{onOpen:e=>{Jv(e);try{window.focus()}catch{}}})]}),f):null]})}function PG(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()).filter(Boolean),n=!1,r=!1,i=!1,a=!1,o=``;for(let e of t)e===`ctrl`||e===`control`?n=!0:e===`meta`||e===`cmd`||e===`command`||e===`super`?r=!0:e===`shift`?i=!0:e===`alt`||e===`option`?a=!0:o=e;return{ctrl:n,meta:r,shift:i,alt:a,key:o}}function FG(e,t){let n=PG(e);return!n.key||n.ctrl!==t.ctrlKey||n.meta!==t.metaKey||n.shift!==t.shiftKey||n.alt!==t.altKey?!1:t.key.toLowerCase()===n.key.toLowerCase()}function IG(e){let t=e;return t?t.isContentEditable||t.closest?.(`input, textarea, select, [contenteditable=true]`)?!0:t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`:!1}function LG(){return(0,E.useEffect)(()=>{let e=St(),t=pt(()=>{e=St()}),n=t=>{if(!t.repeat&&!IG(t.target)&&!document.querySelector(`[role="dialog"], [cmdk-root], [data-radix-popper-content-wrapper], [role="menu"], [role="listbox"]`))for(let n of e){let e=n.keybind;if(e&&FG(e,t)){t.preventDefault();try{let e=Ng().currentSessionID??void 0;n.run({sessionID:e})}catch(e){console.error(`[extensions] command "${n.id}" keybind failed:`,e)}break}}};return window.addEventListener(`keydown`,n),()=>{t(),window.removeEventListener(`keydown`,n)}},[]),null}function RG(){let e=(0,E.useSyncExternalStore)(DS,OS,OS);return e.length===0?null:(0,R.jsx)(`div`,{className:`pointer-events-none fixed right-4 bottom-4 z-50 flex w-[min(22rem,calc(100vw-2rem))] flex-col gap-2`,children:e.map(e=>(0,R.jsxs)(`div`,{role:`status`,className:`pointer-events-auto flex flex-col gap-0.5 rounded-md border px-3 py-2.5 shadow-lg backdrop-blur-sm transition-all ${e.variant===`destructive`?`border-[color:var(--surface-critical-strong)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_12%,var(--surface-float-base))] text-[var(--text-strong)]`:`border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-strong)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium leading-tight`,children:e.title}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>kS(e.id),className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,"aria-label":`Dismiss`,children:`✕`})]}),e.description?(0,R.jsx)(`span`,{className:`text-xs leading-snug text-[var(--text-weak)]`,children:e.description}):null]},e.id))})}function zG(e,t=`main`){let n=Ng();if(n.currentSessionID&&Sg(n).some(e=>e.req.sessionID===n.currentSessionID))return;wv();let r=document.getElementById(`composer-input-${t}`);if(r){r.focus({preventScroll:!0});return}BG(e,t)}function BG(e,t){let n=0,r=()=>{let i=document.getElementById(`composer-input-${t}`);if(!i){n++===2&&Ev(),n<30&&requestAnimationFrame(r);return}i.focus({preventScroll:!0});let a=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set;if(a){a.call(i,i.value+e),i.dispatchEvent(new Event(`input`,{bubbles:!0}));let t=i.value.length;i.setSelectionRange(t,t)}};requestAnimationFrame(r)}var VG=/^\/ext\/([A-Za-z0-9_-]+)$/,HG=`webui:navigate`;function UG(){let[e,t]=(0,E.useState)(()=>window.location.pathname);return(0,E.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),window.addEventListener(HG,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(HG,e)}},[]),e}function WG(){let e=J(e=>e.currentSessionID),t=J(e=>e.connected),n=J(e=>e.currentSessionID?e.sessions.find(t=>t.id===e.currentSessionID)??e.sessionDetails[e.currentSessionID]:void 0),r=J(e=>e.sessions),i=J(e=>e.runsPanelOpen),a=J(t=>kv(t,e)),o=J(e=>e.panes[0]?.sessionID??null),s=J(e=>e.panes.slice(1)),c=J(e=>e.focusedPane),l=UG(),u=VG.exec(l)?.[1]??null,d=(u?At(u):void 0)?.title;(0,E.useEffect)(()=>{if(d!==void 0){document.title=d;return}document.title=e?`${a?`● `:``}${Eg(e)?`New session`:n?.title??`Untitled session`}`:`OpenCode Web`},[e,n?.title,a,d]);function f(){return!!document.querySelector(`[role="dialog"]`)||i}let p=e=>void Jv(e);function m(t){if(!e||!n?.parentID||f())return;let i=Ov(r,n.parentID).slice().sort((e,t)=>e.id<t.id?-1:1);if(i.length===0)return;let a=i.findIndex(t=>t.id===e),o=(((a===-1?0:a)+t)%i.length+i.length)%i.length;p(i[o].id)}(0,E.useEffect)(()=>{let e=e=>{if(e.key.length!==1||e.metaKey)return;let t=e.ctrlKey&&e.altKey;if(e.ctrlKey&&!t||e.altKey&&!t)return;let n=e.target;n&&(n.isContentEditable||n.closest(`input, textarea, select, [contenteditable=true]`))||document.querySelector(`[role="dialog"], [cmdk-root], [data-radix-popper-content-wrapper], [role="menu"], [role="listbox"]`)||zG(e.key,Yv())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);function h(){if(f())return;let e=document.getElementById(`session-search`);e&&(e.focus(),e.select())}hb({arrowup:()=>{!n?.parentID||!e||f()||p(n.parentID)},arrowdown:()=>{!e||f()||Cv()},arrowleft:()=>m(-1),arrowright:()=>m(1),enter:()=>{!n?.parentID||!e||f()||Ev()},backspace:()=>{if(!n?.parentID||!e||f())return;let t=document.getElementById(`composer-input-${Yv()}`);t&&t.value!==``||p(n.parentID)},"ctrl+n":()=>Wy(null),"ctrl+\\":()=>Uv(),"meta+f":h,"ctrl+f":h,escape:e=>{let t=e?.target;document.querySelector(`[role="dialog"]`)||t&&(t.id.startsWith(`composer-input`)||t.closest(`[data-radix-popper-content-wrapper], [cmdk-root], [data-slot="command"]`))||Iy()}});let g=e=>()=>void Hv(e);return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,R.jsx)(Nt,{region:`app.header`,sessionID:e??void 0}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(KI,{}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto`,children:[(0,R.jsx)(`section`,{className:`flex min-w-0 flex-1 flex-col`,onPointerDownCapture:g(wg),onFocusCapture:g(wg),children:u?(0,R.jsx)(qG,{id:u}):o?(0,R.jsx)(IF,{sessionID:o,paneKey:`main`,focused:c===wg,onNavigate:p},o):(0,R.jsx)(KG,{connected:t})}),s.map(e=>(0,R.jsx)(`section`,{className:`pane-surface hidden min-w-0 border-l border-[var(--border-base)] lg:flex`,style:{flex:`1 1 0`,maxWidth:`50%`},onPointerDownCapture:g(e.id),onFocusCapture:g(e.id),children:e.sessionID?(0,R.jsx)(IF,{sessionID:e.sessionID,paneKey:e.id,focused:c===e.id,onClose:()=>void Kv(e.id),onNavigate:p},`${e.id}:${e.sessionID}`):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--text-weaker)]`,children:`Empty pane`})},e.id)),(0,R.jsx)(`div`,{className:`hidden w-9 shrink-0 flex-col items-center border-l border-[var(--border-base)] pt-2 lg:flex`,children:(0,R.jsx)(`button`,{type:`button`,onClick:Uv,disabled:s.length>=3,title:`Split view — open a session beside this one`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)] disabled:pointer-events-none disabled:opacity-40`,children:(0,R.jsx)(le,{className:`size-4`})})})]})]}),(0,R.jsx)(NG,{}),(0,R.jsx)(Nt,{region:`footer`}),(0,R.jsx)(GG,{}),(0,R.jsx)(vG,{}),(0,R.jsx)(yb,{}),(0,R.jsx)(LG,{}),(0,R.jsx)(RG,{}),(0,R.jsx)(ZF,{}),(0,R.jsx)(lG,{trigger:(0,R.jsx)(`span`,{className:`hidden`})})]})}function GG(){let e=J(e=>Sg(e).filter(t=>t.req.sessionID!==e.currentSessionID)),t=e.map(e=>e.req.id).join(`,`);return(0,E.useEffect)(()=>{t&&Hh(`chip`,`foreign waiting: ${t}`)},[t]),e.length===0?null:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void Pv(e[0].req.sessionID,{history:`push`}),title:e.map(e=>`${e.kind} — ${e.req.sessionID}`).join(`
|
|
122
|
-
`),className:`fixed right-4 bottom-10 z-40 flex items-center gap-1.5 rounded-full border border-[color-mix(in_oklch,var(--surface-warning-strong)_45%,transparent)] bg-[var(--surface-float-base)] px-2.5 py-1 text-xs text-[var(--text-weak)] shadow-md transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-warning-strong)]`,"aria-hidden":!0}),e.length,` waiting in other session`,e.length>1?`s`:``,` — switch`]})}function KG({connected:e}){return(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-neutral-500`,children:[(0,R.jsx)(`div`,{className:`size-2.5 rounded-full ${e?`bg-emerald-500`:`bg-amber-500`}`}),(0,R.jsx)(`p`,{className:`text-sm`,children:e?`Select or create a session on the left`:`Connecting to the opencode service…`})]})}function qG({id:e}){JG();let t=At(e),n=Tt();return(0,R.jsx)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6`,children:[(0,R.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>window.history.back(),title:`Go back`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),`Back`]}),(0,R.jsx)(`h1`,{className:`truncate text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:t?t.title:`Unknown extension page`})]}),t?.description&&(0,R.jsx)(`p`,{className:`mt-1 text-sm text-[var(--text-weaker)]`,children:t.description})]})}),(0,R.jsx)(`div`,{className:`mt-4`,children:t?t.render({}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm text-[var(--text-weak)]`,children:[(0,R.jsxs)(`p`,{children:[`No extension registered “`,e,`”. Available pages:`]}),n.length===0?(0,R.jsx)(`p`,{className:`text-[var(--text-weaker)]`,children:`No extension pages are registered.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description??e.title,className:`text-[var(--text-interactive-base)] underline underline-offset-2`,children:[`/ext/`,e.id,` — `,e.title]})},e.id))})]})})]})})}function JG(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),[e]}var YG=class extends E.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[app] render error:`,e)}render(){return this.state.error?(0,R.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:`The UI hit a render error.`}),(0,R.jsx)(`pre`,{className:`max-h-48 max-w-full overflow-auto rounded-md border border-border bg-muted p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:this.state.error.message}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`cursor-pointer rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-muted`,children:`Retry`})]}):this.props.children}},XG=Object.assign({"./report/index.tsx":()=>ug(()=>import(`./report-
|
|
122
|
+
`),className:`fixed right-4 bottom-10 z-40 flex items-center gap-1.5 rounded-full border border-[color-mix(in_oklch,var(--surface-warning-strong)_45%,transparent)] bg-[var(--surface-float-base)] px-2.5 py-1 text-xs text-[var(--text-weak)] shadow-md transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-warning-strong)]`,"aria-hidden":!0}),e.length,` waiting in other session`,e.length>1?`s`:``,` — switch`]})}function KG({connected:e}){return(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-neutral-500`,children:[(0,R.jsx)(`div`,{className:`size-2.5 rounded-full ${e?`bg-emerald-500`:`bg-amber-500`}`}),(0,R.jsx)(`p`,{className:`text-sm`,children:e?`Select or create a session on the left`:`Connecting to the opencode service…`})]})}function qG({id:e}){JG();let t=At(e),n=Tt();return(0,R.jsx)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6`,children:[(0,R.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>window.history.back(),title:`Go back`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),`Back`]}),(0,R.jsx)(`h1`,{className:`truncate text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:t?t.title:`Unknown extension page`})]}),t?.description&&(0,R.jsx)(`p`,{className:`mt-1 text-sm text-[var(--text-weaker)]`,children:t.description})]})}),(0,R.jsx)(`div`,{className:`mt-4`,children:t?t.render({}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm text-[var(--text-weak)]`,children:[(0,R.jsxs)(`p`,{children:[`No extension registered “`,e,`”. Available pages:`]}),n.length===0?(0,R.jsx)(`p`,{className:`text-[var(--text-weaker)]`,children:`No extension pages are registered.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description??e.title,className:`text-[var(--text-interactive-base)] underline underline-offset-2`,children:[`/ext/`,e.id,` — `,e.title]})},e.id))})]})})]})})}function JG(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),[e]}var YG=class extends E.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[app] render error:`,e)}render(){return this.state.error?(0,R.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:`The UI hit a render error.`}),(0,R.jsx)(`pre`,{className:`max-h-48 max-w-full overflow-auto rounded-md border border-border bg-muted p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:this.state.error.message}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`cursor-pointer rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-muted`,children:`Retry`})]}):this.props.children}},XG=Object.assign({"./report/index.tsx":()=>ug(()=>import(`./report-Yer97DOV.js`),[]),"./runtime-status/index.tsx":()=>ug(()=>import(`./runtime-status-DDyLoT2y.js`),[])});async function ZG(){let e=new Set;await Promise.all(Object.values(XG).map(async t=>{let n=await t();n&&typeof n.id==`string`&&e.add(n.id)})),ht(e)}ZG();var QG=new Map,$G=8e3;function eK(){let e=window,t=e.__opencodeUI??{};t.notify||=AS,t.getHooks||=kt,t.register||=yt,t.version||fetch(`/api/webui/config`).then(e=>e.ok?e.json():null).then(e=>{if(!e)return;let t=window.__opencodeUI;e.version&&(t.version=e.version),e.reportRepo&&(t.reportRepo=e.reportRepo)}).catch(()=>{}),e.__opencodeUI=t}var tK=!1;async function nK(e){if(eK(),!e?.force&&tK&&document.hidden)return;let t;try{let e=await fetch(`/api/webui/extensions`);if(!e.ok)return;let n=(await e.json())?.data;t=Array.isArray(n)?n:[]}catch{return}let n=new Set;for(let e of t)if(typeof e?.id==`string`&&typeof e?.url==`string`&&!aS(e.id)&&(n.add(e.id),gt([e.id]),QG.get(e.id)!==e.url))try{await ug(()=>import(e.url),[]),QG.set(e.id,e.url)}catch{}let r=[];for(let e of QG.keys())n.has(e)||(r.push(e),QG.delete(e));r.length>0&&_t(r)}function rK(){tK||(tK=!0,eK(),nK({force:!0}),og({name:`extensions-manifest`,minInterval:$G,run:()=>nK()}))}var iK=typeof localStorage<`u`&&localStorage.getItem(`webui.debug`)===`1`;window.__WEBUI_DEBUG_CONSOLE__=iK,window.__opencodeUI={version:1,register:yt,react:E,jsxRuntime:R,useStore:J,api:G,notify:AS,getHooks:kt},rK(),mv(),Hh(`boot`,`app render (console mirror: ${iK?`on`:`off`})`),(0,ot.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(E.StrictMode,{children:(0,R.jsx)(YG,{children:(0,R.jsx)(WG,{})})}));export{ey as a,st as c,Yy as i,p as l,Ng as n,J as o,Eg as r,yt as s,AS as t,l as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,n as r,r as i,s as a,t as o}from"./index-
|
|
1
|
+
import{a as e,c as t,i as n,n as r,r as i,s as a,t as o}from"./index-BBldSR-0.js";var s=`report`,c=`AbdelftahZowail/opencode-webui`,l=10,u=window;function d(e){let t=u.__reportErrors??=[];t.push(e),t.length>l&&t.splice(0,t.length-l)}u.__reportErrorsInstalled||(u.__reportErrorsInstalled=!0,window.onerror=(e,t,n,r,i)=>{d({message:String(e).slice(0,500),source:t??``,line:n??0,stack:i instanceof Error?i.stack?.slice(0,500):void 0})},window.addEventListener(`unhandledrejection`,e=>{let t=e.reason;d({message:(t instanceof Error?t.message:String(t)).slice(0,500),source:`unhandledrejection`,line:0,stack:t instanceof Error?t.stack?.slice(0,500):void 0})}));async function f(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}async function p(e){let[n,r]=await Promise.all([f(`/api/webui/config`),f(`/api/webui/extensions`)]);return{url:location.href,userAgent:navigator.userAgent,language:navigator.language,viewport:`${window.innerWidth}x${window.innerHeight}`,version:n?.version??`unknown`,reportRepo:n?.reportRepo??c,builtins:[...t],runtimeExtensions:(r?.data??[]).map(e=>e.id??``).filter(Boolean),errors:u.__reportErrors??[],sessionID:e,timestamp:new Date().toISOString()}}function m(e,t){let n=`WebUI bug: ${e?e.slice(0,80):`user report`}`,r=[`### What happened`,e||``,``,`### Steps to reproduce`,`1. `,``,`### Expected`,``,`### Actual`,``,`<details><summary>Diagnostics</summary>`,``,"```json",JSON.stringify(t,null,2),"```",`</details>`].join(`
|
|
2
2
|
`);return{title:n,body:r,url:`https://github.com/${t.reportRepo}/issues/new?title=${encodeURIComponent(n)}&body=${encodeURIComponent(r)}`}}async function h(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}async function g(t,a){let s=t.trim(),c=s.startsWith(`--agent`),l=c?s.replace(/^--agent\b/,``).trim():s,u=await p(a.sessionID??r().currentSessionID??null),{title:d,body:f,url:g}=m(l,u);if(c){let t=`File a bug against ${u.reportRepo} using the gh CLI: create an issue with the title and body below, then reply with the issue URL. Do not include any private session content beyond the diagnostics JSON.\n\nTitle: ${d}\n\n${f}`,s=a.sessionID??r().currentSessionID??null;if(s&&i(s))try{s=await n(``)}catch{s=null}if(!s){let e=await h(t);o({title:e?`No active session — report prompt copied`:`No active session`,description:e?`Paste it into a session to have the agent file the issue.`:`Could not copy the report prompt either.`,variant:e?`default`:`destructive`});return}o({title:`Report handed to the agent`,description:`It will file the issue and reply with the URL.`}),await e(s,t);return}if(window.open(g,`_blank`))o({title:`Opening GitHub issue…`});else{let e=await h(g);o({title:e?`Report ready — link copied`:`Report link`,description:e?`Popup blocked; paste the link in a browser.`:`Popup blocked and the clipboard is unavailable.`,variant:e?`default`:`destructive`})}}a({kind:`slash`,id:`report`,name:`report`,aliases:[`bug`],description:`Report a webui bug on GitHub — diag bundle prefilled`,run:g});export{s as id};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l as e,o as t,s as n,u as r}from"./index-BBldSR-0.js";var i=r(e(),1),a=`runtime-status`;function o(){let e=t(e=>e.connected),n=t(e=>e.serviceOK),r=t(e=>e.activeIDs.length),a=e&&n;return(0,i.jsxs)(`footer`,{className:`flex min-h-7 items-center justify-end gap-3 border-t border-[var(--border-weak-base)] bg-[var(--background-base)] px-3 py-1 font-mono text-[10px] text-[var(--text-weaker)]`,children:[(0,i.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:a?`Connected to the OpenCode service`:`Waiting for the OpenCode service`,children:[(0,i.jsx)(`span`,{className:`size-1.5 rounded-full ${a?`bg-[var(--surface-success-strong)]`:`bg-[var(--surface-warning-strong)]`}`}),a?`connected`:`offline`]}),r>0&&(0,i.jsxs)(`span`,{children:[r,` active`]})]})}n({kind:`region`,id:`runtime-status`,region:`footer`,render:()=>(0,i.jsx)(o,{})});export{a as id};
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/assets/opencode.svg" />
|
|
7
7
|
<title>OpenCode Web</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-BBldSR-0.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-BJLgA6bC.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Web UI for the OpenCode coding agent — chat, streaming, tool cards, and extensions over the OpenCode engine's HTTP API.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.7",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
package/server/index.ts
CHANGED
|
@@ -605,9 +605,20 @@ const server: Server<Record<string, unknown>> = Bun.serve({
|
|
|
605
605
|
return new Response("not found", { status: 404 });
|
|
606
606
|
}
|
|
607
607
|
const file = Bun.file(resolved);
|
|
608
|
-
if (await file.exists())
|
|
608
|
+
if (await file.exists()) {
|
|
609
|
+
// Hashed assets are immutable; anything NOT hash-named (index.html,
|
|
610
|
+
// SPA fallbacks, favicon) must be revalidated — a cached index.html
|
|
611
|
+
// pins the browser to a stale bundle after every update.
|
|
612
|
+
const immutable = /-[A-Za-z0-9_-]{8}\.[a-z0-9]+$/.test(filePath);
|
|
613
|
+
return new Response(file, {
|
|
614
|
+
headers: {
|
|
615
|
+
"cache-control": immutable ? "public, max-age=31536000, immutable" : "no-store",
|
|
616
|
+
},
|
|
617
|
+
});
|
|
618
|
+
}
|
|
609
619
|
const index = Bun.file(DIST_DIR + "index.html");
|
|
610
|
-
if (await index.exists())
|
|
620
|
+
if (await index.exists())
|
|
621
|
+
return new Response(index, { headers: { "cache-control": "no-store" } });
|
|
611
622
|
}
|
|
612
623
|
return new Response("not found", { status: 404 });
|
|
613
624
|
}
|
package/skills/webui/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ service credentials. One port for UI + `/api/*`: http://localhost:4097
|
|
|
11
11
|
(`WEBUI_PROXY_PORT`).
|
|
12
12
|
|
|
13
13
|
- **Repo**: https://github.com/AbdelftahZowail/opencode-webui
|
|
14
|
-
- **This skill's version**: 1.0.
|
|
14
|
+
- **This skill's version**: 1.0.7 (matches the `v1.0.7` git tag —
|
|
15
15
|
the file links below are pinned to it, so they always describe the code
|
|
16
16
|
this skill was generated with)
|
|
17
17
|
- **A running instance exposes its version** at `GET /api/webui/config` →
|
|
@@ -24,12 +24,12 @@ fetch the exact file at the pinned tag instead of reading a local clone:
|
|
|
24
24
|
|
|
25
25
|
| File | Purpose |
|
|
26
26
|
| --- | --- |
|
|
27
|
-
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.
|
|
28
|
-
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.
|
|
29
|
-
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.
|
|
30
|
-
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.
|
|
31
|
-
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.
|
|
32
|
-
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.
|
|
27
|
+
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.7/ui-extensions/README.md | Full authoring guide — the source of truth for kinds/hooks/regions |
|
|
28
|
+
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.7/src/extensions/registry.tsx | The slot registry — exact register() shapes per kind |
|
|
29
|
+
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.7/src/components/Composer.tsx | Where slash entries / prompt hooks / composer regions live |
|
|
30
|
+
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.7/src/components/MessageItem.tsx | Where message/message.decoration/message.part render |
|
|
31
|
+
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.7/src/lib/composerHandoff.ts | Type-anywhere → composer behavior (if your extension competes for keys) |
|
|
32
|
+
| https://raw.githubusercontent.com/AbdelftahZowail/opencode-webui/v1.0.7/src/store.ts | The store — actions useStore exposes to extensions |
|
|
33
33
|
|
|
34
34
|
## Environment
|
|
35
35
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as e,o as t,s as n,u as r}from"./index-DmEJZk-g.js";var i=r(e(),1),a=`runtime-status`;function o(){let e=t(e=>e.connected),n=t(e=>e.serviceOK),r=t(e=>e.activeIDs.length),a=e&&n;return(0,i.jsxs)(`footer`,{className:`flex min-h-7 items-center justify-end gap-3 border-t border-[var(--border-weak-base)] bg-[var(--background-base)] px-3 py-1 font-mono text-[10px] text-[var(--text-weaker)]`,children:[(0,i.jsx)(`span`,{className:`hidden sm:inline`,children:`webui extension`}),(0,i.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:a?`Connected to the OpenCode service`:`Waiting for the OpenCode service`,children:[(0,i.jsx)(`span`,{className:`size-1.5 rounded-full ${a?`bg-[var(--surface-success-strong)]`:`bg-[var(--surface-warning-strong)]`}`}),a?`connected`:`offline`]}),r>0&&(0,i.jsxs)(`span`,{children:[r,` active`]})]})}n({kind:`region`,id:`runtime-status`,region:`footer`,render:()=>(0,i.jsx)(o,{})});export{a as id};
|