/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as t,h as e,H as s,g as i}from"./index-a5e15b1e.js";import{av as a,v as h,n as l,aw as n}from"./index-c3ae175d.js";const o=class{constructor(e){t(this,e),this.state={_active:!1,_hasChildren:!1,_href:"",_label:"",_open:!1},this._active=void 0,this._label=void 0,this._open=void 0,this._href=void 0}render(){return e(s,{onSlotchange:this.handleSlotchange.bind(this)},e("li",{class:"tree-item"},e("kol-link",{class:{"tree-link":!0,active:Boolean(this.state._active)},_label:"",_href:this.state._href,ref:e=>this.linkElement=e,_tabIndex:this.state._active?0:-1},e("span",{slot:"expert"},this.state._hasChildren&&(this.state._open?e("span",{class:"toggle-button",onClick:e=>{this.handleCollapseClick(e)}},"-"):e("span",{class:"toggle-button",onClick:e=>{this.handleExpandClick(e)}},"+"))," ",this.state._label)),e("ul",{hidden:!this.state._hasChildren||!this.state._open,role:"group"},e("slot",null))))}validateActive(e){a(this,e||!1)}validateLabel(e){h(this,e)}validateOpen(e){l(this,e)}validateHref(e){n(this,e)}componentWillLoad(){this.validateActive(this._active),this.validateLabel(this._label),this.validateOpen(this._open),this.validateHref(this._href),this.checkForChildren()}handleSlotchange(){this.checkForChildren()}checkForChildren(){var e;this.state=Object.assign(Object.assign({},this.state),{_hasChildren:Boolean(null===(e=this.host.querySelector("slot"))||void 0===e?void 0:e.assignedElements().length)})}async focusLink(){this.linkElement.focus()}async handleExpandClick(e){e.preventDefault(),this.linkElement.focus(),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 null!==(e=this.state._open)&&void 0!==e&&e}get host(){return i(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};export{o as kol_tree_item_wc};