import{g as t,f as e}from"./p-1469ddb8.js";const n=(t,e,n)=>{const o=t.get(e);if(!o){t.set(e,[n])}else if(!o.includes(n)){o.push(n)}};const o=(t,e)=>{let n;return(...o)=>{if(n){clearTimeout(n)}n=setTimeout((()=>{n=0;t(...o)}),e)}};const s=t=>!("isConnected"in t)||t.isConnected;const r=o((t=>{for(let e of t.keys()){t.set(e,t.get(e).filter(s))}}),2e3);const c=()=>{if(typeof t!=="function"){return{}}const o=new Map;return{dispose:()=>o.clear(),get:e=>{const s=t();if(s){n(o,e,s)}},set:t=>{const n=o.get(t);if(n){o.set(t,n.filter(e))}r(o)},reset:()=>{o.forEach((t=>t.forEach(e)));r(o)}}};const u=(t,e=((t,e)=>t!==e))=>{let n=new Map(Object.entries(t!==null&&t!==void 0?t:{}));const o={dispose:[],get:[],set:[],reset:[]};const s=()=>{n=new Map(Object.entries(t!==null&&t!==void 0?t:{}));o.reset.forEach((t=>t()))};const r=()=>{o.dispose.forEach((t=>t()));s()};const c=t=>{o.get.forEach((e=>e(t)));return n.get(t)};const u=(t,s)=>{const r=n.get(t);if(e(s,r,t)){n.set(t,s);o.set.forEach((e=>e(t,s,r)))}};const f=typeof Proxy==="undefined"?{}:new Proxy(t,{get(t,e){return c(e)},ownKeys(t){return Array.from(n.keys())},getOwnPropertyDescriptor(){return{enumerable:true,configurable:true}},has(t,e){return n.has(e)},set(t,e,n){u(e,n);return true}});const l=(t,e)=>{o[t].push(e);return()=>{i(o[t],e)}};const a=(e,n)=>{const o=l("set",((t,o)=>{if(t===e){n(o)}}));const s=l("reset",(()=>n(t[e])));return()=>{o();s()}};const p=(...t)=>{const e=t.reduce(((t,e)=>{if(e.set){t.push(l("set",e.set))}if(e.get){t.push(l("get",e.get))}if(e.reset){t.push(l("reset",e.reset))}if(e.dispose){t.push(l("dispose",e.dispose))}return t}),[]);return()=>e.forEach((t=>t()))};const d=t=>{const e=n.get(t);o.set.forEach((n=>n(t,e,e)))};return{state:f,get:c,set:u,on:l,onChange:a,use:p,dispose:r,reset:s,forceUpdate:d}};const i=(t,e)=>{const n=t.indexOf(e);if(n>=0){t[n]=t[t.length-1];t.length--}};const f=(t,e)=>{const n=u(t,e);n.use(c());return n};const l=t=>{var e;const n=window;const o=new URL(n.location.href);const s=(e=t===null||t===void 0?void 0:t.parseURL)!==null&&e!==void 0?e:p;const{state:r,onChange:c,dispose:u}=f({url:o,activePath:s(o)},((t,e,n)=>{if(n==="url"){return t.href!==e.href}return t!==e}));const i=t=>{history.pushState(null,null,t);const e=new URL(t,document.baseURI);r.url=e;r.activePath=s(e)};const l=t=>{const{activePath:e}=r;for(let n of t){const o=a(e,n.path);if(o){if(n.to!=null){const o=typeof n.to==="string"?n.to:n.to(e);i(o);return l(t)}else{return{params:o,route:n}}}}return undefined};const d=()=>{const t=new URL(n.location.href);r.url=t;r.activePath=s(t)};const g=(t,e)=>{const n=l(e);if(n){if(typeof n.route.jsx==="function"){return n.route.jsx(n.params)}else{return n.route.jsx}}};const w=()=>{n.removeEventListener("popstate",d);u()};const y={Switch:g,get url(){return r.url},get activePath(){return r.activePath},push:i,onChange:c,dispose:w};d();n.addEventListener("popstate",d);return y};const a=(t,e)=>{if(typeof e==="string"){if(e===t){return{}}}else if(typeof e==="function"){const n=e(t);if(n){return n===true?{}:{...n}}}else{const n=e.exec(t);if(n){e.lastIndex=0;return{...n}}}return undefined};const p=t=>t.pathname.toLowerCase();const d=l();export{d as Router};
//# sourceMappingURL=index.esm.js.map