PageSourceSearch

https://www.childfund.org/scripts/CgVsFCmu-entraIdPaymentWizard.js

js childfund.org collected 2026-10-02 06:07:19 UTC 45,571 bytes, 2 lines download raw bytes

1import{j as e}from"./D_zvdyIk-jsx-runtime.js";import{r as i}from"./DEmwW7Sr-index.js";import{L as Z}from"./byCXDQjA-loaderChildfund.js";import{S as Qe,b as er,c as rr,f as Ne,d as fe,C as xe,A as nr,D as ar,u as tr,a as ir}from"./D7vLzwps-types.js";import{R as V,B as Ee}from"./Dqp8F04z-rtf.js";import{S as B}from"./CBDLwlLx-svg.js";import{f as sr,g as dr}from"./B-PNIMXA-stateOptions.js";import{u as cr,s as Te}from"./BSro-SPp-events.js";const or=({steps:r})=>e.jsx("ol",{className:"progress-indicator",role:"list","aria-label":"Checkout progress",children:r.map((n,s)=>e.jsx("li",{className:`progress-indicator__step${n.isComplete?" progress-indicator__step--complete":""}`,...n.isCurrent?{"aria-current":"step"}:{}},s))}),lr={control:r=>({...r,minHeight:"64px",height:"64px",backgroundColor:"#ffffff",borderColor:"#3c423f",borderWidth:"1px",borderRadius:"8px",boxShadow:"none",cursor:"text","&:hover":{borderColor:"#3c423f"}}),valueContainer:r=>({...r,padding:"16px 19px",height:"62px"}),input:r=>({...r,margin:0,padding:0,color:"#000000",fontFamily:"var(--font-family-body)",fontSize:"20px",fontWeight:400,lineHeight:"32px"}),singleValue:r=>({...r,color:"#000000",fontFamily:"var(--font-family-body)",fontSize:"20px",fontWeight:400,lineHeight:"32px"}),placeholder:r=>({...r,color:"#999999",fontFamily:"var(--font-family-body)",fontSize:"20px",fontWeight:400,lineHeight:"32px"}),menu:r=>({...r,backgroundColor:"#ffffff",border:"1px solid #3c423f",borderRadius:"8px",boxShadow:"0 4px 8px rgba(0, 0, 0, 0.1)",marginTop:"4px",zIndex:10}),menuList:r=>({...r,padding:0,maxHeight:"200px"}),option:(r,n)=>({...r,backgroundColor:n.isSelected?"#d4edda":n.isFocused?"#f5f5f5":"transparent",color:"#000000",fontFamily:"var(--font-family-body)",fontSize:"20px",fontWeight:400,lineHeight:"32px",padding:"12px 19px",cursor:"pointer","&:active":{backgroundColor:"#d4edda"}}),indicatorSeparator:()=>({display:"none"}),dropdownIndicator:r=>({...r,color:"#3c423f",padding:"0 19px","&:hover":{color:"#3c423f"}}),clearIndicator:r=>({...r,color:"#999999",padding:"0 8px","&:hover":{color:"#3c423f"}})},_e=r=>{const n=(r??"").trim().toLowerCase();return n===""||n==="0"||n==="null"||n==="undefined"},Ie=({idPrefix:r,isSameAsMailing:n,onSameAsMailingChange:s,donorContact:t,billingFormData:b,onBillingFormChange:x,stateOptions:j,experianToken:l,labels:_,onAddressAutofilled:f,onSuggestionsReceived:M,onManualAddressEdit:A})=>{const[o,c]=i.useState(null),u=i.useMemo(()=>{const p=t?.stateName??"",y=t?.state??"";return _e(p)?_e(y)?"":y:p},[t]),m=i.useRef(null),L=i.useRef(null),C=i.useRef(null),I=i.useRef(null),N=i.useRef(null),E=i.useCallback((p,y)=>{x(T=>({...T,[p]:y}))},[x]),h=i.useCallback((p,y)=>{A?.(),E(p,y)},[E,A]),O=i.useCallback(p=>{const T=p.replace(/\D/g,"").slice(0,9),k=T.length>5?`${T.slice(0,5)}-${T.slice(5)}`:T;h("zipCode",k)},[h]);i.useEffect(()=>{if(b.state&&j.length>0){const p=j.find(y=>y.value===b.state||y.label===b.state);p&&p.value!==o?.value&&c(p)}else!b.state&&o&&c(null)},[b.state,j,o]),cr({addressLine1Ref:m,addressLine2Ref:L,cityRef:C,stateRef:I,zipCodeRef:N,formData:{billingAddressLine1:b.addressLine1,billingAddressLine2:b.addressLine2,city:b.city,state:b.state,zipCode:b.zipCode},onFieldChange:(p,y)=>{const k={billingAddressLine1:"addressLine1",billingAddressLine2:"addressLine2",city:"city",state:"state",zipCode:"zipCode"}[p];k&&E(k,y)},onAddressAutofilled:f,onSuggestionsReceived:M,onManualAddressEdit:A,experianToken:l});const w=i.useCallback(p=>{c(p),h("state",p?.value??"")},[h]);return e.jsxs("div",{className:"entra-id-payment__billing-section",children:[e.jsxs("div",{className:"entra-id-payment__checkbox-wrapper",children:[e.jsx("input",{id:`${r}-same-as-mailing`,type:"checkbox",className:"entra-id-payment__checkbox",checked:n,onChange:p=>s(p.target.checked)}),e.jsxs("label",{htmlFor:`${r}-same-as-mailing`,className:"entra-id-payment__checkbox-label",children:[e.jsx("span",{className:"entra-id-payment__checkbox-label-title copy-medium",children:_.billingCheckboxLabel}),t&&e.jsxs("span",{className:"entra-id-payment__checkbox-label-text copy-medium",children:[t.addressLine1,t.addressLine2&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),t.addressLine2]}),e.jsx("br",{}),t.city,u?`, ${u}`:"",t.zipCode&&` ${t.zipCode}`,t.countryName&&` ${t.countryName}
1`,t.phone&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),t.phone]})]})]})]}),e.jsxs("div",{className:"entra-id-payment__billing-form",style:{display:n?"none":"flex"},children:[e.jsxs("div",{className:"entra-id-payment__form-field entra-id-payment__form-field--address",children:[e.jsxs("label",{htmlFor:`${r}-address1`,className:"entra-id-payment__form-label",children:[_.billingAddressLine1Label,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{ref:m,id:`${r}-address1`,type:"text",className:"entra-id-payment__form-input",value:b.addressLine1,onChange:p=>h("addressLine1",p.target.value),placeholder:_.billingAddressLine1Placeholder,required:!0,"aria-required":"true",autoComplete:"new-password"})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsx("label",{htmlFor:`${r}-address2`,className:"entra-id-payment__form-label",children:_.billingAddressLine2Label}),e.jsx("input",{ref:L,id:`${r}-address2`,type:"text",className:"entra-id-payment__form-input",value:b.addressLine2,onChange:p=>h("addressLine2",p.target.value),placeholder:_.billingAddressLine2Placeholder})]}),e.jsxs("div",{className:"entra-id-payment__form-row",children:[e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:`${r}-city`,className:"entra-id-payment__form-label",children:[_.cityLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{ref:C,id:`${r}-city`,type:"text",className:"entra-id-payment__form-input",value:b.city,onChange:p=>h("city",p.target.value),placeholder:_.cityPlaceholder,required:!0,"aria-required":"true"})]}),e.jsxs("div",{className:"entra-id-payment__form-field entra-id-payment__form-field--state",children:[e.jsxs("label",{htmlFor:`${r}-state`,className:"entra-id-payment__form-label",children:[_.stateLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsxs(e.Fragment,{children:[e.jsx(Qe,{inputId:`${r}-state`,name:`${r}-state`,options:j,value:o,onChange:w,placeholder:_.statePlaceholder,isSearchable:!0,styles:lr,classNamePrefix:"entra-id-payment-select",noOptionsMessage:()=>_.stateNoOptionsMessage,"aria-label":`${_.stateLabel}, required`}),e.jsx("input",{ref:I,type:"hidden",value:b.state,onChange:p=>E("state",p.target.value),"aria-hidden":"true",tabIndex:-1})]})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:`${r}-zipcode`,className:"entra-id-payment__form-label",children:[_.zipCodeLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{ref:N,id:`${r}-zipcode`,type:"text",inputMode:"numeric",className:"entra-id-payment__form-input",value:b.zipCode,onChange:p=>O(p.target.value),placeholder:_.zipCodePlaceholder,maxLength:10,required:!0,"aria-required":"true"})]})]})]})]})},ur=({isExpanded:r,onToggle:n,hasSavedMethods:s,formData:t,onFormDataChange:b,billingFormData:x,onBillingFormChange:j,billingSameAsMailing:l,onBillingSameAsMailingChange:_,donorContact:f,stateOptions:M,experianToken:A,labels:o,formErrors:c,touchedFields:u,onFieldBlur:m,onAddressAutofilled:L,onSuggestionsReceived:C,onManualAddressEdit:I})=>{const N=s?o.bankAccordionLabelSaved:o.bankAccordionLabel,E=i.useCallback((h,O)=>{b({...t,[h]:O})},[t,b]);return e.jsxs("div",{className:"entra-id-payment__accordion",children:[e.jsxs("button",{type:"button",id:"entra-bank-trigger",className:"entra-id-payment__accordion-trigger","aria-expanded":r,"aria-controls":"entra-bank-panel",onClick:n,children:[e.jsx(B,{name:"bank",className:"entra-id-payment__accordion-icon"}),e.jsx("span",{className:"entra-id-payment__accordion-text",children:N}),e.jsx(B,{name:r?"minus":"plus",className:`entra-id-payment__accordion-toggle-icon${r?" entra-id-payment__accordion-toggle-icon--expanded":""}`})]}),e.jsx("div",{id:"entra-bank-panel",role:"region","aria-labelledby":"entra-bank-trigger",className:`entra-id-payment__accordion-panel${r?" entra-id-payment__accordion-panel--expanded":""}`,children:e.jsx("div",{className:"entra-id-payment__accordion-content",children:e.jsxs("div",{className:"entra-id-payment__payment-form-fields",children:[e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-routingNumber",className:"entra-id-payment__form-label",children:[o.routingNumberLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{id:"entra-routingNumber",type:"text",inputMode:"numeric",maxLength:9,className:`entra-id-payment__form-input${u.routingNumber&&c.routingNumber?" entra-id-payment__form-input--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.routingNumber&&c.routingNumber),"aria-describedby":c.routingNumber?"entra-routingNumber-error":void 0,value:t.routingNumber,onChange:h=>E("routingNumber",h.target.value.replace(/\D/g,"").slice(0,9)),onBlur:()=>m("routingNumber"),placeholder:o.routingNumberPlaceholder}),u.routingNumber&&c.routingNumber&&e.jsx("span",{id:"entra-routingNumber-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.routingNumber})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-confirmRoutingNumber",className:"entra-id-payment__form-label",children:[o.confirmRoutingNumberLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{id:"entra-confirmRoutingNumber",type:"text",inputMode:"numeric",maxLength:9,className:`entra-id-payment__form-input${u.confirmRoutingNumber&&c.confirmRoutingNumber?" entra-id-payment__form-input--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.confirmRoutingNumber&&c.confirmRoutingNumber),"aria-describedby":c.confirmRoutingNumber?"entra-confirmRoutingNumber-error":void 0,value:t.confirmRoutingNumber,onChange:h=>E("confirmRoutingNumber",h.target.value.replace(/\D/g,"").slice(0,9)),onBlur:()=>m("confirmRoutingNumber"),placeholder:o.routingNumberPlaceholder}),u.confirmRoutingNumber&&c.confirmRoutingNumber&&e.jsx("span",{id:"entra-confirmRoutingNumber-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.confirmRoutingNumber})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-accountNumber",className:"entra-id-payment__form-label",children:[o.accountNumberLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{id:"entra-accountNumber",type:"text",inputMode:"numeric",maxLength:17,className:`entra-id-payment__form-input${u.accountNumber&&c.accountNumber?" entra-id-payment__form-input--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.accountNumber&&c.accountNumber),"aria-describedby":c.accountNumber?"entra-accountNumber-error":void 0,value:t.accountNumber,onChange:h=>E("accountNumber",h.target.value.replace(/\D/g,"").slice(0,17)),onBlur:()=>m("accountNumber"),placeholder:o.accountNumberPlaceholder}),u.accountNumber&&c.accountNumber&&e.jsx("span",{id:"entra-accountNumber-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.accountNumber})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-confirmAccountNumber",className:"entra-id-payment__form-label",children:[o.confirmAccountNumberLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{id:"entra-confirmAccountNumber",type:"text",inputMode:"numeric",maxLength:17,className:`entra-id-payment__form-input${u.confirmAccountNumber&&c.confirmAccountNumber?" entra-id-payment__form-input--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.confirmAccountNumber&&c.confirmAccountNumber),"aria-describedby":c.confirmAccountNumber?"entra-confirmAccountNumber-error":void 0,value:t.confirmAccountNumber,onChange:h=>E("confirmAccountNumber",h.target.value.replace(/\D/g,"").slice(0,17)),onBlur:()=>m("confirmAccountNumber"),placeholder:o.accountNumberPlaceholder}),u.confirmAccountNumber&&c.confirmAccountNumber&&e.jsx("span",{id:"entra-confirmAccountNumber-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.confirmAccountNumber})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-nameOnAccount",className:"entra-id-payment__form-label",children:[o.nameOnAccountLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{id:"entra-nameOnAccount",type:"text",className:`entra-id-payment__form-input${u.nameOnAccount&&c.nameOnAccount?" entra-id-payment__form-input--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.nameOnAccount&&c.nameOnAccount),"aria-describedby":c.nameOnAccount?"entra-nameOnAccount-error":void 0,value:t.nameOnAccount,onChange:h=>E("nameOnAccount",h.target.value),onBlur:()=>m("nameOnAccount"),placeholder:o.nameOnAccountPlaceholder}),u.nameOnAccount&&c.nameOnAccount&&e.jsx("span",{id:"entra-nameOnAccount-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.nameOnAccount})]}),e.jsx(Ie,{idPrefix:"bank",isSameAsMailing:l,onSameAsMailingChange:_,donorContact:f,billingFormData:x,onBillingFormChange:j,stateOptions:M,experianToken:A,labels:o,onAddressAutofilled:L,onSuggestionsReceived:C,onManualAddressEdit:I}),e.jsxs("div",{className:"entra-id-payment__checkbox-wrapper",children:[e.jsx("input",{id:"entra-agreeToTerms",type:"checkbox",className:`entra-id-payment__checkbox${u.agreeToTerms&&c.agreeToTerms?" entra-id-payment__checkbox--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.agreeToTerms&&c.agreeToTerms),"aria-describedby":c.agreeToTerms?"entra-agreeToTerms-error":void 0,checked:t.agreeToTerms,onChange:h=>E("agreeToTerms",h.target.checked)}),e.jsxs("label",{htmlFor:"entra-agreeToTerms",className:"entra-id-payment__checkbox-label",children:[e.jsx(V,{className:"entra-id-payment__checkbox-label-title entra-id-payment__terms-rtf copy-medium",value:o.termsLabel,size:"medium"}),e.jsx(V,{className:"entra-id-payment__checkbox-label-text copy-medium",value:o.processingNote,size:"medium"})]})]}),u.agreeToTerms&&c.agreeToTerms&&e.jsx("span",{id:"entra-agreeToTerms-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.agreeToTerms})]})})})]})},mr=({isExpanded:r,onToggle:n,hasSavedMethods:s,formData:t,onFormDataChange:b,billingFormData:x,onBillingFormChange:j,billingSameAsMailing:l,onBillingSameAsMailingChange:_,donorContact:f,stateOptions:M,experianToken:A,labels:o,formErrors:c,touchedFields:u,onFieldBlur:m,onAddressAutofilled:L,onSuggestionsReceived:C,onManualAddressEdit:I})=>{const{meta:N,getCardNumberProps:E,getExpiryDateProps:h,getCVCProps:O}
1=er({errorMessages:{emptyCardNumber:o.cardNumberError,invalidCardNumber:o.cardNumberError,emptyExpiryDate:o.expirationError,monthOutOfRange:o.expirationError,yearOutOfRange:o.expirationError,dateOutOfRange:o.expirationError,invalidExpiryDate:o.expirationError,emptyCVC:o.securityCodeError,invalidCVC:o.securityCodeError}}),w=s?o.cardAccordionLabelSaved:o.cardAccordionLabel,p=i.useCallback((y,T)=>{b({...t,[y]:T})},[t,b]);return e.jsxs("div",{className:"entra-id-payment__accordion",children:[e.jsxs("button",{type:"button",id:"entra-card-trigger",className:"entra-id-payment__accordion-trigger","aria-expanded":r,"aria-controls":"entra-card-panel",onClick:n,children:[e.jsx(B,{name:"credit-card",className:"entra-id-payment__accordion-icon"}),e.jsx("span",{className:"entra-id-payment__accordion-text",children:w}),e.jsx(B,{name:r?"minus":"plus",className:`entra-id-payment__accordion-toggle-icon${r?" entra-id-payment__accordion-toggle-icon--expanded":""}`})]}),e.jsx("div",{id:"entra-card-panel",role:"region","aria-labelledby":"entra-card-trigger",className:`entra-id-payment__accordion-panel${r?" entra-id-payment__accordion-panel--expanded":""}`,children:e.jsx("div",{className:"entra-id-payment__accordion-content",children:e.jsxs("div",{className:"entra-id-payment__payment-form-fields",children:[e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-cardNumber",className:"entra-id-payment__form-label",children:[o.cardNumberLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{...E({onChange:y=>{p("cardNumber",y.target.value)},onBlur:()=>{m("cardNumber")}}),id:"entra-cardNumber",name:"entra-cardNumber",className:`entra-id-payment__form-input${u.cardNumber&&N.erroredInputs.cardNumber?" entra-id-payment__form-input--error":""}`,placeholder:o.cardNumberPlaceholder,value:t.cardNumber}),u.cardNumber&&N.erroredInputs.cardNumber&&e.jsx("span",{className:"entra-id-payment__form-error-text",role:"alert",children:N.erroredInputs.cardNumber})]}),e.jsxs("div",{className:"entra-id-payment__form-row",children:[e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-expiration",className:"entra-id-payment__form-label",children:[o.expirationLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{...h({onChange:y=>{p("expiration",y.target.value)},onBlur:()=>{m("expiration")}}),id:"entra-expiration",name:"entra-expiration",className:`entra-id-payment__form-input${u.expiration&&N.erroredInputs.expiryDate?" entra-id-payment__form-input--error":""}`,placeholder:o.expirationPlaceholder,value:t.expiration}),u.expiration&&N.erroredInputs.expiryDate&&e.jsx("span",{className:"entra-id-payment__form-error-text",role:"alert",children:N.erroredInputs.expiryDate})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-securityCode",className:"entra-id-payment__form-label",children:[o.securityCodeLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{...O({onChange:y=>{p("securityCode",Te(y.target.value))},onBlur:()=>{m("securityCode")}}),id:"entra-securityCode",name:"entra-securityCode",className:`entra-id-payment__form-input${u.securityCode&&N.erroredInputs.cvc?" entra-id-payment__form-input--error":""}`,placeholder:o.securityCodePlaceholder,value:t.securityCode}),u.securityCode&&N.erroredInputs.cvc&&e.jsx("span",{className:"entra-id-payment__form-error-text",role:"alert",children:N.erroredInputs.cvc})]})]}),e.jsxs("div",{className:"entra-id-payment__form-field",children:[e.jsxs("label",{htmlFor:"entra-nameOnCard",className:"entra-id-payment__form-label",children:[o.nameOnCardLabel,e.jsx("span",{className:"entra-id-payment__required-asterisk",children:"*"})]}),e.jsx("input",{id:"entra-nameOnCard",type:"text",className:`entra-id-payment__form-input${u.nameOnCard&&c.nameOnCard?" entra-id-payment__form-input--error":""}`,required:!0,"aria-required":"true","aria-invalid":!!(u.nameOnCard&&c.nameOnCard),"aria-describedby":c.nameOnCard?"entra-nameOnCard-error":void 0,value:t.nameOnCard,onChange:y=>p("nameOnCard",y.target.value),onBlur:()=>m("nameOnCard"),placeholder:o.nameOnCardPlaceholder}),u.nameOnCard&&c.nameOnCard&&e.jsx("span",{id:"entra-nameOnCard-error",className:"entra-id-payment__form-error-text",role:"alert","aria-live":"polite",children:c.nameOnCard})]}),e.jsx(Ie,{idPrefix:"card",isSameAsMailing:l,onSameAsMailingChange:_,donorContact:f,billingFormData:x,onBillingFormChange:j,stateOptions:M,experianToken:A,labels:o,onAddressAutofilled:L,onSuggestionsReceived:C,onManualAddressEdit:I})]})})})]})};function pr(r,n){return r.success?{success:!0,transactionId:r.transactionId,currentDate:r.currentDate,message:r.message}:{success:!1,message:r.message||n}}function br(r){if(!r||typeof r!="object")return;const n=r.billingAddress;if(!n||typeof n!="object")return;const s=n.email;return typeof s=="string"?s:void 0}const gr=({endpoint:r,fallbackErrorMessage:n})=>{const[s,t]=i.useState(!1),[b,x]=i.useState([]),[j,l]=i.useState(null),_=i.useRef(null),f=n||"An error occurred while processing your donation. Please try again.",M=i.useCallback(async A=>
1{if(!r)return{success:!1};const o=br(A);_.current?.abort();const c=new AbortController;_.current=c,t(!0),x([]);try{const u=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A),signal:c.signal});if(!u.ok)throw new Error(`Submission failed: ${u.status}`);const m=await u.json(),L=pr(m,f);if(L.success){const C={...L,billingAddressEmail:o};return l(C),C}return x(L.message?[L.message]:[f]),L}catch(u){return u instanceof DOMException&&u.name==="AbortError"?{success:!1}:(x([f]),{success:!1})}finally{t(!1)}},[r,f]);return{isSubmitting:s,errors:b,successData:j,submitDonation:M}},Ae=r=>{const n=(r??"").trim().toLowerCase();return n===""||n==="0"||n==="null"||n==="undefined"},hr=(r,n)=>Ae(r)?Ae(n)?"":(n??"").trim():(r??"").trim();function yr(r,n){return(n.type==="card"||n.type==="bank")&&n.billingAddress?{...n.billingAddress,countryName:null,countryCode:null}:{countryName:r.countryName,countryCode:r.countryCode,addressLine1:r.addressLine1,addressLine2:r.addressLine2,city:r.city,state:hr(r.stateName,r.state),zipCode:r.zipCode}}function Nr(r,n,s){const t=yr(r,n),b={firstName:r.firstName,lastName:r.lastName,email:r.email,billingAddressLine1:t.addressLine1,billingAddressLine2:t.addressLine2,city:t.city,state:t.state,countryName:t.countryName,countryCode:t.countryCode,zipCode:t.zipCode,phoneNumber:r.phone,phoneExt:r.phoneExt};let x;switch(n.type){case"existing":x={type:"existing",paymentMethodId:String(n.paymentMethodId),existingPaymentStringKeyword:n.methodType==="card"?"GenericCreditCard":"Account"};break;case"bank":x={type:"bank",bankData:n.bankData};break;default:x={type:"card",cardData:{...n.cardData,cardNumber:n.cardData.cardNumber.replace(/\s/g,""),securityCode:Te(n.cardData.securityCode),nameOnCard:n.cardData.nameOnCard.trim(),coverProcessingFees:!1}};break}return rr(b,x,s,!1)}function fr(r){return{agpId:r.id,label:r.accountNumber,iconName:r.accountNumberIconName,isLastUsed:r.isLastUsed||r.IsLastUsed||!1,methodType:r.stringKeyword==="GenericCreditCard"?"card":"bank"}}const Oe={cardNumberLabel:"Card number",cardNumberPlaceholder:"0000 0000 0000 0000",cardNumberError:"Please enter a valid card number",expirationLabel:"Expiration (MM/YY)",expirationPlaceholder:"MM/YY",expirationError:"Please enter a valid expiration date",securityCodeLabel:"Security Code (CVV)",securityCodePlaceholder:"ex 123",securityCodeError:"Please enter a valid security code",nameOnCardLabel:"Name on Card",nameOnCardPlaceholder:"John T. Smith",nameOnCardError:"Please enter the name on your card",routingNumberLabel:"Routing Number",routingNumberPlaceholder:"123456789",routingNumberError:"Please enter a valid routing number",routingNumberLengthError:"Routing number must be exactly 9 digits",confirmRoutingNumberLabel:"Confirm Routing Number",confirmRoutingNumberError:"Routing numbers do not match",accountNumberLabel:"Account Number",accountNumberPlaceholder:"1234567890",accountNumberError:"Please enter a valid account number",accountNumberMinLengthError:"Account number must be between 4 and 17 digits",confirmAccountNumberLabel:"Confirm Account Number",confirmAccountNumberError:"Account numbers do not match",nameOnAccountLabel:"Name as Appears on Account",nameOnAccountPlaceholder:"John T. Smith",nameOnAccountError:"Please enter the name on your account",termsLabel:'<p><strong>By checking this box I agree to the <a href="#" target="_blank" rel="noopener noreferrer">payment terms and conditions</a></strong></p>',termsError:"You must agree to the terms and conditions",processingNote:"<p>Please allow for up to 1 business day for your payment method updates to process</p>",bankAccordionLabel:"Pay with Bank",bankAccordionLabelSaved:"Add Bank Account",cardAccordionLabel:"Pay with Credit Card",cardAccordionLabelSaved:"Add Credit Card",billingCheckboxLabel:"Same as mailing address",billingAddressLine1Label:"Billing Address Line 1",billingAddressLine1Placeholder:"Street address",billingAddressLine2Label:"Billing Address Line 2",billingAddressLine2Placeholder:"Apartment, suite, unit (optional)",cityLabel:"City",cityPlaceholder:"Enter your city",stateLabel:"State",statePlaceholder:"State",z
1ipCodeLabel:"Zip Code",zipCodePlaceholder:"Enter your ZIP code",reviewCtaLabel:"Review Your Donation",stepIndicator:"Proceed to step 2 of 2",confirmAddressModalTitle:"Confirm your billing address",confirmAddressModalDescription:"Please confirm the billing address you entered or select one of the suggested addresses below.",continueLabel:"Continue",cancelLabel:"Cancel",userEnteredAddressLabel:"Address you entered",suggestedAddressLabel:"Suggested address",exactMatchAddress:"Same as entered above",contactInfoHeader:"Contact Information",billingAddressHeader:"Billing Address",paymentInfoHeader:"Payment Information",editLabel:"Edit",confirmDonationLabel:"Confirm Donation",submissionErrorMessage:"An error occurred while processing your donation. Please try again.",loadingLabel:"Loading payment information",processingLabel:"Processing your donation",paymentMethodHeader:"Payment Method",savedMethodsLegend:"Select a payment method",savedPaymentMethodFallback:"Saved payment method",stateNoOptionsMessage:"No states found",cardBrandVisa:"Visa",cardBrandMasterCard:"MasterCard",cardBrandAmericanExpress:"American Express",cardBrandDiscover:"Discover",cardBrandGeneric:"Card",cardEndingTemplate:"{brand} ending in {last4}",bankAccountEndingTemplate:"Bank account ending in {last4}",savedCardTemplate:"{brand} {ending}",checkingAccountTemplate:"Checking account {ending}",savingsAccountTemplate:"Savings account {ending}",accountFallbackLabel:"Account"},Le=9,Ce=4,ve=17,xr={routingNumber:"",confirmRoutingNumber:"",accountNumber:"",confirmAccountNumber:"",nameOnAccount:"",agreeToTerms:!1},_r={cardNumber:"",expiration:"",securityCode:"",nameOnCard:""},je={countryName:null,countryCode:null,addressLine1:"",addressLine2:"",city:"",state:"",zipCode:""},Ar=(r,n)=>{if(r?.type==="existing")return String(r.paymentMethodId);if(!(r?.type==="bank"||r?.type==="card"))return n},Lr=(r,n)=>r?.type==="bank"?"bank":r?.type==="card"?"card":n?null:"card",ke=(r,n)=>r?.type===n&&r.billingAddress?{...je,...r.billingAddress}:{...je},Cr=({savedMethods:r,donorContact:n,onReviewDonation:s,initialPaymentData:t,reviewOrderEndpoint:b,stateOptions:x,experianToken:j,labels:l,ctaLabel:_})=>{const f=i.useId(),M=r.length>0,A=r.find(a=>a.isLastUsed),o=A?String(A.agpId):void 0,[c,u]=i.useState(()=>Ar(t,o)),[m,L]=i.useState(()=>Lr(t,M));i.useEffect(()=>{!o||m!==null||u(a=>a&&r.some(d=>String(d.agpId)===a)?a:o)},[m,o,r]);const[C,I]=i.useState(()=>t?.type==="bank"?{...t.bankData}:{...xr}),[N,E]=i.useState(()=>ke(t,"bank")),[h,O]=i.useState(()=>!(t?.type==="bank"&&t.billingAddress)),[w,p]=i.useState(!1),[y,T]=i.useState(()=>t?.type==="card"?{...t.cardData}:{..._r}),[k,$]=i.useState(()=>ke(t,"card")),[R,U]=i.useState(()=>!(t?.type==="card"&&t.billingAddress)),[P,v]=i.useState(!1),[z,we]=i.useState([]),[Y,q]=i.useState(!1),[D,Be]=i.useState([]),[K,F]=i.useState(!1),[J,X]=i.useState(null),{isSubmitting:Q,errors:Re,submitDonation:ee}=gr({endpoint:b,fallbackErrorMessage:l.submissionErrorMessage}),re=i.useCallback(a=>{const d=sr(a,x),g=String(d?.value??"").trim(),S=String(d?.stateCode??"").trim();return g&&/[A-Za-z]/.test(g)?g.toUpperCase():S&&/[A-Za-z]/.test(S)?S.toUpperCase():dr(a,x)},[x]),ne=i.useCallback(a=>{const d=re(a.state),g=n?.countryCode??a.countryCode;
1return{street:a.addressLine2?`${a.addressLine1}, ${a.addressLine2}`:a.addressLine1,cityStateZip:[a.city,d,a.zipCode].filter(Boolean).join(" "),billingAddressLine1:a.addressLine1,billingAddressLine2:a.addressLine2,city:a.city,state:d,zipCode:a.zipCode,phone:Ne(g,n?.phone??null)}},[n?.countryCode,n?.phone,re]),ae=i.useCallback(a=>{const d=a.match(/^(.+),\s*([^,]*[^,\s])\s+([A-Z]{2})\s+(\d{5}(?:-\d{4})?)$/i);return d&&d[1]&&d[2]&&d[3]&&d[4]?{street:d[1].trim(),city:d[2].trim(),state:d[3].toUpperCase(),zipCode:d[4]}:{street:a,city:"",state:"",zipCode:""}},[]),te=i.useCallback(a=>{const d=ae(a.text||"");return{street:d.street,cityStateZip:d.city?`${d.city} ${d.state} ${d.zipCode}`:"",billingAddressLine1:d.street,billingAddressLine2:"",city:d.city,state:d.state,zipCode:d.zipCode,phone:Ne(n?.countryCode,n?.phone??null)}},[n?.countryCode,n?.phone,ae]),Pe=i.useCallback((a,d)=>{const g=d==="suggested"?a:{billingAddressLine1:N.addressLine1,billingAddressLine2:N.addressLine2,city:N.city,state:N.state,zipCode:N.zipCode};E(S=>({...S,addressLine1:g.billingAddressLine1,addressLine2:g.billingAddressLine2,city:g.city,state:g.state,zipCode:g.zipCode})),p(!1),q(!1)},[N]),ze=i.useCallback((a,d)=>{const g=d==="suggested"?a:{billingAddressLine1:k.addressLine1,billingAddressLine2:k.addressLine2,city:k.city,state:k.state,zipCode:k.zipCode};$(S=>({...S,addressLine1:g.billingAddressLine1,addressLine2:g.billingAddressLine2,city:g.city,state:g.state,zipCode:g.zipCode})),v(!1),F(!1)},[k]),$e=i.useCallback(()=>{p(!1)},[]),qe=i.useCallback(()=>{v(!1)},[]),Fe=i.useCallback(a=>{O(a),a&&(p(!1),q(!1))},[]),He=i.useCallback(a=>{U(a),a&&(v(!1),F(!1))},[]),[Ve,ie]=i.useState({}),[Ue,se]=i.useState({}),H=i.useCallback((a,d)=>{switch(a){case"routingNumber":{const g=d.routingNumber.replace(/\D/g,"");return g?g.length!==Le?l.routingNumberLengthError:"":l.routingNumberError}case"confirmRoutingNumber":return d.confirmRoutingNumber?d.confirmRoutingNumber!==d.routingNumber?l.confirmRoutingNumberError:"":l.routingNumberError;case"accountNumber":{const g=d.accountNumber.replace(/\D/g,"");return g?g.length<Ce||g.length>ve?l.accountNumberMinLengthError:"":l.accountNumberError}case"confirmAccountNumber":return d.confirmAccountNumber?d.confirmAccountNumber!==d.accountNumber?l.confirmAccountNumberError:"":l.accountNumberError;case"nameOnAccount":return d.nameOnAccount.trim()?"":l.nameOnAccountError;case"agreeToTerms":return d.agreeToTerms?"":l.termsError;default:return""}},[l]),De=i.useCallback(a=>{se(g=>({...g,[a]:!0}));const d=H(a,C);ie(g=>({...g,[a]:d}))},[C,H]),de=i.useCallback(()=>{const a=["routingNumber","confirmRoutingNumber","accountNumber","confirmAccountNumber","nameOnAccount","agreeToTerms"],d={},g={};for(const S of a)d[S]=H(S,C),g[S]=!0;return ie(d),se(g),!Object.values(d).some(S=>S!=="")},[C,H]),[Ge,ce]=i.useState({}),[We,oe]=i.useState({}),Ze=i.useCallback(a=>
1{if(oe(d=>({...d,[a]:!0})),a==="nameOnCard"){const d=y.nameOnCard.trim()?"":l.nameOnCardError;ce(g=>({...g,nameOnCard:d}))}},[y.nameOnCard,l.nameOnCardError]),G=i.useCallback(a=>a.addressLine1.trim()!==""&&a.city.trim()!==""&&a.state!==""&&a.zipCode.replace(/\D/g,"").length>=5,[]),le=i.useMemo(()=>{const a=C;return a.routingNumber.replace(/\D/g,"").length===Le&&a.confirmRoutingNumber===a.routingNumber&&a.accountNumber.replace(/\D/g,"").length>=Ce&&a.accountNumber.replace(/\D/g,"").length<=ve&&a.confirmAccountNumber===a.accountNumber&&a.nameOnAccount.trim()!==""&&a.agreeToTerms},[C]),ue=i.useMemo(()=>y.cardNumber!==""&&y.expiration!==""&&y.securityCode!==""&&y.nameOnCard.trim()!=="",[y]),me=i.useCallback(a=>{L(d=>d===a?null:a),m!==a&&u(void 0)},[m]),W=i.useCallback(a=>{u(a),L(null)},[]),Ye=i.useCallback(async()=>{let a=null;if(c&&m===null){const g=r.find(S=>String(S.agpId)===c);g&&(a={type:"existing",paymentMethodId:g.agpId,methodType:g.methodType})}else if(m==="bank"){if(!de())return;if(!h&&w&&z.length>0){q(!0);return}a={type:"bank",bankData:C,billingAddress:h?null:N}}else if(m==="card"){if(!y.nameOnCard.trim()){ce(S=>({...S,nameOnCard:l.nameOnCardError})),oe(S=>({...S,nameOnCard:!0}));return}if(!R&&P&&D.length>0){F(!0);return}a={type:"card",cardData:y,billingAddress:R?null:k}}if(!a)return;if(!n){X(l.submissionErrorMessage);return}X(null);const d=Nr(n,a,x);b&&!(await ee(d)).success||s(a,d)},[c,m,r,n,C,y,N,k,h,R,w,P,z,D,s,x,b,ee,de,l.nameOnCardError,l.submissionErrorMessage]),Ke=i.useMemo(()=>c&&m===null?!1:m==="bank"?!le||!h&&!G(N):m==="card"?!ue||!R&&!G(k):!0,[c,m,le,ue,h,R,N,k,G]),pe=J?[J]:Re,be=ne(N),ge=z.map(te),Je=fe(be,ge,x),he=ne(k),ye=D.map(te),Xe=fe(he,ye,x);return e.jsxs("div",{className:"entra-id-payment",children:[e.jsxs("div",{className:"entra-id-payment__content-wrapper",children:[e.jsx("h2",{className:"entra-id-payment__header heading-5",children:l.paymentMethodHeader}),e.jsxs("div",{className:"entra-id-payment__content",children:[r.length>0&&e.jsxs("fieldset",{className:"entra-id-payment__saved-methods",children:[e.jsx("legend",{className:"visually-hidden",children:"Select a payment method"}),r.map(a=>e.jsxs("div",{className:"entra-id-payment__saved-method-option",children:[e.jsx("input",{type:"radio",id:`${f}-pm-${a.agpId}`,name:f,value:String(a.agpId),checked:c===String(a.agpId),onChange:()=>W(String(a.agpId)),className:"entra-id-payment__saved-method-radio"}),e.jsxs("label",{htmlFor:`${f}-pm-${a.agpId}`,className:"entra-id-payment__saved-method-label",onClick:()=>W(String(a.agpId)),onKeyDown:d=>{d.key==="Enter"&&W(String(a.agpId))},children:[e.jsx(B,{name:a.iconName,className:"entra-id-payment__saved-method-icon"}),e.jsx("span",{className:"entra-id-payment__saved-method-text copy-medium",children:a.label})]})]},a.agpId))]}),e.jsxs("div",{className:"entra-id-payment__add-payment-methods",children:[e.jsx(ur,{isExpanded:m==="bank",onToggle:()=>me("bank"),hasSavedMethods:M,formData:C,onFormDataChange:I,billingFormData:N,onBillingFormChange:E,billingSameAsMailing:h,onBillingSameAsMailingChange:Fe,donorContact:n,stateOptions:x,experianToken:j,labels:l,formErrors:Ve,touchedFields:Ue,onFieldBlur:De,onAddressAutofilled:$e,onSuggestionsReceived:a=>we(a.slice(0,2)),onManualAddressEdit:()=>p(!0)}),e.jsx(mr,{isExpanded:m==="card",onToggle:()=>me("card"),hasSavedMethods:M,formData:y,onFormDataChange:T,billingFormData:k,onBillingFormChange:$,billingSameAsMailing:R,onBillingSameAsMailingChange:He,donorContact:n,stateOptions:x,experianToken:j,labels:l,formErrors:Ge,touchedFields:We,onFieldBlur:Ze,onAddressAutofilled:qe,onSuggestionsReceived:a=>Be(a.slice(0,2)),onManualAddressEdit:()=>v(!0)})]})]})]}),e.jsxs("div",{className:"entra-id-payment__actions",children:[Q?e.jsx(Z,{ariaLabel:l.processingLabel}):e.jsx(Ee,{className:"entra-id-payment__review-btn",label:_||l.reviewCtaLabel,onClick:Ye,disabled:Ke||Q}),e.jsx("p",{className:"entra-id-payment__step-indicator copy-medium",children:l.stepIndicator})]}),pe.length>0&&e.jsx("div",{className:"entra-id-payment__form-error",role:"alert",children:pe.map((a,d)=>e.jsx("p",{children:a},d))}),Y&&e.jsx(xe,{isOpen:Y,enteredAddress:be,suggestedAddresses:ge,onConfirm:Pe,onCancel:()=>q(!1),title:l.confirmAddressModalTitle,description:l.confirmAddressModalDescription,continueLabel:l.continueLabel,cancelLabel:l.cancelLabel,userEnteredAddressLabel:l.userEnteredAddressLabel,suggestedAddressLabel:l.suggestedAddressLabel,exactMatchAddressLabel:l.exactMatchAddress,exactMatchIndex:Je}),K&&e.jsx(xe,{isOpen:K,enteredAddress:he,suggestedAddresses:ye,onConfirm:ze,onCancel:()=>F(!1),title:l.confirmAddressModalTitle,description:l.confirmAddressModalDescription,continueLabel:l.continueLabel,cancelLabel:l.cancelLabel,userEnteredAddressLabel:l.userEnteredAddressLabel,suggestedAddressLabel:l.suggestedAddressLabel,exactMatchAddressLabel:l.exactMatchAddress,exactMatchIndex:Xe})]})};function vr(r,n){const s=r.replace(/\s/g,""),t=s[0],b=s.slice(0,2);return t==="4"?{label:n.cardBrandVisa,iconName:"visa"}:b>="51"&&b<="55"?{label:n.cardBrandMasterCard,iconName:"mastercard"}:b==="34"||b==="37"?{label:n.cardBrandAmericanExpress,iconName:"amex"}:b==="60"||b==="65"?{label:n.cardBrandDiscover,iconName:"discover"}
1:{label:n.cardBrandGeneric,iconName:"credit-card"}}function Se(r){return r.replace(/\D/g,"").slice(-4)}const Me=r=>{const n=(r??"").trim().toLowerCase();return n===""||n==="0"||n==="null"||n==="undefined"},jr=({paymentData:r,orderRequest:n,donorContact:s,savedMethods:t,onBack:b,onConfirmDonation:x,isSubmitting:j,submissionErrors:l,errorMessage:_,labels:f})=>{const M=i.useMemo(()=>!r||r.type==="existing"?!1:r.billingAddress!==null,[r]),A=i.useMemo(()=>r?r.type==="card"&&r.billingAddress||r.type==="bank"&&r.billingAddress?r.billingAddress:s?{countryName:s.countryName,countryCode:s.countryCode,addressLine1:s.addressLine1,addressLine2:s.addressLine2,city:s.city,state:s.state,stateName:s.stateName,zipCode:s.zipCode}:null:null,[r,s]),o=i.useMemo(()=>{const m=A?.stateName,L=A?.state;return Me(m)?Me(L)?"":L:m},[A]),c=i.useMemo(()=>{if(!r)return null;if(r.type==="existing"){const m=t.find(L=>L.agpId===r.paymentMethodId);return m?{label:m.label,iconName:m.iconName}:{label:f.savedPaymentMethodFallback,iconName:"credit-card"}}if(r.type==="card"){const m=vr(r.cardData.cardNumber,f),L=Se(r.cardData.cardNumber);return{label:f.cardEndingTemplate.replace("{brand}",m.label).replace("{last4}",L),iconName:m.iconName}}if(r.type==="bank"){const m=Se(r.bankData.accountNumber);return{label:f.bankAccountEndingTemplate.replace("{last4}",m),iconName:"bank"}}return null},[r,t,f]),u=l.length>0;return e.jsxs("div",{className:"entra-id-payment entra-id-payment--review",children:[e.jsxs("div",{className:"entra-id-payment__review-rows",children:[e.jsxs("div",{className:"entra-id-payment__review-row",children:[e.jsxs("div",{className:"entra-id-payment__review-row-header",children:[e.jsx(B,{name:"check-circle",className:"entra-id-payment__review-check-icon"}),e.jsx("h3",{className:"entra-id-payment__review-row-title heading-5",children:f.contactInfoHeader})]}),e.jsx("div",{className:"entra-id-payment__review-row-body",children:e.jsx("div",{className:"entra-id-payment__review-row-content copy-medium",children:s&&e.jsx("p",{children:s.email})})})]}),e.jsxs("div",{className:"entra-id-payment__review-row",children:[e.jsxs("div",{className:"entra-id-payment__review-row-header",children:[e.jsx(B,{name:"check-circle",className:"entra-id-payment__review-check-icon"}),e.jsx("h3",{className:"entra-id-payment__review-row-title heading-5",children:f.billingAddressHeader})]}),e.jsxs("div",{className:"entra-id-payment__review-row-body",children:[e.jsxs("div",{className:"entra-id-payment__review-row-content copy-medium",children:[s&&e.jsxs("p",{children:[s.firstName," ",s.lastName]}),A&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[A.addressLine1,A.addressLine2?`, ${A.addressLine2}`:""]}),e.jsxs("p",{children:[A.city,o?`, ${o}`:""," ",A.zipCode]}),A.countryName&&e.jsx("p",{children:A.countryName})]}),s?.phone&&e.jsx("p",{children:s.phone})]}),M&&e.jsx("button",{className:"entra-id-payment__review-row-edit",type:"button",onClick:b,children:f.editLabel})]})]}),e.jsxs("div",{className:"entra-id-payment__review-row",children:[e.jsxs("div",{className:"entra-id-payment__review-row-header",children:[e.jsx(B,{name:"check-circle",className:"entra-id-payment__review-check-icon"}),e.jsx("h3",{className:"entra-id-payment__review-row-title heading-5",children:f.paymentInfoHeader})]}),e.jsxs("div",{className:"entra-id-payment__review-row-body",children:[e.jsx("div",{className:"entra-id-payment__review-row-content copy-medium",children:c&&e.jsxs("span",{className:"entra-id-payment__review-payment-display",children:[e.jsx(B,{name:c.iconName,className:"entra-id-payment__review-payment-icon"}),e.jsx("span",{children:c.label})]})}),e.jsx("button",{className:"entra-id-payment__review-row-edit",type:"button",onClick:b,children:f.editLabel})]})]})]}),u&&e.jsx("div",{className:"entra-id-payment__form-error",role:"alert",children:l.map((m,L)=>e.jsx(V,{value:m,size:"medium"},L))}),_&&!u&&e.jsx(V,{value:_,className:"entra-id-payment__review-disclaimer",size:"small"}),j?e.jsx(Z,{ariaLabel:f.processingLabel}):e.jsx("div",{className:"entra-id-payment__actions",children:e.jsx(Ee,{className:"entra-id-payment__confirm-btn",label:f.confirmDonationLabel,onClick:x,disabled:!n})})]})},kr=2;function Sr(r){return Array.from({length:kr},(n,s)=>({stepNumber:s+1,isComplete:s+1<=r,isCurrent:s+1===r}))}function Mr(r){if(!r)return Oe;const{checkoutPaymentLabels:n,contactInfoLabels:s,entraIdLabels:t}=r;return{cardNumberLabel:n.cardNumberLabel,cardNumberPlaceholder:n.cardNumberPlaceholder,cardNumberError:n.cardNumberError,expirationLabel:n.expirationLabel,expirationPlaceholder:n.expirationPlaceholder,expirationError:n.expirationError,securityCodeLabel:n.securityCodeLabel,securityCodePlaceholder:n.securityCodePlaceholder,securityCodeError:n.securityCodeError,nameOnCardLabel:n.nameOnCardLabel,nameOnCardPlaceholder:n.nameOnCardPlaceholder,nameOnCardError:n.nameOnCardError,rout
1ingNumberLabel:n.routingNumberLabel,routingNumberPlaceholder:n.routingNumberPlaceholder,routingNumberError:n.routingNumberError,routingNumberLengthError:n.routingNumberLengthError,confirmRoutingNumberLabel:n.confirmRoutingNumberLabel,confirmRoutingNumberError:n.confirmRoutingNumberError,accountNumberLabel:n.accountNumberLabel,accountNumberPlaceholder:n.accountNumberPlaceholder,accountNumberError:n.accountNumberError,accountNumberMinLengthError:n.accountNumberMinLengthError,confirmAccountNumberLabel:n.confirmAccountNumberLabel,confirmAccountNumberError:n.confirmAccountNumberError,nameOnAccountLabel:n.nameOnAccountLabel,nameOnAccountPlaceholder:n.nameOnAccountPlaceholder,nameOnAccountError:n.nameOnAccountError,termsLabel:n.termsLabel,termsError:n.termsError,processingNote:n.processingNote,billingAddressLine1Label:s.billingAddressLine1Label,billingAddressLine1Placeholder:s.billingAddressLine1Placeholder,billingAddressLine2Label:s.billingAddressLine2Label,billingAddressLine2Placeholder:s.billingAddressLine2Placeholder,cityLabel:s.cityLabel,cityPlaceholder:s.cityPlaceholder,stateLabel:s.stateLabel,statePlaceholder:s.statePlaceholder,zipCodeLabel:s.zipCodeLabel,zipCodePlaceholder:s.zipCodePlaceholder,confirmAddressModalTitle:s.confirmAddressModalTitle,confirmAddressModalDescription:s.confirmAddressModalDescription,continueLabel:s.continueLabel,cancelLabel:s.cancelLabel,userEnteredAddressLabel:s.userEnteredAddressLabel,suggestedAddressLabel:s.suggestedAddressLabel,exactMatchAddress:t.exactMatchAddress,editLabel:s.editLabel,bankAccordionLabel:t.bankAccordionLabel,bankAccordionLabelSaved:t.bankAccordionLabelSaved,cardAccordionLabel:t.cardAccordionLabel,cardAccordionLabelSaved:t.cardAccordionLabelSaved,billingCheckboxLabel:t.billingCheckboxLabel,stateNoOptionsMessage:t.stateNoOptionsMessage,reviewCtaLabel:t.reviewCtaLabel,stepIndicator:t.stepIndicator,contactInfoHeader:t.contactInfoHeader,billingAddressHeader:t.billingAddressHeader,paymentInfoHeader:t.paymentInfoHeader,confirmDonationLabel:t.confirmDonationLabel,submissionErrorMessage:t.submissionErrorMessage,loadingLabel:t.loadingLabel,processingLabel:t.processingLabel,paymentMethodHeader:t.paymentMethodHeader,savedMethodsLegend:t.savedMethodsLegend,savedPaymentMethodFallback:t.savedPaymentMethodFallback,cardBrandVisa:t.cardBrandVisa,cardBrandMasterCard:t.cardBrandMasterCard,cardBrandAmericanExpress:t.cardBrandAmericanExpress,cardBrandDiscover:t.cardBrandDiscover,cardBrandGeneric:t.cardBrandGeneric,cardEndingTemplate:t.cardEndingTemplate,bankAccountEndingTemplate:t.bankAccountEndingTemplate,savedCardTemplate:t.savedCardTemplate,checkingAccountTemplate:t.checkingAccountTemplate,savingsAccountTemplate:t.savingsAccountTemplate,accountFallbackLabel:t.accountFallbackLabel}}const Er=({validatePaymentEndpoint:r,reviewOrderEndpoint:n,onConfirmDonation:s,isSubmitting:t,submissionErrors:b,errorMessage:x,stateOptions:j,experianToken:l,ctaLabel:_,onLoadingChange:f,onStepChange:M})=>{const A=i.useMemo(()=>{if(!j)return[];try{return JSON.parse(j)}catch{return[]}},[j]),{labels:o,isLoading:c}=tr(),u=i.useMemo(()=>Mr(o),[o]),[m,L]=i.useState("payment"),[C,I]=i.useState(null),[N,E]=i.useState(null),{donorInfo:h,isLoading:O}=ir(),w=i.useMemo(()=>{if(!h?.donorInfo)return null;const v=h.donorInfo;return{firstName:v.firstName??"",lastName:v.lastName??"",email:v.email??"",addressLine1:v.billingAddressLine1??"",addressLine2:v.billingAddressLine2??"",city:v.city??"",state:v.state??"",stateName:v.stateName??void 0,stateCode:0,zipCode:v.zipCode??"",countryName:v.countryName??null,countryCode:v.countryCode??null,phone:v.phoneNumber??"",phoneExt:v.phoneExtension??""}},[h]),p=i.useMemo(()=>(h?.paymentMethods??[]).map(fr),[h]),y=n??r,T=m==="payment"?1:2,k=i.useMemo(()=>Sr(T),[T]),$=i.useCallback((v,z)=>{I(v),E(z),L("review"),M?.("review")},[M]),R=i.useCallback(()=>{L("payment"),M?.("payment")},[M]),U=i.useCallback(async()=>{N&&await s(N)},[N,s]),P=O||c;return i.useEffect(()=>{f?.(P)},[P,f]),P?e.jsx(Z,{ariaLabel:Oe.loadingLabel}):e.jsxs("div",{className:"entra-id-payment-wizard",children:[e.jsx(or,{steps:k}),m==="payment"&&e.jsx(Cr,{savedMethods:p,donorContact:w,onReviewDonation:$,initialPaymentData:C,reviewOrderEndpoint:y,stateOptions:A,experianToken:l,labels:u,ctaLabel:_}),m==="review"&&e.jsx(jr,{paymentData:C,orderRequest:N,donorContact:w,savedMethods:p,onBack:R,onConfirmDonation:U,isSubmitting:t,submissionErrors:b,errorMessage:x,labels:u})]})},Tr=({donorInfoEndpoint:r,allLabelsEndpoint:n,...s})=>
1e.jsx(nr,{endpoint:n,children:e.jsx(ar,{endpoint:r,children:e.jsx(Er,{...s})})}),qr=Object.freeze(Object.defineProperty({__proto__:null,default:Tr},Symbol.toStringTag,{value:"Module"}));export{Tr as E,qr as e,gr as u};
2//# sourceMappingURL=CgVsFCmu-entraIdPaymentWizard.js.map

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.