text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TemplateRouter",[],t):"object"==typeof exports?exports.TemplateRouter=t():e.TemplateRouter=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,function(e){if(e.exports&&!e.exports.__esModule&&void 0===e.exports.default){if(e.exports.headers&&e.exports.headers.common&&e.exports.headers.common.Accept&&e.exports.adapter&&e.exports.transformRequest&&e.exports.transformResponse)return;e.exports.default=e.exports}}(o),o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(e){return function(t,n){return a(this,void 0,void 0,function(){function r(e){var n=t;if(e)if(Array.isArray(e))e.forEach(function(e){var t=e(n);t&&(n=t)});else if("function"==typeof e){var r=e(n);r&&(n=r)}return n}var o,i,a,c,s,f;return u(this,function(u){switch(u.label){case 0:return i={querySelector:e.querySelector||"body",template:e.template,endpoint:e.endpoint},t.middlewareInfo=i,o=r(e.beforeFetch),o&&(t=o,o.middlewareInfo.cancel&&n()),[4,fetch(t.middlewareInfo.endpoint).then(function(e){return e.json()})];case 1:return a=u.sent(),c={querySelector:t.middlewareInfo.querySelector,template:t.middlewareInfo.template,data:a},t.middlewareInfo=c,o=r(e.beforeRender),o&&(t=o,o.middlewareInfo.cancel&&n()),s=t.middlewareInfo.template(t.middlewareInfo.data),f={querySelector:t.middlewareInfo.querySelector,html:s},t.middlewareInfo=f,o=r(e.afterRender),o&&(t=o,o.middlewareInfo.cancel&&n()),document.querySelector(t.middlewareInfo.querySelector).innerHTML=s,t.save(),n(),[2]}})})}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n.n(o),a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){function n(e){return function(t){return r([e,t])}}function r(n){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(a=i[2&n[0]?"return":n[0]?"throw":"next"])&&!(a=a.call(i,n[1])).done)return a;switch(i=0,a&&(n=[0,a.value]),n[0]){case 0:case 1:a=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(a=c.trys,!(a=a.length>0&&a[a.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){c.label=n[1];break}if(6===n[0]&&c.label<a[1]){c.label=a[1],a=n;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(n);break}a[2]&&c.ops.pop(),c.trys.pop();continue}n=t.call(e,c)}catch(e){n=[6,e],i=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var o,i,a,u,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return u={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u},c=function(e){Array.isArray(e)||"object"!=typeof e?Array.isArray(e)&&e.forEach(function(e){return i()(e.route,r(e))}):i()(e.route,r(e))};c.page=i.a,t.default=c},function(e,t,n){"use strict";(function(t){function r(e,t){if("function"==typeof e)return r("*",e);if("function"==typeof t)for(var n=new u(e),o=1;o<arguments.length;++o)r.callbacks.push(n.middleware(arguments[o]));else"string"==typeof e?r["string"==typeof t?"redirect":"show"](e,t):r.start(e)}function o(e){if(!e.handled){var t;t=x?w+m.hash.replace("#!",""):m.pathname+m.search,t!==e.canonicalPath&&(r.stop(),e.handled=!1,m.href=e.canonicalPath)}}function i(e){return"string"!=typeof e?e:v?decodeURIComponent(e.replace(/\+/g," ")):e}function a(e,t){"/"===e[0]&&0!==e.indexOf(w)&&(e=w+(x?"#!":"")+e);var n=e.indexOf("?");if(this.canonicalPath=e,this.path=e.replace(w,"")||"/",x&&(this.path=this.path.replace("#!","")||"/"),this.title=document.title,this.state=t||{},this.state.path=e,this.querystring=~n?i(e.slice(n+1)):"",this.pathname=i(~n?e.slice(0,n):e),this.params={},this.hash="",!x){if(!~this.path.indexOf("#"))return;var r=this.path.split("#");this.path=r[0],this.hash=i(r[1])||"",this.querystring=this.querystring.split("#")[0]}}function u(e,t){t=t||{},this.path="*"===e?"(.*)":e,this.method="GET",this.regexp=l(this.path,this.keys=[],t)}function c(e){if(1===s(e)&&!(e.metaKey||e.ctrlKey||e.shiftKey||e.defaultPrevented)){for(var n=e.path?e.path[0]:e.target;n&&"A"!==n.nodeName;)n=n.parentNode;if(n&&"A"===n.nodeName&&!n.hasAttribute("download")&&"external"!==n.getAttribute("rel")){var o=n.getAttribute("href");if((x||n.pathname!==m.pathname||!n.hash&&"#"!==o)&&!(o&&o.indexOf("mailto:")>-1)&&!n.target&&f(n.href)){var i=n.pathname+n.search+(n.hash||"");void 0!==t&&i.match(/^\/[a-zA-Z]:\//)&&(i=i.replace(/^\/[a-zA-Z]:\//,"/"));var a=i;0===i.indexOf(w)&&(i=i.substr(w.length)),x&&(i=i.replace("#!","")),w&&a===i||(e.preventDefault(),r.show(a))}}}}function s(e){return e=e||window.event,null===e.which?e.button:e.which}function f(e){var t=m.protocol+"//"+m.hostname;return m.port&&(t+=":"+m.port),e&&0===e.indexOf(t)}var l=n(3);e.exports=r;var p,h,d="undefined"!=typeof document&&document.ontouchstart?"touchstart":"click",m="undefined"!=typeof window&&(window.history.location||window.location),y=!0,v=!0,w="",x=!1;r.callbacks=[],r.exits=[],r.current="",r.len=0,r.base=function(e){if(0===arguments.length)return w;w=e},r.start=function(e){if(e=e||{},!p&&(p=!0,!1===e.dispatch&&(y=!1),!1===e.decodeURLComponents&&(v=!1),!1!==e.popstate&&window.addEventListener("popstate",g,!1),!1!==e.click&&document.addEventListener(d,c,!1),!0===e.hashbang&&(x=!0),y)){var t=x&&~m.hash.indexOf("#!")?m.hash.substr(2)+m.search:m.pathname+m.search+m.hash;r.replace(t,null,!0,y)}},r.stop=function(){p&&(r.current="",r.len=0,p=!1,document.removeEventListener(d,c,!1),window.removeEventListener("popstate",g,!1))},r.show=function(e,t,n,o){var i=new a(e,t);return r.current=i.path,!1!==n&&r.dispatch(i),!1!==i.handled&&!1!==o&&i.pushState(),i},r.back=function(e,t){r.len>0?(history.back(),r.len--):e?setTimeout(function(){r.show(e,t)}):setTimeout(function(){r.show(w,t)})},r.redirect=function(e,t){"string"==typeof e&&"string"==typeof t&&r(e,function(e){setTimeout(function(){r.replace(t)},0)}),"string"==typeof e&&void 0===t&&setTimeout(function(){r.replace(e)},0)},r.replace=function(e,t,n,o){var i=new a(e,t);return r.current=i.path,i.init=n,i.save(),!1!==o&&r.dispatch(i),i},r.dispatch=function(e){function t(){var e=r.exits[u++];if(!e)return n();e(i,t)}function n(){var t=r.callbacks[a++];return e.path!==r.current?void(e.handled=!1):t?void t(e,n):o(e)}var i=h,a=0,u=0;h=e,i?t():n()},r.exit=function(e,t){if("function"==typeof e)return r.exit("*",e);for(var n=new u(e),o=1;o<arguments.length;++o)r.exits.push(n.middleware(arguments[o]))},r.Context=a,a.prototype.pushState=function(){r.len++,history.pushState(this.state,this.title,x&&"/"!==this.path?"#!"+this.path:this.canonicalPath)},a.prototype.save=function(){history.replaceState(this.state,this.title,x&&"/"!==this.path?"#!"+this.path:this.canonicalPath)},r.Route=u,u.prototype.middleware=function(e){var t=this;return function(n,r){if(t.match(n.path,n.params))return e(n,r);r()}},u.prototype.match=function(e,t){var n=this.keys,r=e.indexOf("?"),o=~r?e.slice(0,r):e,a=this.regexp.exec(decodeURIComponent(o));if(!a)return!1;for(var u=1,c=a.length;u<c;++u){var s=n[u-1],f=i(a[u]);void 0===f&&hasOwnProperty.call(t,s.name)||(t[s.name]=f)}return!0};var g=function(){var e=!1;if("undefined"!=typeof window)return"complete"===document.readyState?e=!0:window.addEventListener("load",function(){setTimeout(function(){e=!0},0)}),function(t){if(e)if(t.state){var n=t.state.path;r.replace(n,t.state)}else r.show(m.pathname+m.hash,void 0,void 0,!1)}}();r.sameOrigin=f}).call(t,n(2))},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function i(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function a(){m&&h&&(m=!1,h.length?d=h.concat(d):y=-1,d.length&&u())}function u(){if(!m){var e=o(a);m=!0;for(var t=d.length;t;){for(h=d,d=[];++y<t;)h&&h[y].run();y=-1,t=d.length}h=null,m=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function s(){}var f,l,p=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(e){l=r}}();var h,d=[],m=!1,y=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new c(e,t)),1!==d.length||m||o(u)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,p.prependListener=s,p.prependOnceListener=s,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t,n){function r(e){for(var t,n=[],r=0,o=0,i="";null!=(t=y.exec(e));){var a=t[0],c=t[1],s=t.index;if(i+=e.slice(o,s),o=s+a.length,c)i+=c[1];else{i&&(n.push(i),i="");var f=t[2],l=t[3],p=t[4],h=t[5],d=t[6],m=t[7],v="+"===d||"*"===d,w="?"===d||"*"===d,x=f||"/",g=p||h||(m?".*":"[^"+x+"]+?");n.push({name:l||r++,prefix:f||"",delimiter:x,optional:w,repeat:v,pattern:u(g)})}}return o<e.length&&(i+=e.substr(o)),i&&n.push(i),n}function o(e){return i(r(e))}function i(e){for(var t=new Array(e.length),n=0;n<e.length;n++)"object"==typeof e[n]&&(t[n]=new RegExp("^"+e[n].pattern+"$"));return function(n){for(var r="",o=n||{},i=0;i<e.length;i++){var a=e[i];if("string"!=typeof a){var u,c=o[a.name];if(null==c){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to be defined')}if(m(c)){if(!a.repeat)throw new TypeError('Expected "'+a.name+'" to not repeat, but received "'+c+'"');if(0===c.length){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to not be empty')}for(var s=0;s<c.length;s++){if(u=encodeURIComponent(c[s]),!t[i].test(u))throw new TypeError('Expected all "'+a.name+'" to match "'+a.pattern+'", but received "'+u+'"');r+=(0===s?a.prefix:a.delimiter)+u}}else{if(u=encodeURIComponent(c),!t[i].test(u))throw new TypeError('Expected "'+a.name+'" to match "'+a.pattern+'", but received "'+u+'"');r+=a.prefix+u}}else r+=a}return r}}function a(e){return e.replace(/([.+*?=^!:${}()[\]|\/])/g,"\\$1")}function u(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function c(e,t){return e.keys=t,e}function s(e){return e.sensitive?"":"i"}function f(e,t){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,pattern:null});return c(e,t)}function l(e,t,n){for(var r=[],o=0;o<e.length;o++)r.push(d(e[o],t,n).source);return c(new RegExp("(?:"+r.join("|")+")",s(n)),t)}function p(e,t,n){for(var o=r(e),i=h(o,n),a=0;a<o.length;a++)"string"!=typeof o[a]&&t.push(o[a]);return c(i,t)}function h(e,t){t=t||{};for(var n=t.strict,r=!1!==t.end,o="",i=e[e.length-1],u="string"==typeof i&&/\/$/.test(i),c=0;c<e.length;c++){var f=e[c];if("string"==typeof f)o+=a(f);else{var l=a(f.prefix),p=f.pattern;f.repeat&&(p+="(?:"+l+p+")*"),p=f.optional?l?"(?:"+l+"("+p+"))?":"("+p+")?":l+"("+p+")",o+=p}}return n||(o=(u?o.slice(0,-2):o)+"(?:\\/(?=$))?"),o+=r?"$":n&&u?"":"(?=\\/|$)",new RegExp("^"+o,s(t))}function d(e,t,n){return t=t||[],m(t)?n||(n={}):(n=t,t=[]),e instanceof RegExp?f(e,t,n):m(e)?l(e,t,n):p(e,t,n)}var m=n(4);e.exports=d,e.exports.parse=r,e.exports.compile=o,e.exports.tokensToFunction=i,e.exports.tokensToRegExp=h;var y=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))"].join("|"),"g")},function(e,t){e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}}]).default});
  //# sourceMappingURL=template-router.min.js.map