(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{3897:(e,t,l)=>{"use strict";l.d(t,{default:()=>x});var s=l(5155),a=l(2115),n=l(6766),i=l(1362);let o=()=>{let{resolvedTheme:e}=(0,i.D)(),[t,l]=(0,a.useState)("/logo_prompt_ui_light_bg.svg");return(0,a.useEffect)(()=>{l("dark"===e?"/logo_prompt_ui_dark_bg.svg":"/logo_prompt_ui_light_bg.svg")},[e]),(0,s.jsx)("div",{className:"flex flex-col w-full h-content bg-accent border-b border-accent-dark items-start p-2 pt-4 mb-4",children:(0,s.jsx)(n.default,{className:"ml-2",src:t,alt:"logo",width:120,height:120})})};var r=l(1013),c=l(760),d=l(6408);let u=e=>{let{messageData:t}=e,{content:l,role:a}=t;return"user"===a?(0,s.jsx)("div",{className:"w-full flex justify-end",children:(0,s.jsx)(c.N,{children:(0,s.jsx)(d.P.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0,transition:{delay:.5}},className:"p-2 bg-accent rounded-lg w-fit min-w-[100px] max-w-lg",children:(0,s.jsx)("p",{className:"text-sm",children:l})})})}):"assistant"===a?(0,s.jsx)("div",{className:"w-full flex justify-start",children:(0,s.jsx)(c.N,{children:(0,s.jsx)(d.P.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0,transition:{delay:.5}},className:"p-2 w-fit min-w-[100px] max-w-3xl",children:l?(0,s.jsx)("p",{className:"text-sm",children:l}):(0,s.jsx)("span",{className:"loading loading-dots loading-md"})})})}):null},x=()=>{let[e,t]=(0,a.useState)({content:"",role:"user",sessionId:""}),[l,n]=(0,a.useState)([]);(0,a.useEffect)(()=>{let e=document.querySelector(".chat-container");e&&(e.scrollTop=e.scrollHeight),l.length>0&&"assistant"==l[l.length-1].role&&""==l[l.length-1].content&&i(l[l.length-2].content)},[l]);let i=async e=>{let t=await fetch("".concat("http://localhost:9001","/prompt"),{method:"POST",body:JSON.stringify({prompt:e})}),s={content:(await t.json()).response,role:"assistant",sessionId:""},a=[...l];a[a.length-1]=s,n(a)},c=async s=>{0!==e.content.trim().length&&(s.preventDefault(),n([...l,e,{content:"",role:"assistant",sessionId:""}]),t({content:"",role:"user",sessionId:""}))};return(0,s.jsxs)("div",{className:"w-full h-full flex flex-col justify-end items-center",children:[(0,s.jsx)(o,{}),(0,s.jsxs)("div",{className:"flex justify-end mx-auto px-4 bg-background pb-4 md:pb-6 gap-2 h-full w-full md:max-w-3xl overflow-y-scroll overflow-x-hidden chat-container",children:[0===l.length&&(0,s.jsxs)("div",{className:"max-w-3xl mx-auto md:mt-20 px-8 size-full flex flex-col justify-start",children:[(0,s.jsx)("div",{className:"text-2xl font-semibold",children:"Test your model"}),(0,s.jsx)("div",{className:"text-2xl text-zinc-400",children:"Input a prompt below"})]}),l.length>0&&(0,s.jsx)("div",{className:"flex flex-col gap-2 w-full",children:l.map((e,t)=>(0,s.jsx)(u,{messageData:e},t))})]}),(0,s.jsx)("form",{className:"flex mx-auto p-4 md:pb-6 gap-2 w-full md:max-w-3xl",children:(0,s.jsxs)("div",{className:"relative w-full",children:[(0,s.jsx)("textarea",{rows:1,className:" flex w-full border border-input px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm min-h-[24px] max-h-[calc(75dvh)] overflow-hidden resize-none rounded-2xl !text-base bg-muted pb-10 dark:border-zinc-700",placeholder:"Send a message...",value:e.content,onChange:e=>{t({content:e.target.value,role:"user",sessionId:""})},onKeyDown:e=>{let t=e.currentTarget.value.trim();"Enter"===e.key&&!e.shiftKey&&t.length>0&&(e.preventDefault(),c(e))}}),(0,s.jsx)("button",{onClick:c,type:"submit",className:"absolute bottom-2 right-2 p-2 w-fit flex flex-row justify-end bg-[#464851] rounded-full h-8 w-8 flex items-center justify-center cursor-pointer",children:(0,s.jsx)(r.$_z,{className:"text-white",size:16})})]})})]})}},7220:(e,t,l)=>{Promise.resolve().then(l.bind(l,3897))}},e=>{var t=t=>e(e.s=t);e.O(0,[512,242,441,684,358],()=>t(7220)),_N_E=e.O()}]);