"use strict";(()=>{var e={};e.id=9636,e.ids=[9636],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},88336:(e,r,t)=>{t.r(r),t.d(r,{headerHooks:()=>P,originalPathname:()=>f,requestAsyncStorage:()=>l,routeModule:()=>c,serverHooks:()=>p,staticGenerationAsyncStorage:()=>m,staticGenerationBailout:()=>A});var o={};t.r(o),t.d(o,{GET:()=>i}),t(95655);var s=t(83323),a=t(54647),n=t(66886),u=t(30953);async function i(e){try{let{searchParams:r}=new URL(e.url),t=r.get("q"),o={};if(t){let e=!isNaN(Number(t));o.OR=[{email:{contains:t}},{name:{contains:t}},{phone:{contains:t}},{id:{equals:t}},{orders:{some:{OR:[{id:{contains:t}},...e?[{orderNumber:{equals:Number(t)}}]:[]]}}}]}let s=await u._.customer.findMany({where:o,include:{_count:{select:{orders:!0}},orders:{take:1,orderBy:{createdAt:"desc"},select:{createdAt:!0}}},orderBy:{createdAt:"desc"}}),a=s.map(e=>({...e,orderCount:e._count.orders,lastOrderDate:e.orders[0]?.createdAt||null}));return n.Z.json(a)}catch(e){return console.error("Error fetching customers:",e),n.Z.json({error:"Error fetching customers"},{status:500})}}let d=s.AppRouteRouteModule,c=new d({definition:{kind:a.x.APP_ROUTE,page:"/api/customers/route",pathname:"/api/customers",filename:"route",bundlePath:"app/api/customers/route"},resolvedPagePath:".\\app\\api\\customers\\route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:l,staticGenerationAsyncStorage:m,serverHooks:p,headerHooks:P,staticGenerationBailout:A}=c,f="/api/customers/route"},30953:(e,r,t)=>{t.d(r,{_:()=>a});var o=t(53524);let s=globalThis,a=s.prisma??new o.PrismaClient},54647:(e,r)=>{var t;Object.defineProperty(r,"x",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(t||(t={}))}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[9727,3497,6886],()=>t(88336));module.exports=o})();