module.exports=[23862,a=>a.a(async(b,c)=>{try{let b=await a.y("pg-587764f78a6c7a9c");a.n(b),c()}catch(a){c(a)}},!0),93695,(a,b,c)=>{b.exports=a.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},50645,a=>{a.n(a.i(27572))},43619,a=>{a.n(a.i(79962))},13718,a=>{a.n(a.i(85523))},18198,a=>{a.n(a.i(45518))},62212,a=>{a.n(a.i(66114))},22260,a=>a.a(async(b,c)=>{try{var d=a.i(23862),e=b([d]);[d]=e.then?(await e)():e;let f=new d.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});f.on("error",a=>{console.error("❌ [DB OPS ERROR]:",a.message)}),a.s(["queryOps",0,(a,b)=>f.query(a,b)]),c()}catch(a){c(a)}},!1),53679,a=>{"use strict";a.s(["default",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call the default export of [project]/src/components/dashboard/PedidosTable.tsx <module evaluation> from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/dashboard/PedidosTable.tsx <module evaluation>","default")},73988,a=>{"use strict";a.s(["default",()=>b]);let b=(0,a.i(11857).registerClientReference)(function(){throw Error("Attempted to call the default export of [project]/src/components/dashboard/PedidosTable.tsx from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"[project]/src/components/dashboard/PedidosTable.tsx","default")},2126,a=>{"use strict";a.i(53679);var b=a.i(73988);a.n(b)},78108,a=>a.a(async(b,c)=>{try{var d=a.i(7997),e=a.i(22260),f=a.i(2126),g=b([e]);async function h(){let a=Date.now();try{console.log("--- Consultando pedidos e items a OPS DB ---");let b=`
      SELECT 
        id, 
        "numeroPedidoLocal", 
        "vendedorId", 
        "clienteId", 
        "clienteNombre", 
        estado, 
        subtotal, 
        impuestos, 
        total, 
        "notasEntrega", 
        sincronizado,
        "fechaDespacho",
        "choferNombre",
        "vehiculoPlaca",
        "noConduce",
        "merma",
        "createdAt", 
        "updatedAt"
      FROM "Pedido"
      ORDER BY "createdAt" DESC
      LIMIT 100;
    `,c=(await (0,e.queryOps)(b)).rows;if(0===c.length)return[];let d=c.map(a=>a.id),f=`
      SELECT 
        id, "pedidoId", "productoId", "productoNombre", cantidad, "precioUnitario"
      FROM "ItemPedido"
      WHERE "pedidoId" = ANY($1);
    `,g=(await (0,e.queryOps)(f,[d])).rows,h=c.map(a=>({...a,items:g.filter(b=>b.pedidoId===a.id)})),i=(Date.now()-a)/1e3;return console.log(`✅ Consulta exitosa. Pedidos: ${c.length}, Items: ${g.length}. Tiempo: ${i}s`),JSON.parse(JSON.stringify(h))}catch(c){let b=(Date.now()-a)/1e3;return console.error(`❌ Error al obtener pedidos tras ${b}s:`,c.message),[]}}async function i(){let a=await h(),b=a.reduce((a,b)=>a+Number(b.total),0),c=a.filter(a=>"pendiente"===a.estado).length,e=a.filter(a=>"despachado"===a.estado).length,g=a.filter(a=>"en proceso"===a.estado),i={};g.forEach(a=>{a.items.forEach(a=>{i[a.productoId]||(i[a.productoId]={nombre:a.productoNombre,cantidad:0}),i[a.productoId].cantidad+=a.cantidad})});let j=Object.values(i).sort((a,b)=>b.cantidad-a.cantidad);return(0,d.jsxs)("div",{className:"p-8 bg-gray-50 min-h-screen",children:[(0,d.jsxs)("div",{className:"mb-8",children:[(0,d.jsx)("h1",{className:"text-3xl font-bold text-gray-900 tracking-tight",children:"Dashboard de Operaciones"}),(0,d.jsx)("p",{className:"text-gray-500 mt-2",children:"Gestión de despacho y logística de pedidos."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6 mb-8",children:[(0,d.jsxs)("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[(0,d.jsx)("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Total Pedidos"}),(0,d.jsx)("p",{className:"text-3xl font-black text-gray-900 mt-2",children:a.length})]}),(0,d.jsxs)("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[(0,d.jsx)("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Pendientes Despacho"}),(0,d.jsx)("p",{className:"text-3xl font-black text-orange-500 mt-2",children:c})]}),(0,d.jsxs)("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[(0,d.jsx)("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Despachados"}),(0,d.jsx)("p",{className:"text-3xl font-black text-green-600 mt-2",children:e})]}),(0,d.jsxs)("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[(0,d.jsx)("p",{className:"text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Facturación Total"}),(0,d.jsxs)("p",{className:"text-2xl font-black text-red-600 mt-2",children:["RD$ ",b.toLocaleString()]})]})]}),j.length>0&&(0,d.jsxs)("div",{className:"mb-10 bg-slate-900 rounded-[2.5rem] p-8 text-white shadow-2xl shadow-slate-300",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-xl font-black tracking-tight flex items-center gap-2",children:[(0,d.jsx)("span",{className:"w-2 h-2 bg-red-500 rounded-full animate-pulse"}),"Resumen de Producción (Planta)"]}),(0,d.jsx)("p",{className:"text-slate-400 text-xs font-bold mt-1 uppercase tracking-widest",children:"Basado en pedidos en estado 'EN PROCESO'"})]}),(0,d.jsxs)("div",{className:"px-4 py-2 bg-slate-800 rounded-xl border border-slate-700",children:[(0,d.jsx)("span",{className:"text-[10px] font-black text-slate-500 uppercase block",children:"Total SKUs"}),(0,d.jsx)("span",{className:"text-lg font-black text-white",children:j.length})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:j.map(a=>(0,d.jsxs)("div",{className:"bg-slate-800/50 border border-slate-700/50 p-5 rounded-2xl flex justify-between items-center group hover:bg-slate-800 transition-all",children:[(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{className:"text-[10px] font-black text-red-500 uppercase tracking-tighter mb-1",children:"Producto"}),(0,d.jsx)("span",{className:"text-sm font-bold text-slate-100 group-hover:text-white",children:a.nombre})]}),(0,d.jsxs)("div",{className:"text-right",children:[(0,d.jsx)("span",{className:"text-[10px] font-black text-slate-500 uppercase block",children:"Faltante"}),(0,d.jsx)("span",{className:"text-2xl font-black text-red-500",children:a.cantidad.toLocaleString()})]})]},a.nombre))})]}),(0,d.jsx)(f.default,{pedidos:a})]})}[e]=g.then?(await g)():g,a.s(["default",()=>i]),c()}catch(a){c(a)}},!1)];

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