function addLoadEvent(e){var t=window.onload;"function"!=typeof window.onload?window.onload=e:window.onload=function(){t&&t(),e()}}!function(e){var t=function(){"use strict";var e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();var o=function(){function o(e,t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),this.context_=e||{base_url:"",prefix:"",host:"",port:"",scheme:"",locale:""},this.setRoutes(t||{})}return n(o,[{key:"setRoutingData",value:function(e){this.setBaseUrl(e.base_url),this.setRoutes(e.routes),"prefix"in e&&this.setPrefix(e.prefix),"port"in e&&this.setPort(e.port),"locale"in e&&this.setLocale(e.locale),this.setHost(e.host),this.setScheme(e.scheme)}},{key:"setRoutes",value:function(e){this.routes_=Object.freeze(e)}},{key:"getRoutes",value:function(){return this.routes_}},{key:"setBaseUrl",value:function(e){this.context_.base_url=e}},{key:"getBaseUrl",value:function(){return this.context_.base_url}},{key:"setPrefix",value:function(e){this.context_.prefix=e}},{key:"setScheme",value:function(e){this.context_.scheme=e}},{key:"getScheme",value:function(){return this.context_.scheme}},{key:"setHost",value:function(e){this.context_.host=e}},{key:"getHost",value:function(){return this.context_.host}},{key:"setPort",value:function(e){this.context_.port=e}},{key:"getPort",value:function(){return this.context_.port}},{key:"setLocale",value:function(e){this.context_.locale=e}},{key:"getLocale",value:function(){return this.context_.locale}},{key:"buildQueryParams",value:function(e,n,o){var r=this,i=void 0,s=new RegExp(/\[\]$/);if(n instanceof Array)n.forEach((function(n,i){s.test(e)?o(e,n):r.buildQueryParams(e+"["+("object"===(void 0===n?"undefined":t(n))?i:"")+"]",n,o)}));else if("object"===(void 0===n?"undefined":t(n)))for(i in n)this.buildQueryParams(e+"["+i+"]",n[i],o);else o(e,n)}},{key:"getRoute",value:function(e){var t=[this.context_.prefix+e,e+"."+this.context_.locale,this.context_.prefix+e+"."+this.context_.locale,e];for(var n in t)if(t[n]in this.routes_)return this.routes_[t[n]];throw new Error('The route "'+e+'" does not exist.')}},{key:"generate",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.getRoute(t),s=n||{},u=e({},s),c="",a=!0,l="",f=void 0===this.getPort()||null===this.getPort()?"":this.getPort();if(i.tokens.forEach((function(e){if("text"===e[0])return c=o.encodePathComponent(e[1])+c,void(a=!1);if("variable"!==e[0])throw new Error('The token type "'+e[0]+'" is not supported.');var n=i.defaults&&e[3]in i.defaults;if(!1===a||!n||e[3]in s&&s[e[3]]!=i.defaults[e[3]]){var r=void 0;if(e[3]in s)r=s[e[3]],delete u[e[3]];else{if(!n){if(a)return;throw new Error('The route "'+t+'" requires the parameter "'+e[3]+'".')}r=i.defaults[e[3]]}if(!(!0===r||!1===r||""===r)||!a){var l=o.encodePathComponent(r);"null"===l&&null===r&&(l=""),c=e[1]+l+c}a=!1}else n&&e[3]in u&&delete u[e[3]]})),""===c&&(c="/"),i.hosttokens.forEach((function(e){var t=void 0;"text"!==e[0]?"variable"===e[0]&&(e[3]in s?(t=s[e[3]],delete u[e[3]]):i.defaults&&e[3]in i.defaults&&(t=i.defaults[e[3]]),l=e[1]+t+l):l=e[1]+l})),c=this.context_.base_url+c,i.requirements&&"_scheme"in i.requirements&&this.getScheme()!=i.requirements._scheme){var h=l||this.getHost();c=i.requirements._scheme+"://"+h+(h.indexOf(":"+f)>-1||""===f?"":":"+f)+c}else if(void 0!==i.schemes&&void 0!==i.schemes[0]&&this.getScheme()!==i.schemes[0]){var d=l||this.getHost();c=i.schemes[0]+"://"+d+(d.indexOf(":"+f)>-1||""===f?"":":"+f)+c}else l&&this.getHost()!==l+(l.indexOf(":"+f)>-1||""===f?"":":"+f)?c=this.getScheme()+"://"+l+(l.indexOf(":"+f)>-1||""===f?"":":"+f)+c:!0===r&&(c=this.getScheme()+"://"+this.getHost()+(this.getHost().indexOf(":"+f)>-1||""===f?"":":"+f)+c);if(Object.keys(u).length>0){var p=void 0,v=[],y=function(e,t){t=null===(t="function"==typeof t?t():t)?"":t,v.push(o.encodeQueryComponent(e)+"="+o.encodeQueryComponent(t))};for(p in u)this.buildQueryParams(p,u[p],y);c=c+"?"+v.join("&")}return c}}],[{key:"getInstance",value:function(){return r}},{key:"setData",value:function(e){o.getInstance().setRoutingData(e)}},{key:"customEncodeURIComponent",value:function(e){return encodeURIComponent(e).replace(/%2F/g,"/").replace(/%40/g,"@").replace(/%3A/g,":").replace(/%21/g,"!").replace(/%3B/g,";").replace(/%2C/g,",").replace(/%2A/g,"*").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/'/g,"%27")}},{key:"encodePathComponent",value:function(e){return o.customEncodeURIComponent(e).replace(/%3D/g,"=").replace(/%2B/g,"+").replace(/%21/g,"!").replace(/%7C/g,"|")}},{key:"encodeQueryComponent",value:function(e){return o.customEncodeURIComponent(e).replace(/%3F/g,"?")}}]),o}(),r=(o.Route,o.Context,new o);return{Router:o,Routing:r}}();"function"==typeof define&&define.amd?define([],t.Routing):"object"==typeof module&&module.exports?module.exports=t.Routing:(e.Routing=t.Routing,e.fos={Router:t.Router})}(this);