(function(){"use strict";u8.Crm.Application=function(e,t){this.Application(e,$.extend({},u8.Crm.Application.defaults,t))};var e="~/crm";u8.Crm.Application.defaults={baseUrl:e,startPage:e+"/main.aspx",emptyPage:e+"/empty.aspx",loginPage:e+"/login"};u8.Crm.CrmProcessIds={designerDataModel:"50050010",designerProcessesAndRoles:"50050100",designerCatalogs:"50050090",designerFixedCatalogs:"50050020",dataModelChangeFieldLabels:"3210011",catalogMaintenance:"312600?"};$.extend(u8.Crm.Application.prototype,{dispose:function(){this.Application_dispose()},_applyUrlParameters:function(){this.Application__applyUrlParameters();if(!this.login||typeof this.login.sessionSettings=="undefined"){var e=this._elWindow.page.url;var t=e.get("roles");var i=null;var n=null;if(t){if(t=="*"){i={changeRoles:true}}else{n={roleIds:t.split(",")}}}var s=e.get("phoneProfile");if(s){if(s=="*"){i=$.extend(i,{changePhoneProfile:true})}else{n=$.extend(n,{phoneProfile:s})}}var a=e.get("language");if(a){if(a=="*"){i=$.extend(i,{changeLanguage:true})}else{n=$.extend(n,{language:a})}}if(i){this.login=$.extend(this.login,i)}if(n){this.login=$.extend(this.login,{sessionSettings:n})}}},_onLoginComplete:function(){this.Application__onLoginComplete();if(u8.session.isNotificationPluginEnabled){u8.services.changeNotificationsHub.init()}}});u8.Crm.Application.makeClass({name:"Application",deriveFrom:u8.Base.Application});u8.using.loaders.push({name:"processes",load:function(e,t){var i=Object.keys(e);var n=i.map(function(e){return e in u8.Crm.CrmProcessIds?u8.Crm.CrmProcessIds[e]:e});u8.request("AuthenticationChannel.GetProcessStates",{processIds:n},function(n,s){var a=s.response||[];i.forEach(function(t,i){e[t]=a[i]==="Active"});t()})}});u8.services.factory.ready("BrowserHistory",function(){var e=/\/(crm|sdk)\/\w+(\.aspx)?$/;var t=/\.aspx$/i;var i=/\/\w+$/;function n(e){e.pathname=e.pathname.replace(t,"");delete e.params.hid;delete e.params.history;delete e.params.login;var i=u8.debug.level;if(!e.has("debug")&&i){e.set("debug",i==u8.Base.Log.Severity.debug?null:i)}return e}function s(e){e.pathname+=".aspx";delete e.params.debug;return e}function a(e){return u8.application.url&&e.startsWith(u8.application.url)}function r(r){r=u8.url(r);if(!a(r.path)){return false}var o=r.pathname;var l=e.test(o);if(!l){return false}var u;if(t.test(o)){u=n(r.clone())}else if(i.test(o)){u=r;r=s(r.clone())}else{return false}return{route:u.toString(),url:r.toString()}}u8.services.events.bind("u8.services.browserHistory.onSetUrl",function(e,t){var i=r(t.url);if(!i){t.cancel=true}else{t.url=i.route;t.state.url=i.url}})})})();