"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_library_1=require("../media-library"),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,i]=(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_library_1.MediaLibrary,{className:MODAL_CLASS_NAME,allowedTypes:e,multiple:"add",uploaderParams:{type:"downloadable_product"},onSelect:function(e){o(e)}},(({open:e})=>{return(0,element_1.createElement)(components_1.MenuItem,{icon:icons_1.media,iconPosition:"left",onClick:(o=e,function(){o(),i(!0)}),info:(0,i18n_1.__)("Choose from uploaded media","woocommerce")},(0,i18n_1.__)("Media Library","woocommerce"));var o}))}exports.MediaLibraryMenuItem=MediaLibraryMenuItem;