(()=>{"use strict";var e={n:l=>{var n=l&&l.__esModule?()=>l.default:()=>l;return e.d(n,{a:n}),n},d:(l,n)=>{for(var a in n)e.o(n,a)&&!e.o(l,a)&&Object.defineProperty(l,a,{enumerable:!0,get:n[a]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.blocks,n=window.wp.serverSideRender;var a=e.n(n);const o=window.wp.components,t=window.wp.blockEditor,r=window.wp.element,i=window.wp.hooks,s=window.wp.data;function c(e){var l="string";return"categories"==e?l="array":"number"==e?l="number":"checkbox"==e&&(l="boolean"),l}function u(e,l=[],n=""){for(var a=0;a<e.length;a+=1)l.push({label:n+e[a].name,value:e[a].id}),e[a].children.length>0&&u(e[a].children,l,n.trim()+"—");return l}const p=window.ReactJSXRuntime,d=JSON.parse('{"UU":"aiovg/videos"}');(0,l.registerBlockType)(d.UU,{attributes:function(){var e={};for(var l in aiovg_blocks.videos){var n=aiovg_blocks.videos[l].fields;for(var a in n)e[n[a].name]={type:c(n[a].type),default:n[a].value}}return e}(),edit:function({attributes:e,setAttributes:l}){const n=aiovg_blocks.videos,c=(0,s.useSelect)(e=>e("core").getEntityRecords("taxonomy","aiovg_categories",{per_page:-1})),d=(0,s.useSelect)(e=>e("core").getEntityRecords("taxonomy","aiovg_tags",{per_page:-1})),g=(0,r.useMemo)(()=>{let e=[];if(c&&c.length>0){let l=u(function(e){for(var l,n={},a=[],o=0;o<e.length;o+=1)n[e[o].id]=o,e[o].children=[];for(o=0;o<e.length;o+=1)0==(l=e[o]).parent?a.push(l):n.hasOwnProperty(l.parent)&&e[n[l.parent]].children.push(l);return a}(c));e=[...e,...l]}return e},[c]),h=(0,r.useMemo)(()=>{let e=[];if(d&&d.length>0)for(let l=0;l<d.length;l+=1)e.push({label:d[l].name,value:d[l].id});return e},[d]),m=e=>n=>{l({[e]:n})},b=(0,r.useRef)();return(0,r.useEffect)(()=>{b.current?(0,i.applyFilters)("aiovg_block_init",e):b.current=!0}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(t.InspectorControls,{children:Object.keys(n).map((a,r)=>{return s=a,(0,i.applyFilters)("aiovg_block_toggle_panels",!0,s,e)&&(0,p.jsx)(o.PanelBody,{title:n[a].title,initialOpen:0==r,className:"aiovg-block-panel",children:Object.keys(n[a].fields).map((r,s)=>((n,a)=>{if(!(l=>{let n=!0;return"show_more"!=l&&"more_label"!=l&&"more_link"!=l||(n=!1),(0,i.applyFilters)("aiovg_block_toggle_controls",n,l,e)})(n.name))return"";const r=n.placeholder?n.placeholder:"",s=n.description?n.description:"";switch(n.type){case"header":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)("h3",{className:"aiovg-no-margin",children:n.label})},a);case"categories":return(0,p.jsx)(o.PanelRow,{className:"aiovg-block-multiselect",children:(0,p.jsx)(o.SelectControl,{multiple:!0,label:n.label,help:s,options:g,value:e[n.name],onChange:m(n.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"tags":return(0,p.jsx)(o.PanelRow,{className:"aiovg-block-multiselect",children:(0,p.jsx)(o.SelectControl,{multiple:!0,label:n.label,help:s,options:h,value:e[n.name],onChange:m(n.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"number":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.RangeControl,{label:n.label,help:s,placeholder:r,value:e[n.name],min:n.min,max:n.max,onChange:m(n.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"textarea":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.TextareaControl,{label:n.label,help:s,placeholder:r,value:e[n.name],onChange:m(n.name),__nextHasNoMarginBottom:!0})},a);case"select":case"radio":let i=[];for(let e in n.options)i.push({label:n.options[e],value:e});return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.SelectControl,{label:n.label,help:s,options:i,value:e[n.name],onChange:m(n.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"checkbox":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.ToggleControl,{label:n.label,help:s,checked:e[n.name],onChange:(c=n.name,e=>{l({[c]:e})}),__nextHasNoMarginBottom:!0})},a);case"color":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(t.PanelColorSettings,{title:n.label,colorSettings:[{label:aiovg_blocks.i18n.select_color,value:e[n.name],onChange:m(n.name)}]})},a);default:return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.TextControl,{label:n.label,help:s,placeholder:r,value:e[n.name],onChange:m(n.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a)}var c})(n[a].fields[r],"aiovg-block-control-"+s))},"aiovg-block-panel-"+r);var s})}),(0,p.jsx)("div",{...(0,t.useBlockProps)(),children:(0,p.jsx)(o.Disabled,{children:(0,p.jsx)(a(),{block:"aiovg/videos",attributes:e})})})]})}})})();