teodor-new-chat-ui 3.0.187 → 3.0.188

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/index.esm.js CHANGED
@@ -10713,9 +10713,9 @@ const Ql = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, wd = B.forwa
10713
10713
  _.current !== !1 && (_.current = !1);
10714
10714
  return;
10715
10715
  }
10716
- const I = t && C ? "auto" : !1;
10716
+ const I = C ? "auto" : !1;
10717
10717
  _.current !== I && (_.current = I);
10718
- }, [t, C, b, v]), e.length === 0 ? /* @__PURE__ */ l.jsx("div", { className: f, style: h, children: /* @__PURE__ */ l.jsx("div", { className: "flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto", children: m || "No messages yet. Start a conversation!" }) }) : /* @__PURE__ */ l.jsx("div", { className: f, style: h, children: /* @__PURE__ */ l.jsx(
10718
+ }, [C, b, v]), e.length === 0 ? /* @__PURE__ */ l.jsx("div", { className: f, style: h, children: /* @__PURE__ */ l.jsx("div", { className: "flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto", children: m || "No messages yet. Start a conversation!" }) }) : /* @__PURE__ */ l.jsx("div", { className: f, style: h, children: /* @__PURE__ */ l.jsx(
10719
10719
  ov,
10720
10720
  {
10721
10721
  ref: (I) => {
package/dist/index.umd.js CHANGED
@@ -128,7 +128,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
128
128
  … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_result");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Iw(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Nw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Vu(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_result":return"result";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Aw(e,t,n=16){const[r,o]=C.useState(e),s=C.useRef(e),i=C.useRef(null),a=C.useRef(null);return C.useEffect(()=>{if(s.current=e,!t){i.current&&cancelAnimationFrame(i.current),a.current&&clearTimeout(a.current),o(e);return}return a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>o(s.current))},n),()=>{i.current&&cancelAnimationFrame(i.current),a.current&&clearTimeout(a.current)}},[e,t,n]),r}function Rw({className:e}){const[t,n]=C.useState(0);return C.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:X("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const qu=C.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:o=16,isEditing:s=!1,showActions:i=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:u="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:f=200,truncateUserMessages:h=!0,userMessagePreviewLength:m=200,customStyles:b={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:w}){const[y,E]=C.useState(!1),[S,T]=C.useState("collapsed"),[I,N]=C.useState(!1),{currentThreadId:R}=ao(),{toast:j}=yi(),[A,z]=C.useState({}),[V,O]=C.useState(!1),[G,W]=C.useState(null),q=u==="phone"||u==="half-screen",L=t.role,M=L==="tool",le=!(r&&L!=="user"),J=C.useMemo(()=>{switch(L){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[L]),ee=C.useMemo(()=>Cw(t.content),[t.content]),D=C.useMemo(()=>Tw(t.content),[t.content]),Z=C.useMemo(()=>t.content.filter(ue=>ue.type==="image_url"),[t.content]),ke=C.useMemo(()=>t.content.filter(ue=>ue.type==="file"),[t.content]),he=C.useMemo(()=>Ew(t.content),[t.content]);C.useMemo(()=>Iw(t.content),[t.content]);const $=C.useMemo(()=>he.length<=Bn?he:`${he.slice(0,Bn)}
129
129
  … [truncated ${he.length-Bn} chars]`,[he]),P=Aw(ee,r,o),H=C.useCallback(async(ue="all")=>{const pe=ue==="visible"&&M?$:M?he:ee;async function Se(Oe){try{await navigator.clipboard.writeText(Oe)}catch{try{const Ve=document.createElement("textarea");Ve.value=Oe,Ve.setAttribute("readonly",""),Ve.style.position="absolute",Ve.style.left="-9999px",document.body.appendChild(Ve),Ve.select(),document.execCommand("copy"),document.body.removeChild(Ve)}catch(Ve){throw console.error("Failed to copy:",Ve),Ve}}}try{await Se(pe),E(!0),setTimeout(()=>E(!1),2e3),w==null||w(pe)}catch(Oe){console.error("Failed to copy:",Oe)}},[M,he,ee,$,w]),Q=C.useCallback(()=>{if(!v)return;const ue=M?he:ee;v(t.id,ue)},[v,t.id,M,he,ee]),ce=C.useCallback(()=>{g==null||g(n)},[g,n]),ie=C.useCallback(async(ue,fe,pe)=>{if(!le){ue.preventDefault();return}if(A[pe]){ue.preventDefault();return}try{const Se=String(fe.url??""),Oe=Se.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Oe){ue.preventDefault();const Ve=Oe[1],F=fe.name||`file_${Ve}`,Y=fe.mimeType||"application/octet-stream";W({id:Ve,name:F,mimeType:Y}),O(!0);return}if(Se.startsWith("data:")){ue.preventDefault(),z(Y=>({...Y,[pe]:!0}));const Ve=`${fe.name}_${fe.size}_${Date.now()}`,F=j({title:"Fetching file...",description:"",open:!0});try{const Y=await ev(R??void 0);if(!Y||!Array.isArray(Y))throw new Error("Invalid file list response");const je=Y.find(nt=>!nt||typeof nt!="object"||!((nt.filename??"")===(fe.name??""))?!1:typeof fe.size=="number"&&typeof nt.size=="number"?nt.size===fe.size:!0);if(!(je!=null&&je.id))throw new Error(`File "${fe.name}" is not yet available on the server`);if(!je.id||!je.filename)throw new Error("Invalid file data received from server");W({id:je.id,name:fe.name||je.filename||`file_${je.id}`,mimeType:fe.mimeType||je.mime_type||"application/octet-stream"}),O(!0),F.update({id:F.id,title:"Success",description:`Opened ${fe.name}`,open:!0})}catch(Y){console.error("Failed to fetch server file:",Y);const je=Y instanceof Error?Y.message:"Unknown error occurred";F.update({id:F.id,title:"Failed",description:je}),j({title:"Failed to fetch file",description:je,open:!0})}finally{z(Y=>({...Y,[pe]:!1}))}}}catch(Se){console.error("File click error:",Se),z(Oe=>({...Oe,[pe]:!1}))}},[le,A,j,R]),Fe=C.useCallback(()=>{const fe=X(q?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",J);switch(L){case"user":return l.jsx(oe.User,{className:fe});case"assistant":return l.jsx(oe.Bot,{className:fe});case"tool":return l.jsx(oe.Wrench,{className:fe});default:return l.jsx(oe.Bot,{className:fe})}},[q,J,L]),$e=C.useCallback(()=>{const ue="group relative mb-4 flex w-full";switch(L){case"user":return X(ue,"justify-end");case"assistant":case"tool":case"system":return X(ue,"justify-start");default:return ue}},[L]),we=C.useCallback(()=>{const ue=X("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",q&&"px-3 py-2 text-sm");switch(L){case"user":return X(ue,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return X(ue,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return X(ue,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return X(ue,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return X(ue,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[q,L]),Ne=C.useCallback(({part:ue,i:fe})=>{if(ue.type==="text")return l.jsx(No,{content:ue.text,allowHtml:!1},fe);if(ue.type==="image_url"){const pe=ue;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:pe.url,alt:pe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},fe)}if(ue.type==="file"){const pe=ue,Se=pe.name||"file";return l.jsxs("a",{href:pe.url,onClick:Oe=>ie(Oe,pe,fe),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
130
  dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[A[fe]?l.jsx(oe.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[Se,A[fe]?" (processing)":""]})]},fe)}return null},[ie,A]),Ue=C.useCallback(()=>l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),et=C.useCallback(()=>{const fe=Hu(L,P)?Di(P):null;if(fe!==null)return l.jsx(Ku,{data:fe});const pe=Sw(yw(P)),Se=P.trim().length===0;return l.jsx(l.Fragment,{children:Se?l.jsx("div",{className:"w-full",children:l.jsxs("div",{className:"animate-pulse space-y-2",children:[l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):l.jsx("pre",{className:X("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",q&&"text-xs"),children:pe})})},[L,P,q]),Xe=C.useCallback(()=>{const ue=ee.trim(),pe=Hu(L,ue)?Di(ue):null;if(pe!==null)return l.jsx(Ku,{data:pe});if(L==="user"&&h){const Se=ue;if(Se.length>m)return l.jsxs(jc,{open:I,onOpenChange:N,children:[l.jsx("div",{className:X("text-sm text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:I?l.jsx(No,{content:Se,allowHtml:!1}):l.jsxs("pre",{className:X("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:[Se.substring(0,m),"..."]})}),l.jsx(Pc,{asChild:!0,children:l.jsx(We,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:I?l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Se.length-m," chars)"]})})})]})}return l.jsx(No,{content:ee.trim(),allowHtml:!1})},[ee,L,h,m,I,q]),ut=C.useCallback(()=>{if(!(ee.trim().length>0||Z.length>0||ke.length>0)&&!r)return Ue();if(t.model==="reflection"){const fe=ee.trim(),pe=Di(fe);if(pe&&typeof pe=="object")return l.jsx(jw,{data:pe})}if(M&&D.name==="get_issues"){const fe=t.content.find(Oe=>Oe.type==="tool_result"),pe=(fe==null?void 0:fe.output)??he,Se=Wu(pe);if(Se)return l.jsx(Pw,{issues:Se})}if(M){const fe=kw(t.content);if(fe.length>0)return l.jsx("div",{className:"space-y-2",children:fe.map((pe,Se)=>{const Oe=typeof pe.output=="string"?pe.output:Li(pe.output),Ve=Oe.length>Bn?`${Oe.slice(0,Bn)}
131
- … [truncated ${Oe.length-Bn} chars]`:Oe,F=S==="expanded";return l.jsxs(jc,{open:F,onOpenChange:Y=>T(Y?"expanded":"preview"),children:[l.jsx("div",{className:"flex items-center gap-2 text-xs",children:l.jsx(fi,{variant:"outline",children:(pe.name??"tool")+(pe.toolCallId?` • ${pe.toolCallId.slice(0,8)}`:"")})}),l.jsx("div",{className:"font-mono text-sm mt-1",children:l.jsx("pre",{className:"whitespace-pre-wrap break-words",children:F?Ve:Ve.slice(0,f)+(Ve.length>f?"...":"")})}),l.jsx(Pc,{asChild:!0,children:l.jsx(We,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:F?l.jsxs(l.Fragment,{children:[" ",l.jsx(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},pe.toolCallId??Se)})})}if(!M)return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[et(),r&&l.jsx(Rw,{className:J})]}):l.jsx("div",{className:"space-y-2",children:t.content.map((fe,pe)=>l.jsx(Ne,{part:fe,i:pe},pe))})},[ee,Z.length,ke.length,r,t.model,M,D.name,he,S,d,Ue,et,Xe,J]),dt=C.useMemo(()=>Nw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:X($e(),b.container),children:l.jsxs("div",{className:X(we(),b.content),children:[(a||c||M)&&l.jsxs("div",{className:X("flex items-center justify-between mb-2 pb-2 border-b border-current/10",q&&"mb-1 pb-1",J,b.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Fe(),c&&dt&&l.jsx("span",{className:X("font-medium",q?"text-xs":"text-sm"),children:dt}),M&&D.name&&l.jsxs(fi,{variant:"outline",className:X("text-xs flex items-center gap-1 cursor-pointer",J,"border border-current/40",q&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":S!=="collapsed",onKeyDown:ue=>{(ue.key==="Enter"||ue.key===" ")&&(ue.preventDefault(),T(fe=>fe==="collapsed"?"preview":"collapsed"))},onClick:()=>T(ue=>ue==="collapsed"?"preview":"collapsed"),children:[l.jsx("span",{children:D.name}),l.jsx("span",{className:"inline-flex items-center",children:S!=="collapsed"?l.jsx(oe.ChevronUp,{className:"h-3 w-3"}):l.jsx(oe.ChevronDown,{className:"h-3 w-3"})})]}),M&&!D.name&&l.jsx(We,{variant:"ghost",size:"sm",className:X("h-6 px-1",J,"hover:bg-foreground/10"),onClick:()=>T(ue=>ue==="collapsed"?"preview":"collapsed"),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",S!=="collapsed"?l.jsx(oe.ChevronUp,{className:"h-3 w-3"}):l.jsx(oe.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.createdAt&&l.jsx("time",{className:X("text-xs opacity-60",J,q&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),i&&!s&&l.jsxs("div",{className:X("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsxs("div",{className:"relative",children:[l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H(M?"visible":"all"),className:X("h-6 w-6 p-0 hover:bg-foreground/10",J,q&&"h-5 w-5"),"aria-label":M?"Copy visible":"Copy message",title:M?"Copy visible portion":"Copy message",children:l.jsx(oe.Copy,{className:X(y?"text-success":J,q?"h-3 w-3":"h-4 w-4")})}),M&&l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H("all"),className:X("h-6 px-1 text-xs hover:bg-foreground/10",J),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),L==="user"&&v&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Q,className:X("h-6 w-6 p-0 hover:bg-foreground/10",J,q&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(oe.Edit,{className:X(J,q?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&g&&l.jsx(We,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-foreground/10",J,q&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(oe.RotateCcw,{className:X(J,q?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:ut()}),M&&S==="expanded"&&(D.toolCallId||D.name)&&l.jsxs("div",{className:X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[D.name&&l.jsxs("div",{children:["Function: ",D.name]}),D.toolCallId&&l.jsxs("div",{children:["Call ID: ",D.toolCallId]})]}),!(a||c||M)&&i&&!s&&l.jsxs("div",{className:X("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H(),className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(oe.Copy,{className:X(y?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),L==="user"&&v&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Q,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(oe.Edit,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&g&&l.jsx(We,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(oe.RotateCcw,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),G&&l.jsx(bw,{isOpen:V,onClose:()=>{O(!1),W(null)},fileId:G.id,fileName:G.name,mimeType:G.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Vu(e.message)===Vu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function Ku({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Ko,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Li(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return l.jsxs("div",{className:Ko,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Ko,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:_w(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Li(e)})}function _w(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return l.jsx("code",{className:"text-xs",children:JSON.stringify(jr(e))})}catch{return String(e)}}function jw({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Pw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Ko,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Gu=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,$i=C.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:b=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},w)=>{const y=C.useRef(null),E=C.useRef(null),S=C.useRef(!1),[T,I]=C.useState(!0),N=C.useCallback(A=>{I(A),g&&g(!A),x&&x(A)},[g,x]),R=C.useMemo(()=>{if(a)return async()=>{if(!S.current){S.current=!0;try{await a()}finally{S.current=!1}}}},[a]),j=C.useRef(!1);return C.useEffect(()=>{if(!b||v){j.current!==!1&&(j.current=!1);return}const A=t&&T?"auto":!1;j.current!==A&&(j.current=A)},[t,T,b,v]),e.length===0?l.jsx("div",{className:f,style:h,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:h,children:l.jsx(ox,{ref:A=>{y.current=A},scrollerRef:A=>{E.current=A instanceof HTMLDivElement?A:null},data:e,followOutput:j.current,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{R&&R()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(A,z)=>Gu(z,A),itemContent:(A,z)=>{const V=Gu(z,A);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":V,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(qu,{message:z,messageIndex:A,isStreamingMessage:t&&n===z.id,streamingDebounceMs:r,isEditing:i===z.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(A),onCancelEdit:d})})}})})});$i.displayName="MessageList";const Go=1e4;function Ow(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
131
+ … [truncated ${Oe.length-Bn} chars]`:Oe,F=S==="expanded";return l.jsxs(jc,{open:F,onOpenChange:Y=>T(Y?"expanded":"preview"),children:[l.jsx("div",{className:"flex items-center gap-2 text-xs",children:l.jsx(fi,{variant:"outline",children:(pe.name??"tool")+(pe.toolCallId?` • ${pe.toolCallId.slice(0,8)}`:"")})}),l.jsx("div",{className:"font-mono text-sm mt-1",children:l.jsx("pre",{className:"whitespace-pre-wrap break-words",children:F?Ve:Ve.slice(0,f)+(Ve.length>f?"...":"")})}),l.jsx(Pc,{asChild:!0,children:l.jsx(We,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:F?l.jsxs(l.Fragment,{children:[" ",l.jsx(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},pe.toolCallId??Se)})})}if(!M)return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[et(),r&&l.jsx(Rw,{className:J})]}):l.jsx("div",{className:"space-y-2",children:t.content.map((fe,pe)=>l.jsx(Ne,{part:fe,i:pe},pe))})},[ee,Z.length,ke.length,r,t.model,M,D.name,he,S,d,Ue,et,Xe,J]),dt=C.useMemo(()=>Nw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:X($e(),b.container),children:l.jsxs("div",{className:X(we(),b.content),children:[(a||c||M)&&l.jsxs("div",{className:X("flex items-center justify-between mb-2 pb-2 border-b border-current/10",q&&"mb-1 pb-1",J,b.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Fe(),c&&dt&&l.jsx("span",{className:X("font-medium",q?"text-xs":"text-sm"),children:dt}),M&&D.name&&l.jsxs(fi,{variant:"outline",className:X("text-xs flex items-center gap-1 cursor-pointer",J,"border border-current/40",q&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":S!=="collapsed",onKeyDown:ue=>{(ue.key==="Enter"||ue.key===" ")&&(ue.preventDefault(),T(fe=>fe==="collapsed"?"preview":"collapsed"))},onClick:()=>T(ue=>ue==="collapsed"?"preview":"collapsed"),children:[l.jsx("span",{children:D.name}),l.jsx("span",{className:"inline-flex items-center",children:S!=="collapsed"?l.jsx(oe.ChevronUp,{className:"h-3 w-3"}):l.jsx(oe.ChevronDown,{className:"h-3 w-3"})})]}),M&&!D.name&&l.jsx(We,{variant:"ghost",size:"sm",className:X("h-6 px-1",J,"hover:bg-foreground/10"),onClick:()=>T(ue=>ue==="collapsed"?"preview":"collapsed"),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",S!=="collapsed"?l.jsx(oe.ChevronUp,{className:"h-3 w-3"}):l.jsx(oe.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.createdAt&&l.jsx("time",{className:X("text-xs opacity-60",J,q&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),i&&!s&&l.jsxs("div",{className:X("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsxs("div",{className:"relative",children:[l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H(M?"visible":"all"),className:X("h-6 w-6 p-0 hover:bg-foreground/10",J,q&&"h-5 w-5"),"aria-label":M?"Copy visible":"Copy message",title:M?"Copy visible portion":"Copy message",children:l.jsx(oe.Copy,{className:X(y?"text-success":J,q?"h-3 w-3":"h-4 w-4")})}),M&&l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H("all"),className:X("h-6 px-1 text-xs hover:bg-foreground/10",J),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),L==="user"&&v&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Q,className:X("h-6 w-6 p-0 hover:bg-foreground/10",J,q&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(oe.Edit,{className:X(J,q?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&g&&l.jsx(We,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-foreground/10",J,q&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(oe.RotateCcw,{className:X(J,q?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:ut()}),M&&S==="expanded"&&(D.toolCallId||D.name)&&l.jsxs("div",{className:X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[D.name&&l.jsxs("div",{children:["Function: ",D.name]}),D.toolCallId&&l.jsxs("div",{children:["Call ID: ",D.toolCallId]})]}),!(a||c||M)&&i&&!s&&l.jsxs("div",{className:X("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsx(We,{variant:"ghost",size:"sm",onClick:()=>H(),className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(oe.Copy,{className:X(y?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),L==="user"&&v&&l.jsx(We,{variant:"ghost",size:"sm",onClick:Q,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(oe.Edit,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&g&&l.jsx(We,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:l.jsx(oe.RotateCcw,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),G&&l.jsx(bw,{isOpen:V,onClose:()=>{O(!1),W(null)},fileId:G.id,fileName:G.name,mimeType:G.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Vu(e.message)===Vu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function Ku({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:Ko,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Li(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return l.jsxs("div",{className:Ko,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:Ko,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:_w(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Li(e)})}function _w(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return l.jsx("code",{className:"text-xs",children:JSON.stringify(jr(e))})}catch{return String(e)}}function jw({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Pw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:Ko,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const Gu=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,$i=C.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:b=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},w)=>{const y=C.useRef(null),E=C.useRef(null),S=C.useRef(!1),[T,I]=C.useState(!0),N=C.useCallback(A=>{I(A),g&&g(!A),x&&x(A)},[g,x]),R=C.useMemo(()=>{if(a)return async()=>{if(!S.current){S.current=!0;try{await a()}finally{S.current=!1}}}},[a]),j=C.useRef(!1);return C.useEffect(()=>{if(!b||v){j.current!==!1&&(j.current=!1);return}const A=T?"auto":!1;j.current!==A&&(j.current=A)},[T,b,v]),e.length===0?l.jsx("div",{className:f,style:h,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:h,children:l.jsx(ox,{ref:A=>{y.current=A},scrollerRef:A=>{E.current=A instanceof HTMLDivElement?A:null},data:e,followOutput:j.current,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{R&&R()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(A,z)=>Gu(z,A),itemContent:(A,z)=>{const V=Gu(z,A);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":V,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(qu,{message:z,messageIndex:A,isStreamingMessage:t&&n===z.id,streamingDebounceMs:r,isEditing:i===z.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(A),onCancelEdit:d})})}})})});$i.displayName="MessageList";const Go=1e4;function Ow(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
132
132
  `).replace(/<p>(.*?)<\/p>/gi,`$1
133
133
 
134
134
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "3.0.187",
3
+ "version": "3.0.188",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",