@miiflow/assistant-ui 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes, ReactNode } from 'react';
3
- import { A as Attachment, M as MessageData, b as ParticipantRole, d as SuggestedAction, S as SourceReference } from './message-D2ElX5k7.js';
4
- import { a as AvatarProps$1 } from './avatar-DnLePg72.js';
5
- import { k as StreamingChunk, u as VisualizationChunkData, M as MediaChunkData, A as ArtifactChunkData, d as ClarificationData, s as ToolApprovalData } from './streaming-B_u_jno6.js';
6
- import { c as CommandProvider } from './types-DeHbndy0.js';
7
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { A as Attachment, M as MessageData, P as ParticipantRole, d as SuggestedAction, S as SourceReference } from './message-D0oMw3tR.js';
4
+ import { h as AvatarProps$1 } from './avatar-CD685KQV.js';
5
+ import { S as StreamingChunk, V as VisualizationChunkData, M as MediaChunkData, A as ArtifactChunkData, C as ClarificationData, T as ToolApprovalData } from './streaming-CmQo_OOA.js';
6
+ import { C as CommandProvider } from './types-Du00UBst.js';
8
7
 
9
8
  interface AttachmentPreviewProps {
10
9
  /** The attachment to preview */
@@ -54,7 +53,7 @@ interface MarkdownContentProps {
54
53
  * Styled markdown renderer with syntax highlighting, copy-to-clipboard,
55
54
  * and heading anchor links.
56
55
  */
57
- declare function MarkdownContent({ children, className, baselineFontSize, darkCodeTheme, }: MarkdownContentProps): react_jsx_runtime.JSX.Element;
56
+ declare function MarkdownContent({ children, className, baselineFontSize, darkCodeTheme, }: MarkdownContentProps): react.JSX.Element;
58
57
 
59
58
  interface MessageProps {
60
59
  /** The message data */
@@ -248,7 +247,7 @@ interface MessageActionBarProps {
248
247
  * Action bar that appears on hover below assistant message bubbles.
249
248
  * Currently implements Copy; onRegenerate and onEdit are reserved for future use.
250
249
  */
251
- declare function MessageActionBar({ textContent, onRegenerate, onEdit, onReportIncorrect, onConfirmCorrect, className, }: MessageActionBarProps): react_jsx_runtime.JSX.Element;
250
+ declare function MessageActionBar({ textContent, onRegenerate, onEdit, onReportIncorrect, onConfirmCorrect, className, }: MessageActionBarProps): react.JSX.Element;
252
251
 
253
252
  interface ScrollToBottomButtonProps {
254
253
  /** Whether the viewport is at the bottom (hides button when true) */
@@ -263,7 +262,7 @@ interface ScrollToBottomButtonProps {
263
262
  * allowing them to quickly jump back to the latest messages.
264
263
  * Fades in/out based on scroll position.
265
264
  */
266
- declare function ScrollToBottomButton({ isAtBottom, onScrollToBottom, className, }: ScrollToBottomButtonProps): react_jsx_runtime.JSX.Element;
265
+ declare function ScrollToBottomButton({ isAtBottom, onScrollToBottom, className, }: ScrollToBottomButtonProps): react.JSX.Element;
267
266
 
268
267
  type ToolStatus = "running" | "complete" | "failed" | "pending";
269
268
  interface ToolStatusIndicatorProps {
@@ -281,7 +280,7 @@ interface ToolStatusIndicatorProps {
281
280
  * Shows tool name + status icon (spinner/check/X/clock).
282
281
  * Running state includes a subtle shimmer animation.
283
282
  */
284
- declare function ToolStatusIndicator({ toolName, status, description, className, }: ToolStatusIndicatorProps): react_jsx_runtime.JSX.Element;
283
+ declare function ToolStatusIndicator({ toolName, status, description, className, }: ToolStatusIndicatorProps): react.JSX.Element;
285
284
 
286
285
  interface ChatLayoutProps {
287
286
  /** Whether the chat is in empty state (no messages) */
@@ -344,4 +343,4 @@ interface WelcomeScreenProps {
344
343
  */
345
344
  declare const WelcomeScreen: react.ForwardRefExoticComponent<WelcomeScreenProps & react.RefAttributes<HTMLDivElement>>;
346
345
 
347
- export { AttachmentPreview as A, ChatContainer as C, MarkdownContent as M, ScrollToBottomButton as S, type ToolStatus as T, WelcomeScreen as W, type AttachmentPreviewProps as a, Avatar as b, type AvatarProps as c, type ChatContainerProps as d, ChatLayout as e, type ChatLayoutProps as f, type MarkdownContentProps as g, Message as h, MessageActionBar as i, type MessageActionBarProps as j, MessageComposer as k, type MessageComposerProps as l, MessageList as m, type MessageListProps as n, type MessageProps as o, type ScrollToBottomButtonProps as p, StreamingText as q, type StreamingTextProps as r, SuggestedActions as s, type SuggestedActionsProps as t, ToolStatusIndicator as u, type ToolStatusIndicatorProps as v, TypingIndicator as w, type TypingIndicatorProps as x, type WelcomeScreenProps as y };
346
+ export { AttachmentPreview as A, ChatContainer as C, MarkdownContent as M, ScrollToBottomButton as S, ToolStatusIndicator as T, WelcomeScreen as W, Avatar as a, ChatLayout as b, Message as c, MessageActionBar as d, MessageComposer as e, MessageList as f, StreamingText as g, SuggestedActions as h, TypingIndicator as i, type AttachmentPreviewProps as j, type AvatarProps as k, type ChatContainerProps as l, type ChatLayoutProps as m, type MarkdownContentProps as n, type MessageActionBarProps as o, type MessageComposerProps as p, type MessageListProps as q, type MessageProps as r, type ScrollToBottomButtonProps as s, type StreamingTextProps as t, type SuggestedActionsProps as u, type ToolStatus as v, type ToolStatusIndicatorProps as w, type TypingIndicatorProps as x, type WelcomeScreenProps as y };
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes, ReactNode, TextareaHTMLAttributes, ButtonHTMLAttributes } from 'react';
3
- import { M as MessageData, b as ParticipantRole } from './message-D2ElX5k7.js';
3
+ import { M as MessageData, P as ParticipantRole } from './message-D0oMw3tR.js';
4
4
 
5
5
  interface MessageContextValue {
6
6
  message: MessageData;
@@ -106,4 +106,4 @@ interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
106
106
  */
107
107
  declare const Avatar: react.ForwardRefExoticComponent<AvatarProps & react.RefAttributes<HTMLDivElement>>;
108
108
 
109
- export { Avatar as A, ComposerContext as C, Message as M, type AvatarProps as a, ComposerInput as b, type ComposerInputProps as c, ComposerSubmit as d, type ComposerSubmitProps as e, MessageComposer as f, type MessageComposerProps as g, MessageContent as h, type MessageContentProps as i, MessageContext as j, type MessageProps as k, MessageTimestamp as l, type MessageTimestampProps as m, useMessage as n, useComposer as u };
109
+ export { Avatar as A, ComposerContext as C, MessageComposer as M, ComposerInput as a, ComposerSubmit as b, MessageContent as c, MessageContext as d, Message as e, MessageTimestamp as f, useMessage as g, type AvatarProps as h, type ComposerInputProps as i, type ComposerSubmitProps as j, type MessageComposerProps as k, type MessageContentProps as l, type MessageProps as m, type MessageTimestampProps as n, useComposer as u };
@@ -0,0 +1,133 @@
1
+ import {l,m,c,d,r}from'./chunk-6RN7SUWT.js';import {a as a$3}from'./chunk-D2PFIJNZ.js';import {a as a$2}from'./chunk-4WWJTYYA.js';import {a as a$1}from'./chunk-NKLA5PPB.js';import {b}from'./chunk-NG4HKXYB.js';import {a,i,g,b as b$1}from'./chunk-ZP4FGAAH.js';import {forwardRef,useState,useContext,useMemo,useRef,useCallback,useEffect,Children,Fragment as Fragment$1,isValidElement,cloneElement}from'react';import {X,Zap,ExternalLink,Search,Mail,Copy,Navigation,Send,Loader2,Square,ArrowUp,Image,FileText,File,User,Bot,Link,ArrowRight,AlertCircle,Check,ChevronDown,HelpCircle,ChevronLeft,ChevronRight,Plus,Download,Video,FileIcon,ChevronUp,MoreVertical,ArrowDown,Minus}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import Or from'react-markdown';import Wr from'remark-gfm';import {Prism}from'react-syntax-highlighter';import {oneLight,oneDark}from'react-syntax-highlighter/dist/esm/styles/prism';import {createPortal}from'react-dom';import {AnimatePresence,motion}from'framer-motion';import {ResponsiveContainer,ScatterChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Scatter,PieChart,Pie,Cell,AreaChart,Area,BarChart,Bar,LineChart,Line}from'recharts';import {z}from'zod';function kr(e){return e.startsWith("image/")?Image:e==="application/pdf"||e.startsWith("text/")?FileText:File}function wr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var Qa=forwardRef(({attachment:e,onRemove:t,removable:a$1=true,className:n},r)=>{let i=kr(e.mimeType),s=e.mimeType.startsWith("image/");return jsxs("div",{ref:r,className:a("relative group","flex items-center gap-2","p-2 rounded-lg","border border-chat-border","bg-chat-panel-bg",n),children:[jsx("div",{className:a("w-10 h-10 rounded","flex items-center justify-center","bg-gray-100 dark:bg-gray-800","overflow-hidden flex-shrink-0"),children:s&&e.previewUrl?jsx("img",{src:e.previewUrl,alt:e.filename,className:"w-full h-full object-cover"}):jsx(i,{className:"w-5 h-5 text-chat-subtle"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("p",{className:"text-sm font-medium truncate text-chat-text",children:e.filename}),jsx("p",{className:"text-xs text-chat-subtle",children:wr(e.size)})]}),a$1&&t&&jsx("button",{type:"button",onClick:t,className:a("absolute -top-1.5 -right-1.5","w-5 h-5 rounded-full","flex items-center justify-center","bg-gray-500 text-white","opacity-0 group-hover:opacity-100","hover:bg-gray-600","transition-opacity duration-200"),"aria-label":`Remove ${e.filename}`,children:jsx(X,{className:"w-3 h-3"})})]})});Qa.displayName="AttachmentPreview";var Sr={sm:"w-6 h-6 text-xs",md:"w-8 h-8 text-sm",lg:"w-10 h-10 text-base"},Tr={sm:14,md:16,lg:20};function Pr(e,t){let a=Tr[t];switch(e){case "assistant":return jsx(Bot,{size:a});case "user":return jsx(User,{size:a});default:return jsx(User,{size:a})}}var Le=forwardRef(({name:e,src:t,alt:a$1,role:n,size:r="md",className:i,...s},o)=>jsx(l,{ref:o,name:e,src:t,alt:a$1,role:n,className:a("rounded-full overflow-hidden flex-shrink-0","flex items-center justify-center","font-medium",n==="assistant"?"bg-primary/10 text-primary":"bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300",Sr[r],i),fallback:Pr(n,r),...s}));Le.displayName="Avatar";var en=forwardRef(({children:e,className:t,...a$1},n)=>jsx("div",{ref:n,className:a("flex flex-col h-full","bg-white dark:bg-gray-900","font-sans text-chat-text",t),...a$1,children:e}));en.displayName="ChatContainer";var Mr=a("flex-shrink-0 rounded-lg flex items-center justify-center","text-[var(--chat-text-subtle,rgba(0,0,0,0.5))]","hover:bg-[var(--chat-panel-bg,rgba(0,0,0,0.02))] hover:text-[var(--chat-text,#1d2033)]","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-150");function Xe({onAttachClick:e,disabled:t,hint:a$1="Enter to send",showHint:n=true,endSlot:r,className:i}){return jsxs("div",{className:a("flex items-center gap-1 min-w-0",i),children:[e&&jsx("button",{type:"button",title:"Attach files","aria-label":"Attach files",onClick:e,disabled:t,className:a(Mr,"w-7 h-7"),children:jsx(Plus,{size:16})}),jsx("div",{className:"flex-1 min-w-0"}),n&&jsx("span",{className:a("hidden sm:block flex-shrink-0 mr-1.5 text-[11px] select-none","text-[var(--chat-placeholder,rgba(0,0,0,0.4))]","opacity-0 group-focus-within:opacity-100 transition-opacity duration-200"),children:a$1}),r]})}var Lr={small:"w-1.5 h-1.5",medium:"w-2 h-2",large:"w-2.5 h-2.5"},Ir={small:"gap-1",medium:"gap-1.5",large:"gap-2"};function Ze({size:e="medium",className:t}){let a$1=Lr[e];return jsxs("div",{className:a("flex items-center",Ir[e],t),children:[jsx("div",{className:a(a$1,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-1")}),jsx("div",{className:a(a$1,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-2")}),jsx("div",{className:a(a$1,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-3")})]})}var Xr=new Set(["mode","skill"]);function Zr(e,t){let a=g(e);if(a.length===0)return [e];let n=[],r=0;return a.forEach((i,s)=>{if(i.index>r&&n.push(e.slice(r,i.index)),Xr.has(i.kind)){r=i.endIndex,e[r]===" "&&(r+=1);return}let o=t?.(i.id,i.kind);n.push(jsx(b$1,{id:i.id,kind:i.kind,label:o?.label,tag:o?.tag,variant:"chip"},`tok-${s}`)),r=i.endIndex;}),r<e.length&&n.push(e.slice(r)),n}function je(e,t){return Children.map(e,(a,n)=>{if(typeof a=="string"){let r=Zr(a,t);return r.length===1&&r[0]===a?a:jsx(Fragment$1,{children:r},`text-${n}`)}if(isValidElement(a)){let r=a.type,i=typeof r=="string"?r:void 0;if(i==="code"||i==="pre")return a;let s=a.props.children;return s==null?a:cloneElement(a,void 0,je(s,t))}return a})}var Qr={js:"javascript",ts:"typescript",jsx:"jsx",tsx:"tsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",cs:"csharp",swift:"swift",kt:"kotlin",php:"php",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",shell:"bash",html:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",graphql:"graphql",dockerfile:"docker",toml:"toml"};function Jr(e){return Qr[e.toLowerCase()]||e.toLowerCase()}function Wt(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function eo({text:e}){let[t,a]=useState(false),n=useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3);}catch{}},[e]);return jsxs("button",{onClick:n,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-white/10 transition-colors text-gray-400 hover:text-gray-200","aria-label":t?"Copied":"Copy code",children:[t?jsx(Check,{size:14}):jsx(Copy,{size:14}),t?"Copied":"Copy"]})}function oe({children:e,className:t,baselineFontSize:a$2,darkCodeTheme:n}){let r=n??(typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches),i=a$2!=null?{fontSize:`${a$2}rem`}:void 0,s=useContext(a$1)?.resolveCommandToken;return jsx(Or,{className:a("chat-prose",t),remarkPlugins:[Wr],components:{h1:({children:o})=>{let c=String(o),d=Wt(c);return jsxs("h1",{id:d,className:"group text-xl font-semibold mt-4 mb-2 first:mt-0",style:i,children:[o,jsx("a",{href:`#${d}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:16,className:"inline"})})]})},h2:({children:o})=>{let c=String(o),d=Wt(c);return jsxs("h2",{id:d,className:"group text-lg font-semibold mt-3 mb-2 first:mt-0",style:i,children:[o,jsx("a",{href:`#${d}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:14,className:"inline"})})]})},h3:({children:o})=>{let c=String(o),d=Wt(c);return jsxs("h3",{id:d,className:"group text-base font-medium mt-2 mb-1 first:mt-0",style:i,children:[o,jsx("a",{href:`#${d}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:12,className:"inline"})})]})},h4:({children:o})=>jsx("h4",{className:"text-base font-medium mt-2 mb-1 first:mt-0",style:i,children:je(o,s)}),p:({children:o})=>jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",style:i,children:je(o,s)}),a:({href:o,children:c})=>o&&/\.(png|jpe?g|gif|webp|svg)([?#]|$)/i.test(o)?jsx("img",{src:o,alt:typeof c=="string"?c:"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"}):jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:opacity-80 transition-opacity",style:i,children:c}),ul:({children:o})=>jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:o}),ol:({children:o})=>jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:o}),li:({children:o})=>jsx("li",{className:"leading-relaxed",style:i,children:je(o,s)}),blockquote:({children:o})=>jsx("blockquote",{className:"border-l-2 border-gray-300 dark:border-gray-600 pl-3 my-2 italic text-chat-subtle",style:i,children:je(o,s)}),code:({className:o,children:c})=>{let d=/language-(\w+)/.exec(o||""),p=String(c).replace(/\n$/,"");if(!d&&!p.includes(`
2
+ `))return jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono",style:i,children:c});let y=d?Jr(d[1]):"text";return jsxs("div",{className:"relative group my-2 rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsx("span",{className:"text-xs font-mono text-gray-400",children:y}),jsx(eo,{text:p})]}),jsx(Prism,{language:y,style:r===false?oneLight:oneDark,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:p})]})},pre:({children:o})=>jsx(Fragment,{children:o}),table:({children:o})=>jsx("div",{className:"overflow-x-auto my-2 rounded-lg border border-gray-200 dark:border-gray-700",children:jsx("table",{className:"min-w-full",children:o})}),thead:({children:o})=>jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:o}),th:({children:o})=>jsx("th",{className:"px-3 py-2 text-left text-sm font-medium",style:i,children:je(o,s)}),td:({children:o})=>jsx("td",{className:"px-3 py-2 text-sm border-t border-gray-100 dark:border-gray-700",style:i,children:je(o,s)}),hr:()=>jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),strong:({children:o})=>jsx("strong",{className:"font-semibold",children:o}),em:({children:o})=>jsx("em",{className:"italic",children:o}),img:({src:o,alt:c})=>jsx("img",{src:o,alt:c??"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"})},children:e})}var Ae=/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([A-Za-z0-9_-]{11})/,oo=e=>{let t=e.match(Ae);return t?t[1]:null};function Ut(e,t,a){if(typeof e=="string"){let n=e.trim();if(!n)return null;if(n.startsWith("media_ref:")&&a&&a.length>0){let s=n.slice(10),o=a.find(c=>c.id===s);return o?{id:o.id,url:o.url,mediaType:o.mediaType||(Ae.test(o.url)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(o.url)?"video":"image"),altText:o.altText}:null}let r=n,i=Ae.test(r)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(r);return {id:t,url:r,mediaType:i?"video":"image"}}if(e&&typeof e=="object"){let n=e,r=n.url||n.image_url||n.video_url;if(!r||typeof r!="string")return null;let i=n.media_type||n.mediaType||n.type,s=n.alt||n.alt_text||n.altText;return {id:n.id||t,url:r,mediaType:i||(Ae.test(r)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(r)?"video":"image"),altText:s}}return null}var Ke=({label:e})=>jsx("div",{className:a("absolute inset-0 flex cursor-pointer items-center justify-center","bg-black/20 transition-colors hover:bg-black/35"),"aria-label":e,children:jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-black/55 shadow-lg",children:jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"white","aria-hidden":"true",children:jsx("path",{d:"M8 5v14l11-7z"})})})});function gt({items:e,index:t,onClose:a$1,onNavigate:n}){let r=e[t];if(useEffect(()=>{let c=p=>{p.key==="Escape"?a$1():p.key==="ArrowLeft"?n(-1):p.key==="ArrowRight"&&n(1);};window.addEventListener("keydown",c);let d=typeof document<"u"?document.body.style.overflow:"";return typeof document<"u"&&(document.body.style.overflow="hidden"),()=>{window.removeEventListener("keydown",c),typeof document<"u"&&(document.body.style.overflow=d);}},[a$1,n]),!r||typeof document>"u")return null;let i=r.mediaType==="video"?oo(r.url):null,s=e.length>1,o=jsxs("div",{className:a("fixed inset-0 z-[9999] flex items-center justify-center","bg-black/85 backdrop-blur-sm"),role:"dialog","aria-modal":"true","aria-label":"Media viewer",onClick:a$1,children:[jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),a$1();},className:a("absolute right-4 top-4 z-10 flex h-10 w-10 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Close",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})}),s&&jsxs("div",{className:"absolute left-4 top-4 z-10 rounded-full bg-white/10 px-3 py-1 text-sm text-white",onClick:c=>c.stopPropagation(),children:[t+1," / ",e.length]}),s&&jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),n(-1);},className:a("absolute left-4 z-10 flex h-12 w-12 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Previous",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),s&&jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),n(1);},className:a("absolute right-4 z-10 flex h-12 w-12 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Next",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),jsxs("div",{className:"flex max-h-[90vh] max-w-[90vw] flex-col items-center",onClick:c=>c.stopPropagation(),children:[r.mediaType==="video"&&i?jsx("div",{className:"relative overflow-hidden rounded-lg bg-black",style:{width:"min(90vw, 1024px)",aspectRatio:"16 / 9"},children:jsx("iframe",{src:`https://www.youtube.com/embed/${i}?autoplay=1`,title:r.altText||"Video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:true,className:"absolute inset-0 h-full w-full border-0"})}):r.mediaType==="video"?jsxs("video",{controls:true,autoPlay:true,preload:"metadata",className:"block max-h-[85vh] max-w-[90vw] rounded-lg",children:[jsx("source",{src:r.url}),"Your browser does not support the video tag."]}):jsx("img",{src:r.url,alt:r.altText||"Image",className:"block max-h-[85vh] max-w-[90vw] rounded-lg object-contain"}),r.altText&&jsx("div",{className:"mt-2 max-w-[90vw] text-center text-sm text-white/80",children:r.altText})]})]});return createPortal(o,document.body)}function ht(e){let[t,a]=useState(null),n=useCallback(s=>a(s),[]),r=useCallback(()=>a(null),[]),i=useCallback(s=>{a(o=>o===null||e.length===0?o:(o+s+e.length)%e.length);},[e.length]);return {index:t,open:n,close:r,navigate:i}}function nn(e){switch(e){case "knowledge_base":return {label:"Knowledge Base",color:"#4caf50"};case "api":return {label:"API",color:"#2196f3"};case "system_tool":return {label:"Tool",color:"#ff9800"};case "mcp_tool":return {label:"MCP",color:"#9c27b0"};case "workflow":return {label:"Workflow",color:"#00bcd4"};case "memory":return {label:"Memory",color:"#e91e63"};default:return {label:"Source",color:"#757575"}}}function Yt({sources:e,className:t}){let[a$1,n]=useState(null),[r,i]=useState(false);if(!e||e.length===0)return null;let s=8,o=r?e:e.slice(0,s),c=e.length-s;return jsxs(Fragment,{children:[jsxs("div",{className:a("flex flex-wrap gap-1.5 mt-2",t),children:[o.map(d=>{let p=nn(d.source_type);return jsx("span",{className:"inline-flex items-center gap-0.5",children:jsxs("button",{onClick:()=>n(d),className:"inline-flex items-center h-6 px-2 text-[0.75rem] font-medium rounded-full border cursor-pointer transition-colors max-w-[280px] truncate",style:{backgroundColor:p.color+"1a",color:p.color,borderColor:p.color+"40"},children:["[",d.index,"] ",d.title]})},d.index)}),!r&&c>0&&jsxs("button",{onClick:()=>i(true),className:"inline-flex items-center h-6 px-2 text-[0.75rem] font-medium rounded-full border cursor-pointer transition-colors text-gray-500 border-gray-300 hover:bg-gray-50 dark:border-gray-600 dark:hover:bg-gray-800",children:["+",c," more"]})]}),jsx(rn,{source:a$1,onClose:()=>n(null)})]})}function rn({source:e,onClose:t}){if(useEffect(()=>{if(!e)return;let n=r=>{r.key==="Escape"&&t();};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t]),!e)return null;let a=nn(e.source_type);return jsx(AnimatePresence,{children:e&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/50",onClick:t}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.15},className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("h3",{className:"text-lg font-semibold truncate",children:e.title}),jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded font-medium shrink-0",style:{backgroundColor:a.color+"1a",color:a.color},children:a.label})]}),jsx("button",{onClick:t,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 ml-2",children:jsx(X,{size:16})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:e.tool_name.replace(/_/g," ")}),e.query&&jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded border border-gray-200 dark:border-gray-700 max-w-[200px] truncate",title:e.query,children:["Query: ",e.query.slice(0,40),e.query.length>40?"...":""]})]}),e.url&&jsx("div",{className:"mb-4",children:jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-500 hover:underline inline-flex items-center gap-1",children:[e.url.length>80?`${e.url.slice(0,80)}...`:e.url,jsx(ExternalLink,{size:12})]})}),e.description&&jsx("p",{className:"text-sm text-gray-500 mb-4",children:e.description}),e.full_content?jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 max-h-[400px] overflow-auto",children:e.full_content}):e.snippet?jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:e.snippet}):jsx("p",{className:"text-sm text-gray-400 italic",children:"No content available for this source."})]}),jsx("div",{className:"flex justify-end p-3 border-t border-gray-200 dark:border-gray-700",children:jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"Close"})})]})]})})}function po({index:e,source:t}){return jsx("span",{className:a("inline-flex items-center justify-center min-w-[16px] h-4 rounded-full","bg-blue-500 text-white text-[0.6rem] font-semibold","px-0.5 mx-0.5 align-super",t?.url?"cursor-pointer hover:opacity-85":"cursor-default"),title:t?`${t.title}${t.description?": "+t.description:""}`:void 0,onClick:a=>{t?.url&&(a.stopPropagation(),window.open(t.url,"_blank","noopener,noreferrer"));},children:e})}function vo(e){return e.questions&&e.questions.length>0?e.questions.map(t=>({question:t.question,options:t.options||[],multiSelect:t.multiSelect??t.multi_select,key:t.key})):e.question?[{question:e.question,options:e.options||[],multiSelect:false}]:[]}function ln(e,t){let a=(t||"").trim();return a?[...e,a]:e}function ko(e,t,a){return e.map((n,r)=>({key:n.key,question:n.question,selected:ln(t[r]||[],a[r])}))}function wo(e,t,a){return e.map((n,r)=>{let i=ln(t[r]||[],a[r]),s=i.length>0?i.join(", "):"(no answer)";return `${e.length>1?`${r+1}. `:""}${n.question}
3
+ \u2192 ${s}`}).join(`
4
+
5
+ `)}function Xt({clarification:e,onSubmit:t,onOptionSelect:a$1,disabled:n=false,loading:r=false,className:i,answer:s}){let o=useMemo(()=>vo(e),[e]),[c,d]=useState({}),[p,v]=useState({}),[y,P]=useState(0),b=typeof s=="string"&&s.length>0,h=useRef(null);useEffect(()=>()=>{h.current&&clearTimeout(h.current);},[]);let S=useCallback((w,u)=>{for(let C=w+1;C<o.length;C++)if((u[C]||[]).length===0){P(C);return}w+1<o.length&&P(w+1);},[o.length]),L=useCallback((w,u,C)=>{d($=>{let K=$[w]||[],G;C?G=K.includes(u)?K.filter(E=>E!==u):[...K,u]:G=[u],G.includes(u)&&a$1?.(u);let ce={...$,[w]:G};return C||(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>S(w,ce),250)),ce});},[a$1,S]),R=o.length>0&&o.every((w,u)=>(c[u]||[]).length>0||(p[u]||"").trim().length>0),N=useCallback(()=>{if(!t||!R)return;let w=wo(o,c,p),u=ko(o,c,p);d({}),v({}),P(0),t(w,u);},[t,R,o,c,p]);if(b)return jsx("div",{className:a("mx-4 mb-3 flex justify-end font-sans",i),children:jsxs("details",{className:"group max-w-[85%]",children:[jsxs("summary",{className:a("flex items-center justify-end gap-1.5 cursor-pointer select-none","text-xs text-gray-600 dark:text-gray-300","hover:text-gray-900 dark:hover:text-gray-100 transition-colors","list-none [&::-webkit-details-marker]:hidden"),children:[jsx(Check,{size:12,strokeWidth:2.75,className:"text-emerald-600 dark:text-emerald-500"}),jsx("span",{children:"Clarification answered"}),jsx(ChevronDown,{size:12,className:"text-gray-400 transition-transform group-open:rotate-180"})]}),jsx("div",{className:"mt-2 text-right",children:jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 whitespace-pre-wrap break-words text-left",children:s})})]})});if(o.length===0)return null;let T="var(--chat-clarification-accent,#f97316)",f=o.length>1,g=Math.min(y,o.length-1),A=w=>{let u=o[w],C=!!u.multiSelect,$=c[w]||[];return jsxs("div",{children:[jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[!e.context&&!f?jsx("span",{className:"text-[var(--chat-clarification-accent,#f97316)] mt-0.5 flex-shrink-0",children:jsx(HelpCircle,{size:14})}):null,jsx("div",{className:"flex-1 min-w-0",children:jsx(oe,{className:"text-sm font-medium",children:u.question})})]}),jsxs("div",{className:"ml-5 space-y-1",children:[u.options.map((K,G)=>{let ce=$.includes(K);return jsxs("label",{className:a("flex items-center gap-2 py-0.5 cursor-pointer text-sm rounded px-1 -mx-1","hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)]"),children:[jsx("input",{type:C?"checkbox":"radio",name:`clarification-q${w}`,value:K,checked:ce,onChange:()=>L(w,K,C),disabled:n||r,className:"w-3.5 h-3.5",style:{accentColor:T}}),K]},G)}),jsxs("div",{className:"flex items-center gap-2 py-0.5 px-1 -mx-1 text-sm",children:[jsx("span",{className:"flex-shrink-0 text-gray-500 dark:text-gray-400",children:"Other:"}),jsx("input",{type:"text",value:p[w]||"",placeholder:$.length>0?"Add anything else\u2026 (optional)":"Or type your own answer\u2026",onChange:K=>v(G=>({...G,[w]:K.target.value})),onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),((p[w]||"").trim()||(c[w]||[]).length>0)&&S(w,c));},disabled:n||r,className:a("flex-1 min-w-0 px-2 py-0.5 text-sm rounded border bg-transparent","border-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_40%,transparent)]","focus:outline-none focus:border-[var(--chat-clarification-accent,#f97316)]","placeholder:text-gray-400 dark:placeholder:text-gray-500")})]})]})]})};return jsxs("div",{className:a("mx-4 mb-3 px-4 py-3 font-sans","bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_12%,transparent)]","border-l-[3px] border-[var(--chat-clarification-accent,#f97316)]","rounded-r-lg",i),children:[e.context?jsxs("div",{className:"flex items-start gap-2 mb-2",children:[jsx("span",{className:"text-[var(--chat-clarification-accent,#f97316)] mt-0.5 flex-shrink-0",children:jsx(HelpCircle,{size:14})}),jsx("div",{className:"flex-1 min-w-0",children:jsx(oe,{className:"text-sm text-gray-600 dark:text-gray-300",children:e.context})})]}):null,f?jsx("div",{role:"tablist","aria-label":"Clarification questions",className:"flex items-center gap-1 mb-2 border-b border-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_30%,transparent)]",children:o.map((w,u)=>{let C=u===g,$=(c[u]||[]).length>0;return jsxs("button",{role:"tab","aria-selected":C,onClick:()=>{h.current&&clearTimeout(h.current),P(u);},className:a("flex items-center gap-1 px-2.5 py-1 text-xs rounded-t -mb-px border-b-2 transition-colors",C?"border-[var(--chat-clarification-accent,#f97316)] text-[var(--chat-clarification-accent,#f97316)] font-medium":"border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"),children:[$?jsx(Check,{size:11,strokeWidth:3,className:"text-emerald-600 dark:text-emerald-500"}):null,jsx("span",{children:u+1})]},u)})}):null,jsx("div",{className:"max-h-[50vh] overflow-y-auto pr-1",children:A(g)}),jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[f?jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:`${o.filter((u,C)=>(c[C]||[]).length>0).length} of ${o.length} answered`}):jsx("span",{}),jsxs("div",{className:"flex items-center gap-1",children:[f?jsxs(Fragment,{children:[jsx("button",{type:"button","aria-label":"Previous question",onClick:()=>{h.current&&clearTimeout(h.current),P(w=>Math.max(0,w-1));},disabled:g===0,className:a("flex items-center justify-center w-6 h-6 rounded transition-colors",g===0?"text-gray-300 dark:text-gray-600 cursor-default":"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)]"),children:jsx(ChevronLeft,{size:16})}),jsx("button",{type:"button","aria-label":"Next question",onClick:()=>{h.current&&clearTimeout(h.current),P(w=>Math.min(o.length-1,w+1));},disabled:g===o.length-1,className:a("flex items-center justify-center w-6 h-6 rounded transition-colors mr-1",g===o.length-1?"text-gray-300 dark:text-gray-600 cursor-default":"text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)]"),children:jsx(ChevronRight,{size:16})})]}):null,jsxs("button",{onClick:N,disabled:!R||n||r,className:a("flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors",R?"text-[var(--chat-clarification-accent,#f97316)] hover:text-[var(--chat-clarification-accent-soft,#fdba74)]":"text-gray-300 dark:text-gray-600"),children:[jsx("span",{className:"text-xs",children:"Submit"}),jsx(Send,{size:14})]})]})]})]})}var cn=140;function Zt(e){return e==null?"\u2014":typeof e=="boolean"?e?"yes":"no":String(e)}function Qt(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function So({value:e}){let[t,a]=useState(false);if(Qt(e)){let r=Zt(e);return r.length>cn||r.includes(`
6
+ `)?jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t?jsx("pre",{className:"whitespace-pre-wrap break-words text-xs font-mono bg-black/5 dark:bg-white/5 rounded px-2 py-1.5 max-h-60 overflow-auto",children:r}):jsxs("span",{className:"break-words text-current/80",children:[r.slice(0,cn),"\u2026"]}),jsx("button",{type:"button",onClick:()=>a(s=>!s),className:"self-start text-[11px] underline-offset-2 hover:underline opacity-70 hover:opacity-100",children:t?"Show less":"Show more"})]}):jsx("span",{className:"break-words",children:r})}if(Array.isArray(e)&&e.every(Qt)){let r=e.map(Zt).join(", ")||"(empty)";return jsx("span",{className:"break-words",children:r})}let n="";try{n=JSON.stringify(e,null,2);}catch{n=String(e);}return jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[jsxs("button",{type:"button",onClick:()=>a(r=>!r),className:"self-start text-[11px] underline-offset-2 hover:underline opacity-70 hover:opacity-100",children:[t?"Hide":"Show"," ",Array.isArray(e)?"items":"details"]}),t&&jsx("pre",{className:"whitespace-pre-wrap break-words text-xs font-mono bg-black/5 dark:bg-white/5 rounded px-2 py-1.5 max-h-60 overflow-auto",children:n})]})}var mn=({onClick:e,disabled:t,children:a$1})=>jsx("button",{type:"button",onClick:e,disabled:t,className:a("px-4 py-1.5 rounded-full text-sm font-medium transition-colors","bg-[var(--chat-approve-bg,#1c1917)] hover:bg-[var(--chat-approve-bg-hover,#292524)] text-[var(--chat-approve-text,white)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:a$1}),To=({onClick:e,disabled:t,children:a$1})=>jsx("button",{type:"button",onClick:e,disabled:t,className:a("px-4 py-1.5 rounded-full text-sm font-medium transition-colors","bg-[var(--chat-reject-bg,#f5f5f4)] text-[var(--chat-reject-text,#44403c)] hover:bg-[var(--chat-reject-bg-hover,#e7e5e4)] dark:bg-[var(--chat-reject-bg-dark,rgba(255,255,255,0.06))] dark:text-[var(--chat-reject-text-dark,#e7e5e4)] dark:hover:bg-[var(--chat-reject-bg-hover-dark,rgba(255,255,255,0.1))]","disabled:opacity-50 disabled:cursor-not-allowed"),children:a$1}),Po=({onClick:e,disabled:t,children:a$1})=>jsx("button",{type:"button",onClick:e,disabled:t,className:a("text-sm underline-offset-4 transition-colors","text-[var(--chat-text-subtle,rgba(0,0,0,0.55))] hover:text-[var(--chat-text,#1c1917)] hover:underline","dark:text-[var(--chat-text-subtle-dark,rgba(255,255,255,0.55))] dark:hover:text-[var(--chat-text-dark,#fafaf9)]","disabled:opacity-50 disabled:cursor-not-allowed"),children:a$1}),zo=mn,Ao=({value:e,onChange:t,onSubmit:a,onCancel:n,placeholder:r,disabled:i,autoFocus:s})=>jsx("textarea",{value:e,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.shiftKey?(o.preventDefault(),a()):o.key==="Escape"&&(o.preventDefault(),n());},placeholder:r,disabled:i,autoFocus:s,rows:2,className:"w-full text-sm bg-transparent border-b border-[var(--chat-border,rgba(0,0,0,0.12))] dark:border-[var(--chat-border-dark,rgba(255,255,255,0.15))] focus:border-[var(--chat-text,#1c1917)] dark:focus:border-[var(--chat-text-dark,#fafaf9)] py-1.5 resize-y disabled:opacity-50 placeholder:text-[var(--chat-text-subtle,rgba(0,0,0,0.4))] outline-none transition-colors"}),Eo=3,dn=32;function Mo(e){let t=Zt(e);return t.length<=dn?t:`${t.slice(0,dn-1)}\u2026`}function Jt({approval:e,onApprove:t,onReject:a$1,disabled:n=false,className:r,slots:i}){let[s,o]=useState("idle"),[c,d]=useState(""),[p,v]=useState(false),y=useCallback(()=>{t(e.toolInputs);},[t,e.toolInputs]),P=useCallback(()=>{a$1("User declined this action");},[a$1]),b=useCallback(()=>{let u=c.trim();u&&a$1(u);},[c,a$1]),h=useCallback(()=>{o("idle"),d("");},[]);useEffect(()=>{if(s!=="idle"||n)return;let u=C=>{let $=C.target,K=$?.tagName;K==="INPUT"||K==="TEXTAREA"||K==="SELECT"||($?.isContentEditable??false)||(C.key==="Enter"&&!C.shiftKey&&!C.metaKey&&!C.ctrlKey&&!C.altKey?(C.preventDefault(),y()):C.key==="Escape"&&(C.preventDefault(),P()));};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s,n,y,P]);let S=e.toolDescription?.trim()||`Run ${e.toolName}`,L=e.toolLabel?.trim()||e.toolName,R=Object.entries(e.toolInputs).filter(([u])=>u!=="__description"),N=R.filter(([,u])=>Qt(u)).slice(0,Eo),T=i?.AllowButton??mn,f=i?.RejectButton??To,g=i?.SendButton??zo,A=i?.CancelButton??Po,w=i?.ChatInput??Ao;return jsxs("div",{role:"group","aria-label":"Tool approval",className:a("mx-4 mb-4 font-sans","px-4 py-3.5 rounded-2xl","bg-[var(--chat-approval-panel-bg,oklch(0.995_0.003_70))]","border-[1.5px] border-[var(--chat-approval-panel-border,oklch(0.86_0.005_70))]","shadow-[var(--chat-approval-panel-shadow,0_1px_0_rgba(0,0,0,0.04),0_8px_24px_-12px_rgba(0,0,0,0.10))]","text-[var(--chat-text,#1c1917)] dark:text-[var(--chat-text-dark,#fafaf9)]",r),children:[s==="idle"&&jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[jsx("span",{"aria-hidden":true,className:"inline-block w-1.5 h-1.5 rounded-full bg-[var(--chat-activity,var(--chat-primary,#106997))] animate-pulse-subtle shrink-0"}),jsx("span",{className:"uppercase tracking-[0.08em] text-[11px] font-semibold opacity-70 shrink-0",children:"Approve action"}),L&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":true,className:"opacity-30 shrink-0",children:"\xB7"}),jsx("span",{className:"text-[11px] opacity-60 truncate",title:L,children:L})]})]}),jsx("div",{className:"max-h-[40vh] overflow-y-auto pr-1",children:jsx("p",{className:"text-base leading-relaxed",children:S})}),s==="idle"?jsxs(Fragment,{children:[N.length>0&&jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:N.map(([u,C])=>jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-mono bg-black/[0.04] dark:bg-white/[0.06]",children:[jsxs("span",{className:"opacity-60",children:[u,":"]}),jsx("span",{children:Mo(C)})]},u))}),jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-2",children:[jsx(T,{onClick:y,disabled:n,children:"Approve"}),jsx(f,{onClick:P,disabled:n,children:"Decline"}),!n&&jsxs("span",{"aria-hidden":true,className:"ml-auto text-[11px] opacity-50 select-none hidden sm:inline",children:[jsx("kbd",{className:"font-sans",children:"\u23CE"})," approve \xB7"," ",jsx("kbd",{className:"font-sans",children:"Esc"})," decline"]})]}),R.length>0&&jsxs("div",{className:"mt-3",children:[jsx("button",{type:"button",onClick:()=>v(u=>!u),className:"text-xs underline-offset-4 hover:underline opacity-60 hover:opacity-100 transition-opacity",children:p?"Hide all details":"Show all details"}),p&&jsx("dl",{className:"mt-2 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-xs opacity-70 max-h-[40vh] overflow-y-auto pr-1",children:R.map(([u,C])=>jsxs("div",{className:"contents",children:[jsx("dt",{className:"font-mono text-[11px] pt-0.5 self-start",children:u}),jsx("dd",{className:"min-w-0",children:jsx(So,{value:C})})]},u))})]})]}):jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[jsx(w,{value:c,onChange:d,onSubmit:b,onCancel:h,placeholder:"Tell me what you want instead\u2026",disabled:n,autoFocus:true}),jsxs("div",{className:"flex items-center gap-x-3",children:[jsx(g,{onClick:b,disabled:n||!c.trim(),children:"Send"}),jsx(A,{onClick:h,disabled:n,children:"Cancel"})]})]})]})}var Io=["Incorrect or incomplete","Not what I asked for","Wrong data","Bad recommendation","Tone or style","Other"];function ta({textContent:e,onRegenerate:t,onEdit:a$1,onReportIncorrect:n,onConfirmCorrect:r,className:i}){let[s,o]=useState(false),[c,d]=useState("none"),[p,v]=useState(false),[y,P]=useState(null),[b,h]=useState(""),S=useCallback(()=>{v(false),P(null),h("");},[]),L=useCallback(()=>{if(c!=="none")return;let N=b.trim(),T=y&&N?`${y}: ${N}`:y||N;d("incorrect"),v(false),P(null),h(""),n?.(T||void 0);},[c,y,b,n]);useEffect(()=>{if(!p)return;let N=T=>{T.key==="Escape"&&S();};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[p,S]);let R=useCallback(async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3);}catch{let N=document.createElement("textarea");N.value=e,N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.select(),document.execCommand("copy"),document.body.removeChild(N),o(true),setTimeout(()=>o(false),2e3);}},[e]);return jsxs("div",{className:a("relative flex items-center gap-1",p?"opacity-100":"opacity-0 group-hover:opacity-100 transition-opacity duration-150",i),children:[jsx("button",{type:"button",onClick:R,"aria-label":s?"Copied":"Copy message",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:s?jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})}):jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}),t&&jsx("button",{type:"button",onClick:t,"aria-label":"Regenerate response",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})}),a$1&&jsx("button",{type:"button",onClick:a$1,"aria-label":"Edit message",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),(r||n)&&c==="none"&&jsx("div",{className:"w-px h-4 bg-[var(--chat-text-subtle)] opacity-20 mx-0.5"}),r&&c==="none"&&jsx("button",{type:"button",onClick:()=>{d("correct"),r();},"aria-label":"This response was helpful",className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 10v12"}),jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2h0a3.13 3.13 0 0 1 3 3.88Z"})]})}),n&&c==="none"&&jsx("button",{type:"button",onClick:()=>v(true),"aria-label":"This response was incorrect","aria-haspopup":"dialog","aria-expanded":p,className:a("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]",p&&"bg-[var(--chat-panel-bg)] text-[var(--chat-text)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 14V2"}),jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22h0a3.13 3.13 0 0 1-3-3.88Z"})]})}),c!=="none"&&jsx("span",{className:"text-xs text-[var(--chat-text-subtle)] px-1",children:c==="correct"?"Thanks!":"Reported"}),p&&typeof document<"u"&&createPortal(jsxs("div",{role:"presentation",onClick:S,style:{position:"fixed",inset:0,zIndex:2147483600,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:"Inter, system-ui, -apple-system, sans-serif"},children:[jsx("style",{children:Do}),jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Share feedback",onClick:N=>N.stopPropagation(),className:"mf-fbm-card",children:[jsxs("div",{className:"mf-fbm-header",children:[jsx("span",{className:"mf-fbm-title",children:"Share feedback"}),jsx("button",{type:"button",onClick:S,"aria-label":"Close feedback",className:"mf-fbm-close",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]})})]}),jsx("div",{className:"mf-fbm-chips",children:Io.map(N=>{let T=y===N;return jsx("button",{type:"button",onClick:()=>P(T?null:N),className:a("mf-fbm-chip",T&&"mf-fbm-chip--active"),children:N},N)})}),jsx("textarea",{value:b,onChange:N=>h(N.target.value),placeholder:"What went wrong? (optional)",rows:3,className:"mf-fbm-textarea"}),jsx("div",{className:"mf-fbm-actions",children:jsx("button",{type:"button",onClick:L,disabled:!y&&!b.trim(),className:"mf-fbm-submit",children:"Submit"})})]})]}),document.body)]})}var Do=`
7
+ .mf-fbm-card {
8
+ width: 420px;
9
+ max-width: 100%;
10
+ background: #ffffff;
11
+ color: #111827;
12
+ border-radius: 12px;
13
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
14
+ padding: 20px;
15
+ box-sizing: border-box;
16
+ }
17
+ .mf-fbm-header {
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: space-between;
21
+ margin-bottom: 12px;
22
+ }
23
+ .mf-fbm-title {
24
+ font-size: 15px;
25
+ font-weight: 600;
26
+ color: #111827;
27
+ }
28
+ .mf-fbm-close {
29
+ width: 28px;
30
+ height: 28px;
31
+ display: inline-flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ background: transparent;
35
+ border: none;
36
+ border-radius: 6px;
37
+ color: #6b7280;
38
+ cursor: pointer;
39
+ padding: 0;
40
+ }
41
+ .mf-fbm-close:hover {
42
+ background: rgba(0, 0, 0, 0.05);
43
+ color: #111827;
44
+ }
45
+ .mf-fbm-chips {
46
+ display: flex;
47
+ flex-wrap: wrap;
48
+ gap: 6px;
49
+ margin-bottom: 14px;
50
+ }
51
+ .mf-fbm-chip {
52
+ font-size: 12px;
53
+ line-height: 1;
54
+ padding: 6px 10px;
55
+ border-radius: 9999px;
56
+ border: 1px solid rgba(0, 0, 0, 0.18);
57
+ background: #ffffff;
58
+ color: #111827;
59
+ cursor: pointer;
60
+ transition: background 120ms, color 120ms, border-color 120ms;
61
+ }
62
+ .mf-fbm-chip:hover {
63
+ background: rgba(0, 0, 0, 0.04);
64
+ }
65
+ .mf-fbm-chip--active,
66
+ .mf-fbm-chip--active:hover {
67
+ background: #111827;
68
+ color: #ffffff;
69
+ border-color: #111827;
70
+ }
71
+ .mf-fbm-textarea {
72
+ width: 100%;
73
+ box-sizing: border-box;
74
+ font-family: inherit;
75
+ font-size: 13px;
76
+ line-height: 1.5;
77
+ color: #111827;
78
+ background: #f9fafb;
79
+ border: 1px solid rgba(0, 0, 0, 0.18);
80
+ border-radius: 8px;
81
+ padding: 10px 12px;
82
+ resize: none;
83
+ outline: none;
84
+ }
85
+ .mf-fbm-textarea:focus {
86
+ border-color: #111827;
87
+ }
88
+ .mf-fbm-textarea::placeholder {
89
+ color: rgba(0, 0, 0, 0.45);
90
+ }
91
+ .mf-fbm-actions {
92
+ display: flex;
93
+ justify-content: flex-end;
94
+ margin-top: 14px;
95
+ }
96
+ .mf-fbm-submit {
97
+ font-size: 13px;
98
+ font-weight: 500;
99
+ padding: 7px 14px;
100
+ border-radius: 8px;
101
+ border: none;
102
+ background: #111827;
103
+ color: #ffffff;
104
+ cursor: pointer;
105
+ transition: opacity 120ms;
106
+ }
107
+ .mf-fbm-submit:hover {
108
+ opacity: 0.9;
109
+ }
110
+ .mf-fbm-submit:disabled {
111
+ opacity: 0.4;
112
+ cursor: not-allowed;
113
+ }
114
+ `;function na({attachments:e,onDownload:t,onPreview:a$1,className:n}){let[r,i]=useState(null);if(!e||e.length===0)return null;let s=c=>{if(t){t(c);return}if(c.url){let d=document.createElement("a");d.href=c.url,d.download=c.filename,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d);}},o=c=>{if(a$1){a$1(c);return}c.isImage&&c.url&&i(c.url);};return jsxs("div",{className:a("flex flex-wrap gap-1.5",n),children:[e.map(c=>jsx(Oo,{attachment:c,onDownload:()=>s(c),onPreview:()=>o(c)},c.id)),r&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:()=>i(null),children:[jsx("button",{className:"absolute top-4 right-4 p-2 text-white hover:bg-white/20 rounded-full transition-colors",onClick:()=>i(null),"aria-label":"Close",children:jsx(X,{size:24})}),jsx("img",{src:r,alt:"Preview",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:c=>c.stopPropagation()})]})]})}function Oo({attachment:e,onDownload:t,onPreview:a$1}){let n=e.humanReadableSize||Ko(e.size);return jsxs("div",{className:a("inline-flex items-center gap-2 px-2.5 py-1.5 rounded-lg max-w-full","border border-[var(--chat-border)] bg-[var(--chat-panel-bg)]",e.isImage&&e.url&&"cursor-pointer hover:bg-[var(--chat-border)]/30"),onClick:e.isImage&&e.url?a$1:void 0,children:[jsx(Wo,{mimeType:e.mimeType,size:14}),jsx("span",{className:"text-xs text-[var(--chat-text)] truncate min-w-0",children:e.filename}),n&&n!=="0 Bytes"&&jsx("span",{className:"text-[10px] text-[var(--chat-text-subtle)] flex-shrink-0",children:n}),e.url&&jsx("button",{onClick:r=>{r.stopPropagation(),t();},className:"p-0.5 hover:bg-[var(--chat-border)] rounded transition-colors flex-shrink-0","aria-label":"Download",children:jsx(Download,{size:12,className:"text-[var(--chat-text-subtle)]"})})]})}function Wo({mimeType:e,size:t=14}){return e.startsWith("image/")?jsx(Image,{size:t,className:"text-[var(--chat-primary)] flex-shrink-0"}):e.startsWith("video/")?jsx(Video,{size:t,className:"text-[var(--chat-primary)] flex-shrink-0"}):e==="application/pdf"?jsx(FileText,{size:t,className:"text-red-500 flex-shrink-0"}):jsx(FileIcon,{size:t,className:"text-gray-500 flex-shrink-0"})}function Ko(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+a[n]}var un="miiflow-reasoning-keyframes",ra=`
115
+ @keyframes beamer{0%{left:-30%}100%{left:100%}}
116
+ @keyframes mf-halo{0%,100%{opacity:0;transform:translate(-50%,-50%) scale(.65)}50%{opacity:.5;transform:translate(-50%,-50%) scale(1)}}
117
+ @keyframes mf-wave{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-1.5px)}}
118
+ @keyframes mf-caret{0%,100%{opacity:.95}50%{opacity:.15}}
119
+ @keyframes mf-rail-flow{0%{transform:translateY(-110%)}100%{transform:translateY(220%)}}
120
+ @keyframes mf-text-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}
121
+ @keyframes mf-bars{0%,100%{transform:scaleY(.28)}50%{transform:scaleY(1)}}
122
+ @keyframes mf-led{0%,100%{opacity:.5}50%{opacity:1}}
123
+ @keyframes mf-scanline{0%{transform:translateX(-110%)}100%{transform:translateX(220%)}}
124
+ @keyframes mf-mono-blink{0%,49%{opacity:1}50%,100%{opacity:.45}}
125
+ @keyframes mf-row-enter{0%{opacity:0;transform:translateY(3px)}100%{opacity:1;transform:translateY(0)}}
126
+ @keyframes mf-halo-once{0%{opacity:0;transform:scale(.4)}38%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(1.55)}}
127
+ .mf-row-enter{animation:mf-row-enter 360ms cubic-bezier(.16,1,.3,1) both}
128
+ .mf-tool-mark{transition:transform 220ms cubic-bezier(.16,1,.3,1);transform-origin:50% 62%;will-change:transform}
129
+ .mf-tool-row:hover .mf-tool-mark{transform:rotate(-9deg) scale(1.08)}
130
+ @media (prefers-reduced-motion:reduce){.mf-row-enter{animation:none}.mf-tool-mark{transition:none}.mf-tool-row:hover .mf-tool-mark{transform:none}}
131
+ `;function Ee(e){if(typeof document>"u")return;let t=e?.getRootNode?.(),a=t instanceof ShadowRoot?t:document.head,n=a.querySelector(`#${un}`);if(n){n.textContent!==ra&&(n.textContent=ra);return}let r=document.createElement("style");r.id=un,r.textContent=ra,a.appendChild(r);}function yt({status:e,size:t=20,className:a$1,kind:n}){let r=useRef(null);useEffect(()=>{Ee(r.current);},[]);let i=Math.max(t,16),s=n==="subagent",o=n==="tool";return jsxs("div",{ref:r,className:a("relative flex-shrink-0 flex items-center justify-center",a$1),style:{width:t,height:t},children:[e==="pending"&&jsx("span",{"aria-hidden":true,style:{width:7,height:7,borderRadius:"50%",border:"1.25px solid var(--chat-text-subtle)",opacity:.35,background:"transparent"}}),e==="running"&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":true,style:{position:"absolute",left:"50%",top:"50%",width:i,height:i,borderRadius:"50%",background:"radial-gradient(closest-side, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 55%, transparent), transparent 70%)",transform:"translate(-50%, -50%) scale(.55)",animation:"mf-halo 1.5s cubic-bezier(.16,1,.3,1) infinite",pointerEvents:"none"}}),o?jsx("span",{"aria-hidden":true,style:{position:"relative",width:5,height:5,background:"var(--chat-activity, var(--chat-primary))",boxShadow:"0 0 0 1.5px color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 26%, transparent), 0 0 0 2.5px color-mix(in srgb, var(--chat-text) 6%, transparent)"}}):s?jsx("span",{"aria-hidden":true,style:{position:"relative",width:8,height:8,borderRadius:1.5,background:"var(--chat-activity, var(--chat-primary))",boxShadow:"0 0 0 1.5px color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 26%, transparent), 0 0 0 2.5px color-mix(in srgb, var(--chat-text) 6%, transparent)"}}):jsx("span",{"aria-hidden":true,style:{position:"relative",width:7,height:7,borderRadius:"50%",background:"var(--chat-activity, var(--chat-primary))",boxShadow:"0 0 0 1.5px color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 24%, transparent), 0 0 0 2.5px color-mix(in srgb, var(--chat-text) 6%, transparent)"}})]}),e==="completed"&&(s?jsxs("span",{"aria-hidden":true,style:{position:"relative",display:"inline-block",width:7,height:7},children:[jsx("span",{style:{position:"absolute",inset:0,border:"1.25px solid color-mix(in srgb, var(--chat-text) 32%, transparent)",boxSizing:"border-box"}}),jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:2,height:2,background:"color-mix(in srgb, var(--chat-text) 60%, transparent)"}})]}):o?jsx("span",{"aria-hidden":true,style:{width:4,height:4,background:"color-mix(in srgb, var(--chat-text) 38%, transparent)",boxShadow:"inset 0 0 0 0.5px color-mix(in srgb, var(--chat-text) 65%, transparent)"}}):jsx("span",{"aria-hidden":true,style:{width:4,height:4,borderRadius:"50%",background:"color-mix(in srgb, var(--chat-text) 55%, transparent)"}})),e==="failed"&&jsx("span",{"aria-hidden":true,style:{position:"relative",width:12,height:12,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--chat-error)",fontSize:12,lineHeight:1,fontWeight:600,transform:"translateY(-0.5px)"},children:"\xD7"})]})}function Go(e,t){return t?e==="subagent"||t==="subagent"?6:e==="observation"||t==="observation"?12:e===t?4:9:0}function $e({items:e,badgeSize:t=20,className:a$1}){let n=useRef(null);if(useEffect(()=>{Ee(n.current);},[]),e.length===0)return null;let r=t/2;return jsx("div",{ref:n,className:a("max-w-full",a$1),children:jsxs("div",{style:{position:"relative"},children:[e.length>1&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:r-.5,top:6,bottom:6,width:1,background:"color-mix(in srgb, var(--chat-text) 10%, transparent)",pointerEvents:"none"}}),jsx("div",{className:"flex flex-col",children:e.map((i,s)=>{let o=s===e.length-1,d=i.status==="running"&&!o,p=o?0:Go(i.kind,e[s+1]?.kind);return jsxs("div",{className:"mf-row-enter",style:{display:"grid",gridTemplateColumns:`${t}px 1fr`,columnGap:"0.625rem",paddingBottom:p,position:"relative"},children:[jsxs("div",{className:"relative flex flex-col items-center flex-shrink-0",style:{paddingTop:4},children:[jsx(yt,{status:i.status,size:t,kind:i.kind}),d&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:t+4,width:1,height:`calc(100% - ${t}px + 4px)`,overflow:"hidden",pointerEvents:"none"},children:jsx("div",{style:{position:"absolute",left:0,top:0,width:"100%",height:"55%",background:"linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 70%, transparent) 50%, transparent 100%)",animation:"mf-rail-flow 1.6s cubic-bezier(.16,1,.3,1) infinite",willChange:"transform"}})})]}),jsx("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",position:"relative",overflow:"hidden",paddingTop:2,paddingBottom:2},children:i.content})]},i.id)})})]})})}function Xo({status:e,isLast:t=false,badgeSize:a$1=20,children:n,className:r}){let i=useRef(null);useEffect(()=>{Ee(i.current);},[]);let o=e==="running"&&!t;return jsxs("div",{ref:i,className:a("relative flex items-start gap-2.5 animate-fade-in",!t&&"pb-3",r),children:[jsxs("div",{className:"relative flex-shrink-0",style:{paddingTop:4},children:[!t&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:a$1/2-.5,top:a$1+4,width:1,height:"calc(100% + 8px)",background:"color-mix(in srgb, var(--chat-text) 10%, transparent)",pointerEvents:"none"}}),jsx(yt,{status:e,size:a$1}),o&&jsx("div",{"aria-hidden":true,style:{position:"absolute",left:a$1/2-.5,top:a$1+4,width:1,height:"calc(100% + 8px)",overflow:"hidden",pointerEvents:"none"},children:jsx("div",{style:{position:"absolute",left:0,top:0,width:"100%",height:"55%",background:"linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 70%, transparent) 50%, transparent 100%)",animation:"mf-rail-flow 1.6s cubic-bezier(.16,1,.3,1) infinite",willChange:"transform"}})})]}),jsx("div",{style:{minWidth:0,flex:1,position:"relative",overflow:"hidden",borderRadius:4},children:n})]})}function ei(){return jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":true,style:{flexShrink:0,display:"block"},children:jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})}var ia="ui-monospace, 'SFMono-Regular', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",hn={backgroundImage:"linear-gradient(90deg, var(--chat-text) 0%, var(--chat-text) 40%, color-mix(in srgb, var(--chat-text) 35%, transparent) 50%, var(--chat-text) 60%, var(--chat-text) 100%)",backgroundSize:"200% 100%",backgroundRepeat:"repeat-x",backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",color:"transparent",animation:"mf-text-shimmer 2.4s linear infinite"};function bn({seconds:e,maxSeconds:t}){let a=t>0?Math.min(1,Math.max(.08,e/t)):.2;return jsxs("span",{"aria-label":`${e.toFixed(1)} seconds`,style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-end",gap:2,marginLeft:8,flexShrink:0,paddingTop:2},children:[jsxs("span",{className:"tabular-nums",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-text) 45%, transparent)",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em",lineHeight:1},children:[e.toFixed(1),"s"]}),jsx("span",{"aria-hidden":true,style:{width:24,height:1.5,background:"color-mix(in srgb, var(--chat-text) 8%, transparent)",borderRadius:1,position:"relative",overflow:"hidden"},children:jsx("span",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${a*100}%`,background:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 60%, transparent)",borderRadius:1}})})]})}function sa({event:e,className:t,isRunning:a$1,maxDurationSeconds:n}){let r=useRef(null);useEffect(()=>{Ee(r.current);},[]);let i=e.durationSeconds!=null&&e.durationSeconds>.05;if(e.type==="thinking"||e.type==="planning")return jsxs("div",{ref:r,className:a("min-w-0 max-w-full",t),style:{paddingTop:1,paddingBottom:1,display:"flex",alignItems:"flex-start",gap:8},children:[jsx("div",{style:{lineHeight:1.6,letterSpacing:"-0.005em",fontWeight:a$1?480:400,flex:1,minWidth:0,...a$1?hn:{color:"color-mix(in srgb, var(--chat-text) 78%, transparent)"}},children:jsx(oe,{className:"text-[14px]",children:e.content})}),i&&jsx(bn,{seconds:e.durationSeconds,maxSeconds:n??e.durationSeconds})]});if(e.type==="tool"){let s=e.toolDescription?.trim(),o=!!s&&s.length>0,c=o?s:e.toolName||"Tool call";return jsxs("div",{ref:r,className:a("mf-tool-row inline-flex items-center gap-2.5 min-w-0 max-w-full",t),style:{position:"relative"},title:e.toolName,children:[jsx("span",{"aria-hidden":true,className:"mf-tool-mark",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:14,height:14,color:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 70%, var(--chat-text))",opacity:.82},children:jsx(ei,{})}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontFamily:o?void 0:ia,fontVariantLigatures:o?void 0:"none",fontSize:o?14:12.5,lineHeight:1.5,letterSpacing:"-0.005em",fontWeight:o?450:500,fontVariantNumeric:"tabular-nums",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...a$1?hn:{color:"color-mix(in srgb, var(--chat-text) 86%, transparent)"}},children:[jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:c}),a$1&&jsx("span",{"aria-hidden":true,style:{display:"inline-block",width:2,height:"0.95em",background:"var(--chat-activity, var(--chat-primary))",marginLeft:4,animation:"mf-caret 1.05s cubic-bezier(.4,0,.6,1) infinite",borderRadius:1,flexShrink:0,WebkitTextFillColor:"currentColor",color:"var(--chat-activity, var(--chat-primary))",backgroundImage:"none",backgroundClip:"border-box",WebkitBackgroundClip:"border-box"}})]}),i&&jsx(bn,{seconds:e.durationSeconds,maxSeconds:n??e.durationSeconds})]})}if(e.type==="observation"){let o=e.success!==false?"--chat-secondary":"--chat-warning";return jsxs("div",{ref:r,className:a("max-w-full overflow-auto",t),style:{padding:"8px 12px",borderRadius:3,background:`color-mix(in srgb, var(${o}) 4%, transparent)`,boxShadow:`inset 0 0 0 0.5px color-mix(in srgb, var(${o}) 22%, transparent)`},children:[jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,marginBottom:4},children:[jsx("span",{"aria-hidden":true,style:{width:3,height:3,background:`var(${o})`}}),jsx("span",{style:{fontFamily:ia,fontSize:9.5,fontWeight:700,letterSpacing:"0.16em",textTransform:"uppercase",color:`var(${o})`,fontVariantLigatures:"none"},children:"response"})]}),jsx("div",{className:"text-[var(--chat-text)]",children:jsx(oe,{className:"text-[14px]",children:e.content})})]})}if(e.type==="subagent"){let s=e.subagentData,o=(s.nestedChunks??[]).map((c,d)=>Ie(c,d)).filter(c=>c!==null);return s.result&&s.result.trim().length>0&&o.push({id:`result-${s.subagentId}`,type:"thinking",status:s.status==="failed"?"failed":"completed",content:s.result}),jsx(ti,{slug:s.subagentType||"sub-assistant",durationSeconds:s.durationMs!=null?s.durationMs/1e3:void 0,isRunning:s.status==="running",isFailed:s.status==="failed",defaultExpanded:false,nestedEvents:o})}return null}function ti({slug:e,durationSeconds:t,isRunning:a$1,isFailed:n,defaultExpanded:r,nestedEvents:i}){let[s,o]=useState(r),c=i.length>0,d=c,p=n?"var(--chat-error)":a$1?"color-mix(in srgb, var(--chat-text) 92%, transparent)":"color-mix(in srgb, var(--chat-text) 78%, transparent)";return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:c?()=>o(v=>!v):void 0,className:a("inline-flex items-center gap-2 min-w-0 max-w-full",c&&"cursor-pointer"),style:{paddingTop:1,paddingBottom:1},children:[jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",fontFamily:ia,fontSize:13,lineHeight:1.35,fontWeight:500,letterSpacing:0,color:p,fontVariantLigatures:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:[jsx("span",{"aria-hidden":true,style:{opacity:.55,marginRight:1,fontWeight:400},children:"@"}),e]}),t!=null&&t>0?jsxs("span",{className:"shrink-0 tabular-nums",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-text) 50%, transparent)",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em"},children:[t.toFixed(1),"s"]}):a$1?jsx("span",{className:"shrink-0",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 85%, transparent)",fontStyle:"italic",letterSpacing:"0.01em"},children:"running\u2026"}):null,d&&jsx("span",{"aria-hidden":true,className:"shrink-0 inline-flex items-center justify-center",style:{width:14,height:14,color:"color-mix(in srgb, var(--chat-text) 40%, transparent)",fontSize:11,lineHeight:1,transform:s?"rotate(90deg)":"rotate(0deg)",transition:"transform 220ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),c&&s&&jsx("div",{className:"animate-fade-in",style:{marginTop:6,paddingLeft:14},children:jsx(Me,{events:i})})]})}var ai=["create_plan","tool_search","unknown","dispatch_assistant"];function yn(e){return e?ai.includes(e.toLowerCase().trim()):false}function Ie(e,t){if(e.toolName&&yn(e.toolName))return null;if(e.type==="thinking")return !e.content||e.content.trim().length===0?null:{id:`thinking-${t}`,type:"thinking",status:"completed",content:e.content};if(e.type==="planning"){if(!e.content||e.content.trim().length===0)return null;let a=e.planData!==void 0||e.content.includes("\u2713 Created plan");return {id:`planning-${t}`,type:"planning",status:a?"completed":"running",content:e.content,isComplete:a}}if(e.type==="tool"){let a=e.status==="executing"?"running":e.status==="completed"?"completed":"pending";return {id:`tool-${t}`,type:"tool",status:a,toolName:e.toolName||"Unknown Tool",toolDescription:e.toolDescription}}if(e.type==="subagent"&&e.subagentData){let a=e.subagentData.status==="running"?"running":e.subagentData.status==="completed"?"completed":e.subagentData.status==="failed"?"failed":"pending";return {id:`subagent-${e.subagentData.subagentId}-${t}`,type:"subagent",status:a,subagentData:e.subagentData}}return null}function ni(e){let t=[],a=[];e.forEach((n,r)=>{let i=typeof n.timestamp=="number"?n.timestamp:void 0;if(n.type==="thought"){let s=n.thought;if(!s||s.trim().length===0)return;t.push({id:`thought-${r}`,type:"thinking",status:"completed",content:s,timestamp:i}),a.push(i??NaN);}else if(n.type==="tool"){let s=n.tool||"Unknown Tool";if(yn(s))return;t.push({id:`tool-${r}`,type:"tool",status:"completed",toolName:s,toolDescription:n.tool_description,timestamp:i}),a.push(i??NaN);}});for(let n=0;n<t.length-1;n++){let r=a[n],i=a[n+1];if(Number.isFinite(r)&&Number.isFinite(i)&&i>r){let s=i-r,o=s>1e3?s/1e3:s;o>0&&o<3600&&(t[n].durationSeconds=o);}}return t}function ri(e){switch(e.type){case "thinking":return "thinking";case "planning":return "planning";case "tool":return "tool";case "observation":return "observation";case "subagent":return "subagent";default:return}}function Me({events:e,className:t}){if(e.length===0)return null;let a=e.reduce((r,i)=>i.durationSeconds&&i.durationSeconds>r?i.durationSeconds:r,0),n=e.map(r=>({id:r.id,status:r.status,kind:ri(r),content:jsx(sa,{event:r,isRunning:r.status==="running",maxDurationSeconds:a}),bare:r.type==="subagent"}));return jsx($e,{items:n,badgeSize:20,className:t})}function tt({label:e,description:t,durationSeconds:a$1,isFailed:n=false,defaultExpanded:r=false,nestedEvents:i,hideChevron:s=false}){let[o,c]=useState(r),d=!!(i&&i.length>0),p=d&&!s;return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:p?()=>c(!o):void 0,className:a("flex items-center gap-2 min-w-0",p&&"cursor-pointer"),children:[jsx("span",{className:a("text-sm truncate",n?"text-[var(--chat-error)]":"text-[var(--chat-text)]"),style:{fontWeight:500,letterSpacing:"-0.005em"},children:e}),t&&jsx("span",{className:a("text-sm truncate flex-1",n?"text-[var(--chat-error)]":"text-[var(--chat-text-subtle)]"),children:t}),a$1!=null&&a$1>0&&jsxs("span",{className:"shrink-0 tabular-nums",style:{fontSize:11,color:"color-mix(in srgb, var(--chat-text) 50%, transparent)",fontVariantNumeric:"tabular-nums",letterSpacing:"0.01em"},children:[a$1.toFixed(1),"s"]}),p&&jsx("span",{"aria-hidden":true,className:"shrink-0 inline-flex items-center justify-center",style:{width:14,height:14,color:"color-mix(in srgb, var(--chat-text) 40%, transparent)",fontSize:11,lineHeight:1,transform:o?"rotate(90deg)":"rotate(0deg)",transition:"transform 220ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),d&&o&&jsx("div",{className:"mt-2 pl-2 animate-fade-in",children:jsx(Me,{events:i})})]})}var ii=["create_plan","tool_search","unknown"];function si(e){return e?ii.includes(e.toLowerCase().trim()):false}function li(e){let t=[];return e.forEach((a,n)=>{if(a.type==="thinking"){if(!a.content||a.content.trim().length===0)return;t.push({id:`thinking-${n}`,type:"thinking",status:"completed",content:a.content});}else if(a.type==="tool"){if(si(a.toolName))return;let r=a.status==="executing"?"running":a.status==="completed"?"completed":"pending";t.push({id:`tool-${n}`,type:"tool",status:r,toolName:a.toolName||"Unknown Tool",toolDescription:a.toolDescription});}}),t}function ci({subtask:e,executionChunks:t=[]}){let a=e.status==="failed",n=e.status==="completed",r=li(t);return jsx(tt,{label:e.description,description:a?e.error:void 0,durationSeconds:n?e.execution_time:void 0,isFailed:a,defaultExpanded:e.status==="running",nestedEvents:r})}function ca({plan:e,streamingChunks:t=[],className:a$1}){let n=e.subtasks.map(r=>{let i=t.filter(o=>o.subtaskId===r.id),s=r.status==="running"?"running":r.status==="completed"?"completed":r.status==="failed"?"failed":"pending";return {id:String(r.id),status:s,content:jsx(ci,{subtask:r,executionChunks:i})}});return jsxs("div",{className:a("space-y-2",a$1),children:[jsx("span",{className:"text-sm text-[var(--chat-text-subtle)]",children:"Plan:"}),jsx($e,{items:n,badgeSize:20})]})}function mi(e){let t=useRef(null),[a,n]=useState(0),r=useRef(0);return useEffect(()=>{if(e){t.current===null&&(t.current=Date.now());let i=setInterval(()=>{if(t.current!==null){let s=Math.floor((Date.now()-t.current)/1e3);n(s),r.current=s;}},1e3);return ()=>clearInterval(i)}else t.current!==null&&(r.current=Math.floor((Date.now()-t.current)/1e3),n(r.current),t.current=null);},[e]),{display:`${a}`,finalSeconds:r.current}}function ui(e){return e.some(t=>t.type==="subagent")}var ma=new Set(["create_plan","tool_search","unknown","dispatch_assistant"]);function fi(e){let t=[];return e.forEach(a=>{if(a.type==="thought"&&a.thought)t.push({type:"thinking",content:a.thought,subtaskId:a.subtask_id});else if(a.type==="tool"){let n=(a.tool||"").toLowerCase().trim();if(ma.has(n))return;t.push({type:"tool",content:"",toolName:a.tool||"Unknown Tool",toolDescription:a.tool_description,status:"completed",subtaskId:a.subtask_id}),a.observation&&t.push({type:"observation",content:a.observation,toolName:a.tool||"Unknown Tool",success:true,subtaskId:a.subtask_id});}}),t}function gi(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}var vn="ui-monospace, 'SFMono-Regular', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace";function hi({isStreaming:e,justCompleted:t}){return jsx("span",{"aria-hidden":true,style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,flexShrink:0},children:e?jsx("span",{style:{display:"inline-flex",alignItems:"flex-end",gap:1.5,height:10},children:[0,1,2].map(a=>jsx("span",{style:{width:1.5,height:10,background:"var(--chat-activity, var(--chat-primary))",transformOrigin:"bottom",animation:"mf-bars 0.95s cubic-bezier(.16,1,.3,1) infinite",animationDelay:`${a*.13}s`,display:"inline-block"}},a))}):jsxs(Fragment,{children:[jsx("span",{style:{width:5,height:5,background:t?"var(--chat-activity, var(--chat-primary))":"color-mix(in srgb, var(--chat-text) 42%, transparent)",boxShadow:"inset 0 0 0 0.5px color-mix(in srgb, var(--chat-text) 70%, transparent)",transform:t?"scale(1.18)":"scale(1)",transition:"background 820ms cubic-bezier(.16,1,.3,1), transform 540ms cubic-bezier(.16,1,.3,1)",display:"inline-block"}}),t&&jsx("span",{style:{position:"absolute",left:"50%",top:"50%",width:14,height:14,marginLeft:-7,marginTop:-7,borderRadius:"50%",background:"radial-gradient(closest-side, color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 38%, transparent), transparent 70%)",animation:"mf-halo-once 720ms cubic-bezier(.16,1,.3,1) forwards",pointerEvents:"none"}})]})})}function ua({isStreaming:e=false,chunks:t=[],plan:a$1,executionTimeline:n=[],userMessageTimestamp:r,executionTime:i,defaultExpanded:s=false,expanded:o,onExpandedChange:c,className:d}){let[p,v]=useState(s),{display:y,finalSeconds:P}=mi(e),b=useRef(null);useEffect(()=>{Ee(b.current);},[]);let h=useRef(null),[S,L]=useState(false);useEffect(()=>{let E=h.current===true&&e===false;if(h.current=e,E){L(true);let j=setTimeout(()=>L(false),820);return ()=>clearTimeout(j)}},[e]);let R=a$3(b,300),N=o??p,T=useCallback(E=>{R(),v(E),c?.(E);},[R,c]),f=useMemo(()=>e?t.map((E,j)=>Ie(E,j)).filter(E=>E!==null):[],[e,t]),g=useMemo(()=>!e&&(n.length>0||t.length>0)?t.map((E,j)=>Ie(E,j)).filter(E=>E!==null):[],[e,n,t]),A=useMemo(()=>!e&&n.length>0?fi(n):[],[e,n]),w=useMemo(()=>{if(i&&i>0)return i;if(!e){if(a$1?.subtasks)return a$1.subtasks.reduce((E,j)=>E+(j.execution_time||0),0);if(n.length>0){let E=n[n.length-1];if(r&&E.timestamp){let j=E.timestamp-r;if(j>0)return j}if(n.length>1){let j=n[0];if(j.timestamp&&E.timestamp){let k=E.timestamp-j.timestamp;if(k>0)return k}}}}return 0},[e,a$1,n,r,i]),u=useMemo(()=>{if(e)return null;let E=0,j=k=>{if(!k)return;let Q=k.toLowerCase().trim();ma.has(Q)||(E+=1);};if(t.length>0)for(let k of t)k.type==="tool"&&j(k.toolName);else if(n.length>0)for(let k of n)k.type==="tool"&&j(k.tool);return E===0?null:`${E} ${E===1?"source":"sources"}`},[e,t,n]);if(!e){let E=a$1||n.length>0||t.length>0;if(!E||E&&g.length===0&&!a$1&&n.length===0)return null}let C=t.length>0?t[t.length-1]:null,$=ui(t),K=()=>{if($&&C?.type==="subagent"&&C?.subagentData)return C.subagentData.subagentType;let E=C?.toolName?.toLowerCase().trim(),j=!!E&&ma.has(E);if(!j&&C?.toolDescription)return C.toolDescription;if(!j&&C?.toolName)return C.toolName;switch(C?.type){case "planning":return "Planning\u2026";case "thinking":return "Thinking\u2026";case "tool":return "Thinking\u2026";case "observation":return "Analyzing results\u2026";case "progress":return "Working\u2026";default:return "Thinking\u2026"}},G=w>0?w:P>0?P:0,ce=a$1?.subtasks&&a$1.subtasks.length>=2;return jsxs("div",{ref:b,className:a("max-w-full",d),children:[jsxs("div",{onClick:()=>T(!N),style:{position:"relative",display:"inline-flex",alignItems:"center",gap:8,padding:"3px 8px 3px 3px",borderRadius:4,cursor:"pointer",transition:"background-color 220ms cubic-bezier(.16,1,.3,1)",background:e?"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 6%, transparent)":"transparent"},children:[jsx(hi,{isStreaming:e,justCompleted:S}),e&&jsxs(Fragment,{children:[jsx("span",{style:{fontSize:13.5,lineHeight:1.35,fontWeight:500,letterSpacing:"-0.005em",color:"color-mix(in srgb, var(--chat-text) 86%, transparent)",maxWidth:520,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:K()}),parseInt(y)>0&&jsxs("span",{className:"tabular-nums",style:{fontFamily:vn,fontSize:11,color:"color-mix(in srgb, var(--chat-activity, var(--chat-primary)) 75%, var(--chat-text))",fontVariantNumeric:"tabular-nums",letterSpacing:"0.02em",fontWeight:600},children:[y,"s"]})]}),!e&&(u||G>0)&&jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:vn,fontSize:11.5,fontWeight:500,letterSpacing:"0.005em",color:"color-mix(in srgb, var(--chat-text) 55%, transparent)",fontVariantNumeric:"tabular-nums",fontVariantLigatures:"none"},children:[G>0&&jsxs("span",{children:["Thought for ",gi(G)]}),G>0&&u&&jsx("span",{"aria-hidden":true,style:{width:2,height:2,borderRadius:"50%",background:"color-mix(in srgb, var(--chat-text) 28%, transparent)",display:"inline-block"}}),u&&jsx("span",{children:u})]}),jsx("span",{"aria-hidden":true,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:12,height:12,marginLeft:1,color:"color-mix(in srgb, var(--chat-text) 38%, transparent)",fontSize:11,lineHeight:1,transform:N?"rotate(90deg)":"rotate(0deg)",transition:"transform 240ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),N&&jsxs("div",{className:"animate-fade-in",style:{position:"relative",marginTop:6},children:[jsx("div",{"aria-hidden":true,style:{position:"absolute",left:9.5,top:-6,width:1,height:10,background:"color-mix(in srgb, var(--chat-text) 10%, transparent)",pointerEvents:"none"}}),e?jsx(Me,{events:f}):a$1?a$1.subtasks?.length===0?null:ce?jsx(ca,{plan:a$1,streamingChunks:A}):jsx(Me,{events:g}):jsx(Me,{events:g})]})]})}var nt=forwardRef(({content:e,isStreaming:t=false,renderMarkdown:a$1=true,className:n,baselineFontSize:r,markdownProps:i},s)=>jsx(m,{ref:s,content:e,isStreaming:t,showCursor:false,className:a("relative",n),children:a$1?jsx(oe,{baselineFontSize:r,...i,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));nt.displayName="StreamingText";var Ei={send_message:jsx(Send,{size:14}),navigate:jsx(Navigation,{size:14}),copy_text:jsx(Copy,{size:14}),compose_email:jsx(Mail,{size:14}),search_emails:jsx(Search,{size:14}),open_modal:jsx(ExternalLink,{size:14}),api_call:jsx(Zap,{size:14})};function Mi(e){return e?Ei[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var wt=forwardRef(({actions:e,onSelect:t,className:a$1,showIcons:n=true,disabled:r=false},i)=>{let[s,o]=useState(null);if(e.length===0)return null;let c=async(d,p)=>{if(!(!t||s!==null)){o(p);try{await t(d);}finally{o(null);}}};return jsx("div",{ref:i,role:"group","aria-label":"Suggested actions",className:a("flex flex-wrap gap-2",a$1),children:jsx(AnimatePresence,{children:e.map((d,p)=>{let v=s===p,y=r||s!==null;return jsxs(motion.button,{type:"button",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,delay:p*.05},disabled:y,onClick:()=>c(d,p),className:a("inline-flex items-center gap-1.5","px-3 py-1.5 rounded-lg","text-sm font-medium","border border-gray-200 dark:border-gray-700","bg-white dark:bg-gray-800","text-gray-700 dark:text-gray-300","opacity-80 hover:opacity-100","hover:border-gray-300 dark:hover:border-gray-600","hover:bg-gray-50 dark:hover:bg-gray-750","hover:-translate-y-px","active:translate-y-0","transition-all duration-200","focus:outline-none focus:ring-2 focus:ring-blue-500/20","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0"),children:[v?jsx(Loader2,{size:14,className:"animate-spin"}):n&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Mi(d.type)}),d.label]},d.id)})})})});wt.displayName="SuggestedActions";var Ki=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function Tt({data:e,config:t,isStreaming:a=false}){let{chartType:n,series:r,xAxis:i,yAxis:s}=e,o=t?.colors||Ki,c=t?.height||300,d=t?.legend!==false,p=t?.grid!==false,v=t?.tooltip!==false,y=t?.animate!==false&&!a,P=t?.stacked||false,h=(()=>{if(n==="pie")return (r[0]?.data||[]).map((g,A)=>({name:g.name||g.x||`Item ${A+1}`,value:g.value??g.y??0}));let T=new Map;return r.forEach(f=>{f.data.forEach(g=>{let A=g.x??g.name;T.has(A)||T.set(A,{x:A}),T.get(A)[f.name]=g.y??g.value??0;});}),Array.from(T.values())})(),S={data:h,margin:{top:10,right:30,left:0,bottom:0}},L={fontSize:12},R={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsx("div",{className:"w-full",style:{height:c},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(n){case "line":return jsxs(LineChart,{...S,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...L,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...L,tickLine:false,width:40}),v&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),r.map((T,f)=>jsx(Line,{type:"monotone",dataKey:T.name,stroke:T.color||o[f%o.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:y},T.name))]});case "bar":return jsxs(BarChart,{...S,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...L,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...L,tickLine:false,width:40}),v&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),r.map((T,f)=>jsx(Bar,{dataKey:T.name,fill:T.color||o[f%o.length],stackId:P?"stack":void 0,isAnimationActive:y,radius:[4,4,0,0]},T.name))]});case "area":return jsxs(AreaChart,{...S,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...L,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...L,tickLine:false,width:40}),v&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),r.map((T,f)=>jsx(Area,{type:"monotone",dataKey:T.name,stroke:T.color||o[f%o.length],fill:T.color||o[f%o.length],fillOpacity:.3,stackId:P?"stack":void 0,isAnimationActive:y},T.name))]});case "pie":return jsxs(PieChart,{children:[v&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),jsx(Pie,{data:h,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(c,300)/3,isAnimationActive:y,label:({name:T,percent:f})=>`${T}: ${((f??0)*100).toFixed(0)}%`,labelLine:false,children:h.map((T,f)=>jsx(Cell,{fill:o[f%o.length]},`cell-${f}`))})]});case "scatter":return jsxs(ScatterChart,{...S,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",...L,tickLine:false,name:i?.label,padding:{left:10,right:10}}),jsx(YAxis,{...L,tickLine:false,name:s?.label,width:40}),v&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),r.map((T,f)=>jsx(Scatter,{name:T.name,data:T.data.map(g=>({x:g.x,y:g.y})),fill:T.color||o[f%o.length],isAnimationActive:y},T.name))]});default:return null}})()||jsx(Fragment,{})})})}var Qi=new Set(["number","currency","date","badge","boolean","progress"]);function Tn(e){if(e==null)return "";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Ji({text:e,anchorRect:t,onEnter:a$1,onLeave:n}){let[r,i]=useState(false);if(typeof document>"u")return null;let s=16,o=Math.min(360,window.innerWidth-2*s),c=window.innerHeight-t.bottom-s,d=c>=120||c>=t.top,p=t.left;p+o>window.innerWidth-s&&(p=Math.max(s,window.innerWidth-o-s));let v={position:"fixed",left:p,width:"max-content",maxWidth:o,maxHeight:"50vh",zIndex:9998,...d?{top:t.bottom+4}:{bottom:window.innerHeight-t.top+4}},y=async()=>{try{await navigator.clipboard.writeText(e),i(!0),window.setTimeout(()=>i(!1),1200);}catch{}};return createPortal(jsxs("div",{style:v,className:a("relative overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-900"),role:"tooltip",onMouseEnter:a$1,onMouseLeave:n,children:[jsx("div",{className:a("select-text overflow-auto px-2.5 py-1.5 pr-8 text-sm text-gray-900 dark:text-gray-100","whitespace-pre-wrap break-words"),style:{maxHeight:"50vh"},children:e||jsx("span",{className:"text-gray-400",children:"\u2014"})}),jsx("button",{type:"button",onClick:y,"aria-label":r?"Copied":"Copy",title:r?"Copied":"Copy",className:a("absolute bottom-1 right-1 flex h-6 w-6 items-center justify-center","rounded text-gray-500 transition-colors","hover:bg-gray-100 hover:text-gray-800","dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100"),children:r?jsx(Check,{size:12}):jsx(Copy,{size:12})})]}),document.body)}function es({item:e,onOpen:t}){if(e.mediaType==="video"){let a=e.url.match(Ae),n=a?a[1]:null,r=n?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:void 0;return jsxs("button",{type:"button",onClick:t,className:"relative block overflow-hidden rounded-md border-0 bg-black/5 p-0",style:{width:72,height:72},"aria-label":e.altText||"Open video",children:[r?jsx("img",{src:r,alt:e.altText||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-[10px] text-gray-400",children:"Video"}),jsx(Ke,{label:e.altText||"Open video"})]})}return jsx("button",{type:"button",onClick:t,className:"block overflow-hidden rounded-md border-0 bg-transparent p-0 transition-opacity hover:opacity-80",style:{width:72,height:72},"aria-label":e.altText||"Open image",children:jsx("img",{src:e.url,alt:e.altText||"Image",className:"h-full w-full object-cover",loading:"lazy"})})}var ts={active:"bg-green-100 text-green-700",completed:"bg-green-100 text-green-700",success:"bg-green-100 text-green-700",enabled:"bg-green-100 text-green-700",pending:"bg-yellow-100 text-yellow-700",processing:"bg-yellow-100 text-yellow-700",in_progress:"bg-yellow-100 text-yellow-700",failed:"bg-red-100 text-red-700",error:"bg-red-100 text-red-700",disabled:"bg-red-100 text-red-700",inactive:"bg-gray-100 text-gray-700",draft:"bg-gray-100 text-gray-700"};function Pn(e,t){if(e==null)return jsx("span",{className:"text-gray-400",children:"-"});switch(t.type||"string"){case "number":return typeof e=="number"?e.toLocaleString():String(e);case "currency":return typeof e=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e):String(e);case "date":try{return new Date(e).toLocaleDateString()}catch{return String(e)}case "badge":{let n=String(e).toLowerCase().replace(/\s+/g,"_"),r=ts[n]||"bg-gray-100 text-gray-700";return jsx("span",{className:a("inline-block px-2 py-0.5 rounded-full text-xs font-medium",r),children:String(e)})}case "link":return jsx("a",{href:String(e),target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:String(e)});case "boolean":return e?jsx(Check,{size:18,className:"text-green-500"}):jsx(X,{size:18,className:"text-gray-400"});case "progress":{let n=typeof e=="number"?e:parseFloat(String(e));return jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${Math.min(100,Math.max(0,n))}%`}})}),jsxs("span",{className:"text-xs text-gray-500",children:[n.toFixed(0),"%"]})]})}default:return String(e)}}function zn(e,t,a){let n=e[a],r=t[a];return n==null?1:r==null?-1:typeof n=="number"&&typeof r=="number"?r-n:String(r).localeCompare(String(n))}function Pt({data:e,config:t,medias:a$1}){let{columns:n,rows:r}=e,i=t?.sortable!==false,s=t?.paginated||false,o=t?.pageSize||10,[c,d]=useState("asc"),[p,v]=useState(n[0]?.key||""),[y,P]=useState(0),b=k=>{d(p===k&&c==="asc"?"desc":"asc"),v(k);},h=useMemo(()=>{let k=[...r];return i&&p&&k.sort((Q,M)=>c==="desc"?zn(Q,M,p):-zn(Q,M,p)),s&&(k=k.slice(y*o,(y+1)*o)),k},[r,c,p,y,o,i,s]),S=Math.ceil(r.length/o),L=useMemo(()=>{let k=[],Q={},M=n.filter(fe=>fe.type==="media");return M.length===0?{items:k,lookup:Q}:(h.forEach((fe,Re)=>{M.forEach(ge=>{let he=fe[ge.key],_e=Ut(he,`${ge.key}-${Re}`,a$1);_e&&(Q[`${Re}::${ge.key}`]=k.length,k.push(_e));});}),{items:k,lookup:Q})},[h,n,a$1]),{index:R,open:N,close:T,navigate:f}=ht(L.items),[g,A]=useState(null),w=useRef(null),u=useRef(null),C=()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null);},$=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null);},K=(k,Q,M)=>{C(),$(),w.current=window.setTimeout(()=>{A({rowIdx:k,colKey:Q,rect:M}),w.current=null;},250);},G=()=>{C(),$(),u.current=window.setTimeout(()=>{A(null),u.current=null;},150);},ce=()=>{$();};useEffect(()=>()=>{C(),$();},[]),useEffect(()=>{R!==null&&(C(),$(),A(null));},[R]);let E=g&&n.find(k=>k.key===g.colKey),j=g&&E?Tn(h[g.rowIdx]?.[g.colKey]):"";return jsxs("div",{className:"w-full overflow-x-auto",children:[jsxs("table",{className:"min-w-full text-sm",children:[jsx("thead",{children:jsx("tr",{children:n.map(k=>jsx("th",{className:a("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",i&&k.type!=="media"&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:k.width,textAlign:k.align||"left"},onClick:()=>i&&k.type!=="media"&&b(k.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[k.label,i&&k.type!=="media"&&p===k.key&&(c==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},k.key))})}),jsxs("tbody",{children:[h.map((k,Q)=>jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:n.map(M=>{if(M.type==="media"){let ge=Ut(k[M.key],`${M.key}-${Q}`,a$1);return jsx("td",{className:"px-3 py-2 align-middle",style:{textAlign:M.align||"left"},children:ge?jsx(es,{item:ge,onOpen:()=>{let he=L.lookup[`${Q}::${M.key}`];typeof he=="number"&&N(he);}}):jsx("span",{className:"text-gray-400",children:"-"})},M.key)}let fe=Qi.has(M.type||"string"),Re=Tn(k[M.key]);return jsx("td",{className:a("px-3 py-2 align-top",fe?"max-w-[300px]":"max-w-[320px]"),style:{textAlign:M.align||"left"},onMouseEnter:ge=>{if(!Re)return;let he=ge.currentTarget.getBoundingClientRect();K(Q,M.key,he);},onMouseLeave:()=>{G();},children:fe?jsx("div",{className:"overflow-hidden whitespace-nowrap text-ellipsis",children:Pn(k[M.key],M)}):jsx("div",{className:"whitespace-normal break-words [display:-webkit-box] [-webkit-line-clamp:2] [-webkit-box-orient:vertical] overflow-hidden",children:Pn(k[M.key],M)})},M.key)})},Q)),h.length===0&&jsx("tr",{children:jsx("td",{colSpan:n.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),g&&E&&R===null&&jsx(Ji,{text:j,anchorRect:g.rect,onEnter:ce,onLeave:G}),R!==null&&jsx(gt,{items:L.items,index:R,onClose:T,onNavigate:f}),s&&r.length>o&&jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 text-sm",children:[jsxs("span",{className:"text-gray-500",children:[y*o+1,"-",Math.min((y+1)*o,r.length)," of ",r.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>P(Math.max(0,y-1)),disabled:y===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsx("button",{onClick:()=>P(Math.min(S-1,y+1)),disabled:y>=S-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function zt({data:e,config:t,onAction:a$1}){let{subtitle:n,imageUrl:r,sections:i,actions:s}=e,o=t?.collapsible||false,c=t?.initiallyCollapsed||false,[d,p]=useState(!c),v=b=>{b.startsWith("http://")||b.startsWith("https://")||b.startsWith("/")?window.open(b,"_blank","noopener,noreferrer"):a$1?a$1({type:"card_action",action:b}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:b}}));},y=(b,h)=>jsxs("div",{className:a(h<i.length-1&&"mb-4"),children:[b.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:b.title}),b.items&&b.items.length>0&&jsx("div",{className:"space-y-1",children:b.items.map((S,L)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:S.label}),jsx("span",{className:"text-sm font-medium text-right",children:S.value})]},L))}),b.content&&jsx(oe,{children:b.content})]},h),P=jsxs(Fragment,{children:[r&&jsx("img",{src:r,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),n&&jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:n}),i.map((b,h)=>jsxs("div",{children:[y(b,h),h<i.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},h))]});return jsxs("div",{className:"w-full",children:[o&&jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>p(!d),children:[jsx("span",{className:"text-sm text-gray-500",children:d?"Click to collapse":"Click to expand"}),jsx("button",{className:"p-1",children:d?jsx(ChevronUp,{size:18}):jsx(ChevronDown,{size:18})})]}),(!o||d)&&P,s&&s.length>0&&jsx("div",{className:"flex gap-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:s.map((b,h)=>jsxs("button",{onClick:()=>v(b.action),className:a("px-3 py-1.5 text-sm rounded-lg transition-colors",b.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":b.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[b.label,b.action.startsWith("http")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},h))})]})}var ss=["#3B82F6","#10B981","#F59E0B","#8B5CF6"],En=[{label:"text-blue-700 dark:text-blue-300",stripeFrom:"#3b82f6",stripeTo:"#2563eb",tintFrom:"rgba(59,130,246,0.10)",tintMid:"rgba(59,130,246,0.025)",border:"border-blue-200 dark:border-blue-900",borderHover:"hover:border-blue-400 dark:hover:border-blue-700",spark:"#3b82f6",glow:"0 8px 24px rgba(59,130,246,0.18)"},{label:"text-emerald-700 dark:text-emerald-300",stripeFrom:"#10b981",stripeTo:"#059669",tintFrom:"rgba(16,185,129,0.10)",tintMid:"rgba(16,185,129,0.025)",border:"border-emerald-200 dark:border-emerald-900",borderHover:"hover:border-emerald-400 dark:hover:border-emerald-700",spark:"#10b981",glow:"0 8px 24px rgba(16,185,129,0.18)"},{label:"text-purple-700 dark:text-purple-300",stripeFrom:"#a855f7",stripeTo:"#9333ea",tintFrom:"rgba(168,85,247,0.10)",tintMid:"rgba(168,85,247,0.025)",border:"border-purple-200 dark:border-purple-900",borderHover:"hover:border-purple-400 dark:hover:border-purple-700",spark:"#a855f7",glow:"0 8px 24px rgba(168,85,247,0.18)"},{label:"text-orange-700 dark:text-orange-300",stripeFrom:"#f97316",stripeTo:"#ea580c",tintFrom:"rgba(249,115,22,0.10)",tintMid:"rgba(249,115,22,0.025)",border:"border-orange-200 dark:border-orange-900",borderHover:"hover:border-orange-400 dark:hover:border-orange-700",spark:"#f97316",glow:"0 8px 24px rgba(249,115,22,0.18)"},{label:"text-pink-700 dark:text-pink-300",stripeFrom:"#ec4899",stripeTo:"#db2777",tintFrom:"rgba(236,72,153,0.10)",tintMid:"rgba(236,72,153,0.025)",border:"border-pink-200 dark:border-pink-900",borderHover:"hover:border-pink-400 dark:hover:border-pink-700",spark:"#ec4899",glow:"0 8px 24px rgba(236,72,153,0.18)"},{label:"text-teal-700 dark:text-teal-300",stripeFrom:"#14b8a6",stripeTo:"#0d9488",tintFrom:"rgba(20,184,166,0.10)",tintMid:"rgba(20,184,166,0.025)",border:"border-teal-200 dark:border-teal-900",borderHover:"hover:border-teal-400 dark:hover:border-teal-700",spark:"#14b8a6",glow:"0 8px 24px rgba(20,184,166,0.18)"}];function ls(e){return En[e%En.length]}function cs({metric:e,color:t,animate:a$1}){let n=e.trend==="up"?jsx(ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsx(ArrowDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsx(Minus,{size:14,className:"text-gray-400"}):null,r=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",i=e.sparkline?.map((s,o)=>({value:s,idx:o}));return jsxs("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 relative overflow-hidden",children:[i&&i.length>0&&jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 opacity-30",children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsx(AreaChart,{data:i,margin:{top:0,right:0,left:0,bottom:0},children:jsx(Area,{type:"monotone",dataKey:"value",stroke:e.color||t,fill:e.color||t,strokeWidth:1,isAnimationActive:a$1})})})}),jsxs("div",{className:"relative z-10",children:[jsx("span",{className:"text-xs text-gray-500 font-medium uppercase tracking-wider",children:e.label}),jsxs("div",{className:"flex items-baseline gap-1 mt-1",children:[jsx("span",{className:"text-2xl font-bold",children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500",children:e.unit})]}),(e.trend||e.change!==void 0&&e.change!==null)&&jsxs("div",{className:"flex items-center gap-1 mt-2",children:[n,e.change!==void 0&&e.change!==null&&jsx("span",{className:a("text-sm font-medium",r),children:typeof e.change=="number"?`${e.change>0?"+":""}${e.change}`:e.change}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function ga({metric:e,index:t,isHero:a$1,animate:n}){let r=ls(t),i=e.sparkline?.map((p,v)=>({value:p,idx:v})),s=a$1&&i&&i.length>1,o=e.trend==="up"?ArrowUp:e.trend==="down"?ArrowDown:Minus,c=e.trend==="up"?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300":e.trend==="down"?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300",d=e.change!==void 0&&e.change!==null;return jsxs("div",{className:a("relative h-full rounded-xl border bg-white dark:bg-gray-900 overflow-hidden transition-all",r.border,r.borderHover,"hover:-translate-y-0.5",a$1?"p-5":"p-4"),style:{background:a$1?`linear-gradient(135deg, ${r.tintFrom} 0%, ${r.tintMid} 60%, transparent 100%), var(--kpi-bg, white)`:void 0},children:[jsx("div",{"aria-hidden":true,className:"absolute left-0 top-0 bottom-0",style:{width:a$1?4:3,background:`linear-gradient(180deg, ${r.stripeFrom}, ${r.stripeTo})`}}),s&&jsx("div",{"aria-hidden":true,className:"absolute left-0 right-0 bottom-0 pointer-events-none",style:{height:56,opacity:.35},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsxs(AreaChart,{data:i,margin:{top:0,right:0,left:0,bottom:0},children:[jsx("defs",{children:jsxs("linearGradient",{id:`spark-${t}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx("stop",{offset:"0%",stopColor:r.spark,stopOpacity:.6}),jsx("stop",{offset:"100%",stopColor:r.spark,stopOpacity:0})]})}),jsx(Area,{type:"monotone",dataKey:"value",stroke:r.spark,fill:`url(#spark-${t})`,strokeWidth:1.5,isAnimationActive:n})]})})}),jsxs("div",{className:a("relative z-10",a$1?"pl-1":"pl-0.5"),children:[jsx("span",{className:a("block font-semibold uppercase tracking-wider",r.label,a$1?"text-xs":"text-[0.7rem]"),children:e.label}),jsxs("div",{className:a("flex items-baseline gap-1",a$1?"mt-2":"mt-1"),children:[jsx("span",{className:a("font-extrabold tabular-nums text-gray-900 dark:text-gray-100 leading-tight tracking-tight",a$1?"text-4xl sm:text-5xl":"text-2xl"),children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:e.unit})]}),(d||e.changeLabel)&&jsxs("div",{className:a("flex items-center gap-1.5 flex-wrap",a$1?"mt-3":"mt-2"),children:[d&&jsxs("span",{className:a("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-bold tabular-nums",c),children:[jsx(o,{size:a$1?14:12,strokeWidth:2.5}),typeof e.change=="number"?`${e.change>0?"+":""}${e.change}`:e.change]}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.changeLabel})]})]})]})}function ds(e){let t=e.findIndex(a=>a.prominence==="primary");return t>=0?t:0}function ps({metrics:e,animate:t}){if(e.length===0)return null;if(e.length===1)return jsx("div",{className:"w-full",children:jsx(ga,{metric:e[0],index:0,isHero:true,animate:t})});let a$1=ds(e),n=e[a$1],r=e.map((c,d)=>({m:c,i:d})).filter(({i:c})=>c!==a$1),i=r.length,s=i<=3?Math.max(2,i):i>=7?3:2;return jsxs("div",{className:"w-full grid gap-4 md:[grid-template-columns:minmax(0,5fr)_minmax(0,7fr)] items-stretch",children:[jsx("div",{className:"md:min-h-[220px]",children:jsx(ga,{metric:n,index:a$1,isHero:true,animate:t})}),jsx("div",{className:a("grid gap-4 grid-cols-2",s===2?"sm:grid-cols-2":s===3?"sm:grid-cols-3":"sm:grid-cols-2"),children:r.map(({m:c,i:d})=>jsx(ga,{metric:c,index:d,isHero:false,animate:t},d))})]})}function At({data:e,config:t,isStreaming:a$1=false}){let{metrics:n,layout:r="row"}=e,i=t?.colors||ss,s=t?.animate!==false&&!a$1;if(r==="bento")return jsx("div",{className:"w-full",children:jsx(ps,{metrics:n,animate:s})});let o=r==="grid";return jsx("div",{className:a("w-full",o?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:n.map((c,d)=>jsx("div",{className:a(!o&&"flex-1 min-w-[200px]"),children:jsx(cs,{metric:c,color:c.color||i[d%i.length],animate:s})},d))})}var ys={js:"javascript",ts:"typescript",jsx:"jsx",tsx:"tsx",py:"python",rb:"ruby",rs:"rust",go:"go",java:"java",cpp:"cpp",c:"c",cs:"csharp",sh:"bash",bash:"bash",sql:"sql",html:"html",css:"css",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",graphql:"graphql"};function Et({data:e}){let{code:t,language:a,lineNumbers:n=true,highlightLines:r=[],startLine:i=1}=e,[s,o]=useState(false),c=ys[a.toLowerCase()]||a.toLowerCase(),d=async()=>{try{await navigator.clipboard.writeText(t),o(!0);}catch{}};return useEffect(()=>{if(s){let v=setTimeout(()=>o(false),2e3);return ()=>clearTimeout(v)}},[s]),jsxs("div",{className:"relative rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(FileText,{size:16,className:"text-gray-400"}),jsx("span",{className:"text-xs font-mono text-gray-400 lowercase",children:c})]}),jsx("button",{onClick:d,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-white/10 transition-colors text-gray-400 hover:text-gray-200",title:s?"Copied!":"Copy code",children:s?jsx(Check,{size:14,className:"text-green-400"}):jsx(Copy,{size:14})})]}),jsx(Prism,{language:c,style:oneDark,showLineNumbers:n,startingLineNumber:i,wrapLines:true,lineProps:v=>{let y={};return r.includes(v)&&(y.backgroundColor="rgba(59, 130, 246, 0.1)",y.display="block",y.borderLeft="3px solid #3B82F6",y.paddingLeft="8px",y.marginLeft="-11px"),{style:y}},customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6",background:"#1e1e1e"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:t.trim()})]})}function Mt({data:e,config:t,isStreaming:a$1=false,onAction:n}){let{fields:r,submitAction:i}=e,s=t?.submitButtonText||"Submit",o=t?.cancelButtonText||"Cancel",[c,d]=useState(()=>{let f={};return r.forEach(g=>{g.defaultValue!==void 0?f[g.name]=g.defaultValue:g.type==="multiselect"?f[g.name]=[]:g.type==="checkbox"?f[g.name]=false:f[g.name]="";}),f}),[p,v]=useState({}),[y,P]=useState(false),b=(f,g)=>{d(A=>({...A,[f]:g})),p[f]&&v(A=>{let w={...A};return delete w[f],w});},h=()=>{let f={};return r.forEach(g=>{let A=c[g.name];if(g.required&&(A==null||A===""||Array.isArray(A)&&A.length===0)){f[g.name]=`${g.label} is required`;return}if(!(!A&&!g.required)){if(g.validation){let{min:w,max:u,pattern:C,message:$}=g.validation;w!==void 0&&typeof A=="number"&&A<w&&(f[g.name]=$||`Minimum value is ${w}`),u!==void 0&&typeof A=="number"&&A>u&&(f[g.name]=$||`Maximum value is ${u}`),C&&typeof A=="string"&&!new RegExp(C).test(A)&&(f[g.name]=$||"Invalid format");}g.type==="email"&&typeof A=="string"&&A&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A)&&(f[g.name]="Invalid email address");}}),v(f),Object.keys(f).length===0},S=f=>{f.preventDefault(),h()&&(n?n({type:"form_submit",action:i||"",data:c}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:i,data:c}})),P(true));},L=()=>{n?n({type:"form_cancel",action:i||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:i}}));};if(y)return jsxs("div",{className:"text-center py-8",children:[jsx("p",{className:"text-lg font-semibold text-green-500 mb-1",children:"Form Submitted"}),jsx("p",{className:"text-sm text-gray-500",children:"Your response has been recorded."})]});let R="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-colors",N="border-red-500 focus:ring-red-500/20 focus:border-red-500",T=f=>{let g=c[f.name],w=!!p[f.name];switch(f.type){case "text":case "email":case "number":return jsx("input",{type:f.type,placeholder:f.placeholder,required:f.required,value:String(g||""),onChange:u=>b(f.name,f.type==="number"?parseFloat(u.target.value)||"":u.target.value),className:a(R,w&&N),min:f.validation?.min,max:f.validation?.max});case "textarea":return jsx("textarea",{placeholder:f.placeholder,required:f.required,value:String(g||""),onChange:u=>b(f.name,u.target.value),className:a(R,"min-h-[100px] resize-y",w&&N),rows:4});case "select":return jsxs("select",{value:String(g||""),onChange:u=>b(f.name,u.target.value),className:a(R,w&&N),children:[jsx("option",{value:"",disabled:true,children:f.placeholder||"Select an option"}),f.options?.map(u=>jsx("option",{value:u.value,children:u.label},u.value))]});case "multiselect":return jsx("select",{multiple:true,value:g||[],onChange:u=>b(f.name,Array.from(u.target.selectedOptions,C=>C.value)),className:a(R,"min-h-[80px]",w&&N),children:f.options?.map(u=>jsx("option",{value:u.value,children:u.label},u.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!g,onChange:u=>b(f.name,u.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:f.label})]});case "radio":return jsx("div",{className:"space-y-1",children:f.options?.map(u=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:f.name,value:u.value,checked:g===u.value,onChange:C=>b(f.name,C.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),u.label]},u.value))});case "date":return jsx("input",{type:"date",value:String(g||""),onChange:u=>b(f.name,u.target.value),className:a(R,w&&N)});case "datetime":return jsx("input",{type:"datetime-local",value:String(g||""),onChange:u=>b(f.name,u.target.value),className:a(R,w&&N)});default:return null}};return jsxs("form",{onSubmit:S,className:"space-y-4",children:[r.map(f=>jsxs("div",{children:[f.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[f.label,f.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),T(f),p[f.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:p[f.name]})]},f.name)),jsxs("div",{className:"flex gap-2 pt-2",children:[jsx("button",{type:"submit",disabled:a$1,className:"px-4 py-2 text-sm rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 transition-colors",children:s}),jsx("button",{type:"button",onClick:L,className:"px-4 py-2 text-sm rounded-lg border border-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:o})]})]})}var Bn="__miiflow_visualization_registry__",Rt=globalThis[Bn]??(globalThis[Bn]=new Map);function Be(e,t){Rt.set(e,t);}function Lt(e){return Rt.get(e)}function _n(){return Array.from(Rt.keys())}Be("chart",{component:Tt});Be("table",{component:Pt});Be("card",{component:zt});Be("kpi",{component:At});Be("code_preview",{component:Et});Be("form",{component:Mt});function Fn(e){for(let[t,a]of Object.entries(e)){let n=Rt.get(t);n&&(n.schema=a);}}var vs=z.object({name:z.string(),data:z.array(z.union([z.object({x:z.union([z.string(),z.number()]),y:z.number()}),z.object({name:z.string(),value:z.number()})])),color:z.string().nullish()}),jn=z.object({label:z.string().nullish(),type:z.enum(["category","number","time"]).nullish(),min:z.number().nullish(),max:z.number().nullish()}),xa=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(vs),xAxis:jn.nullish(),yAxis:jn.nullish()}),ks=z.object({key:z.string(),label:z.string(),type:z.enum(["string","number","currency","date","badge","link","boolean","progress","media"]).nullish(),align:z.enum(["left","center","right"]).nullish(),width:z.string().nullish()}),ya=z.object({columns:z.array(ks),rows:z.array(z.record(z.string(),z.unknown()))}),ws=z.object({title:z.string().nullish(),items:z.array(z.object({label:z.string(),value:z.union([z.string(),z.number()])})).nullish(),content:z.string().nullish()}),Cs=z.object({label:z.string(),action:z.string(),variant:z.enum(["primary","secondary","text"]).nullish()}),va=z.object({subtitle:z.string().nullish(),imageUrl:z.string().nullish(),sections:z.array(ws),actions:z.array(Cs).nullish()}),Ns=z.object({label:z.string(),value:z.union([z.string(),z.number()]),unit:z.string().nullish(),trend:z.enum(["up","down","neutral"]).nullish(),change:z.union([z.string(),z.number()]).nullish(),changeLabel:z.string().nullish(),sparkline:z.array(z.number()).nullish(),color:z.string().nullish()}),ka=z.object({metrics:z.array(Ns),layout:z.enum(["row","grid","bento"]).nullish()}),wa=z.object({code:z.string(),language:z.string(),lineNumbers:z.boolean().nullish(),highlightLines:z.array(z.number()).nullish(),startLine:z.number().nullish()}),Ss=z.object({name:z.string(),type:z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:z.string(),required:z.boolean().nullish(),placeholder:z.string().nullish(),options:z.array(z.object({value:z.string(),label:z.string()})).nullish(),defaultValue:z.unknown().nullish(),validation:z.object({min:z.number().nullish(),max:z.number().nullish(),pattern:z.string().nullish(),message:z.string().nullish()}).nullish()}),Ca=z.object({fields:z.array(Ss),submitAction:z.string().nullish()});Fn({chart:xa,table:ya,card:va,kpi:ka,code_preview:wa,form:Ca});function lt({data:e,isStreaming:t=false,onAction:a,medias:n}){let{type:r,title:i,description:s,data:o,config:c}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(i||s)&&jsxs("div",{className:"mb-2",children:[i&&jsx("p",{className:"text-sm font-semibold",children:i}),s&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s})]}),jsx("div",{children:(()=>{let p=Lt(r);if(!p)return jsxs("div",{className:"flex items-center gap-2 p-4 text-yellow-500",children:[jsx(AlertCircle,{size:20}),jsxs("span",{className:"text-sm",children:["Unknown visualization type: ",r]})]});if(p.schema){let y=p.schema.safeParse(o);if(!y.success){let P=y.error.issues.slice(0,3);return jsxs("div",{className:"p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/30",children:[jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 mb-2",children:[jsx(AlertCircle,{size:18}),jsxs("span",{className:"text-sm font-medium",children:["Invalid ",r," visualization data"]})]}),jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[P.map((b,h)=>jsxs("li",{children:[b.path.join("."),": ",b.message]},h)),y.error.issues.length>3&&jsxs("li",{children:["...and ",y.error.issues.length-3," more"]})]})]})}}let v=p.component;return jsx(v,{data:o,config:c,isStreaming:t,onAction:a,medias:n})})()})]})}function It({artifact:e,isStreaming:t,onOpen:a}){let n=e.status??"ready",r=n==="pending"||t&&n!=="failed",i=n==="failed",s=r||i;return jsxs("button",{type:"button",onClick:()=>{s||a?.(e);},disabled:s,"aria-label":i?`Artifact failed: ${e.title}`:`Open ${e.kind.toUpperCase()} artifact: ${e.title}`,"data-artifact-id":e.id,"data-artifact-status":n,style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",marginTop:"8px",background:i?"var(--miiflow-artifact-error-bg, #fdecea)":"var(--miiflow-artifact-bg, #f6f8fa)",border:"1px solid",borderColor:i?"var(--miiflow-artifact-error-border, #f1aeb5)":"var(--miiflow-artifact-border, #d0d7de)",borderRadius:"8px",font:"inherit",color:"inherit",textAlign:"left",cursor:s?i?"default":"progress":"pointer",width:"100%",maxWidth:"420px",opacity:r?.7:1},children:[jsx("span",{"aria-hidden":true,style:{fontSize:"22px",lineHeight:1,flex:"0 0 auto"},children:i?"\u26A0\uFE0F":"\u{1F4C4}"}),jsxs("span",{style:{flex:1,minWidth:0},children:[jsx("span",{style:{display:"block",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsx("span",{style:{display:"block",fontSize:"12px",color:i?"var(--miiflow-artifact-error-text, #b42318)":"var(--miiflow-artifact-meta, #57606a)"},children:i?e.errorMessage||"Generation failed":[e.kind.toUpperCase(),e.pageCount?`${e.pageCount} pages`:null,r?"generating\u2026":null].filter(Boolean).join(" \xB7 ")})]})]})}var On="__miiflow_artifact_registry__",Sa=globalThis[On]??(globalThis[On]=new Map);function Wn(e,t){Sa.set(e,t);}function Dt(e){return Sa.get(e)}function Kn(){return Array.from(Sa.keys())}function Vt({artifacts:e,isStreaming:t,onOpen:a}){return e?.length?jsx("div",{"data-artifact-list":true,style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(n=>{let i=Dt(n.kind)?.InlineCard??It;return jsx(i,{artifact:n,isStreaming:t,onOpen:a},n.id)})}):null}var Yn=/\[(VIZ|MEDIA|SA):([\w-]+)\]/gi;function qn(e){let t=[],a=0,n;for(Yn.lastIndex=0;(n=Yn.exec(e))!==null;){if(n.index>a){let i=e.slice(a,n.index);i.trim()&&t.push({type:"text",content:i});}let r=n[1].toUpperCase();r==="VIZ"?t.push({type:"viz",id:n[2]}):r==="SA"?t.push({type:"sa",id:n[2]}):t.push({type:"media",id:n[2]}),a=n.index+n[0].length;}if(a<e.length){let r=e.slice(a);r.trim()&&t.push({type:"text",content:r});}return t}var zs=[/```/,/\[VIZ:/,/\[SA:/,/\[MEDIA:/,/!\[/,/<img\b/i];function As(e){for(let t of zs)if(t.test(e))return false;return true}function Gn(e,t,a){let[n,r]=useState(void 0);return useEffect(()=>{if(!a){r(void 0);return}let i=e.current;if(!i||!t||!As(t))return;let s=false,o=()=>{if(s)return;let d=i.clientWidth;if(d<=0)return;let p=b(t,d);p&&r(v=>v===void 0||p.height>v?p.height:v);};o();let c=typeof ResizeObserver<"u"?new ResizeObserver(o):null;return c?.observe(i),()=>{s=true,c?.disconnect();}},[e,t,a]),n}var Ls=({ytId:e,altText:t})=>{let[a,n]=useState(false),r=`https://i.ytimg.com/vi/${e}/hqdefault.jpg`;return jsxs("div",{className:"my-3",children:[jsx("div",{className:"relative w-full overflow-hidden rounded-lg",style:{maxWidth:640,aspectRatio:"16 / 9"},children:a?jsx("iframe",{src:`https://www.youtube.com/embed/${e}?autoplay=1`,title:t||"Video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:true,className:"absolute inset-0 h-full w-full border-0"}):jsxs("button",{type:"button",onClick:()=>n(true),className:"absolute inset-0 block border-0 bg-transparent p-0","aria-label":t||"Play video",children:[jsx("img",{src:r,alt:t||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}),jsx(Ke,{label:t||"Play video"})]})}),t&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:t})]})},Is=({url:e,posterUrl:t,altText:a})=>{let[n,r]=useState(false);return jsxs("div",{className:"my-3",children:[jsx("div",{className:"relative overflow-hidden rounded-lg",style:{maxWidth:640,maxHeight:512},children:n?jsxs("video",{controls:true,autoPlay:true,preload:"metadata",className:"block max-h-[512px] w-full rounded-lg",poster:t,children:[jsx("source",{src:e}),"Your browser does not support the video tag."]}):jsxs("button",{type:"button",onClick:()=>r(true),className:"block w-full border-0 bg-transparent p-0","aria-label":a||"Play video",children:[t?jsx("img",{src:t,alt:a||"Video preview",className:"block max-h-[512px] w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex w-full items-center justify-center bg-gray-900 text-gray-400",style:{aspectRatio:"16 / 9"},children:jsx("span",{className:"text-sm",children:"Click to load video"})}),jsx(Ke,{label:a||"Play video"})]})}),a&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:a})]})},Ds=({media:e,onOpen:t})=>{if(e.mediaType==="video"){let a$1=e.url.match(Ae),n=a$1?a$1[1]:null,r=n?`https://i.ytimg.com/vi/${n}/hqdefault.jpg`:void 0;return jsxs("button",{type:"button",onClick:t,className:a("relative block w-full overflow-hidden rounded-lg border-0 bg-black/5 p-0","aspect-square cursor-pointer transition-opacity hover:opacity-90"),style:{aspectRatio:"1 / 1"},"aria-label":e.altText||"Open video",children:[r?jsx("img",{src:r,alt:e.altText||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-xs text-gray-400",children:"Video"}),jsx(Ke,{label:e.altText||"Open video"})]})}return jsx("button",{type:"button",onClick:t,className:a("block w-full overflow-hidden rounded-lg border-0 bg-transparent p-0","aspect-square cursor-pointer transition-opacity hover:opacity-90"),style:{aspectRatio:"1 / 1"},"aria-label":e.altText||"Open image",children:jsx("img",{src:e.url,alt:e.altText||"Image",className:"h-full w-full object-cover",loading:"lazy"})})},Qn=forwardRef(({message:e,viewerRole:t="user",className:a$2,showAvatar:n=true,showTimestamp:r=true,renderMarkdown:i=true,reasoning:s,executionPlan:o,executionTimeline:c$1,suggestedActions:d$1,onSuggestedAction:p,reasoningExpanded:v,onReasoningExpandedChange:y,citations:P,visualizations:b,medias:h,artifacts:S,onArtifactOpen:L,baselineFontSize:R,executionTime:N,pendingClarification:T,onClarificationSubmit:f,pendingToolApproval:g,onToolApprove:A,onToolReject:w,renderInlineSuggestedAction:u,onReportIncorrect:C,onConfirmCorrect:$},K)=>{let ce=useContext(a$1)?.onVisualizationAction,E=(e.participant?.role||"").toLowerCase(),j=(t||"").toLowerCase(),k=E===j,Q=E==="assistant",M=e.isStreaming,fe=s?.filter(H=>H.type==="thinking"||H.type==="tool"||H.type==="observation"||H.type==="planning"||H.type==="subtask"||H.type==="subagent"),Re=fe&&fe.length>0,ge=!M&&(o||c$1&&c$1.length>0),he=Re||ge,_e=M&&!e.textContent&&!he,Ge=e.attachments,z=Ge&&Ge.length>0,q=useMemo(()=>{if(!b||b.length===0)return null;let H=new Map;return b.forEach(B=>H.set(B.id,B)),H},[b]),Y=q&&q.size>0||e.textContent&&/\[SA:[\w-]+\]/i.test(e.textContent),de=useMemo(()=>!Y||!e.textContent?null:qn(e.textContent),[Y,e.textContent]),pe=useMemo(()=>!h||h.length===0||!e.textContent?e.textContent:e.textContent.replace(/\[MEDIA:[a-f0-9-]+\]/gi,"").trim(),[e.textContent,h]),pr=()=>{if(!e.textContent)return null;if(de&&de.length>0&&Y){let H=new Set;return jsx(Fragment,{children:de.map((B,ze)=>{if(B.type==="text")return M?jsx(nt,{content:B.content,isStreaming:true,baselineFontSize:R},ze):jsx(oe,{baselineFontSize:R,className:k?"prose-invert":"",children:B.content},ze);if(B.type==="viz"){if(H.has(B.id))return null;let ja=q?.get(B.id);return ja?(H.add(B.id),jsx(lt,{data:ja,isStreaming:M,onAction:ce,medias:h},`viz-${B.id}`)):null}return B.type==="sa"&&u?jsx("div",{children:u(B.id)},`sa-${B.id}`):null})})}return M&&i?jsx(nt,{content:pe||"",isStreaming:true,baselineFontSize:R,className:k?"prose-invert":""}):i?jsx(oe,{baselineFontSize:R,className:k?"prose-invert":"",children:pe||""}):jsx("p",{className:"whitespace-pre-wrap",children:pe})},Oe=useMemo(()=>{if(!h||h.length===0)return [];let H=pe||"";return h.filter(B=>B.mediaType!=="image"?true:!H.includes(B.url)).map(B=>({id:B.id,url:B.url,mediaType:B.mediaType,altText:B.altText}))},[h,pe]),{index:Da,open:Va,close:mr,navigate:ur}=ht(Oe),fr=()=>{if(Oe.length===0)return null;if(Oe.length>=2)return jsx("div",{className:"my-3 grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",maxWidth:640},children:Oe.map((B,ze)=>jsx(Ds,{media:B,onOpen:()=>Va(ze)},`media-${B.id}`))});let H=Oe[0];if(H.mediaType==="image")return jsx("div",{className:"my-3",children:jsx("button",{type:"button",onClick:()=>Va(0),className:"block cursor-zoom-in border-0 bg-transparent p-0","aria-label":H.altText||"Open image",children:jsx("img",{src:H.url,alt:H.altText||"Generated image",className:"max-w-full rounded-lg",loading:"lazy",style:{maxHeight:512,display:"block"}})})});if(H.mediaType==="video"){let B=H.url.match(Ae);return B?jsx(Ls,{ytId:B[1],altText:H.altText},`media-${H.id}`):jsx(Is,{url:H.url,posterUrl:H.posterUrl,altText:H.altText},`media-${H.id}`)}return null},Ba=useRef(M);M&&(Ba.current=true);let gr=!M&&!Ba.current,_a=useRef(null),Fa=Gn(_a,e.textContent,!!M);return jsx(c,{ref:K,message:e,viewerRole:t,className:a("w-full",gr&&"animate-message-in",a$2),children:jsxs("div",{className:a("flex flex-col gap-1 w-full"),"data-is-viewer":k,children:[_e&&jsxs("div",{className:a("flex items-start gap-2 w-full"),children:[n&&!k&&jsx("div",{className:"flex-shrink-0",children:jsx(Le,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"px-4 py-3",children:jsx(Ze,{size:"small"})})]}),he&&Q&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(ua,{isStreaming:M,chunks:fe,plan:o,executionTimeline:c$1,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:N,expanded:v,onExpandedChange:y})}),e.textContent&&jsxs("div",{className:a("group flex items-start gap-2 w-full",k?"flex-row-reverse":"flex-row"),children:[n&&!k&&jsx("div",{className:"flex-shrink-0",children:jsx(Le,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{ref:_a,className:a("max-w-[85%]","flex flex-col"),"data-message-role":k?"viewer":"other",style:Fa?{minHeight:Fa}:void 0,children:[jsxs("div",{className:a("rounded-2xl",k||n?"px-4 py-3":""),style:{backgroundColor:k?"var(--chat-user-message-bg)":"transparent",color:k?"var(--chat-user-message-text, #ffffff)":"var(--chat-text)"},children:[jsx(d,{children:pr()}),fr(),Da!==null&&jsx(gt,{items:Oe,index:Da,onClose:mr,onNavigate:ur}),b&&b.length>0&&(()=>{let H=e.textContent||"",B=b.filter(ze=>!H.includes(`[VIZ:${ze.id}]`));return B.length===0?null:B.map(ze=>jsx("div",{className:"my-3",children:jsx(lt,{data:ze,isStreaming:M,onAction:ce,medias:h})},`viz-unreferenced-${ze.id}`))})(),S&&S.length>0&&jsx("div",{className:"mt-2",children:jsx(Vt,{artifacts:S,isStreaming:M,onOpen:L})}),P&&P.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(Yt,{sources:P})})]}),z&&jsx("div",{className:"mt-2",children:jsx(na,{attachments:Ge})}),!M&&(r&&e.createdAt||Q&&e.textContent)&&jsxs("div",{className:a("flex items-center gap-2 mt-1",k&&"flex-row-reverse"),children:[r&&e.createdAt&&jsx(Vs,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:k}),Q&&e.textContent&&jsx(ta,{textContent:e.textContent,onReportIncorrect:C,onConfirmCorrect:$})]})]})]}),e.error&&jsxs("div",{className:a("flex items-start gap-2 w-full max-w-[85%]","rounded-lg border px-3 py-2 mt-1"),style:{borderColor:"var(--chat-error, #B1001B)",backgroundColor:"color-mix(in srgb, var(--chat-error, #B1001B) 6%, transparent)",color:"var(--chat-error, #B1001B)"},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 mt-0.5",children:[jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{className:"text-sm",children:e.error.message})]}),!e.textContent&&n&&!k&&he&&!_e&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Le,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),T&&!M&&f&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(Xt,{clarification:T,onSubmit:f})}),g&&!M&&A&&w&&jsx("div",{className:"w-full",children:jsx(Jt,{approval:g,onApprove:A,onReject:w})}),d$1&&d$1.length>0&&!M&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(wt,{actions:d$1,onSelect:p})})]})})});Qn.displayName="Message";function Vs({createdAt:e}){return jsx("span",{className:"text-xs text-[var(--chat-text-subtle)]",children:(a=>{try{return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}})(e)})}var Ys=100*1024*1024,qs=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],Gs=["application/pdf","text/plain","text/csv","text/markdown","application/json","text/json","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],Xs=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],Zs=[...qs,...Gs,...Xs];function Jn(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+a[n]}function Qs(e,t,a){return e.size>a?`File size (${Jn(e.size)}) exceeds max (${Jn(a)})`:t.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function Js({attachments:e,onRemove:t,disabled:a$1}){return e.length===0?null:jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3 pb-0",children:e.map(n=>{let r=n.file.type.startsWith("image/"),i=n.status==="error",s=n.status==="uploading";return jsxs("div",{className:a("relative flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-xs max-w-[200px]",i?"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[s?jsx(Loader2,{size:14,className:"flex-shrink-0 animate-spin"}):i?jsx(AlertCircle,{size:14,className:"flex-shrink-0"}):r&&n.previewUrl?jsx("img",{src:n.previewUrl,alt:n.file.name,className:"w-5 h-5 rounded object-cover"}):r?jsx(Image,{size:14,className:"flex-shrink-0"}):jsx(FileText,{size:14,className:"flex-shrink-0"}),jsx("span",{className:"truncate",title:i?n.error:n.file.name,children:i?n.error:n.file.name}),!a$1&&jsx("button",{type:"button",onClick:()=>t(n.id),className:"flex-shrink-0 ml-0.5 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-zinc-600 transition-colors",children:jsx(X,{size:12})})]},n.id)})})}var tr=forwardRef(({onSubmit:e,onAttach:t,onUploadFile:a$1,onRemoveUploadedAttachment:n,disabled:r=false,supportsAttachments:i$1=true,allowedFileTypes:s=Zs,maxFileSize:o=Ys,placeholder:c="Type a message...",className:d,isSubmitting:p=false,centered:v=false,isStreaming:y=false,onStopStreaming:P,commandProvider:b,commandProviders:h},S)=>{let[L,R]=useState(false),[N,T]=useState([]),[f,g]=useState(false),A=useRef(null),w=useRef(null),u=useRef(0),C=useRef(false),$=r||p,K=N.some(z=>z.status==="uploading"),G=N.filter(z=>z.status==="uploaded"&&z.attachmentId).map(z=>z.attachmentId),ce=G.length>0||N.some(z=>z.status==="pending"),E=L||ce,j=useCallback(async z=>{let q=z.map(U=>{let Y=Qs(U,s,o),de={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:U,status:Y?"error":a$1?"uploading":"pending",error:Y||void 0};return !Y&&U.type.startsWith("image/")&&(de.previewUrl=URL.createObjectURL(U)),de});if(T(U=>[...U,...q]),t?.(z),a$1){for(let U of q)if(U.status==="uploading")try{let Y=await a$1(U.file);T(de=>de.map(pe=>pe.id===U.id?{...pe,status:"uploaded",attachmentId:Y}:pe));}catch(Y){T(de=>de.map(pe=>pe.id===U.id?{...pe,status:"error",error:Y instanceof Error?Y.message:"Upload failed"}:pe));}}},[s,o,a$1,t]),k=useCallback(async z=>{if(!E&&z.trim().length===0||$||K||C.current)return;C.current=true;let q=N.filter(Y=>Y.status!=="error").map(Y=>Y.file),U=N;w.current?.clear(),R(false),T([]);try{a$1&&G.length>0?await e(z,void 0,G):await e(z,q.length>0?q:void 0);}catch{T(U);}finally{C.current=false;}},[N,E,$,K,e,a$1,G]),Q=useCallback(()=>{w.current?.submit();},[]),M=useCallback(z=>{let q=z.target.files;!q||q.length===0||(j(Array.from(q)),z.target.value="");},[j]),fe=useCallback(z=>{if(!i$1||p)return;let q=z.clipboardData;if(!q)return;let U=[];for(let Y of q.files)U.push(Y);if(U.length===0&&q.items){for(let Y of q.items)if(Y.kind==="file"){let de=Y.getAsFile();de&&U.push(de);}}U.length>0&&(z.preventDefault(),j(U));},[i$1,p,j]),Re=useCallback(z=>{T(q=>{let U=q.find(Y=>Y.id===z);return U?.previewUrl&&URL.revokeObjectURL(U.previewUrl),U?.attachmentId&&n&&n(U.attachmentId),q.filter(Y=>Y.id!==z)});},[n]),ge=useCallback(z=>{z.preventDefault(),z.stopPropagation(),!(!i$1||p)&&(u.current++,z.dataTransfer.types.includes("Files")&&g(true));},[i$1,p]),he=useCallback(z=>{z.preventDefault(),z.stopPropagation(),u.current--,u.current===0&&g(false);},[]),_e=useCallback(z=>{z.preventDefault(),z.stopPropagation();},[]),Ge=useCallback(z=>{if(z.preventDefault(),z.stopPropagation(),u.current=0,g(false),!i$1||p)return;let q=Array.from(z.dataTransfer.files);q.length>0&&j(q);},[i$1,p,j]);return useEffect(()=>()=>{N.forEach(z=>{z.previewUrl&&URL.revokeObjectURL(z.previewUrl);});},[]),jsx("div",{ref:S,className:a("flex-shrink-0",v?"p-0 bg-transparent":"px-3 pb-3",d),style:v?{padding:0,background:"transparent",border:"none"}:void 0,onDragEnter:ge,onDragLeave:he,onDragOver:_e,onDrop:Ge,children:jsxs("div",{className:a("mx-auto max-w-[900px]","chat-composer-shell group",v?"overflow-hidden":"rounded-xl",f&&"ring-2 ring-[var(--chat-primary,#106997)] border-[var(--chat-primary,#106997)]"),style:v?{borderRadius:"1rem",overflow:"hidden"}:void 0,children:[f&&jsx("div",{className:"px-3 pt-3 pb-0",children:jsx("div",{className:"flex items-center justify-center py-4 rounded-lg border-2 border-dashed border-[var(--chat-composer-border-focus,rgba(16,105,151,0.35))] bg-[var(--chat-panel-bg,rgba(0,0,0,0.02))] text-[var(--chat-primary,#106997)] text-sm",children:"Drop files here"})}),jsx(Js,{attachments:N,onRemove:Re,disabled:p}),jsx("div",{className:a(v?"px-4 pt-3.5":"px-3 pt-2.5",N.length>0&&"pt-1.5"),onPaste:fe,children:jsx(i,{ref:w,placeholder:c,disabled:$,commandProvider:b??null,commandProviders:h,inputClassName:a("text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500"),onChange:({text:z})=>R(z.trim().length>0),onSubmit:({text:z})=>k(z)})}),jsx(Xe,{className:v?"px-2.5 pb-2.5 pt-1":"px-2 pb-2 pt-1",onAttachClick:i$1?()=>A.current?.click():void 0,disabled:p,endSlot:y&&P?jsxs("div",{className:"relative flex-shrink-0 w-8 h-8",children:[jsx("span",{className:"absolute inset-0 rounded-lg bg-gray-400 dark:bg-zinc-400",style:{animation:"streaming-flash 3s ease-in-out infinite"}}),jsx("button",{type:"button",onClick:P,"aria-label":"Stop generating",className:a("relative w-full h-full rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-100 text-white dark:text-zinc-900","hover:bg-gray-700 dark:hover:bg-zinc-300","transition-colors duration-200"),children:jsx(Square,{size:14,fill:"currentColor"})})]}):jsx("button",{type:"button",onClick:Q,disabled:!E||$||K,"aria-label":"Send message",className:a("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-100 text-white dark:text-zinc-900","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-300","active:scale-95","disabled:bg-gray-200 dark:disabled:bg-zinc-700 disabled:text-gray-400 dark:disabled:text-zinc-500 disabled:shadow-none disabled:cursor-not-allowed","transition-[background-color,color,transform] duration-150"),children:p||K?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})}),i$1&&jsx("input",{ref:A,type:"file",multiple:true,accept:s.join(","),onChange:M,className:"hidden"})]})})});tr.displayName="MessageComposer";function Aa({isAtBottom:e,onScrollToBottom:t,className:a$1}){return jsx("button",{type:"button",onClick:t,"aria-label":"Scroll to bottom",className:a("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center","w-8 h-8 rounded-full","bg-[var(--chat-bg,#ffffff)] border border-[var(--chat-border)]","shadow-subtle hover:shadow-button-hover","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","transition-all duration-200",e?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0",a$1),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 5v14"}),jsx("path",{d:"m19 12-7 7-7-7"})]})})}var nr=forwardRef(({children:e,autoScroll:t=true,showScrollToBottom:a$1=true,className:n},r)=>{let{containerRef:i,scrollToBottom:s,isAtBottom:o}=a$2({enabled:t});return jsxs("div",{className:"relative flex-1 overflow-hidden",style:{mask:"linear-gradient(to bottom, black 0%, black calc(100% - 20px), transparent 100%)",WebkitMask:"linear-gradient(to bottom, black 0%, black calc(100% - 20px), transparent 100%)"},children:[jsx("div",{ref:d=>{i.current=d,typeof r=="function"?r(d):r&&(r.current=d);},className:a("h-full overflow-y-auto","flex flex-col gap-4 p-4 pb-12","chat-scrollbar",n),children:e}),a$1&&jsx(Aa,{isAtBottom:o,onScrollToBottom:()=>s("smooth")})]})});nr.displayName="MessageList";function nl({label:e,className:t}){return jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${t??""}`,role:"separator",children:[jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"}),jsx("span",{className:"text-xs font-medium text-[var(--chat-text-subtle)] whitespace-nowrap",children:e}),jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"})]})}var or=forwardRef(({className:e},t)=>jsx(r,{ref:t,className:a("inline-flex items-center gap-1","px-4 py-3",e),children:jsx(Ze,{size:"small"})}));or.displayName="TypingIndicator";function dl({title:e,subtitle:t,logo:a$1,actions:n,showClose:r,onClose:i,loading:s,className:o,style:c}){let[d,p]=useState(false),v=useRef(null),y=useRef(null);return useEffect(()=>{let P=b=>{let h=b.composedPath();v.current&&!h.includes(v.current)&&y.current&&!h.includes(y.current)&&p(false);};if(d)return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[d]),jsxs("header",{className:a("flex items-center justify-between gap-3","px-4 py-2.5","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",o),style:c,children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[a$1&&jsx("div",{className:"flex-shrink-0",children:typeof a$1=="string"?jsx("img",{src:a$1,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):a$1}),jsxs("div",{className:"flex flex-col min-w-0",children:[s?jsx("div",{className:"h-5 w-24 bg-gray-200 rounded animate-pulse"}):jsx("h1",{className:"text-base font-semibold text-[var(--chat-text)] truncate",children:e}),t&&jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:t})]})]}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n&&n.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{ref:y,onClick:()=>p(!d),className:a("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Menu","aria-expanded":d,children:jsx(MoreVertical,{size:18})}),d&&jsx("div",{ref:v,className:a("absolute right-0 top-full mt-1 z-50","min-w-[180px]","bg-[var(--chat-composer-bg,#ffffff)] rounded-lg","shadow-[0_1px_2px_rgba(29,32,51,0.04),0_8px_24px_-12px_rgba(29,32,51,0.24)]","border border-[var(--chat-border)]","py-1","animate-fade-in"),children:n.map(P=>jsxs("button",{onClick:()=>{P.onClick(),p(false);},disabled:P.disabled,className:a("w-full flex items-center gap-2 px-3 py-2","text-sm text-left","text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors duration-150"),children:[P.icon&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:P.icon}),P.label]},P.id))})]}),r&&i&&jsx("button",{onClick:i,className:a("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Close",children:jsx(X,{size:18})})]})]})}function pl({toolName:e,status:t,description:a$1,className:n}){return jsxs("div",{className:a("relative flex items-center gap-2 py-1 px-2 rounded-md text-sm overflow-hidden",t==="running"&&"animate-shimmer",n),children:[jsx(ml,{status:t}),jsx("span",{className:"font-medium text-[var(--chat-text)]",children:e}),a$1&&jsx("span",{className:"text-[var(--chat-text-subtle)] truncate",children:a$1})]})}function ml({status:e}){switch(e){case "running":return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin text-[var(--chat-primary)]",children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})});case "complete":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-secondary,#56C18A)]",children:[jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]});case "failed":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-error,#B1001B)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]});case "pending":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-text-subtle)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]})}}var sr=forwardRef(({isEmpty:e,header:t,welcomeScreen:a$1,messageList:n,composer:r,footer:i,className:s},o)=>jsx("div",{ref:o,"data-chat-ui":true,className:a("relative h-full overflow-hidden flex flex-col min-h-0",s),children:jsx(AnimatePresence,{mode:"wait",children:e&&a$1?jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[t,a$1]},"welcome"):jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[t,jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:n}),jsxs(motion.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.1},className:"relative z-10",children:[i,r]})]},"active")})}));sr.displayName="ChatLayout";function yl(e,t=3e3){let[a,n]=useState(0),r=useRef(null);return useEffect(()=>{if(e.length<=1)return;let i=()=>{r.current=setInterval(()=>{n(o=>(o+1)%e.length);},t);},s=()=>{document.visibilityState!=="visible"?r.current&&(clearInterval(r.current),r.current=null):i();};return i(),document.addEventListener("visibilitychange",s),()=>{r.current&&clearInterval(r.current),document.removeEventListener("visibilitychange",s);}},[e,t]),e[a]??""}function vl({placeholder:e,onSubmit:t,disabled:a$1,supportsAttachments:n,commandProvider:r,commandProviders:i$1}){let[s,o]=useState(false),[c,d]=useState([]),p=useRef(null),v=useRef(null),y=useCallback(S=>{!S.trim()&&c.length===0||a$1||(t(S.trim(),c.length>0?c:void 0),p.current?.clear(),o(false),d([]));},[a$1,c,t]),P=S=>{S.target.files&&d(L=>[...L,...Array.from(S.target.files)]),S.target.value="";},b=S=>{d(L=>L.filter((R,N)=>N!==S));},h=(s||c.length>0)&&!a$1;return jsxs("div",{className:a("w-full relative mx-auto","rounded-2xl overflow-hidden","chat-composer-shell group"),style:{borderRadius:"1rem",overflow:"hidden"},children:[c.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:c.map((S,L)=>jsxs("div",{className:a("flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs","bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[jsx("span",{className:"max-w-[120px] truncate",children:S.name}),jsx("button",{type:"button",onClick:()=>b(L),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${S.name}-${L}`))}),jsx(i,{ref:p,placeholder:e,disabled:a$1,commandProvider:r??null,commandProviders:i$1,className:"px-4 sm:px-5 pt-3.5 sm:pt-4 pb-1",inputClassName:"text-sm sm:text-base text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-zinc-500",placeholderClassName:"text-sm sm:text-base",onChange:({text:S})=>o(S.trim().length>0),onSubmit:({text:S})=>y(S)}),jsx(Xe,{className:"px-2.5 pb-2.5 pt-1",onAttachClick:n?()=>v.current?.click():void 0,disabled:a$1,endSlot:jsx("button",{type:"button",onClick:()=>p.current?.submit(),disabled:!h,"aria-label":"Send message",className:a("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-zinc-50","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","active:scale-95","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:cursor-not-allowed","transition-[background-color,color,transform] duration-150"),children:jsx(ArrowUp,{size:16,strokeWidth:2})})}),n&&jsx("input",{ref:v,type:"file",multiple:true,onChange:P,className:"hidden"})]})}function kl({text:e,onClick:t,index:a$1}){return jsx(motion.button,{type:"button",onClick:t,initial:{opacity:0},animate:{opacity:1},transition:{delay:.15+a$1*.03,duration:.2},className:a("inline-flex items-center rounded-full","border border-[var(--chat-border,rgba(29,32,51,0.08))]","px-3.5 py-1.5","text-sm leading-normal text-left","text-[var(--chat-text-subtle,rgba(0,0,0,0.5))]","cursor-pointer select-none","transition-colors duration-150","hover:bg-[var(--chat-panel-bg,rgba(0,0,0,0.02))]","hover:border-[var(--chat-border-hover,rgba(0,0,0,0.12))]","hover:text-[var(--chat-text,#1d2033)]","active:bg-[var(--chat-message-bg,rgba(0,0,0,0.03))]"),style:{borderRadius:"9999px"},children:e})}var cr=forwardRef(({placeholders:e=[],suggestions:t=[],onSubmit:a$1,onSuggestionClick:n,welcomeText:r="How can I help you today?",supportsAttachments:i,composerSlot:s,commandProvider:o,commandProviders:c,className:d,assistantAvatar:p,assistantName:v},y)=>{let P=yl(e),b=useCallback(h=>{n?.(h);},[n]);return jsxs("div",{ref:y,className:a("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",d),children:[jsx("div",{className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(ellipse 60% 50% at 50% 45%, var(--chat-halo-primary, rgba(16,105,151,0.06)), var(--chat-halo-secondary, rgba(86,193,138,0.03)) 60%, transparent 100%)"}}),jsxs(motion.div,{layout:true,initial:{y:8,opacity:0},animate:{y:0,opacity:1},transition:{duration:.22,ease:[.16,1,.3,1]},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[r&&p?jsxs(motion.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.05,duration:.2,ease:[.4,0,.2,1]},className:"flex items-start gap-2 w-full",children:[jsx("div",{className:"flex-shrink-0",children:jsx(Le,{name:v,src:p,role:"assistant",className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"rounded-2xl px-4 py-3",children:jsx("p",{style:{fontSize:"1rem",lineHeight:"1.5rem",color:"var(--chat-text, #1d2033)"},className:"text-base",children:r})})]}):r?jsx(motion.h2,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.05,duration:.2,ease:[.4,0,.2,1]},style:{fontSize:"1.5rem",lineHeight:"2rem",fontWeight:600,letterSpacing:"-0.01em",color:"var(--chat-text, #1d2033)"},className:"text-2xl font-semibold text-center",children:r}):null,jsx("div",{className:"w-full",children:s??jsx(vl,{placeholder:P,onSubmit:(h,S)=>a$1?.(h,S),supportsAttachments:i,commandProvider:o??null,commandProviders:c})}),t.length>0&&jsx("div",{className:"flex flex-wrap justify-center gap-2 w-full max-w-[640px]",children:t.map((h,S)=>jsx(kl,{text:h,onClick:()=>b(h),index:S},S))})]})]})});cr.displayName="WelcomeScreen";function wl(e){return e?e.split(/[_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):"Sub-assistant"}function Cl({chunk:e}){let t=e.subagentData;if(!t)return null;let a=t.status==="running"?"running":t.status==="completed"?"completed":t.status==="failed"?"failed":"pending",n=(t.nestedChunks??[]).map((i,s)=>Ie(i,s)).filter(i=>i!==null);t.result&&t.result.trim().length>0&&n.push({id:`result-${t.subagentId}`,type:"thinking",status:t.status==="failed"?"failed":"completed",content:t.result});let r=[{id:t.subagentId,status:a,content:jsx(tt,{label:wl(t.subagentType),durationSeconds:t.durationMs!=null?t.durationMs/1e3:void 0,isFailed:t.status==="failed",nestedEvents:n})}];return jsx($e,{items:r,badgeSize:20})}
132
+ export{dl as $,Pt as A,zt as B,At as C,Et as D,Mt as E,Be as F,Lt as G,_n as H,xa as I,ya as J,va as K,ka as L,wa as M,Ca as N,lt as O,It as P,Wn as Q,Dt as R,Kn as S,Vt as T,qn as U,Qn as V,tr as W,Aa as X,nr as Y,nl as Z,or as _,Qa as a,pl as aa,Le as b,sr as ba,en as c,cr as ca,Xe as d,Cl as da,Ze as e,oe as f,Yt as g,rn as h,po as i,Xt as j,Jt as k,ta as l,na as m,yt as n,$e as o,Xo as p,sa as q,Ie as r,ni as s,Me as t,tt as u,ca as v,ua as w,nt as x,wt as y,Tt as z};//# sourceMappingURL=chunk-UZ2Z7C43.js.map
133
+ //# sourceMappingURL=chunk-UZ2Z7C43.js.map