@miiflow/assistant-ui 0.7.0 → 0.9.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.
- package/dist/{WelcomeScreen-XVZqMpVW.d.ts → WelcomeScreen-CVxniqqK.d.ts} +15 -4
- package/dist/{avatar-C13xc3tA.d.ts → avatar-DnLePg72.d.ts} +2 -2
- package/dist/branding-NieTEGQf.d.ts +32 -0
- package/dist/chunk-ERJKVQQT.js +132 -0
- package/dist/chunk-ERJKVQQT.js.map +1 -0
- package/dist/chunk-IUCKTDTZ.js +2 -0
- package/dist/chunk-IUCKTDTZ.js.map +1 -0
- package/dist/chunk-NG4HKXYB.js +2 -0
- package/dist/chunk-NG4HKXYB.js.map +1 -0
- package/dist/chunk-NKLA5PPB.js +2 -0
- package/dist/chunk-NKLA5PPB.js.map +1 -0
- package/dist/chunk-QECTWT2H.js +2 -0
- package/dist/chunk-QECTWT2H.js.map +1 -0
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +7 -5
- package/dist/client/index.js.map +1 -1
- package/dist/composer/index.d.ts +180 -0
- package/dist/composer/index.js +2 -0
- package/dist/composer/index.js.map +1 -0
- package/dist/context/index.d.ts +16 -3
- package/dist/context/index.js +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/index.d.ts +14 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{message-BrHFdwb2.d.ts → message-D2ElX5k7.d.ts} +2 -2
- package/dist/primitives/index.d.ts +3 -3
- package/dist/{streaming-DURrv9_E.d.ts → streaming-B_u_jno6.d.ts} +33 -122
- package/dist/styled/index.d.ts +169 -66
- package/dist/styled/index.js +1 -1
- package/dist/styles-no-preflight.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types-DeHbndy0.d.ts +48 -0
- package/package.json +18 -2
- package/dist/branding-SzYU4ncD.d.ts +0 -18
- package/dist/chunk-EI3GOLHT.js +0 -128
- package/dist/chunk-EI3GOLHT.js.map +0 -1
- package/dist/chunk-NSTK5EUQ.js +0 -2
- package/dist/chunk-NSTK5EUQ.js.map +0 -1
- package/dist/chunk-O2ILSWHS.js +0 -2
- package/dist/chunk-O2ILSWHS.js.map +0 -1
- package/dist/chunk-OCKHJ4WO.js +0 -2
- package/dist/chunk-OCKHJ4WO.js.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
-
import { A as Attachment, M as MessageData,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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';
|
|
6
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
8
|
|
|
8
9
|
interface AttachmentPreviewProps {
|
|
@@ -150,6 +151,11 @@ interface MessageComposerProps {
|
|
|
150
151
|
isStreaming?: boolean;
|
|
151
152
|
/** Callback to stop the current streaming response */
|
|
152
153
|
onStopStreaming?: () => void;
|
|
154
|
+
/** Optional slash-command typeahead provider (e.g. for skill picker). */
|
|
155
|
+
commandProvider?: CommandProvider | null;
|
|
156
|
+
/** Multiple typeahead providers for distinct triggers (e.g. `/` skills +
|
|
157
|
+
* modes plus `@` ad accounts). Takes precedence over `commandProvider`. */
|
|
158
|
+
commandProviders?: CommandProvider[];
|
|
153
159
|
}
|
|
154
160
|
/**
|
|
155
161
|
* MessageComposer with textarea, attachment support,
|
|
@@ -317,6 +323,11 @@ interface WelcomeScreenProps {
|
|
|
317
323
|
supportsAttachments?: boolean;
|
|
318
324
|
/** Override the default plain-text input with a custom composer (e.g. chat-ui MessageComposer) */
|
|
319
325
|
composerSlot?: ReactNode;
|
|
326
|
+
/** Optional slash-command typeahead provider (e.g. for skill picker). */
|
|
327
|
+
commandProvider?: CommandProvider | null;
|
|
328
|
+
/** Multiple typeahead providers for distinct triggers (e.g. `/` skills +
|
|
329
|
+
* modes plus `@` ad accounts). Takes precedence over `commandProvider`. */
|
|
330
|
+
commandProviders?: CommandProvider[];
|
|
320
331
|
/** Additional CSS classes for the outer wrapper */
|
|
321
332
|
className?: string;
|
|
322
333
|
/** Assistant avatar image URL — when provided, welcome text renders in message format */
|
|
@@ -333,4 +344,4 @@ interface WelcomeScreenProps {
|
|
|
333
344
|
*/
|
|
334
345
|
declare const WelcomeScreen: react.ForwardRefExoticComponent<WelcomeScreenProps & react.RefAttributes<HTMLDivElement>>;
|
|
335
346
|
|
|
336
|
-
export { AttachmentPreview as A, ChatContainer as C, MarkdownContent as M, ScrollToBottomButton as S,
|
|
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 };
|
|
@@ -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,
|
|
3
|
+
import { M as MessageData, b as ParticipantRole } from './message-D2ElX5k7.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,
|
|
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 };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branding types for theming chat UI components.
|
|
3
|
+
*/
|
|
4
|
+
interface BrandingData {
|
|
5
|
+
customName?: string;
|
|
6
|
+
messageFontSize?: number;
|
|
7
|
+
fontFamily?: string;
|
|
8
|
+
welcomeMessage?: string;
|
|
9
|
+
chatboxPlaceholder?: string;
|
|
10
|
+
backgroundBubbleColor?: string;
|
|
11
|
+
headerBackgroundColor?: string;
|
|
12
|
+
showHeader?: boolean;
|
|
13
|
+
rotatingPlaceholders?: string[];
|
|
14
|
+
presetQuestions?: string[];
|
|
15
|
+
chatbotLogo?: string;
|
|
16
|
+
assistantAvatar?: string;
|
|
17
|
+
approvalAccentColor?: string;
|
|
18
|
+
approveButtonColor?: string;
|
|
19
|
+
approveButtonHoverColor?: string;
|
|
20
|
+
rejectButtonHoverColor?: string;
|
|
21
|
+
clarificationAccentColor?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Accent color used for in-progress / live indicators in the reasoning
|
|
24
|
+
* panel: the running-state halo, animated caret, header wave, rail-flow
|
|
25
|
+
* gradient, and active-row wash. Defaults to `backgroundBubbleColor`
|
|
26
|
+
* (i.e. `--chat-primary`); set this independently when the brand
|
|
27
|
+
* primary is neutral, so activity stays distinguishable.
|
|
28
|
+
*/
|
|
29
|
+
activityAccentColor?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type { BrandingData as B };
|
|
@@ -0,0 +1,132 @@
|
|
|
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-IUCKTDTZ.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,Paperclip,Square,ArrowUp,Image,FileText,File,User,Bot,Link,ArrowRight,AlertCircle,Check,ChevronDown,HelpCircle,MessageCircleQuestion,Download,Video,FileIcon,ChevronUp,MoreVertical,ArrowDown,Minus}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import Dr from'react-markdown';import Vr 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 hr(e){return e.startsWith("image/")?Image:e==="application/pdf"||e.startsWith("text/")?FileText:File}function br(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var Ga=forwardRef(({attachment:e,onRemove:t,removable:a$1=true,className:n},r)=>{let o=hr(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(o,{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:br(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"})})]})});Ga.displayName="AttachmentPreview";var vr={sm:"w-6 h-6 text-xs",md:"w-8 h-8 text-sm",lg:"w-10 h-10 text-base"},kr={sm:14,md:16,lg:20};function wr(e,t){let a=kr[t];switch(e){case "assistant":return jsx(Bot,{size:a});case "user":return jsx(User,{size:a});default:return jsx(User,{size:a})}}var Re=forwardRef(({name:e,src:t,alt:a$1,role:n,size:r="md",className:o,...s},i)=>jsx(l,{ref:i,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",vr[r],o),fallback:wr(n,r),...s}));Re.displayName="Avatar";var Za=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}));Za.displayName="ChatContainer";var Sr={small:"w-1.5 h-1.5",medium:"w-2 h-2",large:"w-2.5 h-2.5"},Tr={small:"gap-1",medium:"gap-1.5",large:"gap-2"};function Ze({size:e="medium",className:t}){let a$1=Sr[e];return jsxs("div",{className:a("flex items-center",Tr[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 Or=new Set(["mode","skill"]);function $r(e,t){let a=g(e);if(a.length===0)return [e];let n=[],r=0;return a.forEach((o,s)=>{if(o.index>r&&n.push(e.slice(r,o.index)),Or.has(o.kind)){r=o.endIndex,e[r]===" "&&(r+=1);return}let i=t?.(o.id,o.kind);n.push(jsx(b$1,{id:o.id,kind:o.kind,label:i?.label,tag:i?.tag,variant:"chip"},`tok-${s}`)),r=o.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=$r(a,t);return r.length===1&&r[0]===a?a:jsx(Fragment$1,{children:r},`text-${n}`)}if(isValidElement(a)){let r=a.type,o=typeof r=="string"?r:void 0;if(o==="code"||o==="pre")return a;let s=a.props.children;return s==null?a:cloneElement(a,void 0,je(s,t))}return a})}var Wr={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 Kr(e){return Wr[e.toLowerCase()]||e.toLowerCase()}function Ut(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function Ur({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=1,darkCodeTheme:n}){let r=n??(typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches),o=a$2!==1?{fontSize:`${a$2}rem`}:void 0,s=useContext(a$1)?.resolveCommandToken;return jsx(Dr,{className:a("chat-prose",t),remarkPlugins:[Vr],components:{h1:({children:i})=>{let c=String(i),d=Ut(c);return jsxs("h1",{id:d,className:"group text-xl font-semibold mt-4 mb-2 first:mt-0",style:o,children:[i,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:i})=>{let c=String(i),d=Ut(c);return jsxs("h2",{id:d,className:"group text-lg font-semibold mt-3 mb-2 first:mt-0",style:o,children:[i,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:i})=>{let c=String(i),d=Ut(c);return jsxs("h3",{id:d,className:"group text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:[i,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:i})=>jsx("h4",{className:"text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:je(i,s)}),p:({children:i})=>jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",style:o,children:je(i,s)}),a:({href:i,children:c})=>i&&/\.(png|jpe?g|gif|webp|svg)([?#]|$)/i.test(i)?jsx("img",{src:i,alt:typeof c=="string"?c:"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"}):jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:opacity-80 transition-opacity",style:o,children:c}),ul:({children:i})=>jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:i}),ol:({children:i})=>jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:i}),li:({children:i})=>jsx("li",{className:"leading-relaxed",style:o,children:je(i,s)}),blockquote:({children:i})=>jsx("blockquote",{className:"border-l-2 border-gray-300 dark:border-gray-600 pl-3 my-2 italic text-chat-subtle",style:o,children:je(i,s)}),code:({className:i,children:c})=>{let d=/language-(\w+)/.exec(i||""),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:o,children:c});let f=d?Kr(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:f}),jsx(Ur,{text:p})]}),jsx(Prism,{language:f,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:i})=>jsx(Fragment,{children:i}),table:({children:i})=>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:i})}),thead:({children:i})=>jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:i}),th:({children:i})=>jsx("th",{className:"px-3 py-2 text-left text-sm font-medium",style:o,children:je(i,s)}),td:({children:i})=>jsx("td",{className:"px-3 py-2 text-sm border-t border-gray-100 dark:border-gray-700",style:o,children:je(i,s)}),hr:()=>jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),strong:({children:i})=>jsx("strong",{className:"font-semibold",children:i}),em:({children:i})=>jsx("em",{className:"italic",children:i}),img:({src:i,alt:c})=>jsx("img",{src:i,alt:c??"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"})},children:e})}var ze=/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([A-Za-z0-9_-]{11})/,Zr=e=>{let t=e.match(ze);return t?t[1]:null};function Yt(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),i=a.find(c=>c.id===s);return i?{id:i.id,url:i.url,mediaType:i.mediaType||(ze.test(i.url)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(i.url)?"video":"image"),altText:i.altText}:null}let r=n,o=ze.test(r)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(r);return {id:t,url:r,mediaType:o?"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 o=n.media_type||n.mediaType||n.type,s=n.alt||n.alt_text||n.altText;return {id:n.id||t,url:r,mediaType:o||(ze.test(r)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(r)?"video":"image"),altText:s}}return null}var Ue=({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 ft({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 o=r.mediaType==="video"?Zr(r.url):null,s=e.length>1,i=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"&&o?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/${o}?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(i,document.body)}function gt(e){let[t,a]=useState(null),n=useCallback(s=>a(s),[]),r=useCallback(()=>a(null),[]),o=useCallback(s=>{a(i=>i===null||e.length===0?i:(i+s+e.length)%e.length);},[e.length]);return {index:t,open:n,close:r,navigate:o}}function en(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 Gt({sources:e,className:t}){let[a$1,n]=useState(null),[r,o]=useState(false);if(!e||e.length===0)return null;let s=8,i=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:[i.map(d=>{let p=en(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:()=>o(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(tn,{source:a$1,onClose:()=>n(null)})]})}function tn({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=en(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 ao({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 Xt({clarification:e,onSubmit:t,onOptionSelect:a$1,disabled:n=false,loading:r=false,className:o,answer:s}){let[i,c]=useState(""),[d,p]=useState(null),w=typeof s=="string"&&s.length>0,f=useCallback(()=>{if(!t)return;let C=i.trim(),x=d;if(!x&&!C)return;let S=x&&C?`${x}
|
|
3
|
+
|
|
4
|
+
${C}`:x||C;c(""),p(null),t(S);},[i,d,t]),z=C=>{let x=C.target.value;p(x),a$1?.(x);},h=C=>{C.key==="Enter"&&!C.shiftKey&&(i.trim()||d)&&(C.preventDefault(),f());},v=e.options&&e.options.length>0,N=e.allowFreeText!==false,E=d!==null||i.trim().length>0;return w?jsx("div",{className:a("mx-4 mb-3 flex justify-end font-sans",o),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"})]}),jsxs("div",{className:"mt-2 text-right",children:[jsx(oe,{className:"text-sm text-gray-700 dark:text-gray-200 text-left",children:e.question}),jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 whitespace-pre-wrap break-words",children:s})]})]})}):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",o),children:[jsxs("div",{className:a("flex items-start gap-2",(v||N)&&"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 max-h-[40vh] overflow-y-auto pr-1",children:jsx(oe,{className:"text-sm font-medium",children:e.question})})]}),v&&jsx("div",{className:a("ml-5 space-y-1",(N||v)&&"mb-2"),children:e.options.map((C,x)=>jsxs("label",{className:"flex items-center gap-2 py-0.5 cursor-pointer text-sm hover:bg-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_18%,transparent)] rounded px-1 -mx-1",children:[jsx("input",{type:"radio",name:"clarification-option",value:C,checked:d===C,onChange:z,disabled:n||r,className:"accent-[var(--chat-clarification-accent,#f97316)] w-3.5 h-3.5"}),C]},x))}),N?jsxs("div",{className:"flex items-center ml-5 bg-white dark:bg-gray-900 rounded border border-[color-mix(in_oklab,var(--chat-clarification-accent,#f97316)_30%,transparent)] px-3 py-1",children:[jsx("input",{type:"text",value:i,onChange:C=>c(C.target.value),onKeyDown:h,placeholder:v?"Add a note or type your response...":"Type your response...",disabled:n||r,className:"flex-1 text-sm bg-transparent outline-none placeholder:text-gray-400 disabled:opacity-50"}),jsx("button",{onClick:f,disabled:!E||n||r,className:a("p-1 rounded transition-colors",E?"text-[var(--chat-clarification-accent,#f97316)] hover:text-[var(--chat-clarification-accent-soft,#fdba74)]":"text-gray-300"),children:jsx(Send,{size:16})})]}):v?jsx("div",{className:"ml-5 flex justify-end",children:jsx("button",{onClick:f,disabled:!E||n||r,className:a("p-1 rounded transition-colors",E?"text-[var(--chat-clarification-accent,#f97316)] hover:text-[var(--chat-clarification-accent-soft,#fdba74)]":"text-gray-300"),children:jsx(Send,{size:16})})}):null]})}var rn=140;function Zt(e){return e==null?"\u2014":typeof e=="boolean"?e?"yes":"no":String(e)}function Jt(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function co({value:e}){let[t,a]=useState(false);if(Jt(e)){let r=Zt(e);return r.length>rn||r.includes(`
|
|
5
|
+
`)?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,rn),"\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(Jt)){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 ln=({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}),po=({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}),mo=({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}),uo=ln,fo=({value:e,onChange:t,onSubmit:a,onCancel:n,placeholder:r,disabled:o,autoFocus:s})=>jsx("textarea",{value:e,onChange:i=>t(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.shiftKey?(i.preventDefault(),a()):i.key==="Escape"&&(i.preventDefault(),n());},placeholder:r,disabled:o,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"}),go=3,on=32;function ho(e){let t=Zt(e);return t.length<=on?t:`${t.slice(0,on-1)}\u2026`}function Qt({approval:e,onApprove:t,onReject:a$1,disabled:n=false,className:r,slots:o}){let[s,i]=useState("idle"),[c,d]=useState(""),[p,w]=useState(false),f=useCallback(()=>{t(e.toolInputs);},[t,e.toolInputs]),z=useCallback(()=>{a$1("User declined this action");},[a$1]),h=useCallback(()=>{let g=c.trim();g&&a$1(g);},[c,a$1]),v=useCallback(()=>{i("idle"),d("");},[]);useEffect(()=>{if(s!=="idle"||n)return;let g=M=>{let G=M.target,ne=G?.tagName;ne==="INPUT"||ne==="TEXTAREA"||ne==="SELECT"||(G?.isContentEditable??false)||(M.key==="Enter"&&!M.shiftKey&&!M.metaKey&&!M.ctrlKey&&!M.altKey?(M.preventDefault(),f()):M.key==="Escape"&&(M.preventDefault(),z()));};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[s,n,f,z]);let N=e.toolDescription?.trim()||`Run ${e.toolName}`,E=e.toolLabel?.trim()||e.toolName,C=Object.entries(e.toolInputs).filter(([g])=>g!=="__description"),x=C.filter(([,g])=>Jt(g)).slice(0,go),S=o?.AllowButton??ln,u=o?.RejectButton??po,y=o?.SendButton??uo,A=o?.CancelButton??mo,V=o?.ChatInput??fo;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"}),E&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":true,className:"opacity-30 shrink-0",children:"\xB7"}),jsx("span",{className:"text-[11px] opacity-60 truncate",title:E,children:E})]})]}),jsx("div",{className:"max-h-[40vh] overflow-y-auto pr-1",children:jsx("p",{className:"text-base leading-relaxed",children:N})}),s==="idle"?jsxs(Fragment,{children:[x.length>0&&jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:x.map(([g,M])=>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:[g,":"]}),jsx("span",{children:ho(M)})]},g))}),jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-2",children:[jsx(S,{onClick:f,disabled:n,children:"Approve"}),jsx(u,{onClick:z,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"]})]}),C.length>0&&jsxs("div",{className:"mt-3",children:[jsx("button",{type:"button",onClick:()=>w(g=>!g),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:C.map(([g,M])=>jsxs("div",{className:"contents",children:[jsx("dt",{className:"font-mono text-[11px] pt-0.5 self-start",children:g}),jsx("dd",{className:"min-w-0",children:jsx(co,{value:M})})]},g))})]})]}):jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[jsx(V,{value:c,onChange:d,onSubmit:h,onCancel:v,placeholder:"Tell me what you want instead\u2026",disabled:n,autoFocus:true}),jsxs("div",{className:"flex items-center gap-x-3",children:[jsx(y,{onClick:h,disabled:n||!c.trim(),children:"Send"}),jsx(A,{onClick:v,disabled:n,children:"Cancel"})]})]})]})}var xo=["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:o}){let[s,i]=useState(false),[c,d]=useState("none"),[p,w]=useState(false),[f,z]=useState(null),[h,v]=useState(""),N=useCallback(()=>{w(false),z(null),v("");},[]),E=useCallback(()=>{if(c!=="none")return;let x=h.trim(),S=f&&x?`${f}: ${x}`:f||x;d("incorrect"),w(false),z(null),v(""),n?.(S||void 0);},[c,f,h,n]);useEffect(()=>{if(!p)return;let x=S=>{S.key==="Escape"&&N();};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[p,N]);let C=useCallback(async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3);}catch{let x=document.createElement("textarea");x.value=e,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.select(),document.execCommand("copy"),document.body.removeChild(x),i(true),setTimeout(()=>i(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",o),children:[jsx("button",{type:"button",onClick:C,"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:()=>w(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:N,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:vo}),jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Share feedback",onClick:x=>x.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:N,"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:xo.map(x=>{let S=f===x;return jsx("button",{type:"button",onClick:()=>z(S?null:x),className:a("mf-fbm-chip",S&&"mf-fbm-chip--active"),children:x},x)})}),jsx("textarea",{value:h,onChange:x=>v(x.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:E,disabled:!f&&!h.trim(),className:"mf-fbm-submit",children:"Submit"})})]})]}),document.body)]})}var vo=`
|
|
6
|
+
.mf-fbm-card {
|
|
7
|
+
width: 420px;
|
|
8
|
+
max-width: 100%;
|
|
9
|
+
background: #ffffff;
|
|
10
|
+
color: #111827;
|
|
11
|
+
border-radius: 12px;
|
|
12
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
|
|
13
|
+
padding: 20px;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
.mf-fbm-header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
margin-bottom: 12px;
|
|
21
|
+
}
|
|
22
|
+
.mf-fbm-title {
|
|
23
|
+
font-size: 15px;
|
|
24
|
+
font-weight: 600;
|
|
25
|
+
color: #111827;
|
|
26
|
+
}
|
|
27
|
+
.mf-fbm-close {
|
|
28
|
+
width: 28px;
|
|
29
|
+
height: 28px;
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
background: transparent;
|
|
34
|
+
border: none;
|
|
35
|
+
border-radius: 6px;
|
|
36
|
+
color: #6b7280;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
padding: 0;
|
|
39
|
+
}
|
|
40
|
+
.mf-fbm-close:hover {
|
|
41
|
+
background: rgba(0, 0, 0, 0.05);
|
|
42
|
+
color: #111827;
|
|
43
|
+
}
|
|
44
|
+
.mf-fbm-chips {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-wrap: wrap;
|
|
47
|
+
gap: 6px;
|
|
48
|
+
margin-bottom: 14px;
|
|
49
|
+
}
|
|
50
|
+
.mf-fbm-chip {
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
line-height: 1;
|
|
53
|
+
padding: 6px 10px;
|
|
54
|
+
border-radius: 9999px;
|
|
55
|
+
border: 1px solid rgba(0, 0, 0, 0.18);
|
|
56
|
+
background: #ffffff;
|
|
57
|
+
color: #111827;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: background 120ms, color 120ms, border-color 120ms;
|
|
60
|
+
}
|
|
61
|
+
.mf-fbm-chip:hover {
|
|
62
|
+
background: rgba(0, 0, 0, 0.04);
|
|
63
|
+
}
|
|
64
|
+
.mf-fbm-chip--active,
|
|
65
|
+
.mf-fbm-chip--active:hover {
|
|
66
|
+
background: #111827;
|
|
67
|
+
color: #ffffff;
|
|
68
|
+
border-color: #111827;
|
|
69
|
+
}
|
|
70
|
+
.mf-fbm-textarea {
|
|
71
|
+
width: 100%;
|
|
72
|
+
box-sizing: border-box;
|
|
73
|
+
font-family: inherit;
|
|
74
|
+
font-size: 13px;
|
|
75
|
+
line-height: 1.5;
|
|
76
|
+
color: #111827;
|
|
77
|
+
background: #f9fafb;
|
|
78
|
+
border: 1px solid rgba(0, 0, 0, 0.18);
|
|
79
|
+
border-radius: 8px;
|
|
80
|
+
padding: 10px 12px;
|
|
81
|
+
resize: none;
|
|
82
|
+
outline: none;
|
|
83
|
+
}
|
|
84
|
+
.mf-fbm-textarea:focus {
|
|
85
|
+
border-color: #111827;
|
|
86
|
+
}
|
|
87
|
+
.mf-fbm-textarea::placeholder {
|
|
88
|
+
color: rgba(0, 0, 0, 0.45);
|
|
89
|
+
}
|
|
90
|
+
.mf-fbm-actions {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: flex-end;
|
|
93
|
+
margin-top: 14px;
|
|
94
|
+
}
|
|
95
|
+
.mf-fbm-submit {
|
|
96
|
+
font-size: 13px;
|
|
97
|
+
font-weight: 500;
|
|
98
|
+
padding: 7px 14px;
|
|
99
|
+
border-radius: 8px;
|
|
100
|
+
border: none;
|
|
101
|
+
background: #111827;
|
|
102
|
+
color: #ffffff;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
transition: opacity 120ms;
|
|
105
|
+
}
|
|
106
|
+
.mf-fbm-submit:hover {
|
|
107
|
+
opacity: 0.9;
|
|
108
|
+
}
|
|
109
|
+
.mf-fbm-submit:disabled {
|
|
110
|
+
opacity: 0.4;
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
}
|
|
113
|
+
`;function na({attachments:e,onDownload:t,onPreview:a$1,className:n}){let[r,o]=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);}},i=c=>{if(a$1){a$1(c);return}c.isImage&&c.url&&o(c.url);};return jsxs("div",{className:a("flex flex-wrap gap-1.5",n),children:[e.map(c=>jsx(Po,{attachment:c,onDownload:()=>s(c),onPreview:()=>i(c)},c.id)),r&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:()=>o(null),children:[jsx("button",{className:"absolute top-4 right-4 p-2 text-white hover:bg-white/20 rounded-full transition-colors",onClick:()=>o(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 Po({attachment:e,onDownload:t,onPreview:a$1}){let n=e.humanReadableSize||Ao(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(Eo,{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 Eo({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 Ao(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 cn="miiflow-reasoning-keyframes",ra=`
|
|
114
|
+
@keyframes beamer{0%{left:-30%}100%{left:100%}}
|
|
115
|
+
@keyframes mf-halo{0%,100%{opacity:0;transform:translate(-50%,-50%) scale(.65)}50%{opacity:.5;transform:translate(-50%,-50%) scale(1)}}
|
|
116
|
+
@keyframes mf-wave{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-1.5px)}}
|
|
117
|
+
@keyframes mf-caret{0%,100%{opacity:.95}50%{opacity:.15}}
|
|
118
|
+
@keyframes mf-rail-flow{0%{transform:translateY(-110%)}100%{transform:translateY(220%)}}
|
|
119
|
+
@keyframes mf-text-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}
|
|
120
|
+
@keyframes mf-bars{0%,100%{transform:scaleY(.28)}50%{transform:scaleY(1)}}
|
|
121
|
+
@keyframes mf-led{0%,100%{opacity:.5}50%{opacity:1}}
|
|
122
|
+
@keyframes mf-scanline{0%{transform:translateX(-110%)}100%{transform:translateX(220%)}}
|
|
123
|
+
@keyframes mf-mono-blink{0%,49%{opacity:1}50%,100%{opacity:.45}}
|
|
124
|
+
@keyframes mf-row-enter{0%{opacity:0;transform:translateY(3px)}100%{opacity:1;transform:translateY(0)}}
|
|
125
|
+
@keyframes mf-halo-once{0%{opacity:0;transform:scale(.4)}38%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(1.55)}}
|
|
126
|
+
.mf-row-enter{animation:mf-row-enter 360ms cubic-bezier(.16,1,.3,1) both}
|
|
127
|
+
.mf-tool-mark{transition:transform 220ms cubic-bezier(.16,1,.3,1);transform-origin:50% 62%;will-change:transform}
|
|
128
|
+
.mf-tool-row:hover .mf-tool-mark{transform:rotate(-9deg) scale(1.08)}
|
|
129
|
+
@media (prefers-reduced-motion:reduce){.mf-row-enter{animation:none}.mf-tool-mark{transition:none}.mf-tool-row:hover .mf-tool-mark{transform:none}}
|
|
130
|
+
`;function Pe(e){if(typeof document>"u")return;let t=e?.getRootNode?.(),a=t instanceof ShadowRoot?t:document.head,n=a.querySelector(`#${cn}`);if(n){n.textContent!==ra&&(n.textContent=ra);return}let r=document.createElement("style");r.id=cn,r.textContent=ra,a.appendChild(r);}function yt({status:e,size:t=20,className:a$1,kind:n}){let r=useRef(null);useEffect(()=>{Pe(r.current);},[]);let o=Math.max(t,16),s=n==="subagent",i=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:o,height:o,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"}}),i?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)"}})]}):i?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 Io(e,t){return t?e==="subagent"||t==="subagent"?6:e==="observation"||t==="observation"?12:e===t?4:9:0}function Oe({items:e,badgeSize:t=20,className:a$1}){let n=useRef(null);if(useEffect(()=>{Pe(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((o,s)=>{let i=s===e.length-1,d=o.status==="running"&&!i,p=i?0:Io(o.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:o.status,size:t,kind:o.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:o.content})]},o.id)})})]})})}function Do({status:e,isLast:t=false,badgeSize:a$1=20,children:n,className:r}){let o=useRef(null);useEffect(()=>{Pe(o.current);},[]);let i=e==="running"&&!t;return jsxs("div",{ref:o,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}),i&&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 Fo(){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",mn={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 un({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(()=>{Pe(r.current);},[]);let o=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?mn:{color:"color-mix(in srgb, var(--chat-text) 78%, transparent)"}},children:jsx(oe,{className:"text-[14px]",children:e.content})}),o&&jsx(un,{seconds:e.durationSeconds,maxSeconds:n??e.durationSeconds})]});if(e.type==="tool"){let s=e.toolDescription?.trim(),i=!!s&&s.length>0,c=i?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(Fo,{})}),jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontFamily:i?void 0:ia,fontVariantLigatures:i?void 0:"none",fontSize:i?14:12.5,lineHeight:1.5,letterSpacing:"-0.005em",fontWeight:i?450:500,fontVariantNumeric:"tabular-nums",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...a$1?mn:{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"}})]}),o&&jsx(un,{seconds:e.durationSeconds,maxSeconds:n??e.durationSeconds})]})}if(e.type==="observation"){let i=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(${i}) 4%, transparent)`,boxShadow:`inset 0 0 0 0.5px color-mix(in srgb, var(${i}) 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(${i})`}}),jsx("span",{style:{fontFamily:ia,fontSize:9.5,fontWeight:700,letterSpacing:"0.16em",textTransform:"uppercase",color:`var(${i})`,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,i=(s.nestedChunks??[]).map((c,d)=>Le(c,d)).filter(c=>c!==null);return s.result&&s.result.trim().length>0&&i.push({id:`result-${s.subagentId}`,type:"thinking",status:s.status==="failed"?"failed":"completed",content:s.result}),jsx(jo,{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:i})}return null}function jo({slug:e,durationSeconds:t,isRunning:a$1,isFailed:n,defaultExpanded:r,nestedEvents:o}){let[s,i]=useState(r),c=o.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?()=>i(w=>!w):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(Ee,{events:o})})]})}var Ho=["create_plan","tool_search","unknown","dispatch_assistant"];function gn(e){return e?Ho.includes(e.toLowerCase().trim()):false}function Le(e,t){if(e.toolName&&gn(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 Oo(e){let t=[],a=[];e.forEach((n,r)=>{let o=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:o}),a.push(o??NaN);}else if(n.type==="tool"){let s=n.tool||"Unknown Tool";if(gn(s))return;t.push({id:`tool-${r}`,type:"tool",status:"completed",toolName:s,toolDescription:n.tool_description,timestamp:o}),a.push(o??NaN);}});for(let n=0;n<t.length-1;n++){let r=a[n],o=a[n+1];if(Number.isFinite(r)&&Number.isFinite(o)&&o>r){let s=o-r,i=s>1e3?s/1e3:s;i>0&&i<3600&&(t[n].durationSeconds=i);}}return t}function $o(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 Ee({events:e,className:t}){if(e.length===0)return null;let a=e.reduce((r,o)=>o.durationSeconds&&o.durationSeconds>r?o.durationSeconds:r,0),n=e.map(r=>({id:r.id,status:r.status,kind:$o(r),content:jsx(sa,{event:r,isRunning:r.status==="running",maxDurationSeconds:a}),bare:r.type==="subagent"}));return jsx(Oe,{items:n,badgeSize:20,className:t})}function tt({label:e,description:t,durationSeconds:a$1,isFailed:n=false,defaultExpanded:r=false,nestedEvents:o,hideChevron:s=false}){let[i,c]=useState(r),d=!!(o&&o.length>0),p=d&&!s;return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:p?()=>c(!i):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:i?"rotate(90deg)":"rotate(0deg)",transition:"transform 220ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),d&&i&&jsx("div",{className:"mt-2 pl-2 animate-fade-in",children:jsx(Ee,{events:o})})]})}var Ko=["create_plan","tool_search","unknown"];function Uo(e){return e?Ko.includes(e.toLowerCase().trim()):false}function qo(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(Uo(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 Yo({subtask:e,executionChunks:t=[]}){let a=e.status==="failed",n=e.status==="completed",r=qo(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 o=t.filter(i=>i.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(Yo,{subtask:r,executionChunks:o})}});return jsxs("div",{className:a("space-y-2",a$1),children:[jsx("span",{className:"text-sm text-[var(--chat-text-subtle)]",children:"Plan:"}),jsx(Oe,{items:n,badgeSize:20})]})}function Zo(e){let t=useRef(null),[a,n]=useState(0),r=useRef(0);return useEffect(()=>{if(e){t.current===null&&(t.current=Date.now());let o=setInterval(()=>{if(t.current!==null){let s=Math.floor((Date.now()-t.current)/1e3);n(s),r.current=s;}},1e3);return ()=>clearInterval(o)}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 Jo(e){return e.some(t=>t.type==="subagent")}var ma=new Set(["create_plan","tool_search","unknown","dispatch_assistant"]);function Qo(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 ei(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}var hn="ui-monospace, 'SFMono-Regular', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace";function ti({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:o,defaultExpanded:s=false,expanded:i,onExpandedChange:c,className:d}){let[p,w]=useState(s),{display:f,finalSeconds:z}=Zo(e),h=useRef(null);useEffect(()=>{Pe(h.current);},[]);let v=useRef(null),[N,E]=useState(false);useEffect(()=>{let R=v.current===true&&e===false;if(v.current=e,R){E(true);let j=setTimeout(()=>E(false),820);return ()=>clearTimeout(j)}},[e]);let C=a$3(h,300),x=i??p,S=useCallback(R=>{C(),w(R),c?.(R);},[C,c]),u=useMemo(()=>e?t.map((R,j)=>Le(R,j)).filter(R=>R!==null):[],[e,t]),y=useMemo(()=>!e&&(n.length>0||t.length>0)?t.map((R,j)=>Le(R,j)).filter(R=>R!==null):[],[e,n,t]),A=useMemo(()=>!e&&n.length>0?Qo(n):[],[e,n]),V=useMemo(()=>{if(o&&o>0)return o;if(!e){if(a$1?.subtasks)return a$1.subtasks.reduce((R,j)=>R+(j.execution_time||0),0);if(n.length>0){let R=n[n.length-1];if(r&&R.timestamp){let j=R.timestamp-r;if(j>0)return j}if(n.length>1){let j=n[0];if(j.timestamp&&R.timestamp){let k=R.timestamp-j.timestamp;if(k>0)return k}}}}return 0},[e,a$1,n,r,o]),g=useMemo(()=>{if(e)return null;let R=0,j=k=>{if(!k)return;let X=k.toLowerCase().trim();ma.has(X)||(R+=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 R===0?null:`${R} ${R===1?"source":"sources"}`},[e,t,n]);if(!e){let R=a$1||n.length>0||t.length>0;if(!R||R&&y.length===0&&!a$1&&n.length===0)return null}let M=t.length>0?t[t.length-1]:null,G=Jo(t),ne=()=>{if(G&&M?.type==="subagent"&&M?.subagentData)return M.subagentData.subagentType;let R=M?.toolName?.toLowerCase().trim(),j=!!R&&ma.has(R);if(!j&&M?.toolDescription)return M.toolDescription;if(!j&&M?.toolName)return M.toolName;switch(M?.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"}},re=V>0?V:z>0?z:0,Ae=a$1?.subtasks&&a$1.subtasks.length>=2;return jsxs("div",{ref:h,className:a("max-w-full",d),children:[jsxs("div",{onClick:()=>S(!x),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(ti,{isStreaming:e,justCompleted:N}),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:ne()}),parseInt(f)>0&&jsxs("span",{className:"tabular-nums",style:{fontFamily:hn,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:[f,"s"]})]}),!e&&(g||re>0)&&jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontFamily:hn,fontSize:11.5,fontWeight:500,letterSpacing:"0.005em",color:"color-mix(in srgb, var(--chat-text) 55%, transparent)",fontVariantNumeric:"tabular-nums",fontVariantLigatures:"none"},children:[re>0&&jsxs("span",{children:["Thought for ",ei(re)]}),re>0&&g&&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"}}),g&&jsx("span",{children:g})]}),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:x?"rotate(90deg)":"rotate(0deg)",transition:"transform 240ms cubic-bezier(.16,1,.3,1)"},children:"\u203A"})]}),x&&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(Ee,{events:u}):a$1?a$1.subtasks?.length===0?null:Ae?jsx(ca,{plan:a$1,streamingChunks:A}):jsx(Ee,{events:y}):jsx(Ee,{events:y})]})]})}var nt=forwardRef(({content:e,isStreaming:t=false,renderMarkdown:a$1=true,className:n,baselineFontSize:r,markdownProps:o},s)=>jsx(m,{ref:s,content:e,isStreaming:t,showCursor:false,className:a("relative",n),children:a$1?jsx(oe,{baselineFontSize:r,...o,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));nt.displayName="StreamingText";var gi={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 hi(e){return e?gi[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var kt=forwardRef(({actions:e,onSelect:t,className:a$1,showIcons:n=true,disabled:r=false},o)=>{let[s,i]=useState(null);if(e.length===0)return null;let c=async(d,p)=>{if(!(!t||s!==null)){i(p);try{await t(d);}finally{i(null);}}};return jsx("div",{ref:o,role:"group","aria-label":"Suggested actions",className:a("flex flex-wrap gap-2",a$1),children:jsx(AnimatePresence,{children:e.map((d,p)=>{let w=s===p,f=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:f,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:[w?jsx(Loader2,{size:14,className:"animate-spin"}):n&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:hi(d.type)}),d.label]},d.id)})})})});kt.displayName="SuggestedActions";var Ai=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function St({data:e,config:t,isStreaming:a=false}){let{chartType:n,series:r,xAxis:o,yAxis:s}=e,i=t?.colors||Ai,c=t?.height||300,d=t?.legend!==false,p=t?.grid!==false,w=t?.tooltip!==false,f=t?.animate!==false&&!a,z=t?.stacked||false,v=(()=>{if(n==="pie")return (r[0]?.data||[]).map((y,A)=>({name:y.name||y.x||`Item ${A+1}`,value:y.value??y.y??0}));let S=new Map;return r.forEach(u=>{u.data.forEach(y=>{let A=y.x??y.name;S.has(A)||S.set(A,{x:A}),S.get(A)[u.name]=y.y??y.value??0;});}),Array.from(S.values())})(),N={data:v,margin:{top:10,right:30,left:0,bottom:0}},E={fontSize:12},C={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,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...E,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...E,tickLine:false,width:40}),w&&jsx(Tooltip,{contentStyle:C}),d&&jsx(Legend,{}),r.map((S,u)=>jsx(Line,{type:"monotone",dataKey:S.name,stroke:S.color||i[u%i.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:f},S.name))]});case "bar":return jsxs(BarChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...E,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...E,tickLine:false,width:40}),w&&jsx(Tooltip,{contentStyle:C}),d&&jsx(Legend,{}),r.map((S,u)=>jsx(Bar,{dataKey:S.name,fill:S.color||i[u%i.length],stackId:z?"stack":void 0,isAnimationActive:f,radius:[4,4,0,0]},S.name))]});case "area":return jsxs(AreaChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...E,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...E,tickLine:false,width:40}),w&&jsx(Tooltip,{contentStyle:C}),d&&jsx(Legend,{}),r.map((S,u)=>jsx(Area,{type:"monotone",dataKey:S.name,stroke:S.color||i[u%i.length],fill:S.color||i[u%i.length],fillOpacity:.3,stackId:z?"stack":void 0,isAnimationActive:f},S.name))]});case "pie":return jsxs(PieChart,{children:[w&&jsx(Tooltip,{contentStyle:C}),d&&jsx(Legend,{}),jsx(Pie,{data:v,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(c,300)/3,isAnimationActive:f,label:({name:S,percent:u})=>`${S}: ${((u??0)*100).toFixed(0)}%`,labelLine:false,children:v.map((S,u)=>jsx(Cell,{fill:i[u%i.length]},`cell-${u}`))})]});case "scatter":return jsxs(ScatterChart,{...N,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",...E,tickLine:false,name:o?.label,padding:{left:10,right:10}}),jsx(YAxis,{...E,tickLine:false,name:s?.label,width:40}),w&&jsx(Tooltip,{contentStyle:C}),d&&jsx(Legend,{}),r.map((S,u)=>jsx(Scatter,{name:S.name,data:S.data.map(y=>({x:y.x,y:y.y})),fill:S.color||i[u%i.length],isAnimationActive:f},S.name))]});default:return null}})()||jsx(Fragment,{})})})}var Bi=new Set(["number","currency","date","badge","boolean","progress"]);function wn(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 _i({text:e,anchorRect:t,onEnter:a$1,onLeave:n}){let[r,o]=useState(false);if(typeof document>"u")return null;let s=16,i=Math.min(360,window.innerWidth-2*s),c=window.innerHeight-t.bottom-s,d=c>=120||c>=t.top,p=t.left;p+i>window.innerWidth-s&&(p=Math.max(s,window.innerWidth-i-s));let w={position:"fixed",left:p,width:"max-content",maxWidth:i,maxHeight:"50vh",zIndex:9998,...d?{top:t.bottom+4}:{bottom:window.innerHeight-t.top+4}},f=async()=>{try{await navigator.clipboard.writeText(e),o(!0),window.setTimeout(()=>o(!1),1200);}catch{}};return createPortal(jsxs("div",{style:w,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:f,"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 Fi({item:e,onOpen:t}){if(e.mediaType==="video"){let a=e.url.match(ze),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(Ue,{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 ji={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 Cn(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=ji[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 Nn(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 Tt({data:e,config:t,medias:a$1}){let{columns:n,rows:r}=e,o=t?.sortable!==false,s=t?.paginated||false,i=t?.pageSize||10,[c,d]=useState("asc"),[p,w]=useState(n[0]?.key||""),[f,z]=useState(0),h=k=>{d(p===k&&c==="asc"?"desc":"asc"),w(k);},v=useMemo(()=>{let k=[...r];return o&&p&&k.sort((X,P)=>c==="desc"?Nn(X,P,p):-Nn(X,P,p)),s&&(k=k.slice(f*i,(f+1)*i)),k},[r,c,p,f,i,o,s]),N=Math.ceil(r.length/i),E=useMemo(()=>{let k=[],X={},P=n.filter(me=>me.type==="media");return P.length===0?{items:k,lookup:X}:(v.forEach((me,Me)=>{P.forEach(ue=>{let fe=me[ue.key],_e=Yt(fe,`${ue.key}-${Me}`,a$1);_e&&(X[`${Me}::${ue.key}`]=k.length,k.push(_e));});}),{items:k,lookup:X})},[v,n,a$1]),{index:C,open:x,close:S,navigate:u}=gt(E.items),[y,A]=useState(null),V=useRef(null),g=useRef(null),M=()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null);},G=()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null);},ne=(k,X,P)=>{M(),G(),V.current=window.setTimeout(()=>{A({rowIdx:k,colKey:X,rect:P}),V.current=null;},250);},re=()=>{M(),G(),g.current=window.setTimeout(()=>{A(null),g.current=null;},150);},Ae=()=>{G();};useEffect(()=>()=>{M(),G();},[]),useEffect(()=>{C!==null&&(M(),G(),A(null));},[C]);let R=y&&n.find(k=>k.key===y.colKey),j=y&&R?wn(v[y.rowIdx]?.[y.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",o&&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:()=>o&&k.type!=="media"&&h(k.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[k.label,o&&k.type!=="media"&&p===k.key&&(c==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},k.key))})}),jsxs("tbody",{children:[v.map((k,X)=>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(P=>{if(P.type==="media"){let ue=Yt(k[P.key],`${P.key}-${X}`,a$1);return jsx("td",{className:"px-3 py-2 align-middle",style:{textAlign:P.align||"left"},children:ue?jsx(Fi,{item:ue,onOpen:()=>{let fe=E.lookup[`${X}::${P.key}`];typeof fe=="number"&&x(fe);}}):jsx("span",{className:"text-gray-400",children:"-"})},P.key)}let me=Bi.has(P.type||"string"),Me=wn(k[P.key]);return jsx("td",{className:a("px-3 py-2 align-top",me?"max-w-[300px]":"max-w-[320px]"),style:{textAlign:P.align||"left"},onMouseEnter:ue=>{if(!Me)return;let fe=ue.currentTarget.getBoundingClientRect();ne(X,P.key,fe);},onMouseLeave:()=>{re();},children:me?jsx("div",{className:"overflow-hidden whitespace-nowrap text-ellipsis",children:Cn(k[P.key],P)}):jsx("div",{className:"whitespace-normal break-words [display:-webkit-box] [-webkit-line-clamp:2] [-webkit-box-orient:vertical] overflow-hidden",children:Cn(k[P.key],P)})},P.key)})},X)),v.length===0&&jsx("tr",{children:jsx("td",{colSpan:n.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),y&&R&&C===null&&jsx(_i,{text:j,anchorRect:y.rect,onEnter:Ae,onLeave:re}),C!==null&&jsx(ft,{items:E.items,index:C,onClose:S,onNavigate:u}),s&&r.length>i&&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:[f*i+1,"-",Math.min((f+1)*i,r.length)," of ",r.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>z(Math.max(0,f-1)),disabled:f===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsx("button",{onClick:()=>z(Math.min(N-1,f+1)),disabled:f>=N-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:o,actions:s}=e,i=t?.collapsible||false,c=t?.initiallyCollapsed||false,[d,p]=useState(!c),w=h=>{h.startsWith("http://")||h.startsWith("https://")||h.startsWith("/")?window.open(h,"_blank","noopener,noreferrer"):a$1?a$1({type:"card_action",action:h}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:h}}));},f=(h,v)=>jsxs("div",{className:a(v<o.length-1&&"mb-4"),children:[h.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:h.title}),h.items&&h.items.length>0&&jsx("div",{className:"space-y-1",children:h.items.map((N,E)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:N.label}),jsx("span",{className:"text-sm font-medium text-right",children:N.value})]},E))}),h.content&&jsx(oe,{children:h.content})]},v),z=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}),o.map((h,v)=>jsxs("div",{children:[f(h,v),v<o.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},v))]});return jsxs("div",{className:"w-full",children:[i&&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})})]}),(!i||d)&&z,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((h,v)=>jsxs("button",{onClick:()=>w(h.action),className:a("px-3 py-1.5 text-sm rounded-lg transition-colors",h.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":h.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[h.label,h.action.startsWith("http")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},v))})]})}var Ui=["#3B82F6","#10B981","#F59E0B","#8B5CF6"],Tn=[{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 qi(e){return Tn[e%Tn.length]}function Yi({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",o=e.sparkline?.map((s,i)=>({value:s,idx:i}));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:[o&&o.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:o,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=qi(t),o=e.sparkline?.map((p,w)=>({value:p,idx:w})),s=a$1&&o&&o.length>1,i=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:o,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(i,{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 Gi(e){let t=e.findIndex(a=>a.prominence==="primary");return t>=0?t:0}function Xi({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=Gi(e),n=e[a$1],r=e.map((c,d)=>({m:c,i:d})).filter(({i:c})=>c!==a$1),o=r.length,s=o<=3?Math.max(2,o):o>=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 Pt({data:e,config:t,isStreaming:a$1=false}){let{metrics:n,layout:r="row"}=e,o=t?.colors||Ui,s=t?.animate!==false&&!a$1;if(r==="bento")return jsx("div",{className:"w-full",children:jsx(Xi,{metrics:n,animate:s})});let i=r==="grid";return jsx("div",{className:a("w-full",i?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:n.map((c,d)=>jsx("div",{className:a(!i&&"flex-1 min-w-[200px]"),children:jsx(Yi,{metric:c,color:c.color||o[d%o.length],animate:s})},d))})}var rs={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:o=1}=e,[s,i]=useState(false),c=rs[a.toLowerCase()]||a.toLowerCase(),d=async()=>{try{await navigator.clipboard.writeText(t),i(!0);}catch{}};return useEffect(()=>{if(s){let w=setTimeout(()=>i(false),2e3);return ()=>clearTimeout(w)}},[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:o,wrapLines:true,lineProps:w=>{let f={};return r.includes(w)&&(f.backgroundColor="rgba(59, 130, 246, 0.1)",f.display="block",f.borderLeft="3px solid #3B82F6",f.paddingLeft="8px",f.marginLeft="-11px"),{style:f}},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 At({data:e,config:t,isStreaming:a$1=false,onAction:n}){let{fields:r,submitAction:o}=e,s=t?.submitButtonText||"Submit",i=t?.cancelButtonText||"Cancel",[c,d]=useState(()=>{let u={};return r.forEach(y=>{y.defaultValue!==void 0?u[y.name]=y.defaultValue:y.type==="multiselect"?u[y.name]=[]:y.type==="checkbox"?u[y.name]=false:u[y.name]="";}),u}),[p,w]=useState({}),[f,z]=useState(false),h=(u,y)=>{d(A=>({...A,[u]:y})),p[u]&&w(A=>{let V={...A};return delete V[u],V});},v=()=>{let u={};return r.forEach(y=>{let A=c[y.name];if(y.required&&(A==null||A===""||Array.isArray(A)&&A.length===0)){u[y.name]=`${y.label} is required`;return}if(!(!A&&!y.required)){if(y.validation){let{min:V,max:g,pattern:M,message:G}=y.validation;V!==void 0&&typeof A=="number"&&A<V&&(u[y.name]=G||`Minimum value is ${V}`),g!==void 0&&typeof A=="number"&&A>g&&(u[y.name]=G||`Maximum value is ${g}`),M&&typeof A=="string"&&!new RegExp(M).test(A)&&(u[y.name]=G||"Invalid format");}y.type==="email"&&typeof A=="string"&&A&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A)&&(u[y.name]="Invalid email address");}}),w(u),Object.keys(u).length===0},N=u=>{u.preventDefault(),v()&&(n?n({type:"form_submit",action:o||"",data:c}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:o,data:c}})),z(true));},E=()=>{n?n({type:"form_cancel",action:o||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:o}}));};if(f)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 C="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",x="border-red-500 focus:ring-red-500/20 focus:border-red-500",S=u=>{let y=c[u.name],V=!!p[u.name];switch(u.type){case "text":case "email":case "number":return jsx("input",{type:u.type,placeholder:u.placeholder,required:u.required,value:String(y||""),onChange:g=>h(u.name,u.type==="number"?parseFloat(g.target.value)||"":g.target.value),className:a(C,V&&x),min:u.validation?.min,max:u.validation?.max});case "textarea":return jsx("textarea",{placeholder:u.placeholder,required:u.required,value:String(y||""),onChange:g=>h(u.name,g.target.value),className:a(C,"min-h-[100px] resize-y",V&&x),rows:4});case "select":return jsxs("select",{value:String(y||""),onChange:g=>h(u.name,g.target.value),className:a(C,V&&x),children:[jsx("option",{value:"",disabled:true,children:u.placeholder||"Select an option"}),u.options?.map(g=>jsx("option",{value:g.value,children:g.label},g.value))]});case "multiselect":return jsx("select",{multiple:true,value:y||[],onChange:g=>h(u.name,Array.from(g.target.selectedOptions,M=>M.value)),className:a(C,"min-h-[80px]",V&&x),children:u.options?.map(g=>jsx("option",{value:g.value,children:g.label},g.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!y,onChange:g=>h(u.name,g.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:u.label})]});case "radio":return jsx("div",{className:"space-y-1",children:u.options?.map(g=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:u.name,value:g.value,checked:y===g.value,onChange:M=>h(u.name,M.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),g.label]},g.value))});case "date":return jsx("input",{type:"date",value:String(y||""),onChange:g=>h(u.name,g.target.value),className:a(C,V&&x)});case "datetime":return jsx("input",{type:"datetime-local",value:String(y||""),onChange:g=>h(u.name,g.target.value),className:a(C,V&&x)});default:return null}};return jsxs("form",{onSubmit:N,className:"space-y-4",children:[r.map(u=>jsxs("div",{children:[u.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[u.label,u.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),S(u),p[u.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:p[u.name]})]},u.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:E,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:i})]})]})}var Ln="__miiflow_visualization_registry__",Mt=globalThis[Ln]??(globalThis[Ln]=new Map);function Ve(e,t){Mt.set(e,t);}function Rt(e){return Mt.get(e)}function In(){return Array.from(Mt.keys())}Ve("chart",{component:St});Ve("table",{component:Tt});Ve("card",{component:zt});Ve("kpi",{component:Pt});Ve("code_preview",{component:Et});Ve("form",{component:At});function Dn(e){for(let[t,a]of Object.entries(e)){let n=Mt.get(t);n&&(n.schema=a);}}var os=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()}),Vn=z.object({label:z.string().nullish(),type:z.enum(["category","number","time"]).nullish(),min:z.number().nullish(),max:z.number().nullish()}),ya=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(os),xAxis:Vn.nullish(),yAxis:Vn.nullish()}),is=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()}),xa=z.object({columns:z.array(is),rows:z.array(z.record(z.string(),z.unknown()))}),ss=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()}),ls=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(ss),actions:z.array(ls).nullish()}),cs=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(cs),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()}),ds=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(ds),submitAction:z.string().nullish()});Dn({chart:ya,table:xa,card:va,kpi:ka,code_preview:wa,form:Ca});function lt({data:e,isStreaming:t=false,onAction:a,medias:n}){let{type:r,title:o,description:s,data:i,config:c}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(o||s)&&jsxs("div",{className:"mb-2",children:[o&&jsx("p",{className:"text-sm font-semibold",children:o}),s&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s})]}),jsx("div",{children:(()=>{let p=Rt(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 f=p.schema.safeParse(i);if(!f.success){let z=f.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:[z.map((h,v)=>jsxs("li",{children:[h.path.join("."),": ",h.message]},v)),f.error.issues.length>3&&jsxs("li",{children:["...and ",f.error.issues.length-3," more"]})]})]})}}let w=p.component;return jsx(w,{data:i,config:c,isStreaming:t,onAction:a,medias:n})})()})]})}function Lt({artifact:e,isStreaming:t,onOpen:a}){let n=e.status??"ready",r=n==="pending"||t&&n!=="failed",o=n==="failed",s=r||o;return jsxs("button",{type:"button",onClick:()=>{s||a?.(e);},disabled:s,"aria-label":o?`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:o?"var(--miiflow-artifact-error-bg, #fdecea)":"var(--miiflow-artifact-bg, #f6f8fa)",border:"1px solid",borderColor:o?"var(--miiflow-artifact-error-border, #f1aeb5)":"var(--miiflow-artifact-border, #d0d7de)",borderRadius:"8px",font:"inherit",color:"inherit",textAlign:"left",cursor:s?o?"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:o?"\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:o?"var(--miiflow-artifact-error-text, #b42318)":"var(--miiflow-artifact-meta, #57606a)"},children:o?e.errorMessage||"Generation failed":[e.kind.toUpperCase(),e.pageCount?`${e.pageCount} pages`:null,r?"generating\u2026":null].filter(Boolean).join(" \xB7 ")})]})]})}var Fn="__miiflow_artifact_registry__",Sa=globalThis[Fn]??(globalThis[Fn]=new Map);function jn(e,t){Sa.set(e,t);}function It(e){return Sa.get(e)}function Hn(){return Array.from(Sa.keys())}function Dt({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 o=It(n.kind)?.InlineCard??Lt;return jsx(o,{artifact:n,isStreaming:t,onOpen:a},n.id)})}):null}var $n=/\[(VIZ|MEDIA|SA):([\w-]+)\]/gi;function Wn(e){let t=[],a=0,n;for($n.lastIndex=0;(n=$n.exec(e))!==null;){if(n.index>a){let o=e.slice(a,n.index);o.trim()&&t.push({type:"text",content:o});}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 us=[/```/,/\[VIZ:/,/\[SA:/,/\[MEDIA:/,/!\[/,/<img\b/i];function fs(e){for(let t of us)if(t.test(e))return false;return true}function Kn(e,t,a){let[n,r]=useState(void 0);return useEffect(()=>{if(!a){r(void 0);return}let o=e.current;if(!o||!t||!fs(t))return;let s=false,i=()=>{if(s)return;let d=o.clientWidth;if(d<=0)return;let p=b(t,d);p&&r(w=>w===void 0||p.height>w?p.height:w);};i();let c=typeof ResizeObserver<"u"?new ResizeObserver(i):null;return c?.observe(o),()=>{s=true,c?.disconnect();}},[e,t,a]),n}var ys=({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(Ue,{label:t||"Play video"})]})}),t&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:t})]})},xs=({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(Ue,{label:a||"Play video"})]})}),a&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:a})]})},vs=({media:e,onOpen:t})=>{if(e.mediaType==="video"){let a$1=e.url.match(ze),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(Ue,{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"})})},Yn=forwardRef(({message:e,viewerRole:t="user",className:a$2,showAvatar:n=true,showTimestamp:r=true,renderMarkdown:o=true,reasoning:s,executionPlan:i,executionTimeline:c$1,suggestedActions:d$1,onSuggestedAction:p,reasoningExpanded:w,onReasoningExpandedChange:f,citations:z,visualizations:h,medias:v,artifacts:N,onArtifactOpen:E,baselineFontSize:C,executionTime:x,pendingClarification:S,onClarificationSubmit:u,pendingToolApproval:y,onToolApprove:A,onToolReject:V,renderInlineSuggestedAction:g,onReportIncorrect:M,onConfirmCorrect:G},ne)=>{let Ae=useContext(a$1)?.onVisualizationAction,R=(e.participant?.role||"").toLowerCase(),j=(t||"").toLowerCase(),k=R===j,X=R==="assistant",P=e.isStreaming,me=s?.filter(H=>H.type==="thinking"||H.type==="tool"||H.type==="observation"||H.type==="planning"||H.type==="subtask"||H.type==="subagent"),Me=me&&me.length>0,ue=!P&&(i||c$1&&c$1.length>0),fe=Me||ue,_e=P&&!e.textContent&&!fe,Xe=e.attachments,T=Xe&&Xe.length>0,U=useMemo(()=>{if(!h||h.length===0)return null;let H=new Map;return h.forEach(B=>H.set(B.id,B)),H},[h]),W=U&&U.size>0||e.textContent&&/\[SA:[\w-]+\]/i.test(e.textContent),le=useMemo(()=>!W||!e.textContent?null:Wn(e.textContent),[W,e.textContent]),ce=useMemo(()=>!v||v.length===0||!e.textContent?e.textContent:e.textContent.replace(/\[MEDIA:[a-f0-9-]+\]/gi,"").trim(),[e.textContent,v]),ir=()=>{if(!e.textContent)return null;if(le&&le.length>0&&W){let H=new Set;return jsx(Fragment,{children:le.map((B,Te)=>{if(B.type==="text")return P?jsx(nt,{content:B.content,isStreaming:true,baselineFontSize:C},Te):jsx(oe,{baselineFontSize:C,className:k?"prose-invert":"",children:B.content},Te);if(B.type==="viz"){if(H.has(B.id))return null;let Ba=U?.get(B.id);return Ba?(H.add(B.id),jsx(lt,{data:Ba,isStreaming:P,onAction:Ae,medias:v},`viz-${B.id}`)):null}return B.type==="sa"&&g?jsx("div",{children:g(B.id)},`sa-${B.id}`):null})})}return P&&o?jsx(nt,{content:ce||"",isStreaming:true,baselineFontSize:C,className:k?"prose-invert":""}):o?jsx(oe,{baselineFontSize:C,className:k?"prose-invert":"",children:ce||""}):jsx("p",{className:"whitespace-pre-wrap",children:ce})},We=useMemo(()=>{if(!v||v.length===0)return [];let H=ce||"";return v.filter(B=>B.mediaType!=="image"?true:!H.includes(B.url)).map(B=>({id:B.id,url:B.url,mediaType:B.mediaType,altText:B.altText}))},[v,ce]),{index:Ra,open:La,close:sr,navigate:lr}=gt(We),cr=()=>{if(We.length===0)return null;if(We.length>=2)return jsx("div",{className:"my-3 grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",maxWidth:640},children:We.map((B,Te)=>jsx(vs,{media:B,onOpen:()=>La(Te)},`media-${B.id}`))});let H=We[0];if(H.mediaType==="image")return jsx("div",{className:"my-3",children:jsx("button",{type:"button",onClick:()=>La(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(ze);return B?jsx(ys,{ytId:B[1],altText:H.altText},`media-${H.id}`):jsx(xs,{url:H.url,posterUrl:H.posterUrl,altText:H.altText},`media-${H.id}`)}return null},Ia=useRef(P);P&&(Ia.current=true);let dr=!P&&!Ia.current,Da=useRef(null),Va=Kn(Da,e.textContent,!!P);return jsx(c,{ref:ne,message:e,viewerRole:t,className:a("w-full",dr&&"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(Re,{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"})})]}),fe&&X&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(ua,{isStreaming:P,chunks:me,plan:i,executionTimeline:c$1,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:x,expanded:w,onExpandedChange:f})}),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(Re,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{ref:Da,className:a("max-w-[85%]","flex flex-col"),"data-message-role":k?"viewer":"other",style:Va?{minHeight:Va}: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:ir()}),cr(),Ra!==null&&jsx(ft,{items:We,index:Ra,onClose:sr,onNavigate:lr}),h&&h.length>0&&(()=>{let H=e.textContent||"",B=h.filter(Te=>!H.includes(`[VIZ:${Te.id}]`));return B.length===0?null:B.map(Te=>jsx("div",{className:"my-3",children:jsx(lt,{data:Te,isStreaming:P,onAction:Ae,medias:v})},`viz-unreferenced-${Te.id}`))})(),N&&N.length>0&&jsx("div",{className:"mt-2",children:jsx(Dt,{artifacts:N,isStreaming:P,onOpen:E})}),z&&z.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(Gt,{sources:z})})]}),T&&jsx("div",{className:"mt-2",children:jsx(na,{attachments:Xe})}),!P&&(r&&e.createdAt||X&&e.textContent)&&jsxs("div",{className:a("flex items-center gap-2 mt-1",k&&"flex-row-reverse"),children:[r&&e.createdAt&&jsx(ks,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:k}),X&&e.textContent&&jsx(ta,{textContent:e.textContent,onReportIncorrect:M,onConfirmCorrect:G})]})]})]}),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&&fe&&!_e&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Re,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),S&&!P&&u&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(Xt,{clarification:S,onSubmit:u})}),y&&!P&&A&&V&&jsx("div",{className:"w-full",children:jsx(Qt,{approval:y,onApprove:A,onReject:V})}),d$1&&d$1.length>0&&!P&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(kt,{actions:d$1,onSelect:p})})]})})});Yn.displayName="Message";function ks({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 Ls=100*1024*1024,Is=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],Ds=["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"],Vs=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],Bs=[...Is,...Ds,...Vs];function Gn(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 _s(e,t,a){return e.size>a?`File size (${Gn(e.size)}) exceeds max (${Gn(a)})`:t.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function Fs({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/"),o=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]",o?"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"}):o?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:o?n.error:n.file.name,children:o?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 Zn=forwardRef(({onSubmit:e,onAttach:t,onUploadFile:a$1,onRemoveUploadedAttachment:n,disabled:r=false,supportsAttachments:o=true,allowedFileTypes:s=Bs,maxFileSize:i$1=Ls,placeholder:c="Type a message...",className:d,isSubmitting:p=false,centered:w=false,isStreaming:f=false,onStopStreaming:z,commandProvider:h,commandProviders:v},N)=>{let[E,C]=useState(false),[x,S]=useState([]),[u,y]=useState(false),A=useRef(null),V=useRef(null),g=useRef(0),M=useRef(false),G=r||p,ne=x.some(T=>T.status==="uploading"),re=x.filter(T=>T.status==="uploaded"&&T.attachmentId).map(T=>T.attachmentId),Ae=re.length>0||x.some(T=>T.status==="pending"),R=E||Ae,j=useCallback(async T=>{let U=T.map($=>{let W=_s($,s,i$1),le={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:$,status:W?"error":a$1?"uploading":"pending",error:W||void 0};return !W&&$.type.startsWith("image/")&&(le.previewUrl=URL.createObjectURL($)),le});if(S($=>[...$,...U]),t?.(T),a$1){for(let $ of U)if($.status==="uploading")try{let W=await a$1($.file);S(le=>le.map(ce=>ce.id===$.id?{...ce,status:"uploaded",attachmentId:W}:ce));}catch(W){S(le=>le.map(ce=>ce.id===$.id?{...ce,status:"error",error:W instanceof Error?W.message:"Upload failed"}:ce));}}},[s,i$1,a$1,t]),k=useCallback(async T=>{if(!R&&T.trim().length===0||G||ne||M.current)return;M.current=true;let U=x.filter(W=>W.status!=="error").map(W=>W.file),$=x;V.current?.clear(),C(false),S([]);try{a$1&&re.length>0?await e(T,void 0,re):await e(T,U.length>0?U:void 0);}catch{S($);}finally{M.current=false;}},[x,R,G,ne,e,a$1,re]),X=useCallback(()=>{V.current?.submit();},[]),P=useCallback(T=>{let U=T.target.files;!U||U.length===0||(j(Array.from(U)),T.target.value="");},[j]),me=useCallback(T=>{if(!o||p)return;let U=T.clipboardData;if(!U)return;let $=[];for(let W of U.files)$.push(W);if($.length===0&&U.items){for(let W of U.items)if(W.kind==="file"){let le=W.getAsFile();le&&$.push(le);}}$.length>0&&(T.preventDefault(),j($));},[o,p,j]),Me=useCallback(T=>{S(U=>{let $=U.find(W=>W.id===T);return $?.previewUrl&&URL.revokeObjectURL($.previewUrl),$?.attachmentId&&n&&n($.attachmentId),U.filter(W=>W.id!==T)});},[n]),ue=useCallback(T=>{T.preventDefault(),T.stopPropagation(),!(!o||p)&&(g.current++,T.dataTransfer.types.includes("Files")&&y(true));},[o,p]),fe=useCallback(T=>{T.preventDefault(),T.stopPropagation(),g.current--,g.current===0&&y(false);},[]),_e=useCallback(T=>{T.preventDefault(),T.stopPropagation();},[]),Xe=useCallback(T=>{if(T.preventDefault(),T.stopPropagation(),g.current=0,y(false),!o||p)return;let U=Array.from(T.dataTransfer.files);U.length>0&&j(U);},[o,p,j]);return useEffect(()=>()=>{x.forEach(T=>{T.previewUrl&&URL.revokeObjectURL(T.previewUrl);});},[]),jsx("div",{ref:N,className:a("flex-shrink-0",w?"p-0 bg-transparent":"px-3 pb-3",d),style:w?{padding:0,background:"transparent",border:"none"}:void 0,onDragEnter:ue,onDragLeave:fe,onDragOver:_e,onDrop:Xe,children:jsxs("div",{className:a("mx-auto max-w-[900px]","bg-white dark:bg-zinc-800","transition-all duration-200",w?"":"rounded-xl border border-gray-200 dark:border-zinc-700 shadow-sm focus-within:shadow-md focus-within:border-gray-300 dark:focus-within:border-zinc-600",u&&"ring-2 ring-blue-400 border-blue-400"),style:w?{borderRadius:"1rem",overflow:"hidden",backgroundColor:"var(--chat-composer-bg, #ffffff)",border:"1px solid var(--chat-composer-border, rgba(0,0,0,0.06))",boxShadow:"var(--chat-composer-shadow, 0 8px 30px rgba(0,0,0,0.08))"}:void 0,children:[u&&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-blue-300 bg-blue-50 dark:bg-blue-900/20 text-blue-500 text-sm",children:"Drop files here"})}),jsx(Fs,{attachments:x,onRemove:Me,disabled:p}),jsxs("div",{className:a("flex items-center gap-2",w?"p-4":"p-3",x.length>0&&"pt-1.5"),style:w?{padding:"1rem"}:void 0,children:[o&&jsx("button",{type:"button",onClick:()=>A.current?.click(),disabled:p,className:a("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","border border-gray-200 dark:border-zinc-600","text-gray-500 dark:text-zinc-400","hover:bg-gray-50 dark:hover:bg-zinc-700","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("div",{className:"flex-1 min-w-0",onPaste:me,children:jsx(i,{ref:V,placeholder:c,disabled:G,commandProvider:h??null,commandProviders:v,inputClassName:a("text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500"),onChange:({text:T})=>C(T.trim().length>0),onSubmit:({text:T})=>k(T)})}),f&&z?jsxs("div",{className:"relative flex-shrink-0 w-9 h-9",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:z,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:X,disabled:!R||G||ne,className:a("flex-shrink-0","w-9 h-9 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 hover:shadow-md","active:shadow-sm","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-all duration-200"),children:p||ne?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})]}),o&&jsx("input",{ref:A,type:"file",multiple:true,accept:s.join(","),onChange:P,className:"hidden"})]})})});Zn.displayName="MessageComposer";function Pa({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 Qn=forwardRef(({children:e,autoScroll:t=true,showScrollToBottom:a$1=true,className:n},r)=>{let{containerRef:o,scrollToBottom:s,isAtBottom:i}=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=>{o.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(Pa,{isAtBottom:i,onScrollToBottom:()=>s("smooth")})]})});Qn.displayName="MessageList";function $s({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 tr=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"})}));tr.displayName="TypingIndicator";function Xs({title:e,subtitle:t,logo:a$1,actions:n,showClose:r,onClose:o,loading:s,className:i,style:c}){let[d,p]=useState(false),w=useRef(null),f=useRef(null);return useEffect(()=>{let z=h=>{let v=h.composedPath();w.current&&!v.includes(w.current)&&f.current&&!v.includes(f.current)&&p(false);};if(d)return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[d]),jsxs("header",{className:a("flex items-center justify-between gap-3","px-4 py-3","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",i),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-lg 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:f,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:w,className:a("absolute right-0 top-full mt-1 z-50","min-w-[180px]","bg-white rounded-lg shadow-lg","border border-[var(--chat-border)]","py-1","animate-fade-in"),children:n.map(z=>jsxs("button",{onClick:()=>{z.onClick(),p(false);},disabled:z.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:[z.icon&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:z.icon}),z.label]},z.id))})]}),r&&o&&jsx("button",{onClick:o,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 Zs({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(Js,{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 Js({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 nr=forwardRef(({isEmpty:e,header:t,welcomeScreen:a$1,messageList:n,composer:r,footer:o,className:s},i)=>jsx("div",{ref:i,"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:.3},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:.4},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[t,jsx(motion.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:n}),jsxs(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},className:"relative z-10",children:[o,r]})]},"active")})}));nr.displayName="ChatLayout";function il(e,t=3e3){let[a,n]=useState(0),r=useRef(null);return useEffect(()=>{if(e.length<=1)return;let o=()=>{r.current=setInterval(()=>{n(i=>(i+1)%e.length);},t);},s=()=>{document.visibilityState!=="visible"?r.current&&(clearInterval(r.current),r.current=null):o();};return o(),document.addEventListener("visibilitychange",s),()=>{r.current&&clearInterval(r.current),document.removeEventListener("visibilitychange",s);}},[e,t]),e[a]??""}function sl({placeholder:e,onSubmit:t,disabled:a$1,supportsAttachments:n,commandProvider:r,commandProviders:o}){let[s,i$1]=useState(false),[c,d]=useState([]),p=useRef(null),w=useRef(null),f=useCallback(N=>{!N.trim()&&c.length===0||a$1||(t(N.trim(),c.length>0?c:void 0),p.current?.clear(),i$1(false),d([]));},[a$1,c,t]),z=N=>{N.target.files&&d(E=>[...E,...Array.from(N.target.files)]),N.target.value="";},h=N=>{d(E=>E.filter((C,x)=>x!==N));},v=(s||c.length>0)&&!a$1;return jsxs("div",{className:a("w-full relative mx-auto","rounded-2xl overflow-hidden","transition duration-200"),style:{borderRadius:"1rem",overflow:"hidden",backgroundColor:"var(--chat-composer-bg, #ffffff)",border:"1px solid var(--chat-composer-border, rgba(0,0,0,0.06))",boxShadow:"var(--chat-composer-shadow, 0 8px 30px rgba(0,0,0,0.08))"},children:[c.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:c.map((N,E)=>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:N.name}),jsx("button",{type:"button",onClick:()=>h(E),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${N.name}-${E}`))}),jsxs("div",{className:"flex items-center gap-2",style:{padding:"0.25rem 0"},children:[n&&jsx("button",{type:"button",onClick:()=>w.current?.click(),disabled:a$1,className:a("ml-3 flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","text-gray-400 dark:text-zinc-500","hover:bg-gray-100 dark:hover:bg-zinc-700","hover:text-gray-600 dark:hover:text-zinc-300","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),style:{marginLeft:"0.75rem"},children:jsx(Paperclip,{size:16})}),jsx(i,{ref:p,placeholder:e,disabled:a$1,commandProvider:r??null,commandProviders:o,className:a("flex-1",n?"pl-1":"pl-4 sm:pl-6","py-4 sm:py-5 pr-1"),inputClassName:"text-sm sm:text-base text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-zinc-500",onChange:({text:N})=>i$1(N.trim().length>0),onSubmit:({text:N})=>f(N)}),jsx("button",{type:"button",onClick:()=>p.current?.submit(),disabled:!v,className:a("mr-3 flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-white dark:text-zinc-100","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),style:{marginRight:"0.75rem",width:"2.25rem",height:"2.25rem",borderRadius:"0.5rem"},children:jsx("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 19V5M5 12l7-7 7 7"})})})]}),n&&jsx("input",{ref:w,type:"file",multiple:true,onChange:z,className:"hidden"})]})}function ll({text:e,onClick:t,index:a$1}){let n=useRef(null),r=useRef(typeof window<"u"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),[o,s]=useState(null),i=useCallback(d=>{if(r.current)return;let p=d.currentTarget.getBoundingClientRect();s({x:d.clientX-p.left,y:d.clientY-p.top});},[]),c=useCallback(()=>{s(null);},[]);return jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2+a$1*.1,duration:.4},children:jsxs("button",{ref:n,type:"button",onClick:t,onMouseMove:i,onMouseLeave:c,className:a("relative overflow-hidden","w-full text-left","p-3","cursor-pointer","border border-gray-200 dark:border-zinc-700","rounded-lg","transition-all duration-200 ease-out","bg-white dark:bg-zinc-800","hover:border-gray-300 dark:hover:border-zinc-600","hover:bg-gray-50 dark:hover:bg-zinc-750","hover:shadow-sm","active:bg-gray-100 dark:active:bg-zinc-700"),children:[o&&jsx("div",{className:"pointer-events-none absolute inset-0 z-0",style:{background:`radial-gradient(120px circle at ${o.x}px ${o.y}px, var(--chat-halo-primary, rgba(16,105,151,0.06)), transparent)`}}),jsxs("div",{className:"relative z-10 flex items-start gap-2.5",children:[jsx(MessageCircleQuestion,{size:16,strokeWidth:2,className:"mt-0.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),jsx("span",{className:"text-sm text-gray-600 dark:text-zinc-300 leading-relaxed flex-1",children:e})]})]})})}var rr=forwardRef(({placeholders:e=[],suggestions:t=[],onSubmit:a$1,onSuggestionClick:n,welcomeText:r="How can I help you today?",supportsAttachments:o,composerSlot:s,commandProvider:i,commandProviders:c,className:d,assistantAvatar:p,assistantName:w},f)=>{let z=il(e),h=useCallback(v=>{n?.(v);},[n]);return jsxs("div",{ref:f,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 animate-welcome-halo",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:{scale:.95,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},transition:{type:"spring",stiffness:200,damping:25},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[r&&p?jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"flex items-start gap-2 w-full",children:[jsx("div",{className:"flex-shrink-0",children:jsx(Re,{name:w,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"},className:"text-base text-gray-800 dark:text-white",children:r})})]}):r?jsx(motion.h2,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},style:{fontSize:"1.5rem",lineHeight:"2rem",fontWeight:600},className:"text-2xl font-semibold text-gray-800 dark:text-white text-center",children:r}):null,jsx("div",{className:a("w-full rounded-2xl","transition-shadow duration-500","shadow-[0_0_15px_rgba(16,105,151,0.08)]","focus-within:shadow-[0_0_20px_rgba(16,105,151,0.15),0_0_40px_rgba(86,193,138,0.08)]","dark:shadow-[0_0_15px_rgba(255,255,255,0.04)]","dark:focus-within:shadow-[0_0_20px_rgba(255,255,255,0.08),0_0_40px_rgba(255,255,255,0.03)]"),children:s??jsx(sl,{placeholder:z,onSubmit:(v,N)=>a$1?.(v,N),supportsAttachments:o,commandProvider:i??null,commandProviders:c})}),t.length>0&&jsx("div",{className:a("grid gap-3 w-full max-w-[900px]","grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(250px,1fr))]"),children:t.map((v,N)=>jsx(ll,{text:v,onClick:()=>h(v),index:N},N))})]})]})});rr.displayName="WelcomeScreen";function cl(e){return e?e.split(/[_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" "):"Sub-assistant"}function dl({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((o,s)=>Le(o,s)).filter(o=>o!==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:cl(t.subagentType),durationSeconds:t.durationMs!=null?t.durationMs/1e3:void 0,isFailed:t.status==="failed",nestedEvents:n})}];return jsx(Oe,{items:r,badgeSize:20})}
|
|
131
|
+
export{Zs as $,zt as A,Pt as B,Et as C,At as D,Ve as E,Rt as F,In as G,ya as H,xa as I,va as J,ka as K,wa as L,Ca as M,lt as N,Lt as O,jn as P,It as Q,Hn as R,Dt as S,Wn as T,Yn as U,Zn as V,Pa as W,Qn as X,$s as Y,tr as Z,Xs as _,Ga as a,nr as aa,Re as b,rr as ba,Za as c,dl as ca,Ze as d,oe as e,Gt as f,tn as g,ao as h,Xt as i,Qt as j,ta as k,na as l,yt as m,Oe as n,Do as o,sa as p,Le as q,Oo as r,Ee as s,tt as t,ca as u,ua as v,nt as w,kt as x,St as y,Tt as z};//# sourceMappingURL=chunk-ERJKVQQT.js.map
|
|
132
|
+
//# sourceMappingURL=chunk-ERJKVQQT.js.map
|