import{g as e,f as t}from"./p-8a04cc92.js";const r=e=>!("isConnected"in e)||e.isConnected,n=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout(()=>{e=0,(e=>{for(let t of e.keys())e.set(t,e.get(t).filter(r))})(...t)},2e3)}})();let o;const s=r=>{var s;const i=window,a=new URL(i.location.href),l=null!==(s=null==r?void 0:r.parseURL)&&void 0!==s?s:c,{state:p,onChange:f,dispose:g}=((r,o)=>{const s=((e,t=((e,t)=>e!==t))=>{let r=new Map(Object.entries(null!=e?e:{}));const n={dispose:[],get:[],set:[],reset:[]},o=()=>{r=new Map(Object.entries(null!=e?e:{})),n.reset.forEach(e=>e())},s=e=>(n.get.forEach(t=>t(e)),r.get(e)),i=(e,o)=>{const s=r.get(e);t(o,s,e)&&(r.set(e,o),n.set.forEach(t=>t(e,o,s)))},a="undefined"==typeof Proxy?{}:new Proxy(e,{get:(e,t)=>s(t),ownKeys:()=>Array.from(r.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>r.has(t),set:(e,t,r)=>(i(t,r),!0)}),u=(e,t)=>(n[e].push(t),()=>{((e,t)=>{const r=e.indexOf(t);r>=0&&(e[r]=e[e.length-1],e.length--)})(n[e],t)});return{state:a,get:s,set:i,on:u,onChange:(t,r)=>{const n=u("set",(e,n)=>{e===t&&r(n)}),o=u("reset",()=>r(e[t]));return()=>{n(),o()}},use:(...e)=>e.forEach(e=>{e.set&&u("set",e.set),e.get&&u("get",e.get),e.reset&&u("reset",e.reset)}),dispose:()=>{n.dispose.forEach(e=>e()),o()},reset:o}})(r,o);return(({on:r})=>{const o=new Map;"function"==typeof e&&(r("dispose",()=>{o.clear()}),r("get",t=>{const r=e();r&&((e,t,r)=>{const n=e.get(t);n?n.includes(r)||n.push(r):e.set(t,[r])})(o,t,r)}),r("set",e=>{const r=o.get(e);r&&o.set(e,r.filter(t)),n(o)}),r("reset",()=>{o.forEach(e=>e.forEach(t)),n(o)}))})(s),s})({url:a,activePath:l(a)},(e,t,r)=>"url"===r?e.href!==t.href:e!==t),v=e=>{history.pushState(null,null,e);const t=new URL(e,document.baseURI);p.url=t,p.activePath=l(t)},d=e=>{const{activePath:t}=p;for(let r of e){const n=u(t,r.path);if(n)return null!=r.to?(v(r.to),d(e)):{params:n,route:r}}},w=()=>{const e=new URL(i.location.href);p.url=e,p.activePath=l(e)},y=o={Switch:(e,t)=>{const r=d(t);if(r)return"function"==typeof r.route.jsx?r.route.jsx(r.params):r.route.jsx},get url(){return p.url},get activePath(){return p.activePath},push:v,onChange:f,dispose:()=>{o=void 0,i.removeEventListener("popstate",w),g()}};return w(),i.addEventListener("popstate",w),y},i=(e,t)=>{var r;return"to"in e?{path:e.path,to:e.to}:{path:e.path,id:e.id,jsx:null!==(r=e.render)&&void 0!==r?r:t}},a=(e,t=o)=>({href:e,onClick:r=>{r.preventDefault(),t.push(e)}}),u=(e,t)=>{if("string"==typeof t){if(t===e)return{}}else if("function"==typeof t){const r=t(e);if(r)return!0===r?{}:{...r}}else{const r=t.exec(e);if(r)return t.lastIndex=0,{...r}}},c=e=>e.pathname.toLowerCase(),l=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g"),p=e=>e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),f=e=>e.replace(/([=!:$/()])/g,"\\$1"),g=e=>e&&e.sensitive?"":"i",v=(e,t,r)=>{for(var n=(r=r||{}).strict,o=!1!==r.end,s=p(r.delimiter||"/"),i=r.delimiters||"./",a=[].concat(r.endsWith||[]).map(p).concat("$").join("|"),u="",c=!1,l=0;l<e.length;l++){var f=e[l];if("string"==typeof f)u+=p(f),c=l===e.length-1&&i.indexOf(f[f.length-1])>-1;else{var v=p(f.prefix||""),d=f.repeat?"(?:"+f.pattern+")(?:"+v+"(?:"+f.pattern+"))*":f.pattern;t&&t.push(f),u+=f.optional?f.partial?v+"("+d+")?":"(?:"+v+"("+d+"))?":v+"("+d+")"}}return o?(n||(u+="(?:"+s+")?"),u+="$"===a?"$":"(?="+a+")"):(n||(u+="(?:"+s+"(?="+a+"))?"),c||(u+="(?="+s+"|"+a+")")),new RegExp("^"+u,g(r))},d=(e,t,r)=>e instanceof RegExp?((e,t)=>{if(!t)return e;var r=e.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)t.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e})(e,t):Array.isArray(e)?((e,t,r)=>{for(var n=[],o=0;o<e.length;o++)n.push(d(e[o],t,r).source);return new RegExp("(?:"+n.join("|")+")",g(r))})(e,t,r):((e,t,r)=>v(((e,t)=>{for(var r,n=[],o=0,s=0,i="",a=t&&t.delimiter||"/",u=t&&t.delimiters||"./",c=!1;null!==(r=l.exec(e));){var g=r[0],v=r[1],d=r.index;if(i+=e.slice(s,d),s=d+g.length,v)i+=v[1],c=!0;else{var w="",y=e[s],h=r[2],m=r[3],x=r[4],$=r[5];if(!c&&i.length){var R=i.length-1;u.indexOf(i[R])>-1&&(w=i[R],i=i.slice(0,R))}i&&(n.push(i),i="",c=!1);var P=w||a,C=m||x;n.push({name:h||o++,prefix:w,delimiter:P,optional:"?"===$||"*"===$,repeat:"+"===$||"*"===$,partial:""!==w&&void 0!==y&&y!==w,pattern:C?f(C):"[^"+p(P)+"]+?"})}}return(i||s<e.length)&&n.push(i+e.substr(s)),n})(e,r),t,r))(e,t,r);let w=0;const y={},h=(e,t={})=>{const{exact:r=!1,strict:n=!1}=t,{re:o,keys:s}=((e,t)=>{const r=`${t.end}${t.strict}`,n=y[r]||(y[r]={}),o=JSON.stringify(e);if(n[o])return n[o];const s=[],i={re:d(e,s,t),keys:s};return w<1e4&&(n[o]=i,w+=1),i})(e,{end:r,strict:n});return e=>{const t=o.exec(e);if(!t)return;const[n,...i]=t;return r&&e!==n?void 0:s.reduce((e,t,r)=>(e[t.name]=i[r],e),{})}};export{i as R,s as c,a as h,h as m}