(()=>{var e={};e.id=6073,e.ids=[6073],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")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},93032:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>y,routeModule:()=>k,serverHooks:()=>j,workAsyncStorage:()=>v,workUnitAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{GET:()=>m,POST:()=>f});var n=t(96559),a=t(48088),o=t(37719),i=t(32190),u=t(43205),c=t.n(u),d=t(96330),p=t(12909);let l=new d.PrismaClient,x=(0,p.u)();async function m(e){try{let r,t=(0,p.V)(e);if(!t)return i.NextResponse.json({error:"Unauthorized"},{status:401});try{r=c().verify(t,x)}catch{return i.NextResponse.json({error:"Invalid token"},{status:401})}if(!r.userId)return i.NextResponse.json({error:"Unauthorized"},{status:401});let s=await l.ticket.findMany({where:{userId:r.userId},include:{messages:{orderBy:{createdAt:"asc"},take:1},user:{select:{name:!0,surname:!0,email:!0}}},orderBy:{updatedAt:"desc"}});return i.NextResponse.json({tickets:s})}catch(e){return console.error("Get tickets error:",e),i.NextResponse.json({error:"Server error"},{status:500})}finally{await l.$disconnect()}}async function f(e){try{let r,t=(0,p.V)(e);if(!t)return i.NextResponse.json({error:"Unauthorized"},{status:401});try{r=c().verify(t,x)}catch{return i.NextResponse.json({error:"Invalid token"},{status:401})}if(!r.userId)return i.NextResponse.json({error:"Unauthorized"},{status:401});let{title:s,message:n}=await e.json();if(!s||!n)return i.NextResponse.json({error:"Başlık ve mesaj gereklidir"},{status:400});let a=await l.ticket.create({data:{userId:r.userId,title:s,status:"OPEN",messages:{create:{userId:r.userId,message:n,isFromAdmin:!1}}},include:{messages:!0,user:{select:{name:!0,surname:!0,email:!0}}}});return i.NextResponse.json({ticket:a},{status:201})}catch(e){return console.error("Create ticket error:",e),i.NextResponse.json({error:"Server error"},{status:500})}finally{await l.$disconnect()}}let k=new n.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/tickets/route",pathname:"/api/tickets",filename:"route",bundlePath:"app/api/tickets/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/tickets/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:v,workUnitAsyncStorage:h,serverHooks:j}=k;function y(){return(0,o.patchFetch)({workAsyncStorage:v,workUnitAsyncStorage:h})}},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(93032));module.exports=s})();