1import{c as I,e as K,g as B,r as j,j as e,a as W,X as P,i as N,T as R,L as T,t as i,s as E}from"./main-D4XVkRLd.js";import{c as Q,d as z,e as v,S as O,f as $,a as D}from"./SiteFooter-D8xGH5zs.js";import{Z as q}from"./zap-CigTWHuD.js";import{U as V}from"./upload-C_9VA3S8.js";import{C as Z}from"./check-DhUKAC2Q.js";import{F as H}from"./file-text-CYYRXc8A.js";import"./netsuite-account.functions-C4Jg4JUd.js";const J=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],X=I("file-spreadsheet",J);function G(c){return c.split(/\r?\n/).map(o=>o.trim()).filter(Boolean).map(o=>{const x=o.split(/[,\t\s]+/).filter(Boolean),u=x[0]?.trim()??"",m=Math.max(1,Math.min(9999,parseInt(x[1]??"1",10)||1));return{sku:u,qty:m}}).filter(o=>o.sku.length>0)}function le(){const{isWholesale:c}=Q(),{enabled:o}=z(),x=K(),u=B(t=>t.addLocalItem),[m,k]=j.useState(""),[h,w]=j.useState(!1),[f,y]=j.useState([]),S=async t=>{const s=t.target.files?.[0];if(!s)return;if(s.size>2e6){i.error("File too large (max 2 MB)");return}const a=await s.text();k(a),i.success(`Loaded ${s.name}`),t.target.value=""},C=async()=>{const t=G(m);if(t.length===0){i.error("Paste at least one SKU");return}if(t.length>200){i.error("Max 200 SKUs at a time");return}w(!0);const s=r=>r.replace(/^(smc|blu|sat)[-_:]\s*/i,""),a=r=>{const n=r.trim(),d=s(n);return[...new Set([n,n.toUpperCase(),d,d.toUpperCase(),d.replace(/^0+/,""),d.replace(/^0+/,"").toUpperCase()])].filter(Boolean)},l=Array.from(new Set(t.flatMap(r=>a(r.sku)))),{data:b,error:F}=await E.from("bpw_products").select("id,sku,title,price,in_stock").eq("visible",!0).in("sku",l);if(w(!1),F){i.error("Lookup failed");return}const g=new Map;for(const r of b??[])g.set(r.sku,r),g.set(r.sku.toUpperCase(),r);y(t.map(r=>{const n=a(r.sku).map(d=>g.get(d)).find(Boolean);return n?{input:r.sku,qty:r.qty,found:!0,id:n.id,sku:n.sku,title:n.title,price:n.price,in_stock:n.in_stock}:{input:r.sku,qty:r.qty,found:!1}}))},U=t=>y(s=>s.filter((a,l)=>l!==t)),M=(t,s)=>y(a=>a.map((l,b)=>b===t?{...l,qty:Math.max(1,Math.min(9999,s||1))}:l)),p=f.filter(t=>t.found),A=p.reduce((t,s)=>{const a=v(s.price??null,c&&o)??0;return t+a*s.qty},0),L=()=>{if(p.length===0){i.error("Nothing to add");return}let t=0;for(const s of p)s.in_stock!==!1&&(u({productId:s.id??s.sku??s.input,title:s.title??s.sku??s.input,price:s.price??null,image:null,handle:s.sku??null,quantity:s.qty}),t+=s.qty);i.success(`Added ${t} item${t===1?"":"s"} to cart`)},_=()=>{if(p.length===0){i.error("Nothing to quote");return}sessionStorage.setItem("bpw_quote_lines",JSON.stringify(p.map(t=>({sku:t.sku??t.input,title:t.title??"",qty:t.qty})))),x({to:"/quote"})};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(O,{}),e.jsx("section",{className:"border-b border-border bg-gradient-to-br from-primary to-primary/90 text-primary-foreground",children:e.jsxs("div",{className:"mx-auto max-w-[1400px] px-4 py-12",children:[e.jsxs("div",{className:"text-xs font-bold uppercase tracking-[0.2em] text-bus-yellow flex items-center gap-2",children:[e.jsx(q,{className:"h-3.5 w-3.5"})," Quick Order"]}),e.jsx("h1",{className:"mt-3 font-display text-5xl font-black",children:"Paste SKUs. Build an order in seconds."}),e.jsx("p",{className:"mt-3 opacity-85 max-w-2xl",children:"For power buyers. Drop a list of part numbers (one per line, optionally with quantity) - we'll match them to live inventory and pricing."})]})}),e.jsxs("div",{className:"mx-auto max-w-[1400px] px-4 py-12 grid lg:grid-cols-[420px_1fr] gap-8",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(X,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"font-display text-lg font-bold",children:"SKU list"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["One SKU per line. Add quantity after a comma, tab or space. Example:",e.jsx("br",{}),e.jsx("code",{className:"text-[11px]",children:"10215A, 4"})]}),e.jsx("textarea",{rows:14,value:m,onChange:t=>k(t.target.value),placeholder:`10215A, 4 210715A, 2 3107WA`,className:"w-full rounded-md border border-border bg-background px-3 py-2.5 text-sm font-mono outline-none focus:ring-2 focus:ring-primary/30"}),e.jsxs("button",{onClick:C,disabled:h,className:"mt-3 w-full inline-flex items-center justify-center gap-2 rounded-md bg-primary py-3 font-bold uppercase tracking-wider text-primary-foreground hover:bg-primary/90 disabled:opacity-60",children:[h?e.jsx(W,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{className:"h-4 w-4"}
3),h?"Looking upâ¦":"Look up SKUs"]}),e.jsxs("label",{className:"mt-3 flex items-center justify-center gap-2 rounded-md border border-dashed border-border bg-background py-2.5 text-xs font-bold uppercase tracking-wider text-muted-foreground hover:border-primary hover:text-primary cursor-pointer",children:[e.jsx(V,{className:"h-3.5 w-3.5"})," Upload .csv / .txt",e.jsx("input",{type:"file",accept:".csv,.txt,text/csv,text/plain",className:"hidden",onChange:S})]}),e.jsx("a",{href:`data:text/csv;charset=utf-8,${encodeURIComponent(`sku,qty 410215A,4 510715A,2 6107WA,1 7`)}`,download:"bpw-quick-order-sample.csv",className:"mt-2 block text-center text-[11px] text-muted-foreground hover:text-primary underline",children:"Download sample CSV"})]}),e.jsx("div",{className:"rounded-2xl border border-border bg-card overflow-hidden",children:f.length===0?e.jsx("div",{className:"text-center py-24 text-muted-foreground text-sm",children:'Paste your SKU list, then click "Look up SKUs".'}):e.jsxs(e.Fragment,{children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-secondary/60 text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3",children:"SKU / Title"}),e.jsx("th",{className:"text-right px-4 py-3",children:"Unit price"}),e.jsx("th",{className:"text-center px-4 py-3 w-24",children:"Qty"}),e.jsx("th",{className:"text-right px-4 py-3",children:"Line total"}),e.jsx("th",{className:"px-2 py-3"})]})}),e.jsx("tbody",{children:f.map((t,s)=>{const a=v(t.price??null,c&&o);return e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"px-4 py-3",children:t.found?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-700 text-xs font-bold",children:[e.jsx(Z,{className:"h-3.5 w-3.5"})," Found"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive text-xs font-bold",children:[e.jsx(P,{className:"h-3.5 w-3.5"})," Not found"]})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:t.input}),t.title&&e.jsx("div",{className:"font-medium line-clamp-1",children:t.title})]}),e.jsxs("td",{className:"px-4 py-3 text-right font-mono",children:[a!=null?N(a):"-",c&&o&&t.found&&t.price!=null&&e.jsx("div",{className:"text-[10px] text-emerald-600 font-bold uppercase",children:"Wholesale"})]}),e.jsx("td",{className:"px-4 py-3 text-center",children:e.jsx("input",{type:"number",min:1,value:t.qty,onChange:l=>M(s,parseInt(l.target.value,10)),className:"w-16 rounded border border-border bg-background px-2 py-1 text-center text-sm"})}),e.jsx("td",{className:"px-4 py-3 text-right font-mono font-bold",children:a!=null?N(a*t.qty):"-"}),e.jsx("td",{className:"px-2 py-3",children:e.jsx("button",{onClick:()=>U(s),className:"text-muted-foreground hover:text-destructive",children:e.jsx(R,{className:"h-4 w-4"})})})]},s)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 px-4 py-5 border-t border-border bg-secondary/40",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground font-bold",children:"Estimated subtotal"}),e.jsx("div",{className:"font-display text-3xl font-black text-safety-red",children:N(A)}),!c&&e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-1",children:[e.jsx(T,{to:"/wholesale",className:"text-primary underline",children:"Wholesale accounts"})," save 15% on these prices."]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:L,className:"inline-flex items-center gap-2 rounded-md bg-bus-yellow text-bus-yellow-foreground px-5 py-3 font-bold uppercase tracking-wider text-xs hover:bg-bus-yellow/90",children:[e.jsx($,{className:"h-4 w-4"})," Add all to cart"]}),e.jsxs("button",{onClick:_,className:"inline-flex items-center gap-2 rounded-md bg-primary px-5 py-3 font-bold uppercase tracking-wider text-xs text-primary-foreground hover:bg-primary/90",children:[e.jsx(H,{className:"h-4 w-4"})," Request quote"]})]})]})]})})]}),e.jsx(D,{})]})}
7export{le as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.