function updateQuestionVisibilityBasedOnScore(){var n=npsSurveyViewModel.ActiveNpsScore();npsSurveyViewModel.ShowPromoterFollowUpQuestion(n>=9);npsSurveyViewModel.ShowPassiveFollowUpQuestion(n>=7&&n<9);npsSurveyViewModel.ShowDetractorFollowUpQuestion(n<7)}(function(){var n=typeof isNpsSurveyPage=="undefined"||isNpsSurveyPage===null;npsSurveyViewModel={IsModal:ko.observable(n),NpsSurveyId:ko.observable(n?npsSurveyId:npsScoreIdForSurveyPage),NpsUniqueId:ko.observable(null),MainQuestion:ko.observable(""),PromoterFollowUpQuestion:ko.observable(""),PassiveFollowUpQuestion:ko.observable(""),DetractorFollowUpQuestion:ko.observable(""),UseSecondaryLogo:ko.observable(!1),PromoterThankYouMessage:ko.observable(""),PassiveThankYouMessage:ko.observable(""),DetractorThankYouMessage:ko.observable(""),ActiveNpsScore:ko.observable(n?null:npsScoreForSurveyPage),Feedback:ko.observable(null),ShowSurvey:ko.observable(!0),ShowMainQuestion:ko.observable(!0),ShowPromoterFollowUpQuestion:ko.observable(!1),ShowPassiveFollowUpQuestion:ko.observable(!1),ShowDetractorFollowUpQuestion:ko.observable(!1),ShowFeedback:ko.observable(!1),ShowThankYou:ko.observable(!1),ShowError:ko.observable(!1),ErrorMessage:ko.observable(""),IsLoadingNpsSurvey:ko.observable(!1),GetNpsSurveyFormData:function(){npsSurveyViewModel.IsLoadingNpsSurvey(!0);$.ajax({url:getNpsSurveyFormDataUrl,type:"GET",data:{npsScoreId:npsSurveyViewModel.NpsSurveyId()},success:function(n){n&&(npsSurveyViewModel.NpsUniqueId(n.UniqueID),npsSurveyViewModel.MainQuestion(n.MainQuestion),npsSurveyViewModel.PromoterFollowUpQuestion(n.PromoterFollowUpQuestion),npsSurveyViewModel.PassiveFollowUpQuestion(n.PassiveFollowUpQuestion),npsSurveyViewModel.DetractorFollowUpQuestion(n.DetractorFollowUpQuestion),npsSurveyViewModel.PromoterThankYouMessage(n.PromoterPostSurveyMessage),npsSurveyViewModel.PassiveThankYouMessage(n.PassivePostSurveyMessage),npsSurveyViewModel.DetractorThankYouMessage(n.DetractorPostSurveyMessage),npsSurveyViewModel.UseSecondaryLogo(n.UseSecondaryLogo))},error:function(n){npsSurveyViewModel.ShowSurvey(!1);npsSurveyViewModel.ShowThankYou(!1);var t="An unexpected error occurred while requesting NPS Survey: ";t+=n.status==404||n.responseText.includes("NPS Survey was not found.")?"\nNPS Survey was not found.":n.responseText?"\n"+n.responseText:"\nError details could not be parsed.";npsSurveyViewModel.ErrorMessage(t);npsSurveyViewModel.ShowError(!0)}}).always(function(){npsSurveyViewModel.IsLoadingNpsSurvey(!1)})},AnswerNpsSurvey:function(n){npsSurveyViewModel.ActiveNpsScore(n);npsSurveyViewModel.ShowMainQuestion(!1);npsSurveyViewModel.ShowFeedback(!0);updateQuestionVisibilityBasedOnScore();npsSurveyViewModel.ActiveNpsScore()>=9?(npsSurveyViewModel.ShowPromoterFollowUpQuestion(!0),npsSurveyViewModel.ShowPassiveFollowUpQuestion(!1),npsSurveyViewModel.ShowDetractorFollowUpQuestion(!1)):npsSurveyViewModel.ActiveNpsScore()>=7&&npsSurveyViewModel.ActiveNpsScore()<9?(npsSurveyViewModel.ShowPromoterFollowUpQuestion(!1),npsSurveyViewModel.ShowPassiveFollowUpQuestion(!0),npsSurveyViewModel.ShowDetractorFollowUpQuestion(!1)):(npsSurveyViewModel.ShowPromoterFollowUpQuestion(!1),npsSurveyViewModel.ShowPassiveFollowUpQuestion(!1),npsSurveyViewModel.ShowDetractorFollowUpQuestion(!0));npsSurveyViewModel.ActiveNpsScore()!=null&&npsSurveyViewModel.NpsUniqueId()!=null&&$.ajax({url:answerNpsSurveyUrl,type:"POST",data:{uniqueID:npsSurveyViewModel.NpsUniqueId(),score:npsSurveyViewModel.ActiveNpsScore()},error:function(){ShowCustomAlert("You are impersonating a user.  For security reasons, you cannot perform this action.");$("#novi-pop-up").modal("hide")}})},SubmitNpsSurveyFeedback:function(){npsSurveyViewModel.ShowSurvey(!1);npsSurveyViewModel.ShowThankYou(!0);npsSurveyViewModel.Feedback()!=null&&npsSurveyViewModel.NpsUniqueId()!=null&&$.ajax({url:submitNpsSurveyFeedbackUrl,type:"POST",data:{uniqueID:npsSurveyViewModel.NpsUniqueId(),feedback:npsSurveyViewModel.Feedback()}})},SkipNpsSurvey:function(){npsSurveyViewModel.ActiveNpsScore()==null&&npsSurveyViewModel.NpsUniqueId()!=null?$.ajax({url:skipNpsSurveyUrl,type:"POST",data:{uniqueID:npsSurveyViewModel.NpsUniqueId()},error:function(){ShowCustomAlert("You are impersonating a user.  For security reasons, you cannot perform this action.")}}).always(function(){$("#novi-pop-up").modal("hide")}):$("#novi-pop-up").modal("hide")},SnoozeNpsSurvey:function(){$("#novi-pop-up").modal("hide");npsSurveyViewModel.ActiveNpsScore()==null&&npsSurveyViewModel.NpsSurveyId()!=null&&$.ajax({url:snoozeNpsSurveyUrl,type:"POST",data:{id:npsSurveyViewModel.NpsSurveyId()}})},ThankYouCloseNpsSurvey:function(){$("#novi-pop-up").modal("hide")}};npsSurveyViewModel.ThankYouMessage=ko.computed(function(){const n=this.ActiveNpsScore();return n<=6&&this.DetractorThankYouMessage()!=null&&this.DetractorThankYouMessage()!==""?this.DetractorThankYouMessage():n<=8&&this.PassiveThankYouMessage()!=null&&this.PassiveThankYouMessage()!==""?this.PassiveThankYouMessage():n<=10&&this.PromoterThankYouMessage()!=null&&this.PromoterThankYouMessage()!==""?this.PromoterThankYouMessage():"Thank You!"},npsSurveyViewModel)})();$(document).ready(function(){var n=document.getElementById("nps-survey");n&&(ko.cleanNode(n),ko.applyBindings(npsSurveyViewModel,n),npsSurveyViewModel.GetNpsSurveyFormData(),npsSurveyViewModel.ActiveNpsScore()==null||npsSurveyViewModel.IsModal()||(npsSurveyViewModel.ShowMainQuestion(!1),updateQuestionVisibilityBasedOnScore(),npsSurveyViewModel.ShowFeedback(!0)))})