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 o;var a=e.i(23862),n=t([a]);async function s(e,t){let r=function(){if(!o){let e=process.env.DATABASE_URL;if(!e)throw Error("DATABASE_URL environment variable is not set");(o=new a.Pool({connectionString:e,ssl:{rejectUnauthorized:!1}})).on("error",e=>{console.error("Unexpected error on idle client",e),process.exit(-1)})}return o}();Date.now();let n=await r.query(e,t);return Date.now(),n}[a]=n.then?(await n)():n,e.s(["query",()=>s]),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 a=e.i(66680);function n(){return function(e=21){var n;n=e|=0,!t||t.length<n?(t=Buffer.allocUnsafe(128*n),a.webcrypto.getRandomValues(t),r=0):r+n>t.length&&(a.webcrypto.getRandomValues(t),r=0),r+=n;let s="";for(let a=r-e;a<r;a++)s+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&t[a]];return s}()}function s(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 o(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",()=>n,"rowToCustomer",()=>s,"rowToTimeEntry",()=>i,"rowToUser",()=>o],57688)},21670,e=>e.a(async(t,r)=>{try{var a=e.i(89171),n=e.i(62294),s=e.i(57688),o=t([n]);async function i(e){try{let t=e.nextUrl.searchParams,r=t.get("customerId"),o=t.get("userId"),i=`
      SELECT te.*,
        json_build_object(
          'id', c.id,
          'name', c.name,
          'company', c.company
        ) as customer,
        json_build_object(
          'id', u.id,
          'name', u.name,
          'email', u.email
        ) as user
      FROM time_entries te
      LEFT JOIN customers c ON c.id = te."customerId"
      LEFT JOIN users u ON u.id = te."userId"
      WHERE 1=1
    `,d=[],u=0;r&&(u++,i+=` AND te."customerId" = $${u}`,d.push(r)),o&&(u++,i+=` AND te."userId" = $${u}`,d.push(o)),i+=' ORDER BY te."createdAt" DESC';let l=(await (0,n.query)(i,d.length>0?d:void 0)).rows.map(e=>({...(0,s.rowToTimeEntry)(e),customer:"string"==typeof e.customer?JSON.parse(e.customer):e.customer,user:"string"==typeof e.user?JSON.parse(e.user):e.user}));return a.NextResponse.json(l)}catch(e){return console.error("Error fetching time entries:",e),a.NextResponse.json({error:"Failed to fetch time entries"},{status:500})}}async function d(e){try{let{description:t,startTime:r,endTime:o,duration:i,customerId:d,userId:u}=await e.json();if(!t||!d||!u)return a.NextResponse.json({error:"Description, customerId, and userId are required"},{status:400});let l=(0,s.generateId)(),c=new Date,p=await (0,n.query)(`INSERT INTO time_entries (id, description, "startTime", "endTime", duration, "customerId", "userId", "createdAt", "updatedAt")
       VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
       RETURNING *`,[l,t,new Date(r),new Date(o),parseInt(String(i),10),d,u,c,c]),m=(0,s.rowToTimeEntry)(p.rows[0]),h=await (0,n.query)("SELECT id, name, company FROM customers WHERE id = $1",[d]),R=await (0,n.query)("SELECT id, name, email FROM users WHERE id = $1",[u]);return a.NextResponse.json({...m,customer:h.rows[0]||null,user:R.rows[0]||null},{status:201})}catch(e){return console.error("Error creating time entry:",e),a.NextResponse.json({error:"Failed to create time entry"},{status:500})}}[n]=o.then?(await o)():o,e.s(["GET",()=>i,"POST",()=>d]),r()}catch(e){r(e)}},!1),6426,e=>e.a(async(t,r)=>{try{var a=e.i(47909),n=e.i(74017),s=e.i(96250),o=e.i(59756),i=e.i(61916),d=e.i(74677),u=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),y=e.i(10372),E=e.i(93695);e.i(52474);var w=e.i(220),f=e.i(21670),g=t([f]);[f]=g.then?(await g)():g;let T=new a.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/time-entries/route",pathname:"/api/time-entries",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/app/api/time-entries/route.ts",nextConfigOutput:"standalone",userland:f}),{workAsyncStorage:C,workUnitAsyncStorage:N,serverHooks:I}=T;function v(){return(0,s.patchFetch)({workAsyncStorage:C,workUnitAsyncStorage:N})}async function A(e,t,r){T.isDev&&(0,o.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let a="/api/time-entries/route";a=a.replace(/\/index$/,"")||"/";let s=await T.prepare(e,t,{srcPage:a,multiZoneDraftMode:!1});if(!s)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:f,params:g,nextConfig:v,parsedUrl:A,isDraftMode:C,prerenderManifest:N,routerServerContext:I,isOnDemandRevalidate:b,revalidateOnlyGenerated:O,resolvedPathname:S,clientReferenceManifest:j,serverActionsManifest:q}=s,_=(0,u.normalizeAppPath)(a),P=!!(N.dynamicRoutes[_]||N.routes[S]),D=async()=>((null==I?void 0:I.render404)?await I.render404(e,t,A,!1):t.end("This page could not be found"),null);if(P&&!C){let e=!!N.routes[S],t=N.dynamicRoutes[_];if(t&&!1===t.fallback&&!e){if(v.experimental.adapterPath)return await D();throw new E.NoFallbackError}}let U=null;!P||T.isDev||C||(U=S,U="/index"===U?"/":U);let $=!0===T.isDev||!P,k=P&&!$;q&&j&&(0,d.setManifestsSingleton)({page:a,clientReferenceManifest:j,serverActionsManifest:q});let H=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:$,incrementalCache:(0,o.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:v.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>T.onRequestError(e,t,a,n,I)},sharedContext:{buildId:f}},B=new l.NodeNextRequest(e),K=new l.NodeNextResponse(t),V=c.NextRequestAdapter.fromNodeNextRequest(B,(0,c.signalFromNodeResponse)(t));try{let s=async e=>T.handle(V,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 n=r.get("next.route");if(n){let t=`${H} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${H} ${a}`)}),d=!!(0,o.getRequestMeta)(e,"minimalMode"),u=async o=>{var i,u;let l=async({previousCacheEntry:n})=>{try{if(!d&&b&&O&&!n)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await s(o);e.fetchMetrics=L.renderOpts.fetchMetrics;let i=L.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let u=L.renderOpts.collectedTags;if(!P)return await (0,h.sendResponse)(B,K,a,L.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,R.toNodeOutgoingHttpHeaders)(a.headers);u&&(t[y.NEXT_CACHE_TAGS_HEADER]=u),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==L.renderOpts.collectedRevalidate&&!(L.renderOpts.collectedRevalidate>=y.INFINITE_CACHE)&&L.renderOpts.collectedRevalidate,n=void 0===L.renderOpts.collectedExpire||L.renderOpts.collectedExpire>=y.INFINITE_CACHE?void 0:L.renderOpts.collectedExpire;return{value:{kind:w.CachedRouteKind.APP_ROUTE,status:a.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:n}}}}catch(t){throw(null==n?void 0:n.isStale)&&await T.onRequestError(e,t,{routerKind:"App Router",routePath:a,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:k,isOnDemandRevalidate:b})},!1,I),t}},c=await T.handleResponse({req:e,nextConfig:v,cacheKey:U,routeKind:n.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:N,isRoutePPREnabled:!1,isOnDemandRevalidate:b,revalidateOnlyGenerated:O,responseGenerator:l,waitUntil:r.waitUntil,isMinimalMode:d});if(!P)return null;if((null==c||null==(i=c.value)?void 0:i.kind)!==w.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(u=c.value)?void 0:u.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});d||t.setHeader("x-nextjs-cache",b?"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 d&&P||p.delete(y.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 u(M):await F.withPropagatedContext(e.headers,()=>F.trace(p.BaseServerSpan.handleRequest,{spanName:`${H} ${a}`,kind:i.SpanKind.SERVER,attributes:{"http.method":H,"http.target":e.url}},u))}catch(t){if(t instanceof E.NoFallbackError||await T.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,m.getRevalidateReason)({isStaticGeneration:k,isOnDemandRevalidate:b})},!1,I),P)throw t;return await (0,h.sendResponse)(B,K,new Response(null,{status:500})),null}}e.s(["handler",()=>A,"patchFetch",()=>v,"routeModule",()=>T,"serverHooks",()=>I,"workAsyncStorage",()=>C,"workUnitAsyncStorage",()=>N]),r()}catch(e){r(e)}},!1)];

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