define(["ember","app","broad","mm","core/utilities/math.helper"],function(a,b,c,d){return a.Mixin.create({model:{},statusBar:{signal:{},updateState:""},state:"loaded",forcedupdate:!1,updateState:"none",dialogResolve:null,dialogQuence:a.RSVP.Promise.resolve(!0),onInit:function(){var c=this;d.listener.on("ping",function(b,d){c.set("statusBar.signal",a.Object.create({status:d.status,takes:d.takes}))}),d.request(!0,{module:"version",action:"get"}).then(function(c){b.version.set("client",a.Object.create(c)),console.log("app version: "),console.log(b.version)})}.on("init"),didUpdateStateChanged:function(){this.set("statusBar.updateState",this.get("updateState"))}.observes("updateState"),login:function(){this.get("session.appUser.Token")&&d.post({Token:this.get("session.appUser.Token"),PersonID:this.get("session.appUser.PersonID"),ClassID:this.get("session.appUser.ClassID"),ChineseName:this.get("session.appUser.ChineseName")},{module:"instruction",action:"setUser"})}.observes("session.appUser"),actions:{tokenExpired:function(){this.set("previousTransition",this.get("activeTransition")),this.transitionToRoute("login")},startLoading:function(){if("loaded"==this.get("state")){this.set("state","loading");var b=this;this.get("dialogQuence").then(function(){return new a.RSVP.Promise(function(a){b.set("dialogResolve",a);var c=b.get("dialogManager").getDialog(b.get("dialog-name-loading"));c||(b.get("dialogManager").custom('<div class="dialog-body"><div class="pload"><p class="xtu1"></p><p class="xwork">正在努力工作中...</p><p class="xzi"></p><p class="xbi"></p><p class="xs"></p><p class="xzhi"></p></div></div>',{},{name:b.get("dialog-name-loading"),width:561,height:427,front:!0,frame:!1}),c=b.get("dialogManager").getDialog(b.get("dialog-name-loading"))),c.show()})})}},stopLoading:function(){if("loading"==this.get("state")){this.set("state","loaded");var b=this.get("dialogManager").getDialog(this.get("dialog-name-loading"));b&&b.hide(),this.get("dialogResolve")&&(a.run(null,this.get("dialogResolve"),!0),this.set("dialogResolve",null))}},notice:function(b){var c=this;this.get("dialogQuence").then(function(){return new a.RSVP.Promise(function(d){c.get("dialogManager").notice(b),a.run.later(function(){a.run(null,d,!0)},5e3)})})},reload:function(){var b=this;b.set("updateState","none"),this.get("dialogQuence").then(function(){return new a.RSVP.Promise(function(c){b.get("forcedupdate")?(d.post({},{module:"loader",action:"reload"}),b.set("forcedupdate",!1)):b.get("dialogManager").confirm("更新内容已下载完毕，是否立即重启？",{},{title:"软件更新提示",front:!0}).then(function(){d.post({},{module:"loader",action:"reload"}),a.run(null,c,!0)},function(){a.run(null,c,!0)})})})}}})});