"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[8534],{93686:(e,t,a)=>{a.d(t,{l$:()=>d,My:()=>w,D2:()=>m,ls:()=>_}),a(62932);var n=a(69307),o=a(65736),i=a(55609),s=a(9818),c=a(67221),r=a(10431);const m=({gatewayId:e,gatewayState:t,settingsHref:a,onboardingHref:m,isOffline:l,acceptIncentive:d=(()=>{}),gatewayHasRecommendedPaymentMethods:w,buttonText:_=(0,o.__)("Enable","woocommerce"),incentive:g=null})=>{const[y,f]=(0,n.useState)(!1),{createErrorNotice:u}=(0,s.dispatch)("core/notices"),{togglePaymentGateway:E,invalidateResolutionForStoreSelector:h}=(0,s.useDispatch)(c.PAYMENT_SETTINGS_STORE_NAME),p=()=>{u((0,o.__)("An error occurred. You will be redirected to the settings page, try enabling the payment gateway there.","woocommerce"),{type:"snackbar",explicitDismiss:!0})};return(0,n.createElement)(i.Button,{variant:"primary",isBusy:y,disabled:y,onClick:n=>{if(n.preventDefault(),t.enabled)return;const o=window.woocommerce_admin.nonces?.gateway_toggle||"";if(!o)return p(),void(window.location.href=a);f(!0),g&&d(g.promo_id),E(e,window.woocommerce_admin.ajax_url,o).then((e=>{if("needs_setup"===e.data&&!t.account_connected){if(!w)return void(window.location.href=m);(0,r.getHistory)().push((0,r.getNewPath)({},"/payment-methods"))}h(l?"getOfflinePaymentGateways":"getPaymentProviders"),f(!1)})).catch((()=>{f(!1),p(),window.location.href=a}))},href:a},_)};var l=a(87778);const d=({acceptIncentive:e,buttonText:t=(0,o.__)("Activate payments","woocommerce"),incentive:a=null})=>{const[s,c]=(0,n.useState)(!1);return(0,n.createElement)(i.Button,{variant:"primary",isBusy:s,disabled:s,onClick:()=>{c(!0),a&&e(a.promo_id),window.location.href=(0,l.vA)()}},t)},w=({gatewayId:e,gatewayState:t,onboardingState:a,settingsHref:s,onboardingHref:c,gatewayHasRecommendedPaymentMethods:m,buttonText:l=(0,o.__)("Complete setup","woocommerce")})=>{const[d,w]=(0,n.useState)(!1),_=t.account_connected,g=a.started,y=a.completed;return(0,n.createElement)(i.Button,{key:e,variant:"primary",isBusy:d,disabled:d,onClick:()=>{if(w(!0),_&&g)return _&&g&&!y?void(window.location.href=c):void(window.location.href=s);m?((0,r.getHistory)().push((0,r.getNewPath)({},"/payment-methods")),w(!1)):window.location.href=c}},l)},_=({settingsHref:e,buttonText:t=(0,o.__)("Manage","woocommerce")})=>(0,n.createElement)(i.Button,{variant:"secondary",href:e},t)},41682:(e,t,a)=>{a.r(t),a.d(t,{SettingsPaymentsOffline:()=>f,default:()=>u});var n=a(69307),o=a(9818),i=a(67221),s=a(65736),c=a(29346),r=a(22629),m=a(42058),l=a(82453),d=a(93686);const w=({gateway:e,...t})=>(0,n.createElement)(l.TR,(0,c.Z)({key:e.id,id:e.id,className:"woocommerce-list__item woocommerce-list__item-enter-done"},t),(0,n.createElement)("div",{className:"woocommerce-list__item-inner"},(0,n.createElement)("div",{className:"woocommerce-list__item-before"},(0,n.createElement)(l.mR,null),e.icon&&(0,n.createElement)("img",{className:"woocommerce-list__item-image",src:e.icon,alt:e.title+" logo"})),(0,n.createElement)("div",{className:"woocommerce-list__item-text"},(0,n.createElement)("span",{className:"woocommerce-list__item-title"},e.title),(0,n.createElement)("span",{className:"woocommerce-list__item-content",dangerouslySetInnerHTML:(0,m.ZP)((0,r.decodeEntities)(e.description))})),(0,n.createElement)("div",{className:"woocommerce-list__item-after"},(0,n.createElement)("div",{className:"woocommerce-list__item-after__actions"},e.state.enabled?(0,n.createElement)(d.ls,{settingsHref:e.management._links.settings.href}):(0,n.createElement)(d.D2,{gatewayId:e.id,gatewayState:e.state,settingsHref:e.management._links.settings.href,onboardingHref:e.onboarding._links.onboard.href,isOffline:!0,gatewayHasRecommendedPaymentMethods:!1}))))),_=({gateways:e,setGateways:t})=>(0,n.createElement)(l.JN,{className:"woocommerce-list",items:e,setItems:t},e.map((e=>(0,n.createElement)(w,{gateway:e,key:e.id}))));var g=a(40404);const y=({isFetching:e,offlinePaymentGateways:t,updateOrdering:a})=>(0,n.createElement)("div",{className:"settings-payment-gateways"},(0,n.createElement)("div",{className:"settings-payment-gateways__header"},(0,n.createElement)("div",{className:"settings-payment-gateways__header-title"},(0,s.__)("Payment methods","woocommerce"))),e?(0,n.createElement)(g.a,{rows:3}):(0,n.createElement)(_,{gateways:t,setGateways:a})),f=()=>{const{offlinePaymentGateways:e,isFetching:t}=(0,o.useSelect)((e=>({isFetching:e(i.PAYMENT_SETTINGS_STORE_NAME).isFetching(),offlinePaymentGateways:e(i.PAYMENT_SETTINGS_STORE_NAME).getOfflinePaymentGateways()}))),{updateProviderOrdering:a}=(0,o.useDispatch)(i.PAYMENT_SETTINGS_STORE_NAME),[s,c]=(0,n.useState)(null);return(0,n.createElement)("div",{className:"settings-payments-offline__container"},(0,n.createElement)(y,{isFetching:t,updateOrdering:function(e){const t=e.map((e=>e._order)).sort(((e,t)=>e-t)),n={};e.forEach(((e,a)=>{n[e.id]=t[a]})),a(n),c(e)},offlinePaymentGateways:s||e}))},u=f}}]);