(()=>{var e={};e.id=8417,e.ids=[8417],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,t,r)=>{"use strict";function s(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function i(e){let t=e.headers.get("authorization");if(t&&t.startsWith("Bearer "))return t.slice(7);let r=e.cookies.get("admin_token")?.value;if(r)return r;let s=e.cookies.get("token")?.value;return s||null}r.d(t,{V:()=>i,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")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{},98172:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>h,routeModule:()=>f,serverHooks:()=>y,workAsyncStorage:()=>k,workUnitAsyncStorage:()=>v});var s={};r.r(s),r.d(s,{GET:()=>g});var i=r(96559),n=r(48088),a=r(37719),u=r(32190),o=r(43205),c=r.n(o),d=r(96330),l=r(12909);let p=new d.PrismaClient,m=(0,l.u)();async function x(e){let t=(0,l.V)(e);if(!t)return null;try{let e=c().verify(t,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function g(e){try{if(!await x(e))return u.NextResponse.json({error:"Unauthorized"},{status:401});let{searchParams:t}=new URL(e.url),r=t.get("status"),s={};r&&["OPEN","IN_PROGRESS","RESOLVED","CLOSED"].includes(r)&&(s.status=r);let i=await p.ticket.findMany({where:s,include:{user:{select:{id:!0,name:!0,surname:!0,email:!0,company:{select:{id:!0,name:!0}}}},messages:{orderBy:{createdAt:"desc"},take:1},_count:{select:{messages:!0}}},orderBy:{updatedAt:"desc"}});return await p.$disconnect(),u.NextResponse.json({tickets:i.map(e=>({id:e.id,title:e.title,status:e.status,createdAt:e.createdAt.toISOString(),updatedAt:e.updatedAt.toISOString(),user:e.user,lastMessage:e.messages[0]||null,messageCount:e._count.messages}))})}catch(e){return console.error("Get tickets error:",e),await p.$disconnect(),u.NextResponse.json({error:"Server error"},{status:500})}}let f=new i.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/admin/tickets/route",pathname:"/api/admin/tickets",filename:"route",bundlePath:"app/api/admin/tickets/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/tickets/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:k,workUnitAsyncStorage:v,serverHooks:y}=f;function h(){return(0,a.patchFetch)({workAsyncStorage:k,workUnitAsyncStorage:v})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[4447,580,3205],()=>r(98172));module.exports=s})();