var frontexpress=function(){"use strict";var t=["GET","POST","PUT","DELETE"],e=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r=function(){function t(t,e){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:"";e(this,t),this.name=r}return r(t,[{key:"next",value:function(){return!0}}]),t}(),u=function(){function t(r,i,n,a){e(this,t),this.router=r,this.uriPart=i,this.method=n,this.middleware=a,this.visited=!1}return r(t,[{key:"uri",get:function(){if(this.uriPart||this.method)return this.uriPart instanceof RegExp?this.uriPart:this.router.baseUri instanceof RegExp?this.router.baseUri:this.router.baseUri&&this.uriPart?(this.router.baseUri.trim()+this.uriPart.trim()).replace(/\/{2,}/,"/"):this.router.baseUri?this.router.baseUri.trim():this.uriPart}}]),t}(),d=function(){function i(t){e(this,i),t&&(this._baseUri=t),this._routes=[]}return r(i,[{key:"_add",value:function(t){return this._routes.push(t),this}},{key:"routes",value:function(t,e){return this._routes.filter(function(r){if(!r.uri&&!r.method)return!0;if(r.method!==e)return!1;if(!r.uri)return!0;var i=t,n=i.indexOf("?");n>=0&&(i=i.slice(0,n));var a=i.indexOf("#");return a>=0&&(i=i.slice(0,a)),r.uri instanceof RegExp?i.match(r.uri):r.uri===i})}},{key:"visited",value:function(){return this._routes.filter(function(t){return t.visited})}},{key:"use",value:function(t){if(!(t instanceof s)&&"function"!=typeof t)throw new TypeError("use method takes at least a middleware");return this._add(new u(this,void 0,void 0,t)),this}},{key:"all",value:function(){for(var e=arguments.length,r=Array(e),i=0;i0&&void 0!==arguments[0]?arguments[0]:window.location.pathname+window.location.search,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=[],i=!0,a=!1,o=void 0;try{for(var s,u=this.routers[Symbol.iterator]();!(i=(s=u.next()).done);i=!0){var d=s.value;r.push.apply(r,n(d.routes(t,e)))}}catch(t){a=!0,o=t}finally{try{!i&&u.return&&u.return()}finally{if(a)throw o}}return r}},{key:"_callMiddlewareMethod",value:function(t,e,r,i){if("exited"!==t){var n=!0,a=!1,o=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){var d=s.value;if("updated"===t&&(d.visited=r),d.middleware[t]){if(d.middleware[t](r,i),d.middleware.next&&!d.middleware.next())break}else if("entered"!==t){var h=!0,l=function(){h=!1};if(d.middleware(r,i,l),h)break}}}catch(t){a=!0,o=t}finally{try{!n&&u.return&&u.return()}finally{if(a)throw o}}}else{var f=!0,c=!1,v=void 0;try{for(var y,w=this.routers[Symbol.iterator]();!(f=(y=w.next()).done);f=!0){var p=y.value,m=!0,g=!1,x=void 0;try{for(var b,T=p.visited()[Symbol.iterator]();!(m=(b=T.next()).done);m=!0){var _=b.value;_.middleware.exited&&(_.middleware.exited(_.visited),_.visited=null)}}catch(t){g=!0,x=t}finally{try{!m&&T.return&&T.return()}finally{if(g)throw x}}}}catch(t){c=!0,v=t}finally{try{!f&&w.return&&w.return()}finally{if(c)throw v}}}}},{key:"_fetch",value:function(t,e,r){var i=this,n=t.method,a=t.uri,o=t.headers,s=t.data,u=t.history,d=this.get("http "+n+" transformer");d&&(a=d.uri?d.uri({uri:a,headers:o,data:s}):a,o=d.headers?d.headers({uri:a,headers:o,data:s}):o,s=d.data?d.data({uri:a,headers:o,data:s}):s),this._callMiddlewareMethod("exited");var h=this._routes(a,n);this._callMiddlewareMethod("entered",h,t),this.settings.get("http requester").fetch(t,function(t,r){u&&window.history.pushState({request:t,response:r},u.title,u.uri),i._callMiddlewareMethod("updated",h,t,r),e&&e(t,r)},function(t,e){i._callMiddlewareMethod("failed",h,t,e),r&&r(t,e)})}}]),i}();t.reduce(function(t,e){var r=e.toLowerCase();t[r]=function(){for(var t=arguments.length,e=Array(t),i=0;i