"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[3307],{36778:(e,t,n)=>{n.r(t),n.d(t,{default:()=>h});var r=n(69307),a=n(65736),c=n(14599),i=n(9818),s=n(86020),l=n(67221),o=n(85597),u=n(67628),d=n(83292),m=n(90142),p=n(48023),E=n(45473),v=n(32604),_=n(64620),g=n(3143),P=n(95822);const h=()=>{var e,t;const{productId:n}=(0,o.UO)(),h=(0,r.useRef)(),w=(0,r.useRef)(null),{product:f,isLoading:I,isPendingAction:k}=(0,i.useSelect)((e=>{const{getProduct:t,hasFinishedResolution:r,isPending:a,getPermalinkParts:c}=e(l.PRODUCTS_STORE_NAME);if(n){const e=t(parseInt(n,10),void 0);return{product:c(parseInt(n,10))&&e?e:void 0,isLoading:!r("getProduct",[parseInt(n,10)])||!r("getPermalinkParts",[parseInt(n,10)]),isPendingAction:a("createProduct")||a("deleteProduct",parseInt(n,10))||a("updateProduct",parseInt(n,10))}}return{isLoading:!1,isPendingAction:!1}}));(0,r.useEffect)((()=>{h.current&&f&&h.current.id!==f.id&&w.current&&w.current.resetForm(f),h.current=f}),[f]),(0,r.useEffect)((()=>{(0,c.recordEvent)("view_new_product_management_experience")}),[]);const b=(null===(e=h.current)||void 0===e?void 0:e.id)===(null==f?void 0:f.id)&&"trash"!==(null===(t=h.current)||void 0===t?void 0:t.status)&&"trash"===(null==f?void 0:f.status);return(0,r.createElement)("div",{className:"woocommerce-edit-product"},I&&!f?(0,r.createElement)("div",{className:"woocommerce-edit-product__spinner"},(0,r.createElement)(s.Spinner,null)):null,f&&"trash"===f.status&&!k&&!b&&(0,r.createElement)(u.a,null,(0,r.createElement)("div",{className:"woocommerce-edit-product__error"},(0,a.__)("You cannot edit this item because it is in the Trash. Please restore it and try again.","woocommerce"))),f&&("trash"!==f.status||b)&&(0,r.createElement)(s.Form,{ref:w,initialValues:f||{},validate:g.G,errors:{}},(0,r.createElement)(u.a,null,(0,r.createElement)(m.o,null),(0,r.createElement)(E.t,null),(0,r.createElement)(_.I,null),(0,r.createElement)(p.i,null),(0,r.createElement)(v.I,{product:f}),(0,r.createElement)(P.J,null),(0,r.createElement)(d.p,null))))}}}]);