"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(e,t,o,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let _ of __getOwnPropNames(t))__hasOwnProp.call(e,_)||_===o||__defProp(e,_,{get:()=>t[_],enumerable:!(r=__getOwnPropDesc(t,_))||r.enumerable});return e},__toESM=(e,t,o)=>(o=null!=e?__create(__getProtoOf(e)):{},__copyProps(!t&&e&&e.__esModule?o:__defProp(o,"default",{value:e,enumerable:!0}),e)),__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),edit_exports={};__export(edit_exports,{Edit:()=>Edit}),module.exports=__toCommonJS(edit_exports);var import_element=require("@wordpress/element"),import_components=require("@wordpress/components"),import_block_templates=require("@woocommerce/block-templates"),import_tracks=require("@woocommerce/tracks"),import_sanitize=require("@woocommerce/sanitize"),import_core_data=require("@wordpress/core-data"),import_use_product_entity_prop=__toESM(require("../../../hooks/use-product-entity-prop")),import_constants=require("../../../constants");function Edit({attributes:e,context:{postType:t}}){const o=(0,import_block_templates.useWooBlockProps)(e),{_templateBlockId:r,label:_,property:p,disabled:n,disabledCopy:i,checkedValue:c,uncheckedValue:l}=e,[s,a]=(0,import_use_product_entity_prop.default)(p,{postType:t,fallbackValue:!1}),m=(0,import_core_data.useEntityId)("postType",t),[d]=(0,import_core_data.useEntityProp)("postType",t,"parent_id");function u(){return void 0!==c?c===s:s}let y=null;return e?.help&&(y=(0,import_element.createElement)("div",{dangerouslySetInnerHTML:{__html:(0,import_sanitize.sanitizeHTML)(e.help)}})),e?.checkedHelp&&u()&&(y=(0,import_element.createElement)("div",{dangerouslySetInnerHTML:{__html:(0,import_sanitize.sanitizeHTML)(e.checkedHelp)}})),e?.uncheckedHelp&&!u()&&(y=(0,import_element.createElement)("div",{dangerouslySetInnerHTML:{__html:(0,import_sanitize.sanitizeHTML)(e.uncheckedHelp)}})),(0,import_element.createElement)("div",{...o},(0,import_element.createElement)(import_components.ToggleControl,{label:_,checked:u(),disabled:n,onChange:function(e){(0,import_tracks.recordEvent)("product_toggle_click",{block_id:r,source:import_constants.TRACKS_SOURCE,product_id:d>0?d:m}),a(e?void 0!==c?c:e:void 0!==l?l:e)},help:y}),n&&(0,import_element.createElement)("p",{className:"wp-block-woocommerce-product-toggle__disable-copy",dangerouslySetInnerHTML:{__html:(0,import_sanitize.sanitizeHTML)(i)}}))}