"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[7387],{9661:(e,t,o)=>{o.r(t),o.d(t,{default:()=>g});var r=o(69307),n=o(51393),c=o(14599),s=o(98817),i=o(85597),l=o(46530),u=o(9818),d=o(65736),a=o(86020),p=o(90495),m=o(65545);const _=e=>{let{shouldTourBeShown:t,dismissModal:o}=e;const{isNewUser:s,loadingPublishedProductsCount:i}=(0,m.E)();(0,r.useEffect)((()=>{t&&(0,c.recordEvent)("block_product_editor_spotlight_view")}),[t]);const[l,u]=(0,r.useState)(!1),{maybeShowFeedbackBar:_}=(0,n.__experimentalUseFeedbackBar)();if(i)return null;if(l)return(0,r.createElement)(p.Z,{isNewUser:s,onCloseGuide:(e,t)=>{o(),"finish"===t?(0,c.recordEvent)("block_product_editor_spotlight_tell_me_more_click"):(0,c.recordEvent)("block_product_editor_spotlight_dismissed",{current_page:e+1}),u(!1),_()}});if(t){const{heading:e,description:t}={heading:s?(0,d.__)("Meet the product editing form","woocommerce"):(0,d.__)("Welcome to the new product form!","woocommerce"),description:s?(0,d.__)("Discover the product form's unique features with a quick overview of what's included.","woocommerce"):(0,d.__)("Discover its new features and improvements with a quick overview of what's included.","woocommerce")};return(0,r.createElement)(a.TourKit,{config:{steps:[{meta:{name:"woocommerce-block-editor-tour",primaryButton:{text:(0,d.__)("View highlights","woocommerce")},descriptions:{desktop:t},heading:(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",null,e),(0,r.createElement)(a.Pill,null,(0,d.__)("Beta","woocommerce")))},referenceElements:{desktop:"#adminmenuback"}}],closeHandler:(e,t,r)=>{"done-btn"===r?((0,c.recordEvent)("block_product_editor_spotlight_view_highlights"),u(!0)):(o(),(0,c.recordEvent)("block_product_editor_spotlight_dismissed",{current_page:0}),_())},options:{effects:{arrowIndicator:!1,overlay:!1,liveResize:{rootElementSelector:"#adminmenuback",resize:!0}},portalParentElement:document.getElementById("wpbody"),popperModifiers:[{name:"bottom-left",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:e=>{let{state:t}=e;t.styles.popper.top="auto",t.styles.popper.left="auto",t.styles.popper.bottom="10px",t.styles.popper.transform="translate3d(10px, 0px, 0px)"}}],classNames:"woocommerce-block-editor-tourkit"}}})}return null};var h=o(67221);const E="woocommerce_block_product_tour_shown",w=()=>{const e=(()=>{const{updateOptions:e}=(0,u.useDispatch)(h.OPTIONS_STORE_NAME),{shouldTourBeShown:t}=(0,u.useSelect)((e=>{const{getOption:t,hasFinishedResolution:o}=e(h.OPTIONS_STORE_NAME);return{shouldTourBeShown:!("yes"===t(E)||!o("getOption",[E]))}}));return{dismissModal:()=>{e({[E]:"yes"})},shouldTourBeShown:t}})();return(0,r.createElement)(_,e)};var f=o(81596);function g(){const{productId:e}=(0,i.UO)(),t=function(e){const{saveEntityRecord:t}=(0,u.useDispatch)("core"),[o,c]=(0,r.useState)(void 0);return(0,r.useEffect)((()=>{(e?(0,u.resolveSelect)("core").getEntityRecord("postType","product",Number.parseInt(e,10)):t("postType","product",{title:n.AUTO_DRAFT_NAME,status:"auto-draft"})).then((e=>{c(e)})).catch((e=>{throw c(void 0),e}))}),[e]),o}(e);return(0,r.useEffect)((()=>{(0,s.registerPlugin)("wc-admin-more-menu",{scope:"woocommerce-product-block-editor",render:()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(n.__experimentalWooProductMoreMenuItem,null,(e=>{let{onClose:t}=e;return(0,r.createElement)(f.e,{onClose:t})})))});const e=(0,n.__experimentalInitBlocks)();return()=>{(0,s.unregisterPlugin)("wc-admin-more-menu"),e()}}),[]),(0,r.useEffect)((function(){e?(0,c.recordEvent)("product_edit_view",{source:n.TRACKS_SOURCE,product_id:e}):(0,c.recordEvent)("product_add_view",{source:n.TRACKS_SOURCE})}),[e]),null!=t&&t.id?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(n.__experimentalEditor,{product:t,settings:productBlockEditorSettings||{}}),(0,r.createElement)(l.WooFooterItem,null,(0,r.createElement)(r.Fragment,null,(0,r.createElement)(n.__experimentalProductMVPCESFooter,{productType:"product"}),(0,r.createElement)(n.__experimentalProductMVPFeedbackModalContainer,{productId:t.id}))),(0,r.createElement)(w,null)):(0,r.createElement)(n.ProductPageSkeleton,null)}(0,n.productApiFetchMiddleware)()}}]);