pikiloom 0.4.29 → 0.4.31

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.
Files changed (28) hide show
  1. package/dashboard/dist/assets/{AgentTab-DtjuI8NU.js → AgentTab-CYoIkNyL.js} +1 -1
  2. package/dashboard/dist/assets/{ConnectionModal-BIx6a5o1.js → ConnectionModal-CbWtylsE.js} +1 -1
  3. package/dashboard/dist/assets/{DirBrowser-BINh_7NB.js → DirBrowser-BsHjGC5A.js} +1 -1
  4. package/dashboard/dist/assets/ExtensionsTab-BYoLkIki.js +1 -0
  5. package/dashboard/dist/assets/{IMAccessTab-C4DbGxbG.js → IMAccessTab-B-SxDXft.js} +1 -1
  6. package/dashboard/dist/assets/{Modal-D_PUi-5O.js → Modal-CzQbFS5c.js} +1 -1
  7. package/dashboard/dist/assets/{Modals-BahDEMqf.js → Modals-V9ykx8c4.js} +1 -1
  8. package/dashboard/dist/assets/{Select-Cp5VXb_2.js → Select-DE6cseW_.js} +1 -1
  9. package/dashboard/dist/assets/SessionPanel-CMu962uE.js +1 -0
  10. package/dashboard/dist/assets/{SystemTab-CLznS31f.js → SystemTab-Cx6DyiFf.js} +1 -1
  11. package/dashboard/dist/assets/index-Cjaly0tB.js +23 -0
  12. package/dashboard/dist/assets/index-Dp_KlJM9.js +3 -0
  13. package/dashboard/dist/assets/{shared-C8DCTJ44.js → shared-DQrcGYOc.js} +1 -1
  14. package/dashboard/dist/index.html +1 -1
  15. package/dist/agent/artifacts.js +11 -1
  16. package/dist/agent/index.js +1 -1
  17. package/dist/bot/bot.js +8 -5
  18. package/dist/bot/queue-steer.js +5 -0
  19. package/dist/catalog/mcp-servers.js +24 -0
  20. package/dist/core/utils.js +12 -6
  21. package/dist/dashboard/routes/sessions.js +7 -2
  22. package/dist/pikichannel/adapter-pikiloom.js +7 -3
  23. package/dist/pikichannel/protocol.js +5 -2
  24. package/package.json +1 -1
  25. package/dashboard/dist/assets/ExtensionsTab-CHpd147b.js +0 -1
  26. package/dashboard/dist/assets/SessionPanel-DZVNXptx.js +0 -1
  27. package/dashboard/dist/assets/index-CLGovkkw.js +0 -3
  28. package/dashboard/dist/assets/index-DcYOI6rL.js +0 -23
