"use strict";const e=require("react/jsx-runtime"),w=require("../../providers/Stream.cjs.js"),i=require("lucide-react"),m=require("react");function v({message:r,fontSize:s}){const[p,c]=m.useState(!1),[l,d]=m.useState(""),f=w.useStreamContext(),g=f.getMessagesMetadata(r),b=g?.firstSeenState?.parent_checkpoint,a=r.content;let n="",u=[];typeof a=="string"?n=a:Array.isArray(a)&&(n=a.filter(t=>t.type==="text").map(t=>t.type==="text"?t.text:"").join(""),u=a.filter(t=>t.type==="document")??[]);const h=()=>{if(!l.trim())return;c(!1);const t={type:"human",content:l};f.submit({messages:[t]},{checkpoint:b,streamMode:["values"],streamSubgraphs:!0,streamResumable:!0,optimisticValues:o=>{const x=g?.firstSeenState?.values;return x?{...x,messages:[...x.messages??[],t]}:o}})};return e.jsx("div",{className:"flex flex-col gap-1 w-full group my-1",children:e.jsxs("div",{className:"flex flex-1 flex-col gap-2 items-end min-w-0 mr-4",children:[u.length>0&&e.jsx("div",{className:"flex flex-col gap-2 max-w-[90%]",children:u.map((t,o)=>e.jsxs("div",{className:"flex items-center gap-3 bg-linear-to-br from-zinc-800/90 to-zinc-900/90 backdrop-blur-sm px-4 py-1 rounded-xl border border-zinc-700/50 shadow-md hover:border-blue-500/40 hover:shadow-lg hover:shadow-blue-500/10 transition-all duration-200 cursor-pointer group/file",children:[e.jsx("div",{className:"p-1.5 bg-blue-500/10 rounded-lg border border-blue-500/20 group-hover/file:bg-blue-500/20 transition-colors",children:e.jsx(i.FileIcon,{size:16,className:"text-blue-400 shrink-0"})}),e.jsx("span",{className:"text-sm text-zinc-200 truncate font-medium",children:t.source?.filename||`Document ${o+1}`})]},`${r.id}-doc-${o}`))}),n&&e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("div",{className:"relative flex-1 w-full flex justify-end",children:p?e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsx("textarea",{value:l,onChange:t=>d(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),h())},className:"font-normal leading-relaxed rounded-2xl px-5 bg-zinc-900 border border-zinc-800 text-white shadow-lg wrap-break-word overflow-wrap-anywhere resize-none focus:outline-none min-h-15",style:s?{fontSize:s}:{fontSize:"15px"},autoFocus:!0}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>{c(!1),d("")},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-sm transition-colors",children:e.jsx(i.X,{size:16})}),e.jsx("button",{onClick:h,disabled:!l.trim(),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white text-black text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:e.jsx(i.Send,{size:16})})]})]}):e.jsx("div",{className:"font-normal leading-relaxed rounded-xl py-2 px-4 bg-[#242322] text-white shadow-lg max-w-full break-words overflow-wrap-anywhere",style:s?{fontSize:s}:{fontSize:"15px"},children:n})}),!p&&e.jsxs("div",{className:"flex items-center gap-4 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:[e.jsx(i.Pencil,{size:16,className:"text-zinc-500 cursor-pointer hover:text-white",onClick:()=>{c(!0),d(n)}}),e.jsx(i.Copy,{size:16,className:"text-zinc-500 cursor-pointer hover:text-white",onClick:()=>{navigator.clipboard.writeText(n)}})]})]})]})})}const y=m.memo(v,(r,s)=>r.message.id===s.message.id&&r.fontSize===s.fontSize);module.exports=y;
//# sourceMappingURL=HumanMessage.cjs.js.map
