"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__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 n of __getOwnPropNames(t))__hasOwnProp.call(e,n)||n===o||__defProp(e,n,{get:()=>t[n],enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),insert_url_menu_item_exports={};__export(insert_url_menu_item_exports,{InsertUrlMenuItem:()=>InsertUrlMenuItem}),module.exports=__toCommonJS(insert_url_menu_item_exports);var import_element=require("@wordpress/element"),import_i18n=require("@wordpress/i18n"),import_icons=require("@wordpress/icons"),import_components=require("@wordpress/components");function validateInput(e){e.required=!0,e.setCustomValidity(""),e.validity.valueMissing&&e.setCustomValidity((0,import_i18n.__)("The URL is required","woocommerce")),e.validity.typeMismatch&&e.setCustomValidity((0,import_i18n.__)("Insert a valid URL","woocommerce"))}function InsertUrlMenuItem({onLinkSuccess:e,onLinkError:t}){function o(o){o.preventDefault();const r=o.currentTarget,n=r.url;if(validateInput(n),r.checkValidity()){const t=r.url.value;e([{url:t}])}else t(n.validationMessage)}function r(e){validateInput(e.target)}function n(e){validateInput(e.target)}return(0,import_element.createElement)(import_components.Dropdown,{popoverProps:{placement:"left"},renderToggle:({isOpen:e,onToggle:t})=>(0,import_element.createElement)(import_components.MenuItem,{"aria-expanded":e,icon:import_icons.customLink,iconPosition:"left",onClick:t,info:(0,import_i18n.__)("Link to a file hosted elsewhere","woocommerce")},(0,import_i18n.__)("Insert from URL","woocommerce")),renderContent:()=>(0,import_element.createElement)("form",{className:"components-dropdown-menu__menu",noValidate:!0,onSubmit:o},(0,import_element.createElement)(import_components.__experimentalInputControl,{name:"url",type:"url",placeholder:(0,import_i18n.__)("Insert URL","woocommerce"),suffix:(0,import_element.createElement)(import_components.Button,{icon:import_icons.keyboardReturn,type:"submit"}),className:"woocommerce-inert-url-menu-item__input","aria-label":(0,import_i18n.__)("Insert URL","woocommerce"),onInput:r,onBlur:n}))})}