define(["Marionette","base/BaseCtrl","./views/LayoutView","./views/PicView","./views/TextView","./views/HandMenuView","./views/NextPrevView","events/EventManager"],function(a,b,c,d,e,f,g,h){var i=a.Controller.extend({initialize:function(a){b.applyMixin.call(this),this.ctrls={},this.views={},this.eventManager=new h(this),this.region=a.region,this.lessonsModel=a.lessonsModel,this.settingsModel=a.settingsModel,_.bindAll(this,"onSettingsModelAudioChanged","onClickToogleSpace"),this.eventManager.bindKeyboardEvents(),this.eventManager.addKeyVisible(this.cid),this._bindEvents()},_bindEvents:function(){this.eventManager.bind(CtrlEvents.Settings.audioChanged,this.onSettingsModelAudioChanged,this),this.eventManager.bind("key:space",this.onClickToogleSpace,this)},_unbindEvents:function(){this.eventManager&&this.eventManager.unbindAll(),this.eventManager&&this.eventManager.unbindKeyboardEvents()},onSettingsModelAudioChanged:function(){this.showHandeView()},show:function(){this.views.layoutView=componentUtils.destroy(this.views.layoutView),this.views.layoutView=new c({lessonsModel:this.lessonsModel,settingsModel:this.settingsModel}),this.region.show(this.views.layoutView),this.showTextView(),this.showPicView(),this.showHandeView(),this.lessonsModel.getModelLength()>1&&(this.showNextView(),this.showPrevView())},showPicView:function(){this.views.picView=componentUtils.destroy(this.views.picView),"hide"!==this.settingsModel.getPictureLessonSelected().id&&this.lessonsModel.isLessonPic()&&(this.views.picView=new d({lessonsModel:this.lessonsModel,settingsModel:this.settingsModel}),this.views.picView.on("request:clickPicture",this.onClickText,this),this.views.layoutView.picRegion.show(this.views.picView))},showTextView:function(){this.views.textView=componentUtils.destroy(this.views.textView),this.lessonsModel.isLessonText()&&(this.views.textView=new e({lessonsModel:this.lessonsModel,settingsModel:this.settingsModel}),this.views.textView.on("request:clickText",this.onClickText,this),this.views.layoutView.textRegion.show(this.views.textView))},onClickToogleSpace:function(){this.settingsModel.stopAudio(),this.settingsModel.tooglePlayPauseAudio()},onClickText:function(){this.settingsModel.tooglePlayPauseAudio()},showHandeView:function(){window.myConfigApp.display.audioPlayer.show&&(this.views.handMenuView&&!this.views.handMenuView.isDestroyed?this.views.handMenuView.render():(this.views.handMenuView=componentUtils.destroy(this.views.handMenuView),this.views.handMenuView=new f({settingsModel:this.settingsModel,lessonsModel:this.lessonsModel}),this.views.handMenuView.on("request:modelAudioPlayPause",this.onModelAudioPlayPause,this),this.views.handMenuView.on("request:modelAudioStop",this.onModelAudioStop,this),this.views.handMenuView.on("request:modeAudioplay",this.onModeAudioplay,this),this.views.layoutView.handMenuRegion.show(this.views.handMenuView)))},onModelAudioPlayPause:function(){this.settingsModel.tooglePlayPauseAudio()},onModelAudioStop:function(){this.settingsModel.stopAudio()},onModeAudioplay:function(){this.settingsModel.toogleModeAudioplay()},showNextView:function(){this.views.nextView=componentUtils.destroy(this.views.nextView),this.views.nextView=new g({isNext:!0}),this.views.nextView.on("request:click",this.onClickNext,this),this.views.layoutView.nextLesson.show(this.views.nextView)},showPrevView:function(){this.views.prevView=componentUtils.destroy(this.views.prevView),this.views.prevView=new g({isNext:!1}),this.views.prevView.on("request:click",this.onClickPrev,this),this.views.layoutView.prevLesson.show(this.views.prevView)},onClickPrev:function(){this.lessonsModel.prevLesson()},onClickNext:function(){this.lessonsModel.nextLesson()}});return _.extend(i.prototype,b),i});