text: function t(t,n){void 0===n&&(n={});for(var r=function(t){for(var e=[],n=0;n<t.length;){var r=t[n];if("*"!==r&&"+"!==r&&"?"!==r)if("\\"!==r)if("{"!==r)if("}"!==r)if(":"!==r)if("("!==r)e.push({type:"CHAR",index:n,value:t[n++]});else{var i=1,o="";if("?"===t[u=n+1])throw new TypeError('Pattern cannot start with "?" at '+u);for(;u<t.length;)if("\\"!==t[u]){if(")"===t[u]){if(0==--i){u++;break}}else if("("===t[u]&&(i++,"?"!==t[u+1]))throw new TypeError("Capturing groups are not allowed at "+u);o+=t[u++]}else o+=t[u++]+t[u++];if(i)throw new TypeError("Unbalanced pattern at "+n);if(!o)throw new TypeError("Missing pattern at "+n);e.push({type:"PATTERN",index:n,value:o}),n=u}else{for(var s="",u=n+1;u<t.length;){var a=t.charCodeAt(u);if(!(a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||95===a))break;s+=t[u++]}if(!s)throw new TypeError("Missing parameter name at "+n);e.push({type:"NAME",index:n,value:s}),n=u}else e.push({type:"CLOSE",index:n,value:t[n++]});else e.push({type:"OPEN",index:n,value:t[n++]});else e.push({type:"ESCAPED_CHAR",index:n++,value:t[n++]});else e.push({type:"MODIFIER",index:n,value:t[n++]})}return e.push({type:"END",index:n,value:""}),e}(t),i=n.prefixes,o=void 0===i?"./":i,s="[^"+e(n.delimiter||"/#?")+"]+?",u=[],a=0,h=0,l="",c=function(t){if(h<r.length&&r[h].type===t)return r[h++].value},d=function(t){var e=c(t);if(void 0!==e)return e;var n=r[h],i=n.type,o=n.index;throw new TypeError("Unexpected "+i+" at "+o+", expected "+t)},p=function(){for(var t,e="";t=c("CHAR")||c("ESCAPED_CHAR");)e+=t;return e};h<r.length;){var f=c("CHAR"),m=c("NAME"),v=c("PATTERN");if(m||v){var g=f||"";-1===o.indexOf(g)&&(l+=g,g=""),l&&(u.push(l),l=""),u.push({name:m||a++,prefix:g,suffix:"",pattern:v||s,modifier:c("MODIFIER")||""})}else{var y=f||c("ESCAPED_CHAR");if(y)l+=y;else if(l&&(u.push(l),l=""),c("OPEN")){g=p();var w=c("NAME")||"",b=c("PATTERN")||"",x=p();d("CLOSE"),u.push({name:w||(b?a++:""),pattern:w&&!b?s:b,prefix:g,suffix:x,modifier:c("MODIFIER")||""})}else d("END")}}return u}function e(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function n(t){return t&&t.sensitive?"":"i"}function r(r,i,o){return function(t,r,i){void 0===i&&(i={});for(var o=i.strict,s=void 0!==o&&o,u=i.start,a=void 0===u||u,h=i.end,l=void 0===h||h,c=i.encode,d=void 0===c?function(t){return t}:c,p="["+e(i.endsWith||"")+"]|$",f="["+e(i.delimiter||"/#?")+"]",m=a?"^":"",v=0,g=t;v<g.length;v++){var y=g[v];if("string"==typeof y)m+=e(d(y));else{var w=e(d(y.prefix)),b=e(d(y.suffix));if(y.pattern)if(r&&r.push(y),w||b)if("+"===y.modifier||"*"===y.modifier){var x="*"===y.modifier?"?":"";m+="(?:"+w+"((?:"+y.pattern+")(?:"+b+w+"(?:"+y.pattern+"))*)"+b+")"+x}else m+="(?:"+w+"("+y.pattern+")"+b+")"+y.modifier;else m+="("+y.pattern+")"+y.modifier;else m+="(?:"+w+b+")"+y.modifier}}if(l)s||(m+=f+"?"),m+=i.endsWith?"(?="+p+")":"$";else{var N=t[t.length-1],E="string"==typeof N?f.indexOf(N[N.length-1])>-1:void 0===N;s||(m+="(?:"+f+"(?="+p+"))?"),E||(m+="(?="+f+"|"+p+")")}return new RegExp(m,n(i))}(t(r,o),i,o)}function i(t,e,o){return t instanceof RegExp?function(t,e){if(!e)return t;for(var n=/\((?:\?<(.*?)>)?(?!\?)/g,r=0,i=n.exec(t.source);i;)e.push({name:i[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),i=n.exec(t.source);return t}(t,e):Array.isArray(t)?function(t,e,r){var o=t.map((function(t){return i(t,e,r).source}));return new RegExp("(?:"+o.join("|")+")",n(r))}(t,e,o):r(t,e,o)}class o extends class{constructor(){this._events={}}destroy(){this._events=null}addListener(t,e){return Object.prototype.hasOwnProperty.call(this._events,t)?this._events[t].indexOf(e)<0&&this._events[t].push(e):this._events[t]=[e],!0}removeListener(t,e){if(!Object.prototype.hasOwnProperty.call(this._events,t))return;if(this._events[t].length<=0)return;const n=this._events[t].indexOf(e);n>=0&&this._events[t].splice(n,1)}removeAllListeners(t){void 0===t&&(t=null),t&&!Object.prototype.hasOwnProperty.call(this._events,t)||delete this._events[t]}dispatch(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];Object.prototype.hasOwnProperty.call(this._events,t)&&(this._events[t].length<=0||this._events[t].forEach((t=>{t(...n)})))}}{constructor(t){void 0===t&&(t=null),super(),this._options=Object.assign({basePath:"",updateHistory:!1,pathToRegexp:{}},t),this._pathCurrent=null,this._routes={},this._routeCurrent=null}destroy(){this._options=null,this._pathCurrent=null,this._routeCurrent=null,this._routes=null,super.destroy()}getPath(){return this._pathCurrent}addRoute(t,e){void 0===e&&(e={});const n=i(t,[],e);this._routes[t]=t=>n.test(t),this.dispatch("added",{route:t,router:this})}removeRoute(t){delete this._routes[t]}getRoutes(){return Object.keys(this._routes)}push(t){const e=t.replace(this._options.basePath,"");if(this._pathCurrent===e)return!0;let n=null;for(const t in this._routes){if((0,this._routes[t])(e)){n=t;break}}if(!n)return!1;if(this._pathCurrent=e,this._routeCurrent=n,this._options.updateHistory&&"undefined"!=typeof window){const e=t.includes(this._options.basePath)?t:this._options.basePath+t;e!==window.history.location&&window.history.pushState(null,window.document.title,e)}return this.dispatch("pushed",{path:this._pathCurrent,router:this,route:this._routeCurrent}),!0}}var s=4;function u(t,e){t.firstChild&&(e.appendChild(t.firstChild),u(t,e))}function a(t){Array.from(t).forEach(h)}const h=t=>t&&t.parentNode&&t.parentNode.removeChild(t),l=(t,e)=>e&&e.parentNode&&e.parentNode.insertBefore(t,e),c=Symbol.for("pure"),d=Symbol("parent");function p(t,e){return typeof t===e}function f(t){const e=t.ownerSVGElement;return!!e||null===e}function m(t){return!y(t.content)}function v(t){return p(t,"function")}function g(t){return!y(t)&&p(t,"object")}function y(t){return null==t}const w=Symbol("unmount"),b={nodes:[],mount(t,e){return this.update(t,e)},update(t,e){const{placeholder:n,nodes:r,childrenMap:i}=this,o=t===w?null:this.evaluate(t),s=o?Array.from(o):[],{newChildrenMap:u,batches:a,futureNodes:c}=(n.parentNode,function(t,e,n,r){const{condition:i,template:o,childrenMap:s,itemName:u,getKey:a,indexName:h,root:l,isTemplateTag:c}=r,d=new Map,p=[],f=[];return t.forEach(((t,r)=>{const m=function(t,{itemName:e,indexName:n,index:r,item:i}){t[e]=i,n&&(t[n]=r);return t}(Object.create(e),{itemName:u,indexName:h,index:r,item:t}),v=a?a(m):r,g=s.get(v);if(function(t,e){return!!t&&!1===Boolean(t(e))}(i,m))return;const y=g?g.template:o.clone(),w=g?y.el:l.cloneNode(),b=!g,x=c&&b?function(t){const e=t.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:e,children:Array.from(e.childNodes)}}(y):{};if(b?p.push((()=>y.mount(w,m,n,x))):p.push((()=>y.update(m,n))),c){const t=x.children||y.children;f.push(...t)}else f.push(w);s.delete(v),d.set(v,{template:y,context:m,index:r})})),{newChildrenMap:d,batches:p,futureNodes:f}}(s,t,e,this));return((t,e,n,r,i)=>{const o=n.length;let s=e.length,u=o,a=0,c=0,d=null;for(;a<s||c<u;)if(s===a){const t=u<o?c?r(n[c-1],-0).nextSibling:r(n[u-c],0):i;for(;c<u;)l(r(n[c++],1),t)}else if(u===c)for(;a<s;)d&&d.has(e[a])||h(r(e[a],-1)),a++;else if(e[a]===n[c])a++,c++;else if(e[s-1]===n[u-1])s--,u--;else if(e[a]===n[u-1]&&n[c]===e[s-1]){const t=r(e[--s],-1).nextSibling;l(r(n[c++],1),r(e[a++],-1).nextSibling),l(r(n[--u],1),t),e[s]=n[u]}else{if(!d){d=new Map;let t=c;for(;t<u;)d.set(n[t],t++)}if(d.has(e[a])){const t=d.get(e[a]);if(c<t&&t<u){let i=a,o=1;for(;++i<s&&i<u&&d.get(e[i])===t+o;)o++;if(o>t-c){const i=r(e[a],0);for(;c<t;)l(r(n[c++],1),i)}else p=r(n[c++],1),(f=r(e[a++],-1))&&f.parentNode&&f.parentNode.replaceChild(p,f)}else a++}else h(r(e[a++],-1))}var p,f})(0,r,c,function(t,e){return(n,r)=>{if(r<0){const n=t.pop();if(n){const{template:t,context:r}=n;t.unmount(r,e,null)}}return n}}(Array.from(i.values()),e),n),a.forEach((t=>t())),this.childrenMap=u,this.nodes=c,this},unmount(t,e){return this.update(w,e),this}};const x={mount(t,e){return this.update(t,e)},update(t,e){const n=!!this.evaluate(t),r=!this.value&&n,i=this.value&&!n,o=()=>{const n=this.node.cloneNode();l(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,t,e)};switch(!0){case r:o();break;case i:this.unmount(t);break;default:n&&this.template.update(t,e)}return this.value=n,this},unmount(t,e){return this.template.unmount(t,e,!0),this}};const N="undefined"==typeof Element?{}:Element.prototype,E=function(t){const e=new Map,n=n=>(e.has(n)||e.set(n,t.call(this,n)))&&e.get(n);return n.cache=e,n}((t=>N.hasOwnProperty(t)));function C(t,{name:e},n,r){if(!e)return r&&function(t,e,n){const r=e?Object.keys(e):[];Object.keys(n).filter((t=>!r.includes(t))).forEach((e=>t.removeAttribute(e)))}(t,n,r),void(n&&function(t,e){Object.entries(e).forEach((([e,n])=>C(t,{name:e},n)))}(t,n));!E(e)&&(function(t){return p(t,"boolean")}(n)||g(n)||v(n))&&(t[e]=n),t[function(t){return y(t)||!1===t||""===t||g(t)||v(t)?"removeAttribute":"setAttribute"}(n)](e,function(t,e){return!0===e?t:e}(e,n))}const O=/^on/,_={handleEvent(t){this[t.type](t)}},A=new WeakMap;function T(t){return y(t)?"":t}const M=(t,e)=>{const n=t.childNodes[e];if(n.nodeType===Node.COMMENT_NODE){const e=document.createTextNode("");return t.replaceChild(e,n),e}return n};var R={0:C,1:function(t,{name:e},n){const r=e.replace(O,""),i=A.get(t)||(t=>{const e=Object.create(_);return A.set(t,e),e})(t),[o,s]=(t=>Array.isArray(t)?t:[t,!1])(n),u=i[r],a=o&&!u;u&&!o&&t.removeEventListener(r,i),a&&t.addEventListener(r,i,s),i[r]=o},2:function(t,e,n){t.data=T(n)},3:function(t,e,n){t.value=T(n)}};const P={mount(t){return this.value=this.evaluate(t),S(this,this.value),this},update(t){const e=this.evaluate(t);return this.value!==e&&(S(this,e),this.value=e),this},unmount(){return 1===this.type&&S(this,null),this}};function S(t,e){return R[t.type](t.node,t,e,t.value)}const D=(t,e)=>t[d]||e,j={attributes:[],getTemplateScope(t,e){return function(t,e,n){if(!t||!t.length)return n;const r=t.map((t=>({...t,value:t.evaluate(e)})));return Object.assign(Object.create(n||null),function(t){return t.reduce(((t,e)=>{const{value:n,type:r}=e;switch(!0){case!e.name&&0===r:return{...t,...n};case 3===r:t.value=e.value;break;default:t[(i=e.name,i.replace(/-(\w)/g,((t,e)=>e.toUpperCase())))]=e.value}var i;return t}),{})}(r))}(this.attributes,t,e)},mount(t,e){const n=!!t.slots&&t.slots.find((({id:t})=>t===this.name)),{parentNode:r}=this.node,i=D(t,e);return this.template=n&&K(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,this.getTemplateScope(t,i),i),this.template.children=Array.from(this.node.childNodes),k(this.node)),h(this.node),this},update(t,e){if(this.template){const n=D(t,e);this.template.update(this.getTemplateScope(t,n),n)}return this},unmount(t,e,n){return this.template&&this.template.unmount(this.getTemplateScope(t,e),null,n),this}};function k(t){const e=t&&t.firstChild;e&&(l(e,t),k(t))}function H(t){return t.reduce(((t,{bindings:e})=>t.concat(e)),[])}const I={mount(t){return this.update(t)},update(t,e){const n=this.evaluate(t);return n===this.name?this.tag.update(t):(this.unmount(t,e,!0),this.name=n,this.tag=function(t,e=[],n=[]){return t?t({slots:e,attributes:n}):K(function(t){return t.reduce(((t,e)=>t+e.html),"")}(e),[...H(e),{expressions:n.map((t=>({type:0,...t})))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,t)),this},unmount(t,e,n){return this.tag&&this.tag.unmount(n),this}};var L={1:function(t,{evaluate:e,template:n}){const r=document.createTextNode("");return l(r,t),h(t),{...x,node:t,evaluate:e,placeholder:r,template:n.createDOM(t)}},2:function(t,{expressions:e}){return{...(n=e.map((e=>function(t,e){return{...P,...e,node:2===e.type?M(t,e.childNodeIndex):t}}(t,e))),r=["mount","update","unmount"],r.reduce(((t,e)=>({...t,[e]:t=>n.map((n=>n[e](t)))&&i})),{}))};var n,r,i},0:function(t,{evaluate:e,condition:n,itemName:r,indexName:i,getKey:o,template:s}){const u=document.createTextNode(""),a=t.cloneNode();return l(u,t),h(t),{...b,childrenMap:new Map,node:t,root:a,condition:n,evaluate:e,isTemplateTag:m(a),template:s.createDOM(t),getKey:o,indexName:i,itemName:r,placeholder:u}},3:function(t,{evaluate:e,getComponent:n,slots:r,attributes:i}){return{...I,node:t,evaluate:e,slots:r,attributes:i,getComponent:n}},4:function(t,{name:e,attributes:n}){return{...j,attributes:n,node:t,name:e}}};function F(t,e){return t.map((t=>2===t.type?{...t,childNodeIndex:t.childNodeIndex+e}:t))}function B(t,e){return f(t)?function(t,e){return e.ownerDocument.importNode((new window.DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,"application/xml").documentElement,!0)}(e,t):function(t,e){const n=m(e)?e:document.createElement("template");return n.innerHTML=t,n.content}(e,t)}function U(t,e){switch(!0){case f(t):u(e,t);break;case m(t):t.parentNode.replaceChild(e,t);break;default:t.appendChild(e)}}const $=Object.freeze({createDOM(t){return this.dom=this.dom||function(t,e){return e&&("string"==typeof e?B(t,e):e)}(t,this.html),this},mount(t,e,n,r={}){if(!t)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(e);const{fragment:i,children:o,avoidDOMInjection:s}=r,{parentNode:u}=o?o[0]:t,a=m(t),h=a?Math.max(Array.from(u.childNodes).indexOf(t),0):null;return this.isTemplateTag=a,this.createDOM(t),this.dom&&(this.fragment=i||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?u:t,this.children=this.isTemplateTag?o||Array.from(this.fragment.childNodes):null,!s&&this.fragment&&U(t,this.fragment),this.bindings=this.bindingsData.map((t=>function(t,e,n){const{selector:r,type:i,redundantAttribute:o,expressions:s}=e,u=r?t.querySelector(r):t;o&&u.removeAttribute(o);const a=s||[];return(L[i]||L[2])(u,{...e,expressions:n&&!r?F(a,n):a})}(this.el,t,h))),this.bindings.forEach((t=>t.mount(e,n))),this},update(t,e){return this.bindings.forEach((n=>n.update(t,e))),this},unmount(t,e,n){if(this.el){switch(this.bindings.forEach((r=>r.unmount(t,e,n))),!0){case this.el[c]:break;case this.children&&null!==n:a(this.children);break;case!0===n:h(this.el);break;case null!==n:a(this.el.childNodes)}this.el=null}return this},clone(){return{...this,el:null}}});function K(t,e=[]){return{...$,html:t,bindingsData:e}}const W=function(t){return t[c]=!0,t},q=Symbol("riouter");var z={css:null,exports:W((({slots:t,attributes:e,props:n})=>{const r=t=>e&&e.find((e=>e.name===t));return{mount(e,n){if(t&&t.length){if(this.active=!1,this.el=this.root=e,this.state={},this.slot=K(null,[{type:s,name:"default"}]),this.router=n[q].router,this.route=this.root.getAttribute("path"),!this.route)throw new Error("No path found for route component.");this.router.addRoute(this.route),this.handleRouteChange=({route:t})=>{const e=this.route===t;this.active!==e&&(this.active=e,this.update(n))},this.router.addListener("pushed",this.handleRouteChange)}},update(e){if(this.active){const n=r("onBeforeMount");n&&n.evaluate(e)(this,this.router,this.route);const i=document.createElement("div");this.root.appendChild(i),this.slot.mount(i,{slots:t},e);const o=r("onMounted");o&&o.evaluate(e)(this,this.router,this.route)}else{const n=r("onBeforeUnmount");n&&n.evaluate(e)(this,this.router,this.route),this.slot.unmount({slots:t},e,!0);const i=r("onUnmounted");i&&i.evaluate(e)(this,this.router,this.route)}},unmount(...t){this.router.removeListener("pushed",this.handleRouteChange),this.router.removeRoute(this.route),this.slot.unmount(...t)}}})),template:null,name:"riouter-route"};const G=window.requestAnimationFrame||window.setTimeout,V=window.cancelAnimationFrame||window.clearTimeout;var J={css:null,exports:W((({slots:t,attributes:e,props:n})=>{const r=t=>e&&e.find((e=>e.name===t)),i=t=>{const e=r("base");return e?e.evaluate(t):window.location.protocol+"//"+window.location.host};return{mount(e,n){if(!t||!t.length)return;this.el=this.root=e,this.state={};let u=r("updateHistory");u=!!u&&!!u.evaluate(n),this.router=new o({basePath:i(),updateHistory:u}),this.router.push(window.location.href),this.slot=K(null,[{type:s,name:"default"}]),n[q]=this;const a=r("onBeforeStart");a&&a.evaluate(n)(this,this.router),this.slot.mount(this.root,{slots:t},n);const h=r("onStarted");h&&h.evaluate(n)(this,this.router)},unmount(...t){this.slot&&this.slot.unmount(...t),this.root.remove(),this.router.destroy()},update(t){this.slot&&(this.deferred&&V(this.deferred),this.deferred=G((()=>{this.slot.update({},this)})))}}})),template:null,name:"riouter-router"};export{o as Router,z as route,J as router};
  