"use strict";define(["app","Controller","../../../../../components/Overlay/Views/OverlayView","../Views/PatientOrientationPopupView","../../Models/AdminSettingsModel","utils"],function(d,e,c,g,f,a){var b=e.extend({callback:null,initialize:function(h){this.adminSettingsModel=new f();e.prototype.initialize.apply(this,arguments);_.extend(this,h);this.overlayView=new c({framework:d.instance().FrontendFramework(),css:{display:"none","background-color":"rgba(27,27,27,0.9)","z-index":"100"}});this.patientOrientationPopupView=new g({parent:this.overlayView});this.validationModel=new (Backbone.Model.extend({validation:{questionText:{required:true},messageText:{required:true},selectCrystalReport:[{required:false},{fn:_.bind(function(l,i,j){if(l){var k=l.split(".").pop().toLowerCase();if(k!="rpt"){return a.localize(this,["adminglobal.crystalreportfileerror"]);}}},this)}]}}))();},open:function(h,i){this.callback=i;this.Id=h.Id;h.questionTypes=[{type:0,text:a.localize(this,["adminsetting.unanswered"])},{type:1,text:a.localize(this,["adminsetting.YesNo"]),selected:"selected"}];this.view=this.patientOrientationPopupView.render(h);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(p,j){var n=this.view.$el.find("form").serialize();this.validationModel.set(n);var h=this.view.$el.find("#selectCrystalReport").get(0).files;if(h.length>0){this.validationModel.set({selectCrystalReport:h[0].name});}j.validating=this.validationModel.isValid(true);if(this.validationModel.isValid(true)){if(this.callback){var i=this.Id;var q=parseInt(this.view.$el.find("#questionTypeSelect option:selected").val().trim(),10);var o=this.view.$el.find("#questionText").val().trim();var r=this.view.$el.find("#messageText").val().trim();var m=this.view.$el.find("#textFileArea").val();var l=(m.length>0&&h.length>0)?h[0]:null;var k=this.view.$el.find("#languageSelect").val();this.callback.apply(this,[{id:i,type:q,questionText:o,messageText:r,crystalReport:m,file:l,languageCode:k}]);}}}});return b;});