PageSourceSearch

https://vidapeps.com/assets/Quote-TrqB-ody.js

js vidapeps.com collected 2026-10-04 08:09:49 UTC 31,832 bytes, 1 lines download raw bytes

1import{j as e,u as _e}from"./vendor-query-CniT1WJL.js";import{r as l,k as Ye}from"./vendor-react-69GsFwrV.js";import{u as ye,A as Ie}from"./AddressFormFields-Byy1VLUa.js";import{cT as He,a2 as Ge,L as oe,B as S,a3 as Se,I as le,cU as Ze,aI as De,cV as Je,cW as Xe,a8 as et,cX as tt,cY as st,cZ as nt,aa as at,ab as rt,c_ as qe,c$ as it}from"./index-KjAD5lCC.js";import{P as ot,a as lt}from"./PayLinkVidapayTile-COzDVRE7.js";import{v as dt}from"./product-type-ELOBn7Yu.js";import{a3 as ct,a7 as ut,H as mt,Z as pt,br as ht,bs as xt,_ as ft,ao as yt,aw as gt,a4 as bt,ap as vt}from"./vendor-ui-Ad3ANzF6.js";import{C as jt,a as Nt,c as pe}from"./customer-error-copy-BMVNH5_E.js";import{B as $e}from"./badge-DyGI04xR.js";import"./vendor-forms-q6h4WU-p.js";import"./PaymentCard-CNmbrjef.js";function kt(t){const a=dt(t),o=x=>x.charAt(0).toUpperCase()+x.slice(1);return[{value:"unit",label:o(a.unit),labelPlural:o(a.unitPlural),hint:`Price is per ${a.unit}.`},{value:"kit",label:o(a.pack),labelPlural:o(a.packPlural),hint:`Price is per ${a.pack}; each ${a.pack} holds several ${a.unitPlural}.`}]}function Fe(t,a,o={}){const x=kt(t).find(u=>u.value===a);return(o.plural?x?.labelPlural:x?.label)??(a==="kit"?"Pack":"Unit")}function Ct({readUrl:t,writeUrl:a,company:o=!1,updateMethod:x="PATCH",addressRole:p,value:u,fullName:h,onSelect:k,beforeSave:w,disabled:g}){const[j,L]=l.useState([]),[P,O]=l.useState(""),[A,W]=l.useState(""),[E,f]=l.useState(""),[q,B]=l.useState(""),[I,K]=l.useState(!0),[U,z]=l.useState(!1),D=l.useRef(!1),[M,b]=l.useState(0);l.useEffect(()=>{const r=new AbortController;return K(!0),f(""),O(""),L([]),fetch(t,{credentials:"include",signal:r.signal}).then(async d=>{if(!d.ok)throw new Error("Address book could not be loaded. Try again.");return d.json()}).then(d=>L((Array.isArray(d)?d:d.addresses??[]).filter(C=>C.status!=="archived"))).catch(d=>{r.signal.aborted||f(d.message)}).finally(()=>{r.signal.aborted||K(!1)}),()=>r.abort()},[t,M]);const F=He(j,p).filter(r=>!r.country||r.country==="US"),i=Ge(F,p),c=r=>{O(String(r.id)),B(""),k(r)};async function N(r){if(D.current||g)return;D.current=!0,z(!0),f(""),B("");const d=j.find(C=>String(C.id)===P);try{if(!await w())return;const C={line1:u.line1,city:u.city,state:u.state,zip:u.zip,line2:u.line2?.trim()||null,country:"US",...r&&x==="PUT"?{label:d?.label??null,phone:d?.phone??null}:{},...r?{}:{type:p},...o?{attention:h.trim()||null,...r?{}:{label:`${p==="shipping"?"Shipping":"Billing"}: ${u.line1}`.slice(0,128)}}:{fullName:h.trim()||null}},R=await fetch(r&&d?`${a}/${d.id}`:a,{method:r&&d?x:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify(C)});if(!R.ok){const Y=await R.json().catch(()=>({}));throw new Error(Y.message||"Could not save this address. Check the fields and try again.")}b(Y=>Y+1),B(r?"Saved address updated. Save quote details to apply it to this quote.":"Address added to the book.")}catch(C){f(C instanceof Error?C.message:"Could not save address")}finally{D.current=!1,z(!1)}}const y=!!(u.line1.trim()&&u.city.trim()&&u.state.trim()&&u.zip.trim());return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(oe,{htmlFor:`book-${p}`,children:o?"Company address book":"Customer address book"}),i&&e.jsxs(S,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:g||I,onClick:()=>c(i),children:["Use ",Se(i,p)?"default":"saved"," ",p]})]}),F.length>5&&e.jsx(le,{"aria-label":`Search ${p} addresses`,placeholder:"Search saved addresses",value:A,onChange:r=>W(r.target.value)}),e.jsxs("select",{id:`book-${p}`,className:"min-h-11 w-full min-w-0 rounded-md border border-input bg-background px-3 text-sm",disabled:g||I,value:P,onChange:r=>{const d=F.find(C=>String(C.id)===r.target.value);d?c(d):O("")},children:[e.jsx("option",{value:"",children:I?"Loading saved addresses…":F.length?"Choose a saved address":"No saved US addresses"}),F.filter(r=>`${r.label} ${r.fullName??r.attention} ${r.line1} ${r.city} ${r.zip}`.toLowerCase().includes(A.toLowerCase())).map(r=>
1e.jsxs("option",{value:r.id,children:[Se(r,p)?"Default · ":"",r.label||r.fullName||r.attention||"Address"," · ",r.line1,r.line2?`, ${r.line2}`:"",", ",r.city,", ",r.state," ",r.zip]},r.id))]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:g||U||!y,onClick:()=>{N(!1)},children:U?"Saving…":"Add to address book"}),P&&e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"min-h-11",disabled:g||U||!y,onClick:()=>{N(!0)},children:"Update saved address"})]}),q&&e.jsx("p",{role:"status",children:q}),E&&e.jsxs("div",{role:"alert",className:"text-destructive",children:[E," ",e.jsx(S,{type:"button",variant:"link",onClick:()=>b(r=>r+1),children:"Reload addresses"})]})]})}const Te=()=>({fullName:"",line1:"",line2:"",city:"",state:"",zip:""}),Ae=t=>({fullName:t?.fullName??"",line1:t?.line1??"",line2:t?.line2??"",city:t?.city??"",state:t?.state??"",zip:t?.zip??"",phone:t?.phone??""}),Re=t=>!!(t.fullName?.trim()&&t.line1.trim()&&t.city.trim()&&t.state.trim()&&t.zip.trim());function wt({token:t,version:a,requiresShipping:o,onSaved:x,onDirtyChange:p,disabled:u}){const[h,k]=l.useState(null),[w,g]=l.useState(Te),[j,L]=l.useState(Te),[P,O]=l.useState(!1),[A,W]=l.useState(!1),E=l.useRef(!1),[f,q]=l.useState(""),[B,I]=l.useState(""),[K,U]=l.useState(0),z=ye(),D=ye(),M=`/api/quotes/${encodeURIComponent(t)}/addresses`;l.useEffect(()=>{const i=new AbortController;return q(""),k(null),fetch(M,{credentials:"include",signal:i.signal}).then(async c=>{const N=await c.json();if(!c.ok)throw new Error(N.error||"Addresses could not be loaded.");return N}).then(c=>{k(c),g(Ae(c.shippingAddress)),L(Ae(c.billingAddress)),O(!1),p(!1)}).catch(c=>{i.signal.aborted||q(c.message)}),()=>i.abort()},[M,a,K,p]);const b=(i,c)=>{(i==="shipping"?g:L)(c),O(!0),p(!0),I("")};async function F(){if(!h||u||E.current)return;const i=!!(j.line1.trim()||j.city.trim()||j.state.trim()||j.zip.trim());
1if(o&&!Re(w)||i&&!Re(j)){q("Enter a recipient, street, city, state and ZIP for each address.");return}E.current=!0,W(!0),q("");try{if((await Promise.all([o?z.ensureResolvedForSubmit(w):!0,i?D.ensureResolvedForSubmit(j):!0])).some(d=>!d)){q("Choose Use suggested or Keep mine for the address correction, then save.");return}const N=d=>({fullName:d.fullName?.trim(),line1:d.line1,line2:d.line2||"",city:d.city,state:d.state,zip:d.zip,country:"US",...d.phone?{phone:d.phone}:{}}),y=await fetch(M,{method:"PATCH",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({version:h.version,...o?{shippingAddress:N(w)}:{},...i?{billingAddress:N(j)}:{}})}),r=await y.json();if(!y.ok)throw new Error(r.error||"Could not save addresses.");await x(),O(!1),p(!1),I("Quote addresses saved.")}catch(c){q(c instanceof Error?c.message:"Could not save addresses.")}finally{E.current=!1,W(!1)}}return h?h.editable?e.jsxs("details",{className:"mt-4 border-t pt-3",open:o&&!h.shippingAddress?.line1,children:[e.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 font-medium",children:[o&&!h.shippingAddress?.line1?"Add shipping and billing addresses":"Change shipping or billing address",P?" · Unsaved changes":""]}),e.jsx("div",{className:"grid gap-6 py-3 sm:grid-cols-2",children:["shipping","billing"].filter(i=>i!=="shipping"||o).map(i=>{const c=i==="shipping"?w:j,N=i==="shipping"?z:D;return e.jsxs("fieldset",{disabled:u||A,className:"min-w-0 space-y-3",children:[e.jsx("legend",{className:"mb-3 w-full font-semibold",children:e.jsxs("span",{className:"flex min-h-11 items-center justify-between gap-2",children:[i==="shipping"?"Ship to":"Bill to",i==="billing"&&o&&e.jsx(S,{type:"button",variant:"outline",className:"min-h-11",onClick:()=>{b("billing",{...w}),D.reset()},children:"Use shipping address"})]})}),h.book?e.jsx(Ct,{...h.book,updateMethod:h.book.company?"PATCH":"PUT",addressRole:i,value:c,fullName:c.fullName??"",disabled:u||A,beforeSave:()=>N.ensureResolvedForSubmit(c),onSelect:y=>{b(i,{fullName:y.fullName??y.attention??"",line1:y.line1,line2:y.line2||"",city:y.city,state:y.state,zip:y.zip}),N.reset()}}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sign in with access to this"," ",i==="shipping"?"customer or company":"account"," to use and save its address book."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(oe,{htmlFor:`public-quote-${i}-name`,children:"Recipient name"}),e.jsx(le,{id:`public-quote-${i}-name`,autoComplete:`${i} name`,value:c.fullName??"",onChange:y=>b(i,{...c,fullName:y.target.value})})]}),e.jsx(Ie,{compact:!0,idPrefix:`public-quote-${i}`,value:c,onChange:y=>b(i,{...c,...y}),check:N,disabled:u||A})]},i)})}),f&&e.jsx("p",{role:"alert",className:"mb-3 text-sm text-destructive",children:f}),B&&e.jsx("p",{role:"status",className:"mb-3 text-sm",children:B}),e.jsx(S,{type:"button",className:"min-h-11",disabled:u||A||!P,onClick:()=>{F()},children:A?"Saving addresses…":"Save quote addresses"}),P&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Save these changes before approving or paying. Address book changes are saved separately."})]}):null:e.jsx("div",{className:"mt-4 text-sm",children:f?e.jsxs("p",{role:"alert",children:[f," ",e.jsx(S,{type:"button",variant:"link",onClick:()=>U(i=>i+1),children:"Reload addresses"})]}):e.jsx("p",{role:"status",children:"Loading addresses…"})})}const Pt={fullName:"",phone:"",address:{line1:"",line2:"",city:"",state:"",zip:""}};function ge(t){return!!(t.fullName.trim()&&t.address.line1.trim()&&t.address.city.trim()&&t.address.state.trim()&&t.address.zip.trim())}const Qe={ship:{icon:pt,title:"Shipped to you",blurb:"We send this by carrier once payment clears."},delivery:{icon:mt,title:"Local delivery",blurb:"We bring this to your address ourselves."},pickup:{icon:ut,title:"Collected in person",blurb:"Pick this up from us, nothing gets posted."},handoff:{icon:ct,title:"Handed to you in person",blurb:"We arranged to hand this over directly, so there is nothing to address."}};function St({fulfillment:t,draft:a,onDraftChange:o,addressCheck:x,disabled:p,addressEditor:u}){const h=Qe[t.method]??Qe.ship,k=h.icon,w=t.addressRequired&&!t.addressOnFile;return e.jsxs("section",{className:"mt-6 rounded-2xl border bg-card p-5 shadow-sm sm:p-6","data-testid":"quote-delivery",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h2",{className:"font-semibold",children:h.title})]}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:h.blurb}),t.destinationSummary&&e.jsxs("p",{className:"mt-2 text-sm leading-6","data-testid":"quote-delivery-summary",children:[e.jsx("span",{className:"text-muted-foreground",children:"Destination: "}),e.jsx("span",{className:"font-medium",children:t.destinationSummary})]}),t.addressRequired&&t.addressOnFile&&!u&&e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"We already have your address for this order. Let us know before you pay if it has changed."}),u,w&&!u&&e.jsxs("div",{className:"mt-5 space-y-4","data-testid":"quote-destination-form",children:[e.jsxs("p",{className:"rounded-lg bg-muted/40 p-3 text-sm leading-6",children:["We put this quote together before we had your address, so we need it now."," ",t.method==="delivery"?"Tell us where to bring it.":"Tell us where to send it."]}),e.jsx(Ie,{idPrefix:"quote-dest",value:a.address,onChange:g=>o({...a,address:g}),check:x,required:!0,disabled:p,line1Label:"Street address",children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(oe,{htmlFor:"quote-dest-name",className:"text-sm",children:["Full name",e.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]}),e.jsx(le,{id:"quote-dest-name",value:a.fullName,onChange:g=>o({...a,fullName:g.target.value}),disabled:p,autoComplete:"name","data-testid":"quote-dest-name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(oe,{htmlFor:"quote-dest-phone",className:"text-sm",children:"Phone (optional)"}
1),e.jsx(le,{id:"quote-dest-phone",value:a.phone,onChange:g=>o({...a,phone:g.target.value}),disabled:p,autoComplete:"tel","data-testid":"quote-dest-phone"})]})]})}),!ge(a)&&e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"quote-destination-incomplete",children:"Fill in the name, street, city, state and ZIP to continue to payment."})]})]})}function qt(t){return t instanceof De&&t.status===404}function $t(t,a){const o=Je.getPublicBulkQuote,x=a===void 0?void 0:{version:a};return Ze(t,x,{request:{cache:"no-store",omitCartToken:!0},query:{queryKey:Xe(t,x),enabled:!!t,staleTime:o.staleTimeMs,gcTime:o.gcTimeMs,retry:(u,h)=>h instanceof De&&h.status>=400&&h.status<500?!1:u<1}})}function v(t){return`$${(t/100).toFixed(2)}`}function Oe(t){return t.sizeLabel??`${t.size}${t.unit}`}function X(t,a=!0){return Fe(t.productType,"unit",{plural:a}).toLowerCase()}function de(t,a=!0){return Fe(t.productType,"kit",{plural:a}).toLowerCase()}function Ee(t){return t.pricingBasis==="kit"?`${t.quantity} ${de(t)} × ${t.unitsPerKit} (${t.totalUnits} ${X(t)})`:`${t.quantity} ${X(t)}`}function he(t){return`${v(t.unitListPriceCents)}/${X(t,!1)}`}function ae(t){return t.unitsPerKit>1?`${v(t.unitListPriceCents*t.unitsPerKit)}/${de(t,!1)} of ${t.unitsPerKit}`:null}function xe(t){return t.pricingBasis==="kit"?`${v(t.unitQuotePriceCents)}/${de(t,!1)}`:`${v(t.unitQuotePriceCents)}/${X(t,!1)}`}function re(t){return t.pricingBasis==="kit"?`${v(Math.round(t.unitQuotePriceCents/t.unitsPerKit))}/${X(t,!1)}`:t.unitsPerKit>1?`${v(t.unitQuotePriceCents*t.unitsPerKit)}/${de(t,!1)} of ${t.unitsPerKit}`:null}function Tt(t){return t[0].toUpperCase()+t.slice(1)}function At(t,a){return a<=0?0:Math.round(t*a/1e4)}function Mt(){const[,t]=Ye("/quote/:token"),a=t?.token??"",o=new URLSearchParams(window.location.search).get("version"),x=o===null?void 0:Number(o),p=x!==void 0&&(!/^\d+$/.test(o??"")||!Number.isSafeInteger(x)||x<=0),u=p?void 0:x,h=l.useRef(null),[k,w]=l.useState(null),[g,j]=l.useState(null),[L,P]=l.useState(null),[O,A]=l.useState(!1),[W,E]=l.useState(!1),[f,q]=l.useState(null),B=et(f?.orderNumber),[I,K]=l.useState(!1),[U,z]=l.useState(null),D=tt(),M=st(),[b,F]=l.useState(Pt),i=ye(),[c,N]=l.useState(!1),[y,r]=l.useState(!1),[d,C]=l.useState(null),[R,Y]=l.useState(null);function be(){const s=$?.quote.fulfillment;if(!s?.addressRequired||s.addressOnFile||!ge(b))return;const{address:m}=b;return{shippingAddress:{fullName:b.fullName.trim(),line1:m.line1.trim(),...m.line2?.trim()?{line2:m.line2.trim()}:{},city:m.city.trim(),state:m.state.trim(),zip:m.zip.trim(),...b.phone.trim()?{phone:b.phone.trim()}:{}}}}async function ve(){if(c)return!1;const s=$?.quote.fulfillment;return!s?.addressRequired||s.addressOnFile?!0:i.ensureResolvedForSubmit(b.address)}
1async function Le(){const s=$?.quote.version,m=$?.quote.termsOffer;if(!(s===void 0||!m?.available||m.paymentTermsDays<=0)&&await ve()){r(!0),C(null);try{const T=await M.mutateAsync({token:a,data:{version:s,settlement:"terms",paymentTermsDays:m.paymentTermsDays,...be()}});Y({orderId:T.orderId,orderNumber:T.orderNumber??null,invoiceNumber:T.invoiceNumber??null,invoiceDueDate:T.invoiceDueDate??null}),await H()}catch(T){if(jt.has(Nt(T)??"")){const ne=encodeURIComponent(window.location.pathname+window.location.search);window.location.href=`/login?redirect=${ne}`;return}C(pe(T,"We could not place this order on terms."))}finally{r(!1)}}}const{data:$,isLoading:Be,error:je,isFetching:Ne,refetch:H}=_e($t(p?"":a,u));async function Ue(){if(c)return;const s=$?.quote.version;if(s!==void 0){K(!0),z(null);try{await D.mutateAsync({token:a,data:{version:s}}),await H()}catch(m){z(pe(m,"We could not accept this quote. Please try again."))}finally{K(!1)}}}async function ee(s,m,T){const ne=$?.quote.version;if(ne!==void 0&&await ve()){w(s),j(null),T?.cardInlineError&&P(null);try{const V=await M.mutateAsync({token:a,data:{railKey:s,version:ne,...m?.paymentToken?{paymentToken:m.paymentToken}:{},...m?.verificationToken?{verificationToken:m.verificationToken}:{},...be()}}),_=window.location.pathname+window.location.search,Pe="checkoutUrl"in V&&typeof V.checkoutUrl=="string"?V.checkoutUrl:null;if(Pe){qe(_),window.location.href=Pe;return}q(V);const me="payment"in V?V.payment.paymentUrl:null;typeof me=="string"&&me?(qe(_),window.location.href=me):T?.reloadQuoteAfterPayment&&(window.location.href=_)}
1catch(V){const _=pe(V,"We could not start this payment. Please try again.");T?.cardInlineError?P(_):j(_)}finally{w(null)}}}async function ze(s){P(null),E(!0);const m=await h.current?.tokenize();E(!1),m&&await ee(s.key,m,{reloadQuoteAfterPayment:!0,cardInlineError:!0})}if(p)return e.jsx("div",{className:"ph-no-capture mx-auto max-w-4xl px-5 py-16 text-foreground",children:"Quote not found."});if(Be)return e.jsx("div",{className:"ph-no-capture mx-auto max-w-4xl px-5 py-16 text-foreground",children:"Loading quote..."});if(je||!$)return!a||qt(je)?e.jsx("div",{className:"ph-no-capture mx-auto max-w-4xl px-5 py-16 text-foreground",children:"Quote not found."}):e.jsxs("div",{className:"ph-no-capture mx-auto max-w-4xl px-5 py-16 text-foreground",children:[e.jsx("p",{children:"We could not load this quote right now. Please try again."}),e.jsx(S,{type:"button",variant:"outline",className:"mt-4",disabled:Ne,onClick:()=>{H()},children:Ne?"Retrying...":"Retry"})]});const n=$.quote,ce=$.disclosureTier==="summary",Me=$.disclosureRecipients,te=(ce||n.items.length>0)&&n.totals.totalQuoteCents>0,ke=n.convertedOrderId!=null&&n.convertedOrder!=null&&["awaiting_payment","unpaid"].includes(n.convertedOrder.paymentStatus),G=n.fulfillment??null,Ve=!G?.addressRequired||G.addressOnFile||ge(b),Ce=!c&&n.isCurrentVersion&&te&&Ve&&(["sent","viewed","accepted"].includes(n.status)&&!n.convertedOrderId||n.status==="converted"&&ke),We=!c&&n.isCurrentVersion&&te&&["sent","viewed"].includes(n.status)&&!n.convertedOrderId,Z=[...$.paymentMethods].sort((s,m)=>s.sortOrder-m.sortOrder),Q=Z.find(s=>s.checkoutMode==="embedded_card"&&s.clientConfig&&(s.provider==="square"||s.key==="card"))??Z.find(s=>s.checkoutMode==="embedded_card"&&s.clientConfig),se=Z.find(s=>s.kind==="vidapay")??null,we=Z.filter(s=>s.key!==Q?.key&&s.key!==se?.key),Ke=Q?At(n.totals.totalQuoteCents,Q.discountBps):0,ue=Math.max(n.totals.totalQuoteCents-Ke,1);return e.jsx("div",{className:"ph-no-capture min-h-screen bg-background text-foreground",children:e.jsxs("main",{className:"mx-auto w-full max-w-4xl px-4 py-8 sm:px-6 lg:py-12",children:[e.jsxs("section",{className:"rounded-2xl border bg-card p-5 shadow-sm sm:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ht,{className:"h-4 w-4"})," Bulk quote"]}),e.jsx("h1",{className:"mt-2 break-words text-2xl font-bold tracking-tight sm:text-3xl",children:n.quoteNumber}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground sm:text-base",children:["Prepared for"," ",e.jsx("span",{className:"font-medium text-foreground",children:n.customerDisplayName}),n.customerCompany?`, ${n.customerCompany}`:""]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx($e,{variant:"outline",className:"capitalize",children:Tt(n.status)}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>window.open(`/api/quotes/${encodeURIComponent(a)}/pdf${n.version>0?`?version=${n.version}`:""}`,"_blank","noopener"),children:[e.jsx(xt,{className:"mr-2 h-4 w-4"})," Print"]})]})]}),!n.isCurrentVersion&&e.jsx("div",{className:"mt-5 rounded-xl border border-amber-300 bg-amber-50 p-4 text-sm text-amber-950",role:"status","data-testid":"notice-superseded-quote",children:"This is an earlier quote version. You can review or print it, but only the latest version can be approved or paid."}),e.jsxs("div",{className:"mt-6 grid gap-3 sm:grid-cols-3",children:[e.jsx(fe,{label:"Total units",value:n.totals.totalUnits.toLocaleString()}),e.jsx(fe,{label:"Quote discount",value:`${n.totals.discountPercent}%`}),e.jsx(fe,{label:"Quote total",value:v(n.totals.totalQuoteCents),strong:!0})]}),n.customerNotes&&e.jsxs("div",{className:"mt-5 rounded-xl border bg-muted/40 p-4 text-sm leading-6 text-foreground",children:[e.jsx("div",{className:"mb-1 font-semibold",children:"Note from VidaPeps"}),n.customerNotes]})]}),e.jsxs("section",{className:"mt-6 overflow-hidden rounded-2xl border bg-card shadow-sm",children:[e.jsxs("div",{className:"border-b px-5 py-4 sm:px-6",children:[e.jsx("h2",{className:"font-semibold",children:"Quote lines"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Review products, quantities, and quoted pricing before payment."})]}),ce?e.jsx("div",{className:"p-6",children:e.jsx(ot,{token:a,recipients:Me??[],onUnlocked:()=>{H()}})}):te?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden sm:block",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-5 py-3 text-left font-medium",children:"Product"}),e.jsx("th",{className:"px-3 py-3 text-right font-medium",children:"Qty"}),e.jsx("th",{className:"px-3 py-3 text-right font-medium",children:"List"}),e.jsx("th",{className:"px-3 py-3 text-right font-medium",children:"Quote"}),e.jsx("th",{className:"px-5 py-3 text-right font-medium",children:"Line total"})]})}),e.jsx("tbody",{className:"divide-y",children:n.items.map((s,m)=>e.jsxs("tr",{children:[e.jsxs("td",{className:"px-5 py-4 align-top",children:[e.jsx("div",{className:"font-medium",children:s.productName}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.sku," · ",Oe(s)]})]}
1),e.jsx("td",{className:"px-3 py-4 text-right align-top tabular-nums",children:Ee(s)}),e.jsxs("td",{className:"px-3 py-4 text-right align-top text-muted-foreground tabular-nums",children:[he(s),ae(s)&&e.jsx("div",{className:"text-xs",children:ae(s)})]}),e.jsxs("td",{className:"px-3 py-4 text-right align-top font-medium tabular-nums",children:[xe(s),re(s)&&e.jsx("div",{className:"text-xs font-normal text-muted-foreground",children:re(s)})]}),e.jsx("td",{className:"px-5 py-4 text-right align-top font-semibold tabular-nums",children:v(s.lineQuoteCents)})]},`${s.sku}:${m}`))})]})}),e.jsx("div",{className:"divide-y sm:hidden",children:n.items.map((s,m)=>e.jsxs("div",{className:"p-5",children:[e.jsx("div",{className:"font-medium",children:s.productName}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.sku," · ",Oe(s)]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3 text-sm",children:[e.jsx(ie,{label:"Qty",value:Ee(s)}),e.jsx(ie,{label:"List",value:ae(s)?`${he(s)} · ${ae(s)}`:he(s)}),e.jsx(ie,{label:"Quote",value:re(s)?`${xe(s)} · ${re(s)}`:xe(s)}),e.jsx(ie,{label:"Line total",value:v(s.lineQuoteCents),strong:!0})]})]},`${s.sku}:${m}`))})]}):e.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This quote does not have line items yet. VidaPeps is still preparing the quote, so payment is disabled until products and prices are added."}),e.jsx("div",{className:"border-t bg-muted/20 p-5 sm:p-6",children:e.jsxs("div",{className:"ml-auto w-full max-w-sm space-y-2 text-sm",children:[e.jsx(J,{label:"List subtotal",value:v(n.totals.subtotalListCents),muted:!0}),e.jsx(J,{label:"Quoted subtotal",value:v(n.totals.subtotalQuoteCents)}),n.totals.discountCents>0&&e.jsx(J,{label:`Discount (${n.totals.discountPercent}% off list)`,value:v(n.totals.discountCents),muted:!0}),e.jsx(J,{label:"Shipping",value:n.shippingCents===0?"Included":v(n.shippingCents)}),e.jsx(J,{label:"Total due",value:v(n.totals.totalQuoteCents),strong:!0})]})})]}),G&&n.isCurrentVersion&&!n.convertedOrderId&&e.jsx(St,{fulfillment:G,draft:b,onDraftChange:F,addressCheck:i,disabled:k!==null||y,addressEditor:ce?void 0:e.jsx(wt,{token:a,version:n.version,requiresShipping:G.addressRequired,onSaved:async()=>{if(u!==void 0){const s=new URL(window.location.href);s.searchParams.delete("version"),window.location.assign(s.pathname+s.search);return}await H()},onDirtyChange:N,disabled:k!==null||y})}),n.isCurrentVersion&&(We||n.status==="accepted")&&!n.convertedOrderId&&e.jsxs("section",{className:"mt-6 rounded-2xl border bg-card p-5 shadow-sm sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h2",{className:"font-semibold",children:"Approve this quote"})]}),n.status==="accepted"?e.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"You approved this quote. VidaPeps is preparing your order; you can still pay below to speed things up."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"Everything look right? Approve the quote and VidaPeps will start preparing your order. You can also pay right away below."}),e.jsx(S,{className:"mt-4",disabled:I,onClick:()=>{Ue()},"data-testid":"button-approve-quote",children:I?"Approving...":"Approve quote"}),U&&e.jsx("p",{className:"mt-2 text-sm text-destructive",children:U})]})]}),Ce&&n.termsOffer?.available?e.jsxs("section",{className:"mt-6 rounded-2xl border bg-card p-5 shadow-sm sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h2",{className:"font-semibold",children:"Bill my company"})]}),R?e.jsxs("div",{className:"mt-3 space-y-2 text-sm leading-6",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Accepted. Order ",R.orderNumber??`#${R.orderId}`," is placed."]}),R.invoiceNumber?e.jsxs("p",{className:"text-muted-foreground",children:["Invoice ",R.invoiceNumber,R.invoiceDueDate?` is due ${R.invoiceDueDate}`:""," and has been emailed to your billing contacts. You can also see it any time under Company in your account."]}):e.jsx("p",{className:"text-muted-foreground",children:"Your order is placed. We are finishing the invoice and will email it shortly."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:["Your company is set up on Net ",n.termsOffer.paymentTermsDays,". Accept this quote and we will place the order and send an invoice due in"," ",n.termsOffer.paymentTermsDays," days - no card needed now."]}),e.jsx(S,{className:"mt-4",disabled:y,onClick:()=>{Le()},"data-testid":"button-accept-on-terms",children:y?"Placing your order...":`Accept and invoice me (Net ${n.termsOffer.paymentTermsDays})`}),d&&e.jsx("p",{className:"mt-2 text-sm text-destructive",children:d})]})]}):null,e.jsxs("section",{className:"mt-6 rounded-2xl border bg-card p-5 shadow-sm sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h2",{className:"font-semibold",children:"Payment"})]}),Ce?Z.length===0?e.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"Online payment is not enabled for this quote yet. Contact VidaPeps to complete payment."}):e.jsxs("div",{className:"mt-4 space-y-4",children:[ke&&e.jsxs("p",{className:"rounded-xl bg-muted p-3 text-sm leading-6","data-testid":"text-quote-resume-payment",children:["Order ",n.convertedOrder?.orderNumber??`#${n.convertedOrderId}`," was created from this quote and is still awaiting payment - finish paying below."]}),se&&e.jsx(lt,{method:se,baseAmountCents:n.totals.totalQuoteCents,payingKey:k,onSelect:()=>{ee(se.key)}}),Q?.clientConfig&&e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 font-semibold",children:[e.jsx(bt,{className:"h-4 w-4"})," ",Q.displayName,e.jsx($e,{variant:"secondary",children:"Default"})]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Secure card, Apple Pay, Google Pay, or Afterpay through Square. Square receives only the VidaPeps Package descriptor and this quote total."})]}),e.jsx("div",{className:"shrink-0 text-right text-sm font-bold tabular-nums",children:v(ue)})]}),e.jsx(nt,{ref:h,config:Q.clientConfig,amountCents:ue,onError:P,onReady:A,onWalletToken:s=>
1{ee(Q.key,s,{reloadQuoteAfterPayment:!0,cardInlineError:!0})}}),L&&e.jsx("p",{className:"mt-2 text-xs text-destructive","data-testid":"text-quote-card-error",children:L}),e.jsx(S,{type:"button",className:"mt-3 w-full",disabled:k!==null||W||!O,onClick:()=>{ze(Q)},"data-testid":"button-pay-quote-card",children:k===Q.key||W?"Processing...":`Pay ${v(ue)} with card`})]}),we.length>0&&e.jsxs("div",{children:[Q&&e.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Other payment options"}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:we.map(s=>e.jsxs("button",{type:"button",disabled:k!==null,onClick:()=>{ee(s.key)},className:"flex min-h-20 items-start justify-between gap-4 rounded-xl border bg-background p-4 text-left transition hover:border-primary/40 hover:bg-muted/30 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium",children:s.displayName}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:s.description??s.checkoutMode})]}),e.jsx(vt,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]},s.key))})]})]}):e.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:n.convertedOrderId?`This quote was converted to order #${n.convertedOrderId}.`:n.isCurrentVersion?te?"This quote is not currently payable. Contact VidaPeps if you need it reopened.":"Payment is disabled until this quote has products and pricing.":"This earlier quote version is not payable. Open the latest version to continue."}),f&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-muted p-4 text-sm",children:["Order #",f.orderId," created."," ",f.payment?.paymentUrl?"If you were not redirected, follow the payment link to finish paying.":"Follow the payment instructions below to finish paying."]}),f.payment&&!f.payment.paymentUrl&&e.jsx(at,{railKey:f.payment.railKey,amountCents:f.payment.amountCents,discountCents:f.payment.discountCents,referenceCode:f.payment.referenceCode,expiresAt:f.payment.expiresAt,memoDocumentNo:B,instructions:f.payment.instructions,reportPayer:rt(s=>it(a,s,{cache:"no-store",omitCartToken:!0}))})]}),g&&e.jsx("div",{className:"mt-4 rounded-xl border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive",children:g})]})]})})}function fe({label:t,value:a,strong:o}){return e.jsxs("div",{className:"rounded-xl border bg-background px-4 py-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:o?"mt-1 text-xl font-bold tabular-nums":"mt-1 font-semibold tabular-nums",children:a})]})}function ie({label:t,value:a,strong:o}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:o?"font-semibold tabular-nums":"tabular-nums",children:a})]})}function J({label:t,value:a,muted:o,strong:x}){return e.jsxs("div",{className:x?"flex justify-between border-t pt-3 text-lg font-bold":o?"flex justify-between text-muted-foreground":"flex justify-between",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"tabular-nums",children:a})]})}export{Mt as default};

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.