Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vaadin/router

Package Overview
Dependencies
Maintainers
15
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vaadin/router - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

dist/vaadin-router.d.ts

2

dist/vaadin-router.min.js

@@ -1,1 +0,1 @@

function t(t){return t=t||[],Array.isArray(t)?t:[t]}function e(t){return`[Vaadin.Router] ${t}`}const n="module",r="nomodule",o=[n,r];function i(t){if(!t.match(/.+\.[m]?js$/))throw new Error(e(`Unsupported type for bundle "${t}": .js or .mjs expected.`))}function s(t){if(!t||!l(t.path))throw new Error(e('Expected route config to be an object with a "path" string property, or an array of such objects'));const s=t.bundle,c=["component","redirect","bundle"];if(!(h(t.action)||Array.isArray(t.children)||h(t.children)||f(s)||c.some(e=>l(t[e]))))throw new Error(e(`Expected route config "${t.path}" to include either "${c.join('", "')}" `+'or "action" function but none found.'));if(s)if(l(s))i(s);else{if(!o.some(t=>t in s))throw new Error(e('Expected route bundle to include either "'+r+'" or "'+n+'" keys, or both'));o.forEach(t=>t in s&&i(s[t]))}t.redirect&&["bundle","component"].forEach(n=>{n in t&&console.warn(e(`Route config "${t.path}" has both "redirect" and "${n}" properties, `+`and "redirect" will always override the latter. Did you mean to only use "${n}"?`))})}function c(e){t(e).forEach(t=>s(t))}function u(t,e){let o=document.head.querySelector('script[src="'+t+'"][async]');return o||((o=document.createElement("script")).setAttribute("src",t),e===n?o.setAttribute("type",n):e===r&&o.setAttribute(r,""),o.async=!0),new Promise((t,e)=>{o.onreadystatechange=o.onload=(e=>{o.t=!0,t(e)}),o.onerror=(t=>{o.parentNode&&o.parentNode.removeChild(o),e(t)}),null===o.parentNode?document.head.appendChild(o):o.t&&t()})}function a(t,e){return!window.dispatchEvent(new CustomEvent(`vaadin-router-${t}`,{cancelable:"go"===t,detail:e}))}function f(t){return"object"==typeof t&&!!t}function h(t){return"function"==typeof t}function l(t){return"string"==typeof t}function d(t){const n=new Error(e(`Page not found (${t.pathname})`));return n.context=t,n.code=404,n}const p=new class{};function w(t){if(t.defaultPrevented)return;if(0!==t.button)return;if(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=t.target;const n=t.composedPath?t.composedPath():t.path||[];for(let t=0;t<n.length;t++){const r=n[t];if(r.nodeName&&"a"===r.nodeName.toLowerCase()){e=r;break}}for(;e&&"a"!==e.nodeName.toLowerCase();)e=e.parentNode;if(!e||"a"!==e.nodeName.toLowerCase())return;if(e.target&&"_self"!==e.target.toLowerCase())return;if(e.hasAttribute("download"))return;if(e.pathname===window.location.pathname&&""!==e.hash)return;if((e.origin||function(t){const e=t.port,n=t.protocol;return`${n}//${"http:"===n&&"80"===e||"https:"===n&&"443"===e?t.hostname:t.host}`}(e))!==window.location.origin)return;const{pathname:r,search:o,hash:i}=e;a("go",{pathname:r,search:o,hash:i})&&t.preventDefault()}const m={activate(){window.document.addEventListener("click",w)},inactivate(){window.document.removeEventListener("click",w)}};function v(t){if("vaadin-router-ignore"===t.state)return;const{pathname:e,search:n,hash:r}=window.location;a("go",{pathname:e,search:n,hash:r})}/Trident/.test(navigator.userAgent)&&!h(window.PopStateEvent)&&(window.PopStateEvent=function(t,e){e=e||{};var n=document.createEvent("Event");return n.initEvent(t,Boolean(e.bubbles),Boolean(e.cancelable)),n.state=e.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);const y={activate(){window.addEventListener("popstate",v)},inactivate(){window.removeEventListener("popstate",v)}};var b=S,g=P,E=function(t,e){return R(P(t,e))},$=R,_=k,x="/",O="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function P(t,e){for(var n,r=[],o=0,i=0,s="",c=e&&e.delimiter||x,u=e&&e.delimiters||O,a=!1;null!==(n=j.exec(t));){var f=n[0],h=n[1],l=n.index;if(s+=t.slice(i,l),i=l+f.length,h)s+=h[1],a=!0;else{var d="",p=t[i],w=n[2],m=n[3],v=n[4],y=n[5];if(!a&&s.length){var b=s.length-1;u.indexOf(s[b])>-1&&(d=s[b],s=s.slice(0,b))}s&&(r.push(s),s="",a=!1);var g=""!==d&&void 0!==p&&p!==d,E="+"===y||"*"===y,$="?"===y||"*"===y,_=d||c,P=m||v;r.push({name:w||o++,prefix:d,delimiter:_,optional:$,repeat:E,partial:g,pattern:P?C(P):"[^"+A(_)+"]+?"})}}return(s||i<t.length)&&r.push(s+t.substr(i)),r}function R(t){for(var e=new Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=new RegExp("^(?:"+t[n].pattern+")$"));return function(n,r){for(var o="",i=r&&r.encode||encodeURIComponent,s=0;s<t.length;s++){var c=t[s];if("string"!=typeof c){var u,a=n?n[c.name]:void 0;if(Array.isArray(a)){if(!c.repeat)throw new TypeError('Expected "'+c.name+'" to not repeat, but got array');if(0===a.length){if(c.optional)continue;throw new TypeError('Expected "'+c.name+'" to not be empty')}for(var f=0;f<a.length;f++){if(u=i(a[f],c),!e[s].test(u))throw new TypeError('Expected all "'+c.name+'" to match "'+c.pattern+'"');o+=(0===f?c.prefix:c.delimiter)+u}}else if("string"!=typeof a&&"number"!=typeof a&&"boolean"!=typeof a){if(!c.optional)throw new TypeError('Expected "'+c.name+'" to be '+(c.repeat?"an array":"a string"));c.partial&&(o+=c.prefix)}else{if(u=i(String(a),c),!e[s].test(u))throw new TypeError('Expected "'+c.name+'" to match "'+c.pattern+'", but got "'+u+'"');o+=c.prefix+u}}else o+=c}return o}}function A(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function C(t){return t.replace(/([=!:$/()])/g,"\\$1")}function T(t){return t&&t.sensitive?"":"i"}function k(t,e,n){for(var r=(n=n||{}).strict,o=!1!==n.start,i=!1!==n.end,s=A(n.delimiter||x),c=n.delimiters||O,u=[].concat(n.endsWith||[]).map(A).concat("$").join("|"),a=o?"^":"",f=0===t.length,h=0;h<t.length;h++){var l=t[h];if("string"==typeof l)a+=A(l),f=h===t.length-1&&c.indexOf(l[l.length-1])>-1;else{var d=l.repeat?"(?:"+l.pattern+")(?:"+A(l.delimiter)+"(?:"+l.pattern+"))*":l.pattern;e&&e.push(l),l.optional?l.partial?a+=A(l.prefix)+"("+d+")?":a+="(?:"+A(l.prefix)+"("+d+"))?":a+=A(l.prefix)+"("+d+")"}}return i?(r||(a+="(?:"+s+")?"),a+="$"===u?"$":"(?="+u+")"):(r||(a+="(?:"+s+"(?="+u+"))?"),f||(a+="(?="+s+"|"+u+")")),new RegExp(a,T(n))}function S(t,e,n){return t instanceof RegExp?function(t,e){if(!e)return t;var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return t}(t,e):Array.isArray(t)?function(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(S(t[o],e,n).source);return new RegExp("(?:"+r.join("|")+")",T(n))}(t,e,n):function(t,e,n){return k(P(t,n),e,n)}(t,e,n)}b.parse=g,b.compile=E,b.tokensToFunction=$,b.tokensToRegExp=_;const{hasOwnProperty:B}=Object.prototype,M=new Map;function U(t){try{return decodeURIComponent(t)}catch(e){return t}}function I(t,e,n,r,o){let i,s,c=0,u=t.path||"";return"/"===u.charAt(0)&&(n&&(u=u.substr(1)),n=!0),{next(a){if(t===a)return{done:!0};const f=t.o=t.o||t.children;if(!i&&(i=function(t,e,n,r,o){const i=`${t}|${n=!!n}`;let s=M.get(i);if(!s){const e=[];s={keys:e,pattern:b(t,e,{end:n,strict:""===t})},M.set(i,s)}const c=s.pattern.exec(e);if(!c)return null;const u=Object.assign({},o);for(let t=1;t<c.length;t++){const e=s.keys[t-1],n=e.name,r=c[t];void 0===r&&B.call(u,n)||(e.repeat?u[n]=r?r.split(e.delimiter).map(U):[]:u[n]=r?U(r):r)}return{path:c[0],keys:(r||[]).concat(s.keys),params:u}}(u,e,!f,r,o)))return{done:!1,value:{route:t,keys:i.keys,params:i.params,path:i.path}};if(i&&f)for(;c<f.length;){if(!s){const r=f[c];r.parent=t;let o=i.path.length;o>0&&"/"===e.charAt(o)&&(o+=1),s=I(r,e.substr(o),n,i.keys,i.params)}const r=s.next(a);if(!r.done)return{done:!1,value:r.value};s=null,c++}return{done:!0}}}}function L(t){if(h(t.route.action))return t.route.action(t)}M.set("|false",{keys:[],pattern:/(?:)/});class D{constructor(t,e={}){if(Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=e.baseUrl||"",this.errorHandler=e.errorHandler,this.resolveRoute=e.resolveRoute||L,this.context=Object.assign({resolver:this},e.context),this.root=Array.isArray(t)?{path:"",o:t,parent:null,i:!0}:t,this.root.parent=null}getRoutes(){return[...this.root.o]}setRoutes(e){c(e);const n=[...t(e)];this.root.o=n}addRoutes(e){return c(e),this.root.o.push(...t(e)),this.getRoutes()}removeRoutes(){this.setRoutes([])}resolve(t){const e=Object.assign({},this.context,l(t)?{pathname:t}:t),n=I(this.root,this.s(e.pathname),this.baseUrl),r=this.resolveRoute;let o=null,i=null,s=e;function c(t,u=o.value.route,a){const f=null===a&&o.value.route;return o=i||n.next(f),i=null,t||!o.done&&function(t,e){let n=e;for(;n;)if((n=n.parent)===t)return!0;return!1}(u,o.value.route)?o.done?Promise.reject(d(e)):(function(t,e){const{route:n,path:r}=e;if(n&&!n.i){const e={path:r,route:n};!function(t,e){return!e.parent||!t||!t.length||t[t.length-1].route!==e.parent}(t.chain,n)?t.chain.push(e):t.chain=[e]}}(e,o.value),s=Object.assign({},e,o.value),Promise.resolve(r(s)).then(e=>null!==e&&void 0!==e&&e!==p?(s.result=e.result||e,s):c(t,u,e))):(i=o,Promise.resolve(p))}return e.next=c,Promise.resolve().then(()=>c(!0,this.root)).catch(t=>{const e=function(t){let e=`Path '${t.pathname}' is not properly resolved due to an error.`;const n=(t.route||{}).path;return n&&(e+=` Resolution had failed on route: '${n}'`),e}(s);if(t?console.warn(e):t=new Error(e),t.context=t.context||s,t instanceof DOMException||(t.code=t.code||500),this.errorHandler)return s.result=this.errorHandler(t),s;throw t})}static u(t,e){return new URL(t,e)}get h(){return this.baseUrl?this.constructor.u(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\/]*$/,""):""}s(t){if(!this.baseUrl)return t;const e=this.h,n=this.constructor.u(t,e).href;return n.slice(0,e.length)===e?n.slice(e.length):void 0}}D.pathToRegexp=b;const{pathToRegexp:F}=D,N=new Map;function H(t,e){const n=t.get(e);if(n&&n.length>1)throw new Error(`Duplicate route with name "${e}".`+" Try seting unique 'name' route properties.");return n&&n[0]}function q(t){let e=t.path;return void 0!==(e=Array.isArray(e)?e[0]:e)?e:""}function z(t,e={}){if(!(t instanceof D))throw new TypeError("An instance of Resolver is expected");const n=new Map;return(r,o)=>{let i=H(n,r);if(!(i||(n.clear(),function t(e,n,r){const o=n.name||n.component;if(o&&(e.has(o)?e.get(o).push(n):e.set(o,[n])),Array.isArray(r))for(let o=0;o<r.length;o++){const i=r[o];i.parent=n,t(e,i,i.o||i.children)}}(n,t.root,t.root.o),i=H(n,r))))throw new Error(`Route "${r}" not found`);let s=N.get(i.fullPath);if(!s){let t=q(i),e=i.parent;for(;e;){const n=q(e);n&&(t=n.replace(/\/$/,"")+"/"+t.replace(/^\//,"")),e=e.parent}const n=F.parse(t),r=F.tokensToFunction(n),o=Object.create(null);for(let t=0;t<n.length;t++)l(n[t])||(o[n[t].name]=!0);s={toPath:r,keys:o},N.set(t,s),i.fullPath=t}let c=s.toPath(o,e)||"/";if(e.stringifyQueryParams&&o){const t={},n=Object.keys(o);for(let e=0;e<n.length;e++){const r=n[e];s.keys[r]||(t[r]=o[r])}const r=e.stringifyQueryParams(t);r&&(c+="?"===r.charAt(0)?r:`?${r}`)}return c}}let J=[];function K(t){J.forEach(t=>t.inactivate()),t.forEach(t=>t.activate()),J=t}const V=t=>{const e=getComputedStyle(t).getPropertyValue("animation-name");return e&&"none"!==e},W=(t,e)=>{const n=()=>{t.removeEventListener("animationend",n),e()};t.addEventListener("animationend",n)};function G(t,e){return t.classList.add(e),new Promise(n=>{if(V(t)){const r=t.getBoundingClientRect(),o=`height: ${r.bottom-r.top}px; width: ${r.right-r.left}px`;t.setAttribute("style",`position: absolute; ${o}`),W(t,()=>{t.classList.remove(e),t.removeAttribute("style"),n()})}else t.classList.remove(e),n()})}const Q=256;function X(t){return null!==t&&void 0!==t}function Y({pathname:t="",chain:e=[],params:n={},redirectFrom:r,resolver:o},i){const s=e.map(t=>t.route);return{baseUrl:o&&o.baseUrl||"",pathname:t,routes:s,route:i||s.length&&s[s.length-1]||null,params:n,redirectFrom:r,getUrl:(t={})=>rt(it.pathToRegexp.compile(ot(s))(Object.assign({},n,t)),o)}}function Z(t,e){const n=Object.assign({},t.params);return{redirect:{pathname:e,from:t.pathname,params:n}}}function tt(t,e,n){if(h(t))return t.apply(n,e)}function et(t,e,n){return r=>r&&(r.cancel||r.redirect)?r:n?tt(n[t],e,n):void 0}function nt(t){if(t&&t.length){const e=t[0].parentNode;for(let n=0;n<t.length;n++)e.removeChild(t[n])}}function rt(t,e){const n=e.h;return n?e.constructor.u(t.replace(/^\//,""),n).pathname:t}function ot(t){return t.map(t=>t.path).reduce((t,e)=>e.length?t.replace(/\/$/,"")+"/"+e.replace(/^\//,""):t,"")}class it extends D{constructor(t,e){const n=document.head.querySelector("base");super([],Object.assign({baseUrl:n&&n.getAttribute("href")},e)),this.resolveRoute=(t=>this.l(t));const r=it.NavigationTrigger;it.setTriggers.apply(it,Object.keys(r).map(t=>r[t])),this.baseUrl,this.ready,this.ready=Promise.resolve(t),this.location,this.location=Y({resolver:this}),this.p=0,this.m=this.v.bind(this),this.setOutlet(t),this.subscribe()}l(n){const r=n.route;let i=Promise.resolve();h(r.children)&&(i=i.then(()=>r.children(function(t){const e=Object.assign({},t);return delete e.next,e}(n))).then(n=>{X(n)||h(r.children)||(n=r.children),function(n,r){if(!Array.isArray(n)&&!f(n))throw new Error(e(`Incorrect "children" value for the route ${r.path}: expected array or object, but got ${n}`));r.o=[];const o=t(n);for(let t=0;t<o.length;t++)s(o[t]),r.o.push(o[t])}(n,r)}));const c={redirect:t=>Z(n,t),component:t=>document.createElement(t)};return i.then(()=>tt(r.action,[n,c],r)).then(t=>X(t)&&(t instanceof HTMLElement||t.redirect||t===p)?t:l(r.redirect)?c.redirect(r.redirect):r.bundle?(a=r.bundle,l(a)?u(a):Promise.race(o.filter(t=>t in a).map(t=>u(a[t],t)))).then(()=>{},()=>{throw new Error(e(`Bundle not found: ${r.bundle}. Check if the file name is correct`))}):void 0).then(t=>X(t)?t:l(r.component)?c.component(r.component):void 0);var a}setOutlet(t){t&&this.g(t),this.$=t}getOutlet(){return this.$}setRoutes(t){this._=void 0,super.setRoutes(t),this.v()}render(t,e){const n=++this.p,r=t.pathname||t,o=t.search||"",i=t.hash||"";return this.ready=this.resolve({pathname:r,search:o,hash:i}).then(t=>this.O(t)).then(t=>{if(n===this.p){const r=this.j;if(t===r)return this.location;this.location=Y(t),a("location-changed",{router:this,location:this.location}),e&&this.P(t,t.redirectFrom),this.R(t,r);const o=this.A(t);return this.C(t),this.T(t,r),o.then(()=>{if(n===this.p)return this.k(),this.j=t,this.location})}}).catch(t=>{if(n===this.p)throw e&&this.P({pathname:r,search:o,hash:i}),nt(this.$&&this.$.children),this.location=Y({pathname:r,resolver:this}),a("error",{router:this,error:t,pathname:r}),t}),this.ready}O(t,e=t){return this.S(e).then(n=>{const r=n!==e?n:t;return n.next().then(t=>{if(null===t||t===p){if(rt(ot(n.chain),n.resolver)!==n.pathname)throw d(r)}return t&&t!==p?this.O(r,t):this.B(n)})})}S(t){const n=t.result;return n instanceof HTMLElement?(function(t,e){e.location=Y(t);const n=t.chain.map(t=>t.route).indexOf(t.route);t.chain[n].element=e}(t,n),Promise.resolve(t)):n.redirect?this.M(n.redirect,t.U).then(t=>this.S(t)):n instanceof Error?Promise.reject(n):Promise.reject(new Error(e(`Invalid route resolution result for path "${t.pathname}". `+`Expected redirect object or HTML element, but got: "${function(t){if("object"!=typeof t)return String(t);const e=Object.prototype.toString.call(t).match(/ (.*)\]$/)[1];return"Object"===e||"Array"===e?`${e} ${JSON.stringify(t)}`:e}(n)}". `+"Double check the action return value for the route.")))}B(t){return this.I(t).then(e=>e===this.j||e===t?e:this.O(e))}I(t){const e=(this.j||{}).chain||[],n=t.chain;let r=Promise.resolve();const o=()=>({cancel:!0}),i=e=>Z(t,e);if(t.L=0,e.length){for(let r=0;r<Math.min(e.length,n.length)&&(e[r].route===n[r].route&&e[r].path===n[r].path&&(e[r].element&&e[r].element.localName)===(n[r].element&&n[r].element.localName));r=++t.L);for(let n=e.length-1;n>=t.L;n--){const i=Y(t);r=r.then(et("onBeforeLeave",[i,{prevent:o},this],e[n].element)).then(t=>{if(!(t||{}).redirect)return t})}}for(let e=t.L;e<n.length;e++){const s=Y(t,n[e].route);r=r.then(et("onBeforeEnter",[s,{prevent:o,redirect:i},this],n[e].element))}return r.then(e=>{if(e){if(e.cancel)return this.j;if(e.redirect)return this.M(e.redirect,t.U)}return t})}M(t,n){if(n>Q)throw new Error(e(`Too many redirects when rendering ${t.from}`));return this.resolve({pathname:this.urlForPath(t.pathname,t.params),redirectFrom:t.from,U:(n||0)+1})}g(t=this.$){if(!(t instanceof Node))throw new TypeError(e(`Expected router outlet to be a valid DOM Node (but got ${t})`))}P({pathname:t,search:e="",hash:n=""},r){if(window.location.pathname!==t||window.location.search!==e||window.location.hash!==n){const o=r?"replaceState":"pushState";window.history[o](null,document.title,t+e+n),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}R(t,e){this.g(),this.D();let n=this.$;for(let r=0;r<t.L;r++){const o=e&&e.chain[r].element;if(o){if(o.parentNode!==n)break;t.chain[r].element=o,n=o}}this.F=Array.from(n.children),this.N=[];let r=n;for(let e=t.L;e<t.chain.length;e++){const o=t.chain[e].element;o&&(r.appendChild(o),r===n&&this.N.push(o),r=o)}}k(){this.F&&nt(this.F),this.F=null,this.N=null}D(){this.F&&this.N&&(nt(this.N),this.F=null,this.N=null)}T(t,e){if(e)for(let n=e.chain.length-1;n>=t.L;n--){const r=e.chain[n].element;if(r)try{const n=Y(t);tt(r.onAfterLeave,[n,{},e.resolver],r)}finally{nt(r.children)}}}C(t){for(let e=t.L;e<t.chain.length;e++){const n=t.chain[e].element||{},r=Y(t,t.chain[e].route);tt(n.onAfterEnter,[r,{},t.resolver],n)}}A(t){const e=(this.F||[])[0],n=(this.N||[])[0],r=[],o=t.chain;let i;for(let t=o.length;t>0;t--)if(o[t-1].route.animate){i=o[t-1].route.animate;break}if(e&&n&&i){const t=f(i)&&i.leave||"leaving",o=f(i)&&i.enter||"entering";r.push(G(e,t)),r.push(G(n,o))}return Promise.all(r).then(()=>t)}subscribe(){window.addEventListener("vaadin-router-go",this.m)}unsubscribe(){window.removeEventListener("vaadin-router-go",this.m)}v(t){const e=t?t.detail.pathname:window.location.pathname;l(this.s(e))&&(t&&t.preventDefault&&t.preventDefault(),this.render(t?t.detail:{pathname:e},!0))}static setTriggers(...t){K(t)}urlForName(t,e){return this._||(this._=z(this)),rt(this._(t,e),this)}urlForPath(t,e){return rt(it.pathToRegexp.compile(t)(e),this)}static go(t){return a("go",{pathname:t})}}const st=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i,ct=window.Vaadin&&window.Vaadin.Flow&&window.Vaadin.Flow.clients;function ut(t,e){if("function"!=typeof t)return;const n=st.exec(t.toString());if(n)try{t=new Function(n[1])}catch(t){console.log("vaadin-development-mode-detector: uncommentAndRun() failed",t)}return t(e)}window.Vaadin=window.Vaadin||{};const at=function(t,e){if(window.Vaadin.developmentMode)return ut(t,e)};function ft(){}void 0===window.Vaadin.developmentMode&&(window.Vaadin.developmentMode=function(){try{return!!localStorage.getItem("vaadin.developmentmode.force")||["localhost","127.0.0.1"].indexOf(window.location.hostname)>=0&&(ct?!function(){if(ct){const t=Object.keys(ct).map(t=>ct[t]).filter(t=>t.productionMode);if(t.length>0)return!0}return!1}():!ut(function(){return!0}))}catch(t){return!1}}());window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0"}),at(ft),it.NavigationTrigger={POPSTATE:y,CLICK:m};export{D as Resolver,it as Router};
function t(t){return t=t||[],Array.isArray(t)?t:[t]}function e(t){return`[Vaadin.Router] ${t}`}const n="module",r="nomodule",o=[n,r];function i(t){if(!t.match(/.+\.[m]?js$/))throw new Error(e(`Unsupported type for bundle "${t}": .js or .mjs expected.`))}function s(t){if(!t||!l(t.path))throw new Error(e('Expected route config to be an object with a "path" string property, or an array of such objects'));const s=t.bundle,a=["component","redirect","bundle"];if(!(f(t.action)||Array.isArray(t.children)||f(t.children)||h(s)||a.some(e=>l(t[e]))))throw new Error(e(`Expected route config "${t.path}" to include either "${a.join('", "')}" `+'or "action" function but none found.'));if(s)if(l(s))i(s);else{if(!o.some(t=>t in s))throw new Error(e('Expected route bundle to include either "'+r+'" or "'+n+'" keys, or both'));o.forEach(t=>t in s&&i(s[t]))}t.redirect&&["bundle","component"].forEach(n=>{n in t&&console.warn(e(`Route config "${t.path}" has both "redirect" and "${n}" properties, `+`and "redirect" will always override the latter. Did you mean to only use "${n}"?`))})}function a(e){t(e).forEach(t=>s(t))}function c(t,e){let o=document.head.querySelector('script[src="'+t+'"][async]');return o||((o=document.createElement("script")).setAttribute("src",t),e===n?o.setAttribute("type",n):e===r&&o.setAttribute(r,""),o.async=!0),new Promise((t,e)=>{o.onreadystatechange=o.onload=(e=>{o.t=!0,t(e)}),o.onerror=(t=>{o.parentNode&&o.parentNode.removeChild(o),e(t)}),null===o.parentNode?document.head.appendChild(o):o.t&&t()})}function u(t,e){return!window.dispatchEvent(new CustomEvent(`vaadin-router-${t}`,{cancelable:"go"===t,detail:e}))}function h(t){return"object"==typeof t&&!!t}function f(t){return"function"==typeof t}function l(t){return"string"==typeof t}function d(t){const n=new Error(e(`Page not found (${t.pathname})`));return n.context=t,n.code=404,n}const p=new class{};function w(t){if(t.defaultPrevented)return;if(0!==t.button)return;if(t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)return;let e=t.target;const n=t.composedPath?t.composedPath():t.path||[];for(let t=0;t<n.length;t++){const r=n[t];if(r.nodeName&&"a"===r.nodeName.toLowerCase()){e=r;break}}for(;e&&"a"!==e.nodeName.toLowerCase();)e=e.parentNode;if(!e||"a"!==e.nodeName.toLowerCase())return;if(e.target&&"_self"!==e.target.toLowerCase())return;if(e.hasAttribute("download"))return;if(e.pathname===window.location.pathname&&""!==e.hash)return;if((e.origin||function(t){const e=t.port,n=t.protocol;return`${n}//${"http:"===n&&"80"===e||"https:"===n&&"443"===e?t.hostname:t.host}`}(e))!==window.location.origin)return;const{pathname:r,search:o,hash:i}=e;u("go",{pathname:r,search:o,hash:i})&&t.preventDefault()}const m={activate(){window.document.addEventListener("click",w)},inactivate(){window.document.removeEventListener("click",w)}};function v(t){if("vaadin-router-ignore"===t.state)return;const{pathname:e,search:n,hash:r}=window.location;u("go",{pathname:e,search:n,hash:r})}/Trident/.test(navigator.userAgent)&&!f(window.PopStateEvent)&&(window.PopStateEvent=function(t,e){e=e||{};var n=document.createEvent("Event");return n.initEvent(t,Boolean(e.bubbles),Boolean(e.cancelable)),n.state=e.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);const y={activate(){window.addEventListener("popstate",v)},inactivate(){window.removeEventListener("popstate",v)}};var b=M,g=R,E=function(t,e){return P(R(t,e))},_=P,$=T,x="/",O="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function R(t,e){for(var n,r=[],o=0,i=0,s="",a=e&&e.delimiter||x,c=e&&e.delimiters||O,u=!1;null!==(n=j.exec(t));){var h=n[0],f=n[1],l=n.index;if(s+=t.slice(i,l),i=l+h.length,f)s+=f[1],u=!0;else{var d="",p=t[i],w=n[2],m=n[3],v=n[4],y=n[5];if(!u&&s.length){var b=s.length-1;c.indexOf(s[b])>-1&&(d=s[b],s=s.slice(0,b))}s&&(r.push(s),s="",u=!1);var g=""!==d&&void 0!==p&&p!==d,E="+"===y||"*"===y,_="?"===y||"*"===y,$=d||a,R=m||v;r.push({name:w||o++,prefix:d,delimiter:$,optional:_,repeat:E,partial:g,pattern:R?k(R):"[^"+A($)+"]+?"})}}return(s||i<t.length)&&r.push(s+t.substr(i)),r}function P(t){for(var e=new Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=new RegExp("^(?:"+t[n].pattern+")$"));return function(n,r){for(var o="",i=r&&r.encode||encodeURIComponent,s=0;s<t.length;s++){var a=t[s];if("string"!=typeof a){var c,u=n?n[a.name]:void 0;if(Array.isArray(u)){if(!a.repeat)throw new TypeError('Expected "'+a.name+'" to not repeat, but got array');if(0===u.length){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to not be empty')}for(var h=0;h<u.length;h++){if(c=i(u[h],a),!e[s].test(c))throw new TypeError('Expected all "'+a.name+'" to match "'+a.pattern+'"');o+=(0===h?a.prefix:a.delimiter)+c}}else if("string"!=typeof u&&"number"!=typeof u&&"boolean"!=typeof u){if(!a.optional)throw new TypeError('Expected "'+a.name+'" to be '+(a.repeat?"an array":"a string"));a.partial&&(o+=a.prefix)}else{if(c=i(String(u),a),!e[s].test(c))throw new TypeError('Expected "'+a.name+'" to match "'+a.pattern+'", but got "'+c+'"');o+=a.prefix+c}}else o+=a}return o}}function A(t){return t.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function k(t){return t.replace(/([=!:$/()])/g,"\\$1")}function C(t){return t&&t.sensitive?"":"i"}function T(t,e,n){for(var r=(n=n||{}).strict,o=!1!==n.start,i=!1!==n.end,s=A(n.delimiter||x),a=n.delimiters||O,c=[].concat(n.endsWith||[]).map(A).concat("$").join("|"),u=o?"^":"",h=0===t.length,f=0;f<t.length;f++){var l=t[f];if("string"==typeof l)u+=A(l),h=f===t.length-1&&a.indexOf(l[l.length-1])>-1;else{var d=l.repeat?"(?:"+l.pattern+")(?:"+A(l.delimiter)+"(?:"+l.pattern+"))*":l.pattern;e&&e.push(l),l.optional?l.partial?u+=A(l.prefix)+"("+d+")?":u+="(?:"+A(l.prefix)+"("+d+"))?":u+=A(l.prefix)+"("+d+")"}}return i?(r||(u+="(?:"+s+")?"),u+="$"===c?"$":"(?="+c+")"):(r||(u+="(?:"+s+"(?="+c+"))?"),h||(u+="(?="+s+"|"+c+")")),new RegExp(u,C(n))}function M(t,e,n){return t instanceof RegExp?function(t,e){if(!e)return t;var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return t}(t,e):Array.isArray(t)?function(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(M(t[o],e,n).source);return new RegExp("(?:"+r.join("|")+")",C(n))}(t,e,n):function(t,e,n){return T(R(t,n),e,n)}(t,e,n)}b.parse=g,b.compile=E,b.tokensToFunction=_,b.tokensToRegExp=$;const{hasOwnProperty:S}=Object.prototype,B=new Map;function U(t){try{return decodeURIComponent(t)}catch(e){return t}}function I(t,e,n,r,o){let i,s,a=0,c=t.path||"";return"/"===c.charAt(0)&&(n&&(c=c.substr(1)),n=!0),{next(u){if(t===u)return{done:!0};const h=t.o=t.o||t.children;if(!i&&(i=function(t,e,n,r,o){const i=`${t}|${n=!!n}`;let s=B.get(i);if(!s){const e=[];s={keys:e,pattern:b(t,e,{end:n,strict:""===t})},B.set(i,s)}const a=s.pattern.exec(e);if(!a)return null;const c=Object.assign({},o);for(let t=1;t<a.length;t++){const e=s.keys[t-1],n=e.name,r=a[t];void 0===r&&S.call(c,n)||(e.repeat?c[n]=r?r.split(e.delimiter).map(U):[]:c[n]=r?U(r):r)}return{path:a[0],keys:(r||[]).concat(s.keys),params:c}}(c,e,!h,r,o)))return{done:!1,value:{route:t,keys:i.keys,params:i.params,path:i.path}};if(i&&h)for(;a<h.length;){if(!s){const r=h[a];r.parent=t;let o=i.path.length;o>0&&"/"===e.charAt(o)&&(o+=1),s=I(r,e.substr(o),n,i.keys,i.params)}const r=s.next(u);if(!r.done)return{done:!1,value:r.value};s=null,a++}return{done:!0}}}}function L(t){if(f(t.route.action))return t.route.action(t)}B.set("|false",{keys:[],pattern:/(?:)/});class D{constructor(t,e={}){if(Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=e.baseUrl||"",this.errorHandler=e.errorHandler,this.resolveRoute=e.resolveRoute||L,this.context=Object.assign({resolver:this},e.context),this.root=Array.isArray(t)?{path:"",o:t,parent:null,i:!0}:t,this.root.parent=null}getRoutes(){return[...this.root.o]}setRoutes(e){a(e);const n=[...t(e)];this.root.o=n}addRoutes(e){return a(e),this.root.o.push(...t(e)),this.getRoutes()}removeRoutes(){this.setRoutes([])}resolve(t){const e=Object.assign({},this.context,l(t)?{pathname:t}:t),n=I(this.root,this.s(e.pathname),this.baseUrl),r=this.resolveRoute;let o=null,i=null,s=e;function a(t,c=o.value.route,u){const h=null===u&&o.value.route;return o=i||n.next(h),i=null,t||!o.done&&function(t,e){let n=e;for(;n;)if((n=n.parent)===t)return!0;return!1}(c,o.value.route)?o.done?Promise.reject(d(e)):(function(t,e){const{route:n,path:r}=e;if(n&&!n.i){const e={path:r,route:n};!function(t,e){return!e.parent||!t||!t.length||t[t.length-1].route!==e.parent}(t.chain,n)?t.chain.push(e):t.chain=[e]}}(e,o.value),s=Object.assign({},e,o.value),Promise.resolve(r(s)).then(e=>null!==e&&void 0!==e&&e!==p?(s.result=e.result||e,s):a(t,c,e))):(i=o,Promise.resolve(p))}return e.next=a,Promise.resolve().then(()=>a(!0,this.root)).catch(t=>{const e=function(t){let e=`Path '${t.pathname}' is not properly resolved due to an error.`;const n=(t.route||{}).path;return n&&(e+=` Resolution had failed on route: '${n}'`),e}(s);if(t?console.warn(e):t=new Error(e),t.context=t.context||s,t instanceof DOMException||(t.code=t.code||500),this.errorHandler)return s.result=this.errorHandler(t),s;throw t})}static u(t,e){return new URL(t,e)}get h(){return this.baseUrl?this.constructor.u(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\/]*$/,""):""}s(t){if(!this.baseUrl)return t;const e=this.h,n=this.constructor.u(t,e).href;return n.slice(0,e.length)===e?n.slice(e.length):void 0}}D.pathToRegexp=b;const{pathToRegexp:F}=D,N=new Map;function H(t,e){const n=t.get(e);if(n&&n.length>1)throw new Error(`Duplicate route with name "${e}".`+" Try seting unique 'name' route properties.");return n&&n[0]}function W(t){let e=t.path;return void 0!==(e=Array.isArray(e)?e[0]:e)?e:""}function q(t,e={}){if(!(t instanceof D))throw new TypeError("An instance of Resolver is expected");const n=new Map;return(r,o)=>{let i=H(n,r);if(!(i||(n.clear(),function t(e,n,r){const o=n.name||n.component;if(o&&(e.has(o)?e.get(o).push(n):e.set(o,[n])),Array.isArray(r))for(let o=0;o<r.length;o++){const i=r[o];i.parent=n,t(e,i,i.o||i.children)}}(n,t.root,t.root.o),i=H(n,r))))throw new Error(`Route "${r}" not found`);let s=N.get(i.fullPath);if(!s){let t=W(i),e=i.parent;for(;e;){const n=W(e);n&&(t=n.replace(/\/$/,"")+"/"+t.replace(/^\//,"")),e=e.parent}const n=F.parse(t),r=F.tokensToFunction(n),o=Object.create(null);for(let t=0;t<n.length;t++)l(n[t])||(o[n[t].name]=!0);s={toPath:r,keys:o},N.set(t,s),i.fullPath=t}let a=s.toPath(o,e)||"/";if(e.stringifyQueryParams&&o){const t={},n=Object.keys(o);for(let e=0;e<n.length;e++){const r=n[e];s.keys[r]||(t[r]=o[r])}const r=e.stringifyQueryParams(t);r&&(a+="?"===r.charAt(0)?r:`?${r}`)}return a}}let z=[];function J(t){z.forEach(t=>t.inactivate()),t.forEach(t=>t.activate()),z=t}const K=t=>{const e=getComputedStyle(t).getPropertyValue("animation-name");return e&&"none"!==e},V=(t,e)=>{const n=()=>{t.removeEventListener("animationend",n),e()};t.addEventListener("animationend",n)};function G(t,e){return t.classList.add(e),new Promise(n=>{if(K(t)){const r=t.getBoundingClientRect(),o=`height: ${r.bottom-r.top}px; width: ${r.right-r.left}px`;t.setAttribute("style",`position: absolute; ${o}`),V(t,()=>{t.classList.remove(e),t.removeAttribute("style"),n()})}else t.classList.remove(e),n()})}const Q=256;function X(t){return null!==t&&void 0!==t}function Y({pathname:t="",search:e="",hash:n="",chain:r=[],params:o={},redirectFrom:i,resolver:s},a){const c=r.map(t=>t.route);return{baseUrl:s&&s.baseUrl||"",pathname:t,search:e,hash:n,routes:c,route:a||c.length&&c[c.length-1]||null,params:o,redirectFrom:i,getUrl:(t={})=>rt(it.pathToRegexp.compile(ot(c))(Object.assign({},o,t)),s)}}function Z(t,e){const n=Object.assign({},t.params);return{redirect:{pathname:e,from:t.pathname,params:n}}}function tt(t,e,n){if(f(t))return t.apply(n,e)}function et(t,e,n){return r=>r&&(r.cancel||r.redirect)?r:n?tt(n[t],e,n):void 0}function nt(t){if(t&&t.length){const e=t[0].parentNode;for(let n=0;n<t.length;n++)e.removeChild(t[n])}}function rt(t,e){const n=e.h;return n?e.constructor.u(t.replace(/^\//,""),n).pathname:t}function ot(t){return t.map(t=>t.path).reduce((t,e)=>e.length?t.replace(/\/$/,"")+"/"+e.replace(/^\//,""):t,"")}class it extends D{constructor(t,e){const n=document.head.querySelector("base");super([],Object.assign({baseUrl:n&&n.getAttribute("href")},e)),this.resolveRoute=(t=>this.l(t));const r=it.NavigationTrigger;it.setTriggers.apply(it,Object.keys(r).map(t=>r[t])),this.baseUrl,this.ready,this.ready=Promise.resolve(t),this.location,this.location=Y({resolver:this}),this.p=0,this.m=this.v.bind(this),this.setOutlet(t),this.subscribe(),this.g=new WeakMap}l(n){const r=n.route;let i=Promise.resolve();f(r.children)&&(i=i.then(()=>r.children(function(t){const e=Object.assign({},t);return delete e.next,e}(n))).then(n=>{X(n)||f(r.children)||(n=r.children),function(n,r){if(!Array.isArray(n)&&!h(n))throw new Error(e(`Incorrect "children" value for the route ${r.path}: expected array or object, but got ${n}`));r.o=[];const o=t(n);for(let t=0;t<o.length;t++)s(o[t]),r.o.push(o[t])}(n,r)}));const a={redirect:t=>Z(n,t),component:t=>{const e=document.createElement(t);return this.g.set(e,!0),e}};return i.then(()=>tt(r.action,[n,a],r)).then(t=>X(t)&&(t instanceof HTMLElement||t.redirect||t===p)?t:l(r.redirect)?a.redirect(r.redirect):r.bundle?(u=r.bundle,l(u)?c(u):Promise.race(o.filter(t=>t in u).map(t=>c(u[t],t)))).then(()=>{},()=>{throw new Error(e(`Bundle not found: ${r.bundle}. Check if the file name is correct`))}):void 0).then(t=>X(t)?t:l(r.component)?a.component(r.component):void 0);var u}setOutlet(t){t&&this._(t),this.$=t}getOutlet(){return this.$}setRoutes(t,e=!1){return this.O=void 0,this.j=void 0,super.setRoutes(t),e||this.v(),this.ready}render(t,e){const n=++this.p,{pathname:r,search:o,hash:i}=l(t)?{pathname:t,search:"",hash:""}:t;return this.ready=this.resolve({pathname:r,search:o,hash:i}).then(t=>this.R(t)).then(t=>{if(n===this.p){const r=this.O;if(t===r)return this.P(r,!0),this.location;if(this.location=Y(t),u("location-changed",{router:this,location:this.location}),e&&this.P(t,t.redirectFrom),t.A)return this.location;this.k(t,r);const o=this.C(t);return this.T(t),this.M(t,r),o.then(()=>{if(n===this.p)return this.S(),this.O=t,this.location})}}).catch(t=>{if(n===this.p)throw e&&this.P({pathname:r,search:o,hash:i}),nt(this.$&&this.$.children),this.location=Y({pathname:r,resolver:this}),u("error",{router:this,error:t,pathname:r}),t}),this.ready}R(t,e=t){return this.B(e).then(n=>{const r=n!==e?n:t;return n.next().then(t=>{if(null===t||t===p){if(rt(ot(n.chain),n.resolver)!==n.pathname)throw d(r)}return t&&t!==p?this.R(r,t):this.U(n)})})}B(t){const n=t.result;return n instanceof HTMLElement?(function(t,e){e.location=Y(t);const n=t.chain.map(t=>t.route).indexOf(t.route);t.chain[n].element=e}(t,n),Promise.resolve(t)):n.redirect?this.I(n.redirect,t.L).then(t=>this.B(t)):n instanceof Error?Promise.reject(n):Promise.reject(new Error(e(`Invalid route resolution result for path "${t.pathname}". `+`Expected redirect object or HTML element, but got: "${function(t){if("object"!=typeof t)return String(t);const e=Object.prototype.toString.call(t).match(/ (.*)\]$/)[1];return"Object"===e||"Array"===e?`${e} ${JSON.stringify(t)}`:e}(n)}". `+"Double check the action return value for the route.")))}U(t){return this.D(t).then(e=>e===this.O||e===t?e:this.R(e))}D(t){const e=this.O||{},n=e.chain||[],r=t.chain;let o=Promise.resolve();const i=()=>({cancel:!0}),s=e=>Z(t,e);if(t.F=0,t.A=!1,n.length){for(let e=0;e<Math.min(n.length,r.length)&&(n[e].route===r[e].route&&(n[e].path===r[e].path||n[e].element===r[e].element)&&this.N(n[e].element,r[e].element));e=++t.F);t.A=r.length===n.length&&t.F==r.length&&this.N(t.result,e.result);for(let e=n.length-1;!t.A&&e>=t.F;e--){const r=Y(t);o=o.then(et("onBeforeLeave",[r,{prevent:i},this],n[e].element)).then(t=>{if(!(t||{}).redirect)return t})}}for(let e=t.F;!t.A&&e<r.length;e++){const n=Y(t,r[e].route);o=o.then(et("onBeforeEnter",[n,{prevent:i,redirect:s},this],r[e].element))}return o.then(e=>{if(e){if(e.cancel)return this.O;if(e.redirect)return this.I(e.redirect,t.L)}return t})}N(t,e){return!(!t||!e)&&(this.g.get(e)?t.localName===e.localName:t===e)}I(t,n){if(n>Q)throw new Error(e(`Too many redirects when rendering ${t.from}`));return this.resolve({pathname:this.urlForPath(t.pathname,t.params),redirectFrom:t.from,L:(n||0)+1})}_(t=this.$){if(!(t instanceof Node))throw new TypeError(e(`Expected router outlet to be a valid DOM Node (but got ${t})`))}P({pathname:t,search:e="",hash:n=""},r){if(window.location.pathname!==t||window.location.search!==e||window.location.hash!==n){const o=r?"replaceState":"pushState";window.history[o](null,document.title,t+e+n),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}k(t,e){this._(),this.H();let n=this.$;for(let r=0;r<t.F;r++){const o=e&&e.chain[r].element;if(o){if(o.parentNode!==n)break;t.chain[r].element=o,n=o}}this.W=[],this.q=Array.from(n.children).filter(e=>e!==t.result);let r=n;for(let e=t.F;e<t.chain.length;e++){const o=t.chain[e].element;o&&(r.appendChild(o),r===n&&this.W.push(o),r=o)}}S(){this.q&&nt(this.q),this.q=null,this.W=null}H(){this.q&&this.W&&(nt(this.W),this.q=null,this.W=null)}M(t,e){if(e)for(let n=e.chain.length-1;n>=t.F;n--){const r=e.chain[n].element;if(r)try{const n=Y(t);tt(r.onAfterLeave,[n,{},e.resolver],r)}finally{this.q.indexOf(r)>-1&&nt(r.children)}}}T(t){for(let e=t.F;e<t.chain.length;e++){const n=t.chain[e].element||{},r=Y(t,t.chain[e].route);tt(n.onAfterEnter,[r,{},t.resolver],n)}}C(t){const e=(this.q||[])[0],n=(this.W||[])[0],r=[],o=t.chain;let i;for(let t=o.length;t>0;t--)if(o[t-1].route.animate){i=o[t-1].route.animate;break}if(e&&n&&i){const t=h(i)&&i.leave||"leaving",o=h(i)&&i.enter||"entering";r.push(G(e,t)),r.push(G(n,o))}return Promise.all(r).then(()=>t)}subscribe(){window.addEventListener("vaadin-router-go",this.m)}unsubscribe(){window.removeEventListener("vaadin-router-go",this.m)}v(t){const{pathname:e,search:n,hash:r}=t?t.detail:window.location;l(this.s(e))&&(t&&t.preventDefault&&t.preventDefault(),this.render({pathname:e,search:n,hash:r},!0))}static setTriggers(...t){J(t)}urlForName(t,e){return this.j||(this.j=q(this)),rt(this.j(t,e),this)}urlForPath(t,e){return rt(it.pathToRegexp.compile(t)(e),this)}static go(t){return u("go",{pathname:t})}}const st=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i,at=window.Vaadin&&window.Vaadin.Flow&&window.Vaadin.Flow.clients;function ct(t,e){if("function"!=typeof t)return;const n=st.exec(t.toString());if(n)try{t=new Function(n[1])}catch(t){console.log("vaadin-development-mode-detector: uncommentAndRun() failed",t)}return t(e)}window.Vaadin=window.Vaadin||{};const ut=function(t,e){if(window.Vaadin.developmentMode)return ct(t,e)};function ht(){}void 0===window.Vaadin.developmentMode&&(window.Vaadin.developmentMode=function(){try{return!!localStorage.getItem("vaadin.developmentmode.force")||["localhost","127.0.0.1"].indexOf(window.location.hostname)>=0&&(at?!function(){if(at){const t=Object.keys(at).map(t=>at[t]).filter(t=>t.productionMode);if(t.length>0)return!0}return!1}():!ct(function(){return!0}))}catch(t){return!1}}());window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0"}),ut(ht),it.NavigationTrigger={POPSTATE:y,CLICK:m};export{D as Resolver,it as Router};

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Vaadin=e.Vaadin||{})}(this,function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t,n){return(u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function l(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function s(e){return e=e||[],Array.isArray(e)?e:[e]}function f(e){return"[Vaadin.Router] ".concat(e)}var h="module",d="nomodule",p=[h,d];function v(e){if(!e.match(/.+\.[m]?js$/))throw new Error(f('Unsupported type for bundle "'.concat(e,'": .js or .mjs expected.')))}function m(e){if(!e||!E(e.path))throw new Error(f('Expected route config to be an object with a "path" string property, or an array of such objects'));var t=e.bundle,n=["component","redirect","bundle"];if(!(b(e.action)||Array.isArray(e.children)||b(e.children)||w(t)||n.some(function(t){return E(e[t])})))throw new Error(f('Expected route config "'.concat(e.path,'" to include either "').concat(n.join('", "'),'" ')+'or "action" function but none found.'));if(t)if(E(t))v(t);else{if(!p.some(function(e){return e in t}))throw new Error(f('Expected route bundle to include either "'+d+'" or "'+h+'" keys, or both'));p.forEach(function(e){return e in t&&v(t[e])})}e.redirect&&["bundle","component"].forEach(function(t){t in e&&console.warn(f('Route config "'.concat(e.path,'" has both "redirect" and "').concat(t,'" properties, ')+'and "redirect" will always override the latter. Did you mean to only use "'.concat(t,'"?')))})}function _(e){s(e).forEach(function(e){return m(e)})}function g(e,t){var n=document.head.querySelector('script[src="'+e+'"][async]');return n||((n=document.createElement("script")).setAttribute("src",e),t===h?n.setAttribute("type",h):t===d&&n.setAttribute(d,""),n.async=!0),new Promise(function(e,t){n.onreadystatechange=n.onload=function(t){n.__dynamicImportLoaded=!0,e(t)},n.onerror=function(e){n.parentNode&&n.parentNode.removeChild(n),t(e)},null===n.parentNode?document.head.appendChild(n):n.__dynamicImportLoaded&&e()})}function y(e,t){return!window.dispatchEvent(new CustomEvent("vaadin-router-".concat(e),{cancelable:"go"===e,detail:t}))}function w(e){return"object"===t(e)&&!!e}function b(e){return"function"==typeof e}function E(e){return"string"==typeof e}function x(e){var t=new Error(f("Page not found (".concat(e.pathname,")")));return t.context=e,t.code=404,t}var C=new function e(){n(this,e)};function k(e){if(!e.defaultPrevented&&0===e.button&&!(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){for(var t=e.target,n=e.composedPath?e.composedPath():e.path||[],r=0;r<n.length;r++){var o=n[r];if(o.nodeName&&"a"===o.nodeName.toLowerCase()){t=o;break}}for(;t&&"a"!==t.nodeName.toLowerCase();)t=t.parentNode;if(t&&"a"===t.nodeName.toLowerCase())if(!t.target||"_self"===t.target.toLowerCase())if(!t.hasAttribute("download"))if(t.pathname!==window.location.pathname||""===t.hash)if((t.origin||function(e){var t=e.port,n=e.protocol,r="http:"===n&&"80"===t||"https:"===n&&"443"===t?e.hostname:e.host;return"".concat(n,"//").concat(r)}(t))===window.location.origin){var a=t;y("go",{pathname:a.pathname,search:a.search,hash:a.hash})&&e.preventDefault()}}}var O={activate:function(){window.document.addEventListener("click",k)},inactivate:function(){window.document.removeEventListener("click",k)}};function A(e){if("vaadin-router-ignore"!==e.state){var t=window.location;y("go",{pathname:t.pathname,search:t.search,hash:t.hash})}}/Trident/.test(navigator.userAgent)&&!b(window.PopStateEvent)&&(window.PopStateEvent=function(e,t){t=t||{};var n=document.createEvent("Event");return n.initEvent(e,Boolean(t.bubbles),Boolean(t.cancelable)),n.state=t.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);var R={activate:function(){window.addEventListener("popstate",A)},inactivate:function(){window.removeEventListener("popstate",A)}},P=D,j=V,T=function(e,t){return B(V(e,t))},L=B,S=$,U="/",N="./",I=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function V(e,t){for(var n,r=[],o=0,a=0,i="",c=t&&t.delimiter||U,u=t&&t.delimiters||N,l=!1;null!==(n=I.exec(e));){var s=n[0],f=n[1],h=n.index;if(i+=e.slice(a,h),a=h+s.length,f)i+=f[1],l=!0;else{var d="",p=e[a],v=n[2],m=n[3],_=n[4],g=n[5];if(!l&&i.length){var y=i.length-1;u.indexOf(i[y])>-1&&(d=i[y],i=i.slice(0,y))}i&&(r.push(i),i="",l=!1);var w=""!==d&&void 0!==p&&p!==d,b="+"===g||"*"===g,E="?"===g||"*"===g,x=d||c,C=m||_;r.push({name:v||o++,prefix:d,delimiter:x,optional:E,repeat:b,partial:w,pattern:C?M(C):"[^"+F(x)+"]+?"})}}return(i||a<e.length)&&r.push(i+e.substr(a)),r}function B(e){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"===t(e[r])&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(t,r){for(var o="",a=r&&r.encode||encodeURIComponent,i=0;i<e.length;i++){var c=e[i];if("string"!=typeof c){var u,l=t?t[c.name]:void 0;if(Array.isArray(l)){if(!c.repeat)throw new TypeError('Expected "'+c.name+'" to not repeat, but got array');if(0===l.length){if(c.optional)continue;throw new TypeError('Expected "'+c.name+'" to not be empty')}for(var s=0;s<l.length;s++){if(u=a(l[s],c),!n[i].test(u))throw new TypeError('Expected all "'+c.name+'" to match "'+c.pattern+'"');o+=(0===s?c.prefix:c.delimiter)+u}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){if(!c.optional)throw new TypeError('Expected "'+c.name+'" to be '+(c.repeat?"an array":"a string"));c.partial&&(o+=c.prefix)}else{if(u=a(String(l),c),!n[i].test(u))throw new TypeError('Expected "'+c.name+'" to match "'+c.pattern+'", but got "'+u+'"');o+=c.prefix+u}}else o+=c}return o}}function F(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function M(e){return e.replace(/([=!:$/()])/g,"\\$1")}function H(e){return e&&e.sensitive?"":"i"}function $(e,t,n){for(var r=(n=n||{}).strict,o=!1!==n.start,a=!1!==n.end,i=F(n.delimiter||U),c=n.delimiters||N,u=[].concat(n.endsWith||[]).map(F).concat("$").join("|"),l=o?"^":"",s=0===e.length,f=0;f<e.length;f++){var h=e[f];if("string"==typeof h)l+=F(h),s=f===e.length-1&&c.indexOf(h[h.length-1])>-1;else{var d=h.repeat?"(?:"+h.pattern+")(?:"+F(h.delimiter)+"(?:"+h.pattern+"))*":h.pattern;t&&t.push(h),h.optional?h.partial?l+=F(h.prefix)+"("+d+")?":l+="(?:"+F(h.prefix)+"("+d+"))?":l+=F(h.prefix)+"("+d+")"}}return a?(r||(l+="(?:"+i+")?"),l+="$"===u?"$":"(?="+u+")"):(r||(l+="(?:"+i+"(?="+u+"))?"),s||(l+="(?="+i+"|"+u+")")),new RegExp(l,H(n))}function D(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}(e,t):Array.isArray(e)?function(e,t,n){for(var r=[],o=0;o<e.length;o++)r.push(D(e[o],t,n).source);return new RegExp("(?:"+r.join("|")+")",H(n))}(e,t,n):function(e,t,n){return $(V(e,n),t,n)}(e,t,n)}P.parse=j,P.compile=T,P.tokensToFunction=L,P.tokensToRegExp=S;var K=Object.prototype.hasOwnProperty,q=new Map;function z(e){try{return decodeURIComponent(e)}catch(t){return e}}function W(e,t,n,r,o){var a,i,c=0,u=e.path||"";return"/"===u.charAt(0)&&(n&&(u=u.substr(1)),n=!0),{next:function(l){if(e===l)return{done:!0};var s=e.__children=e.__children||e.children;if(!a&&(a=function(e,t,n,r,o){n=!!n;var a="".concat(e,"|").concat(n),i=q.get(a);if(!i){var c=[];i={keys:c,pattern:P(e,c,{end:n,strict:""===e})},q.set(a,i)}var u=i.pattern.exec(t);if(!u)return null;for(var l=Object.assign({},o),s=1;s<u.length;s++){var f=i.keys[s-1],h=f.name,d=u[s];void 0===d&&K.call(l,h)||(f.repeat?l[h]=d?d.split(f.delimiter).map(z):[]:l[h]=d?z(d):d)}return{path:u[0],keys:(r||[]).concat(i.keys),params:l}}(u,t,!s,r,o)))return{done:!1,value:{route:e,keys:a.keys,params:a.params,path:a.path}};if(a&&s)for(;c<s.length;){if(!i){var f=s[c];f.parent=e;var h=a.path.length;h>0&&"/"===t.charAt(h)&&(h+=1),i=W(f,t.substr(h),n,a.keys,a.params)}var d=i.next(l);if(!d.done)return{done:!1,value:d.value};i=null,c++}return{done:!0}}}}function Q(e){if(b(e.route.action))return e.route.action(e)}q.set("|false",{keys:[],pattern:/(?:)/});var J=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.errorHandler=r.errorHandler,this.resolveRoute=r.resolveRoute||Q,this.context=Object.assign({resolver:this},r.context),this.root=Array.isArray(t)?{path:"",__children:t,parent:null,__synthetic:!0}:t,this.root.parent=null}return o(e,[{key:"getRoutes",value:function(){return l(this.root.__children)}},{key:"setRoutes",value:function(e){_(e);var t=l(s(e));this.root.__children=t}},{key:"addRoutes",value:function(e){var t;return _(e),(t=this.root.__children).push.apply(t,l(s(e))),this.getRoutes()}},{key:"removeRoutes",value:function(){this.setRoutes([])}},{key:"resolve",value:function(e){var t=this,n=Object.assign({},this.context,E(e)?{pathname:e}:e),r=W(this.root,this.__normalizePathname(n.pathname),this.baseUrl),o=this.resolveRoute,a=null,i=null,c=n;function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.value.route,l=null===(arguments.length>2?arguments[2]:void 0)&&a.value.route;return a=i||r.next(l),i=null,e||!a.done&&function(e,t){for(var n=t;n;)if((n=n.parent)===e)return!0;return!1}(t,a.value.route)?a.done?Promise.reject(x(n)):(function(e,t){var n=t.route,r=t.path;if(n&&!n.__synthetic){var o={path:r,route:n};!function(e,t){return!t.parent||!e||!e.length||e[e.length-1].route!==t.parent}(e.chain,n)?e.chain.push(o):e.chain=[o]}}(n,a.value),c=Object.assign({},n,a.value),Promise.resolve(o(c)).then(function(n){return null!==n&&void 0!==n&&n!==C?(c.result=n.result||n,c):u(e,t,n)})):(i=a,Promise.resolve(C))}return n.next=u,Promise.resolve().then(function(){return u(!0,t.root)}).catch(function(e){var n=function(e){var t="Path '".concat(e.pathname,"' is not properly resolved due to an error."),n=(e.route||{}).path;return n&&(t+=" Resolution had failed on route: '".concat(n,"'")),t}(c);if(e?console.warn(n):e=new Error(n),e.context=e.context||c,e instanceof DOMException||(e.code=e.code||500),t.errorHandler)return c.result=t.errorHandler(e),c;throw e})}},{key:"__normalizePathname",value:function(e){if(!this.baseUrl)return e;var t=this.__effectiveBaseUrl,n=this.constructor.__createUrl(e,t).href;return n.slice(0,t.length)===t?n.slice(t.length):void 0}},{key:"__effectiveBaseUrl",get:function(){return this.baseUrl?this.constructor.__createUrl(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\/]*$/,""):""}}],[{key:"__createUrl",value:function(e,t){return new URL(e,t)}}]),e}();J.pathToRegexp=P;var G=J.pathToRegexp,X=new Map;function Y(e,t){var n=e.get(t);if(n&&n.length>1)throw new Error('Duplicate route with name "'.concat(t,'".')+" Try seting unique 'name' route properties.");return n&&n[0]}function Z(e){var t=e.path;return void 0!==(t=Array.isArray(t)?t[0]:t)?t:""}function ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e instanceof J))throw new TypeError("An instance of Resolver is expected");var n=new Map;return function(r,o){var a=Y(n,r);if(!(a||(n.clear(),function e(t,n,r){var o=n.name||n.component;if(o&&(t.has(o)?t.get(o).push(n):t.set(o,[n])),Array.isArray(r))for(var a=0;a<r.length;a++){var i=r[a];i.parent=n,e(t,i,i.__children||i.children)}}(n,e.root,e.root.__children),a=Y(n,r))))throw new Error('Route "'.concat(r,'" not found'));var i=X.get(a.fullPath);if(!i){for(var c=Z(a),u=a.parent;u;){var l=Z(u);l&&(c=l.replace(/\/$/,"")+"/"+c.replace(/^\//,"")),u=u.parent}for(var s=G.parse(c),f=G.tokensToFunction(s),h=Object.create(null),d=0;d<s.length;d++)E(s[d])||(h[s[d].name]=!0);i={toPath:f,keys:h},X.set(c,i),a.fullPath=c}var p=i.toPath(o,t)||"/";if(t.stringifyQueryParams&&o){for(var v={},m=Object.keys(o),_=0;_<m.length;_++){var g=m[_];i.keys[g]||(v[g]=o[g])}var y=t.stringifyQueryParams(v);y&&(p+="?"===y.charAt(0)?y:"?".concat(y))}return p}}var te=[];function ne(e){te.forEach(function(e){return e.inactivate()}),e.forEach(function(e){return e.activate()}),te=e}var re=function(e){var t=getComputedStyle(e).getPropertyValue("animation-name");return t&&"none"!==t},oe=function(e,t){e.addEventListener("animationend",function n(){e.removeEventListener("animationend",n),t()})};function ae(e,t){return e.classList.add(t),new Promise(function(n){if(re(e)){var r=e.getBoundingClientRect(),o="height: ".concat(r.bottom-r.top,"px; width: ").concat(r.right-r.left,"px");e.setAttribute("style","position: absolute; ".concat(o)),oe(e,function(){e.classList.remove(t),e.removeAttribute("style"),n()})}else e.classList.remove(t),n()})}function ie(e){return null!==e&&void 0!==e}function ce(e,t){var n=e.pathname,r=void 0===n?"":n,o=e.chain,a=void 0===o?[]:o,i=e.params,c=void 0===i?{}:i,u=e.redirectFrom,l=e.resolver,s=a.map(function(e){return e.route});return{baseUrl:l&&l.baseUrl||"",pathname:r,routes:s,route:t||s.length&&s[s.length-1]||null,params:c,redirectFrom:u,getUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return he(pe.pathToRegexp.compile(de(s))(Object.assign({},c,e)),l)}}}function ue(e,t){var n=Object.assign({},e.params);return{redirect:{pathname:t,from:e.pathname,params:n}}}function le(e,t,n){if(b(e))return e.apply(n,t)}function se(e,t,n){return function(r){return r&&(r.cancel||r.redirect)?r:n?le(n[e],t,n):void 0}}function fe(e){if(e&&e.length)for(var t=e[0].parentNode,n=0;n<e.length;n++)t.removeChild(e[n])}function he(e,t){var n=t.__effectiveBaseUrl;return n?t.constructor.__createUrl(e.replace(/^\//,""),n).pathname:e}function de(e){return e.map(function(e){return e.path}).reduce(function(e,t){return t.length?e.replace(/\/$/,"")+"/"+t.replace(/^\//,""):e},"")}var pe=function(e){function r(e,t){var o;n(this,r);var i,u,l=document.head.querySelector("base");i=this,u=a(r).call(this,[],Object.assign({baseUrl:l&&l.getAttribute("href")},t)),(o=!u||"object"!=typeof u&&"function"!=typeof u?c(i):u).resolveRoute=function(e){return o.__resolveRoute(e)};var s=r.NavigationTrigger;return r.setTriggers.apply(r,Object.keys(s).map(function(e){return s[e]})),o.baseUrl,o.ready,o.ready=Promise.resolve(e),o.location,o.location=ce({resolver:c(o)}),o.__lastStartedRenderId=0,o.__navigationEventHandler=o.__onNavigationEvent.bind(c(o)),o.setOutlet(e),o.subscribe(),o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(r,J),o(r,[{key:"__resolveRoute",value:function(e){var t=e.route,n=Promise.resolve();b(t.children)&&(n=n.then(function(){return t.children(function(e){var t=Object.assign({},e);return delete t.next,t}(e))}).then(function(e){ie(e)||b(t.children)||(e=t.children),function(e,t){if(!Array.isArray(e)&&!w(e))throw new Error(f('Incorrect "children" value for the route '.concat(t.path,": expected array or object, but got ").concat(e)));t.__children=[];for(var n=s(e),r=0;r<n.length;r++)m(n[r]),t.__children.push(n[r])}(e,t)}));var r={redirect:function(t){return ue(e,t)},component:function(e){return document.createElement(e)}};return n.then(function(){return le(t.action,[e,r],t)}).then(function(e){return ie(e)&&(e instanceof HTMLElement||e.redirect||e===C)?e:E(t.redirect)?r.redirect(t.redirect):t.bundle?(n=t.bundle,E(n)?g(n):Promise.race(p.filter(function(e){return e in n}).map(function(e){return g(n[e],e)}))).then(function(){},function(){throw new Error(f("Bundle not found: ".concat(t.bundle,". Check if the file name is correct")))}):void 0;var n}).then(function(e){return ie(e)?e:E(t.component)?r.component(t.component):void 0})}},{key:"setOutlet",value:function(e){e&&this.__ensureOutlet(e),this.__outlet=e}},{key:"getOutlet",value:function(){return this.__outlet}},{key:"setRoutes",value:function(e){this.__urlForName=void 0,u(a(r.prototype),"setRoutes",this).call(this,e),this.__onNavigationEvent()}},{key:"render",value:function(e,t){var n=this,r=++this.__lastStartedRenderId,o=e.pathname||e,a=e.search||"",i=e.hash||"";return this.ready=this.resolve({pathname:o,search:a,hash:i}).then(function(e){return n.__fullyResolveChain(e)}).then(function(e){if(r===n.__lastStartedRenderId){var o=n.__previousContext;if(e===o)return n.location;n.location=ce(e),y("location-changed",{router:n,location:n.location}),t&&n.__updateBrowserHistory(e,e.redirectFrom),n.__addAppearingContent(e,o);var a=n.__animateIfNeeded(e);return n.__runOnAfterEnterCallbacks(e),n.__runOnAfterLeaveCallbacks(e,o),a.then(function(){if(r===n.__lastStartedRenderId)return n.__removeDisappearingContent(),n.__previousContext=e,n.location})}}).catch(function(e){if(r===n.__lastStartedRenderId)throw t&&n.__updateBrowserHistory({pathname:o,search:a,hash:i}),fe(n.__outlet&&n.__outlet.children),n.location=ce({pathname:o,resolver:n}),y("error",{router:n,error:e,pathname:o}),e}),this.ready}},{key:"__fullyResolveChain",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return this.__findComponentContextAfterAllRedirects(n).then(function(r){var o=r!==n?r:e;return r.next().then(function(e){if((null===e||e===C)&&he(de(r.chain),r.resolver)!==r.pathname)throw x(o);return e&&e!==C?t.__fullyResolveChain(o,e):t.__amendWithOnBeforeCallbacks(r)})})}},{key:"__findComponentContextAfterAllRedirects",value:function(e){var n=this,r=e.result;return r instanceof HTMLElement?(function(e,t){t.location=ce(e);var n=e.chain.map(function(e){return e.route}).indexOf(e.route);e.chain[n].element=t}(e,r),Promise.resolve(e)):r.redirect?this.__redirect(r.redirect,e.__redirectCount).then(function(e){return n.__findComponentContextAfterAllRedirects(e)}):r instanceof Error?Promise.reject(r):Promise.reject(new Error(f('Invalid route resolution result for path "'.concat(e.pathname,'". ')+'Expected redirect object or HTML element, but got: "'.concat(function(e){if("object"!==t(e))return String(e);var n=Object.prototype.toString.call(e).match(/ (.*)\]$/)[1];return"Object"===n||"Array"===n?"".concat(n," ").concat(JSON.stringify(e)):n}(r),'". ')+"Double check the action return value for the route.")))}},{key:"__amendWithOnBeforeCallbacks",value:function(e){var t=this;return this.__runOnBeforeCallbacks(e).then(function(n){return n===t.__previousContext||n===e?n:t.__fullyResolveChain(n)})}},{key:"__runOnBeforeCallbacks",value:function(e){var t=this,n=(this.__previousContext||{}).chain||[],r=e.chain,o=Promise.resolve(),a=function(){return{cancel:!0}},i=function(t){return ue(e,t)};if(e.__divergedChainIndex=0,n.length){for(var c=0;c<Math.min(n.length,r.length)&&(n[c].route===r[c].route&&n[c].path===r[c].path&&(n[c].element&&n[c].element.localName)===(r[c].element&&r[c].element.localName));c=++e.__divergedChainIndex);for(var u=n.length-1;u>=e.__divergedChainIndex;u--){var l=ce(e);o=o.then(se("onBeforeLeave",[l,{prevent:a},this],n[u].element)).then(function(e){if(!(e||{}).redirect)return e})}}for(var s=e.__divergedChainIndex;s<r.length;s++){var f=ce(e,r[s].route);o=o.then(se("onBeforeEnter",[f,{prevent:a,redirect:i},this],r[s].element))}return o.then(function(n){if(n){if(n.cancel)return t.__previousContext;if(n.redirect)return t.__redirect(n.redirect,e.__redirectCount)}return e})}},{key:"__redirect",value:function(e,t){if(t>256)throw new Error(f("Too many redirects when rendering ".concat(e.from)));return this.resolve({pathname:this.urlForPath(e.pathname,e.params),redirectFrom:e.from,__redirectCount:(t||0)+1})}},{key:"__ensureOutlet",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.__outlet;if(!(e instanceof Node))throw new TypeError(f("Expected router outlet to be a valid DOM Node (but got ".concat(e,")")))}},{key:"__updateBrowserHistory",value:function(e,t){var n=e.pathname,r=e.search,o=void 0===r?"":r,a=e.hash,i=void 0===a?"":a;if(window.location.pathname!==n||window.location.search!==o||window.location.hash!==i){var c=t?"replaceState":"pushState";window.history[c](null,document.title,n+o+i),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}},{key:"__addAppearingContent",value:function(e,t){this.__ensureOutlet(),this.__removeAppearingContent();for(var n=this.__outlet,r=0;r<e.__divergedChainIndex;r++){var o=t&&t.chain[r].element;if(o){if(o.parentNode!==n)break;e.chain[r].element=o,n=o}}this.__disappearingContent=Array.from(n.children),this.__appearingContent=[];for(var a=n,i=e.__divergedChainIndex;i<e.chain.length;i++){var c=e.chain[i].element;c&&(a.appendChild(c),a===n&&this.__appearingContent.push(c),a=c)}}},{key:"__removeDisappearingContent",value:function(){this.__disappearingContent&&fe(this.__disappearingContent),this.__disappearingContent=null,this.__appearingContent=null}},{key:"__removeAppearingContent",value:function(){this.__disappearingContent&&this.__appearingContent&&(fe(this.__appearingContent),this.__disappearingContent=null,this.__appearingContent=null)}},{key:"__runOnAfterLeaveCallbacks",value:function(e,t){if(t)for(var n=t.chain.length-1;n>=e.__divergedChainIndex;n--){var r=t.chain[n].element;if(r)try{var o=ce(e);le(r.onAfterLeave,[o,{},t.resolver],r)}finally{fe(r.children)}}}},{key:"__runOnAfterEnterCallbacks",value:function(e){for(var t=e.__divergedChainIndex;t<e.chain.length;t++){var n=e.chain[t].element||{},r=ce(e,e.chain[t].route);le(n.onAfterEnter,[r,{},e.resolver],n)}}},{key:"__animateIfNeeded",value:function(e){for(var t,n=(this.__disappearingContent||[])[0],r=(this.__appearingContent||[])[0],o=[],a=e.chain,i=a.length;i>0;i--)if(a[i-1].route.animate){t=a[i-1].route.animate;break}if(n&&r&&t){var c=w(t)&&t.leave||"leaving",u=w(t)&&t.enter||"entering";o.push(ae(n,c)),o.push(ae(r,u))}return Promise.all(o).then(function(){return e})}},{key:"subscribe",value:function(){window.addEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"unsubscribe",value:function(){window.removeEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"__onNavigationEvent",value:function(e){var t=e?e.detail.pathname:window.location.pathname;E(this.__normalizePathname(t))&&(e&&e.preventDefault&&e.preventDefault(),this.render(e?e.detail:{pathname:t},!0))}},{key:"urlForName",value:function(e,t){return this.__urlForName||(this.__urlForName=ee(this)),he(this.__urlForName(e,t),this)}},{key:"urlForPath",value:function(e,t){return he(r.pathToRegexp.compile(e)(t),this)}}],[{key:"setTriggers",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];ne(t)}},{key:"go",value:function(e){return y("go",{pathname:e})}}]),r}(),ve=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i,me=window.Vaadin&&window.Vaadin.Flow&&window.Vaadin.Flow.clients;function _e(e,t){if("function"==typeof e){var n=ve.exec(e.toString());if(n)try{e=new Function(n[1])}catch(e){console.log("vaadin-development-mode-detector: uncommentAndRun() failed",e)}return e(t)}}window.Vaadin=window.Vaadin||{};var ge=function(e,t){if(window.Vaadin.developmentMode)return _e(e,t)};function ye(){}void 0===window.Vaadin.developmentMode&&(window.Vaadin.developmentMode=function(){try{return!!localStorage.getItem("vaadin.developmentmode.force")||["localhost","127.0.0.1"].indexOf(window.location.hostname)>=0&&(me?!function(){if(me){var e=Object.keys(me).map(function(e){return me[e]}).filter(function(e){return e.productionMode});if(e.length>0)return!0}return!1}():!_e(function(){return!0}))}catch(e){return!1}}());var we,be,Ee,xe;window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0"}),ge(ye),pe.NavigationTrigger={POPSTATE:R,CLICK:O},J.__ensureUrlAvailableOrPolyfilled=function(){if(void 0===we){try{var e=new URL("b","http://a");e.pathname="c",we="http://a/c"===e.href}catch(e){we=!1}we||(be=document.implementation.createHTMLDocument("url"),Ee=be.createElement("base"),be.head.appendChild(Ee),(xe=be.createElement("a")).origin||(Object.defineProperty(xe,"origin",{get:function(){var e=xe.protocol,t=xe.port,n="http:"===e&&"80"===t||"https:"===e&&"443"===t?xe.hostname:xe.host;return"".concat(e,"//").concat(n)}}),Object.defineProperty(xe,"pathname",{get:function(){return xe.href.slice(xe.origin.length)}})))}},J.__createUrl=function(e,t){return J.__ensureUrlAvailableOrPolyfilled(),we?new URL(e,t):(Ee.href=t,xe.href=e.replace(/ /g,"%20"),xe.href=xe.href,xe)},e.Resolver=J,e.Router=pe,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Vaadin=e.Vaadin||{})}(this,function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,t,n){return(u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n):o.value}})(e,t,n||e)}function l(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function s(e){return e=e||[],Array.isArray(e)?e:[e]}function h(e){return"[Vaadin.Router] ".concat(e)}var f="module",d="nomodule",p=[f,d];function v(e){if(!e.match(/.+\.[m]?js$/))throw new Error(h('Unsupported type for bundle "'.concat(e,'": .js or .mjs expected.')))}function _(e){if(!e||!E(e.path))throw new Error(h('Expected route config to be an object with a "path" string property, or an array of such objects'));var t=e.bundle,n=["component","redirect","bundle"];if(!(b(e.action)||Array.isArray(e.children)||b(e.children)||w(t)||n.some(function(t){return E(e[t])})))throw new Error(h('Expected route config "'.concat(e.path,'" to include either "').concat(n.join('", "'),'" ')+'or "action" function but none found.'));if(t)if(E(t))v(t);else{if(!p.some(function(e){return e in t}))throw new Error(h('Expected route bundle to include either "'+d+'" or "'+f+'" keys, or both'));p.forEach(function(e){return e in t&&v(t[e])})}e.redirect&&["bundle","component"].forEach(function(t){t in e&&console.warn(h('Route config "'.concat(e.path,'" has both "redirect" and "').concat(t,'" properties, ')+'and "redirect" will always override the latter. Did you mean to only use "'.concat(t,'"?')))})}function m(e){s(e).forEach(function(e){return _(e)})}function g(e,t){var n=document.head.querySelector('script[src="'+e+'"][async]');return n||((n=document.createElement("script")).setAttribute("src",e),t===f?n.setAttribute("type",f):t===d&&n.setAttribute(d,""),n.async=!0),new Promise(function(e,t){n.onreadystatechange=n.onload=function(t){n.__dynamicImportLoaded=!0,e(t)},n.onerror=function(e){n.parentNode&&n.parentNode.removeChild(n),t(e)},null===n.parentNode?document.head.appendChild(n):n.__dynamicImportLoaded&&e()})}function y(e,t){return!window.dispatchEvent(new CustomEvent("vaadin-router-".concat(e),{cancelable:"go"===e,detail:t}))}function w(e){return"object"===t(e)&&!!e}function b(e){return"function"==typeof e}function E(e){return"string"==typeof e}function x(e){var t=new Error(h("Page not found (".concat(e.pathname,")")));return t.context=e,t.code=404,t}var C=new function e(){n(this,e)};function k(e){if(!e.defaultPrevented&&0===e.button&&!(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){for(var t=e.target,n=e.composedPath?e.composedPath():e.path||[],r=0;r<n.length;r++){var o=n[r];if(o.nodeName&&"a"===o.nodeName.toLowerCase()){t=o;break}}for(;t&&"a"!==t.nodeName.toLowerCase();)t=t.parentNode;if(t&&"a"===t.nodeName.toLowerCase())if(!t.target||"_self"===t.target.toLowerCase())if(!t.hasAttribute("download"))if(t.pathname!==window.location.pathname||""===t.hash)if((t.origin||function(e){var t=e.port,n=e.protocol,r="http:"===n&&"80"===t||"https:"===n&&"443"===t?e.hostname:e.host;return"".concat(n,"//").concat(r)}(t))===window.location.origin){var a=t;y("go",{pathname:a.pathname,search:a.search,hash:a.hash})&&e.preventDefault()}}}var A={activate:function(){window.document.addEventListener("click",k)},inactivate:function(){window.document.removeEventListener("click",k)}};function O(e){if("vaadin-router-ignore"!==e.state){var t=window.location;y("go",{pathname:t.pathname,search:t.search,hash:t.hash})}}/Trident/.test(navigator.userAgent)&&!b(window.PopStateEvent)&&(window.PopStateEvent=function(e,t){t=t||{};var n=document.createEvent("Event");return n.initEvent(e,Boolean(t.bubbles),Boolean(t.cancelable)),n.state=t.state||null,n},window.PopStateEvent.prototype=window.Event.prototype);var R={activate:function(){window.addEventListener("popstate",O)},inactivate:function(){window.removeEventListener("popstate",O)}},P=D,j=B,T=function(e,t){return V(B(e,t))},L=V,S=$,U="/",I="./",N=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function B(e,t){for(var n,r=[],o=0,a=0,i="",c=t&&t.delimiter||U,u=t&&t.delimiters||I,l=!1;null!==(n=N.exec(e));){var s=n[0],h=n[1],f=n.index;if(i+=e.slice(a,f),a=f+s.length,h)i+=h[1],l=!0;else{var d="",p=e[a],v=n[2],_=n[3],m=n[4],g=n[5];if(!l&&i.length){var y=i.length-1;u.indexOf(i[y])>-1&&(d=i[y],i=i.slice(0,y))}i&&(r.push(i),i="",l=!1);var w=""!==d&&void 0!==p&&p!==d,b="+"===g||"*"===g,E="?"===g||"*"===g,x=d||c,C=_||m;r.push({name:v||o++,prefix:d,delimiter:x,optional:E,repeat:b,partial:w,pattern:C?M(C):"[^"+F(x)+"]+?"})}}return(i||a<e.length)&&r.push(i+e.substr(a)),r}function V(e){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"===t(e[r])&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(t,r){for(var o="",a=r&&r.encode||encodeURIComponent,i=0;i<e.length;i++){var c=e[i];if("string"!=typeof c){var u,l=t?t[c.name]:void 0;if(Array.isArray(l)){if(!c.repeat)throw new TypeError('Expected "'+c.name+'" to not repeat, but got array');if(0===l.length){if(c.optional)continue;throw new TypeError('Expected "'+c.name+'" to not be empty')}for(var s=0;s<l.length;s++){if(u=a(l[s],c),!n[i].test(u))throw new TypeError('Expected all "'+c.name+'" to match "'+c.pattern+'"');o+=(0===s?c.prefix:c.delimiter)+u}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){if(!c.optional)throw new TypeError('Expected "'+c.name+'" to be '+(c.repeat?"an array":"a string"));c.partial&&(o+=c.prefix)}else{if(u=a(String(l),c),!n[i].test(u))throw new TypeError('Expected "'+c.name+'" to match "'+c.pattern+'", but got "'+u+'"');o+=c.prefix+u}}else o+=c}return o}}function F(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function M(e){return e.replace(/([=!:$/()])/g,"\\$1")}function H(e){return e&&e.sensitive?"":"i"}function $(e,t,n){for(var r=(n=n||{}).strict,o=!1!==n.start,a=!1!==n.end,i=F(n.delimiter||U),c=n.delimiters||I,u=[].concat(n.endsWith||[]).map(F).concat("$").join("|"),l=o?"^":"",s=0===e.length,h=0;h<e.length;h++){var f=e[h];if("string"==typeof f)l+=F(f),s=h===e.length-1&&c.indexOf(f[f.length-1])>-1;else{var d=f.repeat?"(?:"+f.pattern+")(?:"+F(f.delimiter)+"(?:"+f.pattern+"))*":f.pattern;t&&t.push(f),f.optional?f.partial?l+=F(f.prefix)+"("+d+")?":l+="(?:"+F(f.prefix)+"("+d+"))?":l+=F(f.prefix)+"("+d+")"}}return a?(r||(l+="(?:"+i+")?"),l+="$"===u?"$":"(?="+u+")"):(r||(l+="(?:"+i+"(?="+u+"))?"),s||(l+="(?="+i+"|"+u+")")),new RegExp(l,H(n))}function D(e,t,n){return e instanceof RegExp?function(e,t){if(!t)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)t.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}(e,t):Array.isArray(e)?function(e,t,n){for(var r=[],o=0;o<e.length;o++)r.push(D(e[o],t,n).source);return new RegExp("(?:"+r.join("|")+")",H(n))}(e,t,n):function(e,t,n){return $(B(e,n),t,n)}(e,t,n)}P.parse=j,P.compile=T,P.tokensToFunction=L,P.tokensToRegExp=S;var K=Object.prototype.hasOwnProperty,W=new Map;function q(e){try{return decodeURIComponent(e)}catch(t){return e}}function z(e,t,n,r,o){var a,i,c=0,u=e.path||"";return"/"===u.charAt(0)&&(n&&(u=u.substr(1)),n=!0),{next:function(l){if(e===l)return{done:!0};var s=e.__children=e.__children||e.children;if(!a&&(a=function(e,t,n,r,o){n=!!n;var a="".concat(e,"|").concat(n),i=W.get(a);if(!i){var c=[];i={keys:c,pattern:P(e,c,{end:n,strict:""===e})},W.set(a,i)}var u=i.pattern.exec(t);if(!u)return null;for(var l=Object.assign({},o),s=1;s<u.length;s++){var h=i.keys[s-1],f=h.name,d=u[s];void 0===d&&K.call(l,f)||(h.repeat?l[f]=d?d.split(h.delimiter).map(q):[]:l[f]=d?q(d):d)}return{path:u[0],keys:(r||[]).concat(i.keys),params:l}}(u,t,!s,r,o)))return{done:!1,value:{route:e,keys:a.keys,params:a.params,path:a.path}};if(a&&s)for(;c<s.length;){if(!i){var h=s[c];h.parent=e;var f=a.path.length;f>0&&"/"===t.charAt(f)&&(f+=1),i=z(h,t.substr(f),n,a.keys,a.params)}var d=i.next(l);if(!d.done)return{done:!1,value:d.value};i=null,c++}return{done:!0}}}}function Q(e){if(b(e.route.action))return e.route.action(e)}W.set("|false",{keys:[],pattern:/(?:)/});var J=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,e),Object(t)!==t)throw new TypeError("Invalid routes");this.baseUrl=r.baseUrl||"",this.errorHandler=r.errorHandler,this.resolveRoute=r.resolveRoute||Q,this.context=Object.assign({resolver:this},r.context),this.root=Array.isArray(t)?{path:"",__children:t,parent:null,__synthetic:!0}:t,this.root.parent=null}return o(e,[{key:"getRoutes",value:function(){return l(this.root.__children)}},{key:"setRoutes",value:function(e){m(e);var t=l(s(e));this.root.__children=t}},{key:"addRoutes",value:function(e){var t;return m(e),(t=this.root.__children).push.apply(t,l(s(e))),this.getRoutes()}},{key:"removeRoutes",value:function(){this.setRoutes([])}},{key:"resolve",value:function(e){var t=this,n=Object.assign({},this.context,E(e)?{pathname:e}:e),r=z(this.root,this.__normalizePathname(n.pathname),this.baseUrl),o=this.resolveRoute,a=null,i=null,c=n;function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a.value.route,l=null===(arguments.length>2?arguments[2]:void 0)&&a.value.route;return a=i||r.next(l),i=null,e||!a.done&&function(e,t){for(var n=t;n;)if((n=n.parent)===e)return!0;return!1}(t,a.value.route)?a.done?Promise.reject(x(n)):(function(e,t){var n=t.route,r=t.path;if(n&&!n.__synthetic){var o={path:r,route:n};!function(e,t){return!t.parent||!e||!e.length||e[e.length-1].route!==t.parent}(e.chain,n)?e.chain.push(o):e.chain=[o]}}(n,a.value),c=Object.assign({},n,a.value),Promise.resolve(o(c)).then(function(n){return null!==n&&void 0!==n&&n!==C?(c.result=n.result||n,c):u(e,t,n)})):(i=a,Promise.resolve(C))}return n.next=u,Promise.resolve().then(function(){return u(!0,t.root)}).catch(function(e){var n=function(e){var t="Path '".concat(e.pathname,"' is not properly resolved due to an error."),n=(e.route||{}).path;return n&&(t+=" Resolution had failed on route: '".concat(n,"'")),t}(c);if(e?console.warn(n):e=new Error(n),e.context=e.context||c,e instanceof DOMException||(e.code=e.code||500),t.errorHandler)return c.result=t.errorHandler(e),c;throw e})}},{key:"__normalizePathname",value:function(e){if(!this.baseUrl)return e;var t=this.__effectiveBaseUrl,n=this.constructor.__createUrl(e,t).href;return n.slice(0,t.length)===t?n.slice(t.length):void 0}},{key:"__effectiveBaseUrl",get:function(){return this.baseUrl?this.constructor.__createUrl(this.baseUrl,document.baseURI||document.URL).href.replace(/[^\/]*$/,""):""}}],[{key:"__createUrl",value:function(e,t){return new URL(e,t)}}]),e}();J.pathToRegexp=P;var G=J.pathToRegexp,X=new Map;function Y(e,t){var n=e.get(t);if(n&&n.length>1)throw new Error('Duplicate route with name "'.concat(t,'".')+" Try seting unique 'name' route properties.");return n&&n[0]}function Z(e){var t=e.path;return void 0!==(t=Array.isArray(t)?t[0]:t)?t:""}function ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e instanceof J))throw new TypeError("An instance of Resolver is expected");var n=new Map;return function(r,o){var a=Y(n,r);if(!(a||(n.clear(),function e(t,n,r){var o=n.name||n.component;if(o&&(t.has(o)?t.get(o).push(n):t.set(o,[n])),Array.isArray(r))for(var a=0;a<r.length;a++){var i=r[a];i.parent=n,e(t,i,i.__children||i.children)}}(n,e.root,e.root.__children),a=Y(n,r))))throw new Error('Route "'.concat(r,'" not found'));var i=X.get(a.fullPath);if(!i){for(var c=Z(a),u=a.parent;u;){var l=Z(u);l&&(c=l.replace(/\/$/,"")+"/"+c.replace(/^\//,"")),u=u.parent}for(var s=G.parse(c),h=G.tokensToFunction(s),f=Object.create(null),d=0;d<s.length;d++)E(s[d])||(f[s[d].name]=!0);i={toPath:h,keys:f},X.set(c,i),a.fullPath=c}var p=i.toPath(o,t)||"/";if(t.stringifyQueryParams&&o){for(var v={},_=Object.keys(o),m=0;m<_.length;m++){var g=_[m];i.keys[g]||(v[g]=o[g])}var y=t.stringifyQueryParams(v);y&&(p+="?"===y.charAt(0)?y:"?".concat(y))}return p}}var te=[];function ne(e){te.forEach(function(e){return e.inactivate()}),e.forEach(function(e){return e.activate()}),te=e}var re=function(e){var t=getComputedStyle(e).getPropertyValue("animation-name");return t&&"none"!==t},oe=function(e,t){e.addEventListener("animationend",function n(){e.removeEventListener("animationend",n),t()})};function ae(e,t){return e.classList.add(t),new Promise(function(n){if(re(e)){var r=e.getBoundingClientRect(),o="height: ".concat(r.bottom-r.top,"px; width: ").concat(r.right-r.left,"px");e.setAttribute("style","position: absolute; ".concat(o)),oe(e,function(){e.classList.remove(t),e.removeAttribute("style"),n()})}else e.classList.remove(t),n()})}function ie(e){return null!==e&&void 0!==e}function ce(e,t){var n=e.pathname,r=void 0===n?"":n,o=e.search,a=void 0===o?"":o,i=e.hash,c=void 0===i?"":i,u=e.chain,l=void 0===u?[]:u,s=e.params,h=void 0===s?{}:s,f=e.redirectFrom,d=e.resolver,p=l.map(function(e){return e.route});return{baseUrl:d&&d.baseUrl||"",pathname:r,search:a,hash:c,routes:p,route:t||p.length&&p[p.length-1]||null,params:h,redirectFrom:f,getUrl:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return fe(pe.pathToRegexp.compile(de(p))(Object.assign({},h,e)),d)}}}function ue(e,t){var n=Object.assign({},e.params);return{redirect:{pathname:t,from:e.pathname,params:n}}}function le(e,t,n){if(b(e))return e.apply(n,t)}function se(e,t,n){return function(r){return r&&(r.cancel||r.redirect)?r:n?le(n[e],t,n):void 0}}function he(e){if(e&&e.length)for(var t=e[0].parentNode,n=0;n<e.length;n++)t.removeChild(e[n])}function fe(e,t){var n=t.__effectiveBaseUrl;return n?t.constructor.__createUrl(e.replace(/^\//,""),n).pathname:e}function de(e){return e.map(function(e){return e.path}).reduce(function(e,t){return t.length?e.replace(/\/$/,"")+"/"+t.replace(/^\//,""):e},"")}var pe=function(e){function r(e,t){var o;n(this,r);var i,u,l=document.head.querySelector("base");i=this,u=a(r).call(this,[],Object.assign({baseUrl:l&&l.getAttribute("href")},t)),(o=!u||"object"!=typeof u&&"function"!=typeof u?c(i):u).resolveRoute=function(e){return o.__resolveRoute(e)};var s=r.NavigationTrigger;return r.setTriggers.apply(r,Object.keys(s).map(function(e){return s[e]})),o.baseUrl,o.ready,o.ready=Promise.resolve(e),o.location,o.location=ce({resolver:c(o)}),o.__lastStartedRenderId=0,o.__navigationEventHandler=o.__onNavigationEvent.bind(c(o)),o.setOutlet(e),o.subscribe(),o.__renderedElements=new WeakMap,o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(r,J),o(r,[{key:"__resolveRoute",value:function(e){var t=this,n=e.route,r=Promise.resolve();b(n.children)&&(r=r.then(function(){return n.children(function(e){var t=Object.assign({},e);return delete t.next,t}(e))}).then(function(e){ie(e)||b(n.children)||(e=n.children),function(e,t){if(!Array.isArray(e)&&!w(e))throw new Error(h('Incorrect "children" value for the route '.concat(t.path,": expected array or object, but got ").concat(e)));t.__children=[];for(var n=s(e),r=0;r<n.length;r++)_(n[r]),t.__children.push(n[r])}(e,n)}));var o={redirect:function(t){return ue(e,t)},component:function(e){var n=document.createElement(e);return t.__renderedElements.set(n,!0),n}};return r.then(function(){return le(n.action,[e,o],n)}).then(function(e){return ie(e)&&(e instanceof HTMLElement||e.redirect||e===C)?e:E(n.redirect)?o.redirect(n.redirect):n.bundle?(t=n.bundle,E(t)?g(t):Promise.race(p.filter(function(e){return e in t}).map(function(e){return g(t[e],e)}))).then(function(){},function(){throw new Error(h("Bundle not found: ".concat(n.bundle,". Check if the file name is correct")))}):void 0;var t}).then(function(e){return ie(e)?e:E(n.component)?o.component(n.component):void 0})}},{key:"setOutlet",value:function(e){e&&this.__ensureOutlet(e),this.__outlet=e}},{key:"getOutlet",value:function(){return this.__outlet}},{key:"setRoutes",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.__previousContext=void 0,this.__urlForName=void 0,u(a(r.prototype),"setRoutes",this).call(this,e),t||this.__onNavigationEvent(),this.ready}},{key:"render",value:function(e,t){var n=this,r=++this.__lastStartedRenderId,o=E(e)?{pathname:e,search:"",hash:""}:e,a=o.pathname,i=o.search,c=o.hash;return this.ready=this.resolve({pathname:a,search:i,hash:c}).then(function(e){return n.__fullyResolveChain(e)}).then(function(e){if(r===n.__lastStartedRenderId){var o=n.__previousContext;if(e===o)return n.__updateBrowserHistory(o,!0),n.location;if(n.location=ce(e),y("location-changed",{router:n,location:n.location}),t&&n.__updateBrowserHistory(e,e.redirectFrom),e.__skipAttach)return n.location;n.__addAppearingContent(e,o);var a=n.__animateIfNeeded(e);return n.__runOnAfterEnterCallbacks(e),n.__runOnAfterLeaveCallbacks(e,o),a.then(function(){if(r===n.__lastStartedRenderId)return n.__removeDisappearingContent(),n.__previousContext=e,n.location})}}).catch(function(e){if(r===n.__lastStartedRenderId)throw t&&n.__updateBrowserHistory({pathname:a,search:i,hash:c}),he(n.__outlet&&n.__outlet.children),n.location=ce({pathname:a,resolver:n}),y("error",{router:n,error:e,pathname:a}),e}),this.ready}},{key:"__fullyResolveChain",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return this.__findComponentContextAfterAllRedirects(n).then(function(r){var o=r!==n?r:e;return r.next().then(function(e){if((null===e||e===C)&&fe(de(r.chain),r.resolver)!==r.pathname)throw x(o);return e&&e!==C?t.__fullyResolveChain(o,e):t.__amendWithOnBeforeCallbacks(r)})})}},{key:"__findComponentContextAfterAllRedirects",value:function(e){var n=this,r=e.result;return r instanceof HTMLElement?(function(e,t){t.location=ce(e);var n=e.chain.map(function(e){return e.route}).indexOf(e.route);e.chain[n].element=t}(e,r),Promise.resolve(e)):r.redirect?this.__redirect(r.redirect,e.__redirectCount).then(function(e){return n.__findComponentContextAfterAllRedirects(e)}):r instanceof Error?Promise.reject(r):Promise.reject(new Error(h('Invalid route resolution result for path "'.concat(e.pathname,'". ')+'Expected redirect object or HTML element, but got: "'.concat(function(e){if("object"!==t(e))return String(e);var n=Object.prototype.toString.call(e).match(/ (.*)\]$/)[1];return"Object"===n||"Array"===n?"".concat(n," ").concat(JSON.stringify(e)):n}(r),'". ')+"Double check the action return value for the route.")))}},{key:"__amendWithOnBeforeCallbacks",value:function(e){var t=this;return this.__runOnBeforeCallbacks(e).then(function(n){return n===t.__previousContext||n===e?n:t.__fullyResolveChain(n)})}},{key:"__runOnBeforeCallbacks",value:function(e){var t=this,n=this.__previousContext||{},r=n.chain||[],o=e.chain,a=Promise.resolve(),i=function(){return{cancel:!0}},c=function(t){return ue(e,t)};if(e.__divergedChainIndex=0,e.__skipAttach=!1,r.length){for(var u=0;u<Math.min(r.length,o.length)&&(r[u].route===o[u].route&&(r[u].path===o[u].path||r[u].element===o[u].element)&&this.__isReusableElement(r[u].element,o[u].element));u=++e.__divergedChainIndex);e.__skipAttach=o.length===r.length&&e.__divergedChainIndex==o.length&&this.__isReusableElement(e.result,n.result);for(var l=r.length-1;!e.__skipAttach&&l>=e.__divergedChainIndex;l--){var s=ce(e);a=a.then(se("onBeforeLeave",[s,{prevent:i},this],r[l].element)).then(function(e){if(!(e||{}).redirect)return e})}}for(var h=e.__divergedChainIndex;!e.__skipAttach&&h<o.length;h++){var f=ce(e,o[h].route);a=a.then(se("onBeforeEnter",[f,{prevent:i,redirect:c},this],o[h].element))}return a.then(function(n){if(n){if(n.cancel)return t.__previousContext;if(n.redirect)return t.__redirect(n.redirect,e.__redirectCount)}return e})}},{key:"__isReusableElement",value:function(e,t){return!(!e||!t)&&(this.__renderedElements.get(t)?e.localName===t.localName:e===t)}},{key:"__redirect",value:function(e,t){if(t>256)throw new Error(h("Too many redirects when rendering ".concat(e.from)));return this.resolve({pathname:this.urlForPath(e.pathname,e.params),redirectFrom:e.from,__redirectCount:(t||0)+1})}},{key:"__ensureOutlet",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.__outlet;if(!(e instanceof Node))throw new TypeError(h("Expected router outlet to be a valid DOM Node (but got ".concat(e,")")))}},{key:"__updateBrowserHistory",value:function(e,t){var n=e.pathname,r=e.search,o=void 0===r?"":r,a=e.hash,i=void 0===a?"":a;if(window.location.pathname!==n||window.location.search!==o||window.location.hash!==i){var c=t?"replaceState":"pushState";window.history[c](null,document.title,n+o+i),window.dispatchEvent(new PopStateEvent("popstate",{state:"vaadin-router-ignore"}))}}},{key:"__addAppearingContent",value:function(e,t){this.__ensureOutlet(),this.__removeAppearingContent();for(var n=this.__outlet,r=0;r<e.__divergedChainIndex;r++){var o=t&&t.chain[r].element;if(o){if(o.parentNode!==n)break;e.chain[r].element=o,n=o}}this.__appearingContent=[],this.__disappearingContent=Array.from(n.children).filter(function(t){return t!==e.result});for(var a=n,i=e.__divergedChainIndex;i<e.chain.length;i++){var c=e.chain[i].element;c&&(a.appendChild(c),a===n&&this.__appearingContent.push(c),a=c)}}},{key:"__removeDisappearingContent",value:function(){this.__disappearingContent&&he(this.__disappearingContent),this.__disappearingContent=null,this.__appearingContent=null}},{key:"__removeAppearingContent",value:function(){this.__disappearingContent&&this.__appearingContent&&(he(this.__appearingContent),this.__disappearingContent=null,this.__appearingContent=null)}},{key:"__runOnAfterLeaveCallbacks",value:function(e,t){if(t)for(var n=t.chain.length-1;n>=e.__divergedChainIndex;n--){var r=t.chain[n].element;if(r)try{var o=ce(e);le(r.onAfterLeave,[o,{},t.resolver],r)}finally{this.__disappearingContent.indexOf(r)>-1&&he(r.children)}}}},{key:"__runOnAfterEnterCallbacks",value:function(e){for(var t=e.__divergedChainIndex;t<e.chain.length;t++){var n=e.chain[t].element||{},r=ce(e,e.chain[t].route);le(n.onAfterEnter,[r,{},e.resolver],n)}}},{key:"__animateIfNeeded",value:function(e){for(var t,n=(this.__disappearingContent||[])[0],r=(this.__appearingContent||[])[0],o=[],a=e.chain,i=a.length;i>0;i--)if(a[i-1].route.animate){t=a[i-1].route.animate;break}if(n&&r&&t){var c=w(t)&&t.leave||"leaving",u=w(t)&&t.enter||"entering";o.push(ae(n,c)),o.push(ae(r,u))}return Promise.all(o).then(function(){return e})}},{key:"subscribe",value:function(){window.addEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"unsubscribe",value:function(){window.removeEventListener("vaadin-router-go",this.__navigationEventHandler)}},{key:"__onNavigationEvent",value:function(e){var t=e?e.detail:window.location,n=t.pathname,r=t.search,o=t.hash;E(this.__normalizePathname(n))&&(e&&e.preventDefault&&e.preventDefault(),this.render({pathname:n,search:r,hash:o},!0))}},{key:"urlForName",value:function(e,t){return this.__urlForName||(this.__urlForName=ee(this)),fe(this.__urlForName(e,t),this)}},{key:"urlForPath",value:function(e,t){return fe(r.pathToRegexp.compile(e)(t),this)}}],[{key:"setTriggers",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];ne(t)}},{key:"go",value:function(e){return y("go",{pathname:e})}}]),r}(),ve=/\/\*\*\s+vaadin-dev-mode:start([\s\S]*)vaadin-dev-mode:end\s+\*\*\//i,_e=window.Vaadin&&window.Vaadin.Flow&&window.Vaadin.Flow.clients;function me(e,t){if("function"==typeof e){var n=ve.exec(e.toString());if(n)try{e=new Function(n[1])}catch(e){console.log("vaadin-development-mode-detector: uncommentAndRun() failed",e)}return e(t)}}window.Vaadin=window.Vaadin||{};var ge=function(e,t){if(window.Vaadin.developmentMode)return me(e,t)};function ye(){}void 0===window.Vaadin.developmentMode&&(window.Vaadin.developmentMode=function(){try{return!!localStorage.getItem("vaadin.developmentmode.force")||["localhost","127.0.0.1"].indexOf(window.location.hostname)>=0&&(_e?!function(){if(_e){var e=Object.keys(_e).map(function(e){return _e[e]}).filter(function(e){return e.productionMode});if(e.length>0)return!0}return!1}():!me(function(){return!0}))}catch(e){return!1}}());var we,be,Ee,xe;window.Vaadin=window.Vaadin||{},window.Vaadin.registrations=window.Vaadin.registrations||[],window.Vaadin.registrations.push({is:"@vaadin/router",version:"1.2.0"}),ge(ye),pe.NavigationTrigger={POPSTATE:R,CLICK:A},J.__ensureUrlAvailableOrPolyfilled=function(){if(void 0===we){try{var e=new URL("b","http://a");e.pathname="c",we="http://a/c"===e.href}catch(e){we=!1}we||(be=document.implementation.createHTMLDocument("url"),Ee=be.createElement("base"),be.head.appendChild(Ee),(xe=be.createElement("a")).origin||(Object.defineProperty(xe,"origin",{get:function(){var e=xe.protocol,t=xe.port,n="http:"===e&&"80"===t||"https:"===e&&"443"===t?xe.hostname:xe.host;return"".concat(e,"//").concat(n)}}),Object.defineProperty(xe,"pathname",{get:function(){return xe.href.slice(xe.origin.length)}})))}},J.__createUrl=function(e,t){return J.__ensureUrlAvailableOrPolyfilled(),we?new URL(e,t):(Ee.href=t,xe.href=e.replace(/ /g,"%20"),xe.href=xe.href,xe)},e.Resolver=J,e.Router=pe,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=vaadin-router.umd.min.js.map
{
"name": "@vaadin/router",
"version": "1.3.0",
"version": "1.4.0",
"description": "Small and powerful client-side router for Web Components. Framework-agnostic.",

@@ -24,2 +24,3 @@ "main": "dist/vaadin-router.js",

"index.polyfilled.js",
"interfaces.d.ts",
"src",

@@ -33,5 +34,6 @@ "dist/vaadin-router.*"

"lint:css": "stylelint demo/**/*.html",
"build": "rollup -c && npm-run-all --parallel build:minify.*",
"build": "rollup -c && npm-run-all --parallel build:minify.* build:typescript-declarations",
"build:minify.module": "uglifyjs dist/vaadin-router.umd.js -c -m --source-map content=dist/vaadin-router.umd.js.map,url=vaadin-router.umd.min.js.map --output dist/vaadin-router.umd.min.js",
"build:minify.browser": "uglifyjs dist/vaadin-router.js -c -m --mangle-props regex=/^__/ --toplevel --source-map --output dist/vaadin-router.min.js",
"build:typescript-declarations": "gen-typescript-declarations --outDir . --verify",
"build:watch": "rollup -c -w",

@@ -41,8 +43,10 @@ "start": "npm run build && polyserve --port 8000",

"start:watch": "npm-run-all --parallel build:watch start start:browser-sync",
"test": "wct && npm run test:coverage",
"test": "wct && npm run test:coverage && npm run test:typescript-declarations",
"test:coverage": "wct --profile=coverage",
"test:typescript-declarations": "tsc --noEmit",
"size-control": "bundlesize",
"docs": "npm run build && npm run docs:analyze && gulp docs",
"docs:analyze": "polymer analyze dist/vaadin-router.js src/documentation/*.js > analysis.json",
"browserslist": "browserslist && browserslist --coverage"
"browserslist": "browserslist && browserslist --coverage",
"prepare": "npm run build"
},

@@ -73,2 +77,4 @@ "bundlesize": [

"@babel/preset-env": "^7.5.5",
"@polymer/gen-typescript-declarations": "^1.6.2",
"@types/form-data": "^2.5.0",
"bower": "^1.8.8",

@@ -93,2 +99,3 @@ "browser-sync": "^2.26.7",

"stylelint-config-vaadin": "latest",
"typescript": "^3.5.3",
"uglify-es": "^3.3.9",

@@ -95,0 +102,0 @@ "wct-istanbul": "^0.14.3",

@@ -14,3 +14,3 @@ /**

*
* @memberof Vaadin.Router
* @memberof Router
* @summary Type declaration for the `router.location` property.

@@ -22,3 +22,3 @@ */

* The base URL used in the router. See [the `baseUrl` property
* ](#/classes/Vaadin.Router#property-baseUrl) in the Vaadin.Router.
* ](#/classes/Router#property-baseUrl) in the Router.
*

@@ -40,2 +40,18 @@ * @public

/**
* The query string portion of the current url.
*
* @public
* @type {!string}
*/
this.search;
/**
* The fragment identifier (including hash character) for the current page.
*
* @public
* @type {!string}
*/
this.hash;
/**
* (optional) The original pathname string in case if this location is a

@@ -55,3 +71,3 @@ * result of a redirect.

* See the **Redirects** section of the
* [live demos](#/classes/Vaadin.Router/demos/demo/index.html) for more
* [live demos](#/classes/Router/demos/demo/index.html) for more
* details.

@@ -76,3 +92,3 @@ *

* @public
* @type {?Vaadin.Router.Route}
* @type {?Router.Route}
*/

@@ -87,7 +103,7 @@ this.route;

* See the **Getting Started** section of the
* [live demos](#/classes/Vaadin.Router/demos/demo/index.html) for more
* [live demos](#/classes/Router/demos/demo/index.html) for more
* details on child routes and nested layouts.
*
* @public
* @type {!Array<!Vaadin.Router.Route>}
* @type {!Array<!Router.Route>}
*/

@@ -102,7 +118,7 @@ this.routes;

* See the **Route Parameters** section of the
* [live demos](#/classes/Vaadin.Router/demos/demo/index.html) for more
* [live demos](#/classes/Router/demos/demo/index.html) for more
* details.
*
* @public
* @type {!Object}
* @type {!Router.IndexedParams}
*/

@@ -119,3 +135,3 @@ this.params;

* @type {Function}
* @param {?Object} params optional object with parameters to override.
* @param {Router.Params=} params optional object with parameters to override.
* Named parameters are passed by name (`params[name] = value`), unnamed

@@ -122,0 +138,0 @@ * parameters are passed by index (`params[index] = value`).

/**
* @namespace Vaadin
* @namespace Router
*/
window.Vaadin = {};
/**
* @namespace Vaadin.Router
* @memberOf Vaadin
* @summary Type declaration for properties and method parameters of the
* Vaadin.Router class.
*/
window.Vaadin.Router = {};
const Router = {};

@@ -13,3 +13,3 @@ /**

*
* Check the [documentation on the `Vaadin.Router` class](#/classes/Vaadin.Router)
* Check the [documentation on the `Router` class](#/classes/Router)
* to learn more.

@@ -60,5 +60,4 @@ *

* Other examples can be found in the
* [live demos](#/classes/Vaadin.Router/demos/demo/index.html) and tests.
* [live demos](#/classes/Router/demos/demo/index.html) and tests.
*
* @memberof Vaadin
*/

@@ -65,0 +64,0 @@ export class WebComponentInterface {

@@ -52,3 +52,2 @@ /**

/**
* @memberof Vaadin
*/

@@ -74,3 +73,3 @@ class Resolver {

*
* @return {!Array<!Route>}
* @return {!Array<!Router.Route>}
*/

@@ -84,3 +83,3 @@ getRoutes() {

*
* @param {!Array<!Route>|!Route} routes a single route or an array of those
* @param {!Array<!Router.Route>|!Router.Route} routes a single route or an array of those
* (the array is shallow copied)

@@ -98,5 +97,5 @@ */

*
* @param {!Array<!Route>|!Route} routes a single route or an array of those
* @param {!Array<!Router.Route>|!Router.Route} routes a single route or an array of those
* (the array is shallow copied)
* @return {!Array<!Route>}
* @return {!Array<!Router.Route>}
* @protected

@@ -103,0 +102,0 @@ */

@@ -31,3 +31,3 @@ import Resolver from './resolver/resolver.js';

function createLocation({pathname = '', chain = [], params = {}, redirectFrom, resolver}, route) {
function createLocation({pathname = '', search = '', hash = '', chain = [], params = {}, redirectFrom, resolver}, route) {
const routes = chain.map(item => item.route);

@@ -37,2 +37,4 @@ return {

pathname,
search,
hash,
routes,

@@ -143,3 +145,3 @@ route: route || routes.length && routes[routes.length - 1] || null,

* the `baseUrl` property
* ](#/classes/Vaadin.Router#property-baseUrl)
* ](#/classes/Router#property-baseUrl)
*

@@ -149,14 +151,13 @@ * The Router instance is automatically subscribed to navigation events

*
* See [Live Examples](#/classes/Vaadin.Router/demos/demo/index.html) for the detailed usage demo and code snippets.
* See [Live Examples](#/classes/Router/demos/demo/index.html) for the detailed usage demo and code snippets.
*
* See also detailed API docs for the following methods, for the advanced usage:
*
* * [setOutlet](#/classes/Vaadin.Router#method-setOutlet) – should be used to configure the outlet.
* * [setTriggers](#/classes/Vaadin.Router#method-setTriggers) – should be used to configure the navigation events.
* * [setRoutes](#/classes/Vaadin.Router#method-setRoutes) – should be used to configure the routes.
* * [setOutlet](#/classes/Router#method-setOutlet) – should be used to configure the outlet.
* * [setTriggers](#/classes/Router#method-setTriggers) – should be used to configure the navigation events.
* * [setRoutes](#/classes/Router#method-setRoutes) – should be used to configure the routes.
*
* Only `setRoutes` has to be called manually, others are automatically invoked when creating a new instance.
*
* @memberof Vaadin
* @extends Vaadin.Resolver
* @extends Resolver
* @demo demo/index.html

@@ -175,7 +176,7 @@ * @summary JavaScript class that renders different DOM content depending on

* ```
* const router = new Vaadin.Router();
* const router = new Router();
* router.setOutlet(outlet);
* ```
* @param {?Node} outlet
* @param {?RouterOptions} options
* @param {?Node=} outlet
* @param {?Router.Options=} options
*/

@@ -210,3 +211,3 @@ constructor(outlet, options) {

* @public
* @type {!Promise<!Vaadin.Router.Location>}
* @type {!Promise<!Router.Location>}
*/

@@ -219,7 +220,7 @@ this.ready;

* pathname, active routes, parameters. See the
* [Location type declaration](#/classes/Vaadin.Router.Location)
* [Location type declaration](#/classes/Router.Location)
* for more details.
*
* @public
* @type {!Vaadin.Router.Location}
* @type {!Router.Location}
*/

@@ -233,2 +234,3 @@ this.location;

this.subscribe();
this.__renderedElements = new WeakMap();
}

@@ -256,3 +258,7 @@

redirect: path => createRedirect(context, path),
component: component => document.createElement(component)
component: (component) => {
const element = document.createElement(component);
this.__renderedElements.set(element, true);
return element;
}
};

@@ -266,3 +272,3 @@

// end the resolution, despite the result is not empty. Checking
// the result with a whitelist of values that end the resulution.
// the result with a whitelist of values that end the resolution.
if (result instanceof HTMLElement ||

@@ -352,7 +358,7 @@ result.redirect ||

* and other route config properties are ignored.
* See also **Route Actions** section in [Live Examples](#/classes/Vaadin.Router/demos/demo/index.html).
* See also **Route Actions** section in [Live Examples](#/classes/Router/demos/demo/index.html).
*
* * `redirect` – other route's path to redirect to. Passes all route parameters to the redirect target.
* The target route should also be defined.
* See also **Redirects** section in [Live Examples](#/classes/Vaadin.Router/demos/demo/index.html).
* See also **Redirects** section in [Live Examples](#/classes/Router/demos/demo/index.html).
*

@@ -365,3 +371,3 @@ * * `bundle` – string containing the path to `.js` or `.mjs` bundle to load before resolving the route,

* Any error, e.g. 404 while loading bundle will cause route resolution to throw.
* See also **Code Splitting** section in [Live Examples](#/classes/Vaadin.Router/demos/demo/index.html).
* See also **Code Splitting** section in [Live Examples](#/classes/Router/demos/demo/index.html).
*

@@ -375,3 +381,3 @@ * * `component` – the tag name of the Web Component to resolve the route to.

* * `name` – the string name of the route to use in the
* [`router.urlForName(name, params)`](#/classes/Vaadin.Router#method-urlForName)
* [`router.urlForName(name, params)`](#/classes/Router#method-urlForName)
* navigation helper method.

@@ -406,8 +412,16 @@ *

*
* @param {!Array<!Object>|!Object} routes a single route or an array of those
* @param {!Array<!Router.Route>|!Router.Route} routes a single route or an array of those
* @param {?boolean} skipRender configure the router but skip rendering the
* route corresponding to the current `window.location` values
*
* @return {!Promise<!Node>}
*/
setRoutes(routes) {
setRoutes(routes, skipRender = false) {
this.__previousContext = undefined;
this.__urlForName = undefined;
super.setRoutes(routes);
this.__onNavigationEvent();
if (!skipRender) {
this.__onNavigationEvent();
}
return this.ready;
}

@@ -432,2 +446,4 @@

* to pass to the resolver.
* @param {boolean=} shouldUpdateHistory
* update browser history with the rendered location
* @return {!Promise<!Node>}

@@ -437,5 +453,7 @@ */

const renderId = ++this.__lastStartedRenderId;
const pathname = pathnameOrContext.pathname || pathnameOrContext;
const search = pathnameOrContext.search || '';
const hash = pathnameOrContext.hash || '';
const {
pathname,
search,
hash
} = isString(pathnameOrContext) ? {pathname: pathnameOrContext, search: '', hash: ''} : pathnameOrContext;

@@ -457,2 +475,5 @@ // Find the first route that resolves to a non-empty result

if (context === previousContext) {
// Replace the history with the previous context
// to make sure the URL stays the same.
this.__updateBrowserHistory(previousContext, true);
return this.location;

@@ -468,2 +489,7 @@ }

// Skip detaching/re-attaching there are no render changes
if (context.__skipAttach) {
return this.location;
}
this.__addAppearingContent(context, previousContext);

@@ -581,9 +607,8 @@ const animationDone = this.__animateIfNeeded(context);

newContext.__divergedChainIndex = 0;
newContext.__skipAttach = false;
if (previousChain.length) {
for (let i = 0; i < Math.min(previousChain.length, newChain.length); i = ++newContext.__divergedChainIndex) {
if (previousChain[i].route !== newChain[i].route
|| previousChain[i].path !== newChain[i].path
|| (previousChain[i].element && previousChain[i].element.localName)
!== (newChain[i].element && newChain[i].element.localName)
) {
|| previousChain[i].path !== newChain[i].path && previousChain[i].element !== newChain[i].element
|| !this.__isReusableElement(previousChain[i].element, newChain[i].element)) {
break;

@@ -593,3 +618,10 @@ }

for (let i = previousChain.length - 1; i >= newContext.__divergedChainIndex; i--) {
// Skip re-attaching and notifications if element and chain do not change
newContext.__skipAttach =
// Same route chain
newChain.length === previousChain.length && newContext.__divergedChainIndex == newChain.length &&
// Same element
this.__isReusableElement(newContext.result, previousContext.result);
for (let i = previousChain.length - 1; !newContext.__skipAttach && i >= newContext.__divergedChainIndex; i--) {
const location = createLocation(newContext);

@@ -606,3 +638,3 @@ callbacks = callbacks

for (let i = newContext.__divergedChainIndex; i < newChain.length; i++) {
for (let i = newContext.__divergedChainIndex; !newContext.__skipAttach && i < newChain.length; i++) {
const location = createLocation(newContext, newChain[i].route);

@@ -625,2 +657,11 @@ callbacks = callbacks.then(amend('onBeforeEnter', [location, {prevent, redirect}, this], newChain[i].element));

__isReusableElement(element, otherElement) {
if (element && otherElement) {
return this.__renderedElements.get(otherElement)
? element.localName === otherElement.localName
: element === otherElement;
}
return false;
}
__redirect(redirectData, counter) {

@@ -683,4 +724,4 @@ if (counter > MAX_REDIRECT_COUNT) {

// - and those that should remain
this.__disappearingContent = Array.from(deepestCommonParent.children);
this.__appearingContent = [];
this.__disappearingContent = Array.from(deepestCommonParent.children).filter(e => e !== context.result);

@@ -738,3 +779,5 @@ // Add new elements (starting after the deepest common parent) to the DOM.

} finally {
removeDomNodes(currentComponent.children);
if (this.__disappearingContent.indexOf(currentComponent) > -1) {
removeDomNodes(currentComponent.children);
}
}

@@ -799,3 +842,3 @@ }

__onNavigationEvent(event) {
const pathname = event ? event.detail.pathname : window.location.pathname;
const {pathname, search, hash} = event ? event.detail : window.location;
if (isString(this.__normalizePathname(pathname))) {

@@ -805,3 +848,3 @@ if (event && event.preventDefault) {

}
this.render(event ? event.detail : {pathname}, true);
this.render({pathname, search, hash}, true);
}

@@ -811,3 +854,3 @@ }

/**
* Configures what triggers Vaadin.Router navigation events:
* Configures what triggers Router navigation events:
* - `POPSTATE`: popstate events on the current `window`

@@ -823,5 +866,5 @@ * - `CLICK`: click events on `<a>` links leading to the current page

*
* See also **Navigation Triggers** section in [Live Examples](#/classes/Vaadin.Router/demos/demo/index.html).
* See also **Navigation Triggers** section in [Live Examples](#/classes/Router/demos/demo/index.html).
*
* @param {...NavigationTrigger} triggers
* @param {...Router.NavigationTrigger} triggers
*/

@@ -836,3 +879,3 @@ static setTriggers(...triggers) {

*
* The route is searched in all the Vaadin.Router instances subscribed to
* The route is searched in all the Router instances subscribed to
* navigation events.

@@ -846,3 +889,3 @@ *

* @param {!string} name the route name or the route’s `component` name.
* @param {?Object} params Optional object with route path parameters.
* @param {Router.Params=} params Optional object with route path parameters.
* Named parameters are passed by name (`params[name] = value`), unnamed

@@ -868,3 +911,3 @@ * parameters are passed by index (`params[index] = value`).

* @param {!string} path string route path declared in [express.js syntax](https://expressjs.com/en/guide/routing.html#route-paths").
* @param {?Object} params Optional object with route path parameters.
* @param {Router.Params=} params Optional object with route path parameters.
* Named parameters are passed by name (`params[name] = value`), unnamed

@@ -884,3 +927,3 @@ * parameters are passed by index (`params[index] = value`).

* Triggers navigation to a new path. Returns a boolean without waiting until
* the navigation is complete. Returns `true` if at least one `Vaadin.Router`
* the navigation is complete. Returns `true` if at least one `Router`
* has handled the navigation (was subscribed and had `baseUrl` matching

@@ -887,0 +930,0 @@ * the `pathname` argument), otherwise returns `false`.

@@ -97,3 +97,3 @@ import {fireRouterEvent} from '../utils.js';

*
* @memberOf Vaadin.Router.Triggers
* @memberOf Router.Triggers
* @type {NavigationTrigger}

@@ -100,0 +100,0 @@ */

@@ -30,3 +30,3 @@ import {fireRouterEvent, isFunction} from '../utils.js';

*
* @memberOf Vaadin.Router.Triggers
* @memberOf Router.Triggers
* @type {NavigationTrigger}

@@ -33,0 +33,0 @@ */

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc