(()=>{var e={};e.id=4793,e.ids=[4793],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,t)=>{"use strict";function s(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function n(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 s=e.cookies.get("token")?.value;return s||null}t.d(r,{V:()=>n,u:()=>s})},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")},66879:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>g,routeModule:()=>v,serverHooks:()=>h,workAsyncStorage:()=>R,workUnitAsyncStorage:()=>w});var s={};t.r(s),t.d(s,{GET:()=>f,PUT:()=>k});var n=t(96559),i=t(48088),a=t(37719),o=t(32190),u=t(43205),c=t.n(u),d=t(96330),l=t(12909);let p=new d.PrismaClient,m=(0,l.u)();async function x(e){let r=(0,l.V)(e);if(!r)return null;try{let e=c().verify(r,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function f(e,{params:r}){try{if(!await x(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let t=await Promise.resolve(r),s=parseInt(t.id);if(isNaN(s))return o.NextResponse.json({error:"Invalid ticket ID"},{status:400});let n=await p.ticket.findUnique({where:{id:s},include:{messages:{orderBy:{createdAt:"asc"},include:{user:{select:{name:!0,surname:!0,email:!0}},globalAdmin:{select:{name:!0,surname:!0,email:!0}}}},user:{select:{id:!0,name:!0,surname:!0,email:!0,company:{select:{id:!0,name:!0}}}}}});if(!n)return o.NextResponse.json({error:"Ticket not found"},{status:404});return await p.$disconnect(),o.NextResponse.json({ticket:n})}catch(e){return console.error("Get ticket error:",e),await p.$disconnect(),o.NextResponse.json({error:"Server error"},{status:500})}}async function k(e,{params:r}){try{if(!await x(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let t=await Promise.resolve(r),s=parseInt(t.id);if(isNaN(s))return o.NextResponse.json({error:"Invalid ticket ID"},{status:400});let{status:n}=await e.json();if(!n||!["OPEN","IN_PROGRESS","RESOLVED","CLOSED"].includes(n))return o.NextResponse.json({error:"Ge\xe7erli bir durum gereklidir (OPEN, IN_PROGRESS, RESOLVED, CLOSED)"},{status:400});let i=await p.ticket.update({where:{id:s},data:{status:n},include:{messages:{orderBy:{createdAt:"asc"},include:{user:{select:{name:!0,surname:!0,email:!0}},globalAdmin:{select:{name:!0,surname:!0,email:!0}}}},user:{select:{id:!0,name:!0,surname:!0,email:!0,company:{select:{id:!0,name:!0}}}}}});return await p.$disconnect(),o.NextResponse.json({ticket:i})}catch(e){return console.error("Update ticket error:",e),await p.$disconnect(),o.NextResponse.json({error:"Server error"},{status:500})}}let v=new n.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/admin/tickets/[id]/route",pathname:"/api/admin/tickets/[id]",filename:"route",bundlePath:"app/api/admin/tickets/[id]/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/tickets/[id]/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:R,workUnitAsyncStorage:w,serverHooks:h}=v;function g(){return(0,a.patchFetch)({workAsyncStorage:R,workUnitAsyncStorage:w})}},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},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),s=r.X(0,[4447,580,3205],()=>t(66879));module.exports=s})();