//>>built
define("dojo/router/RouterBase",["dojo/_base/declare","dojo/hash","dojo/topic"],function(n,l,o){function p(a,b,c){var d,e,f;d=this.callbackQueue;f=e=!1;a={stopImmediatePropagation:function(){e=!0},preventDefault:function(){f=!0},oldPath:b,newPath:c,params:a};for(b=0,c=d.length;b<c;++b)if(!e)d[b](a);return!f}var m;m=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")};return n(null,{_routes:null,_routeIndex:null,_started:!1,_currentPath:"",
idMatch:/:(\w[\w\d]*)/g,idReplacement:"([^\\/]+)",globMatch:/\*(\w[\w\d]*)/,globReplacement:"(.+)",constructor:function(a){this._routes=[];this._routeIndex={};for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])},register:function(a,b){return this._registerRoute(a,b)},registerBefore:function(a,b){return this._registerRoute(a,b,!0)},go:function(a,b){var c,a=m(a);(c=this._handlePathChange(a))&&l(a,b);return c},startup:function(){if(!this._started){var a=this;this._started=!0;this._handlePathChange(l());
o.subscribe("/dojo/hashchange",function(){a._handlePathChange.apply(a,arguments)})}},_handlePathChange:function(a){var b,c,d,e,f,g,h,i,j=this._routes,k=this._currentPath;if(!this._started||a===k)return c;c=!0;for(b=0,d=j.length;b<d;++b)if(f=j[b],g=f.route.exec(a)){if(f.parameterNames){h=f.parameterNames;i={};for(c=0,e=h.length;c<e;++c)i[h[c]]=g[c+1]}else i=g.slice(1);c=f.fire(i,k,a)}if(c)this._currentPath=a;return c},_convertRouteToRegExp:function(a){a=a.replace(this.idMatch,this.idReplacement);a=
a.replace(this.globMatch,this.globReplacement);return RegExp("^"+a+"$")},_getParameterNames:function(a){var b=this.idMatch,c=this.globMatch,d=[],e;for(b.lastIndex=0;null!==(e=b.exec(a));)d.push(e[1]);null!==(e=c.exec(a))&&d.push(e[1]);return 0<d.length?d:null},_indexRoutes:function(){var a,b,c,d,e=this._routes;d=this._routeIndex={};for(a=0,b=e.length;a<b;++a)c=e[a],d[c.route]=a},_registerRoute:function(a,b,c){var d,e,f,g,h,i=this,j=this._routes,k=this._routeIndex;d=this._routeIndex[a];(e="undefined"!==
typeof d)&&(f=j[d]);f||(f={route:a,callbackQueue:[],fire:p});g=f.callbackQueue;if("string"==typeof a)f.parameterNames=this._getParameterNames(a),f.route=this._convertRouteToRegExp(a);c?g.unshift(b):g.push(b);if(!e)d=j.length,k[a]=d,j.push(f);h=!1;return{remove:function(){var a,c;if(!h){for(a=0,c=g.length;a<c;++a)g[a]===b&&g.splice(a,1);0===g.length&&(j.splice(d,1),i._indexRoutes());h=!0}},register:function(b,c){return i.register(a,b,c)}}}})});