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-DCi8lcS0.js";import{c as f}from"./clsx-eK3rPvPS-B-dksMZM.js";import{v as p}from"./href-C62X6aSC-DV3RKhNy.js";import{v as b}from"./label-pIlPsS_A-DDeB9XCl.js";import{v as m}from"./open-BKi_QyJH-CmZHliA9.js";import{n as k}from"./dev.utils-C7mSu-bP-DwZEltMr.js";const u=(e,t,i)=>{v(e,"_active",t,i)},E=class{constructor(e){o(this,e),this.groupId=`tree-group-${k()}`,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:"442889bb000355873e79c2df59cce348ed0afb0c",onSlotchange:this.handleSlotchange.bind(this)},a("li",{key:"ab695fb7c3857e493631704e56f86b6c6211ad9f",class:"kol-tree-item",style:{"--level":`${this.level}`}},a(r,{key:"ac9855976707c3665cb09f90af3a6ecd490bb653",class:f("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:"9122a46258722d8df6bc5423cf8ee8b9412c763b",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:"b6108f314822588593d7426ad43f3bddaf42ae3c",class:"kol-tree-item__text"},n))),a("ul",{key:"2ca328f5ca9dfc25264ac1cf5a05ebf9b8a47eb8",class:"kol-tree-item__children",hidden:!i||!l,role:"group",id:this.groupId},a("slot",{key:"756437d12f6ea52ef666a5813221d84b6b29c575"}))))}validateActive(e){u(this,e||!1)}validateLabel(e){b(this,e)}validateOpen(e){m(this,e)}validateHref(e){p(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 focus(){var e;return Promise.resolve((e=this.linkElement)===null||e===void 0?void 0:e.focus())}async focusLink(){return this.focus()}async handleExpandClick(e){var t;e.preventDefault(),await((t=this.linkElement)===null||t===void 0?void 0:t.focus()),await this.expand()}async expand(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!0}))}async handleCollapseClick(e){var t;e.preventDefault(),await((t=this.linkElement)===null||t===void 0?void 0:t.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-mSCH55fY.js.map
