import{Router as t}from"../../../../@vaadin/router/dist/vaadin-router.js";import{autorun as e,toJS as o}from"../../../../mobx/dist/mobx.esm.js";import{store as s}from"./AppHaxStore.js";export class AppHaxRouter extends HTMLElement{static get tag(){return"app-hax-router"}constructor(){super();const a={};this.baseURI&&(a.baseUrl=this.baseURI),this.windowControllers=new AbortController,this.router=new t(this,a),e((()=>{this._updateRouter(o(s.routes))})),e((()=>{const t=o(s.manifest),e=o(s.AppHaxAPI.basePath);if(t&&t.items&&t.items.length>0){const o=t.items.map((t=>({path:t.slug.replace(e,""),slug:t.slug,name:t.id,component:`fake-${t.id}-e`})));s.routes=[...o].concat(s.baseRoutes)}}))}connectedCallback(){globalThis.addEventListener("vaadin-router-location-changed",this._routerLocationChanged.bind(this),{signal:this.windowControllers.signal})}disconnectedCallback(){this.windowControllers.abort()}_updateRouter(t){this.router.setRoutes([...t])}_routerLocationChanged(t){s.location=t.detail.location}}customElements.define(AppHaxRouter.tag,AppHaxRouter);