"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[7387],{3995:(e,t,r)=>{r.r(t),r.d(t,{default:()=>b});var o=r(69307),n=r(51393),c=r(86020),d=r(14599),a=r(99196),l=r(98817),i=r(85597),u=r(46530),s=r(65736),p=r(9818),m=r(5771);(0,n.productEditorHeaderApiFetchMiddleware)(),(0,n.productApiFetchMiddleware)();const _=(0,a.lazy)((()=>r.e(6083).then(r.bind(r,6083)))),E=(0,a.lazy)((()=>Promise.resolve().then(r.t.bind(r,51393,23)).then((e=>({default:e.__experimentalProductMVPFeedbackModalContainer})))));function b(){const{productId:e}=(0,i.UO)();(0,a.useEffect)((()=>{document.body.classList.add("is-product-editor"),(0,l.registerPlugin)("wc-admin-product-editor",{scope:"woocommerce-product-block-editor",render:()=>(0,a.useContext)(n.__experimentalEditorLoadingContext)?null:(0,o.createElement)(o.Fragment,null,(0,o.createElement)(n.__experimentalWooProductMoreMenuItem,null,(({onClose:e})=>(0,o.createElement)(m.e,{onClose:e}))),(0,o.createElement)(u.WooFooterItem,null,(0,o.createElement)(o.Fragment,null,(0,o.createElement)(n.__experimentalProductMVPCESFooter,{productType:"product"}),(0,o.createElement)(a.Suspense,{fallback:(0,o.createElement)(c.Spinner,null)},(0,o.createElement)(E,{productId:e?Number.parseInt(e,10):void 0})))),(0,o.createElement)(a.Suspense,{fallback:(0,o.createElement)(c.Spinner,null)},(0,o.createElement)(_,null)))});const t=(0,n.__experimentalInitBlocks)();return()=>{document.body.classList.remove("is-product-editor"),(0,l.unregisterPlugin)("wc-admin-product-editor"),t()}}),[e]),(0,a.useEffect)((function(){e?(0,d.recordEvent)("product_edit_view",{source:n.TRACKS_SOURCE,product_id:e}):(0,d.recordEvent)("product_add_view",{source:n.TRACKS_SOURCE})}),[e]);const t=function(e){const[t,r]=(0,o.useState)(void 0);return(0,o.useEffect)((()=>{e?r(Number.parseInt(e,10)):(0,p.dispatch)("core").saveEntityRecord("postType","product",{title:n.AUTO_DRAFT_NAME,status:"auto-draft"}).then((e=>r(e.id))).catch((e=>{throw r(void 0),e}))}),[e]),t}(e);return t?(0,o.createElement)(n.__experimentalEditor,{productId:t}):(0,o.createElement)("div",{className:"woocommerce-layout__loading"},(0,o.createElement)(c.Spinner,{"aria-label":(0,s.__)("Creating the product","woocommerce")}))}}}]);