(function(){const component={name:"menu",version:[2,2,0],ccm:"https://ccmjs.github.io/ccm/versions/ccm-18.0.0.js",config:{html:{main:{id:"main",inner:[{id:"entries"},{id:"content"}]},entry:{id:"%id%",class:"entry",onclick:"%click%",inner:{class:"title"}}},css:["ccm.load","https://ccmjs.github.io/akless-components/menu/resources/default.css"],data:{store:["ccm.store"]}},Instance:function(){let $;this.init=(async()=>{if(!this.inner)return;const entries=[];[...this.inner.children].forEach(child=>{if(child.tagName&&child.tagName==="ENTRY")entries.push({title:child.getAttribute("title"),content:child.innerHTML})});this.data={entries:entries}});this.ready=(async()=>{$=this.ccm.helper;this.logger&&this.logger.log("ready",$.privatize(this,true))});this.start=(async()=>{const dataset=await $.dataset(this.data);this.logger&&this.logger.log("start",$.clone(dataset));$.setContent(this.element,$.html(this.html.main));const entries_elem=this.element.querySelector("#entries");const content_elem=this.element.querySelector("#content");const self=this;dataset.entries&&dataset.entries.forEach(renderMenuEntry);this.selected&&entries_elem.querySelectorAll(".entry")[this.selected-1].click();function renderMenuEntry(entry_data,i){if(typeof entry_data==="string")entry_data={title:entry_data};if(!entry_data.id)entry_data.id=`entry-${i+1}`;const entry_elem=$.html(self.html.entry,{id:entry_data.id,click:onClick});$.setContent(entry_elem.querySelector(".title"),$.html(entry_data.title));if(entry_data.disabled){entry_elem.disabled=true;entry_elem.classList.add("disabled");entry_elem.removeEventListener("click",onClick)}entries_elem.appendChild(entry_elem);async function onClick(){const selected=entry_elem.classList.contains("selected");let event_data={title:entry_data.title,id:entry_data.id,nr:i+1};self.logger&&self.logger.log("click",$.clone(event_data));const selected_entry=entries_elem.querySelector(".entry.selected");if(selected_entry)selected_entry.classList.remove("selected","active");if(!selected||!self.deselectable)entry_elem.classList.add("selected","active");self.deselectable&&$.setContent(content_elem,"");if(selected)return;await renderContent();performActions();async function renderContent(){entry_data.content=await $.solveDependency(entry_data.content);if(!entry_data.content)return;if($.isInstance(entry_data.content)){$.setContent(content_elem,entry_data.content.root);entry_data.content.parent=self;await entry_data.content.start()}else if(self.content)await self.content.start({root:content_elem,inner:entry_data.content});else $.setContent(content_elem,$.html(entry_data.content))}function performActions(){event_data=$.integrate(entry_data,event_data);event_data.content=content_elem;event_data.entry=entry_elem;delete event_data.actions;if(entry_data.actions)if(typeof entry_data.actions==="function")entry_data.actions($.clone(event_data),self);else entry_data.actions.forEach(action=>$.action([action[0],$.clone(event_data),self]));self.onclick&&$.action([self.onclick,$.clone(event_data),self])}}}})}};let b="ccm."+component.name+(component.version?"-"+component.version.join("."):"")+".js";if(window.ccm&&null===window.ccm.files[b])return window.ccm.files[b]=component;(b=window.ccm&&window.ccm.components[component.name])&&b.ccm&&(component.ccm=b.ccm);"string"===typeof component.ccm&&(component.ccm={url:component.ccm});let c=(component.ccm.url.match(/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/)||["latest"])[0];if(window.ccm&&window.ccm[c])window.ccm[c].component(component);else{var a=document.createElement("script");document.head.appendChild(a);component.ccm.integrity&&a.setAttribute("integrity",component.ccm.integrity);component.ccm.crossorigin&&a.setAttribute("crossorigin",component.ccm.crossorigin);a.onload=function(){window.ccm[c].component(component);document.head.removeChild(a)};a.src=component.ccm.url}})();