(()=>{"use strict";const e=window.wp.blocks,t=window.wp.components,i=window.wp.blockEditor,o=window.wp.element,r=window.wp.i18n,a=window.wp.serverSideRender,n=JSON.parse('{"UU":"sabaiapps/drts-directory-locations"}'),s=window.ReactJSXRuntime;(0,e.registerBlockType)(n.UU,{edit:function({attributes:e,setAttributes:c}){const[l,d]=(0,o.useState)(drts_wordpress_block_editor_vars_directory_locations.directories||[]),[_,p]=(0,o.useState)(!1),u=drts_wordpress_block_editor_vars_directory_locations.cache_options||[],w=e.directory&&""!==e.directory;return(0,o.useEffect)(()=>{d(e=>[{value:"",label:(0,r.__)("Select a directory","directories-pro")},...e]),p(!0)},[]),(0,o.useEffect)(()=>{_&&c({cacheLifetime:0})},[e.directory]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.InspectorControls,{children:(0,s.jsxs)(t.PanelBody,{title:(0,r.__)("Settings","directories-pro"),children:[(0,s.jsx)(t.SelectControl,{label:(0,r.__)("Directory","directories-pro"),value:e.directory,options:l,onChange:e=>c({directory:e})}),w&&u.length>0&&(0,s.jsx)(t.SelectControl,{label:(0,r.__)("Cache output","directories-pro"),value:e.cacheLifetime,options:u,onChange:e=>c({cacheLifetime:""!==e?parseInt(e,10):void 0})})]})}),(0,s.jsx)("div",{...(0,i.useBlockProps)(),children:w?(0,s.jsx)(t.Disabled,{children:(0,s.jsx)(a.ServerSideRender,{block:n.UU,attributes:e})}):(0,s.jsx)(t.SelectControl,{value:e.directory,options:l,onChange:e=>c({directory:e})})})]})}})})();