import{r as t,a as r,h as e,c as s}from"./p-5da71329.js";import{e as i,a as n}from"./p-e070304f.js";const a="/";const o="./";const c=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");const f=(t,r)=>{var e=[];var s=0;var i=0;var n="";var f=r&&r.delimiter||a;var h=r&&r.delimiters||o;var v=false;var p;while((p=c.exec(t))!==null){var g=p[0];var m=p[1];var d=p.index;n+=t.slice(i,d);i=d+g.length;if(m){n+=m[1];v=true;continue}var w="";var x=t[i];var y=p[2];var $=p[3];var b=p[4];var E=p[5];if(!v&&n.length){var R=n.length-1;if(h.indexOf(n[R])>-1){w=n[R];n=n.slice(0,R)}}if(n){e.push(n);n="";v=false}var S=w!==""&&x!==undefined&&x!==w;var O=E==="+"||E==="*";var j=E==="?"||E==="*";var T=w||f;var k=$||b;e.push({name:y||s++,prefix:w,delimiter:T,optional:j,repeat:O,partial:S,pattern:k?u(k):"[^"+l(T)+"]+?"})}if(n||i<t.length){e.push(n+t.substr(i))}return e};const l=t=>t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1");const u=t=>t.replace(/([=!:$/()])/g,"\\$1");const h=t=>t&&t.sensitive?"":"i";const v=(t,r)=>{if(!r)return t;var e=t.source.match(/\((?!\?)/g);if(e){for(var s=0;s<e.length;s++){r.push({name:s,prefix:null,delimiter:null,optional:false,repeat:false,partial:false,pattern:null})}}return t};const p=(t,r,e)=>{var s=[];for(var i=0;i<t.length;i++){s.push(d(t[i],r,e).source)}return new RegExp("(?:"+s.join("|")+")",h(e))};const g=(t,r,e)=>m(f(t,e),r,e);const m=(t,r,e)=>{e=e||{};var s=e.strict;var i=e.end!==false;var n=l(e.delimiter||a);var c=e.delimiters||o;var f=[].concat(e.endsWith||[]).map(l).concat("$").join("|");var u="";var v=false;for(var p=0;p<t.length;p++){var g=t[p];if(typeof g==="string"){u+=l(g);v=p===t.length-1&&c.indexOf(g[g.length-1])>-1}else{var m=l(g.prefix||"");var d=g.repeat?"(?:"+g.pattern+")(?:"+m+"(?:"+g.pattern+"))*":g.pattern;if(r)r.push(g);if(g.optional){if(g.partial){u+=m+"("+d+")?"}else{u+="(?:"+m+"("+d+"))?"}}else{u+=m+"("+d+")"}}}if(i){if(!s)u+="(?:"+n+")?";u+=f==="$"?"$":"(?="+f+")"}else{if(!s)u+="(?:"+n+"(?="+f+"))?";if(!v)u+="(?="+n+"|"+f+")"}return new RegExp("^"+u,h(e))};const d=(t,r,e)=>{if(t instanceof RegExp){return v(t,r)}if(Array.isArray(t)){return p(t,r,e)}return g(t,r,e)};let w=0;const x={};const y=1e4;const $=(t,r)=>{const e=`${r.end}${r.strict}`;const s=x[e]||(x[e]={});const i=JSON.stringify(t);if(s[i]){return s[i]}const n=[];const a=d(t,n,r);const o={re:a,keys:n};if(w<y){s[i]=o;w+=1}return o};const b=(t,r={})=>{if(typeof r==="string"){r={path:r}}const{path:e="/",exact:s=false,strict:i=false}=r;const{re:n,keys:a}=$(e,{end:s,strict:i});const o=n.exec(t);if(!o){return null}const[c,...f]=o;const l=t===c;if(s&&!l){return null}return{path:e,url:e==="/"&&c===""?"/":c,isExact:l,params:a.reduce(((t,r,e)=>{t[r.name]=f[e];return t}),{})}};const E=()=>((Math.random()*1e17).toString().match(/.{4}/g)||[]).join("-");const R=(t,r,e)=>b(t,{path:r,exact:e,strict:true});const S=t=>t.tagName==="STENCIL-ROUTE";let O=class{constructor(e){t(this,e);this.group=E();this.subscribers=[];this.queue=r(this,"queue")}componentWillLoad(){if(this.location!=null){this.regenerateSubscribers(this.location)}else{console.warn(`<animated-route-switch> requires the "location" prop in order to be wired to Stencil Router.`)}}async regenerateSubscribers(t){console.log(t);if(t==null){return}let r=-1;this.subscribers=Array.prototype.slice.call(this.el.children).filter(S).map(((e,s)=>{const i=R(t.pathname,e.url,e.exact);if(i&&r===-1){r=s}return{el:e,match:i}}));if(r===-1){return}if(this.activeIndex===r){this.subscribers[r].el.match=this.subscribers[r].match;return}this.prevIndex=this.activeIndex;this.activeIndex=r;const e=this.subscribers[this.prevIndex];if(e){await i(e.el)}const s=this.subscribers[this.activeIndex];if(typeof this.scrollTopOffset==="number"){s.el.scrollTopOffset=this.scrollTopOffset}s.el.group=this.group;s.el.match=s.match;s.el.componentUpdated=t=>{this.queue.write((()=>{this.subscribers.forEach(((t,r)=>{t.el.componentUpdated=undefined;if(r===this.activeIndex){t.el.style.display="";return n(t.el)}if(typeof this.scrollTopOffset==="number"){t.el.scrollTopOffset=this.scrollTopOffset}t.el.group=this.group;t.el.match=null;t.el.style.display="none"}))}));if(this.routeViewsUpdated){this.routeViewsUpdated(Object.assign({scrollTopOffset:this.scrollTopOffset},t))}}}render(){return e("slot",null)}get el(){return s(this)}static get watchers(){return{location:["regenerateSubscribers"]}}};export{O as animated_route_switch};
//# sourceMappingURL=p-c6d81a04.entry.js.map