"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MediaLibraryMenuItem=void 0;const components_1=require("@wordpress/components"),element_1=require("@wordpress/element"),i18n_1=require("@wordpress/i18n"),icons_1=require("@wordpress/icons"),media_utils_1=require("@wordpress/media-utils"),MODAL_CLASS_NAME="woocommerce-media-library-menu-item__upload_files_modal",MODAL_WRAPPER_CLASS_NAME="woocommerce-media-library-menu-item__upload_files_modal_wrapper";function MediaLibraryMenuItem({allowedTypes:e,onUploadSuccess:o}){const[r,n]=(0,element_1.useState)(!1);return(0,element_1.useEffect)((function(){const e=document.querySelector(`.${MODAL_CLASS_NAME}`),o=null==e?void 0:e.closest('[role="dialog"]'),r=null==o?void 0:o.parentElement;return null==r||r.classList.add(MODAL_WRAPPER_CLASS_NAME),()=>{null==r||r.classList.remove(MODAL_WRAPPER_CLASS_NAME)}}),[r]),(0,element_1.createElement)(media_utils_1.MediaUpload,{modalClass:MODAL_CLASS_NAME,onSelect:function(e){o(e)},allowedTypes:e,multiple:"add",render:({open:e})=>{return(0,element_1.createElement)(components_1.MenuItem,{icon:icons_1.media,iconPosition:"left",onClick:(o=e,function(){o(),n(!0)}),info:(0,i18n_1.__)("Choose from uploaded media","woocommerce")},(0,i18n_1.__)("Media Library","woocommerce"));var o}})}exports.MediaLibraryMenuItem=MediaLibraryMenuItem;