//>>built
define("dojox/app/controllers/History",["dojo/_base/lang","dojo/_base/declare","dojo/on","../Controller"],function(g,d,h,e){return d("dojox.app.controllers.History",e,{constructor:function(a){this.events={startTransition:this.onStartTransition};this.inherited(arguments);this.bind(window,"popstate",g.hitch(this,this.onPopState))},_buildHashWithParams:function(a,b){"#"!==a.charAt(0)&&(a="#"+a);for(var c in b){var f=b[c];c&&null!=f&&(a=a+"&"+c+"="+b[c])}return a},onStartTransition:function(a){var b=
/#(.+)/;!a.detail.target&&b.test(a.detail.href)&&a.detail.href.match(b);b=a.detail.url||"#"+a.detail.target;a.detail.params&&(b=this._buildHashWithParams(b,a.detail.params));history.pushState(a.detail,a.detail.href,b)},onPopState:function(a){if(this.app.getStatus()===this.app.lifecycle.STARTED){var b=a.state;b||(b=!this.app._startView&&window.location.hash?{target:(location.hash&&"#"==location.hash.charAt(0)?location.hash.substr(1):location.hash).split("&")[0],url:location.hash,params:this.app.getParamsFromHash(location.hash)||
this.defaultParams||{}}:{});var c=b.target||this.app._startView||this.app.defaultView,f=b.params||this.app._startParams||this.app.defaultParams||{};if(this.app._startView)this.app._startView=null;var d=b.title||null,e=b.url||null;a._sim&&history.replaceState(b,d,e);this.app.trigger("transition",{viewId:c,opts:g.mixin({reverse:!0},a.detail,{params:f})})}}})});