Loading
function(e,t,n){n.d(t,{E:()=>h,p:()=>C}),n(321073);var l=n(64700),i=n(602853),r=n(661531),a=n(964486),s=n(626584),o=n(739508),u=n(71532),c=n(219538),d=n(648335),p=n(818348);let m=new s.A("useStripePaymentElementOptions"),h=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.r)(r.A.colors.MODAL_BACKGROUND),n=(0,i.r)(r.A.colors.TEXT_STRONG),a=(0,i.r)(r.A.colors.INPUT_BACKGROUND_DEFAULT),s=e.theme??"flat",o=e.colorText??n.hex(),u=e.colorBackground??t.hex(),c=e.inputBackgroundColor??a.hex(),d=e.tabBackgroundColor??a.hex(),p=e.tabSelectedBackgroundColor??null;return{elementsAppearance:l.useMemo(()=>({theme:s,variables:{colorText:o,colorBackground:u},rules:{".Input":{backgroundColor:c},".Tab":{backgroundColor:d},...null!=p?{".Tab--selected":{backgroundColor:p}}:{}}}),[s,o,u,c,d,p]),elementsAppearanceOptions:{theme:s,colorText:o,colorBackground:u,inputBackgroundColor:c,tabBackgroundColor:d}}},C=e=>{let{onSetupError:t,elementsAppearanceOptions:n={}}=e,[i,r]=l.useState(void 0),[s,C]=l.useState(null),[A,y]=l.useState(!0),[E,P]=l.useState([]),S=l.useMemo(()=>{let e=["card"],t=E.find(e=>e.payment_source_type===p.he.PAYPAL);return null!=t&&e.push(t.custom_payment_method_id),e},[E]),{customPaymentMethods:f,customPaymentMethodIdsToSourceTypes:_}=l.useMemo(()=>({customPaymentMethods:(0,d.Dd)(E),customPaymentMethodIdsToSourceTypes:E.reduce((e,t)=>(e[t.custom_payment_method_id]=t.payment_source_type,e),{})}),[E]),T=l.useCallback(async()=>{try{let{client_secret:e,custom_payment_methods:t}=await (0,c.w)();P(t),r(e)}catch(e){C(e),null!=t&&t(e),m.error("there was an error on setup for Payment Elements: ",e),(0,o.pM)(e,{tags:{source:"payment_elements"}})}y(!1)},[t]);(0,a.Ay)(()=>{T()});let{elementsAppearance:I,elementsAppearanceOptions:x}=h(n),N=(0,u.PU)(),g=l.useMemo(()=>A?null:{clientSecret:i,appearance:I,locale:N,customPaymentMethods:f,paymentMethodCreation:"manual"},[I,N,i,f,A]),v={setupError:s,customPaymentMethods:f,customPaymentMethodIdsToSourceTypes:_,paymentMethodOrder:S,elementsAppearanceOptions:x};return null==i||null==g||A?{...v,isLoading:!0,elementsOptions:g,setupIntentSecret:i}:{...v,isLoading:!1,elementsOptions:g,setupIntentSecret:i}}}