"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[823],{78591:(e,o,s)=>{s.r(o),s.d(o,{Products:()=>T});var t=s(65736),c=s(76025),r=s(14812),i=s(98817),n=s(69307),d=s(55609),a=s(74617),p=s(59550),l=s(91667),u=s(58176),m=s(14599),k=s(92694),w=s(91978),_=s(76731),h=s(55684),x=s(639),C=s(43378),j=s(19987),b=s(24304),g=s(80945),y=s(40955),Z=s(81514);const v=({isExpanded:e,onClick:o})=>(0,Z.jsxs)(d.Button,{className:"woocommerce-task-products__button-view-less-product-types",onClick:o,children:[e?(0,t.__)("View less product types","woocommerce"):(0,t.__)("View more product types","woocommerce"),(0,Z.jsx)(p.Z,{icon:e?l.Z:u.Z})]}),T=()=>{const[e,o]=(0,n.useState)(!1),[s,c]=(0,n.useState)(!1),i=(0,_.r)((()=>{const e=(0,w.O3)("onboarding");return e?.profile&&e?.profile.product_types||["physical"]})()),{productTypes:d,isRequesting:p}=(0,h.Z)((0,_.Q)(),i),{recordCompletionTime:l}=(0,g.Z)("products"),u=(0,n.useMemo)((()=>d.map((e=>({...e,onClick:()=>{e.onClick(),l()}})))),[l,d]),{loadSampleProduct:T,isLoadingSampleProducts:f}=(0,j.Z)({redirectUrlAfterSuccess:(0,a.getAdminLink)("edit.php?post_type=product&wc_onboarding_active_task=products")}),A=(0,n.useMemo)((()=>{const o=u.filter((e=>i.includes(e.key)));return e&&u.forEach((e=>!o.includes(e)&&o.push(e))),(0,k.applyFilters)(y.x,o)}),[i,e,u]),O=(0,n.useMemo)((()=>{const e=[],o={...y.RC,onClick:()=>{y.RC.onClick(),l()}};return e.push(o),window.wcAdminFeatures&&!0===window.wcAdminFeatures.printful&&e.push(y.xz),e}),[l]);return(0,Z.jsxs)("div",{className:"woocommerce-task-products",children:[(0,Z.jsx)(r.Text,{variant:"title",as:"h2",className:"woocommerce-task-products__title",children:(0,t.__)("What product do you want to add?","woocommerce")}),(0,Z.jsxs)("div",{className:"woocommerce-product-content",children:[(0,Z.jsx)(x.Z,{items:A,onClickLoadSampleProduct:()=>c(!0),showOtherOptions:e,isTaskListItemClicked:p}),(0,Z.jsx)(v,{isExpanded:e,onClick:()=>{e||(0,m.recordEvent)("tasklist_view_more_product_types_click"),o(!e)}}),(0,Z.jsx)(x.Z,{items:O,showOtherOptions:!1,isTaskListItemClicked:p})]}),f?(0,Z.jsx)(C.Z,{}):s&&(0,Z.jsx)(b.Z,{onCancel:()=>{c(!1),(0,m.recordEvent)("tasklist_cancel_load_sample_products_click")},onImport:()=>{c(!1),T()}})]})},f=()=>(0,Z.jsx)(c.WooOnboardingTask,{id:"products",children:(0,Z.jsx)(T,{})});(0,i.registerPlugin)("wc-admin-onboarding-task-products",{scope:"woocommerce-tasks",render:()=>(0,Z.jsx)(f,{})})}}]);