"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of __getOwnPropNames(t))__hasOwnProp.call(e,n)||n===r||__defProp(e,n,{get:()=>t[n],enumerable:!(o=__getOwnPropDesc(t,n))||o.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),media_library_exports={};__export(media_library_exports,{MediaLibrary:()=>MediaLibrary}),module.exports=__toCommonJS(media_library_exports);var import_element=require("@wordpress/element");function MediaLibrary({allowedTypes:e,modalTitle:t,modalButtonText:r,multiple:o,className:n,uploaderParams:a,children:p,onSelect:i}){const l=(0,import_element.useMemo)(function(){return wp.media({title:t,library:{type:e},button:{text:r},multiple:o,states:[new wp.media.controller.Library({title:t,library:wp.media.query(),multiple:o,priority:20,filterable:"all"})]})},[e,t,r,o]);return(0,import_element.useEffect)(function(){function e(){const e=l.state().get("selection").toJSON();i(e)}function t(){l.uploader.options.uploader.params=a}return l.on("select",e),l.on("ready",t),function(){l.off("select",e),l.off("ready",t)}},[l,a,i]),(0,import_element.useEffect)(()=>function(){l.remove()},[l]),p({open:function(){l.$el.addClass(n),l.open()}})}