/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@typeclient/core@1.4.2/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var nextTick=require("next-tick"),path=require("path");require("reflect-metadata");var inversify=require("inversify"),mitt=require("mitt"),reactivity=require("@vue/reactivity"),Url=require("url-parse");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var invokeTimer,nextTick__default=_interopDefaultLegacy(nextTick),mitt__default=_interopDefaultLegacy(mitt),Url__default=_interopDefaultLegacy(Url),History={mode:"hashchange",stacks:[],listener:invoke};function invoke(){clearTimeout(invokeTimer),invokeTimer=setTimeout((function(){for(var e=History.listener?getUrlByLocation():"/",t=History.stacks.length;t--;)History.stacks[t](e)}),16)}function unSubscribe(){History.listener&&(window.removeEventListener(History.mode,History.listener),History.listener=null)}function useHistoryFeedback(e){return History.stacks.push(e),function(){var t=History.stacks.indexOf(e);t>-1&&History.stacks.splice(t,1)}}function usePopStateHistoryMode(){var e="popstate";window.history.pushState&&0!==window.location.protocol.toLowerCase().indexOf("file:")||(console.warn("Browser does not support `popstate` mode, change it to `hashchange` instead."),e="hashchange"),History.mode!==e&&(unSubscribe(),window.addEventListener(History.mode=e,invoke),History.listener=invoke)}function getUrlByLocation(){if("hashchange"===History.mode)return window.location.hash.replace(/^\#/,"")||"/";var e=window.location;return e.pathname+e.search+e.hash}window.addEventListener(History.mode,invoke);var bootstrp=invoke;function redirect(e,t){if(void 0===t&&(t=window.document.title),"popstate"===History.mode)return window.history.pushState(null,t,e),invoke();window.location.hash=e,window.document.title=t}function replace(e,t){if(void 0===t&&(t=window.document.title),"popstate"===History.mode)return window.history.replaceState(null,t,e),invoke();var r=window.location.href.indexOf("#");window.location.replace(window.location.href.slice(0,r>=0?r:0)+"#"+e),window.document.title=t}var reload=invoke,extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},extendStatics(e,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function __extends(e,t){function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function __awaiter(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))}function __generator(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function __values(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function __read(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}var ClassMetaCreator=function(){function e(){this.stacks=new Map}return e.prototype.set=function(e,t){return this.stacks.set(e,t),this},e.prototype.get=function(e){return this.stacks.get(e)},Object.defineProperty(e.prototype,"size",{get:function(){return this.stacks.size},enumerable:!1,configurable:!0}),e.prototype.has=function(e){return this.stacks.has(e)},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.size>0},enumerable:!1,configurable:!0}),e.prototype.got=function(e,t){return this.has(e)?this.get(e):t},e.instance=function(t){var r;return Reflect.hasMetadata(e.namespace,t)?r=Reflect.getMetadata(e.namespace,t):(r=new e,Reflect.defineMetadata(e.namespace,r,t)),r},e.define=function(t,r){return function(n){e.instance(n).set(t,r)}},e.push=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return function(n){var o=e.instance(n),i=o.has(t)?o.get(t):[];i.push.apply(i,__spread(r)),o.set(t,i)}},e.unshift=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return function(n){var o=e.instance(n),i=o.has(t)?o.get(t):[];i.unshift.apply(i,__spread(r)),o.set(t,i)}},e.join=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return e.forEach((function(e){return e(t)}))}},e.namespace=Symbol("metadata.class.namespace"),e.initializeNamespace=Symbol("meta.class.initialize.namespace"),e}(),MethodMetaCreator=function(){function e(){this.stacks=new Map}return e.prototype.setParent=function(e){this.parent=e},e.prototype.set=function(e,t){return this.stacks.set(e,t),this},e.prototype.get=function(e){return this.stacks.get(e)},Object.defineProperty(e.prototype,"size",{get:function(){return this.stacks.size},enumerable:!1,configurable:!0}),e.prototype.has=function(e){return this.stacks.has(e)},Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.size>0},enumerable:!1,configurable:!0}),e.prototype.got=function(e,t){return this.has(e)?this.get(e):t},e.instance=function(t){var r;return Reflect.hasMetadata(e.namespace,t.value)?r=Reflect.getMetadata(e.namespace,t.value):(r=new e,Reflect.defineMetadata(e.namespace,r,t.value)),r},e.define=function(t,r){return function(n,o,i){e.instance(i).set(t,r)}},e.push=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return function(n,o,i){var a=e.instance(i),s=a.has(t)?a.get(t):[];s.push.apply(s,__spread(r)),a.set(t,s)}},e.unshift=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return function(n,o,i){var a=e.instance(i),s=a.has(t)?a.get(t):[];s.unshift.apply(s,__spread(r)),a.set(t,s)}},e.join=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t,r,n){return e.forEach((function(e){return e(t,r,n)}))}},e.namespace=Symbol("metadata.method.namespace"),e}(),ParameterMetaCreator=function(){function e(){this.stacks=[]}return e.prototype.setParent=function(e){this.parent=e},Object.defineProperty(e.prototype,"size",{get:function(){return this.stacks.length},enumerable:!1,configurable:!0}),e.prototype.set=function(e,t){return this.stacks[e]=t,this},e.prototype.get=function(e,t){for(var r,n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];if("function"==typeof this.stacks[e])return(r=this.stacks)[e].apply(r,__spread([t],n))},e.prototype.exec=function(e){return Promise.all(this.stacks.map((function(t){return"function"==typeof t?Promise.resolve(t(e)):Promise.resolve()})))},e.instance=function(t){var r;return Reflect.hasMetadata(e.namespace,t)?r=Reflect.getMetadata(e.namespace,t):(r=new e,Reflect.defineMetadata(e.namespace,r,t)),r},e.define=function(t){return function(r,n,o){var i=r.constructor.prototype[n];i&&e.instance(i).set(o,(function(e){return t(e)}))}},e.pushToParent=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return function(r,n,o){var i=Object.getOwnPropertyDescriptor(r.constructor.prototype,n),a=MethodMetaCreator.instance(i),s=a.has(e)?a.get(e):[];s.push.apply(s,__spread(t)),a.set(e,s)}},e.unshiftToParent=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return function(r,n,o){var i=Object.getOwnPropertyDescriptor(r.constructor.prototype,n),a=MethodMetaCreator.instance(i),s=a.has(e)?a.get(e):[];s.push.apply(s,__spread(t)),a.set(e,s)}},e.joinToParent=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t,r,n){return e.forEach((function(e){return e(t,r,n)}))}},e.namespace=Symbol("metadata.parameter.namespace"),e}();function AnnotationMetaDataScan(e,t){AnnotationDependenciesAutoRegister(e,t);var r=ClassMetaCreator.instance(e),n=Object.getOwnPropertyNames(e.prototype),o=new Map;return n.forEach((function(t){if("constructor"!==t){var n=Object.getOwnPropertyDescriptor(e.prototype,t);if(n.value&&"function"==typeof n.value){var i=e.prototype[t],a=MethodMetaCreator.instance(n),s=ParameterMetaCreator.instance(i);a.setParent(r),s.setParent(a),o.set(t,{meta:a,parameter:s})}}})),{meta:r,methods:o}}function AnnotationDependenciesAutoRegister(e,t){if(Reflect.hasMetadata(inversify.METADATA_KEY.PARAM_TYPES,e)&&t&&!t.isBound(e)&&(t.bind(e).toSelf(),Reflect.hasMetadata(inversify.METADATA_KEY.TAGGED_PROP,e))){var r=Reflect.getMetadata(inversify.METADATA_KEY.TAGGED_PROP,e);for(var n in r){var o=r[n];Array.isArray(o)&&o.forEach((function(e){"inject"!==e.key||t.isBound(e.value)||AnnotationDependenciesAutoRegister(e.value,t)}))}}}function Controller(e){return void 0===e&&(e="/"),ClassMetaCreator.join(inversify.injectable(),ClassMetaCreator.define(exports.NAMESPACE.CONTROLLER,e))}function useInject(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t,r,n){r?MethodMetaCreator.push.apply(MethodMetaCreator,__spread([exports.NAMESPACE.INJECTABLE],e))(t,r,n):ClassMetaCreator.push.apply(ClassMetaCreator,__spread([exports.NAMESPACE.INJECTABLE],e))(t)}}function Route(e){return void 0===e&&(e="/"),MethodMetaCreator.unshift(exports.NAMESPACE.PATH,e)}function State(e){return function(t,r,n){return r?MethodMetaCreator.define(exports.NAMESPACE.STATE,e||{})(t,r,n):ClassMetaCreator.define(exports.NAMESPACE.STATE,e||{})(t)}}function mergeState(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(){return e.reduce((function(e,t){return Object.assign(e,t())}),{})}}!function(e){e.CONTROLLER="TypeClient.NAMESPACE.HTTP.Controller",e.PREFIX="TypeClient.NAMESPACE.HTTP.Controller.Prefix",e.PATH="TypeClient.NAMESPACE.HTTP.Controller.Path",e.MIDDLEWARE="TypeClient.NAMESPACE.HTTP.Controller.Middleware",e.EXCEPTION="TypeClient.NAMESPACE.HTTP.Controller.Exception",e.INJECTABLE="TypeClient.NAMESPACE.HTTP.Controller.Injectable",e.INTERCEPTOR="TypeClient.NAMESPACE.HTTP.Controller.Interceptor",e.STATE="TypeClient.NAMESPACE.HTTP.Controller.State",e.CONTEXTCREATED="TypeClient.NAMESPACE.HTTP.Context.Create",e.ACTION="TypeClient.NAMESPACE.HTTP.Context.Action"}(exports.NAMESPACE||(exports.NAMESPACE={}));var Service=inversify.injectable;function useMiddleware(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t,r,n){var o=e.filter((function(e){return!(!e.prototype||!e.prototype.use)&&!!ClassMetaCreator.instance(e).got(exports.NAMESPACE.MIDDLEWARE,!1)}));useInject.apply(void 0,__spread(o))(t,r,n),r?MethodMetaCreator.unshift.apply(MethodMetaCreator,__spread([exports.NAMESPACE.MIDDLEWARE],e))(t,r,n):ClassMetaCreator.unshift.apply(ClassMetaCreator,__spread([exports.NAMESPACE.MIDDLEWARE],e))(t)}}function Middleware(){return ClassMetaCreator.join(ClassMetaCreator.define(exports.NAMESPACE.MIDDLEWARE,!0),inversify.injectable())}function useException(e){return function(t,r,n){e&&(ClassMetaCreator.instance(e).got(exports.NAMESPACE.EXCEPTION,!1)&&(useInject(e)(t,r,n),r?MethodMetaCreator.define(exports.NAMESPACE.EXCEPTION,e)(t,r,n):ClassMetaCreator.define(exports.NAMESPACE.EXCEPTION,e)(t)))}}function Exception(){return ClassMetaCreator.join(ClassMetaCreator.define(exports.NAMESPACE.EXCEPTION,!0),inversify.injectable())}function Action(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return MethodMetaCreator.join(inversify.injectable(),MethodMetaCreator.unshift.apply(MethodMetaCreator,__spread([exports.NAMESPACE.ACTION],e)))}function Redirect(e){var t=this;return Action((function(r,n){return __awaiter(t,void 0,void 0,(function(){var t;return __generator(this,(function(o){if(!(t=n?"string"==typeof n?n:n.url:e))throw new Error("Redirection Function must return a value of string.");return r.replace(t),[2]}))}))}))}function onContextCreated(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t,r,n){return r?MethodMetaCreator.unshift.apply(MethodMetaCreator,__spread([exports.NAMESPACE.CONTEXTCREATED],e))(t,r,n):ClassMetaCreator.unshift.apply(ClassMetaCreator,__spread([exports.NAMESPACE.CONTEXTCREATED],e))(t)}}var TypeClientContainer=new inversify.Container,UTF8_ACCEPT=12,UTF8_REJECT=0,UTF8_DATA=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function decodeURIComponent(e){var t=e.indexOf("%");if(-1===t)return e;for(var r=e.length,n="",o=0,i=0,a=t,s=UTF8_ACCEPT;t>-1&&t<r;){var u=hexCodeToInt(e[t+1],4)|hexCodeToInt(e[t+2],0),c=UTF8_DATA[u];if(s=UTF8_DATA[256+s+c],i=i<<6|u&UTF8_DATA[364+c],s!==UTF8_ACCEPT){if(s===UTF8_REJECT)return null;if((t+=3)<r&&37===e.charCodeAt(t))continue;return null}n+=e.slice(o,a),n+=i<=65535?String.fromCharCode(i):String.fromCharCode(55232+(i>>10),56320+(1023&i)),i=0,o=t+3,t=a=e.indexOf("%",o)}return n+e.slice(o)}var types,HEX={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function hexCodeToInt(e,t){var r=HEX[e];return void 0===r?255:r<<t}!function(e){e[e.STATIC=0]="STATIC",e[e.PARAM=1]="PARAM",e[e.MATCH_ALL=2]="MATCH_ALL",e[e.REGEX=3]="REGEX",e[e.MULTI_PARAM=4]="MULTI_PARAM"}(types||(types={}));var Handlers=buildHandlers(),Node=function(){function e(e){void 0===e&&(e={}),this.prefix=e.prefix||"/",this.label=this.prefix[0],this.children=e.children||{},this.numberOfChildren=Object.keys(this.children).length,this.kind=e.kind||this.types.STATIC,this.handlers=new Handlers(e.handlers),this.regex=e.regex||null,this.wildcardChild=null,this.parametricBrother=null}return Object.defineProperty(e.prototype,"types",{get:function(){return types},enumerable:!1,configurable:!0}),e.prototype.getLabel=function(){return this.prefix[0]},e.prototype.addChild=function(e){var t=this,r="";switch(e.kind){case this.types.STATIC:r=e.getLabel();break;case this.types.PARAM:case this.types.REGEX:case this.types.MULTI_PARAM:r=":";break;case this.types.MATCH_ALL:this.wildcardChild=e,r="*";break;default:throw new Error("Unknown node kind: "+e.kind)}if(void 0!==this.children[r])throw new Error("There is already a child with label '"+r+"'");this.children[r]=e,this.numberOfChildren=Object.keys(this.children).length;for(var n=Object.keys(this.children),o=this.parametricBrother,i=0;i<n.length;i++){var a=this.children[n[i]];if(":"===a.label){o=a;break}}var s=function(e){if(e&&e.kind===t.types.STATIC){e!==t&&(e.parametricBrother=o||e.parametricBrother);for(var r=Object.keys(e.children),n=0;n<r.length;n++)s(e.children[r[n]])}};return s(this),this},e.prototype.reset=function(e){return this.prefix=e,this.children={},this.kind=this.types.STATIC,this.handlers=new Handlers,this.numberOfChildren=0,this.regex=null,this.wildcardChild=null,this},e.prototype.findByLabel=function(e){return this.children[e[0]]},e.prototype.findChild=function(e){var t=this.findByLabel(e);return void 0!==t&&(t.numberOfChildren>0||null!==t.handlers.GET)&&e.slice(0,t.prefix.length)===t.prefix||void 0!==(t=this.children[":"]||this.children["*"])&&(t.numberOfChildren>0||null!==t.handlers.GET)?t:null},e.prototype.setHandler=function(e,t){if(e){var r="GET";if(void 0===this.handlers[r])throw new Error("There is already an handler with method 'GET'");this.handlers[r]={handler:e,params:t,paramsLength:t.length}}},e.prototype.getHandler=function(){return this.handlers.GET},e}();function buildHandlers(){return function(e){e=e||{},this.GET=e.GET||null}}var NODE_TYPES=types,FULL_PATH_REGEXP=/^https?:\/\/.*\//,Router=function(){function e(e){void 0===e&&(e={}),this.caseSensitive=void 0===e.caseSensitive||e.caseSensitive,this.ignoreTrailingSlash=e.ignoreTrailingSlash||!1,this.maxParamLength=e.maxParamLength||100,this.tree=new Node,this.routes=[]}return e.prototype.on=function(e,t,r){if("function"==typeof t&&(r=t,t={}),"string"!=typeof e)throw new Error("Path should be a string");if(0===e.length)throw new Error("The path could not be empty");if("/"!==e[0]&&"*"!==e[0])throw new Error("The first character of a path should be `/` or `*`");if("function"!=typeof r)throw new Error("Handler should be a function");this._on(e,t,r),this.ignoreTrailingSlash&&"/"!==e&&!e.endsWith("*")&&(e.endsWith("/")?this._on(e.slice(0,-1),t,r):this._on(e+"/",t,r))},e.prototype._on=function(e,t,r){var n=[],o=0;this.routes.push({method:"GET",path:e,opts:t,handler:r});for(var i=0,a=e.length;i<a;i++)if(58===e.charCodeAt(i)){var s=NODE_TYPES.PARAM;o=i+1;var u=e.slice(0,i);!1===this.caseSensitive&&(u=u.toLowerCase()),this._insert(u,0,null,null,null);for(var c=!1;i<a&&47!==e.charCodeAt(i);){if(c=c||"("===e[i]){i=getClosingParenthensePosition(e,i)+1;break}if(45===e.charCodeAt(i))break;i++}!c||i!==a&&47!==e.charCodeAt(i)?i<a&&47!==e.charCodeAt(i)&&(s=NODE_TYPES.MULTI_PARAM):s=NODE_TYPES.REGEX;var l=e.slice(o,i),p=c?new RegExp(l.slice(l.indexOf("("),i)):null;if(n.push(l.slice(0,c?l.indexOf("("):i)),e=e.slice(0,o)+e.slice(i),(i=o)===(a=e.length)){var f=e.slice(0,i);return!1===this.caseSensitive&&(f=f.toLowerCase()),this._insert(f,s,n,r,p)}this._insert(e.slice(0,i),s,n,null,p),i--}else if(42===e.charCodeAt(i))return this._insert(e.slice(0,i),0,null,null,null),n.push("*"),this._insert(e.slice(0,a),2,n,r,null);!1===this.caseSensitive&&(e=e.toLowerCase()),this._insert(e,0,n,r,null)},e.prototype._insert=function(e,t,r,n,o){void 0===r&&(r=[]);for(var i=e,a=this.tree,s="",u=0,c=0,l=0,p=0,f=null;;){for(c=(s=a.prefix).length,l=0,p=(u=e.length)<c?u:c;l<p&&e[l]===s[l];)l++;if(l<c)if(f=new Node({prefix:s.slice(l),children:a.children,kind:a.kind,handlers:new Handlers(a.handlers),regex:a.regex}),null!==a.wildcardChild&&(f.wildcardChild=a.wildcardChild),a.reset(s.slice(0,l)).addChild(f),l===u){if(a.getHandler())throw new Error("Method 'GET' already declared for route '"+i+"'");a.setHandler(n,r),a.kind=t}else(f=new Node({prefix:e.slice(l),kind:t,handlers:null,regex:o})).setHandler(n,r),a.addChild(f);else if(l<u){if(e=e.slice(l),f=a.findByLabel(e)){a=f;continue}(f=new Node({prefix:e,kind:t,handlers:null,regex:o})).setHandler(n,r),a.addChild(f)}else if(n){if(a.getHandler())throw new Error("Method 'GET' already declared for route '"+i+"'");a.setHandler(n,r)}return}},e.prototype.reset=function(){this.tree=new Node,this.routes=[]},e.prototype.off=function(e){var t=this,r="GET";if(Array.isArray(r))return r.map((function(r){return t.off(e)}));if("string"!=typeof e)throw new Error("Path should be a string");if(0===e.length)throw new Error("The path could not be empty");if("/"!==e[0]&&"*"!==e[0])throw new Error("The first character of a path should be `/` or `*`");var n=this.ignoreTrailingSlash,o=t.routes.filter((function(t){if(!n)return!(r===t.method&&e===t.path);if(e.endsWith("/")){var o=e===t.path||e.slice(0,-1)===t.path;return!(r===t.method&&o)}var i=e===t.path||e+"/"===t.path;return!(r===t.method&&i)}));n&&(o=o.filter((function(e,t,r){return e.path.endsWith("/")&&t<r.length-1?e.path.slice(0,-1)!==r[t+1].path:!(!1===e.path.endsWith("/")&&t<r.length-1)||e.path+"/"!==r[t+1].path}))),t.reset(),o.forEach((function(e){return t.on(e.path,e.opts,e.handler)}))},e.prototype.lookup=function(e){var t=this.find(sanitizeUrl(e));if(null!==t)return t},e.prototype.get=function(e,t){return this.on(e,t)},e.prototype.find=function(e){47!==e.charCodeAt(0)&&(e=e.replace(FULL_PATH_REGEXP,"/"));var t=e,r=e.length;!1===this.caseSensitive&&(e=e.toLowerCase());for(var n=this.maxParamLength,o=this.tree,i=null,a=0,s=null,u=0,c=[],l=0,p=0;;){var f=e.length,h=o.prefix,d=h.length,C=0,y=e;if(0===f||e===h){var E=o.handlers.GET;if(null!=E){var v={};if(E.paramsLength>0){var A=E.params;for(l=0;l<E.paramsLength;l++)v[A[l]]=c[l]}return{handler:E.handler,params:v}}}for(l=f<d?f:d;C<l&&e.charCodeAt(C)===h.charCodeAt(C);)C++;C===d&&(f=(e=e.slice(C)).length,p+=C);var m=o.findChild(e);if(null===m){if(null===(m=o.parametricBrother))return getWildcardNode(i,t,a);if(-1===t.indexOf("/"+y)){var g=t.slice(0,r-f);y=g.slice(g.lastIndexOf("/")+1,g.length)+e}p-=y.length-e.length,e=y,f=y.length,C=d}var T=m.kind;if(T!==NODE_TYPES.STATIC){if(C!==d)return getWildcardNode(i,t,a);if(null!==o.wildcardChild&&(i=o.wildcardChild,a=f),T!==NODE_TYPES.PARAM)if(T!==NODE_TYPES.MATCH_ALL)if(T!==NODE_TYPES.REGEX)if(T!==NODE_TYPES.MULTI_PARAM)i=null;else{if(o=m,l=0,null!==m.regex){var _=e.match(m.regex);if(null===_)return null;l=_[1].length}else{for(;l<f&&47!==e.charCodeAt(l)&&45!==e.charCodeAt(l);)l++;if(l>n)return null}if(null===(s=decodeURIComponent(t.slice(p,p+l))))return null;c[u++]=s,e=e.slice(l),p+=l}else{if(o=m,-1===(l=e.indexOf("/"))&&(l=f),l>n)return null;if(null===(s=decodeURIComponent(t.slice(p,p+l))))return null;if(!m.regex.test(s))return null;c[u++]=s,e=e.slice(l),p+=l}else{if(null===(s=decodeURIComponent(t.slice(p))))return null;c[u]=s,o=m,e=""}else{if(o=m,-1===(l=e.indexOf("/"))&&(l=f),l>n)return null;if(null===(s=decodeURIComponent(t.slice(p,p+l))))return null;c[u++]=s,e=e.slice(l),p+=l}}else null!==o.wildcardChild&&(i=o.wildcardChild,a=f),o=m}},e}();function sanitizeUrl(e){for(var t=0,r=e.length;t<r;t++){var n=e.charCodeAt(t);if(63===n||59===n||35===n)return e.slice(0,t)}return e}function getWildcardNode(e,t,r){if(null===e)return null;var n=decodeURIComponent(t.slice(-r));if(null===n)return null;var o=e.handlers.GET;return null!=o?{handler:o.handler,params:{"*":n}}:null}function getClosingParenthensePosition(e,t){for(var r=1;t<e.length;)if("\\"!==e[++t]){if(")"===e[t]?r--:"("===e[t]&&r++,!r)return t}else t++;throw new Error('Invalid regexp expression in "'+e+'"')}var index=0,Context=function(){function e(e,t,r){var n=this;this.$e=mitt__default.default(),this.self=this,this.error=reactivity.ref(null),this.status=reactivity.ref(100),this.rejections=[],this.callbacks=[],this.redirect=function(e,t){if(100===n.status.value)throw n.status.value=302,function(){return n.app.redirect(e,t)};n.app.redirect(e,t)},this.replace=function(e,t){if(100===n.status.value)throw n.status.value=302,function(){return n.app.replace(e,t)};n.app.replace(e,t)},this.reload=function(){if(100===n.status.value)throw n.status.value=302,function(){return n.app.reload()};n.app.reload()},this.useEffect=function(e){var t=function(){var t=e();if("function"==typeof t)return n.$e.on("context.destroy",t)};return n.$e.on("context.create",t),function(){return n.$e.off("context.create",t)}},this.app=e,this.req=t,this.state=reactivity.reactive(r),this.query=this.req.query,this.params=this.req.params,this.id=index++,this.onHashAnchor()}return e.prototype.onHashAnchor=function(){var e=this;this.$e.on("context.create",(function(){var t=e.req.hash;if(t){var r=t.substring(1);r&&nextTick__default.default((function(){var t=document.getElementById(r);t&&e.app.emitHashAnchor(t)}))}}))},e.prototype.useReject=function(e){var t=this;return this.rejections.push(e),function(){var r=t.rejections.indexOf(e);r>-1&&t.rejections.splice(r,1)}},e.prototype.destroy=function(){var e=this.rejections.slice(0);this.status.value=900,this.rejections.length=0;for(var t=e.length;t--;)e[t]();this.$e.emit("context.destroy")},e}();function Compose(e){var t,r;if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");try{for(var n=__values(e),o=n.next();!o.done;o=n.next()){if("function"!=typeof o.value)throw new TypeError("Middleware must be composed of functions!")}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return function(t,r){var n=-1;return function o(i){if(i<=n)return Promise.reject(new Error("next() called multiple times"));n=i;var a=e[i];i===e.length&&(a=r);if(!a)return Promise.resolve();try{return Promise.resolve(a(t,o.bind(null,i+1)))}catch(e){return Promise.reject(e)}}(0)}}var MiddlewareTransforms=function(){function e(){}return e.prototype.compose=function(e,t){var r=this;return this.common(e,t,(function(e,t){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return e.status.value=200,[4,t()];case 1:return r.sent(),[2]}}))}))}))},e.prototype.common=function(e,t,r){var n=this.getMiddlewareIndefiners(e,t),o=this.generateMiddlewares.apply(this,__spread(n));return r&&o.push(r),Compose(o)(e)},e.prototype.getMiddlewareIndefiners=function(e,t){var r=t.meta.parent.got(exports.NAMESPACE.MIDDLEWARE,[]),n=t.meta.got(exports.NAMESPACE.MIDDLEWARE,[]);return this.generateMiddlewares.apply(this,__spread(e.app.middlewares)).concat(r).concat(n)},e.prototype.generateMiddlewares=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.map((function(t){return t.prototype&&t.prototype.use?function(r,n){return __awaiter(e,void 0,void 0,(function(){var e;return __generator(this,(function(o){switch(o.label){case 0:if(!(e=TypeClientContainer.get(t)))throw new Error("Cannot find the ioc object on TypeClientContainer.");return[4,e.use(r,n)];case 1:return o.sent(),[2]}}))}))}:t}))},e}(),ExceptionConsumer=function(){function e(){}return e.prototype.catch=function(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,o;return __generator(this,(function(i){switch(i.label){case 0:return(n=this.getExceptorsIndefiners(t))?[3,2]:[4,Promise.resolve(r.app.getError(e,r))];case 1:case 3:case 5:return[2,i.sent()];case 2:return(o=TypeClientContainer.get(n))?[3,4]:[4,Promise.resolve(r.app.getError(new Error("Cannot find the ioc object on TypeClientContainer."),r))];case 4:return[4,Promise.resolve(o.catch(e,{ctx:r,metadata:t}))]}}))}))},e.prototype.getExceptorsIndefiners=function(e){var t=e.meta.parent.got(exports.NAMESPACE.EXCEPTION,null);return e.meta.got(exports.NAMESPACE.EXCEPTION,null)||t||null},e}();function ContextTransforming(e,t,r){return __awaiter(this,void 0,void 0,(function(){var n,o=this;return __generator(this,(function(i){switch(i.label){case 0:return n=new MiddlewareTransforms,[4,Promise.all([n.compose(e,t),r()]).then((function(){if(200===e.status.value)return Promise.resolve(e.$e.emit("context.create"))})).catch((function(r){return __awaiter(o,void 0,void 0,(function(){var n,o;return __generator(this,(function(i){switch(i.label){case 0:return"function"!=typeof r?[3,1]:[2,r()];case 1:return 100!==e.status.value?[3,3]:(n=new ExceptionConsumer,o=e.error,[4,n.catch(r,t,e)]);case 2:o.value=i.sent(),e.status.value=500,i.label=3;case 3:return[2]}}))}))}))];case 1:return[2,i.sent()]}}))}))}function ActionTransforming(e,t,r,n,o){return __awaiter(this,void 0,void 0,(function(){var i,a=this;return __generator(this,(function(s){switch(s.label){case 0:return[4,(new MiddlewareTransforms).common(e,t,(function(e,t){return __awaiter(a,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,Promise.resolve(r[n](e))];case 1:return i=o.sent(),[4,t()];case 2:return o.sent(),[2]}}))}))}))];case 1:return s.sent(),e.status.value=200,[4,Promise.all(o.map((function(t){return t(e,i)})))];case 2:return s.sent(),[2]}}))}))}var Request=function(e){function t(t){var r=e.call(this,t,!0)||this;return r.params={},r.method="GET",r}return __extends(t,e),t}(Url__default.default),Application=function(){function e(e){void 0===e&&(e={prefix:"/"}),this._initialized=!1,this._subscribed=!1,this._onHashChangeHandler=function(e){return e.scrollIntoView({behavior:"smooth"})},this.middlewares=[],this.reload=reload,this.prefix=e.prefix||"/",this.router=new Router(e),this.subscribe()}return e.prototype.setBeforeContextCreate=function(e){return this._beforeContextCreate=e,this},e.prototype.setAfterContextCreated=function(e){return this._afterContextCreated=e,this},e.prototype.use=function(e){return e.prototype&&e.prototype.use&&this.injectClassModules(e),this.middlewares.push(e),this},e.prototype.subscribe=function(){var e=this;return this._subscribed||(this._unSubscribe=useHistoryFeedback((function(t){return e._initialized?e.createContext(t):e.emitApplicationInitialize((function(){e._initialized=!0,e.createContext(t)}))})),this._subscribed=!0),this},e.prototype.emitApplicationInitialize=function(e){"function"==typeof this.applicationInitialize?this.applicationInitialize(e):e()},e.prototype.emitApplicationComponentRenderr=function(e,t,r,n){if("function"!=typeof this.applicationComponentRender)throw new Error("Can not render component in application render lifecycle.");this.applicationComponentRender(e,t,r,n)},e.prototype.emitApplicationErrorRender=function(e){if("function"!=typeof this.applicationErrorRender)throw new Error("Can not render error in application error lifecycle.");this.applicationErrorRender(e)},e.prototype.unSubscribe=function(){return this._subscribed?(this._unSubscribe&&(this._unSubscribe(),this._subscribed=!1),this):this},e.prototype.onNotFound=function(e){return this._onNotFoundHandler=e,this},e.prototype.emitNotFound=function(e){if("function"==typeof this._onNotFoundHandler){var t=this._onNotFoundHandler(e);t&&this.emitApplicationErrorRender(t)}},e.prototype.onError=function(e){return this._onErrorHandler=e,this},e.prototype.getError=function(e,t){if("function"==typeof this._onErrorHandler)return this._onErrorHandler(e,t)},e.prototype.emitError=function(e,t){var r=this.getError(e,t);r&&this.emitApplicationErrorRender(r)},e.prototype.onHashAnchor=function(e){return this._onHashChangeHandler=e,this},e.prototype.emitHashAnchor=function(e){"function"==typeof this._onHashChangeHandler&&this._onHashChangeHandler(e)},e.prototype.createContext=function(e){var t=this.decode(e);if(t){var r=new Request(t),n=this.router.lookup(r.pathname),o=this.context;if(!n)return this.emitNotFound(r);if(o)switch(o.status.value){case 100:o.destroy();break;case 200:o.$e.emit("context.destroy")}r.params=n.params||{},nextTick__default.default((function(){return n.handler.call(r,r)}))}},e.prototype.decode=function(e){if(e.startsWith(this.prefix)){var t=e.substring(this.prefix.length)||"/";return t.startsWith("/")||(t="/"+t),t}},e.prototype.injectClassModules=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.forEach((function(e){AnnotationDependenciesAutoRegister(e,TypeClientContainer)})),this},e.prototype.setController=function(e){var t,r,n=this,o=AnnotationMetaDataScan(e,TypeClientContainer),i=o.meta.got(exports.NAMESPACE.CONTROLLER,"/"),a=o.meta.got(exports.NAMESPACE.INJECTABLE,[]);this.injectClassModules.apply(this,__spread(a));var s=function(t,r){var o=r.meta.got(exports.NAMESPACE.PATH,[]);if(!o.length)return"continue";var a=r.meta.got(exports.NAMESPACE.INJECTABLE,[]),s=r.meta.got(exports.NAMESPACE.STATE,{}),c=r.meta.got(exports.NAMESPACE.CONTEXTCREATED,[]),l=r.meta.got(exports.NAMESPACE.ACTION,[]);u.injectClassModules.apply(u,__spread(a)),o.forEach((function(o){var a=path.join(i,".",o);n.router.on(a,(function(o){var i,a=TypeClientContainer.get(e),u=function(e){i=n.context=new Context(n,o,e),n._afterContextCreated&&n._afterContextCreated(i),c.forEach((function(e){return e(i)}))};n._beforeContextCreate?n._beforeContextCreate({server:a,key:t,state:s,next:u}):u("function"==typeof s?s():s),l.length?ActionTransforming(i,r,a,t,l).catch((function(e){return n.emitError(e,i)})):ContextTransforming(i,r,(function(){return Promise.resolve(n.emitApplicationComponentRenderr(i,a,t,r))}))}))}))},u=this;try{for(var c=__values(o.methods),l=c.next();!l.done;l=c.next()){var p=__read(l.value,2);s(p[0],p[1])}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}},e.prototype.urlencode=function(e){return e.startsWith(this.prefix)?e:path.join(this.prefix,".",e)},e.prototype.redirect=function(e,t){return redirect(this.urlencode(e),t)},e.prototype.replace=function(e,t){return replace(this.urlencode(e),t)},e}();Object.defineProperty(exports,"inject",{enumerable:!0,get:function(){return inversify.inject}}),exports.Action=Action,exports.ActionTransforming=ActionTransforming,exports.AnnotationDependenciesAutoRegister=AnnotationDependenciesAutoRegister,exports.AnnotationMetaDataScan=AnnotationMetaDataScan,exports.Application=Application,exports.ClassMetaCreator=ClassMetaCreator,exports.Compose=Compose,exports.Context=Context,exports.ContextTransforming=ContextTransforming,exports.Controller=Controller,exports.Exception=Exception,exports.ExceptionConsumer=ExceptionConsumer,exports.MethodMetaCreator=MethodMetaCreator,exports.Middleware=Middleware,exports.MiddlewareTransforms=MiddlewareTransforms,exports.ParameterMetaCreator=ParameterMetaCreator,exports.Redirect=Redirect,exports.Request=Request,exports.Route=Route,exports.Router=Router,exports.Service=Service,exports.State=State,exports.TypeClientContainer=TypeClientContainer,exports.bootstrp=bootstrp,exports.invoke=invoke,exports.mergeState=mergeState,exports.onContextCreated=onContextCreated,exports.redirect=redirect,exports.reload=reload,exports.replace=replace,exports.unSubscribe=unSubscribe,exports.useException=useException,exports.useHistoryFeedback=useHistoryFeedback,exports.useInject=useInject,exports.useMiddleware=useMiddleware,exports.usePopStateHistoryMode=usePopStateHistoryMode;
//# sourceMappingURL=/sm/1cec3cd4f6bcc31fb271dbd386a4a5de162e55947008f04e90073553d5610c24.map