"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[5396],{53797:(e,t,s)=>{s.r(t),s.d(t,{default:()=>h}),s(99196);var n=s(65736),o=s(9818),a=s(22629),i=s(55609),c=s(69307),r=s(86020),m=s(14812),d=s(67221),l=s(14599),_=s(24081),u=s(4174),p=s(21464),y=s(95313),g=s(81514);const w=document.querySelector('[data-gateway_id="pre_install_woocommerce_payments_promotion"]'),h=()=>{const[e,t]=(0,c.useState)(null),[s,h]=(0,c.useState)(!1),[x,E]=(0,c.useState)(!1),{installAndActivatePlugins:v,dismissRecommendedPlugins:A}=(0,o.useDispatch)(d.PLUGINS_STORE_NAME),{createNotice:j}=(0,o.useDispatch)("core/notices"),{installedPaymentGateway:N,installedPaymentGateways:S,paymentGatewaySuggestions:T,isResolving:G}=(0,o.useSelect)((t=>{const s=x&&(0,p.V7)(e);return{installedPaymentGateway:s&&t(d.PAYMENT_GATEWAYS_STORE_NAME).getPaymentGateway(s),installedPaymentGateways:t(d.PAYMENT_GATEWAYS_STORE_NAME).getPaymentGateways().reduce(((e,t)=>(s===t.id||(e[t.id]=!0),e)),{}),isResolving:t(d.ONBOARDING_STORE_NAME).isResolving("getPaymentGatewaySuggestions"),paymentGatewaySuggestions:t(d.ONBOARDING_STORE_NAME).getPaymentGatewaySuggestions()}}),[x]),f=(0,c.useRef)(!1),P=T&&T.length>0&&!(0,y.j)(T)&&!s;if((0,c.useEffect)((()=>{if((P||w&&!G)&&!f.current){f.current=!0;const e=(T||[]).reduce(((e,t)=>t.plugins&&t.plugins.length>0?{...e,[t.plugins[0].replace(/\-/g,"_")+"_displayed"]:!0}:e),{woocommerce_payments_displayed:!!w});(0,l.recordEvent)("settings_payments_recommendations_pageview",e)}}),[P,w,G]),(0,c.useEffect)((()=>{N&&(window.location.href=N.settings_url)}),[N]),!P)return null;const R=async()=>{h(!0),(0,l.recordEvent)("settings_payments_recommendations_dismiss",{}),await A("payments")||(h(!1),j("error",(0,n.__)('There was a problem hiding the "Additional ways to get paid" card.',"woocommerce")))},b=(T||[]).filter((e=>!S[e.id]&&e.plugins?.length&&(!window.wcAdminFeatures["wc-pay-promotion"]||!e.id.startsWith("woocommerce_payments")))).map((s=>({key:s.id,title:(0,g.jsxs)(g.Fragment,{children:[s.title,s.recommended&&(0,g.jsx)(r.Pill,{children:(0,n.__)("Recommended","woocommerce")})]}),content:(0,a.decodeEntities)(s.content),after:(0,g.jsx)(i.Button,{isSecondary:!0,onClick:()=>(s=>{e||(t(s.id),(0,l.recordEvent)("settings_payments_recommendations_setup",{extension_selected:s.plugins[0]}),v([s.plugins[0]]).then((()=>{E(!0)})).catch((e=>{(0,u.a)(e),t(null)})))})(s),isBusy:e===s.id,disabled:!!e,children:s.actionText||(0,n.__)("Get started","woocommerce")}),before:(0,g.jsx)("img",{src:s.square_image||s.image_72x72||s.image,alt:""})})));return 0===b.length?null:(0,g.jsxs)(i.Card,{size:"medium",className:"woocommerce-recommended-payments-card",children:[(0,g.jsxs)(i.CardHeader,{children:[(0,g.jsxs)("div",{className:"woocommerce-recommended-payments-card__header",children:[(0,g.jsx)(m.Text,{variant:"title.small",as:"p",size:"20",lineHeight:"28px",children:(0,n.__)("Recommended payment providers","woocommerce")}),(0,g.jsx)(m.Text,{className:"woocommerce-recommended-payments__header-heading",variant:"caption",as:"p",size:"12",lineHeight:"16px",children:(0,n.__)('We recommend adding one of the following payment extensions to your store. The extension will be installed and activated for you when you click "Get started".',"woocommerce")})]}),(0,g.jsx)("div",{className:"woocommerce-card__menu woocommerce-card__header-item",children:(0,g.jsx)(r.EllipsisMenu,{label:(0,n.__)("Task List Options","woocommerce"),renderContent:()=>(0,g.jsx)("div",{className:"woocommerce-review-activity-card__section-controls",children:(0,g.jsx)(i.Button,{onClick:R,children:(0,n.__)("Hide this","woocommerce")})})})})]}),(0,g.jsx)(r.List,{items:b}),(0,g.jsx)(i.CardFooter,{children:(0,g.jsxs)(i.Button,{href:"https://woocommerce.com/product-category/woocommerce-extensions/payment-gateways/?utm_source=payments_recommendations",target:"_blank",isTertiary:!0,children:[(0,n.__)("Discover other payment providers","woocommerce"),(0,g.jsx)(_.Z,{size:18})]})})]})}}}]);