@@ -1,23 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionPanel-DZVNXptx.js","assets/react-vendor-C7Sl8SE7.js","assets/index-CLGovkkw.js","assets/router-DHISdpPk.js","assets/index-CXIN3nTr.css","assets/Modal-D_PUi-5O.js","assets/Select-Cp5VXb_2.js","assets/DirBrowser-BINh_7NB.js","assets/markdown-DxQYQFeH.js","assets/ExtensionsTab-CHpd147b.js"])))=>i.map(i=>d[i]);
2
- import{c as M,a as ee,u as ye,i as yn,f as It,A as us,s as Dt,S as pe,B as rt,g as ln,w as hs,b as xs,E as en,C as xn,d as ps,r as Nn,e as Sn,h as fs,n as gs,j as ms,k as An,l as Bt,m as Ie,D as zt,o as bs,p as Rn,_ as _n,T as js,q as vs}from"./index-CLGovkkw.js";import{j as e,r,a as pn}from"./react-vendor-C7Sl8SE7.js";import{I as ws}from"./Select-Cp5VXb_2.js";import{M as Ft,a as Ut}from"./Modal-D_PUi-5O.js";import{D as ks}from"./DirBrowser-BINh_7NB.js";import{n as ys,r as Ns,M as fn}from"./markdown-DxQYQFeH.js";import{WorkspaceExtensionsBody as Ss}from"./ExtensionsTab-CHpd147b.js";function Cs({open:t,className:n}){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("shrink-0 text-fg-5/40 transition-transform duration-200",t&&"rotate-180",n),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function ot({open:t,onToggle:n,dot:s,label:a,preview:l,badge:c,collapsedContent:x,children:d,className:m}){return e.jsxs("div",{className:M("rounded-md border border-edge bg-panel overflow-hidden","shadow-[0_2px_8px_rgba(0,0,0,0.06)]",m),children:[e.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-panel-h/40 transition-colors",children:[s&&e.jsx("span",{className:M("h-[7px] w-[7px] shrink-0 rounded-full",s.color,s.pulse&&"animate-pulse")}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:a}),e.jsx("span",{className:"flex-1 min-w-0 overflow-hidden",children:l}),c,e.jsx(Cs,{open:t})]}),!t&&x,t&&d&&e.jsx("div",{className:"border-t border-edge",children:d})]})}const Ls=5e3,Ms=15e3,$t=8,Ot=30,Ts=1,st=new Map,ke=new Map,tn=new Set,Pn=[];let At=0;function nn(t){return typeof t=="number"&&Number.isFinite(t)}function ze(t,n,s,a){for(t.delete(n),t.set(n,s);t.size>a;){const l=t.keys().next().value;if(!l)break;t.delete(l)}}function Wn(t,n){const s=t.get(n);return!s?.value||s.expiresAt<=Date.now()?null:(ze(t,n,s,t===ke?Ot:$t),s.value)}function Bn(t){return{workdir:t.workdir,agent:t.agent,sessionId:t.sessionId,rich:t.rich??!0,lastNTurns:nn(t.lastNTurns)?t.lastNTurns:void 0,turnOffset:nn(t.turnOffset)?t.turnOffset:void 0,turnLimit:nn(t.turnLimit)?t.turnLimit:void 0}}function gn(t){const n=Bn(t);return[n.workdir,n.agent,n.sessionId,n.rich?"rich":"plain",n.lastNTurns??"",n.turnOffset??"",n.turnLimit??""].join("::")}function $n(){for(;At<Ts;){const t=Pn.shift();if(!t)return;At+=1,t().finally(()=>{At=Math.max(0,At-1),$n()})}}async function Es(t,n={}){const s=t;if(!n.force){const c=Wn(st,s);if(c)return c}const a=st.get(s);if(a?.promise)return a.promise;const l=ee.getWorkspaceSessions(t,n.request).then(c=>(ze(st,s,{value:c,expiresAt:c.ok?Date.now()+Ls:0},$t),c)).finally(()=>{const c=st.get(s);c?.promise&&ze(st,s,{value:c.value,expiresAt:c.expiresAt},$t)});return ze(st,s,{value:a?.value,expiresAt:a?.expiresAt??0,promise:l},$t),l}function Is(t,n={}){const s=gn(t),a=ke.get(s);return a?.value?.ok&&(n.allowStale||a.expiresAt>Date.now())?a.value:null}async function As(t,n={}){const s=Bn(t),a=gn(s);if(!n.force){const x=Wn(ke,a);if(x?.ok)return x}const l=ke.get(a);if(l?.promise)return l.promise;const c=ee.getSessionMessages(s.workdir,s.agent,s.sessionId,{rich:s.rich,lastNTurns:s.lastNTurns,turnOffset:s.turnOffset,turnLimit:s.turnLimit},n.request).then(x=>(ze(ke,a,{value:x,expiresAt:x.ok?Date.now()+Ms:0},Ot),x)).finally(()=>{const x=ke.get(a);x?.promise&&ze(ke,a,{value:x.value,expiresAt:x.expiresAt},Ot)});return ze(ke,a,{value:l?.value,expiresAt:l?.expiresAt??0,promise:c},Ot),c}function Rs(t){const n=gn(t);Is(t)||tn.has(n)||ke.get(n)?.promise||(tn.add(n),Pn.push(async()=>{try{await As(t)}catch{}finally{tn.delete(n)}}),$n())}function Cn(t){return(t||"").replace(/\s+/g," ").trim()}function to(t,n){return Cn(t)===Cn(n)}function no(t){const n=t.richMessages?.length?t.richMessages:t.messages?.map(x=>({role:x.role,text:x.text,blocks:[{type:"text",content:x.text}]}))||[],s=Ps(n),a=Math.max(t.window?.totalTurns??t.totalTurns??s.length,s.length),l=t.window?.endTurn??a,c=t.window?.startTurn??Math.max(0,l-s.length);return{turns:s,startTurn:c,endTurn:l,totalTurns:a,hasOlder:t.window?.hasOlder??c>0}}function so(t,n){const s=Math.max(0,t.startTurn-n.startTurn);return{turns:[...n.turns.slice(0,s),...t.turns],startTurn:n.startTurn,endTurn:t.endTurn,totalTurns:Math.max(t.totalTurns,n.totalTurns),hasOlder:n.hasOlder}}function ro(t,n){if(n.startTurn<=t.startTurn)return n;const s=Math.max(0,n.startTurn-t.startTurn);return{turns:[...t.turns.slice(0,s),...n.turns],startTurn:t.startTurn,endTurn:n.endTurn,totalTurns:n.totalTurns,hasOlder:t.startTurn>0}}function _s(t,n){const s=[t.text,n.text].filter(Boolean);return{role:t.role,text:s.join(`
3
-
4
- `),blocks:[...t.blocks,...n.blocks],usage:n.usage??t.usage??null}}function Ps(t){const n=[];let s={user:null,assistant:null};for(const a of t)if(a.role==="user"){if(s.assistant&&On(a.text))continue;(s.user||s.assistant)&&(n.push(s),s={user:null,assistant:null}),s.user=a}else s.assistant?s.assistant=_s(s.assistant,a):s.assistant=a;return(s.user||s.assistant)&&n.push(s),n}const Ws=new Set(["task-notification","system-reminder","persisted-output","local-command-stdout","local-command-caveat","local-command-stderr","ide_opened_file","ide_diagnostics","ide_selection","event","analysis","case_id","tool-use-id","output-file"]),Bs=["continued from a previous","summary below covers","earlier portion of the conversation","Summary:","Key Technical Concepts"];function On(t){const s=t.trim().match(/^<([a-z][a-z0-9_-]*)\b/i);return s&&Ws.has(s[1].toLowerCase())?!0:Bs.some(a=>t.includes(a))}function Dn(t,n){const s=t.split(`
5
- `).filter(a=>a.trim());return s.length<=n?s.join(`
6
- `):s.slice(-n).join(`
7
- `)}function $s(t){const n=String(t||"").trim().toLowerCase();return n?n.startsWith("interrupted by user")?"interrupted":n.startsWith("timed out")||n.startsWith("stopped before completion")||n.includes("max tokens")?"incomplete":"error":"error"}function sn(t){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,file:t,previewUrl:URL.createObjectURL(t)}}function Os(t){for(const n of t)URL.revokeObjectURL(n.previewUrl)}function Fn(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${t} B`;const n=t/1024;if(n<1024)return`${n.toFixed(n>=100?0:1)} KB`;const s=n/1024;return`${s.toFixed(s>=100?0:1)} MB`}async function Ds(t){if(typeof ClipboardItem>"u"||!navigator.clipboard?.write)return!1;try{return await navigator.clipboard.write([new ClipboardItem({[t.type||"image/png"]:t})]),!0}catch{return!1}}function Z(t,n=120){if(t==null)return"";const a=(typeof t=="string"?t:String(t)).replace(/\s+/g," ").trim();return a.length<=n?a:a.slice(0,Math.max(0,n-1))+"…"}function Fs(t){if(!t)return null;try{const n=JSON.parse(t);return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Un(t){const n=String(t.toolName||"").trim()||"Tool",s=Fs(t.content);if(!s)return n;const a=Z(s.description,120);switch(n){case"Read":{const l=Z(s.file_path||s.path,140);return l?`Read ${l}`:"Read"}case"Edit":{const l=Z(s.file_path||s.path,140);return l?`Edit ${l}`:"Edit"}case"Write":{const l=Z(s.file_path||s.path,140);return l?`Write ${l}`:"Write"}case"Glob":{const l=Z(s.pattern||s.glob,120);return l?`Glob ${l}`:"Glob"}case"Grep":{const l=Z(s.pattern||s.query,120);return l?`Grep ${l}`:"Grep"}case"WebFetch":{const l=Z(s.url,120);return l?`WebFetch ${l}`:"WebFetch"}case"WebSearch":{const l=Z(s.query,120);return l?`WebSearch ${l}`:"WebSearch"}case"TodoWrite":return"Update plan";case"AskUserQuestion":{const c=(Array.isArray(s.questions)?s.questions:[])[0],x=Z(c?.question||s.question,120);return x?`Ask user: ${x}`:"Ask user"}case"Task":{const l=Z(s.description||s.prompt,120);return l?`Task: ${l}`:"Task"}case"Bash":{if(a)return`Bash: ${a}`;const l=Z(s.command,120);return l?`Bash: ${l}`:"Bash"}default:{const l=n.match(/^mcp__[^_]+__(.+)$/),c=l?l[1]:n;if(c==="im_send_file"){const d=Z(s.path,120);return d?`Send file: ${d}`:"Send file"}if(c==="im_list_files")return"List workspace files";if(a)return`${n}: ${a}`;const x=Z(s.file_path||s.path||s.command||s.query||s.pattern||s.url,120);return x?`${n}: ${x}`:n}}}function Us(t){const n=(t.content||"").trim();if(!n)return"result";const s=n.split(`
8
- `).map(a=>a.trim()).find(Boolean)||"";return s?Z(s,140):"result"}function zs(t){const n=t.indexOf(":");if(n<=0)return null;const s=t.slice(0,n).trim(),a=t.slice(n+1).trim();return!s||!a?null:{agent:s,sessionId:a}}const vt=new Map;function Ks(t,n){return`${t}:${n}`}function Hs(t){const n=(()=>{try{return new URL(t.baseURL).host.toLowerCase()}catch{return""}})();return n.includes("openrouter")?"openrouter":n.includes("anthropic")?"anthropic":n.includes("deepseek")?"deepseek":n.includes("googleapis")||n.includes("vertex")?"google":n.includes("openai.com")?"openai":n.includes("dashscope")||n.includes("qwen")||n.includes("aliyun")?"qwen":n.includes("volces")||n.includes("volcengine")||n.includes("doubao")?"doubao":n.includes("bigmodel")||n.includes("zhipu")||n.includes("z.ai")?"glm":n.includes("minimax")?"minimax":t.kind==="anthropic"?"anthropic":t.kind==="google"?"google":t.kind==="openai"?"openai":"custom"}const Vs=r.memo(function({session:n,workdir:s,onStreamQueued:a,onSendStart:l,onSendTaskAssigned:c,onSessionChange:x,t:d,streamPhase:m,streamTaskId:j,queuedTaskIds:g,queuedTasks:w,pendingQueuedSends:L,onRecall:N,onSteer:I,onStopAll:T,editDraft:A,onEditDraftConsumed:W,onSelectionChange:S}){const[B,te]=r.useState(""),[E,G]=r.useState(!1),[P,D]=r.useState(null),[ae,R]=r.useState(()=>new Set),[ce,re]=r.useState(()=>new Set),Y=r.useRef({prompt:"",files:[]}),Ne=ye(i=>i.agentStatus?.agents??null),[K,wt]=r.useState(Ne||[]),[fe,lt]=r.useState(""),[Ke,He]=r.useState(""),[oe,Ae]=r.useState(""),[ne,Se]=r.useState([]),[Re,Ve]=r.useState(null),[de,kt]=r.useState(null),[ue,Ge]=r.useState(null),[_e,se]=r.useState(null),[qe,Ce]=r.useState(null),[Le,at]=r.useState(void 0),[$,q]=r.useState("closed"),[U,ct]=r.useState(null),Q=r.useRef(null),Qe=r.useRef(!1),yt=r.useRef(null),Ht=r.useRef(null),ge=r.useRef(null),dt=r.useRef([]),[me,Pe]=r.useState([]),[X,We]=r.useState(!1),[Be,$e]=r.useState(0),Ye=r.useRef(null),ut=ye(i=>i.refreshAgentStatus),[ht,Me]=r.useState([]),[be,Xe]=r.useState([]),[Je,je]=r.useState({}),Te=r.useCallback(async()=>{try{const[i,f,b]=await Promise.all([fetch("/api/models/providers").then(C=>C.json()),fetch("/api/models/profiles").then(C=>C.json()),fetch("/api/models/agents").then(C=>C.json())]);if(i?.ok&&Xe(i.providers||[]),f?.ok&&Me(f.profiles||[]),b?.ok){const C={};for(const z of b.bindings||[])C[z.agent]=z.activeProfileId;je(C)}}catch{}},[]);r.useEffect(()=>{Te()},[Te]),r.useEffect(()=>{Ne?.length&&wt(Ne)},[Ne]),r.useEffect(()=>{dt.current=ne},[ne]);const ve=Ks(n.agent||"",n.sessionId),ie=r.useRef(ve);ie.current=ve,r.useEffect(()=>{const i=vt.get(ve);return i&&(vt.delete(ve),i.text&&te(i.text),i.files.length&&Se(i.files.map(sn))),()=>{const f=Q.current?.value||"",b=dt.current.map(C=>C.file);for(const C of dt.current)URL.revokeObjectURL(C.previewUrl);f||b.length?vt.set(ie.current,{text:f,files:b}):vt.delete(ie.current)}},[ve]);const Ze=r.useRef({agent:n.agent||"",sessionId:n.sessionId});r.useEffect(()=>{const i=Ze.current,f={agent:n.agent||"",sessionId:n.sessionId};Ze.current=f,!(i.agent===f.agent&&yn(i.sessionId)&&!yn(f.sessionId))&&(lt(""),He(""),Ae(""),Ge(null),se(null),Ce(null),q("closed"))},[n.agent,n.sessionId]),r.useEffect(()=>{A!=null&&(te(A),W?.(),requestAnimationFrame(()=>{const i=Q.current;i&&(i.focus(),i.setSelectionRange(A.length,A.length))}))},[A,W]),r.useEffect(()=>{if(!s)return;let i=!1;return ee.getSkills(s).then(f=>{!i&&f.ok&&Pe(f.skills)}).catch(()=>{}),()=>{i=!0}},[s]);const xt=X?(()=>{const i=B.match(/^\/(\S*)$/);return i?i[1].toLowerCase():null})():null,we=xt!==null?me.filter(i=>i.name.toLowerCase().includes(xt)||i.label&&i.label.toLowerCase().includes(xt)):[];r.useEffect(()=>{$e(0)},[X,B]),r.useEffect(()=>{if(!X||!Ye.current)return;const i=Ye.current.querySelector(`[data-skill-idx="${Be}"]`);i&&i.scrollIntoView({block:"nearest"})},[Be,X]),r.useEffect(()=>{if(!X)return;const i=f=>{Ye.current?.contains(f.target)||Q.current?.contains(f.target)||We(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[X]),r.useEffect(()=>{if($==="closed")return;const i=f=>{const b=f.target;ge.current?.contains(b)||document.getElementById("cascade-portal")?.contains(b)||(q("closed"),Ge(null),se(null),Ce(null))};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[$]),r.useLayoutEffect(()=>{if($==="closed"||!ge.current){ct(null);return}const i=ge.current.getBoundingClientRect();ct({left:i.left,bottom:window.innerHeight-i.top+8})},[$]);const Nt=g&&g.length?g[0]:null;r.useEffect(()=>{P&&(Nt||m!==null&&m!=="queued")&&D(null)},[m,P,Nt]),r.useEffect(()=>{const i=Q.current;i&&(i.style.height="auto",i.style.height=Math.min(i.scrollHeight,200)+"px")},[B]);const pt=r.useCallback(i=>{const f=Array.from(i||[]).filter(b=>b.type.startsWith("image/"));f.length&&Se(b=>[...b,...f.map(sn)])},[]),St=r.useCallback(()=>{Ve(null),Se(i=>(Os(i),[]))},[]),Ct=r.useCallback(i=>{Se(f=>{const b=f.find(C=>C.id===i);return b&&URL.revokeObjectURL(b.previewUrl),f.filter(C=>C.id!==i)}),Ve(f=>f===i?null:f)},[]),Lt=r.useCallback(()=>{const i=B.trim(),f=ne.map(J=>J.file);if(!i&&f.length===0||E)return;const b=fe||n.agent||K.find(J=>J.isDefault)?.agent||"";if(!b)return;const C=K.find(J=>J.agent===b)||null,z=!!n.agent&&b===n.agent,xe=(Ke||z&&n.model||""||C?.selectedModel||"").trim()||null,Fe=b==="gemini"?null:(oe||(z?It(b,n.thinkingEffort,n.workflowEnabled):"")||It(b,C?.selectedEffort,C?.workflowEnabled)||"").trim()||null,Ee=b!==n.agent,le=Ee?"":n.sessionId,Zt=Ee&&n.agent?n.agent:null,cs=Ee&&n.sessionId?n.sessionId:null;G(!0),Y.current={prompt:i,files:f},te(""),vt.delete(ie.current);const ds=f.length?f.map(J=>URL.createObjectURL(J)):void 0;St(),l(i,ds),a(),ee.sendSessionMessage(s,b,le,i,{attachments:f,model:xe,effort:Fe,previousAgent:Zt,previousSessionId:cs}).then(J=>{if(J.taskId&&(D(J.taskId),c?.(J.taskId)),!J.ok)return;const jt=typeof J.sessionKey=="string"?zs(J.sessionKey):null;jt&&(jt.agent!==n.agent||jt.sessionId!==n.sessionId)&&jt&&x?.({...jt,workdir:s})}).catch(()=>{}).finally(()=>G(!1))},[K,St,ne,B,l,c,x,a,fe,oe,Ke,E,n.agent,n.sessionId,s]),Mt=m==="streaming",he=(()=>{const i=[];return g&&g.length&&i.push(...g),m==="queued"&&j&&!i.includes(j)&&i.unshift(j),P&&!i.includes(P)&&(m==="queued"||!m)&&i.push(P),i})(),ft=he[he.length-1]||null,gt=he.length>0,Vt=gt||Mt;r.useEffect(()=>{const i=f=>he.includes(f)||f===j;R(f=>{let b=!1;const C=new Set;for(const z of f)i(z)?C.add(z):b=!0;return b?C:f}),re(f=>{let b=!1;const C=new Set;for(const z of f)i(z)?C.add(z):b=!0;return b?C:f})},[he,j]),r.useEffect(()=>{!gt&&Y.current.files.length&&(Y.current={prompt:"",files:[]})},[gt]);const Gt=r.useCallback(i=>{if(!ae.has(i)){if(R(f=>{const b=new Set(f);return b.add(i),b}),i===ft){const f=Y.current;f.prompt&&te(f.prompt),f.files.length&&Se(f.files.map(sn)),Y.current={prompt:"",files:[]}}N?.(i),i===P&&D(null)}},[ae,ft,P,N]),[et,Tt]=r.useState(!1),o=r.useCallback(async()=>{if(!(et||!T)){Tt(!0);try{await T()}finally{Tt(!1)}}},[et,T]),h=r.useCallback(i=>{ce.has(i)||(re(f=>{const b=new Set(f);return b.add(i),b}),I?.(i),i===P&&D(null))},[ce,P,I]),u=r.useCallback(i=>{te(`/${i.name} `),We(!1),requestAnimationFrame(()=>{const f=Q.current;f&&(f.focus(),f.setSelectionRange(f.value.length,f.value.length))})},[]),p=r.useCallback(i=>{te(i);const f=/^\/\S*$/.test(i)&&me.length>0;We(f)},[me.length]),v=i=>{if(X&&we.length>0){if(i.key==="ArrowDown"){i.preventDefault(),$e(f=>(f+1)%we.length);return}if(i.key==="ArrowUp"){i.preventDefault(),$e(f=>(f-1+we.length)%we.length);return}if(i.key==="Tab"||i.key==="Enter"&&!i.shiftKey&&!Qe.current){i.preventDefault(),u(we[Be]);return}if(i.key==="Escape"){i.preventDefault(),We(!1);return}}i.key==="Enter"&&!i.shiftKey&&!Qe.current&&(i.preventDefault(),Lt())},y=r.useCallback(i=>{const f=Array.from(i.clipboardData?.items||[]).filter(b=>b.kind==="file"&&b.type.startsWith("image/")).map(b=>b.getAsFile()).filter(b=>!!b);f.length&&(i.preventDefault(),pt(f))},[pt]),k=fe||n.agent||K.find(i=>i.isDefault)?.agent||K.find(i=>i.installed)?.agent||K[0]?.agent||"",H=K.find(i=>i.agent===k)||null,F=ue||k,_=K.find(i=>i.agent===F)||H,O=r.useMemo(()=>{if(!_)return[];const i=[];for(const b of _.models||[])i.push({id:b.id,label:b.id,kind:"native",description:b.alias&&b.alias.toLowerCase()!==b.id.toLowerCase()?b.alias:void 0});const f=new Set(us[F]||[]);for(const b of ht){const C=be.find(xe=>xe.id===b.providerId);if(!C||!f.has(C.kind))continue;const z=b.name.trim().toLowerCase()!==b.modelId.trim().toLowerCase();i.push({id:b.modelId,label:b.name,kind:"profile",profileId:b.id,description:z?`${C.name} · ${b.modelId}`:C.name})}return i},[_,F,ht,be]),mt=r.useMemo(()=>O.findIndex(i=>i.kind==="profile"),[O]),jn=Je[F]||null,vn=!!n.agent&&k===n.agent,bt=Ke||vn&&n.model||""||H?.selectedModel||"",Et=k==="gemini"?"":oe||(vn?It(k,n.thinkingEffort,n.workflowEnabled):"")||It(k,H?.selectedEffort,H?.workflowEnabled)||"";r.useEffect(()=>{S?.({model:bt||null,effort:Et||null})},[bt,Et,S]);const ss=en[F]||[],Oe=Re&&ne.find(i=>i.id===Re)||null,rs=Oe?{key:Oe.id,url:Oe.previewUrl,name:Oe.file.name,size:Oe.file.size,file:Oe.file,onRemove:()=>Ct(Oe.id)}:de?{key:de,url:de}:null,wn=(!!B.trim()||ne.length>0)&&!E&&!!k,qt=()=>{Ge(null),se(null),Ce(null),at(void 0)},Qt=r.useCallback(async(i,f,b)=>{const C=i==="gemini"?"":b||"";if(Le!==void 0)try{await fetch(`/api/models/agents/${i}/active`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:Le})}),Te(),ut()}catch{}lt(i),He(f),Ae(C),qt(),q("closed")},[Le,Te,ut]),os=()=>{$==="closed"?(qt(),ut(),Te(),q("agent")):(qt(),q("closed"))},Yt=ue||k,kn=ln(Yt),Xt=_e??bt,tt=qe??Et,is=Xt?Dt(Xt):"",De=(()=>{const i=Je[Yt];return i?ht.find(f=>f.id===i)??null:null})(),nt=De?be.find(i=>i.id===De.providerId)??null:null,ls=nt?Hs(nt):null,Jt=De?De.name.trim().toLowerCase()!==De.modelId.trim().toLowerCase()?De.name:Dt(De.modelId):is,as=[kn.shortLabel,nt?nt.name:null,Jt||null,tt?tt.charAt(0).toUpperCase()+tt.slice(1):null].filter(Boolean).join(" / ");return e.jsxs("div",{className:"shrink-0",ref:Ht,children:[e.jsxs("div",{className:"max-w-[680px] mx-auto px-5 pb-4 pt-2",children:[Vt&&e.jsxs("div",{className:"mb-2 space-y-1.5",children:[Mt&&e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-primary/20 bg-primary/[0.04] px-3.5 py-1.5 transition-colors",children:[e.jsx(pe,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 text-[12px] font-medium text-fg-3 truncate",children:d("hub.running")}),e.jsxs("button",{onClick:o,disabled:et,title:d("hub.stopHint"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-fg-4 hover:text-err hover:bg-err/10 transition-colors disabled:opacity-30 disabled:pointer-events-none shrink-0",children:[et?e.jsx(pe,{className:"h-2.5 w-2.5"}):e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),d("hub.stop")]})]}),he.map((i,f)=>{const b=f===he.length-1,C=ce.has(i),z=C?d("hub.steering"):he.length>1?`${d("hub.queued")} #${f+1}`:d("hub.queued"),xe=L?.find(le=>le.taskId===i)||(b?L?.find(le=>!le.taskId):void 0),Fe=w?.find(le=>le.taskId===i)?.prompt||xe?.prompt||null,Ee=xe?.imageUrls?.length?xe.imageUrls:[];return e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-warn/25 bg-warn/[0.04] px-3.5 py-1.5 transition-colors",children:[C?e.jsx(pe,{className:"h-3 w-3 text-warn shrink-0"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-warn animate-pulse shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-medium text-warn shrink-0",children:z}),Ee.length>0&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[Ee.slice(0,3).map((le,Zt)=>e.jsx("button",{type:"button",onClick:()=>kt(le),title:d("hub.previewImage"),className:"block h-5 w-5 shrink-0 overflow-hidden rounded border border-warn/30 transition-opacity hover:opacity-80",children:e.jsx("img",{src:le,alt:"",className:"h-full w-full object-cover"})},`${le}-${Zt}`)),Ee.length>3&&e.jsxs("span",{className:"text-[10px] text-fg-5/60",children:["+",Ee.length-3]})]}),Fe&&e.jsx("span",{className:"text-[11px] text-fg-5/60 truncate",children:Fe})]}),!C&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>h(i),title:d("hub.steerHint"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-fg-4 hover:text-blue-400 hover:bg-blue-400/10 transition-colors disabled:opacity-30 disabled:pointer-events-none",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),d("hub.steer")]}),e.jsxs("button",{onClick:()=>Gt(i),disabled:ae.has(i),title:d("hub.recallHint"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-fg-4 hover:text-err hover:bg-err/10 transition-colors disabled:opacity-30 disabled:pointer-events-none",children:[ae.has(i)?e.jsx(pe,{className:"h-2.5 w-2.5"}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"M6 6l12 12"})]}),d("hub.recall")]})]})]},i)})]}),e.jsxs("div",{className:"relative rounded-xl border border-edge/40 bg-panel shadow-sm transition-[border-color,box-shadow] duration-200 focus-within:border-fg-5/40 focus-within:shadow-md",children:[e.jsx("input",{ref:yt,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:i=>{pt(i.target.files),i.target.value=""}}),ne.length>0&&e.jsx("div",{className:"px-3 pt-3",children:e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:ne.map(i=>e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>Ve(i.id),title:d("hub.previewImage"),className:"group relative h-[72px] w-[72px] overflow-hidden rounded-lg border border-edge/30 bg-panel-alt/30",children:[e.jsx("img",{src:i.previewUrl,alt:i.file.name,className:"h-full w-full object-cover transition-transform duration-200 group-hover:scale-[1.03]"}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/60 via-black/10 to-transparent px-1.5 pb-1 pt-3 text-left",children:e.jsx("div",{className:"truncate text-[8px] font-medium text-white/90 leading-tight",children:i.file.name})})]}),e.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),Ct(i.id)},title:d("hub.removeImage"),className:"absolute -right-1 -top-1 flex h-5 w-5 items-center justify-center rounded-full border border-white/10 bg-black/65 text-white/75 transition-colors hover:bg-black/80 hover:text-white",children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]},i.id))})}),X&&we.length>0&&e.jsxs("div",{ref:Ye,className:"absolute bottom-full left-0 right-0 mb-1.5 z-50 max-h-[200px] overflow-y-auto rounded-xl border border-edge/40 bg-[var(--th-dropdown)] backdrop-blur-xl shadow-lg animate-in",children:[e.jsx("div",{className:"px-3 pt-2 pb-1 border-b border-edge/20",children:e.jsx("span",{className:"text-[10px] font-semibold text-fg-5 uppercase tracking-wider",children:d("hub.skills")})}),e.jsx("div",{className:"py-1",children:we.map((i,f)=>e.jsxs("button",{"data-skill-idx":f,onMouseDown:b=>{b.preventDefault(),u(i)},onMouseEnter:()=>$e(f),className:M("flex flex-col w-full px-3 py-1.5 text-left transition-colors",f===Be?"bg-panel-h text-fg":"text-fg-3 hover:bg-panel-alt/50"),children:[e.jsxs("span",{className:"text-[12.5px] font-medium",children:["/",i.name]}),(i.label||i.description)&&e.jsx("span",{className:"text-[11px] text-fg-5 truncate",children:i.label||i.description})]},i.name))})]}),e.jsx("textarea",{ref:Q,value:B,onChange:i=>p(i.target.value),onPaste:y,onKeyDown:v,onCompositionStart:()=>{Qe.current=!0},onCompositionEnd:()=>{Qe.current=!1},placeholder:d("hub.inputPlaceholder"),rows:1,className:"w-full resize-none bg-transparent px-4 pt-3 pb-1 text-[13.5px] text-fg outline-none placeholder:text-fg-5/25 leading-[1.6]",style:{maxHeight:200,overflow:B.split(`
9
- `).length>6?"auto":"hidden"}}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 pb-2 pt-1",children:[e.jsx("button",{type:"button",onClick:()=>yt.current?.click(),title:d("hub.addImages"),className:"flex h-7 w-7 items-center justify-center rounded-lg text-fg-5/50 transition-colors hover:bg-panel-h/60 hover:text-fg-3",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}),e.jsxs("button",{ref:ge,onClick:os,disabled:!K.length,title:K.length?as:void 0,className:M("flex items-center gap-1.5 h-[28px] px-2.5 rounded-lg text-[11px] font-medium transition-all duration-200 select-none",$!=="closed"?"bg-panel-h border border-edge-h text-fg-3":"text-fg-5/60 hover:text-fg-4 hover:bg-panel-h/50 border border-transparent"),children:[K.length?e.jsx(rt,{brand:Yt,size:12}):e.jsx(pe,{className:"h-3 w-3"}),K.length?e.jsxs("span",{className:"flex items-center gap-1 max-w-[460px] min-w-0 truncate",children:[e.jsx("span",{className:"shrink-0",children:kn.shortLabel}),nt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-5/40 shrink-0",children:"/"}),e.jsx(rt,{brand:ls||"custom",size:12}),e.jsx("span",{className:"shrink-0 truncate max-w-[140px]",children:nt.name})]}),Jt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-5/40 shrink-0",children:"/"}),e.jsx("span",{className:"truncate",title:Xt||void 0,children:Jt})]}),tt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-5/40 shrink-0",children:"/"}),e.jsx("span",{className:"shrink-0",children:tt.charAt(0).toUpperCase()+tt.slice(1)})]})]}):e.jsx("span",{className:"max-w-[420px] truncate",children:d("hub.selectAgent")}),e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:M("text-fg-5/30 transition-transform duration-200",$!=="closed"&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),$!=="closed"&&U&&pn.createPortal(e.jsxs("div",{id:"cascade-portal",className:"fixed z-[200] w-[300px] rounded-xl border border-edge/40 bg-[var(--th-dropdown)] backdrop-blur-xl shadow-lg overflow-hidden animate-in",style:{left:U.left,bottom:U.bottom},children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2.5 pb-1.5 border-b border-edge/20",children:[$!=="agent"&&e.jsx("button",{onClick:()=>{if($==="effort"){const i=_?.capabilities?.modelSwitch!==!1;q(i?"model":"agent")}else q("agent")},className:"p-0.5 rounded text-fg-5/50 hover:text-fg-3 transition-colors",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-[10px] font-semibold text-fg-5 uppercase tracking-wider",children:d($==="agent"?"hub.selectAgent":$==="model"?"hub.selectModel":"hub.selectEffort")}),e.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:(()=>{const f=_?.capabilities?.modelSwitch!==!1?["agent","model","effort"]:["agent","effort"],b=f.indexOf($);return f.map((C,z)=>e.jsx("span",{className:M("w-1.5 h-1.5 rounded-full transition-colors",$===C?"bg-primary":z<b?"bg-primary/40":"bg-fg-5/15")},C))})()})]}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto py-1",children:[$==="agent"&&K.filter(i=>i.installed).map(i=>{const f=ln(i.agent),b=hs(i.usage),C=b?xs(b):"ok";return e.jsxs(rn,{selected:i.agent===(ue||k),onClick:()=>{if(Ge(i.agent),se(i.selectedModel||""),Ce(i.selectedEffort||""),!(i.capabilities?.modelSwitch!==!1)){(en[i.agent]||[]).length?q("effort"):Qt(i.agent,i.selectedModel||"",null);return}q("model")},children:[e.jsx(rt,{brand:i.agent,size:14}),e.jsx("span",{style:{color:f.color},children:f.label}),b&&e.jsxs("span",{className:M("ml-auto font-mono text-[10px]",C==="err"?"text-err":C==="warn"?"text-warn":"text-fg-5"),children:[b.label," ",Math.round(b.usedPercent??0),"%"]})]},i.agent)}),$==="model"&&e.jsxs(e.Fragment,{children:[O.map((i,f)=>{const b=f===0&&i.kind==="native",C=f===mt&&i.kind==="profile",z=Le!==void 0?Le:jn,xe=i.kind==="profile"?!!i.profileId&&i.profileId===z:!z&&i.id===(_e??bt);return e.jsxs("div",{children:[b&&e.jsx("div",{className:"px-3 pb-1 pt-1.5 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:d("hub.modelGroupNative")}),C&&e.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:d("hub.modelGroupProfiles")}),e.jsx(rn,{selected:xe,onClick:()=>{const Fe=ue||k;if(se(i.id),at(i.profileId??null),en[Fe]?.length){q("effort");return}Qt(Fe,i.id,null)},children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:M("truncate text-[11.5px]",i.kind==="native"&&"font-mono text-[11px]"),title:i.id,children:i.label}),i.description&&e.jsx("div",{className:"truncate text-[10px] text-fg-5/80",children:i.description})]})})]},`${i.kind}:${i.profileId||i.id}`)}),O.length===0&&e.jsx("div",{className:"px-3 py-3 text-[11px] text-fg-5 text-center",children:d("config.noModel")})]}),$==="effort"&&ss.map(i=>e.jsx(rn,{selected:i===(qe||Et),onClick:()=>{Ce(i),Qt(ue||k,_e??bt,i)},children:i.charAt(0).toUpperCase()+i.slice(1)},i))]})]}),document.body),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:Lt,disabled:!wn,className:M("flex items-center justify-center w-[30px] h-[30px] rounded-lg transition-all duration-200",wn?"bg-primary text-primary-fg hover:brightness-110 shadow-sm":"bg-fg/6 text-fg-5/20"),children:E?e.jsx(pe,{className:"h-3.5 w-3.5"}):e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),e.jsx("polyline",{points:"5 12 12 5 19 12"})]})})]})]})]}),e.jsx(Gs,{source:rs,onClose:()=>{Ve(null),kt(null)},t:d})]})});function Gs({source:t,onClose:n,t:s}){const[a,l]=r.useState(!1);if(r.useEffect(()=>{l(!1)},[t?.key]),r.useEffect(()=>{if(!t)return;const d=m=>{m.key==="Escape"&&n()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,n]),!t)return null;const c=t.file,x=t.onRemove;return pn.createPortal(e.jsx("div",{className:"fixed inset-0 z-[220] flex items-center justify-center bg-black/72 px-4 py-6 backdrop-blur-sm",onClick:n,children:e.jsxs("div",{className:"w-full max-w-[1024px]",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-[11px] text-white/72",children:[t.name&&e.jsx("span",{className:"truncate font-medium text-white/90",children:t.name}),typeof t.size=="number"&&e.jsx("span",{children:Fn(t.size)}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[c&&e.jsx("button",{type:"button",onClick:async()=>{await Ds(c)&&(l(!0),window.setTimeout(()=>l(!1),1600))},className:"rounded-lg border border-white/12 bg-white/10 px-3 py-1.5 text-[11px] font-medium text-white/88 transition-colors hover:bg-white/14",children:s(a?"hub.copied":"hub.copyImage")}),x&&e.jsx("button",{type:"button",onClick:x,className:"rounded-lg border border-white/12 bg-white/10 px-3 py-1.5 text-[11px] font-medium text-white/88 transition-colors hover:bg-white/14",children:s("hub.removeImage")}),e.jsx("button",{type:"button",onClick:n,className:"flex h-9 w-9 items-center justify-center rounded-full border border-white/12 bg-white/10 text-white/88 transition-colors hover:bg-white/14",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-white/10 bg-black/35 shadow-[0_20px_70px_rgba(0,0,0,0.45)]",children:e.jsx("img",{src:t.url,alt:t.name||"",className:"max-h-[80vh] w-full object-contain"})})]})}),document.body)}function rn({selected:t,onClick:n,children:s}){return e.jsxs("button",{onClick:n,className:M("flex items-center gap-2 w-full px-3 py-2 text-[12px] text-left transition-colors",t?"text-fg bg-panel-h font-medium":"text-fg-3 hover:bg-panel-alt/50 hover:text-fg-2"),children:[s,t&&e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"ml-auto text-ok",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),!t&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"ml-auto text-fg-5/20",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})]})}function qs(){return function(t){ys(t)}}const mn=[Ns,qs],zn=t=>/^https?:\/\//.test(t),Qs=t=>/^[a-z][a-z0-9+.-]*:\/\//i.test(t);function Ys(t){return t.replace(/:(\d+)(?::\d+)?$/,"")}function Xs(t){let n=t.trim();const s=[["`","`"],['"','"'],["'","'"],["<",">"]];let a=!0;for(;a&&n.length>=2;){a=!1;for(const[l,c]of s)n.startsWith(l)&&n.endsWith(c)&&(n=n.slice(l.length,-c.length).trim(),a=!0)}return n}function Kn(t){let n=Xs(t),s="";for(;n.length>1;){const a=n[n.length-1];if(!a||!/[),.;!?]/.test(a)||a==="."&&/^\.[A-Za-z0-9_-]+$/.test(n))break;s=a+s,n=n.slice(0,-1)}return{text:n,trailing:s}}function an(t){const n=Kn(t).text;if(!n||zn(n)||Qs(n)&&!n.startsWith("file://"))return!1;const s=Ys(n);if(!s)return!1;if(s.startsWith("file://"))return s.length>7;if(/^[A-Za-z]:[\\/]/.test(s))return!0;if(/^(\/|~\/|\.{1,2}\/)/.test(s))return s.length>1;if(s.includes("/")){const a=s.split("/")[0]||"";return!/^[A-Za-z0-9-]+\.[A-Za-z]{2,}$/.test(a)}return!1}function bn(t,n){ee.openInEditor(t,void 0,n||void 0).catch(()=>{})}function Hn(t,n,s){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),bn(n,s))}function Js({locator:t,workdir:n,children:s}){return e.jsx("span",{role:"link",tabIndex:0,title:t,className:"text-blue-400 underline underline-offset-2 decoration-blue-400/30 cursor-pointer hover:text-blue-300 transition-colors",onClick:()=>bn(t,n),onKeyDown:a=>Hn(a,t,n),children:s??t})}function Zs({text:t}){const[n,s]=r.useState(!1),a=()=>{navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)}).catch(()=>{})};return e.jsx("button",{onClick:a,className:"flex items-center text-fg-5/50 hover:text-fg-3 transition-colors",children:n?e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function Ln(t){const n=an(t),s=/^(npm |npx |git |python|pip |yarn |pnpm |cargo |go |make )/.test(t);return n?"bg-blue-500/8 border-blue-400/12 text-blue-300/90":s?"bg-amber-500/8 border-amber-400/10 text-amber-300/80":"bg-[rgba(255,255,255,0.06)] border-edge/20 text-fg-3"}function Kt(t={}){const n=t.workdir||null;return{h1:({children:s})=>e.jsx("h2",{className:"text-[16px] font-bold text-fg mt-4 mb-2",children:s}),h2:({children:s})=>e.jsx("h3",{className:"text-[14.5px] font-semibold text-fg mt-4 mb-1.5",children:s}),h3:({children:s})=>e.jsx("h4",{className:"text-[13.5px] font-semibold text-fg mt-3 mb-1",children:s}),p:({children:s})=>e.jsx("p",{className:"my-1.5 whitespace-pre-wrap break-words",children:s}),strong:({children:s})=>e.jsx("strong",{className:"font-semibold text-fg",children:s}),em:({children:s})=>e.jsx("em",{className:"italic text-fg-3",children:s}),a:({href:s,children:a})=>s&&zn(s)?e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 underline underline-offset-2 decoration-blue-400/30 cursor-pointer hover:text-blue-300 transition-colors",children:a}):s&&an(s)?e.jsx(Js,{locator:Kn(s).text,workdir:n,children:a}):e.jsx("span",{className:"text-blue-400 underline underline-offset-2 decoration-blue-400/30",children:a}),ul:({children:s})=>e.jsx("ul",{className:"space-y-1 my-2 ml-1",children:s}),ol:({children:s})=>e.jsx("ol",{className:"space-y-1 my-2 ml-1 list-decimal list-inside",children:s}),li:({children:s})=>e.jsxs("li",{className:"flex gap-2 items-start",children:[e.jsx("span",{className:"shrink-0 mt-[10px] w-[5px] h-[5px] rounded-full bg-fg-5/40"}),e.jsx("span",{className:"flex-1",children:s})]}),blockquote:({children:s})=>e.jsx("blockquote",{className:"border-l-2 border-fg-5/30 pl-3 my-2 text-fg-4 italic",children:s}),hr:()=>e.jsx("hr",{className:"border-edge/30 my-4"}),code:({className:s,children:a})=>{const l=String(a).replace(/\n$/,""),c=/language-(\w+)/.exec(s||"");if(!c&&!s&&!l.includes(`
10
- `))return an(l)?e.jsx("code",{role:"link",tabIndex:0,title:l,className:M("px-1.5 py-[1px] rounded text-[12px] font-mono border cursor-pointer hover:brightness-125 transition-all",Ln(l)),onClick:()=>bn(l,n),onKeyDown:d=>Hn(d,l,n),children:l}):e.jsx("code",{className:M("px-1.5 py-[1px] rounded text-[12px] font-mono border",Ln(l)),children:l});const x=c?.[1]||"";return e.jsxs("div",{className:"rounded-lg overflow-hidden border border-edge/30 bg-[rgba(0,0,0,0.25)] my-3 not-prose",children:[e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-1.5 border-b border-edge/15 bg-[rgba(0,0,0,0.12)]",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-5/50",children:x||"text"}),e.jsx(Zs,{text:l})]}),e.jsx("pre",{className:"px-3.5 py-3 text-[12px] leading-[1.65] text-fg-3 font-mono whitespace-pre-wrap break-words overflow-x-auto",children:e.jsx("code",{children:l})})]})},pre:({children:s})=>e.jsx(e.Fragment,{children:s}),table:({children:s})=>e.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-edge/30",children:e.jsx("table",{className:"w-full text-[12.5px]",children:s})}),thead:({children:s})=>e.jsx("thead",{className:"bg-[rgba(0,0,0,0.1)]",children:s}),th:({children:s})=>e.jsx("th",{className:"px-3 py-1.5 text-left font-semibold text-fg-3 border-b border-edge/30",children:s}),td:({children:s})=>e.jsx("td",{className:"px-3 py-1.5 text-fg-4 border-t border-edge/12",children:s}),tr:({children:s})=>e.jsx("tr",{className:"even:bg-[rgba(255,255,255,0.015)]",children:s})}}Kt();function it(t){return!!t?.steps?.length}function er(t,n){let s=t;for(const[a,l]of Object.entries(n))s=s.replace(new RegExp(`\\{${a}\\}`,"g"),l);return s}function tr({status:t}){return t==="completed"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-ok",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):t==="inProgress"?e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cyan-400 animate-pulse"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/25"})}function Vn({plan:t,t:n,className:s}){const[a,l]=r.useState(!1);if(!it(t))return null;const c=t.steps.length,x=t.steps.filter(j=>j.status==="completed").length,d=c>0&&x===c,m=er(n("hub.planProgress"),{done:String(x),total:String(c)});return e.jsx(ot,{open:a,onToggle:()=>l(j=>!j),dot:{color:d?"bg-emerald-400/60":"bg-cyan-400/60",pulse:!d},label:m,preview:t.explanation?e.jsx("span",{className:"text-[11.5px] text-fg-4 truncate",children:t.explanation}):void 0,badge:e.jsx("span",{className:M("rounded-md border px-1.5 py-0.5 text-[10px] font-mono",d?"border-ok/20 text-ok":"border-edge text-fg-5"),children:n(d?"hub.planDone":"hub.planInProgress")}),className:s,children:e.jsx("div",{className:"px-3.5 py-2.5 space-y-1",children:t.steps.map((j,g)=>{const w=j.status==="completed"?"text-fg-5 line-through decoration-fg-5/40":j.status==="inProgress"?"text-fg-3":"text-fg-4";return e.jsxs("div",{className:"flex items-center gap-2 py-[2px]",children:[e.jsx("span",{className:"shrink-0 flex items-center justify-center w-[10px]",children:e.jsx(tr,{status:j.status})}),e.jsx("span",{className:M("text-[12px] leading-[1.5]",w),children:j.step})]},`${g}:${j.step}`)})})})}function Gn({url:t,fileName:n,fileSize:s,caption:a}){return e.jsxs("div",{className:"flex flex-col gap-1 max-w-[340px]",children:[e.jsxs("a",{href:t,download:n,target:"_blank",rel:"noreferrer",title:a||n,className:M("group inline-flex items-center gap-2.5 rounded-md no-underline","border border-fg-6/40 bg-fg-6/[0.05] px-3 py-2","hover:bg-fg-6/[0.12] hover:border-fg-6/60 transition-colors"),children:[e.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded bg-fg-6/10 text-fg-3",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[12.5px] font-medium text-fg-2",children:n}),typeof s=="number"&&s>0&&e.jsx("span",{className:"block text-[11px] text-fg-5/70",children:Fn(s)})]}),e.jsx("span",{className:"shrink-0 text-fg-5/50 group-hover:text-fg-3 transition-colors",children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]}),a&&e.jsx("span",{className:"px-0.5 text-[11.5px] leading-[1.55] text-fg-4 break-words",children:a})]})}function qn(t){return!!t.text||!!t.thinking||!!(t.activity&&t.activity.split(`
11
- `).filter(Boolean).length)||!!t.previewMeta?.toolCalls?.length||it(t.plan)||!!(t.subAgents&&t.subAgents.length)||!!(t.artifacts&&t.artifacts.length)}function oo(t){return qn(t)||t.phase==="streaming"?!0:t.phase==="done"&&!!t.error}function nr(t){return t.phase!=="done"||!t.error?null:qn(t)?"hub.streamErrored":"hub.streamFailed"}function sr({detail:t,t:n,className:s}){const a=$s(t);if(a==="interrupted")return e.jsxs("div",{className:M("flex items-center gap-1.5 text-[11px] text-fg-5/55",s),children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px] bg-fg-5/45 shrink-0"}),e.jsx("span",{children:n("hub.turnStopped")})]});const l=a==="error"?{dot:"bg-rose-400/55",text:"text-rose-300/65"}:{dot:"bg-fg-5/40",text:"text-fg-5/55"};return e.jsxs("div",{className:M("flex items-start gap-1.5 text-[11px] leading-[1.6]",l.text,s),children:[e.jsx("span",{className:M("mt-[5px] h-1 w-1 rounded-full shrink-0",l.dot)}),e.jsx("span",{className:"min-w-0 break-words",children:t})]})}const rr=64;function or(t,n){const[s,a]=r.useState(t),l=r.useRef(0),c=r.useRef(null);return r.useEffect(()=>{if(n<=0)return;const x=Date.now()-l.current,d=()=>{l.current=Date.now(),a(t)};return x>=n?d():(c.current&&clearTimeout(c.current),c.current=window.setTimeout(d,n-x)),()=>{c.current&&clearTimeout(c.current)}},[t,n]),n<=0?t:s}function io({stream:t,t:n,workdir:s}){const a=it(t.plan),[l,c]=r.useState(!1),[x,d]=r.useState(!1),m=r.useRef(null),j=r.useRef(null),g=nr(t),w=r.useMemo(()=>(t.activity||"").split(`
12
- `).filter(Boolean),[t.activity]),L=t.previewMeta?.toolCalls??[],N=w[w.length-1]||L[L.length-1]?.summary||"";r.useLayoutEffect(()=>{const S=m.current;S&&l&&(S.scrollTop=S.scrollHeight)},[l,t.activity,L.length]),r.useLayoutEffect(()=>{const S=j.current;S&&x&&(S.scrollTop=S.scrollHeight)},[x,t.thinking]);const I=t.subAgents??null,T=or(t.text,t.phase==="streaming"?rr:0),A=r.useMemo(()=>Kt({workdir:s}),[s]),W=r.useMemo(()=>e.jsx(fn,{remarkPlugins:mn,components:A,children:T}),[T,A]);return e.jsxs("div",{className:"space-y-3 animate-in",children:[a&&e.jsx(Vn,{plan:t.plan,t:n,className:"mb-1 max-w-[760px]"}),I&&I.length>0&&I.map(S=>e.jsx(Qn,{sub:S,t:n},S.id)),(L.length>0||w.length>0)&&e.jsx(ot,{open:l,onToggle:()=>c(S=>!S),dot:{color:"bg-cyan-400/60",pulse:!0},label:n("hub.activity"),preview:e.jsx("span",{className:"text-[12px] text-fg-4 truncate",children:N}),badge:(L.length||w.length)>1?e.jsx(xn,{children:L.length||w.length}):void 0,children:e.jsx("div",{ref:m,className:"px-3.5 py-2.5 space-y-0.5 max-h-[280px] overflow-y-auto",children:L.length>0?L.map(S=>e.jsx(ir,{call:S},S.id)):w.map((S,B)=>e.jsxs("div",{className:"flex items-center gap-1.5 py-[2px]",children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0 bg-fg-5/30"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 truncate",children:S})]},B))})}),t.thinking&&e.jsx(ot,{open:x,onToggle:()=>d(S=>!S),dot:{color:"bg-violet-400/50",pulse:!0},label:n("hub.thinking"),collapsedContent:e.jsx("div",{className:"px-3.5 pb-2.5 -mt-0.5 text-[12px] text-fg-4 leading-[1.65] whitespace-pre-wrap break-words line-clamp-3",children:Dn(t.thinking,3)}),children:e.jsx("div",{ref:j,className:"px-3.5 py-3 text-[12px] text-fg-4 leading-[1.7] whitespace-pre-wrap break-words max-h-[280px] overflow-y-auto",children:t.thinking})}),t.text&&e.jsxs("div",{className:"session-md text-[13.5px] leading-[1.75] text-fg-2",children:[W,t.phase==="streaming"&&e.jsx(cn,{className:"ml-1 inline-flex align-text-bottom text-fg-4"})]}),t.artifacts&&t.artifacts.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:t.artifacts.map((S,B)=>S.kind==="photo"?e.jsx("a",{href:S.url,target:"_blank",rel:"noreferrer",className:"inline-block",children:e.jsx("img",{src:S.url,alt:S.caption||S.fileName,className:"max-w-[400px] max-h-[300px] rounded-md border border-fg-6/50 object-contain hover:opacity-90 transition-opacity"})},B):e.jsx(Gn,{url:S.url,fileName:S.fileName,fileSize:S.fileSize,caption:S.caption},B))}),!t.text&&t.phase==="streaming"&&e.jsx("div",{className:"py-1",children:e.jsx(cn,{className:"text-fg-5"})}),t.phase==="streaming"&&(t.generatingImages??0)>0&&e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-fg-4",children:[e.jsxs("span",{className:"relative inline-flex items-center justify-center w-3 h-3",children:[e.jsx("span",{className:"absolute inline-flex w-3 h-3 rounded-full bg-cyan-400/40 animate-ping"}),e.jsx("span",{className:"relative inline-block w-1.5 h-1.5 rounded-full bg-cyan-400/80"})]}),e.jsx("span",{children:t.generatingImages===1?"Generating image…":`Generating ${t.generatingImages} images…`})]}),g&&t.error&&e.jsx(sr,{detail:t.error,t:n,className:"pt-0.5"})]})}function ir({call:t}){const[n,s]=r.useState(!1),a=!!(t.input||t.result),l=t.status==="failed"?"bg-rose-400/70":t.status==="running"?"bg-cyan-400/70":"bg-fg-5/30";return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>a&&s(c=>!c),className:`flex w-full items-center gap-1.5 py-[2px] text-left min-w-0 ${a?"cursor-pointer hover:bg-white/[0.03] rounded":"cursor-default"}`,title:a?void 0:t.summary,children:[e.jsx("span",{className:`w-1 h-1 rounded-full shrink-0 ${l} ${t.status==="running"?"animate-pulse":""}`}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 truncate flex-1",children:t.summary}),a&&e.jsx("span",{className:`shrink-0 text-[9px] text-fg-5/40 transition-transform ${n?"rotate-90":""}`,children:"▸"})]}),n&&e.jsxs("div",{className:"ml-2.5 mt-0.5 mb-1 space-y-1 border-l border-white/[0.06] pl-2.5",children:[t.input&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-[10.5px] font-mono leading-[1.55] text-fg-4/80 max-h-[140px] overflow-y-auto",children:t.input}),t.result&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-[10.5px] font-mono leading-[1.55] text-fg-5/70 max-h-[140px] overflow-y-auto border-t border-white/[0.04] pt-1",children:t.result})]})]})}function cn({className:t}){return e.jsxs("span",{className:`thinking-dots inline-flex items-center gap-[3px] ${t||""}`,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}function Qn({sub:t,t:n}){const[s,a]=r.useState(!1),l=t.status,c=l==="failed"?"bg-rose-400/60":l==="done"?"bg-emerald-400/55":"bg-amber-400/60",x=l==="running",d=t.tools,m=r.useMemo(()=>{const w=new Set,L=[];for(const N of d)w.has(N.name)||(w.add(N.name),L.push(N.name));return L},[d]),j=t.kind?`${n("hub.subAgent")||"Sub-agent"} · ${t.kind}`:n("hub.subAgent")||"Sub-agent",g=t.model?Dt(t.model):null;return e.jsx(ot,{open:s,onToggle:()=>a(w=>!w),dot:{color:c,pulse:x},label:j,preview:e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0 text-[12px] text-fg-4",children:[t.description&&e.jsx("span",{className:"truncate",children:t.description}),g&&e.jsx("span",{className:"text-[10px] font-mono text-fg-5/55 shrink-0",children:g}),!t.description&&m.length>0&&e.jsx("span",{className:"font-mono text-fg-5/60 truncate",children:m.join(" · ")})]}),badge:d.length>0?e.jsx(xn,{children:d.length}):void 0,children:e.jsxs("div",{className:"px-3.5 py-2.5 space-y-1 max-h-[260px] overflow-y-auto",children:[t.description&&e.jsx("div",{className:"mb-1.5 text-[12px] text-fg-3 leading-[1.55]",children:t.description}),d.length===0?e.jsxs("div",{className:"text-[11px] font-mono text-fg-5/50",children:["— ",n("hub.subAgentWaiting")||"waiting for first tool…"]}):d.map(w=>e.jsxs("div",{className:"flex items-center gap-1.5 py-[2px]",children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0 bg-fg-5/30"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/65 truncate",children:w.summary})]},w.id))]})})}function lr({message:t,t:n,workdir:s}){const{activityBlocks:a,thinkingBlocks:l,planBlocks:c,subAgentBlocks:x,outputBlocks:d,noticeBlocks:m}=Yn(t.blocks),j=[...c].reverse().find(w=>it(w.plan));return a.length>0||x.length>0||!!j?.plan||l.length>0||d.length>0||m.length>0?e.jsxs("div",{className:"space-y-3",children:[a.length>0&&e.jsx(dr,{blocks:a,t:n}),x.map(w=>w.subAgent?e.jsx(Qn,{sub:w.subAgent,t:n},w.toolId||w.subAgent.id):null),j?.plan&&e.jsx(Vn,{plan:j.plan,t:n,className:"max-w-[760px]"}),l.length>0&&e.jsx(hr,{blocks:l,t:n}),d.length>0&&e.jsx(fr,{blocks:d,t:n,workdir:s}),m.length>0&&e.jsx(cr,{blocks:m,t:n})]}):null}function ar(t){const{activityBlocks:n,thinkingBlocks:s,planBlocks:a,subAgentBlocks:l,outputBlocks:c,noticeBlocks:x}=Yn(t.blocks);return c.length>0||n.length>0||l.length>0||s.length>0||a.some(d=>it(d.plan))||x.length>0}function Yn(t){const n=t.filter(s=>s.type==="plan"||s.type==="tool_use"||s.type==="tool_result"||s.type==="image"||s.type==="file"||s.type==="sub_agent"||!!s.content.trim());return{activityBlocks:n.filter(s=>s.type==="tool_use"||s.type==="tool_result"),thinkingBlocks:n.filter(s=>s.type==="thinking"),planBlocks:n.filter(s=>s.type==="plan"&&it(s.plan)),subAgentBlocks:n.filter(s=>s.type==="sub_agent"),outputBlocks:n.filter(s=>s.type==="text"||s.type==="image"||s.type==="file"),noticeBlocks:n.filter(s=>s.type==="system_notice")}}function cr({blocks:t,t:n}){const s=t.map(a=>a.content).filter(Boolean).join(`
13
-
14
- `).trim();return s?e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/[0.06] px-3 py-2 text-[12.5px] leading-[1.7] text-fg-3",children:[e.jsx("span",{className:"mt-[6px] h-1.5 w-1.5 rounded-full bg-amber-400/70 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-mono uppercase tracking-wide text-amber-300/80",children:n("hub.systemNotice")||"Agent notice"}),e.jsx("div",{className:"mt-0.5 break-words whitespace-pre-wrap",children:s})]})]}):null}function dr({blocks:t,t:n}){const[s,a]=r.useState(!1),l=t.filter(m=>m.type==="tool_use"),c=l.length,x=l[l.length-1],d=x?Un(x):"";return e.jsx(ot,{open:s,onToggle:()=>a(m=>!m),dot:{color:"bg-cyan-400/60"},label:n("hub.activity"),preview:e.jsx("span",{className:"text-[11.5px] font-mono text-fg-4 truncate",children:d}),badge:c>0?e.jsx(xn,{children:c}):void 0,children:e.jsx("div",{className:"px-3.5 py-2.5 space-y-0.5",children:t.map((m,j)=>e.jsx(ur,{block:m},j))})})}function ur({block:t}){const[n,s]=r.useState(!1),a=t.type==="tool_use",l=a?Un(t):Us(t);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>t.content&&s(c=>!c),className:M("flex items-center gap-2 py-[3px] w-full text-left group rounded-sm transition-colors",t.content&&"hover:bg-panel-h/30"),children:[e.jsx("span",{className:M("h-1.5 w-1.5 rounded-full shrink-0",a?"bg-fg-5/40":"bg-ok/40")}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 group-hover:text-fg-3 transition-colors truncate",children:l})]}),n&&t.content&&e.jsx("pre",{className:"ml-3 mt-1 mb-2 p-3 rounded-md bg-inset border border-edge text-[11px] leading-[1.6] text-fg-4 font-mono whitespace-pre-wrap break-words max-h-[240px] overflow-y-auto",children:t.content.length>3e3?t.content.slice(0,3e3)+`
15
- …`:t.content})]})}function hr({blocks:t,t:n}){const[s,a]=r.useState(!1),l=r.useRef(null),c=t.map(d=>d.content).filter(Boolean).join(`
16
-
17
- `).trim();if(!c)return null;const x=Dn(c,3);return e.jsx(ot,{open:s,onToggle:()=>a(d=>!d),dot:{color:"bg-violet-400/50"},label:n("hub.thinking"),collapsedContent:x?e.jsx("div",{className:"px-3.5 pb-2.5 -mt-0.5 text-[12px] text-fg-4 leading-[1.65] whitespace-pre-wrap break-words line-clamp-3",children:x}):void 0,children:e.jsx(xr,{scrollRef:l,text:c})})}function xr({scrollRef:t,text:n}){return r.useLayoutEffect(()=>{const s=t.current;s&&(s.scrollTop=s.scrollHeight)},[t]),e.jsx("div",{ref:t,className:"px-3.5 py-3 text-[12px] text-fg-4 leading-[1.7] whitespace-pre-wrap break-words max-h-[320px] overflow-y-auto",children:n})}function pr({block:t,onLightbox:n,t:s}){const a=t.imageCaption?.trim()||"",l=t.imageCaptionKind==="prompt",[c,x]=r.useState(!1);return e.jsxs("figure",{className:"flex flex-col gap-1.5 max-w-[400px]",children:[e.jsx("img",{src:t.content,alt:a||"",className:"max-w-[400px] max-h-[300px] rounded-md border border-fg-6/50 object-contain cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>n(t.content)}),a&&(l?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>x(d=>!d),"aria-expanded":c,className:M("self-start inline-flex items-center gap-1 px-2 py-[3px] rounded-md","text-[11px] font-medium tracking-wide","border border-fg-6/40 bg-fg-6/[0.06] text-fg-3","hover:bg-fg-6/[0.12] hover:text-fg-2 hover:border-fg-6/60","transition-colors"),title:s(c?"hub.imagePromptHide":"hub.imagePromptShow"),children:[e.jsx("span",{"aria-hidden":!0,className:"text-[9px] leading-none",children:c?"▾":"▸"}),e.jsx("span",{children:s("hub.imagePrompt")})]}),c&&e.jsx("div",{className:"rounded-md border border-fg-6/30 bg-fg-6/[0.05] px-3 py-2 max-w-[400px] max-h-[260px] overflow-y-auto",children:e.jsx("div",{className:"text-[11.5px] leading-[1.65] text-fg-3 whitespace-pre-wrap break-words",children:a})})]}):e.jsx("figcaption",{className:"text-[11px] leading-[1.55] text-fg-5 max-w-[400px] break-words whitespace-pre-wrap",children:a}))]})}function fr({blocks:t,t:n,workdir:s}){const a=t.filter(g=>g.type==="text"),l=t.filter(g=>g.type==="image"),c=t.filter(g=>g.type==="file"),x=a.map(g=>g.content).filter(Boolean).join(`
18
-
19
- `),[d,m]=r.useState(null),j=r.useMemo(()=>Kt({workdir:s}),[s]);return!x.trim()&&l.length===0&&c.length===0?null:e.jsxs(e.Fragment,{children:[x.trim()&&e.jsx("div",{className:"session-md text-[13.5px] leading-[1.75] text-fg-2",children:e.jsx(fn,{remarkPlugins:mn,components:j,children:x})}),l.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mt-2",children:l.map((g,w)=>e.jsx(pr,{block:g,onLightbox:m,t:n},w))}),c.length>0&&e.jsx("div",{className:"flex flex-col gap-2 mt-2",children:c.map((g,w)=>e.jsx(Gn,{url:g.content,fileName:g.fileName||"file",fileSize:g.fileSize,caption:g.fileCaption},w))}),d&&e.jsx(Xn,{src:d,onClose:()=>m(null)})]})}const lo=r.memo(function({turn:n,turnIndex:s,agent:a,meta:l,model:c,effort:x,providerName:d,t:m,workdir:j,onResend:g,onEdit:w,onFork:L}){const N=n.user&&On(n.user.text),I=L&&typeof s=="number"?()=>L(s):void 0,T=r.useMemo(()=>Kt({workdir:j}),[j]),A=!!n.assistant&&ar(n.assistant);return e.jsxs("div",{className:"session-turn",children:[n.user&&!N&&e.jsx(Jn,{text:n.user.text,blocks:n.user.blocks,t:m,onResend:g,onEdit:w,onFork:I}),N&&n.user&&!n.assistant&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-lg bg-[rgba(255,255,255,0.02)] border border-edge/20 text-[12.5px] leading-[1.7] text-fg-4",children:e.jsx(fn,{remarkPlugins:mn,components:T,children:n.user.text})}),A&&e.jsxs(e.Fragment,{children:[e.jsx(jr,{agent:a,meta:l,model:c,effort:x,providerName:d,previewMeta:n.assistant.usage??null}),e.jsx("div",{className:"mb-6",children:e.jsx(lr,{message:n.assistant,t:m,workdir:j})})]})]})});function Xn({src:t,onClose:n}){return r.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),pn.createPortal(e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm cursor-zoom-out",onClick:n,children:e.jsx("img",{src:t,className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:s=>s.stopPropagation()})}),document.body)}const gr=1500,mr=16,Mn=8;function br(t){const n=t.split(`
20
- `);return n.length<=Mn?t:n.slice(0,Mn).join(`
21
- `)}function Jn({text:t,blocks:n,t:s,onResend:a,onEdit:l,onFork:c}){const[x,d]=r.useState(!1),[m,j]=r.useState(!1),[g,w]=r.useState(null),L=t?t.split(`
22
- `).length:0,N=!!t&&(t.length>gr||L>mr),[I,T]=r.useState(!1),A=t?N&&!I?br(t):t:"",W=!!(a||l||c),S=n?.filter(E=>E.type==="image")||[],B=()=>{navigator.clipboard.writeText(t).then(()=>{j(!0),setTimeout(()=>j(!1),1500)}).catch(()=>{})},te=s("hub.expand").replace("{chars}",t?t.length.toLocaleString():"0").replace("{lines}",String(L));return e.jsxs("div",{className:"flex flex-col items-end mb-5 group/bubble",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[e.jsxs("div",{className:"max-w-[72%] rounded-md border border-fg-6 bg-panel px-4 py-3 text-[13.5px] leading-[1.72] text-fg shadow-sm",children:[t&&e.jsxs("div",{className:"whitespace-pre-wrap break-words",children:[A,N&&!I&&e.jsx("span",{className:"text-fg-5/60",children:"…"})]}),N&&e.jsx("button",{type:"button",onClick:()=>T(E=>!E),className:"mt-2 text-[11.5px] text-fg-4 hover:text-fg-2 underline decoration-fg-5/40 underline-offset-2 transition-colors",children:I?s("hub.collapse"):te}),S.length>0&&e.jsx("div",{className:M("flex flex-wrap gap-2",t&&"mt-2"),children:S.map((E,G)=>e.jsx("img",{src:E.content,className:"max-w-[280px] max-h-[200px] rounded border border-fg-6/50 object-cover cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>w(E.content)},G))})]}),g&&e.jsx(Xn,{src:g,onClose:()=>w(null)}),W&&e.jsxs("div",{className:M("flex items-center gap-1 mt-1.5 mr-1 transition-all duration-200",x?"opacity-100 translate-y-0":"opacity-0 -translate-y-1 pointer-events-none"),children:[e.jsx(Rt,{label:s(m?"hub.copied":"hub.copy"),onClick:B,children:m?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),a&&e.jsx(Rt,{label:s("hub.rerun"),onClick:()=>a(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),l&&e.jsx(Rt,{label:s("hub.edit"),onClick:()=>l(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),c&&e.jsx(Rt,{label:s("hub.fork"),onClick:c,children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]})})]})]})}function Rt({label:t,onClick:n,children:s}){return e.jsx("button",{onClick:n,title:t,className:"flex items-center justify-center w-7 h-7 rounded border border-fg-6 bg-panel text-fg-4 shadow-sm hover:text-fg-2 hover:border-edge-h hover:bg-panel-h transition-colors",children:s})}function jr({agent:t,meta:n,model:s,effort:a,providerName:l,previewMeta:c,liveStartedAt:x}){const d=c?.contextPercent??null,m=c?.contextUsedTokens??0,j=c?.turnOutputTokens??0,g=d!=null||m>0||j>0,w=x!=null&&x>0,L=c?.providerName??l??null;return e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 mb-3",children:[e.jsx(rt,{brand:t,size:13}),e.jsx("span",{style:{color:n.color},className:"text-[12px] font-semibold opacity-70",children:n.label}),(s||a)&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/50",children:[s||"",s&&a?" · ":"",a||""]}),L&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/70 px-1.5 py-px rounded bg-fg-5/8",title:`This turn is routed through ${L} (BYOK), not the agent CLI's native auth.`,children:["via ",L]}),(g||w)&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[10px] font-mono text-fg-5/55",title:yr(c),children:[d!=null&&e.jsx(Nr,{pct:d}),e.jsx("span",{children:d!=null?`${d.toFixed(1)}%`:""}),m>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ",kr(m)]}),j>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ↑",Zn(j)]}),w&&e.jsx(vr,{startedAt:x,leadingDot:g})]})]})}function vr({startedAt:t,leadingDot:n}){const[,s]=r.useState(0);r.useEffect(()=>{const l=setInterval(()=>s(c=>c+1),1e3);return()=>clearInterval(l)},[]);const a=Math.max(0,Date.now()-t);return e.jsxs("span",{className:"text-fg-5/55 tabular-nums",title:"Elapsed time of the running turn",children:[n?"· ":"",wr(a)]})}function wr(t){const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60),a=n%60;return s<60?`${s}m${a.toString().padStart(2,"0")}s`:`${Math.floor(s/60)}h${(s%60).toString().padStart(2,"0")}m`}function kr(t){return`${Zn(t)} tok`}function Zn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:`${t}`}function yr(t){if(!t)return"";const n=[];return t.contextPercent!=null&&n.push(`Context: ${t.contextPercent.toFixed(1)}%`),t.inputTokens!=null&&n.push(`Input: ${t.inputTokens.toLocaleString()}`),t.turnOutputTokens!=null?n.push(`Output (turn): ${t.turnOutputTokens.toLocaleString()}`):t.outputTokens!=null&&n.push(`Output: ${t.outputTokens.toLocaleString()}`),t.cachedInputTokens!=null&&n.push(`Cached: ${t.cachedInputTokens.toLocaleString()}`),n.join(" · ")}function Nr({pct:t}){const n=t>=85?"bg-rose-400/70":t>=60?"bg-amber-400/70":"bg-emerald-400/70";return e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n}`})}function Tn(t,n,s){return t==="zh-CN"?n:s}function Sr({open:t,onClose:n,workdir:s}){const a=ye(c=>c.locale),l=s.split("/").pop()||s;return e.jsxs(Ft,{open:t,onClose:n,wide:!0,children:[e.jsx(Ut,{title:Tn(a,`${l} — 项目扩展`,`${l} — Project Extensions`),description:Tn(a,"仅对当前工作区生效。直接操作项目目录中的 .mcp.json 与 .pikiloom/skills/。","Project-scoped only. Operates directly on .mcp.json and .pikiloom/skills/ in the workspace directory."),onClose:n}),t?e.jsx(Ss,{workdir:s}):null]})}let En=_n(()=>import("./SessionPanel-DZVNXptx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));function dn(){return En??=_n(()=>import("./SessionPanel-DZVNXptx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),En}const Cr=r.lazy(async()=>({default:(await dn()).SessionPanel})),on=5,Lr=240,Mr=120,Tr=12,Er=900*1e3,V=(t,n)=>`${t}:${n}`;function Ir(t){const n=new Map;for(const d of t)n.set(V(d.agent||"",d.sessionId),d);const s=new Map,a=new Set;for(const d of t){const m=d.migratedFrom;if(!m||m.kind!=="fork"||!m.sessionId)continue;const j=V(m.agent||d.agent||"",m.sessionId);n.has(j)&&(a.add(V(d.agent||"",d.sessionId)),s.has(j)||s.set(j,[]),s.get(j).push(d))}const l=[],c=new Set,x=(d,m)=>{const j=V(d.agent||"",d.sessionId);if(c.has(j))return;c.add(j),l.push(Object.assign({},d,{__forkDepth:m}));const g=s.get(j);if(g)for(const w of g)x(w,m+1)};for(const d of t){const m=V(d.agent||"",d.sessionId);a.has(m)||x(d,0)}for(const d of t)x(d,0);return l}let Ar=0;function _t(){return`mk-${Date.now().toString(36)}-${(++Ar).toString(36)}`}function Pt(t){try{const n=localStorage.getItem(t);if(n!=null)return n;const s=sessionStorage.getItem(t);if(s!=null){try{localStorage.setItem(t,s),sessionStorage.removeItem(t)}catch{}return s}}catch{}return null}function Wt(t,n){try{localStorage.setItem(t,n)}catch{}}const Rr=[1,2,3,6],un=6;function _r(t){for(const n of Rr)if(n>=t)return n;return un}function In(){const t=typeof window<"u"?window.innerWidth:1280;return t>=1920?3:t>=1280?2:1}function Ue(t,n){const s=_r(t);return s>n?s:n}function Pr(t){return t==="vscode"||t==="cursor"||t==="windsurf"||t==="finder"||t==="default"}function Wr(t,n){const s=String(t||"").toLowerCase();return s.includes("cursor")?"cursor":s.includes("windsurf")?"windsurf":s.includes("code")||n==="darwin"?"vscode":"default"}function es(t){switch(t){case"cursor":return"hub.openTargetCursor";case"windsurf":return"hub.openTargetWindsurf";case"finder":return"hub.openTargetFinder";case"default":return"hub.openTargetDefault";default:return"hub.openTargetVsCode"}}const Br=r.memo(function({active:n=!0}){const s=ye(o=>o.locale),a=ye(o=>o.state?.runtimeWorkdir??null),l=r.useMemo(()=>ps(s),[s]),[c,x]=r.useState([]),[d,m]=r.useState({}),[j,g]=r.useState({}),[w,L]=r.useState(!0),[N,I]=r.useState(()=>{const o=Pt("pikiloom-layout-mode");return o==="1"||o==="2"||o==="3"||o==="6"?Number(o):In()}),[T,A]=r.useState(()=>{const o=Pt("pikiloom-layout-floor");return o==="1"||o==="2"||o==="3"||o==="6"?Number(o):In()}),[W,S]=r.useState(()=>{try{const o=Pt("pikiloom-open-sessions");if(o){const h=JSON.parse(o);if(Array.isArray(h))return h.map(u=>({...u,mountKey:u.mountKey||_t()}))}}catch{}return[]}),[B,te]=r.useState(()=>{const o=Pt("pikiloom-active-slot");if(o!=null){const h=Number(o);if(Number.isFinite(h)&&h>=0)return h}return 0}),E=r.useCallback(o=>{I(o),Wt("pikiloom-layout-mode",String(o))},[]),G=r.useCallback(o=>{A(o),Wt("pikiloom-layout-floor",String(o))},[]),P=r.useCallback(o=>{S(h=>{const u=typeof o=="function"?o(h):o,p=u.map(({pendingPrompt:v,pendingImageUrls:y,...k})=>k);return Wt("pikiloom-open-sessions",JSON.stringify(p)),u})},[]),D=r.useCallback(o=>{te(h=>{const u=typeof o=="function"?o(h):o;return Wt("pikiloom-active-slot",String(u)),u})},[]),ae=r.useCallback(o=>{E(o),G(o)},[E,G]);r.useEffect(()=>{P(o=>o.length>N?o.slice(0,N):o),D(o=>o>=N?N-1:o)},[N]);const[R,ce]=r.useState(!1),re=r.useRef(N);re.current=N;const Y=r.useRef(T);Y.current=T;const Ne=r.useRef(B);Ne.current=B;const K=r.useRef(W);K.current=W;const wt=r.useRef(-1),fe=W[B]??null,lt=r.useCallback(o=>{if(!o){P([]),D(0);return}const h=o.mountKey?o:{...o,mountKey:_t()};P(u=>{const p=u.findIndex(y=>y.agent===h.agent&&y.sessionId===h.sessionId);if(p>=0)return D(p),u;if(u.length<re.current){const y=[...u,h];return D(y.length-1),y}if(re.current<un){const y=[...u,h];return E(Ue(y.length,Y.current)),D(y.length-1),y}const v=[...u];return v[Ne.current]=h,v})},[P,D,E]),[Ke,He]=r.useState(!1),[oe,Ae]=r.useState(null),[ne,Se]=r.useState(""),[Re,Ve]=r.useState("all"),[de,kt]=r.useState({}),[ue,Ge]=r.useState({}),_e=r.useDeferredValue(ne),se=r.useRef(!1),qe=r.useRef({}),Ce=r.useRef(d);Ce.current=d;const Le=r.useRef(de);Le.current=de;const at=r.useRef(new Set),$=r.useRef({});r.useEffect(()=>()=>{for(const o of Object.values($.current))clearTimeout(o)},[]),r.useEffect(()=>{P(o=>{let h=!1;const u=o.map(p=>{const v=ue[p.workdir];if(!v)return p;const y=Nn(v,p.agent,p.sessionId);return y===p.sessionId?p:(h=!0,{...p,sessionId:y})});return h?u:o})},[ue,P]);const q=r.useCallback(async()=>{try{const o=await ee.getWorkspaces(),h=o.ok?o.workspaces:[];h.length&&x(u=>u.length===h.length&&u.every((p,v)=>p.path===h[v].path&&p.name===h[v].name)?u:h),se.current=!0}catch{se.current=!0}finally{L(!1)}},[]);r.useEffect(()=>{q()},[q]);const U=r.useCallback(async(o,h={})=>{if(!qe.current[o]){qe.current[o]=!0,h.background||g(u=>({...u,[o]:!0}));try{const u=await Es(o,{force:h.force});r.startTransition(()=>{Ge(p=>{const v=u.promotions||{},y=p[o];return y&&Object.keys(y).length===Object.keys(v).length&&Object.entries(v).every(([k,H])=>y[k]===H)?p:{...p,[o]:v}}),m(p=>{const v=u.sessions||[],y=p[o]||[],k=new Set(v.map(F=>V(F.agent||"",F.sessionId))),H=y.filter(F=>{if(F.runState!=="running")return!1;const _=V(F.agent||"",F.sessionId);if(k.has(_))return!1;const O=Le.current[_];return!(O?.resolvedKey&&O.resolvedKey!==_)});return{...p,[o]:H.length?[...H,...v]:v}})})}catch{h.background||r.startTransition(()=>{m(u=>({...u,[o]:[]}))})}finally{qe.current[o]=!1,h.background||g(u=>({...u,[o]:!1}))}}},[]),ct=r.useRef(a);r.useEffect(()=>{a!==ct.current&&(ct.current=a,!(!a||!se.current)&&q().then(()=>{U(a,{force:!0})}))},[a,q,U]);const Q=r.useCallback((o,h)=>{const u=o.agent||"";!u||!o.sessionId||(dn(),Rs({workdir:h,agent:u,sessionId:o.sessionId,rich:!0,turnOffset:0,turnLimit:Tr}))},[]),Qe=r.useCallback((o,h,u=Mr)=>{const p=`${h}:${V(o.agent||"",o.sessionId)}`,v=$.current[p];v&&clearTimeout(v),$.current[p]=setTimeout(()=>{delete $.current[p],Q(o,h)},u)},[Q]),yt=r.useCallback((o,h)=>{const u=`${h}:${V(o.agent||"",o.sessionId)}`,p=$.current[u];p&&(clearTimeout(p),delete $.current[u])},[]);r.useEffect(()=>{n&&dn()},[n]),r.useEffect(()=>{if(!n)return;const o=[];return c.forEach((h,u)=>{if(d[h.path]||j[h.path])return;const p=setTimeout(()=>{U(h.path)},u*90);o.push(p)}),()=>{for(const h of o)clearTimeout(h)}},[n,U,j,d,c]);const Ht=r.useRef(new Map);Sn(n&&se.current&&c.length>0?"sessions-changed":null,r.useCallback(o=>{if(typeof document<"u"&&document.visibilityState==="hidden")return;const h=o.key,u=h?c.filter(y=>(Ce.current[y.path]||[]).some(k=>V(k.agent||"",k.sessionId)===h)):c,p=u.length?u:c,v=Ht.current;for(const y of p)v.has(y.path)&&clearTimeout(v.get(y.path)),v.set(y.path,setTimeout(()=>{v.delete(y.path),U(y.path,{background:!0,force:!0})},300))},[c,U]));const ge=r.useCallback(o=>{const h=o.agent||"";return!h||!o.sessionId?o:fs(o,de[V(h,o.sessionId)]||null)},[de]);Sn("stream-update",r.useCallback(o=>{const h=o.key;if(!h)return;const u=gs(h,o.snapshot??null);kt(p=>{if(!u){const _=p[h];return!_||_.phase==="done"?p:{...p,[h]:{..._,phase:"done",updatedAt:Date.now()}}}const v=(_,O)=>!!_&&!!O&&_.phase===O.phase&&_.resolvedKey===O.resolvedKey&&_.sessionId===O.sessionId&&_.incomplete===O.incomplete&&_.error===O.error,y=v(p[h],u),k=u.resolvedKey===h||v(p[u.resolvedKey],{...u,key:u.resolvedKey});if(y&&k)return p;const H=Date.now()-Er,F={};for(const[_,O]of Object.entries(p))O.phase==="done"&&O.updatedAt<H||(F[_]=O);return F[h]=u,u.resolvedKey!==h&&(F[u.resolvedKey]={...u,key:u.resolvedKey}),F})},[])),ms(r.useCallback(()=>{if(!(!n||!se.current||c.length===0))for(const o of c)U(o.path,{background:!0,force:!0})},[n,c,U])),r.useEffect(()=>{if(!n||!se.current||c.length===0)return;const o=()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const u of c)U(u.path,{background:!0,force:!0})};if(o(),typeof document>"u"||typeof window>"u")return;const h=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",h),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",h)}},[n,U,c]),r.useEffect(()=>{if(!n)return;const o=[];return c.forEach((h,u)=>{const p=(d[h.path]||[])[0];if(!p)return;const v=`${h.path}:${V(p.agent||"",p.sessionId)}`;if(at.current.has(v))return;const y=setTimeout(()=>{at.current.add(v),Q(p,h.path)},Lr+u*120);o.push(y)}),()=>{for(const h of o)clearTimeout(h)}},[n,d,Q,c]);const dt=r.useCallback(async o=>{try{(await ee.addWorkspace(o)).ok&&(He(!1),await q(),U(o))}catch{}},[q,U]),[me,Pe]=r.useState(null),[X,We]=r.useState(!1),[Be,$e]=r.useState(null),Ye=r.useCallback(o=>{Pe(o)},[]),ut=r.useCallback(async()=>{const o=me;if(o){We(!0);try{await ee.removeWorkspace(o),x(h=>h.filter(u=>u.path!==o)),m(h=>{const u={...h};return delete u[o],u}),P(h=>{const u=h.filter(p=>p.workdir!==o);return u.length!==h.length&&E(Ue(u.length,Y.current)),u}),D(0),Pe(null)}catch{}finally{We(!1)}}},[me]),ht=r.useCallback(o=>{U(o,{force:!0})},[U]),[Me,be]=r.useState(null),[Xe,Je]=r.useState(!1),[je,Te]=r.useState(!1),ve=ye(o=>o.toast),[ie,Ze]=r.useState(null),xt=r.useCallback((o,h,u)=>{Ze({anchor:{right:o.right,bottom:o.bottom},target:{workdir:u,agent:h.agent||"",sessionId:h.sessionId,title:An(h).slice(0,120)||h.sessionId.slice(0,16)}})},[]);r.useEffect(()=>{if(!ie)return;const o=()=>Ze(null),h=u=>{u.key==="Escape"&&o()};return window.addEventListener("mousedown",o),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o),window.removeEventListener("keydown",h)}},[ie]);const we=r.useCallback(o=>{Je(!1),be(o),Ze(null)},[]),Nt=r.useCallback(async()=>{const o=Me;if(o){Te(!0);try{const h=await ee.deleteSession(o.workdir,o.agent,o.sessionId,Xe);if(!h.ok){const u=h.error?.includes("still running")?l("session.deleteRunningError"):h.error||l("session.deleteFailed");ve(u,!1);return}m(u=>{const p=u[o.workdir];if(!p)return u;const v=p.filter(y=>!(y.agent===o.agent&&y.sessionId===o.sessionId));return v.length===p.length?u:{...u,[o.workdir]:v}}),P(u=>{const p=u.filter(v=>!(v.workdir===o.workdir&&v.agent===o.agent&&v.sessionId===o.sessionId));return p.length!==u.length&&E(Ue(p.length,Y.current)),p}),be(null)}catch(h){ve(h?.message||l("session.deleteFailed"),!1)}finally{Te(!1)}}},[Me,Xe,l,ve]),pt=r.useCallback(o=>{P(h=>{let u=!1;const p=h.map(v=>v.mountKey===o&&(v.pendingPrompt!=null||v.pendingImageUrls)?(u=!0,{...v,pendingPrompt:null,pendingImageUrls:void 0}):v);return u?p:h})},[P]),St=r.useCallback((o,h,u)=>{Q({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),m(y=>{const k=y[o.workdir]||[];if(k.some(_=>_.sessionId===o.sessionId&&_.agent===o.agent))return y;const F={sessionId:o.sessionId,agent:o.agent,runState:"running",lastQuestion:h,createdAt:new Date().toISOString(),runUpdatedAt:new Date().toISOString()};return{...y,[o.workdir]:[F,...k]}});const p=wt.current,v={...o,mountKey:_t(),pendingPrompt:h||null,pendingImageUrls:u&&u.length?u:void 0};r.startTransition(()=>{Ae(null),P(y=>{if(p>=y.length)return[...y,v];const k=[...y];return k[p]=v,k}),D(p>=0?p:0)}),U(o.workdir,{background:!0,force:!0})},[U,Q,P,D]),Ct=r.useCallback(o=>{K.current.length>=re.current&&re.current<un&&E(Ue(re.current+1,Y.current)),Ae(o)},[E]),Lt=r.useCallback(()=>{Ae(null),E(Ue(K.current.length,Y.current))},[E]),Mt=r.useCallback((o,h)=>{Q(o,h);const u=o.agent||"";K.current.some(p=>p.agent===u&&p.sessionId===o.sessionId)&&E(Ue(K.current.length,Y.current)),Ae(null),r.startTransition(()=>{lt({agent:u,sessionId:o.sessionId,workdir:h})})},[Q,E]),he=r.useCallback((o,h)=>{Q({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),r.startTransition(()=>{h!=null?(P(u=>{if(h>=u.length)return u;const p=[...u];return p[h]={...u[h],agent:o.agent,sessionId:o.sessionId,workdir:o.workdir},p}),D(h)):lt({...o,mountKey:_t()})}),U(o.workdir,{background:!0,force:!0})},[U,Q]),ft=r.useCallback(o=>{let h=o;if(Re==="running"?h=h.filter(u=>Bt(u)==="running"):Re==="review"&&(h=h.filter(u=>Bt(u)==="incomplete")),_e.trim()){const u=_e.toLowerCase();h=h.filter(p=>(p.lastMessageText||"").toLowerCase().includes(u)||(p.lastQuestion||"").toLowerCase().includes(u)||(p.lastAnswer||"").toLowerCase().includes(u)||(p.title||"").toLowerCase().includes(u)||(p.agent||"").toLowerCase().includes(u))}return h},[_e,Re]),gt=r.useMemo(()=>{const o={};for(const h of c){const u=(d[h.path]||[]).map(ge),p=ue[h.path],v=new Map;for(const k of u){const H=V(k.agent||"",k.sessionId),F=de[H],_=p?Nn(p,k.agent||"",k.sessionId):k.sessionId,O=F?.resolvedKey&&F.resolvedKey!==H?F.resolvedKey:_!==k.sessionId?V(k.agent||"",_):H,mt=v.get(O);if(!mt){v.set(O,k);continue}V(mt.agent||"",mt.sessionId)!==O&&H===O&&v.set(O,k)}const y=ft([...v.values()]);o[h.path]=Ir(y)}return o},[c,d,de,ue,ft,ge]),Vt=r.useCallback(o=>{const h=(d[o.workdir]||[]).find(u=>u.sessionId===o.sessionId&&u.agent===o.agent)??{sessionId:o.sessionId,agent:o.agent,runState:"running"};return ge(h)},[ge,d]),Gt=r.useMemo(()=>new Set(W.map(o=>V(o.agent,o.sessionId))),[W]),et=fe?V(fe.agent,fe.sessionId):null,Tt=r.useCallback(o=>{P(h=>{const u=h.filter((p,v)=>v!==o);return u.length===0?D(0):Ne.current>=u.length&&D(u.length-1),E(Ue(u.length,Y.current)),u})},[P,D,E]);return e.jsxs("div",{className:"h-full overflow-hidden p-4 flex gap-3 mx-auto",children:[e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5/40 group-focus-within:text-fg-4 transition-colors",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:ne,onChange:o=>Se(o.target.value),placeholder:l("hub.search"),className:"w-full rounded-lg border border-edge/40 bg-inset/50 pl-8 pr-7 py-1.5 text-[12px] text-fg outline-none placeholder:text-fg-5/30 focus:border-primary/30 focus:bg-inset focus:shadow-[0_0_0_3px_rgba(99,102,241,0.06)] transition-all duration-200"}),ne&&e.jsx("button",{onClick:()=>Se(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-fg-5/30 hover:text-fg-4 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex items-center rounded-lg bg-inset/30 border border-edge/20 p-0.5",children:["all","running","review"].map(o=>e.jsx("button",{onClick:()=>Ve(o),className:M("flex-1 px-2 py-[5px] rounded-md text-[11px] font-medium transition-all duration-200",Re===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1),inset_0_1px_0_rgba(255,255,255,0.04)]":"text-fg-5/60 hover:text-fg-4"),children:l(`hub.filter${o[0].toUpperCase()+o.slice(1)}`)},o))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:w?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(pe,{className:"h-4 w-4 text-fg-5"})}):c.length===0&&!Ke?e.jsx("div",{className:"py-12 text-center text-[13px] text-fg-5",children:l("hub.noWorkspaces")}):c.map(o=>e.jsx(Fr,{workspace:o,sessions:gt[o.path]||[],loading:!!j[o.path]||!(o.path in d),isActive:o.path===a,selectedKey:et,openSessionKeys:Gt,onSelectSession:Mt,onNewSession:Ct,onRefresh:ht,onRemove:Ye,onExtensions:$e,onWarmSession:Qe,onCancelWarmSession:yt,onSessionMenuOpen:xt,t:l},o.path))}),e.jsxs("div",{className:"shrink-0 border-t border-edge/20 px-3 py-2 space-y-1.5",children:[e.jsx("div",{className:"flex items-center rounded-md bg-inset/30 border border-edge/20 p-0.5",children:[1,2,3,6].map(o=>e.jsx("button",{onClick:()=>ae(o),className:M("flex-1 flex items-center justify-center p-1.5 rounded transition-all",N===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1)]":"text-fg-5/40 hover:text-fg-4"),title:l(`hub.layout${o}`),children:o===1?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"})}):o===2?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"9",y:"2",width:"6",height:"12",rx:"1.5"})]}):o===3?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"0.5",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"6",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"11.5",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:[e.jsx("rect",{x:"0.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"0.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"})]})},o))}),e.jsxs(Ie,{variant:"ghost",size:"sm",onClick:()=>He(o=>!o),className:"w-full",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),l("hub.addWorkspace")]})]})]}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden gap-0",children:e.jsx("div",{className:"flex-1 min-h-0 grid gap-3",style:{gridTemplateColumns:`repeat(${N===6?3:N}, 1fr)`,gridTemplateRows:N===6?"repeat(2, 1fr)":"1fr"},children:(()=>{const o=oe?W.length<N?W.length:B:-1;return wt.current=o,Array.from({length:N},(h,u)=>{if(oe&&u===o)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-edge bg-panel flex flex-col",style:{boxShadow:"var(--th-card-shadow)"},children:e.jsx(Or,{workdir:oe,workspaceName:c.find(k=>k.path===oe)?.name||oe.split("/").pop()||"",onSessionCreated:St,onClose:Lt,t:l},oe)},`new-${oe}`);const p=W[u]??null;if(!p)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-dashed border-edge/40 bg-panel/30 flex items-center justify-center",children:e.jsxs("div",{className:"text-center px-4",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:"mx-auto text-fg-5/20 mb-2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),e.jsx("div",{className:"text-[12px] text-fg-5/40",children:l("hub.emptySlot")})]})},`empty-${u}`);const v=Vt(p),y=u===B;return e.jsxs("div",{className:M("min-w-0 overflow-hidden rounded-xl border bg-panel flex flex-col transition-[border-color,box-shadow] duration-200",y?"border-primary/40 ring-[3px] ring-primary/[0.06]":"border-edge hover:border-edge-h"),style:{boxShadow:y?"var(--th-card-shadow), 0 0 0 1px rgba(14,165,233,0.08)":"var(--th-card-shadow)"},onClick:()=>D(u),children:[e.jsxs("div",{className:M("shrink-0 flex items-center gap-2 px-2.5 h-8 border-b border-edge/30",y?"bg-primary/[0.03]":"bg-panel/60"),children:[(()=>{const k=Bt(v);return e.jsx(zt,{variant:k==="running"?"ok":k==="waiting"?"info":k==="incomplete"?"warn":"idle",pulse:k==="running"||k==="waiting"})})(),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-0",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-fg-5",children:p.workdir.split("/").pop()||p.workdir}),e.jsx("span",{className:"shrink-0 text-fg-6 text-[10px] mx-1",children:"/"}),e.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-fg-3",children:v.title||v.lastQuestion?.slice(0,60)||p.sessionId.slice(0,12)})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2.5 pl-4 text-[9px] text-fg-5/50 tabular-nums",children:[e.jsx("span",{title:l("hub.created"),children:bs(v.createdAt)}),v.runUpdatedAt&&e.jsx("span",{title:l("hub.updated"),children:Rn(v.runUpdatedAt)}),!!v.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),v.numTurns]}),e.jsx("button",{"data-filetree-toggle":!0,onClick:k=>{k.stopPropagation(),ce(H=>!H)},className:M("p-0.5 rounded transition-colors",R?"text-fg-3 bg-panel-h":"text-fg-5/40 hover:text-fg-3 hover:bg-panel-h"),title:l("hub.files"),children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}),e.jsx("button",{onClick:k=>{k.stopPropagation(),Tt(u)},className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 hover:bg-panel-h transition-colors",title:l("hub.closePanel"),children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full"}),children:e.jsx(Cr,{session:v,workdir:p.workdir,active:n&&y,onSessionChange:k=>he(k,u),initialPendingPrompt:p.pendingPrompt??null,initialPendingImageUrls:p.pendingImageUrls,onPendingPromptConsumed:()=>pt(p.mountKey)},p.mountKey)})})]},p.mountKey||V(p.agent,p.sessionId))})})()})}),R&&fe&&e.jsx(zr,{workdir:fe.workdir,onClose:()=>ce(!1),t:l}),e.jsx($r,{open:Ke,initialPath:a||void 0,onAdd:dt,onClose:()=>He(!1),t:l}),e.jsxs(Ft,{open:!!me,onClose:()=>!X&&Pe(null),children:[e.jsx(Ut,{title:l("hub.removeWorkspace"),onClose:()=>!X&&Pe(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:l("modal.confirmRemoveWorkspace")}),e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:l("modal.confirmRemoveWorkspaceHint")}),me&&e.jsx("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 font-mono text-[11px] text-fg-4 break-all",children:me}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(Ie,{variant:"ghost",onClick:()=>Pe(null),disabled:X,children:l("modal.cancel")}),e.jsx(Ie,{variant:"primary",onClick:ut,disabled:X,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:l(X?"modal.removing":"modal.remove")})]})]}),ie&&(()=>{const h=Math.max(8,Math.min(ie.anchor.right-160,window.innerWidth-160-8)),u=Math.min(ie.anchor.bottom+4,window.innerHeight-60);return e.jsx("div",{className:"fixed z-[60] min-w-[160px] rounded-md border border-edge bg-panel/95 backdrop-blur-md py-1",style:{left:h,top:u,boxShadow:"0 8px 24px rgba(0,0,0,0.20), 0 2px 6px rgba(0,0,0,0.10)"},onMouseDown:p=>p.stopPropagation(),role:"menu",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>we(ie.target),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] text-fg-2 hover:bg-panel-h/60 hover:text-red-400 transition-colors",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"}),e.jsx("path",{d:"M9 6V4a2 2 0 012-2h2a2 2 0 012 2v2"})]}),l("session.delete")]})})})(),e.jsxs(Ft,{open:!!Me,onClose:()=>!je&&be(null),children:[e.jsx(Ut,{title:l("session.deleteTitle"),onClose:()=>!je&&be(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:l("session.deleteHint")}),Me&&e.jsxs("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 text-[11px] text-fg-4 break-all",children:[e.jsx("span",{className:"font-mono text-fg-5",children:Me.agent}),e.jsx("span",{className:"mx-1.5 text-fg-5/50",children:"·"}),e.jsx("span",{children:Me.title})]}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:!Xe,onChange:()=>Je(!1),disabled:je,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:l("session.deletePikiloomOnly")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:l("session.deletePikiloomOnlyHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:Xe,onChange:()=>Je(!0),disabled:je,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:l("session.deletePurgeNative")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:l("session.deletePurgeNativeHint")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(Ie,{variant:"ghost",onClick:()=>be(null),disabled:je,children:l("modal.cancel")}),e.jsx(Ie,{variant:"primary",onClick:Nt,disabled:je,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:l(je?"session.deleting":"modal.remove")})]})]}),e.jsx(Sr,{open:!!Be,onClose:()=>$e(null),workdir:Be||""})]})});function $r({open:t,initialPath:n,onAdd:s,onClose:a,t:l}){const[c,x]=r.useState(""),d=r.useCallback(m=>x(m),[]);return r.useEffect(()=>{t&&x("")},[t]),e.jsxs(Ft,{open:t,onClose:a,children:[e.jsx(Ut,{title:l("hub.addWorkspace"),onClose:a}),e.jsx(ks,{initialPath:n,maxHeight:360,minHeight:200,onSelect:d,t:l}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(Ie,{disabled:!c,onClick:()=>c&&s(c),className:"flex-1",children:l("hub.add")}),e.jsx(Ie,{variant:"secondary",onClick:a,className:"flex-1",children:l("hub.cancel")})]})]})}function Or({workdir:t,workspaceName:n,onSessionCreated:s,onClose:a,t:l}){const[c,x]=r.useState(null),[d,m]=r.useState([]),j=r.useRef(null),g=r.useRef([]),w=r.useMemo(()=>({sessionId:"",agent:"",runState:"completed"}),[]),L=r.useCallback(()=>{},[]),N=r.useCallback((A,W)=>{x(A||null),j.current=A||null;const S=W||[];m(S),g.current=S},[]),I=r.useCallback(A=>{const W=g.current;g.current=[],s(A,j.current||void 0,W.length?W:void 0)},[s]),T=!!c||d.length>0;return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 h-10 border-b border-edge/50 bg-panel/40 backdrop-blur-md z-10",children:[e.jsx("span",{className:"flex-1 min-w-0 text-[13px] font-medium text-fg truncate",children:l("hub.newSession")}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-fg-5/60 shrink-0",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"})}),e.jsx("span",{className:"max-w-[80px] truncate",children:n})]}),e.jsx(zt,{variant:T?"ok":"idle",pulse:T}),!T&&e.jsx("button",{onClick:a,className:"p-1 rounded text-fg-5 hover:text-fg-2 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:T?e.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[e.jsx(Jn,{text:c||"",blocks:d.map(A=>({type:"image",content:A})),t:l}),e.jsx("div",{className:"mt-3 mb-4 animate-in",children:e.jsx(cn,{className:"text-fg-5"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center space-y-1.5",children:e.jsx("div",{className:"text-[13px] text-fg-5",children:l("hub.newSessionHint")})})})}),e.jsx(Vs,{session:w,workdir:t,onStreamQueued:L,onSendStart:N,onSessionChange:I,t:l,streamPhase:null})]})}function Dr({git:t}){if(!t)return null;const n=[t.detached?`detached HEAD${t.shortSha?` @ ${t.shortSha}`:""}`:`branch ${t.branch??"?"}`,t.upstream?`upstream ${t.upstream}`:t.detached?"":"no upstream",t.ahead||t.behind?`↑${t.ahead} ahead · ↓${t.behind} behind`:"",t.changed>0?`${t.changed} changed (${t.staged} staged · ${t.unstaged} unstaged · ${t.untracked} untracked)`:"clean"].filter(Boolean).join(`
23
- `);return e.jsx(js,{content:n,className:M("shrink-0 items-center",t.changed>0?"text-amber-400/80":t.ahead||t.behind?"text-sky-400/70":"text-fg-5/50"),onClick:s=>s.stopPropagation(),children:e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"2.5"}),e.jsx("circle",{cx:"18",cy:"8",r:"2.5"}),e.jsx("path",{d:"M6 8.5v7"}),e.jsx("path",{d:"M18 10.5c0 4.5-6 3-6 7.5"})]})})}const Fr=r.memo(function({workspace:n,sessions:s,loading:a,isActive:l,selectedKey:c,openSessionKeys:x,onSelectSession:d,onNewSession:m,onRefresh:j,onRemove:g,onExtensions:w,onWarmSession:L,onCancelWarmSession:N,onSessionMenuOpen:I,t:T}){const[A,W]=r.useState(!0),[S,B]=r.useState(on);r.useEffect(()=>{B(on)},[s.length]);const te=s.slice(0,S),E=s.length-S,G=n.path,[P,D]=r.useState(null),ae=r.useCallback(()=>{ee.getWorkspaceGit(G).then(R=>D(R.git)).catch(()=>D(null))},[G]);return r.useEffect(()=>{ae()},[ae]),e.jsxs("div",{className:"border-b border-edge/30",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-panel-h/50 transition-colors",onClick:()=>W(R=>!R),children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:M("shrink-0 text-fg-5 transition-transform duration-150",A&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[e.jsx("span",{className:M("min-w-0 truncate text-[12px] font-semibold",l?"text-primary":"text-fg-3"),children:n.name}),e.jsx(Dr,{git:P})]}),l&&e.jsx(zt,{variant:"ok"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:R=>{R.stopPropagation(),m(G)},className:"p-1 rounded text-fg-5 hover:text-primary hover:bg-panel-h/60 transition-colors",title:T("hub.newSession"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e.jsx("button",{onClick:R=>{R.stopPropagation(),w(G)},className:"p-1 rounded text-fg-5 hover:text-primary hover:bg-panel-h/60 transition-colors",title:T("hub.extensions"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 22v-5"}),e.jsx("path",{d:"M9 8V2"}),e.jsx("path",{d:"M15 8V2"}),e.jsx("path",{d:"M18 8v5a6 6 0 0 1-12 0V8z"})]})}),e.jsx("button",{onClick:R=>{R.stopPropagation(),j(G),ae()},className:"p-1 rounded text-fg-5 hover:text-fg-2 hover:bg-panel-h/60 transition-colors",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),!l&&e.jsx("button",{onClick:R=>{R.stopPropagation(),g(G)},className:"p-1 rounded text-fg-5 hover:text-red-400 hover:bg-panel-h/60 transition-colors",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),A&&e.jsx("div",{className:"pb-1",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(pe,{className:"h-3 w-3 text-fg-5"})}):s.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:T("sessions.noSessions")}):e.jsxs(e.Fragment,{children:[te.map(R=>{const ce=V(R.agent||"",R.sessionId),re=R.__forkDepth||0;return e.jsx(Ur,{session:R,isSelected:c===ce,isOpen:x?.has(ce)??!1,forkDepth:re,onClick:()=>d(R,G),onWarm:()=>L(R,G),onCancelWarm:()=>N(R,G),onShowMenu:Y=>I(Y,R,G),menuLabel:T("session.openActions")},ce)}),E>0&&e.jsxs("button",{onClick:()=>B(R=>R+on),className:"flex items-center gap-1.5 w-full px-3 py-1.5 text-[11px] text-fg-5 hover:text-fg-3 hover:bg-panel-h/50 transition-colors",children:[e.jsxs("span",{children:["+ ",T("hub.nMore").replace("{n}",String(E))]}),e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]})})]})}),Ur=r.memo(function({session:n,isSelected:s,isOpen:a,forkDepth:l=0,onClick:c,onWarm:x,onCancelWarm:d,onShowMenu:m,menuLabel:j}){const g=ln(n.agent||""),w=Bt(n),L=An(n).slice(0,500)||n.sessionId.slice(0,16),N=vs(n,L).slice(0,500),I=n.model?Dt(n.model):null,T=l>0?Math.min(l,3)*14:0,A=a?10:12,W=r.useRef(null);return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:c,onMouseEnter:x,onFocus:x,onMouseLeave:d,onBlur:d,className:M("w-full pr-3 py-2 text-left transition-all duration-100",s?"bg-selected hover:bg-selected-h":a?"bg-panel-h/30 hover:bg-panel-h/50":"hover:bg-panel-h/50"),style:{paddingLeft:A+T,...a?{borderLeft:`2px solid ${s?g.color:`${g.color}30`}`}:{}},children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-5",children:[l>0&&e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-fg-5/60 shrink-0","aria-label":"Fork",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]}),e.jsx(rt,{brand:n.agent||"",size:10}),e.jsx("span",{className:"font-medium shrink-0",style:{color:g.color},children:g.shortLabel}),I&&e.jsx("span",{className:"truncate max-w-[72px] font-mono text-fg-5/40 text-[9px]",children:I}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 shrink-0 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0",children:[!!n.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5 text-fg-5/50 tabular-nums",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-50",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),n.numTurns]}),e.jsx("span",{className:"tabular-nums",children:Rn(n.runUpdatedAt||n.createdAt)})]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(zt,{variant:w==="running"?"ok":w==="waiting"?"info":w==="incomplete"?"warn":"idle",pulse:w==="running"||w==="waiting"}),e.jsx("span",{className:"truncate text-[12px] leading-snug text-fg-2",children:L})]}),N&&e.jsx("div",{className:"mt-0.5 pl-[11px]",children:e.jsx("span",{className:"block truncate text-[10px] leading-snug text-fg-5",children:N})})]}),e.jsx("button",{ref:W,type:"button","aria-label":j,"aria-haspopup":"menu",onMouseDown:S=>{S.stopPropagation()},onClick:S=>{S.stopPropagation(),S.preventDefault(),W.current&&m(W.current.getBoundingClientRect())},className:"absolute top-1.5 right-1.5 p-1 rounded text-fg-5 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-panel-h hover:text-fg-2 transition-opacity",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})})]})}),zr=r.memo(function({workdir:n,onClose:s,t:a}){const l=ye(g=>g.state?.hostApp??null),c=ye(g=>g.state?.platform??null),x=ye(g=>g.toast),[d,m]=r.useState(()=>Wr(l,c)),j=r.useCallback(async g=>{try{const w=await ee.openInEditor(g,d);if(!w.ok)throw new Error(w.error||`Failed to open ${g}`)}catch(w){x(w?.message||String(w),!1)}},[d,x]);return e.jsxs("div",{className:"fixed z-50 w-[280px] max-h-[calc(100vh-100px)] flex flex-col rounded-xl border border-edge bg-panel/95 backdrop-blur-md overflow-hidden",style:{boxShadow:"0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.12)",right:16,top:80},children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-2.5 py-1.5 border-b border-edge/30",children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"shrink-0 text-fg-5",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})}),e.jsx("span",{className:"flex-1 text-[10px] font-semibold text-fg-4 uppercase tracking-wider",children:a("hub.files")}),e.jsx("button",{onClick:s,className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 transition-colors",title:a("hub.closePanel"),children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"shrink-0 px-2.5 py-1.5 border-b border-edge/20 flex items-center gap-2",children:[e.jsx(ws,{value:d,options:(c==="darwin"?["vscode","finder"]:["vscode"]).map(g=>({value:g,label:a(es(g))})),onChange:g=>{Pr(g)&&m(g)},renderIcon:g=>e.jsx(ts,{target:g,size:14})}),e.jsx(Ie,{size:"sm",variant:"ghost",onClick:()=>j(n),className:"flex-1 min-w-0 text-[11px]",children:a("hub.openProject")})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-1.5",children:e.jsx(Kr,{basePath:n,openTarget:d,onOpenPath:j,t:a})})]})});function ts({target:t,size:n=16}){return t==="default"?e.jsxs("svg",{width:n,height:n,viewBox:"0 0 16 16",className:"shrink-0 text-fg-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 3H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-2"}),e.jsx("path",{d:"M9 2h5v5"}),e.jsx("path",{d:"M14 2L7 9"})]}):e.jsx(rt,{brand:t,size:n})}function Kr({basePath:t,includeHidden:n=!1,openTarget:s,onOpenPath:a,t:l}){const[c,x]=r.useState([]),[d,m]=r.useState(!0);r.useEffect(()=>{let g=!1;return m(!0),ee.lsDir(t,!0,n).then(w=>{!g&&w.ok&&x(w.dirs.slice(0,50).map(L=>({entry:L,expanded:!1,children:null,loading:!1})))}).catch(()=>{}).finally(()=>{g||m(!1)}),()=>{g=!0}},[t,n]);const j=r.useCallback(g=>{const w=L=>L.map(N=>N.entry.path===g?N.expanded?{...N,expanded:!1}:N.children===null?(ee.lsDir(g,!0,n).then(I=>{I.ok&&x(T=>hn(T,g,{children:I.dirs.slice(0,50).map(A=>({entry:A,expanded:!1,children:null,loading:!1})),loading:!1}))}).catch(()=>{x(I=>hn(I,g,{children:[],loading:!1}))}),{...N,loading:!0,expanded:!0}):{...N,expanded:!0}:N.children?{...N,children:w(N.children)}:N);x(L=>w(L))},[n]);return d?e.jsx("div",{className:"flex justify-center py-3",children:e.jsx(pe,{className:"h-3 w-3 text-fg-5"})}):c.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:"—"}):e.jsx("div",{className:"space-y-px",children:e.jsx(ns,{nodes:c,depth:0,onToggle:j,openTarget:s,onOpenPath:a,t:l})})}function ns({nodes:t,depth:n,onToggle:s,openTarget:a,onOpenPath:l,t:c}){return e.jsx(e.Fragment,{children:t.map(x=>e.jsx(Hr,{node:x,depth:n,onToggle:s,openTarget:a,onOpenPath:l,t:c},x.entry.path))})}function Hr({node:t,depth:n,onToggle:s,openTarget:a,onOpenPath:l,t:c}){const{entry:x,expanded:d,children:m,loading:j}=t,g=n*14,[w,L]=r.useState(!1),N=c(es(a)),I=c("hub.openWithTarget").replace("{target}",N);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:x.isDir?()=>s(x.path):void 0,onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),className:M("flex items-center gap-1.5 py-1 rounded text-[11px] text-fg-3 transition-colors",x.isDir?"hover:bg-panel-h/50 cursor-pointer":"hover:bg-panel-h/50 cursor-default"),style:{paddingLeft:8+g,paddingRight:8},children:[x.isDir?j?e.jsx(pe,{className:"h-2 w-2 text-fg-5 shrink-0"}):e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:M("shrink-0 text-fg-5/40 transition-transform duration-150",d&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}):e.jsx("span",{className:"w-2 shrink-0"}),x.isDir?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",className:"shrink-0 text-blue-400/70",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z",fill:"currentColor",opacity:"0.25",stroke:"currentColor",strokeWidth:"1.5"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"shrink-0 text-fg-5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"truncate flex-1",children:x.name}),w&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:T=>{T.stopPropagation(),l(x.path)},className:"inline-flex items-center gap-1 rounded px-1 py-0.5 text-fg-5 hover:text-blue-400 transition-colors",title:I,children:e.jsx(ts,{target:a,subtle:!0})}),!x.isDir&&e.jsx(Vr,{filePath:x.path,t:c})]})]}),x.isDir&&d&&m&&m.length>0&&e.jsx(ns,{nodes:m,depth:n+1,onToggle:s,openTarget:a,onOpenPath:l,t:c})]})}function Vr({filePath:t,t:n}){const[s,a]=r.useState(!1);return e.jsx("button",{onClick:l=>{l.stopPropagation(),navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},className:M("p-0.5 rounded transition-colors",s?"text-ok":"text-fg-5 hover:text-fg-3"),title:n("hub.copied"),children:s?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})}function hn(t,n,s){return t.map(a=>a.entry.path===n?{...a,...s}:a.children?{...a,children:hn(a.children,n,s)}:a)}const ao=Object.freeze(Object.defineProperty({__proto__:null,SessionWorkspace:Br},Symbol.toStringTag,{value:"Module"}));export{Vs as I,io as L,sr as R,lo as T,Jn as U,so as a,qn as b,cn as c,oo as d,jr as e,ao as i,As as l,ro as m,no as n,Is as p,to as s};