"use strict";(()=>{var e={};e.id=5077,e.ids=[5077],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")},36730:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>x,patchFetch:()=>m,requestAsyncStorage:()=>c,routeModule:()=>l,serverHooks:()=>v,staticGenerationAsyncStorage:()=>f});var s={};t.r(s),t.d(s,{GET:()=>d,POST:()=>p});var a=t(49303),o=t(88716),i=t(60670),n=t(87070),u=t(72331);async function d(e){let{searchParams:r}=new URL(e.url),t=r.get("userId");if(!t)return n.NextResponse.json({error:"User ID is required"},{status:400});try{let e=await u._.favorite.findMany({where:{userId:t},orderBy:{createdAt:"desc"}});return n.NextResponse.json(e)}catch(e){return console.error("Error fetching favorites:",e),n.NextResponse.json({error:"Failed to fetch favorites"},{status:500})}}async function p(e){try{let{userId:r,dramaId:t,title:s,image:a,endpoints:o,provider:i}=await e.json();if(!r||!t)return n.NextResponse.json({error:"Missing required fields"},{status:400});let d=await u._.favorite.findUnique({where:{userId_dramaId:{userId:r,dramaId:t}}});if(d)return await u._.favorite.delete({where:{id:d.id}}),n.NextResponse.json({action:"removed"});return await u._.favorite.create({data:{userId:r,dramaId:t,title:s,image:a,endpoints:o?String(o):null,provider:i}}),n.NextResponse.json({action:"added"})}catch(e){return console.error(e),n.NextResponse.json({error:"Failed to update favorites"},{status:500})}}let l=new a.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/user/favorites/route",pathname:"/api/user/favorites",filename:"route",bundlePath:"app/api/user/favorites/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\user\\favorites\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:f,serverHooks:v}=l,x="/api/user/favorites/route";function m(){return(0,i.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:f})}},72331:(e,r,t)=>{t.d(r,{_:()=>a});var s=t(53524);let a=global.prisma||new s.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972],()=>t(36730));module.exports=s})();