import{b as e,d as a}from"./app-DTeOhhdM.js";function y({list:r,info:j}){var p,m,h;if(!r||Object.keys(r).length===0)return null;const b=t=>t?new Date(t).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"numeric"}):"N/A",g=Array.isArray(r.details)?r.details:[],f=t=>t.product_attribute||t.productAttribute||null,i=(t,o)=>{if(!t)return null;const c=o.replace(/_([a-z])/g,(l,d)=>d.toUpperCase()),s=t[o]||t[c];return(s==null?void 0:s.name)??null};return e.jsxs("div",{className:"hidden print:block",children:[e.jsx("style",{children:`
        @media print {
          @page { size: 58mm auto; margin: 0; padding: 0; }
          body { margin: 0; padding: 0; }
          .purchase-2inch-root {
            width: 58mm !important;
            max-width: 58mm !important;
            margin: 0 auto !important;
            font-size: 11px !important;
            color: #000 !important;
          }
          .purchase-2inch-root * { color: inherit !important; }
          .purchase-2inch-root p, .purchase-2inch-root span, .purchase-2inch-root div { color: #000 !important; font-weight: 500 !important; }
          .purchase-2inch-root .font-semibold, .purchase-2inch-root .font-bold { font-weight: 700 !important; }
          .purchase-2inch-root .font-medium { font-weight: 600 !important; }
        }
      `}),e.jsxs("div",{className:"purchase-2inch-root bg-white px-1.5 py-1 text-[10px] text-gray-900",children:[e.jsxs("div",{className:"text-center border-b border-gray-400 pb-1 mb-1",children:[e.jsx("h2",{className:"text-[11px] font-bold uppercase tracking-wide",children:a.name}),a.address&&e.jsx("p",{className:"text-[9px] font-semibold text-gray-900 leading-tight",children:a.address}),e.jsxs("p",{className:"text-[9px] font-semibold text-gray-900",children:[a.phone&&e.jsxs(e.Fragment,{children:["Ph: ",a.phone]})," ",a.email&&e.jsxs(e.Fragment,{children:["| ",a.email]})]}),e.jsx("p",{className:"text-[9px] font-semibold mt-0.5",children:"PURCHASE ORDER"}),e.jsxs("div",{className:"flex justify-between text-[9px] font-semibold mt-0.5",children:[e.jsxs("span",{children:["PO: ",r.po_no||"N/A"]}),e.jsx("span",{children:b(r.po_date)})]}),((p=r.supplier)==null?void 0:p.name)&&e.jsxs("p",{className:"mt-0.5 text-[9px] font-semibold text-gray-900",children:["Supplier: ",r.supplier.name]})]}),r.supplier&&e.jsxs("div",{className:"border-b border-dashed border-gray-300 pb-1 mb-1",children:[e.jsxs("p",{className:"text-[9px] font-semibold",children:["Supplier: ",((m=r.supplier)==null?void 0:m.name)||"N/A"]}),((h=r.supplier)==null?void 0:h.number)&&e.jsxs("p",{className:"text-[9px] font-semibold text-gray-900",children:["Ph: ",r.supplier.number]})]}),e.jsxs("div",{className:"border-b border-gray-400 pb-1 mb-1",children:[e.jsxs("div",{className:"grid grid-cols-12 text-[9px] font-semibold mb-0.5",children:[e.jsx("div",{className:"col-span-6",children:"Item"}),e.jsx("div",{className:"col-span-3 text-right",children:"CTN/Box"}),e.jsx("div",{className:"col-span-3 text-right",children:"Qty"})]}),g.map((t,o)=>{var c;return e.jsxs("div",{className:"grid grid-cols-12 items-baseline text-[13px] py-0.5 border-t border-dashed border-gray-200",children:[e.jsxs("div",{className:"col-span-6 pr-1",children:[e.jsx("p",{className:"font-semibold leading-tight text-[13px]",children:((c=t.product_info)==null?void 0:c.name)||"N/A"}),(()=>{const s=f(t);if(!s)return null;const l=i(s,"product_type")||i(s,"productType"),d=i(s,"size"),x=i(s,"color"),u=i(s,"model"),n=[];return l&&n.push(l),d&&n.push(d),x&&n.push(x),u&&n.push(u),!n.length&&!s.sku?null:e.jsxs("div",{className:"mt-0.5 text-[12px] font-semibold text-gray-900 leading-tight",children:[s.sku&&e.jsxs("span",{className:"block",children:["SKU: ",s.sku]}),n.length>0&&e.jsx("span",{children:n.join(" • ")})]})})()]}),e.jsx("div",{className:"col-span-3 text-right",children:t.carton_box??""}),e.jsx("div",{className:"col-span-3 text-right",children:t.quantity||0})]},o)})]}),e.jsx("div",{className:"pt-1 text-center",children:e.jsx("p",{className:"text-[9px] font-semibold text-gray-900",children:"--- End of Purchase Order ---"})})]})]})}export{y as default};
