import{__exports as e}from"../../../../_virtual/router.js_commonjs-exports";import r from"../../node_modules/@babel/runtime/helpers/interopRequireWildcard.js";import t from"../../node_modules/@babel/runtime/helpers/interopRequireDefault.js";import o from"react";import"../next-server/lib/router/router.js";import"../next-server/lib/router-context.js";import"./with-router.js";import{__exports as a}from"../../../../_virtual/with-router.js_commonjs-exports";import{__exports as s}from"../../../../_virtual/router2.js_commonjs-exports";import{__exports as n}from"../../../../_virtual/router-context.js_commonjs-exports";var u=r,i=t;e.__esModule=!0,e.useRouter=function(){return l.default.useContext(f.RouterContext)},e.makePublicRouterInstance=function(e){const r=e,t={};for(const e of m)"object"!=typeof r[e]?t[e]=r[e]:t[e]=Object.assign(Array.isArray(r[e])?[]:{},r[e]);return t.events=c.default.events,d.forEach((e=>{t[e]=(...t)=>r[e](...t)})),t},e.createRouter=e.withRouter=e.default=void 0;var l=i(o),c=u(s);e.Router=c.default,e.NextRouter=c.NextRouter;var f=n,p=i(a);e.withRouter=p.default;const h={router:null,readyCallbacks:[],ready(e){if(this.router)return e();"undefined"!=typeof window&&this.readyCallbacks.push(e)}},m=["pathname","route","query","asPath","components","isFallback","basePath","locale","locales","defaultLocale","isReady","isPreview","isLocaleDomain"],d=["push","replace","reload","back","prefetch","beforePopState"];function b(){if(!h.router){throw new Error('No router instance found.\nYou should only use "next/router" inside the client side of your app.\n')}return h.router}Object.defineProperty(h,"events",{get:()=>c.default.events}),m.forEach((e=>{Object.defineProperty(h,e,{get:()=>b()[e]})})),d.forEach((e=>{h[e]=(...r)=>b()[e](...r)})),["routeChangeStart","beforeHistoryChange","routeChangeComplete","routeChangeError","hashChangeStart","hashChangeComplete"].forEach((e=>{h.ready((()=>{c.default.events.on(e,((...r)=>{const t=`on${e.charAt(0).toUpperCase()}${e.substring(1)}`,o=h;if(o[t])try{o[t](...r)}catch(e){console.error(`Error when running the Router event: ${t}`),console.error(`${e.message}\n${e.stack}`)}}))}))}));var _=h;e.default=_;e.createRouter=(...e)=>(h.router=new c.default(...e),h.readyCallbacks.forEach((e=>e())),h.readyCallbacks=[],h.router);
//# sourceMappingURL=router.js.map
