-
Notifications
You must be signed in to change notification settings - Fork 0
/
p-f5dab098.entry.js
5 lines (5 loc) · 1.17 KB
/
p-f5dab098.entry.js
1
2
3
4
5
/*!
* Built by BASIS
* Copyright BASIS International Ltd.
*/
import{r as t,h as s,g as o}from"./p-00e3df8e.js";const a=class{constructor(s){t(this,s),this.autoOpen=!0}handlePopstate(){var t;const s=`${location.pathname}${location.search}`,o=Array.from(this.el.querySelectorAll("dwc-app-nav-item"));for(const t of o){const o=t.path;t.selected=!(!o||!this.isMatch(o,s))}const a=o.filter((t=>t.selected))[0];if(a){const s=null===(t=null==a?void 0:a.parentElement)||void 0===t?void 0:t.closest("dwc-app-nav-item");s&&s.hasItems&&(s.selected=!0,this.autoOpen&&(s.opened=!0))}}componentDidLoad(){this.handlePopstate()}isMatch(t,s){const o=this.parseUrl(t),a=this.parseUrl(s),n=t=>t.replace(/^\/+|\/+$/g,"")||"/";return o.origin===a.origin&&n(o.pathname)===n(a.pathname)&&o.queryParams===a.queryParams}parseUrl(t){const s=new URL(t,"http://root"),o=[...s.searchParams.entries()].sort(((t,s)=>t[0].localeCompare(s[0]))).map((([t,s])=>`${t}=${s}`)).join("&");return{origin:s.origin,pathname:s.pathname,queryParams:o}}render(){return s("slot",{key:"d38fbf88bb3f0811df348db7daae273fae579509"})}get el(){return o(this)}};a.style=":host{display:block;margin:var(--dwc-space-s)}";export{a as dwc_app_nav}