(()=>{var e={};e.id=2370,e.ids=[2370],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,r,s)=>{"use strict";function t(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function i(e){let r=e.headers.get("authorization");if(r&&r.startsWith("Bearer "))return r.slice(7);let s=e.cookies.get("admin_token")?.value;if(s)return s;let t=e.cookies.get("token")?.value;return t||null}s.d(r,{V:()=>i,u:()=>t})},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")},91847:(e,r,s)=>{"use strict";s.r(r),s.d(r,{patchFetch:()=>g,routeModule:()=>f,serverHooks:()=>w,workAsyncStorage:()=>h,workUnitAsyncStorage:()=>v});var t={};s.r(t),s.d(t,{PUT:()=>x});var i=s(96559),n=s(48088),a=s(37719),o=s(32190),u=s(43205),p=s.n(u),d=s(96330),c=s(12909);let l=new d.PrismaClient,m=(0,c.u)();async function y(e){let r=(0,c.V)(e);if(!r)return null;try{let e=p().verify(r,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function x(e,{params:r}){try{if(!await y(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let s=await Promise.resolve(r),t=parseInt(s.id),i=parseInt(s.userId);if(isNaN(t)||isNaN(i))return o.NextResponse.json({error:"Invalid company ID or user ID"},{status:400});let{systemPermissions:n}=await e.json();if(!await l.user.findFirst({where:{id:i,companyId:t}}))return o.NextResponse.json({error:"User not found or does not belong to this company"},{status:404});await l.$transaction(async e=>{await e.userSystemPermission.deleteMany({where:{userId:i}}),Array.isArray(n)&&n.length>0&&await e.userSystemPermission.createMany({data:n.map(e=>({userId:i,permission:e}))})});let a=await l.user.findUnique({where:{id:i},include:{systemPermissions:!0}});return o.NextResponse.json({message:"System permissions updated successfully",user:a})}catch(e){return console.error("Update user system permissions error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let f=new i.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/admin/companies/[id]/users/[userId]/system-permissions/route",pathname:"/api/admin/companies/[id]/users/[userId]/system-permissions",filename:"route",bundlePath:"app/api/admin/companies/[id]/users/[userId]/system-permissions/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/companies/[id]/users/[userId]/system-permissions/route.ts",nextConfigOutput:"standalone",userland:t}),{workAsyncStorage:h,workUnitAsyncStorage:v,serverHooks:w}=f;function g(){return(0,a.patchFetch)({workAsyncStorage:h,workUnitAsyncStorage:v})}},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var r=require("../../../../../../../../webpack-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[4447,580,3205],()=>s(91847));module.exports=t})();