1import{j as e}from"./vendor-query-CniT1WJL.js";import{r as l}from"./vendor-react-69GsFwrV.js";import{d0 as N,d1 as v,B as m,I as w,d2 as k,d3 as C}from"./index-KjAD5lCC.js";import{P as h}from"./PaymentCard-CNmbrjef.js";import{aw as p,h as P,a4 as S,g as L}from"./vendor-ui-Ad3ANzF6.js";function W({token:i,recipients:n,onUnlocked:d}){const[s,a]=l.useState("idle"),c=N(),f=v(),[u,g]=l.useState(null),[r,y]=l.useState(""),[x,o]=l.useState(null);async function j(t){g(t),a("sending"),o(null);try{await c.mutateAsync({token:i,data:{recipientId:t.id}}),a("code")}catch{o("We could not send the code just now. You can still pay below."),a("choosing")}}async function b(){if(!(!u||r.trim().length!==6)){a("verifying"),o(null);try{await f.mutateAsync({token:i,data:{recipientId:u.id,code:r.trim()}}),d()}catch{o("That code did not work. Check it, or send a new one."),a("code")}}}return n.length===0?e.jsx(h,{"data-testid":"card-pay-disclosure-unavailable",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(p,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Item details are private"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Contact us if you need a breakdown of this request. You can pay it below either way."})]})]})}):e.jsx(h,{"data-testid":"card-pay-disclosure-gate",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(p,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Item details are private"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"We keep what you ordered off this page unless you confirm it is you. You do not need to do this to pay."}),s==="idle"&&e.jsx(m,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>a("choosing"),"data-testid":"button-pay-disclosure-start",children:"See what this is for"}),s==="choosing"&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Where should we send your code?"}),n.map(t=>e.jsxs(m,{variant:"outline",size:"sm",className:"w-full justify-start gap-2",onClick:()=>{j(t)},"data-testid":`button-pay-disclosure-recipient-${t.id.slice(0,8)}`,children:[e.jsx(P,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[t.maskedEmail,t.label?` (${t.label})`:""]})]},t.id))]}),(s==="sending"||s==="code"||s==="verifying")&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s==="sending"?"Sending your codeâ¦":`Enter the 6-digit code we sent to ${u?.maskedEmail??"your inbox"}.`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(w,{inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,value:r,onChange:t=>y(t.target.value.replace(/[^0-9]/g,"")),placeholder:"000000",className:"font-mono","data-testid":"input-pay-disclosure-code",disabled:s!=="code"}),e.jsx(m,{size:"sm",onClick:()=>{b()},disabled:s!=="code"||r.length!==6,"data-testid":"button-pay-disclosure-verify",children:"Unlock"})]}),s==="code"&&e.jsx("button",{type:"button",className:"text-xs text-muted-foreground underline",onClick:()=>a("choosing"),children:"Send to a different address"})]}),x&&e.jsx("p",{className:"mt-2 text-sm text-danger","data-testid":"text-pay-disclosure-error",children:x})]})]})})}function Y({method:i,baseAmountCents:n,payingKey:d,onSelect:s}){const a=k(n,i.discountBps),c=d===i.key;return e.jsxs("button",{type:"button",disabled:d!==null,onClick:s,"data-testid":"tile-pay-rail-vidapay",className:"relative w-full overflow-hidden rounded-card border border-primary bg-card p-5 text-left shadow-sm transition hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0",style:{background:"radial-gradient(140% 120% at 90% -30%, hsl(var(--secondary) / 0.9) 0%, transparent 58%)"}}),e.jsxs("span",{className:"relative flex min-h-16 items-start justify-between gap-4",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground",children:e.jsx(S,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx("span",{className:"font-display text-base font-semibold tracking-tight",children:i.displayName}),e.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-secondary-foreground",children:"Recommended"})]}),i.description&&e.jsx("span",{className:"mt-1.5 block text-xs leading-5 text-muted-foreground",children:i.description})]}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end gap-1",children:[e.jsx("span",{className:"money-numeral font-display text-lg font-bold",children:C(n-a)}),c&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground","data-testid":"text-vidapay-tile-busy",children:[e.jsx(L,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Opening secure checkout..."]})]})]})]})}export{W as P,Y as a};
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.