@miiflow/assistant-ui 0.1.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/LICENSE +21 -0
- package/README.md +563 -0
- package/dist/WelcomeScreen-CsFaFNcu.d.mts +246 -0
- package/dist/WelcomeScreen-TrcbOYob.d.ts +246 -0
- package/dist/avatar-D5eHcfjf.d.mts +109 -0
- package/dist/avatar-DftdWqSs.d.ts +109 -0
- package/dist/branding-SzYU4ncD.d.mts +18 -0
- package/dist/branding-SzYU4ncD.d.ts +18 -0
- package/dist/chunk-3E2HG62U.mjs +2 -0
- package/dist/chunk-3E2HG62U.mjs.map +1 -0
- package/dist/chunk-3ERHTQXR.js +2 -0
- package/dist/chunk-3ERHTQXR.js.map +1 -0
- package/dist/chunk-3GQNGDXX.mjs +22 -0
- package/dist/chunk-3GQNGDXX.mjs.map +1 -0
- package/dist/chunk-3KB4JYSQ.js +2 -0
- package/dist/chunk-3KB4JYSQ.js.map +1 -0
- package/dist/chunk-BA3VCHRC.js +22 -0
- package/dist/chunk-BA3VCHRC.js.map +1 -0
- package/dist/chunk-CRNBTU42.mjs +2 -0
- package/dist/chunk-CRNBTU42.mjs.map +1 -0
- package/dist/chunk-KPGHBLGY.mjs +2 -0
- package/dist/chunk-KPGHBLGY.mjs.map +1 -0
- package/dist/chunk-LJQHWCUK.js +2 -0
- package/dist/chunk-LJQHWCUK.js.map +1 -0
- package/dist/chunk-MFCWFFJV.mjs +2 -0
- package/dist/chunk-MFCWFFJV.mjs.map +1 -0
- package/dist/chunk-NSTK5EUQ.js +2 -0
- package/dist/chunk-NSTK5EUQ.js.map +1 -0
- package/dist/chunk-OCKHJ4WO.js +2 -0
- package/dist/chunk-OCKHJ4WO.js.map +1 -0
- package/dist/chunk-RTT6LULU.mjs +2 -0
- package/dist/chunk-RTT6LULU.mjs.map +1 -0
- package/dist/client/index.d.mts +249 -0
- package/dist/client/index.d.ts +249 -0
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +9 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/context/index.d.mts +43 -0
- package/dist/context/index.d.ts +43 -0
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/index.mjs +2 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +109 -0
- package/dist/hooks/index.d.ts +109 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +157 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/message-B21_kqE2.d.ts +78 -0
- package/dist/message-ufYsvKXP.d.mts +78 -0
- package/dist/primitives/index.d.mts +86 -0
- package/dist/primitives/index.d.ts +86 -0
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/index.mjs +2 -0
- package/dist/primitives/index.mjs.map +1 -0
- package/dist/streaming-CF63E6iS.d.mts +426 -0
- package/dist/streaming-CF63E6iS.d.ts +426 -0
- package/dist/styled/index.d.mts +477 -0
- package/dist/styled/index.d.ts +477 -0
- package/dist/styled/index.js +2 -0
- package/dist/styled/index.js.map +1 -0
- package/dist/styled/index.mjs +2 -0
- package/dist/styled/index.mjs.map +1 -0
- package/dist/styles-no-preflight.css +1 -0
- package/dist/styles.css +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkLJQHWCUK_js=require('./chunk-LJQHWCUK.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var m=react.createContext(null);function d(){let e=react.useContext(m);if(!e)throw new Error("useMessage must be used within a Message component");return e}var v=react.forwardRef(({message:e,viewerRole:t="user",children:s,...o},r)=>{let n=(e.participant?.role||"").toLowerCase()===(t||"").toLowerCase(),i=e.isStreaming??false;return jsxRuntime.jsx(m.Provider,{value:{message:e,isViewer:n,isStreaming:i},children:jsxRuntime.jsx("div",{ref:r,"data-role":e.participant?.role,"data-viewer":n,"data-streaming":i,...o,children:s})})});v.displayName="Message";var S=react.forwardRef(({children:e,...t},s)=>{let{message:o}=d();return jsxRuntime.jsx("div",{ref:s,...t,children:e??o.textContent})});S.displayName="MessageContent";var L=react.forwardRef(({format:e,...t},s)=>{let{message:o}=d(),r=typeof o.createdAt=="string"?new Date(o.createdAt):o.createdAt,n=e?e(r):r.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true});return jsxRuntime.jsx("span",{ref:s,...t,children:n})});L.displayName="MessageTimestamp";var h=react.forwardRef(({children:e,autoScroll:t=true,scrollThreshold:s=100,...o},r)=>{let{containerRef:n,scrollToBottom:i}=chunkLJQHWCUK_js.a({enabled:t,threshold:s});return jsxRuntime.jsx("div",{ref:p=>{n.current=p,typeof r=="function"?r(p):r&&(r.current=p);},"data-scroll-to-bottom":i,...o,children:e})});h.displayName="MessageList";var f=react.createContext(null);function M(){let e=react.useContext(f);if(!e)throw new Error("useComposer must be used within a MessageComposer component");return e}var P=react.forwardRef(({onSubmit:e,disabled:t=false,children:s,className:o},r)=>{let n=chunkLJQHWCUK_js.b({onSubmit:e,disabled:t}),i=p=>{p.preventDefault(),n.handleSubmit();},a={...n,canSubmit:!!n.canSubmit};return jsxRuntime.jsx(f.Provider,{value:a,children:jsxRuntime.jsx("form",{ref:r,className:o,onSubmit:i,"data-submitting":n.isSubmitting,"data-can-submit":n.canSubmit,children:s})})});P.displayName="MessageComposer";var H=react.forwardRef((e,t)=>{let{content:s,handleContentChange:o,handleKeyDown:r,inputRef:n}=M();return jsxRuntime.jsx("textarea",{ref:a=>{n.current=a,typeof t=="function"?t(a):t&&(t.current=a);},value:s,onChange:a=>o(a.target.value),onKeyDown:r,...e})});H.displayName="ComposerInput";var R=react.forwardRef(({children:e,disabled:t,...s},o)=>{let{canSubmit:r,isSubmitting:n}=M();return jsxRuntime.jsx("button",{ref:o,type:"submit",disabled:t||!r,"data-submitting":n,...s,children:e})});R.displayName="ComposerSubmit";function q(e){let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}var E=react.forwardRef(({name:e,src:t,alt:s,role:o,fallback:r,children:n,...i},a)=>{let p=e?q(e):null;return jsxRuntime.jsx("div",{ref:a,"data-role":o,...i,children:n??jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?jsxRuntime.jsx("img",{src:t,alt:s??e??o??"Avatar",style:{width:"100%",height:"100%"}}):r??p??o?.charAt(0).toUpperCase()})})});E.displayName="Avatar";var N=react.forwardRef(({content:e,isStreaming:t=false,showCursor:s=true,cursor:o,children:r,...n},i)=>jsxRuntime.jsxs("div",{ref:i,"data-streaming":t,...n,children:[r??e,t&&s&&(o??jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:"2px",height:"1em",backgroundColor:"currentColor",marginLeft:"2px",verticalAlign:"text-bottom",animation:"blink 1s step-end infinite"}}))]}));N.displayName="StreamingText";var C=react.createContext(null);function D(){let e=react.useContext(C);if(!e)throw new Error("useSuggestedActions must be used within a SuggestedActions component");return e}var B=react.forwardRef(({actions:e,onSelect:t,children:s,className:o},r)=>e.length===0?null:jsxRuntime.jsx(C.Provider,{value:{actions:e,onSelect:t},children:jsxRuntime.jsx("div",{ref:r,role:"group","aria-label":"Suggested actions",className:o,children:s})}));B.displayName="SuggestedActions";var I=react.forwardRef(({action:e,children:t,onClick:s,...o},r)=>{let{onSelect:n}=D();return jsxRuntime.jsx("button",{ref:r,type:"button",onClick:a=>{s?.(a),a.defaultPrevented||n(e);},...o,children:t??e.label})});I.displayName="ActionButton";var k=react.forwardRef(({children:e,dotCount:t=3,...s},o)=>jsxRuntime.jsx("div",{ref:o,role:"status","aria-label":"Assistant is typing",...s,children:e??jsxRuntime.jsx("span",{"aria-hidden":"true",children:Array.from({length:t}).map((r,n)=>jsxRuntime.jsx("span",{style:{display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"currentColor",marginRight:n<t-1?"4px":0,animation:"typing 1.4s infinite ease-in-out",animationDelay:`${n*.2}s`}},n))})}));k.displayName="TypingIndicator";exports.a=m;exports.b=d;exports.c=v;exports.d=S;exports.e=L;exports.f=h;exports.g=f;exports.h=M;exports.i=P;exports.j=H;exports.k=R;exports.l=E;exports.m=N;exports.n=C;exports.o=D;exports.p=B;exports.q=I;exports.r=k;//# sourceMappingURL=chunk-3KB4JYSQ.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-3KB4JYSQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/primitives/message.tsx","../src/primitives/message-list.tsx","../src/primitives/message-composer.tsx","../src/primitives/avatar.tsx","../src/primitives/streaming-text.tsx","../src/primitives/suggested-actions.tsx","../src/primitives/typing-indicator.tsx"],"names":["MessageContext","createContext","useMessage","context","useContext","Message","forwardRef","message","viewerRole","children","props","ref","isViewer","isStreaming","jsx","MessageContent","MessageTimestamp","format","date","formatted","MessageList","autoScroll","scrollThreshold","containerRef","scrollToBottom","useAutoScroll","node","ComposerContext","useComposer","MessageComposer","onSubmit","disabled","className","composer","useMessageComposer","handleFormSubmit","e","contextValue","ComposerInput","content","handleContentChange","handleKeyDown","inputRef","ComposerSubmit","canSubmit","isSubmitting","getInitials","name","parts","Avatar","src","alt","role","fallback","initials","Fragment","StreamingText","showCursor","cursor","jsxs","SuggestedActionsContext","useSuggestedActions","SuggestedActions","actions","onSelect","ActionButton","action","onClick","TypingIndicator","dotCount","_","i"],"mappings":"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","file":"chunk-3KB4JYSQ.js","sourcesContent":["import { createContext, forwardRef, useContext, type HTMLAttributes, type ReactNode } from \"react\";\nimport type { MessageData, ParticipantRole } from \"../types\";\n\ninterface MessageContextValue {\n\tmessage: MessageData;\n\tisViewer: boolean;\n\tisStreaming: boolean;\n}\n\nconst MessageContext = createContext<MessageContextValue | null>(null);\n\n/**\n * Hook to access the current message context.\n * Must be used within a Message component.\n */\nexport function useMessage() {\n\tconst context = useContext(MessageContext);\n\tif (!context) {\n\t\tthrow new Error(\"useMessage must be used within a Message component\");\n\t}\n\treturn context;\n}\n\nexport interface MessageProps extends HTMLAttributes<HTMLDivElement> {\n\t/** The message data */\n\tmessage: MessageData;\n\t/** The viewer's role (used to determine alignment) */\n\tviewerRole?: ParticipantRole;\n\t/** Children to render inside the message */\n\tchildren: ReactNode;\n}\n\n/**\n * Headless Message primitive.\n * Provides message context to children and data attributes for styling.\n */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n\t({ message, viewerRole = \"user\", children, ...props }, ref) => {\n\t\t// Case-insensitive comparison for role matching\n\t\tconst isViewer = (message.participant?.role || \"\").toLowerCase() === (viewerRole || \"\").toLowerCase();\n\t\tconst isStreaming = message.isStreaming ?? false;\n\n\t\treturn (\n\t\t\t<MessageContext.Provider value={{ message, isViewer, isStreaming }}>\n\t\t\t\t<div\n\t\t\t\t\tref={ref}\n\t\t\t\t\tdata-role={message.participant?.role}\n\t\t\t\t\tdata-viewer={isViewer}\n\t\t\t\t\tdata-streaming={isStreaming}\n\t\t\t\t\t{...props}>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t</MessageContext.Provider>\n\t\t);\n\t},\n);\n\nMessage.displayName = \"Message\";\n\nexport interface MessageContentProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Custom content to render instead of message text */\n\tchildren?: ReactNode;\n}\n\n/**\n * Renders the message content.\n * By default renders the message's textContent.\n */\nexport const MessageContent = forwardRef<HTMLDivElement, MessageContentProps>(({ children, ...props }, ref) => {\n\tconst { message } = useMessage();\n\n\treturn (\n\t\t<div ref={ref} {...props}>\n\t\t\t{children ?? message.textContent}\n\t\t</div>\n\t);\n});\n\nMessageContent.displayName = \"MessageContent\";\n\nexport interface MessageTimestampProps extends HTMLAttributes<HTMLSpanElement> {\n\t/** Custom date formatter */\n\tformat?: (date: Date) => string;\n}\n\n/**\n * Renders the message timestamp.\n */\nexport const MessageTimestamp = forwardRef<HTMLSpanElement, MessageTimestampProps>(({ format, ...props }, ref) => {\n\tconst { message } = useMessage();\n\tconst date = typeof message.createdAt === \"string\" ? new Date(message.createdAt) : message.createdAt;\n\n\tconst formatted = format\n\t\t? format(date)\n\t\t: date.toLocaleTimeString(\"en-US\", {\n\t\t\t\thour: \"numeric\",\n\t\t\t\tminute: \"2-digit\",\n\t\t\t\thour12: true,\n\t\t\t});\n\n\treturn (\n\t\t<span ref={ref} {...props}>\n\t\t\t{formatted}\n\t\t</span>\n\t);\n});\n\nMessageTimestamp.displayName = \"MessageTimestamp\";\n\nexport { MessageContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { useAutoScroll } from \"../hooks/use-auto-scroll\";\n\nexport interface MessageListProps extends HTMLAttributes<HTMLDivElement> {\n\t/** Messages to render */\n\tchildren: ReactNode;\n\t/** Whether to auto-scroll to bottom on new messages */\n\tautoScroll?: boolean;\n\t/** Threshold from bottom to trigger auto-scroll (pixels) */\n\tscrollThreshold?: number;\n}\n\n/**\n * Headless MessageList primitive.\n * Provides a scrollable container with auto-scroll behavior.\n */\nexport const MessageList = forwardRef<HTMLDivElement, MessageListProps>(\n\t({ children, autoScroll = true, scrollThreshold = 100, ...props }, ref) => {\n\t\tconst { containerRef, scrollToBottom } = useAutoScroll<HTMLDivElement>({\n\t\t\tenabled: autoScroll,\n\t\t\tthreshold: scrollThreshold,\n\t\t});\n\n\t\t// Merge refs\n\t\tconst mergedRef = (node: HTMLDivElement | null) => {\n\t\t\t(containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t};\n\n\t\treturn (\n\t\t\t<div ref={mergedRef} data-scroll-to-bottom={scrollToBottom} {...props}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t},\n);\n\nMessageList.displayName = \"MessageList\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type TextareaHTMLAttributes,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport { useMessageComposer } from \"../hooks/use-message-composer\";\n\ninterface ComposerContextValue {\n content: string;\n isSubmitting: boolean;\n canSubmit: boolean;\n error: string | null;\n handleContentChange: (value: string) => void;\n handleSubmit: () => Promise<void>;\n handleKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n inputRef: React.RefObject<HTMLTextAreaElement | null>;\n}\n\nconst ComposerContext = createContext<ComposerContextValue | null>(null);\n\n/**\n * Hook to access the composer context.\n * Must be used within a MessageComposer component.\n */\nexport function useComposer() {\n const context = useContext(ComposerContext);\n if (!context) {\n throw new Error(\"useComposer must be used within a MessageComposer component\");\n }\n return context;\n}\n\nexport interface MessageComposerProps {\n /** Callback when message is submitted */\n onSubmit: (content: string, attachments?: File[]) => Promise<void>;\n /** Whether the composer is disabled */\n disabled?: boolean;\n /** Children to render inside the composer */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless MessageComposer primitive.\n * Provides composer state and behavior to children.\n */\nexport const MessageComposer = forwardRef<HTMLFormElement, MessageComposerProps>(\n ({ onSubmit, disabled = false, children, className }, ref) => {\n const composer = useMessageComposer({ onSubmit, disabled });\n\n const handleFormSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n composer.handleSubmit();\n };\n\n const contextValue: ComposerContextValue = {\n ...composer,\n canSubmit: Boolean(composer.canSubmit),\n };\n\n return (\n <ComposerContext.Provider value={contextValue}>\n <form\n ref={ref}\n className={className}\n onSubmit={handleFormSubmit}\n data-submitting={composer.isSubmitting}\n data-can-submit={composer.canSubmit}\n >\n {children}\n </form>\n </ComposerContext.Provider>\n );\n }\n);\n\nMessageComposer.displayName = \"MessageComposer\";\n\nexport interface ComposerInputProps\n extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"onChange\" | \"value\"> {}\n\n/**\n * Text input for the message composer.\n */\nexport const ComposerInput = forwardRef<HTMLTextAreaElement, ComposerInputProps>(\n (props, ref) => {\n const { content, handleContentChange, handleKeyDown, inputRef } = useComposer();\n\n // Merge refs\n const mergedRef = (node: HTMLTextAreaElement | null) => {\n (inputRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n };\n\n return (\n <textarea\n ref={mergedRef}\n value={content}\n onChange={(e) => handleContentChange(e.target.value)}\n onKeyDown={handleKeyDown}\n {...props}\n />\n );\n }\n);\n\nComposerInput.displayName = \"ComposerInput\";\n\nexport interface ComposerSubmitProps extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\n/**\n * Submit button for the message composer.\n */\nexport const ComposerSubmit = forwardRef<HTMLButtonElement, ComposerSubmitProps>(\n ({ children, disabled, ...props }, ref) => {\n const { canSubmit, isSubmitting } = useComposer();\n\n return (\n <button\n ref={ref}\n type=\"submit\"\n disabled={disabled || !canSubmit}\n data-submitting={isSubmitting}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\n\nComposerSubmit.displayName = \"ComposerSubmit\";\n\nexport { ComposerContext };\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport type { ParticipantRole } from \"../types\";\n\nexport interface AvatarProps extends HTMLAttributes<HTMLDivElement> {\n /** Name for fallback initials */\n name?: string;\n /** Image URL */\n src?: string;\n /** Alt text for image */\n alt?: string;\n /** Participant role for styling */\n role?: ParticipantRole;\n /** Fallback content when no image or name */\n fallback?: React.ReactNode;\n}\n\n/**\n * Get initials from a name.\n */\nfunction getInitials(name: string): string {\n const parts = name.trim().split(/\\s+/);\n if (parts.length === 1) {\n return parts[0].charAt(0).toUpperCase();\n }\n return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase();\n}\n\n/**\n * Headless Avatar primitive.\n * Renders an image or fallback initials.\n */\nexport const Avatar = forwardRef<HTMLDivElement, AvatarProps>(\n ({ name, src, alt, role, fallback, children, ...props }, ref) => {\n const initials = name ? getInitials(name) : null;\n const altText = alt ?? name ?? role ?? \"Avatar\";\n\n return (\n <div ref={ref} data-role={role} {...props}>\n {children ?? (\n <>\n {src ? (\n <img src={src} alt={altText} style={{ width: \"100%\", height: \"100%\" }} />\n ) : (\n fallback ?? initials ?? role?.charAt(0).toUpperCase()\n )}\n </>\n )}\n </div>\n );\n }\n);\n\nAvatar.displayName = \"Avatar\";\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface StreamingTextProps extends HTMLAttributes<HTMLDivElement> {\n /** The content to display */\n content: string;\n /** Whether the text is currently streaming */\n isStreaming?: boolean;\n /** Show a cursor indicator while streaming */\n showCursor?: boolean;\n /** Custom cursor element */\n cursor?: ReactNode;\n /** Children override (takes precedence over content) */\n children?: ReactNode;\n}\n\n/**\n * Headless StreamingText primitive.\n * Renders text with streaming indicator support.\n */\nexport const StreamingText = forwardRef<HTMLDivElement, StreamingTextProps>(\n (\n { content, isStreaming = false, showCursor = true, cursor, children, ...props },\n ref\n ) => {\n const defaultCursor = (\n <span\n aria-hidden=\"true\"\n style={{\n display: \"inline-block\",\n width: \"2px\",\n height: \"1em\",\n backgroundColor: \"currentColor\",\n marginLeft: \"2px\",\n verticalAlign: \"text-bottom\",\n animation: \"blink 1s step-end infinite\",\n }}\n />\n );\n\n return (\n <div ref={ref} data-streaming={isStreaming} {...props}>\n {children ?? content}\n {isStreaming && showCursor && (cursor ?? defaultCursor)}\n </div>\n );\n }\n);\n\nStreamingText.displayName = \"StreamingText\";\n","import {\n createContext,\n useContext,\n forwardRef,\n type ReactNode,\n type ButtonHTMLAttributes,\n} from \"react\";\nimport type { SuggestedAction } from \"../types\";\n\ninterface SuggestedActionsContextValue {\n actions: SuggestedAction[];\n onSelect: (action: SuggestedAction) => void;\n}\n\nconst SuggestedActionsContext = createContext<SuggestedActionsContextValue | null>(null);\n\n/**\n * Hook to access suggested actions context.\n */\nexport function useSuggestedActions() {\n const context = useContext(SuggestedActionsContext);\n if (!context) {\n throw new Error(\n \"useSuggestedActions must be used within a SuggestedActions component\"\n );\n }\n return context;\n}\n\nexport interface SuggestedActionsProps {\n /** List of suggested actions */\n actions: SuggestedAction[];\n /** Callback when an action is selected */\n onSelect: (action: SuggestedAction) => void;\n /** Children to render */\n children: ReactNode;\n /** Additional CSS classes */\n className?: string;\n}\n\n/**\n * Headless SuggestedActions primitive.\n * Provides context for rendering action buttons.\n */\nexport const SuggestedActions = forwardRef<HTMLDivElement, SuggestedActionsProps>(\n ({ actions, onSelect, children, className }, ref) => {\n if (actions.length === 0) {\n return null;\n }\n\n return (\n <SuggestedActionsContext.Provider value={{ actions, onSelect }}>\n <div ref={ref} role=\"group\" aria-label=\"Suggested actions\" className={className}>\n {children}\n </div>\n </SuggestedActionsContext.Provider>\n );\n }\n);\n\nSuggestedActions.displayName = \"SuggestedActions\";\n\nexport interface ActionButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** The action this button represents */\n action: SuggestedAction;\n /** Children to render inside button */\n children?: ReactNode;\n}\n\n/**\n * Button for a suggested action.\n */\nexport const ActionButton = forwardRef<HTMLButtonElement, ActionButtonProps>(\n ({ action, children, onClick, ...props }, ref) => {\n const { onSelect } = useSuggestedActions();\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n if (!e.defaultPrevented) {\n onSelect(action);\n }\n };\n\n return (\n <button ref={ref} type=\"button\" onClick={handleClick} {...props}>\n {children ?? action.label}\n </button>\n );\n }\n);\n\nActionButton.displayName = \"ActionButton\";\n\nexport { SuggestedActionsContext };\n","import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\n\nexport interface TypingIndicatorProps extends HTMLAttributes<HTMLDivElement> {\n /** Custom content to show while typing */\n children?: ReactNode;\n /** Number of dots to show */\n dotCount?: number;\n}\n\n/**\n * Headless TypingIndicator primitive.\n * Shows animated dots or custom content.\n */\nexport const TypingIndicator = forwardRef<HTMLDivElement, TypingIndicatorProps>(\n ({ children, dotCount = 3, ...props }, ref) => {\n return (\n <div ref={ref} role=\"status\" aria-label=\"Assistant is typing\" {...props}>\n {children ?? (\n <span aria-hidden=\"true\">\n {Array.from({ length: dotCount }).map((_, i) => (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n width: \"6px\",\n height: \"6px\",\n borderRadius: \"50%\",\n backgroundColor: \"currentColor\",\n marginRight: i < dotCount - 1 ? \"4px\" : 0,\n animation: `typing 1.4s infinite ease-in-out`,\n animationDelay: `${i * 0.2}s`,\n }}\n />\n ))}\n </span>\n )}\n </div>\n );\n }\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';var chunk3KB4JYSQ_js=require('./chunk-3KB4JYSQ.js'),chunkOCKHJ4WO_js=require('./chunk-OCKHJ4WO.js'),react=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),jsxRuntime=require('react/jsx-runtime'),yr=require('react-markdown'),hr=require('remark-gfm'),reactSyntaxHighlighter=require('react-syntax-highlighter'),prism=require('react-syntax-highlighter/dist/esm/styles/prism'),framerMotion=require('framer-motion'),recharts=require('recharts'),zod=require('zod'),link=require('@lexical/link'),list=require('@lexical/list'),markdown=require('@lexical/markdown'),LexicalComposer=require('@lexical/react/LexicalComposer'),LexicalContentEditable=require('@lexical/react/LexicalContentEditable'),LexicalErrorBoundary=require('@lexical/react/LexicalErrorBoundary'),LexicalHistoryPlugin=require('@lexical/react/LexicalHistoryPlugin'),LexicalListPlugin=require('@lexical/react/LexicalListPlugin'),LexicalRichTextPlugin=require('@lexical/react/LexicalRichTextPlugin'),LexicalOnChangePlugin=require('@lexical/react/LexicalOnChangePlugin'),LexicalAutoFocusPlugin=require('@lexical/react/LexicalAutoFocusPlugin'),richText=require('@lexical/rich-text'),LexicalComposerContext=require('@lexical/react/LexicalComposerContext'),lexical=require('lexical');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var yr__default=/*#__PURE__*/_interopDefault(yr);var hr__default=/*#__PURE__*/_interopDefault(hr);function i(...e){return tailwindMerge.twMerge(clsx.clsx(e))}function nr(e){return e.startsWith("image/")?lucideReact.Image:e==="application/pdf"||e.startsWith("text/")?lucideReact.FileText:lucideReact.File}function or(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var pa=react.forwardRef(({attachment:e,onRemove:a,removable:r=true,className:t},n)=>{let s=nr(e.mimeType),o=e.mimeType.startsWith("image/");return jsxRuntime.jsxs("div",{ref:n,className:i("relative group","flex items-center gap-2","p-2 rounded-lg","border border-chat-border","bg-chat-panel-bg",t),children:[jsxRuntime.jsx("div",{className:i("w-10 h-10 rounded","flex items-center justify-center","bg-gray-100 dark:bg-gray-800","overflow-hidden flex-shrink-0"),children:o&&e.previewUrl?jsxRuntime.jsx("img",{src:e.previewUrl,alt:e.filename,className:"w-full h-full object-cover"}):jsxRuntime.jsx(s,{className:"w-5 h-5 text-chat-subtle"})}),jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsx("p",{className:"text-sm font-medium truncate text-chat-text",children:e.filename}),jsxRuntime.jsx("p",{className:"text-xs text-chat-subtle",children:or(e.size)})]}),r&&a&&jsxRuntime.jsx("button",{type:"button",onClick:a,className:i("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:jsxRuntime.jsx(lucideReact.X,{className:"w-3 h-3"})})]})});pa.displayName="AttachmentPreview";var lr={sm:"w-6 h-6 text-xs",md:"w-8 h-8 text-sm",lg:"w-10 h-10 text-base"},cr={sm:14,md:16,lg:20};function pr(e,a){let r=cr[a];switch(e){case "assistant":return jsxRuntime.jsx(lucideReact.Bot,{size:r});case "user":return jsxRuntime.jsx(lucideReact.User,{size:r});default:return jsxRuntime.jsx(lucideReact.User,{size:r})}}var Ie=react.forwardRef(({name:e,src:a,alt:r,role:t,size:n="md",className:s,...o},l)=>jsxRuntime.jsx(chunk3KB4JYSQ_js.l,{ref:l,name:e,src:a,alt:r,role:t,className:i("rounded-full overflow-hidden flex-shrink-0","flex items-center justify-center","font-medium",t==="assistant"?"bg-primary/10 text-primary":"bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300",lr[n],s),fallback:pr(t,n),...o}));Ie.displayName="Avatar";var ma=react.forwardRef(({children:e,className:a,...r},t)=>jsxRuntime.jsx("div",{ref:t,className:i("flex flex-col h-full","bg-white dark:bg-gray-900","font-sans text-chat-text",a),...r,children:e}));ma.displayName="ChatContainer";var ur={small:"w-1.5 h-1.5",medium:"w-2 h-2",large:"w-2.5 h-2.5"},gr={small:"gap-1",medium:"gap-1.5",large:"gap-2"};function We({size:e="medium",className:a}){let r=ur[e];return jsxRuntime.jsxs("div",{className:i("flex items-center",gr[e],a),children:[jsxRuntime.jsx("div",{className:i(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-1")}),jsxRuntime.jsx("div",{className:i(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-2")}),jsxRuntime.jsx("div",{className:i(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-3")})]})}var Sr={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 zr(e){return Sr[e.toLowerCase()]||e.toLowerCase()}function Tt(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function Pr({text:e}){let[a,r]=react.useState(false),t=react.useCallback(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3);}catch{}},[e]);return jsxRuntime.jsxs("button",{onClick:t,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":a?"Copied":"Copy code",children:[a?jsxRuntime.jsx(lucideReact.Check,{size:14}):jsxRuntime.jsx(lucideReact.Copy,{size:14}),a?"Copied":"Copy"]})}function re({children:e,className:a,baselineFontSize:r=1,darkCodeTheme:t}){let n=t??(typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches),s=r!==1?{fontSize:`${r}rem`}:void 0;return jsxRuntime.jsx(yr__default.default,{className:i("chat-prose",a),remarkPlugins:[hr__default.default],components:{h1:({children:o})=>{let l=String(o),p=Tt(l);return jsxRuntime.jsxs("h1",{id:p,className:"group text-xl font-semibold mt-4 mb-2 first:mt-0",style:s,children:[o,jsxRuntime.jsx("a",{href:`#${p}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsxRuntime.jsx(lucideReact.Link,{size:16,className:"inline"})})]})},h2:({children:o})=>{let l=String(o),p=Tt(l);return jsxRuntime.jsxs("h2",{id:p,className:"group text-lg font-semibold mt-3 mb-2 first:mt-0",style:s,children:[o,jsxRuntime.jsx("a",{href:`#${p}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsxRuntime.jsx(lucideReact.Link,{size:14,className:"inline"})})]})},h3:({children:o})=>{let l=String(o),p=Tt(l);return jsxRuntime.jsxs("h3",{id:p,className:"group text-base font-medium mt-2 mb-1 first:mt-0",style:s,children:[o,jsxRuntime.jsx("a",{href:`#${p}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsxRuntime.jsx(lucideReact.Link,{size:12,className:"inline"})})]})},h4:({children:o})=>jsxRuntime.jsx("h4",{className:"text-base font-medium mt-2 mb-1 first:mt-0",style:s,children:o}),p:({children:o})=>jsxRuntime.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",style:s,children:o}),a:({href:o,children:l})=>jsxRuntime.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:opacity-80 transition-opacity",style:s,children:l}),ul:({children:o})=>jsxRuntime.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:o}),ol:({children:o})=>jsxRuntime.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:o}),li:({children:o})=>jsxRuntime.jsx("li",{className:"leading-relaxed",style:s,children:o}),blockquote:({children:o})=>jsxRuntime.jsx("blockquote",{className:"border-l-2 border-gray-300 dark:border-gray-600 pl-3 my-2 italic text-chat-subtle",style:s,children:o}),code:({className:o,children:l})=>{let p=/language-(\w+)/.exec(o||""),d=String(l).replace(/\n$/,"");if(!p&&!d.includes(`
|
|
2
|
+
`))return jsxRuntime.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono",style:s,children:l});let x=p?zr(p[1]):"text";return jsxRuntime.jsxs("div",{className:"relative group my-2 rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxRuntime.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:[jsxRuntime.jsx("span",{className:"text-xs font-mono text-gray-400",children:x}),jsxRuntime.jsx(Pr,{text:d})]}),jsxRuntime.jsx(reactSyntaxHighlighter.Prism,{language:x,style:n===false?prism.oneLight:prism.oneDark,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:d})]})},pre:({children:o})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:o}),table:({children:o})=>jsxRuntime.jsx("div",{className:"overflow-x-auto my-2 rounded-lg border border-gray-200 dark:border-gray-700",children:jsxRuntime.jsx("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:o})}),thead:({children:o})=>jsxRuntime.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:o}),th:({children:o})=>jsxRuntime.jsx("th",{className:"px-3 py-2 text-left text-sm font-medium text-gray-700 dark:text-gray-300",style:s,children:o}),td:({children:o})=>jsxRuntime.jsx("td",{className:"px-3 py-2 text-sm text-gray-600 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700",style:s,children:o}),hr:()=>jsxRuntime.jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),strong:({children:o})=>jsxRuntime.jsx("strong",{className:"font-semibold",children:o}),em:({children:o})=>jsxRuntime.jsx("em",{className:"italic",children:o}),img:({src:o,alt:l})=>jsxRuntime.jsx("img",{src:o,alt:l??"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"})},children:e})}function ga(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"};default:return {label:"Source",color:"#757575"}}}function Rt({sources:e,className:a}){let[r,t]=react.useState(null);return !e||e.length===0?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:i("flex flex-wrap gap-1.5 mt-2",a),children:e.map(n=>{let s=ga(n.source_type);return jsxRuntime.jsxs("button",{onClick:()=>t(n),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:s.color+"1a",color:s.color,borderColor:s.color+"40"},children:["[",n.index,"] ",n.title]},n.index)})}),jsxRuntime.jsx(fa,{source:r,onClose:()=>t(null)})]})}function fa({source:e,onClose:a}){if(react.useEffect(()=>{if(!e)return;let t=n=>{n.key==="Escape"&&a();};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,a]),!e)return null;let r=ga(e.source_type);return jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/50",onClick:a}),jsxRuntime.jsxs(framerMotion.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("h3",{className:"text-lg font-semibold truncate",children:e.title}),jsxRuntime.jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded font-medium shrink-0",style:{backgroundColor:r.color+"1a",color:r.color},children:r.label})]}),jsxRuntime.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 ml-2",children:jsxRuntime.jsx(lucideReact.X,{size:16})})]}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[jsxRuntime.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&&jsxRuntime.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&&jsxRuntime.jsx("div",{className:"mb-4",children:jsxRuntime.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,jsxRuntime.jsx(lucideReact.ExternalLink,{size:12})]})}),e.description&&jsxRuntime.jsx("p",{className:"text-sm text-gray-500 mb-4",children:e.description}),e.full_content?jsxRuntime.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?jsxRuntime.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}):jsxRuntime.jsx("p",{className:"text-sm text-gray-400 italic",children:"No content available for this source."})]}),jsxRuntime.jsx("div",{className:"flex justify-end p-3 border-t border-gray-200 dark:border-gray-700",children:jsxRuntime.jsx("button",{onClick:a,className:"px-3 py-1.5 text-sm rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"Close"})})]})]})})}function _r({index:e,source:a}){return jsxRuntime.jsx("span",{className:i("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",a?.url?"cursor-pointer hover:opacity-85":"cursor-default"),title:a?`${a.title}${a.description?": "+a.description:""}`:void 0,onClick:r=>{a?.url&&(r.stopPropagation(),window.open(a.url,"_blank","noopener,noreferrer"));},children:e})}function Mt({clarification:e,onSubmit:a,onOptionSelect:r,disabled:t=false,loading:n=false,className:s}){let[o,l]=react.useState(""),p=react.useCallback(v=>{v.trim()&&(l(""),a(v.trim()));},[a]),d=v=>{let g=v.target.value;r?.(g),p(g);},f=v=>{v.key==="Enter"&&!v.shiftKey&&o.trim()&&(v.preventDefault(),p(o));},x=e.options&&e.options.length>0,h=e.allowFreeText!==false;return jsxRuntime.jsxs("div",{className:i("mx-4 mb-3 px-4 py-3","bg-orange-50/60 dark:bg-orange-950/20","border-l-[3px] border-orange-400","rounded-r-lg",s),children:[jsxRuntime.jsxs("div",{className:i("flex items-start gap-2",(x||h)&&"mb-2"),children:[jsxRuntime.jsx("span",{className:"text-orange-600 mt-0.5",children:jsxRuntime.jsx(lucideReact.MessageCircle,{size:14})}),jsxRuntime.jsx("p",{className:"text-sm font-medium",children:e.question})]}),x&&jsxRuntime.jsx("div",{className:i("ml-5 space-y-1",h&&"mb-2"),children:e.options.map((v,g)=>jsxRuntime.jsxs("label",{className:"flex items-center gap-2 py-0.5 cursor-pointer text-sm hover:bg-orange-100/50 dark:hover:bg-orange-900/20 rounded px-1 -mx-1",children:[jsxRuntime.jsx("input",{type:"radio",name:"clarification-option",value:v,onChange:d,disabled:t||n,className:"accent-orange-500 w-3.5 h-3.5"}),v]},g))}),h&&jsxRuntime.jsxs("div",{className:"flex items-center ml-5 bg-white dark:bg-gray-900 rounded border border-orange-200 dark:border-orange-800 px-3 py-1",children:[jsxRuntime.jsx("input",{type:"text",value:o,onChange:v=>l(v.target.value),onKeyDown:f,placeholder:x?"Or type your response...":"Type your response...",disabled:t||n,className:"flex-1 text-sm bg-transparent outline-none placeholder:text-gray-400 disabled:opacity-50"}),jsxRuntime.jsx("button",{onClick:()=>p(o),disabled:!o.trim()||t||n,className:i("p-1 rounded transition-colors",o.trim()?"text-orange-600 hover:text-orange-700":"text-gray-300"),children:jsxRuntime.jsx(lucideReact.Send,{size:16})})]})]})}function _t({attachments:e,onDownload:a,onPreview:r,className:t}){let[n,s]=react.useState(null);if(!e||e.length===0)return null;let o=p=>{if(a){a(p);return}if(p.url){let d=document.createElement("a");d.href=p.url,d.download=p.filename,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d);}},l=p=>{if(r){r(p);return}p.isImage&&p.url&&s(p.url);};return jsxRuntime.jsxs("div",{className:i("flex flex-wrap gap-1.5",t),children:[e.map(p=>jsxRuntime.jsx(qr,{attachment:p,onDownload:()=>o(p),onPreview:()=>l(p)},p.id)),n&&jsxRuntime.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:()=>s(null),children:[jsxRuntime.jsx("button",{className:"absolute top-4 right-4 p-2 text-white hover:bg-white/20 rounded-full transition-colors",onClick:()=>s(null),"aria-label":"Close",children:jsxRuntime.jsx(lucideReact.X,{size:24})}),jsxRuntime.jsx("img",{src:n,alt:"Preview",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:p=>p.stopPropagation()})]})]})}function qr({attachment:e,onDownload:a,onPreview:r}){let t=e.humanReadableSize||Xr(e.size);return jsxRuntime.jsxs("div",{className:i("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?r:void 0,children:[jsxRuntime.jsx(Gr,{mimeType:e.mimeType,size:14}),jsxRuntime.jsx("span",{className:"text-xs text-[var(--chat-text)] truncate min-w-0",children:e.filename}),t&&t!=="0 Bytes"&&jsxRuntime.jsx("span",{className:"text-[10px] text-[var(--chat-text-subtle)] flex-shrink-0",children:t}),e.url&&jsxRuntime.jsx("button",{onClick:n=>{n.stopPropagation(),a();},className:"p-0.5 hover:bg-[var(--chat-border)] rounded transition-colors flex-shrink-0","aria-label":"Download",children:jsxRuntime.jsx(lucideReact.Download,{size:12,className:"text-[var(--chat-text-subtle)]"})})]})}function Gr({mimeType:e,size:a=14}){return e.startsWith("image/")?jsxRuntime.jsx(lucideReact.Image,{size:a,className:"text-[var(--chat-primary)] flex-shrink-0"}):e.startsWith("video/")?jsxRuntime.jsx(lucideReact.Video,{size:a,className:"text-[var(--chat-primary)] flex-shrink-0"}):e==="application/pdf"?jsxRuntime.jsx(lucideReact.FileText,{size:a,className:"text-red-500 flex-shrink-0"}):jsxRuntime.jsx(lucideReact.FileIcon,{size:a,className:"text-gray-500 flex-shrink-0"})}function Xr(e){if(e===0)return "0 Bytes";let a=1024,r=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(a));return parseFloat((e/Math.pow(a,t)).toFixed(2))+" "+r[t]}var ba="miiflow-beamer-keyframes";function Pe(e){if(typeof document>"u")return;let a=e?.getRootNode?.(),r=a instanceof ShadowRoot?a:document.head;if(r.querySelector(`#${ba}`))return;let t=document.createElement("style");t.id=ba,t.textContent="@keyframes beamer{0%{left:-30%}100%{left:100%}}",r.appendChild(t);}var Ee={position:"absolute",top:0,left:"-30%",width:"30%",height:"100%",background:"linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.7) 50%, transparent 100%)",animation:"beamer 2s linear infinite",zIndex:1,pointerEvents:"none"};function Qe({status:e,size:a=16,className:r}){let t=Math.max(a-4,10);return jsxRuntime.jsxs("div",{className:i("relative flex-shrink-0 flex items-center justify-center",r),style:{width:a,height:a},children:[e==="pending"&&jsxRuntime.jsx(lucideReact.CircleDashed,{size:a,strokeWidth:2,className:"text-[var(--chat-text-subtle)] opacity-40"}),e==="running"&&jsxRuntime.jsxs("div",{className:"relative flex items-center justify-center",style:{width:a,height:a},children:[jsxRuntime.jsx("div",{className:"absolute inset-0 rounded-full bg-indigo-500/20 animate-ping",style:{animationDuration:"1.5s"}}),jsxRuntime.jsx("div",{className:"relative rounded-full bg-gradient-to-br from-indigo-500 to-purple-500 p-[2px] animate-pulse-glow",children:jsxRuntime.jsx("div",{className:"rounded-full bg-white dark:bg-gray-900 flex items-center justify-center",style:{width:t,height:t},children:jsxRuntime.jsx(lucideReact.Loader2,{size:t-2,strokeWidth:2.5,className:"text-indigo-500 animate-spin"})})})]}),e==="completed"&&jsxRuntime.jsx("div",{className:"animate-complete-pop",children:jsxRuntime.jsx("div",{className:"rounded-full animate-success-flash",children:jsxRuntime.jsx(lucideReact.CircleCheck,{size:a,strokeWidth:2,className:"text-green-500"})})}),e==="failed"&&jsxRuntime.jsx(lucideReact.CircleX,{size:a,strokeWidth:2,className:"text-red-500"})]})}function De({items:e,badgeSize:a=20,className:r}){let t=react.useRef(null);return react.useEffect(()=>{Pe(t.current);},[]),e.length===0?null:jsxRuntime.jsx("div",{ref:t,className:i("max-w-full",r),children:jsxRuntime.jsx("div",{className:"flex flex-col",children:e.map((n,s)=>{let o=s===e.length-1,p=(o?null:e[s+1])?.status==="pending",d=n.status==="running"&&!o;return jsxRuntime.jsxs("div",{className:"animate-fade-in",style:{display:"grid",gridTemplateColumns:`${a}px 1fr`,gap:"0.5rem",paddingBottom:o?0:"0.5rem",position:"relative"},children:[jsxRuntime.jsxs("div",{className:"relative flex flex-col items-center flex-shrink-0",style:{paddingTop:"4px"},children:[jsxRuntime.jsx(Qe,{status:n.status,size:a}),!o&&(d?jsxRuntime.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] animate-flow-down",style:{top:a+6,height:`calc(100% - ${a}px + 4px)`,background:`repeating-linear-gradient(
|
|
3
|
+
180deg,
|
|
4
|
+
rgb(99, 102, 241) 0px,
|
|
5
|
+
rgb(99, 102, 241) 4px,
|
|
6
|
+
transparent 4px,
|
|
7
|
+
transparent 8px
|
|
8
|
+
)`,zIndex:1}}):jsxRuntime.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",style:{top:a+6,height:`calc(100% - ${a}px + 4px)`,width:0,borderLeft:"2px",borderStyle:p?"dashed":"solid",borderColor:"var(--chat-border)",zIndex:1}}))]}),jsxRuntime.jsxs("div",{style:{minWidth:0,flex:1,display:"flex",alignItems:"center",position:"relative",overflow:"hidden",borderRadius:4,...n.status==="running"&&{backgroundColor:"rgba(0, 0, 0, 0.02)",padding:"2px 4px"}},children:[n.status==="running"&&jsxRuntime.jsx("div",{style:Ee}),n.content]})]},n.id)})})})}function en({status:e,isLast:a=false,badgeSize:r=16,children:t,className:n}){let s=react.useRef(null);react.useEffect(()=>{Pe(s.current);},[]);let o=e==="running"&&!a;return jsxRuntime.jsxs("div",{ref:s,className:i("relative flex items-start gap-3 animate-fade-in",!a&&"pb-3",n),children:[jsxRuntime.jsxs("div",{className:"relative flex-shrink-0 pt-0.5",children:[jsxRuntime.jsx(Qe,{status:e,size:r}),!a&&(o?jsxRuntime.jsx("div",{className:"absolute w-[2px] animate-flow-down",style:{left:r/2-1,top:r+4,height:"calc(100% + 12px)",background:`repeating-linear-gradient(
|
|
9
|
+
180deg,
|
|
10
|
+
rgb(99, 102, 241) 0px,
|
|
11
|
+
rgb(99, 102, 241) 4px,
|
|
12
|
+
transparent 4px,
|
|
13
|
+
transparent 8px
|
|
14
|
+
)`,zIndex:1}}):jsxRuntime.jsx("div",{className:"absolute bg-[var(--chat-border)] opacity-30",style:{left:r/2-.5,top:r+4,height:"calc(100% + 12px)",width:1,zIndex:1}}))]}),jsxRuntime.jsxs("div",{style:{minWidth:0,flex:1,position:"relative",overflow:"hidden",borderRadius:4,...e==="running"&&{backgroundColor:"rgba(0, 0, 0, 0.02)",padding:"2px 4px"}},children:[e==="running"&&jsxRuntime.jsx("div",{style:Ee}),t]})]})}function Lt({event:e,className:a,isRunning:r}){let t=react.useRef(null);if(react.useEffect(()=>{Pe(t.current);},[]),e.type==="thinking")return jsxRuntime.jsx("div",{ref:t,className:i("p-1 rounded transition-colors","bg-black/[0.01] hover:bg-black/[0.02]",a),children:jsxRuntime.jsx("div",{className:"text-[var(--chat-text-subtle)] leading-relaxed",children:jsxRuntime.jsx(re,{className:"text-[14px]",children:e.content})})});if(e.type==="planning")return jsxRuntime.jsx("div",{ref:t,className:i("p-1 rounded transition-colors","bg-black/[0.01] hover:bg-black/[0.02]",a),children:jsxRuntime.jsx("div",{className:"text-[var(--chat-text-subtle)] leading-relaxed",children:jsxRuntime.jsx(re,{className:"text-[14px]",children:e.content})})});if(e.type==="tool")return jsxRuntime.jsxs("div",{ref:t,className:i("inline-flex items-center gap-1.5",a),style:{position:"relative",overflow:"hidden",borderRadius:4,...r&&{backgroundColor:"rgba(0, 0, 0, 0.02)",padding:"2px 4px"}},children:[r&&jsxRuntime.jsx("div",{style:Ee}),jsxRuntime.jsx(lucideReact.Wrench,{size:14,className:"text-black/50 relative z-10 shrink-0"}),jsxRuntime.jsx("span",{className:"text-[14px] text-black/65 relative z-10",children:e.toolDescription||e.toolName})]});if(e.type==="observation"){let n=e.success!==false;return jsxRuntime.jsxs("div",{ref:t,className:i("px-3 py-1.5 rounded max-w-full overflow-auto",n?"bg-green-50 border-l-[3px] border-green-400":"bg-yellow-50 border-l-[3px] border-yellow-400",a),children:[jsxRuntime.jsxs("span",{className:i("text-xs font-semibold uppercase tracking-wide block mb-1",n?"text-green-700":"text-yellow-700"),children:[e.toolName," Result"]}),jsxRuntime.jsx("div",{className:i(n?"text-green-900":"text-yellow-900"),children:jsxRuntime.jsx(re,{className:"text-[14px]",children:e.content})})]})}return null}var nn=["create_plan","unknown"];function wa(e){return e?nn.includes(e.toLowerCase().trim()):false}function et(e,a){if(e.toolName&&wa(e.toolName))return null;if(e.type==="thinking")return !e.content||e.content.trim().length===0?null:{id:`thinking-${a}`,type:"thinking",status:"completed",content:e.content};if(e.type==="planning"){if(!e.content||e.content.trim().length===0)return null;let r=e.planData!==void 0||e.content.includes("\u2713 Created plan");return {id:`planning-${a}`,type:"planning",status:r?"completed":"running",content:e.content,isComplete:r}}if(e.type==="tool"){let r=e.status==="executing"?"running":e.status==="completed"?"completed":"pending";return {id:`tool-${a}`,type:"tool",status:r,toolName:e.toolName||"Unknown Tool",toolDescription:e.toolDescription}}return null}function on(e){let a=[];return e.forEach((r,t)=>{if(r.type==="thought"){let n=r.thought;if(!n||n.trim().length===0)return;a.push({id:`thought-${t}`,type:"thinking",status:"completed",content:n});}else if(r.type==="tool"){let n=r.tool||"Unknown Tool";if(wa(n))return;a.push({id:`tool-${t}`,type:"tool",status:"completed",toolName:n,toolDescription:r.tool_description});}}),a}function we({events:e,className:a}){if(e.length===0)return null;let r=e.map(t=>({id:t.id,status:t.status,content:jsxRuntime.jsx(Lt,{event:t,isRunning:t.status==="running"})}));return jsxRuntime.jsx(De,{items:r,badgeSize:20,className:a})}function pn(e){let a=[];return e.forEach((r,t)=>{if(r.type==="thinking"){if(!r.content||r.content.trim().length===0)return;a.push({id:`thinking-${t}`,type:"thinking",status:"completed",content:r.content});}else if(r.type==="tool"){let n=r.status==="executing"?"running":r.status==="completed"?"completed":"pending";a.push({id:`tool-${t}`,type:"tool",status:n,toolName:r.toolName||"Unknown Tool",toolDescription:r.toolDescription});}}),a}function dn({subtask:e,executionChunks:a=[]}){let[r,t]=react.useState(e.status==="running"),n=e.status==="running",s=e.status==="failed",o=e.status==="completed";n&&!r&&t(true);let l=a.length>0,p=pn(a);return jsxRuntime.jsxs("div",{className:"flex-1 min-w-0",children:[jsxRuntime.jsxs("div",{onClick:()=>l&&t(!r),className:i("flex items-center gap-2 min-w-0",l&&"cursor-pointer"),children:[jsxRuntime.jsx("span",{className:i("text-sm font-medium truncate",s?"text-red-500":"text-black/85"),children:e.description}),s&&e.error&&jsxRuntime.jsx("span",{className:"text-sm text-red-500 truncate flex-1",children:e.error}),o&&e.execution_time!=null&&e.execution_time>0&&jsxRuntime.jsxs("span",{className:"text-xs text-black/40 shrink-0 tabular-nums",children:[e.execution_time.toFixed(1),"s"]}),l&&jsxRuntime.jsx("span",{className:"text-black/40 shrink-0 flex items-center",children:r?jsxRuntime.jsx(lucideReact.ChevronUp,{size:14}):jsxRuntime.jsx(lucideReact.ChevronDown,{size:14})})]}),l&&r&&jsxRuntime.jsx("div",{className:"mt-2 pl-2",children:jsxRuntime.jsx(we,{events:p})})]})}function at({plan:e,streamingChunks:a=[],className:r}){let t=e.subtasks.map(n=>{let s=a.filter(l=>l.subtaskId===n.id),o=n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending";return {id:String(n.id),status:o,content:jsxRuntime.jsx(dn,{subtask:n,executionChunks:s})}});return jsxRuntime.jsxs("div",{className:i("space-y-2",r),children:[jsxRuntime.jsx("span",{className:"text-sm text-black/50",children:"Plan:"}),jsxRuntime.jsx(De,{items:t,badgeSize:20})]})}function rt({chunk:e}){let[a,r]=react.useState(false),t=e.claudeToolData;if(!t)return null;let n=t.status==="pending",s=t.status==="error",o=t.status==="completed",l=()=>n?jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"animate-spin text-gray-400"}):s?jsxRuntime.jsx(lucideReact.XCircle,{size:14,className:"text-red-500"}):jsxRuntime.jsx(lucideReact.CheckCircle2,{size:14,className:"text-green-500"});return jsxRuntime.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[jsxRuntime.jsxs("div",{onClick:()=>r(!a),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",children:[jsxRuntime.jsx(lucideReact.Wrench,{size:16,className:"text-gray-400 shrink-0"}),jsxRuntime.jsxs("span",{className:"flex-1 text-sm truncate",children:[jsxRuntime.jsx("span",{className:"font-medium",children:(()=>{let d=t.toolName;if(d.startsWith("mcp__")){let f=d.split("__");if(f.length>=3)return `${f[1]}/${f[2]}`}return d})()}),t.toolDescription&&jsxRuntime.jsx("span",{className:"text-gray-400 ml-2",children:t.toolDescription})]}),l(),o&&t.durationMs!=null&&jsxRuntime.jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 bg-black/5 dark:bg-white/5 rounded",children:[Math.round(t.durationMs),"ms"]}),jsxRuntime.jsx("span",{className:"p-0.5",children:a?jsxRuntime.jsx(lucideReact.ChevronDown,{size:14}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:14})})]}),a&&jsxRuntime.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[t.toolInput&&Object.keys(t.toolInput).length>0&&jsxRuntime.jsxs("div",{className:"mb-3",children:[jsxRuntime.jsx("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider mb-1",children:"Input"}),jsxRuntime.jsx("pre",{className:"text-[0.75rem] font-mono bg-gray-100 dark:bg-gray-900 rounded p-2 overflow-auto max-h-[150px] m-0",children:JSON.stringify(t.toolInput,null,2)})]}),s&&jsxRuntime.jsx("p",{className:"text-sm text-red-500 font-mono",children:t.content||"Tool execution failed"}),n&&jsxRuntime.jsx("p",{className:"text-sm text-gray-400 italic",children:"Executing tool..."}),o&&t.content&&!t.isError&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider mb-1",children:"Result"}),jsxRuntime.jsx("pre",{className:"text-[0.75rem] font-mono bg-gray-100 dark:bg-gray-900 rounded p-2 overflow-auto max-h-[200px] whitespace-pre-wrap break-words m-0",children:t.content.length>1500?`${t.content.slice(0,1500)}
|
|
15
|
+
... (truncated)`:t.content})]})]})]})}function nt({chunk:e}){let[a,r]=react.useState(true),t=e.terminalData;if(!t)return null;let n=()=>{switch(t.status){case "running":return jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"animate-spin text-blue-500"});case "completed":return jsxRuntime.jsx(lucideReact.CheckCircle2,{size:14,className:"text-green-500"});case "failed":return jsxRuntime.jsx(lucideReact.XCircle,{size:14,className:"text-red-500"});default:return null}},s=t.status==="running"?"border-blue-500/30":t.status==="failed"?"border-red-500/30":t.exitCode===0?"border-green-500/30":"border-yellow-500/30",o=t.status==="running"?"bg-blue-500/10":t.status==="failed"?"bg-red-500/10":"bg-green-500/10",l=t.status==="running"?"text-blue-500":t.status==="failed"?"text-red-500":"text-green-500",p=d=>d?d<1e3?d+"ms":(d/1e3).toFixed(1)+"s":null;return jsxRuntime.jsxs("div",{className:i("my-1 bg-[#1a1a1a] rounded border",s,"overflow-hidden"),children:[jsxRuntime.jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",o,"hover:brightness-110"),children:[jsxRuntime.jsx("span",{className:"p-0.5 text-gray-500",children:a?jsxRuntime.jsx(lucideReact.ChevronDown,{size:16}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:16})}),jsxRuntime.jsx(lucideReact.Terminal,{size:16,className:l}),jsxRuntime.jsxs("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-300 truncate",children:[jsxRuntime.jsx("span",{className:"text-gray-500",children:"$ "}),t.command]}),t.durationMs!=null&&jsxRuntime.jsx("span",{className:"text-[0.7rem] text-gray-600",children:p(t.durationMs)}),n(),t.status!=="running"&&t.exitCode!==void 0&&jsxRuntime.jsxs("span",{className:i("text-[0.7rem] font-mono",t.exitCode===0?"text-green-500":"text-red-500"),children:["[",t.exitCode,"]"]})]}),a&&jsxRuntime.jsxs("div",{className:"p-3",children:[t.description&&jsxRuntime.jsx("p",{className:"text-gray-500 text-[0.75rem] italic mb-2",children:t.description}),t.stdout&&jsxRuntime.jsx("pre",{className:i("m-0 p-2 text-[0.7rem] font-mono bg-[#0d0d0d] rounded overflow-auto max-h-[300px]","text-green-400 whitespace-pre-wrap break-words",t.stderr&&"mb-2"),children:t.stdout}),t.stderr&&jsxRuntime.jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-red-500/10 rounded border border-red-500/30 overflow-auto max-h-[200px] text-red-400 whitespace-pre-wrap break-words",children:t.stderr}),t.status==="running"&&!t.stdout&&!t.stderr&&jsxRuntime.jsx("p",{className:"text-gray-500 text-[0.75rem] italic",children:"Running..."}),t.status==="completed"&&!t.stdout&&!t.stderr&&t.exitCode===0&&jsxRuntime.jsx("p",{className:"text-gray-600 text-[0.75rem] italic",children:"Command completed with no output"})]})]})}function ot({chunk:e}){let[a,r]=react.useState(false),t=e.fileOperationData;if(!t)return null;let n=t.operation==="read"?jsxRuntime.jsx(lucideReact.Eye,{size:16}):t.operation==="write"?jsxRuntime.jsx(lucideReact.Save,{size:16}):t.operation==="edit"?jsxRuntime.jsx(lucideReact.Pencil,{size:16}):jsxRuntime.jsx(lucideReact.FileText,{size:16}),s=t.operation==="read"?"text-blue-500 border-blue-500":t.operation==="write"?"text-green-500 border-green-500":t.operation==="edit"?"text-yellow-500 border-yellow-500":"text-gray-500 border-gray-500",o=t.operation==="read"?"bg-blue-500/5 hover:bg-blue-500/8":t.operation==="write"?"bg-green-500/5 hover:bg-green-500/8":t.operation==="edit"?"bg-yellow-500/5 hover:bg-yellow-500/8":"bg-gray-500/5",l=t.status==="pending"?jsxRuntime.jsx(lucideReact.Clock,{size:14,className:"text-gray-400"}):t.status==="completed"?jsxRuntime.jsx(lucideReact.CheckCircle2,{size:14,className:"text-green-500"}):jsxRuntime.jsx(lucideReact.XCircle,{size:14,className:"text-red-500"}),p=t.operation==="read"?"Read":t.operation==="write"?"Write":t.operation==="edit"?"Edit":"File",d=f=>{let x=f.split("/");return x.length<=3?f:".../"+x.slice(-3).join("/")};return jsxRuntime.jsxs("div",{className:i("my-1 border rounded overflow-hidden",s.split(" ")[1]+"/30"),children:[jsxRuntime.jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",o),children:[jsxRuntime.jsx("span",{className:"p-0.5",children:a?jsxRuntime.jsx(lucideReact.ChevronDown,{size:16}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:16})}),jsxRuntime.jsx("span",{className:s.split(" ")[0],children:n}),jsxRuntime.jsx("span",{className:i("font-medium text-[0.75rem]",s.split(" ")[0]),children:p}),jsxRuntime.jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:d(t.filePath)}),t.totalLines!=null&&jsxRuntime.jsxs("span",{className:"text-[0.7rem] text-gray-400",children:[t.totalLines," lines"]}),l]}),a&&jsxRuntime.jsxs("div",{className:"p-3 bg-gray-50 dark:bg-[#1e1e1e]",children:[t.operation==="read"&&t.content&&jsxRuntime.jsx(Vn,{content:t.content}),t.operation==="edit"&&jsxRuntime.jsx(Fn,{oldString:t.oldString,newString:t.newString}),t.operation==="write"&&t.status==="completed"&&jsxRuntime.jsx("p",{className:"text-green-500 text-sm",children:"File written successfully"}),t.error&&jsxRuntime.jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})]})]})}function Vn({content:e}){let a=react.useMemo(()=>e.split(`
|
|
16
|
+
`).slice(0,50),[e]),r=e.split(`
|
|
17
|
+
`).length,t=r>50;return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("pre",{className:"m-0 p-2 text-[0.75rem] font-mono bg-gray-100 dark:bg-[#1a1a1a] rounded overflow-auto max-h-[300px]",children:a.map((n,s)=>jsxRuntime.jsxs("div",{className:"flex",children:[jsxRuntime.jsx("span",{className:"inline-block w-10 text-right pr-3 mr-3 border-r border-gray-200 dark:border-gray-700 text-gray-400 select-none",children:s+1}),jsxRuntime.jsx("span",{children:n||" "})]},s))}),t&&jsxRuntime.jsxs("p",{className:"text-[0.75rem] text-gray-400 mt-1",children:["... and ",r-50," more lines"]})]})}function Fn({oldString:e,newString:a}){return !e&&!a?jsxRuntime.jsx("p",{className:"text-gray-500 text-sm",children:"No changes to display"}):jsxRuntime.jsxs("div",{className:"flex gap-4",children:[jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("span",{className:"text-[0.75rem] font-medium text-red-500 block mb-1",children:"- Removed"}),jsxRuntime.jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-red-500/10 rounded border border-red-500/30 overflow-auto max-h-[200px] whitespace-pre-wrap break-words",children:e||"(empty)"})]}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx("span",{className:"text-[0.75rem] font-medium text-green-500 block mb-1",children:"+ Added"}),jsxRuntime.jsx("pre",{className:"m-0 p-2 text-[0.7rem] font-mono bg-green-500/10 rounded border border-green-500/30 overflow-auto max-h-[200px] whitespace-pre-wrap break-words",children:a||"(empty)"})]})]})}function st({chunk:e}){let[a,r]=react.useState(true),t=e.searchResultsData;if(!t)return null;let n=t.tool==="grep",s=n?"text-purple-500":"text-blue-500",o=n?"border-purple-500/30":"border-blue-500/30",l=n?"bg-purple-500/5 hover:bg-purple-500/8":"bg-blue-500/5 hover:bg-blue-500/8",p=n?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500";return jsxRuntime.jsxs("div",{className:i("my-1 border rounded overflow-hidden",o),children:[jsxRuntime.jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer",l),children:[jsxRuntime.jsx("span",{className:"p-0.5",children:a?jsxRuntime.jsx(lucideReact.ChevronDown,{size:16}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:16})}),jsxRuntime.jsx("span",{className:s,children:n?jsxRuntime.jsx(lucideReact.FileSearch,{size:16}):jsxRuntime.jsx(lucideReact.FolderSearch,{size:16})}),jsxRuntime.jsx("span",{className:i("text-[0.7rem] px-1.5 py-0.5 rounded font-medium",p),children:n?"Grep":"Glob"}),jsxRuntime.jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:t.pattern}),jsxRuntime.jsxs("span",{className:i("text-[0.7rem] px-1.5 py-0.5 rounded",t.totalCount>0?"bg-green-500/10 text-green-500":"bg-gray-500/10 text-gray-500"),children:[t.totalCount," results"]})]}),a&&jsxRuntime.jsxs("div",{className:"max-h-[300px] overflow-auto",children:[t.results.length>0?jsxRuntime.jsxs("div",{children:[t.results.slice(0,50).map((d,f)=>jsxRuntime.jsx(jn,{result:d,isGrep:n},f)),t.results.length>50&&jsxRuntime.jsx("div",{className:"py-1 px-3",children:jsxRuntime.jsxs("span",{className:"text-[0.75rem] text-gray-400",children:["... and ",t.results.length-50," more results"]})})]}):jsxRuntime.jsx("div",{className:"p-3",children:jsxRuntime.jsx("p",{className:"text-gray-500 text-sm",children:"No results found"})}),t.error&&jsxRuntime.jsx("div",{className:"p-3",children:jsxRuntime.jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})})]})]})}function jn({result:e,isGrep:a}){return jsxRuntime.jsxs("div",{className:"flex items-start gap-2 py-1 px-3 border-b border-gray-100 dark:border-gray-800 last:border-b-0 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[jsxRuntime.jsx(lucideReact.File,{size:14,className:"text-gray-400 mt-0.5 shrink-0"}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"font-mono text-[0.75rem] truncate",children:(t=>{let n=t.split("/");return n.length<=4?t:".../"+n.slice(-4).join("/")})(e.filePath)}),a&&e.lineNumber!=null&&jsxRuntime.jsxs("span",{className:"font-mono text-[0.7rem] text-blue-500",children:[":",e.lineNumber]})]}),e.snippet&&jsxRuntime.jsx("p",{className:"font-mono text-[0.7rem] text-gray-500 truncate max-w-[400px]",children:e.snippet})]})]})}function it({chunk:e}){let[a,r]=react.useState(false),t=e.webOperationData;if(!t)return null;let n=t.operation==="search",s=t.status==="pending",o=t.status==="error",l=t.status==="completed",p=()=>s?jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"animate-spin text-gray-400"}):o?jsxRuntime.jsx(lucideReact.XCircle,{size:14,className:"text-red-500"}):jsxRuntime.jsx(lucideReact.CheckCircle2,{size:14,className:"text-green-500"}),f=n?(()=>{if(!t.results||typeof t.results!="string")return [];let x=/\[([^\]]+)\]\(([^)]+)\)/g,h=[],v;for(;(v=x.exec(t.results))!==null;)h.push({title:v[1],url:v[2]});return h})():[];return jsxRuntime.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[jsxRuntime.jsxs("div",{onClick:()=>r(!a),className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",children:[n?jsxRuntime.jsx(lucideReact.Search,{size:16,className:"text-gray-400 shrink-0"}):jsxRuntime.jsx(lucideReact.Globe,{size:16,className:"text-gray-400 shrink-0"}),jsxRuntime.jsx("span",{className:"flex-1 text-sm truncate",children:n?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Searching: ",jsxRuntime.jsx("span",{className:"font-medium",children:t.query})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["Fetching: ",jsxRuntime.jsx("span",{className:"font-medium",children:t.url})]})}),p(),l&&t.durationMs!=null&&jsxRuntime.jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 bg-black/5 dark:bg-white/5 rounded",children:[Math.round(t.durationMs),"ms"]}),jsxRuntime.jsx("span",{className:"p-0.5",children:a?jsxRuntime.jsx(lucideReact.ChevronDown,{size:14}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:14})})]}),a&&jsxRuntime.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[o&&t.error&&jsxRuntime.jsx("p",{className:"text-sm text-red-500 font-mono",children:t.error}),s&&jsxRuntime.jsx("p",{className:"text-sm text-gray-400 italic",children:n?"Searching the web...":"Fetching content..."}),n&&l&&f.length>0&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider",children:[f.length," Results"]}),f.slice(0,5).map((x,h)=>jsxRuntime.jsxs("div",{className:i("flex items-center gap-2 py-1",h<Math.min(f.length,5)-1&&"border-b border-gray-200 dark:border-gray-700"),children:[jsxRuntime.jsx(lucideReact.ExternalLink,{size:12,className:"text-gray-400 shrink-0"}),jsxRuntime.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm truncate hover:underline",children:x.title})]},h)),f.length>5&&jsxRuntime.jsxs("p",{className:"text-[0.75rem] text-gray-400 italic",children:["+",f.length-5," more results"]})]}),n&&l&&f.length===0&&t.results&&jsxRuntime.jsxs("p",{className:"text-sm whitespace-pre-wrap max-h-[200px] overflow-auto",children:[typeof t.results=="string"?t.results.slice(0,1e3):JSON.stringify(t.results,null,2).slice(0,1e3),t.results.length>1e3&&"..."]}),!n&&l&&t.content&&jsxRuntime.jsx("div",{className:"max-h-[300px] overflow-auto bg-gray-100 dark:bg-gray-900 rounded p-2",children:jsxRuntime.jsxs("pre",{className:"text-[0.75rem] font-mono whitespace-pre-wrap break-words m-0",children:[t.content.slice(0,2e3),t.content.length>2e3&&`
|
|
18
|
+
... (truncated)`]})})]})]})}var lo={code_reviewer:"Code Review",researcher:"Research",data_analyst:"Data Analysis",Explore:"Explore",Plan:"Planning",Bash:"Command Execution"};function lt({chunk:e}){let[a,r]=react.useState(true),t=e.subagentData;if(!t)return null;let n=t.status==="running"?jsxRuntime.jsx(lucideReact.Loader2,{size:16,className:"animate-spin text-blue-500"}):t.status==="completed"?jsxRuntime.jsx(lucideReact.CheckCircle2,{size:16,className:"text-green-500"}):t.status==="failed"?jsxRuntime.jsx(lucideReact.XCircle,{size:16,className:"text-red-500"}):null,s=t.status==="running"?"border-blue-500":t.status==="completed"?"border-green-500":t.status==="failed"?"border-red-500":"border-gray-500",o=t.status==="running"?"bg-blue-500/3":t.status==="completed"?"bg-green-500/3":t.status==="failed"?"bg-red-500/3":"bg-gray-500/3",l=t.status==="running"?"bg-blue-500/10 text-blue-500":t.status==="completed"?"bg-green-500/10 text-green-500":t.status==="failed"?"bg-red-500/10 text-red-500":"bg-gray-500/10 text-gray-500",p=f=>f?f<1e3?f+"ms":(f/1e3).toFixed(1)+"s":null,d=lo[t.subagentType]||t.subagentType;return jsxRuntime.jsxs("div",{className:i("border border-dashed rounded ml-4 my-2 overflow-hidden",s+"/50",o),children:[jsxRuntime.jsxs("div",{onClick:()=>r(!a),className:i("flex items-center gap-2 px-3 py-1.5 cursor-pointer hover:brightness-95"),children:[jsxRuntime.jsx("span",{className:"p-0.5",children:a?jsxRuntime.jsx(lucideReact.ChevronDown,{size:18}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:18})}),jsxRuntime.jsx(lucideReact.GitBranch,{size:16,className:s.replace("border-","text-")}),jsxRuntime.jsx("span",{className:i("text-[0.75rem] px-2 py-0.5 rounded font-medium",l),children:d}),jsxRuntime.jsx("span",{className:"flex-1 text-sm text-gray-500 truncate",children:t.description}),n,t.durationMs!=null&&jsxRuntime.jsx("span",{className:"text-[0.7rem] text-gray-400",children:p(t.durationMs)})]}),a&&jsxRuntime.jsxs("div",{className:"px-4 pb-3",children:[t.nestedChunks&&t.nestedChunks.length>0&&jsxRuntime.jsx("div",{className:"mt-2 space-y-1",children:t.nestedChunks.map((f,x)=>jsxRuntime.jsx(co,{chunk:f},x))}),t.status==="completed"&&t.result&&jsxRuntime.jsxs("div",{className:"mt-2 p-2 rounded bg-green-500/5 border border-green-500/20",children:[jsxRuntime.jsx("span",{className:"text-[0.75rem] font-medium text-green-500",children:"Result"}),jsxRuntime.jsx("p",{className:"mt-1 text-sm text-gray-500 whitespace-pre-wrap",children:t.result.length>500?t.result.slice(0,500)+"...":t.result})]})]})]})}function co({chunk:e}){return e.type==="tool"||e.type==="observation"?jsxRuntime.jsxs("div",{className:"py-1 px-2 my-1 rounded bg-blue-500/5 text-[0.75rem]",children:[jsxRuntime.jsxs("span",{className:"font-medium text-blue-500",children:[e.toolName||"Tool",":"]})," ",jsxRuntime.jsxs("span",{className:"text-gray-500",children:[e.content?.slice(0,200)||e.toolDescription||"Executing...",e.content&&e.content.length>200&&"..."]})]}):e.type==="thinking"||e.type==="claude_thinking"?jsxRuntime.jsxs("p",{className:"py-1 text-[0.75rem] text-gray-400 italic",children:[e.content?.slice(0,150),e.content&&e.content.length>150&&"..."]}):null}function vo(e){let a=react.useRef(null),[r,t]=react.useState(0),n=react.useRef(0);return react.useEffect(()=>{if(e){a.current===null&&(a.current=Date.now());let s=setInterval(()=>{if(a.current!==null){let o=Math.floor((Date.now()-a.current)/1e3);t(o),n.current=o;}},1e3);return ()=>clearInterval(s)}else a.current!==null&&(n.current=Math.floor((Date.now()-a.current)/1e3),t(n.current),a.current=null);},[e]),{display:`${r}`,finalSeconds:n.current}}function wo(e){return e.some(a=>a.orchestrator==="claude_agent_sdk"||a.type==="subagent"||a.type==="file_operation"||a.type==="terminal"||a.type==="search_results"||a.type==="web_operation"||a.type==="claude_text"||a.type==="claude_thinking")}function No(e){return e.some(a=>a.type==="wave_start"||a.type==="wave_complete"||a.type==="parallel_subtask_start"||a.type==="parallel_subtask_complete"||a.isParallel)}function ko(e){let a=e.filter(p=>p.type==="wave_start"&&p.waveData);if(a.length===0)return null;let r=a[a.length-1],t=r.waveData?.waveNumber??0,n=r.waveData?.totalWaves??1,s=r.waveData?.parallelCount??0,o=[],l=[];return e.forEach(p=>{if(p.type==="parallel_subtask_start"&&p.waveNumber===t&&p.subtaskId!==void 0&&(l.includes(p.subtaskId)||o.push(p.subtaskId)),p.type==="parallel_subtask_complete"&&p.waveNumber===t&&p.subtaskId!==void 0){l.push(p.subtaskId);let d=o.indexOf(p.subtaskId);d>=0&&o.splice(d,1);}}),{currentWave:t,totalWaves:n,parallelCount:s,activeSubtasks:o,completedSubtasks:l}}function Co(e){return e.some(a=>a.type==="multi_agent_planning"||a.type==="multi_agent_planning_complete"||a.type==="subagent_start"||a.type==="subagent_complete"||a.type==="subagent_failed"||a.type==="synthesis"||a.isMultiAgent)}function Pa(e){return e.find(r=>(r.type==="multi_agent_planning"||r.type==="multi_agent_planning_complete")&&r.subagentAllocations)?.subagentAllocations||[]}function Ea(e){let a=new Map,r=false;Pa(e).forEach(s=>{a.set(s.name,{name:s.name,task:s.query||s.focus,status:"pending"});});let t={pending:0,running:1,completed:2,failed:2};e.forEach(s=>{if(s.subagentInfo?.name){let o=s.subagentInfo.id||s.subagentInfo.name,l=a.get(o);(!l||(t[s.subagentInfo.status]??0)>=(t[l.status]??0))&&a.set(o,s.subagentInfo);}s.type==="synthesis"&&(r=true);});let n=[...a.values()];return {subagents:a,running:n.filter(s=>s.status==="running").length,completed:n.filter(s=>s.status==="completed").length,failed:n.filter(s=>s.status==="failed").length,pending:n.filter(s=>s.status==="pending").length,isSynthesizing:r}}function So(e){let a=[];return e.forEach(r=>{r.type==="thought"&&r.thought?a.push({type:"thinking",content:r.thought,subtaskId:r.subtask_id}):r.type==="tool"&&(a.push({type:"tool",content:"",toolName:r.tool||"Unknown Tool",toolDescription:r.tool_description,status:"completed",subtaskId:r.subtask_id}),r.observation&&a.push({type:"observation",content:r.observation,toolName:r.tool||"Unknown Tool",success:true,subtaskId:r.subtask_id}));}),a}function zo({chunks:e}){let a=Ea(e),r=[...a.subagents.values()];if(r.length===0){let n=e.some(o=>o.type==="multi_agent_planning"),s=Pa(e);return s.length>0?jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"animate-spin text-gray-400"}),jsxRuntime.jsxs("span",{className:"text-sm text-gray-500",children:["Allocating agents: ",s.map(o=>o.name).join(", ")]})]}):n?jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"animate-spin text-gray-400"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:"Planning agent allocation..."})]}):null}let t=r.map((n,s)=>({id:n.id||`agent-${s}`,status:n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending",content:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:"text-sm font-medium",children:n.name}),jsxRuntime.jsx("span",{className:i("text-sm flex-1 truncate",n.status==="failed"?"text-red-500":"text-gray-500"),children:n.status==="failed"&&n.error?n.error:n.task}),n.status==="completed"&&n.executionTime!=null&&jsxRuntime.jsxs("span",{className:"text-xs text-gray-400 shrink-0",children:[n.executionTime.toFixed(1),"s"]})]})}));return jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:a.running===0?"Agents:":"Running agents:"}),jsxRuntime.jsx(De,{items:t,badgeSize:16}),a.isSynthesizing&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.Sparkle,{size:14,className:"text-gray-500"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:"Synthesizing results..."})]})]})}function Po({chunks:e}){return jsxRuntime.jsx("div",{className:"space-y-2",children:e.map((a,r)=>a.type==="subagent"&&a.subagentData?jsxRuntime.jsx(lt,{chunk:a},`subagent-${a.subagentData.subagentId}-${r}`):a.type==="file_operation"&&a.fileOperationData?jsxRuntime.jsx(ot,{chunk:a},`file-op-${a.fileOperationData.toolUseId}-${r}`):a.type==="terminal"&&a.terminalData?jsxRuntime.jsx(nt,{chunk:a},`terminal-${a.terminalData.toolUseId}-${r}`):a.type==="search_results"&&a.searchResultsData?jsxRuntime.jsx(st,{chunk:a},`search-${a.searchResultsData.toolUseId}-${r}`):a.type==="web_operation"&&a.webOperationData?jsxRuntime.jsx(it,{chunk:a},`web-op-${a.webOperationData.toolUseId}-${r}`):a.claudeToolData?jsxRuntime.jsx(rt,{chunk:a},`claude-tool-${a.claudeToolData.toolUseId}-${r}`):null)})}function Ca(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}function Ft({isStreaming:e=false,chunks:a=[],plan:r,executionTimeline:t=[],userMessageTimestamp:n,executionTime:s,defaultExpanded:o=false,expanded:l,onExpandedChange:p,className:d}){let[f,x]=react.useState(o),{display:h,finalSeconds:v}=vo(e),g=react.useRef(null);react.useEffect(()=>{Pe(g.current);},[]);let C=l??f,E=N=>{x(N),p?.(N);},I=react.useMemo(()=>e?a.map((N,b)=>et(N,b)).filter(N=>N!==null):[],[e,a]),L=react.useMemo(()=>!e&&(t.length>0||a.length>0)?a.map((N,b)=>et(N,b)).filter(N=>N!==null):[],[e,t,a]),ee=react.useMemo(()=>!e&&t.length>0?So(t):[],[e,t]),P=react.useMemo(()=>{if(!e)return null;let N=a.find(z=>z.planData!==void 0);if(!N?.planData)return null;let b={...N.planData},D=[...b.subtasks||[]],T=0,y=0;return a.forEach(z=>{if(z.type==="parallel_subtask_start"&&z.subtaskId!==void 0){let F=D.findIndex(B=>String(B.id)===String(z.subtaskId));F!==-1&&(D[F]={...D[F],status:"running"});}else if(z.type==="parallel_subtask_complete"&&z.subtaskId!==void 0){let F=D.findIndex(B=>String(B.id)===String(z.subtaskId));if(F!==-1){let B={...D[F]};z.parallelSubtaskData?.success===false||z.success===false?(B.status="failed",B.error=z.parallelSubtaskData?.error,y++):(B.status="completed",B.result=z.parallelSubtaskData?.result,B.execution_time=z.parallelSubtaskData?.executionTime,T++),D[F]=B;}}else if(z.type==="subtask"&&z.subtaskId!==void 0){let F=D.findIndex(B=>String(B.id)===String(z.subtaskId));if(F!==-1){let B={...D[F]};if(z.content.includes("\u2713 Completed"))B.status="completed",z.subtaskData?.execution_time&&(B.execution_time=z.subtaskData.execution_time),T++;else if(z.content.includes("\u2717 Failed")){B.status="failed";let ta=z.content.match(/✗ Failed: (.*)/);ta&&(B.error=ta[1]),y++;}else z.content.includes("\u2192 **Subtask")&&(B.status="running");D[F]=B;}}}),b.subtasks=D,b.completed_subtasks=T,b.failed_subtasks=y,b.progress_percentage=T/b.total_subtasks*100,b},[e,a]),u=react.useMemo(()=>{if(!e){if(r?.subtasks)return r.subtasks.reduce((N,b)=>N+(b.execution_time||0),0);if(t.length>0){let N=t[t.length-1];if(n&&N.timestamp)return N.timestamp-n;if(t.length>1){let b=t[0];if(b.timestamp&&N.timestamp)return N.timestamp-b.timestamp}}}return s||0},[e,r,t,n,s]);if(!e){let N=r||t.length>0||a.length>0;if(!N||N&&L.length===0&&!r&&t.length===0)return null}let c=a.length>0?a[a.length-1]:null,k=c?.type==="tool"||!!c?.toolName,O=c?.type==="planning",w=No(a),q=w?ko(a):null,Y=wo(a),fe=Co(a),he=fe?Ea(a):null,Ae=()=>{if(!e)return u>0?`Thought for ${Ca(u)}`:v>0?`Thought for ${Ca(v)}`:(a.length>0,"Thought for a few seconds");if(fe&&he){let{running:N,completed:b,failed:D,isSynthesizing:T}=he;if(T)return "Synthesizing results...";if(c?.type==="multi_agent_planning")return "Planning subagent allocation...";if(c?.type==="subagent_start"&&c?.subagentInfo)return `${c.subagentInfo.name}: ${c.subagentInfo.task?.slice(0,30)||"working"}...`;if(c?.type==="subagent_complete"&&c?.subagentInfo)return `${c.subagentInfo.name} complete`;if(c?.type==="subagent_failed"&&c?.subagentInfo)return `${c.subagentInfo.name} failed`;let y=N+b+D;if(N>0)return `${N} subagent${N>1?"s":""} running (${b}/${y} done)`;if(y>0)return `Multi-agent execution (${b}/${y} complete)`}if(Y){if(c?.type==="subagent"&&c?.subagentData)return `${c.subagentData.subagentType}: ${c.subagentData.description}`;if(c?.type==="file_operation"&&c?.fileOperationData){let N=c.fileOperationData.operation,b=c.fileOperationData.filePath.split("/").pop();return `${N==="read"?"Reading":N==="edit"?"Editing":"Writing"} ${b}`}if(c?.type==="terminal"&&c?.terminalData){let N=c.terminalData.command;return N.length>40?`$ ${N.slice(0,37)}...`:`$ ${N}`}if(c?.type==="search_results"&&c?.searchResultsData)return `${c.searchResultsData.tool}: ${c.searchResultsData.pattern}`;if(c?.type==="web_operation"&&c?.webOperationData)return c.webOperationData.operation==="search"?`Searching: ${c.webOperationData.query}`:`Fetching: ${c.webOperationData.url?.slice(0,40)}...`}if(w&&q){let{currentWave:N,totalWaves:b,parallelCount:D,activeSubtasks:T,completedSubtasks:y}=q;if(c?.type==="wave_start")return `Wave ${N+1}/${b}: ${D} parallel subtasks`;if(c?.type==="wave_complete")return `Wave ${N+1} complete (${y.length} done)`;if(c?.type==="parallel_subtask_start"&&c?.parallelSubtaskData?.description){let z=c.parallelSubtaskData.description;return z.length>40?`${z.slice(0,37)}...`:z}return T.length>0?`Wave ${N+1}/${b}: ${T.length} running...`:`Parallel execution (Wave ${N+1}/${b})`}if(c?.toolDescription)return c.toolDescription;if(c?.toolName)return c.toolName;switch(c?.type){case "planning":return "Planning...";case "thinking":return "Thinking...";case "tool":return c.toolName||"Using tool...";case "subtask":return `Executing subtask ${c.subtaskId||""}...`;case "observation":return "Analyzing results...";case "progress":return "Working...";case "wave_start":return "Starting parallel execution...";case "wave_complete":return "Parallel wave complete";case "parallel_subtask_start":return "Running parallel subtask...";case "parallel_subtask_complete":return "Parallel subtask complete";default:return "Thinking..."}},Se=()=>fe?jsxRuntime.jsx(lucideReact.Users,{size:14}):Y?c?.type==="subagent"?jsxRuntime.jsx(lucideReact.GitBranch,{size:14}):c?.type==="file_operation"?jsxRuntime.jsx(lucideReact.FileText,{size:14}):c?.type==="terminal"?jsxRuntime.jsx(lucideReact.Terminal,{size:14}):c?.type==="search_results"?jsxRuntime.jsx(lucideReact.Search,{size:14}):c?.type==="web_operation"?jsxRuntime.jsx(lucideReact.Globe,{size:14}):jsxRuntime.jsx(lucideReact.Sparkle,{size:14}):w?jsxRuntime.jsx(lucideReact.Zap,{size:14}):k?jsxRuntime.jsx(lucideReact.Wrench,{size:14}):O?jsxRuntime.jsx(lucideReact.ListTodo,{size:14}):jsxRuntime.jsx(lucideReact.Sparkle,{size:14}),Be=N=>N?.subtasks&&N.subtasks.length>=2,ce=e?P:r,_e=Be(ce);return jsxRuntime.jsxs("div",{ref:g,className:i("max-w-full",d),children:[jsxRuntime.jsxs("div",{onClick:()=>E(!C),style:{position:"relative",display:"inline-flex",alignItems:"center",gap:6,padding:"4px 6px",overflow:"hidden",borderRadius:8,cursor:"pointer",transition:"opacity 0.2s",...!e&&{opacity:.6}},children:[e&&jsxRuntime.jsx("div",{style:Ee}),jsxRuntime.jsx("span",{className:i("flex items-center text-gray-500"),children:e?Se():jsxRuntime.jsx(lucideReact.Sparkle,{size:14})}),jsxRuntime.jsx("span",{className:i("text-sm font-medium",e?"text-[var(--chat-text)]":"text-[var(--chat-text-subtle)]"),children:Ae()}),e&&parseInt(h)>0&&jsxRuntime.jsxs("span",{className:"text-gray-500 font-medium tabular-nums text-sm",children:[h,"s"]})]}),C&&jsxRuntime.jsx("div",{className:"mt-3 animate-fade-in",children:e?fe?jsxRuntime.jsx(zo,{chunks:a}):Y?jsxRuntime.jsx(Po,{chunks:a}):_e&&ce?jsxRuntime.jsx(at,{plan:ce,streamingChunks:a}):P?.subtasks?.length===1?jsxRuntime.jsx(we,{events:I}):P?.subtasks?.length===0?null:jsxRuntime.jsx(we,{events:I}):r?r.subtasks?.length===0?null:r.subtasks?.length===1?jsxRuntime.jsx(we,{events:L}):jsxRuntime.jsx(at,{plan:r,streamingChunks:ee}):jsxRuntime.jsx(we,{events:L})})]})}var je=react.forwardRef(({content:e,isStreaming:a=false,renderMarkdown:r=true,className:t,baselineFontSize:n,markdownProps:s},o)=>jsxRuntime.jsx(chunk3KB4JYSQ_js.m,{ref:o,content:e,isStreaming:a,showCursor:false,className:i("relative",t),children:r?jsxRuntime.jsx(re,{baselineFontSize:n,...s,children:e}):jsxRuntime.jsx("span",{className:"whitespace-pre-wrap",children:e})}));je.displayName="StreamingText";var Bo={send_message:jsxRuntime.jsx(lucideReact.Send,{size:14}),navigate:jsxRuntime.jsx(lucideReact.Navigation,{size:14}),copy_text:jsxRuntime.jsx(lucideReact.Copy,{size:14}),compose_email:jsxRuntime.jsx(lucideReact.Mail,{size:14}),search_emails:jsxRuntime.jsx(lucideReact.Search,{size:14}),open_modal:jsxRuntime.jsx(lucideReact.ExternalLink,{size:14}),api_call:jsxRuntime.jsx(lucideReact.Zap,{size:14})};function Wo(e){return e?Bo[e]||jsxRuntime.jsx(lucideReact.ArrowRight,{size:14}):jsxRuntime.jsx(lucideReact.ArrowRight,{size:14})}var pt=react.forwardRef(({actions:e,onSelect:a,className:r,showIcons:t=true,disabled:n=false},s)=>{let[o,l]=react.useState(null);if(e.length===0)return null;let p=async(d,f)=>{if(!(!a||o!==null)){l(f);try{await a(d);}finally{l(null);}}};return jsxRuntime.jsx("div",{ref:s,role:"group","aria-label":"Suggested actions",className:i("flex flex-wrap gap-2",r),children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:e.map((d,f)=>{let x=o===f,h=n||o!==null;return jsxRuntime.jsxs(framerMotion.motion.button,{type:"button",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,delay:f*.05},disabled:h,onClick:()=>p(d,f),className:i("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:[x?jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"animate-spin"}):t&&jsxRuntime.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Wo(d.type)}),d.label]},d.id)})})})});pt.displayName="SuggestedActions";var as=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function gt({data:e,config:a,isStreaming:r=false}){let{chartType:t,series:n,xAxis:s,yAxis:o}=e,l=a?.colors||as,p=a?.height||300,d=a?.legend!==false,f=a?.grid!==false,x=a?.tooltip!==false,h=a?.animate!==false&&!r,v=a?.stacked||false,C=(()=>{if(t==="pie")return (n[0]?.data||[]).map((c,k)=>({name:c.name||c.x||`Item ${k+1}`,value:c.value??c.y??0}));let P=new Map;return n.forEach(u=>{u.data.forEach(c=>{let k=c.x??c.name;P.has(k)||P.set(k,{x:k}),P.get(k)[u.name]=c.y??c.value??0;});}),Array.from(P.values())})(),E={data:C,margin:{top:10,right:30,left:0,bottom:0}},I={fontSize:12},L={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsxRuntime.jsx("div",{className:"w-full",style:{height:p},children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(t){case "line":return jsxRuntime.jsxs(recharts.LineChart,{...E,children:[f&&jsxRuntime.jsx(recharts.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsxRuntime.jsx(recharts.YAxis,{...I,tickLine:false,width:40}),x&&jsxRuntime.jsx(recharts.Tooltip,{contentStyle:L}),d&&jsxRuntime.jsx(recharts.Legend,{}),n.map((P,u)=>jsxRuntime.jsx(recharts.Line,{type:"monotone",dataKey:P.name,stroke:P.color||l[u%l.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:h},P.name))]});case "bar":return jsxRuntime.jsxs(recharts.BarChart,{...E,children:[f&&jsxRuntime.jsx(recharts.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsxRuntime.jsx(recharts.YAxis,{...I,tickLine:false,width:40}),x&&jsxRuntime.jsx(recharts.Tooltip,{contentStyle:L}),d&&jsxRuntime.jsx(recharts.Legend,{}),n.map((P,u)=>jsxRuntime.jsx(recharts.Bar,{dataKey:P.name,fill:P.color||l[u%l.length],stackId:v?"stack":void 0,isAnimationActive:h,radius:[4,4,0,0]},P.name))]});case "area":return jsxRuntime.jsxs(recharts.AreaChart,{...E,children:[f&&jsxRuntime.jsx(recharts.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"x",...I,tickLine:false,padding:{left:10,right:10}}),jsxRuntime.jsx(recharts.YAxis,{...I,tickLine:false,width:40}),x&&jsxRuntime.jsx(recharts.Tooltip,{contentStyle:L}),d&&jsxRuntime.jsx(recharts.Legend,{}),n.map((P,u)=>jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:P.name,stroke:P.color||l[u%l.length],fill:P.color||l[u%l.length],fillOpacity:.3,stackId:v?"stack":void 0,isAnimationActive:h},P.name))]});case "pie":return jsxRuntime.jsxs(recharts.PieChart,{children:[x&&jsxRuntime.jsx(recharts.Tooltip,{contentStyle:L}),d&&jsxRuntime.jsx(recharts.Legend,{}),jsxRuntime.jsx(recharts.Pie,{data:C,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(p,300)/3,isAnimationActive:h,label:({name:P,percent:u})=>`${P}: ${((u??0)*100).toFixed(0)}%`,labelLine:false,children:C.map((P,u)=>jsxRuntime.jsx(recharts.Cell,{fill:l[u%l.length]},`cell-${u}`))})]});case "scatter":return jsxRuntime.jsxs(recharts.ScatterChart,{...E,children:[f&&jsxRuntime.jsx(recharts.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsxRuntime.jsx(recharts.XAxis,{dataKey:"x",type:"number",...I,tickLine:false,name:s?.label,padding:{left:10,right:10}}),jsxRuntime.jsx(recharts.YAxis,{...I,tickLine:false,name:o?.label,width:40}),x&&jsxRuntime.jsx(recharts.Tooltip,{contentStyle:L}),d&&jsxRuntime.jsx(recharts.Legend,{}),n.map((P,u)=>jsxRuntime.jsx(recharts.Scatter,{name:P.name,data:P.data.map(c=>({x:c.x,y:c.y})),fill:P.color||l[u%l.length],isAnimationActive:h},P.name))]});default:return null}})()||jsxRuntime.jsx(jsxRuntime.Fragment,{})})})}var cs={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 ps(e,a){if(e==null)return jsxRuntime.jsx("span",{className:"text-gray-400",children:"-"});switch(a.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 t=String(e).toLowerCase().replace(/\s+/g,"_"),n=cs[t]||"bg-gray-100 text-gray-700";return jsxRuntime.jsx("span",{className:i("inline-block px-2 py-0.5 rounded-full text-xs font-medium",n),children:String(e)})}case "link":return jsxRuntime.jsx("a",{href:String(e),target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:String(e)});case "boolean":return e?jsxRuntime.jsx(lucideReact.Check,{size:18,className:"text-green-500"}):jsxRuntime.jsx(lucideReact.X,{size:18,className:"text-gray-400"});case "progress":{let t=typeof e=="number"?e:parseFloat(String(e));return jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:jsxRuntime.jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${Math.min(100,Math.max(0,t))}%`}})}),jsxRuntime.jsxs("span",{className:"text-xs text-gray-500",children:[t.toFixed(0),"%"]})]})}default:return String(e)}}function Ta(e,a,r){let t=e[r],n=a[r];return t==null?1:n==null?-1:typeof t=="number"&&typeof n=="number"?n-t:String(n).localeCompare(String(t))}function ft({data:e,config:a}){let{columns:r,rows:t}=e,n=a?.sortable!==false,s=a?.paginated||false,o=a?.pageSize||10,[l,p]=react.useState("asc"),[d,f]=react.useState(r[0]?.key||""),[x,h]=react.useState(0),v=E=>{p(d===E&&l==="asc"?"desc":"asc"),f(E);},g=react.useMemo(()=>{let E=[...t];return n&&d&&E.sort((I,L)=>l==="desc"?Ta(I,L,d):-Ta(I,L,d)),s&&(E=E.slice(x*o,(x+1)*o)),E},[t,l,d,x,o,n,s]),C=Math.ceil(t.length/o);return jsxRuntime.jsxs("div",{className:"w-full overflow-x-auto",children:[jsxRuntime.jsxs("table",{className:"min-w-full text-sm",children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsx("tr",{children:r.map(E=>jsxRuntime.jsx("th",{className:i("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",n&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:E.width,textAlign:E.align||"left"},onClick:()=>n&&v(E.key),children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.label,n&&d===E.key&&(l==="asc"?jsxRuntime.jsx(lucideReact.ChevronUp,{size:14}):jsxRuntime.jsx(lucideReact.ChevronDown,{size:14}))]})},E.key))})}),jsxRuntime.jsxs("tbody",{children:[g.map((E,I)=>jsxRuntime.jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:r.map(L=>jsxRuntime.jsx("td",{className:"px-3 py-2 whitespace-nowrap max-w-[300px] overflow-hidden text-ellipsis",style:{textAlign:L.align||"left"},children:ps(E[L.key],L)},L.key))},I)),g.length===0&&jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:r.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),s&&t.length>o&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 text-sm",children:[jsxRuntime.jsxs("span",{className:"text-gray-500",children:[x*o+1,"-",Math.min((x+1)*o,t.length)," of ",t.length]}),jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx("button",{onClick:()=>h(Math.max(0,x-1)),disabled:x===0,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Prev"}),jsxRuntime.jsx("button",{onClick:()=>h(Math.min(C-1,x+1)),disabled:x>=C-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function bt({data:e,config:a,onAction:r}){let{subtitle:t,imageUrl:n,sections:s,actions:o}=e,l=a?.collapsible||false,p=a?.initiallyCollapsed||false,[d,f]=react.useState(!p),x=g=>{g.startsWith("http://")||g.startsWith("https://")||g.startsWith("/")?window.open(g,"_blank","noopener,noreferrer"):r?r({type:"card_action",action:g}):window.dispatchEvent(new CustomEvent("visualization-action",{detail:{action:g}}));},h=(g,C)=>jsxRuntime.jsxs("div",{className:i(C<s.length-1&&"mb-4"),children:[g.title&&jsxRuntime.jsx("h4",{className:"font-semibold text-sm mb-2",children:g.title}),g.items&&g.items.length>0&&jsxRuntime.jsx("div",{className:"space-y-1",children:g.items.map((E,I)=>jsxRuntime.jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsxRuntime.jsx("span",{className:"text-sm text-gray-500 shrink-0",children:E.label}),jsxRuntime.jsx("span",{className:"text-sm font-medium text-right",children:E.value})]},I))}),g.content&&jsxRuntime.jsx(re,{children:g.content})]},C),v=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("img",{src:n,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),t&&jsxRuntime.jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:t}),s.map((g,C)=>jsxRuntime.jsxs("div",{children:[h(g,C),C<s.length-1&&jsxRuntime.jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},C))]});return jsxRuntime.jsxs("div",{className:"w-full",children:[l&&jsxRuntime.jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>f(!d),children:[jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:d?"Click to collapse":"Click to expand"}),jsxRuntime.jsx("button",{className:"p-1",children:d?jsxRuntime.jsx(lucideReact.ChevronUp,{size:18}):jsxRuntime.jsx(lucideReact.ChevronDown,{size:18})})]}),(!l||d)&&v,o&&o.length>0&&jsxRuntime.jsx("div",{className:"flex gap-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:o.map((g,C)=>jsxRuntime.jsxs("button",{onClick:()=>x(g.action),className:i("px-3 py-1.5 text-sm rounded-lg transition-colors",g.variant==="primary"?"bg-blue-500 text-white hover:bg-blue-600":g.variant==="text"?"text-blue-500 hover:bg-blue-50":"border border-gray-300 hover:bg-gray-50"),children:[g.label,g.action.startsWith("http")&&jsxRuntime.jsx(lucideReact.ExternalLink,{size:14,className:"inline ml-1"})]},C))})]})}var Ns=["#3B82F6","#10B981","#F59E0B","#8B5CF6"];function ks({metric:e,color:a,animate:r}){let t=e.trend==="up"?jsxRuntime.jsx(lucideReact.ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsxRuntime.jsx(lucideReact.ChevronDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsxRuntime.jsx(lucideReact.Circle,{size:14,className:"text-gray-400"}):null,n=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",s=e.sparkline?.map((o,l)=>({value:o,idx:l}));return jsxRuntime.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:[s&&s.length>0&&jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 opacity-30",children:jsxRuntime.jsx(recharts.ResponsiveContainer,{width:"100%",height:"100%",children:jsxRuntime.jsx(recharts.AreaChart,{data:s,margin:{top:0,right:0,left:0,bottom:0},children:jsxRuntime.jsx(recharts.Area,{type:"monotone",dataKey:"value",stroke:e.color||a,fill:e.color||a,strokeWidth:1,isAnimationActive:r})})})}),jsxRuntime.jsxs("div",{className:"relative z-10",children:[jsxRuntime.jsx("span",{className:"text-xs text-gray-500 font-medium uppercase tracking-wider",children:e.label}),jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1 mt-1",children:[jsxRuntime.jsx("span",{className:"text-2xl font-bold",children:e.value}),e.unit&&jsxRuntime.jsx("span",{className:"text-sm text-gray-500",children:e.unit})]}),(e.trend||e.change)&&jsxRuntime.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[t,e.change&&jsxRuntime.jsx("span",{className:i("text-sm font-medium",n),children:e.change}),e.changeLabel&&jsxRuntime.jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function yt({data:e,config:a,isStreaming:r=false}){let{metrics:t,layout:n="row"}=e,s=a?.colors||Ns,o=a?.animate!==false&&!r,l=n==="grid";return jsxRuntime.jsx("div",{className:i("w-full",l?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:t.map((p,d)=>jsxRuntime.jsx("div",{className:i(!l&&"flex-1 min-w-[200px]"),children:jsxRuntime.jsx(ks,{metric:p,color:p.color||s[d%s.length],animate:o})},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 ht({data:e}){let{code:a,language:r,lineNumbers:t=true,highlightLines:n=[],startLine:s=1}=e,[o,l]=react.useState(false),p=Rs[r.toLowerCase()]||r.toLowerCase(),d=async()=>{try{await navigator.clipboard.writeText(a),l(!0);}catch{}};return react.useEffect(()=>{if(o){let x=setTimeout(()=>l(false),2e3);return ()=>clearTimeout(x)}},[o]),jsxRuntime.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(lucideReact.FileText,{size:16,className:"text-gray-400"}),jsxRuntime.jsx("span",{className:"text-xs font-mono text-gray-400 lowercase",children:p})]}),jsxRuntime.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:o?"Copied!":"Copy code",children:o?jsxRuntime.jsx(lucideReact.Check,{size:14,className:"text-green-400"}):jsxRuntime.jsx(lucideReact.Copy,{size:14})})]}),jsxRuntime.jsx(reactSyntaxHighlighter.Prism,{language:p,style:prism.oneDark,showLineNumbers:t,startingLineNumber:s,wrapLines:true,lineProps:x=>{let h={};return n.includes(x)&&(h.backgroundColor="rgba(59, 130, 246, 0.1)",h.display="block",h.borderLeft="3px solid #3B82F6",h.paddingLeft="8px",h.marginLeft="-11px"),{style:h}},customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6",background:"#1e1e1e"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:a.trim()})]})}function vt({data:e,config:a,isStreaming:r=false,onAction:t}){let{fields:n,submitAction:s}=e,o=a?.submitButtonText||"Submit",l=a?.cancelButtonText||"Cancel",[p,d]=react.useState(()=>{let u={};return n.forEach(c=>{c.defaultValue!==void 0?u[c.name]=c.defaultValue:c.type==="multiselect"?u[c.name]=[]:c.type==="checkbox"?u[c.name]=false:u[c.name]="";}),u}),[f,x]=react.useState({}),[h,v]=react.useState(false),g=(u,c)=>{d(k=>({...k,[u]:c})),f[u]&&x(k=>{let O={...k};return delete O[u],O});},C=()=>{let u={};return n.forEach(c=>{let k=p[c.name];if(c.required&&(k==null||k===""||Array.isArray(k)&&k.length===0)){u[c.name]=`${c.label} is required`;return}if(!(!k&&!c.required)){if(c.validation){let{min:O,max:w,pattern:q,message:Y}=c.validation;O!==void 0&&typeof k=="number"&&k<O&&(u[c.name]=Y||`Minimum value is ${O}`),w!==void 0&&typeof k=="number"&&k>w&&(u[c.name]=Y||`Maximum value is ${w}`),q&&typeof k=="string"&&!new RegExp(q).test(k)&&(u[c.name]=Y||"Invalid format");}c.type==="email"&&typeof k=="string"&&k&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k)&&(u[c.name]="Invalid email address");}}),x(u),Object.keys(u).length===0},E=u=>{u.preventDefault(),C()&&(t?t({type:"form_submit",action:s||"",data:p}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:s,data:p}})),v(true));},I=()=>{t?t({type:"form_cancel",action:s||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:s}}));};if(h)return jsxRuntime.jsxs("div",{className:"text-center py-8",children:[jsxRuntime.jsx("p",{className:"text-lg font-semibold text-green-500 mb-1",children:"Form Submitted"}),jsxRuntime.jsx("p",{className:"text-sm text-gray-500",children:"Your response has been recorded."})]});let L="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",ee="border-red-500 focus:ring-red-500/20 focus:border-red-500",P=u=>{let c=p[u.name],O=!!f[u.name];switch(u.type){case "text":case "email":case "number":return jsxRuntime.jsx("input",{type:u.type,placeholder:u.placeholder,required:u.required,value:String(c||""),onChange:w=>g(u.name,u.type==="number"?parseFloat(w.target.value)||"":w.target.value),className:i(L,O&&ee),min:u.validation?.min,max:u.validation?.max});case "textarea":return jsxRuntime.jsx("textarea",{placeholder:u.placeholder,required:u.required,value:String(c||""),onChange:w=>g(u.name,w.target.value),className:i(L,"min-h-[100px] resize-y",O&&ee),rows:4});case "select":return jsxRuntime.jsxs("select",{value:String(c||""),onChange:w=>g(u.name,w.target.value),className:i(L,O&&ee),children:[jsxRuntime.jsx("option",{value:"",disabled:true,children:u.placeholder||"Select an option"}),u.options?.map(w=>jsxRuntime.jsx("option",{value:w.value,children:w.label},w.value))]});case "multiselect":return jsxRuntime.jsx("select",{multiple:true,value:c||[],onChange:w=>g(u.name,Array.from(w.target.selectedOptions,q=>q.value)),className:i(L,"min-h-[80px]",O&&ee),children:u.options?.map(w=>jsxRuntime.jsx("option",{value:w.value,children:w.label},w.value))});case "checkbox":return jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:!!c,onChange:w=>g(u.name,w.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsxRuntime.jsx("span",{className:"text-sm",children:u.label})]});case "radio":return jsxRuntime.jsx("div",{className:"space-y-1",children:u.options?.map(w=>jsxRuntime.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsxRuntime.jsx("input",{type:"radio",name:u.name,value:w.value,checked:c===w.value,onChange:q=>g(u.name,q.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),w.label]},w.value))});case "date":return jsxRuntime.jsx("input",{type:"date",value:String(c||""),onChange:w=>g(u.name,w.target.value),className:i(L,O&&ee)});case "datetime":return jsxRuntime.jsx("input",{type:"datetime-local",value:String(c||""),onChange:w=>g(u.name,w.target.value),className:i(L,O&&ee)});default:return null}};return jsxRuntime.jsxs("form",{onSubmit:E,className:"space-y-4",children:[n.map(u=>jsxRuntime.jsxs("div",{children:[u.type!=="checkbox"&&jsxRuntime.jsxs("label",{className:"block text-sm font-medium mb-1",children:[u.label,u.required&&jsxRuntime.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),P(u),f[u.name]&&jsxRuntime.jsx("p",{className:"text-xs text-red-500 mt-1",children:f[u.name]})]},u.name)),jsxRuntime.jsxs("div",{className:"flex gap-2 pt-2",children:[jsxRuntime.jsx("button",{type:"submit",disabled:r,className:"px-4 py-2 text-sm rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-50 transition-colors",children:o}),jsxRuntime.jsx("button",{type:"button",onClick:I,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:l})]})]})}var wt=new Map;function Ce(e,a){wt.set(e,a);}function Nt(e){return wt.get(e)}function Ra(){return Array.from(wt.keys())}Ce("chart",{component:gt});Ce("table",{component:ft});Ce("card",{component:bt});Ce("kpi",{component:yt});Ce("code_preview",{component:ht});Ce("form",{component:vt});function Ma(e){for(let[a,r]of Object.entries(e)){let t=wt.get(a);t&&(t.schema=r);}}var Ms=zod.z.object({name:zod.z.string(),data:zod.z.array(zod.z.union([zod.z.object({x:zod.z.union([zod.z.string(),zod.z.number()]),y:zod.z.number()}),zod.z.object({name:zod.z.string(),value:zod.z.number()})])),color:zod.z.string().optional()}),Aa=zod.z.object({label:zod.z.string().optional(),type:zod.z.enum(["category","number","time"]).optional(),min:zod.z.number().optional(),max:zod.z.number().optional()}),Ut=zod.z.object({chartType:zod.z.enum(["line","bar","pie","area","scatter","composed"]),series:zod.z.array(Ms),xAxis:Aa.optional(),yAxis:Aa.optional()}),As=zod.z.object({key:zod.z.string(),label:zod.z.string(),type:zod.z.enum(["string","number","currency","date","badge","link","boolean","progress"]).optional(),align:zod.z.enum(["left","center","right"]).optional(),width:zod.z.string().optional()}),Ht=zod.z.object({columns:zod.z.array(As),rows:zod.z.array(zod.z.record(zod.z.string(),zod.z.unknown()))}),_s=zod.z.object({title:zod.z.string().optional(),items:zod.z.array(zod.z.object({label:zod.z.string(),value:zod.z.union([zod.z.string(),zod.z.number()])})).optional(),content:zod.z.string().optional()}),Is=zod.z.object({label:zod.z.string(),action:zod.z.string(),variant:zod.z.enum(["primary","secondary","text"]).optional()}),jt=zod.z.object({subtitle:zod.z.string().optional(),imageUrl:zod.z.string().optional(),sections:zod.z.array(_s),actions:zod.z.array(Is).optional()}),Ls=zod.z.object({label:zod.z.string(),value:zod.z.union([zod.z.string(),zod.z.number()]),unit:zod.z.string().optional(),trend:zod.z.enum(["up","down","neutral"]).optional(),change:zod.z.string().optional(),changeLabel:zod.z.string().optional(),sparkline:zod.z.array(zod.z.number()).optional(),color:zod.z.string().optional()}),Kt=zod.z.object({metrics:zod.z.array(Ls),layout:zod.z.enum(["row","grid"]).optional()}),qt=zod.z.object({code:zod.z.string(),language:zod.z.string(),lineNumbers:zod.z.boolean().optional(),highlightLines:zod.z.array(zod.z.number()).optional(),startLine:zod.z.number().optional()}),Vs=zod.z.object({name:zod.z.string(),type:zod.z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:zod.z.string(),required:zod.z.boolean().optional(),placeholder:zod.z.string().optional(),options:zod.z.array(zod.z.object({value:zod.z.string(),label:zod.z.string()})).optional(),defaultValue:zod.z.unknown().optional(),validation:zod.z.object({min:zod.z.number().optional(),max:zod.z.number().optional(),pattern:zod.z.string().optional(),message:zod.z.string().optional()}).optional()}),Gt=zod.z.object({fields:zod.z.array(Vs),submitAction:zod.z.string().optional()});Ma({chart:Ut,table:Ht,card:jt,kpi:Kt,code_preview:qt,form:Gt});function kt({data:e,isStreaming:a=false,onAction:r}){let{type:t,title:n,description:s,data:o,config:l}=e;return jsxRuntime.jsxs("div",{className:"my-3 overflow-hidden",children:[(n||s)&&jsxRuntime.jsxs("div",{className:"mb-2",children:[n&&jsxRuntime.jsx("p",{className:"text-sm font-semibold",children:n}),s&&jsxRuntime.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s})]}),jsxRuntime.jsx("div",{children:(()=>{let d=Nt(t);if(!d)return jsxRuntime.jsxs("div",{className:"flex items-center gap-2 p-4 text-yellow-500",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{size:20}),jsxRuntime.jsxs("span",{className:"text-sm",children:["Unknown visualization type: ",t]})]});if(d.schema){let x=d.schema.safeParse(o);if(!x.success){let h=x.error.issues.slice(0,3);return jsxRuntime.jsxs("div",{className:"p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/30",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 mb-2",children:[jsxRuntime.jsx(lucideReact.AlertCircle,{size:18}),jsxRuntime.jsxs("span",{className:"text-sm font-medium",children:["Invalid ",t," visualization data"]})]}),jsxRuntime.jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[h.map((v,g)=>jsxRuntime.jsxs("li",{children:[v.path.join("."),": ",v.message]},g)),x.error.issues.length>3&&jsxRuntime.jsxs("li",{children:["...and ",x.error.issues.length-3," more"]})]})]})}}let f=d.component;return jsxRuntime.jsx(f,{data:o,config:l,isStreaming:a,onAction:r})})()})]})}var La=/\[VIZ:([a-f0-9-]+)\]/gi;function Ws(e){let a=[],r=0,t;for(La.lastIndex=0;(t=La.exec(e))!==null;){if(t.index>r){let n=e.slice(r,t.index);n.trim()&&a.push({type:"text",content:n});}a.push({type:"viz",id:t[1]}),r=t.index+t[0].length;}if(r<e.length){let n=e.slice(r);n.trim()&&a.push({type:"text",content:n});}return a}var Va=react.forwardRef(({message:e,viewerRole:a="user",className:r,showAvatar:t=true,showTimestamp:n=true,renderMarkdown:s=true,reasoning:o,executionPlan:l,executionTimeline:p,suggestedActions:d,onSuggestedAction:f,reasoningExpanded:x,onReasoningExpandedChange:h,citations:v,visualizations:g,baselineFontSize:C,pendingClarification:E,onClarificationSubmit:I},L)=>{let P=react.useContext(chunkOCKHJ4WO_js.a)?.onVisualizationAction,u=(e.participant?.role||"").toLowerCase(),c=(a||"").toLowerCase(),k=u===c,O=u==="assistant",w=e.isStreaming,q=o?.filter(y=>y.type==="thinking"||y.type==="tool"||y.type==="observation"||y.type==="planning"||y.type==="subtask"||y.type==="wave_start"||y.type==="wave_complete"||y.type==="parallel_subtask_start"||y.type==="parallel_subtask_complete"||y.type==="multi_agent_planning"||y.type==="subagent_start"||y.type==="subagent_complete"||y.type==="subagent_failed"||y.type==="synthesis"||y.type==="claude_thinking"||y.type==="subagent"||y.type==="file_operation"||y.type==="terminal"||y.type==="search_results"||y.type==="web_operation"||y.claudeToolData!=null),Y=q&&q.length>0,fe=!w&&(l||p&&p.length>0),he=Y||fe,Ae=w&&!e.textContent&&!he,Se=e.attachments,Be=Se&&Se.length>0,ce=react.useMemo(()=>{if(!g||g.length===0)return null;let y=new Map;return g.forEach(z=>y.set(z.id,z)),y},[g]),_e=ce&&ce.size>0,N=react.useMemo(()=>!_e||!e.textContent?null:Ws(e.textContent),[_e,e.textContent]),b=()=>e.textContent?N&&N.length>0&&ce?jsxRuntime.jsx(jsxRuntime.Fragment,{children:N.map((y,z)=>{if(y.type==="text")return w?jsxRuntime.jsx(je,{content:y.content,isStreaming:true,baselineFontSize:C},z):jsxRuntime.jsx(re,{baselineFontSize:C,className:k?"prose-invert":"",children:y.content},z);let F=ce.get(y.id);return F?jsxRuntime.jsx(kt,{data:F,isStreaming:w,onAction:P},`viz-${y.id}`):null})}):w&&s?jsxRuntime.jsx(je,{content:e.textContent,isStreaming:true,baselineFontSize:C,className:k?"prose-invert":""}):s?jsxRuntime.jsx(re,{baselineFontSize:C,className:k?"prose-invert":"",children:e.textContent}):jsxRuntime.jsx("p",{className:"whitespace-pre-wrap",children:e.textContent}):null,D=react.useRef(w);w&&(D.current=true);let T=!w&&!D.current;return jsxRuntime.jsx(chunk3KB4JYSQ_js.c,{ref:L,message:e,viewerRole:a,className:i("w-full",T&&"animate-fade-in",r),children:jsxRuntime.jsxs("div",{className:i("flex flex-col gap-1 w-full"),"data-is-viewer":k,children:[Ae&&jsxRuntime.jsxs("div",{className:i("flex items-start gap-2 w-full"),children:[t&&!k&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx(Ie,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxRuntime.jsx("div",{className:"px-4 py-3",children:jsxRuntime.jsx(We,{size:"small"})})]}),he&&O&&jsxRuntime.jsx("div",{className:"w-full max-w-[80%]",children:jsxRuntime.jsx(Ft,{isStreaming:w,chunks:q,plan:l,executionTimeline:p,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,expanded:x,onExpandedChange:h})}),e.textContent&&jsxRuntime.jsxs("div",{className:i("flex items-start gap-2 w-full",k?"flex-row-reverse":"flex-row"),children:[t&&!k&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx(Ie,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxRuntime.jsxs("div",{className:i("max-w-[85%]","flex flex-col"),"data-message-role":k?"viewer":"other",children:[jsxRuntime.jsxs("div",{className:i("rounded-2xl",k||t?"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:[jsxRuntime.jsx(chunk3KB4JYSQ_js.d,{children:b()}),v&&v.length>0&&jsxRuntime.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsxRuntime.jsx(Rt,{sources:v})})]}),Be&&jsxRuntime.jsx("div",{className:"mt-2",children:jsxRuntime.jsx(_t,{attachments:Se})}),n&&!w&&e.createdAt&&jsxRuntime.jsx(Us,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:k})]})]}),!e.textContent&&t&&!k&&he&&!Ae&&jsxRuntime.jsx("div",{className:"flex items-start gap-2 w-full",children:jsxRuntime.jsx("div",{className:"flex-shrink-0",children:jsxRuntime.jsx(Ie,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),E&&!w&&I&&jsxRuntime.jsx("div",{className:"w-full max-w-[80%]",children:jsxRuntime.jsx(Mt,{clarification:E,onSubmit:I})}),d&&d.length>0&&!w&&jsxRuntime.jsx("div",{className:"w-full max-w-[80%]",children:jsxRuntime.jsx(pt,{actions:d,onSelect:f})})]})})});Va.displayName="Message";function Us({createdAt:e,isViewer:a}){let r=t=>{try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}};return jsxRuntime.jsx("span",{className:i("text-xs mt-1 block text-[var(--chat-text-subtle)]",a&&"text-right"),children:r(e)})}var Fa=[markdown.BOLD_STAR,markdown.ITALIC_UNDERSCORE,markdown.QUOTE,markdown.ORDERED_LIST,markdown.UNORDERED_LIST],Ni={ltr:"ltr",rtl:"rtl",placeholder:"editor-placeholder",paragraph:"editor-paragraph",quote:"editor-quote",text:{}},ki=100*1024*1024,Ci=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],Si=["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"],zi=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],Pi=[...Ci,...Si,...zi];function $a(e){if(e===0)return "0 Bytes";let a=1024,r=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(a));return parseFloat((e/Math.pow(a,t)).toFixed(2))+" "+r[t]}function Ei(e,a,r){return e.size>r?`File size (${$a(e.size)}) exceeds max (${$a(r)})`:a.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function Di({attachments:e,onRemove:a,disabled:r}){return e.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 px-3 pt-3 pb-0",children:e.map(t=>{let n=t.file.type.startsWith("image/"),s=t.status==="error",o=t.status==="uploading";return jsxRuntime.jsxs("div",{className:i("relative flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-xs max-w-[200px]",s?"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:[o?jsxRuntime.jsx(lucideReact.Loader2,{size:14,className:"flex-shrink-0 animate-spin"}):s?jsxRuntime.jsx(lucideReact.AlertCircle,{size:14,className:"flex-shrink-0"}):n&&t.previewUrl?jsxRuntime.jsx("img",{src:t.previewUrl,alt:t.file.name,className:"w-5 h-5 rounded object-cover"}):n?jsxRuntime.jsx(lucideReact.Image,{size:14,className:"flex-shrink-0"}):jsxRuntime.jsx(lucideReact.FileText,{size:14,className:"flex-shrink-0"}),jsxRuntime.jsx("span",{className:"truncate",title:s?t.error:t.file.name,children:s?t.error:t.file.name}),!r&&jsxRuntime.jsx("button",{type:"button",onClick:()=>a(t.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:jsxRuntime.jsx(lucideReact.X,{size:12})})]},t.id)})})}function Ti({onSubmit:e,disabled:a}){let[r]=LexicalComposerContext.useLexicalComposerContext();return react.useEffect(()=>r.registerCommand(lexical.KEY_ENTER_COMMAND,t=>!t||t.shiftKey?false:(t.preventDefault(),a||e(),true),lexical.COMMAND_PRIORITY_HIGH),[r,e,a]),null}function Ri({clearRef:e}){let[a]=LexicalComposerContext.useLexicalComposerContext();return react.useEffect(()=>{e.current=()=>{a.update(()=>{let r=lexical.$getRoot();r.clear(),r.append(lexical.$createParagraphNode());});};},[a,e]),null}var Wa=react.forwardRef(({onSubmit:e,onAttach:a,onUploadFile:r,onRemoveUploadedAttachment:t,disabled:n=false,supportsAttachments:s=true,allowedFileTypes:o=Pi,maxFileSize:l=ki,placeholder:p="Type a message...",className:d,isSubmitting:f=false},x)=>{let[h,v]=react.useState(""),[g,C]=react.useState([]),[E,I]=react.useState(false),L=react.useRef(null),ee=react.useRef(null),P=react.useRef(0),u=n||f,c=g.some(b=>b.status==="uploading"),k=g.filter(b=>b.status==="uploaded"&&b.attachmentId).map(b=>b.attachmentId),O=k.length>0||g.some(b=>b.status==="pending"),w=h.trim().length>0||O,q=react.useCallback(b=>{b.read(()=>{let T=markdown.$convertToMarkdownString(Fa).replace(/\n\s*\n\s*\n+/g,`
|
|
19
|
+
|
|
20
|
+
`).replace(/(?<!\n)\n(?!\n)/g,`
|
|
21
|
+
`);v(T);});},[]),Y=react.useCallback(async b=>{let D=b.map(T=>{let y=Ei(T,o,l),z={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:T,status:y?"error":r?"uploading":"pending",error:y||void 0};return !y&&T.type.startsWith("image/")&&(z.previewUrl=URL.createObjectURL(T)),z});if(C(T=>[...T,...D]),a?.(b),r){for(let T of D)if(T.status==="uploading")try{let y=await r(T.file);C(z=>z.map(F=>F.id===T.id?{...F,status:"uploaded",attachmentId:y}:F));}catch(y){C(z=>z.map(F=>F.id===T.id?{...F,status:"error",error:y instanceof Error?y.message:"Upload failed"}:F));}}},[o,l,r,a]),fe=react.useCallback(async()=>{if(!w||u||c)return;let b=h,D=g.filter(y=>y.status!=="error").map(y=>y.file),T=g;ee.current?.(),v(""),C([]);try{r&&k.length>0?await e(b,void 0,k):await e(b,D.length>0?D:void 0);}catch{v(b),C(T);}},[h,g,w,u,c,e,r,k]),he=react.useCallback(b=>{let D=b.target.files;!D||D.length===0||(Y(Array.from(D)),b.target.value="");},[Y]),Ae=react.useCallback(b=>{C(D=>{let T=D.find(y=>y.id===b);return T?.previewUrl&&URL.revokeObjectURL(T.previewUrl),T?.attachmentId&&t&&t(T.attachmentId),D.filter(y=>y.id!==b)});},[t]),Se=react.useCallback(b=>{b.preventDefault(),b.stopPropagation(),!(!s||f)&&(P.current++,b.dataTransfer.types.includes("Files")&&I(true));},[s,f]),Be=react.useCallback(b=>{b.preventDefault(),b.stopPropagation(),P.current--,P.current===0&&I(false);},[]),ce=react.useCallback(b=>{b.preventDefault(),b.stopPropagation();},[]),_e=react.useCallback(b=>{if(b.preventDefault(),b.stopPropagation(),P.current=0,I(false),!s||f)return;let D=Array.from(b.dataTransfer.files);D.length>0&&Y(D);},[s,f,Y]);react.useEffect(()=>()=>{g.forEach(b=>{b.previewUrl&&URL.revokeObjectURL(b.previewUrl);});},[]);let N={namespace:"ChatComposer",theme:Ni,onError(b){console.error("[ChatComposer]",b);},editorState(){return markdown.$convertFromMarkdownString("",Fa)},nodes:[list.ListItemNode,list.ListNode,link.AutoLinkNode,richText.QuoteNode],editable:!f};return jsxRuntime.jsx("div",{ref:x,className:i("flex-shrink-0 px-3 pt-2 pb-3","border-t border-gray-200 dark:border-zinc-700","bg-white/95 dark:bg-zinc-900/95 backdrop-blur-sm",d),onDragEnter:Se,onDragLeave:Be,onDragOver:ce,onDrop:_e,children:jsxRuntime.jsxs("div",{className:i("mx-auto max-w-[900px]","rounded-xl","bg-white dark:bg-zinc-800","border border-gray-200 dark:border-zinc-700","shadow-sm","transition-all duration-200","focus-within:shadow-md focus-within:border-gray-300 dark:focus-within:border-zinc-600",E&&"ring-2 ring-blue-400 border-blue-400"),children:[E&&jsxRuntime.jsx("div",{className:"px-3 pt-3 pb-0",children:jsxRuntime.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"})}),jsxRuntime.jsx(Di,{attachments:g,onRemove:Ae,disabled:f}),jsxRuntime.jsxs("div",{className:i("flex items-center gap-2 p-3",g.length>0&&"pt-1.5"),children:[s&&jsxRuntime.jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:f,className:i("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:jsxRuntime.jsx(lucideReact.Paperclip,{size:16})}),jsxRuntime.jsx("div",{className:"flex-1 min-w-0",children:jsxRuntime.jsx(LexicalComposer.LexicalComposer,{initialConfig:N,children:jsxRuntime.jsxs("div",{className:"relative px-1 text-sm",children:[jsxRuntime.jsx(LexicalRichTextPlugin.RichTextPlugin,{contentEditable:jsxRuntime.jsx(LexicalContentEditable.ContentEditable,{className:i("outline-none resize-none","min-h-[24px] max-h-[200px] overflow-y-auto","text-gray-900 dark:text-zinc-100","[&_.editor-paragraph]:my-0","[&_.editor-quote]:ml-0 [&_.editor-quote]:pl-3 [&_.editor-quote]:border-l-4 [&_.editor-quote]:border-gray-300","[&_ul]:pl-4 [&_ol]:pl-4")}),placeholder:jsxRuntime.jsx("span",{className:"absolute top-0 left-1 text-gray-400 dark:text-zinc-500 pointer-events-none select-none",children:p}),ErrorBoundary:LexicalErrorBoundary.LexicalErrorBoundary}),jsxRuntime.jsx(LexicalOnChangePlugin.OnChangePlugin,{onChange:q}),jsxRuntime.jsx(LexicalListPlugin.ListPlugin,{}),jsxRuntime.jsx(LexicalHistoryPlugin.HistoryPlugin,{}),jsxRuntime.jsx(LexicalAutoFocusPlugin.AutoFocusPlugin,{defaultSelection:"rootStart"}),jsxRuntime.jsx(Ti,{onSubmit:fe,disabled:u||c}),jsxRuntime.jsx(Ri,{clearRef:ee})]})})}),jsxRuntime.jsx("button",{type:"button",onClick:fe,disabled:!w||u||c,className:i("flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-blue-500 text-white","shadow-sm","hover:bg-blue-600 hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-600 disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),children:f||c?jsxRuntime.jsx(lucideReact.Loader2,{size:16,className:"animate-spin"}):jsxRuntime.jsx(lucideReact.ArrowUp,{size:16})})]}),s&&jsxRuntime.jsx("input",{ref:L,type:"file",multiple:true,accept:o.join(","),onChange:he,className:"hidden"})]})})});Wa.displayName="MessageComposer";var Ua=react.forwardRef(({children:e,autoScroll:a=true,className:r},t)=>jsxRuntime.jsx(chunk3KB4JYSQ_js.f,{ref:t,autoScroll:a,className:i("flex-1 overflow-y-auto","flex flex-col gap-4 p-4","chat-scrollbar",r),children:e}));Ua.displayName="MessageList";function _i({label:e,className:a}){return jsxRuntime.jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${a??""}`,role:"separator",children:[jsxRuntime.jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"}),jsxRuntime.jsx("span",{className:"text-xs font-medium text-[var(--chat-text-subtle)] whitespace-nowrap",children:e}),jsxRuntime.jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"})]})}var ja=react.forwardRef(({className:e},a)=>jsxRuntime.jsx(chunk3KB4JYSQ_js.r,{ref:a,className:i("inline-flex items-center gap-1","px-4 py-3",e),children:jsxRuntime.jsx(We,{size:"small"})}));ja.displayName="TypingIndicator";function Bi({title:e,subtitle:a,logo:r,actions:t,showClose:n,onClose:s,loading:o,className:l,style:p}){let[d,f]=react.useState(false),x=react.useRef(null),h=react.useRef(null);return react.useEffect(()=>{let v=g=>{let C=g.composedPath();x.current&&!C.includes(x.current)&&h.current&&!C.includes(h.current)&&f(false);};if(d)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]),jsxRuntime.jsxs("header",{className:i("flex items-center justify-between gap-3","px-4 py-3","border-b border-[var(--chat-border)]","bg-[var(--chat-header-bg,#ffffff)]",l),style:p,children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[r&&jsxRuntime.jsx("div",{className:"flex-shrink-0",children:typeof r=="string"?jsxRuntime.jsx("img",{src:r,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):r}),jsxRuntime.jsxs("div",{className:"flex flex-col min-w-0",children:[o?jsxRuntime.jsx("div",{className:"h-5 w-24 bg-gray-200 rounded animate-pulse"}):jsxRuntime.jsx("h1",{className:"text-lg font-semibold text-[var(--chat-text)] truncate",children:e}),a&&jsxRuntime.jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:a})]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t&&t.length>0&&jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx("button",{ref:h,onClick:()=>f(!d),className:i("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:jsxRuntime.jsx(lucideReact.MoreVertical,{size:18})}),d&&jsxRuntime.jsx("div",{ref:x,className:i("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:t.map(v=>jsxRuntime.jsxs("button",{onClick:()=>{v.onClick(),f(false);},disabled:v.disabled,className:i("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:[v.icon&&jsxRuntime.jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:v.icon}),v.label]},v.id))})]}),n&&s&&jsxRuntime.jsx("button",{onClick:s,className:i("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:jsxRuntime.jsx(lucideReact.X,{size:18})})]})]})}var Ga=react.forwardRef(({isEmpty:e,header:a,welcomeScreen:r,messageList:t,composer:n,footer:s,className:o},l)=>jsxRuntime.jsx("div",{ref:l,className:i("relative h-full overflow-hidden flex flex-col min-h-0",o),children:jsxRuntime.jsx(framerMotion.AnimatePresence,{mode:"wait",children:e&&r?jsxRuntime.jsxs(framerMotion.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:[a,r]},"welcome"):jsxRuntime.jsxs(framerMotion.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:[a,jsxRuntime.jsx(framerMotion.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:t}),s,jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},children:n})]},"active")})}));Ga.displayName="ChatLayout";function Gi(e,a=3e3){let[r,t]=react.useState(0),n=react.useRef(null);return react.useEffect(()=>{if(e.length<=1)return;let s=()=>{n.current=setInterval(()=>{t(l=>(l+1)%e.length);},a);},o=()=>{document.visibilityState!=="visible"?n.current&&(clearInterval(n.current),n.current=null):s();};return s(),document.addEventListener("visibilitychange",o),()=>{n.current&&clearInterval(n.current),document.removeEventListener("visibilitychange",o);}},[e,a]),e[r]??""}function Xi({placeholder:e,onSubmit:a,disabled:r,supportsAttachments:t}){let[n,s]=react.useState(""),[o,l]=react.useState([]),p=react.useRef(null),d=react.useRef(null);react.useEffect(()=>{p.current&&(p.current.style.height="auto",p.current.style.height=p.current.scrollHeight+"px");},[n]);let f=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),x());},x=()=>{!n.trim()&&o.length===0||r||(a(n.trim(),o.length>0?o:void 0),s(""),l([]));},h=g=>{g.target.files&&l(C=>[...C,...Array.from(g.target.files)]),g.target.value="";},v=g=>{l(C=>C.filter((E,I)=>I!==g));};return jsxRuntime.jsxs("form",{className:i("w-full relative mx-auto","bg-white dark:bg-zinc-800","rounded-2xl overflow-hidden","shadow-[0_8px_30px_rgba(0,0,0,0.08)]","border border-gray-100 dark:border-zinc-700/50","transition duration-200","focus-within:shadow-[0_8px_30px_rgba(0,0,0,0.12)] focus-within:border-gray-200 dark:focus-within:border-zinc-600"),onSubmit:g=>{g.preventDefault(),x();},children:[o.length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:o.map((g,C)=>jsxRuntime.jsxs("div",{className:i("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:[jsxRuntime.jsx("span",{className:"max-w-[120px] truncate",children:g.name}),jsxRuntime.jsx("button",{type:"button",onClick:()=>v(C),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsxRuntime.jsx(lucideReact.X,{size:12})})]},`${g.name}-${C}`))}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[t&&jsxRuntime.jsx("button",{type:"button",onClick:()=>d.current?.click(),disabled:r,className:i("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"),children:jsxRuntime.jsx(lucideReact.Paperclip,{size:16})}),jsxRuntime.jsx("textarea",{ref:p,value:n,onChange:g=>s(g.target.value),onKeyDown:f,disabled:r,rows:1,placeholder:e,className:i("flex-1 text-sm sm:text-base","border-none bg-transparent","text-gray-900 dark:text-white","focus:outline-none focus:ring-0 resize-none","py-4 sm:py-5",t?"pl-1":"pl-4 sm:pl-6","placeholder:text-gray-400 dark:placeholder:text-zinc-500","disabled:opacity-50 disabled:cursor-not-allowed","max-h-[200px] overflow-y-auto")}),jsxRuntime.jsx("button",{type:"submit",disabled:!n.trim()&&o.length===0||!!r,className:i("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"),children:jsxRuntime.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]}),t&&jsxRuntime.jsx("input",{ref:d,type:"file",multiple:true,onChange:h,className:"hidden"})]})}function Yi({text:e,onClick:a,index:r}){let t=react.useRef(null),n=react.useRef(typeof window<"u"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),[s,o]=react.useState(null),l=react.useCallback(d=>{if(n.current)return;let f=d.currentTarget.getBoundingClientRect();o({x:d.clientX-f.left,y:d.clientY-f.top});},[]),p=react.useCallback(()=>{o(null);},[]);return jsxRuntime.jsx(framerMotion.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2+r*.1,duration:.4},children:jsxRuntime.jsxs("button",{ref:t,type:"button",onClick:a,onMouseMove:l,onMouseLeave:p,className:i("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:[s&&jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 z-0",style:{background:`radial-gradient(120px circle at ${s.x}px ${s.y}px, var(--chat-halo-primary, rgba(16,105,151,0.06)), transparent)`}}),jsxRuntime.jsxs("div",{className:"relative z-10 flex items-start gap-2.5",children:[jsxRuntime.jsx(lucideReact.MessageCircleQuestion,{size:16,strokeWidth:2,className:"mt-0.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),jsxRuntime.jsx("span",{className:"text-sm text-gray-600 dark:text-zinc-300 leading-relaxed flex-1",children:e})]})]})})}var Ya=react.forwardRef(({placeholders:e=[],suggestions:a=[],onSubmit:r,onSuggestionClick:t,welcomeText:n="How can I help you today?",supportsAttachments:s,composerSlot:o,className:l},p)=>{let d=Gi(e),f=react.useCallback(x=>{t?.(x);},[t]);return jsxRuntime.jsxs("div",{ref:p,className:i("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",l),children:[jsxRuntime.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%)"}}),jsxRuntime.jsxs(framerMotion.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:[n&&jsxRuntime.jsx(framerMotion.motion.h2,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"text-2xl font-semibold text-gray-800 dark:text-gray-300 text-center",children:n}),jsxRuntime.jsx("div",{className:i("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:o??jsxRuntime.jsx(Xi,{placeholder:d,onSubmit:(x,h)=>r?.(x,h),supportsAttachments:s})}),a.length>0&&jsxRuntime.jsx("div",{className:i("grid gap-3 w-full max-w-[900px]","grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(250px,1fr))]"),children:a.map((x,h)=>jsxRuntime.jsx(Yi,{text:x,onClick:()=>f(x),index:h},h))})]})]})});Ya.displayName="WelcomeScreen";exports.A=je;exports.B=pt;exports.C=gt;exports.D=ft;exports.E=bt;exports.F=yt;exports.G=ht;exports.H=vt;exports.I=Ce;exports.J=Nt;exports.K=Ra;exports.L=Ut;exports.M=Ht;exports.N=jt;exports.O=Kt;exports.P=qt;exports.Q=Gt;exports.R=kt;exports.S=Va;exports.T=Wa;exports.U=Ua;exports.V=_i;exports.W=ja;exports.X=Bi;exports.Y=Ga;exports.Z=Ya;exports.a=i;exports.b=pa;exports.c=Ie;exports.d=ma;exports.e=We;exports.f=re;exports.g=Rt;exports.h=fa;exports.i=_r;exports.j=Mt;exports.k=_t;exports.l=Qe;exports.m=De;exports.n=en;exports.o=Lt;exports.p=et;exports.q=on;exports.r=we;exports.s=at;exports.t=rt;exports.u=nt;exports.v=ot;exports.w=st;exports.x=it;exports.y=lt;exports.z=Ft;//# sourceMappingURL=chunk-BA3VCHRC.js.map
|
|
22
|
+
//# sourceMappingURL=chunk-BA3VCHRC.js.map
|