"use strict";(()=>{var e={};e.id=8194,e.ids=[8194],e.modules={2934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},4580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},5869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},852:e=>{e.exports=require("async_hooks")},6113:e=>{e.exports=require("crypto")},7147:e=>{e.exports=require("fs")},4492:e=>{e.exports=require("node:stream")},1017:e=>{e.exports=require("path")},2781:e=>{e.exports=require("stream")},3837:e=>{e.exports=require("util")},4308:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>g,originalPathname:()=>h,patchFetch:()=>j,requestAsyncStorage:()=>l,routeModule:()=>p,serverHooks:()=>x,staticGenerationAsyncStorage:()=>m,staticGenerationBailout:()=>q});var s={};t.r(s),t.d(s,{POST:()=>c});var a=t(5419),o=t(9108),n=t(9678),i=t(8070),u=t(2509),d=t(8799);async function c(e){try{let r=await (0,u.e)(),{data:{user:s},error:a}=await r.auth.getUser();if(a||!s)return i.Z.json({error:{code:"UNAUTHORIZED",message:"Authentication required"}},{status:401});let{site_id:o,conversation_id:n,to:c,subject:p,html:l,text:m,from:x,reply_to:g,metadata:q}=await e.json();if(!o||!c||!p)return i.Z.json({error:{code:"MISSING_REQUIRED_FIELD",message:"site_id, to, and subject are required"}},{status:400});let{createAdminClient:h}=await Promise.resolve().then(t.bind(t,2509)),j=h(),{data:f,error:E}=await j.from("sites").select("tenant_id").eq("id",o).single();if(E||!f)return i.Z.json({error:{code:"SITE_NOT_FOUND",message:"Site not found"}},{status:404});let I=await (0,d.Te)({siteId:o,conversationId:n,to:c,subject:p,html:l,text:m,from:x,replyTo:g,metadata:q});if(!I.success)return i.Z.json({error:{code:"EMAIL_SEND_FAILED",message:I.error||"Failed to send email"}},{status:500});return i.Z.json({success:!0,message_id:I.messageId})}catch(e){return console.error("Email send error:",e),i.Z.json({error:{code:"INTERNAL_ERROR",message:e instanceof Error?e.message:"Failed to send email"}},{status:500})}}let p=new a.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/email/send/route",pathname:"/api/email/send",filename:"route",bundlePath:"app/api/email/send/route"},resolvedPagePath:"C:\\xampp\\htdocs\\AI Woo Chat\\src\\app\\api\\email\\send\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:l,staticGenerationAsyncStorage:m,serverHooks:x,headerHooks:g,staticGenerationBailout:q}=p,h="/api/email/send/route";function j(){return(0,n.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:m})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[1638,9989,6206,1788,8799],()=>t(4308));module.exports=s})();