import{proxyCustomElement,HTMLElement,createEvent,h,Host}from"@stencil/core/internal/client";import{c as classnames}from"./index2.js";const vaSidenavSubmenuCss='button:not([disabled]):focus,select:not([disabled]):focus,a:not([disabled]):focus,h1:focus,input:not([disabled]):focus,textarea:not([disabled]):focus,#form-question [role=\'option\']:focus,*[tabindex]:focus,a.va-sidenav-submenu__link:focus{outline:2px solid var(--vads-color-action-focus-on-light);outline-offset:2px}:host{list-style-type:none;padding-left:0;margin:0;position:relative;display:block;height:100%}.va-sidenav-submenu__label{border-bottom:1px solid var(--vads-color-base-lightest);color:var(--vads-color-base);font-size:0.8625rem;font-weight:700;padding:0.7rem 1rem;padding-left:1rem;text-transform:uppercase}a:hover{background-color:var(--vads-color-base-lightest);-webkit-box-shadow:none;box-shadow:none}.va-sidenav-submenu__link{border-bottom:1px solid var(--vads-color-base-lightest);color:var(--vads-color-link);display:block;padding:0.7rem 1rem;padding-left:var(--va-sidenav-item-link-padding-left, 1rem);position:relative;text-decoration:none}.va-sidenav-submenu__link:focus{z-index:2}.va-sidenav-submenu__current-link{font-weight:var(--font-weight-bold)}.va-sidenav-submenu__current-link::after{background-color:var(--vads-color-link);content:"";display:block;position:absolute;bottom:0.25rem;top:0.25rem;width:0.25rem;left:0;z-index:1}::slotted(va-sidenav-item){--va-sidenav-item-link-padding-left:2rem}:host(.va-sidenav-submenu__current)::after{background-color:var(--vads-color-primary-lighter);content:"";display:block;position:absolute;bottom:0;top:0;width:0.25rem;left:0}',VaSidenavSubmenuStyle0=vaSidenavSubmenuCss,VaSidenavMenu=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.vaRouteChange=createEvent(this,"vaRouteChange",7),this.label=void 0,this.href=void 0,this.currentPage=void 0,this.routerLink=void 0,this.hasCurrentPageItem=!1,this.isCurrentPage=!1}componentWillLoad(){this.href&&this.currentPage&&(this.isCurrentPage=!0)}componentDidLoad(){setTimeout(()=>{this.checkForCurrentPageItem(),this.setupMutationObserver()},0)}disconnectedCallback(){this.mutationObserver&&this.mutationObserver.disconnect()}onSlotChange(){this.checkForCurrentPageItem(),this.mutationObserver&&(this.mutationObserver.disconnect(),this.setupMutationObserver())}setupMutationObserver(){var e;this.mutationObserver=new MutationObserver(e=>{e.some(e=>"attributes"===e.type&&"current-page"===e.attributeName)&&this.checkForCurrentPageItem()}),this.mutationObserver.observe(this.el,{attributes:!0,attributeFilter:["current-page"]});const t=null===(e=this.el.shadowRoot)||void 0===e?void 0:e.querySelector("slot");t&&t.assignedElements().forEach(e=>{this.mutationObserver.observe(e,{attributes:!0,attributeFilter:["current-page"]})})}handleClick(e){this.routerLink&&(e.preventDefault(),this.vaRouteChange.emit({href:this.href}))}isCurrentPageItem(e){return"va-sidenav-item"===e.tagName.toLowerCase()&&e.hasAttribute("current-page")&&"false"!==e.getAttribute("current-page")}checkForCurrentPageItem(){var e;const t=null===(e=this.el.shadowRoot)||void 0===e?void 0:e.querySelector("slot"),s=null==t?void 0:t.assignedElements();if(!t||!s||0===s.length)return this.isCurrentPage=this.href&&this.currentPage,void(this.hasCurrentPageItem=!1);let n=!1;s.forEach(e=>{this.isCurrentPageItem(e)&&(n=!0)}),this.hasCurrentPageItem=n,this.isCurrentPage=!n&&this.href&&this.currentPage}render(){const e=classnames({"va-sidenav-submenu__current":this.hasCurrentPageItem||this.isCurrentPage}),t=classnames({"va-sidenav-submenu__current-link":this.isCurrentPage,"va-sidenav-submenu__link":!0}),s=this.currentPage?"#content":this.href;return h(Host,{key:"f9716d8eca1cf5578a1cab6dc98bfe5b49ce059b",role:"listitem",class:e},this.href?h("a",{class:t,href:s,"aria-current":this.currentPage?"page":void 0,onClick:this.handleClick.bind(this)},this.label):h("div",{id:"va-sidenav-submenu__label",class:"va-sidenav-submenu__label"},this.label),h("div",{key:"b7c2130193bde42466b2fdbeffdd4135e90ab2ab",role:"list","aria-describedby":"va-sidenav-submenu__label"},h("slot",{key:"78d6d76b8c24dc8fc02c0b8867d67dbc52ee2f7d"})))}get el(){return this}static get style(){return VaSidenavSubmenuStyle0}},[1,"va-sidenav-submenu",{label:[1],href:[1],currentPage:[4,"current-page"],routerLink:[4,"router-link"],hasCurrentPageItem:[32],isCurrentPage:[32]},[[0,"slotchange","onSlotChange"]]]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["va-sidenav-submenu"].forEach(e=>{"va-sidenav-submenu"===e&&(customElements.get(e)||customElements.define(e,VaSidenavMenu))})}const VaSidenavSubmenu=VaSidenavMenu,defineCustomElement=defineCustomElement$1;export{VaSidenavSubmenu,defineCustomElement};