"use strict";define(["app","handlebars","View","text!/v2/webapps/FirstAccess/AdminSettings/ClinicExceptionPopup/Templates/ClinicExceptionPopupTemplate.html","utils"],function(d,f,e,a,b){var c=e.extend({id:"clinicExceptionPopup",overlay:null,clinicExceptionPopupTemplate:f.compile(a),events:{"click .excpSave-btn":"Save","click .excpCancel-btn":"Cancel","change #languageSelect":"changeLanguages","change #clinicExcp":"changeClinic","keyup #messageText":"changeText"},Save:function(g){g.preventDefault();this.trigger("view:validate",{overlay:this.overlay},this);if(this.validating===true){this.overlay.close();}},Cancel:function(g){g.preventDefault();this.overlay.close();},initialize:function(g){e.prototype.initialize.apply(this,arguments);this.options=g||{};this.overlay=this.options.parent;this.validating=false;},changeText:function(){d.instance().Cache.Applied=false;},changeLanguages:function(i){if(d.instance().Cache.mode=="edit"){var h=d.instance().Cache.FormDataCache;var j=d.instance().Cache.excpDetails;var l=$("#languageSelect").val();var g;var k;h.forEach(function(m){if(m.clinicExcp===j.ClinicId&&l===m.languageSelect){g=m.message;k=m.excpId;}});if(g===undefined){g="";}document.getElementById("messageText").innerHTML=g;d.instance().Cache.Applied=false;d.instance().Cache.NewIdToEdit=k;}},render:function(g){e.prototype.render.apply(this,arguments);this.setParent(g.parent);d.instance().Cache.mode=g.mode;if(g.mode=="edit"){d.instance().Cache.excpDetails=g.exceptionDetails;g.Id=g.exceptionDetails!==undefined?parseInt(g.exceptionDetails.ClinicId,10):0;g.ExcpMessage=g.exceptionDetails!==undefined?g.exceptionDetails.Message:"";g.LangCd=g.exceptionDetails!==undefined?g.exceptionDetails.LangCd:0;g.languages=_.filter(g.languages,function(h){return h.Selected==="selected";});g.clinics=_.filter(g.clinics,function(h){return h.Id===g.Id;});}else{if(g.mode==="add"){g.Id=0;g.ExcpMessage="";g.LangCd=0;}}this.$el.html(this.clinicExceptionPopupTemplate(g));this.overlay.render().$el.find("#overlay").html(this.$el);g.parent.$el.append(this.overlay.$el);this.delegateEvents();return this;}});return c;});