"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./page-DeDqgvS7.cjs"),u=require("axios");exports.axios=void 0;const n=s=>{s.state&&a.setPage(s.state)};function p(...s){if(!exports.axios)throw new Error("Router not initialized!");const e=s.reduce((t,o)=>{const r=o(exports.axios.interceptors);return t.request=[...t.request,...r!=null&&r.request?[r.request]:[]],t.response=[...t.response,...r!=null&&r.response?[r.response]:[]],t},{request:[],response:[]});return()=>{e.request.forEach(t=>{var o;return(o=exports.axios)==null?void 0:o.interceptors.request.eject(t)}),e.response.forEach(t=>{var o;return(o=exports.axios)==null?void 0:o.interceptors.response.eject(t)})}}function c(){exports.axios=u.create(),exports.axios.reload=function(s){var e;return this({url:(e=a.getPage())==null?void 0:e.url,...s})},window.history.replaceState(a.getPage(),"",window.location.href),window.addEventListener("popstate",n),exports.axios.defaults.vortex=!0}function d(){window.removeEventListener("popstate",n),exports.axios=void 0}async function g(s,e="#app"){var r,i;if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("Root element not found!");const t=JSON.parse(((r=e.dataset)==null?void 0:r.page)??"null");if(!t)throw new Error("Initial page data not defined!");a.setPage(t),c();const o=await s(e,t,!!((i=e.dataset)!=null&&i.ssr));return()=>{o&&o(),d()}}exports.getPage=a.getPage;exports.setPage=a.setPage;exports.subscribe=a.subscribe;exports.createVortex=g;exports.install=p;