var __defProp=Object.defineProperty,__defNormalProp=(e,l,t)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,__publicField=(e,l,t)=>(__defNormalProp(e,"symbol"!=typeof l?l+"":l,t),t);!function(e){"use strict";const l=()=>window.filebirdDiviBuilder||{};class t extends e.Component{constructor(){super(...arguments),__publicField(this,"state",{query:""}),__publicField(this,"toggle",e=>{const l=this.selected,t=l.includes(e)?l.filter(l=>l!==e):[...l,e];this.commit(this.folders.map(e=>e.value).filter(e=>t.includes(e)))})}get folders(){return l().folders||[]}get selected(){return e=this.props.value,String(e||"").split(",").map(e=>e.trim()).filter(Boolean);var e}commit(e){this.props._onChange(this.props.name,e.join(","))}visibleFolders(){const e=this.state.query.trim().toLowerCase();return e?this.folders.filter(l=>l.label.toLowerCase().includes(e)):this.folders}render(){const{i18n:t={}}=l(),i=this.folders,r=this.selected;if(!i.length)return e.createElement("p",{className:"filebird-folder-picker__empty"},t.noFolders);const s=this.visibleFolders();return e.createElement("div",{className:"filebird-folder-picker"},e.createElement("input",{type:"search",className:"filebird-folder-picker__search",value:this.state.query,placeholder:t.searchHint,onChange:e=>this.setState({query:e.target.value})}),e.createElement("div",{className:"filebird-folder-picker__actions"},e.createElement("span",{className:"filebird-folder-picker__count"},(t.selected||"%d selected").replace("%d",r.length)),e.createElement("span",{className:"filebird-folder-picker__buttons"},e.createElement("button",{type:"button",onClick:()=>this.commit(s.map(e=>e.value))},t.selectAll),e.createElement("button",{type:"button",onClick:()=>this.commit([]),disabled:!r.length},t.clearAll))),e.createElement("ul",{className:"filebird-folder-picker__list"},s.map(l=>e.createElement("li",{key:l.value,style:{paddingLeft:16*l.depth+"px"}},e.createElement("label",null,e.createElement("input",{type:"checkbox",value:l.value,checked:r.includes(l.value),onChange:()=>this.toggle(l.value)}),e.createElement("span",null,l.label))))))}}__publicField(t,"slug",l().folderPickerField||"filebird_folder_picker");const i=[t];class r extends e.Component{componentDidMount(){this.initCarousel()}componentDidUpdate(){this.initCarousel()}initCarousel(){window.filebirdGalleryCarousel&&window.filebirdGalleryCarousel.init()}render(){var l;const t=this.props.__gallery,i=(null==(l=window.filebirdDiviBuilder)?void 0:l.i18n)||{};return"string"!=typeof t?e.createElement("div",{className:"filebird-gallery-loading"},i.loading):t.trim()?e.createElement("div",{dangerouslySetInnerHTML:{__html:t}}):e.createElement("div",{className:"filebird-gallery-error"},i.selectFolder)}}__publicField(r,"slug","filebird_divi_gallery");const s=[r],n=window.jQuery;n&&n(window).on("et_builder_api_ready",(e,l)=>{l.registerModules(s),l.registerModalFields(i)})}(React);
