module.exports=[70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},23862,e=>e.a(async(t,r)=>{try{let t=await e.y("pg-587764f78a6c7a9c");e.n(t),r()}catch(e){r(e)}},!0),62294,e=>e.a(async(t,r)=>{try{let s;var n=e.i(23862),a=t([n]);async function o(e,t){let r=function(){if(!s){let e=process.env.DATABASE_URL;if(!e)throw Error("DATABASE_URL environment variable is not set");(s=new n.Pool({connectionString:e,ssl:{rejectUnauthorized:!1}})).on("error",e=>{console.error("Unexpected error on idle client",e),process.exit(-1)})}return s}();Date.now();let a=await r.query(e,t);return Date.now(),a}[n]=a.then?(await a)():a,e.s(["query",()=>o]),r()}catch(e){r(e)}},!1),66680,(e,t,r)=>{t.exports=e.x("node:crypto",()=>require("node:crypto"))},57688,e=>{"use strict";let t,r;var n=e.i(66680);function a(){return function(e=21){var a;a=e|=0,!t||t.length<a?(t=Buffer.allocUnsafe(128*a),n.webcrypto.getRandomValues(t),r=0):r+a>t.length&&(n.webcrypto.getRandomValues(t),r=0),r+=a;let o="";for(let n=r-e;n<r;n++)o+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[n]];return o}()}function o(e){return{id:e.id,name:e.name,email:e.email,phone:e.phone,company:e.company,address:e.address,notes:e.notes,createdAt:e.createdAt,updatedAt:e.updatedAt}}function s(e){return{id:e.id,email:e.email,name:e.name,image:e.image,createdAt:e.createdAt,updatedAt:e.updatedAt}}function i(e){return{id:e.id,description:e.description,startTime:e.startTime,endTime:e.endTime,duration:e.duration,createdAt:e.createdAt,updatedAt:e.updatedAt,customerId:e.customerId,userId:e.userId}}e.s(["generateId",()=>a,"rowToCustomer",()=>o,"rowToTimeEntry",()=>i,"rowToUser",()=>s],57688)},28503,e=>e.a(async(t,r)=>{try{var n=e.i(89171),a=e.i(62294),o=e.i(57688),s=t([a]);async function i(e,{params:t}){try{let{id:e}=await t,r=await (0,a.query)("SELECT * FROM customers WHERE id = $1",[e]);if(0===r.rows.length)return n.NextResponse.json({error:"Customer not found"},{status:404});let s=(0,o.rowToCustomer)(r.rows[0]),i=(await (0,a.query)(`SELECT te.*, 
        json_build_object(
          'name', u.name,
          'email', u.email
        ) as user
       FROM time_entries te
       LEFT JOIN users u ON u.id = te."userId"
       WHERE te."customerId" = $1
       ORDER BY te."createdAt" DESC`,[e])).rows.map(e=>({id:e.id,description:e.description,startTime:e.startTime,endTime:e.endTime,duration:e.duration,createdAt:e.createdAt,updatedAt:e.updatedAt,customerId:e.customerId,userId:e.userId,user:"string"==typeof e.user?JSON.parse(e.user):e.user}));return n.NextResponse.json({...s,timeEntries:i})}catch(e){return console.error("Error fetching customer:",e),n.NextResponse.json({error:"Failed to fetch customer"},{status:500})}}async function u(e,{params:t}){try{let{id:r}=await t,{name:s,email:i,phone:u,company:d,address:l,notes:c}=await e.json();if(!s)return n.NextResponse.json({error:"Name is required"},{status:400});let p=await (0,a.query)(`UPDATE customers 
       SET name = $1, email = $2, phone = $3, company = $4, address = $5, notes = $6, "updatedAt" = $7
       WHERE id = $8
       RETURNING *`,[s,i||null,u||null,d||null,l||null,c||null,new Date,r]);if(0===p.rows.length)return n.NextResponse.json({error:"Customer not found"},{status:404});let m=(0,o.rowToCustomer)(p.rows[0]);return n.NextResponse.json(m)}catch(e){return console.error("Error updating customer:",e),n.NextResponse.json({error:"Failed to update customer"},{status:500})}}async function d(e,{params:t}){try{let{id:e}=await t;return await (0,a.query)("DELETE FROM customers WHERE id = $1",[e]),n.NextResponse.json({success:!0})}catch(e){return console.error("Error deleting customer:",e),n.NextResponse.json({error:"Failed to delete customer"},{status:500})}}[a]=s.then?(await s)():s,e.s(["DELETE",()=>d,"GET",()=>i,"PUT",()=>u]),r()}catch(e){r(e)}},!1),98611,e=>e.a(async(t,r)=>{try{var n=e.i(47909),a=e.i(74017),o=e.i(96250),s=e.i(59756),i=e.i(61916),u=e.i(74677),d=e.i(69741),l=e.i(16795),c=e.i(87718),p=e.i(95169),m=e.i(47587),h=e.i(66012),R=e.i(70101),x=e.i(26937),E=e.i(10372),w=e.i(93695);e.i(52474);var f=e.i(220),y=e.i(28503),g=t([y]);[y]=g.then?(await g)():g;let T=new n.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/customers/[id]/route",pathname:"/api/customers/[id]",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/customers/[id]/route.ts",nextConfigOutput:"standalone",userland:y}),{workAsyncStorage:C,workUnitAsyncStorage:N,serverHooks:b}=T;function v(){return(0,o.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:N})}async function A(e,t,r){T.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let n="/api/customers/[id]/route";n=n.replace(/\/index$/,"")||"/";let o=await T.prepare(e,t,{srcPage:n,multiZoneDraftMode:!1});if(!o)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:y,params:g,nextConfig:v,parsedUrl:A,isDraftMode:C,prerenderManifest:N,routerServerContext:b,isOnDemandRevalidate:j,revalidateOnlyGenerated:q,resolvedPathname:I,clientReferenceManifest:O,serverActionsManifest:P}=o,S=(0,d.normalizeAppPath)(n),U=!!(N.dynamicRoutes[S]||N.routes[I]),_=async()=>((null==b?void 0:b.render404)?await b.render404(e,t,A,!1):t.end("This page could not be found"),null);if(U&&!C){let e=!!N.routes[I],t=N.dynamicRoutes[S];if(t&&!1===t.fallback&&!e){if(v.experimental.adapterPath)return await _();throw new w.NoFallbackError}}let D=null;!U||T.isDev||C||(D=I,D="/index"===D?"/":D);let k=!0===T.isDev||!U,H=U&&!k;P&&O&&(0,u.setManifestsSingleton)({page:n,clientReferenceManifest:O,serverActionsManifest:P});let $=e.method||"GET",F=(0,i.getTracer)(),M=F.getActiveScopeSpan(),L={params:g,prerenderManifest:N,renderOpts:{experimental:{authInterrupts:!!v.experimental.authInterrupts},cacheComponents:!!v.cacheComponents,supportsDynamicResponse:k,incrementalCache:(0,s.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:v.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,n,a)=>T.onRequestError(e,t,n,a,b)},sharedContext:{buildId:y}},B=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),W=c.NextRequestAdapter.fromNodeNextRequest(B,(0,c.signalFromNodeResponse)(t));try{let o=async e=>T.handle(W,L).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==p.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${$} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t)}else e.updateName(`${$} ${n}`)}),u=!!(0,s.getRequestMeta)(e,"minimalMode"),d=async s=>{var i,d;let l=async({previousCacheEntry:a})=>{try{if(!u&&j&&q&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let n=await o(s);e.fetchMetrics=L.renderOpts.fetchMetrics;let i=L.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let d=L.renderOpts.collectedTags;if(!U)return await (0,h.sendResponse)(B,K,n,L.renderOpts.pendingWaitUntil),null;{let e=await n.blob(),t=(0,R.toNodeOutgoingHttpHeaders)(n.headers);d&&(t[E.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==L.renderOpts.collectedRevalidate&&!(L.renderOpts.collectedRevalidate>=E.INFINITE_CACHE)&&L.renderOpts.collectedRevalidate,a=void 0===L.renderOpts.collectedExpire||L.renderOpts.collectedExpire>=E.INFINITE_CACHE?void 0:L.renderOpts.collectedExpire;return{value:{kind:f.CachedRouteKind.APP_ROUTE,status:n.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==a?void 0:a.isStale)&&await T.onRequestError(e,t,{routerKind:"App Router",routePath:n,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:j})},!1,b),t}},c=await T.handleResponse({req:e,nextConfig:v,cacheKey:D,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:j,revalidateOnlyGenerated:q,responseGenerator:l,waitUntil:r.waitUntil,isMinimalMode:u});if(!U)return null;if((null==c||null==(i=c.value)?void 0:i.kind)!==f.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(d=c.value)?void 0:d.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});u||t.setHeader("x-nextjs-cache",j?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let p=(0,R.fromNodeOutgoingHttpHeaders)(c.value.headers);return u&&U||p.delete(E.NEXT_CACHE_TAGS_HEADER),!c.cacheControl||t.getHeader("Cache-Control")||p.get("Cache-Control")||p.set("Cache-Control",(0,x.getCacheControlHeader)(c.cacheControl)),await (0,h.sendResponse)(B,K,new Response(c.value.body,{headers:p,status:c.value.status||200})),null};M?await d(M):await F.withPropagatedContext(e.headers,()=>F.trace(p.BaseServerSpan.handleRequest,{spanName:`${$} ${n}`,kind:i.SpanKind.SERVER,attributes:{"http.method":$,"http.target":e.url}},d))}catch(t){if(t instanceof w.NoFallbackError||await T.onRequestError(e,t,{routerKind:"App Router",routePath:S,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:j})},!1,b),U)throw t;return await (0,h.sendResponse)(B,K,new Response(null,{status:500})),null}}e.s(["handler",()=>A,"patchFetch",()=>v,"routeModule",()=>T,"serverHooks",()=>b,"workAsyncStorage",()=>C,"workUnitAsyncStorage",()=>N]),r()}catch(e){r(e)}},!1)];

//# sourceMappingURL=%5Broot-of-the-server%5D__07d89bc0._.js.map