"use strict";define(["app","Controller","../../../../../components/Overlay/Views/OverlayView","../Views/ClinicExceptionPopupView"],function(d,e,b,c){var a=e.extend({callback:null,initialize:function(f){e.prototype.initialize.apply(this,arguments);_.extend(this,f);this.overlayView=new b({framework:d.instance().FrontendFramework(),css:{display:"none","background-color":"rgba(27,27,27,0.9)","z-index":"100"}});this.clinicExceptionPopupView=new c({parent:this.overlayView});this.validationModel=new (Backbone.Model.extend({validation:{clinicExcp:{required:true},messageText:{required:true}}}))();},open:function(f,g){this.callback=g;this.view=this.clinicExceptionPopupView.render(f);Backbone.Validation.bind(this.view,{model:this.validationModel});this.listenTo(this.view,"view:validate",_.bind(this.validate,this));},close:function(){this.overlayView.close();},validate:function(i,f){var j=false;var h=this.view.$el.find("form").serialize();var l=d.instance().Cache.FormDataCache?d.instance().Cache.FormDataCache:[];if(l.length>0){_.find(l,function(o){if(o.clinicExcp.toString()===h.clinicExcp.toString()&&o.languageSelect===h.languageSelect){j=true;o.message=h.messageText;}});}this.validationModel.set(h);f.validating=this.validationModel.isValid(true);if(this.validationModel.isValid(true)&&(!j||d.instance().Cache.mode==="edit")&&d.instance().Cache.Applied===false){if(!j){l.push(h);}d.instance().Cache.FormDataCache=l;var k=this.view.$el.find("#clinicExcp").val();var m=this.view.$el.find("#clinicExcp option:selected").text().trim();var g=this.view.$el.find("#messageText").val().trim();var n=this.view.$el.find("#languageSelect option:selected").val();if(this.callback){this.callback.apply(this,[{clinicId:k,clinicDesc:m,LangCd:n,excpMessage:g}]);}}}});return a;});