"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),R=require("../../components/ChatBody.cjs.js"),N=require("../../components/sidebar/ChatInput.cjs.js"),V=require("../../components/Suggestion.cjs.js"),E=require("../../components/threads/ThreadHistory.cjs.js"),P=require("../../providers/ChatRuntime.cjs.js"),W=require("../../providers/FileProvider.cjs.js"),C=require("../../providers/Stream.cjs.js"),U=require("../../providers/Thread.cjs.js"),F=require("../../utils/submitUtils.cjs.js"),i=require("react"),_=require("../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.cjs.js");function $(m){const{callThisOnSubmit:f,handleFileSelect:I,enableToolCallIndicator:A,chatBodyProps:q,textToSpeechVoice:g}=m||{},[k,h]=i.useState(!0),[l,x]=i.useState(""),[b,p]=i.useState(!1),{fileInput:r,setFileInput:o}=W.useFileProvider(),[B,T]=i.useState([]),{fetchCatalog:w}=C.useStreamContext(),d=C.useStreamContext(),{assistantId:D,setAssistantId:L}=P.useChatRuntime(),M=d.isLoading,{setMode:v,threadId:j}=U.useThread();i.useEffect(()=>{(async()=>{const t=await w(),u=(Array.isArray(t?.agents)?t.agents:[]).map(a=>a?.graph_id).filter(a=>typeof a=="string"&&a.length>0);T(u)})()},[w]);const H=s=>{const t=s.target.innerText;L(t),p(!1)};i.useEffect(()=>{v("multi")},[v]),i.useEffect(()=>{d.messages&&d.messages.length>0?h(!1):j||h(!0)},[j,d.messages]);const y=async s=>{if(s.preventDefault(),l.trim().length===0&&r.length===0||M)return;let t=r,c;if(f){const n=await f();Array.isArray(n?.files)&&n.files.length>0&&(t=n.files),n&&n?.contextValues&&(c=n.contextValues)}const u=F.buildContentBlocks(l,t),a={id:_(),type:"human",content:u};h(!1);const z=l,O=r;x(""),o([]);try{await d.submitMessage(a,{contextValues:c})}catch(n){throw x(z),o(O),n}},S=I||(async s=>{const t=s.target.files;if(!t)return;const c=await F.readFilesAsBase64(t);o(u=>[...u,...c])});return e.jsxs("div",{className:"flex h-screen w-screen bg-[#0f0f0f] text-white",children:[e.jsx(E,{header:m?.header||{title:"AI Assistant"}}),e.jsxs("main",{className:"flex flex-1 flex-col",children:[e.jsxs("header",{className:"flex h-14 items-center justify-between border-b border-white/10 px-6",children:[e.jsxs("button",{id:"dropdownDividerButton",onClick:()=>p(!b),className:"inline-flex items-center justify-center text-white bg-brand box-border border rounded-2xl border-transparent hover:bg-brand-strong font-medium leading-5 rounded-base text-sm px-4 py-2.5 bg-zinc-800",type:"button",children:[D,e.jsx("svg",{className:"w-4 h-4 ms-1.5 -me-0.5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",children:e.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m19 9-7 7-7-7"})})]}),e.jsx("div",{id:"dropdownDivider",className:`z-10 absolute top-14 bg-neutral-primary-medium bg-zinc-800 rounded-2xl  divide-y divide-default-medium w-44 ${b?"":"hidden"}`,children:e.jsx("ul",{className:"p-2 text-sm text-body font-medium","aria-labelledby":"dropdownDividerButton",children:B.map(s=>e.jsx("li",{className:"hover:bg-zinc-700 hover:rounded-2xl",onClick:H,children:e.jsx("span",{className:"inline-flex items-center w-full p-2 hover:bg-neutral-tertiary-medium hover:text-heading rounded",children:s})},s))})})]}),e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:k?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center",children:[e.jsx("h1",{className:"mb-8 text-2xl font-medium text-white/80",children:"What are you working on?"}),e.jsx("div",{className:"w-full max-w-2xl px-4",children:e.jsx(N,{input:l,setInput:x,textToSpeechVoice:g,handleSubmit:y,fileInput:r,setFileInput:o,handleFileSelect:S})})]}):e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-none [&::-webkit-scrollbar]:hidden",children:e.jsx("div",{className:"mx-auto max-w-3xl px-4 py-6",children:e.jsx(R,{setIsFirstMessage:h,enableToolCallIndicator:A,chatBodyProps:q})})}),e.jsx("div",{className:"mx-auto",children:e.jsx(V,{})}),e.jsx("div",{className:"border-t border-white/10 p-1",children:e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(N,{input:l,setInput:x,textToSpeechVoice:g,handleSubmit:y,fileInput:r,setFileInput:o,handleFileSelect:S})})})]})})]})]})}exports.Chat=$;
//# sourceMappingURL=Chat.cjs.js.map
