(()=>{"use strict";function e(t){var s,o,n="";if("string"==typeof t||"number"==typeof t)n+=t;else if("object"==typeof t)if(Array.isArray(t)){var r=t.length;for(s=0;s<r;s++)t[s]&&(o=e(t[s]))&&(n&&(n+=" "),n+=o)}else for(o in t)t[o]&&(n&&(n+=" "),n+=o);return n}const t=function(){for(var t,s,o=0,n="",r=arguments.length;o<r;o++)(t=arguments[o])&&(s=e(t))&&(n&&(n+=" "),n+=s);return n},s=window.wp.blocks,o=window.wp.blockEditor,n=window.wp.element,r=window.wp.data,i=window.wp.i18n,l=JSON.parse('{"UU":"mine-cloudvod/question-archive-template"}'),c=window.ReactJSXRuntime,d=[["mine-cloudvod/question-term-title"],["core/query"]];function a({classList:e}){const s=(0,o.useInnerBlocksProps)({className:t("wp-block-post",e)},{template:d,__unstableDisableLayoutClassNames:!0});return(0,c.jsx)("div",{...s})}const u=(0,n.memo)((function({blocks:e,blockContextId:s,classList:n,isHidden:r,setActiveBlockContextId:i}){const l=(0,o.__experimentalUseBlockPreview)({blocks:e,props:{className:t("wp-block-post",n)}}),d=()=>{i(s)},a={display:r?"none":void 0};return(0,c.jsx)("li",{...l,tabIndex:0,role:"button",onClick:d,onKeyPress:d,style:a})}));(0,s.registerBlockType)(l.UU,{edit:({attributes:e,setAttributes:t,clientId:s})=>{const[l,d]=(0,n.useState)(),p=(0,o.useBlockProps)(),{terms:m,blocks:k}=(0,r.useSelect)((e=>{const{getBlocks:t}=e(o.store);return{terms:e("core").getEntityRecords("taxonomy","question_category",{per_page:-1,hide_empty:!0})||[],blocks:t(s)}}),[]),w=(0,n.useMemo)((()=>m?.map((e=>{var t;return{termId:e.id,classList:null!==(t=e.class_list)&&void 0!==t?t:""}}))),[m]);return m?m.length?(0,c.jsx)(c.Fragment,{children:(0,c.jsx)("ul",{...p,children:w&&w.map(((e,t)=>{if(0==t)return(0,c.jsxs)(o.BlockContextProvider,{value:e,children:[e.termId===(l||w[0]?.termId)?(0,c.jsx)(a,{classList:e.classList}):null,(0,c.jsx)(u,{blocks:k,blockContextId:e.termId,classList:e.classList,setActiveBlockContextId:d,isHidden:e.termId===(l||w[0]?.termId)})]},e.termId)}))})}):(0,c.jsxs)("p",{...p,children:[" ",(0,i.__)("No results found.")]}):(0,c.jsx)("p",{...p,children:(0,c.jsx)(Spinner,{})})},save:()=>(0,c.jsx)(o.InnerBlocks.Content,{})})})();