(()=>{"use strict";var e={n:o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.blocks,t=window.wp.i18n,n=JSON.parse('{"UU":"mine-cloudvod/course-list","DD":"Course List"}'),l=window.wp.components,r=window.wp.blockEditor,s=window.wp.data,i=window.wp.element,a=window.wp.serverSideRender;var d=e.n(a);const u=window.ReactJSXRuntime,c=window.wp.primitives;var p=(0,u.jsxs)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,u.jsx)(c.Path,{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,u.jsx)(c.Path,{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]});function m({attributes:e,setAttributes:o}){return(0,u.jsx)(l.Dropdown,{contentClassName:"block-library-query-toolbar__popover",renderToggle:({isOpen:e,onToggle:o})=>(0,u.jsx)(l.ToolbarGroup,{children:(0,u.jsx)(l.ToolbarButton,{icon:p,label:wp.i18n.__("Display settings"),showTooltip:!0,"aria-haspopup":"true","aria-expanded":e,onClick:o})}),renderContent:({})=>(0,u.jsxs)("div",{children:[(0,u.jsx)(l.__experimentalNumberControl,{label:wp.i18n.__("Number of rows","mine-cloudvod"),labelPosition:"edge",type:"number",value:e.rows,onChange:e=>o({rows:null!=e?e:1}),__unstableInputWidth:"60px",min:1,max:10,step:"1",isDragEnabled:!1}),(0,u.jsx)(l.__experimentalNumberControl,{label:wp.i18n.__("Number of columns","mine-cloudvod"),labelPosition:"edge",type:"number",value:e.columns,onChange:e=>o({columns:null!=e?e:4}),__unstableInputWidth:"60px",min:1,max:6,step:"1",isDragEnabled:!1})]})})}const w={edit:(0,l.withNotices)((({attributes:e,setAttributes:o})=>{const{categories:a,title:c,tags:p,morelink:w,moretext:b,rows:g,columns:h,template:x}=e,v=(0,r.useBlockProps)(),{rawCategories:_,rawTags:C}=(0,s.useSelect)((e=>{const o={per_page:-1,orderby:"count",order:"desc",_fields:["id","name","count"],hide_empty:!0};return{rawCategories:e("core").getEntityRecords("taxonomy","course-category",o)||[],rawTags:e("core").getEntityRecords("taxonomy","course-tag",o)||[]}}),[]),j=(0,i.useMemo)((()=>_.map((e=>({value:e.id,label:e.name})))),[_]),y=(0,i.useMemo)((()=>C.map((e=>({value:e.id,label:e.name})))),[C]),[T,k]=(0,i.useState)(null),[f,P]=(0,i.useState)(null),N=null!==T?T:j,D=null!==f?f:y,L=(0,u.jsxs)(i.Fragment,{children:[(0,u.jsx)(r.BlockControls,{children:(0,u.jsx)(m,{attributes:e,setAttributes:o})}),(0,u.jsx)(r.InspectorControls,{children:(0,u.jsxs)(l.PanelBody,{title:n.DD+(0,t.__)("Settings","mine-cloudvod"),children:[(0,u.jsx)(l.TextControl,{type:"string",label:(0,t.__)("Title","mine-cloudvod"),value:c,onChange:e=>o({title:e})}),!x&&(0,u.jsx)(l.TextControl,{type:"string",label:(0,t.__)("More Link","mine-cloudvod"),value:w,onChange:e=>o({morelink:e})}),!x&&(0,u.jsx)(l.TextControl,{type:"string",label:(0,t.__)("More Text","mine-cloudvod"),value:b,onChange:e=>o({moretext:e})}),(0,u.jsx)(l.ComboboxControl,{label:(0,t.__)("Categories","mine-cloudvod"),value:a,onChange:e=>{o({categories:e})},options:N,onInputChange:e=>{k(e?j.filter((o=>o.label.toLowerCase().startsWith(e.toLowerCase()))):null)}}),(0,u.jsx)(l.ComboboxControl,{label:(0,t.__)("Tags","mine-cloudvod"),value:p,onChange:e=>{o({tags:e})},options:D,onInputChange:e=>{P(e?y.filter((o=>o.label.toLowerCase().startsWith(e.toLowerCase()))):null)}})]})})]});return(0,u.jsxs)("div",{...v,children:[L,(0,u.jsx)(d(),{block:n.UU,attributes:e,LoadingResponsePlaceholder:()=>(0,u.jsx)("div",{className:"mine-cloudvod__placeholder is-loading",children:(0,u.jsx)("p",{children:(0,t.__)("Loading preview…","mine-cloudvod")})}),ErrorResponsePlaceholder:({error:e})=>(0,u.jsx)("div",{className:"mine-cloudvod__placeholder",children:(0,u.jsx)("p",{children:e||(0,t.__)("Error loading preview","mine-cloudvod")})})})]})})),save:function(){return null}};(0,o.registerBlockType)(n.UU,w)})();