@townco/gui-template 0.1.97 → 0.1.99
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.
|
@@ -4,7 +4,7 @@ import{r as i,j as e,M as ta,c as Rt,h as sa}from"./react-CsyacleJ.js";import{bb
|
|
|
4
4
|
[Cancelled]`,isStreaming:!1,streamingStartTime:void 0})):(Q.warn("Stream ended without isComplete flag"),u(W,{isStreaming:!1,streamingStartTime:void 0})),l(!1),r(null),v.current=null)}catch(K){const D=K instanceof Error?K.message:String(K);m(D),l(!1),r(null),v.current=null,u(W,{isStreaming:!1,streamingStartTime:void 0})}},[t,o,s,c,u,l,r,m,d,p,g,h,x,f,N]),M=i.useCallback(async()=>{if(!t||!n){Q.debug("Cannot cancel: not streaming or no client");return}Q.info("Cancelling current turn"),k.current=!0;try{await t.cancel(o||void 0)}catch(S){Q.error("Error cancelling turn",{error:S})}},[t,n,o]),A=i.useCallback(async(S,I,$)=>{if(Q.debug("[editAndResend] Called with",{userMessageIndex:S,contentLength:I.length,attachmentsCount:$?.length||0}),!t){Q.error("No client available"),m("No client available");return}if(!o){Q.error("No session available"),m("No session available");return}let B=0,W=-1;for(let z=0;z<a.length;z++)if(a[z]?.role==="user"){if(B===S){W=z;break}B++}if(W===-1){Q.error("User message not found",{userMessageIndex:S,totalUserMessages:B}),m("User message not found");return}const K=a[W];Q.debug("[editAndResend] Found target message",{userMessageIndex:S,targetArrayIndex:W,messageRole:K?.role});const D=me("assistant");try{const z=Date.now();l(!0),r(z),C(W);const T={id:me("user"),role:"user",content:I,timestamp:new Date().toISOString(),isStreaming:!1,...$&&$.length>0?{images:$.filter(_=>_.mimeType.startsWith("image/")).map(_=>({mimeType:_.mimeType,data:_.data}))}:{}};c(T);const E={id:D,role:"assistant",content:"",timestamp:new Date().toISOString(),isStreaming:!0,streamingStartTime:z};c(E),v.current=D,k.current=!1;const j=t.receiveMessages();t.editAndResend(S,I,o,$).catch(_=>{const q=_ instanceof Error?_.message:String(_);m(q),l(!1),r(null)});let y="",R=!1;for await(const _ of j){if(k.current){Q.info("Stream cancelled, exiting loop");break}if(_.type==="content"){const X=_._meta?.context_size||_.context_size;if(X!=null){const V=X;Q.info("✅ Received context_size from backend",{context_size:V,totalEstimated:V.totalEstimated}),d(V)}if(_.isComplete){u(D,{content:y,isStreaming:!1,streamingStartTime:void 0,..._.tokenUsage?{tokenUsage:_.tokenUsage}:{}}),l(!1),r(null),v.current=null,R=!0;break}else _.contentDelta.type==="text"&&(y+=_.contentDelta.text,u(D,{content:y,..._.tokenUsage?{tokenUsage:_.tokenUsage}:{}}),document.hidden||await new Promise(V=>setTimeout(V,16)))}else _.type==="tool_call"?(Q.debug("Received tool_call chunk",{chunk:_}),p(o,_.toolCall),h(_.toolCall)):_.type==="tool_call_update"?(Q.debug("Received tool_call_update chunk",{chunk:_}),g(o,_.toolCallUpdate),x(_.toolCallUpdate)):_.type==="hook_notification"?(Q.debug("Received hook_notification chunk",{chunk:_}),f(_.notification)):_.type==="sources"&&(Q.debug("Received sources chunk",{chunk:_}),N(_.sources))}R||(k.current?(Q.info("Stream cancelled by user"),u(D,{content:`${y}
|
|
5
5
|
|
|
6
6
|
[Cancelled]`,isStreaming:!1,streamingStartTime:void 0})):(Q.warn("Stream ended without isComplete flag"),u(D,{isStreaming:!1,streamingStartTime:void 0})),l(!1),r(null),v.current=null)}catch(z){const T=z instanceof Error?z.message:String(z);m(T),l(!1),r(null),v.current=null,u(D,{isStreaming:!1,streamingStartTime:void 0})}},[t,o,a,C,c,u,l,r,m,d,p,g,h,x,f,N]);return{messages:a,isStreaming:n,sendMessage:P,editAndResend:A,cancel:M}}const es=xe("use-chat-input","debug");function Oo(t,s){const a=L(g=>g.input),n=L(g=>g.setInputValue),o=L(g=>g.setInputSubmitting),l=L(g=>g.addFileAttachment),r=L(g=>g.removeFileAttachment),{sendMessage:c}=Ks(t,s),u=i.useCallback(g=>{n(g)},[n]),m=i.useCallback(async()=>{const g=L.getState().input;if(!g.value.trim()||g.isSubmitting)return;const h=g.value,x=g.attachedFiles,f=g.selectedPromptParameters;es.debug("Submitting message with attachments",{messageLength:h.length,attachmentCount:x.length,hasAttachments:x.length>0,hasPromptParameters:!!f&&Object.keys(f).length>0,promptParameters:f}),n(""),o(!0);try{await c(h,x.length>0?x:void 0,f&&Object.keys(f).length>0?f:void 0),L.setState(N=>({input:{...N.input,attachedFiles:[]}}))}catch(N){es.error("Failed to send message",{error:N instanceof Error?N.message:String(N)})}finally{o(!1)}},[n,o,c]),d=i.useCallback(g=>{l(g)},[l]),p=i.useCallback(g=>{r(g)},[r]);return{value:a.value,isSubmitting:a.isSubmitting,attachedFiles:a.attachedFiles,onChange:u,onSubmit:m,onAttachFile:d,onRemoveFile:p}}const Se=xe("use-chat-session","debug");function Fo(t,s){const a=L(f=>f.connectionStatus),n=L(f=>f.sessionId),o=L(f=>f.setConnectionStatus),l=L(f=>f.setSessionId),r=L(f=>f.setError),c=L(f=>f.clearMessages),u=L(f=>f.resetTokens),m=L(f=>f.addMessage),d=L(f=>f.setLatestContextSize);i.useEffect(()=>t?t.onSessionUpdate(N=>{const C=N._meta,v=C?.context_size||N.context_size;if(v!=null){const k=v;Se.info("✅ Received context_size from session update",{context_size:k,totalEstimated:k.totalEstimated,isReplay:C?.isReplay}),d(k)}if(N.message&&(Se.debug("Session update with message",{message:N.message}),N.message.role!=="tool")){const k=N.message.content.map(S=>S.type==="text"?S.text:"").join(""),P=[];for(const S of N.message.content)if(S.type==="image"){const I=S;I.source?.data?P.push({mimeType:I.source.media_type||"image/png",data:I.source.data}):I.data&&P.push({mimeType:I.mimeType||"image/png",data:I.data})}const M=L.getState().messages,A=M[M.length-1];if(N.message.role==="assistant"&&A?.role==="assistant"&&A.content===""&&k)Se.debug("Appending text to existing assistant message"),L.getState().updateMessage(A.id,{content:A.content+k});else{const S={id:N.message.id,role:N.message.role,content:k,timestamp:N.message.timestamp,isStreaming:!1,...P.length>0?{images:P}:{}};m(S)}}}):void 0,[t,m,d]);const p=i.useCallback(async()=>{if(!t){r("No client available");return}try{o("connecting"),r(null),await t.connect();const f=t.getCurrentSession();if(f?.id&&(l(f.id),typeof window<"u")){const N=new URL(window.location.href);N.searchParams.set("session",f.id),window.history.replaceState({},"",N.toString())}o("connected")}catch(f){Se.error("Failed to connect",{error:f instanceof Error?f.message:String(f)});const N=f instanceof Error?f.message:String(f);r(N),o("error")}},[t,o,l,r]),g=i.useCallback(async f=>{if(!t){r("No client available");return}try{o("connecting"),r(null),c(),u();const N=await t.loadSession(f);l(N),o("connected"),Se.info("Session loaded successfully",{sessionId:N})}catch(N){Se.warn("Failed to load session, creating new one instead",{sessionId:f,error:N instanceof Error?N.message:String(N)});try{await p();const C=await t.startSession();if(l(C),c(),u(),typeof window<"u"){const v=new URL(window.location.href);v.searchParams.set("session",C),window.history.replaceState({},"",v.toString())}Se.info("Created new session after failed load",{sessionId:C})}catch(C){const v=C instanceof Error?C.message:String(C);r(`Failed to load or create session: ${v}`),o("error")}}},[t,o,l,r,c,u,p]),h=i.useCallback(async()=>{if(!t)return r("No client available"),null;try{const f=await t.startSession();if(l(f),L.getState().messages.length===0&&(c(),u()),typeof window<"u"){const C=new URL(window.location.href);C.searchParams.set("session",f),window.history.pushState({},"",C.toString())}return f}catch(f){const N=f instanceof Error?f.message:String(f);return r(N),null}},[t,l,r,c,u]),x=i.useCallback(async()=>{if(t)try{await t.disconnect(),o("disconnected"),l(null)}catch(f){const N=f instanceof Error?f.message:String(f);r(N)}},[t,o,l,r]);return i.useEffect(()=>{!t||a!=="disconnected"||(s?(Se.info("Loading initial session from URL",{sessionId:s}),g(s)):p())},[t,a,s,p,g]),{connectionStatus:a,sessionId:n,connect:p,loadSession:g,startSession:h,disconnect:x}}const ts="town-message-history",Bo=100;function Ho(){const[t,s]=i.useState(-1),[a,n]=i.useState(""),o=i.useCallback(()=>{try{const d=localStorage.getItem(ts);return d?JSON.parse(d):[]}catch{return[]}},[]),l=i.useCallback(d=>{const p=d.trim();if(p){try{const g=o();if(g[0]===p)return;const h=[p,...g].slice(0,Bo);localStorage.setItem(ts,JSON.stringify(h))}catch{}s(-1),n("")}},[o]),r=i.useCallback(d=>{const p=o();if(p.length===0)return null;t===-1&&n(d);const g=Math.min(t+1,p.length-1);if(g===t)return null;const h=p[g];return h===void 0?null:(s(g),h)},[t,o]),c=i.useCallback(()=>{if(t===-1)return null;const d=o();if(t===0){s(-1);const h=a;return n(""),h}const p=t-1,g=d[p];return g===void 0?null:(s(p),g)},[t,a,o]),u=i.useCallback(()=>{t!==-1&&(s(-1),n(""))},[t]);return{addToHistory:l,navigatePrevious:r,navigateNext:c,resetNavigation:u,isBrowsingHistory:t!==-1,historyIndex:t}}const le=xe("subagent-stream");function Wo(t){const[s,a]=i.useState([]),[n,o]=i.useState(!!t),[l,r]=i.useState(!1),[c,u]=i.useState(null),m=i.useRef(null),d=i.useRef(null),p=i.useRef(null),g=i.useCallback(()=>{p.current||(p.current=setTimeout(()=>{p.current=null,d.current&&a([{...d.current}])},250))},[]),h=i.useCallback(k=>{try{const P=JSON.parse(k);if(le.debug("Processing SSE message",{method:P.method,hasParams:!!P.params}),P.method==="session/update"&&P.params?.update){const M=P.params.update;if(le.debug("Got session update",{sessionUpdate:M.sessionUpdate}),M.sessionUpdate==="agent_message_chunk"){const A=M.content;if(A?.type==="text"&&typeof A.text=="string"&&d.current){d.current.content+=A.text;const S=d.current.contentBlocks??[],I=S[S.length-1];I&&I.type==="text"?I.text+=A.text:S.push({type:"text",text:A.text}),d.current.contentBlocks=S,g()}}else if(M.sessionUpdate==="tool_call"){const A={id:M.toolCallId??`tc-${Date.now()}`,title:M.title??"Tool call",prettyName:M._meta?.prettyName,icon:M._meta?.icon,status:M.status??"pending",content:[]};if(d.current){d.current.toolCalls=[...d.current.toolCalls??[],A];const S=d.current.contentBlocks??[];S.push({type:"tool_call",toolCall:A}),d.current.contentBlocks=S,g()}}else if(M.sessionUpdate==="tool_call_update"&&d.current?.toolCalls){const A=M.toolCallId,S=I=>I.id===A?{...I,status:M.status??I.status,content:M.content??I.content}:I;d.current.toolCalls=d.current.toolCalls.map(S),d.current.contentBlocks&&(d.current.contentBlocks=d.current.contentBlocks.map(I=>I.type==="tool_call"?{...I,toolCall:S(I.toolCall)}:I)),g()}}}catch(P){le.error("Failed to parse sub-agent SSE message",{error:P instanceof Error?P.message:String(P)})}},[g]),x=i.useCallback(async(k,P,M)=>{const A=`http://${M}:${k}`;le.info("Connecting to sub-agent SSE",{baseUrl:A,sessionId:P}),o(!0),u(null);const S=new AbortController;m.current=S;try{le.info("Fetching SSE endpoint",{url:`${A}/events`,sessionId:P});const I=await fetch(`${A}/events`,{method:"GET",headers:{"X-Session-ID":P},signal:S.signal});if(le.info("SSE response received",{status:I.status,ok:I.ok}),!I.ok)throw new Error(`SSE connection failed: HTTP ${I.status}`);if(!I.body)throw new Error("Response body is null");le.info("Sub-agent SSE connection opened, starting to read stream");const $=I.body.getReader(),B=new TextDecoder;let W="";for(d.current={id:`subagent-${Date.now()}`,content:"",toolCalls:[],contentBlocks:[],isStreaming:!0},a([d.current]);;){const{done:K,value:D}=await $.read();if(K){le.debug("Sub-agent SSE stream closed");break}W+=B.decode(D,{stream:!0});const z=W.split(`
|
|
7
|
-
`);W=z.pop()||"";let T={event:"message",data:""};for(const E of z)E.startsWith("event:")?T.event=E.substring(6).trim():E.startsWith("data:")?T.data=E.substring(5).trim():E===""&&(T.event==="message"&&T.data&&h(T.data),T={event:"message",data:""})}}catch(I){if(I instanceof Error&&I.name==="AbortError")le.debug("Sub-agent SSE stream aborted");else{const $=I instanceof Error?I.message:"Failed to connect to sub-agent";le.error("Sub-agent SSE error",{error:$}),u($)}}finally{d.current&&(d.current.isStreaming=!1,a(I=>I.map($=>$.id===d.current?.id?{...$,isStreaming:!1}:$))),r(!0),o(!1),m.current=null,le.debug("Sub-agent stream completed")}},[h]),f=t?.port,N=t?.sessionId,C=t?.host??"localhost";return i.useEffect(()=>{if(!(!f||!N))return a([]),u(null),r(!1),o(!0),x(f,N,C),()=>{m.current&&(m.current.abort(),m.current=null),p.current&&(clearTimeout(p.current),p.current=null)}},[f,N,C,x]),{messages:s,isStreaming:!l,error:c}}function Vo(t){const s=L(r=>r.toolCalls),a=L(r=>r.addToolCall),n=L(r=>r.updateToolCall),o=L(r=>r.addToolCallToCurrentMessage),l=L(r=>r.updateToolCallInCurrentMessage);return i.useEffect(()=>{if(!t)return;const r=t.onSessionUpdate(c=>{c.type==="tool_call"?(a(c.sessionId,c.toolCall),o(c.toolCall)):c.type==="tool_call_update"&&(n(c.sessionId,c.toolCallUpdate),l(c.toolCallUpdate))});return()=>{r()}},[t,a,n,o,l]),{toolCalls:s,getToolCallsForSession:r=>{const c=s[r];return c&&c.length>0?c:Object.values(s).flat()}}}const qo=F({name:w(),description:w().optional(),parameters:te(w(),ie()).optional()}),Ko=F({name:w(),description:w(),parameters:te(w(),ie()),required:Z(w()).optional()}),Yo=F({name:w(),version:w().optional(),description:w().optional(),author:w().optional(),capabilities:Z(qo).optional(),tools:Z(Ko).optional(),supportedFormats:Z(w()).optional()}),Go=ae(["initializing","ready","busy","error","terminated"]);F({status:Go,info:Yo.optional(),pid:H().optional(),error:w().optional(),uptime:H().optional()});const Ys=ae(["idle","connecting","connected","active","streaming","error","disconnected"]),Qo=F({agentPath:w(),agentArgs:Z(w()).optional(),environment:te(w(),w()).optional(),workingDirectory:w().optional(),timeout:H().optional()}),Xo=F({agentName:w().optional(),agentVersion:w().optional(),capabilities:Z(w()).optional(),startedAt:ot(),lastActivityAt:ot().optional()});F({id:w(),status:Ys,config:Qo,metadata:Xo.optional(),messages:Z(Bs),error:w().optional()});const yt=F({sessionId:w(),status:Ys.optional(),message:Bs.optional(),error:w().optional(),_meta:te(w(),ie()).optional()}),Jo=yt.extend({type:J("tool_call"),toolCall:qs,messageId:w().optional()}),Zo=yt.extend({type:J("tool_call_update"),toolCallUpdate:Io,messageId:w().optional()}),er=yt.extend({type:J("tool_output"),toolOutput:F({id:w(),content:Z(Mt()).optional(),rawOutput:te(w(),ie()).optional()}),messageId:w().optional()}),tr=yt.extend({type:J("generic").optional()});oa([Jo,Zo,er,tr]);const sr=[{id:"folder-1",name:"Item 1",type:"folder",children:[{id:"file-1-1",name:"Item 2",type:"file",extension:"tsx"},{id:"file-1-2",name:"Item 3",type:"file",extension:"ts"},{id:"file-1-3",name:"Item 4",type:"file",extension:"json"},{id:"file-1-4",name:"Item 5",type:"file",extension:"md"}]},{id:"folder-2",name:"Description 1",type:"folder",children:[{id:"file-2-1",name:"Description 2",type:"file",extension:"tsx"},{id:"file-2-2",name:"Description 3",type:"file",extension:"ts"},{id:"file-2-3",name:"Description 4",type:"file",extension:"json"},{id:"file-2-4",name:"Description 5",type:"file",extension:"md"}]},{id:"folder-3",name:"financial-docs",type:"folder",children:[]}];class nr{data;constructor(s=sr){this.data=s}async getRootItems(){return Promise.resolve(this.data)}async getItemChildren(s){const a=o=>{for(const l of o){if(l.id===s)return l;if(l.children){const r=a(l.children);if(r)return r}}},n=a(this.data);return Promise.resolve(n?.children||[])}async getItemDetails(s){const a=o=>{for(const l of o){if(l.id===s)return l;if(l.children){const r=a(l.children);if(r)return r}}},n=a(this.data);if(!n)throw new Error(`Item with id ${s} not found`);return Promise.resolve(n)}}function b(...t){return ra(ia(t))}const ar=je("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-paragraph-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive-hover",outline:"border border-input bg-background hover:bg-accent-hover hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover",ghost:"hover:bg-accent-hover hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=i.forwardRef(({className:t,variant:s,size:a,asChild:n=!1,...o},l)=>{const r=n?ue:"button";return e.jsx(r,{className:b(ar({variant:s,size:a,className:t})),ref:l,...o})});ne.displayName="Button";const fe=ma,ge=pa,he=fa,de=i.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(ds,{ref:n,sideOffset:s,className:b("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));de.displayName=ds.displayName;const Gs=({className:t,children:s,...a})=>e.jsx("div",{className:b("flex items-center gap-1",t),...a,children:s}),it=({tooltip:t,children:s,label:a,className:n,variant:o="ghost",size:l="sm",...r})=>{const c=e.jsxs(ne,{className:b("relative size-7 p-1.5 text-muted-foreground hover:text-foreground",n),size:l,type:"button",variant:o,...r,children:[s,e.jsx("span",{className:"sr-only",children:a||t})]});return t?e.jsx(fe,{children:e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:c}),e.jsx(de,{children:e.jsx("p",{children:t})})]})}):c},ke=i.forwardRef(({className:t,...s},a)=>e.jsx(ne,{ref:a,variant:"ghost",size:"icon",className:b("rounded-full",t),...s}));ke.displayName="IconButton";const Xe=ha,Je=xa,or=i.forwardRef(({className:t,inset:s,children:a,...n},o)=>e.jsxs(us,{ref:o,className:b("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-paragraph-sm outline-none","focus:bg-muted data-[state=open]:bg-muted",s&&"pl-8",t),...n,children:[a,e.jsx(We,{className:"ml-auto h-4 w-4"})]}));or.displayName=us.displayName;const rr=i.forwardRef(({className:t,...s},a)=>e.jsx(ms,{ref:a,className:b("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",t),...s}));rr.displayName=ms.displayName;const Le=i.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(ga,{children:e.jsx(ps,{ref:n,sideOffset:s,className:b("z-50 min-w-[8rem] overflow-hidden rounded-lg border border-border bg-popover p-0.5 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",t),...a})}));Le.displayName=ps.displayName;const pe=i.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(fs,{ref:n,className:b("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s&&"pl-8",t),...a}));pe.displayName=fs.displayName;const ir=i.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(gs,{ref:n,className:b("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(hs,{children:e.jsx(pt,{className:"h-4 w-4"})})}),s]}));ir.displayName=gs.displayName;const lr=i.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(xs,{ref:n,className:b("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(hs,{children:e.jsx(ft,{className:"h-2 w-2 fill-current"})})}),s]}));lr.displayName=xs.displayName;const cr=i.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(bs,{ref:n,className:b("px-2 py-1.5 text-paragraph-sm font-semibold",s&&"pl-8",t),...a}));cr.displayName=bs.displayName;const Qs=i.forwardRef(({className:t,...s},a)=>e.jsx(ys,{ref:a,className:b("-mx-1 my-1 h-px bg-border",t),...s}));Qs.displayName=ys.displayName;const dr=256,ur="calc(100vw - 104px)",Xs=450,ss=250,ns=800,mr=720,pr=56,fr=pr*2;function Js(t){i.useEffect(()=>{if(!t)return;const s=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${s}px`,document.body.style.width="100%",document.body.style.overflow="hidden",()=>{document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,s)}},[t])}const Ct=768;function Zs(){const[t,s]=i.useState(void 0);return i.useEffect(()=>{const a=window.matchMedia(`(max-width: ${Ct-1}px)`),n=()=>{s(window.innerWidth<Ct)};return a.addEventListener("change",n),s(window.innerWidth<Ct),()=>a.removeEventListener("change",n)},[]),!!t}const Ze={smooth:[.25,.1,.25,1]},gr={duration:.25,ease:Ze.smooth},as={duration:.15,ease:Ze.smooth},hr={initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"}},xr={initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"}},os={initial:{opacity:0,x:-20},animate:{opacity:1,x:0}},rs={duration:.25,ease:Ze.smooth,delay:.1},br={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},yr={initial:{x:"100%"},animate:{x:0},exit:{x:"100%"}},vr={initial:{opacity:0,x:20},animate:{opacity:1,x:0}},wr={duration:.25,ease:Ze.smooth,delay:.1},jr={duration:.15,ease:Ze.smooth},Nr=je("flex h-10 w-full rounded-md border bg-input-background px-3 py-2 text-paragraph-sm ring-offset-background file:border-0 file:bg-transparent file:text-paragraph-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),en=i.forwardRef(({className:t,type:s,variant:a,...n},o)=>e.jsx("input",{type:s,className:b(Nr({variant:a,className:t})),ref:o,...n}));en.displayName="Input";const Sr="sidebar_state",Cr=3600*24*7,kr="s",tn=i.createContext(null);function Te(){const t=i.useContext(tn);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const sn=i.forwardRef(({defaultOpen:t=!0,open:s,onOpenChange:a,className:n,style:o,children:l,...r},c)=>{const u=Zs(),[m,d]=i.useState(!1),[p,g]=i.useState(t),h=s??p,x=i.useCallback(v=>{const k=typeof v=="function"?v(h):v;a?a(k):g(k),document.cookie=`${Sr}=${k}; path=/; max-age=${Cr}`},[a,h]),f=i.useCallback(()=>u?d(v=>!v):x(v=>!v),[u,x]);i.useEffect(()=>{const v=k=>{k.key.toLowerCase()===kr&&k.shiftKey&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),f())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f]);const N=h?"expanded":"collapsed",C=i.useMemo(()=>({state:N,open:h,setOpen:x,isMobile:u,openMobile:m,setOpenMobile:d,toggleSidebar:f}),[N,h,x,u,m,f]);return e.jsx(tn.Provider,{value:C,children:e.jsx(fe,{delayDuration:0,children:e.jsx("div",{className:b("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",n),ref:c,style:o,...r,children:l})})})});sn.displayName="SidebarProvider";const nn=i.forwardRef(({className:t,children:s},a)=>{const{isMobile:n,open:o,openMobile:l,setOpenMobile:r}=Te();return Js(n&&l),n?e.jsx(Ye,{initial:!1,children:l&&e.jsxs(e.Fragment,{children:[e.jsx(ve.div,{className:"fixed inset-0 z-40 bg-background/80",variants:br,initial:"initial",animate:"animate",exit:"exit",transition:as,onClick:()=>r(!1),"aria-label":"Close sidebar"}),e.jsx(ve.aside,{ref:a,className:b("fixed inset-y-0 left-0 z-50","bg-sidebar text-sidebar-foreground","flex flex-col","border-r border-sidebar-border","max-h-screen overflow-hidden",t),style:{width:ur},variants:xr,initial:"initial",animate:"animate",exit:"exit",transition:as,"data-sidebar":"sidebar","data-mobile":"true",children:e.jsx(ve.div,{className:"flex flex-col h-full overflow-y-auto",variants:os,initial:"initial",animate:"animate",transition:rs,children:s})})]})}):e.jsx("div",{className:"group peer hidden md:block","data-state":o?"expanded":"collapsed","data-side":"left",ref:a,children:e.jsx(Ye,{initial:!1,mode:"wait",children:o&&e.jsx(ve.aside,{className:b("fixed inset-y-0 left-0 z-40","bg-sidebar text-sidebar-foreground","border-r border-sidebar-border","flex flex-col","max-h-screen overflow-hidden",t),style:{width:dr},variants:hr,initial:"initial",animate:"animate",exit:"exit",transition:gr,"data-sidebar":"sidebar",children:e.jsx(ve.div,{className:"flex flex-col h-full overflow-y-auto",variants:os,initial:"initial",animate:"animate",transition:rs,children:s})})})})});nn.displayName="Sidebar";const Tr=i.forwardRef(({className:t,onClick:s,...a},n)=>{const{toggleSidebar:o}=Te();return e.jsxs(ne,{className:b("h-7 w-7",t),"data-sidebar":"trigger",onClick:l=>{s?.(l),o()},ref:n,size:"icon",variant:"ghost",...a,children:[e.jsx(Sa,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Tr.displayName="SidebarTrigger";const Ir=i.forwardRef(({className:t,...s},a)=>{const{toggleSidebar:n}=Te();return e.jsx("button",{type:"button","aria-label":"Toggle Sidebar",className:b("-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),"data-sidebar":"rail",onClick:n,ref:a,tabIndex:-1,title:"Toggle Sidebar",...s})});Ir.displayName="SidebarRail";const an=i.forwardRef(({className:t,children:s,...a},n)=>{const{isMobile:o,open:l}=Te();return e.jsx("main",{className:b("relative flex w-full flex-1 flex-col bg-background transition-all duration-250",!o&&l&&"md:pl-64",t),ref:n,...a,children:s})});an.displayName="SidebarInset";const Rr=i.forwardRef(({className:t,...s},a)=>e.jsx(en,{className:b("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),"data-sidebar":"input",ref:a,...s}));Rr.displayName="SidebarInput";const on=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("flex flex-col gap-2 p-2",t),"data-sidebar":"header",ref:a,...s}));on.displayName="SidebarHeader";const rn=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("flex flex-col gap-2 p-2",t),"data-sidebar":"footer",ref:a,...s}));rn.displayName="SidebarFooter";const _r=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("mx-2 h-px w-auto bg-sidebar-border",t),"data-sidebar":"separator",ref:a,...s}));_r.displayName="SidebarSeparator";const ln=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),"data-sidebar":"content",ref:a,...s}));ln.displayName="SidebarContent";const Be=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("relative flex w-full min-w-0 flex-col p-4",t),"data-sidebar":"group",ref:a,...s}));Be.displayName="SidebarGroup";const cn=i.forwardRef(({className:t,asChild:s=!1,...a},n)=>{const o=s?ue:"div";return e.jsx(o,{className:b("flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),"data-sidebar":"group-label",ref:n,...a})});cn.displayName="SidebarGroupLabel";const Mr=i.forwardRef(({className:t,asChild:s=!1,...a},n)=>{const o=s?ue:"button";return e.jsx(o,{className:b("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:-inset-2 after:absolute after:md:hidden","group-data-[collapsible=icon]:hidden",t),"data-sidebar":"group-action",ref:n,type:"button",...a})});Mr.displayName="SidebarGroupAction";const He=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("w-full text-sm",t),"data-sidebar":"group-content",ref:a,...s}));He.displayName="SidebarGroupContent";const dn=i.forwardRef(({className:t,...s},a)=>e.jsx("ul",{className:b("flex w-full min-w-0 flex-col gap-1",t),"data-sidebar":"menu",ref:a,...s}));dn.displayName="SidebarMenu";const un=i.forwardRef(({className:t,...s},a)=>e.jsx("li",{className:b("group/menu-item relative",t),"data-sidebar":"menu-item",ref:a,...s}));un.displayName="SidebarMenuItem";const Er=je("peer/menu-button group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"group-data-[collapsible=icon]:!p-0 h-12 text-sm"}},defaultVariants:{variant:"default",size:"default"}}),mn=i.forwardRef(({asChild:t=!1,isActive:s=!1,variant:a="default",size:n="default",tooltip:o,className:l,...r},c)=>{const u=t?ue:"button",{isMobile:m,state:d}=Te(),p=e.jsx(u,{className:b(Er({variant:a,size:n}),l),"data-active":s,"data-sidebar":"menu-button","data-size":n,ref:c,type:t?void 0:"button",...r});return o?(typeof o=="string"&&(o={children:o}),e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:p}),e.jsx(de,{align:"center",hidden:d!=="collapsed"||m,side:"right",...o})]})):p});mn.displayName="SidebarMenuButton";const pn=i.forwardRef(({className:t,asChild:s=!1,showOnHover:a=!1,...n},o)=>{const l=s?ue:"button";return e.jsx(l,{className:b("absolute top-3 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:-inset-2 after:absolute after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-2.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",a&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),"data-sidebar":"menu-action",ref:o,type:s?void 0:"button",...n})});pn.displayName="SidebarMenuAction";const Ar=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 font-medium text-sidebar-foreground text-xs tabular-nums","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),"data-sidebar":"menu-badge",ref:a,...s}));Ar.displayName="SidebarMenuBadge";const Pr=i.forwardRef(({className:t,showIcon:s=!1,...a},n)=>{const o=i.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return e.jsxs("div",{className:b("flex h-8 items-center gap-2 rounded-md px-2",t),"data-sidebar":"menu-skeleton",ref:n,...a,children:[s&&e.jsx("div",{className:"size-4 rounded-md bg-sidebar-accent-foreground/10 animate-pulse","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse","data-sidebar":"menu-skeleton-text",style:{maxWidth:o}})]})});Pr.displayName="SidebarMenuSkeleton";const Dr=i.forwardRef(({className:t,...s},a)=>e.jsx("ul",{className:b("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),"data-sidebar":"menu-sub",ref:a,...s}));Dr.displayName="SidebarMenuSub";const Ur=i.forwardRef(({...t},s)=>e.jsx("li",{ref:s,...t}));Ur.displayName="SidebarMenuSubItem";const zr=i.forwardRef(({asChild:t=!1,size:s="md",isActive:a,className:n,...o},l)=>{const r=t?ue:"a";return e.jsx(r,{className:b("-translate-x-px flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",s==="sm"&&"text-xs",s==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",n),"data-active":a,"data-sidebar":"menu-sub-button","data-size":s,ref:l,...o})});zr.displayName="SidebarMenuSubButton";const $r=({session:t,isActive:s,onSelect:a,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r})=>e.jsxs(un,{children:[e.jsx(mn,{asChild:!0,isActive:s,onClick:()=>{a(t.sessionId),r(!1)},className:"h-10 px-2 py-3",children:e.jsx("button",{type:"button",className:"w-full text-base",children:e.jsx("span",{className:"truncate",children:t.firstUserMessage||"Empty session"})})}),e.jsxs(Xe,{modal:!0,children:[e.jsx(Je,{asChild:!0,children:e.jsxs(pn,{className:"mr-0.5 data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",showOnHover:!s,children:[e.jsx(Ca,{}),e.jsx("span",{className:"sr-only",children:"More"})]})}),e.jsxs(Le,{align:"end",side:"bottom",children:[e.jsx(pe,{className:"cursor-pointer",disabled:!n,onSelect:()=>n?.(t.sessionId),children:"Rename"}),e.jsx(pe,{className:"cursor-pointer",disabled:!o,onSelect:()=>o?.(t.sessionId),children:"Archive"}),e.jsx(Qs,{}),e.jsx(pe,{className:b("cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive"),disabled:!l,onSelect:()=>l?.(t.sessionId),children:"Delete"})]})]})]}),Fe=i.memo($r,(t,s)=>!(t.isActive!==s.isActive||t.session.sessionId!==s.session.sessionId||t.session.firstUserMessage!==s.session.firstUserMessage)),Lr=xe("session-history"),Or=t=>{const s=new Date;return t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear()},Fr=t=>{const s=new Date;return s.setDate(s.getDate()-1),t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear()},Br=t=>{const s=new Date,a=new Date(s.getTime()-10080*60*1e3),n=new Date(s.getTime()-720*60*60*1e3);return t.reduce((o,l)=>{const r=new Date(l.updatedAt);return Or(r)?o.today.push(l):Fr(r)?o.yesterday.push(l):r>a?o.lastWeek.push(l):r>n?o.lastMonth.push(l):o.older.push(l),o},{today:[],yesterday:[],lastWeek:[],lastMonth:[],older:[]})};function Hr({client:t,currentSessionId:s,onSessionSelect:a,onRenameSession:n,onArchiveSession:o,onDeleteSession:l}){const{setOpenMobile:r}=Te(),[c,u]=i.useState([]),[m,d]=i.useState(!1),p=i.useCallback(async()=>{if(t){d(!0);try{const x=await t.listSessions();u(x)}catch(x){Lr.error("Failed to fetch sessions",{error:x})}finally{d(!1)}}},[t]);i.useEffect(()=>{p()},[p]);const g=x=>{if(x!==s)if(a)a(x);else{const f=new URL(window.location.href);f.searchParams.set("session",x),window.location.href=f.toString()}};if(!t)return e.jsx(Be,{children:e.jsx(He,{children:e.jsx("div",{className:"flex w-full flex-row items-center justify-center gap-2 px-2 text-sm text-muted-foreground",children:"Connect to an agent to see session history"})})});if(m)return e.jsxs(Be,{children:[e.jsx(cn,{children:"Today"}),e.jsx(He,{children:e.jsx("div",{className:"flex flex-col",children:[44,32,28,64,52].map(x=>e.jsx("div",{className:"flex h-8 items-center gap-2 rounded-md px-2",children:e.jsx("div",{className:"h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse",style:{maxWidth:`${x}%`}})},x))})})]});if(c.length===0)return e.jsx(Be,{children:e.jsx(He,{children:e.jsx("div",{className:"flex w-full flex-row items-center justify-center gap-2 px-2 py-4 text-sm text-muted-foreground",children:"Your sessions will appear here once you start chatting!"})})});const h=Br(c);return e.jsx(Be,{children:e.jsx(He,{children:e.jsx(dn,{children:e.jsxs("div",{className:"flex flex-col gap-6",children:[h.today.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Today"}),h.today.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.yesterday.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Yesterday"}),h.yesterday.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.lastWeek.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Last 7 days"}),h.lastWeek.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.lastMonth.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Last 30 days"}),h.lastMonth.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.older.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Older"}),h.older.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]})]})})})})}const Wr={theme:"system",setTheme:()=>null,resolvedTheme:"light"},fn=i.createContext(Wr);function Vr({children:t,defaultTheme:s="system",storageKey:a="vite-ui-theme"}){const[n,o]=i.useState(()=>localStorage.getItem(a)||s),[l,r]=i.useState("light");i.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),n==="system"){const m=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(m),r(m);return}u.classList.add(n),r(n)},[n]);const c={theme:n,setTheme:u=>{localStorage.setItem(a,u),o(u)},resolvedTheme:l};return e.jsx(fn.Provider,{value:c,children:t})}const $t=()=>{const t=i.useContext(fn);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function qr(){const{setTheme:t}=$t();return e.jsxs(Xe,{children:[e.jsx(Je,{asChild:!0,children:e.jsxs(ke,{children:[e.jsx(As,{className:"size-4 text-muted-foreground rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(Ps,{className:"absolute size-4 text-muted-foreground rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(Le,{align:"end",children:[e.jsx(pe,{onClick:()=>t("light"),children:"Light"}),e.jsx(pe,{onClick:()=>t("dark"),children:"Dark"}),e.jsx(pe,{onClick:()=>t("system"),children:"System"})]})]})}function Kr({client:t,currentSessionId:s,onSessionSelect:a,onNewSession:n,onRenameSession:o,onArchiveSession:l,onDeleteSession:r,className:c}){const{setOpenMobile:u}=Te(),m=()=>{if(n)n();else{const d=new URL(window.location.href);d.searchParams.delete("session"),window.location.href=d.toString()}u(!1)};return e.jsxs(nn,{className:b("group-data-[side=left]:border-r-0",c),children:[e.jsx(on,{className:"h-16 py-5 px-4 justify-center gap-0",children:e.jsxs("div",{className:"flex flex-row items-center justify-between w-full pl-2",children:[e.jsx("span",{className:"font-semibold text-xl tracking-tight",children:"Sessions"}),e.jsx(ke,{onClick:m,"aria-label":"New Chat",variant:"default",children:e.jsx(ka,{className:"size-4"})})]})}),e.jsx(ln,{className:"gap-6",children:e.jsx(Hr,{client:t,currentSessionId:s,onSessionSelect:a,onRenameSession:o,onArchiveSession:l,onDeleteSession:r})}),e.jsx(rn,{className:"p-0",children:e.jsxs("div",{className:"border-t border-border pl-6 pr-4 py-5 flex justify-end gap-2",children:[e.jsx(qr,{}),e.jsx(ke,{"aria-label":"Settings",children:e.jsx(Et,{className:"size-4 text-muted-foreground"})})]})})]})}const Yr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Yr.displayName="Card";const Gr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("flex flex-col space-y-1.5 p-6",t),...s}));Gr.displayName="CardHeader";const Qr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("text-2xl font-semibold leading-none tracking-tight",t),...s}));Qr.displayName="CardTitle";const Xr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("text-sm text-muted-foreground",t),...s}));Xr.displayName="CardDescription";const Jr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("p-6 pt-0",t),...s}));Jr.displayName="CardContent";const Zr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("flex items-center p-6 pt-0",t),...s}));Zr.displayName="CardFooter";const gn=i.forwardRef(({title:t,titleElement:s,description:a,guideUrl:n,guideText:o="Guide",suggestedPrompts:l=[],onPromptClick:r,onGuideClick:c,onOpenFiles:u,onOpenSettings:m,toolsAndMcpsCount:d,onPromptHover:p,onPromptLeave:g,className:h,...x},f)=>{const N=k=>{r?.(k)},C=()=>{n&&window.open(n,"_blank","noopener,noreferrer"),c?.()},v=[];for(let k=0;k<l.length;k+=2)v.push(l.slice(k,k+2));return e.jsxs("div",{ref:f,className:b("flex flex-col items-start",h),...x,children:[s?e.jsx("div",{className:"text-heading-4 text-text-primary mb-6",children:s}):e.jsx("h3",{className:"text-heading-4 text-text-primary mb-6",children:t}),e.jsx("p",{className:"text-subheading text-text-secondary max-w-prose mb-6",children:a}),(u||m)&&e.jsxs("div",{className:"flex items-center gap-1 -ml-3 mb-6",children:[u&&e.jsxs("button",{type:"button",onClick:u,className:"inline-flex items-center gap-1 py-1.5 pr-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsx("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:"View Files"}),e.jsx(We,{className:"size-4 text-foreground shrink-0"})]}),m&&e.jsxs("button",{type:"button",onClick:m,className:"inline-flex items-center gap-1 py-1.5 pr-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsxs("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:["View Tools & MCPs",d!==void 0&&d>0&&e.jsxs("span",{className:"ml-1",children:["(",d,")"]})]}),e.jsx(We,{className:"size-4 text-foreground shrink-0"})]})]}),(n||c)&&e.jsxs("button",{type:"button",onClick:C,className:"inline-flex items-center gap-1 py-1.5 pr-3 -ml-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsx("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:o}),e.jsx(We,{className:"size-4 text-foreground shrink-0"})]}),l.length>0&&e.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-prompt-container",children:[e.jsx("p",{className:"text-text-tertiary",children:"Suggested Prompts"}),e.jsx("div",{className:"flex flex-col gap-2.5",children:v.map(k=>e.jsx("div",{className:"flex gap-2.5 items-center",children:k.map(P=>e.jsx("button",{type:"button",onClick:()=>N(P),onMouseEnter:()=>p?.(P),onMouseLeave:()=>g?.(),className:"flex-1 flex items-start gap-2 p-3 bg-secondary hover:bg-secondary/80 rounded-2xl transition-colors min-w-0",children:e.jsx("span",{className:"text-paragraph font-normal leading-normal text-text-tertiary truncate",children:P})},P))},k.join("-")))})]})]})});gn.displayName="ChatEmptyState";const hn=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex items-center justify-between",t),...a,children:s}));hn.displayName="ChatHeader.Root";const ei=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("h1",{ref:n,className:b("m-0 text-subheading font-semibold",t),...a,children:s}));ei.displayName="ChatHeader.Title";const ti=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex items-center gap-3",t),...a,children:s}));ti.displayName="ChatHeader.Actions";const xn=i.forwardRef(({commands:t=[],showCommandMenu:s,commandMenuQuery:a,selectedMenuIndex:n,setSelectedMenuIndex:o,setMenuItemCount:l,triggerCounter:r,onChange:c,onClose:u,className:m,...d},p)=>{const g=i.useCallback((f,N)=>{const C=f.toLowerCase(),v=N.toLowerCase();if(!N)return 1;if(C.includes(v))return 1-v.length/C.length;let k=0;for(let P=0;P<C.length&&k<v.length;P++)C[P]===v[k]&&k++;return k===v.length?.5-k/C.length:0},[]),h=i.useMemo(()=>t.map(f=>({...f,score:Math.max(g(f.label,a),f.description?g(f.description,a):0)})).filter(f=>f.score>0).sort((f,N)=>N.score-f.score),[t,a,g]);i.useEffect(()=>{l(h.length)},[h.length,l]),i.useEffect(()=>{o(0)},[o]);const x=i.useRef(0);return i.useEffect(()=>{r>0&&r!==x.current&&h[n]&&(x.current=r,h[n].onSelect(),c(""),u?.())},[r,h,n,c,u]),!s||h.length===0?null:e.jsxs("div",{ref:p,className:b("absolute bottom-full left-0 z-50 mb-2 w-full max-w-md","rounded-md border border-border bg-card p-2 shadow-lg",m),...d,children:[e.jsx("div",{className:"text-caption font-semibold text-muted-foreground px-2 py-1",children:"Commands"}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:h.map((f,N)=>e.jsxs("button",{type:"button",onClick:()=>{f.onSelect(),c(""),u?.()},className:b("w-full rounded-sm px-2 py-2 text-left text-paragraph-sm transition-colors","flex items-start gap-2","hover:bg-muted",N===n&&"bg-muted"),children:[f.icon&&e.jsx("span",{className:"shrink-0 mt-0.5",children:f.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:f.label}),f.description&&e.jsx("div",{className:"text-caption text-muted-foreground truncate",children:f.description})]})]},f.id))})]})});xn.displayName="ChatInputCommandMenu";const bn=i.createContext(void 0),et=()=>{const t=i.useContext(bn);if(!t)throw new Error("ChatInput components must be used within ChatInput.Root");return t},yn=i.forwardRef(({client:t,startSession:s,value:a,onChange:n,onSubmit:o,onCancel:l,disabled:r=!1,isSubmitting:c,submitOnEnter:u=!0,className:m,children:d,...p},g)=>{const h=i.useRef(null),x=i.useCallback(async()=>Promise.resolve(null),[]),f=Oo(t??null,s??x),N=L(U=>U.isStreaming),{addToHistory:C,navigatePrevious:v,navigateNext:k,resetNavigation:P}=Ho(),M=t&&s,A=M?f.value:a||"",S=M?f.onChange:n||(()=>{}),I=M?f.onSubmit:o||(async()=>{}),$=M?f.isSubmitting||N:c||!1,B=i.useCallback(async()=>{const U=A.trim();U&&C(U),await I()},[A,C,I]),[W,K]=i.useState(!1),[D,z]=i.useState(""),[T,E]=i.useState(0),[j,y]=i.useState(0),[R,_]=i.useState(0),q=i.useCallback(()=>{_(U=>U+1)},[]),X=async U=>{U.preventDefault(),A.trim()&&!$&&!r&&(await B(),setTimeout(()=>{h.current?.focus()},0))},V=U=>{const G=U.target;!(G.tagName==="BUTTON"||G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.closest("button"))&&h.current&&h.current.focus()},Y=U=>{const G=U.target;!(G.tagName==="BUTTON"||G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.closest("button"))&&U.key===" "&&(U.preventDefault(),h.current&&h.current.focus())};return i.useEffect(()=>{const U=document.querySelector('textarea[name="chat-input"]');U&&h.current!==U&&(h.current=U)},[]),i.useEffect(()=>{!A&&h.current&&(h.current.style.height="auto",h.current.style.overflowY="hidden")},[A]),e.jsx(bn.Provider,{value:{value:A,onChange:S,onSubmit:B,onCancel:l,disabled:r,isSubmitting:$,submitOnEnter:u,showCommandMenu:W,setShowCommandMenu:K,commandMenuQuery:D,setCommandMenuQuery:z,selectedMenuIndex:T,setSelectedMenuIndex:E,menuItemCount:j,setMenuItemCount:y,triggerMenuSelect:q,triggerCounter:R,navigateHistoryPrevious:v,navigateHistoryNext:k,resetHistoryNavigation:P},children:e.jsx("form",{ref:g,onSubmit:X,onClick:V,onKeyDown:Y,className:b("relative w-full divide-y rounded-xl border bg-background shadow-md",m),...p,children:d})})});yn.displayName="ChatInput.Root";const vn=i.forwardRef(({asChild:t=!1,className:s,onKeyDown:a,onFilesDropped:n,children:o,...l},r)=>{const{value:c,onChange:u,onSubmit:m,disabled:d,isSubmitting:p,submitOnEnter:g,showCommandMenu:h,setShowCommandMenu:x,setCommandMenuQuery:f,setSelectedMenuIndex:N,menuItemCount:C,triggerMenuSelect:v,navigateHistoryPrevious:k,navigateHistoryNext:P,resetHistoryNavigation:M}=et(),A=i.useRef(null),[S,I]=i.useState(!1),$=i.useCallback(j=>{A.current=j,typeof r=="function"?r(j):r&&(r.current=j)},[r]),B=j=>new Promise((y,R)=>{const _=new FileReader;_.readAsDataURL(j),_.onload=()=>{const q=_.result.split(",")[1];y(q||"")},_.onerror=q=>R(q)}),E={ref:$,name:"chat-input",value:c,onChange:j=>{const y=j.target.value;if(u(y),M(),y.startsWith("/")&&!y.includes(`
|
|
7
|
+
`);W=z.pop()||"";let T={event:"message",data:""};for(const E of z)E.startsWith("event:")?T.event=E.substring(6).trim():E.startsWith("data:")?T.data=E.substring(5).trim():E===""&&(T.event==="message"&&T.data&&h(T.data),T={event:"message",data:""})}}catch(I){if(I instanceof Error&&I.name==="AbortError")le.debug("Sub-agent SSE stream aborted");else{const $=I instanceof Error?I.message:"Failed to connect to sub-agent";le.error("Sub-agent SSE error",{error:$}),u($)}}finally{d.current&&(d.current.isStreaming=!1,a(I=>I.map($=>$.id===d.current?.id?{...$,isStreaming:!1}:$))),r(!0),o(!1),m.current=null,le.debug("Sub-agent stream completed")}},[h]),f=t?.port,N=t?.sessionId,C=t?.host??(typeof window<"u"?window.location.hostname:"localhost");return i.useEffect(()=>{if(!(!f||!N))return a([]),u(null),r(!1),o(!0),x(f,N,C),()=>{m.current&&(m.current.abort(),m.current=null),p.current&&(clearTimeout(p.current),p.current=null)}},[f,N,C,x]),{messages:s,isStreaming:!l,error:c}}function Vo(t){const s=L(r=>r.toolCalls),a=L(r=>r.addToolCall),n=L(r=>r.updateToolCall),o=L(r=>r.addToolCallToCurrentMessage),l=L(r=>r.updateToolCallInCurrentMessage);return i.useEffect(()=>{if(!t)return;const r=t.onSessionUpdate(c=>{c.type==="tool_call"?(a(c.sessionId,c.toolCall),o(c.toolCall)):c.type==="tool_call_update"&&(n(c.sessionId,c.toolCallUpdate),l(c.toolCallUpdate))});return()=>{r()}},[t,a,n,o,l]),{toolCalls:s,getToolCallsForSession:r=>{const c=s[r];return c&&c.length>0?c:Object.values(s).flat()}}}const qo=F({name:w(),description:w().optional(),parameters:te(w(),ie()).optional()}),Ko=F({name:w(),description:w(),parameters:te(w(),ie()),required:Z(w()).optional()}),Yo=F({name:w(),version:w().optional(),description:w().optional(),author:w().optional(),capabilities:Z(qo).optional(),tools:Z(Ko).optional(),supportedFormats:Z(w()).optional()}),Go=ae(["initializing","ready","busy","error","terminated"]);F({status:Go,info:Yo.optional(),pid:H().optional(),error:w().optional(),uptime:H().optional()});const Ys=ae(["idle","connecting","connected","active","streaming","error","disconnected"]),Qo=F({agentPath:w(),agentArgs:Z(w()).optional(),environment:te(w(),w()).optional(),workingDirectory:w().optional(),timeout:H().optional()}),Xo=F({agentName:w().optional(),agentVersion:w().optional(),capabilities:Z(w()).optional(),startedAt:ot(),lastActivityAt:ot().optional()});F({id:w(),status:Ys,config:Qo,metadata:Xo.optional(),messages:Z(Bs),error:w().optional()});const yt=F({sessionId:w(),status:Ys.optional(),message:Bs.optional(),error:w().optional(),_meta:te(w(),ie()).optional()}),Jo=yt.extend({type:J("tool_call"),toolCall:qs,messageId:w().optional()}),Zo=yt.extend({type:J("tool_call_update"),toolCallUpdate:Io,messageId:w().optional()}),er=yt.extend({type:J("tool_output"),toolOutput:F({id:w(),content:Z(Mt()).optional(),rawOutput:te(w(),ie()).optional()}),messageId:w().optional()}),tr=yt.extend({type:J("generic").optional()});oa([Jo,Zo,er,tr]);const sr=[{id:"folder-1",name:"Item 1",type:"folder",children:[{id:"file-1-1",name:"Item 2",type:"file",extension:"tsx"},{id:"file-1-2",name:"Item 3",type:"file",extension:"ts"},{id:"file-1-3",name:"Item 4",type:"file",extension:"json"},{id:"file-1-4",name:"Item 5",type:"file",extension:"md"}]},{id:"folder-2",name:"Description 1",type:"folder",children:[{id:"file-2-1",name:"Description 2",type:"file",extension:"tsx"},{id:"file-2-2",name:"Description 3",type:"file",extension:"ts"},{id:"file-2-3",name:"Description 4",type:"file",extension:"json"},{id:"file-2-4",name:"Description 5",type:"file",extension:"md"}]},{id:"folder-3",name:"financial-docs",type:"folder",children:[]}];class nr{data;constructor(s=sr){this.data=s}async getRootItems(){return Promise.resolve(this.data)}async getItemChildren(s){const a=o=>{for(const l of o){if(l.id===s)return l;if(l.children){const r=a(l.children);if(r)return r}}},n=a(this.data);return Promise.resolve(n?.children||[])}async getItemDetails(s){const a=o=>{for(const l of o){if(l.id===s)return l;if(l.children){const r=a(l.children);if(r)return r}}},n=a(this.data);if(!n)throw new Error(`Item with id ${s} not found`);return Promise.resolve(n)}}function b(...t){return ra(ia(t))}const ar=je("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-paragraph-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive-hover",outline:"border border-input bg-background hover:bg-accent-hover hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover",ghost:"hover:bg-accent-hover hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ne=i.forwardRef(({className:t,variant:s,size:a,asChild:n=!1,...o},l)=>{const r=n?ue:"button";return e.jsx(r,{className:b(ar({variant:s,size:a,className:t})),ref:l,...o})});ne.displayName="Button";const fe=ma,ge=pa,he=fa,de=i.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(ds,{ref:n,sideOffset:s,className:b("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a}));de.displayName=ds.displayName;const Gs=({className:t,children:s,...a})=>e.jsx("div",{className:b("flex items-center gap-1",t),...a,children:s}),it=({tooltip:t,children:s,label:a,className:n,variant:o="ghost",size:l="sm",...r})=>{const c=e.jsxs(ne,{className:b("relative size-7 p-1.5 text-muted-foreground hover:text-foreground",n),size:l,type:"button",variant:o,...r,children:[s,e.jsx("span",{className:"sr-only",children:a||t})]});return t?e.jsx(fe,{children:e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:c}),e.jsx(de,{children:e.jsx("p",{children:t})})]})}):c},ke=i.forwardRef(({className:t,...s},a)=>e.jsx(ne,{ref:a,variant:"ghost",size:"icon",className:b("rounded-full",t),...s}));ke.displayName="IconButton";const Xe=ha,Je=xa,or=i.forwardRef(({className:t,inset:s,children:a,...n},o)=>e.jsxs(us,{ref:o,className:b("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-paragraph-sm outline-none","focus:bg-muted data-[state=open]:bg-muted",s&&"pl-8",t),...n,children:[a,e.jsx(We,{className:"ml-auto h-4 w-4"})]}));or.displayName=us.displayName;const rr=i.forwardRef(({className:t,...s},a)=>e.jsx(ms,{ref:a,className:b("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",t),...s}));rr.displayName=ms.displayName;const Le=i.forwardRef(({className:t,sideOffset:s=4,...a},n)=>e.jsx(ga,{children:e.jsx(ps,{ref:n,sideOffset:s,className:b("z-50 min-w-[8rem] overflow-hidden rounded-lg border border-border bg-popover p-0.5 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",t),...a})}));Le.displayName=ps.displayName;const pe=i.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(fs,{ref:n,className:b("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s&&"pl-8",t),...a}));pe.displayName=fs.displayName;const ir=i.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(gs,{ref:n,className:b("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(hs,{children:e.jsx(pt,{className:"h-4 w-4"})})}),s]}));ir.displayName=gs.displayName;const lr=i.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(xs,{ref:n,className:b("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(hs,{children:e.jsx(ft,{className:"h-2 w-2 fill-current"})})}),s]}));lr.displayName=xs.displayName;const cr=i.forwardRef(({className:t,inset:s,...a},n)=>e.jsx(bs,{ref:n,className:b("px-2 py-1.5 text-paragraph-sm font-semibold",s&&"pl-8",t),...a}));cr.displayName=bs.displayName;const Qs=i.forwardRef(({className:t,...s},a)=>e.jsx(ys,{ref:a,className:b("-mx-1 my-1 h-px bg-border",t),...s}));Qs.displayName=ys.displayName;const dr=256,ur="calc(100vw - 104px)",Xs=450,ss=250,ns=800,mr=720,pr=56,fr=pr*2;function Js(t){i.useEffect(()=>{if(!t)return;const s=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${s}px`,document.body.style.width="100%",document.body.style.overflow="hidden",()=>{document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,s)}},[t])}const Ct=768;function Zs(){const[t,s]=i.useState(void 0);return i.useEffect(()=>{const a=window.matchMedia(`(max-width: ${Ct-1}px)`),n=()=>{s(window.innerWidth<Ct)};return a.addEventListener("change",n),s(window.innerWidth<Ct),()=>a.removeEventListener("change",n)},[]),!!t}const Ze={smooth:[.25,.1,.25,1]},gr={duration:.25,ease:Ze.smooth},as={duration:.15,ease:Ze.smooth},hr={initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"}},xr={initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"}},os={initial:{opacity:0,x:-20},animate:{opacity:1,x:0}},rs={duration:.25,ease:Ze.smooth,delay:.1},br={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},yr={initial:{x:"100%"},animate:{x:0},exit:{x:"100%"}},vr={initial:{opacity:0,x:20},animate:{opacity:1,x:0}},wr={duration:.25,ease:Ze.smooth,delay:.1},jr={duration:.15,ease:Ze.smooth},Nr=je("flex h-10 w-full rounded-md border bg-input-background px-3 py-2 text-paragraph-sm ring-offset-background file:border-0 file:bg-transparent file:text-paragraph-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),en=i.forwardRef(({className:t,type:s,variant:a,...n},o)=>e.jsx("input",{type:s,className:b(Nr({variant:a,className:t})),ref:o,...n}));en.displayName="Input";const Sr="sidebar_state",Cr=3600*24*7,kr="s",tn=i.createContext(null);function Te(){const t=i.useContext(tn);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const sn=i.forwardRef(({defaultOpen:t=!0,open:s,onOpenChange:a,className:n,style:o,children:l,...r},c)=>{const u=Zs(),[m,d]=i.useState(!1),[p,g]=i.useState(t),h=s??p,x=i.useCallback(v=>{const k=typeof v=="function"?v(h):v;a?a(k):g(k),document.cookie=`${Sr}=${k}; path=/; max-age=${Cr}`},[a,h]),f=i.useCallback(()=>u?d(v=>!v):x(v=>!v),[u,x]);i.useEffect(()=>{const v=k=>{k.key.toLowerCase()===kr&&k.shiftKey&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),f())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[f]);const N=h?"expanded":"collapsed",C=i.useMemo(()=>({state:N,open:h,setOpen:x,isMobile:u,openMobile:m,setOpenMobile:d,toggleSidebar:f}),[N,h,x,u,m,f]);return e.jsx(tn.Provider,{value:C,children:e.jsx(fe,{delayDuration:0,children:e.jsx("div",{className:b("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",n),ref:c,style:o,...r,children:l})})})});sn.displayName="SidebarProvider";const nn=i.forwardRef(({className:t,children:s},a)=>{const{isMobile:n,open:o,openMobile:l,setOpenMobile:r}=Te();return Js(n&&l),n?e.jsx(Ye,{initial:!1,children:l&&e.jsxs(e.Fragment,{children:[e.jsx(ve.div,{className:"fixed inset-0 z-40 bg-background/80",variants:br,initial:"initial",animate:"animate",exit:"exit",transition:as,onClick:()=>r(!1),"aria-label":"Close sidebar"}),e.jsx(ve.aside,{ref:a,className:b("fixed inset-y-0 left-0 z-50","bg-sidebar text-sidebar-foreground","flex flex-col","border-r border-sidebar-border","max-h-screen overflow-hidden",t),style:{width:ur},variants:xr,initial:"initial",animate:"animate",exit:"exit",transition:as,"data-sidebar":"sidebar","data-mobile":"true",children:e.jsx(ve.div,{className:"flex flex-col h-full overflow-y-auto",variants:os,initial:"initial",animate:"animate",transition:rs,children:s})})]})}):e.jsx("div",{className:"group peer hidden md:block","data-state":o?"expanded":"collapsed","data-side":"left",ref:a,children:e.jsx(Ye,{initial:!1,mode:"wait",children:o&&e.jsx(ve.aside,{className:b("fixed inset-y-0 left-0 z-40","bg-sidebar text-sidebar-foreground","border-r border-sidebar-border","flex flex-col","max-h-screen overflow-hidden",t),style:{width:dr},variants:hr,initial:"initial",animate:"animate",exit:"exit",transition:gr,"data-sidebar":"sidebar",children:e.jsx(ve.div,{className:"flex flex-col h-full overflow-y-auto",variants:os,initial:"initial",animate:"animate",transition:rs,children:s})})})})});nn.displayName="Sidebar";const Tr=i.forwardRef(({className:t,onClick:s,...a},n)=>{const{toggleSidebar:o}=Te();return e.jsxs(ne,{className:b("h-7 w-7",t),"data-sidebar":"trigger",onClick:l=>{s?.(l),o()},ref:n,size:"icon",variant:"ghost",...a,children:[e.jsx(Sa,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Tr.displayName="SidebarTrigger";const Ir=i.forwardRef(({className:t,...s},a)=>{const{toggleSidebar:n}=Te();return e.jsx("button",{type:"button","aria-label":"Toggle Sidebar",className:b("-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),"data-sidebar":"rail",onClick:n,ref:a,tabIndex:-1,title:"Toggle Sidebar",...s})});Ir.displayName="SidebarRail";const an=i.forwardRef(({className:t,children:s,...a},n)=>{const{isMobile:o,open:l}=Te();return e.jsx("main",{className:b("relative flex w-full flex-1 flex-col bg-background transition-all duration-250",!o&&l&&"md:pl-64",t),ref:n,...a,children:s})});an.displayName="SidebarInset";const Rr=i.forwardRef(({className:t,...s},a)=>e.jsx(en,{className:b("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),"data-sidebar":"input",ref:a,...s}));Rr.displayName="SidebarInput";const on=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("flex flex-col gap-2 p-2",t),"data-sidebar":"header",ref:a,...s}));on.displayName="SidebarHeader";const rn=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("flex flex-col gap-2 p-2",t),"data-sidebar":"footer",ref:a,...s}));rn.displayName="SidebarFooter";const _r=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("mx-2 h-px w-auto bg-sidebar-border",t),"data-sidebar":"separator",ref:a,...s}));_r.displayName="SidebarSeparator";const ln=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),"data-sidebar":"content",ref:a,...s}));ln.displayName="SidebarContent";const Be=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("relative flex w-full min-w-0 flex-col p-4",t),"data-sidebar":"group",ref:a,...s}));Be.displayName="SidebarGroup";const cn=i.forwardRef(({className:t,asChild:s=!1,...a},n)=>{const o=s?ue:"div";return e.jsx(o,{className:b("flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),"data-sidebar":"group-label",ref:n,...a})});cn.displayName="SidebarGroupLabel";const Mr=i.forwardRef(({className:t,asChild:s=!1,...a},n)=>{const o=s?ue:"button";return e.jsx(o,{className:b("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:-inset-2 after:absolute after:md:hidden","group-data-[collapsible=icon]:hidden",t),"data-sidebar":"group-action",ref:n,type:"button",...a})});Mr.displayName="SidebarGroupAction";const He=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("w-full text-sm",t),"data-sidebar":"group-content",ref:a,...s}));He.displayName="SidebarGroupContent";const dn=i.forwardRef(({className:t,...s},a)=>e.jsx("ul",{className:b("flex w-full min-w-0 flex-col gap-1",t),"data-sidebar":"menu",ref:a,...s}));dn.displayName="SidebarMenu";const un=i.forwardRef(({className:t,...s},a)=>e.jsx("li",{className:b("group/menu-item relative",t),"data-sidebar":"menu-item",ref:a,...s}));un.displayName="SidebarMenuItem";const Er=je("peer/menu-button group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"group-data-[collapsible=icon]:!p-0 h-12 text-sm"}},defaultVariants:{variant:"default",size:"default"}}),mn=i.forwardRef(({asChild:t=!1,isActive:s=!1,variant:a="default",size:n="default",tooltip:o,className:l,...r},c)=>{const u=t?ue:"button",{isMobile:m,state:d}=Te(),p=e.jsx(u,{className:b(Er({variant:a,size:n}),l),"data-active":s,"data-sidebar":"menu-button","data-size":n,ref:c,type:t?void 0:"button",...r});return o?(typeof o=="string"&&(o={children:o}),e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:p}),e.jsx(de,{align:"center",hidden:d!=="collapsed"||m,side:"right",...o})]})):p});mn.displayName="SidebarMenuButton";const pn=i.forwardRef(({className:t,asChild:s=!1,showOnHover:a=!1,...n},o)=>{const l=s?ue:"button";return e.jsx(l,{className:b("absolute top-3 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:-inset-2 after:absolute after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-2.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",a&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),"data-sidebar":"menu-action",ref:o,type:s?void 0:"button",...n})});pn.displayName="SidebarMenuAction";const Ar=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{className:b("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 font-medium text-sidebar-foreground text-xs tabular-nums","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),"data-sidebar":"menu-badge",ref:a,...s}));Ar.displayName="SidebarMenuBadge";const Pr=i.forwardRef(({className:t,showIcon:s=!1,...a},n)=>{const o=i.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return e.jsxs("div",{className:b("flex h-8 items-center gap-2 rounded-md px-2",t),"data-sidebar":"menu-skeleton",ref:n,...a,children:[s&&e.jsx("div",{className:"size-4 rounded-md bg-sidebar-accent-foreground/10 animate-pulse","data-sidebar":"menu-skeleton-icon"}),e.jsx("div",{className:"h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse","data-sidebar":"menu-skeleton-text",style:{maxWidth:o}})]})});Pr.displayName="SidebarMenuSkeleton";const Dr=i.forwardRef(({className:t,...s},a)=>e.jsx("ul",{className:b("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),"data-sidebar":"menu-sub",ref:a,...s}));Dr.displayName="SidebarMenuSub";const Ur=i.forwardRef(({...t},s)=>e.jsx("li",{ref:s,...t}));Ur.displayName="SidebarMenuSubItem";const zr=i.forwardRef(({asChild:t=!1,size:s="md",isActive:a,className:n,...o},l)=>{const r=t?ue:"a";return e.jsx(r,{className:b("-translate-x-px flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",s==="sm"&&"text-xs",s==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",n),"data-active":a,"data-sidebar":"menu-sub-button","data-size":s,ref:l,...o})});zr.displayName="SidebarMenuSubButton";const $r=({session:t,isActive:s,onSelect:a,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r})=>e.jsxs(un,{children:[e.jsx(mn,{asChild:!0,isActive:s,onClick:()=>{a(t.sessionId),r(!1)},className:"h-10 px-2 py-3",children:e.jsx("button",{type:"button",className:"w-full text-base",children:e.jsx("span",{className:"truncate",children:t.firstUserMessage||"Empty session"})})}),e.jsxs(Xe,{modal:!0,children:[e.jsx(Je,{asChild:!0,children:e.jsxs(pn,{className:"mr-0.5 data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",showOnHover:!s,children:[e.jsx(Ca,{}),e.jsx("span",{className:"sr-only",children:"More"})]})}),e.jsxs(Le,{align:"end",side:"bottom",children:[e.jsx(pe,{className:"cursor-pointer",disabled:!n,onSelect:()=>n?.(t.sessionId),children:"Rename"}),e.jsx(pe,{className:"cursor-pointer",disabled:!o,onSelect:()=>o?.(t.sessionId),children:"Archive"}),e.jsx(Qs,{}),e.jsx(pe,{className:b("cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive"),disabled:!l,onSelect:()=>l?.(t.sessionId),children:"Delete"})]})]})]}),Fe=i.memo($r,(t,s)=>!(t.isActive!==s.isActive||t.session.sessionId!==s.session.sessionId||t.session.firstUserMessage!==s.session.firstUserMessage)),Lr=xe("session-history"),Or=t=>{const s=new Date;return t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear()},Fr=t=>{const s=new Date;return s.setDate(s.getDate()-1),t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear()},Br=t=>{const s=new Date,a=new Date(s.getTime()-10080*60*1e3),n=new Date(s.getTime()-720*60*60*1e3);return t.reduce((o,l)=>{const r=new Date(l.updatedAt);return Or(r)?o.today.push(l):Fr(r)?o.yesterday.push(l):r>a?o.lastWeek.push(l):r>n?o.lastMonth.push(l):o.older.push(l),o},{today:[],yesterday:[],lastWeek:[],lastMonth:[],older:[]})};function Hr({client:t,currentSessionId:s,onSessionSelect:a,onRenameSession:n,onArchiveSession:o,onDeleteSession:l}){const{setOpenMobile:r}=Te(),[c,u]=i.useState([]),[m,d]=i.useState(!1),p=i.useCallback(async()=>{if(t){d(!0);try{const x=await t.listSessions();u(x)}catch(x){Lr.error("Failed to fetch sessions",{error:x})}finally{d(!1)}}},[t]);i.useEffect(()=>{p()},[p]);const g=x=>{if(x!==s)if(a)a(x);else{const f=new URL(window.location.href);f.searchParams.set("session",x),window.location.href=f.toString()}};if(!t)return e.jsx(Be,{children:e.jsx(He,{children:e.jsx("div",{className:"flex w-full flex-row items-center justify-center gap-2 px-2 text-sm text-muted-foreground",children:"Connect to an agent to see session history"})})});if(m)return e.jsxs(Be,{children:[e.jsx(cn,{children:"Today"}),e.jsx(He,{children:e.jsx("div",{className:"flex flex-col",children:[44,32,28,64,52].map(x=>e.jsx("div",{className:"flex h-8 items-center gap-2 rounded-md px-2",children:e.jsx("div",{className:"h-4 flex-1 rounded-md bg-sidebar-accent-foreground/10 animate-pulse",style:{maxWidth:`${x}%`}})},x))})})]});if(c.length===0)return e.jsx(Be,{children:e.jsx(He,{children:e.jsx("div",{className:"flex w-full flex-row items-center justify-center gap-2 px-2 py-4 text-sm text-muted-foreground",children:"Your sessions will appear here once you start chatting!"})})});const h=Br(c);return e.jsx(Be,{children:e.jsx(He,{children:e.jsx(dn,{children:e.jsxs("div",{className:"flex flex-col gap-6",children:[h.today.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Today"}),h.today.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.yesterday.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Yesterday"}),h.yesterday.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.lastWeek.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Last 7 days"}),h.lastWeek.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.lastMonth.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Last 30 days"}),h.lastMonth.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]}),h.older.length>0&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"px-2 py-1 text-muted-foreground text-sm font-medium",children:"Older"}),h.older.map(x=>e.jsx(Fe,{session:x,isActive:x.sessionId===s,onSelect:g,onRename:n,onArchive:o,onDelete:l,setOpenMobile:r},x.sessionId))]})]})})})})}const Wr={theme:"system",setTheme:()=>null,resolvedTheme:"light"},fn=i.createContext(Wr);function Vr({children:t,defaultTheme:s="system",storageKey:a="vite-ui-theme"}){const[n,o]=i.useState(()=>localStorage.getItem(a)||s),[l,r]=i.useState("light");i.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),n==="system"){const m=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(m),r(m);return}u.classList.add(n),r(n)},[n]);const c={theme:n,setTheme:u=>{localStorage.setItem(a,u),o(u)},resolvedTheme:l};return e.jsx(fn.Provider,{value:c,children:t})}const $t=()=>{const t=i.useContext(fn);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function qr(){const{setTheme:t}=$t();return e.jsxs(Xe,{children:[e.jsx(Je,{asChild:!0,children:e.jsxs(ke,{children:[e.jsx(As,{className:"size-4 text-muted-foreground rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(Ps,{className:"absolute size-4 text-muted-foreground rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(Le,{align:"end",children:[e.jsx(pe,{onClick:()=>t("light"),children:"Light"}),e.jsx(pe,{onClick:()=>t("dark"),children:"Dark"}),e.jsx(pe,{onClick:()=>t("system"),children:"System"})]})]})}function Kr({client:t,currentSessionId:s,onSessionSelect:a,onNewSession:n,onRenameSession:o,onArchiveSession:l,onDeleteSession:r,className:c}){const{setOpenMobile:u}=Te(),m=()=>{if(n)n();else{const d=new URL(window.location.href);d.searchParams.delete("session"),window.location.href=d.toString()}u(!1)};return e.jsxs(nn,{className:b("group-data-[side=left]:border-r-0",c),children:[e.jsx(on,{className:"h-16 py-5 px-4 justify-center gap-0",children:e.jsxs("div",{className:"flex flex-row items-center justify-between w-full pl-2",children:[e.jsx("span",{className:"font-semibold text-xl tracking-tight",children:"Sessions"}),e.jsx(ke,{onClick:m,"aria-label":"New Chat",variant:"default",children:e.jsx(ka,{className:"size-4"})})]})}),e.jsx(ln,{className:"gap-6",children:e.jsx(Hr,{client:t,currentSessionId:s,onSessionSelect:a,onRenameSession:o,onArchiveSession:l,onDeleteSession:r})}),e.jsx(rn,{className:"p-0",children:e.jsxs("div",{className:"border-t border-border pl-6 pr-4 py-5 flex justify-end gap-2",children:[e.jsx(qr,{}),e.jsx(ke,{"aria-label":"Settings",children:e.jsx(Et,{className:"size-4 text-muted-foreground"})})]})})]})}const Yr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Yr.displayName="Card";const Gr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("flex flex-col space-y-1.5 p-6",t),...s}));Gr.displayName="CardHeader";const Qr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("text-2xl font-semibold leading-none tracking-tight",t),...s}));Qr.displayName="CardTitle";const Xr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("text-sm text-muted-foreground",t),...s}));Xr.displayName="CardDescription";const Jr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("p-6 pt-0",t),...s}));Jr.displayName="CardContent";const Zr=i.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:b("flex items-center p-6 pt-0",t),...s}));Zr.displayName="CardFooter";const gn=i.forwardRef(({title:t,titleElement:s,description:a,guideUrl:n,guideText:o="Guide",suggestedPrompts:l=[],onPromptClick:r,onGuideClick:c,onOpenFiles:u,onOpenSettings:m,toolsAndMcpsCount:d,onPromptHover:p,onPromptLeave:g,className:h,...x},f)=>{const N=k=>{r?.(k)},C=()=>{n&&window.open(n,"_blank","noopener,noreferrer"),c?.()},v=[];for(let k=0;k<l.length;k+=2)v.push(l.slice(k,k+2));return e.jsxs("div",{ref:f,className:b("flex flex-col items-start",h),...x,children:[s?e.jsx("div",{className:"text-heading-4 text-text-primary mb-6",children:s}):e.jsx("h3",{className:"text-heading-4 text-text-primary mb-6",children:t}),e.jsx("p",{className:"text-subheading text-text-secondary max-w-prose mb-6",children:a}),(u||m)&&e.jsxs("div",{className:"flex items-center gap-1 -ml-3 mb-6",children:[u&&e.jsxs("button",{type:"button",onClick:u,className:"inline-flex items-center gap-1 py-1.5 pr-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsx("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:"View Files"}),e.jsx(We,{className:"size-4 text-foreground shrink-0"})]}),m&&e.jsxs("button",{type:"button",onClick:m,className:"inline-flex items-center gap-1 py-1.5 pr-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsxs("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:["View Tools & MCPs",d!==void 0&&d>0&&e.jsxs("span",{className:"ml-1",children:["(",d,")"]})]}),e.jsx(We,{className:"size-4 text-foreground shrink-0"})]})]}),(n||c)&&e.jsxs("button",{type:"button",onClick:C,className:"inline-flex items-center gap-1 py-1.5 pr-3 -ml-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsx("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:o}),e.jsx(We,{className:"size-4 text-foreground shrink-0"})]}),l.length>0&&e.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-prompt-container",children:[e.jsx("p",{className:"text-text-tertiary",children:"Suggested Prompts"}),e.jsx("div",{className:"flex flex-col gap-2.5",children:v.map(k=>e.jsx("div",{className:"flex gap-2.5 items-center",children:k.map(P=>e.jsx("button",{type:"button",onClick:()=>N(P),onMouseEnter:()=>p?.(P),onMouseLeave:()=>g?.(),className:"flex-1 flex items-start gap-2 p-3 bg-secondary hover:bg-secondary/80 rounded-2xl transition-colors min-w-0",children:e.jsx("span",{className:"text-paragraph font-normal leading-normal text-text-tertiary truncate",children:P})},P))},k.join("-")))})]})]})});gn.displayName="ChatEmptyState";const hn=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex items-center justify-between",t),...a,children:s}));hn.displayName="ChatHeader.Root";const ei=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("h1",{ref:n,className:b("m-0 text-subheading font-semibold",t),...a,children:s}));ei.displayName="ChatHeader.Title";const ti=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex items-center gap-3",t),...a,children:s}));ti.displayName="ChatHeader.Actions";const xn=i.forwardRef(({commands:t=[],showCommandMenu:s,commandMenuQuery:a,selectedMenuIndex:n,setSelectedMenuIndex:o,setMenuItemCount:l,triggerCounter:r,onChange:c,onClose:u,className:m,...d},p)=>{const g=i.useCallback((f,N)=>{const C=f.toLowerCase(),v=N.toLowerCase();if(!N)return 1;if(C.includes(v))return 1-v.length/C.length;let k=0;for(let P=0;P<C.length&&k<v.length;P++)C[P]===v[k]&&k++;return k===v.length?.5-k/C.length:0},[]),h=i.useMemo(()=>t.map(f=>({...f,score:Math.max(g(f.label,a),f.description?g(f.description,a):0)})).filter(f=>f.score>0).sort((f,N)=>N.score-f.score),[t,a,g]);i.useEffect(()=>{l(h.length)},[h.length,l]),i.useEffect(()=>{o(0)},[o]);const x=i.useRef(0);return i.useEffect(()=>{r>0&&r!==x.current&&h[n]&&(x.current=r,h[n].onSelect(),c(""),u?.())},[r,h,n,c,u]),!s||h.length===0?null:e.jsxs("div",{ref:p,className:b("absolute bottom-full left-0 z-50 mb-2 w-full max-w-md","rounded-md border border-border bg-card p-2 shadow-lg",m),...d,children:[e.jsx("div",{className:"text-caption font-semibold text-muted-foreground px-2 py-1",children:"Commands"}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:h.map((f,N)=>e.jsxs("button",{type:"button",onClick:()=>{f.onSelect(),c(""),u?.()},className:b("w-full rounded-sm px-2 py-2 text-left text-paragraph-sm transition-colors","flex items-start gap-2","hover:bg-muted",N===n&&"bg-muted"),children:[f.icon&&e.jsx("span",{className:"shrink-0 mt-0.5",children:f.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:f.label}),f.description&&e.jsx("div",{className:"text-caption text-muted-foreground truncate",children:f.description})]})]},f.id))})]})});xn.displayName="ChatInputCommandMenu";const bn=i.createContext(void 0),et=()=>{const t=i.useContext(bn);if(!t)throw new Error("ChatInput components must be used within ChatInput.Root");return t},yn=i.forwardRef(({client:t,startSession:s,value:a,onChange:n,onSubmit:o,onCancel:l,disabled:r=!1,isSubmitting:c,submitOnEnter:u=!0,className:m,children:d,...p},g)=>{const h=i.useRef(null),x=i.useCallback(async()=>Promise.resolve(null),[]),f=Oo(t??null,s??x),N=L(U=>U.isStreaming),{addToHistory:C,navigatePrevious:v,navigateNext:k,resetNavigation:P}=Ho(),M=t&&s,A=M?f.value:a||"",S=M?f.onChange:n||(()=>{}),I=M?f.onSubmit:o||(async()=>{}),$=M?f.isSubmitting||N:c||!1,B=i.useCallback(async()=>{const U=A.trim();U&&C(U),await I()},[A,C,I]),[W,K]=i.useState(!1),[D,z]=i.useState(""),[T,E]=i.useState(0),[j,y]=i.useState(0),[R,_]=i.useState(0),q=i.useCallback(()=>{_(U=>U+1)},[]),X=async U=>{U.preventDefault(),A.trim()&&!$&&!r&&(await B(),setTimeout(()=>{h.current?.focus()},0))},V=U=>{const G=U.target;!(G.tagName==="BUTTON"||G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.closest("button"))&&h.current&&h.current.focus()},Y=U=>{const G=U.target;!(G.tagName==="BUTTON"||G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.closest("button"))&&U.key===" "&&(U.preventDefault(),h.current&&h.current.focus())};return i.useEffect(()=>{const U=document.querySelector('textarea[name="chat-input"]');U&&h.current!==U&&(h.current=U)},[]),i.useEffect(()=>{!A&&h.current&&(h.current.style.height="auto",h.current.style.overflowY="hidden")},[A]),e.jsx(bn.Provider,{value:{value:A,onChange:S,onSubmit:B,onCancel:l,disabled:r,isSubmitting:$,submitOnEnter:u,showCommandMenu:W,setShowCommandMenu:K,commandMenuQuery:D,setCommandMenuQuery:z,selectedMenuIndex:T,setSelectedMenuIndex:E,menuItemCount:j,setMenuItemCount:y,triggerMenuSelect:q,triggerCounter:R,navigateHistoryPrevious:v,navigateHistoryNext:k,resetHistoryNavigation:P},children:e.jsx("form",{ref:g,onSubmit:X,onClick:V,onKeyDown:Y,className:b("relative w-full divide-y rounded-xl border bg-background shadow-md",m),...p,children:d})})});yn.displayName="ChatInput.Root";const vn=i.forwardRef(({asChild:t=!1,className:s,onKeyDown:a,onFilesDropped:n,children:o,...l},r)=>{const{value:c,onChange:u,onSubmit:m,disabled:d,isSubmitting:p,submitOnEnter:g,showCommandMenu:h,setShowCommandMenu:x,setCommandMenuQuery:f,setSelectedMenuIndex:N,menuItemCount:C,triggerMenuSelect:v,navigateHistoryPrevious:k,navigateHistoryNext:P,resetHistoryNavigation:M}=et(),A=i.useRef(null),[S,I]=i.useState(!1),$=i.useCallback(j=>{A.current=j,typeof r=="function"?r(j):r&&(r.current=j)},[r]),B=j=>new Promise((y,R)=>{const _=new FileReader;_.readAsDataURL(j),_.onload=()=>{const q=_.result.split(",")[1];y(q||"")},_.onerror=q=>R(q)}),E={ref:$,name:"chat-input",value:c,onChange:j=>{const y=j.target.value;if(u(y),M(),y.startsWith("/")&&!y.includes(`
|
|
8
8
|
`)){x(!0);const q=y.slice(1);f(q)}else x(!1),f("");const R=A.current;if(!R)return;R.style.height="auto";const _=Math.min(R.scrollHeight,164);R.style.height=`${_}px`,R.scrollHeight>164?R.style.overflowY="auto":R.style.overflowY="hidden"},onKeyDown:j=>{if(h&&C>0){if(j.key==="ArrowDown"){j.preventDefault(),N(y=>(y+1)%C);return}else if(j.key==="ArrowUp"){j.preventDefault(),N(y=>(y-1+C)%C);return}else if(j.key==="Enter"&&!j.shiftKey){j.preventDefault(),v();return}else if(j.key==="Escape"){j.preventDefault(),x(!1),f("");return}}if(!h){const y=A.current,R=y?.selectionStart===0&&y?.selectionEnd===0,_=y?.selectionStart===c.length&&y?.selectionEnd===c.length,q=c.includes(`
|
|
9
9
|
`);if(j.key==="ArrowUp"&&(R||!c||!q)){const X=k(c);if(X!==null){j.preventDefault(),u(X),setTimeout(()=>{A.current&&(A.current.selectionStart=X.length,A.current.selectionEnd=X.length)},0);return}}else if(j.key==="ArrowDown"&&(_||!c||!q)){const X=P();if(X!==null){j.preventDefault(),u(X),setTimeout(()=>{A.current&&(A.current.selectionStart=X.length,A.current.selectionEnd=X.length)},0);return}}}g&&j.key==="Enter"&&!j.shiftKey&&(c.trim()&&!p&&!d?(j.preventDefault(),m()):(p||d)&&j.preventDefault()),a?.(j)},onDrop:async j=>{j.preventDefault(),I(!1);const y=j.dataTransfer.files;if(!y||y.length===0||!n)return;const R=[];for(const _ of Array.from(y))if(_.type.startsWith("image/"))try{const q=await B(_);R.push({name:_.name,path:_.name,size:_.size,mimeType:_.type,data:q})}catch(q){console.error("Failed to process dropped file:",_.name,q)}R.length>0&&n(R)},onDragOver:j=>{j.preventDefault(),I(!0)},onDragLeave:j=>{j.preventDefault(),I(!1)},disabled:d,...l};return t&&i.isValidElement(o)?i.cloneElement(o,E):e.jsx("textarea",{...E,rows:1,className:b("w-full resize-none rounded-none border-none p-4 shadow-none","outline-none ring-0 max-h-[6lh] min-h-[44px]","bg-transparent dark:bg-transparent focus-visible:ring-0","text-paragraph-sm placeholder:text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-50",S&&"ring-2 ring-primary ring-offset-2",s)})});vn.displayName="ChatInput.Field";const wn=i.forwardRef(({asChild:t=!1,className:s,disabled:a,children:n,...o},l)=>{const{value:r,disabled:c,isSubmitting:u}=et();if(u)return null;const m=a||c||!r.trim(),d=t?ue:ne;return e.jsx(d,{ref:l,type:"submit",disabled:m,variant:t?void 0:"default",size:"icon",className:b(!t&&"gap-1.5 rounded-full",s),...o,children:n})});wn.displayName="ChatInput.Submit";const jn=i.forwardRef(({asChild:t=!1,className:s,children:a,...n},o)=>{const{onCancel:l,isSubmitting:r}=et(),c=t?ue:ne;return r?e.jsx(c,{ref:o,type:"button",onClick:()=>l?.(),variant:t?void 0:"default",size:"icon",className:b(!t&&"gap-1.5 rounded-full",s),...n,children:a||e.jsx(Ta,{className:"size-4 fill-current"})}):null});jn.displayName="ChatInput.Stop";const Nn=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex items-center justify-between p-2",t),...a,children:s}));Nn.displayName="ChatInput.Toolbar";const Sn=i.forwardRef(({asChild:t=!1,className:s,children:a,onClick:n,...o},l)=>{const{value:r,onChange:c,setShowCommandMenu:u,setCommandMenuQuery:m}=et(),d=g=>{r.startsWith("/")||(c("/"),u(!0),m("")),n?.(g)},p=t?ue:ne;return e.jsx(p,{ref:l,type:"button",variant:"ghost",size:"icon",className:b("rounded-full",s),onClick:d,...o,children:a||e.jsx(Ia,{className:"size-4"})})});Sn.displayName="ChatInput.Actions";const Cn=i.forwardRef(({asChild:t=!1,className:s,children:a,onFilesSelected:n,...o},l)=>{const r=i.useRef(null),c=p=>new Promise((g,h)=>{const x=new FileReader;x.readAsDataURL(p),x.onload=()=>{const f=x.result.split(",")[1];g(f||"")},x.onerror=f=>h(f)}),u=async p=>{const g=p.target.files;if(!g||g.length===0)return;const h=[];for(const x of Array.from(g))if(x.type.startsWith("image/"))try{const f=await c(x);h.push({name:x.name,path:x.name,size:x.size,mimeType:x.type,data:f})}catch(f){console.error("Failed to process file:",x.name,f)}h.length>0&&n&&n(h),r.current&&(r.current.value="")},m=p=>{p.preventDefault(),r.current?.click()},d=t?ue:ne;return e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:r,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:u}),e.jsx(d,{ref:l,type:"button",variant:"ghost",size:"icon",className:b("rounded-full",s),onClick:m,...o,children:a||e.jsx(Ra,{className:"size-4"})})]})});Cn.displayName="ChatInput.Attachment";const kn=i.forwardRef(({asChild:t=!1,className:s,children:a,...n},o)=>{const l=t?ue:ne;return e.jsx(l,{ref:o,type:"button",variant:"ghost",size:"icon",className:b("rounded-full",s),...n,children:a||e.jsx(_a,{className:"size-4"})})});kn.displayName="ChatInput.VoiceInput";const Tn=i.forwardRef(({commands:t=[],className:s,onChange:a,...n},o)=>{const{showCommandMenu:l,commandMenuQuery:r,selectedMenuIndex:c,setSelectedMenuIndex:u,setMenuItemCount:m,triggerCounter:d,onChange:p,setShowCommandMenu:g,setCommandMenuQuery:h}=et();return e.jsx(xn,{ref:o,commands:t,showCommandMenu:l,commandMenuQuery:r,selectedMenuIndex:c,setSelectedMenuIndex:u,setMenuItemCount:m,triggerCounter:d,onChange:p,onClose:()=>{g(!1),h("")},className:s,...n})});Tn.displayName="ChatInput.CommandMenu";function si({parameters:t,className:s}){const a=L(c=>c.input.selectedPromptParameters),n=L(c=>c.setSelectedPromptParameters),o=i.useCallback(c=>c.defaultOptionId??c.options[0]?.id??"",[]);i.useEffect(()=>{if(!a||Object.keys(a).length===0){const c={};for(const u of t)c[u.id]=o(u);Object.keys(c).length>0&&n(c)}},[t,a,n,o]);const l=i.useCallback((c,u)=>{const m={...a,[c]:u};n(m)},[a,n]);if(t.length===0)return null;const r=t.map(c=>{const u=a?.[c.id],m=o(c),d=c.options.find(g=>g.id===u);return{param:c,selectedOption:d,isNonDefault:u&&u!==m}}).filter(c=>c.selectedOption);return e.jsx("div",{className:b("flex items-center gap-1",s),children:r.map(({param:c,selectedOption:u,isNonDefault:m})=>e.jsxs(Xe,{children:[e.jsx(Je,{asChild:!0,children:e.jsxs("button",{type:"button",className:b("inline-flex h-10 items-center gap-1.5 rounded-full px-3","text-sm font-medium transition-colors","focus:outline-none focus-visible:ring-1 focus-visible:ring-ring",m?"bg-accent text-accent-foreground hover:bg-accent/80":"bg-muted/50 text-muted-foreground hover:bg-muted"),children:[e.jsx("span",{className:"truncate max-w-[140px]",children:u?.label}),e.jsx(ce,{className:"h-4 w-4 opacity-50"})]})}),e.jsx(Le,{align:"start",className:"min-w-[160px]",children:c.options.map(d=>e.jsx(pe,{onClick:()=>l(c.id,d.id),className:b(a?.[c.id]===d.id&&"bg-accent"),children:d.label},d.id))})]},c.id))})}function ni(t){const[s,a]=i.useState({width:0,height:0});return i.useEffect(()=>{const n=t.current;if(!n)return;const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const c=r[0];if(!c)return;const{width:u,height:m}=c.contentRect;a({width:u,height:m})});o.observe(n);const l=n.getBoundingClientRect();return a({width:l.width,height:l.height}),()=>{o.disconnect()}},[t]),s}function ai(){const t=i.useRef(null),s=i.useRef(null),[a,n]=i.useState(!0),o=i.useRef(!0),l=i.useRef(!1),[r,c]=i.useState(!1),[u,m]=i.useState(!1),[d,p]=i.useState(0),[g,h]=i.useState(0),x=i.useRef(-1),f=i.useRef(!1),N=i.useRef(null);i.useEffect(()=>{o.current=a},[a]);const C=i.useCallback(()=>{if(!t.current)return!0;const{scrollTop:D,scrollHeight:z,clientHeight:T}=t.current;return D+T>=z-100},[]),v=i.useCallback(()=>{if(!t.current)return[];const D=t.current.querySelectorAll('[aria-label="user message"]');return Array.from(D)},[]),k=i.useCallback(()=>{const D=t.current;if(!D)return[];const z=D.getBoundingClientRect();return v().map((E,j)=>{const R=E.getBoundingClientRect().bottom<z.top+50,_=E.textContent||"",q=_.slice(0,100)+(_.length>100?"...":"");return{index:j,preview:q,element:E,isAboveFold:R}}).filter(({isAboveFold:E})=>E).map(({index:E,preview:j,element:y})=>({index:E,preview:j,element:y}))},[v]),P=i.useCallback((D,z="smooth")=>{const T=v();if(D<0||D>=T.length)return;const E=T[D];if(E){f.current=!0,N.current&&clearTimeout(N.current),E.scrollIntoView({behavior:z,block:"start"}),x.current=D,p(D);const j=T.length-1-D;h(j),m(j>0),N.current=setTimeout(()=>{f.current=!1},500)}},[v]),M=i.useCallback(()=>{const D=t.current;if(!D)return[];const z=D.getBoundingClientRect();return v().filter(E=>E.getBoundingClientRect().bottom<z.top+50)},[v]);i.useCallback(()=>M().length>0,[M]);const A=i.useCallback(()=>{const D=t.current;if(!D)return-1;const z=D.getBoundingClientRect(),T=v();for(let E=0;E<T.length;E++){const j=T[E]?.getBoundingClientRect();if(j&&(j.top>=z.top-50&&j.top<z.top+150||j.top<z.top&&j.bottom>z.top+50))return E}for(let E=T.length-1;E>=0;E--){const j=T[E]?.getBoundingClientRect();if(j&&j.bottom<z.top+50)return E}return-1},[v]);i.useCallback(()=>{const D=v(),z=x.current!==-1?x.current:A();return z===-1?!1:z<D.length-1},[v,A]);const S=i.useCallback((D="smooth")=>{t.current&&(t.current.scrollTo({top:t.current.scrollHeight,behavior:D}),x.current=-1)},[]),I=i.useCallback((D="smooth")=>{const z=t.current;if(!z)return;const T=v();if(T.length===0)return;const E=z.getBoundingClientRect(),j=[];for(let R=0;R<T.length;R++){const _=T[R]?.getBoundingClientRect();_&&_.bottom<E.top+50&&j.push(R)}if(j.length===0)return;let y;if(x.current===-1){const R=j[j.length-1];if(R===void 0)return;y=R}else{const R=j.filter(_=>_<x.current);if(R.length>0){const _=R[R.length-1];if(_===void 0)return;y=_}else{const _=j[0];if(_===void 0)return;y=_}}if(y>=0&&y<T.length){const R=T[y];if(R){f.current=!0,N.current&&clearTimeout(N.current),R.scrollIntoView({behavior:D,block:"start"}),x.current=y,p(y);const _=T.length-1-y;h(_),m(_>0),N.current=setTimeout(()=>{f.current=!1},500)}}},[v]),$=i.useCallback((D="smooth")=>{if(!t.current)return;const T=v();if(T.length!==0&&x.current!==-1){const E=x.current+1;if(E<T.length){const j=T[E];if(j){f.current=!0,N.current&&clearTimeout(N.current),j.scrollIntoView({behavior:D,block:"start"}),x.current=E,p(E);const y=T.length-1-E;h(y),m(y>0),N.current=setTimeout(()=>{f.current=!1},500)}}}},[v]);i.useCallback(()=>x.current>0?!0:M().length>0,[M]),i.useCallback(()=>{const D=v();return x.current===-1?!1:x.current<D.length-1},[v]);const B=i.useCallback(()=>{x.current=-1},[]);i.useEffect(()=>{const D=t.current;if(!D)return;let z;const T=()=>{l.current=!0,clearTimeout(z);const E=C();n(E),o.current=E;const j=M(),y=j.length>0;if(c(y),!f.current){const R=A();R!==-1&&(x.current=R);const _=v();p(j.length);const q=x.current!==-1?x.current:R,X=q!==-1&&q<_.length-1?_.length-1-q:0;h(X),m(X>0)}z=setTimeout(()=>{l.current=!1},150)};return D.addEventListener("scroll",T,{passive:!0}),()=>{D.removeEventListener("scroll",T),clearTimeout(z)}},[C,A,v,M]),i.useEffect(()=>{const D=t.current;if(!D)return;const z=()=>{o.current&&!l.current&&requestAnimationFrame(()=>{D.scrollTo({top:D.scrollHeight,behavior:"instant"}),n(!0),o.current=!0})},T=new MutationObserver(z);T.observe(D,{childList:!0,subtree:!0,characterData:!0});const E=new ResizeObserver(z);return E.observe(D),Array.from(D.children).forEach(j=>{E.observe(j)}),()=>{T.disconnect(),E.disconnect()}},[]);function W(){n(!0),o.current=!0}function K(){n(!1),o.current=!1}return{containerRef:t,endRef:s,isAtBottom:a,scrollToBottom:S,onViewportEnter:W,onViewportLeave:K,isUserMessageAboveFold:r,hasMoreUserMessagesBelow:u,userMessagesAboveCount:d,userMessagesBelowCount:g,scrollToPreviousUserMessage:I,scrollToNextUserMessage:$,scrollToUserMessageByIndex:P,getUserMessagePreviews:k,resetUserMessageCycle:B}}const oi=({...t})=>e.jsx(la,{position:"top-center",className:"toaster group",style:{"--top-offset":"16px","--width:":"calc(100% - 2 * var(--top-offset))",position:"absolute",zIndex:5,top:"var(--top-offset)",left:"50%",transform:"translateX(-50%)",width:"calc(100% - 2 * var(--top-offset))",maxWidth:"480px"},offset:0,toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t}),Lt=i.createContext(void 0),Ie=()=>{const t=i.useContext(Lt);if(!t)throw new Error("ChatLayout components must be used within ChatLayout.Root");return t},In=i.forwardRef(({defaultSidebarOpen:t=!1,defaultPanelSize:s="hidden",defaultActiveTab:a="todo",className:n,children:o,...l},r)=>{const[c,u]=i.useState(t),[m,d]=i.useState(s),[p,g]=i.useState(a),h=i.useMemo(()=>m!=="hidden",[m]),x=i.useRef(!1),[f,N]=i.useState(!1),[C,v]=i.useState(Xs),[k,P]=i.useState(0),M=i.useCallback(()=>{x.current||(x.current=!0,d(S=>S==="hidden"?"large":"hidden"),setTimeout(()=>{x.current=!1},350))},[]),A=i.useCallback(S=>{d(S?"large":"hidden")},[]);return i.useEffect(()=>{const S=I=>{I.key.toLowerCase()==="b"&&(I.metaKey||I.ctrlKey)&&!I.shiftKey&&(I.preventDefault(),M())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[M]),e.jsx(Lt.Provider,{value:{sidebarOpen:c,setSidebarOpen:u,panelSize:m,setPanelSize:S=>{d(S),A(S!=="hidden")},activeTab:p,setActiveTab:g,panelOpen:h,setPanelOpen:A,togglePanel:M,isDraggingAside:f,setIsDraggingAside:N,asideWidth:C,setAsideWidth:v,mainWidth:k,setMainWidth:P},children:e.jsx("div",{ref:r,"data-panel-state":h?"expanded":"collapsed",className:b("flex h-screen flex-row bg-background text-foreground overflow-hidden",n),...l,children:o})})});In.displayName="ChatLayout.Root";const ri=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("relative z-10 border-b border-border bg-card shrink-0",t),...a,children:s}));ri.displayName="ChatLayout.Header";const Rn=i.forwardRef(({className:t,children:s},a)=>{const{panelOpen:n,isDraggingAside:o,asideWidth:l,setMainWidth:r}=Ie(),c=i.useRef(null),{width:u}=ni(c);return i.useEffect(()=>{r(u)},[u,r]),i.useImperativeHandle(a,()=>c.current),e.jsx("div",{ref:c,className:b("flex flex-1 flex-col overflow-hidden h-full min-w-0",!o&&"transition-[padding] duration-250",t),style:{paddingRight:n?l:0},children:s})});Rn.displayName="ChatLayout.Main";const _n=i.forwardRef(({showToaster:t=!0,className:s,children:a,...n},o)=>e.jsxs("div",{ref:o,className:b("relative flex flex-1 flex-col overflow-hidden",s),...n,children:[a,t&&e.jsx(oi,{})]}));_n.displayName="ChatLayout.Body";const Mn=i.forwardRef(({className:t,children:s,onScrollChange:a,showScrollToBottom:n=!0,initialScrollToBottom:o=!0,...l},r)=>{const{mainWidth:c}=Ie(),{containerRef:u,endRef:m,isAtBottom:d,scrollToBottom:p,userMessagesAboveCount:g,scrollToUserMessageByIndex:h}=ai(),x=i.useMemo(()=>({hidden:{opacity:0,x:-8},visible:{opacity:1,x:0,transition:{duration:.2,ease:[.4,0,.2,1]}},exit:{opacity:0,x:-8,transition:{duration:.15}}}),[]),f=i.useMemo(()=>({hidden:{opacity:0,x:-12,scale:.95,transition:{duration:.15}},visible:{opacity:1,x:0,scale:1,transition:{duration:.15,ease:[.4,0,.2,1]}},exit:{opacity:0,x:-8,scale:.98,transition:{duration:.15}}}),[]),[N,C]=i.useState(!1),[v,k]=i.useState([]),[P,M]=i.useState(null),[A,S]=i.useState(0),I=i.useRef(null),$=i.useRef(null),B=i.useRef(null),W=i.useRef(0),K=i.useCallback(()=>{const V=u.current;if(!V)return[];const Y=V.querySelectorAll('[aria-label="user message"]');return Array.from(Y).map((U,G)=>{const se=U.textContent||"",Ne=se.slice(0,100)+(se.length>100?"...":"");return{index:G,preview:Ne}})},[u]);i.useEffect(()=>{const V=u.current;if(!V)return;const Y=()=>{const G=K();k(G)};Y();const U=new MutationObserver(Y);return U.observe(V,{childList:!0,subtree:!0}),()=>{U.disconnect()}},[u,K]),i.useEffect(()=>()=>{I.current&&clearTimeout(I.current),$.current&&clearTimeout($.current),B.current!==null&&cancelAnimationFrame(B.current)},[]);const D=c>mr+fr,z=v.length>1&&D,T=i.useCallback(V=>{const U=V.currentTarget.getBoundingClientRect(),G=V.clientY-U.top;W.current=G,B.current===null&&(B.current=requestAnimationFrame(()=>{S(W.current),B.current=null}))},[]),E=i.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null),I.current=setTimeout(()=>{C(!0)},1500)},[]),j=i.useCallback(()=>{I.current&&(clearTimeout(I.current),I.current=null),$.current=setTimeout(()=>{C(!1),M(null)},500)},[]),y=i.useCallback(V=>{M(V)},[]),R=i.useCallback(()=>{M(null)},[]),_=i.useCallback(V=>{h(V,"smooth")},[h]),q=i.useRef(!1);i.useImperativeHandle(r,()=>u.current),i.useEffect(()=>{a?.(d)},[d,a]),i.useEffect(()=>{if(!o)return;const V=u.current;if(V&&!q.current){const Y=setTimeout(()=>{V.scrollTop=V.scrollHeight,q.current=!0},100);return()=>clearTimeout(Y)}},[o,u]);const X=!d&&n;return e.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[e.jsxs("div",{ref:u,className:b("h-full overflow-y-auto flex flex-col",t),...l,children:[e.jsx("div",{className:"mx-auto max-w-chat flex-1 w-full flex flex-col",children:s}),e.jsx("div",{ref:m,className:"shrink-0"})]}),e.jsx(Ye,{mode:"wait",children:z&&e.jsxs(ve.nav,{variants:x,initial:"hidden",animate:"visible",exit:"exit",className:"absolute p-4 left-0 top-1/2 -translate-y-1/2 z-10",onMouseEnter:E,onMouseMove:T,onMouseLeave:j,"aria-label":"User message navigation",children:[e.jsx("div",{className:"flex flex-col",children:v.map(({index:V})=>{const Y=V===g,U=P===V;return e.jsx("button",{type:"button",onClick:()=>_(V),onMouseEnter:()=>y(V),onMouseLeave:R,className:"py-2 px-1 group","aria-label":`Go to user message ${V+1}`,children:e.jsx("div",{className:b("w-4 h-[2px] rounded-full bg-primary transition-opacity duration-200",Y?"opacity-80":"opacity-10",U&&"opacity-60",!U&&"group-hover:opacity-60")})},V)})}),e.jsx(Ye,{children:N&&v.length>0&&P!==null&&(()=>{const U=40*Math.min(3,v.length)+10,G=40,se=40*P,Ne=G-se,wt=0,jt=U-40*v.length-10,Nt=Math.max(jt,Math.min(wt,Ne));return e.jsx(ve.div,{variants:f,initial:"hidden",animate:"visible",exit:"exit",className:b("absolute left-12 pointer-events-none","w-72 overflow-hidden","bg-card border border-border rounded-lg shadow-xl"),style:{top:`${A}px`,y:"-50%",height:`${U}px`,willChange:"transform"},children:e.jsx("div",{className:"p-1",style:{transform:`translateY(${Nt}px)`,transition:"transform 0.15s cubic-bezier(0.4, 0, 0.2, 1)",willChange:"transform"},children:v.map(({index:ee,preview:Oe})=>{const be=ee===P;return e.jsx("div",{className:b("w-full text-left px-3 py-2 rounded-md","text-sm text-muted-foreground","transition-colors duration-100","truncate",be&&"bg-accent text-foreground"),style:{height:"40px"},children:Oe},ee)})})},"hover-menu")})()})]},"toc")}),X&&e.jsx("button",{type:"button",onClick:()=>p("smooth"),className:b("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center p-2 rounded-full","bg-card border border-border shadow-lg","text-foreground","hover:bg-accent hover:text-accent-foreground","transition-all duration-200 ease-in-out","animate-in fade-in slide-in-from-bottom-2"),"aria-label":"Scroll to bottom",children:e.jsx(Ma,{className:"size-4"})})]})});Mn.displayName="ChatLayout.Messages";const En=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("bg-linear-to-t from-background to-transparent px-4 pb-4",t),...a,children:e.jsx("div",{className:"mx-auto max-w-chat",children:s})}));En.displayName="ChatLayout.Footer";const ii=i.forwardRef(({className:t,children:s,...a},n)=>{const{sidebarOpen:o}=Ie();return o?e.jsx("div",{ref:n,className:b("border-r border-border bg-card w-64 overflow-y-auto",t),...a,children:s}):null});ii.displayName="ChatLayout.Sidebar";const An=i.forwardRef(({breakpoint:t="md",onClose:s,className:a,children:n},o)=>{const{panelSize:l,togglePanel:r,setIsDraggingAside:c,setAsideWidth:u}=Ie(),[m,d]=i.useState(Xs),[p,g]=i.useState(m),[h,x]=i.useState(!1),f=i.useRef(0),N=i.useRef(m),C=l!=="hidden",[v,k]=i.useState(!1);i.useEffect(()=>{if(!C){k(!1);return}const B=requestAnimationFrame(()=>{k(!0)});return()=>cancelAnimationFrame(B)},[C]);const P=Zs();Js(P&&C),i.useEffect(()=>{g(m)},[m]),i.useEffect(()=>{C&&u(h?p:m)},[C,h,p,m,u]);const M=i.useCallback(B=>{B.preventDefault(),x(!0),c(!0),f.current=B.clientX,N.current=m,B.target.setPointerCapture(B.pointerId)},[m,c]),A=i.useCallback(B=>{if(!h)return;const W=B.clientX-f.current,K=Math.max(ss,Math.min(ns,N.current-W));g(K)},[h]),S=i.useCallback(B=>{if(!h)return;const W=B.clientX-f.current,K=Math.max(ss,Math.min(ns,N.current-W));d(K),g(K),x(!1),c(!1),B.target.releasePointerCapture(B.pointerId)},[h,c]),I=C&&P,$=C&&!P;return e.jsxs(Ye,{initial:!1,children:[I&&e.jsx(ve.aside,{variants:yr,initial:"initial",animate:"animate",exit:"exit",transition:jr,className:b("fixed inset-0 z-50 bg-card","flex flex-col","block md:hidden",a),"data-aside":"aside","data-mobile":"true",children:e.jsxs(ve.div,{className:"flex flex-col h-full",variants:vr,initial:"initial",animate:"animate",transition:wr,children:[e.jsx("div",{className:"flex justify-end px-4 pt-3 shrink-0",children:e.jsx(ke,{onClick:()=>{s?.(),r()},"aria-label":"Close panel",children:e.jsx(gt,{className:"size-4"})})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:n})]})},"aside-mobile"),$&&e.jsx("aside",{ref:o,style:{width:h?p:v?m:0,transition:h?"none":"width 0.25s cubic-bezier(0.25, 0.1, 0.25, 1)"},className:b("fixed inset-y-0 right-0 z-40","hidden h-full border-l border-border bg-card overflow-hidden",t==="sm"&&"sm:block",t==="md"&&"md:block",t==="lg"&&"lg:block",t==="xl"&&"xl:block",t==="2xl"&&"2xl:block",a),"data-aside":"aside",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{onPointerDown:M,onPointerMove:A,onPointerUp:S,className:b("absolute left-0 inset-y-0 w-2 -ml-1 cursor-col-resize z-10","group flex items-center justify-center","hover:bg-primary/5 transition-colors delay-300",h&&"bg-primary/10")}),e.jsx("div",{className:b("h-full overflow-y-auto",h?"w-full":void 0),style:h?void 0:{width:`${m}px`},children:n})]})},"aside-desktop")]})});An.displayName="ChatLayout.Aside";class li{constructor(s){this.connection=s}async getRootItems(){try{const s=await fetch(`${this.connection.apiUrl}/sandbox/files?sessionId=${this.connection.sessionId}&path=/home/user`);if(!s.ok)return console.error("Failed to fetch sandbox files:",await s.text()),[];const{files:a}=await s.json();return a.map(this.toFileSystemItem)}catch(s){return console.error("Error fetching sandbox root items:",s),[]}}async getItemChildren(s){try{const a=await fetch(`${this.connection.apiUrl}/sandbox/files?sessionId=${this.connection.sessionId}&path=${encodeURIComponent(s)}`);if(!a.ok)return console.error("Failed to fetch sandbox directory:",await a.text()),[];const{files:n}=await a.json();return n.map(this.toFileSystemItem)}catch(a){return console.error("Error fetching sandbox item children:",a),[]}}async getItemDetails(s){try{const a=s.substring(0,s.lastIndexOf("/")),n=await fetch(`${this.connection.apiUrl}/sandbox/files?sessionId=${this.connection.sessionId}&path=${encodeURIComponent(a||"/")}`);if(!n.ok)throw new Error(`Failed to fetch file details: ${await n.text()}`);const{files:o}=await n.json(),l=o.find(r=>r.path===s);if(!l)throw new Error(`File not found: ${s}`);return this.toFileSystemItem(l)}catch(a){throw console.error("Error fetching sandbox item details:",a),a}}toFileSystemItem=s=>{const a=s.type==="file"&&s.name.includes(".")?s.name.split(".").pop():void 0;return{id:s.path,name:s.name,type:s.type==="dir"?"folder":"file",path:s.path,size:s.size,lastModified:new Date(s.lastModified),...a!==void 0&&{extension:a}}}}function Pn({item:t,level:s=0,onSelect:a,selectedId:n,isDropTarget:o=!1,onDownload:l}){const[r,c]=i.useState(!0),u=n===t.id,m=()=>{t.type==="folder"&&c(!r)},d=()=>{a?.(t),t.type==="folder"&&m()},p=h=>{h.key==="Enter"||h.key===" "?(h.preventDefault(),d()):h.key==="ArrowRight"&&t.type==="folder"&&!r?(h.preventDefault(),c(!0)):h.key==="ArrowLeft"&&t.type==="folder"&&r&&(h.preventDefault(),c(!1))},g=()=>s===0?"p-2":s===1?"pl-8 pr-2 py-2":"pl-16 pr-2 py-2";return e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":t.type==="folder"?r:void 0,className:b("group/item flex items-center gap-2 rounded-md cursor-pointer transition-colors text-paragraph-sm",g(),"hover:bg-accent-hover","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-border-dark",u&&"bg-accent",o&&["bg-accent","border border-dashed border-border-dark"]),onClick:d,onKeyDown:p,children:[e.jsx("div",{className:"shrink-0 size-4 flex items-center justify-center text-foreground",children:t.type==="folder"?r?e.jsx(Ea,{className:"size-4"}):e.jsx(Aa,{className:"size-4"}):e.jsx(Pa,{className:"size-4"})}),e.jsx("p",{className:"flex-1 text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:t.name}),e.jsxs(Xe,{children:[e.jsx(Je,{asChild:!0,children:e.jsx("button",{className:b("shrink-0 size-4 transition-opacity text-muted-foreground hover:text-foreground","opacity-0 group-hover/item:opacity-100","data-[state=open]:opacity-100"),onClick:h=>{h.stopPropagation()},"aria-label":"More options",type:"button",tabIndex:-1,children:e.jsx(Da,{className:"size-4"})})}),e.jsx(Le,{align:"end",side:"bottom",sideOffset:5,alignOffset:0,collisionPadding:8,className:"w-40 z-[100]",onClick:h=>h.stopPropagation(),children:l&&e.jsx(pe,{onClick:h=>{h.stopPropagation(),l(t)},children:"Download"})})]}),t.type==="folder"&&e.jsx("div",{className:"shrink-0 size-4 flex items-center justify-center text-muted-foreground",children:e.jsx(ce,{className:b("size-4 transition-transform",!r&&"-rotate-90")})})]}),t.type==="folder"&&r&&t.children&&e.jsx("div",{className:"flex flex-col",children:t.children.map(h=>e.jsx(Pn,{item:h,level:s+1,...a&&{onSelect:a},...n&&{selectedId:n},...l&&{onDownload:l}},h.id))})]})}const ci=new nr;function di({className:t,provider:s=ci,onItemSelect:a,onDownload:n}){const[o,l]=i.useState([]),[r,c]=i.useState(),[u,m]=i.useState(!0),[d,p]=i.useState(),[g,h]=i.useState(0);i.useEffect(()=>{const f=setInterval(()=>{h(N=>N+1)},6e4);return()=>clearInterval(f)},[]),i.useEffect(()=>{(async()=>{try{m(!0);const N=await s.getRootItems();l(N),p(void 0)}catch(N){p(N instanceof Error?N.message:"Failed to load items")}finally{m(!1)}})()},[s]);const x=f=>{c(f.id),a?.(f)};return u?e.jsx("div",{className:b("",t),children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})}):d?e.jsx("div",{className:b("",t),children:e.jsxs("p",{className:"text-sm text-destructive",children:["Error: ",d]})}):o.length===0?e.jsxs("div",{className:b("flex flex-col items-center justify-center h-full text-center py-8 max-w-sm mx-auto",t),children:[e.jsx($e,{className:"size-8 text-muted-foreground opacity-50 mb-3"}),e.jsx("p",{className:"text-paragraph text-muted-foreground",children:"No files yet"}),e.jsx("p",{className:"text-paragraph-sm text-muted-foreground/70 mt-1",children:"Files will appear when your agent writes to the sandbox."})]}):e.jsx("div",{className:b("flex flex-col",t),children:o.map(f=>e.jsx(Pn,{item:f,onSelect:x,...r&&{selectedId:r},...n&&{onDownload:n}},f.id))})}const Dn=i.forwardRef(({source:t,isSelected:s,className:a,...n},o)=>e.jsxs("button",{ref:o,type:"button",className:b("group flex w-full text-left gap-2 items-start p-2 rounded-md cursor-pointer transition-colors text-paragraph-sm","hover:bg-accent-hover","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-border-dark",s&&"bg-accent",a),onClick:()=>window.open(t.url,"_blank"),...n,children:[e.jsx("div",{className:"shrink-0 flex items-center h-5",children:e.jsx("div",{className:"relative rounded-[3px] size-4 overflow-hidden bg-muted",children:t.favicon?e.jsx("img",{alt:t.sourceName,className:"size-full object-cover",src:t.favicon}):e.jsx("div",{className:"size-full bg-muted"})})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-1 min-w-0",children:[e.jsxs("div",{className:"text-paragraph-sm text-foreground truncate",children:[e.jsx("span",{className:"font-medium",children:t.sourceName}),e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.title]})]}),e.jsx("p",{className:"text-paragraph-sm text-muted-foreground line-clamp-3 break-all",children:t.snippet})]})]}));Dn.displayName="SourceListItem";const Un=i.forwardRef(({todo:t,className:s,...a},n)=>{const o=t.status==="completed";return e.jsxs("div",{ref:n,className:b("group flex items-start gap-2 p-2 rounded-md cursor-pointer transition-colors text-paragraph-sm","hover:bg-accent-hover","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-border-dark",!1,s),role:"button",tabIndex:0,...a,children:[e.jsx("div",{className:"shrink-0 flex items-center justify-center w-4 h-5 mt-0.5",children:t.status==="completed"?e.jsx(ht,{className:"size-4 text-muted-foreground"}):t.status==="in_progress"?e.jsx("div",{className:"size-2.5 rounded-full bg-foreground animate-pulse-scale"}):e.jsx(ft,{className:"size-4 text-foreground"})}),e.jsx("p",{className:b("flex-1 text-foreground",o&&"line-through text-muted-foreground",t.status==="in_progress"&&"font-medium"),children:t.text})]})});Un.displayName="TodoListItem";function ui(){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-8 max-w-sm mx-auto",children:[e.jsx(xt,{className:"size-8 text-muted-foreground opacity-50 mb-3"}),e.jsx("p",{className:"text-paragraph text-muted-foreground",children:"To-do list is empty"}),e.jsx("p",{className:"text-paragraph-sm text-muted-foreground/70 mt-1",children:"Your agent will create tasks as it works through requests."})]})}const Ot=i.forwardRef(({client:t,todos:s,className:a,...n},o)=>{const l=s||[];return l.length===0?e.jsx("div",{ref:o,className:b("h-full",a),...n,children:e.jsx(ui,{})}):e.jsx("div",{ref:o,className:b("space-y-2 overflow-y-auto",a),...n,children:l.map(r=>e.jsx(Un,{todo:r},r.id))})});Ot.displayName="TodoList";const Ft=i.forwardRef(({todos:t=[],className:s,...a},n)=>e.jsx("div",{ref:n,className:b("h-full",s),...a,children:e.jsx(Ot,{todos:t,className:"h-full"})}));Ft.displayName="TodoTabContent";const Bt=i.forwardRef(({files:t=[],provider:s,sessionId:a,agentApiUrl:n,client:o,onFileSelect:l,className:r,...c},u)=>{const[m,d]=i.useState(0),p=i.useRef(void 0),g=i.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(f=>f+1)},300)},[]);i.useEffect(()=>!a||!o?void 0:o.onFileSystemChange(a,N=>{console.log("Files changed:",N),g()}),[a,o,g]);const h=i.useMemo(()=>{if(s)return s;if(a&&n)return new li({sessionId:a,apiUrl:n})},[s,a,n]),x=i.useCallback(async f=>{if(f.type==="folder"){console.warn("Cannot download folders");return}if(!a||!n){console.error("Cannot download: missing sessionId or agentApiUrl");return}try{const N=`${n}/sandbox/download?sessionId=${encodeURIComponent(a)}&path=${encodeURIComponent(f.path||f.name)}`,C=document.createElement("a");C.href=N,C.download=f.name,document.body.appendChild(C),C.click(),document.body.removeChild(C)}catch(N){console.error("Failed to download file:",N)}},[a,n]);return e.jsx("div",{ref:u,className:b("h-full",r),...c,children:e.jsx(di,{...h&&{provider:h},onItemSelect:f=>{f.type==="file"&&l&&l(f.path||f.name)},onDownload:x,className:"h-full"},m)})});Bt.displayName="FilesTabContent";const Ht=i.forwardRef(({sources:t=[],highlightedSourceId:s,className:a,...n},o)=>t.length===0?e.jsxs("div",{ref:o,className:b("flex flex-col items-center justify-center h-full text-center py-8 max-w-sm mx-auto",a),...n,children:[e.jsx(Ds,{className:"size-8 text-muted-foreground opacity-50 mb-3"}),e.jsx("p",{className:"text-paragraph text-muted-foreground",children:"No sources yet"}),e.jsx("p",{className:"text-paragraph-sm text-muted-foreground/70 mt-1",children:"Sources will appear when your agent searches the web or fetches data."})]}):e.jsx("div",{ref:o,className:b("space-y-2",a),...n,children:t.map(l=>e.jsx(Dn,{source:l,isSelected:l.id===s},l.id))}));Ht.displayName="SourcesTabContent";const mi=i.forwardRef(({data:t,className:s,...a},n)=>e.jsxs("div",{ref:n,className:b("space-y-4",s),...a,children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"Database"}),e.jsxs("div",{className:"text-paragraph-sm text-muted-foreground",children:[e.jsx("p",{children:"Database viewer - panel automatically expanded to large size"}),e.jsxs("div",{className:"mt-4 p-4 border border-border rounded",children:[e.jsx("p",{children:"Your large data table would go here"}),t&&typeof t=="object"?e.jsx("pre",{className:"mt-2 text-caption overflow-auto",children:JSON.stringify(t,null,2)}):null]})]})]}));mi.displayName="DatabaseTabContent";const pi=({tool:t})=>{const s=t.children&&t.children.length>0;return e.jsxs("div",{className:"p-3 border border-border rounded-lg bg-muted/30",children:[e.jsx("div",{className:"font-medium text-paragraph-sm",children:t.prettyName||t.name}),t.description&&!s&&e.jsx("div",{className:"text-caption text-muted-foreground mt-1 line-clamp-1",children:t.description}),s&&e.jsxs("div",{className:"text-caption text-muted-foreground mt-1",children:["Built-in tools:"," ",t.children?.map(a=>a.prettyName||a.name).join(", ")]})]})},zn=i.forwardRef(({tools:t=[],mcps:s=[],subagents:a=[],className:n,...o},l)=>e.jsxs("div",{ref:l,className:b("space-y-6",n),...o,children:[e.jsxs("div",{className:"space-y-3 p-2",children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"Tools"}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(r=>e.jsx(pi,{tool:r},r.name))}):e.jsx("p",{className:"text-paragraph-sm text-muted-foreground",children:"No tools available"})]}),e.jsxs("div",{className:"space-y-3 p-2",children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"MCP Servers"}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(r=>e.jsxs("div",{className:"p-3 border border-border rounded-lg bg-muted/30",children:[e.jsx("div",{className:"font-medium text-paragraph-sm",children:r.name}),e.jsxs("div",{className:"text-caption text-muted-foreground mt-1",children:["Transport: ",r.transport]})]},r.name))}):e.jsx("p",{className:"text-paragraph-sm text-muted-foreground",children:"No MCP servers connected"})]}),e.jsxs("div",{className:"space-y-3 p-2",children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"Subagents"}),a.length>0?e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsxs("div",{className:"p-3 border border-border rounded-lg bg-muted/30",children:[e.jsx("div",{className:"font-medium text-paragraph-sm",children:r.name}),e.jsx("div",{className:"text-caption text-muted-foreground mt-1 line-clamp-2",children:r.description})]},r.name))}):e.jsx("p",{className:"text-paragraph-sm text-muted-foreground",children:"No subagents available"})]})]}));zn.displayName="SettingsTabContent";const $n=ba,Ve=i.forwardRef(({className:t,...s},a)=>e.jsx(vs,{ref:a,className:b("inline-flex h-10 items-center rounded-md bg-muted p-1 text-muted-foreground gap-1",t),...s}));Ve.displayName=vs.displayName;const qe=i.forwardRef(({className:t,...s},a)=>e.jsx(ws,{ref:a,className:b("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-paragraph-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...s}));qe.displayName=ws.displayName;const we=i.forwardRef(({className:t,...s},a)=>e.jsx(js,{ref:a,className:b("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));we.displayName=js.displayName;const fi=i.forwardRef(({client:t,todos:s,variant:a="animated",showIcons:n=!1,visibleTabs:o=["todo","files","database"],className:l,...r},c)=>{const u=s||[],[m,d]=i.useState(o[0]||"todo"),p=i.useRef(null),g=i.useRef(null);i.useEffect(()=>{const N=setTimeout(()=>{const C=p.current;if(m&&C){const v=g.current;if(v){const k=C.getBoundingClientRect(),P=v.getBoundingClientRect(),M=P.left-k.left,A=P.width,S=M/k.width*100,I=100-(M+A)/k.width*100;C.style.clipPath=`inset(0 ${I.toFixed(2)}% 0 ${S.toFixed(2)}% round 999px)`}}},0);return()=>clearTimeout(N)},[m]);const x=[{id:"todo",label:a==="pills"?"To-do":"To-Do List",icon:xt},{id:"files",label:"Files",icon:$e},{id:"database",label:"Database",icon:Us},{id:"sources",label:"Sources",icon:zs}].filter(f=>o.includes(f.id));return e.jsx("div",{ref:c,className:b("select-none",l),...r,children:e.jsxs($n,{value:m,onValueChange:d,className:"w-full",children:[a==="pills"?e.jsx(Ve,{className:b("w-full justify-start bg-transparent p-0 h-auto","gap-1"),children:x.map(f=>{const N=f.icon;return e.jsxs(qe,{value:f.id,className:b("gap-2 px-3 py-1.5 rounded-lg text-paragraph-sm font-medium","data-[state=active]:bg-accent data-[state=active]:text-foreground","data-[state=inactive]:text-muted-foreground"),children:[n&&N&&e.jsx(N,{className:"size-4"}),f.label]},f.id)})}):e.jsxs("div",{className:"relative mb-4 border-border",children:[e.jsx(Ve,{className:"bg-transparent p-0 h-auto rounded-none w-full border-none",children:x.map(f=>e.jsx(qe,{value:f.id,className:"px-3 py-1 text-paragraph-sm font-medium rounded-none text-foreground opacity-60 data-[state=active]:opacity-100 data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:f.label},f.id))}),e.jsx("div",{ref:p,className:"absolute top-0 left-0 w-full overflow-hidden z-10 pointer-events-none",style:{clipPath:"inset(0 100% 0 0% round 999px)",transition:"clip-path 0.25s ease-out"},children:e.jsx(Ve,{className:"bg-secondary p-0 h-auto rounded-none w-full border-none",children:x.map(f=>e.jsx(qe,{value:f.id,ref:m===f.id?g:null,className:"px-3 py-1 text-paragraph-sm font-medium rounded-none text-primary bg-transparent data-[state=active]:shadow-none shadow-none",tabIndex:-1,children:f.label},f.id))})})]}),e.jsx(we,{value:"todo",className:a==="pills"?"mt-0":"",children:a==="pills"?e.jsx(Ft,{todos:u}):e.jsx(Ot,{todos:u})}),e.jsx(we,{value:"files",className:a==="pills"?"mt-0":"",children:e.jsx(Bt,{})}),e.jsx(we,{value:"database",className:a==="pills"?"mt-0":"",children:e.jsx("div",{className:"text-paragraph-sm text-foreground opacity-60 italic",children:"Database tab coming soon..."})}),e.jsx(we,{value:"sources",className:a==="pills"?"mt-0":"",children:e.jsx(Ht,{})})]})})});fi.displayName="ChatSecondaryPanel";const gi=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex h-full flex-col",t),...a,children:s}));gi.displayName="ChatSidebar.Root";const hi=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("border-b border-border px-4 py-3",t),...a,children:s}));hi.displayName="ChatSidebar.Header";const xi=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("flex-1 overflow-y-auto p-4",t),...a,children:s}));xi.displayName="ChatSidebar.Content";const bi=i.forwardRef(({className:t,children:s,...a},n)=>e.jsx("div",{ref:n,className:b("border-t border-border px-4 py-3",t),...a,children:s}));bi.displayName="ChatSidebar.Footer";const yi=i.forwardRef(({children:t,className:s,...a},n)=>{const[o,l]=i.useState(t),[r,c]=i.useState(!1),u=i.useRef(t),m=i.useRef(!0);return i.useEffect(()=>{if(m.current){m.current=!1,u.current=t;return}if(u.current===t)return;c(!0);const d=setTimeout(()=>{l(t),u.current=t,requestAnimationFrame(()=>{c(!1)})},150);return()=>{clearTimeout(d)}},[t]),e.jsx("span",{ref:n,className:b("text-sm text-foreground opacity-60 transition-opacity duration-300",r?"opacity-0":"opacity-60",s),...a,children:o})});yi.displayName="ChatStatus";const vi=500;function wi(t){const s=L(o=>o.isStreaming),a=i.useRef(null),n=i.useRef(0);i.useEffect(()=>{t&&!s&&(document.title=t)},[t,s]),i.useEffect(()=>{if(!t)return;const o=()=>{const l=".".repeat(n.current);document.title=`${t}${l}`,n.current=(n.current+1)%4};if(s)return n.current=0,o(),a.current=setInterval(o,vi),()=>{a.current&&(clearInterval(a.current),a.current=null),document.title=t}},[s,t])}const ye=xe("gui");function ji({children:t}){const{setPanelSize:s,setActiveTab:a,panelSize:n,activeTab:o}=Ie(),l=()=>{n!=="hidden"&&o==="files"?s("hidden"):(s("small"),a("files"))},r=()=>{n!=="hidden"&&o==="settings"?s("hidden"):(s("small"),a("settings"))};return e.jsx(e.Fragment,{children:t({openFiles:l,openSettings:r})})}function Ni({client:t,startSession:s,placeholder:a,commandMenuItems:n,onCancel:o,promptParameters:l}){const r=L(d=>d.input.attachedFiles),c=L(d=>d.addFileAttachment),u=L(d=>d.removeFileAttachment),m=d=>{for(const p of d)c(p)};return e.jsxs(yn,{client:t,startSession:s,onCancel:o,children:[e.jsx(Tn,{commands:n}),r.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 p-3 border-b border-border",children:r.map((d,p)=>e.jsxs("div",{className:"relative group rounded-md overflow-hidden border border-border",children:[e.jsx("img",{src:`data:${d.mimeType};base64,${d.data}`,alt:d.name,className:"h-20 w-20 object-cover"}),e.jsx("button",{type:"button",onClick:()=>u(p),className:"absolute top-1 right-1 p-1 rounded-full bg-background/80 hover:bg-background opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(gt,{className:"size-3"})})]},`attached-${d.name}-${d.data.slice(0,20)}`))}),e.jsx(vn,{placeholder:a,autoFocus:!0,onFilesDropped:m}),e.jsxs(Nn,{children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{}),e.jsx(Cn,{onFilesSelected:m}),l&&l.length>0&&e.jsx(si,{parameters:l})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(kn,{}),e.jsx(jn,{}),e.jsx(wn,{children:e.jsx(za,{className:"size-4"})})]})]})]})}function Si({todos:t,sources:s,tools:a,mcps:n,subagents:o,sessionId:l,agentApiUrl:r,client:c}){const{activeTab:u,setActiveTab:m}=Ie();return e.jsxs($n,{value:u,onValueChange:d=>m(d),className:"flex flex-col h-full",children:[e.jsx("div",{className:b("border-b border-border bg-card","px-4 py-2 h-16","flex items-center","sticky top-0 z-10 shrink-0"),children:e.jsx(Gn,{showIcons:!0,visibleTabs:["todo","files","sources","settings"],variant:"compact"})}),e.jsx(we,{value:"todo",className:"flex-1 p-4 mt-0 overflow-y-auto",children:e.jsx(Ft,{todos:t})}),e.jsx(we,{value:"files",className:"flex-1 p-4 mt-0 overflow-y-auto",children:e.jsx(Bt,{sessionId:l,agentApiUrl:r,client:c})}),e.jsx(we,{value:"sources",className:"flex-1 p-4 mt-0 overflow-y-auto",children:e.jsx(Ht,{sources:s})}),e.jsx(we,{value:"settings",className:"flex-1 p-4 mt-0 overflow-y-auto",children:e.jsx(zn,{tools:a??[],mcps:n??[],subagents:o??[]})})]})}function Ci({agentName:t,showHeader:s,sessionId:a,debuggerUrl:n}){const{togglePanel:o,panelOpen:l}=Ie(),r=n?a?`${n}/sessions/${a}`:n:null;return e.jsx(hn,{className:b("border-b border-border bg-card h-16"),children:e.jsxs("div",{className:"flex items-center w-full py-5 px-4 lg:px-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx(jl,{}),s&&t&&e.jsx("span",{className:"text-heading-4 text-foreground",children:t})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(On,{}),n&&e.jsx(fe,{children:e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:e.jsx(ke,{"aria-label":"View session in debugger",disabled:!r,asChild:!!r,children:r?e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Kt,{className:"size-4 text-muted-foreground"})}):e.jsx(Kt,{className:"size-4 text-muted-foreground"})})}),e.jsx(de,{children:e.jsx("p",{children:a?"View session in debugger":"Open debugger"})})]})}),e.jsx(ke,{"aria-label":"Toggle panel",onClick:o,"data-state":l?"open":"closed",children:e.jsx(Ua,{className:"size-4 text-muted-foreground"})})]})]})})}function ki({client:t,initialSessionId:s,error:a,debuggerUrl:n}){const{connectionStatus:o,connect:l,sessionId:r,startSession:c}=Fo(t,s),{messages:u,sendMessage:m,editAndResend:d,cancel:p}=Ks(t,c);Vo(t);const g=L(Y=>Y.error),[h,x]=i.useState(void 0),[f,N]=i.useState(void 0),[C,v]=i.useState(void 0),[k,P]=i.useState([]),[M,A]=i.useState([]),[S,I]=i.useState([]),[$,B]=i.useState([]),[W,K]=i.useState("Type a message or / for commands..."),[D,z]=i.useState(!1),[T,E]=i.useState(null),j=L(Lo);L(Y=>Y.latestContextSize);const{resolvedTheme:y,setTheme:R}=$t(),_=i.useMemo(()=>{const Y=[];for(const U of u)if(U.sources)for(const G of U.sources)Y.push({id:G.id,title:G.title,url:G.url,snippet:G.snippet||"",sourceName:G.sourceName||"",favicon:G.favicon||""});return Y},[u]);wi(h),i.useEffect(()=>{ye.debug("Connection status changed",{status:o}),o==="error"&&g&&ye.error("Connection error occurred",{error:g})},[o,g]),i.useEffect(()=>{if(t&&o==="connected"){const Y=t.getCurrentSession();Y?.metadata?.agentName&&x(Y.metadata.agentName);const U=t.getAgentInfo();U.displayName?x(U.displayName):U.name&&x(U.name),N(U.description||"Start a conversation below to begin working with this agent."),U.suggestedPrompts&&U.suggestedPrompts.length>0?v(U.suggestedPrompts):v([]),U.tools&&U.tools.length>0&&(P(U.tools),ye.info("Agent tools loaded",{tools:U.tools})),U.mcps&&U.mcps.length>0&&(A(U.mcps),ye.info("Agent MCPs loaded",{mcps:U.mcps})),U.subagents&&U.subagents.length>0&&(I(U.subagents),ye.info("Agent subagents loaded",{subagents:U.subagents})),U.promptParameters&&U.promptParameters.length>0&&(B(U.promptParameters),ye.info("Agent prompt parameters loaded",{promptParameters:U.promptParameters})),U.uiConfig?.hideTopBar&&z(!0)}},[t,o]);const q=Y=>{K(Y)},X=()=>{K("Type a message or / for commands...")};if(a)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-background",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[e.jsx("h1",{className:"text-2xl font-bold text-destructive mb-4",children:"Initialization Error"}),e.jsx("p",{className:"text-foreground mb-4",children:a}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to initialize the ACP client. Check the console for details."})]})});const V=[{id:"dark-mode",label:y==="dark"?"Light Mode":"Dark Mode",description:`Switch to ${y==="dark"?"light":"dark"} theme`,icon:y==="dark"?e.jsx(As,{className:"h-4 w-4"}):e.jsx(Ps,{className:"h-4 w-4"}),category:"action",onSelect:()=>{R(y==="dark"?"light":"dark"),ye.info("User toggled theme",{newTheme:y==="dark"?"light":"dark"})}},{id:"settings",label:"Open Settings",description:"Configure chat preferences",icon:e.jsx(Et,{className:"h-4 w-4"}),category:"action",onSelect:()=>{ye.info("User opened settings")}}];return e.jsxs(sn,{defaultOpen:!1,children:[e.jsx(Kr,{client:t,currentSessionId:r}),e.jsx(an,{children:e.jsxs(In,{defaultPanelSize:"hidden",defaultActiveTab:"todo",children:[e.jsxs(Rn,{children:[!D&&e.jsx(Ci,{agentName:h,showHeader:u.length>0,sessionId:r,...n&&{debuggerUrl:n}}),o==="error"&&g&&e.jsx("div",{className:"border-b border-destructive/20 bg-destructive/10 px-6 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"mb-1 text-paragraph-sm font-semibold text-destructive",children:"Connection Error"}),e.jsx("p",{className:"whitespace-pre-line text-paragraph-sm text-foreground",children:g})]}),e.jsx("button",{type:"button",onClick:l,className:"rounded-lg bg-destructive px-4 py-2 text-paragraph-sm font-medium text-destructive-foreground transition-colors hover:bg-destructive-hover",children:"Retry"})]})}),e.jsxs(_n,{children:[e.jsx(Mn,{children:u.length===0?h!==void 0?e.jsx(ji,{children:({openFiles:Y,openSettings:U})=>e.jsx("div",{className:"flex flex-1 items-center px-4",children:e.jsx(gn,{title:h,description:f??"",suggestedPrompts:C??[],onPromptClick:G=>{const se=L.getState().input.selectedPromptParameters;m(G,void 0,se&&Object.keys(se).length>0?se:void 0),K("Type a message or / for commands..."),ye.info("Prompt clicked",{prompt:G})},onPromptHover:q,onPromptLeave:X,onOpenFiles:Y,onOpenSettings:U,toolsAndMcpsCount:k.length+M.length+S.length})})}):null:e.jsx("div",{className:"flex flex-col px-4",children:u.map((Y,U)=>{const G=U===0,se=G?null:u[U-1];let Ne="mt-2";G?Ne=Y.role==="assistant"?"mt-8":"mt-2":Y.role==="user"?Ne=(se?.role==="user","mt-4"):Y.role==="assistant"&&(Ne=se?.role==="assistant"?"mt-2":"mt-6");const wt=u.some(ee=>ee.isStreaming),jt=Y.role==="user"?u.slice(0,U+1).filter(ee=>ee.role==="user").length-1:-1,Nt=T!==null&&U>T;return e.jsx(Bn,{message:Y,className:b(Ne,"group",Nt&&"opacity-50"),isLastMessage:U===u.length-1,children:e.jsx("div",{className:"flex flex-col w-full",children:Y.role==="user"?e.jsx(Di,{message:Y,messageIndex:jt,isStreaming:wt,onEditAndResend:d,sticky:!0,onEditingChange:ee=>{E(ee?U:null)}}):e.jsxs(e.Fragment,{children:[e.jsx(Yn,{message:Y,thinkingDisplayStyle:"collapsible"}),e.jsx(Bi,{message:Y,isStreaming:Y.isStreaming,onSendMessage:m,isLastAssistantMessage:U===u.findLastIndex(ee=>ee.role==="assistant"),onRedo:()=>{let ee=null,Oe=-1;for(let be=U-1;be>=0;be--)if(u[be]?.role==="user"){ee=u[be],Oe=u.slice(0,be+1).filter(tt=>tt.role==="user").length-1;break}if(ee?.content&&Oe>=0){const be=ee.images?.map((tt,ea)=>({name:`image-${ea}`,path:"",size:0,mimeType:tt.mimeType,data:tt.data}));d(Oe,ee.content,be)}}})]})})},Y.id)})})}),e.jsx(En,{children:e.jsx(Ni,{client:t,startSession:c,placeholder:W,commandMenuItems:V,onCancel:p,promptParameters:$})})]})]}),e.jsx(An,{breakpoint:"md",children:e.jsx(Si,{todos:j,sources:_,tools:k,mcps:M,subagents:S,sessionId:r,agentApiUrl:t?.getBaseUrl(),client:t})})]})})]})}const Ln=i.forwardRef(({sourceId:t,sources:s,className:a},n)=>{const o=s.find(u=>u.id===t);let l=null;try{l=Ie()}catch{}const r=i.useCallback(u=>{u.preventDefault(),u.stopPropagation(),l&&(l.setPanelSize("small"),l.setActiveTab("sources")),o?.url&&window.open(o.url,"_blank","noopener,noreferrer")},[l,o?.url]);if(!o)return e.jsxs("span",{ref:n,className:b("inline-flex items-center px-1.5 py-0.5 text-xs font-medium","bg-muted text-muted-foreground rounded-md","cursor-default",a),children:["[",t,"]"]});const c=o.sourceName||Ti(o.url);return e.jsx(fe,{delayDuration:200,children:e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:e.jsxs("span",{ref:n,role:"button",tabIndex:0,onClick:r,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&r(u)},className:b("inline-flex items-center gap-1 px-1.5 py-0.5","text-xs font-medium rounded-md","bg-accent/50 text-accent-foreground","hover:bg-accent cursor-pointer transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",a),children:[o.favicon&&e.jsx("img",{src:o.favicon,alt:"",className:"size-3 rounded-sm",onError:u=>{u.target.style.display="none"}}),e.jsx("span",{children:c})]})}),e.jsx(de,{side:"top",align:"start",className:"max-w-xs p-0 overflow-hidden",children:e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.favicon&&e.jsx("img",{src:o.favicon,alt:"",className:"size-4 rounded-sm"}),e.jsx("span",{className:"font-medium text-sm",children:c})]}),e.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 mb-1",children:o.title}),o.snippet&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3 mb-2",children:o.snippet}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx($a,{className:"size-3"}),e.jsx("span",{children:"Click to open"})]})]})})]})})});Ln.displayName="CitationChip";function Ti(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}const Ii=2e5,On=i.forwardRef(({className:t,...s},a)=>{const n=L(k=>k.latestContextSize);if(n==null)return null;const o=n,l=Math.max(o.totalEstimated,o.llmReportedInputTokens??0),r=o.modelContextWindow??Ii,c=l/r*100,u=`${c.toFixed(1)}%`,m=Math.min(100,Math.max(0,c)),p=(k=>k<50?"text-foreground":k<75?"text-yellow-500":"text-red-500")(c),g=k=>l===0?"0.0%":`${(k/l*100).toFixed(1)}%`,h=16,x=2,f=(h-x)/2,N=h/2,C=2*Math.PI*f,v=C-m/100*C;return e.jsx(fe,{children:e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:e.jsx(ne,{ref:a,type:"button",variant:"ghost",size:"icon",className:b("rounded-full cursor-default",p,t),...s,children:e.jsxs("svg",{width:h,height:h,viewBox:`0 0 ${h} ${h}`,className:"transform -rotate-90",children:[e.jsx("title",{children:"Context usage indicator"}),e.jsx("circle",{cx:N,cy:N,r:f,stroke:"currentColor",strokeWidth:x,fill:"transparent",className:"opacity-20"}),e.jsx("circle",{cx:N,cy:N,r:f,stroke:"currentColor",strokeWidth:x,fill:"transparent",strokeDasharray:C,strokeDashoffset:v,strokeLinecap:"round",className:"transition-all duration-300 ease-in-out"})]})})}),e.jsx(de,{side:"top",align:"center",className:"p-3",children:e.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"System Prompt:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.systemPromptTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.systemPromptTokens),")"]})]})]}),o.toolOverheadTokens!==void 0&&o.toolOverheadTokens>0&&e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tools Definition:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.toolOverheadTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.toolOverheadTokens),")"]})]})]}),o.mcpOverheadTokens!==void 0&&o.mcpOverheadTokens>0&&e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"MCPs Definition:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.mcpOverheadTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.mcpOverheadTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"User Messages:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.userMessagesTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.userMessagesTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Assistant Messages:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.assistantMessagesTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.assistantMessagesTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tool Inputs:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.toolInputTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.toolInputTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tool Results:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:o.toolResultsTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",g(o.toolResultsTokens),")"]})]})]})]}),e.jsx("div",{className:"border-t border-border pt-2",children:e.jsxs("div",{className:b("flex justify-end gap-2 font-semibold",p),children:[e.jsx("span",{children:l.toLocaleString()}),e.jsxs("span",{children:["(",u,")"]})]})})]})})]})})});On.displayName="ContextUsageButton";const Ri=i.forwardRef(({autoScroll:t=!0,isStreaming:s=!1,scrollBehavior:a="smooth",scrollThreshold:n=100,showScrollButton:o=!0,scrollButton:l,className:r,children:c,...u},m)=>{const d=i.useRef(null),[p,g]=i.useState(!0),[h,x]=i.useState(!1),f=i.useRef(0);i.useImperativeHandle(m,()=>{if(!d.current)throw new Error("Container ref not initialized");return d.current});const N=i.useCallback(()=>{const v=d.current;if(!v)return;const{scrollTop:k,scrollHeight:P,clientHeight:M}=v,S=P-k-M<n;g(S),x(!S&&o),f.current=k},[n,o]),C=i.useCallback((v=a)=>{const k=d.current;k&&k.scrollTo({top:k.scrollHeight,behavior:v})},[a]);return i.useEffect(()=>{!t||!d.current||(s&&p?C("auto"):!s&&p&&C())},[t,s,p,C]),i.useEffect(()=>{const v=d.current;if(!v)return;const k=()=>{N()};return v.addEventListener("scroll",k,{passive:!0}),N(),()=>{v.removeEventListener("scroll",k)}},[N]),i.useEffect(()=>{const v=d.current;if(!v)return;const k=new ResizeObserver(()=>{p&&t&&C("auto")});return k.observe(v),()=>{k.disconnect()}},[p,t,C]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("div",{ref:d,className:b("h-full overflow-y-auto overflow-x-hidden","scrollbar-thin scrollbar-thumb-[border] scrollbar-track-transparent",r),...u,children:e.jsx("div",{className:"flex flex-col gap-4 px-4 py-4",children:c})}),h&&e.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-10",children:l||e.jsxs("button",{type:"button",onClick:()=>C(),className:"px-4 py-2 rounded-full bg-card border border-border shadow-lg hover:shadow-xl hover:bg-card/90 transition-all text-sm font-medium text-foreground flex items-center gap-2","aria-label":"Scroll to bottom",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Down arrow",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})}),"Scroll to bottom"]})})]})});Ri.displayName="Conversation";const _i=Ns,Fn=i.forwardRef(({className:t,...s},a)=>e.jsx(ct,{ref:a,className:b("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));Fn.displayName=ct.displayName;const Mi=i.forwardRef(({className:t,children:s,...a},n)=>e.jsxs(_i,{children:[e.jsx(Fn,{}),e.jsxs(dt,{ref:n,className:b("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...a,children:[s,e.jsxs(Ss,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mi.displayName=dt.displayName;const Ei=i.forwardRef(({className:t,...s},a)=>e.jsx(ut,{ref:a,className:b("text-subheading font-semibold leading-none tracking-tight",t),...s}));Ei.displayName=ut.displayName;const Ai=i.forwardRef(({className:t,...s},a)=>e.jsx(mt,{ref:a,className:b("text-paragraph-sm text-muted-foreground",t),...s}));Ai.displayName=mt.displayName;function Pi({message:t,messageIndex:s,isStreaming:a,onEditAndResend:n,sticky:o=!1,onEditingChange:l}){const[r,c]=i.useState(!1),[u,m]=i.useState(!1),d=i.useRef(null),p=i.useRef(null);i.useEffect(()=>{l?.(r)},[r,l]);const g=i.useCallback(()=>{if(!o||!d.current)return;let v=d.current.parentElement;for(;v&&!v.classList.contains("overflow-y-auto");)v=v.parentElement;if(v){d.current.getBoundingClientRect(),v.getBoundingClientRect();const k=d.current.offsetTop;v.scrollTo({top:k-16,behavior:"smooth"})}},[o]),h=i.useCallback(async()=>{if(!t.content){Ce.error("There's no text to copy!");return}try{await navigator.clipboard.writeText(t.content),m(!0),Ce.success("Copied to clipboard!"),setTimeout(()=>{m(!1)},2e3)}catch{Ce.error("Failed to copy to clipboard")}},[t.content]),x=i.useCallback(()=>{c(!0)},[]);i.useEffect(()=>{if(r&&p.current){p.current.focus();const v=document.createRange(),k=window.getSelection();v.selectNodeContents(p.current),v.collapse(!1),k?.removeAllRanges(),k?.addRange(v)}},[r]);const f=i.useCallback(()=>{c(!1),p.current&&(p.current.textContent=t.content||"")},[t.content]),N=i.useCallback(()=>{const v=p.current?.textContent||"";if(!v.trim())return;const k=t.images?.map((P,M)=>({name:`image-${M}`,path:"",size:0,mimeType:P.mimeType,data:P.data}));n(s,v.trim(),k),c(!1)},[s,t.images,n]),C=i.useCallback(v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),N()),v.key==="Escape"&&(v.preventDefault(),f())},[N,f]);return e.jsxs("div",{ref:d,className:"w-full group/user-message",children:[e.jsx("div",{className:b("w-full rounded-2xl bg-secondary px-4 py-4 transition-colors",o&&"sticky top-0 z-10 bg-secondary cursor-pointer",r&&"ring-2 ring-primary/20 focus-within:ring-primary/40 transition-all bg-transparent"),onClick:o&&!r?g:void 0,onKeyDown:o&&!r?v=>{(v.key==="Enter"||v.key===" ")&&g()}:void 0,role:o&&!r?"button":void 0,tabIndex:o&&!r?0:void 0,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[t.images&&t.images.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.images.map((v,k)=>e.jsx("img",{src:`data:${v.mimeType};base64,${v.data}`,alt:`Attachment ${k+1}`,className:b("max-w-[200px] max-h-[200px] rounded-lg object-cover",r&&"opacity-50")},`image-${v.mimeType}-${v.data.slice(0,20)}`))}),t.content&&e.jsx("div",{ref:p,role:"textbox",tabIndex:r?0:-1,contentEditable:r,onKeyDown:r?C:void 0,suppressContentEditableWarning:!0,className:b("whitespace-pre-wrap text-foreground leading-relaxed outline-none",r&&"cursor-text",!r&&"cursor-default"),children:t.content})]})}),!a&&t.content&&e.jsx(Gs,{className:b("mt-2 transition-opacity justify-end",r?"opacity-100":"opacity-0 group-hover/user-message:opacity-100"),children:r?e.jsxs(e.Fragment,{children:[e.jsx(ne,{variant:"ghost",size:"sm",onClick:f,className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",children:"Cancel"}),e.jsx(ne,{size:"sm",onClick:N,className:"h-7 px-3 text-xs",children:"Send"})]}):e.jsxs(e.Fragment,{children:[e.jsx(it,{onClick:h,tooltip:u?"Copied!":"Copy",children:u?e.jsx(pt,{className:"size-4"}):e.jsx($s,{className:"size-4"})}),e.jsx(it,{onClick:x,tooltip:"Edit",children:e.jsx(La,{className:"size-4"})})]})})]})}const Di=i.memo(Pi,(t,s)=>t.isStreaming===s.isStreaming&&t.message.id===s.message.id&&t.message.content===s.message.content&&t.messageIndex===s.messageIndex&&t.sticky===s.sticky&&t.onEditingChange===s.onEditingChange);function Ui(t,s,a,n,o){const l=a==="triggered",r=n==="no_action_needed";return t==="context_size"?l?{icon:re,title:"Compacting Context..."}:{icon:re,title:r?"Context Check":"Context Compacted"}:t==="tool_response"?s==="mid_turn_compaction"||o===!0?l?{icon:re,title:"Compacting Context..."}:{icon:re,title:r?"Context Check":"Context Compacted"}:l?{icon:re,title:"Compacting Response..."}:{icon:re,title:r?"Response Check":"Tool Response Compacted"}:{icon:re,title:l?"Running Hook...":"Hook Executed"}}function Re(t){return t.toLocaleString()}function zi(t){if(t<60)return`${t.toFixed(1)}s`;const s=Math.floor(t/3600),a=Math.floor(t%3600/60),n=Math.floor(t%60);return s>0?`${s}h ${a}m ${n}s`:`${a}m ${n}s`}function kt({notification:t}){const[s,a]=i.useState(!1),[n,o]=i.useState(0),{icon:l,title:r}=Ui(t.hookType,t.callback,t.status,t.metadata?.action,t.metadata?.midTurn),c=t.status==="triggered",u=t.status==="completed",m=t.status==="error";i.useEffect(()=>{if(!c||!t.triggeredAt)return;const h=()=>{const f=(Date.now()-t.triggeredAt)/1e3;o(f)};h();const x=setInterval(h,100);return()=>clearInterval(x)},[c,t.triggeredAt]);const d=t.callback==="mid_turn_compaction"||t.metadata?.midTurn===!0;let p="";if(c&&t.currentPercentage!==void 0)p=`Context at ${t.currentPercentage.toFixed(1)}% (threshold: ${t.threshold}%)`;else if(u&&t.metadata?.tokensSaved!==void 0){const{tokensSaved:h,originalTokens:x,messagesRemoved:f}=t.metadata;if(d)p=`${f!==void 0?`${Re(f)} messages summarized, `:""}${Re(h??0)} tokens saved`;else if(x!==void 0&&x>0)p=`${((h??0)/x*100).toFixed(0)}% reduced`;else if(t.currentPercentage!==void 0&&t.currentPercentage>0){const C=t.currentPercentage/100*2e5;p=`${((h??0)/C*100).toFixed(1)}% context freed`}else p=`${Re(h)} tokens saved`}else m&&t.error&&(p=t.error);const g=t.metadata?.truncationWarning;return e.jsxs("div",{className:"flex flex-col my-3",children:[e.jsxs("button",{type:"button",className:"flex flex-col items-start gap-0.5 cursor-pointer bg-transparent border-none p-0 text-left group w-fit",onClick:()=>a(!s),"aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[e.jsx("div",{className:m?"text-destructive":"text-muted-foreground",children:e.jsx(l,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-paragraph-sm text-muted-foreground",children:r}),c&&e.jsxs(e.Fragment,{children:[e.jsx(At,{className:"h-3 w-3 text-muted-foreground animate-spin"}),e.jsxs("span",{className:"text-muted-foreground/70 tabular-nums",children:[n.toFixed(1),"s"]})]}),u&&e.jsx(ht,{className:"h-3 w-3 text-green-500"}),m&&e.jsx(rt,{className:"h-3 w-3 text-destructive"}),!c&&e.jsx(ce,{className:`h-3 w-3 text-muted-foreground/70 transition-transform duration-200 ${s?"rotate-180":""}`})]}),p&&e.jsx("span",{className:`text-paragraph-sm pl-4.5 ${m?"text-destructive/70":"text-muted-foreground/70"}`,children:p})]}),s&&!c&&e.jsxs("div",{className:"mt-2 text-sm border border-border rounded-lg bg-card overflow-hidden w-full",children:[e.jsxs("div",{className:"p-3 border-b border-border",children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Hook Details"}),e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Type:"}),e.jsx("span",{className:"text-foreground font-mono",children:t.hookType})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Callback:"}),e.jsx("span",{className:"text-foreground font-mono",children:t.callback})]}),t.threshold!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Threshold:"}),e.jsxs("span",{className:"text-foreground",children:[t.threshold,"%"]})]}),t.currentPercentage!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Context Usage:"}),e.jsxs("span",{className:"text-foreground",children:[t.currentPercentage.toFixed(1),"%"]})]})]})]}),t.metadata&&e.jsxs("div",{className:"p-3 border-b border-border last:border-0",children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Result"}),e.jsxs("div",{className:"space-y-1 text-[11px]",children:[t.metadata.action&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Action:"}),e.jsx("span",{className:"text-foreground",children:t.metadata.action})]}),t.metadata.messagesRemoved!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Messages Removed:"}),e.jsx("span",{className:"text-foreground",children:Re(t.metadata.messagesRemoved)})]}),t.metadata.tokensSaved!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens Saved:"}),e.jsx("span",{className:"text-green-500 font-medium",children:Re(t.metadata.tokensSaved)})]}),t.metadata.originalTokens!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Original Size:"}),e.jsxs("span",{className:"text-foreground",children:[Re(t.metadata.originalTokens)," ","tokens"]})]}),t.metadata.finalTokens!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Final Size:"}),e.jsxs("span",{className:"text-foreground",children:[Re(t.metadata.finalTokens)," tokens"]})]})]})]}),g&&e.jsxs("div",{className:"p-3 border-b border-border last:border-0 bg-yellow-500/5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-yellow-600 dark:text-yellow-500 uppercase tracking-wider mb-1.5 font-sans",children:[e.jsx(Oa,{className:"h-3 w-3"}),"Warning"]}),e.jsx("div",{className:"text-[11px] text-yellow-700 dark:text-yellow-400",children:g})]}),t.error&&e.jsxs("div",{className:"p-3 border-b border-border last:border-0",children:[e.jsx("div",{className:"text-[10px] font-bold text-destructive uppercase tracking-wider mb-1.5 font-sans",children:"Error"}),e.jsx("div",{className:"text-[11px] text-destructive font-mono",children:t.error})]}),e.jsx("div",{className:"p-2 bg-muted/50 border-t border-border text-[10px] text-muted-foreground font-sans",children:t.triggeredAt&&e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsxs("span",{children:["Started:"," ",new Date(t.triggeredAt).toLocaleTimeString()]}),t.completedAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"-"}),e.jsxs("span",{children:["Completed:"," ",new Date(t.completedAt).toLocaleTimeString()]}),e.jsx("span",{children:"-"}),e.jsxs("span",{children:["Duration:"," ",zi((t.completedAt-t.triggeredAt)/1e3)]})]})]})})]})]})}const $i=i.forwardRef(({className:t,...s},a)=>e.jsx(Cs,{ref:a,className:b("text-label font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));$i.displayName=Cs.displayName;function Tt({content:t,className:s}){if(!t)return null;const a={table:({node:n,...o})=>e.jsx("div",{className:"overflow-x-auto my-4",children:e.jsx("table",{className:"min-w-full border-collapse border border-border rounded-md",...o})}),thead:({node:n,...o})=>e.jsx("thead",{className:"bg-card border-b border-border",...o}),tbody:({node:n,...o})=>e.jsx("tbody",{...o}),tr:({node:n,...o})=>e.jsx("tr",{className:"border-b border-border hover:bg-card transition-colors",...o}),th:({node:n,...o})=>e.jsx("th",{className:"px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",...o}),td:({node:n,...o})=>e.jsx("td",{className:"px-4 py-2 text-foreground border-r border-border last:border-r-0",...o}),input:({node:n,checked:o,...l})=>l.type==="checkbox"?e.jsx("input",{type:"checkbox",checked:o||!1,disabled:!0,readOnly:!0,className:"mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",...l}):e.jsx("input",{...l}),code:({node:n,...o})=>o.className?.includes("language-")?e.jsx("code",{className:"block p-4 bg-card border border-border rounded-md overflow-x-auto text-code text-foreground",...o}):e.jsx("code",{className:"px-1.5 py-0.5 bg-card border border-border rounded text-code text-foreground",...o}),pre:({node:n,...o})=>e.jsx("pre",{className:"my-4",...o}),h1:({node:n,...o})=>e.jsx("h1",{className:"text-heading-3 mt-6 mb-4 text-foreground",...o}),h2:({node:n,...o})=>e.jsx("h2",{className:"text-subheading mt-5 mb-3 text-foreground",...o}),h3:({node:n,...o})=>e.jsx("h3",{className:"text-subheading mt-4 mb-2 text-foreground",...o}),ul:({node:n,...o})=>{const l=n?.children?.some(r=>typeof r=="object"&&r!==null&&"type"in r&&r.type==="element"&&"tagName"in r&&r.tagName==="li"&&"children"in r&&Array.isArray(r.children)&&r.children.some(c=>typeof c=="object"&&c!==null&&"type"in c&&c.type==="element"&&"tagName"in c&&c.tagName==="input"&&"properties"in c&&typeof c.properties=="object"&&c.properties!==null&&"type"in c.properties&&c.properties.type==="checkbox"));return e.jsx("ul",{className:b("my-2 space-y-1 text-foreground",l?"list-none space-y-2":"list-disc list-inside"),...o})},ol:({node:n,...o})=>e.jsx("ol",{className:"list-decimal list-inside my-2 space-y-1 text-foreground",...o}),li:({node:n,...o})=>{const l=n?.children?.some(r=>typeof r=="object"&&r!==null&&"type"in r&&r.type==="element"&&"tagName"in r&&r.tagName==="input"&&"properties"in r&&typeof r.properties=="object"&&r.properties!==null&&"type"in r.properties&&r.properties.type==="checkbox");return e.jsx("li",{className:b("flex items-start",l?"gap-2":"ml-2"),...o})},a:({node:n,...o})=>e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...o}),p:({node:n,...o})=>e.jsx("p",{className:"my-2 text-foreground leading-relaxed",...o}),blockquote:({node:n,...o})=>e.jsx("blockquote",{className:"border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2",...o})};return e.jsx("div",{className:b("markdown-content prose prose-sm max-w-none dark:prose-invert",s),children:e.jsx(ta,{remarkPlugins:[Ls],components:a,children:t})})}const Li=je("flex animate-fadeIn",{variants:{role:{user:"max-w-[80%] self-end ml-auto mr-2",assistant:"self-start mr-auto",system:"self-start mr-auto max-w-full"},layout:{default:"",full:"max-w-full",compact:"max-w-[90%]"}},defaultVariants:{role:"assistant",layout:"default"}}),Bn=i.forwardRef(({message:t,role:s,layout:a,className:n,children:o,messageId:l,autoScroll:r,isLastMessage:c=!1,...u},m)=>{const d=t?t.role:s||"assistant",p=t?t.id:l,g=i.useRef(null),[h,x]=i.useState(void 0);return i.useImperativeHandle(m,()=>g.current),i.useEffect(()=>{if(!c||d!=="assistant"){x(void 0);return}const f=()=>{const C=g.current;if(!C)return;let v=C.parentElement;for(;v&&!v.classList.contains("overflow-y-auto");)v=v.parentElement;if(!v)return;const k=C.previousElementSibling;if(!k||k.getAttribute("aria-label")!=="user message"){x(void 0);return}const P=v.clientHeight,M=k.offsetHeight,S=Math.max(0,P-M-32);x(S)};f();const N=new ResizeObserver(f);if(g.current){N.observe(g.current);let C=g.current.parentElement;for(;C&&!C.classList.contains("overflow-y-auto");)C=C.parentElement;C&&N.observe(C)}return()=>N.disconnect()},[c,d]),i.useEffect(()=>{if((r!==void 0?r:d==="user")&&g.current){const N=setTimeout(()=>{g.current?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},50);return()=>clearTimeout(N)}},[d,r]),e.jsx("article",{ref:g,"aria-label":`${d} message`,"data-message-id":p,className:b(Li({role:d,layout:a}),n),style:{minHeight:h!==void 0?`${h}px`:void 0},...u,children:o})});Bn.displayName="Message";const Oi=[{id:"pdf",label:"PDF",icon:$e},{id:"excel",label:"Excel",icon:Yt},{id:"csv",label:"CSV",icon:Yt},{id:"text",label:"Text",icon:Ha},{id:"markdown",label:"Markdown",icon:$e}];function Fi({message:t,isStreaming:s,onRedo:a,onSendMessage:n,isLastAssistantMessage:o=!1}){const[l,r]=i.useState(!1);if(s||t.role!=="assistant"||!t.content)return null;const c=o?"":"opacity-0 group-hover:opacity-100 transition-opacity",u=async()=>{if(!t.content){Ce.error("There's no text to copy!");return}try{await navigator.clipboard.writeText(t.content),r(!0),Ce.success("Copied to clipboard!"),setTimeout(()=>{r(!1)},2e3)}catch{Ce.error("Failed to copy to clipboard")}},m=()=>{a?a():Ce.info("Regenerate not available")},d=p=>{n?n(`produce an artifact as ${p} for this session`):Ce.info("Export not available")};return e.jsxs(Gs,{className:b("mt-2 mb-10",c),children:[e.jsx(it,{onClick:u,tooltip:l?"Copied!":"Copy",children:l?e.jsx(pt,{className:"size-4"}):e.jsx($s,{className:"size-4"})}),e.jsx(it,{onClick:m,tooltip:"Redo",children:e.jsx(Fa,{className:"size-4"})}),e.jsxs(Xe,{children:[e.jsx(fe,{children:e.jsxs(ge,{children:[e.jsx(he,{asChild:!0,children:e.jsx(Je,{asChild:!0,children:e.jsxs(ne,{className:b("relative size-7 p-1.5 text-muted-foreground hover:text-foreground"),size:"sm",type:"button",variant:"ghost",children:[e.jsx(Ba,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Export"})]})})}),e.jsx(de,{children:e.jsx("p",{children:"Export"})})]})}),e.jsx(Le,{align:"start",children:Oi.map(p=>e.jsxs(pe,{onClick:()=>d(p.label),children:[e.jsx(p.icon,{className:"size-4 mr-2"}),p.label]},p.id))})]})]})}const Bi=i.memo(Fi,(t,s)=>!(t.isStreaming!==s.isStreaming||t.message.id!==s.message.id||t.message.content!==s.message.content||t.onRedo!==s.onRedo||t.onSendMessage!==s.onSendMessage||t.isLastAssistantMessage!==s.isLastAssistantMessage)),Hi={Read:{active:"Reading {file}",past:"Read {file}",paramKey:"file_path"},Write:{active:"Writing {file}",past:"Wrote {file}",paramKey:"file_path"},Grep:{active:"Searching for {query}",past:"Searched for {query}",paramKey:"pattern"},WebSearch:{active:"Searching the web for {query}",past:"Searched the web for {query}",paramKey:"query"},WebFetch:{active:"Fetching {url}",past:"Fetched {url}",paramKey:"url"},read_file:{active:"Reading {file}",past:"Read {file}",paramKey:"target_file"},write:{active:"Writing {file}",past:"Wrote {file}",paramKey:"file_path"},grep:{active:"Searching for {query}",past:"Searched for {query}",paramKey:"pattern"},web_search:{active:"Searching the web for {query}",past:"Searched the web for {query}",paramKey:"search_term"},search_replace:{active:"Editing {file}",past:"Edited {file}",paramKey:"file_path"},delete_file:{active:"Deleting {file}",past:"Deleted {file}",paramKey:"target_file"},codebase_search:{active:"Searching codebase for {query}",past:"Searched codebase for {query}",paramKey:"query"},glob_file_search:{active:"Finding files matching {pattern}",past:"Found files matching {pattern}",paramKey:"glob_pattern"},run_terminal_cmd:{active:"Running {command}",past:"Ran {command}",paramKey:"command"},list_dir:{active:"Listing {directory}",past:"Listed {directory}",paramKey:"target_directory"},edit_notebook:{active:"Editing notebook",past:"Edited notebook"},read_lints:{active:"Reading linter errors",past:"Read linter errors"},todo_write:{active:"Updating to-do's",past:"Updated to-do's"}};function Wi(t,s){if(!s||!t.rawInput)return null;const a=t.rawInput[s];return typeof a=="string"?a:null}function Vi(t,s){let a=t;for(const[n,o]of Object.entries(s))a=a.replace(`{${n}}`,o);return a}function qi(t,s){return t.length<=s?t:`${t.substring(0,s-1)}…`}function lt(t,s){const a=t.verbiage||Hi[t.title];if(!a){const o=t.prettyName||t.title;return s==="active"?`Using ${o}`:`Used ${o}`}const n=s==="active"?a.active:a.past;if(a.paramKey){const o=Wi(t,a.paramKey);if(o){const l=qi(o,50);let r="value";return a.paramKey.includes("file")||a.paramKey.includes("path")?r="file":a.paramKey.includes("query")||a.paramKey.includes("pattern")?r="query":a.paramKey.includes("command")?r="command":a.paramKey.includes("directory")&&(r="directory"),Vi(n,{[r]:l})}}if(t.subline){const o=n.split("{")[0];return o?`${o.trim()} ${t.subline}`:t.subline}return n.replace(/\s*\{[^}]+\}/g,"")}function Ki(t){return t.prettyName||t.title}function ze(t){return t.status==="pending"&&(!t.rawInput||Object.keys(t.rawInput).length===0)}function vt(t){return t.status==="failed"||t.error?"failed":t.status==="completed"?"completed":ze(t)?"selecting":(t.status==="pending"||t.status==="in_progress","executing")}function Hn(t){switch(vt(t)){case"selecting":return`Selecting ${t.prettyName||t.title}`;case"executing":return lt(t,"active");case"completed":return lt(t,"past");case"failed":return`Failed to use ${t.prettyName||t.title}`;default:return t.prettyName||t.title}}function Yi(t){return t.every(s=>vt(s)==="completed")}function Gi(t){return t.some(s=>vt(s)==="failed")}function Qi(t){return Gi(t)?"failed":Yi(t)?"completed":t.every(s=>ze(s))?"selecting":"executing"}const is=je("mb-3 rounded-lg bg-card border border-border transition-all",{variants:{variant:{default:"opacity-70",subtle:"opacity-50",prominent:"opacity-90 shadow-sm"}},defaultVariants:{variant:"default"}}),Xi=je("w-4 h-4 text-foreground opacity-60 transition-transform duration-200",{variants:{expanded:{true:"rotate-180",false:""}},defaultVariants:{expanded:!1}}),Wn=i.forwardRef(({content:t,isStreaming:s=!1,mode:a="collapsible",defaultExpanded:n=!1,autoExpand:o=!1,autoCollapse:l=!0,autoCollapseDelay:r=2e3,label:c="Thinking",variant:u,className:m},d)=>{const[p,g]=i.useState(a==="inline"?!0:n),[h,x]=i.useState(!1);return i.useEffect(()=>{if(l&&!s&&t&&a==="collapsible"){const f=setTimeout(()=>{x(!0),g(!1)},r);return()=>clearTimeout(f)}},[s,t,l,r,a]),i.useEffect(()=>{o&&s&&a==="collapsible"&&!h&&g(!0)},[o,s,a,h]),!t&&!s?null:a==="inline"?e.jsxs("div",{ref:d,className:b(is({variant:u}),"p-3",m),children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:"text-caption font-medium text-foreground opacity-60 uppercase tracking-wide",children:c}),s&&e.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse"})]}),e.jsxs("div",{className:"text-paragraph-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[t,s&&t&&e.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})]}):e.jsxs("div",{ref:d,className:b("mb-3",m),children:[e.jsxs("button",{type:"button",onClick:()=>{g(!p),x(!1)},className:"w-full flex items-center justify-between p-2.5 rounded-lg bg-card border border-border hover:bg-card/80 hover:shadow-sm transition-all text-left","aria-expanded":p,"aria-label":`${p?"Collapse":"Expand"} reasoning`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-caption font-medium text-foreground opacity-60 uppercase tracking-wide shrink-0",children:c}),s&&e.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0"}),!p&&t&&e.jsxs("span",{className:"text-caption text-foreground opacity-50 truncate",children:[t.substring(0,60),t.length>60&&"..."]})]}),e.jsx(ce,{className:Xi({expanded:p}),"aria-hidden":"true"})]}),p&&e.jsx("div",{className:b(is({variant:u}),"mt-2 p-3 animate-fadeIn"),children:e.jsxs("div",{className:"text-paragraph-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[t,s&&t&&e.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})})]})});Wn.displayName="Reasoning";function Ji(){return t=>{ca(t,"text",(s,a,n)=>{if(!n||a===void 0)return;const o=/\[\[(\d+)\]\]|\[(\d+)\](?![:(])/g,l=s.value;if(!o.test(l))return;o.lastIndex=0;const r=[];let c=0,u;for(;(u=o.exec(l))!==null;){u.index>c&&r.push({type:"text",value:l.slice(c,u.index)});const m=u[1]??u[2]??"";r.push({type:"citation",data:{hName:"span",hProperties:{"data-citation-id":m,className:"citation-marker"}},sourceId:m}),c=u.index+u[0].length}c<l.length&&r.push({type:"text",value:l.slice(c)}),r.length>0&&n.children.splice(a,1,...r)})}}const De=i.memo(i.forwardRef(({content:t,isStreaming:s=!1,showEmpty:a=!0,emptyMessage:n="",sources:o=[],className:l,...r},c)=>{const u=i.useMemo(()=>[Ls,Ji],[]),m=i.useMemo(()=>({span:d=>{const{className:p,class:g,"data-citation-id":h,children:x,...f}=d,N=p||g;return N==="citation-marker"&&h?e.jsx(Ln,{sourceId:h,sources:o}):e.jsx("span",{className:N,...f,children:x})}}),[o]);return!t&&s&&a?e.jsx("div",{ref:c,className:b("opacity-70 italic text-paragraph-sm",l),...r,children:n}):t?e.jsx("div",{ref:c,...r,children:e.jsx(da,{className:b("size-full","[&>*:first-child]:mt-0 [&>*:last-child]:mb-0","[&_code]:whitespace-pre-wrap [&_code]:break-words","[&_pre]:max-w-full [&_pre]:overflow-x-auto",l),remarkPlugins:u,components:m,children:t})}):null}),(t,s)=>t.content===s.content&&t.sources===s.sources);De.displayName="Response";function Zi(t){if(!t.rawInput)return null;const s=["query","search_term","pattern","target_file","file_path","command","target_directory"];for(const a of s){const n=t.rawInput[a];if(typeof n=="string"&&n.trim())return n.trim()}return t.subline?t.subline:null}function _t(t,s=3){if(t.length===0)return"";if(t.length===1)return t[0];if(t.length<=s)return`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`;const a=t.slice(0,s),n=t.length-s;return`${a.join(", ")} and ${n} more`}function el(t){if(t.length===0)return null;const s=t[0],a=s.lastIndexOf("/");if(a===-1)return null;const n=s.substring(0,a);return t.every(l=>l.startsWith(`${n}/`))?n:null}function tl(t,s){if(t.length===0)return"";if(t.length===1)return lt(t[0],s);const a=t[0],n=a.title,o=t.map(Zi).filter(m=>m!==null);if((n==="Read"||n==="Write"||n==="read_file"||n==="write"||n==="search_replace"||n==="delete_file")&&o.length>0){const m=el(o);if(m){const p=s==="active"?"working on":"worked on";return`${p.charAt(0).toUpperCase()+p.slice(1)} ${o.length} files in ${m}`}return`${n==="Read"||n==="read_file"?s==="active"?"Reading":"Read":n==="Write"||n==="write"?s==="active"?"Writing":"Wrote":n==="search_replace"?s==="active"?"Editing":"Edited":s==="active"?"Deleting":"Deleted"} ${_t(o)}`}if((n==="WebSearch"||n==="Grep"||n==="web_search"||n==="codebase_search"||n==="grep")&&o.length>0)return`${n==="WebSearch"||n==="web_search"?s==="active"?"Searching the web for":"Searched the web for":n==="codebase_search"?s==="active"?"Searching codebase for":"Searched codebase for":s==="active"?"Searching for":"Searched for"} ${_t(o)}`;const c=Ki(a);return`${s==="active"?"Using":"Used"} ${c} ${t.length} times`}function sl(t,s){if(t.length===0)return"";if(t.length===1)return lt(t[0],s);if([...new Set(t.map(l=>l.title))].length===1)return tl(t,s);const n=t.map(l=>l.prettyName||l.title).filter((l,r,c)=>c.indexOf(l)===r);return`${s==="active"?"Running":"Ran"} ${_t(n)}`}const nl=50;function Vn({port:t,sessionId:s,host:a,parentStatus:n,agentName:o,query:l,isExpanded:r,onExpandChange:c,storedMessages:u,isReplay:m=!1}){const[d,p]=i.useState(!1),g=r??d,[h,x]=i.useState(!0),[f,N]=i.useState(!0),C=i.useRef(null),v=!m&&t!==void 0&&s!==void 0,k=i.useMemo(()=>v?{port:t,sessionId:s,...a!==void 0?{host:a}:{}}:null,[v,t,s,a]),{messages:P,isStreaming:M,error:A}=Wo(k),S=u&&u.length>0?u:P,I=m?!1:n==="in_progress"||n==="pending"||M,$=S[S.length-1],B=$&&($.content||$.toolCalls&&$.toolCalls.length>0||$.contentBlocks&&$.contentBlocks.length>0),W=i.useRef(I);i.useEffect(()=>{W.current&&!I&&x(!1),W.current=I},[I]);const K=i.useCallback(()=>{const j=C.current;if(!j)return;const{scrollTop:y,scrollHeight:R,clientHeight:_}=j,q=R-y-_;N(q<nl)},[]),D=i.useCallback(()=>{const j=C.current;j&&(j.scrollTop=j.scrollHeight)},[]);i.useEffect(()=>{f&&(I||B)&&D()},[f,I,B,D]),i.useEffect(()=>{const j=C.current;if(!j)return;const y=()=>K();return j.addEventListener("scroll",y,{passive:!0}),K(),()=>j.removeEventListener("scroll",y)},[K]),i.useEffect(()=>{h&&(N(!0),requestAnimationFrame(()=>{D()}))},[h,D]);const z=$?.content&&$.content.split(`
|
|
10
10
|
`).filter(Boolean).pop()||"",T=z.length>100?`${z.slice(0,100)}...`:z,E=l?(l.split(`
|
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Agent Chat</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DTx1YyU-.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/katex-Dnem94XJ.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/markdown-DPvuyxRv.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/icons-B8NAg8v6.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@townco/gui-template",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"check": "tsgo --noEmit"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@townco/core": "0.0.
|
|
23
|
-
"@townco/ui": "0.1.
|
|
22
|
+
"@townco/core": "0.0.80",
|
|
23
|
+
"@townco/ui": "0.1.102",
|
|
24
24
|
"lucide-react": "^0.552.0",
|
|
25
25
|
"react": "19.2.1",
|
|
26
26
|
"react-dom": "19.2.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@tailwindcss/postcss": "^4.1.17",
|
|
30
|
-
"@townco/tsconfig": "0.1.
|
|
30
|
+
"@townco/tsconfig": "0.1.99",
|
|
31
31
|
"@types/react": "^19.2.2",
|
|
32
32
|
"@types/react-dom": "^19.2.2",
|
|
33
33
|
"@vitejs/plugin-react": "^5.1.0",
|