(()=>{"use strict";const e=window.wp.blocks,t=window.React,a=window.wp.components,n=window.wp.blockEditor,i=window.wp.element,r=window.wp.i18n,l=window.wp.serverSideRender,o=JSON.parse('{"UU":"sabaiapps/drts-view"}'),s=[["core/heading",{level:2,content:"",placeholder:(0,r.__)("Enter title...","directories-pro"),textAlign:"center",style:{typography:{fontStyle:"normal",fontWeight:"200"},spacing:{margin:{top:"80px",bottom:"36px"}}}}]];(0,e.registerBlockType)(o.UU,{edit:function({attributes:e,setAttributes:c}){const[_,p]=(0,i.useState)(drts_wordpress_block_editor_vars_view.views||[]),[u,m]=(0,i.useState)(!1),d=drts_wordpress_block_editor_vars_view.default_views||[],b=drts_wordpress_block_editor_vars_view.cache_options||[],w=e.view&&""!==e.view,v=w&&!d.includes(Number(e.view));(0,i.useEffect)((()=>{p((e=>[{value:"",label:(0,r.__)("Select a view","directories-pro")},...e])),m(!0)}),[]),(0,i.useEffect)((()=>{u&&c({queryLimit:void 0,queryFields:"",cacheLifetime:0})}),[e.view]);const g=(0,n.useInnerBlocksProps)({className:"drts-inner-blocks-container"},{template:s});return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(n.InspectorControls,null,(0,t.createElement)(a.PanelBody,{title:(0,r.__)("Settings","directories-pro")},(0,t.createElement)(a.SelectControl,{label:(0,r.__)("View","directories-pro"),value:e.view,options:_,onChange:e=>c({view:e})}),w&&b.length>0&&(0,t.createElement)(a.SelectControl,{label:(0,r.__)("Cache output","directories-pro"),value:e.cacheLifetime,options:b,onChange:e=>c({cacheLifetime:""!==e?parseInt(e,10):void 0})}),v&&(0,t.createElement)(t.Fragment,null,(0,t.createElement)(a.__experimentalNumberControl,{label:(0,r.__)("Max number of items to query","directories-pro"),value:e.queryLimit,onChange:e=>c({queryLimit:""!==e?parseInt(e,10):void 0}),min:0}),(0,t.createElement)(a.TextControl,{label:(0,r.__)("Query by field","directories-pro"),value:e.queryFields,onChange:e=>c({queryFields:""!==e?e:void 0}),help:(0,r.__)("Enter a query string in the format of aaa=xxx&bbb=yyy&ccc=zzz... where aaa, bbb, and ccc represent a field name and xxx, yyy, and zzz represent value(s) to query for each field. Example: post_author=1&directory_category=food,internet,travel&field_phone=1234567890","directories-pro")})))),(0,t.createElement)("div",{...(0,n.useBlockProps)()},(0,t.createElement)("div",{...g}),w?(0,t.createElement)(a.Disabled,null,(0,t.createElement)(l.ServerSideRender,{block:o.UU,attributes:e})):(0,t.createElement)(a.SelectControl,{value:e.view,options:_,onChange:e=>c({view:e})})))},save:function(){const e=n.useBlockProps.save(),a=n.useInnerBlocksProps.save(e);return(0,t.createElement)("div",{...a})}})})();