"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(t,e)=>{for(var r in e)__defProp(t,r,{get:e[r],enumerable:!0})},__copyProps=(t,e,r,o)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let _ of __getOwnPropNames(e))__hasOwnProp.call(t,_)||_===r||__defProp(t,_,{get:()=>e[_],enumerable:!(o=__getOwnPropDesc(e,_))||o.enumerable});return t},__toCommonJS=t=>__copyProps(__defProp({},"__esModule",{value:!0}),t),edit_exports={};__export(edit_exports,{AttributesBlockEdit:()=>AttributesBlockEdit}),module.exports=__toCommonJS(edit_exports);var import_element=require("@wordpress/element"),import_block_templates=require("@woocommerce/block-templates"),import_i18n=require("@wordpress/i18n"),import_tracks=require("@woocommerce/tracks"),import_core_data=require("@wordpress/core-data"),import_attribute_control=require("../../../components/attribute-control"),import_use_product_attributes=require("../../../hooks/use-product-attributes");function AttributesBlockEdit({attributes:t,context:{isInSelectedTab:e}}){const[r,o]=(0,import_core_data.useEntityProp)("postType","product","attributes"),_=(0,import_core_data.useEntityId)("postType","product"),i=(0,import_block_templates.useWooBlockProps)(t),{attributes:c,fetchAttributes:a,handleChange:n}=(0,import_use_product_attributes.useProductAttributes)({allAttributes:r,onChange:o,productId:_});return(0,import_element.useEffect)(()=>{e&&a()},[r,e]),(0,import_element.createElement)("div",{...i},(0,import_element.createElement)(import_attribute_control.AttributeControl,{value:c,disabledAttributeIds:r.filter(t=>!!t.variation).map(t=>t.id),uiStrings:{disabledAttributeMessage:(0,import_i18n.__)("Already used in Variations","woocommerce")},onAdd:()=>{(0,import_tracks.recordEvent)("product_add_attributes_modal_add_button_click")},onChange:n,onNewModalCancel:()=>{(0,import_tracks.recordEvent)("product_add_attributes_modal_cancel_button_click")},onNewModalOpen:()=>{c.length?(0,import_tracks.recordEvent)("product_add_attribute_button"):(0,import_tracks.recordEvent)("product_add_first_attribute_button_click")},onAddAnother:()=>{(0,import_tracks.recordEvent)("product_add_attributes_modal_add_another_attribute_button_click")},onRemoveItem:()=>{(0,import_tracks.recordEvent)("product_add_attributes_modal_remove_attribute_button_click")},onRemove:()=>(0,import_tracks.recordEvent)("product_remove_attribute_confirmation_confirm_click"),onRemoveCancel:()=>(0,import_tracks.recordEvent)("product_remove_attribute_confirmation_cancel_click"),termsAutoSelection:"first",defaultVisibility:!0}))}