"use strict";(()=>{var e={};e.id=961,e.ids=[961],e.modules={53524:e=>{e.exports=require("@prisma/client")},72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},27790:e=>{e.exports=require("assert")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},86624:e=>{e.exports=require("querystring")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},39639:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>q,patchFetch:()=>w,requestAsyncStorage:()=>g,routeModule:()=>x,serverHooks:()=>h,staticGenerationAsyncStorage:()=>y});var s={};t.r(s),t.d(s,{GET:()=>d,POST:()=>m,dynamic:()=>p});var a=t(49303),o=t(88716),n=t(60670),i=t(87070),l=t(75571),c=t(90455),u=t(72331);let p="force-dynamic";async function d(){try{let e=await u._.category.findMany({orderBy:{order:"asc"},include:{_count:{select:{vehicles:!0}},children:{orderBy:{order:"asc"},include:{_count:{select:{vehicles:!0}}}}}});return i.NextResponse.json(e??[])}catch(e){return console.error("Categories GET error:",e),i.NextResponse.json({error:"Failed to fetch"},{status:500})}}async function m(e){try{if(!await (0,l.getServerSession)(c.L))return i.NextResponse.json({error:"Unauthorized"},{status:401});let r=await e.json(),t=(r?.name??"category").toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-"),s=await u._.category.create({data:{name:r?.name??"",nameEn:r?.nameEn??null,slug:t,description:r?.description??null,imageUrl:r?.imageUrl??null,order:r?.order??0,parentId:r?.parentId??null}});return i.NextResponse.json(s)}catch(e){return console.error("Category create error:",e),i.NextResponse.json({error:"Failed to create"},{status:500})}}let x=new a.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/categories/route",pathname:"/api/categories",filename:"route",bundlePath:"app/api/categories/route"},resolvedPagePath:"/Users/jarolsanchez/Desktop/evotrucks/nextjs_space/app/api/categories/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:g,staticGenerationAsyncStorage:y,serverHooks:h}=x,q="/api/categories/route";function w(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:y})}},90455:(e,r,t)=>{t.d(r,{L:()=>i});var s=t(53797),a=t(42023),o=t.n(a),n=t(72331);let i={providers:[(0,s.Z)({name:"credentials",credentials:{email:{label:"Email",type:"email"},password:{label:"Password",type:"password"}},async authorize(e){if(!e?.email||!e?.password)return null;try{let r=await n._.user.findUnique({where:{email:e.email}});if(!r||!await o().compare(e.password,r.password))return null;return{id:r.id,email:r.email,name:r.name,role:r.role}}catch{return null}}})],session:{strategy:"jwt"},callbacks:{jwt:async({token:e,user:r})=>(r&&(e.role=r?.role,e.id=r?.id),e),session:async({session:e,token:r})=>(e?.user&&(e.user.role=r?.role,e.user.id=r?.id),e)},pages:{signIn:"/admin/login"},secret:process.env.NEXTAUTH_SECRET}},72331:(e,r,t)=>{t.d(r,{_:()=>a});var s=t(53524);let a=globalThis.prisma||new s.PrismaClient}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[948,598,70,790],()=>t(39639));module.exports=s})();