// HashRouter.js Library for hash-based routing. // https://github.com/ahabra/hash-router // Copyright 2021 (C) Abdul Habra. Version 0.3.2. // Apache License Version 2.0 var HashRouter=(()=>{var h=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},k=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of B(t))!U.call(e,i)&&i!==r&&h(e,i,{get:()=>t[i],enumerable:!(n=I(t,i))||n.enumerable});return e};var G=e=>k(h({},"__esModule",{value:!0}),e);var _e={};z(_e,{createRouter:()=>We});var J=Object.defineProperty,a=(e,t)=>{for(var r in t)J(e,r,{get:t[r],enumerable:!0})},K={};a(K,{add:()=>me,all:()=>T,classPresentIf:()=>ye,createElement:()=>ce,createElements:()=>C,first:()=>oe,getAttributes:()=>ae,id:()=>ue,removeElements:()=>de,setContent:()=>ge,tag:()=>R});var Q={};a(Q,{equals:()=>N,forEachEntry:()=>y,has:()=>Y,isDate:()=>g,isFunction:()=>A,isInteger:()=>X,isNil:()=>V,isNumber:()=>O,isRegExp:()=>P,isString:()=>c});function V(e){return e==null}function c(e){return s(e,"String")}function A(e){return s(e,"Function")}function g(e){return s(e,"Date")}function O(e){return s(e,"Number")?Number.isNaN(e)?!1:Number.isFinite(e):!c(e)||(e=e.trim(),e==="")?!1:!isNaN(e)}function X(e){return O(e)?Number.isInteger(Number.parseFloat(e)):!1}function P(e){return s(e,"RegExp")}function s(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function y(e,t){if(!(!e||!t)){if(Array.isArray(e)){e.forEach((r,n)=>{t(n,r)});return}Object.entries(e).forEach(r=>t(r[0],r[1]))}}function Y(e,t){return!e||!t?!1:Object.prototype.hasOwnProperty.call(e,t)}function N(e,t){return e===t?!0:e===void 0||t===void 0?!1:Z(e,t)}function Z(e,t){return S(e)||S(t)?e===t:te(e,t)}var ee=new Set(["boolean","number","bigint","string","symbol"]);function S(e){return ee.has(typeof e)}function te(e,t){return re(e,t)?ne(e,t)?!0:ie(e,t):!1}function re(e,t){return L(e)===L(t)}function L(e){return Object.prototype.toString.call(e)}function ne(e,t){return g(e)&&g(t)?e.getTime()===t.getTime():!1}function ie(e,t){let r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(n=>N(e[n],t[n]))}function ue(e,t=document){return w(t)&&(t=t.shadowRoot),t.getElementById(e)}function T(e,t=document){return w(t)&&(t=t.shadowRoot),Array.from(t.querySelectorAll(e))}function oe(e,t=document){return w(t)&&(t=t.shadowRoot),e.includes("/")?se(e,t):t.querySelector(e)}function se(e,t){let r=e.split("/").map(n=>n.trim()).filter(n=>n.length>0);for(let n of r)if(t=fe(n,t),t===null)break;return t}function fe(e,t){return e==="shadowRoot"||e==="shadow-root"?t.shadowRoot:t.querySelector(e)}function w(e){return e&&e.shadowRoot&&e.tagName.includes("-")}function ae(e){let t={},r=e.attributes;if(!r||r.length===0)return t;for(let n=0;n${r}`}function le(e){let t=[];return y(e,(n,i)=>{t.push(`${n}="${i}"`)}),(t.length>0?" ":"")+t.join(" ")}var pe=new Set(["beforebegin","afterbegin","beforeend","afterend"]);function me(e,t,r="beforeend"){return r=r.toLowerCase(),pe.has(r)?(c(t)?e.insertAdjacentHTML(r,t):he(e,t,r),!0):!1}function he(e,t,r){Array.isArray(t)?t.forEach(n=>e.insertAdjacentElement(r,n)):e.insertAdjacentElement(r,t)}function ge(e,...t){e.innerHTML="",e.append(...t)}function de(e,t=document){T(e,t).forEach(n=>{n.parentNode.removeChild(n)})}function ye(e,t,r){if(!e)return;let n=r?"add":"remove";e.classList[n](t)}var o={};a(o,{endsWith:()=>j,indexOf:()=>E,indexOfFirstMatch:()=>we,indexOfLastMatch:()=>Ee,isEmpty:()=>l,removePrefix:()=>W,removeSuffix:()=>q,removeSurrounding:()=>ve,replaceAll:()=>M,replaceTemplate:()=>Le,startsWith:()=>$,strip:()=>Oe,stripEnd:()=>Ae,stripStart:()=>xe,substringAfter:()=>be,substringBefore:()=>Se,trim:()=>d});function E(e,t,r=0,n=!1){return e?n?e.toLowerCase().indexOf(t.toLowerCase(),r):e.indexOf(t,r):-1}function we(e,t){return!t||!e?-1:e.split("").findIndex(t)}function Ee(e,t){if(!t||!e)return-1;let r=e.split("");for(let n=r.length;n>=0;--n)if(t(r[n],n))return n;return-1}function $(e="",t=void 0,r=!1){if(r){let n=e.substring(0,t.length).toLowerCase();return t.toLowerCase()===n}return e.startsWith(t)}function j(e,t,r=!1){return r?e.toLowerCase().endsWith(t.toLowerCase()):e.endsWith(t)}function W(e,t,r=!1){return $(e,t,r)&&(e=e.substring(t.length)),e}function q(e,t,r=!1){return j(e,t,r)&&(e=e.substring(0,e.length-t.length)),e}function ve(e,t,r,n=!1){return q(W(e,t,n),r,n)}function be(e,t,r=!1){if(!t)return e;let n=E(e,t,0,r);return n<0?"":e.substring(n+t.length)}function Se(e,t,r=!1){if(!t)return"";let n=E(e,t,0,r);return n<0?e:e.substring(0,n)}function d(e){return l(e)?"":(c(e)||(e=String(e)),e.trim(e))}function l(e){return e==null||e===""}function M(e,t,r){if(A(String.prototype.replaceAll))return e.replaceAll(t,r);if(P(t))return e.replace(t,r);let n=new RegExp(t,"g");return e.replace(n,r)}function Le(e="",t={},r="${",n="}"){return y(t,(i,u)=>{u!==void 0&&(i=r+i+n,e=M(e,i,u))}),e}function xe(e,t=""){return l(e)?"":t?_(e,new Set(Array.from(t))):e}function _(e,t){for(let r=0;r=0;r--)if(!t.has(e.charAt(r)))return e.substring(0,r+1);return""}function Oe(e,t=""){if(e===void 0||e==="")return"";if(!t)return e;let r=new Set(Array.from(t));return e=_(e,r),e?H(e,r):""}var Pe={};a(Pe,{compareLines:()=>Ne});function Ne(e,t,{trim:r=!0,skipEmpty:n=!0,caseSensitive:i=!0}={trim:!0,skipEmpty:!0,caseSensitive:!0}){return e=x(e,{trim:r,skipEmpty:n}),t=x(t,{trim:r,skipEmpty:n}),e.length!==t.length?`t1 has ${e.length} lines(s) while t2 has ${t.length} line(s).`:Te(e,t,i)}function Te(e,t,r){for(let n=0;n0)return i}return""}function Ce(e,t,r,n){let i=n?e:e.toLowerCase(),u=n?t:t.toLowerCase();return i!==u?`Line #${r+1} mismatch. ${e} ${t}`:""}function x(e,{trim:t,skipEmpty:r}){return t&&(e=d(e)),e=e.split(` `),t&&(e=e.map(n=>d(n))),r&&(e=e.filter(n=>!!n)),e}function p(e){return e=o.substringAfter(e,"#"),f(e)}function f(e){return o.strip(e," /#")}var m=class{constructor(t){this.parts=Re(t)}isMatch(t,r={}){let n=F(t);if(this.parts.length!==n.length)return!1;for(let i=0;i$e(t))}function F(e){return f(e).split("/").map(t=>t.trim()).filter(t=>t.length>0)}function $e(e){if(e.startsWith(":"))return{type:"param",value:e.substring(1)};if(e.startsWith("[")&&e.endsWith("]")){let t=e.substring(1,e.length-1);return{type:"regex",value:new RegExp(t)}}return{type:"string",value:e}}function je(e,t){return e.type==="param"?!0:e.type==="string"?t===e.value:e.type==="regex"?e.value.test(t):!1}function We(){return new v}var v=class{constructor(){this.routes=[];let t=n=>D(n,this.routes),r=n=>D(n,this.routes,!0);window.addEventListener("hashchange",t,!1),window.addEventListener("load",r,!1)}add(t,r){this.routes.push({route:new m(t),handler:r})}go(t){t="#"+f(t);let n=o.substringBefore(window.location.href,"#")+t;window.history.pushState(null,null,t),window.location.href=n}};function D(e,t,r=!1){let n=qe(e,r);if(n===void 0)return;let i={},u=Me(t,n,i);u&&u(n,i)}function qe(e,t){if(t)return p(e.target.location.href);let r=p(e.oldURL),n=p(e.newURL);return r===n?void 0:n}function Me(e,t,r){let n=e.find(i=>i.route.isMatch(t,r));return n?n.handler:!1}return G(_e);})(); //# sourceMappingURL=HashRouter-script-min.js.map