Loading
function(e,t,n){n.d(t,{n:()=>I,N:()=>f});var l=n(627968),r=n(64700),i=n(17928),a=n(637141),s=n(606267),o=n(826469),u=n(351906),c=n(768050),d=n(120700),p=n(944355),m=n(186460);let h=new Set([d.C.ORB_CHECKOUT]);function A(){let{unifiedCheckoutFlow:e}=(0,c.P5)();return null!=e&&h.has(e)?null:(0,l.jsx)(p.Z4,{className:m.K})}var C=n(364995),E=n(655857),y=n(165272),P=n(722847),S=n(327105),_=n(375708);let f=e=>{let{setPaymentSourceId:t,paymentSourceId:n,label:a,additionalPaymentSourceDropdownProps:o,disabled:c,location:d,onPaymentSourceAdd:m,subscriptionPaymentSourceId:h,hideCurrencySelect:y,renderCustomPaymentSourceSelectorContent:S,resolveGiftCardCheckboxProps:f,resolveDisabledState:I}=e,{setPaymentSourceId:N,paymentSourceId:v}=T({setPaymentSourceId:t,paymentSourceId:n}),{giftCardsEnabled:g,giftCardCheckboxProps:x,walletCoversSubtotal:R,basePaymentSourceDropdownProps:M,isSubscriptionPaidByWallet:b,hidePersonalInformation:L}=(e=>{let{paymentSourceId:t,setPaymentSourceId:n,location:l,subscriptionPaymentSourceId:a}=e,{hasInvoiceOrderContextLoaded:o,checkoutPaymentSources:c}=(0,C.t)(),d=(0,P.t4)(e=>e.checkoutInvoiceError),{dropdownPaymentSources:p,giftCardsEnabled:m,dropdownPaymentSourceId:h,handleDropdownPaymentSourceChange:A,giftCardCheckboxProps:E,walletCoversSubtotal:y,isSubscriptionPaidByWallet:S}=(0,s.Y0)({checkoutPaymentSources:c,paymentSourceId:t,setPaymentSourceId:n,location:l??"BaseStatefulPaymentSourceSelector",isReady:o,subscriptionPaymentSourceId:a}),_=r.useMemo(()=>{let e=p.find(e=>e.isDefault);return null!=e?e.id:void 0},[p]),f=(0,i.bG)([u.A],()=>u.A.hidePersonalInformation??!1);return{giftCardsEnabled:m,giftCardCheckboxProps:E,walletCoversSubtotal:y,basePaymentSourceDropdownProps:r.useMemo(()=>({selectedPaymentSourceId:h,paymentSources:p,defaultPaymentSourceId:_,hidePersonalInformation:f,onChange:A,dropdownLoading:!o&&null==d}),[h,p,_,f,A,o,d]),isSubscriptionPaidByWallet:S,hidePersonalInformation:f}})({paymentSourceId:v,setPaymentSourceId:N,location:d,subscriptionPaymentSourceId:h}),{priceOptions:j,setCurrency:O}=(0,P.t4)(e=>({priceOptions:e.checkoutPriceOptions,setCurrency:e.setCheckoutCurrency})),{dropdownCurrencies:w,displayCurrency:D}=(0,E.Jn)(),U=r.useMemo(()=>null!=I?I(c,{isSubscriptionPaidByWallet:b}):c??!1,[c,b,I]),k=r.useMemo(()=>{if(null!=S)return S({isSubscriptionPaidByWallet:b,selectedSource:M.paymentSources.find(e=>e.id===M.selectedPaymentSourceId),hidePersonalInformation:L})},[S,b,M,L]),G=r.useMemo(()=>{if(!y)return{label:_.intl.string(_.t["/AAR02"]),selectedCurrency:j.currency??D,currencies:w,onChange:O,disabled:U}},[y,j.currency,D,w,O,U]),Y=r.useMemo(()=>({...M,...o,onPaymentSourceAdd:m}),[M,m,o]),F=r.useMemo(()=>null!=f?f(x,{isSubscriptionPaidByWallet:b,selectorDisabled:U}):x,[x,f,b,U]),B=null!=F&&!0===F.locked;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(p.nL,{label:a,giftCardsEnabled:g,giftCardCheckboxProps:F,paymentSourceDropdownProps:Y,showCheckboxAboveDropdown:R||B,disabled:U,currencySelectProps:G,customSelectorContent:k}),g?(0,l.jsx)(A,{}):null]})},I=e=>{let{premiumSubscriptionPaymentSourceId:t,...n}=e,{disableSourceChangeTooltipText:i,hasLockedPaymentSource:s}=r.useMemo(()=>null!=t?{hasLockedPaymentSource:!0,disableSourceChangeTooltipText:_.intl.string(S.default.UdSuwf)}:{hasLockedPaymentSource:!1,disableSourceChangeTooltipText:void 0},[t]),u=r.useCallback((e,t)=>{let{isSubscriptionPaidByWallet:n,selectorDisabled:l}=t;if(null==e)return null;let r=s&&n,a=s?i:void 0,o=!r&&(e.disabled||l),u=a??e.disabledTooltip;return{...e,disabled:o,disabledTooltip:u,locked:r,showDisabledInfoIcon:null==a}},[s,i]),c=r.useCallback((e,t)=>{let{isSubscriptionPaidByWallet:n}=t;return e||s&&!n},[s]),d=r.useCallback(e=>{let{isSubscriptionPaidByWallet:t,selectedSource:n,hidePersonalInformation:r}=e;if(!s||t||null==i||null==n)return null;let u=n instanceof o.A?n.source:n,{brand:c,label:d}=(0,a.Sm)(u,r);return(0,l.jsx)(y.S,{label:d??"",icon:c??void 0,tooltipText:i})},[s,i]);return(0,l.jsx)(f,{...n,resolveGiftCardCheckboxProps:u,resolveDisabledState:c,renderCustomPaymentSourceSelectorContent:d,subscriptionPaymentSourceId:t})},T=e=>{let{setPaymentSourceId:t,paymentSourceId:n}=(0,P.t4)(e=>({setPaymentSourceId:e.setPaymentSourceId,paymentSourceId:e.paymentSourceId})),{setPaymentSourceId:l,paymentSourceId:i}=r.useMemo(()=>({setPaymentSourceId:void 0!==e.setPaymentSourceId?e.setPaymentSourceId:t,paymentSourceId:void 0!==e.paymentSourceId?e.paymentSourceId:n}),[e.setPaymentSourceId,e.paymentSourceId,t,n]);return{setPaymentSourceId:l,paymentSourceId:i}}}