/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */ const t=window.dsfr,e=t.internals.ns.selector("nav__item"),i=t.internals.ns.selector("collapse"),s={NAVIGATION:t.internals.ns.selector("nav"),COLLAPSE:`${e} > ${i}, ${e} > *:not(${e}):not(${i}) > ${i}, ${e} > *:not(${e}):not(${i}) > *:not(${e}):not(${i}) > ${i}`,COLLAPSE_LEGACY:`${e} ${i}`,ITEM:e,ITEM_RIGHT:`${e}--align-right`,MENU:t.internals.ns.selector("menu"),BUTTON:t.internals.ns.selector("nav__btn"),TRANSLATE_BUTTON:t.internals.ns.selector("translate__btn")};class n extends t.core.Instance{constructor(){super(),this._isRightAligned=!1}static get instanceClassName(){return"NavigationItem"}init(){this.addAscent(t.core.DisclosureEmission.ADDED,this.calculate.bind(this)),this.addAscent(t.core.DisclosureEmission.REMOVED,this.calculate.bind(this)),this.isResizing=!0,this.calculate()}resize(){this.calculate()}calculate(){const e=this.element.getDescendantInstances(t.core.Collapse.instanceClassName,null,!0)[0];if(e&&this.isBreakpoint(t.core.Breakpoints.LG)&&e.element.node.matches(s.MENU)){const t=this.element.node.parentElement.getBoundingClientRect().right,i=e.element.node.getBoundingClientRect().width,s=this.element.node.getBoundingClientRect().left;this.isRightAligned=s+i>t}else this.isRightAligned=!1}get isRightAligned(){return this._isRightAligned}set isRightAligned(e){this._isRightAligned!==e&&(this._isRightAligned=e,e?t.internals.dom.addClass(this.element.node,s.ITEM_RIGHT):t.internals.dom.removeClass(this.element.node,s.ITEM_RIGHT))}get collapsePrimary(){return this.element.children.map((t=>t.getInstance("CollapseButton"))).filter((t=>null!==t&&(t.hasClass(s.BUTTON)||t.hasClass(s.TRANSLATE_BUTTON))))[0]}}const a={NONE:-1,INSIDE:0,OUTSIDE:1};class o extends t.core.CollapsesGroup{static get instanceClassName(){return"Navigation"}init(){super.init(),this.clicked=!1,this.out=!1,this.addEmission(t.core.RootEmission.CLICK,this._handleRootClick.bind(this)),this.listen("mousedown",this.handleMouseDown.bind(this)),this.listenClick({capture:!0}),this.isResizing=!0}validate(e){return super.validate(e)&&e.element.node.matches(t.internals.legacy.isLegacy?s.COLLAPSE_LEGACY:s.COLLAPSE)}handleMouseDown(e){this.isBreakpoint(t.core.Breakpoints.LG)&&-1!==this.index&&this.current&&(this.position=this.current.node.contains(e.target)?a.INSIDE:a.OUTSIDE,this.requestPosition())}handleClick(e){!e.target.matches("a, button")||e.target.matches("[aria-controls]")||e.target.matches(t.core.DisclosureSelector.PREVENT_CONCEAL)||(this.index=-1)}_handleRootClick(e){this.isBreakpoint(t.core.Breakpoints.LG)&&(this.node.contains(e)||(this.out=!0,this.requestPosition()))}requestPosition(){this.isRequesting||(this.isRequesting=!0,this.request(this.getPosition.bind(this)))}getPosition(){if(this.out)switch(this.position){case a.OUTSIDE:this.index=-1;break;case a.INSIDE:this.current&&!this.current.node.contains(document.activeElement)&&this.current.focus();break;default:this.index>-1&&!this.current.hasFocus&&(this.index=-1)}this.request(this.requested.bind(this))}requested(){this.position=a.NONE,this.out=!1,this.isRequesting=!1}get index(){return super.index}set index(t){-1===t&&this.current&&this.current.hasFocus&&this.current.focus(),super.index=t}get canUngroup(){return!this.isBreakpoint(t.core.Breakpoints.LG)}resize(){this.update()}}t.navigation={Navigation:o,NavigationItem:n,NavigationMousePosition:a,NavigationSelector:s},t.internals.register(t.navigation.NavigationSelector.NAVIGATION,t.navigation.Navigation),t.internals.register(t.navigation.NavigationSelector.ITEM,t.navigation.NavigationItem); //# sourceMappingURL=navigation.module.min.js.map