(()=>{"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.components,t=window.wp.blockEditor,i=window.wp.element,s=window.wp.data;function r(e,o=[],a=""){for(var l=0;l<e.length;l+=1)o.push({label:a+e[l].name,value:e[l].id}),e[l].children.length>0&&r(e[l].children,o,a.trim()+"—");return o}const c=window.ReactJSXRuntime,g=JSON.parse('{"UU":"aiovg/categories"}');(0,o.registerBlockType)(g.UU,{attributes:{template:{type:"string",default:aiovg_blocks.categories.template},id:{type:"number",default:aiovg_blocks.categories.id},columns:{type:"number",default:aiovg_blocks.categories.columns},limit:{type:"limit",default:aiovg_blocks.categories.limit},orderby:{type:"string",default:aiovg_blocks.categories.orderby},order:{type:"string",default:aiovg_blocks.categories.order},hierarchical:{type:"boolean",default:aiovg_blocks.categories.hierarchical},show_description:{type:"boolean",default:aiovg_blocks.categories.show_description},show_count:{type:"boolean",default:aiovg_blocks.categories.show_count},hide_empty:{type:"boolean",default:aiovg_blocks.categories.hide_empty},show_pagination:{type:"boolean",default:aiovg_blocks.categories.show_pagination}},edit:function({attributes:e,setAttributes:o}){const{template:a,id:g,columns:d,limit:_,orderby:b,order:h,hierarchical:u,show_description:p,show_count:v,hide_empty:x,show_pagination:m}=e,w=(0,s.useSelect)(e=>e("core").getEntityRecords("taxonomy","aiovg_categories",{per_page:-1})),k=(0,i.useMemo)(()=>{let e=[{label:"— "+aiovg_blocks.i18n.select_parent+" —",value:0}];if(w&&w.length>0){let o=function(e){for(var o,a={},l=[],n=0;n<e.length;n+=1)a[e[n].id]=n,e[n].children=[];for(n=0;n<e.length;n+=1)0==(o=e[n]).parent?l.push(o):a.hasOwnProperty(o.parent)&&e[a[o.parent]].children.push(o);return l}(w),a=r(o);e=[...e,...a]}return e},[w]);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(t.InspectorControls,{children:(0,c.jsxs)(n.PanelBody,{title:aiovg_blocks.i18n.general_settings,className:"aiovg-block-panel",children:[(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.SelectControl,{label:aiovg_blocks.i18n.select_template,value:a,options:[{label:aiovg_blocks.i18n.grid,value:"grid"},{label:aiovg_blocks.i18n.list,value:"list"},{label:aiovg_blocks.i18n.dropdown,value:"dropdown"}],onChange:e=>o({template:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.SelectControl,{label:aiovg_blocks.i18n.select_parent,value:g,options:k,onChange:e=>o({id:Number(e)}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),"grid"==a&&(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.RangeControl,{label:aiovg_blocks.i18n.columns,value:d,min:1,max:12,onChange:e=>o({columns:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),"grid"==a&&(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.RangeControl,{label:aiovg_blocks.i18n.limit,value:_,min:0,max:500,onChange:e=>o({limit:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.SelectControl,{label:aiovg_blocks.i18n.order_by,value:b,options:[{label:aiovg_blocks.i18n.id,value:"id"},{label:aiovg_blocks.i18n.count,value:"count"},{label:aiovg_blocks.i18n.name,value:"name"},{label:aiovg_blocks.i18n.slug,value:"slug"},{label:aiovg_blocks.i18n.menu_order,value:"menu_order"}],onChange:e=>o({orderby:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.SelectControl,{label:aiovg_blocks.i18n.order,value:h,options:[{label:aiovg_blocks.i18n.asc,value:"asc"},{label:aiovg_blocks.i18n.desc,value:"desc"}],onChange:e=>o({order:e}),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})}),("list"==a||"dropdown"==a)&&(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.ToggleControl,{label:aiovg_blocks.i18n.show_hierarchy,checked:u,onChange:()=>o({hierarchical:!u}),__nextHasNoMarginBottom:!0})}),"grid"==a&&(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.ToggleControl,{label:aiovg_blocks.i18n.show_description,checked:p,onChange:()=>o({show_description:!p}),__nextHasNoMarginBottom:!0})}),(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.ToggleControl,{label:aiovg_blocks.i18n.show_videos_count,checked:v,onChange:()=>o({show_count:!v}),__nextHasNoMarginBottom:!0})}),(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.ToggleControl,{label:aiovg_blocks.i18n.hide_empty_categories,checked:x,onChange:()=>o({hide_empty:!x}),__nextHasNoMarginBottom:!0})}),"grid"==a&&(0,c.jsx)(n.PanelRow,{children:(0,c.jsx)(n.ToggleControl,{label:aiovg_blocks.i18n.show_pagination,checked:m,onChange:()=>o({show_pagination:!m}),__nextHasNoMarginBottom:!0})})]})}),(0,c.jsx)("div",{...(0,t.useBlockProps)(),children:(0,c.jsx)(n.Disabled,{children:(0,c.jsx)(l(),{block:"aiovg/categories",attributes:e})})})]})}})})();