(()=>{var e={};e.id=7758,e.ids=[7758],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},5486:e=>{"use strict";e.exports=require("bcrypt")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,r,t)=>{"use strict";function a(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function s(e){let r=e.headers.get("authorization");if(r&&r.startsWith("Bearer "))return r.slice(7);let t=e.cookies.get("admin_token")?.value;if(t)return t;let a=e.cookies.get("token")?.value;return a||null}t.d(r,{V:()=>s,u:()=>a})},27910:e=>{"use strict";e.exports=require("stream")},28354:e=>{"use strict";e.exports=require("util")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:e=>{"use strict";e.exports=require("crypto")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},87972:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>w,routeModule:()=>y,serverHooks:()=>v,workAsyncStorage:()=>h,workUnitAsyncStorage:()=>f});var a={};t.r(a),t.d(a,{POST:()=>x});var s=t(96559),n=t(48088),i=t(37719),o=t(32190),u=t(43205),p=t.n(u),c=t(5486),l=t.n(c),m=t(96330),d=t(12909);let k=new m.PrismaClient,g=(0,d.u)();async function x(e){try{let{email:r,password:t}=await e.json();if(!r||!t)return o.NextResponse.json({error:"Email ve şifre gereklidir"},{status:400});let a=await k.user.findUnique({where:{email:r},include:{company:{include:{companyPackages:{where:{status:!0},include:{package:!0}},companyMarketplaces:{include:{marketplace:!0}}}},userMarketplacePermissions:{include:{companyMarketplace:{include:{marketplace:!0}}}}}});if(!a||!await l().compare(t,a.password))return o.NextResponse.json({error:"Ge\xe7ersiz email veya şifre"},{status:401});if(!a.isActive)return o.NextResponse.json({error:"Hesabınız pasif durumda. L\xfctfen y\xf6neticinizle iletişime ge\xe7in."},{status:403});if(!a.company.isApproved)return o.NextResponse.json({error:"Şirketiniz hen\xfcz onaylanmamış. En kısa zamanda y\xf6neticiler sizinle iletişime ge\xe7ecektir."},{status:403});let s=p().sign({userId:a.id,email:a.email,companyId:a.companyId},g,{expiresIn:"7d"}),n=a.company.companyMarketplaces.map(e=>({id:e.id,name:e.name,marketplaceId:e.marketplace.id,marketplaceName:e.marketplace.name.toLowerCase(),bgColor:e.marketplace.bgColor,icon:e.marketplace.icon})),i=a.userMarketplacePermissions.map(e=>e.companyMarketplaceId),u={access_token:s,user:{id:a.id,email:a.email,name:a.name,surname:a.surname,image:null,company:{id:a.company.id,name:a.company.name,packages:a.company.companyPackages.map(e=>({name:e.package.name,packageEndDate:e.packageEndDate.toISOString()})),marketplaces:n,authorizedMarketplaces:i}}},c=o.NextResponse.json(u);return c.cookies.set("token",s,{httpOnly:!0,sameSite:"lax",path:"/",secure:!0,maxAge:604800}),c}catch(e){return console.error("Login error:",e),o.NextResponse.json({error:"Sunucu hatası"},{status:500})}}let y=new s.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/auth/login/route",pathname:"/api/auth/login",filename:"route",bundlePath:"app/api/auth/login/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/auth/login/route.ts",nextConfigOutput:"standalone",userland:a}),{workAsyncStorage:h,workUnitAsyncStorage:f,serverHooks:v}=y;function w(){return(0,i.patchFetch)({workAsyncStorage:h,workUnitAsyncStorage:f})}},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[4447,580,3205],()=>t(87972));module.exports=a})();