This repository has been archived by the owner on Dec 19, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathko-component-router.min.js
2 lines (2 loc) · 40.8 KB
/
ko-component-router.min.js
1
2
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("knockout")):"function"==typeof define&&define.amd?define(["exports","knockout"],e):e((t.ko=t.ko||{},t.ko.router={}),t.ko)}(this,function(t,e){"use strict";function r(t,e,r,n){return new(r||(r=Promise))(function(o,i){function u(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(u,a)}c((n=n.apply(t,e||[])).next())})}function n(t,e){function r(t){return function(e){return n([t,e])}}function n(r){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(u=i[2&r[0]?"return":r[0]?"throw":"next"])&&!(u=u.call(i,r[1])).done)return u;switch(i=0,u&&(r=[0,u.value]),r[0]){case 0:case 1:u=r;break;case 4:return c.label++,{value:r[1],done:!1};case 5:c.label++,i=r[1],r=[0];continue;case 7:r=c.ops.pop(),c.trys.pop();continue;default:if(u=c.trys,!(u=u.length>0&&u[u.length-1])&&(6===r[0]||2===r[0])){c=0;continue}if(3===r[0]&&(!u||r[1]>u[0]&&r[1]<u[3])){c.label=r[1];break}if(6===r[0]&&c.label<u[1]){c.label=u[1],u=r;break}if(u&&c.label<u[2]){c.label=u[2],c.ops.push(r);break}u[2]&&c.ops.pop(),c.trys.pop();continue}r=e.call(t,c)}catch(t){r=[6,t],i=0}finally{o=u=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}var o,i,u,a,c={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return a={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a}function o(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function i(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function u(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function c(t,e,r){function n(t){l[t]&&(f[t]=function(e){return new Promise(function(r,n){h.push([t,e,r,n])>1||o(t,e)})})}function o(t,e){try{i(l[t](e))}catch(t){s(h[0][3],t)}}function i(t){t.value instanceof a?Promise.resolve(t.value.v).then(u,c):s(h[0][2],t)}function u(t){o("next",t)}function c(t){o("throw",t)}function s(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var f,l=r.apply(t,e||[]),h=[];return f={},n("next"),n("throw"),n("return"),f[Symbol.asyncIterator]=function(){return this},f}function s(t,e){return e={exports:{}},t(e,e.exports),e.exports}function f(t){var e=Pr.call(t,Ar),r=t[Ar];try{t[Ar]=void 0;var n=!0}catch(t){}var o=$r.call(t);return n&&(e?t[Ar]=r:delete t[Ar]),o}function l(t){return Sr.call(t)}function h(t){return null==t?void 0===t?Er:Rr:zr&&zr in Object(t)?f(t):l(t)}function p(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function d(t){if(!p(t))return!1;var e=h(t);return e==Mr||e==Dr||e==Cr||e==Tr}function v(t){return void 0===t}function b(t,e){return function(r){return t(e(r))}}function y(t){return null!=t&&"object"==typeof t}function g(t){if(!y(t)||h(t)!=Nr)return!1;var e=Br(t);if(null===e)return!0;var r=Ur.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Lr.call(r)==qr}function _(){}function m(t,e,r){return t===t&&(void 0!==r&&(t=t<=r?t:r),void 0!==e&&(t=t>=e?t:e)),t}function w(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}function j(t){return"symbol"==typeof t||y(t)&&h(t)==Vr}function x(t){if("string"==typeof t)return t;if(Qr(t))return w(t,x)+"";if(j(t))return Gr?Gr.call(t):"";var e=t+"";return"0"==e&&1/t==-Wr?"-0":e}function O(t){if("number"==typeof t)return t;if(j(t))return Kr;if(p(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=p(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Jr,"");var r=Yr.test(t);return r||Zr.test(t)?tn(t.slice(2),r?2:8):Xr.test(t)?Kr:+t}function P(t){if(!t)return 0===t?t:0;if((t=O(t))===en||t===-en){return(t<0?-1:1)*rn}return t===t?t:0}function $(t){var e=P(t),r=e%1;return e===e?r?e-r:e:0}function A(t){return null==t?"":x(t)}function k(t,e,r){return t=A(t),r=null==r?0:m($(r),0,t.length),e=x(e),t.slice(r,r+e.length)==e}function S(t){return!0===t||!1===t||y(t)&&h(t)==nn}function R(t){return"string"==typeof t||!Qr(t)&&y(t)&&h(t)==on}function E(){if(!arguments.length)return[];var t=arguments[0];return Qr(t)?t:[t]}function z(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function C(t){return y(t)&&h(t)==un}function M(t){return Qr(t)||fn(t)||!!(ln&&t&&t[ln])}function D(t,e,r,n,o){var i=-1,u=t.length;for(r||(r=M),o||(o=[]);++i<u;){var a=t[i];e>0&&r(a)?e>1?D(a,e-1,r,n,o):z(o,a):n||(o[o.length]=a)}return o}function T(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function B(){var t=arguments.length;if(!t)return[];for(var e=Array(t-1),r=arguments[0],n=t;n--;)e[n-1]=arguments[n];return z(Qr(r)?T(r):[r],D(e,1))}function N(t){return!!pn&&pn in t}function I(t){if(null!=t){try{return vn.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function F(t){return!(!p(t)||N(t))&&(d(t)?jn:yn).test(I(t))}function L(t,e){return null==t?void 0:t[e]}function U(t,e){var r=L(t,e);return F(r)?r:void 0}function q(t,e,r){"__proto__"==e&&xn?xn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Q(t,e){return t===e||t!==t&&e!==e}function V(t,e,r){var n=t[e];Pn.call(t,e)&&Q(n,r)&&(void 0!==r||e in t)||q(t,e,r)}function W(t,e,r,n){var o=!r;r||(r={});for(var i=-1,u=e.length;++i<u;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?q(r,a,c):V(r,a,c)}return r}function H(t){return t}function G(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function K(t,e,r){return e=$n(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=$n(n.length-e,0),u=Array(i);++o<i;)u[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(u),G(t,this,a)}}function J(t){return function(){return t}}function X(t,e){return En(K(t,e,H),t+"")}function Y(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=zn}function Z(t){return null!=t&&Y(t.length)&&!d(t)}function tt(t,e){return!!(e=null==e?Cn:e)&&("number"==typeof t||Mn.test(t))&&t>-1&&t%1==0&&t<e}function et(t,e,r){if(!p(r))return!1;var n=typeof e;return!!("number"==n?Z(r)&&tt(e,r.length):"string"==n&&e in r)&&Q(r[e],t)}function rt(t){return X(function(e,r){var n=-1,o=r.length,i=o>1?r[o-1]:void 0,u=o>2?r[2]:void 0;for(i=t.length>3&&"function"==typeof i?(o--,i):void 0,u&&et(r[0],r[1],u)&&(i=o<3?void 0:i,o=1),e=Object(e);++n<o;){var a=r[n];a&&t(e,a,n,i)}return e})}function nt(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function ot(){return!1}function it(t){return y(t)&&Y(t.length)&&!!Ln[h(t)]}function ut(t,e){var r=Qr(t),n=!r&&fn(t),o=!r&&!n&&Fn(t),i=!r&&!n&&!o&&Gn(t),u=r||n||o||i,a=u?nt(t.length,String):[],c=a.length;for(var s in t)!e&&!Jn.call(t,s)||u&&("length"==s||o&&("offset"==s||"parent"==s)||i&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||tt(s,c))||a.push(s);return a}function at(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Xn)}function ct(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}function st(t){if(!p(t))return ct(t);var e=at(t),r=[];for(var n in t)("constructor"!=n||!e&&Zn.call(t,n))&&r.push(n);return r}function ft(t){return Z(t)?ut(t,!0):st(t)}function lt(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var u=t[r];e(u,r,t)&&(i[o++]=u)}return i}function ht(t){if(!at(t))return no(t);var e=[];for(var r in Object(t))io.call(t,r)&&"constructor"!=r&&e.push(r);return e}function pt(t){return Z(t)?ut(t):ht(t)}function dt(t,e){return t&&ro(t,e,pt)}function vt(){this.__data__=[],this.size=0}function bt(t,e){for(var r=t.length;r--;)if(Q(t[r][0],e))return r;return-1}function yt(t){var e=this.__data__,r=bt(e,t);return!(r<0)&&(r==e.length-1?e.pop():co.call(e,r,1),--this.size,!0)}function gt(t){var e=this.__data__,r=bt(e,t);return r<0?void 0:e[r][1]}function _t(t){return bt(this.__data__,t)>-1}function mt(t,e){var r=this.__data__,n=bt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}function wt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function jt(){this.__data__=new wt,this.size=0}function xt(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}function Ot(t){return this.__data__.get(t)}function Pt(t){return this.__data__.has(t)}function $t(){this.__data__=fo?fo(null):{},this.size=0}function At(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function kt(t){var e=this.__data__;if(fo){var r=e[t];return r===lo?void 0:r}return po.call(e,t)?e[t]:void 0}function St(t){var e=this.__data__;return fo?void 0!==e[t]:bo.call(e,t)}function Rt(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=fo&&void 0===e?yo:e,this}function Et(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function zt(){this.size=0,this.__data__={hash:new Et,map:new(so||wt),string:new Et}}function Ct(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function Mt(t,e){var r=t.__data__;return Ct(e)?r["string"==typeof e?"string":"hash"]:r.map}function Dt(t){var e=Mt(this,t).delete(t);return this.size-=e?1:0,e}function Tt(t){return Mt(this,t).get(t)}function Bt(t){return Mt(this,t).has(t)}function Nt(t,e){var r=Mt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}function It(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Ft(t,e){var r=this.__data__;if(r instanceof wt){var n=r.__data__;if(!so||n.length<go-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new It(n)}return r.set(t,e),this.size=r.size,this}function Lt(t){var e=this.__data__=new wt(t);this.size=e.size}function Ut(t){return this.__data__.set(t,_o),this}function qt(t){return this.__data__.has(t)}function Qt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new It;++e<r;)this.add(t[e])}function Vt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Wt(t,e){return t.has(e)}function Ht(t,e,r,n,o,i){var u=r&mo,a=t.length,c=e.length;if(a!=c&&!(u&&c>a))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,h=r&wo?new Qt:void 0;for(i.set(t,e),i.set(e,t);++f<a;){var p=t[f],d=e[f];if(n)var v=u?n(d,p,f,e,t,i):n(p,d,f,t,e,i);if(void 0!==v){if(v)continue;l=!1;break}if(h){if(!Vt(e,function(t,e){if(!Wt(h,e)&&(p===t||o(p,t,r,n,i)))return h.push(e)})){l=!1;break}}else if(p!==d&&!o(p,d,r,n,i)){l=!1;break}}return i.delete(t),i.delete(e),l}function Gt(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Kt(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}function Jt(t,e,r,n,o,i,u){switch(r){case Do:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Mo:return!(t.byteLength!=e.byteLength||!i(new jo(t),new jo(e)));case Po:case $o:case So:return Q(+t,+e);case Ao:return t.name==e.name&&t.message==e.message;case Ro:case zo:return t==e+"";case ko:var a=Gt;case Eo:var c=n&xo;if(a||(a=Kt),t.size!=e.size&&!c)return!1;var s=u.get(t);if(s)return s==e;n|=Oo,u.set(t,e);var f=Ht(a(t),a(e),n,o,i,u);return u.delete(t),f;case Co:if(Bo)return Bo.call(t)==Bo.call(e)}return!1}function Xt(t,e,r){var n=e(t);return Qr(t)?n:z(n,r(t))}function Yt(){return[]}function Zt(t){return Xt(t,pt,Lo)}function te(t,e,r,n,o,i){var u=r&Uo,a=Zt(t),c=a.length;if(c!=Zt(e).length&&!u)return!1;for(var s=c;s--;){var f=a[s];if(!(u?f in e:Qo.call(e,f)))return!1}var l=i.get(t);if(l&&i.get(e))return l==e;var h=!0;i.set(t,e),i.set(e,t);for(var p=u;++s<c;){f=a[s];var d=t[f],v=e[f];if(n)var b=u?n(v,d,f,e,t,i):n(d,v,f,t,e,i);if(!(void 0===b?d===v||o(d,v,r,n,i):b)){h=!1;break}p||(p="constructor"==f)}if(h&&!p){var y=t.constructor,g=e.constructor;y!=g&&"constructor"in t&&"constructor"in e&&!("function"==typeof y&&y instanceof y&&"function"==typeof g&&g instanceof g)&&(h=!1)}return i.delete(t),i.delete(e),h}function ee(t,e,r,n,o,i){var u=Qr(t),a=Qr(e),c=u?oi:ei(t),s=a?oi:ei(e);c=c==ni?ii:c,s=s==ni?ii:s;var f=c==ii,l=s==ii,h=c==s;if(h&&Fn(t)){if(!Fn(e))return!1;u=!0,f=!1}if(h&&!f)return i||(i=new Lt),u||Gn(t)?Ht(t,e,r,n,o,i):Jt(t,e,c,r,n,o,i);if(!(r&ri)){var p=f&&ai.call(t,"__wrapped__"),d=l&&ai.call(e,"__wrapped__");if(p||d){var v=p?t.value():t,b=d?e.value():e;return i||(i=new Lt),o(v,b,r,n,i)}}return!!h&&(i||(i=new Lt),te(t,e,r,n,o,i))}function re(t,e,r,n,o){return t===e||(null==t||null==e||!y(t)&&!y(e)?t!==t&&e!==e:ee(t,e,r,n,re,o))}function ne(t,e,r,n){var o=r.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=r[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){a=r[o];var c=a[0],s=t[c],f=a[1];if(u&&a[2]){if(void 0===s&&!(c in t))return!1}else{var l=new Lt;if(n)var h=n(s,f,c,t,e,l);if(!(void 0===h?re(f,s,ci|si,n,l):h))return!1}}return!0}function oe(t){return t===t&&!p(t)}function ie(t){for(var e=pt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,oe(o)]}return e}function ue(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function ae(t){var e=ie(t);return 1==e.length&&e[0][2]?ue(e[0][0],e[0][1]):function(r){return r===t||ne(r,t,e)}}function ce(t,e){if(Qr(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!j(t))||(li.test(t)||!fi.test(t)||null!=e&&t in Object(e))}function se(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError(hi);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return r.cache=i.set(o,u)||i,u};return r.cache=new(se.Cache||It),r}function fe(t,e){return Qr(t)?t:ce(t,e)?[t]:yi(A(t))}function le(t){if("string"==typeof t||j(t))return t;var e=t+"";return"0"==e&&1/t==-gi?"-0":e}function he(t,e){e=fe(e,t);for(var r=0,n=e.length;null!=t&&r<n;)t=t[le(e[r++])];return r&&r==n?t:void 0}function pe(t,e,r){var n=null==t?void 0:he(t,e);return void 0===n?r:n}function de(t,e){return null!=t&&e in Object(t)}function ve(t,e,r){e=fe(e,t);for(var n=-1,o=e.length,i=!1;++n<o;){var u=le(e[n]);if(!(i=null!=t&&r(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&Y(o)&&tt(u,o)&&(Qr(t)||fn(t))}function be(t,e){return null!=t&&ve(t,e,de)}function ye(t,e){return ce(t)&&oe(e)?ue(le(t),e):function(r){var n=pe(r,t);return void 0===n&&n===e?be(r,t):re(e,n,_i|mi)}}function ge(t){return function(e){return null==e?void 0:e[t]}}function _e(t){return function(e){return he(e,t)}}function me(t){return ce(t)?ge(le(t)):_e(t)}function we(t){return"function"==typeof t?t:null==t?H:"object"==typeof t?Qr(t)?ye(t[0],t[1]):ae(t):me(t)}function je(t,e){var r=-1,n=Z(t)?Array(t.length):[];return uo(t,function(t,o,i){n[++r]=e(t,o,i)}),n}function xe(t,e){return(Qr(t)?w:je)(t,we(e,3))}function Oe(t,e){return D(xe(t,e),1)}function Pe(t,e){var r={};return e=we(e,3),dt(t,function(t,n,o){q(r,n,e(t,n,o))}),r}function $e(t,e,r,n){var o=-1,i=null==t?0:t.length;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function Ae(t,e,r,n,o){return o(t,function(t,o,i){r=n?(n=!1,t):e(r,t,o,i)}),r}function ke(t,e,r){var n=Qr(t)?$e:Ae,o=arguments.length<3;return n(t,we(e,4),r,o,uo)}function Se(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return r(this,void 0,void 0,function(){var r,i,a,c,s,f,l,h,p;return n(this,function(n){switch(n.label){case 0:r=0,i=!0,n.label=1;case 1:n.trys.push([1,6,7,8]),a=o(t),c=a.next(),n.label=2;case 2:return c.done?[3,5]:(s=c.value,r++,[4,De(s).apply(void 0,u(e))]);case 3:if(!1===(f=n.sent()))return i=!1,[3,5];n.label=4;case 4:return c=a.next(),[3,2];case 5:return[3,8];case 6:return l=n.sent(),h={error:l},[3,8];case 7:try{c&&!c.done&&(p=a.return)&&p.call(a)}finally{if(h)throw h.error}return[7];case 8:return[2,{count:r,success:i}]}})})}function Re(t,e){if(0===e.indexOf("//"))for(e=e.replace("//","/");!t.isRoot;)t=t.ctx.$parent.router;else for(0===e.indexOf("./")&&(e=e.replace("./","/"),t=t.ctx.$child.router);e&&e.match(/\/?\.\./i)&&!t.isRoot;)t=t.ctx.$parent.router,e=e.replace(/\/?\.\./i,"");return{router:t,path:e}}function Ee(t){var e=t.router,r=t.path;return e.ctx.base+r}function ze(t){for(var e=t.router,r=t.path,n=e.ctx;n;){if(n.router.isNavigating(),n.$child?!k(r,n.pathname):r!==n.pathname)return!1;r=r.substr(n.pathname.length)||"/",n=n.$child}return!0}function Ce(t){return"GeneratorFunction"===t.constructor.name}function Me(t){return!v(t)&&d(t.then)}function De(t){var e=this;return void 0===t&&(t=_),function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];return r(e,void 0,void 0,function(){var e,r,i;return n(this,function(n){switch(n.label){case 0:return e=function(){return t.length===o.length+1?new Promise(function(e){t.apply(void 0,u(o,[e]))}):t.apply(void 0,u(o))},r=e(),Me(r)?[4,r]:[3,2];case 1:return i=n.sent(),[3,3];case 2:i=r,n.label=3;case 3:return[2,i]}})})}}function Te(t){return Ce(t)?t:function(e){return c(this,arguments,function(){var r;return n(this,function(n){switch(n.label){case 0:return[4,a(De(t)(e))];case 1:return r=n.sent(),g(r)?[4,a(De(r.beforeRender)())]:[3,10];case 2:return[4,n.sent()];case 3:return n.sent(),[4,a(De(r.afterRender)())];case 4:return[4,n.sent()];case 5:return n.sent(),[4,a(De(r.beforeDispose)())];case 6:return[4,n.sent()];case 7:return n.sent(),[4,a(De(r.afterDispose)())];case 8:return[4,n.sent()];case 9:return n.sent(),[3,12];case 10:return[4,r];case 11:n.sent(),n.label=12;case 12:return[2]}})})}}function Be(t){for(;!v(t);){if(!v(t.$router))return t.$router;t=t.$parentContext}return Ei.head}function Ne(t,e){for(var r,n=[],o=0,i=0,u="",a=e&&e.delimiter||Ai,c=e&&e.delimiters||ki,s=!1;null!==(r=Si.exec(t));){var f=r[0],l=r[1],h=r.index;if(u+=t.slice(i,h),i=h+f.length,l)u+=l[1],s=!0;else{var p="",d=t[i],v=r[2],b=r[3],y=r[4],g=r[5];if(!s&&u.length){var _=u.length-1;c.indexOf(u[_])>-1&&(p=u[_],u=u.slice(0,_))}u&&(n.push(u),u="",s=!1);var m=""!==p&&void 0!==d&&d!==p,w="+"===g||"*"===g,j="?"===g||"*"===g,x=p||a,O=b||y;n.push({name:v||o++,prefix:p,delimiter:x,optional:j,repeat:w,partial:m,pattern:O?Ue(O):"[^"+Le(x)+"]+?"})}}return(u||i<t.length)&&n.push(u+t.substr(i)),n}function Ie(t,e){return Fe(Ne(t,e))}function Fe(t){for(var e=new Array(t.length),r=0;r<t.length;r++)"object"==typeof t[r]&&(e[r]=new RegExp("^(?:"+t[r].pattern+")$"));return function(r,n){for(var o="",i=n&&n.encode||encodeURIComponent,u=0;u<t.length;u++){var a=t[u];if("string"!=typeof a){var c,s=r?r[a.name]:void 0;if(Array.isArray(s)){if(!a.repeat)throw new TypeError('Expected "'+a.name+'" to not repeat, but got array');if(0===s.length){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to not be empty')}for(var f=0;f<s.length;f++){if(c=i(s[f]),!e[u].test(c))throw new TypeError('Expected all "'+a.name+'" to match "'+a.pattern+'"');o+=(0===f?a.prefix:a.delimiter)+c}}else if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s){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(s)),!e[u].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 Le(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function Ue(t){return t.replace(/([=!:$\/()])/g,"\\$1")}function qe(t){return t&&t.sensitive?"":"i"}function Qe(t,e){if(!e)return t;var r=t.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)e.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return t}function Ve(t,e,r){for(var n=[],o=0;o<t.length;o++)n.push(Ge(t[o],e,r).source);return new RegExp("(?:"+n.join("|")+")",qe(r))}function We(t,e,r){return He(Ne(t,r),e,r)}function He(t,e,r){r=r||{};for(var n=r.strict,o=!1!==r.end,i=Le(r.delimiter||Ai),u=r.delimiters||ki,a=[].concat(r.endsWith||[]).map(Le).concat("$").join("|"),c="",s=!1,f=0;f<t.length;f++){var l=t[f];if("string"==typeof l)c+=Le(l),s=f===t.length-1&&u.indexOf(l[l.length-1])>-1;else{var h=Le(l.prefix),p=l.repeat?"(?:"+l.pattern+")(?:"+h+"(?:"+l.pattern+"))*":l.pattern;e&&e.push(l),l.optional?l.partial?c+=h+"("+p+")?":c+="(?:"+h+"("+p+"))?":c+=h+"("+p+")"}}return o?(n||(c+="(?:"+i+")?"),c+="$"===a?"$":"(?="+a+")"):(n||(c+="(?:"+i+"(?="+a+"))?"),s||(c+="(?="+i+"|"+a+")")),new RegExp("^"+c,qe(r))}function Ge(t,e,r){return t instanceof RegExp?Qe(t,e):Array.isArray(t)?Ve(t,e,r):We(t,e,r)}function Ke(t){var e=Ei.head;if(e)for(;e.bound;)e=e.ctx.$child.router;else e=new Ei(Ei.getPathFromLocation(),void 0,t);if(e.bound=!0,e.isRoot)e.ctx.runBeforeRender().then(function(){e.ctx._redirect?e.ctx.runAfterRender().then(function(){var t=Re(e,e.ctx._redirect),r=t.router,n=t.path;r.update(n,e.ctx._redirectArgs)}):(e.ctx.render(),xe(Ei.onInit,function(t){return t(e)}))});else if(e.ctx._redirect){var r=Re(e,e.ctx._redirect),n=r.router,o=r.path;setTimeout(function(){return n.update(o,e.ctx._redirectArgs)})}return e}var Je=s(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),Xe=s(function(t){var e=t.exports={version:"2.5.1"};"number"==typeof __e&&(__e=e)}),Ye=Je["__core-js_shared__"]||(Je["__core-js_shared__"]={}),Ze=function(t){return Ye[t]||(Ye[t]={})},tr=0,er=Math.random(),rr=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++tr+er).toString(36))},nr=s(function(t){var e=Ze("wks"),r=Je.Symbol,n="function"==typeof r;(t.exports=function(t){return e[t]||(e[t]=n&&r[t]||(n?r:rr)("Symbol."+t))}).store=e}),or=nr,ir={f:or},ur=function(t){return"object"==typeof t?null!==t:"function"==typeof t},ar=function(t){if(!ur(t))throw TypeError(t+" is not an object!");return t},cr=function(t){try{return!!t()}catch(t){return!0}},sr=!cr(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),fr=Je.document,lr=ur(fr)&&ur(fr.createElement),hr=function(t){return lr?fr.createElement(t):{}},pr=!sr&&!cr(function(){return 7!=Object.defineProperty(hr("div"),"a",{get:function(){return 7}}).a}),dr=function(t,e){if(!ur(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!ur(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!ur(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!ur(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},vr=Object.defineProperty,br=sr?Object.defineProperty:function(t,e,r){if(ar(t),e=dr(e,!0),ar(r),pr)try{return vr(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t},yr={f:br},gr=yr.f,_r=function(t){var e=Xe.Symbol||(Xe.Symbol=Je.Symbol||{});"_"==t.charAt(0)||t in e||gr(e,t,{value:ir.f(t)})};_r("asyncIterator"),_r("observable");var mr="object"==typeof global&&global&&global.Object===Object&&global,wr="object"==typeof self&&self&&self.Object===Object&&self,jr=mr||wr||Function("return this")(),xr=jr.Symbol,Or=Object.prototype,Pr=Or.hasOwnProperty,$r=Or.toString,Ar=xr?xr.toStringTag:void 0,kr=Object.prototype,Sr=kr.toString,Rr="[object Null]",Er="[object Undefined]",zr=xr?xr.toStringTag:void 0,Cr="[object AsyncFunction]",Mr="[object Function]",Dr="[object GeneratorFunction]",Tr="[object Proxy]",Br=b(Object.getPrototypeOf,Object),Nr="[object Object]",Ir=Function.prototype,Fr=Object.prototype,Lr=Ir.toString,Ur=Fr.hasOwnProperty,qr=Lr.call(Object),Qr=Array.isArray,Vr="[object Symbol]",Wr=1/0,Hr=xr?xr.prototype:void 0,Gr=Hr?Hr.toString:void 0,Kr=NaN,Jr=/^\s+|\s+$/g,Xr=/^[-+]0x[0-9a-f]+$/i,Yr=/^0b[01]+$/i,Zr=/^0o[0-7]+$/i,tn=parseInt,en=1/0,rn=1.7976931348623157e308,nn="[object Boolean]",on="[object String]",un="[object Arguments]",an=Object.prototype,cn=an.hasOwnProperty,sn=an.propertyIsEnumerable,fn=C(function(){return arguments}())?C:function(t){return y(t)&&cn.call(t,"callee")&&!sn.call(t,"callee")},ln=xr?xr.isConcatSpreadable:void 0,hn=jr["__core-js_shared__"],pn=function(){var t=/[^.]+$/.exec(hn&&hn.keys&&hn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),dn=Function.prototype,vn=dn.toString,bn=/[\\^$.*+?()[\]{}|]/g,yn=/^\[object .+?Constructor\]$/,gn=Function.prototype,_n=Object.prototype,mn=gn.toString,wn=_n.hasOwnProperty,jn=RegExp("^"+mn.call(wn).replace(bn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xn=function(){try{var t=U(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),On=Object.prototype,Pn=On.hasOwnProperty,$n=Math.max,An=xn?function(t,e){return xn(t,"toString",{configurable:!0,enumerable:!1,value:J(e),writable:!0})}:H,kn=800,Sn=16,Rn=Date.now,En=function(t){var e=0,r=0;return function(){var n=Rn(),o=Sn-(n-r);if(r=n,o>0){if(++e>=kn)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(An),zn=9007199254740991,Cn=9007199254740991,Mn=/^(?:0|[1-9]\d*)$/,Dn="object"==typeof t&&t&&!t.nodeType&&t,Tn=Dn&&"object"==typeof module&&module&&!module.nodeType&&module,Bn=Tn&&Tn.exports===Dn,Nn=Bn?jr.Buffer:void 0,In=Nn?Nn.isBuffer:void 0,Fn=In||ot,Ln={};Ln["[object Float32Array]"]=Ln["[object Float64Array]"]=Ln["[object Int8Array]"]=Ln["[object Int16Array]"]=Ln["[object Int32Array]"]=Ln["[object Uint8Array]"]=Ln["[object Uint8ClampedArray]"]=Ln["[object Uint16Array]"]=Ln["[object Uint32Array]"]=!0,Ln["[object Arguments]"]=Ln["[object Array]"]=Ln["[object ArrayBuffer]"]=Ln["[object Boolean]"]=Ln["[object DataView]"]=Ln["[object Date]"]=Ln["[object Error]"]=Ln["[object Function]"]=Ln["[object Map]"]=Ln["[object Number]"]=Ln["[object Object]"]=Ln["[object RegExp]"]=Ln["[object Set]"]=Ln["[object String]"]=Ln["[object WeakMap]"]=!1;var Un="object"==typeof t&&t&&!t.nodeType&&t,qn=Un&&"object"==typeof module&&module&&!module.nodeType&&module,Qn=qn&&qn.exports===Un,Vn=Qn&&mr.process,Wn=function(){try{return Vn&&Vn.binding&&Vn.binding("util")}catch(t){}}(),Hn=Wn&&Wn.isTypedArray,Gn=Hn?function(t){return function(e){return t(e)}}(Hn):it,Kn=Object.prototype,Jn=Kn.hasOwnProperty,Xn=Object.prototype,Yn=Object.prototype,Zn=Yn.hasOwnProperty,to=rt(function(t,e){W(e,ft(e),t)}),eo=rt(function(t,e,r,n){W(e,ft(e),t,n)}),ro=function(t){return function(e,r,n){for(var o=-1,i=Object(e),u=n(e),a=u.length;a--;){var c=u[t?a:++o];if(!1===r(i[c],c,i))break}return e}}(),no=b(Object.keys,Object),oo=Object.prototype,io=oo.hasOwnProperty,uo=function(t,e){return function(r,n){if(null==r)return r;if(!Z(r))return t(r,n);for(var o=r.length,i=e?o:-1,u=Object(r);(e?i--:++i<o)&&!1!==n(u[i],i,u););return r}}(dt),ao=Array.prototype,co=ao.splice;wt.prototype.clear=vt,wt.prototype.delete=yt,wt.prototype.get=gt,wt.prototype.has=_t,wt.prototype.set=mt;var so=U(jr,"Map"),fo=U(Object,"create"),lo="__lodash_hash_undefined__",ho=Object.prototype,po=ho.hasOwnProperty,vo=Object.prototype,bo=vo.hasOwnProperty,yo="__lodash_hash_undefined__";Et.prototype.clear=$t,Et.prototype.delete=At,Et.prototype.get=kt,Et.prototype.has=St,Et.prototype.set=Rt,It.prototype.clear=zt,It.prototype.delete=Dt,It.prototype.get=Tt,It.prototype.has=Bt,It.prototype.set=Nt;var go=200;Lt.prototype.clear=jt,Lt.prototype.delete=xt,Lt.prototype.get=Ot,Lt.prototype.has=Pt,Lt.prototype.set=Ft;var _o="__lodash_hash_undefined__";Qt.prototype.add=Qt.prototype.push=Ut,Qt.prototype.has=qt;var mo=1,wo=2,jo=jr.Uint8Array,xo=1,Oo=2,Po="[object Boolean]",$o="[object Date]",Ao="[object Error]",ko="[object Map]",So="[object Number]",Ro="[object RegExp]",Eo="[object Set]",zo="[object String]",Co="[object Symbol]",Mo="[object ArrayBuffer]",Do="[object DataView]",To=xr?xr.prototype:void 0,Bo=To?To.valueOf:void 0,No=Object.prototype,Io=No.propertyIsEnumerable,Fo=Object.getOwnPropertySymbols,Lo=Fo?function(t){return null==t?[]:(t=Object(t),lt(Fo(t),function(e){return Io.call(t,e)}))}:Yt,Uo=1,qo=Object.prototype,Qo=qo.hasOwnProperty,Vo=U(jr,"DataView"),Wo=U(jr,"Promise"),Ho=U(jr,"Set"),Go=U(jr,"WeakMap"),Ko=I(Vo),Jo=I(so),Xo=I(Wo),Yo=I(Ho),Zo=I(Go),ti=h;(Vo&&"[object DataView]"!=ti(new Vo(new ArrayBuffer(1)))||so&&"[object Map]"!=ti(new so)||Wo&&"[object Promise]"!=ti(Wo.resolve())||Ho&&"[object Set]"!=ti(new Ho)||Go&&"[object WeakMap]"!=ti(new Go))&&(ti=function(t){var e=h(t),r="[object Object]"==e?t.constructor:void 0,n=r?I(r):"";if(n)switch(n){case Ko:return"[object DataView]";case Jo:return"[object Map]";case Xo:return"[object Promise]";case Yo:return"[object Set]";case Zo:return"[object WeakMap]"}return e});var ei=ti,ri=1,ni="[object Arguments]",oi="[object Array]",ii="[object Object]",ui=Object.prototype,ai=ui.hasOwnProperty,ci=1,si=2,fi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,li=/^\w*$/,hi="Expected a function";se.Cache=It;var pi=500,di=/^\./,vi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bi=/\\(\\)?/g,yi=function(t){var e=se(t,function(t){return r.size===pi&&r.clear(),t}),r=e.cache;return e}(function(t){var e=[];return di.test(t)&&e.push(""),t.replace(vi,function(t,r,n,o){e.push(n?o.replace(bi,"$1"):r||t)}),e}),gi=1/0,_i=1,mi=2,wi=function(){function t(t,e,r,n){void 0===n&&(n={}),this._queue=[],this._beforeNavigateCallbacks=[],this._appMiddlewareDownstream=[],this._routeMiddlewareDownstream=[];var o=t.resolveRoute(r),i=o.parse(r),u=i.params,a=i.pathname,c=i.childPath;to(this,{$parent:e,params:u,path:r,pathname:a,route:o,router:t},n),e&&(e.$child=this),c&&new Ei(c,this).ctx}return t.prototype.addBeforeNavigateCallback=function(t){this._beforeNavigateCallbacks.unshift(t)},Object.defineProperty(t.prototype,"base",{get:function(){return this.router.isRoot?Ei.base:this.$parent.base+this.$parent.pathname},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canonicalPath",{get:function(){return this.base.replace(new RegExp(this.$root.base,"i"),"")+this.pathname},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"$root",{get:function(){for(var t=this;t;){if(!t.$parent)return t;t=t.$parent}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"$parents",{get:function(){for(var t=[],e=this.$parent;e;)t.push(e),e=e.$parent;return t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"$children",{get:function(){for(var t=[],e=this.$child;e;)t.push(e),e=e.$child;return t},enumerable:!0,configurable:!0}),t.prototype.queue=function(t){this._queue.push(t)},t.prototype.redirect=function(t,e){void 0===e&&(e={}),this._redirect=t,this._redirectArgs=to({},e,{push:!1})},t.prototype.runBeforeNavigateCallbacks=function(){return r(this,void 0,void 0,function(){var t,e,r;return n(this,function(n){switch(n.label){case 0:for(t=this,e=[];t;)e=u(t._beforeNavigateCallbacks,e),t=t.$child;return[4,Se(e)];case 1:return r=n.sent().success,[2,r]}})})},t.prototype.render=function(){for(var t=this;t;)v(t._redirect)&&t.router.component(t.route.component),t=t.$child;e.tasks.runEarly()},t.prototype.runBeforeRender=function(e){return void 0===e&&(e=!0),r(this,void 0,void 0,function(){var r,o,i,u;return n(this,function(n){switch(n.label){case 0:return r=t.runMiddleware(Ei.middleware,this),o=t.runMiddleware(this.route.middleware,this),[4,Se(r)];case 1:return i=n.sent().count,[4,Se(o)];case 2:return u=n.sent().count,this._appMiddlewareDownstream=r.slice(0,i),this._routeMiddlewareDownstream=o.slice(0,u),this.$child&&v(this._redirect)?[4,this.$child.runBeforeRender(!1)]:[3,4];case 3:n.sent(),n.label=4;case 4:return e?[4,this.flushQueue()]:[3,6];case 5:n.sent(),n.label=6;case 6:return[2]}})})},t.prototype.runAfterRender=function(){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,Se(B(this._appMiddlewareDownstream,this._routeMiddlewareDownstream))];case 1:return t.sent(),[4,this.flushQueue()];case 2:return t.sent(),[2]}})})},
t.prototype.runBeforeDispose=function(t){return void 0===t&&(t=!0),r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return this.$child&&v(this._redirect)?[4,this.$child.runBeforeDispose(!1)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[4,Se(B(this._routeMiddlewareDownstream,this._appMiddlewareDownstream))];case 3:return e.sent(),t?[4,this.flushQueue()]:[3,5];case 4:e.sent(),e.label=5;case 5:return[2]}})})},t.prototype.runAfterDispose=function(t){return void 0===t&&(t=!0),r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return this.$child&&v(this._redirect)?[4,this.$child.runAfterDispose(!1)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[4,Se(B(this._routeMiddlewareDownstream,this._appMiddlewareDownstream))];case 3:return e.sent(),t?[4,this.flushQueue()]:[3,5];case 4:e.sent(),e.label=5;case 5:return[2]}})})},t.prototype.flushQueue=function(){return r(this,void 0,void 0,function(){var t,e,r=this;return n(this,function(n){switch(n.label){case 0:return t=Promise.all(this._queue).then(function(){r._queue=[]}),e=xe(this.$children,function(t){return t.flushQueue()}),[4,Promise.all(u([t],e))];case 1:return n.sent(),[2]}})})},t.runMiddleware=function(t,e){var o=this;return xe(t,function(t){var i=Te(t)(e),u=!0;return function(){return r(o,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return t=i.next(),Me(t)?[4,t]:[3,2];case 1:return r.sent(),[3,4];case 2:return Me(t.value)?[4,t.value]:[3,4];case 3:r.sent(),r.label=4;case 4:return u?(u=!1,[2,v(e._redirect)]):[2,!0]}})})}})},t}(),ji=Ge,xi=Ne,Oi=Ie,Pi=Fe,$i=He,Ai="/",ki="./",Si=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");ji.parse=xi,ji.compile=Oi,ji.tokensToFunction=Pi,ji.tokensToRegExp=$i;var Ri=function(){function t(e,r){var n=i(t.parseConfig(r),3),o=n[0],u=n[1],a=n[2];this.path=e,this.component=o,this.middleware=u,this.children=a;var c=t.parsePath(e,!v(a)),s=c.keys,f=c.regexp;this.keys=s,this.regexp=f}return t.prototype.matches=function(t){var e=this.regexp.exec(t);if(null===e)return!1;if(this.children){try{for(var r=o(this.children),n=r.next();!n.done;n=r.next()){var i=n.value,u="/"+(e[e.length-1]||"");if(i.matches(u))return!0}}catch(t){a={error:t}}finally{try{n&&!n.done&&(c=r.return)&&c.call(r)}finally{if(a)throw a.error}}return!1}return!0;var a,c},t.prototype.parse=function(t){for(var e,r=t,n={},o=this.regexp.exec(t),i=1,u=o.length;i<u;++i){var a=this.keys[i-1],c=o[i]||"";"__child_path__"===a.name?(e="/"+c,r=t.replace(new RegExp(e+"$"),"")):n[a.name]=c}return{params:n,pathname:r,childPath:e}},t.parseConfig=function(e){var r,n,o=ke(e,function(e,o){return R(o)?(o=o,r=o):g(o)?(o=o,n=xe(o,function(e,r){return new t(r,e)}),r||(r="ko-component-router")):d(o)&&(o=o,e.push(o)),e},[]);return[r,o,n]},t.parsePath=function(t,e){e&&(t=t.replace(/\/?!?$/,"/!")),t="!"===t[t.length-1]?t.replace("!",":__child_path__(.*)?"):t.replace(/\(?\*\)?/,"(.*)");var r=[];return{keys:r,regexp:ji(t,r)}},t}(),Ei=function(){function t(r,n,o){void 0===o&&(o={}),this.onInit=[],this.component=e.observable(null),this.isNavigating=e.observable(!0),this.isRoot=v(n),this.routes=this.isRoot?t.createRoutes(t.routes):n.route.children,this.isRoot&&(t.head=this,document.addEventListener(t.events.click,t.onclick),window.addEventListener(t.events.popstate,t.onpopstate)),this.ctx=new wi(this,n,t.getPath(r),o)}return Object.defineProperty(t.prototype,"initialized",{get:function(){var t=this;return this.isNavigating()?new Promise(function(e){return t.onInit.push(e)}):Promise.resolve(this)},enumerable:!0,configurable:!0}),t.prototype.init=function(){var t=this;this.isNavigating(!1),this.ctx.runAfterRender().then(function(){for(var e=t.ctx;e;)xe(e.router.onInit,function(t){return function(e){return e(t)}}(e.router)),e=e.$child})},t.prototype.update=function(o,i){return r(this,void 0,void 0,function(){var r,u,a,c,s,f,l,h,p,d,b,y,g,_,m,w;return n(this,function(n){switch(n.label){case 0:return r=S(i)?{push:i}:v(i)?{}:i,v(r.push)&&(r.push=!0),v(r.with)&&(r.with={}),u=this.ctx,a=t.parseUrl(o),c=a.search,s=a.hash,f=t.getPath(o),l=this.resolveRoute(f),h=l.parse(f),p=h.pathname,d=h.childPath,b=u.pathname===p,u.$child&&b&&!r.force?[4,u.$child.router.update(d+c+s,r)]:[3,2];case 1:return[2,n.sent()];case 2:return y=new wi(this,this.ctx.$parent,f,r.with),y.route?[4,u.runBeforeNavigateCallbacks()]:[2,!1];case 3:return!1===(g=n.sent())?[2,!1]:(this.isNavigating(!0),[4,u.runBeforeDispose()]);case 4:return n.sent(),history[r.push?"pushState":"replaceState"](history.state,document.title,y.base+y.path+c+s),[4,y.runBeforeRender()];case 5:return n.sent(),v(y._redirect)&&(this.component(null),e.tasks.runEarly()),this.ctx=y,[4,u.runAfterDispose()];case 6:return n.sent(),y.render(),v(y._redirect)?[3,8]:[4,y.runAfterRender()];case 7:n.sent(),_=Re(y.router,y._redirect),m=_.router,w=_.path,m.update(w,y._redirectArgs),n.label=8;case 8:return[2,!0]}})})},t.prototype.resolveRoute=function(t){var e,r=1/0;for(var n in this.routes)if(this.routes.hasOwnProperty(n)){var o=this.routes[n];if(o.matches(t)){if(0===o.keys.length)return o;(r===1/0||o.keys.length<r&&".*"!==o.keys[0].pattern)&&(r=o.keys.length,e=o)}}return e},t.prototype.dispose=function(){this.isRoot&&(document.removeEventListener(t.events.click,t.onclick,!1),window.removeEventListener(t.events.popstate,t.onpopstate,!1),delete t.head)},Object.defineProperty(t,"initialized",{get:function(){var e=this;return t.head?Promise.resolve(t.head):new Promise(function(t){return e.onInit.push(t)})},enumerable:!0,configurable:!0}),Object.defineProperty(t,"base",{get:function(){return t.config.base+(t.config.hashbang?"/#!":"")},enumerable:!0,configurable:!0}),t.setConfig=function(e){var r=e.base,n=e.hashbang,o=e.activePathCSSClass;eo(t.config,{base:r,hashbang:n,activePathCSSClass:o},function(t,e){return v(e)?t:e})},t.use=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];(n=t.middleware).push.apply(n,u(e));var n},t.usePlugin=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];(n=t.plugins).push.apply(n,u(e));var n},t.useRoutes=function(e){to(t.routes,t.normalizeRoutes(e))},t.get=function(e){for(var r=t.head;e-- >0;)r=r.ctx.$child.router;return r},t.update=function(e,o){return r(this,void 0,void 0,function(){return n(this,function(r){switch(r.label){case 0:return[4,t.head.update(e,o)];case 1:return[2,r.sent()]}})})},t.getPathFromLocation=function(){var e=location.pathname+location.search+location.hash,r=t.config.base.replace("#!","#?!?");return e.replace(new RegExp(r,"i"),"")},t.onclick=function(e){if(!e.defaultPrevented){for(var r=e.target;r&&"A"!==r.nodeName;)r=r.parentNode;if(r&&"A"===r.nodeName){var n=r.pathname,o=r.search,i=r.hash,u=void 0===i?"":i,a=(n+o+u).replace(new RegExp(t.base,"i"),""),c=t.hasRoute(a),s=!t.sameOrigin(r.href),f=1!==t.which(e),l=r.hasAttribute("download"),h="#"===r.getAttribute("href"),p=0===(r.getAttribute("href")||"").indexOf("mailto:"),d="external"===r.getAttribute("rel"),v=e.metaKey||e.ctrlKey||e.shiftKey,b=r.hasAttribute("target");!c||s||f||l||h||p||d||v||b||(t.update(a),e.preventDefault())}}},t.onpopstate=function(e){t.update(t.getPathFromLocation(),!1),e.preventDefault()},t.canonicalizePath=function(t){return t.replace(new RegExp("/?#?!?/?"),"/")},t.parseUrl=function(e){var r=document.createElement("a"),n=t.base.toLowerCase();return n&&0===e.toLowerCase().indexOf(n)&&(e=e.replace(new RegExp(n,"i"),"")||"/"),r.href=t.canonicalizePath(e),{hash:r.hash,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname,search:r.search}},t.getPath=function(e){return t.parseUrl(e).pathname},t.hasRoute=function(e){return!v(t.head.resolveRoute(t.getPath(e)))},t.createRoutes=function(t){return xe(t,function(t,e){return new Ri(e,t)})},t.normalizeRoutes=function(e){return Pe(e,function(e){return xe(t.runPlugins(e),function(e){return g(e)?t.normalizeRoutes(e):e})})},t.runPlugins=function(e){return Oe(E(e),function(e){var r=ke(t.plugins,function(t,r){var n=r(e);return v(n)?t:t.concat(E(n))},[]);return r.length>0?r:e})},t.sameOrigin=function(t){var e=location.hostname,r=location.port,n=location.protocol,o=n+"//"+e;return r&&(o+=":"+r),t&&0===t.indexOf(o)},t.which=function(t){return t=t||window.event,null===t.which?t.button:t.which},t.onInit=[],t.middleware=[],t.plugins=[],t.config={base:"",hashbang:!1,activePathCSSClass:"active-path"},t.routes={},t.events={click:document.ontouchstart?"touchstart":"click",popstate:"popstate"},t}(),zi={init:function(t,r,n,o,i){var u=n.get("pathActiveClass")||Ei.config.activePathCSSClass,a=e.unwrap(r());Ei.initialized.then(function(){var r=Be(i),n=e.pureComputed(function(){return Re(r,a)});e.applyBindingsToNode(t,{css:(o={},o[u]=e.pureComputed(function(){return ze(n())}),o)});var o})}};e.bindingHandlers.activePath=zi;var Ci={init:function(t,r,n,o,i){var u=e.unwrap(r());zi.init.apply(this,arguments),Ei.initialized.then(function(){var r=Be(i),n=e.pureComputed(function(){return Re(r,u)});e.applyBindingsToNode(t,{attr:{href:e.pureComputed(function(){return Ee(n())})}})})}};e.bindingHandlers.path=Ci,e.components.register("ko-component-router",{synchronous:!0,viewModel:{createViewModel:Ke},template:'<div data-bind="if: component">\n <div class="ko-component-router-view" data-bind="__ko_component_router__"></div>\n </div>'}),e.bindingHandlers.__ko_component_router__={init:function(t,r,n,o,i){var u=i.$rawData;return e.applyBindingsToNode(t,{css:u.component,component:{name:u.component,params:u.ctx}},i.extend({$router:u})),u.isRoot?u.init():u.ctx.$parent.router.initialized.then(function(){return u.init()}),{controlsDescendantBindings:!0}}},t.Context=wi,t.Route=Ri,t.Router=Ei,t.isActivePath=ze,t.resolveHref=Ee,Object.defineProperty(t,"__esModule",{value:!0})});