@miiflow/assistant-ui 0.5.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{WelcomeScreen-D32Tsu6G.d.ts → WelcomeScreen-XVZqMpVW.d.ts} +27 -8
- package/dist/{avatar-CAmTN1L7.d.ts → avatar-C13xc3tA.d.ts} +1 -1
- package/dist/chunk-EI3GOLHT.js +128 -0
- package/dist/chunk-EI3GOLHT.js.map +1 -0
- package/dist/chunk-O2ILSWHS.js +2 -0
- package/dist/chunk-O2ILSWHS.js.map +1 -0
- package/dist/client/index.d.ts +67 -3
- package/dist/client/index.js +5 -5
- package/dist/client/index.js.map +1 -1
- package/dist/context/index.d.ts +2 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{message-D3D59U_Q.d.ts → message-BrHFdwb2.d.ts} +5 -4
- package/dist/primitives/index.d.ts +3 -3
- package/dist/{streaming-Q8hp5ev4.d.ts → streaming-DURrv9_E.d.ts} +46 -4
- package/dist/styled/index.d.ts +89 -19
- package/dist/styled/index.js +1 -1
- package/dist/styles-no-preflight.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
- package/dist/chunk-VDFIXLNO.js +0 -20
- package/dist/chunk-VDFIXLNO.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
-
import { A as Attachment, M as MessageData, P as ParticipantRole,
|
|
4
|
-
import { h as AvatarProps$1 } from './avatar-
|
|
5
|
-
import { S as StreamingChunk, V as VisualizationChunkData, M as MediaChunkData, C as ClarificationData } from './streaming-
|
|
3
|
+
import { A as Attachment, M as MessageData, P as ParticipantRole, d as SuggestedAction, S as SourceReference } from './message-BrHFdwb2.js';
|
|
4
|
+
import { h as AvatarProps$1 } from './avatar-C13xc3tA.js';
|
|
5
|
+
import { S as StreamingChunk, V as VisualizationChunkData, M as MediaChunkData, A as ArtifactChunkData, C as ClarificationData, T as ToolApprovalData } from './streaming-DURrv9_E.js';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
interface AttachmentPreviewProps {
|
|
@@ -88,6 +88,10 @@ interface MessageProps {
|
|
|
88
88
|
visualizations?: VisualizationChunkData[];
|
|
89
89
|
/** Inline media (images/videos) to render within message content */
|
|
90
90
|
medias?: MediaChunkData[];
|
|
91
|
+
/** Inline downloadable artifacts (PDFs, HTMLs, ...) */
|
|
92
|
+
artifacts?: ArtifactChunkData[];
|
|
93
|
+
/** Callback when a user clicks an artifact inline card */
|
|
94
|
+
onArtifactOpen?: (artifact: ArtifactChunkData) => void;
|
|
91
95
|
/** Base font size multiplier for markdown rendering */
|
|
92
96
|
baselineFontSize?: number;
|
|
93
97
|
/** Total execution time in seconds (persisted from streaming wall-clock) */
|
|
@@ -96,10 +100,19 @@ interface MessageProps {
|
|
|
96
100
|
pendingClarification?: ClarificationData;
|
|
97
101
|
/** Callback when user responds to a clarification */
|
|
98
102
|
onClarificationSubmit?: (response: string) => void;
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
+
/** Pending tool approval data (tool requires user approval) */
|
|
104
|
+
pendingToolApproval?: ToolApprovalData;
|
|
105
|
+
/** Callback when user approves a tool execution */
|
|
106
|
+
onToolApprove?: (modifiedInputs: Record<string, unknown>) => void;
|
|
107
|
+
/** Callback when user rejects a tool execution */
|
|
108
|
+
onToolReject?: (reason?: string) => void;
|
|
109
|
+
/** Render function for inline suggested action cards (from [SA:id] markers) */
|
|
110
|
+
renderInlineSuggestedAction?: (id: string) => React.ReactNode;
|
|
111
|
+
/** Report this assistant response as incorrect. Receives an optional reason
|
|
112
|
+
* string (category + free-text details) for the learner pipeline. */
|
|
113
|
+
onReportIncorrect?: (reason?: string) => void;
|
|
114
|
+
/** Confirm this assistant response was correct/helpful */
|
|
115
|
+
onConfirmCorrect?: () => void;
|
|
103
116
|
}
|
|
104
117
|
/**
|
|
105
118
|
* Styled Message component with grid layout matching the main app.
|
|
@@ -216,6 +229,12 @@ interface MessageActionBarProps {
|
|
|
216
229
|
onRegenerate?: () => void;
|
|
217
230
|
/** Optional callback when edit is requested */
|
|
218
231
|
onEdit?: () => void;
|
|
232
|
+
/** Report this response as incorrect (fires mistake-recording pipeline). Reason
|
|
233
|
+
* combines an optional category chip + free-text details, formatted as
|
|
234
|
+
* "{category}: {details}" | "{category}" | "{details}" | "". */
|
|
235
|
+
onReportIncorrect?: (reason?: string) => void;
|
|
236
|
+
/** Confirm this response was helpful / correct */
|
|
237
|
+
onConfirmCorrect?: () => void;
|
|
219
238
|
/** Additional CSS classes */
|
|
220
239
|
className?: string;
|
|
221
240
|
}
|
|
@@ -223,7 +242,7 @@ interface MessageActionBarProps {
|
|
|
223
242
|
* Action bar that appears on hover below assistant message bubbles.
|
|
224
243
|
* Currently implements Copy; onRegenerate and onEdit are reserved for future use.
|
|
225
244
|
*/
|
|
226
|
-
declare function MessageActionBar({ textContent, onRegenerate, onEdit, className, }: MessageActionBarProps): react_jsx_runtime.JSX.Element;
|
|
245
|
+
declare function MessageActionBar({ textContent, onRegenerate, onEdit, onReportIncorrect, onConfirmCorrect, className, }: MessageActionBarProps): react_jsx_runtime.JSX.Element;
|
|
227
246
|
|
|
228
247
|
interface ScrollToBottomButtonProps {
|
|
229
248
|
/** Whether the viewport is at the bottom (hides button when true) */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { HTMLAttributes, ReactNode, TextareaHTMLAttributes, ButtonHTMLAttributes } from 'react';
|
|
3
|
-
import { M as MessageData, P as ParticipantRole } from './message-
|
|
3
|
+
import { M as MessageData, P as ParticipantRole } from './message-BrHFdwb2.js';
|
|
4
4
|
|
|
5
5
|
interface MessageContextValue {
|
|
6
6
|
message: MessageData;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {l,m,c,d,r}from'./chunk-6RN7SUWT.js';import {a as a$2}from'./chunk-D2PFIJNZ.js';import {a as a$1}from'./chunk-4WWJTYYA.js';import {a}from'./chunk-OCKHJ4WO.js';import {b}from'./chunk-O2ILSWHS.js';import {forwardRef,useState,useContext,useMemo,useRef,useCallback,useEffect}from'react';import {X,Zap,ExternalLink,Search,Mail,Copy,Navigation,Send,Loader2,Paperclip,Square,ArrowUp,Image,FileText,File,User,Bot,Link,ArrowRight,Sparkle,AlertCircle,MessageCircle,Shield,Check,MessageCircleQuestion,Users,GitBranch,Terminal,Globe,Wrench,ListTodo,Download,CheckCircle2,XCircle,ChevronDown,ChevronRight,Eye,Save,Pencil,Clock,FileSearch,FolderSearch,ChevronUp,Video,FileIcon,CircleDashed,CircleCheck,CircleX,MoreVertical,Circle}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import En from'react-markdown';import Dn from'remark-gfm';import {Prism}from'react-syntax-highlighter';import {oneLight,oneDark}from'react-syntax-highlighter/dist/esm/styles/prism';import {createPortal}from'react-dom';import {AnimatePresence,motion}from'framer-motion';import {ResponsiveContainer,ScatterChart,CartesianGrid,XAxis,YAxis,Tooltip,Legend,Scatter,PieChart,Pie,Cell,AreaChart,Area,BarChart,Bar,LineChart,Line}from'recharts';import {z}from'zod';function s(...e){return twMerge(clsx(e))}function fn(e){return e.startsWith("image/")?Image:e==="application/pdf"||e.startsWith("text/")?FileText:File}function bn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}var er=forwardRef(({attachment:e,onRemove:a,removable:r=true,className:t},n)=>{let o=fn(e.mimeType),i=e.mimeType.startsWith("image/");return jsxs("div",{ref:n,className:s("relative group","flex items-center gap-2","p-2 rounded-lg","border border-chat-border","bg-chat-panel-bg",t),children:[jsx("div",{className:s("w-10 h-10 rounded","flex items-center justify-center","bg-gray-100 dark:bg-gray-800","overflow-hidden flex-shrink-0"),children:i&&e.previewUrl?jsx("img",{src:e.previewUrl,alt:e.filename,className:"w-full h-full object-cover"}):jsx(o,{className:"w-5 h-5 text-chat-subtle"})}),jsxs("div",{className:"flex-1 min-w-0",children:[jsx("p",{className:"text-sm font-medium truncate text-chat-text",children:e.filename}),jsx("p",{className:"text-xs text-chat-subtle",children:bn(e.size)})]}),r&&a&&jsx("button",{type:"button",onClick:a,className:s("absolute -top-1.5 -right-1.5","w-5 h-5 rounded-full","flex items-center justify-center","bg-gray-500 text-white","opacity-0 group-hover:opacity-100","hover:bg-gray-600","transition-opacity duration-200"),"aria-label":`Remove ${e.filename}`,children:jsx(X,{className:"w-3 h-3"})})]})});er.displayName="AttachmentPreview";var xn={sm:"w-6 h-6 text-xs",md:"w-8 h-8 text-sm",lg:"w-10 h-10 text-base"},vn={sm:14,md:16,lg:20};function wn(e,a){let r=vn[a];switch(e){case "assistant":return jsx(Bot,{size:r});case "user":return jsx(User,{size:r});default:return jsx(User,{size:r})}}var Fe=forwardRef(({name:e,src:a,alt:r,role:t,size:n="md",className:o,...i},l$1)=>jsx(l,{ref:l$1,name:e,src:a,alt:r,role:t,className:s("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",xn[n],o),fallback:wn(t,n),...i}));Fe.displayName="Avatar";var ar=forwardRef(({children:e,className:a,...r},t)=>jsx("div",{ref:t,className:s("flex flex-col h-full","bg-white dark:bg-gray-900","font-sans text-chat-text",a),...r,children:e}));ar.displayName="ChatContainer";var Cn={small:"w-1.5 h-1.5",medium:"w-2 h-2",large:"w-2.5 h-2.5"},Sn={small:"gap-1",medium:"gap-1.5",large:"gap-2"};function it({size:e="medium",className:a}){let r=Cn[e];return jsxs("div",{className:s("flex items-center",Sn[e],a),children:[jsx("div",{className:s(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-1")}),jsx("div",{className:s(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-2")}),jsx("div",{className:s(r,"rounded-full bg-[var(--chat-text-subtle)]","animate-loading-dot animate-loading-dot-3")})]})}var _n={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 Vn(e){return _n[e.toLowerCase()]||e.toLowerCase()}function na(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function Bn({text:e}){let[a,r]=useState(false),t=useCallback(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3);}catch{}},[e]);return 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?jsx(Check,{size:14}):jsx(Copy,{size:14}),a?"Copied":"Copy"]})}function be({children:e,className:a,baselineFontSize:r=1,darkCodeTheme:t}){let n=t??(typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches),o=r!==1?{fontSize:`${r}rem`}:void 0;return jsx(En,{className:s("chat-prose",a),remarkPlugins:[Dn],components:{h1:({children:i})=>{let l=String(i),c=na(l);return jsxs("h1",{id:c,className:"group text-xl font-semibold mt-4 mb-2 first:mt-0",style:o,children:[i,jsx("a",{href:`#${c}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:16,className:"inline"})})]})},h2:({children:i})=>{let l=String(i),c=na(l);return jsxs("h2",{id:c,className:"group text-lg font-semibold mt-3 mb-2 first:mt-0",style:o,children:[i,jsx("a",{href:`#${c}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:14,className:"inline"})})]})},h3:({children:i})=>{let l=String(i),c=na(l);return jsxs("h3",{id:c,className:"group text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:[i,jsx("a",{href:`#${c}`,className:"ml-2 opacity-0 group-hover:opacity-50 transition-opacity","aria-label":"Link to heading",children:jsx(Link,{size:12,className:"inline"})})]})},h4:({children:i})=>jsx("h4",{className:"text-base font-medium mt-2 mb-1 first:mt-0",style:o,children:i}),p:({children:i})=>jsx("p",{className:"mb-2 last:mb-0 leading-relaxed",style:o,children:i}),a:({href:i,children:l})=>i&&/\.(png|jpe?g|gif|webp|svg)([?#]|$)/i.test(i)?jsx("img",{src:i,alt:typeof l=="string"?l:"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"}):jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:opacity-80 transition-opacity",style:o,children:l}),ul:({children:i})=>jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:i}),ol:({children:i})=>jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:i}),li:({children:i})=>jsx("li",{className:"leading-relaxed",style:o,children:i}),blockquote:({children:i})=>jsx("blockquote",{className:"border-l-2 border-gray-300 dark:border-gray-600 pl-3 my-2 italic text-chat-subtle",style:o,children:i}),code:({className:i,children:l})=>{let c=/language-(\w+)/.exec(i||""),d=String(l).replace(/\n$/,"");if(!c&&!d.includes(`
|
|
2
|
+
`))return jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono",style:o,children:l});let y=c?Vn(c[1]):"text";return jsxs("div",{className:"relative group my-2 rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsx("span",{className:"text-xs font-mono text-gray-400",children:y}),jsx(Bn,{text:d})]}),jsx(Prism,{language:y,style:n===false?oneLight:oneDark,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",lineHeight:"1.6"},codeTagProps:{style:{fontFamily:"'Fira Code', 'JetBrains Mono', monospace"}},children:d})]})},pre:({children:i})=>jsx(Fragment,{children:i}),table:({children:i})=>jsx("div",{className:"overflow-x-auto my-2 rounded-lg border border-gray-200 dark:border-gray-700",children:jsx("table",{className:"min-w-full",children:i})}),thead:({children:i})=>jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:i}),th:({children:i})=>jsx("th",{className:"px-3 py-2 text-left text-sm font-medium",style:o,children:i}),td:({children:i})=>jsx("td",{className:"px-3 py-2 text-sm border-t border-gray-100 dark:border-gray-700",style:o,children:i}),hr:()=>jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"}),strong:({children:i})=>jsx("strong",{className:"font-semibold",children:i}),em:({children:i})=>jsx("em",{className:"italic",children:i}),img:({src:i,alt:l})=>jsx("img",{src:i,alt:l??"",className:"max-w-full h-auto rounded-lg my-2",loading:"lazy"})},children:e})}var Ve=/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([A-Za-z0-9_-]{11})/,Wn=e=>{let a=e.match(Ve);return a?a[1]:null};function ia(e,a,r){if(typeof e=="string"){let t=e.trim();if(!t)return null;if(t.startsWith("media_ref:")&&r&&r.length>0){let i=t.slice(10),l=r.find(c=>c.id===i);return l?{id:l.id,url:l.url,mediaType:l.mediaType||(Ve.test(l.url)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(l.url)?"video":"image"),altText:l.altText}:null}let n=t,o=Ve.test(n)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(n);return {id:a,url:n,mediaType:o?"video":"image"}}if(e&&typeof e=="object"){let t=e,n=t.url||t.image_url||t.video_url;if(!n||typeof n!="string")return null;let o=t.media_type||t.mediaType||t.type,i=t.alt||t.alt_text||t.altText;return {id:t.id||a,url:n,mediaType:o||(Ve.test(n)||/\.(mp4|mov|webm|m4v|mkv)(\?|$)/i.test(n)?"video":"image"),altText:i}}return null}var et=({label:e})=>jsx("div",{className:s("absolute inset-0 flex cursor-pointer items-center justify-center","bg-black/20 transition-colors hover:bg-black/35"),"aria-label":e,children:jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-black/55 shadow-lg",children:jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"white","aria-hidden":"true",children:jsx("path",{d:"M8 5v14l11-7z"})})})});function xt({items:e,index:a,onClose:r,onNavigate:t}){let n=e[a];if(useEffect(()=>{let c=p=>{p.key==="Escape"?r():p.key==="ArrowLeft"?t(-1):p.key==="ArrowRight"&&t(1);};window.addEventListener("keydown",c);let d=typeof document<"u"?document.body.style.overflow:"";return typeof document<"u"&&(document.body.style.overflow="hidden"),()=>{window.removeEventListener("keydown",c),typeof document<"u"&&(document.body.style.overflow=d);}},[r,t]),!n||typeof document>"u")return null;let o=n.mediaType==="video"?Wn(n.url):null,i=e.length>1,l=jsxs("div",{className:s("fixed inset-0 z-[9999] flex items-center justify-center","bg-black/85 backdrop-blur-sm"),role:"dialog","aria-modal":"true","aria-label":"Media viewer",onClick:r,children:[jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),r();},className:s("absolute right-4 top-4 z-10 flex h-10 w-10 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Close",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})}),i&&jsxs("div",{className:"absolute left-4 top-4 z-10 rounded-full bg-white/10 px-3 py-1 text-sm text-white",onClick:c=>c.stopPropagation(),children:[a+1," / ",e.length]}),i&&jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),t(-1);},className:s("absolute left-4 z-10 flex h-12 w-12 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Previous",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),i&&jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),t(1);},className:s("absolute right-4 z-10 flex h-12 w-12 items-center justify-center","rounded-full bg-white/10 text-white hover:bg-white/20"),"aria-label":"Next",children:jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),jsxs("div",{className:"flex max-h-[90vh] max-w-[90vw] flex-col items-center",onClick:c=>c.stopPropagation(),children:[n.mediaType==="video"&&o?jsx("div",{className:"relative overflow-hidden rounded-lg bg-black",style:{width:"min(90vw, 1024px)",aspectRatio:"16 / 9"},children:jsx("iframe",{src:`https://www.youtube.com/embed/${o}?autoplay=1`,title:n.altText||"Video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:true,className:"absolute inset-0 h-full w-full border-0"})}):n.mediaType==="video"?jsxs("video",{controls:true,autoPlay:true,preload:"metadata",className:"block max-h-[85vh] max-w-[90vw] rounded-lg",children:[jsx("source",{src:n.url}),"Your browser does not support the video tag."]}):jsx("img",{src:n.url,alt:n.altText||"Image",className:"block max-h-[85vh] max-w-[90vw] rounded-lg object-contain"}),n.altText&&jsx("div",{className:"mt-2 max-w-[90vw] text-center text-sm text-white/80",children:n.altText})]})]});return createPortal(l,document.body)}function vt(e){let[a,r]=useState(null),t=useCallback(i=>r(i),[]),n=useCallback(()=>r(null),[]),o=useCallback(i=>{r(l=>l===null||e.length===0?l:(l+i+e.length)%e.length);},[e.length]);return {index:a,open:t,close:n,navigate:o}}function or(e){switch(e){case "knowledge_base":return {label:"Knowledge Base",color:"#4caf50"};case "api":return {label:"API",color:"#2196f3"};case "system_tool":return {label:"Tool",color:"#ff9800"};case "mcp_tool":return {label:"MCP",color:"#9c27b0"};case "workflow":return {label:"Workflow",color:"#00bcd4"};case "memory":return {label:"Memory",color:"#e91e63"};default:return {label:"Source",color:"#757575"}}}function sa({sources:e,className:a}){let[r,t]=useState(null),[n,o]=useState(false);if(!e||e.length===0)return null;let i=8,l=n?e:e.slice(0,i),c=e.length-i;return jsxs(Fragment,{children:[jsxs("div",{className:s("flex flex-wrap gap-1.5 mt-2",a),children:[l.map(d=>{let p=or(d.source_type);return jsx("span",{className:"inline-flex items-center gap-0.5",children:jsxs("button",{onClick:()=>t(d),className:"inline-flex items-center h-6 px-2 text-[0.75rem] font-medium rounded-full border cursor-pointer transition-colors max-w-[280px] truncate",style:{backgroundColor:p.color+"1a",color:p.color,borderColor:p.color+"40"},children:["[",d.index,"] ",d.title]})},d.index)}),!n&&c>0&&jsxs("button",{onClick:()=>o(true),className:"inline-flex items-center h-6 px-2 text-[0.75rem] font-medium rounded-full border cursor-pointer transition-colors text-gray-500 border-gray-300 hover:bg-gray-50 dark:border-gray-600 dark:hover:bg-gray-800",children:["+",c," more"]})]}),jsx(ir,{source:r,onClose:()=>t(null)})]})}function ir({source:e,onClose:a}){if(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=or(e.source_type);return jsx(AnimatePresence,{children:e&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[jsx(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 bg-black/50",onClick:a}),jsxs(motion.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:{duration:.15},className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("h3",{className:"text-lg font-semibold truncate",children:e.title}),jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded font-medium shrink-0",style:{backgroundColor:r.color+"1a",color:r.color},children:r.label})]}),jsx("button",{onClick:a,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 ml-2",children:jsx(X,{size:16})})]}),jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[jsx("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:e.tool_name.replace(/_/g," ")}),e.query&&jsxs("span",{className:"text-[0.7rem] px-1.5 py-0.5 rounded border border-gray-200 dark:border-gray-700 max-w-[200px] truncate",title:e.query,children:["Query: ",e.query.slice(0,40),e.query.length>40?"...":""]})]}),e.url&&jsx("div",{className:"mb-4",children:jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-500 hover:underline inline-flex items-center gap-1",children:[e.url.length>80?`${e.url.slice(0,80)}...`:e.url,jsx(ExternalLink,{size:12})]})}),e.description&&jsx("p",{className:"text-sm text-gray-500 mb-4",children:e.description}),e.full_content?jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 max-h-[400px] overflow-auto",children:e.full_content}):e.snippet?jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed p-4 rounded-lg bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700",children:e.snippet}):jsx("p",{className:"text-sm text-gray-400 italic",children:"No content available for this source."})]}),jsx("div",{className:"flex justify-end p-3 border-t border-gray-200 dark:border-gray-700",children:jsx("button",{onClick: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 Gn({index:e,source:a}){return jsx("span",{className:s("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 la({clarification:e,onSubmit:a,onOptionSelect:r,disabled:t=false,loading:n=false,className:o}){let[i,l]=useState(""),c=useCallback(v=>{v.trim()&&(l(""),a(v.trim()));},[a]),d=v=>{let g=v.target.value;r?.(g),c(g);},p=v=>{v.key==="Enter"&&!v.shiftKey&&i.trim()&&(v.preventDefault(),c(i));},y=e.options&&e.options.length>0,x=e.allowFreeText!==false;return jsxs("div",{className:s("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",o),children:[jsxs("div",{className:s("flex items-start gap-2",(y||x)&&"mb-2"),children:[jsx("span",{className:"text-orange-600 mt-0.5",children:jsx(MessageCircle,{size:14})}),jsx("p",{className:"text-sm font-medium",children:e.question})]}),y&&jsx("div",{className:s("ml-5 space-y-1",x&&"mb-2"),children:e.options.map((v,g)=>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:[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))}),x&&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:[jsx("input",{type:"text",value:i,onChange:v=>l(v.target.value),onKeyDown:p,placeholder:y?"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"}),jsx("button",{onClick:()=>c(i),disabled:!i.trim()||t||n,className:s("p-1 rounded transition-colors",i.trim()?"text-orange-600 hover:text-orange-700":"text-gray-300"),children:jsx(Send,{size:16})})]})]})}function pa({approval:e,onApprove:a,onReject:r,disabled:t=false,className:n}){let[o,i]=useState(()=>({...e.toolInputs})),[l,c]=useState(false),[d,p]=useState(""),y=useCallback(()=>{a(o);},[a,o]),x=useCallback(()=>{l?r(d||void 0):c(true);},[r,l,d]),v=useCallback((E,M)=>{i(R=>({...R,[E]:M}));},[]),g=e.toolSchema?.parameters?.properties,k=Object.entries(o).filter(([E])=>E!=="__description");return jsxs("div",{className:s("mx-4 mb-3 px-4 py-3","bg-amber-50/60 dark:bg-amber-950/20","border-l-[3px] border-amber-500","rounded-r-lg",n),children:[jsxs("div",{className:"flex items-start gap-2 mb-2",children:[jsx("span",{className:"text-amber-600 mt-0.5",children:jsx(Shield,{size:14})}),jsxs("p",{className:"text-sm font-medium flex-1 min-w-0",children:["Approval required:"," ",e.toolDescription||e.toolName]})]}),k.length>0&&jsx("div",{className:"ml-5 mb-3 space-y-2",children:k.map(([E,M])=>{let R=g?.[E],T=R?.type||"string",z=R?.description,f=R?.enum;return jsxs("div",{className:"flex flex-col gap-0.5",children:[jsxs("label",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:[E,z&&jsxs("span",{className:"font-normal text-gray-400 dark:text-gray-500 ml-1",children:["- ",z]})]}),f&&f.length>0?jsx("select",{value:String(M??""),onChange:h=>v(E,h.target.value),disabled:t,className:"text-sm bg-white dark:bg-gray-900 border border-amber-200 dark:border-amber-800 rounded px-2 py-1 disabled:opacity-50",children:f.map(h=>jsx("option",{value:h,children:h},h))}):T==="boolean"?jsxs("select",{value:String(!!M),onChange:h=>v(E,h.target.value==="true"),disabled:t,className:"text-sm bg-white dark:bg-gray-900 border border-amber-200 dark:border-amber-800 rounded px-2 py-1 disabled:opacity-50",children:[jsx("option",{value:"true",children:"true"}),jsx("option",{value:"false",children:"false"})]}):typeof M=="object"&&M!==null?jsx("textarea",{value:JSON.stringify(M,null,2),onChange:h=>{try{v(E,JSON.parse(h.target.value));}catch{}},disabled:t,rows:3,className:"text-xs font-mono bg-white dark:bg-gray-900 border border-amber-200 dark:border-amber-800 rounded px-2 py-1.5 resize-y disabled:opacity-50"}):jsx("input",{type:T==="number"||T==="integer"?"number":"text",value:String(M??""),onChange:h=>{let u=T==="number"||T==="integer"?Number(h.target.value):h.target.value;v(E,u);},disabled:t,className:"text-sm bg-white dark:bg-gray-900 border border-amber-200 dark:border-amber-800 rounded px-2 py-1 disabled:opacity-50"})]},E)})}),l&&jsx("div",{className:"ml-5 mb-3",children:jsx("input",{type:"text",value:d,onChange:E=>p(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),r(d||void 0));},placeholder:"Reason for rejection (optional)...",disabled:t,autoFocus:true,className:"w-full text-sm bg-white dark:bg-gray-900 border border-red-200 dark:border-red-800 rounded px-2 py-1 disabled:opacity-50 placeholder:text-gray-400"})}),jsxs("div",{className:"flex items-center gap-2 ml-5",children:[jsxs("button",{onClick:y,disabled:t,className:s("flex items-center gap-1.5 px-4 py-1.5 rounded text-sm font-medium transition-colors","bg-green-600 hover:bg-green-700 text-white","disabled:opacity-50 disabled:cursor-not-allowed"),children:[jsx(Check,{size:14}),"Approve"]}),jsxs("button",{onClick:x,disabled:t,className:s("flex items-center gap-1.5 px-4 py-1.5 rounded text-sm font-medium transition-colors","bg-gray-200 text-gray-700 hover:bg-red-600 hover:text-white","dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-red-600 dark:hover:text-white","disabled:opacity-50 disabled:cursor-not-allowed"),children:[jsx(X,{size:14}),l?"Confirm Reject":"Reject"]})]})]})}var oo=["Incorrect or incomplete","Not what I asked for","Wrong data","Bad recommendation","Tone or style","Other"];function ua({textContent:e,onRegenerate:a,onEdit:r,onReportIncorrect:t,onConfirmCorrect:n,className:o}){let[i,l]=useState(false),[c,d]=useState("none"),[p,y]=useState(false),[x,v]=useState(null),[g,k]=useState(""),E=useCallback(()=>{y(false),v(null),k("");},[]),M=useCallback(()=>{if(c!=="none")return;let T=g.trim(),z=x&&T?`${x}: ${T}`:x||T;d("incorrect"),y(false),v(null),k(""),t?.(z||void 0);},[c,x,g,t]);useEffect(()=>{if(!p)return;let T=z=>{z.key==="Escape"&&E();};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[p,E]);let R=useCallback(async()=>{try{await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3);}catch{let T=document.createElement("textarea");T.value=e,T.style.position="fixed",T.style.opacity="0",document.body.appendChild(T),T.select(),document.execCommand("copy"),document.body.removeChild(T),l(true),setTimeout(()=>l(false),2e3);}},[e]);return jsxs("div",{className:s("relative flex items-center gap-1",p?"opacity-100":"opacity-0 group-hover:opacity-100 transition-opacity duration-150",o),children:[jsx("button",{type:"button",onClick:R,"aria-label":i?"Copied":"Copy message",className:s("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:i?jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})}):jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}),a&&jsx("button",{type:"button",onClick:a,"aria-label":"Regenerate response",className:s("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),jsx("path",{d:"M21 3v5h-5"}),jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),jsx("path",{d:"M8 16H3v5"})]})}),r&&jsx("button",{type:"button",onClick:r,"aria-label":"Edit message",className:s("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"}),jsx("path",{d:"m15 5 4 4"})]})}),(n||t)&&c==="none"&&jsx("div",{className:"w-px h-4 bg-[var(--chat-text-subtle)] opacity-20 mx-0.5"}),n&&c==="none"&&jsx("button",{type:"button",onClick:()=>{d("correct"),n();},"aria-label":"This response was helpful",className:s("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7 10v12"}),jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2h0a3.13 3.13 0 0 1 3 3.88Z"})]})}),t&&c==="none"&&jsx("button",{type:"button",onClick:()=>y(true),"aria-label":"This response was incorrect","aria-haspopup":"dialog","aria-expanded":p,className:s("flex items-center justify-center","w-7 h-7 rounded-md","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","hover:bg-[var(--chat-panel-bg)]",p&&"bg-[var(--chat-panel-bg)] text-[var(--chat-text)]","transition-colors duration-150"),children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M17 14V2"}),jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22h0a3.13 3.13 0 0 1-3-3.88Z"})]})}),c!=="none"&&jsx("span",{className:"text-xs text-[var(--chat-text-subtle)] px-1",children:c==="correct"?"Thanks!":"Reported"}),p&&typeof document<"u"&&createPortal(jsxs("div",{role:"presentation",onClick:E,style:{position:"fixed",inset:0,zIndex:2147483600,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,fontFamily:"Inter, system-ui, -apple-system, sans-serif"},children:[jsx("style",{children:io}),jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Share feedback",onClick:T=>T.stopPropagation(),className:"mf-fbm-card",children:[jsxs("div",{className:"mf-fbm-header",children:[jsx("span",{className:"mf-fbm-title",children:"Share feedback"}),jsx("button",{type:"button",onClick:E,"aria-label":"Close feedback",className:"mf-fbm-close",children:jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]})})]}),jsx("div",{className:"mf-fbm-chips",children:oo.map(T=>{let z=x===T;return jsx("button",{type:"button",onClick:()=>v(z?null:T),className:s("mf-fbm-chip",z&&"mf-fbm-chip--active"),children:T},T)})}),jsx("textarea",{value:g,onChange:T=>k(T.target.value),placeholder:"What went wrong? (optional)",rows:3,className:"mf-fbm-textarea"}),jsx("div",{className:"mf-fbm-actions",children:jsx("button",{type:"button",onClick:M,disabled:!x&&!g.trim(),className:"mf-fbm-submit",children:"Submit"})})]})]}),document.body)]})}var io=`
|
|
3
|
+
.mf-fbm-card {
|
|
4
|
+
width: 420px;
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
background: #ffffff;
|
|
7
|
+
color: #111827;
|
|
8
|
+
border-radius: 12px;
|
|
9
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
|
|
10
|
+
padding: 20px;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
.mf-fbm-header {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
margin-bottom: 12px;
|
|
18
|
+
}
|
|
19
|
+
.mf-fbm-title {
|
|
20
|
+
font-size: 15px;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
color: #111827;
|
|
23
|
+
}
|
|
24
|
+
.mf-fbm-close {
|
|
25
|
+
width: 28px;
|
|
26
|
+
height: 28px;
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
background: transparent;
|
|
31
|
+
border: none;
|
|
32
|
+
border-radius: 6px;
|
|
33
|
+
color: #6b7280;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
.mf-fbm-close:hover {
|
|
38
|
+
background: rgba(0, 0, 0, 0.05);
|
|
39
|
+
color: #111827;
|
|
40
|
+
}
|
|
41
|
+
.mf-fbm-chips {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-wrap: wrap;
|
|
44
|
+
gap: 6px;
|
|
45
|
+
margin-bottom: 14px;
|
|
46
|
+
}
|
|
47
|
+
.mf-fbm-chip {
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
line-height: 1;
|
|
50
|
+
padding: 6px 10px;
|
|
51
|
+
border-radius: 9999px;
|
|
52
|
+
border: 1px solid rgba(0, 0, 0, 0.18);
|
|
53
|
+
background: #ffffff;
|
|
54
|
+
color: #111827;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
transition: background 120ms, color 120ms, border-color 120ms;
|
|
57
|
+
}
|
|
58
|
+
.mf-fbm-chip:hover {
|
|
59
|
+
background: rgba(0, 0, 0, 0.04);
|
|
60
|
+
}
|
|
61
|
+
.mf-fbm-chip--active,
|
|
62
|
+
.mf-fbm-chip--active:hover {
|
|
63
|
+
background: #111827;
|
|
64
|
+
color: #ffffff;
|
|
65
|
+
border-color: #111827;
|
|
66
|
+
}
|
|
67
|
+
.mf-fbm-textarea {
|
|
68
|
+
width: 100%;
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
font-family: inherit;
|
|
71
|
+
font-size: 13px;
|
|
72
|
+
line-height: 1.5;
|
|
73
|
+
color: #111827;
|
|
74
|
+
background: #f9fafb;
|
|
75
|
+
border: 1px solid rgba(0, 0, 0, 0.18);
|
|
76
|
+
border-radius: 8px;
|
|
77
|
+
padding: 10px 12px;
|
|
78
|
+
resize: none;
|
|
79
|
+
outline: none;
|
|
80
|
+
}
|
|
81
|
+
.mf-fbm-textarea:focus {
|
|
82
|
+
border-color: #111827;
|
|
83
|
+
}
|
|
84
|
+
.mf-fbm-textarea::placeholder {
|
|
85
|
+
color: rgba(0, 0, 0, 0.45);
|
|
86
|
+
}
|
|
87
|
+
.mf-fbm-actions {
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: flex-end;
|
|
90
|
+
margin-top: 14px;
|
|
91
|
+
}
|
|
92
|
+
.mf-fbm-submit {
|
|
93
|
+
font-size: 13px;
|
|
94
|
+
font-weight: 500;
|
|
95
|
+
padding: 7px 14px;
|
|
96
|
+
border-radius: 8px;
|
|
97
|
+
border: none;
|
|
98
|
+
background: #111827;
|
|
99
|
+
color: #ffffff;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
transition: opacity 120ms;
|
|
102
|
+
}
|
|
103
|
+
.mf-fbm-submit:hover {
|
|
104
|
+
opacity: 0.9;
|
|
105
|
+
}
|
|
106
|
+
.mf-fbm-submit:disabled {
|
|
107
|
+
opacity: 0.4;
|
|
108
|
+
cursor: not-allowed;
|
|
109
|
+
}
|
|
110
|
+
`;function fa({attachments:e,onDownload:a,onPreview:r,className:t}){let[n,o]=useState(null);if(!e||e.length===0)return null;let i=c=>{if(a){a(c);return}if(c.url){let d=document.createElement("a");d.href=c.url,d.download=c.filename,d.target="_blank",document.body.appendChild(d),d.click(),document.body.removeChild(d);}},l=c=>{if(r){r(c);return}c.isImage&&c.url&&o(c.url);};return jsxs("div",{className:s("flex flex-wrap gap-1.5",t),children:[e.map(c=>jsx(fo,{attachment:c,onDownload:()=>i(c),onPreview:()=>l(c)},c.id)),n&&jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",onClick:()=>o(null),children:[jsx("button",{className:"absolute top-4 right-4 p-2 text-white hover:bg-white/20 rounded-full transition-colors",onClick:()=>o(null),"aria-label":"Close",children:jsx(X,{size:24})}),jsx("img",{src:n,alt:"Preview",className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:c=>c.stopPropagation()})]})]})}function fo({attachment:e,onDownload:a,onPreview:r}){let t=e.humanReadableSize||ho(e.size);return jsxs("div",{className:s("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:[jsx(bo,{mimeType:e.mimeType,size:14}),jsx("span",{className:"text-xs text-[var(--chat-text)] truncate min-w-0",children:e.filename}),t&&t!=="0 Bytes"&&jsx("span",{className:"text-[10px] text-[var(--chat-text-subtle)] flex-shrink-0",children:t}),e.url&&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:jsx(Download,{size:12,className:"text-[var(--chat-text-subtle)]"})})]})}function bo({mimeType:e,size:a=14}){return e.startsWith("image/")?jsx(Image,{size:a,className:"text-[var(--chat-primary)] flex-shrink-0"}):e.startsWith("video/")?jsx(Video,{size:a,className:"text-[var(--chat-primary)] flex-shrink-0"}):e==="application/pdf"?jsx(FileText,{size:a,className:"text-red-500 flex-shrink-0"}):jsx(FileIcon,{size:a,className:"text-gray-500 flex-shrink-0"})}function ho(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 sr="miiflow-beamer-keyframes";function qe(e){if(typeof document>"u")return;let a=e?.getRootNode?.(),r=a instanceof ShadowRoot?a:document.head;if(r.querySelector(`#${sr}`))return;let t=document.createElement("style");t.id=sr,t.textContent="@keyframes beamer{0%{left:-30%}100%{left:100%}}",r.appendChild(t);}var Ge={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 kt({status:e,size:a=16,className:r}){let t=Math.max(a-4,10);return jsxs("div",{className:s("relative flex-shrink-0 flex items-center justify-center",r),style:{width:a,height:a},children:[e==="pending"&&jsx(CircleDashed,{size:a,strokeWidth:2,className:"text-[var(--chat-text-subtle)] opacity-40"}),e==="running"&&jsxs("div",{className:"relative flex items-center justify-center",style:{width:a,height:a},children:[jsx("div",{className:"absolute inset-0 rounded-full bg-indigo-500/20 animate-ping",style:{animationDuration:"1.5s"}}),jsx("div",{className:"relative rounded-full bg-gradient-to-br from-indigo-500 to-purple-500 p-[2px] animate-pulse-glow",children:jsx("div",{className:"rounded-full bg-white dark:bg-gray-900 flex items-center justify-center",style:{width:t,height:t},children:jsx(Loader2,{size:t-2,strokeWidth:2.5,className:"text-indigo-500 animate-spin"})})})]}),e==="completed"&&jsx("div",{className:"animate-complete-pop",children:jsx("div",{className:"rounded-full animate-success-flash",children:jsx(CircleCheck,{size:a,strokeWidth:2,className:"text-green-500"})})}),e==="failed"&&jsx(CircleX,{size:a,strokeWidth:2,className:"text-red-500"})]})}function Ye({items:e,badgeSize:a=20,className:r}){let t=useRef(null);return useEffect(()=>{qe(t.current);},[]),e.length===0?null:jsx("div",{ref:t,className:s("max-w-full",r),children:jsx("div",{className:"flex flex-col",children:e.map((n,o)=>{let i=o===e.length-1,c=(i?null:e[o+1])?.status==="pending",d=n.status==="running"&&!i;return jsxs("div",{className:"animate-fade-in",style:{display:"grid",gridTemplateColumns:`${a}px 1fr`,gap:"0.5rem",paddingBottom:i?0:"0.5rem",position:"relative"},children:[jsxs("div",{className:"relative flex flex-col items-center flex-shrink-0",style:{paddingTop:"4px"},children:[jsx(kt,{status:n.status,size:a}),!i&&(d?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(
|
|
111
|
+
180deg,
|
|
112
|
+
rgb(99, 102, 241) 0px,
|
|
113
|
+
rgb(99, 102, 241) 4px,
|
|
114
|
+
transparent 4px,
|
|
115
|
+
transparent 8px
|
|
116
|
+
)`,zIndex:1}}):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:c?"dashed":"solid",borderColor:"var(--chat-border)",zIndex:1}}))]}),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"&&jsx("div",{style:Ge}),n.content]})]},n.id)})})})}function ko({status:e,isLast:a=false,badgeSize:r=16,children:t,className:n}){let o=useRef(null);useEffect(()=>{qe(o.current);},[]);let i=e==="running"&&!a;return jsxs("div",{ref:o,className:s("relative flex items-start gap-3 animate-fade-in",!a&&"pb-3",n),children:[jsxs("div",{className:"relative flex-shrink-0 pt-0.5",children:[jsx(kt,{status:e,size:r}),!a&&(i?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(
|
|
117
|
+
180deg,
|
|
118
|
+
rgb(99, 102, 241) 0px,
|
|
119
|
+
rgb(99, 102, 241) 4px,
|
|
120
|
+
transparent 4px,
|
|
121
|
+
transparent 8px
|
|
122
|
+
)`,zIndex:1}}):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}}))]}),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"&&jsx("div",{style:Ge}),t]})]})}function ha({event:e,className:a,isRunning:r}){let t=useRef(null);if(useEffect(()=>{qe(t.current);},[]),e.type==="thinking")return jsx("div",{ref:t,className:s("p-1 rounded transition-colors","bg-black/[0.01] hover:bg-black/[0.02]",a),children:jsx("div",{className:"text-[var(--chat-text-subtle)] leading-relaxed",children:jsx(be,{className:"text-[14px]",children:e.content})})});if(e.type==="planning")return jsx("div",{ref:t,className:s("p-1 rounded transition-colors","bg-black/[0.01] hover:bg-black/[0.02]",a),children:jsx("div",{className:"text-[var(--chat-text-subtle)] leading-relaxed",children:jsx(be,{className:"text-[14px]",children:e.content})})});if(e.type==="tool")return jsxs("div",{ref:t,className:s("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&&jsx("div",{style:Ge}),jsx(Wrench,{size:14,className:"text-black/50 relative z-10 shrink-0"}),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 jsxs("div",{ref:t,className:s("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:[jsxs("span",{className:s("text-xs font-semibold uppercase tracking-wide block mb-1",n?"text-green-700":"text-yellow-700"),children:[e.toolName," Result"]}),jsx("div",{className:s(n?"text-green-900":"text-yellow-900"),children:jsx(be,{className:"text-[14px]",children:e.content})})]})}return null}var zo=["create_plan","unknown"];function mr(e){return e?zo.includes(e.toLowerCase().trim()):false}function Nt(e,a){if(e.toolName&&mr(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 Po(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(mr(n))return;a.push({id:`tool-${t}`,type:"tool",status:"completed",toolName:n,toolDescription:r.tool_description});}}),a}function $e({events:e,className:a}){if(e.length===0)return null;let r=e.map(t=>({id:t.id,status:t.status,content:jsx(ha,{event:t,isRunning:t.status==="running"})}));return jsx(Ye,{items:r,badgeSize:20,className:a})}function Ao(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 Mo({subtask:e,executionChunks:a=[]}){let[r,t]=useState(e.status==="running"),n=e.status==="running",o=e.status==="failed",i=e.status==="completed";n&&!r&&t(true);let l=a.length>0,c=Ao(a);return jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{onClick:()=>l&&t(!r),className:s("flex items-center gap-2 min-w-0",l&&"cursor-pointer"),children:[jsx("span",{className:s("text-sm font-medium truncate",o?"text-red-500":"text-black/85"),children:e.description}),o&&e.error&&jsx("span",{className:"text-sm text-red-500 truncate flex-1",children:e.error}),i&&e.execution_time!=null&&e.execution_time>0&&jsxs("span",{className:"text-xs text-black/40 shrink-0 tabular-nums",children:[e.execution_time.toFixed(1),"s"]}),l&&jsx("span",{className:"text-black/40 shrink-0 flex items-center",children:r?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14})})]}),l&&r&&jsx("div",{className:"mt-2 pl-2",children:jsx($e,{events:c})})]})}function St({plan:e,streamingChunks:a=[],className:r}){let t=e.subtasks.map(n=>{let o=a.filter(l=>l.subtaskId===n.id),i=n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending";return {id:String(n.id),status:i,content:jsx(Mo,{subtask:n,executionChunks:o})}});return jsxs("div",{className:s("space-y-2",r),children:[jsx("span",{className:"text-sm text-black/50",children:"Plan:"}),jsx(Ye,{items:t,badgeSize:20})]})}function zt({chunk:e}){let[a,r]=useState(false),t=e.claudeToolData;if(!t)return null;let n=t.status==="pending",o=t.status==="error",i=t.status==="completed",l=()=>n?jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}):o?jsx(XCircle,{size:14,className:"text-red-500"}):jsx(CheckCircle2,{size:14,className:"text-green-500"});return jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[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:[jsx(Wrench,{size:16,className:"text-gray-400 shrink-0"}),jsxs("span",{className:"flex-1 text-sm truncate",children:[jsx("span",{className:"font-medium",children:(()=>{let d=t.toolName;if(d.startsWith("mcp__")){let p=d.split("__");if(p.length>=3)return `${p[1]}/${p[2]}`}return d})()}),t.toolDescription&&jsx("span",{className:"text-gray-400 ml-2",children:t.toolDescription})]}),l(),i&&t.durationMs!=null&&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"]}),jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:14}):jsx(ChevronRight,{size:14})})]}),a&&jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[t.toolInput&&Object.keys(t.toolInput).length>0&&jsxs("div",{className:"mb-3",children:[jsx("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider mb-1",children:"Input"}),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)})]}),o&&jsx("p",{className:"text-sm text-red-500 font-mono",children:t.content||"Tool execution failed"}),n&&jsx("p",{className:"text-sm text-gray-400 italic",children:"Executing tool..."}),i&&t.content&&!t.isError&&jsxs("div",{children:[jsx("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider mb-1",children:"Result"}),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)}
|
|
123
|
+
... (truncated)`:t.content})]})]})]})}function Pt({chunk:e}){let[a,r]=useState(true),t=e.terminalData;if(!t)return null;let n=()=>{switch(t.status){case "running":return jsx(Loader2,{size:14,className:"animate-spin text-blue-500"});case "completed":return jsx(CheckCircle2,{size:14,className:"text-green-500"});case "failed":return jsx(XCircle,{size:14,className:"text-red-500"});default:return null}},o=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",i=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",c=d=>d?d<1e3?d+"ms":(d/1e3).toFixed(1)+"s":null;return jsxs("div",{className:s("my-1 bg-[#1a1a1a] rounded border",o,"overflow-hidden"),children:[jsxs("div",{onClick:()=>r(!a),className:s("flex items-center gap-2 px-3 py-1.5 cursor-pointer",i,"hover:brightness-110"),children:[jsx("span",{className:"p-0.5 text-gray-500",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx(Terminal,{size:16,className:l}),jsxs("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-300 truncate",children:[jsx("span",{className:"text-gray-500",children:"$ "}),t.command]}),t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-600",children:c(t.durationMs)}),n(),t.status!=="running"&&t.exitCode!==void 0&&jsxs("span",{className:s("text-[0.7rem] font-mono",t.exitCode===0?"text-green-500":"text-red-500"),children:["[",t.exitCode,"]"]})]}),a&&jsxs("div",{className:"p-3",children:[t.description&&jsx("p",{className:"text-gray-500 text-[0.75rem] italic mb-2",children:t.description}),t.stdout&&jsx("pre",{className:s("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&&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&&jsx("p",{className:"text-gray-500 text-[0.75rem] italic",children:"Running..."}),t.status==="completed"&&!t.stdout&&!t.stderr&&t.exitCode===0&&jsx("p",{className:"text-gray-600 text-[0.75rem] italic",children:"Command completed with no output"})]})]})}function Tt({chunk:e}){let[a,r]=useState(false),t=e.fileOperationData;if(!t)return null;let n=t.operation==="read"?jsx(Eye,{size:16}):t.operation==="write"?jsx(Save,{size:16}):t.operation==="edit"?jsx(Pencil,{size:16}):jsx(FileText,{size:16}),o=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",i=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"?jsx(Clock,{size:14,className:"text-gray-400"}):t.status==="completed"?jsx(CheckCircle2,{size:14,className:"text-green-500"}):jsx(XCircle,{size:14,className:"text-red-500"}),c=t.operation==="read"?"Read":t.operation==="write"?"Write":t.operation==="edit"?"Edit":"File",d=p=>{let y=p.split("/");return y.length<=3?p:".../"+y.slice(-3).join("/")};return jsxs("div",{className:s("my-1 border rounded overflow-hidden",o.split(" ")[1]+"/30"),children:[jsxs("div",{onClick:()=>r(!a),className:s("flex items-center gap-2 px-3 py-1.5 cursor-pointer",i),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx("span",{className:o.split(" ")[0],children:n}),jsx("span",{className:s("font-medium text-[0.75rem]",o.split(" ")[0]),children:c}),jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:d(t.filePath)}),t.totalLines!=null&&jsxs("span",{className:"text-[0.7rem] text-gray-400",children:[t.totalLines," lines"]}),l]}),a&&jsxs("div",{className:"p-3 bg-gray-50 dark:bg-[#1e1e1e]",children:[t.operation==="read"&&t.content&&jsx(ni,{content:t.content}),t.operation==="edit"&&jsx(oi,{oldString:t.oldString,newString:t.newString}),t.operation==="write"&&t.status==="completed"&&jsx("p",{className:"text-green-500 text-sm",children:"File written successfully"}),t.error&&jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})]})]})}function ni({content:e}){let a=useMemo(()=>e.split(`
|
|
124
|
+
`).slice(0,50),[e]),r=e.split(`
|
|
125
|
+
`).length,t=r>50;return jsxs("div",{children:[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,o)=>jsxs("div",{className:"flex",children:[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:o+1}),jsx("span",{children:n||" "})]},o))}),t&&jsxs("p",{className:"text-[0.75rem] text-gray-400 mt-1",children:["... and ",r-50," more lines"]})]})}function oi({oldString:e,newString:a}){return !e&&!a?jsx("p",{className:"text-gray-500 text-sm",children:"No changes to display"}):jsxs("div",{className:"flex gap-4",children:[jsxs("div",{className:"flex-1",children:[jsx("span",{className:"text-[0.75rem] font-medium text-red-500 block mb-1",children:"- Removed"}),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)"})]}),jsxs("div",{className:"flex-1",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500 block mb-1",children:"+ Added"}),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 Et({chunk:e}){let[a,r]=useState(true),t=e.searchResultsData;if(!t)return null;let n=t.tool==="grep",o=n?"text-purple-500":"text-blue-500",i=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",c=n?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500";return jsxs("div",{className:s("my-1 border rounded overflow-hidden",i),children:[jsxs("div",{onClick:()=>r(!a),className:s("flex items-center gap-2 px-3 py-1.5 cursor-pointer",l),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:16}):jsx(ChevronRight,{size:16})}),jsx("span",{className:o,children:n?jsx(FileSearch,{size:16}):jsx(FolderSearch,{size:16})}),jsx("span",{className:s("text-[0.7rem] px-1.5 py-0.5 rounded font-medium",c),children:n?"Grep":"Glob"}),jsx("span",{className:"flex-1 font-mono text-[0.75rem] text-gray-500 truncate",children:t.pattern}),jsxs("span",{className:s("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&&jsxs("div",{className:"max-h-[300px] overflow-auto",children:[t.results.length>0?jsxs("div",{children:[t.results.slice(0,50).map((d,p)=>jsx(mi,{result:d,isGrep:n},p)),t.results.length>50&&jsx("div",{className:"py-1 px-3",children:jsxs("span",{className:"text-[0.75rem] text-gray-400",children:["... and ",t.results.length-50," more results"]})})]}):jsx("div",{className:"p-3",children:jsx("p",{className:"text-gray-500 text-sm",children:"No results found"})}),t.error&&jsx("div",{className:"p-3",children:jsxs("p",{className:"text-red-500 text-sm",children:["Error: ",t.error]})})]})]})}function mi({result:e,isGrep:a}){return 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:[jsx(File,{size:14,className:"text-gray-400 mt-0.5 shrink-0"}),jsxs("div",{className:"min-w-0 flex-1",children:[jsxs("div",{className:"flex items-center gap-2",children:[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&&jsxs("span",{className:"font-mono text-[0.7rem] text-blue-500",children:[":",e.lineNumber]})]}),e.snippet&&jsx("p",{className:"font-mono text-[0.7rem] text-gray-500 truncate max-w-[400px]",children:e.snippet})]})]})}function Dt({chunk:e}){let[a,r]=useState(false),t=e.webOperationData;if(!t)return null;let n=t.operation==="search",o=t.status==="pending",i=t.status==="error",l=t.status==="completed",c=()=>o?jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}):i?jsx(XCircle,{size:14,className:"text-red-500"}):jsx(CheckCircle2,{size:14,className:"text-green-500"}),p=n?(()=>{if(!t.results||typeof t.results!="string")return [];let y=/\[([^\]]+)\]\(([^)]+)\)/g,x=[],v;for(;(v=y.exec(t.results))!==null;)x.push({title:v[1],url:v[2]});return x})():[];return jsxs("div",{className:"bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[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?jsx(Search,{size:16,className:"text-gray-400 shrink-0"}):jsx(Globe,{size:16,className:"text-gray-400 shrink-0"}),jsx("span",{className:"flex-1 text-sm truncate",children:n?jsxs(Fragment,{children:["Searching: ",jsx("span",{className:"font-medium",children:t.query})]}):jsxs(Fragment,{children:["Fetching: ",jsx("span",{className:"font-medium",children:t.url})]})}),c(),l&&t.durationMs!=null&&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"]}),jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:14}):jsx(ChevronRight,{size:14})})]}),a&&jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:[i&&t.error&&jsx("p",{className:"text-sm text-red-500 font-mono",children:t.error}),o&&jsx("p",{className:"text-sm text-gray-400 italic",children:n?"Searching the web...":"Fetching content..."}),n&&l&&p.length>0&&jsxs("div",{className:"space-y-2",children:[jsxs("div",{className:"text-[0.75rem] text-gray-400 uppercase tracking-wider",children:[p.length," Results"]}),p.slice(0,5).map((y,x)=>jsxs("div",{className:s("flex items-center gap-2 py-1",x<Math.min(p.length,5)-1&&"border-b border-gray-200 dark:border-gray-700"),children:[jsx(ExternalLink,{size:12,className:"text-gray-400 shrink-0"}),jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm truncate hover:underline",children:y.title})]},x)),p.length>5&&jsxs("p",{className:"text-[0.75rem] text-gray-400 italic",children:["+",p.length-5," more results"]})]}),n&&l&&p.length===0&&t.results&&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&&jsx("div",{className:"max-h-[300px] overflow-auto bg-gray-100 dark:bg-gray-900 rounded p-2",children: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&&`
|
|
126
|
+
... (truncated)`]})})]})]})}var Ei={code_reviewer:"Code Review",researcher:"Research",data_analyst:"Data Analysis",Explore:"Explore",Plan:"Planning",Bash:"Command Execution"};function At({chunk:e}){let[a,r]=useState(true),t=e.subagentData;if(!t)return null;let n=t.status==="running"?jsx(Loader2,{size:16,className:"animate-spin text-blue-500"}):t.status==="completed"?jsx(CheckCircle2,{size:16,className:"text-green-500"}):t.status==="failed"?jsx(XCircle,{size:16,className:"text-red-500"}):null,o=t.status==="running"?"border-blue-500":t.status==="completed"?"border-green-500":t.status==="failed"?"border-red-500":"border-gray-500",i=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",c=p=>p?p<1e3?p+"ms":(p/1e3).toFixed(1)+"s":null,d=Ei[t.subagentType]||t.subagentType;return jsxs("div",{className:s("border border-dashed rounded ml-4 my-2 overflow-hidden",o+"/50",i),children:[jsxs("div",{onClick:()=>r(!a),className:s("flex items-center gap-2 px-3 py-1.5 cursor-pointer hover:brightness-95"),children:[jsx("span",{className:"p-0.5",children:a?jsx(ChevronDown,{size:18}):jsx(ChevronRight,{size:18})}),jsx(GitBranch,{size:16,className:o.replace("border-","text-")}),jsx("span",{className:s("text-[0.75rem] px-2 py-0.5 rounded font-medium",l),children:d}),jsx("span",{className:"flex-1 text-sm text-gray-500 truncate",children:t.description}),n,t.durationMs!=null&&jsx("span",{className:"text-[0.7rem] text-gray-400",children:c(t.durationMs)})]}),a&&jsxs("div",{className:"px-4 pb-3",children:[t.nestedChunks&&t.nestedChunks.length>0&&jsx("div",{className:"mt-2 space-y-1",children:t.nestedChunks.map((p,y)=>jsx(Di,{chunk:p},y))}),t.status==="completed"&&t.result&&jsxs("div",{className:"mt-2 p-2 rounded bg-green-500/5 border border-green-500/20",children:[jsx("span",{className:"text-[0.75rem] font-medium text-green-500",children:"Result"}),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 Di({chunk:e}){return e.type==="tool"||e.type==="observation"?jsxs("div",{className:"py-1 px-2 my-1 rounded bg-blue-500/5 text-[0.75rem]",children:[jsxs("span",{className:"font-medium text-blue-500",children:[e.toolName||"Tool",":"]})," ",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"?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 $i(e){let a=useRef(null),[r,t]=useState(0),n=useRef(0);return useEffect(()=>{if(e){a.current===null&&(a.current=Date.now());let o=setInterval(()=>{if(a.current!==null){let i=Math.floor((Date.now()-a.current)/1e3);t(i),n.current=i;}},1e3);return ()=>clearInterval(o)}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 ji(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 Wi(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 Hi(e){let a=e.filter(c=>c.type==="wave_start"&&c.waveData);if(a.length===0)return null;let r=a[a.length-1],t=r.waveData?.waveNumber??0,n=r.waveData?.totalWaves??1,o=r.waveData?.parallelCount??0,i=[],l=[];return e.forEach(c=>{if(c.type==="parallel_subtask_start"&&c.waveNumber===t&&c.subtaskId!==void 0&&(l.includes(c.subtaskId)||i.push(c.subtaskId)),c.type==="parallel_subtask_complete"&&c.waveNumber===t&&c.subtaskId!==void 0){l.push(c.subtaskId);let d=i.indexOf(c.subtaskId);d>=0&&i.splice(d,1);}}),{currentWave:t,totalWaves:n,parallelCount:o,activeSubtasks:i,completedSubtasks:l}}function Ui(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 yr(e){return e.find(r=>(r.type==="multi_agent_planning"||r.type==="multi_agent_planning_complete")&&r.subagentAllocations)?.subagentAllocations||[]}function xr(e){let a=new Map,r=false;yr(e).forEach(o=>{a.set(o.name,{name:o.name,task:o.query||o.focus,status:"pending"});});let t={pending:0,running:1,completed:2,failed:2};e.forEach(o=>{if(o.subagentInfo?.name){let i=o.subagentInfo.id||o.subagentInfo.name,l=a.get(i);(!l||(t[o.subagentInfo.status]??0)>=(t[l.status]??0))&&a.set(i,o.subagentInfo);}o.type==="synthesis"&&(r=true);});let n=[...a.values()];return {subagents:a,running:n.filter(o=>o.status==="running").length,completed:n.filter(o=>o.status==="completed").length,failed:n.filter(o=>o.status==="failed").length,pending:n.filter(o=>o.status==="pending").length,isSynthesizing:r}}function Ki(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 qi({chunks:e}){let a=xr(e),r=[...a.subagents.values()];if(r.length===0){let n=e.some(i=>i.type==="multi_agent_planning"),o=yr(e);return o.length>0?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsxs("span",{className:"text-sm text-gray-500",children:["Allocating agents: ",o.map(i=>i.name).join(", ")]})]}):n?jsxs("div",{className:"flex items-center gap-2",children:[jsx(Loader2,{size:14,className:"animate-spin text-gray-400"}),jsx("span",{className:"text-sm text-gray-500",children:"Planning agent allocation..."})]}):null}let t=r.map((n,o)=>({id:n.id||`agent-${o}`,status:n.status==="running"?"running":n.status==="completed"?"completed":n.status==="failed"?"failed":"pending",content:jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[jsx("span",{className:"text-sm font-medium",children:n.name}),jsx("span",{className:s("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&&jsxs("span",{className:"text-xs text-gray-400 shrink-0",children:[n.executionTime.toFixed(1),"s"]})]})}));return jsxs("div",{className:"space-y-2",children:[jsx("span",{className:"text-sm text-gray-500",children:a.running===0?"Agents:":"Running agents:"}),jsx(Ye,{items:t,badgeSize:16}),a.isSynthesizing&&jsxs("div",{className:"flex items-center gap-2",children:[jsx(Sparkle,{size:14,className:"text-gray-500"}),jsx("span",{className:"text-sm text-gray-500",children:"Synthesizing results..."})]})]})}function Gi({chunks:e}){return jsx("div",{className:"space-y-2",children:e.map((a,r)=>a.type==="subagent"&&a.subagentData?jsx(At,{chunk:a},`subagent-${a.subagentData.subagentId}-${r}`):a.type==="file_operation"&&a.fileOperationData?jsx(Tt,{chunk:a},`file-op-${a.fileOperationData.toolUseId}-${r}`):a.type==="terminal"&&a.terminalData?jsx(Pt,{chunk:a},`terminal-${a.terminalData.toolUseId}-${r}`):a.type==="search_results"&&a.searchResultsData?jsx(Et,{chunk:a},`search-${a.searchResultsData.toolUseId}-${r}`):a.type==="web_operation"&&a.webOperationData?jsx(Dt,{chunk:a},`web-op-${a.webOperationData.toolUseId}-${r}`):a.claudeToolData?jsx(zt,{chunk:a},`claude-tool-${a.claudeToolData.toolUseId}-${r}`):null)})}function fr(e){return e<1?`${Math.round(e*1e3)}ms`:`${e.toFixed(1)}s`}function xa({isStreaming:e=false,chunks:a=[],plan:r,executionTimeline:t=[],userMessageTimestamp:n,executionTime:o,defaultExpanded:i=false,expanded:l,onExpandedChange:c,className:d}){let[p,y]=useState(i),{display:x,finalSeconds:v}=$i(e),g=useRef(null);useEffect(()=>{qe(g.current);},[]);let k=a$2(g,300),E=l??p,M=useCallback(N=>{k(),y(N),c?.(N);},[k,c]),R=useMemo(()=>e?a.map((N,L)=>Nt(N,L)).filter(N=>N!==null):[],[e,a]),T=useMemo(()=>!e&&(t.length>0||a.length>0)?a.map((N,L)=>Nt(N,L)).filter(N=>N!==null):[],[e,t,a]),z=useMemo(()=>!e&&t.length>0?Ki(t):[],[e,t]),f=useMemo(()=>{if(!e)return null;let N=a.find(b=>b.planData!==void 0);if(!N?.planData)return null;let L={...N.planData},j=[...L.subtasks||[]],X=0,te=0;return a.forEach(b=>{if(b.type==="parallel_subtask_start"&&b.subtaskId!==void 0){let V=j.findIndex(P=>String(P.id)===String(b.subtaskId));V!==-1&&(j[V]={...j[V],status:"running"});}else if(b.type==="parallel_subtask_complete"&&b.subtaskId!==void 0){let V=j.findIndex(P=>String(P.id)===String(b.subtaskId));if(V!==-1){let P={...j[V]};b.parallelSubtaskData?.success===false||b.success===false?(P.status="failed",P.error=b.parallelSubtaskData?.error,te++):(P.status="completed",P.result=b.parallelSubtaskData?.result,P.execution_time=b.parallelSubtaskData?.executionTime,X++),j[V]=P;}}else if(b.type==="subtask"&&b.subtaskId!==void 0){let V=j.findIndex(P=>String(P.id)===String(b.subtaskId));if(V!==-1){let P={...j[V]};if(b.content.includes("\u2713 Completed"))P.status="completed",b.subtaskData?.execution_time&&(P.execution_time=b.subtaskData.execution_time),X++;else if(b.content.includes("\u2717 Failed")){P.status="failed";let H=b.content.match(/✗ Failed: (.*)/);H&&(P.error=H[1]),te++;}else b.content.includes("\u2192 **Subtask")&&(P.status="running");j[V]=P;}}}),L.subtasks=j,L.completed_subtasks=X,L.failed_subtasks=te,L.progress_percentage=X/L.total_subtasks*100,L},[e,a]),h=useMemo(()=>{if(o&&o>0)return o;if(!e){if(r?.subtasks)return r.subtasks.reduce((N,L)=>N+(L.execution_time||0),0);if(t.length>0){let N=t[t.length-1];if(n&&N.timestamp){let L=N.timestamp-n;if(L>0)return L}if(t.length>1){let L=t[0];if(L.timestamp&&N.timestamp){let j=N.timestamp-L.timestamp;if(j>0)return j}}}}return 0},[e,r,t,n,o]);if(!e){let N=r||t.length>0||a.length>0;if(!N||N&&T.length===0&&!r&&t.length===0)return null}let u=a.length>0?a[a.length-1]:null,W=u?.type==="tool"||!!u?.toolName,S=u?.type==="planning",K=Wi(a),Z=K?Hi(a):null,Ie=ji(a),fe=Ui(a),Pe=fe?xr(a):null,ie=()=>{if(!e)return h>0?`Thought for ${fr(h)}`:v>0?`Thought for ${fr(v)}`:(a.length>0,"Thought for a few seconds");if(fe&&Pe){let{running:N,completed:L,failed:j,isSynthesizing:X}=Pe;if(X)return "Synthesizing results...";if(u?.type==="multi_agent_planning")return "Planning subagent allocation...";if(u?.type==="subagent_start"&&u?.subagentInfo)return `${u.subagentInfo.name}: ${u.subagentInfo.task?.slice(0,30)||"working"}...`;if(u?.type==="subagent_complete"&&u?.subagentInfo)return `${u.subagentInfo.name} complete`;if(u?.type==="subagent_failed"&&u?.subagentInfo)return `${u.subagentInfo.name} failed`;let te=N+L+j;if(N>0)return `${N} subagent${N>1?"s":""} running (${L}/${te} done)`;if(te>0)return `Multi-agent execution (${L}/${te} complete)`}if(Ie){if(u?.type==="subagent"&&u?.subagentData)return `${u.subagentData.subagentType}: ${u.subagentData.description}`;if(u?.type==="file_operation"&&u?.fileOperationData){let N=u.fileOperationData.operation,L=u.fileOperationData.filePath.split("/").pop();return `${N==="read"?"Reading":N==="edit"?"Editing":"Writing"} ${L}`}if(u?.type==="terminal"&&u?.terminalData){let N=u.terminalData.command;return N.length>40?`$ ${N.slice(0,37)}...`:`$ ${N}`}if(u?.type==="search_results"&&u?.searchResultsData)return `${u.searchResultsData.tool}: ${u.searchResultsData.pattern}`;if(u?.type==="web_operation"&&u?.webOperationData)return u.webOperationData.operation==="search"?`Searching: ${u.webOperationData.query}`:`Fetching: ${u.webOperationData.url?.slice(0,40)}...`}if(K&&Z){let{currentWave:N,totalWaves:L,parallelCount:j,activeSubtasks:X,completedSubtasks:te}=Z;if(u?.type==="wave_start")return `Wave ${N+1}/${L}: ${j} parallel subtasks`;if(u?.type==="wave_complete")return `Wave ${N+1} complete (${te.length} done)`;if(u?.type==="parallel_subtask_start"&&u?.parallelSubtaskData?.description){let b=u.parallelSubtaskData.description;return b.length>40?`${b.slice(0,37)}...`:b}return X.length>0?`Wave ${N+1}/${L}: ${X.length} running...`:`Parallel execution (Wave ${N+1}/${L})`}if(u?.toolDescription)return u.toolDescription;if(u?.toolName)return u.toolName;switch(u?.type){case "planning":return "Planning...";case "thinking":return "Thinking...";case "tool":return u.toolName||"Using tool...";case "subtask":return `Executing subtask ${u.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..."}},Le=()=>fe?jsx(Users,{size:14}):Ie?u?.type==="subagent"?jsx(GitBranch,{size:14}):u?.type==="file_operation"?jsx(FileText,{size:14}):u?.type==="terminal"?jsx(Terminal,{size:14}):u?.type==="search_results"?jsx(Search,{size:14}):u?.type==="web_operation"?jsx(Globe,{size:14}):jsx(Sparkle,{size:14}):K?jsx(Zap,{size:14}):W?jsx(Wrench,{size:14}):S?jsx(ListTodo,{size:14}):jsx(Sparkle,{size:14}),C=N=>N?.subtasks&&N.subtasks.length>=2,Y=e?f:r,D=C(Y);return jsxs("div",{ref:g,className:s("max-w-full",d),children:[jsxs("div",{onClick:()=>M(!E),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&&jsx("div",{style:Ge}),jsx("span",{className:s("flex items-center text-gray-500"),children:e?Le():jsx(Sparkle,{size:14})}),jsx("span",{className:s("text-sm font-normal text-gray-500 text-[var(--chat-text-subtle)]"),children:ie()}),e&&parseInt(x)>0&&jsxs("span",{className:"text-gray-500 font-normal tabular-nums text-sm",children:[x,"s"]})]}),E&&jsx("div",{className:"mt-3 animate-fade-in",children:e?fe?jsx(qi,{chunks:a}):Ie?jsx(Gi,{chunks:a}):D&&Y?jsx(St,{plan:Y,streamingChunks:a}):f?.subtasks?.length===1?jsx($e,{events:R}):f?.subtasks?.length===0?null:jsx($e,{events:R}):r?r.subtasks?.length===0?null:r.subtasks?.length===1?jsx($e,{events:T}):jsx(St,{plan:r,streamingChunks:z}):jsx($e,{events:T})})]})}var dt=forwardRef(({content:e,isStreaming:a=false,renderMarkdown:r=true,className:t,baselineFontSize:n,markdownProps:o},i)=>jsx(m,{ref:i,content:e,isStreaming:a,showCursor:false,className:s("relative",t),children:r?jsx(be,{baselineFontSize:n,...o,children:e}):jsx("span",{className:"whitespace-pre-wrap",children:e})}));dt.displayName="StreamingText";var ls={send_message:jsx(Send,{size:14}),navigate:jsx(Navigation,{size:14}),copy_text:jsx(Copy,{size:14}),compose_email:jsx(Mail,{size:14}),search_emails:jsx(Search,{size:14}),open_modal:jsx(ExternalLink,{size:14}),api_call:jsx(Zap,{size:14})};function cs(e){return e?ls[e]||jsx(ArrowRight,{size:14}):jsx(ArrowRight,{size:14})}var Rt=forwardRef(({actions:e,onSelect:a,className:r,showIcons:t=true,disabled:n=false},o)=>{let[i,l]=useState(null);if(e.length===0)return null;let c=async(d,p)=>{if(!(!a||i!==null)){l(p);try{await a(d);}finally{l(null);}}};return jsx("div",{ref:o,role:"group","aria-label":"Suggested actions",className:s("flex flex-wrap gap-2",r),children:jsx(AnimatePresence,{children:e.map((d,p)=>{let y=i===p,x=n||i!==null;return jsxs(motion.button,{type:"button",initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.2,delay:p*.05},disabled:x,onClick:()=>c(d,p),className:s("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:[y?jsx(Loader2,{size:14,className:"animate-spin"}):t&&jsx("span",{className:"text-gray-400 dark:text-gray-500",children:cs(d.type)}),d.label]},d.id)})})})});Rt.displayName="SuggestedActions";var Ns=["#3B82F6","#10B981","#F59E0B","#EF4444","#8B5CF6","#EC4899","#06B6D4","#F97316"];function Vt({data:e,config:a,isStreaming:r=false}){let{chartType:t,series:n,xAxis:o,yAxis:i}=e,l=a?.colors||Ns,c=a?.height||300,d=a?.legend!==false,p=a?.grid!==false,y=a?.tooltip!==false,x=a?.animate!==false&&!r,v=a?.stacked||false,k=(()=>{if(t==="pie")return (n[0]?.data||[]).map((h,u)=>({name:h.name||h.x||`Item ${u+1}`,value:h.value??h.y??0}));let z=new Map;return n.forEach(f=>{f.data.forEach(h=>{let u=h.x??h.name;z.has(u)||z.set(u,{x:u}),z.get(u)[f.name]=h.y??h.value??0;});}),Array.from(z.values())})(),E={data:k,margin:{top:10,right:30,left:0,bottom:0}},M={fontSize:12},R={backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:8};return jsx("div",{className:"w-full",style:{height:c},children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:(()=>{switch(t){case "line":return jsxs(LineChart,{...E,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...M,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...M,tickLine:false,width:40}),y&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),n.map((z,f)=>jsx(Line,{type:"monotone",dataKey:z.name,stroke:z.color||l[f%l.length],strokeWidth:2,dot:false,activeDot:{r:4},isAnimationActive:x},z.name))]});case "bar":return jsxs(BarChart,{...E,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...M,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...M,tickLine:false,width:40}),y&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),n.map((z,f)=>jsx(Bar,{dataKey:z.name,fill:z.color||l[f%l.length],stackId:v?"stack":void 0,isAnimationActive:x,radius:[4,4,0,0]},z.name))]});case "area":return jsxs(AreaChart,{...E,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",...M,tickLine:false,padding:{left:10,right:10}}),jsx(YAxis,{...M,tickLine:false,width:40}),y&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),n.map((z,f)=>jsx(Area,{type:"monotone",dataKey:z.name,stroke:z.color||l[f%l.length],fill:z.color||l[f%l.length],fillOpacity:.3,stackId:v?"stack":void 0,isAnimationActive:x},z.name))]});case "pie":return jsxs(PieChart,{children:[y&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),jsx(Pie,{data:k,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:Math.min(c,300)/3,isAnimationActive:x,label:({name:z,percent:f})=>`${z}: ${((f??0)*100).toFixed(0)}%`,labelLine:false,children:k.map((z,f)=>jsx(Cell,{fill:l[f%l.length]},`cell-${f}`))})]});case "scatter":return jsxs(ScatterChart,{...E,children:[p&&jsx(CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb"}),jsx(XAxis,{dataKey:"x",type:"number",...M,tickLine:false,name:o?.label,padding:{left:10,right:10}}),jsx(YAxis,{...M,tickLine:false,name:i?.label,width:40}),y&&jsx(Tooltip,{contentStyle:R}),d&&jsx(Legend,{}),n.map((z,f)=>jsx(Scatter,{name:z.name,data:z.data.map(h=>({x:h.x,y:h.y})),fill:z.color||l[f%l.length],isAnimationActive:x},z.name))]});default:return null}})()||jsx(Fragment,{})})})}var Ds=new Set(["number","currency","date","badge","boolean","progress"]);function Cr(e){if(e==null)return "";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function As({text:e,anchorRect:a,onEnter:r,onLeave:t}){let[n,o]=useState(false);if(typeof document>"u")return null;let i=16,l=Math.min(360,window.innerWidth-2*i),c=window.innerHeight-a.bottom-i,d=c>=120||c>=a.top,p=a.left;p+l>window.innerWidth-i&&(p=Math.max(i,window.innerWidth-l-i));let y={position:"fixed",left:p,width:"max-content",maxWidth:l,maxHeight:"50vh",zIndex:9998,...d?{top:a.bottom+4}:{bottom:window.innerHeight-a.top+4}},x=async()=>{try{await navigator.clipboard.writeText(e),o(!0),window.setTimeout(()=>o(!1),1200);}catch{}};return createPortal(jsxs("div",{style:y,className:s("relative overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-900"),role:"tooltip",onMouseEnter:r,onMouseLeave:t,children:[jsx("div",{className:s("select-text overflow-auto px-2.5 py-1.5 pr-8 text-sm text-gray-900 dark:text-gray-100","whitespace-pre-wrap break-words"),style:{maxHeight:"50vh"},children:e||jsx("span",{className:"text-gray-400",children:"\u2014"})}),jsx("button",{type:"button",onClick:x,"aria-label":n?"Copied":"Copy",title:n?"Copied":"Copy",className:s("absolute bottom-1 right-1 flex h-6 w-6 items-center justify-center","rounded text-gray-500 transition-colors","hover:bg-gray-100 hover:text-gray-800","dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100"),children:n?jsx(Check,{size:12}):jsx(Copy,{size:12})})]}),document.body)}function Ms({item:e,onOpen:a}){if(e.mediaType==="video"){let r=e.url.match(Ve),t=r?r[1]:null,n=t?`https://i.ytimg.com/vi/${t}/hqdefault.jpg`:void 0;return jsxs("button",{type:"button",onClick:a,className:"relative block overflow-hidden rounded-md border-0 bg-black/5 p-0",style:{width:72,height:72},"aria-label":e.altText||"Open video",children:[n?jsx("img",{src:n,alt:e.altText||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-[10px] text-gray-400",children:"Video"}),jsx(et,{label:e.altText||"Open video"})]})}return jsx("button",{type:"button",onClick:a,className:"block overflow-hidden rounded-md border-0 bg-transparent p-0 transition-opacity hover:opacity-80",style:{width:72,height:72},"aria-label":e.altText||"Open image",children:jsx("img",{src:e.url,alt:e.altText||"Image",className:"h-full w-full object-cover",loading:"lazy"})})}var Rs={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 Sr(e,a){if(e==null)return 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=Rs[t]||"bg-gray-100 text-gray-700";return jsx("span",{className:s("inline-block px-2 py-0.5 rounded-full text-xs font-medium",n),children:String(e)})}case "link":return jsx("a",{href:String(e),target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline",children:String(e)});case "boolean":return e?jsx(Check,{size:18,className:"text-green-500"}):jsx(X,{size:18,className:"text-gray-400"});case "progress":{let t=typeof e=="number"?e:parseFloat(String(e));return jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"flex-1 h-2 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-blue-500 rounded-full",style:{width:`${Math.min(100,Math.max(0,t))}%`}})}),jsxs("span",{className:"text-xs text-gray-500",children:[t.toFixed(0),"%"]})]})}default:return String(e)}}function zr(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 Bt({data:e,config:a,medias:r}){let{columns:t,rows:n}=e,o=a?.sortable!==false,i=a?.paginated||false,l=a?.pageSize||10,[c,d]=useState("asc"),[p,y]=useState(t[0]?.key||""),[x,v]=useState(0),g=C=>{d(p===C&&c==="asc"?"desc":"asc"),y(C);},k=useMemo(()=>{let C=[...n];return o&&p&&C.sort((Y,D)=>c==="desc"?zr(Y,D,p):-zr(Y,D,p)),i&&(C=C.slice(x*l,(x+1)*l)),C},[n,c,p,x,l,o,i]),E=Math.ceil(n.length/l),M=useMemo(()=>{let C=[],Y={},D=t.filter(N=>N.type==="media");return D.length===0?{items:C,lookup:Y}:(k.forEach((N,L)=>{D.forEach(j=>{let X=N[j.key],te=ia(X,`${j.key}-${L}`,r);te&&(Y[`${L}::${j.key}`]=C.length,C.push(te));});}),{items:C,lookup:Y})},[k,t,r]),{index:R,open:T,close:z,navigate:f}=vt(M.items),[h,u]=useState(null),W=useRef(null),S=useRef(null),K=()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null);},Z=()=>{S.current!==null&&(window.clearTimeout(S.current),S.current=null);},Ie=(C,Y,D)=>{K(),Z(),W.current=window.setTimeout(()=>{u({rowIdx:C,colKey:Y,rect:D}),W.current=null;},250);},fe=()=>{K(),Z(),S.current=window.setTimeout(()=>{u(null),S.current=null;},150);},Pe=()=>{Z();};useEffect(()=>()=>{K(),Z();},[]),useEffect(()=>{R!==null&&(K(),Z(),u(null));},[R]);let ie=h&&t.find(C=>C.key===h.colKey),Le=h&&ie?Cr(k[h.rowIdx]?.[h.colKey]):"";return jsxs("div",{className:"w-full overflow-x-auto",children:[jsxs("table",{className:"min-w-full text-sm",children:[jsx("thead",{children:jsx("tr",{children:t.map(C=>jsx("th",{className:s("px-3 py-2 font-semibold bg-gray-50 dark:bg-gray-800 whitespace-nowrap text-left",o&&C.type!=="media"&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700"),style:{width:C.width,textAlign:C.align||"left"},onClick:()=>o&&C.type!=="media"&&g(C.key),children:jsxs("span",{className:"inline-flex items-center gap-1",children:[C.label,o&&C.type!=="media"&&p===C.key&&(c==="asc"?jsx(ChevronUp,{size:14}):jsx(ChevronDown,{size:14}))]})},C.key))})}),jsxs("tbody",{children:[k.map((C,Y)=>jsx("tr",{className:"border-t border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:t.map(D=>{if(D.type==="media"){let j=ia(C[D.key],`${D.key}-${Y}`,r);return jsx("td",{className:"px-3 py-2 align-middle",style:{textAlign:D.align||"left"},children:j?jsx(Ms,{item:j,onOpen:()=>{let X=M.lookup[`${Y}::${D.key}`];typeof X=="number"&&T(X);}}):jsx("span",{className:"text-gray-400",children:"-"})},D.key)}let N=Ds.has(D.type||"string"),L=Cr(C[D.key]);return jsx("td",{className:s("px-3 py-2 align-top",N?"max-w-[300px]":"max-w-[320px]"),style:{textAlign:D.align||"left"},onMouseEnter:j=>{if(!L)return;let X=j.currentTarget.getBoundingClientRect();Ie(Y,D.key,X);},onMouseLeave:()=>{fe();},children:N?jsx("div",{className:"overflow-hidden whitespace-nowrap text-ellipsis",children:Sr(C[D.key],D)}):jsx("div",{className:"whitespace-normal break-words [display:-webkit-box] [-webkit-line-clamp:2] [-webkit-box-orient:vertical] overflow-hidden",children:Sr(C[D.key],D)})},D.key)})},Y)),k.length===0&&jsx("tr",{children:jsx("td",{colSpan:t.length,className:"px-3 py-8 text-center text-gray-400",children:"No data available"})})]})]}),h&&ie&&R===null&&jsx(As,{text:Le,anchorRect:h.rect,onEnter:Pe,onLeave:fe}),R!==null&&jsx(xt,{items:M.items,index:R,onClose:z,onNavigate:f}),i&&n.length>l&&jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 text-sm",children:[jsxs("span",{className:"text-gray-500",children:[x*l+1,"-",Math.min((x+1)*l,n.length)," of ",n.length]}),jsxs("div",{className:"flex gap-1",children:[jsx("button",{onClick:()=>v(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"}),jsx("button",{onClick:()=>v(Math.min(E-1,x+1)),disabled:x>=E-1,className:"px-2 py-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-30",children:"Next"})]})]})]})}function Ft({data:e,config:a,onAction:r}){let{subtitle:t,imageUrl:n,sections:o,actions:i}=e,l=a?.collapsible||false,c=a?.initiallyCollapsed||false,[d,p]=useState(!c),y=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}}));},x=(g,k)=>jsxs("div",{className:s(k<o.length-1&&"mb-4"),children:[g.title&&jsx("h4",{className:"font-semibold text-sm mb-2",children:g.title}),g.items&&g.items.length>0&&jsx("div",{className:"space-y-1",children:g.items.map((E,M)=>jsxs("div",{className:"flex justify-between items-start gap-4",children:[jsx("span",{className:"text-sm text-gray-500 shrink-0",children:E.label}),jsx("span",{className:"text-sm font-medium text-right",children:E.value})]},M))}),g.content&&jsx(be,{children:g.content})]},k),v=jsxs(Fragment,{children:[n&&jsx("img",{src:n,alt:"",className:"w-full h-[140px] object-cover border-b border-gray-200 dark:border-gray-700"}),t&&jsx("p",{className:"text-sm text-gray-500 italic mb-4",children:t}),o.map((g,k)=>jsxs("div",{children:[x(g,k),k<o.length-1&&jsx("hr",{className:"my-4 border-gray-200 dark:border-gray-700"})]},k))]});return jsxs("div",{className:"w-full",children:[l&&jsxs("div",{className:"flex items-center justify-between mb-2 cursor-pointer",onClick:()=>p(!d),children:[jsx("span",{className:"text-sm text-gray-500",children:d?"Click to collapse":"Click to expand"}),jsx("button",{className:"p-1",children:d?jsx(ChevronUp,{size:18}):jsx(ChevronDown,{size:18})})]}),(!l||d)&&v,i&&i.length>0&&jsx("div",{className:"flex gap-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:i.map((g,k)=>jsxs("button",{onClick:()=>y(g.action),className:s("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")&&jsx(ExternalLink,{size:14,className:"inline ml-1"})]},k))})]})}var Us=["#3B82F6","#10B981","#F59E0B","#8B5CF6"];function Ks({metric:e,color:a,animate:r}){let t=e.trend==="up"?jsx(ArrowUp,{size:16,className:"text-green-500"}):e.trend==="down"?jsx(ChevronDown,{size:16,className:"text-red-500"}):e.trend==="neutral"?jsx(Circle,{size:14,className:"text-gray-400"}):null,n=e.trend==="up"?"text-green-500":e.trend==="down"?"text-red-500":"text-gray-500",o=e.sparkline?.map((i,l)=>({value:i,idx:l}));return jsxs("div",{className:"p-4 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 relative overflow-hidden",children:[o&&o.length>0&&jsx("div",{className:"absolute bottom-0 left-0 right-0 h-10 opacity-30",children:jsx(ResponsiveContainer,{width:"100%",height:"100%",children:jsx(AreaChart,{data:o,margin:{top:0,right:0,left:0,bottom:0},children:jsx(Area,{type:"monotone",dataKey:"value",stroke:e.color||a,fill:e.color||a,strokeWidth:1,isAnimationActive:r})})})}),jsxs("div",{className:"relative z-10",children:[jsx("span",{className:"text-xs text-gray-500 font-medium uppercase tracking-wider",children:e.label}),jsxs("div",{className:"flex items-baseline gap-1 mt-1",children:[jsx("span",{className:"text-2xl font-bold",children:e.value}),e.unit&&jsx("span",{className:"text-sm text-gray-500",children:e.unit})]}),(e.trend||e.change!==void 0&&e.change!==null)&&jsxs("div",{className:"flex items-center gap-1 mt-2",children:[t,e.change!==void 0&&e.change!==null&&jsx("span",{className:s("text-sm font-medium",n),children:typeof e.change=="number"?`${e.change>0?"+":""}${e.change}`:e.change}),e.changeLabel&&jsx("span",{className:"text-xs text-gray-500",children:e.changeLabel})]})]})]})}function $t({data:e,config:a,isStreaming:r=false}){let{metrics:t,layout:n="row"}=e,o=a?.colors||Us,i=a?.animate!==false&&!r,l=n==="grid";return jsx("div",{className:s("w-full",l?"grid grid-cols-1 sm:grid-cols-2 gap-4":"flex gap-4 flex-wrap"),children:t.map((c,d)=>jsx("div",{className:s(!l&&"flex-1 min-w-[200px]"),children:jsx(Ks,{metric:c,color:c.color||o[d%o.length],animate:i})},d))})}var el={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 jt({data:e}){let{code:a,language:r,lineNumbers:t=true,highlightLines:n=[],startLine:o=1}=e,[i,l]=useState(false),c=el[r.toLowerCase()]||r.toLowerCase(),d=async()=>{try{await navigator.clipboard.writeText(a),l(!0);}catch{}};return useEffect(()=>{if(i){let y=setTimeout(()=>l(false),2e3);return ()=>clearTimeout(y)}},[i]),jsxs("div",{className:"relative rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700",children:[jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 dark:bg-gray-900 border-b border-gray-700",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(FileText,{size:16,className:"text-gray-400"}),jsx("span",{className:"text-xs font-mono text-gray-400 lowercase",children:c})]}),jsx("button",{onClick:d,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-white/10 transition-colors text-gray-400 hover:text-gray-200",title:i?"Copied!":"Copy code",children:i?jsx(Check,{size:14,className:"text-green-400"}):jsx(Copy,{size:14})})]}),jsx(Prism,{language:c,style:oneDark,showLineNumbers:t,startingLineNumber:o,wrapLines:true,lineProps:y=>{let x={};return n.includes(y)&&(x.backgroundColor="rgba(59, 130, 246, 0.1)",x.display="block",x.borderLeft="3px solid #3B82F6",x.paddingLeft="8px",x.marginLeft="-11px"),{style:x}},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 Wt({data:e,config:a,isStreaming:r=false,onAction:t}){let{fields:n,submitAction:o}=e,i=a?.submitButtonText||"Submit",l=a?.cancelButtonText||"Cancel",[c,d]=useState(()=>{let f={};return n.forEach(h=>{h.defaultValue!==void 0?f[h.name]=h.defaultValue:h.type==="multiselect"?f[h.name]=[]:h.type==="checkbox"?f[h.name]=false:f[h.name]="";}),f}),[p,y]=useState({}),[x,v]=useState(false),g=(f,h)=>{d(u=>({...u,[f]:h})),p[f]&&y(u=>{let W={...u};return delete W[f],W});},k=()=>{let f={};return n.forEach(h=>{let u=c[h.name];if(h.required&&(u==null||u===""||Array.isArray(u)&&u.length===0)){f[h.name]=`${h.label} is required`;return}if(!(!u&&!h.required)){if(h.validation){let{min:W,max:S,pattern:K,message:Z}=h.validation;W!==void 0&&typeof u=="number"&&u<W&&(f[h.name]=Z||`Minimum value is ${W}`),S!==void 0&&typeof u=="number"&&u>S&&(f[h.name]=Z||`Maximum value is ${S}`),K&&typeof u=="string"&&!new RegExp(K).test(u)&&(f[h.name]=Z||"Invalid format");}h.type==="email"&&typeof u=="string"&&u&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)&&(f[h.name]="Invalid email address");}}),y(f),Object.keys(f).length===0},E=f=>{f.preventDefault(),k()&&(t?t({type:"form_submit",action:o||"",data:c}):window.dispatchEvent(new CustomEvent("visualization-form-submit",{detail:{action:o,data:c}})),v(true));},M=()=>{t?t({type:"form_cancel",action:o||""}):window.dispatchEvent(new CustomEvent("visualization-form-cancel",{detail:{action:o}}));};if(x)return jsxs("div",{className:"text-center py-8",children:[jsx("p",{className:"text-lg font-semibold text-green-500 mb-1",children:"Form Submitted"}),jsx("p",{className:"text-sm text-gray-500",children:"Your response has been recorded."})]});let R="w-full px-3 py-2 text-sm rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 outline-none transition-colors",T="border-red-500 focus:ring-red-500/20 focus:border-red-500",z=f=>{let h=c[f.name],W=!!p[f.name];switch(f.type){case "text":case "email":case "number":return jsx("input",{type:f.type,placeholder:f.placeholder,required:f.required,value:String(h||""),onChange:S=>g(f.name,f.type==="number"?parseFloat(S.target.value)||"":S.target.value),className:s(R,W&&T),min:f.validation?.min,max:f.validation?.max});case "textarea":return jsx("textarea",{placeholder:f.placeholder,required:f.required,value:String(h||""),onChange:S=>g(f.name,S.target.value),className:s(R,"min-h-[100px] resize-y",W&&T),rows:4});case "select":return jsxs("select",{value:String(h||""),onChange:S=>g(f.name,S.target.value),className:s(R,W&&T),children:[jsx("option",{value:"",disabled:true,children:f.placeholder||"Select an option"}),f.options?.map(S=>jsx("option",{value:S.value,children:S.label},S.value))]});case "multiselect":return jsx("select",{multiple:true,value:h||[],onChange:S=>g(f.name,Array.from(S.target.selectedOptions,K=>K.value)),className:s(R,"min-h-[80px]",W&&T),children:f.options?.map(S=>jsx("option",{value:S.value,children:S.label},S.value))});case "checkbox":return jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[jsx("input",{type:"checkbox",checked:!!h,onChange:S=>g(f.name,S.target.checked),className:"w-4 h-4 accent-blue-500 rounded"}),jsx("span",{className:"text-sm",children:f.label})]});case "radio":return jsx("div",{className:"space-y-1",children:f.options?.map(S=>jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[jsx("input",{type:"radio",name:f.name,value:S.value,checked:h===S.value,onChange:K=>g(f.name,K.target.value),className:"w-3.5 h-3.5 accent-blue-500"}),S.label]},S.value))});case "date":return jsx("input",{type:"date",value:String(h||""),onChange:S=>g(f.name,S.target.value),className:s(R,W&&T)});case "datetime":return jsx("input",{type:"datetime-local",value:String(h||""),onChange:S=>g(f.name,S.target.value),className:s(R,W&&T)});default:return null}};return jsxs("form",{onSubmit:E,className:"space-y-4",children:[n.map(f=>jsxs("div",{children:[f.type!=="checkbox"&&jsxs("label",{className:"block text-sm font-medium mb-1",children:[f.label,f.required&&jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),z(f),p[f.name]&&jsx("p",{className:"text-xs text-red-500 mt-1",children:p[f.name]})]},f.name)),jsxs("div",{className:"flex gap-2 pt-2",children:[jsx("button",{type:"submit",disabled: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:i}),jsx("button",{type:"button",onClick:M,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 Tr="__miiflow_visualization_registry__",Ht=globalThis[Tr]??(globalThis[Tr]=new Map);function He(e,a){Ht.set(e,a);}function Ut(e){return Ht.get(e)}function Er(){return Array.from(Ht.keys())}He("chart",{component:Vt});He("table",{component:Bt});He("card",{component:Ft});He("kpi",{component:$t});He("code_preview",{component:jt});He("form",{component:Wt});function Dr(e){for(let[a,r]of Object.entries(e)){let t=Ht.get(a);t&&(t.schema=r);}}var tl=z.object({name:z.string(),data:z.array(z.union([z.object({x:z.union([z.string(),z.number()]),y:z.number()}),z.object({name:z.string(),value:z.number()})])),color:z.string().nullish()}),Ar=z.object({label:z.string().nullish(),type:z.enum(["category","number","time"]).nullish(),min:z.number().nullish(),max:z.number().nullish()}),Na=z.object({chartType:z.enum(["line","bar","pie","area","scatter","composed"]),series:z.array(tl),xAxis:Ar.nullish(),yAxis:Ar.nullish()}),al=z.object({key:z.string(),label:z.string(),type:z.enum(["string","number","currency","date","badge","link","boolean","progress","media"]).nullish(),align:z.enum(["left","center","right"]).nullish(),width:z.string().nullish()}),Ca=z.object({columns:z.array(al),rows:z.array(z.record(z.string(),z.unknown()))}),rl=z.object({title:z.string().nullish(),items:z.array(z.object({label:z.string(),value:z.union([z.string(),z.number()])})).nullish(),content:z.string().nullish()}),nl=z.object({label:z.string(),action:z.string(),variant:z.enum(["primary","secondary","text"]).nullish()}),Sa=z.object({subtitle:z.string().nullish(),imageUrl:z.string().nullish(),sections:z.array(rl),actions:z.array(nl).nullish()}),ol=z.object({label:z.string(),value:z.union([z.string(),z.number()]),unit:z.string().nullish(),trend:z.enum(["up","down","neutral"]).nullish(),change:z.union([z.string(),z.number()]).nullish(),changeLabel:z.string().nullish(),sparkline:z.array(z.number()).nullish(),color:z.string().nullish()}),za=z.object({metrics:z.array(ol),layout:z.enum(["row","grid"]).nullish()}),Pa=z.object({code:z.string(),language:z.string(),lineNumbers:z.boolean().nullish(),highlightLines:z.array(z.number()).nullish(),startLine:z.number().nullish()}),il=z.object({name:z.string(),type:z.enum(["text","number","email","select","multiselect","checkbox","radio","textarea","date","datetime"]),label:z.string(),required:z.boolean().nullish(),placeholder:z.string().nullish(),options:z.array(z.object({value:z.string(),label:z.string()})).nullish(),defaultValue:z.unknown().nullish(),validation:z.object({min:z.number().nullish(),max:z.number().nullish(),pattern:z.string().nullish(),message:z.string().nullish()}).nullish()}),Ta=z.object({fields:z.array(il),submitAction:z.string().nullish()});Dr({chart:Na,table:Ca,card:Sa,kpi:za,code_preview:Pa,form:Ta});function ft({data:e,isStreaming:a=false,onAction:r,medias:t}){let{type:n,title:o,description:i,data:l,config:c}=e;return jsxs("div",{className:"my-3 overflow-hidden",children:[(o||i)&&jsxs("div",{className:"mb-2",children:[o&&jsx("p",{className:"text-sm font-semibold",children:o}),i&&jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:i})]}),jsx("div",{children:(()=>{let p=Ut(n);if(!p)return jsxs("div",{className:"flex items-center gap-2 p-4 text-yellow-500",children:[jsx(AlertCircle,{size:20}),jsxs("span",{className:"text-sm",children:["Unknown visualization type: ",n]})]});if(p.schema){let x=p.schema.safeParse(l);if(!x.success){let v=x.error.issues.slice(0,3);return jsxs("div",{className:"p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-950/30",children:[jsxs("div",{className:"flex items-center gap-2 text-red-600 dark:text-red-400 mb-2",children:[jsx(AlertCircle,{size:18}),jsxs("span",{className:"text-sm font-medium",children:["Invalid ",n," visualization data"]})]}),jsxs("ul",{className:"text-xs text-red-500 dark:text-red-400 space-y-1 list-disc list-inside",children:[v.map((g,k)=>jsxs("li",{children:[g.path.join("."),": ",g.message]},k)),x.error.issues.length>3&&jsxs("li",{children:["...and ",x.error.issues.length-3," more"]})]})]})}}let y=p.component;return jsx(y,{data:l,config:c,isStreaming:a,onAction:r,medias:t})})()})]})}function Kt({artifact:e,isStreaming:a,onOpen:r}){let t=e.status??"ready",n=t==="pending"||a&&t!=="failed",o=t==="failed",i=n||o;return jsxs("button",{type:"button",onClick:()=>{i||r?.(e);},disabled:i,"aria-label":o?`Artifact failed: ${e.title}`:`Open ${e.kind.toUpperCase()} artifact: ${e.title}`,"data-artifact-id":e.id,"data-artifact-status":t,style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",marginTop:"8px",background:o?"var(--miiflow-artifact-error-bg, #fdecea)":"var(--miiflow-artifact-bg, #f6f8fa)",border:"1px solid",borderColor:o?"var(--miiflow-artifact-error-border, #f1aeb5)":"var(--miiflow-artifact-border, #d0d7de)",borderRadius:"8px",font:"inherit",color:"inherit",textAlign:"left",cursor:i?o?"default":"progress":"pointer",width:"100%",maxWidth:"420px",opacity:n?.7:1},children:[jsx("span",{"aria-hidden":true,style:{fontSize:"22px",lineHeight:1,flex:"0 0 auto"},children:o?"\u26A0\uFE0F":"\u{1F4C4}"}),jsxs("span",{style:{flex:1,minWidth:0},children:[jsx("span",{style:{display:"block",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title}),jsx("span",{style:{display:"block",fontSize:"12px",color:o?"var(--miiflow-artifact-error-text, #b42318)":"var(--miiflow-artifact-meta, #57606a)"},children:o?e.errorMessage||"Generation failed":[e.kind.toUpperCase(),e.pageCount?`${e.pageCount} pages`:null,n?"generating\u2026":null].filter(Boolean).join(" \xB7 ")})]})]})}var Ir="__miiflow_artifact_registry__",Da=globalThis[Ir]??(globalThis[Ir]=new Map);function Lr(e,a){Da.set(e,a);}function qt(e){return Da.get(e)}function _r(){return Array.from(Da.keys())}function Gt({artifacts:e,isStreaming:a,onOpen:r}){return e?.length?jsx("div",{"data-artifact-list":true,style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(t=>{let o=qt(t.kind)?.InlineCard??Kt;return jsx(o,{artifact:t,isStreaming:a,onOpen:r},t.id)})}):null}var Br=/\[(VIZ|MEDIA|SA):([\w-]+)\]/gi;function Fr(e){let a=[],r=0,t;for(Br.lastIndex=0;(t=Br.exec(e))!==null;){if(t.index>r){let o=e.slice(r,t.index);o.trim()&&a.push({type:"text",content:o});}let n=t[1].toUpperCase();n==="VIZ"?a.push({type:"viz",id:t[2]}):n==="SA"?a.push({type:"sa",id:t[2]}):a.push({type:"media",id:t[2]}),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 cl=[/```/,/\[VIZ:/,/\[SA:/,/\[MEDIA:/,/!\[/,/<img\b/i];function dl(e){for(let a of cl)if(a.test(e))return false;return true}function Or(e,a,r){let[t,n]=useState(void 0);return useEffect(()=>{if(!r){n(void 0);return}let o=e.current;if(!o||!a||!dl(a))return;let i=false,l=()=>{if(i)return;let d=o.clientWidth;if(d<=0)return;let p=b(a,d);p&&n(y=>y===void 0||p.height>y?p.height:y);};l();let c=typeof ResizeObserver<"u"?new ResizeObserver(l):null;return c?.observe(o),()=>{i=true,c?.disconnect();}},[e,a,r]),t}var gl=({ytId:e,altText:a})=>{let[r,t]=useState(false),n=`https://i.ytimg.com/vi/${e}/hqdefault.jpg`;return jsxs("div",{className:"my-3",children:[jsx("div",{className:"relative w-full overflow-hidden rounded-lg",style:{maxWidth:640,aspectRatio:"16 / 9"},children:r?jsx("iframe",{src:`https://www.youtube.com/embed/${e}?autoplay=1`,title:a||"Video",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:true,className:"absolute inset-0 h-full w-full border-0"}):jsxs("button",{type:"button",onClick:()=>t(true),className:"absolute inset-0 block border-0 bg-transparent p-0","aria-label":a||"Play video",children:[jsx("img",{src:n,alt:a||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}),jsx(et,{label:a||"Play video"})]})}),a&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:a})]})},fl=({url:e,posterUrl:a,altText:r})=>{let[t,n]=useState(false);return jsxs("div",{className:"my-3",children:[jsx("div",{className:"relative overflow-hidden rounded-lg",style:{maxWidth:640,maxHeight:512},children:t?jsxs("video",{controls:true,autoPlay:true,preload:"metadata",className:"block max-h-[512px] w-full rounded-lg",poster:a,children:[jsx("source",{src:e}),"Your browser does not support the video tag."]}):jsxs("button",{type:"button",onClick:()=>n(true),className:"block w-full border-0 bg-transparent p-0","aria-label":r||"Play video",children:[a?jsx("img",{src:a,alt:r||"Video preview",className:"block max-h-[512px] w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex w-full items-center justify-center bg-gray-900 text-gray-400",style:{aspectRatio:"16 / 9"},children:jsx("span",{className:"text-sm",children:"Click to load video"})}),jsx(et,{label:r||"Play video"})]})}),r&&jsx("div",{className:"mt-1 text-xs text-gray-500",children:r})]})},bl=({media:e,onOpen:a})=>{if(e.mediaType==="video"){let r=e.url.match(Ve),t=r?r[1]:null,n=t?`https://i.ytimg.com/vi/${t}/hqdefault.jpg`:void 0;return jsxs("button",{type:"button",onClick:a,className:s("relative block w-full overflow-hidden rounded-lg border-0 bg-black/5 p-0","aspect-square cursor-pointer transition-opacity hover:opacity-90"),style:{aspectRatio:"1 / 1"},"aria-label":e.altText||"Open video",children:[n?jsx("img",{src:n,alt:e.altText||"Video preview",className:"h-full w-full object-cover",loading:"lazy"}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-900 text-xs text-gray-400",children:"Video"}),jsx(et,{label:e.altText||"Open video"})]})}return jsx("button",{type:"button",onClick:a,className:s("block w-full overflow-hidden rounded-lg border-0 bg-transparent p-0","aspect-square cursor-pointer transition-opacity hover:opacity-90"),style:{aspectRatio:"1 / 1"},"aria-label":e.altText||"Open image",children:jsx("img",{src:e.url,alt:e.altText||"Image",className:"h-full w-full object-cover",loading:"lazy"})})},Wr=forwardRef(({message:e,viewerRole:a$1="user",className:r,showAvatar:t=true,showTimestamp:n=true,renderMarkdown:o=true,reasoning:i,executionPlan:l,executionTimeline:c$1,suggestedActions:d$1,onSuggestedAction:p,reasoningExpanded:y,onReasoningExpandedChange:x,citations:v,visualizations:g,medias:k,artifacts:E,onArtifactOpen:M,baselineFontSize:R,executionTime:T,pendingClarification:z,onClarificationSubmit:f,pendingToolApproval:h,onToolApprove:u,onToolReject:W,renderInlineSuggestedAction:S,onReportIncorrect:K,onConfirmCorrect:Z},Ie)=>{let Pe=useContext(a)?.onVisualizationAction,ie=(e.participant?.role||"").toLowerCase(),Le=(a$1||"").toLowerCase(),C=ie===Le,Y=ie==="assistant",D=e.isStreaming,N=i?.filter(A=>A.type==="thinking"||A.type==="tool"||A.type==="observation"||A.type==="planning"||A.type==="subtask"||A.type==="wave_start"||A.type==="wave_complete"||A.type==="parallel_subtask_start"||A.type==="parallel_subtask_complete"||A.type==="multi_agent_planning"||A.type==="subagent_start"||A.type==="subagent_complete"||A.type==="subagent_failed"||A.type==="synthesis"||A.type==="claude_thinking"||A.type==="subagent"||A.type==="file_operation"||A.type==="terminal"||A.type==="search_results"||A.type==="web_operation"||A.claudeToolData!=null),L=N&&N.length>0,j=!D&&(l||c$1&&c$1.length>0),X=L||j,te=D&&!e.textContent&&!X,b=e.attachments,V=b&&b.length>0,P=useMemo(()=>{if(!g||g.length===0)return null;let A=new Map;return g.forEach(B=>A.set(B.id,B)),A},[g]),pe=P&&P.size>0||e.textContent&&/\[SA:[\w-]+\]/i.test(e.textContent),ve=useMemo(()=>!pe||!e.textContent?null:Fr(e.textContent),[pe,e.textContent]),ot=useMemo(()=>!k||k.length===0||!e.textContent?e.textContent:e.textContent.replace(/\[MEDIA:[a-f0-9-]+\]/gi,"").trim(),[e.textContent,k]),an=()=>{if(!e.textContent)return null;if(ve&&ve.length>0&&pe){let A=new Set;return jsx(Fragment,{children:ve.map((B,_e)=>{if(B.type==="text")return D?jsx(dt,{content:B.content,isStreaming:true,baselineFontSize:R},_e):jsx(be,{baselineFontSize:R,className:C?"prose-invert":"",children:B.content},_e);if(B.type==="viz"){if(A.has(B.id))return null;let Wa=P?.get(B.id);return Wa?(A.add(B.id),jsx(ft,{data:Wa,isStreaming:D,onAction:Pe,medias:k},`viz-${B.id}`)):null}return B.type==="sa"&&S?jsx("div",{children:S(B.id)},`sa-${B.id}`):null})})}return D&&o?jsx(dt,{content:ot||"",isStreaming:true,baselineFontSize:R,className:C?"prose-invert":""}):o?jsx(be,{baselineFontSize:R,className:C?"prose-invert":"",children:ot||""}):jsx("p",{className:"whitespace-pre-wrap",children:ot})},Je=useMemo(()=>{if(!k||k.length===0)return [];let A=ot||"";return k.filter(B=>B.mediaType!=="image"?true:!A.includes(B.url)).map(B=>({id:B.id,url:B.url,mediaType:B.mediaType,altText:B.altText}))},[k,ot]),{index:Ba,open:Fa,close:rn,navigate:nn}=vt(Je),on=()=>{if(Je.length===0)return null;if(Je.length>=2)return jsx("div",{className:"my-3 grid gap-2",style:{gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",maxWidth:640},children:Je.map((B,_e)=>jsx(bl,{media:B,onOpen:()=>Fa(_e)},`media-${B.id}`))});let A=Je[0];if(A.mediaType==="image")return jsx("div",{className:"my-3",children:jsx("button",{type:"button",onClick:()=>Fa(0),className:"block cursor-zoom-in border-0 bg-transparent p-0","aria-label":A.altText||"Open image",children:jsx("img",{src:A.url,alt:A.altText||"Generated image",className:"max-w-full rounded-lg",loading:"lazy",style:{maxHeight:512,display:"block"}})})});if(A.mediaType==="video"){let B=A.url.match(Ve);return B?jsx(gl,{ytId:B[1],altText:A.altText},`media-${A.id}`):jsx(fl,{url:A.url,posterUrl:A.posterUrl,altText:A.altText},`media-${A.id}`)}return null},Oa=useRef(D);D&&(Oa.current=true);let sn=!D&&!Oa.current,$a=useRef(null),ja=Or($a,e.textContent,!!D);return jsx(c,{ref:Ie,message:e,viewerRole:a$1,className:s("w-full",sn&&"animate-message-in",r),children:jsxs("div",{className:s("flex flex-col gap-1 w-full"),"data-is-viewer":C,children:[te&&jsxs("div",{className:s("flex items-start gap-2 w-full"),children:[t&&!C&&jsx("div",{className:"flex-shrink-0",children:jsx(Fe,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"px-4 py-3",children:jsx(it,{size:"small"})})]}),X&&Y&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(xa,{isStreaming:D,chunks:N,plan:l,executionTimeline:c$1,userMessageTimestamp:e.createdAt?new Date((typeof e.createdAt=="string",e.createdAt)).getTime()/1e3:void 0,executionTime:T,expanded:y,onExpandedChange:x})}),e.textContent&&jsxs("div",{className:s("group flex items-start gap-2 w-full",C?"flex-row-reverse":"flex-row"),children:[t&&!C&&jsx("div",{className:"flex-shrink-0",children:jsx(Fe,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})}),jsxs("div",{ref:$a,className:s("max-w-[85%]","flex flex-col"),"data-message-role":C?"viewer":"other",style:ja?{minHeight:ja}:void 0,children:[jsxs("div",{className:s("rounded-2xl",C||t?"px-4 py-3":""),style:{backgroundColor:C?"var(--chat-user-message-bg)":"transparent",color:C?"var(--chat-user-message-text, #ffffff)":"var(--chat-text)"},children:[jsx(d,{children:an()}),on(),Ba!==null&&jsx(xt,{items:Je,index:Ba,onClose:rn,onNavigate:nn}),g&&g.length>0&&(()=>{let A=e.textContent||"",B=g.filter(_e=>!A.includes(`[VIZ:${_e.id}]`));return B.length===0?null:B.map(_e=>jsx("div",{className:"my-3",children:jsx(ft,{data:_e,isStreaming:D,onAction:Pe,medias:k})},`viz-unreferenced-${_e.id}`))})(),E&&E.length>0&&jsx("div",{className:"mt-2",children:jsx(Gt,{artifacts:E,isStreaming:D,onOpen:M})}),v&&v.length>0&&jsx("div",{className:"mt-2 pt-2 border-t border-[var(--chat-border)]",children:jsx(sa,{sources:v})})]}),V&&jsx("div",{className:"mt-2",children:jsx(fa,{attachments:b})}),!D&&(n&&e.createdAt||Y&&e.textContent)&&jsxs("div",{className:s("flex items-center gap-2 mt-1",C&&"flex-row-reverse"),children:[n&&e.createdAt&&jsx(hl,{createdAt:typeof e.createdAt=="string"?e.createdAt:e.createdAt.toISOString(),isViewer:C}),Y&&e.textContent&&jsx(ua,{textContent:e.textContent,onReportIncorrect:K,onConfirmCorrect:Z})]})]})]}),e.error&&jsxs("div",{className:s("flex items-start gap-2 w-full max-w-[85%]","rounded-lg border px-3 py-2 mt-1"),style:{borderColor:"var(--chat-error, #B1001B)",backgroundColor:"color-mix(in srgb, var(--chat-error, #B1001B) 6%, transparent)",color:"var(--chat-error, #B1001B)"},children:[jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 mt-0.5",children:[jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),jsx("span",{className:"text-sm",children:e.error.message})]}),!e.textContent&&t&&!C&&X&&!te&&jsx("div",{className:"flex items-start gap-2 w-full",children:jsx("div",{className:"flex-shrink-0",children:jsx(Fe,{name:e.participant?.name,src:e.participant?.avatarUrl,role:e.participant?.role,className:"w-10 h-10 flex-shrink-0"})})}),z&&!D&&f&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(la,{clarification:z,onSubmit:f})}),h&&!D&&u&&W&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(pa,{approval:h,onApprove:u,onReject:W})}),d$1&&d$1.length>0&&!D&&jsx("div",{className:"w-full max-w-[80%]",children:jsx(Rt,{actions:d$1,onSelect:p})})]})})});Wr.displayName="Message";function hl({createdAt:e}){return jsx("span",{className:"text-xs text-[var(--chat-text-subtle)]",children:(r=>{try{return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return ""}})(e)})}var Tl=100*1024*1024,El=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/svg+xml","image/bmp"],Dl=["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"],Al=["video/mp4","video/webm","video/ogg","video/avi","video/mov","video/wmv","video/flv","video/mkv"],Ml=[...El,...Dl,...Al];function Ur(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 Rl(e,a,r){return e.size>r?`File size (${Ur(e.size)}) exceeds max (${Ur(r)})`:a.includes(e.type)?null:`File type ${e.type||"unknown"} is not allowed`}function Il({attachments:e,onRemove:a,disabled:r}){return e.length===0?null: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/"),o=t.status==="error",i=t.status==="uploading";return jsxs("div",{className:s("relative flex items-center gap-1.5 px-2 py-1.5 rounded-lg text-xs max-w-[200px]",o?"bg-red-50 dark:bg-red-900/30 text-red-600 dark:text-red-400":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[i?jsx(Loader2,{size:14,className:"flex-shrink-0 animate-spin"}):o?jsx(AlertCircle,{size:14,className:"flex-shrink-0"}):n&&t.previewUrl?jsx("img",{src:t.previewUrl,alt:t.file.name,className:"w-5 h-5 rounded object-cover"}):n?jsx(Image,{size:14,className:"flex-shrink-0"}):jsx(FileText,{size:14,className:"flex-shrink-0"}),jsx("span",{className:"truncate",title:o?t.error:t.file.name,children:o?t.error:t.file.name}),!r&&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:jsx(X,{size:12})})]},t.id)})})}var qr=forwardRef(({onSubmit:e,onAttach:a,onUploadFile:r,onRemoveUploadedAttachment:t,disabled:n=false,supportsAttachments:o=true,allowedFileTypes:i=Ml,maxFileSize:l=Tl,placeholder:c="Type a message...",className:d,isSubmitting:p=false,centered:y=false,isStreaming:x=false,onStopStreaming:v},g)=>{let[k,E]=useState(""),[M,R]=useState([]),[T,z]=useState(false),f=useRef(null),h=useRef(null),u=useRef(0),W=useRef(false),S=n||p,K=M.some(b=>b.status==="uploading"),Z=M.filter(b=>b.status==="uploaded"&&b.attachmentId).map(b=>b.attachmentId),Ie=Z.length>0||M.some(b=>b.status==="pending"),fe=k.trim().length>0||Ie,Pe=useCallback(()=>{let b=h.current;b&&(b.style.height="auto",b.style.height=Math.min(b.scrollHeight,200)+"px");},[]);useEffect(()=>{Pe();},[k,Pe]);let ie=useCallback(async b=>{let V=b.map(P=>{let H=Rl(P,i,l),pe={id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:P,status:H?"error":r?"uploading":"pending",error:H||void 0};return !H&&P.type.startsWith("image/")&&(pe.previewUrl=URL.createObjectURL(P)),pe});if(R(P=>[...P,...V]),a?.(b),r){for(let P of V)if(P.status==="uploading")try{let H=await r(P.file);R(pe=>pe.map(ve=>ve.id===P.id?{...ve,status:"uploaded",attachmentId:H}:ve));}catch(H){R(pe=>pe.map(ve=>ve.id===P.id?{...ve,status:"error",error:H instanceof Error?H.message:"Upload failed"}:ve));}}},[i,l,r,a]),Le=useCallback(async()=>{if(!fe||S||K||W.current)return;W.current=true;let b=k,V=M.filter(H=>H.status!=="error").map(H=>H.file),P=M;E(""),R([]);try{r&&Z.length>0?await e(b,void 0,Z):await e(b,V.length>0?V:void 0);}catch{E(b),R(P);}finally{W.current=false;}},[k,M,fe,S,K,e,r,Z]),C=useCallback(b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),!S&&!K&&Le());},[Le,S,K]),Y=useCallback(b=>{let V=b.target.files;!V||V.length===0||(ie(Array.from(V)),b.target.value="");},[ie]),D=useCallback(b=>{if(!o||p)return;let V=b.clipboardData;if(!V)return;let P=[];for(let H of V.files)P.push(H);if(P.length===0&&V.items){for(let H of V.items)if(H.kind==="file"){let pe=H.getAsFile();pe&&P.push(pe);}}P.length>0&&(b.preventDefault(),ie(P));},[o,p,ie]),N=useCallback(b=>{R(V=>{let P=V.find(H=>H.id===b);return P?.previewUrl&&URL.revokeObjectURL(P.previewUrl),P?.attachmentId&&t&&t(P.attachmentId),V.filter(H=>H.id!==b)});},[t]),L=useCallback(b=>{b.preventDefault(),b.stopPropagation(),!(!o||p)&&(u.current++,b.dataTransfer.types.includes("Files")&&z(true));},[o,p]),j=useCallback(b=>{b.preventDefault(),b.stopPropagation(),u.current--,u.current===0&&z(false);},[]),X=useCallback(b=>{b.preventDefault(),b.stopPropagation();},[]),te=useCallback(b=>{if(b.preventDefault(),b.stopPropagation(),u.current=0,z(false),!o||p)return;let V=Array.from(b.dataTransfer.files);V.length>0&&ie(V);},[o,p,ie]);return useEffect(()=>()=>{M.forEach(b=>{b.previewUrl&&URL.revokeObjectURL(b.previewUrl);});},[]),jsx("div",{ref:g,className:s("flex-shrink-0",y?"p-0 bg-transparent":"px-3 pb-3",d),style:y?{padding:0,background:"transparent",border:"none"}:void 0,onDragEnter:L,onDragLeave:j,onDragOver:X,onDrop:te,children:jsxs("div",{className:s("mx-auto max-w-[900px]","bg-white dark:bg-zinc-800","transition-all duration-200",y?"":"rounded-xl border border-gray-200 dark:border-zinc-700 shadow-sm focus-within:shadow-md focus-within:border-gray-300 dark:focus-within:border-zinc-600",T&&"ring-2 ring-blue-400 border-blue-400"),style:y?{borderRadius:"1rem",overflow:"hidden",backgroundColor:"var(--chat-composer-bg, #ffffff)",border:"1px solid var(--chat-composer-border, rgba(0,0,0,0.06))",boxShadow:"var(--chat-composer-shadow, 0 8px 30px rgba(0,0,0,0.08))"}:void 0,children:[T&&jsx("div",{className:"px-3 pt-3 pb-0",children:jsx("div",{className:"flex items-center justify-center py-4 rounded-lg border-2 border-dashed border-blue-300 bg-blue-50 dark:bg-blue-900/20 text-blue-500 text-sm",children:"Drop files here"})}),jsx(Il,{attachments:M,onRemove:N,disabled:p}),jsxs("div",{className:s("flex items-center gap-2",y?"p-4":"p-3",M.length>0&&"pt-1.5"),style:y?{padding:"1rem"}:void 0,children:[o&&jsx("button",{type:"button",onClick:()=>f.current?.click(),disabled:p,className:s("flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","border border-gray-200 dark:border-zinc-600","text-gray-500 dark:text-zinc-400","hover:bg-gray-50 dark:hover:bg-zinc-700","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),children:jsx(Paperclip,{size:16})}),jsx("div",{className:"flex-1 min-w-0 flex items-center",children:jsx("textarea",{ref:h,value:k,onChange:b=>E(b.target.value),onKeyDown:C,onPaste:D,disabled:S,placeholder:c,rows:1,className:s("w-full resize-none outline-none","p-0 border-0 shadow-none","min-h-[24px] max-h-[200px]","text-sm leading-relaxed","text-gray-900 dark:text-zinc-100","placeholder:text-gray-400 dark:placeholder:text-zinc-500","bg-transparent","disabled:opacity-50 disabled:cursor-not-allowed")})}),x&&v?jsxs("div",{className:"relative flex-shrink-0 w-9 h-9",children:[jsx("span",{className:"absolute inset-0 rounded-lg bg-gray-400 dark:bg-zinc-400",style:{animation:"streaming-flash 3s ease-in-out infinite"}}),jsx("button",{type:"button",onClick:v,className:s("relative w-full h-full rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-100 text-white dark:text-zinc-900","hover:bg-gray-700 dark:hover:bg-zinc-300","transition-colors duration-200"),children:jsx(Square,{size:14,fill:"currentColor"})})]}):jsx("button",{type:"button",onClick:Le,disabled:!fe||S||K,className:s("flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-100 text-white dark:text-zinc-900","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-300 hover:shadow-md","active:shadow-sm","disabled:bg-gray-200 dark:disabled:bg-zinc-700 disabled:text-gray-400 dark:disabled:text-zinc-500 disabled:shadow-none disabled:cursor-not-allowed","transition-all duration-200"),children:p||K?jsx(Loader2,{size:16,className:"animate-spin"}):jsx(ArrowUp,{size:16})})]}),o&&jsx("input",{ref:f,type:"file",multiple:true,accept:i.join(","),onChange:Y,className:"hidden"})]})})});qr.displayName="MessageComposer";function Ra({isAtBottom:e,onScrollToBottom:a,className:r}){return jsx("button",{type:"button",onClick:a,"aria-label":"Scroll to bottom",className:s("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center","w-8 h-8 rounded-full","bg-[var(--chat-bg,#ffffff)] border border-[var(--chat-border)]","shadow-subtle hover:shadow-button-hover","text-[var(--chat-text-subtle)] hover:text-[var(--chat-text)]","transition-all duration-200",e?"opacity-0 pointer-events-none translate-y-2":"opacity-100 translate-y-0",r),children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M12 5v14"}),jsx("path",{d:"m19 12-7 7-7-7"})]})})}var Yr=forwardRef(({children:e,autoScroll:a=true,showScrollToBottom:r=true,className:t},n)=>{let{containerRef:o,scrollToBottom:i,isAtBottom:l}=a$1({enabled:a});return jsxs("div",{className:"relative flex-1 overflow-hidden",style:{mask:"linear-gradient(to bottom, black 0%, black calc(100% - 20px), transparent 100%)",WebkitMask:"linear-gradient(to bottom, black 0%, black calc(100% - 20px), transparent 100%)"},children:[jsx("div",{ref:d=>{o.current=d,typeof n=="function"?n(d):n&&(n.current=d);},className:s("h-full overflow-y-auto","flex flex-col gap-4 p-4 pb-12","chat-scrollbar",t),children:e}),r&&jsx(Ra,{isAtBottom:l,onScrollToBottom:()=>i("smooth")})]})});Yr.displayName="MessageList";function Bl({label:e,className:a}){return jsxs("div",{className:`flex items-center gap-3 py-6 select-none ${a??""}`,role:"separator",children:[jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"}),jsx("span",{className:"text-xs font-medium text-[var(--chat-text-subtle)] whitespace-nowrap",children:e}),jsx("div",{className:"flex-1 h-px bg-[var(--chat-border)]"})]})}var Zr=forwardRef(({className:e},a)=>jsx(r,{ref:a,className:s("inline-flex items-center gap-1","px-4 py-3",e),children:jsx(it,{size:"small"})}));Zr.displayName="TypingIndicator";function Ul({title:e,subtitle:a,logo:r,actions:t,showClose:n,onClose:o,loading:i,className:l,style:c}){let[d,p]=useState(false),y=useRef(null),x=useRef(null);return useEffect(()=>{let v=g=>{let k=g.composedPath();y.current&&!k.includes(y.current)&&x.current&&!k.includes(x.current)&&p(false);};if(d)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]),jsxs("header",{className:s("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:c,children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[r&&jsx("div",{className:"flex-shrink-0",children:typeof r=="string"?jsx("img",{src:r,alt:"",className:"w-10 h-10 rounded-lg object-contain"}):r}),jsxs("div",{className:"flex flex-col min-w-0",children:[i?jsx("div",{className:"h-5 w-24 bg-gray-200 rounded animate-pulse"}):jsx("h1",{className:"text-lg font-semibold text-[var(--chat-text)] truncate",children:e}),a&&jsx("p",{className:"text-sm text-[var(--chat-text-subtle)] truncate",children:a})]})]}),jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t&&t.length>0&&jsxs("div",{className:"relative",children:[jsx("button",{ref:x,onClick:()=>p(!d),className:s("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Menu","aria-expanded":d,children:jsx(MoreVertical,{size:18})}),d&&jsx("div",{ref:y,className:s("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=>jsxs("button",{onClick:()=>{v.onClick(),p(false);},disabled:v.disabled,className:s("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&&jsx("span",{className:"flex-shrink-0 text-[var(--chat-text-subtle)]",children:v.icon}),v.label]},v.id))})]}),n&&o&&jsx("button",{onClick:o,className:s("p-2 rounded-lg","text-[var(--chat-text-subtle)]","hover:bg-[var(--chat-panel-bg)] hover:text-[var(--chat-text)]","transition-colors duration-200"),"aria-label":"Close",children:jsx(X,{size:18})})]})]})}function Kl({toolName:e,status:a,description:r,className:t}){return jsxs("div",{className:s("relative flex items-center gap-2 py-1 px-2 rounded-md text-sm overflow-hidden",a==="running"&&"animate-shimmer",t),children:[jsx(ql,{status:a}),jsx("span",{className:"font-medium text-[var(--chat-text)]",children:e}),r&&jsx("span",{className:"text-[var(--chat-text-subtle)] truncate",children:r})]})}function ql({status:e}){switch(e){case "running":return jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin text-[var(--chat-primary)]",children:jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})});case "complete":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-secondary,#56C18A)]",children:[jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]});case "failed":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-error,#B1001B)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]});case "pending":return jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[var(--chat-text-subtle)]",children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("polyline",{points:"12 6 12 12 16 14"})]})}}var Qr=forwardRef(({isEmpty:e,header:a,welcomeScreen:r,messageList:t,composer:n,footer:o,className:i},l)=>jsx("div",{ref:l,"data-chat-ui":true,className:s("relative h-full overflow-hidden flex flex-col min-h-0",i),children:jsx(AnimatePresence,{mode:"wait",children:e&&r?jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,r]},"welcome"):jsxs(motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.4},className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[a,jsx(motion.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1},className:"flex-1 overflow-hidden flex flex-col min-h-0",children:t}),jsxs(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},className:"relative z-10",children:[o,n]})]},"active")})}));Qr.displayName="ChatLayout";function ec(e,a=3e3){let[r,t]=useState(0),n=useRef(null);return useEffect(()=>{if(e.length<=1)return;let o=()=>{n.current=setInterval(()=>{t(l=>(l+1)%e.length);},a);},i=()=>{document.visibilityState!=="visible"?n.current&&(clearInterval(n.current),n.current=null):o();};return o(),document.addEventListener("visibilitychange",i),()=>{n.current&&clearInterval(n.current),document.removeEventListener("visibilitychange",i);}},[e,a]),e[r]??""}function tc({placeholder:e,onSubmit:a,disabled:r,supportsAttachments:t}){let[n,o]=useState(""),[i,l]=useState([]),c=useRef(null),d=useRef(null);useEffect(()=>{c.current&&(c.current.style.height="auto",c.current.style.height=c.current.scrollHeight+"px");},[n]);let p=g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),y());},y=()=>{!n.trim()&&i.length===0||r||(a(n.trim(),i.length>0?i:void 0),o(""),l([]));},x=g=>{g.target.files&&l(k=>[...k,...Array.from(g.target.files)]),g.target.value="";},v=g=>{l(k=>k.filter((E,M)=>M!==g));};return jsxs("form",{className:s("w-full relative mx-auto","rounded-2xl overflow-hidden","transition duration-200"),style:{borderRadius:"1rem",overflow:"hidden",backgroundColor:"var(--chat-composer-bg, #ffffff)",border:"1px solid var(--chat-composer-border, rgba(0,0,0,0.06))",boxShadow:"var(--chat-composer-shadow, 0 8px 30px rgba(0,0,0,0.08))"},onSubmit:g=>{g.preventDefault(),y();},children:[i.length>0&&jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3",children:i.map((g,k)=>jsxs("div",{className:s("flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs","bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-zinc-300"),children:[jsx("span",{className:"max-w-[120px] truncate",children:g.name}),jsx("button",{type:"button",onClick:()=>v(k),className:"flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-zinc-200",children:jsx(X,{size:12})})]},`${g.name}-${k}`))}),jsxs("div",{className:"flex items-center gap-2",style:{padding:"0.25rem 0"},children:[t&&jsx("button",{type:"button",onClick:()=>d.current?.click(),disabled:r,className:s("ml-3 flex-shrink-0","w-8 h-8 rounded-lg","flex items-center justify-center","text-gray-400 dark:text-zinc-500","hover:bg-gray-100 dark:hover:bg-zinc-700","hover:text-gray-600 dark:hover:text-zinc-300","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors"),style:{marginLeft:"0.75rem"},children:jsx(Paperclip,{size:16})}),jsx("textarea",{ref:c,value:n,onChange:g=>o(g.target.value),onKeyDown:p,disabled:r,rows:1,placeholder:e,className:s("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"),style:{padding:"1rem 0.25rem",border:"none",background:"transparent",outline:"none",resize:"none"}}),jsx("button",{type:"submit",disabled:!n.trim()&&i.length===0||!!r,className:s("mr-3 flex-shrink-0","w-9 h-9 rounded-lg","flex items-center justify-center","bg-gray-900 dark:bg-zinc-600 text-white dark:text-zinc-100","shadow-sm","hover:bg-gray-700 dark:hover:bg-zinc-500","hover:shadow-md hover:-translate-y-px","active:translate-y-0 active:shadow-sm","disabled:bg-gray-300 dark:disabled:bg-zinc-700","disabled:text-gray-500 dark:disabled:text-zinc-400","disabled:shadow-none disabled:translate-y-0 disabled:cursor-not-allowed","transition-all duration-200"),style:{marginRight:"0.75rem",width:"2.25rem",height:"2.25rem",borderRadius:"0.5rem"},children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]}),t&&jsx("input",{ref:d,type:"file",multiple:true,onChange:x,className:"hidden"})]})}function ac({text:e,onClick:a,index:r}){let t=useRef(null),n=useRef(typeof window<"u"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),[o,i]=useState(null),l=useCallback(d=>{if(n.current)return;let p=d.currentTarget.getBoundingClientRect();i({x:d.clientX-p.left,y:d.clientY-p.top});},[]),c=useCallback(()=>{i(null);},[]);return jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2+r*.1,duration:.4},children:jsxs("button",{ref:t,type:"button",onClick:a,onMouseMove:l,onMouseLeave:c,className:s("relative overflow-hidden","w-full text-left","p-3","cursor-pointer","border border-gray-200 dark:border-zinc-700","rounded-lg","transition-all duration-200 ease-out","bg-white dark:bg-zinc-800","hover:border-gray-300 dark:hover:border-zinc-600","hover:bg-gray-50 dark:hover:bg-zinc-750","hover:shadow-sm","active:bg-gray-100 dark:active:bg-zinc-700"),children:[o&&jsx("div",{className:"pointer-events-none absolute inset-0 z-0",style:{background:`radial-gradient(120px circle at ${o.x}px ${o.y}px, var(--chat-halo-primary, rgba(16,105,151,0.06)), transparent)`}}),jsxs("div",{className:"relative z-10 flex items-start gap-2.5",children:[jsx(MessageCircleQuestion,{size:16,strokeWidth:2,className:"mt-0.5 text-gray-400 dark:text-zinc-500 flex-shrink-0"}),jsx("span",{className:"text-sm text-gray-600 dark:text-zinc-300 leading-relaxed flex-1",children:e})]})]})})}var tn=forwardRef(({placeholders:e=[],suggestions:a=[],onSubmit:r,onSuggestionClick:t,welcomeText:n="How can I help you today?",supportsAttachments:o,composerSlot:i,className:l,assistantAvatar:c,assistantName:d},p)=>{let y=ec(e),x=useCallback(v=>{t?.(v);},[t]);return jsxs("div",{ref:p,className:s("relative overflow-hidden","flex-1 flex items-center justify-center","px-4 sm:px-6",l),children:[jsx("div",{className:"pointer-events-none absolute inset-0 animate-welcome-halo",style:{background:"radial-gradient(ellipse 60% 50% at 50% 45%, var(--chat-halo-primary, rgba(16,105,151,0.06)), var(--chat-halo-secondary, rgba(86,193,138,0.03)) 60%, transparent 100%)"}}),jsxs(motion.div,{layout:true,initial:{scale:.95,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},transition:{type:"spring",stiffness:200,damping:25},className:"relative w-full max-w-[800px] flex flex-col items-center gap-8",children:[n&&c?jsxs(motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"flex items-start gap-2 w-full",children:[jsx("div",{className:"flex-shrink-0",children:jsx(Fe,{name:d,src:c,role:"assistant",className:"w-10 h-10 flex-shrink-0"})}),jsx("div",{className:"rounded-2xl px-4 py-3",children:jsx("p",{style:{fontSize:"1rem",lineHeight:"1.5rem"},className:"text-base text-gray-800 dark:text-white",children:n})})]}):n?jsx(motion.h2,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},style:{fontSize:"1.5rem",lineHeight:"2rem",fontWeight:600},className:"text-2xl font-semibold text-gray-800 dark:text-white text-center",children:n}):null,jsx("div",{className:s("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:i??jsx(tc,{placeholder:y,onSubmit:(v,g)=>r?.(v,g),supportsAttachments:o})}),a.length>0&&jsx("div",{className:s("grid gap-3 w-full max-w-[900px]","grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(250px,1fr))]"),children:a.map((v,g)=>jsx(ac,{text:v,onClick:()=>x(v),index:g},g))})]})]})});tn.displayName="WelcomeScreen";
|
|
127
|
+
export{qr as $,At as A,xa as B,dt as C,Rt as D,Vt as E,Bt as F,Ft as G,$t as H,jt as I,Wt as J,He as K,Ut as L,Er as M,Na as N,Ca as O,Sa as P,za as Q,Pa as R,Ta as S,ft as T,Kt as U,Lr as V,qt as W,_r as X,Gt as Y,Fr as Z,Wr as _,s as a,Ra as aa,er as b,Yr as ba,Fe as c,Bl as ca,ar as d,Zr as da,it as e,Ul as ea,be as f,Kl as fa,sa as g,Qr as ga,ir as h,tn as ha,Gn as i,la as j,pa as k,ua as l,fa as m,kt as n,Ye as o,ko as p,ha as q,Nt as r,Po as s,$e as t,St as u,zt as v,Pt as w,Tt as x,Et as y,Dt as z};//# sourceMappingURL=chunk-EI3GOLHT.js.map
|
|
128
|
+
//# sourceMappingURL=chunk-EI3GOLHT.js.map
|