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),64769,e=>e.a(async(t,r)=>{try{var a=e.i(23862),n=t([a]);[a]=n.then?(await n)():n;let o=new a.Pool({host:"209.74.80.58",port:5432,user:"rrgnihyq_admin_domiblocks",password:"D0miblocks#2026",database:"rrgnihyq_DOMIBLOCKS_OPS",max:5,idleTimeoutMillis:3e4,connectionTimeoutMillis:1e4});o.on("error",e=>{console.error("❌ [DB OPS ERROR]:",e.message)}),e.s(["default",0,o,"queryOps",0,(e,t)=>o.query(e,t)]),r()}catch(e){r(e)}},!1),68119,e=>e.a(async(t,r)=>{try{var a=e.i(89171),n=e.i(64769),o=t([n]);async function s(e){let t;try{let{pedidos:r}=await e.json();if(!r||!Array.isArray(r))return a.NextResponse.json({error:"Formato de datos inválido"},{status:400});let o=[];for(let e of(t=await n.default.connect(),r))try{await t.query("BEGIN");let r=await t.query('SELECT id FROM "Pedido" WHERE "numeroPedidoLocal" = $1',[e.numeroPedidoLocal]);if(r.rows.length>0){o.push({idLocal:e.numeroPedidoLocal,status:"already_exists",idServer:r.rows[0].id}),await t.query("ROLLBACK");continue}let a=`
          INSERT INTO "Pedido" (
            id, "numeroPedidoLocal", "vendedorId", "clienteId", "clienteNombre", 
            estado, subtotal, impuestos, total, "notasEntrega", "clienteDireccion", sincronizado, "createdAt", "updatedAt"
          ) VALUES (
            $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, NOW(), NOW()
          ) RETURNING id;
        `,n=`srv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,s=[n,e.numeroPedidoLocal,e.vendedorId,e.clienteId,e.clienteNombre,"pendiente",parseFloat(e.subtotal),parseFloat(e.impuestos),parseFloat(e.total),e.notasEntrega||"",e.localidad||"",!0];await t.query(a,s);let i=`
          INSERT INTO "ItemPedido" (
            id, "pedidoId", "productoId", "productoNombre", cantidad, "precioUnitario"
          ) VALUES ($1, $2, $3, $4, $5, $6);
        `;for(let r of e.items){let e=`itm_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;await t.query(i,[e,n,r.productoId,r.productoNombre,parseInt(r.cantidad),parseFloat(r.precioUnitario)])}await t.query("COMMIT"),o.push({idLocal:e.numeroPedidoLocal,status:"success",idServer:n})}catch(a){await t.query("ROLLBACK");let r=a.message||String(a);console.error(`❌ Error guardando pedido ${e.numeroPedidoLocal}:`,r),o.push({idLocal:e.numeroPedidoLocal,status:"error",message:r})}return a.NextResponse.json({success:!0,resultados:o})}catch(e){return console.error("Error en Sync API:",e.message),a.NextResponse.json({error:"Error interno de sincronización",details:e.message},{status:500})}finally{t&&t.release()}}[n]=o.then?(await o)():o,e.s(["POST",()=>s]),r()}catch(e){r(e)}},!1),68723,e=>e.a(async(t,r)=>{try{var a=e.i(47909),n=e.i(74017),o=e.i(96250),s=e.i(59756),i=e.i(61916),d=e.i(74677),l=e.i(69741),u=e.i(16795),c=e.i(87718),p=e.i(95169),h=e.i(47587),m=e.i(66012),R=e.i(70101),x=e.i(26937),y=e.i(10372),g=e.i(93695);e.i(52474);var v=e.i(220),w=e.i(68119),E=t([w]);[w]=E.then?(await E)():E;let N=new a.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/pedidos/sync/route",pathname:"/api/pedidos/sync",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/pedidos/sync/route.ts",nextConfigOutput:"standalone",userland:w}),{workAsyncStorage:P,workUnitAsyncStorage:b,serverHooks:A}=N;function f(){return(0,o.patchFetch)({workAsyncStorage:P,workUnitAsyncStorage:b})}async function C(e,t,r){N.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let a="/api/pedidos/sync/route";a=a.replace(/\/index$/,"")||"/";let o=await N.prepare(e,t,{srcPage:a,multiZoneDraftMode:!1});if(!o)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:w,params:E,nextConfig:f,parsedUrl:C,isDraftMode:P,prerenderManifest:b,routerServerContext:A,isOnDemandRevalidate:O,revalidateOnlyGenerated:S,resolvedPathname:T,clientReferenceManifest:I,serverActionsManifest:$}=o,q=(0,l.normalizeAppPath)(a),_=!!(b.dynamicRoutes[q]||b.routes[T]),L=async()=>((null==A?void 0:A.render404)?await A.render404(e,t,C,!1):t.end("This page could not be found"),null);if(_&&!P){let e=!!b.routes[T],t=b.dynamicRoutes[q];if(t&&!1===t.fallback&&!e){if(f.experimental.adapterPath)return await L();throw new g.NoFallbackError}}let k=null;!_||N.isDev||P||(k=T,k="/index"===k?"/":k);let j=!0===N.isDev||!_,U=_&&!j;$&&I&&(0,d.setManifestsSingleton)({page:a,clientReferenceManifest:I,serverActionsManifest:$});let M=e.method||"GET",D=(0,i.getTracer)(),H=D.getActiveScopeSpan(),F={params:E,prerenderManifest:b,renderOpts:{experimental:{authInterrupts:!!f.experimental.authInterrupts},cacheComponents:!!f.cacheComponents,supportsDynamicResponse:j,incrementalCache:(0,s.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:f.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,n)=>N.onRequestError(e,t,a,n,A)},sharedContext:{buildId:w}},K=new u.NodeNextRequest(e),B=new u.NodeNextResponse(t),G=c.NextRequestAdapter.fromNodeNextRequest(K,(0,c.signalFromNodeResponse)(t));try{let o=async e=>N.handle(G,F).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=D.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=`${M} ${n}`;e.setAttributes({"next.route":n,"http.route":n,"next.span_name":t}),e.updateName(t)}else e.updateName(`${M} ${a}`)}),d=!!(0,s.getRequestMeta)(e,"minimalMode"),l=async s=>{var i,l;let u=async({previousCacheEntry:n})=>{try{if(!d&&O&&S&&!n)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let a=await o(s);e.fetchMetrics=F.renderOpts.fetchMetrics;let i=F.renderOpts.pendingWaitUntil;i&&r.waitUntil&&(r.waitUntil(i),i=void 0);let l=F.renderOpts.collectedTags;if(!_)return await (0,m.sendResponse)(K,B,a,F.renderOpts.pendingWaitUntil),null;{let e=await a.blob(),t=(0,R.toNodeOutgoingHttpHeaders)(a.headers);l&&(t[y.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==F.renderOpts.collectedRevalidate&&!(F.renderOpts.collectedRevalidate>=y.INFINITE_CACHE)&&F.renderOpts.collectedRevalidate,n=void 0===F.renderOpts.collectedExpire||F.renderOpts.collectedExpire>=y.INFINITE_CACHE?void 0:F.renderOpts.collectedExpire;return{value:{kind:v.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 N.onRequestError(e,t,{routerKind:"App Router",routePath:a,routeType:"route",revalidateReason:(0,h.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:O})},!1,A),t}},c=await N.handleResponse({req:e,nextConfig:f,cacheKey:k,routeKind:n.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:b,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:S,responseGenerator:u,waitUntil:r.waitUntil,isMinimalMode:d});if(!_)return null;if((null==c||null==(i=c.value)?void 0:i.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==c||null==(l=c.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});d||t.setHeader("x-nextjs-cache",O?"REVALIDATED":c.isMiss?"MISS":c.isStale?"STALE":"HIT"),P&&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.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,m.sendResponse)(K,B,new Response(c.value.body,{headers:p,status:c.value.status||200})),null};H?await l(H):await D.withPropagatedContext(e.headers,()=>D.trace(p.BaseServerSpan.handleRequest,{spanName:`${M} ${a}`,kind:i.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},l))}catch(t){if(t instanceof g.NoFallbackError||await N.onRequestError(e,t,{routerKind:"App Router",routePath:q,routeType:"route",revalidateReason:(0,h.getRevalidateReason)({isStaticGeneration:U,isOnDemandRevalidate:O})},!1,A),_)throw t;return await (0,m.sendResponse)(K,B,new Response(null,{status:500})),null}}e.s(["handler",()=>C,"patchFetch",()=>f,"routeModule",()=>N,"serverHooks",()=>A,"workAsyncStorage",()=>P,"workUnitAsyncStorage",()=>b]),r()}catch(e){r(e)}},!1)];

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