"use strict";(()=>{var e={};e.id=1762,e.ids=[1762,2331],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},65758:(e,s,t)=>{t.r(s),t.d(s,{originalPathname:()=>l,patchFetch:()=>h,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>g,staticGenerationAsyncStorage:()=>c});var a={};t.r(a),t.d(a,{POST:()=>d});var r=t(49303),n=t(88716),i=t(60670),o=t(87070),u=t(72331);async function d(e){try{let{user_ids:s,subject:t,content:a}=await e.json();if(!Array.isArray(s)||0===s.length)return o.NextResponse.json({success:!1,message:"Pilih minimal 1 pengguna"},{status:400});if(!t?.trim()||!a?.trim())return o.NextResponse.json({success:!1,message:"Subjek dan isi pesan wajib diisi"},{status:400});let r=await u.prisma.user.findMany({where:{userId:{in:s}},select:{id:!0,userId:!0}});if(0===r.length)return o.NextResponse.json({success:!1,message:"Pengguna tidak ditemukan"},{status:404});let n=`direct_${Date.now()}`;return await u.prisma.message.createMany({data:r.map(e=>({threadId:n,senderType:"admin",recipientId:e.id,subject:t.trim(),content:a.trim(),isBroadcast:!1,isRead:!1}))}),o.NextResponse.json({success:!0,message:`Pesan terkirim ke ${r.length} pengguna`,sent:r.length,recipients:r.map(e=>e.userId)})}catch(e){return console.error("Admin send message error:",e),o.NextResponse.json({success:!1,message:"Gagal mengirim pesan"},{status:500})}}let p=new r.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/admin/messages/send/route",pathname:"/api/admin/messages/send",filename:"route",bundlePath:"app/api/admin/messages/send/route"},resolvedPagePath:"C:\\xampp\\htdocs\\Bolafest\\app\\api\\admin\\messages\\send\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:c,serverHooks:g}=p,l="/api/admin/messages/send/route";function h(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:c})}},72331:(e,s,t)=>{t.d(s,{prisma:()=>r});var a=t(53524);let r=globalThis.prisma??new a.PrismaClient({log:["error"]})}};var s=require("../../../../../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),a=s.X(0,[9276,5972],()=>t(65758));module.exports=a})();