(()=>{"use strict";var e={n:o=>{var a=o&&o.__esModule?()=>o.default:()=>o;return e.d(a,{a}),a},d:(o,a)=>{for(var l in a)e.o(a,l)&&!e.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:a[l]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.blocks,a=window.wp.serverSideRender;var l=e.n(a);const n=window.wp.blockEditor,t=window.wp.components,c=window.wp.element,s=window.wp.hooks,r=window.wp.data;function i(e,o=[],a=""){var l;for(l=0;l<e.length;l+=1)o.push({label:a+e[l].name,value:e[l].id}),e[l].children.length>0&&i(e[l].children,o,a.trim()+"— ");return o}const d=window.ReactJSXRuntime,p=JSON.parse('{"UU":"acadp/locations"}');(0,o.registerBlockType)(p.UU,{attributes:{parent:{type:"number",default:acadp_blocks.locations.parent},columns:{type:"number",default:acadp_blocks.locations.columns},depth:{type:"number",default:acadp_blocks.locations.depth},orderby:{type:"string",default:acadp_blocks.locations.orderby},order:{type:"string",default:acadp_blocks.locations.order},show_count:{type:"boolean",default:acadp_blocks.locations.show_count},hide_empty:{type:"boolean",default:acadp_blocks.locations.hide_empty}},edit:function({attributes:e,setAttributes:o}){const{parent:a,columns:p,depth:b,orderby:_,order:u,show_count:h,hide_empty:w}=e,x=(0,r.useSelect)(e=>e("core").getEntityRecords("taxonomy","acadp_locations",{per_page:-1})),k=(0,c.useMemo)(()=>{let e=[{label:"— "+acadp_blocks.locations.i18n.parent_label+" —",value:0}];if(x&&x.length>0){let o=function(e,o){var a,l,n={},t=[];for(l=0;l<e.length;l+=1)n[e[l].id]=l,e[l].children=[];for(l=0;l<e.length;l+=1)(a=e[l]).parent==o?t.push(a):n.hasOwnProperty(a.parent)&&e[n[a.parent]].children.push(a);return t}(x,parseInt(acadp_blocks.base_location)),a=i(o);e=[...e,...a]}return e},[x]),m=(0,c.useRef)();return(0,c.useEffect)(()=>{m.current?(0,s.doAction)("acadp_init_locations",e):m.current=!0}),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(n.InspectorControls,{children:(0,d.jsxs)(t.PanelBody,{title:acadp_blocks.locations.i18n.panel_settings,children:[(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.SelectControl,{__next40pxDefaultSize:!0,label:acadp_blocks.locations.i18n.parent_label,value:a,options:k,onChange:e=>o({parent:Number(e)})})}),(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.RangeControl,{__next40pxDefaultSize:!0,label:acadp_blocks.locations.i18n.columns_label,value:p,min:1,max:12,onChange:e=>o({columns:e})})}),(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.RangeControl,{__next40pxDefaultSize:!0,label:acadp_blocks.locations.i18n.depth_label,value:b,min:1,max:12,onChange:e=>o({depth:e})})}),(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.SelectControl,{__next40pxDefaultSize:!0,label:acadp_blocks.locations.i18n.orderby_label,value:_,options:[{label:acadp_blocks.locations.i18n.orderby_id,value:"id"},{label:acadp_blocks.locations.i18n.orderby_count,value:"count"},{label:acadp_blocks.locations.i18n.orderby_name,value:"name"},{label:acadp_blocks.locations.i18n.orderby_slug,value:"slug"}],onChange:e=>o({orderby:e})})}),(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.SelectControl,{__next40pxDefaultSize:!0,label:acadp_blocks.locations.i18n.order_label,value:u,options:[{label:acadp_blocks.locations.i18n.order_asc,value:"asc"},{label:acadp_blocks.locations.i18n.order_desc,value:"desc"}],onChange:e=>o({order:e})})}),(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.ToggleControl,{__nextHasNoMarginBottom:!0,label:acadp_blocks.locations.i18n.show_count_label,help:acadp_blocks.locations.i18n.show_count_help,checked:h,onChange:()=>o({show_count:!h})})}),(0,d.jsx)(t.PanelRow,{children:(0,d.jsx)(t.ToggleControl,{__nextHasNoMarginBottom:!0,label:acadp_blocks.locations.i18n.hide_empty_label,help:acadp_blocks.locations.i18n.hide_empty_help,checked:w,onChange:()=>o({hide_empty:!w})})})]})}),(0,d.jsx)("div",{...(0,n.useBlockProps)(),children:(0,d.jsx)(t.Disabled,{children:(0,d.jsx)(l(),{block:"acadp/locations",attributes:e})})})]})}})})();