"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,r)=>{for(var t in r)__defProp(e,t,{get:r[t],enumerable:!0})},__copyProps=(e,r,t,o)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let p of __getOwnPropNames(r))__hasOwnProp.call(e,p)||p===t||__defProp(e,p,{get:()=>r[p],enumerable:!(o=__getOwnPropDesc(r,p))||o.enumerable});return e},__toESM=(e,r,t)=>(t=null!=e?__create(__getProtoOf(e)):{},__copyProps(!r&&e&&e.__esModule?t:__defProp(t,"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_clsx=__toESM(require("clsx")),import_block_templates=require("@woocommerce/block-templates"),import_compose=require("@wordpress/compose"),import_core_data=require("@wordpress/core-data"),import_element=require("@wordpress/element"),import_i18n=require("@wordpress/i18n"),import_components=require("@wordpress/components"),import_sanitize=require("@woocommerce/sanitize"),import_label=require("../../../components/label/label"),import_validation_context=require("../../../contexts/validation-context"),import_use_currency_input_props=require("../../../hooks/use-currency-input-props");function Edit({attributes:e,clientId:r,context:t}){const o=(0,import_block_templates.useWooBlockProps)(e),{label:p,help:i,isRequired:_,tooltip:n,disabled:s}=e,[a,m]=(0,import_core_data.useEntityProp)("postType",t.postType||"product","regular_price"),[c]=(0,import_core_data.useEntityProp)("postType",t.postType||"product","sale_price"),l=(0,import_use_currency_input_props.useCurrencyInputProps)({value:a,onChange:m}),u=(0,import_compose.useInstanceId)(import_components.BaseControl,"wp-block-woocommerce-product-regular-price-field"),{ref:d,error:f,validate:b}=(0,import_validation_context.useValidation)(`regular_price-${r}`,async function(){const e=Number.parseFloat(a);if(e){if(e<0)return{message:(0,import_i18n.__)("Regular price must be greater than or equals to zero.","woocommerce")};if(c&&e<=Number.parseFloat(c))return{message:(0,import_i18n.__)("Regular price must be greater than the sale price.","woocommerce")}}else if(_)return{message:(0,import_i18n.sprintf)((0,import_i18n.__)("%s is required.","woocommerce"),p)}},[a,c]);return(0,import_element.useEffect)(()=>{_&&b()},[]),(0,import_element.createElement)("div",{...o},(0,import_element.createElement)(import_components.BaseControl,{id:u,help:f||function(){if(i)return(0,import_element.createElement)("span",{dangerouslySetInnerHTML:{__html:(0,import_sanitize.sanitizeHTML)(i)}})}(),className:(0,import_clsx.default)({"has-error":f})},(0,import_element.createElement)(import_components.__experimentalInputControl,{...l,id:u,name:"regular_price",inputMode:"decimal",ref:d,label:n?(0,import_element.createElement)(import_label.Label,{label:p,tooltip:n}):p,disabled:s,onBlur:()=>b()})))}