var Client;(function(n){var t=function(){function n(){}return n.prototype.processAjaxError=function(n,t,i){console.log(i);console.log(t);console.log(n);var u=i,r=n.responseJSON;r&&r.Message&&r.Message!==""?u=r.Message:r&&r.ErrorMessage&&r.ErrorMessage!==""&&(u=r.ErrorMessage);r&&r.ExceptionMessage&&r.ExceptionMessage!==""&&(u=r.ExceptionMessage);r&&r.ModelStateErrors&&r.ModelStateErrors.length>0&&(u=r.ModelStateErrors[0]);toastr.error("<div>"+u+"<\/div>","Oops, something went wrong")},n.prototype.ajax=function(n,t,i){var r=this;return $.ajax(t,{data:i,type:n,contentType:"application/json; charset=utf-8'",error:function(n,t,i){r.processAjaxError(n,t,i)}})},n.prototype.get=function(n,t,i,r){if(t===void 0&&(t=!0),i===void 0&&(i="json"),r===void 0&&(r=!1),!n)return $.Deferred().reject().promise();i||(i="json");t==undefined&&(t=!1);var u={type:"get",cache:t,dataType:i,contentType:"application/json; charset=utf-8'"};return r||(u.error=this.processAjaxError),$.ajax(n,u)},n.prototype.getWithData=function(n,t,i,r){return(i===void 0&&(i=!0),r===void 0&&(r="json"),!n)?$.Deferred().reject().promise():(r||(r="json"),i==undefined&&(i=!1),$.ajax(n,{type:"get",data:JSON.stringify(t),cache:i,dataType:r,contentType:"application/json; charset=utf-8'",error:this.processAjaxError}))},n.prototype.getHtml=function(n){return this.get(n,!1,"html")},n.prototype.post=function(n,t){return this.ajax("post",n,t)},n.prototype.put=function(n,t){return this.ajax("put",n,t)},n.prototype.delete=function(n,t){return this.ajax("delete",n,t)},n.prototype.upload=function(n,t,i){return $.ajax({url:n,type:"POST",data:t,cache:!1,contentType:!1,processData:!1,xhr:function(){var n=new XMLHttpRequest;return i&&n.upload.addEventListener("progress",i,!1),n}})},n}();n.AjaxService=t})(Client||(Client={})),function(n){var t=function(){function n(n){this.id=ko.observable();this.name=ko.observable();this.code=ko.observable();this.dateCreated=ko.observable();this.dateModified=ko.observable();this.firstMonthOfSchoolYear=ko.observable();this.fromJs(n)}return n.prototype.fromJs=function(n){this.id(n.Id);this.name(n.Name);this.code(n.Code);this.dateCreated(n.DateCreated);this.dateModified(n.DateModified);this.firstMonthOfSchoolYear(n.FirstMonthOfSchoolYear)},n.prototype.toJs=function(){return{Id:this.id(),Name:this.name(),Code:this.code(),DateCreated:this.dateCreated(),DateModified:this.dateModified(),FirstMonthOfSchoolYear:this.firstMonthOfSchoolYear()}},n}();n.KnockoutCountryIdAndNameDto=t}(Client||(Client={})),function(n){var t=function(){function t(n){this.dto=ko.observable();this.countries=ko.observableArray([]);this.fromJs(n)}return t.prototype.fromJs=function(t){this.dto(t.Dto);this.countries(t.Countries.map(function(t){return new n.KnockoutCountryIdAndNameDto(t)}))},t.prototype.toJs=function(){return{Dto:this.dto(),Countries:this.countries().map(function(n){return n.toJs()})}},t}();n.KnockoutStayUpdatedPageViewModel=t}(Client||(Client={})),function(n){var t=function(){function n(n){this.email=ko.observable();this.firstName=ko.observable();this.lastName=ko.observable();this.countryId=ko.observable();this.interestIds=ko.observableArray([]);this.otherInterests=ko.observable();this.yearFrom=ko.observable();this.yearTo=ko.observable();this.fromJs(n)}return n.prototype.fromJs=function(n){this.email(n.Email);this.firstName(n.FirstName);this.lastName(n.LastName);this.countryId(n.CountryId);this.interestIds(n.InterestIds);this.otherInterests(n.OtherInterests);this.yearFrom(n.YearFrom);this.yearTo(n.YearTo)},n.prototype.toJs=function(){return{Email:this.email(),FirstName:this.firstName(),LastName:this.lastName(),CountryId:this.countryId(),InterestIds:this.interestIds(),OtherInterests:this.otherInterests(),YearFrom:this.yearFrom(),YearTo:this.yearTo()}},n}();n.KnockoutStayUpdatedDto=t}(Client||(Client={})),function(n){var t=function(){function t(t,i){var r=this;this.modelData=t;this.service=i;this.processing=ko.observable(!1);this.submitted=ko.observable(!1);this.success=ko.observable(!1);this.errorMessage=ko.observable("");this.dto=ko.validatedObservable(new n.KnockoutStayUpdatedDto({}));this.countryOptions=ko.observableArray([]);this.selectedYears=ko.observableArray([]);this.showOtherInterestInput=ko.observable(!1);this.canSave=ko.pureComputed(function(){return!!r.dto().firstName()&&!!r.dto().lastName()&&!!r.dto().email()&&!!r.dto().countryId()});this.subjectOptions=[{Id:3,Name:"Mathematics"},{Id:24,Name:"English"},{Id:4,Name:"Science"},{Id:37,Name:"SOLO Taxonomy"}];this.roleOptions=[{Id:47,Name:"Beginning Teacher"},{Id:48,Name:"Teacher"},{Id:50,Name:"Head of Department"},{Id:29,Name:"Assistant/Deputy Principal"},{Id:7,Name:"Head Teacher/Principal"},{Id:46,Name:"Parent"},{Id:45,Name:"Student"}];this.earlyChildhoodOptions=[{Id:31,Name:"ECE"}];this.yearOptions=[{From:1,To:3,Name:"Year 1-3"},{From:4,To:6,Name:"Year 4-6"},{From:7,To:8,Name:"Year 7-8"},{From:9,To:10,Name:"Year 9-10"}];this.derivedYearFrom=ko.computed(function(){var t=_.map(r.selectedYears(),function(n){return n.From}),n=t.sort(function(n,t){return n-t});return n.length?n[0]:0});this.derivedYearTo=ko.computed(function(){var t=_.map(r.selectedYears(),function(n){return n.To}),n=t.sort(function(n,t){return t-n});return n.length?n[0]:0});this.countryOptions(t.Countries);this.dto().fromJs(t.Dto);this.configureValidation()}return t.prototype.save=function(){var n=this;if(this.dto().yearFrom(this.derivedYearFrom()),this.dto().yearTo(this.derivedYearTo()),this.dto.errors&&this.dto.errors().length>0){this.dto.errors.showAllMessages();return}this.errorMessage("");this.success(!1);this.submitted(!0);this.processing(!0);this.service.save(this.dto().toJs()).then(function(){n.processing(!1);n.success(!0)})},t.prototype.configureValidation=function(){this.dto().email.extend({required:!0,email:!0})},t}();n.StayUpdatedIndex=t}(Client||(Client={})),function(n){var t=function(){function t(t){this.urls=t;this.ajax=new n.AjaxService}return t.prototype.save=function(n){return this.ajax.post(this.urls.StayUpdatedApi,JSON.stringify(n))},t}();n.StayUpdatedService=t}(Client||(Client={}))