import{r as o,h as a,j as r,i as h,H as c,as as d,g as _,m as f}from"./index-yJ8X--q8.js";import{v}from"./href-BKuPIzvr-BASTVtvj.js";import{v as p}from"./label-D3d1qqIG-BD7RiEyC.js";import{v as b}from"./open-8iQ59IbX-CrPgRlO_.js";import{n as m}from"./dev.utils-tIfWUJtH-D6CaU-xq.js";import{c as k}from"./clsx-eK3rPvPS-BT_IL7Fz.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const g=(e,t,i)=>{f(e,"_active",t,i)},E=class{constructor(e){o(this,e),this.groupId=`tree-group-${m()}`,this.state={_active:!1,_hasChildren:!1,_href:"",_label:"",_open:!1}}render(){const{_href:e,_active:t,_hasChildren:i,_open:l,_label:n}=this.state;return a(c,{key:"e0d63b982e56ef662c1420fc9ade69068b8a81ff",onSlotchange:this.handleSlotchange.bind(this)},a("li",{key:"7c2d91957ad2e92256d5bc8bcbfa003d830a3645",class:"kol-tree-item",style:{"--level":`${this.level}`}},a(r,{key:"7207fe34d30d14349d397fbd75ff2f0d16aa7086",class:k("kol-tree-item__link",{"kol-tree-item__link--first-level":this.level===0,"kol-tree-item__link--active":t}),_href:e,_label:"",_role:"treeitem",_tabIndex:t?0:-1,_ariaExpanded:i?l:void 0,_ariaOwns:i?this.groupId:void 0,ref:s=>this.linkElement=s},a("span",{key:"d959cfb814982fcbb72f89a7fea3e2b6031e7ab4",class:"kol-tree-item__link-inner",slot:"expert"},i?a("span",{class:"kol-tree-item__toggle-button",onClick:s=>l?void this.handleCollapseClick(s):void this.handleExpandClick(s)},a(h,{class:"kol-tree-item__toggle-button-icon",_icons:`codicon codicon-${l?"chevron-down":"chevron-right"}`,_label:""})):a("span",{class:"kol-tree-item__toggle-button-placeholder"}),a("span",{key:"2249d95f2466360ef113bb8f271d91d5b7ed88e4",class:"kol-tree-item__text"},n))),a("ul",{key:"1648a8aebf70ae58ad6068bf5192078de6d05cfd",class:"kol-tree-item__children",hidden:!i||!l,role:"group",id:this.groupId},a("slot",{key:"07aceb35f569834db39a1d9cfb18f80a5a9753e4"}))))}validateActive(e){g(this,e||!1)}validateLabel(e){p(this,e)}validateOpen(e){b(this,e)}validateHref(e){v(this,e)}componentWillLoad(){this.validateActive(this._active),this.validateLabel(this._label),this.validateOpen(this._open),this.validateHref(this._href),this.checkForChildren(),this.determineTreeItemDepth()}determineTreeItemDepth(){let e=0,t=this.host.parentNode.host.parentNode;for(;t!==null&&t.tagName.toLowerCase()!==d&&t!==document.body;)t=t.parentElement,e+=1;this.level=e}handleSlotchange(){this.checkForChildren()}checkForChildren(){var e,t;this.state=Object.assign(Object.assign({},this.state),{_hasChildren:!!(!((t=(e=this.host.querySelector("slot"))===null||e===void 0?void 0:e.assignedElements)===null||t===void 0)&&t.call(e).length)})}async focusLink(){await this.linkElement.kolFocus()}async handleExpandClick(e){e.preventDefault(),await this.linkElement.kolFocus(),await this.expand()}async expand(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!0}))}async handleCollapseClick(e){e.preventDefault(),this.linkElement.focus(),await this.collapse()}async collapse(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!1}))}async isOpen(){var e;return(e=this.state._open)!==null&&e!==void 0?e:!1}get host(){return _(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};export{E as kol_tree_item_wc};
//# sourceMappingURL=kol-tree-item-wc.entry-DxPzWGwa.js.map
