import{r as o,h as a,j as r,i as c,H as h,aq as d,g as _,m as v}from"./index-BvWOSbaR.js";import{v as f}from"./href-zZq6HYWf-BvA5AGtT.js";import{v as p}from"./label-CdtNxOKu-BgP05vXh.js";import{v as b}from"./open-D9q98v46-B8F38PrN.js";import{n as m}from"./dev.utils-0SH3ep_K-BGa3ho47.js";import{c as k}from"./clsx-eK3rPvPS-BT_IL7Fz.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const g=(e,t,i)=>{v(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(h,{key:"59dba82967b79373a9b3eb040bb1fafed522060b",onSlotchange:this.handleSlotchange.bind(this)},a("li",{key:"214ebbe9b6850f2fde0f9e83bd0019feb6a62714",class:"kol-tree-item",style:{"--level":`${this.level}`}},a(r,{key:"25c19762e151a6628e6604ae656db511cf3bd2ef",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:"1d511401118ac91f1d23dab02a0ac21109a7cbe8",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(c,{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:"0b58755f14c8fff333a07c35c19b82d738512919",class:"kol-tree-item__text"},n))),a("ul",{key:"3477fcc73f76e6b5efa35cd17cea964977980245",class:"kol-tree-item__children",hidden:!i||!l,role:"group",id:this.groupId},a("slot",{key:"5c0e9ca02ee1b65e277d7e9e926d92466e6322a8"}))))}validateActive(e){g(this,e||!1)}validateLabel(e){p(this,e)}validateOpen(e){b(this,e)}validateHref(e){f(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-D3MtzjrC.js.map
