Loading
function(e,t,n){n.d(t,{KS:()=>b,Ky:()=>v,Wf:()=>x,e4:()=>O,eR:()=>j,wD:()=>D});var l=n(627968),r=n(64700),i=n(342393),a=n(503698),s=n.n(a),o=n(17928),u=n(289873),c=n(228366),d=n(783327),p=n(166532),m=n(287809),h=n(174459),A=n(38405),E=n(240248),C=n(71532),y=n(116673),_=n(942340),P=n(550238),S=n(648335),I=n(652215),T=n(818348),f=n(235301);let N=[p.pn.PAYMENT_ELEMENT],v=[p.pn.PAYPAL_INFORMATION,p.pn.VENMO_INFORMATION,p.pn.CASH_APP_INFORMATION,p.pn.EPS_INFORMATION,p.pn.PRZELEWY24_INFORMATION,p.pn.IDEAL_INFORMATION],g=new Set([p.pn.PAYMENT_ELEMENT,...v]),x=r.memo(function(e){let{paymentMethodOrder:t,wallets:n=[],customPaymentMethodIdsToSourceTypes:a,analyticsContext:s,options:u,onChange:c,step:d,...A}=e,E=(0,o.bG)([m.default],()=>{let e=m.default.getCurrentUser();return null!=e?e.email:null}),C=(0,o.bG)([m.default],()=>{let e=m.default.getCurrentUser();return null!=e?e.globalName:null}),y=r.useCallback(e=>{if(d!==p.pn.PAYMENT_ELEMENT)return;let t=(0,S.Wn)(e.value.type,a);if(null!=c&&c(e,t),null!=s){let{contextMetadata:n,activitySessionId:l,analyticsData:r}=s,i=null!=t&&t!==T.he.PAYMENT_REQUEST?S.mr[t]:e.value.type;h.default.track(I.HAw.PAYMENT_ELEMENT_CHANGED,{load_id:n.loadId,activity_session_id:l,payment_element_selected_method:i,payment_source_type:t,complete:e.complete,empty:e.empty,..."string"==typeof r.location?{location:r.location}:void 0})}},[c,s,d,a]),_=r.useMemo(()=>({applePay:n.includes("applePay")?"auto":"never",googlePay:n.includes("googlePay")?"auto":"never",link:n.includes("link")?"auto":"never"}),[n]),P=r.useMemo(()=>({billingDetails:{...null!=E&&{email:E},...null!=C&&{name:C}}}),[E,C]),f=r.useMemo(()=>({id:"stripe-payment-element",options:{layout:{type:"tabs"},wallets:_,defaultValues:P,paymentMethodOrder:t,...u},onChange:y,...A}),[_,P,u,A,y,t]);return(0,l.jsx)(i.PaymentElement,{...f})}),R=e=>{let{children:t}=e,n=(0,d.S)(),{elementsAppearance:r}=(0,_.E)(),a=(0,C.PU)();return(0,l.jsx)(i.Elements,{stripe:n,options:{appearance:r,locale:a,mode:"setup",currency:"usd"},children:t})},M=e=>null!=e&&null!=e&&(!(0,E.uJ)(e.line1)||!(0,E.uJ)(e.city)),b=r.memo(function(e){let{options:t,renderAsStandaloneElement:n,addressElementOnChangeFired:a,billingAddressInfo:s,internalKey:o,...u}=e,c=(0,y.z)(),d=null!=c&&c.length>0?c[0]:(0,E.uJ)(s.country)?"":s.country,p=r.useMemo(()=>{let{name:e,address:t}=(0,C._Z)({...s,country:d});return null!=t&&M(t)?{...null!=e&&""!==e&&{name:e},address:Object.fromEntries(Object.entries(t).filter(e=>{let[t,n]=e;return void 0!==n}))}:null!=e&&""!==e?{name:e}:null!=t&&null!=t.country&&a?{address:{country:d}}:void 0},[s,a,d]),m=r.useMemo(()=>null!=c&&c.length>0?c:void 0,[c]),h=r.useMemo(()=>(0,l.jsx)(i.AddressElement,{options:{mode:"billing",defaultValues:p,allowedCountries:m,...t},...u},o),[p,m,t,u,o]);return n?(0,l.jsxs)(R,{children:[(0,l.jsx)("div",{className:f.R,children:(0,l.jsx)(i.PaymentElement,{id:"stripe-payment-element"})}),h]}):h}),L=e=>{let{step:t,billingAddressInfo:n,customPaymentMethodIdsToSourceTypes:a,stripePaymentElementProps:o,stripeAddressElementProps:u,elementsRef:c,paymentElementSelectedType:d,paymentMethodOrder:m,addressElementKey:h,analyticsContext:A,paymentElementFooter:E}=e,C=(0,i.useElements)();r.useEffect(()=>{c.current=C},[C,c]);let{shouldShowPaymentElement:y,shouldShowAddressElement:_,excludeBodySpacing:P}=r.useMemo(()=>({shouldShowPaymentElement:N.includes(t),shouldShowAddressElement:t===p.pn.ADDRESS,excludeBodySpacing:v.includes(t)}),[t]);return(0,l.jsxs)("div",{className:s()(f.kL,{[f.rf]:!P}),children:[(0,l.jsxs)("div",{className:s()(y?f.RK:[f.R,f.$u],{[f.df]:null==d,[f._m]:d===T.he.CARD,[f.JD]:d===T.he.PAYPAL}),children:[(0,l.jsx)(x,{...o,paymentMethodOrder:m,customPaymentMethodIdsToSourceTypes:a,step:t,analyticsContext:A}),y&&E]}),(0,l.jsx)("div",{className:s()(f.K_,_?f.RK:[f.R,f.vg]),children:(0,l.jsx)(b,{...u,internalKey:h,renderAsStandaloneElement:d===T.he.PAYMENT_REQUEST,billingAddressInfo:n})})]})},j=()=>(0,l.jsx)("div",{className:s()(f.kL,f.rf,f.g4),children:(0,l.jsx)(u.y,{type:u.y.Type.PULSING_ELLIPSIS})}),O=e=>{let{onSetupError:t,...n}=e,{elementsOptions:r,isLoading:a,setupError:s,customPaymentMethodIdsToSourceTypes:o,paymentMethodOrder:u}=(0,_.p)({onSetupError:t}),c=(0,d.S)();return a||null!=s||null==c?(0,l.jsx)(j,{}):(0,l.jsx)(i.Elements,{stripe:c,options:r,children:(0,l.jsx)(L,{...n,customPaymentMethodIdsToSourceTypes:o,paymentMethodOrder:u})})},w=["applePay","googlePay","link"],D=e=>{let{step:t,handleStepChange:n,paymentElementsEnabled:l,logger:a,onBillingAddressChange:s,shouldLogOnChangeEvents:o,continueSessionToInitialStep:u}=e,d=r.useRef(null),m=r.useRef(null),[h,C]=r.useState(!1),[y,_]=r.useState(u===p.pn.CREDIT_CARD_INFORMATION?T.he.CARD:null),[I,f]=r.useState(!1),[N,v]=r.useState(void 0),x=(e=>{let{step:t,paymentElementsEnabled:n,paymentElementSelectedType:l}=e;return!!n&&(g.has(t)||t===p.pn.ADDRESS&&null!=l)})({step:t,paymentElementsEnabled:l,paymentElementSelectedType:y}),R=r.useCallback(()=>{v(Date.now().toString())},[]);r.useEffect(()=>{t===p.pn.PAYMENT_ELEMENT&&(m.current=null)},[t]);let b=r.useMemo(()=>({onChange:(e,t)=>{o&&null!=a&&a.log("PaymentElements onChange event:",e),C(e.complete),_(t)},wallets:w}),[a,o]),L=r.useMemo(()=>({addressElementOnChangeFired:I,onChange:e=>{let{complete:t,value:{address:n,name:l}}=e,r=M(n);o&&null!=a&&a.log("AddressElement onChange event:",{complete:t,address:n,name:l,addressElementOnChangeFired:I,isAddressSubstantial:r}),f(!0);let i={name:l,country:n.country,city:n.city,line1:n.line1,line2:n.line2??"",state:n.state,postalCode:n.postal_code},u=(0,P.Qd)(i);!t||u||P.im.has(n.country)||A.A.captureMessage("Unexpected AddressElement validity mismatch: Stripe complete but address was computed invalid",{tags:{app_context:"billing",billing_context:"payment_element"},extra:{isValidComputed:u,stripeComplete:t,country:n.country,emptyFields:Object.entries(i).filter(e=>{let[,t]=e;return(0,E.uJ)(t)}).map(e=>{let[t]=e;return t})}}),s(i,u&&t)}}),[s,o,a,I,f]),j=r.useCallback(()=>{let e;s({name:"",country:"",city:"",line1:"",line2:"",state:"",postalCode:""},!1),null!=(e=(e=>{if(null==e)return;let t=e.getElement(i.AddressElement);if(null!=t)return t})(d.current))&&e.clear()},[d,s]),O=r.useCallback(function(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];void 0!==e&&_(e),n(p.pn.PAYMENT_ELEMENT,t),f(!1),null!=y&&(0,S.R8)(y)&&j()},[n,j,y]);r.useEffect(()=>{if(!l)return;let e=()=>{O(void 0)};return c.h.subscribe("BRAINTREE_TOKENIZE_PAYPAL_FAIL_WINDOW_CLOSED",e),()=>{c.h.unsubscribe("BRAINTREE_TOKENIZE_PAYPAL_FAIL_WINDOW_CLOSED",e)}},[O,l]);let D=r.useCallback(()=>{_(null)},[]);return{shouldRenderPaymentElement:x,stripePaymentElementProps:b,stripeAddressElementProps:L,combinedStripeElementsRef:d,lastConfirmedSetupIntentRef:m,paymentElementReady:h,paymentElementSelectedType:y,setPaymentElementSelectedType:_,returnToPaymentElementStep:O,onBackFromPaymentElement:D,addressElementKey:N,remountAddressElement:R,clearAddressElement:j}}}