import{c as d,g as S,a as C,u as j,i as g,b as T,h as E,t as F,k as R}from"./web.4OCuPnM3.js";import{T as m,F as k}from"./toast.BAoR90zK.js";var L=F('<form method=post class="flex flex-col gap-3"><div class="flex flex-wrap gap-3"><!$><!/><div class="flex flex-col gap-1 w-full"><label for=message class=px-2><small>Send A Reply</small></label><textarea class="min-h-[10rem] p-3 rounded-lg border border-blue-900/5 outline-0 max-w-full"name=message required placeholder="Type your message"></textarea></div></div><div class="flex flex-wrap justify-center sm:justify-end gap-3"><button type=reset class="border-blue-950 border rounded-lg text-blue-950 p-2 w-[10rem]">Clear</button><button type=submit class="bg-blue-950 rounded-lg text-white p-2 w-[10rem]">');const D=({id:s,name:u,slug:p})=>{const[c,r]=d(!1),[f,b]=d();let n;const x=async e=>{e.preventDefault(),r(!0);const t=await fetch("/api/chat/reply",{method:"POST",body:new FormData(e.target)}),l=await t.json();if(console.log({json:l}),t.ok)return n.reset(),await m.fire({title:"Sent",html:`
        <strong> You just replied "${u??""}"</strong> 
        `}),window.location.assign(`/dashboard/messages/${p}-msg-${s}`);await m.fire({title:"Try Again"}),r(!1)};return(()=>{var e=S(L),t=e.firstChild,l=t.firstChild,[o,h]=C(l.nextSibling),$=o.nextSibling,w=$.firstChild,i=w.nextSibling,y=t.nextSibling,v=y.firstChild,_=v.nextSibling;return j(a=>n=a,e),e.addEventListener("submit",a=>x(a)),g(t,T(k,{name:"id",hidden:!0,value:s,className:"grow"}),o,h),i.addEventListener("change",a=>b(a.target.value)),g(_,()=>c()?"...loading":"Reply"),E(()=>R(i,"value",f()??"")),e})()};export{D as ReplyForm};
