"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Edit=void 0;const i18n_1=require("@wordpress/i18n"),element_1=require("@wordpress/element"),blocks_1=require("@wordpress/blocks"),components_1=require("@wordpress/components"),tracks_1=require("@woocommerce/tracks"),block_editor_1=require("@wordpress/block-editor"),core_data_1=require("@wordpress/core-data"),content_preview_1=require("../../components/content-preview"),modal_editor_1=require("../../components/modal-editor");function Edit(){const e=(0,block_editor_1.useBlockProps)(),[o,t]=(0,element_1.useState)(!1),[r,n]=(0,core_data_1.useEntityProp)("postType","product","description");return(0,element_1.createElement)("div",{...e},(0,element_1.createElement)(components_1.Button,{variant:"secondary",onClick:()=>{t(!0),(0,tracks_1.recordEvent)("product_add_description_click")}},r.length?(0,i18n_1.__)("Edit description","woocommerce"):(0,i18n_1.__)("Add description","woocommerce")),o&&(0,element_1.createElement)(modal_editor_1.ModalEditor,{initialBlocks:(0,blocks_1.parse)(r),onChange:e=>{const o=(0,blocks_1.serialize)(e);n(o)},onClose:()=>t(!1),title:(0,i18n_1.__)("Edit description","woocommerce")}),!!r.length&&(0,element_1.createElement)(content_preview_1.ContentPreview,{content:r}))}exports.Edit=Edit;