var Application,__extends,Commerce,Constants,Entities,Helpers,Services,AccountInfoModel,WebContent;(function(n){$(document).ready(function(){return t.Initialize()});$(document).ready(function(){return t.HandleAdditionalParams()});$(document).ajaxSend(function(n,i){return t.SetupAuthorization(i)});$(document).ajaxComplete(function(n,i,r){return t.AjaxComplete(n,i,r)});var t=function(){function t(){}return t.Initialize=function(){this.ProcessApplyingPromo();this.SetupKnockoutSetting();this.InitalizeTypeScriptContexts();this.InitalizeKnockOutViewModels()},t.SetupAuthorization=function(n){if($.cookie(Constants.Global.UserTokenCookieKey)){var t=new Entities.Token;$.extend(t,JSON.parse($.cookie(Constants.Global.UserTokenCookieKey)));t&&n.setRequestHeader("Authorization",t.TokenType+" "+t.TokenValue)}},t.AjaxComplete=function(n,t){var r,u,i;t.readyState===4&&(t.status===401?($.removeCookie(Constants.Global.BasketCookieKey,{path:"/"}),r=$(".js-wkis-login-open"),location.href=location.origin+r.length&&r.first().attr("href")?r.first().attr("href"):"/store/checkout/sign-in/"):$.cookie(Constants.Global.UserTokenCookieKey)&&(u=new Entities.Token,$.extend(u,JSON.parse($.cookie(Constants.Global.UserTokenCookieKey))),i=new Date,i.setTime(i.getTime()+Constants.Global.UserTokenExpirationMinutes*6e4),u.ExpiresAt=i.toISOString(),$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(u),{path:"/",expires:i,secure:!0}),$.cookie(Constants.Global.BasketCookieKey)&&$.cookie(Constants.Global.BasketCookieKey,$.cookie(Constants.Global.BasketCookieKey),{path:"/",expires:i})))},t.HandleAdditionalParams=function(){var t=this.GetParameterByName("cjevent",""),n;t!=null&&this.HandleCjeCookie(t);n=this.GetParameterByName("form","");n!=null&&this.showPopup(n);$(".show-only-umbraco").remove()},t.GetParameterByName=function(n,t){t||(t=window.location.href);n=n.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?&]"+n+"(=([^&#]*)|&|#|$)"),i=r.exec(t);return i?i[2]?decodeURIComponent(i[2].replace(/\+/g," ")):"":null},t.showPopup=function(n,t){var i,r;t===void 0&&(t=null);n&&(i="modal-id",t!=null&&(i=t),r="div["+i+"='"+n+"']",$(r).length&&($(r).addClass("-is-open"),$("html").addClass("-js-modal-open")))},t.HandleCjeCookie=function(n){if(n){var t=new Date;t.setMonth(t.getMonth()+13);$.cookie("cje",n,{path:"/",expires:t,secure:!0})}},t.SetupKnockoutSetting=function(){n.Knockout.InitializeContributedRules();n.Knockout.InitializeHandlers();ko.validation.init({decorateInputElement:!0,errorElementClass:"ko-error",errorMessageClass:"ko-validation-message"})},t.InitalizeTypeScriptContexts=function(){var n=this.GetAllContext("[ts-initialize]",document),t=this.GetMappedContexts(n,"ts-initialize");this.InitializeContexts(t)},t.InitalizeKnockOutViewModels=function(){var n=this.GetAllContext("[ko-viewmodel]",document),t=this.GetMappedContexts(n,"ko-viewmodel");this.InitializeKnockoutViewModels(t)},t.GetAllContext=function(n,t){return $(n,t).toArray()},t.GetMappedContexts=function(n,t){var r=this,i=[];return n.length&&n.forEach(function(n){i.push({element:n,"class":r.ActivateObject(n.getAttribute(t).split("."))})}),i},t.ActivateObject=function(n){for(var f=[],i,r,e,u,t=1;t<arguments.length;t++)f[t-1]=arguments[t];for(i=window,r=0;r<n.length;r++)e=n[r].trim(),i=i[e];return u=Object.create(i.prototype),u.constructor.apply(u,f),u},t.InitializeContexts=function(n){n.forEach(function(n){n.element&&n.class&&n.class.Initialize&&n.element instanceof HTMLElement&&n.class.Initialize(n.element)})},t.InitializeKnockoutViewModels=function(n){n.forEach(function(n){n.element&&n.class&&n.element instanceof HTMLElement&&ko.applyBindings(Object.create(n.class),n.element)})},t.ProcessApplyingPromo=function(){var n=Helpers.UrlHelper.GetUrlParam(window.location.href.toLowerCase(),"applypromo");n&&localStorage.setItem(Constants.Commerce.ApplyingPromoCodeKey,n)},t}();n.App=t})(Application||(Application={})),function(n){var t=function(){function n(){}return n.InitializeContributedRules=function(){ko.validation.rules.spaceInPassword={validator:function(n,t){return t?!n||n.charAt(0)!=Constants.Global.Space&&n.charAt(n.length-1)!=Constants.Global.Space:!0},message:"No validation was done for leading or trailing spaces in password."};ko.validation.registerExtenders()},n.InitializeHandlers=function(){ko.bindingHandlers.masked={init:function(n,t,i){var r=i().mask||{},u=i().placeholder;u?$(n).mask(r,{placeholder:u}):$(n).mask(r);ko.utils.registerEventHandler(n,"blur",function(){var i=t();i($(n).val())})},update:function(n,t){var i=ko.utils.unwrapObservable(t());$(n).val(i)}}},n}();n.Knockout=t}(Application||(Application={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){var t=this.InitAccountInformation(n);this.InitChangePasswordForm();this.InitChangeEmailForm(t);this.InitEnterPasswordForm(t)},t.prototype.InitAccountInformation=function(t){var i=new n.ViewModel.AccountInformationViewModel(t);return ko.applyBindings(i,t),i},t.prototype.InitChangeEmailForm=function(t){var i=$('[role="dialog"][data-modal="edit-email"]');$('button[data-modal="edit-email"]').click(function(){$("input",i).val("");$(".ko-validation-message",i).not("[instant]").remove();$(".ko-validation-message",i).hide();ko.cleanNode(i[0]);var r=new n.ViewModel.ChangeEmailViewModel(i[0],t);ko.applyBindings(r,i[0])})},t.prototype.InitChangePasswordForm=function(){var t=$('[role="dialog"][data-modal="edit-password"]').first(),i=$('button[data-modal="edit-password"]').click(function(){$("input",t).val("");$(".ko-validation-message",t).not("[instant]").remove();$(".ko-validation-message",t).hide();ko.cleanNode(t[0]);var i=new n.ViewModel.ChangePasswordViewModel(t[0]);ko.applyBindings(i,t[0])})},t.prototype.InitEnterPasswordForm=function(t){var i=$('[role="dialog"][data-modal="enter-password"]').first(),r=$('button[data-modal="enter-password"]').click(function(){$("input",i).val("");$(".ko-validation-message",i).not("[instant]").remove();$(".ko-validation-message",i).hide();ko.cleanNode(i[0]);var r=new n.ViewModel.EnterPasswordViewModel(i[0],t);ko.applyBindings(r,i[0])})},t}();t.AccountInformationPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=Application.App,i=function(){function n(){}return n.prototype.Initialize=function(){Helpers.HtmlHelper.PreventJumpingOnTargetElement(null,this.ShowActiveTabAccordingSelectedTarget);this.ShowDefaultActiveTab();this.HadnleWindowHashChangeEvent();this.ShowActiveTabAccordingSelectedTarget();this.AutoHideHelpInfoOnSelectTab();Helpers.HtmlHelper.HideHelpInfo()},n.prototype.HadnleWindowHashChangeEvent=function(){var n=this;window.onhashchange=function(){n.ShowActiveTabAccordingSelectedTarget()}},n.prototype.ShowActiveTabAccordingSelectedTarget=function(){var i,t;location.hash.length&&(i={paramName:"",contains:!1},n.ContainsTabParameter(location.hash,i),i.contains&&($(".wkis-account-tabs a").removeClass("-active"),t=$(".wkis-account-tabs a[href='#"+i.paramName+"']"),t.addClass("-active"),t.parent().siblings("li").removeClass("active"),t.parent().addClass("active"),$("#accountLastBreadcrumb").text(t.text())))},n.prototype.ShowDefaultActiveTab=function(){var i,u,r,f;location.hash.length==0?(location.href=location.href.replace("#","")+"#accountOverviewContainer",$(document).scrollTop(0)):(i={paramName:"",contains:!1},n.ContainsTabParameter(location.hash,i),i.contains?(u=location.href.indexOf("#"),r="",t.GetParameterByName("popup",location.href)&&(r=t.GetParameterByName("popup",location.href)),f=location.href.substring(0,u!=-1?u:location.href.length),location.href=f+"#"+i.paramName,r.length>0&&t.showPopup(r),$(document).scrollTop(0)):(location.href=location.href.replace("#","")+"#accountOverviewContainer",$(document).scrollTop(0)))},n.ContainsTabParameter=function(n,t){var i=["accountOverviewContainer","accountOrderHistoryContainer","accountInformationContainer","addressBookContainer"],r;for(r in i)n.indexOf(i[r])>-1&&(t.paramName=i[r],t.contains=!0)},n.prototype.AutoHideHelpInfoOnSelectTab=function(){$("ul.wkis-account-tabs-inner li").bind("click.autoHideHelpInfo",function(n){var t=$(n.currentTarget);t.hasClass("active")&&$("#accountOrderHistoryLink",t).length&&$("#accountOrderHistoryContainer").hasClass("loaded-history-model")?Helpers.HtmlHelper.ShowHelpInfo():Helpers.HtmlHelper.HideHelpInfo()})},n}();n.AccountOverviewPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){t.GetAndShowCartItems(n);t.CheckItemsForSuggestions(n);document.addEventListener("remove-line",function(){t.CheckItemsForSuggestions(n)},!1)},t.CallInitialize=function(t,i){try{var r=Services.UserServices.GetUserBasketViewModel(!1,!0);r.Basket_orderLines&&r.Basket_orderLines.length&&(n.ViewModel.BasketViewModel.Basket.setBasketLines(r.Basket_orderLines),n.ViewModel.BasketViewModel.Basket.loadRecommendedProducts([i],3))}finally{Helpers.HtmlHelper.HideGlobalLoaderElement()}},t.GetAndShowCartItems=function(i){Helpers.HtmlHelper.ShowGlobalLoaderElement();try{var u=Services.UserServices.GetUserBasketViewModel(!1),r=new n.ViewModel.BasketViewModel(u,i);i.className==="wkis-page-container"&&r.loadRecommendedProducts();ko.applyBindings(r,i);this.basketViewModel=r;t.CheckCartForExpiredProducts(u)}finally{Helpers.HtmlHelper.HideGlobalLoaderElement()}},t.BindProductPageLinks=function(n){$(".wkis-cart-item-product-container-title",n).find("a").each(function(n,t){var i=$(t);i.attr("href",i.attr("href")+"//"+i.siblings("[name='productUrl']").text())})},t.CheckCartForExpiredProducts=function(n){var r,t,u,i,f;n.Warnings&&(r="expired-product",t=$('div[role="dialog"][data-modal='+r+"]"),t.length&&(u=$(".wkis-modal-body",t),i=[],n.Warnings.forEach(function(n){var t,f,r;if(n.Code=="ExpiredOrderLines"){if(t="",f="",n.Attributes)for(r in n.Attributes)switch(r){case"Sku":t=t+n.Attributes[r]+",";break;case"VariantSku":t=t+n.Attributes[r];break;case"ProductName":f=n.Attributes[r]}t&&f&&(u.append("<p>- "+f+"<\/p>"),i.push(t))}}),i.length&&(f=$("button[type='submit']",t),f.unbind("click.removeExpiredProducts").bind("click.removeExpiredProducts",function(){i.forEach(function(t){Services.OrderServices.RemoveOrderLine(n.Id+";"+t)})}),Helpers.HtmlHelper.OpenModalDialog(r))))},t.CheckItemsForSuggestions=function(n){var t=this,i=this.basketViewModel.getBasketOfferNumbers();$.ajax({type:"POST",url:"/umbraco/surface/CartAddInContent/CheckCartForRule",contentType:"application/json",dataType:"json",cache:!1,data:JSON.stringify({offerNumbers:i}),success:function(i){if(i.displaySuggestion===!0)$.ajax({type:"POST",url:"/umbraco/surface/CartAddInContent/GetPopUpContent",contentType:"application/json",dataType:"html",cache:!1,success:function(i){var u=$(".cart-subst-placeholder")[0],r;u.outerHTML=i;r=$('.wkis-button[id="SubstituteCartBtn"]');r.bind("click.substituteItem",function(i){var r=$(i.currentTarget),u=r.attr("sku"),f=r.attr("variant-sku"),e=r.attr("id-to-replace");t.ChangeItemsInTheCart(u,f,e,n)});$(".wkis-cart-item-total-container-addin").show()}});else{var r=$('.wkis-button[data-modal="replace-product"]');r&&r.hide()}}})},t.ChangeItemsInTheCart=function(n,i,r,u){var f=this,e=JSON.stringify({quantity:1,sKu:n,variantSku:i,participatingInProgram:!1});$.ajax({type:"POST",url:"/umbraco/Surface/Basket/AddToBasket",contentType:"application/json",data:e,cache:!1,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement();Helpers.HtmlHelper.CloseModalDialog()},success:function(){f.basketViewModel.BasketLines().forEach(function(n){var e=n.ProductInfo(),i;e&&(i=e.BackofficeProductId(),i===r&&(f.basketViewModel.removeOrderLine(n),t.CallInitialize(u,i)))})},error:function(){}}).done(function(){var n=$('.wkis-button[data-modal="replace-product"]');n.hide()}).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement()})},t}();t.CartPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(){}return n.prototype.Initialize=function(){var n=$.cookie(Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey);n&&Services.AddressServices.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency()},n}();n.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyInitializer=t})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){this.LoadOrderModel(n)},t.prototype.LoadOrderModel=function(t){var r,i,u,f,e;Helpers.HtmlHelper.ShowGlobalLoaderElement();r=Helpers.UrlHelper.GetUrlParam(window.location.href,"orderNumber");i=new Entities.OrderModels.OrderModel;r&&(u=$(".order-data",t),$.ajax("/api/commerce/Order/"+r,{method:"GET",async:!1}).done(function(t){$.extend(i,t);i.Basket_orderLines=t.BasketLines;var r=new n.ViewModel.OrderViewModel(i,u[0]);ko.applyBindings(r,u[0])}).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}),f=function(i){var u=$(".wkis-page-header-container",t),f=new n.ViewModel.ResendEmailViewModel(r,i,u);ko.applyBindings(f,u[0])},e=void 0,i&&i.ShippingAddress&&i.ShippingAddress.Email?(e=i.ShippingAddress.Email,f(e)):Services.UserServices.GetUserInfo().done(function(n){var t=n.value?n.value[0]:null;t&&t.Email&&f(t.Email)}))},t}();t.ConfirmationPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){this.BindActiveTabElements();this.BindLazyLoadAddressBook(n)},t.prototype.BindActiveTabElements=function(){$('ul[role="navigation"] li').on("click",function(n){var t=$(n.currentTarget);t.siblings("li").removeClass("active");t.addClass("active")})},t.prototype.BindLazyLoadAddressBook=function(t){var i=[],r=function(){if(i=Services.UserServices.GetUserAddressBook(!1),!!ko.dataFor(t)){var r=[];i.forEach(function(i){var u=new n.ViewModel.AddressViewModel(t,i);r.push(u)});n.ViewModel.AddressBookModel.AddressBook.Addresses(r)}else ko.applyBindings(new n.ViewModel.AddressBookModel(i,t),t)};$("#addressBookLink").parent().hasClass("active")&&r();$('[href="#addressBookContainer"]').on("click",function(){r()})},t}();t.CustomerAddressBookInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.ForgotPasswordViewModel(t),t)},t}();t.ForgotPasswordInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){var i=0,r,u;n.ViewModel.BasketViewModel.Basket?i=n.ViewModel.BasketViewModel.Basket.TotalItemCount():(r=new n.ViewModel.BasketViewModel(Services.UserServices.GetUserBasketViewModel(),t),i=r.TotalItemCount());u=new n.ViewModel.CartItemCounterViewModel(i);ko.applyBindings(u,t)},t}();t.HeaderPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.LoginUserViewModel(t),t)},t}();t.LoginUserInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function i(){this.agreementModalDialog=$('div[data-modal="terms-conditions"]')}return i.prototype.Initialize=function(){this.InitializeProgramPopup();this.InitializeAddToCartFlow();this.BindProductSelection();this.BindDigitalProductAddToCart();this.BindCheckingQuantityOnAddToCart();this.RemoveIntegratedEvents();this.triggerTagForSelectedProduct(this.sendProductInformationTag);Helpers.HtmlHelper.HideGlobalLoaderElement()},i.prototype.InitializeProgramPopup=function(){var t=$(".radios label",'div[role="dialog"][data-modal^="standing-order-"]'),n;t.bind("click.selectProgram",function(n){var t=$(n.currentTarget).siblings('input[type="radio"]').first(),i=t.attr("name").replace(/standing-order-/g,""),r=$('input[name="participatingInProgram"]','form[sku="'+i+'"]');r.val(t.val()==="enroll"?"true":"false");t[0].checked=!0});n=$('.js-wkis-modal-open[data-modal^="standing-order-"]');n.bind("click.setDefaultProgram",function(n){var t=$(n.currentTarget),i=t.attr("sku"),r=t.attr("data-modal"),u=$('.js-wkis-modal[data-modal="'+r+'"]');$('label[for="decline-'+i+'"]',u).first().click()})},i.prototype.InitializeAddToCartFlow=function(){var u=this,i,r;$("[id^=banner-add-to-cart-link]").bind("click",function(n){var t=$(n.currentTarget),r=t.attr("id")?t.attr("id").match(/[a-f0-9]+$/)[0]:"",i=t.parent().parent();$('div.wkis-bundle-product-price-format > a[id^="addToCartBtn-"]',i).each(function(n,t){var i=t.parentNode.hidden;i||t.click()})});i=$("input.js-wkis-terms-agree-input",this.agreementModalDialog);r=$("div.ko-validation-custom-message[for='agreement'][rule='accept']");i.bind("click",function(n){var t=$(n.currentTarget)[0];t.checked&&r.hide()});$('.js-wkis-modal-open[data-modal="added-cart"][sku]').add("button.js-wkis-terms-agree-button[sku]").click(function(f){var e=$(f.currentTarget),h=e.attr("id")?e.attr("id").match(/[a-f0-9]+$/)[0]:"",o=e.attr("digital")==="true",c,s;if(o){if(i.length&&!i[0].checked)return r.show(),!1;r.hide();h="digital-"+e.attr("flow")}(e.attr("data-modal")==="added-cart"||o)&&(c=$(f.currentTarget).attr("sku"),s=$('[id="addToCart-'+h+'"][sku="'+c+'"]'),$.ajax({type:s.attr("method"),url:s.attr("action"),data:s.serialize(),beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(i){var s=!1,r,h,f;o&&n.ViewModel.BasketViewModel.Basket.BasketLines().forEach(function(n){n.Id()==i.Id&&(s=!0)});o&&s?(Helpers.HtmlHelper.HideGlobalLoaderElement(),r=e.siblings(".digital-warning").text(),r&&(Helpers.HtmlHelper.CloseModalDialog(),Helpers.HtmlHelper.SetGlobalAlertMessage(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Warning,"WARNING",r)),Helpers.HtmlHelper.ShowGlobalAlertMessage())):(h=i.ProductInfo.OfferNumber,t.CartPageInitializer.CallInitialize($("#added-cart-popup")[0],h),o?(Helpers.HtmlHelper.CloseModalDialog(),f=e.siblings("a.js-wkis-modal-open.js-wkis-terms-agree-button[data-modal]"),f.length&&f[0].click()):u.triggerTagForSelectedProduct(u.sendAddedProductInformationTag))},error:function(n){Helpers.HtmlHelper.HideGlobalLoaderElement();n.status===409&&Helpers.HtmlHelper.OpenModalDialog("added-cart-conflict")}}))})},i.prototype.BindProductSelection=function(){$(".js-wkis-format-price-selector").each(function(n,t){var i=t.value;$(t).siblings(".wkis-bundle-product-price").each(function(n,t){var r=$(".wkis-bundle-product-price-format",t);r&&r.each(function(n,t){var r=t.getAttribute("data-format");r!==i&&(t.hidden=!0)})})})},i.prototype.BindDigitalProductAddToCart=function(){var n=this,t=$("div.wkis-bundle-product-price-format[digital]");t&&t.each(function(t,i){var e=$(".add-to-cart-button",i),r=$('div[role="dialog"][data-modal="terms-conditions"]'),f,u,o;$.cookie(Constants.Global.UserTokenCookieKey)&&(f=function(n){n&&n.Email&&$(".wkis-terms-modal-info-email",r).text(n.Email)},Services.UserServices.GetUserInfo().done(function(n){var t=n.value[0];f(t)}));u=function(){var t=$('div[role="dialog"][data-modal="login"]'),i=$(".wkis-account-login",t),r=$(".wkis-account-register",t),u=$('div[role="dialog"][data-modal="forgot-password"]');i.length&&n.LoginPopupInitialize(i[0]);r.length&&n.RegisterPopupInitialize(r[0]);u.length&&n.ForgotPasswordPopupInitialize(u[0])};o=$(".wkis-terms-modal-info-logout a").click(function(){Services.UserServices.Logout();u()});e.bind("click.openDialog",function(n){var i,f,e;n.preventDefault();var t=$(n.currentTarget),o=t.attr("id").length>0?t.attr("id").match(/[a-f0-9]+$/)[0]:"",s=t.parent(),h=!!$.cookie(Constants.Global.UserTokenCookieKey),c=$("span",s).text();$(".price-info",r).text(c);i=t.attr("sku");$(".js-wkis-terms-agree-button",r).attr("sku",i);f=t.attr("has-program").toLowerCase()==="true";e=f?"standing-order-"+i:"added-cart";$(".js-wkis-terms-agree-button",r).attr("data-modal",e);$(".js-wkis-terms-agree-button",r).attr("flow",o);h?Helpers.HtmlHelper.OpenModalDialog("terms-conditions"):(u(),Helpers.HtmlHelper.OpenModalDialog("login"))})})},i.prototype.BindCheckingQuantityOnAddToCart=function(){$("a[id^='addToCartBtn']").bind("click.checkQuantity",function(n){n.preventDefault();var t=$(n.currentTarget);t.siblings("[id^='add-to-cart-link']")[0].click()})},i.prototype.RemoveIntegratedEvents=function(){var n,t;this.agreementModalDialog.length&&(n=$("button.js-wkis-terms-agree-button",this.agreementModalDialog),n.length&&(t=$("input.js-wkis-terms-agree-input",this.agreementModalDialog),t.bind("change",function(){n.removeAttr("disabled")}),n.removeAttr("disabled")))},i.prototype.triggerTagForSelectedProduct=function(n){var t=$("div.wkis-product-format[data-format][sku][data-active='true']").first();t.length&&n&&n(t)},i.prototype.sendProductInformationTag=function(n){var t=n.attr("product"),i=n.attr("isbn"),r=n.attr("format");window.dataLayer&&window.dataLayer.push({event:"viewProduct",eventCategory:"ProductDetails",product:{productName:t,isbn:i,format:r}})},i.prototype.sendAddedProductInformationTag=function(n){var i=n.attr("product"),r=n.attr("isbn"),u=n.attr("format"),t=$('form[sku="'+n.attr("sku")+'"]').first();if(t.length){var f=$('input[name="sKu"]',t).val(),e=$('input[name="variantSku"]',t).val(),o=$('input[name="quantity"]',t).val(),s=$(".wkis-product-detail-header-selected-info-price-value-original",".js-wkis-product-detail-header-selected-info-content[data-format="+n.attr("sku")+"]").text();window.dataLayer&&window.dataLayer.push({event:"itemWasAddedToCart",eventCategory:"ProductDetails",product:{productName:i,isbn:r,format:u,quantity:o,price:s,id:f+";"+e}})}},i.prototype.LoginPopupInitialize=function(t){var i=ko.dataFor(t);!i?ko.applyBindings(new n.ViewModel.LoginUserViewModel(t),t):($("div",t).add("input",t).removeClass("ko-valid"),$.cookie(Constants.Global.RememberMeCookieKey)?(i.email($.cookie(Constants.Global.RememberMeCookieKey)),i.verifyEmail(i)):i.email(undefined),i.password(undefined),i.errors.showAllMessages(!1))},i.prototype.RegisterPopupInitialize=function(t){var i=ko.dataFor(t);!ko.dataFor(t)?ko.applyBindings(new n.ViewModel.RegisterUserViewModel(t),t):($("div",t).add("input",t).removeClass("ko-valid"),i.email(undefined),i.verifiedEmail=!1,i.password(undefined),i.firstName(undefined),i.lastName(undefined),i.errors.showAllMessages(!1))},i.prototype.ForgotPasswordPopupInitialize=function(t){var i=ko.dataFor(t);!ko.dataFor(t)?ko.applyBindings(new n.ViewModel.ForgotPasswordViewModel(t),t):(i.email(undefined),i.errors.showAllMessages(!1))},i}();t.MarketingBundlePageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.OrderHistoryViewModel(t),t)},t}();t.OrderHistoryPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){this.PreIntialize(n)},t.prototype.PreIntialize=function(t){var i,r,u,f;try{if(i=$.cookie(Constants.Global.BasketCookieKey),r=localStorage.getItem(Constants.Commerce.ApplyingPromoCodeKey),i&&r&&$.ajax("/api/commerce/basket/"+i+"/applypromo/",{type:"POST",data:JSON.stringify(r),contentType:"application/json",async:!1,success:function(){localStorage.removeItem(Constants.Commerce.ApplyingPromoCodeKey)}}),u=Services.UserServices.GetUserBasketViewModel(!1,!0),$.cookie(Constants.Global.UserTokenCookieKey))var e=Services.UserServices.GetUserAddressBook(!1),o=$(".wkis-address-returning-user-inner",t)[0],s=new n.ViewModel.AddressBookModel(e,o);f=new n.ViewModel.OrderViewModel(u,t,s);ko.applyBindings(f,t);n.ViewModel.OrderViewModel.Order.ShippingAddress().Country.clearError();n.ViewModel.OrderViewModel.Order.BillingAddress().Country.clearError()}finally{Helpers.HtmlHelper.HideGlobalLoaderElement()}},t}();t.PaymentSubmitInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){$(document).ready(function(){i.HandleUrlFormat();i.BindButtonPrices();i.BindPrices()});var i=function(){function t(){this.agreementModalDialog=$('div[data-modal="terms-conditions"]')}return t.prototype.Initialize=function(){this.InitializeProgramPopup();this.InitializeRecommendations();this.InitializeSeriesVariants();this.InitializeAddToCartFlow();this.BindProductSelection();this.InitializeQuantity();this.BindDigitalProductAddToCart();this.BindCheckingQuantityOnAddToCart();this.RemoveIntegratedEvents();this.triggerTagForSelectedProduct(this.sendProductInformationTag)},t.prototype.InitializeProgramPopup=function(){var t=$(".radios label",'div[role="dialog"][data-modal^="standing-order-"]'),n;t.bind("click.selectProgram",function(n){var t=$(n.currentTarget).siblings('input[type="radio"]').first(),i=t.attr("name").replace(/standing-order-/g,""),r=$('input[name="participatingInProgram"]','form[sku="'+i+'"]');r.val(t.val()==="enroll"?"true":"false");t[0].checked=!0});n=$('.js-wkis-modal-open[data-modal^="standing-order-"]');n.bind("click.setDefaultProgram",function(n){var t=$(n.currentTarget),i=t.attr("sku");$('label[for="decline-'+i+'"]').first().click()})},t.HandleUrlFormat=function(){var n=window.location.href,f=new RegExp("/store/product/((.[^/]*)|$)(/?)((.[^/]*)|$)?(/?)"),t=f.exec(n);if(t){var e=window.defaultLinkShown==="True",i=!1,r=t[2],u=t[4],o=r&&!u,s=r&&u;o&&(n.substring(n.length-1)==="/"||(n=n+"/",i=!0));e?(n=n.substring(0,n.indexOf(t[2])+t[2].length)+"/",i=!0):s&&n.substring(n.length-1)==="/"&&(n=n.substring(0,n.length-1),i=!0);typeof history.pushState!="undefined"&&i&&history.pushState({urlPath:n},"",n)}},t.BindButtonPrices=function(){var n=$(".wkis-product-format");n.length>0&&n.each(function(n,t){var i=t.getAttribute("product-sku"),r=t.getAttribute("data-offer-number");$.ajax({type:"POST",url:"/umbraco/surface/SellableProductDetails/RenderButtonPrice",contentType:"application/json",dataType:"html",cache:!1,data:JSON.stringify({sku:i,variantSku:r}),success:function(n){var r=$(".wkis-product-format-price-placeholder",t)[0],i;r&&(i=document.createElement("div"),t.replaceChild(i,r),i.outerHTML=n)}})})},t.BindPrices=function(){var n=$(".wkis-product-detail-header-selected-info-price");n.length>0&&n.each(function(n,t){var i=t.closest(".js-wkis-product-detail-header-selected-info-content"),r=i.getAttribute("product-sku"),u=i.getAttribute("sku");$.ajax({type:"POST",url:"/umbraco/surface/SellableProductDetails/RenderProductVariantPrice",contentType:"application/json",dataType:"html",cache:!1,data:JSON.stringify({sku:r,variantSku:u}),success:function(n){var r=$("img",t)[0],i;r&&(i=document.createElement("div"),t.replaceChild(i,r),i.outerHTML=n)}})})},t.prototype.RemoveIntegratedEvents=function(){var n,t;this.agreementModalDialog.length&&(n=$("button.js-wkis-terms-agree-button",this.agreementModalDialog),n.length&&(t=$("input.js-wkis-terms-agree-input",this.agreementModalDialog),t.bind("change",function(){n.removeAttr("disabled")}),n.removeAttr("disabled")))},t.prototype.GetOfferNumber=function(){var n=$(".wkis-product-format[data-active=true]").first();return n.length===0&&(n=$(".wkis-product-format").first()),n.attr("data-offer-number")},t.prototype.InitializeRecommendations=function(){var t=new n.ViewModel.RecommendedProductsViewModel,i;this.recommendedProductsViewModel=t;ko.applyBindings(t,$("#related-products")[0]);t.RecommendedProducts.subscribe(function(n){n&&n.length>0?$("a[href='#related-products']").parent().show():$("a[href='#related-products']").parent().hide()});i=this.GetOfferNumber();i&&t.loadRecommendedProducts([i],8)},t.prototype.InitializeSeriesVariants=function(){var i=new n.ViewModel.SeriesProductVariantsViewModel,t,r,u;this.seriesVariantsViewModel=i;ko.applyBindings(i,$("#series-variants")[0]);i.Variants.subscribe(function(n){n&&n.length>0?$("a[href='#series-variants']").parent().show():$("a[href='#series-variants']").parent().hide()});t=$(".wkis-product-format[data-active=true]").first();t.length===0&&(t=$(".wkis-product-format").first());r=t.attr("data-offer-number");u=t.attr("data-has-series")==="true";r&&i.loadSeriesVariants(r)},t.prototype.BindDigitalProductAddToCart=function(){var t=this,r=$("div.js-wkis-product-detail-header-selected-info-content[digital]"),u,n,f,i,e;r&&(u=$(".add-to-cart-button",r),n=$('div[role="dialog"][data-modal="terms-conditions"]'),$.cookie(Constants.Global.UserTokenCookieKey)&&(f=function(t){t&&t.Email&&$(".wkis-terms-modal-info-email",n).text(t.Email)},Services.UserServices.GetUserInfo().done(function(n){var t=n.value[0];f(t)})),i=function(){var n=$('div[role="dialog"][data-modal="login"]'),i=$(".wkis-account-login",n),r=$(".wkis-account-register",n),u=$('div[role="dialog"][data-modal="forgot-password"]');i.length&&t.LoginPopupInitialize(i[0]);r.length&&t.RegisterPopupInitialize(r[0]);u.length&&t.ForgotPasswordPopupInitialize(u[0])},e=$(".wkis-terms-modal-info-logout a").click(function(){Services.UserServices.Logout();i()}),u.bind("click.openDialog",function(t){var u,f,e;t.preventDefault();var r=$(t.currentTarget),c=r.attr("digital")==="true",o=r.parent(),s=!!$.cookie(Constants.Global.UserTokenCookieKey),h=$(".wkis-product-detail-header-selected-info-price-value-original",o).text();$(".price-info",n).text(h);u=r.attr("sku");$(".js-wkis-terms-agree-button",n).attr("sku",u);f=r.attr("has-program").toLowerCase()==="true";e=f?"standing-order-"+u:"added-cart";$(".js-wkis-terms-agree-button",n).attr("data-modal",e);s?Helpers.HtmlHelper.OpenModalDialog("terms-conditions"):(i(),Helpers.HtmlHelper.OpenModalDialog("login"))}))},t.prototype.BindCheckingQuantityOnAddToCart=function(){$("a[id='addToCartBtn']").bind("click.checkQuantity",function(n){var u,o;n.preventDefault();var f=$(n.currentTarget),s=f.parent(),r=$("input[id='quantity']",s);if(r.length){var h=$("ko-error-text[for='quantity'][rule='minQuantity']").text(),c=$("ko-error-text[for='quantity'][rule='maxQuantity']").text(),i=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"ERROR",h,{duration:2e4}),e=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"ERROR",c,{duration:2e4}),t=$("div.wkis-product-detail-header-info");try{if(u=parseInt(r.val()),o=r.val()==""||u<1,o){t.html().indexOf(i.innerHTML)===-1&&t.prepend(i);return}if(u>99){t.html().indexOf(e.innerHTML)===-1&&t.prepend(e);return}f.siblings("[id='add-to-cart-link']")[0].click()}catch(l){t.html().indexOf(i.innerHTML)===-1&&t.prepend(i);return}}})},t.prototype.LoginPopupInitialize=function(t){var i=ko.dataFor(t);!i?ko.applyBindings(new n.ViewModel.LoginUserViewModel(t),t):($("div",t).add("input",t).removeClass("ko-valid"),$.cookie(Constants.Global.RememberMeCookieKey)?(i.email($.cookie(Constants.Global.RememberMeCookieKey)),i.verifyEmail(i)):i.email(undefined),i.password(undefined),i.errors.showAllMessages(!1))},t.prototype.RegisterPopupInitialize=function(t){var i=ko.dataFor(t);!ko.dataFor(t)?ko.applyBindings(new n.ViewModel.RegisterUserViewModel(t),t):($("div",t).add("input",t).removeClass("ko-valid"),i.email(undefined),i.verifiedEmail=!1,i.password(undefined),i.firstName(undefined),i.lastName(undefined),i.errors.showAllMessages(!1))},t.prototype.ForgotPasswordPopupInitialize=function(t){var i=ko.dataFor(t);!ko.dataFor(t)?ko.applyBindings(new n.ViewModel.ForgotPasswordViewModel(t),t):(i.email(undefined),i.errors.showAllMessages(!1))},t.prototype.InitializeQuantity=function(){var n=$("#quantity"),t=$("#itemCount");t.val(n.val());n.change(function(n){t.text(n.currentTarget.value)})},t.prototype.InitializeAddToCartFlow=function(){var t=this,i=$("input.js-wkis-terms-agree-input",this.agreementModalDialog),r=$("div.ko-validation-custom-message[for='agreement'][rule='accept']");i.bind("click",function(n){var t=$(n.currentTarget)[0];t.checked&&r.hide()});$('.js-wkis-modal-open[data-modal="added-cart"][sku]').add("button.js-wkis-terms-agree-button[sku]").click(function(u){var e=$(u.currentTarget),f=e.attr("digital")==="true",s,o;if(f){if(i.length&&!i[0].checked)return r.show(),!1;r.hide()}(e.attr("data-modal")==="added-cart"||f)&&(s=$(u.currentTarget).attr("sku"),o=$('[id="addToCart"][sku="'+s+'"]'),$.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(i){var o=!1,r,s,u;f&&n.ViewModel.BasketViewModel.Basket.BasketLines().forEach(function(n){n.Id()==i.Id&&(o=!0)});f&&o?(Helpers.HtmlHelper.HideGlobalLoaderElement(),r=e.siblings(".digital-warning").text(),r&&(Helpers.HtmlHelper.CloseModalDialog(),Helpers.HtmlHelper.SetGlobalAlertMessage(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Warning,"WARNING",r)),Helpers.HtmlHelper.ShowGlobalAlertMessage())):(s=t.GetOfferNumber(),n.Initializer.CartPageInitializer.CallInitialize($("#added-cart-popup")[0],s),f?(Helpers.HtmlHelper.CloseModalDialog(),u=e.siblings("a.js-wkis-modal-open.js-wkis-terms-agree-button[data-modal]"),u.length&&u[0].click()):t.triggerTagForSelectedProduct(t.sendAddedProductInformationTag))},error:function(n){Helpers.HtmlHelper.HideGlobalLoaderElement();n.status===409&&Helpers.HtmlHelper.OpenModalDialog("added-cart-conflict")}}))})},t.prototype.BindProductSelection=function(){var n=this,i=location.pathname.split("/"),r=i.indexOf("product"),t;r!==-1&&i.length>r+1&&i.length>r+2&&(t=i[r+2],t&&($("div .wkis-product-format").attr("data-active","false"),$("option[value="+t+"]").prop("selected",!0),$("div .wkis-product-format[sku="+t+"]").attr("data-active","true"),$(".wkis-product-detail-header-info .js-wkis-product-detail-header-selected-info-content").attr("data-active","false"),$(".wkis-product-detail-header-info .js-wkis-product-detail-header-selected-info-content[data-format="+t+"]").attr("data-active","true"),$("div .wkis-product-format[data-active='true']").length||$("div .wkis-product-format[data-active]").first().attr("data-active","true")));$("div.wkis-product-format[data-format][sku]").click(function(t){var r=$(t.currentTarget),e=r.attr("product"),u=r.attr("sku"),i,f;n.ChangeFormatUrl(e,u);n.ChangeProductImage(u);n.ChangeActiveDropdownValue(u);i=r.attr("data-offer-number");i?n.recommendedProductsViewModel.loadRecommendedProducts([i],8):n.recommendedProductsViewModel.RecommendedProducts([]);f=r.attr("data-has-series")==="true";i&&f?n.seriesVariantsViewModel.loadSeriesVariants(i):n.seriesVariantsViewModel.Variants([]);n.sendProductInformationTag($(t.currentTarget).first())});$(".js-wkis-product-format-dropdown").change(function(t){var r=$(t.currentTarget),i=r.val(),u=r.text();n.ChangeFormatUrl(u,i);n.ChangeProductImage(i);n.ChangeActiveDropdownValue(i)})},t.prototype.triggerTagForSelectedProduct=function(n){var t=$("div.wkis-product-format[data-format][sku][data-active='true']").first();t.length&&n&&n(t)},t.prototype.sendProductInformationTag=function(n){var t=n.attr("product"),i=n.attr("isbn"),r=n.attr("format");window.dataLayer&&window.dataLayer.push({event:"viewProduct",eventCategory:"ProductDetails",product:{productName:t,isbn:i,format:r}})},t.prototype.sendAddedProductInformationTag=function(n){var i=n.attr("product"),r=n.attr("isbn"),u=n.attr("format"),t=$('form[sku="'+n.attr("sku")+'"]').first();if(t.length){var f=$('input[name="sKu"]',t).val(),e=$('input[name="variantSku"]',t).val(),o=$('input[name="quantity"]',t).val(),s=$(".wkis-product-detail-header-selected-info-price-value-original",".js-wkis-product-detail-header-selected-info-content[data-format="+n.attr("sku")+"]").text();window.dataLayer&&window.dataLayer.push({event:"itemWasAddedToCart",eventCategory:"ProductDetails",product:{productName:i,isbn:r,format:u,quantity:o,price:s,id:f+";"+e}})}},t.prototype.ChangeFormatUrl=function(n,t){if(typeof history.pushState!="undefined"){var i={Page:n,Url:t};history.pushState(i,i.Page,i.Url)}},t.prototype.ChangeProductImage=function(n){$("img[sku]").hide();$("img[sku="+n+"]").show()},t.prototype.ChangeActiveDropdownValue=function(n){$(".js-wkis-product-format-dropdown > option").removeProp("selected");$("option[value="+n+"]").prop("selected",!0)},t.prototype.InitializeImages=function(){var n=$("img[sku]",".wkis-product-detail-header-container");n.length===1&&n.first().show()},t}();t.ProductDetailsPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.RegisterUserViewModel(t),t)},t}();t.RegisterUserInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){var i=new n.ViewModel.ResetPasswordViewModel(t),r;(ko.applyBindings(i,t),r=Helpers.UrlHelper.GetUrlParam(window.location.toString(),"reset"),r!==null)&&(i.resetToken(r),i.validateToken())},t}();t.ResetPasswordInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){var i=new n.ViewModel.StorePageViewModel;ko.applyBindings(i,t)},t}();t.StorePageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t;(function(n){var h=function(){function n(){this.Labels=[]}return n}(),t,i,r,u,f,e,o,s;n.FacetArg=h;t=function(){function n(){}return n}();n.SearchArgs=t;i=function(){function n(){}return n}();n.Row=i;r=function(){function n(){}return n}();n.FacetResultItem=r;u=function(){function n(){}return n}();n.FacetResult=u;f=function(){function n(){}return n}();n.SearchResult=f;e=function(){function n(){}return n}();n.SelectOptionModel=e;o=function(){function n(){}return n.MarketSegment="marketSegments",n.PracticeArea="practiceAreas",n.Format="format",n.Industry="industry",n.Role="role",n}();n.FacetNames=o;s=function(){function n(){this.Text=ko.observable();this.Value=ko.observable();this.HitCount=ko.observable();this.IsChecked=ko.observable();this.Children=ko.observableArray()}return n}();n.FacetModel=s})(t=n.StorePage||(n.StorePage={}))})(t=n.Models||(n.Models={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(t){var i=this;this.CountryOfResidence=ko.observable(new Entities.AddressBookModels.CountryModel);this.AvailableCountries=ko.observableArray();this.GdprActive=ko.observable();this.DeleteUserAccount=ko.observable(!1);this.load=function(){$.getJSON("/Ecommerce.svc/Users",function(n){var t,r;n&&n.value&&(t=n.value[0],i.Email(t.Email),i.FirstName(t.FirstName),i.LastName(t.LastName),i.PhoneNumber(Helpers.CommerceHelper.GetPhoneNumberFromString(t.PhoneNumber)),i.CustomerType(t.CustomerType),i.ReferralMethod(t.ReferralMethod),i.AdjustMailing(t.AdjustMailing),r=Helpers.CommerceHelper.GetCountryCodefromString(t.PhoneNumber),r&&r.length>0&&i.AvailableCountries().forEach(function(n){if(n.CountryIso==r){var t=n;i.setCountryOfResidence(t);i.changeCountryOfResidenceHandler();i.showDeleteButton()}}))})};this.update=function(n,t){var r,e;if(t.preventDefault(),i.GdprActive())if(r=$(".ko-validation-custom-message[for='AccountMaintenanceMethod'][rule='required']"),i.method)r.hide();else{r.show();return}var u=$(t.currentTarget).parents(".wkis-account-content").children().first(),o=Helpers.CommerceHelper.addCountryCode(i.CountryOfResidence().CountryIso,""),f={FirstName:i.FirstName(),LastName:i.LastName(),PhoneNumber:o,CustomerType:i.CustomerType(),ReferralMethod:i.ReferralMethod(),CompanyName:null,Id:null,Password:null,Email:null};$.extend(f,{"odata.type":Constants.Global.ODataOperation("User")});i.GdprActive()&&(e={elqFormName:"acctInfoForm",emailAddress:i.Email(),firstName:i.FirstName(),lastName:i.LastName(),country:i.CountryOfResidence().CountryIso,consentCheckbox:!i.DeleteUserAccount(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:i.DeleteUserAccount()?Helpers.CommerceHelper.stripHtml($("label[for='negative-consent']").html()):Helpers.CommerceHelper.stripHtml($("label[for='positive-consent']").html()),consentMessageId:$("label[for='positive-consent']").attr("message-id"),pageName:"My Account",pageUrl:location.href},Helpers.CommerceHelper.SendUserConsentToEloqua(e));$.ajax("/Ecommerce.svc/Users('0')",{data:JSON.stringify(f),type:"put",contentType:"application/json;odata=minimalmetadata",success:function(){var t=$(".wkis-account-welcome")[0],n;t&&(n=ko.dataFor(t),n&&(n.FirstName(i.FirstName()),n.LastName(i.LastName())));u.after(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Account Information was successfully updated",{duration:1e4}))},error:function(){u.after(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"FAILED!","Account Information was not updated because of an error",{duration:1e4}))}})};this.delete=function(){};this.radioButtonClick=function(n,t){var r=$(t.currentTarget);i.method=r.val();i.GdprActive()&&(r.val()=="delete"?i.DeleteUserAccount(!0):i.DeleteUserAccount(!1))};this.showDeleteButton=function(){return i.GdprActive()&&i.DeleteUserAccount()?!0:!1};this.deleteUserAccount=function(){i.DeleteUserAccount(!i.DeleteUserAccount())};this.prefillAddress=function(){n.AddressViewModel.Countries&&n.AddressViewModel.Countries.length?i.setCountries(n.AddressViewModel.Countries):$.ajax("/Ecommerce.svc/AddressAdministration_GetCountries",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetCountries")}}),success:function(t){n.AddressViewModel.Countries=t.Countries;i.setCountries(t.Countries)}})};this.setCountries=function(n){n&&n.length&&(i.AvailableCountries.removeAll(),i.sortedCountries(n).forEach(function(n){i.AvailableCountries.push(n)}))};this.changeCountryOfResidenceHandler=function(){i.setCountryOfResidence(i.CountryOfResidence());var n=!1;i.CountryOfResidence()&&(n=Helpers.CommerceHelper.CheckIfCountryWithinEU(i.CountryOfResidence().CountryIso));i.GdprActive(n)};this.setCountryOfResidence=function(n){return i.CountryOfResidence(n),!0};this.sortedCountries=function(n){return n.sort(function(n,t){return Constants.AddressBook.PriorityCountries.indexOf(n.CountryIso)!=-1?-1:Constants.AddressBook.PriorityCountries.indexOf(t.CountryIso)!=-1?1:n.CountryName<t.CountryName?-1:1})};this.$container=$(t);this.Email=ko.observable();this.FirstName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("FirstName","required",this.$container)}});this.LastName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("LastName","required",this.$container)}});this.PhoneNumber=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","required",this.$container)}});this.CustomerType=ko.observable();this.ReferralMethod=ko.observable();this.AdjustMailing=ko.observable();this.prefillAddress();this.CountryOfResidence.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CountryOfResidence","required",this.$container)}});this.errors=ko.validation.group(this,{deep:!0});this.load()}return t}();n.AccountInformationViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(u,f){var e=this,o;this.BasketLines=ko.observableArray();this.RecommendedProducts=ko.observable(new n.RecommendedProductsViewModel);this.removeOrderLine=function(t,i,r){r===void 0&&(r=!1);Services.OrderServices.RemoveOrderLine(e.Id+";"+t.Id()).done(function(){if(e.updateSubTotalPrice(),e.BasketLines.remove(t),r&&e.BasketLines().length===0){var i=$("#redirectLinkForEmptyCart").val();location.href=i?i:location.origin}n.OrderViewModel.Order&&n.OrderViewModel.Order.getUpdatedOrderData();e.loadRecommendedProducts()}).always(function(){document.dispatchEvent(e.RemoveEvent);Helpers.HtmlHelper.HideGlobalLoaderElement()})};this.updateOrderLine=function(t,i){if(t.Quantity()===0)e.removeOrderLine(t,i);else{var r={Id:t.Id(),Quantity:parseInt(t.Quantity()),PriceInfo:null,ParticipatesInProgram:t.ParticipatesInProgram(),ProgramSubscribtion:null};$.extend(r,{"odata.type":Constants.Global.ODataOperation("OrderLine")});Services.OrderServices.UpdateOrderLine(e.Id+";"+t.Id(),JSON.stringify(r)).done(function(i){e.updateSubTotalPrice();var r;(i||Services.OrderServices.GetOrderLine(e.Id,t.Id(),!1).done(function(n){r=n}),r)&&(t.PriceInfo.RegularItemPrice(parseFloat(r.PriceInfo.RegularItemPrice)),t.PriceInfo.ActualItemPrice(parseFloat(r.PriceInfo.ActualItemPrice)),t.PriceInfo.RegularTotalPrice(parseFloat(r.PriceInfo.RegularTotalPrice)),t.PriceInfo.ActualTotalPrice(parseFloat(r.PriceInfo.ActualTotalPrice)),n.OrderViewModel.Order&&n.OrderViewModel.Order.getUpdatedOrderData(),e.loadRecommendedProducts())})}};this.loadRecommendedProducts=function(n,t){n||(n=e.getBasketOfferNumbers());e.RecommendedProducts().loadRecommendedProducts(n,t)};this.getBasketOfferNumbers=function(){var n=[];return e.BasketLines().forEach(function(t){var r=t.ProductInfo(),i;r&&(i=r.BackofficeProductId(),i&&n.push(i))}),n};this.updateSubTotalPrice=function(){var n=Services.UserServices.GetUserBasketViewModel(!1);e.PriceInfo().SubTotal(parseFloat(n.PriceInfo.SubTotal))};this.setBasketLines=function(n){e.BasketLines([]);var t=[];n.forEach(function(n){var i=new r(n);t.push(i)});e.BasketLines(t);e.BasketLines.sort(function(n,t){var i=Helpers.CommonHelper.GetUTCDate(n.ProductInfo().CreateOnDate()),r=Helpers.CommonHelper.GetUTCDate(t.ProductInfo().CreateOnDate());return i<r?1:-1})};this.continueShoppingClick=function(n,t){var i=$.cookie(Constants.Global.StorePageCookieKey);window.location.href=i?i:t.target.href};this.$container=$(f);this.Id=u.Id;o=new i(u.PriceInfo);this.PriceInfo=ko.observable(o);this.OrderStatus=ko.observable(u.OrderStatus);u.Order_orderLines&&(u.Basket_orderLines=u.Order_orderLines);u.Basket_orderLines&&this.setBasketLines(u.Basket_orderLines);this.Discounted=ko.computed(function(){return e.PriceInfo().Discount()>0});this.TotalItemCount=ko.computed(function(){var t=0;return e.BasketLines().forEach(function(n){var i=n.Quantity();t+=i instanceof Number?i:parseInt(i)}),n.CartItemCounterViewModel.Counter&&e.OrderStatus()==="Basket"&&n.CartItemCounterViewModel.Counter.TotalItemCount(t),t});this.calculatedSubTotalPrice=ko.computed(function(){return e.PriceInfo().CurrencySymbol()+e.PriceInfo().SubTotal().toFixed(2)});this.HasOnlyDigitalOrPracticeToolProducts=ko.computed(function(){var n=!0;return e.BasketLines().forEach(function(t){var i=t.ProductInfo().VariantType()==Constants.VariantType.Digital,r=t.ProductInfo().VariantType()==Constants.VariantType.PracticeTool,u=i||r;u||(n=!1)}),n});this.RemoveEvent=document.createEvent("Event");this.RemoveEvent.initEvent("remove-line",!0,!0);t.Basket=this}return t}(),i,r,u,f,e;n.BasketViewModel=t;i=function(){function n(n){var t=this;this.TaxValue=ko.observable(0);this.TaxCalculationError=ko.observable(!1);this.Discount=ko.observable(0);this.ShippingPrice=ko.observable(0);this.OrderTotal=ko.observable(0);this.SubTotal=ko.observable(0);this.CurrencySymbol=ko.observable("");this.Precision=ko.observable(2);n&&(this.TaxValue=ko.observable(parseFloat(n.Tax)),this.TaxCalculationError=ko.observable(n.TaxCalculationError),this.Discount=ko.observable(parseFloat(n.Discount)),this.ShippingPrice=ko.observable(parseFloat(n.Shipping)),this.OrderTotal=ko.observable(parseFloat(n.OrderTotal)),this.SubTotal=ko.observable(parseFloat(n.SubTotal)),this.CurrencySymbol=ko.observable(n.CurrencySymbol));this.formatedTaxValue=ko.computed(function(){return t.CurrencySymbol()+t.TaxValue().toFixed(t.Precision())});this.formatedDiscount=ko.computed(function(){return t.Discount()>0?"-"+t.CurrencySymbol()+t.Discount().toFixed(t.Precision()):""});this.formatedShippingPrice=ko.computed(function(){return t.CurrencySymbol()+t.ShippingPrice().toFixed(t.Precision())});this.formatedOrderTotal=ko.computed(function(){return t.CurrencySymbol()+t.OrderTotal().toFixed(t.Precision())});this.formatedSubTotal=ko.computed(function(){return t.CurrencySymbol()+t.SubTotal().toFixed(t.Precision())})}return n}();n.OrderPriceInfoModel=i;r=function(){function i(i){var r=this;this.updateProgramForm=function(){var n=$('[role="dialog"][data-modal="standing-order"]')[0];ko.cleanNode(n);ko.applyBindings(r,n)};this.updateProgram=function(){var u=$.cookie(Constants.Global.BasketCookieKey),i;u&&(i={Id:r.Id(),Quantity:parseInt(r.Quantity()),PriceInfo:null,ParticipatesInProgram:r.ProductInfo().Program().Enroll(),ProgramSubscribtion:null},$.extend(i,{"odata.type":Constants.Global.ODataOperation("OrderLine")}),Services.OrderServices.UpdateOrderLine(t.Basket.Id+";"+r.Id(),JSON.stringify(i)).done(function(i){var u,f;(i||Services.OrderServices.GetOrderLine(t.Basket.Id,r.Id(),!1).done(function(n){u=n}),u)&&(f=u.ParticipatesInProgram,r.ParticipatesInProgram(f=="true"||f==!0),n.OrderViewModel.Order&&n.OrderViewModel.Order.getUpdatedOrderData())}))};this.Id=ko.observable(i.Id);this.Quantity=ko.observable(i.Quantity);this.ProductInfo=ko.observable(new u(i.Product?i.Product:i.ProductInfo,i.ParticipatesInProgram));this.PriceInfo=new e(i.PriceInfo);this.ParticipatesInProgram=ko.observable(i.ParticipatesInProgram)}return i}();n.OrderLine=r;u=function(){function n(n,t){var i=this;t===void 0&&(t=!1);this.Id=ko.observable();this.ProductName=ko.observable();this.ProductTitle=ko.observable();this.FormatName=ko.observable();this.Program=ko.observable();this.IsDownloadable=ko.observable();this.IsDisplayed=ko.observable();this.ShippingLocation=ko.observable();this.Isbn=ko.observable();this.PublicationFrequency=ko.observable();this.EstimatedShippingDate=ko.observable();this.BackofficeProductId=ko.observable();this.Categories=ko.observable();this.Authors=ko.observable();this.ThumbnailUrl=ko.observable();this.SmallImageUrl=ko.observable();this.ProductUrl=ko.observable();this.RegularPrice=ko.observable(0);this.ActualPrice=ko.observable(0);this.ExtendedRegularPrice=ko.observable(0);this.ExtendedActualPrice=ko.observable(0);this.CurrencySymbol=ko.observable();this.Pages=ko.observable();this.Volumes=ko.observable();this.OrderTrackingUrl=ko.observable();this.VariantType=ko.observable();this.Precision=ko.observable(2);this.Id=ko.observable(n.Id);this.ProductName=ko.observable(n.Name?n.Name:n.ProductName);this.ProductTitle=ko.observable(n.ProductTitle);this.FormatName=ko.observable(n.FormatName);this.IsDownloadable=ko.observable(n.IsDownloadable);this.IsDisplayed=ko.observable(n.IsDisplayed);this.ShippingLocation=ko.observable(n.ShippingLocation?n.ShippingLocation.Name:null);this.PublicationDate=ko.observable(n.PublicationDate);this.CreateOnDate=ko.observable(n.CreateOnDate);this.Program=ko.observable(new f(n.Program,t));this.Isbn=ko.observable(n.Isbn);this.PublicationFrequency=ko.observable(n.PublicationFrequency);this.EstimatedShippingDate=ko.observable(n.EstimatedShippingDate);this.BackofficeProductId=ko.observable(n.BackofficeProductId);this.Categories=ko.observable(n.Categories);this.Authors=ko.observable(n.Authors);this.ThumbnailUrl=ko.observable(n.ImageAltText?n.ImageAltText:n.ThumbnailImageUrl);this.OrderTrackingUrl=ko.observable(n.OrderTrackingUrl);this.SmallImageUrl=ko.observable(n.SmallImageUrl);this.ProductUrl=ko.observable(n.ProductVariantUrl);this.RegularPrice=ko.observable(parseFloat(n.RegularPrice));this.ActualPrice=ko.observable(parseFloat(n.ActualPrice));this.ExtendedRegularPrice=ko.observable(parseFloat(n.ExtendedRegularPrice));this.ExtendedActualPrice=ko.observable(parseFloat(n.ExtendedActualPrice));this.CurrencySymbol=ko.observable(n.CurrencySymbol);this.Pages=ko.observable(n.Pages);this.Volumes=ko.observable(n.Volumes);this.VariantType=ko.observable(n.VariantTypeValue?n.VariantTypeValue:n.VariantType);this.Sku=ko.computed(function(){return i.Id().split(",")[1]});this.formatedRegularPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.RegularPrice().toFixed(i.Precision())});this.formatedActualPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.ActualPrice().toFixed(i.Precision())});this.formatedExtendedRegularPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.ExtendedRegularPrice().toFixed(i.Precision())});this.formatedExtendedActualPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.ExtendedActualPrice().toFixed(i.Precision())});this.formatedAuthors=ko.computed(function(){var n="";return i.Authors()&&i.Authors().length&&i.Authors().forEach(function(t){n+=t;i.Authors().indexOf(t)!=i.Authors().length-1&&(n+=", ")}),n});this.shippingFromLocation=ko.computed(function(){return i.ShippingLocation()&&i.VariantType()!=Constants.VariantType.Digital?i.ShippingLocation():""});this.trackingNumber=ko.computed(function(){return i.OrderTrackingUrl()?JSON.parse(i.OrderTrackingUrl()).Number:""});this.trackingUrl=ko.computed(function(){return i.OrderTrackingUrl()?JSON.parse(i.OrderTrackingUrl()).Url:""})}return n}();n.ProductInfo=u;f=function(){function n(n,t){t===void 0&&(t=!1);this.Type=ko.observable();this.IsSubscribed=ko.observable();this.Enroll=ko.observable();n&&(this.Type(n.TypeValue?n.TypeValue:n.Type),this.IsSubscribed(n.IsSubscribed),this.Enroll(t))}return n}();n.ProductProgram=f;e=function(){function n(n){var t=this;this.RegularItemPrice=ko.observable(0);this.ActualItemPrice=ko.observable(0);this.RegularTotalPrice=ko.observable(0);this.ActualTotalPrice=ko.observable(0);this.CurrencySymbol=ko.observable();this.Precision=ko.observable(2);this.RegularItemPrice=ko.observable(parseFloat(n.RegularItemPrice));this.ActualItemPrice=ko.observable(parseFloat(n.ActualItemPrice));this.RegularTotalPrice=ko.observable(parseFloat(n.RegularTotalPrice));this.ActualTotalPrice=ko.observable(parseFloat(n.ActualTotalPrice));this.CurrencySymbol=ko.observable(n.CurrencySymbol);this.formatedRegularItemPrice=ko.computed(function(){return t.CurrencySymbol()+t.RegularItemPrice().toFixed(t.Precision())});this.formatedActualItemPrice=ko.computed(function(){return t.CurrencySymbol()+t.ActualItemPrice().toFixed(t.Precision())});this.formatedRegularTotalPrice=ko.computed(function(){return t.CurrencySymbol()+t.RegularTotalPrice().toFixed(t.Precision())});this.formatedActualTotalPrice=ko.computed(function(){return t.CurrencySymbol()+t.ActualTotalPrice().toFixed(t.Precision())})}return n}();n.PriceInfo=e})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n,t){var i=this;this.verifiedEmail=!1;this.isChangingEmail=ko.observable(!1);this.save=function(n,t){if(t.preventDefault(),$("[for='password'][rule='invalid']",i.$container).hide(),i.errors().length>0||!i.verifiedEmail){i.errors.showAllMessages(!0);i.verifiedEmail?$("[for='email'][rule='exist']",i.$container).hide():$("[for='email'][rule='exist']",i.$container).show();return}if(!i.isChangingEmail()){i.isChangingEmail(!0);var r=$(".wkis-account-content .wkis-field-group","#accountInformationContainer"),u=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ChangeEmail"),EmailAddress:i.OldEmail(),NewEmailAddress:i.NewEmail(),Password:i.Password()}});$.ajax("/Ecommerce.svc/CustomerAdministration_ChangeEmail",{method:"POST",data:u,success:function(n){var t=JSON.parse(n.value),u;t.Success?($("button.js-wkis-modal-close",i.$container)[0].click(),r.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Email was successfully changed",{duration:1e4})),$(".wkis-signout-link")[0].click()):(t.ResultStatus==103&&($("input[type='password']",i.$container).addClass("ko-error"),$("[for='password'][rule='invalid']",i.$container).show()),t.ResultStatus==104&&(u=$("#NewEmailInput",i.$container),u.addClass("ko-error"),u.removeClass("ko-valid"),u.parent().removeClass("ko-valid"),$("[for='NewEmail'][rule='exist']",i.$container).show()),t.ResultStatus==9999&&($("button.js-wkis-modal-close",i.$container)[0].click(),r.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"FAILED!","Error occured while changing password",{duration:1e4}))))},error:function(n){var u="",t;n.responseText&&(u=n.responseText.split(":")[1].trim().replace(".",""));switch(u){case"invalid password":$("input[type='password']",i.$container).addClass("ko-error");$("[for='password'][rule='invalid']",i.$container).show();break;case"email already exists":t=$("#NewEmailInput",i.$container);t.addClass("ko-error");t.removeClass("ko-valid");t.parent().removeClass("ko-valid");$("[for='NewEmail'][rule='exist']",i.$container).show();break;default:$("button.js-wkis-modal-close",i.$container)[0].click();r.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"FAILED!","Error occured while changing password",{duration:1e4}))}},complete:function(){i.isChangingEmail(!1)}})}};this.verifyEmail=function(n,t){var r,u,f;if(t.preventDefault(),r=$(t.currentTarget),!i.NewEmail.isValid()){$("[for='NewEmail'][rule='exist']",i.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");return}i.verifiedEmail=!1;u=Constants.Global.ODataOperation("EmailExists");f=JSON.stringify({request:{Email:r.val(),"odata.type":u}});$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){n.value===!1?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='NewEmail'][rule='exist']",i.$container).hide(),i.verifiedEmail=!0):(r.addClass("ko-error"),r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),$("[for='NewEmail'][rule='exist']",i.$container).show(),i.verifiedEmail=!1)}})};this.keyUp=function(n,t){t.keyCode===13&&i.save(n,t)};this.$container=$(n);this.OldEmail=Helpers.KnockoutHelper.GetObservableByType("email",this.$container,"OldEmail");this.OldEmail(t.Email());this.NewEmail=Helpers.KnockoutHelper.GetObservableByType("email",this.$container,"NewEmail").extend({notEqual:{message:Helpers.KnockoutHelper.validationMessage("NewEmail","notEqual",this.$container),params:this.NewEmail}});this.ConfirmEmail=Helpers.KnockoutHelper.GetObservableByType("email",this.$container,"ConfirmEmail").extend({equal:{message:Helpers.KnockoutHelper.validationMessage("ConfirmEmail","equal",this.$container),params:this.NewEmail}});this.Password=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("password","required",this.$container)}});this.errors=ko.validation.group(this,{deep:!0})}return n}();n.ChangeEmailViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.verifiedPassword=!0;this.verifyPassword=function(n,i){i.preventDefault();var r=$(i.currentTarget);$("[for='NewPassword'][rule='weak']",t.$container).hide();$.ajax("/api/commerce/customer/verifypassword/",{method:"POST",contentType:"application/json; charset=utf-8",data:t.NewPassword(),success:function(n){console.log(n);n?t.verifiedPassword=!0:(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),r.addClass("ko-error"),$("[for='NewPassword'][rule='weak']",t.$container).show(),t.verifiedPassword=!1)}})};this.changePassword=function(){if(t.errors().length||!t.verifiedPassword){t.errors.showAllMessages(!0);return}var n=$(".wkis-account-content .wkis-field-group","#accountInformationContainer"),i=Constants.Global.ODataOperation("ChangePassword"),r=JSON.stringify({request:{OldPassword:t.OldPassword(),NewPassword:t.NewPassword(),"odata.type":i}});$.ajax("/Ecommerce.svc/CustomerAdministration_ChangePassword",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:r,success:function(){$('[for="wrongOldPassword"]',t.$container).hide();$("button.js-wkis-modal-close",t.$container)[0].click();n.append(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Password was successfully changed",{duration:1e4}))},error:function(){$('[for="wrongOldPassword"]',t.$container).show()}})};this.$container=$(n);this.OldPassword=Helpers.KnockoutHelper.GetObservableByType("password",this.$container,"OldPassword");this.NewPassword=Helpers.KnockoutHelper.GetObservableByTypeRegistration("password",this.$container,"NewPassword").extend({notEqual:{params:this.OldPassword,message:Helpers.KnockoutHelper.validationMessage("NewPassword","notEqual",this.$container)}});this.ConfirmPassword=Helpers.KnockoutHelper.GetObservableByTypeRegistration("password",this.$container,"ConfirmPassword").extend({equal:{message:Helpers.KnockoutHelper.validationMessage("ConfirmPassword","equal",this.$container),params:this.NewPassword}});this.errors=ko.validation.group(this,{deep:!0})}return n}();n.ChangePasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(r,u){var f=this,e,o,s;this.Addresses=ko.observableArray();this.addAddressForm=function(n,r){var f=$(r.currentTarget).attr("data-modal"),u=$("[data-modal='"+f+"'][role='dialog']")[0],e;t.AddAddressModel()?(t.AddAddressModel().clear(),$("input",u).add("select",u).removeClass("ko-error"),$(".ko-validation-custom-message",u).hide()):(e=new i(u,null,!0),t.AddAddressModel(e));f.indexOf("billing")!=-1?t.AddAddressModel().IsBilling=ko.observable(!0):f.indexOf("shipping")!=-1&&(t.AddAddressModel().IsBilling=ko.observable(!1));!!ko.dataFor(u)||(ko.applyBindings(t.AddAddressModel,u),t.AddAddressModel().Country&&t.AddAddressModel().Country.clearError());$("span.ko-validation-message",u).hide();t.AddAddressModel().isValid(!1)};this.selectAddress=function(n){f.Addresses().forEach(function(t){t.IsBilling()==n.IsBilling()&&t!=n&&t.Selected(!1)});n.Selected(!0)};this.$container=$(u);e=[];r&&r.length&&r.forEach(function(t){var r=new i(u,t);n.OrderViewModel.Order&&(o=n.OrderViewModel.Order.BillingAddress()&&n.OrderViewModel.Order.BillingAddress().AddressId()?n.OrderViewModel.Order.BillingAddress():undefined,s=n.OrderViewModel.Order.ShippingAddress()&&n.OrderViewModel.Order.ShippingAddress().AddressId()?n.OrderViewModel.Order.ShippingAddress():undefined);e.push(r)});this.Addresses=ko.observableArray(e);this.ShippingAddress=ko.computed(function(){var n=[];return f.Addresses().forEach(function(t){t.IsBilling()||n.push(t)}),ko.observableArray(n)});this.BillingAddress=ko.computed(function(){var n=[];return f.Addresses().forEach(function(t){t.IsBilling()&&n.push(t)}),ko.observableArray(n)});this.ShippingAddressExcludeDefault=ko.computed(function(){var n=[];return f.ShippingAddress()().forEach(function(t){t.IsDefaultShipping()||n.push(t)}),n});this.BillingAddressExcludeDefault=ko.computed(function(){var n=[];return f.BillingAddress()().forEach(function(t){t.IsDefaultBilling()||n.push(t)}),n});this.DefaultShippingAddress=ko.computed(function(){var n;return f.ShippingAddress()().forEach(function(t){t.IsDefaultShipping()==!0&&(n=t)}),n});this.DefaultBillingAddress=ko.computed(function(){var n;return f.BillingAddress()().forEach(function(t){t.IsDefaultBilling()==!0&&(n=t)}),n});this.SelectedShippingAddress=ko.computed(function(){var n;return f.ShippingAddress()().forEach(function(t){t.Selected()==!0&&(n=t)}),n});this.SelectedBillingAddress=ko.computed(function(){var n;return f.BillingAddress()().forEach(function(t){t.Selected()==!0&&(n=t)}),n});s||this.DefaultShippingAddress()&&(this.DefaultShippingAddress().Selected(!0),n.OrderViewModel.Order&&n.OrderViewModel.Order.ShippingAddress().AddressId()!=this.DefaultShippingAddress().AddressId()&&n.OrderViewModel.Order.setShippingAddress(this.DefaultShippingAddress()));o||this.DefaultBillingAddress()&&(this.DefaultBillingAddress().Selected(!0),n.OrderViewModel.Order&&n.OrderViewModel.Order.BillingAddress().AddressId()!=this.DefaultBillingAddress().AddressId()&&n.OrderViewModel.Order.setBillingAddress(this.DefaultBillingAddress()));t.AddressBook=this}return t.EditAddressModel=ko.observable(),t.AddAddressModel=ko.observable(),t}(),i;n.AddressBookModel=t;i=function(){function i(r,u,f,e){var o=this,s;f===void 0&&(f=!1);this.AddressId=ko.observable();this.AddressLine=ko.observable();this.AddressLine2=ko.observable();this.AvailableCountries=ko.observableArray();this.AvailableStates=ko.observableArray();this.CompanyName=ko.observable();this.Country=ko.observable(new Entities.AddressBookModels.CountryModel);this.CountryOfResidence=ko.observable(new Entities.AddressBookModels.CountryModel);this.CountryIso=ko.observable();this.CountryName=ko.observable();this.City=ko.observable();this.Email=ko.observable();this.FirstName=ko.observable();this.IsBilling=ko.observable();this.IsDefaultBilling=ko.observable();this.IsDefaultShipping=ko.observable();this.LastName=ko.observable();this.PostalCode=ko.observable();this.PhoneNumber=ko.observable();this.Selected=ko.observable();this.State=ko.observable(new Entities.AddressBookModels.StateModel);this.StateIso=ko.observable();this.StateName=ko.observable();this.Region=ko.observable();this.VerificationMessage=ko.observable();this.regionVisibility=ko.observable(!0);this.SaveAsDefault=!1;this.verifiedEmail=!1;this.GdprActive=ko.observable();this.IsEnableCountryOfResidenceValidation=ko.observable(!1);this.bindValidation=function(){o.FirstName.extend({required:{message:Helpers.KnockoutHelper.validationMessage("FirstName","required",o.$container)}});o.LastName.extend({required:{message:Helpers.KnockoutHelper.validationMessage("LastName","required",o.$container)}});o.CompanyName.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CompanyName","required",o.$container)}});o.AddressLine.extend({required:{message:Helpers.KnockoutHelper.validationMessage("AddressLine","required",o.$container)}});o.City.extend({required:{message:Helpers.KnockoutHelper.validationMessage("City","required",o.$container)}});o.PostalCode.extend({required:{message:Helpers.KnockoutHelper.validationMessage("PostalCode","required",o.$container)}});o.PhoneNumber.extend({required:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","required",o.$container)}});o.Email.extend({email:{message:Helpers.KnockoutHelper.validationMessage("email","email",o.$container)}}).extend({required:{message:Helpers.KnockoutHelper.validationMessage("email","required",o.$container)}});o.Country.extend({required:{message:Helpers.KnockoutHelper.validationMessage("Country","required",o.$container)}});o.CountryOfResidence.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CountryOfResidence","required",o.$container),onlyIf:o.IsEnableCountryOfResidenceValidation}})};this.prefillAddress=function(){i.Countries&&i.Countries.length?o.setCountriesAndStates(i.Countries):$.ajax("/Ecommerce.svc/AddressAdministration_GetCountries",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetCountries")}}),success:function(n){i.Countries=n.Countries;i.DefaultCountryIso=n.DefaultCountryIso;o.setCountriesAndStates(n.Countries);o.setDefaultCountryOfResidence(n.DefaultCountryIso);o.IsEnableCountryOfResidenceValidation(!0)}})};this.setCountriesAndStates=function(n,t){var i=o.CountryIso(),u=o.StateName(),f=o.Region(),r;n&&n.length&&(o.AvailableCountries.removeAll(),r=!1,o.sortedCountries(n).forEach(function(n){o.AvailableCountries.push(n);r||(t?(o.selectCountryAndState(n,i,null,null,t),o.setDefaultCountryOfResidence(t)):(o.selectCountryAndState(n,i,u,f),o.setDefaultCountryOfResidence(t)))}));o.Country.clearError()};this.selectCountryAndState=function(n,t,r,u,f){if(o.CountryIso()||i.DefaultCountryIso&&!t&&(t=i.DefaultCountryIso),n.CountryIso&&n.CountryIso==t){o.setCountry(n);var e=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetStates"),Name:o.CountryName()}});$.ajax("/Ecommerce.svc/AddressAdministration_GetStates/",{type:"POST",async:!1,contentType:Constants.ContentType.OsaContentType,data:e,success:function(t){var i=t.value,e;i&&i.length?(e=!1,o.AvailableStates.removeAll(),o.sortedStates(i).forEach(function(n){o.AvailableStates.push(n);r&&!e&&n.StateName==r&&(e=o.setState(n));o.checkRegionVisibility()}),f&&o.chooseState(f)):(n.HasChildren&&u&&o.Region(u),o.setState())}})}};this.changeCountryHandler=function(n,t){o.setCountry(o.Country());o.setState();o.Region("");o.changePhoneValidationAccordingCountry(n);o.getStatesByCountry(n,t);o.checkRegionVisibility()};this.changeCountryOfResidenceHandler=function(){o.setCountryOfResidence(o.CountryOfResidence());var n=!1;o.CountryOfResidence()&&(n=Helpers.CommerceHelper.CheckIfCountryWithinEU(o.CountryOfResidence().CountryIso));o.GdprActive(n)};this.gdprApplicable=function(){return o.GdprActive()};this.changeStateHandler=function(n,t){t&&!t.eventPhase&&!o.State()&&o.StateName()&&o.StateIso()&&(o.State(new Entities.AddressBookModels.StateModel(o.StateName(),o.StateIso())),o.chooseState(o.StateIso()));o.setState(o.State());o.validateRegionState()};this.changeCityHandler=function(n,t){t.preventDefault();o.checkRegionVisibility()};this.checkRegionVisibility=function(){o.regionVisibility(!(o.City()&&Constants.AddressBook.CitiesWithoutRegionValidation.indexOf(o.City().toLowerCase())!=-1))};this.changePhoneValidationAccordingCountry=function(n){var i=n.CountryIso(),t=$("[name='phone']",n.$container).not(".prepopulated");i==Constants.CountriesIso.US||i==Constants.CountriesIso.CA?(n.PhoneNumber.rules.remove(function(n){return n.rule=="digit"}),n.PhoneNumber.rules.remove(function(n){return n.rule=="maxLength"}),n.PhoneNumber.extend({phoneUS:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","phoneUS",n.$container)}}).extend({maxLength:12}),t.length&&t.unbind("keypress.checkForDigit").bind("keypress.checkForDigit",function(n){return o.customMaskForUSPhone(n)})):(n.PhoneNumber.rules.remove(function(n){return n.rule=="phoneUS"}),n.PhoneNumber.rules.remove(function(n){return n.rule=="maxLength"}),n.PhoneNumber.extend({digit:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","number",n.$container)}}).extend({maxLength:16}),t.length&&t.unbind("keypress.checkForDigit"))};this.getStatesByCountry=function(n,t){if(t.preventDefault(),!n.Country()){n.CountryIso(null);n.CountryName(null);return}var n=ko.isObservable(n)?n():n;n.CountryName(n.Country().CountryName);n.CountryIso(n.Country().CountryIso);n.CountryIso()&&(n.AvailableStates.removeAll(),$.ajax("/Ecommerce.svc/AddressAdministration_GetStates/",{type:"POST",async:!1,contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetStates"),Name:o.CountryName()}}),success:function(t){var i=t.value,r;i&&i.length?(r=!1,o.sortedStates(i).forEach(function(t,u){n.AvailableStates.push(t);r||n.StateName()&&i[u].StateName==n.StateName()&&(r=n.setState(i[u]))}),o.checkRegionVisibility()):n.setState()}}))};this.getCityStateByZip=function(n,t){t.preventDefault();n.Country()&&n.Country().CountryIso==Constants.CountriesIso.US&&n.PostalCode()&&$.ajax("/Ecommerce.svc/AddressAdministration_CityStateByZip/",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("CityStateByZip"),Zip:n.PostalCode()}}),success:function(t){t&&(t.City&&!n.City()&&n.City(t.City),t.State&&n.AvailableStates().length&&!n.State()&&o.chooseState(t.State))}})};this.addAddress=function(n,t,i,r){if(i===void 0&&(i=!1),t.preventDefault(),o.isValid()){var u=$("input[default]",n.$container)[0],f=u?u.checked:!1;(n.SaveAsDefault=f,o.suggestAddress(n,"add",f,r))||o.saveAddress(n,t,i)}};this.suggestAddress=function(n,t,r,u){var f,e;if(t===void 0&&(t="add"),!n.IsBilling()&&n.CountryIso()&&n.CountryIso().toLowerCase()===Constants.CountriesIso.US.toLowerCase()&&(f=Services.UserServices.GetSuggestedAddress(ko.mapping.toJS(n,Constants.KnockoutMapping.IgnoreJQueryMapping),!1),f)){e=void 0;f.addressModel?(f.addressModel.Id=f.Id,e=new i(n.$container,f.addressModel,!0),r&&(e.SaveAsDefault=r)):e=new i(n.$container,null,!1,f.message);var o=u?$('[role="dialog"][data-modal="address-verification-apply"]'):$('[role="dialog"][data-modal="address-verification"]'),s=$(".current-address",o)[0],h=$(".wkis-modal-header",o)[0],c=$(".suggested-address",o)[0];return $("button",o).attr("operation",t),ko.cleanNode(s),ko.cleanNode(h),ko.cleanNode(c),ko.applyBindings(n,s),ko.applyBindings(n,h),ko.applyBindings(e,c),Helpers.HtmlHelper.OpenModalDialog(o.attr("data-modal")),!0}return!1};this.useAddress=function(n,t,i){var r=$(t.currentTarget).attr("operation");if(r)switch(r){case"add":o.saveAddress(n,t,i);break;case"update":o.updateAddress(n,t)}else o.saveAddress(n,t,i)};this.applyNewAddress=function(i){t.AddressBook&&t.AddressBook.Addresses()&&t.AddressBook.Addresses().length?o.saveAddress(i,null,!0):n.OrderViewModel.Order.SameAddresses()?n.OrderViewModel.Order.applyAddresses(i,i):i.IsBilling()?n.OrderViewModel.Order.applyAddresses(n.OrderViewModel.Order.ShippingAddress(),i):n.OrderViewModel.Order.applyAddresses(i,n.OrderViewModel.Order.BillingAddress());Helpers.HtmlHelper.CloseModalDialog()};this.saveAddress=function(r,u,f,e){var r,h,s,c,l;e===void 0&&(e=!0);r||(r=o);h={ignore:["$container","AvailableCountries","AvailableStates","State","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","verifiedEmail","SaveAsDefault","CountryOfResidence","CustomerName","IsDefaultBilling","IsDefaultShipping","regionVisibility","GdprActive","IsEnableCountryOfResidenceValidation"]};$("button[type=submit]",o.$container).attr("disabled","disabled");s=ko.mapping.toJS(r,h);$.extend(s,{"odata.type":Constants.Global.ODataOperation("Address")},{Region:r.Region()},{Email:r.Email()});c=o.IsBilling()?0:1;l=JSON.stringify({"odata.type":Constants.Global.ODataOperation("CustomerAddress"),Id:o.AddressId(),IsDefaultBilling:o.IsDefaultBilling(),IsDefaultShipping:o.IsDefaultShipping(),TypeValue:c,Address:s});$.ajax("/Ecommerce.svc/CustomerAddresses",{type:"POST",data:l,async:e,contentType:Constants.ContentType.OsaContentType,complete:function(u){if(u.readyState==4&&u.status==201){var e=new i(o.$container,u.responseJSON,!0);t.AddressBook&&t.AddressBook.Addresses&&t.AddressBook.Addresses.push(e);f==!0&&(t.AddressBook&&t.AddressBook.selectAddress(e),n.OrderViewModel.Order&&(n.OrderViewModel.Order.SameAddresses()?(n.OrderViewModel.Order.setBillingAddress(e),n.OrderViewModel.Order.setShippingAddress(e)):e.IsBilling()?n.OrderViewModel.Order.setBillingAddress(e):n.OrderViewModel.Order.setShippingAddress(e)));r.SaveAsDefault===!0&&e.setDefault();$('.js-wkis-alert-message[data-type="success"]').remove();$(".js-wkis-modal-overlay")[0].click()}$("button[type=submit]",o.$container).removeAttr("disabled")}})};this.validateRegionState=function(n){var t,i,r,u;return n===void 0&&(n=!0),o.Country()&&o.Country().HasChildren?o.AvailableStates().length?(t=$("div.ko-validation-custom-message[for='State'][rule='required']"),i=$("select[name=stateSelector]",o.$container),o.StateIso()||o.City()&&Constants.AddressBook.CitiesWithoutRegionValidation.indexOf(o.City().toLowerCase())!=-1?(i.removeClass("ko-error"),t.hide(),!0):(n&&(i.addClass("ko-error"),t.show()),!1)):(r=$("div.ko-validation-custom-message[for='Region'][rule='required']"),u=$("[name=region]",o.$container),o.Region()?(u.removeClass("ko-error"),r.hide(),!0):(n&&(u.addClass("ko-error"),r.show()),!1)):!0};this.isValid=function(n,t){return(n===void 0&&(n=!0),t===void 0&&(t=!1),o.errors().length>0)?(o.errors.showAllMessages(!1),o.errors.showAllMessages(n),o.validateRegionState(n),t&&o.emailErrors().length>0&&o.emailErrors.showAllMessages(n),!1):o.validateRegionState(n)?o.CountryOfResidence.isValid()?t&&o.emailErrors().length>0&&(o.Email()&&!o.verifiedEmail||!o.Email())?(o.emailErrors.showAllMessages(n),!1):!0:!1:!1};this.setDefault=function(){var n=o,i=ko.mapping.toJS(n,{ignore:["$container","AvailableCountries","AvailableStates","State","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","IsDefaultBilling","IsDefaultShipping","verifiedEmail","SaveAsDefault","AddressId","CustomerName","Selected","regionVisibility","CountryOfResidence","GdprActive","IsEnableCountryOfResidenceValidation"]}),r,u;$.extend(i,{"odata.type":Constants.Global.ODataOperation("Address")},{Region:n.Region()},{Email:n.Email()});r=o.IsBilling()?0:1;u=JSON.stringify({"odata.type":Constants.Global.ODataOperation("CustomerAddress"),Id:o.AddressId(),IsDefaultBilling:o.IsBilling(),IsDefaultShipping:!o.IsBilling(),TypeValue:r,Address:i});$.ajax("/Ecommerce.svc/CustomerAddresses('"+n.AddressId()+"')",{type:"PATCH",contentType:Constants.ContentType.OsaContentType,data:u,success:function(){var i,r;n.IsBilling()!=!0?(t.AddressBook.DefaultShippingAddress()&&t.AddressBook.DefaultShippingAddress().IsDefaultShipping(!1),n.IsDefaultShipping(!0),i=$("div[data-type='shipping']",t.AddressBook.$container).children("button").first(),i&&(r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS","The Default Shipping address was changed successfully",{duration:1e4}),i.after(r))):n.IsBilling()==!0&&(t.AddressBook.DefaultBillingAddress()&&t.AddressBook.DefaultBillingAddress().IsDefaultBilling(!1),n.IsDefaultBilling(!0),i=$("div[data-type='billing']",t.AddressBook.$container).children("button").first(),i&&(r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS","The Default Billing address was changed successfully",{duration:1e4}),i.after(r)))}})};this.removeAddressForm=function(n,t){var r=$(t.currentTarget).attr("data-modal"),i=$("[data-modal='"+r+"'][role='dialog']")[0];ko.cleanNode(i);$("span.ko-validation-message",i).remove();ko.applyBindings(n,i)};this.removeAddress=function(n){if(t.AddressBook)var r=o.IsBilling()?"billing":"shipping",i=$("div[data-type="+r+"]",t.AddressBook.$container).children("button").first();$.ajax("/Ecommerce.svc/CustomerAddresses('"+n.AddressId()+"')/",{type:"DELETE",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({key:n.AddressId}),success:function(){var r,u;t.AddressBook.Addresses.remove(n);n.IsDefaultBilling()?t.AddressBook.BillingAddress()().length?t.AddressBook.BillingAddress()()[0].setDefault():r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Info,"ADVICE","A Default Address should be set to enable a faster checkout process in the future"):n.IsDefaultShipping()&&(t.AddressBook.ShippingAddress()().length?t.AddressBook.ShippingAddress()()[0].setDefault():r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Info,"ADVICE","A Default Address should be set to enable a faster checkout process in the future"));i&&(r&&i.after(r),u=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"Success!","The address has been removed from your address book",{duration:1e4}),i.after(u))},error:function(){if(i){var n=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"Failed!","The address failed to be removed from your address book. Please try again",{duration:1e4});i.after(n)}}})};this.editAddressForm=function(n,i){var f=$(i.currentTarget),r=$("[role=dialog][data-modal="+f.attr("data-modal")+"]")[0],u;$("span.ko-validation-message",r).hide();u=n.clone(r);u.prefillAddress();$("input",r).add("select",r).removeClass("ko-error");$(".ko-validation-custom-message",r).hide();t.EditAddressModel(u);!!ko.dataFor(r)||(ko.applyBindings(t.EditAddressModel,r),t.EditAddressModel().Country&&t.EditAddressModel().Country.clearError())};this.changeAddress=function(n,t,i){(i===void 0&&(i=!1),t.preventDefault(),o.isValid())&&(o.suggestAddress(n,"update")||o.updateAddress(n,t,i))};this.updateAddress=function(n,r,u){var e,f,s,h;(u===void 0&&(u=!1),r.preventDefault(),o.isValid())&&(e={ignore:["$container","AvailableCountries","AvailableStates","State","Selected","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","IsDefaultBilling","IsDefaultShipping","verifiedEmail","SaveAsDefault","AddressId","CustomerName","regionVisibility","CountryOfResidence","GdprActive","IsEnableCountryOfResidenceValidation"]},$("button[type=submit]",o.$container).attr("disabled","disabled"),f=ko.mapping.toJS(n,e),$.extend(f,{"odata.type":Constants.Global.ODataOperation("Address")},{Region:n.Region()},{Email:n.Email()}),s=o.IsBilling()?0:1,h=JSON.stringify({"odata.type":Constants.Global.ODataOperation("CustomerAddress"),Id:o.AddressId(),IsDefaultBilling:o.IsDefaultBilling(),IsDefaultShipping:o.IsDefaultShipping(),TypeValue:s,Address:f}),$.ajax("/Ecommerce.svc/CustomerAddresses('"+n.AddressId()+"')/",{type:"PUT",contentType:Constants.ContentType.OsaContentType,data:h,success:function(){var f=t.AddressBook.Addresses().filter(function(t){return t.AddressId()==n.AddressId()}),e=new i(f[0].$container,n.toEntity());t.AddressBook.Addresses.replace(f[0],e);($(r.currentTarget).attr("aria-label")=="close dialog"||$(r.currentTarget).attr("operation"))&&$("button[aria-label='close dialog']",n.$container).click();u&&o.returnToAddressBook()}}))};this.selectAddress=function(){t.AddressBook?t.AddressBook.selectAddress(o):o.Selected(!o.Selected)};this.returnToAddressBook=function(){var n=o.IsBilling()?'[data-modal="address-book-billing"]':'[data-modal="address-book-shipping"]';$("a.js-wkis-modal-open.wkis-arrow-link.-back"+n)[0].click()};this.verifyEmail=function(t,i){var r,u,f;if(i.preventDefault(),n.OrderViewModel.Order&&n.OrderViewModel.Order.IsGuestOrder()){if(r=$(i.currentTarget),t.emailErrors().length>0){$("[for='email'][rule='exist']",t.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");t.emailErrors.showAllMessages(!0);return}u=Constants.Global.ODataOperation("EmailExists");f=JSON.stringify({request:{Email:r.val(),"odata.type":u}});$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){n&&n.value===!1?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).hide(),o.verifiedEmail=!0):(r.addClass("ko-error"),r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).show(),o.verifiedEmail=!1)}})}};this.setCountry=function(n){return o.CountryName(n?n.CountryName:undefined),o.CountryIso(n?n.CountryIso:undefined),o.Country(n),o.changePhoneValidationAccordingCountry(o),!0};this.setCountryOfResidence=function(n){return o.CountryOfResidence(n),!0};this.setState=function(n){return n?(o.StateName(n.StateName),o.StateIso(n.StateIso),o.State(n)):(o.StateName(""),o.StateIso(""),o.State(null)),!0};this.chooseState=function(n){if(o.AvailableStates()&&o.AvailableStates().length){var t=!1;o.AvailableStates().forEach(function(i){t||i.StateIso.search(n)==-1||(o.setState(i),t=!0)})}};this.sortedStates=function(n){return n.sort(function(n,t){return n.StateName<t.StateName?-1:1})};this.sortedCountries=function(n){return n.sort(function(n,t){return Constants.AddressBook.PriorityCountries.indexOf(n.CountryIso)!=-1?-1:Constants.AddressBook.PriorityCountries.indexOf(t.CountryIso)!=-1?1:n.CountryName<t.CountryName?-1:1})};this.clone=function(n){var r=o.toEntity(),t=new i(n?n:o.$container,r);return t.CustomerName=o.CustomerName,t.AvailableCountries(o.AvailableCountries()),t.AvailableStates(o.AvailableStates()),t.Country(o.Country()),t.State(o.State()),t.Selected(o.Selected()),t.SaveAsDefault=o.SaveAsDefault,t};this.toEntity=function(){var t=new Entities.AddressBookModels.AddressBookModel,n=new Entities.AddressBookModels.AddressModel;return n.AddressLine=o.AddressLine(),n.AddressLine2=o.AddressLine2(),n.City=o.City(),n.CompanyName=o.CompanyName(),n.CountryIso=o.CountryIso(),n.CountryName=o.CountryName(),n.Email=o.Email(),n.FirstName=o.FirstName(),n.LastName=o.LastName(),n.Telephone=o.Telephone(),n.ZipCode=o.ZipCode(),n.StateIso=o.StateIso(),n.StateName=o.StateName(),n.Region=o.Region(),n.IsBilling=o.IsBilling(),t.Address=n,t.Id=o.AddressId(),t.IsDefaultBilling=o.IsDefaultBilling(),t.IsDefaultShipping=o.IsDefaultShipping(),t.TypeValue=o.IsBilling()?0:1,t};this.clear=function(){o.AddressLine(null);o.AddressLine2(null);o.City(null);o.CompanyName(null);o.CountryIso(null);o.CountryName(null);o.Email(null);o.FirstName(null);o.IsBilling(!1);o.IsDefaultBilling(!1);o.IsDefaultShipping(!1);o.LastName(null);o.PhoneNumber(null);o.PostalCode(null);o.StateIso(null);o.StateName(null);o.Region(null);o.AvailableCountries([]);o.AvailableStates([]);o.prefillAddress()};this.customMaskForUSPhone=function(n){var t=$(n.currentTarget)[0],f=!1,e,i,u,r;for(n.key&&(e=n.key.toString(),f=e.search(/\d/)!=-1,t.selectionStart!=t.selectionEnd&&(t.value=t.value.replace(t.value.substr(t.selectionStart,t.selectionEnd),""))),i=t.value,u=0,r=0;r<i.length;r++)i[r].toString().search(/\d/)!=-1&&u++;f&&u>9&&(t.value=i.substring(0,i.length-1))};this.$container=$(r);u&&(u.Address?(this.AddressId=ko.observable(u.Id),this.FirstName=ko.observable(u.Address.FirstName),this.LastName=ko.observable(u.Address.LastName),this.CompanyName=ko.observable(u.Address.CompanyName),this.AddressLine=ko.observable(u.Address.AddressLine),this.AddressLine2=ko.observable(u.Address.AddressLine2),this.CountryIso=ko.observable(u.Address.CountryIso),this.CountryName=ko.observable(u.Address.CountryName),this.City=ko.observable(u.Address.City),this.StateIso=ko.observable(u.Address.StateIso),this.StateName=ko.observable(u.Address.StateName),this.PostalCode=ko.observable(u.Address.ZipCode),this.Email=ko.observable(u.Address.Email),this.IsBilling=ko.observable(u.TypeValue===0),this.IsDefaultBilling=ko.observable(u.IsDefaultBilling),this.IsDefaultShipping=ko.observable(u.IsDefaultShipping),this.PhoneNumber=ko.observable(u.Address.Telephone),this.Region=ko.observable(u.Address.Region)):(s=u,this.AddressId=ko.observable(s.Id),this.FirstName=ko.observable(s.FirstName),this.LastName=ko.observable(s.LastName),this.CompanyName=ko.observable(s.CompanyName),this.AddressLine=ko.observable(s.AddressLine),this.AddressLine2=ko.observable(s.AddressLine2),this.CountryIso=ko.observable(s.CountryIso),this.CountryName=ko.observable(s.CountryName),this.City=ko.observable(s.City),this.StateIso=ko.observable(s.StateIso),this.StateName=ko.observable(s.StateName),this.PostalCode=ko.observable(s.ZipCode?s.ZipCode:s.PostalCode),this.Email=ko.observable(s.Email),this.IsBilling=ko.observable(s.IsBilling),this.IsDefaultBilling=ko.observable(u.IsDefaultBilling),this.IsDefaultShipping=ko.observable(u.IsDefaultShipping),this.PhoneNumber=ko.observable(s.Telephone?s.Telephone:s.PhoneNumber),this.Region=ko.observable(s.Region)));this.ZipCode=ko.computed(function(){return o.PostalCode()?o.PostalCode():""});this.Telephone=ko.computed(function(){return o.PhoneNumber()?o.PhoneNumber():""});this.CustomerName=ko.computed(function(){return o.FirstName()&&o.LastName()?o.FirstName()+" "+o.LastName():""});e&&this.VerificationMessage(e);this.bindValidation();f&&this.prefillAddress();this.errors=ko.validation.group([this.FirstName,this.LastName,this.CompanyName,this.AddressLine,this.City,this.PostalCode,this.PhoneNumber,this.Country,this.State,this.Region],{deep:!0});this.emailErrors=ko.validation.group([this.Email]);this.bindBrowserPrepopulating()}return i.prototype.setDefaultCountryOfResidence=function(n){var t=this;this.AvailableCountries()&&this.AvailableCountries().length>0&&n&&this.AvailableCountries().forEach(function(i){if(i.CountryIso==n){var r=i;t.setCountryOfResidence(r);t.changeCountryOfResidenceHandler()}})},i.prototype.bindBrowserPrepopulating=function(){var n=this;$('input.prepopulated[name="country"]',this.$container).on("input",function(t){var f=$(t.currentTarget).val(),r,u;f&&n.AvailableCountries()&&n.AvailableCountries().length>0&&(n.AvailableCountries().forEach(function(n){r||n.CountryIso!=f||(r=n)}),n.setCountry(r),u=$('input.prepopulated[name="state"]',$(t.currentTarget).parents("form")).val(),u?n.setCountriesAndStates(i.Countries,u):n.prefillAddress())});$('input.prepopulated[name="zip"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.PostalCode(i)});$('input.prepopulated[name="phone"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.PhoneNumber(i)});$('input.prepopulated[name="AddressLine"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.AddressLine(i)});$('input.prepopulated[name="AddressLine2"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.AddressLine2(i)});$('input.prepopulated[name="city"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.City(i)})},i}();n.AddressViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n,t){var i=this;this.updateProfile=function(n,t){var r,u;if(t.preventDefault(),i.errors().length){i.errors.showAllMessages(!0);return}$('[for="wrongPassword"]',i.$container).hide();r={FirstName:i.accountModel.FirstName(),LastName:i.accountModel.LastName(),PhoneNumber:i.accountModel.PhoneNumber(),CustomerType:i.accountModel.CustomerType(),ReferralMethod:i.accountModel.ReferralMethod(),CompanyName:null,Id:null,Password:i.Password(),Email:i.accountModel.Email()};$.extend(r,{"odata.type":Constants.Global.ODataOperation("User")});i.accountModel.GdprActive()&&(u={elqFormName:"acctInfoForm",emailAddress:i.accountModel.Email(),firstName:i.accountModel.FirstName(),lastName:i.accountModel.LastName(),country:i.accountModel.CountryOfResidence().CountryIso,consentCheckbox:!i.accountModel.DeleteUserAccount(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:i.accountModel.DeleteUserAccount()?Helpers.CommerceHelper.stripHtml($("label[for='negative-consent']").html()):Helpers.CommerceHelper.stripHtml($("label[for='positive-consent']").html()),consentMessageId:$("label[for='positive-consent']").attr("message-id"),pageName:"My Account",pageUrl:location.href},Helpers.CommerceHelper.SendUserConsentToEloqua(u));var e=$(t.currentTarget).closest(".js-wkis-modal"),o=e.attr("data-modal"),s=$("button[data-modal='"+o+"']"),f=s.parent().parents(".wkis-account-content").children().first();$.ajax("/Ecommerce.svc/Users('0')",{data:JSON.stringify(r),type:"put",contentType:"application/json;odata=minimalmetadata",success:function(){var t=$(".wkis-account-welcome")[0],n;t&&(n=ko.dataFor(t),n&&(n.FirstName(i.accountModel.FirstName()),n.LastName(i.accountModel.LastName())));$("button.js-wkis-modal-close",i.$container)[0].click();f.after(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Account Information was successfully updated",{duration:1e4}))},error:function(n){n.responseText.indexOf("Invalid password")!==-1?$('[for="wrongPassword"]',i.$container).show():$('[for="generalError"]',i.$container).show();f.after(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"FAILED!","Account Information was not updated because of an error",{duration:1e4}))}})};this.$container=$(n);this.Password=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("password","required",this.$container)}});this.accountModel=t;this.errors=ko.validation.group(this,{deep:!0})}return n}();n.EnterPasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.resetModel=function(){var n=$("[captcha-id]",this.$container);n.length&&(this.grecaptchaWidget=$("[captcha-id]",this.$container).attr("captcha-id"));this.email("");this.email.isModified(!1);grecaptcha.reset(Number(this.grecaptchaWidget));$("#forgotPasswordRecaptcha").css({"border-color":"","border-style":"",width:"",height:""})};this.forgotPassword=function(n,i){var u;if(i.preventDefault(),u=n.email(),t.errors().length>0)t.errors.showAllMessages(!0),$("[for='email'][rule='exist']",t.$container).show();else{var r=!1,f=Constants.Global.ODataOperation("ValidateCaptcha"),e=JSON.stringify({request:{Captcha:$("#forgotPasswordRecaptcha .g-recaptcha-response").val(),"odata.type":f}});$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ValidateCaptcha",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:e,success:function(n){r=n.value},error:function(){r=!1;$("#btnForgotPasswordError").click()}})).done(function(){r?($("#forgotPasswordRecaptcha").css({"border-color":"","border-style":"",width:"",height:""}),$("[for='forgot'][rule='captcha']",t.$container).hide(),$.ajax("/Ecommerce.svc/CustomerAdministration_ForgotPassword",{method:"POST",contentType:Constants.ContentType.OsaContentType,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ForgotPassword"),Email:u}}),success:function(n){var t=n.value;t==!0?$("#btnForgotPasswordSuccess").click():$("#btnForgotPasswordEmailNotFoundError").click()},error:function(){$("#btnForgotPasswordError").click()}}).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement();t.resetModel()})):($("[for='forgot'][rule='captcha']",t.$container).show(),$("#forgotPasswordRecaptcha").css({"border-color":"#f00","border-style":"solid",width:"308px",height:"82px"}))})}};$('.js-wkis-modal-open[data-modal="forgot-password"]').unbind("click.initializeDialog").bind("click.initializeDialog",function(){$("[for='forgot'][rule='captcha']",t.$container).hide()});this.$container=$(n);this.email=Helpers.KnockoutHelper.GetObservableByType("email",this.$container);this.errors=ko.validation.group(this,{deep:!0})}return n}();n.ForgotPasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(t){t===void 0&&(t=0);this.TotalItemCount=ko.observable(0);this.TotalItemCount(t);n.Counter=this}return n}();n.CartItemCounterViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.rememberMe=ko.observable(!0);this.inProgress=ko.observable(!1);this.login=function(n){if(!t.inProgress()){if(t.errors().length>0){t.errors.showAllMessages(!0);return}var i=$(n).find("[type='submit']").attr("href"),r=function(n){var r;$("[for='register']",t.$container).hide();$("[for='locked']",t.$container).hide();$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(n),{path:"/"});t.rememberMe()&&(r=new Date,r.setTime(r.getTime()+Constants.Global.RememberMeExpirationDays*864e5),$.cookie(Constants.Global.RememberMeCookieKey,t.email(),{path:"/",expires:r}));var u=!0,f=function(n){var t,r,f,e;n?(t=n.Id,r=$.cookie(Constants.Global.BasketCookieKey),u=!1,f=function(){$.cookie(Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey,Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey,{path:"/"});location.href=i},$.cookie(Constants.Global.BasketCookieKey,t,{path:"/"}),t!==r?(e=JSON.stringify({BasketId:t,FromBasketId:r}),Services.UserServices.AppendBasket(e,!0).always(f)):f()):$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})},e=function(){$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})},o=function(){u&&(location.href=i)};Services.UserServices.GetCurrentBasket(!1).done(f).fail(e).always(o)},u=function(n){n.responseText=="Locked"?$("[for='locked']",t.$container).show():$("[for='register']",t.$container).show();Helpers.HtmlHelper.HideGlobalLoaderElement()},f=Constants.Global.ODataOperation("Auth"),e=JSON.stringify({request:{Email:t.email(),Password:t.password(),"odata.type":f}});t.inProgress(!0);Services.UserServices.Authentication(e,!0,!0).done(r).fail(u).always(function(){return t.inProgress(!1)})}};this.loginPopup=function(n,i){var r;if(i.preventDefault(),t.inProgress())return!1;if(r=$(i.currentTarget),t.errors().length>0)return t.errors.showAllMessages(!0),!1;var u=function(n){var i,u,f;$("[for='register']",t.$container).hide();$("[for='locked']",t.$container).hide();$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(n),{path:"/"});t.rememberMe()&&(i=new Date,i.setTime(i.getTime()+Constants.Global.RememberMeExpirationDays*864e5),$.cookie(Constants.Global.RememberMeCookieKey,t.email(),{path:"/",expires:i}));u=function(n){var t,i,r;n?(t=n.Id,i=$.cookie(Constants.Global.BasketCookieKey),i&&(r=JSON.stringify({BasketId:t,FromBasketId:i}),Services.UserServices.AppendBasket(r,!0)),$.cookie(Constants.Global.BasketCookieKey,t,{path:"/"})):$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})};f=function(){$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})};Services.UserServices.GetCurrentBasket(!0).done(u).fail(f);$(".wkis-terms-modal-info-email","[role='dialog'][data-modal='terms-conditions']").text(t.email());Services.UserServices.ShowMyAccHeader();r.siblings('a.js-wkis-modal-open[data-modal="terms-conditions"]')[0].click()},f=function(n){n.responseText=="Locked"?$("[for='locked']",t.$container).show():$("[for='register']",t.$container).show()},e=Constants.Global.ODataOperation("Auth"),o=JSON.stringify({request:{Email:t.email(),Password:t.password(),"odata.type":e}});t.inProgress(!0);Services.UserServices.Authentication(o,!0,!0).done(u).fail(f).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement();t.inProgress(!1)})};this.verifyEmail=function(n,t){var i;if(t?(t.preventDefault(),i=$(t.currentTarget)):i=$("[name='Email']",n.$container),!n.email.isValid()){$("[for='email'][rule='exist']",n.$container).hide();i.removeClass("ko-valid");i.parent().removeClass("ko-valid");return}};this.verifyPassword=function(n,i){i.preventDefault();var r=$(i.currentTarget);t.password.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))};this.$container=$(n);this.email=Helpers.KnockoutHelper.GetObservableByType("email",this.$container);this.password=Helpers.KnockoutHelper.GetObservableByType("password",this.$container);this.errors=ko.validation.group(this,{deep:!0});this.odataElement=Constants.Global.ODataElement;$.cookie(Constants.Global.RememberMeCookieKey)&&(this.email($.cookie(Constants.Global.RememberMeCookieKey)),this.verifyEmail(this))}return n}();n.LoginUserViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(t){var i=this,r;if(this.Orders=ko.observableArray(),this.NoOrdersToDisplay=ko.observable(!1),this.OrderViewModel=ko.observable(),this.loadOrders=function(n){var t=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetHistoryOrder"),LastDays:i.Period().LastDays,Year:i.Period().Year,IncludeYears:n}});$.ajax("/Ecommerce.svc/OrderAdministration_GetHistoryOrder/",{method:"POST",data:t,contentType:Constants.ContentType.OsaContentType,success:function(t){var r,u,f;if(n&&t.Years)for(r=0,u=t.Years;r<u.length;r++)f=u[r],i.AvailablePeriods.push({Name:f.toString(),Year:f});i.Orders(t.Order);i.NoOrdersToDisplay(t.Order&&t.Order.length===0)}})},this.periodChanged=function(){i.loadOrders(!1)},this.loadOrder=function(t){$.ajax("/Ecommerce.svc/Orders('"+t+"')?$expand=Order_orderLines/Product",{method:"GET",success:function(t){var r=new Entities.OrderModels.OrderModel,u;$.extend(r,t);u=new n.OrderViewModel(r,i.viewModelContainer);i.OrderViewModel(u);Helpers.HtmlHelper.ShowHelpInfo();i.$container.addClass("loaded-history-model")}})},this.loadOrderClick=function(n){return i.loadOrder(n.Id),!1},this.clearOrder=function(n,t){i.OrderViewModel(null);Helpers.HtmlHelper.HideHelpInfo();i.$container.removeClass("loaded-history-model");t.preventDefault()},this.viewModelContainer=t,this.$container=$(t),this.AvailablePeriods=ko.observableArray([{Name:$("#accountOrderHistoryLast30DaysContainer").text(),LastDays:30},{Name:$("#accountOrderHistoryLast60DaysContainer").text(),LastDays:60}]),this.Period=ko.observable(this.AvailablePeriods()[0]),$("#accountOrderHistoryLink").parent().hasClass("active"))this.loadOrders(!0);else{r=!1;$('[href="#accountOrderHistoryContainer"]').on("click",function(){r||(i.loadOrders(!0),r=!0)})}}return t}();n.OrderHistoryViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t;(function(n){var i=function(i){function r(u,f,e){var o=i.call(this,u,f,e)||this,s,h,c;return o.Password=Helpers.KnockoutHelper.GetObservableByType("password",o.$container),o.IsShippingMethodLoaded=ko.observable(!0),o.ShippingMethods=ko.observableArray(),o.PaymentMethods=ko.observableArray(),o.Promotions=ko.observableArray(),o.BillingAddress=ko.observable(),o.ShippingAddress=ko.observable(),o.AppliedBillingAddress={},o.AppliedShippingAddress={},o.AcceptAgreement=ko.observable(!1),o.VatNumber=ko.observable(""),o.IsValidVatNumber=ko.observable(!0),o.NameOnCC=ko.observable(),o.ExpirationDateCC=ko.observable(),o.IsValidCardNumber=ko.observable(!0),o.UserConsentAgreement=ko.observable(!1),o.AccountCreateConsentAgreement=ko.observable(!1),o.AccountUpdateConsentAgreement=ko.observable(!1),o.RegisteredUserCountryOfResidence=ko.observable(new Entities.AddressBookModels.CountryModel),o.AvailableCountries=ko.observableArray(),o.appliedShippingAddress=ko.observable(!1),o.appliedBillingAddress=ko.observable(!1),o.GdprRulesApplicable=ko.observable(!1),o.CountryOfResidenceNotSet=ko.observable(!1),o.EUCountryOfResidenceSelected=ko.observable(!1),o.isValidPaymentInfo=function(){return o.isKliOrder?!0:o.PaymentMethod()!=="Credit Card"?!0:(Spreedly.validate(),o.IsValidCardNumber()&&!!o.ExpirationDateCC()&&!!o.NameOnCC())},o.initializeShippingAddress=function(t,i){var r;return t?(r=new n.AddressViewModel($('[data-address="shipping"]',i),t,!0),o.appliedShippingAddress(!0)):r=n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.DefaultShippingAddress()?n.AddressBookModel.AddressBook.DefaultShippingAddress():new n.AddressViewModel($('[data-address="shipping"]',i),undefined,!0),r},o.initializeBillingAddress=function(t,i,r){var u;return t?(u=new n.AddressViewModel($('[data-address="billing"]',r),t,!0),o.appliedBillingAddress(!0)):u=n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.DefaultBillingAddress()?n.AddressBookModel.AddressBook.DefaultBillingAddress():i?new n.AddressViewModel($('[data-address="billing"]',r),undefined,!0):o.ShippingAddress(),u},o.bindValidation=function(){o.NameOnCC.extend({required:{message:Helpers.KnockoutHelper.validationMessage("NameOnCC","required",o.$container)}});o.CardNumber.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CardNumber","required",o.$container)}});o.ExpirationDateCC.extend({required:{message:Helpers.KnockoutHelper.validationMessage("ExpirationDateCC","required",o.$container)}});o.Password.rules.remove(function(n){return n.rule=="required"});o.registrationDataErrors=ko.validation.group([o.ShippingAddress,o.BillingAddress,o.Password]);o.paymentDataErrors=ko.validation.group([o.BillingAddress,o.ExpirationDateCC,o.NameOnCC])},o.verifyPassword=function(n,t){t.preventDefault();var i=$(t.currentTarget);o.Password.isValid()?(i.addClass("ko-valid"),i.parent().addClass("ko-valid")):(i.removeClass("ko-valid"),i.parent().removeClass("ko-valid"));o.showAccountCreateConsentCheckbox()},o.applypromo=function(i,r){r.currentTarget.disabled=!0;var f=$(r.currentTarget).siblings("div.wkis-field-item").find("input").first(),e=$(r.currentTarget).parent().siblings(".ko-validation-custom-message"),u=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(u);$.ajax("/api/commerce/basket/"+o.Id+"/applypromo/",{type:"POST",data:JSON.stringify(o.PromoCode()),contentType:"application/json",success:function(i){var r,u,f,e;i.IsApplied&&i.IsApplied===!0?(r={},i.Order||(i.Order=Services.UserServices.GetUserBasketViewModel(!1)),$.extend(r,i.Order),o.PriceInfo(new n.OrderPriceInfoModel(r.PriceInfo)),u=[],r.Promotions.forEach(function(n){var i=new t(n);u.push(i)}),o.Promotions(u),o.PromoCode(""),o.getUpdatedOrderData(!1)):(f=o.Promotions(),f.length>0&&f[0].PromotionCode().length>0?(e=o,o.removePromo(function(){e.showPromoError()})):(o.showPromoError(),o.checkTaxError()))},complete:function(){r.currentTarget.disabled=!1}})},o.showPromoError=function(){var n=$("div.wkis-place-order-content-left").first();n.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"Error",$("div[for='promo'][rule='invalid']").first().text()));o.PromoCode("")},o.removePromo=function(n){var t=o.Promotions()[0].PromotionCode();$.ajax("/Ecommerce.svc/BasketAdministration_DeletePromo",{type:"POST",headers:Constants.JQuery.HeaderReturnContent,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("DeletePromo"),PromoCode:t,BasketId:o.Id}}),contentType:Constants.ContentType.OsaContentType,success:function(){var t=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(t);o.getUpdatedOrderData(!1);n!=undefined&&n()}})},o.accept=function(){if(o.AcceptAgreement(!o.AcceptAgreement()),o.AcceptAgreement()){var n=$("div.ko-validation-custom-message[for='placeorder'][rule='acceptAgreement']");n&&n.hide()}else o.isKliOrder&&($("#payment-frame").hide(),$("#btnPayment").show())},o.acceptUserConsent=function(){o.UserConsentAgreement(!o.UserConsentAgreement())},o.acceptAccountCreateConsent=function(){o.AccountCreateConsentAgreement(!o.AccountCreateConsentAgreement())},o.acceptAccountUpdateConsent=function(){o.AccountUpdateConsentAgreement(!o.AccountUpdateConsentAgreement());o.AccountUpdateConsentAgreement()||o.isKliOrder&&($("#payment-frame").hide(),$("#btnPayment").show())},o.showAccountCreateConsentCheckbox=function(){var n,t;return o.ShippingAddress().GdprActive()?(n=o.Password()&&o.Password.isValid(),n&&(t=$(".ko-validation-custom-message[for='AccountCreateConsent'][rule='acceptAccountCreateAgreement']"),o.AccountCreateConsentAgreement()?t.hide():t.show()),n):!1},o.showUserConsentCheckbox=function(){if(o.HasOnlyDigitalOrPracticeToolProducts()){if(o.BillingAddress().gdprApplicable())return!0}else if(o.ShippingAddress().gdprApplicable())return!0;return!1},o.updateOrder=function(n,t,i){t===void 0&&(t=!0);var u=ko.mapping.toJS(n),r={"odata.type":Constants.Global.ODataOperation("Basket")};$.extend(r,u);$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:JSON.stringify(r),contentType:Constants.ContentType.OsaContentType,headers:Constants.JQuery.HeaderReturnContent,beforeSend:function(){i?i():Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(n){n||(n=Services.UserServices.GetUserBasketViewModel(!1));o._updateOrderInfo(n,t)},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement();Helpers.HtmlHelper.HideMinilLoaderElement();o.IsShippingMethodLoaded(!0)}})},o.updateShippingMethod=function(n,t){var i=$(t.currentTarget),r=function(){Helpers.HtmlHelper.ShowMiniLoaderElement(i,i.width()+40);o.IsShippingMethodLoaded(!1)};o.updateOrder({ShippingMethod:n.ShippingMethod()},!1,r)},o.updatePaymentMethod=function(n){o.updateOrder({PaymentMethod:n.PaymentMethod()},!1)},o.getUpdatedOrderData=function(n){n===void 0&&(n=!0);var t=Services.UserServices.GetUserBasketViewModel(!1,!0);o._updateOrderInfo(t,n,!0)},o.getCreditCardType=function(n){var t="unknown";return/^5[1-5]/.test(n)?t="002":/^4/.test(n)?t="001":/^3[47]/.test(n)&&(t="003"),t},o.setShippingAddress=function(n,t){(t===void 0&&(t=!0),n.isValid(t,o.IsGuestOrder()))&&o.updateShippingAddress(n)},o.updateShippingAddress=function(n){var t,r=o.SameAddresses(),u=Constants.KnockoutMapping.AddressModelOsaMapping,i,f;r?(i=new Entities.AddressBookModels.AddressBookModel,f=ko.mapping.toJS(n,u),$.extend(i,f,{"odata.type":Constants.Global.ODataOperation("Address")}),t={ShippingAddress:n?i:null,BillingAddress:n?i:null}):($.extend(n,{"odata.type":Constants.Global.ODataOperation("Address")}),t={ShippingAddress:n?ko.mapping.toJS(n,u):null});$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:ko.mapping.toJSON(t),contentType:Constants.ContentType.OsaContentType,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},headers:Constants.JQuery.HeaderReturnContent,success:function(i){t.ShippingAddress&&o.showInfoMessageForPoBoxAddress(t.ShippingAddress.AddressLine,t.ShippingAddress.AddressLine2);o._updateOrderInfo(i);o.AppliedShippingAddress=ko.mapping.toJS(n,Constants.KnockoutMapping.IgnoreJQueryMapping);o.ShippingAddress(n);r&&(o.AppliedBillingAddress(o.AppliedShippingAddress()),o.BillingAddress(o.ShippingAddress()),o.appliedBillingAddress(!0),o.checkCurrencyDoesntMatchToBillingAddressCurrency());o.appliedShippingAddress(!0)},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},o.setBillingAddress=function(n,t){(t===void 0&&(t=!0),n.isValid(t))&&o.updateBillingAddress(n)},o.updateBillingAddress=function(n){var i=Constants.KnockoutMapping.AddressModelOsaMapping,t;$.extend(n,{"odata.type":Constants.Global.ODataOperation("Address")});t={BillingAddress:n?ko.mapping.toJS(n,i):null};$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},data:ko.mapping.toJSON(t),contentType:Constants.ContentType.OsaContentType,headers:Constants.JQuery.HeaderReturnContent,success:function(){o.BillingAddress(n);o.AppliedBillingAddress=ko.mapping.toJS(n,Constants.KnockoutMapping.IgnoreJQueryMapping);o.appliedBillingAddress(!0);o.checkCurrencyDoesntMatchToBillingAddressCurrency();o.getPaymentMethods()},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},o.applyAddresses=function(n,t,i){if(i===void 0&&(i=!1),n&&t){var r=$("div.wkis-place-order-content-left").first();if(Helpers.HtmlHelper.RemoveAlertMessages(r),i&&n.isValid(!0,o.IsGuestOrder())&&o.addressVerification(n))return;(o.HasOnlyDigitalOrPracticeToolProducts()||n.isValid(!0,o.IsGuestOrder()))&&t.isValid(!0,!1)&&o.updateAddresses(n,t)}},o.updateAddresses=function(n,t){var u=t.CountryOfResidence().CountryIso,s=Constants.KnockoutMapping.AddressModelOsaMapping,f=n&&n.isValid(!1)?o.mappAddress(n):null,e=t&&t.isValid(!1)?o.mappAddress(t):null,r={},i;f&&($.extend(r,{ShippingAddress:f}),r.ShippingAddress["odata.type"]=Constants.Global.ODataOperation("Address"));e&&($.extend(r,{BillingAddress:e}),r.BillingAddress["odata.type"]=Constants.Global.ODataOperation("Address"));i={"odata.type":Constants.Global.ODataOperation("Basket")};$.extend(i,ko.mapping.toJS(r,s));Helpers.HtmlHelper.ShowGlobalLoaderElement();$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:JSON.stringify(i),headers:Constants.JQuery.HeaderReturnContent,contentType:Constants.ContentType.OsaContentType,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(){o.getUpdatedOrderData();i.ShippingAddress&&o.showInfoMessageForPoBoxAddress(i.ShippingAddress.AddressLine,i.ShippingAddress.AddressLine2);o.ShippingAddress(n);o.BillingAddress(t);o.IsGuestOrder()&&(t.setDefaultCountryOfResidence(u),t.setDefaultCountryOfResidence(u),o.ShippingAddress().verifiedEmail=!0);o.AppliedShippingAddress=ko.mapping.toJS(n,Constants.KnockoutMapping.IgnoreJQueryMapping);o.AppliedBillingAddress=ko.mapping.toJS(t,Constants.KnockoutMapping.IgnoreJQueryMapping);o.appliedShippingAddress(!0);o.appliedBillingAddress(!0);var r=$("div.ko-validation-custom-message[for='address'][rule='shouldBeApplied']");r&&r.hide()},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},o.showInfoMessageForPoBoxAddress=function(n,t){if(n&&n.search(Constants.Commerce.POBoxAddressLineRegexp)>-1||t&&t.search(Constants.Commerce.POBoxAddressLineRegexp)>-1){var i=[];o.ShippingMethods().forEach(function(n){n.IsDeliveringToPOBox===!1&&i.push(n)});i.forEach(function(n){o.ShippingMethods.remove(n)})}},o.mappAddress=function(n){var t={};return $.extend(t,{AddressLine:n.AddressLine()},{AddressLine2:n.AddressLine2()},{Telephone:n.Telephone()},{ZipCode:n.ZipCode()},{CountryName:n.CountryName()},{CountryIso:n.CountryIso()},{CompanyName:n.CompanyName()},{City:n.City()},{FirstName:n.FirstName()},{LastName:n.LastName()},{StateIso:n.StateIso()},{StateName:n.StateName()},{Region:n.Region()},{Email:n.Email()}),t},o.checkCurrencyDoesntMatchToBillingAddressCurrency=function(){var t=o.BillingAddress(),n;t&&(n=t.CountryName(),n&&Services.AddressServices.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency(n))},o.applyAddress=function(t){var r=t==o.ShippingAddress(),i;t.isValid(!0,r)&&(i=n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.SelectedShippingAddress()&&n.AddressBookModel.AddressBook.SelectedShippingAddress()==t,t.IsBilling()||i||!t.CountryIso()||t.CountryIso().toLowerCase()!=Constants.CountriesIso.US.toLowerCase()||!o.addressVerification(t))&&o.setShippingAddress(t)},o.addressVerification=function(t){var f,i,r;if(t.CountryIso()&&t.CountryIso().toLowerCase()===Constants.CountriesIso.US.toLowerCase()&&(f=t.CountryOfResidence,i=Services.UserServices.GetSuggestedAddress(ko.mapping.toJS(t,Constants.KnockoutMapping.IgnoreJQueryMapping),!1),i)){r=void 0;r=i.addressModel?new n.AddressViewModel(t.$container,i.addressModel,!0):new n.AddressViewModel(t.$container,null,!1,i.message);o.IsGuestOrder()&&(r.CountryOfResidence=f);var u=$('[role="dialog"][data-modal="address-verification-apply"]'),e=$(".current-address",u)[0],s=$(".suggested-address",u)[0];return ko.cleanNode(e),ko.cleanNode(s),ko.applyBindings(t,e),ko.applyBindings(r,s),Helpers.HtmlHelper.OpenModalDialog(u.attr("data-modal")),!0}return!1},o.getShippingMethods=function(){$.post({url:"/api/commerce/basket/"+o.Id+"/getShippingMethods",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetShippingMethods"),BasketId:o.Id}}),async:!1,success:function(n){o.setShippingMethods(n)}})},o.setShippingMethods=function(n){if(n.length){var t=o.ShippingMethod(),i=o.sortShippingMethods(n);o.ShippingMethods.removeAll();i.forEach(function(n){o.ShippingMethods.push(n)});o.showInfoMessageForPoBoxAddress(o.BillingAddress().AddressLine(),o.BillingAddress().AddressLine2());o.ShippingMethod(t?t:i[0].MethodName)}},o.getPaymentMethods=function(){$.post({url:"/Ecommerce.svc/BasketAdministration_GetPaymentMethods/",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetPaymentMethods"),BasketId:o.Id}}),success:function(n){o.setPaymentMethods(n.value)}})},o.setPaymentMethods=function(n){var t=o.PaymentMethod(),i=[];n.forEach(function(n){i.push(n.MethodName)});o.PaymentMethods(i);t&&o.PaymentMethods().indexOf(o.PaymentMethod())!=-1?o.PaymentMethod(t):o.PaymentMethod(o.PaymentMethods()[0])},o.sameAddress=function(t,i){var r=$(i.currentTarget)[0];r.checked?o.BillingAddress(o.ShippingAddress()):o.BillingAddress(new n.AddressViewModel($('[data-address="billing"]',o.$container),null,!0))},o.createToken=function(n,t){var r,i;if(t&&t.preventDefault(),o.isValidOrderData())try{if(o.isKliOrder)o.submitOrder($("#hdncardpayments").attr("value"));else if(o.PaymentMethod()!=="Proforma"){if(o.paymentDataErrors().length>0){o.paymentDataErrors.showAllMessages(!0);return}r=o.ExpirationDateCC().split("/");r.length===2&&(i={},i.full_name=o.NameOnCC(),i.month=r[0].trim(),i.year="20"+r[1].trim(),i.email=o.AppliedBillingAddress.Email,i.address1=o.AppliedBillingAddress.AddressLine,i.address2=o.AppliedBillingAddress.AddressLine2,i.city=o.AppliedBillingAddress.City,i.state=o.AppliedBillingAddress.StateName.length>0?o.AppliedBillingAddress.StateName:o.AppliedBillingAddress.Region,i.zip=o.AppliedBillingAddress.ZipCode,i.country=o.AppliedBillingAddress.CountryName,i.phone_number=o.AppliedBillingAddress.Telephone,i.company=o.AppliedBillingAddress.CompanyName,Helpers.HtmlHelper.ShowGlobalLoaderElement(),Spreedly.tokenizeCreditCard(i))}else o.submitOrder()}catch(u){Helpers.HtmlHelper.HideGlobalLoaderElement()}},o.submitOrder=function(t){var r,h,i,s;if(t===void 0&&(t=""),!o.isValidOrderData()){Helpers.HtmlHelper.HideGlobalLoaderElement();return}if(o.CountryOfResidenceNotSet()&&o.updateUserProfile(),r=function(){var n=["$container","AddressBook"];o.HasOnlyDigitalOrPracticeToolProducts()&&n.push("ShippingAddress");n.push("VatNumber","AcceptAgreement","Order","IsGuestOrder","Password","ShippingMethods","PaymentMethods","Promotions","VatNumber","NameOnCC","ExpirationDateCC","IsValidVatNumber","CardNumber","CardType","SameAddresses","registrationDataErrors","paymentDataErrors","enableSubmit","isSameAddress","appliedShippingAddress","appliedBillingAddress","Discounted","HasOnlyDigitalOrPracticeToolProducts","PriceInfo","RecommendedProducts","BasketLines","RecommendedProducts","ShippingAddress","BillingAddress","TotalItemCount","calculatedSubTotalPrice","formatedCardNumber","IsValidCardNumber","Email","cartSummary","AppliedShippingAddress","AppliedBillingAddress","iOS","isKliOrder","UserConsentAgreement","displayPaymentFrame","GdprRulesApplicable","AccountCreateConsentAgreement","AccountUpdateConsentAgreement","registeredUserCountryCode","RegisteredUserCountryOfResidence","AvailableCountries","CountryOfResidenceNotSet","EUCountryOfResidenceSelected","IsShippingMethodLoaded","termsAndConditionsAvailable","RemoveEvent");var r={ignore:n},u=ko.mapping.toJS(o,r),i={"odata.type":Constants.Global.ODataOperation("Basket")};$.extend(i,u);$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:JSON.stringify(i),contentType:Constants.ContentType.OsaContentType,success:function(){var n={Id:o.Id,BillingAddress:null,ShippingAddress:null,OrderCurrency:null,OrderDate:o.OrderDate(),OrderStatus:o.OrderStatus(),PaymentMethod:o.PaymentMethod(),PriceInfo:null,PromoCode:null,Promotion:[],ShippingMethod:o.ShippingMethod()},i;$.extend(n,{"odata.type":Constants.Global.ODataOperation("Order"),BasketId:o.Id,VatNumber:o.VatNumber(),CreditCardToken:t?t:null,PaymentInfo:null},{"Promotion@odata.type":"Collection(ecommerce.Promotion)"});i=JSON.stringify(n);$.ajax("/Ecommerce.svc/Orders",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:i,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(n){!$.cookie(Constants.Global.UserTokenCookieKey)||o.saveAppliedAddresses();$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"});o.sendOrderSubmitTags(n);location.href=Helpers.UrlHelper.SetUrlParam($("#btnPlaceOrder").attr("href"),"orderNumber",n.Id)},error:function(n){var t=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(t);n.status==400?t.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"",window.payment400Error)):n.status==500&&t.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"",n.responseText?n.responseText:window.payment500Error));Helpers.HtmlHelper.HideGlobalLoaderElement()}})},error:function(){Services.UserServices.Logout();location.reload()}})},!o.IsGuestOrder()&&o.GdprRulesApplicable()){var u="",f="",e="";o.HasOnlyDigitalOrPracticeToolProducts()?(u=o.BillingAddress().FirstName(),f=o.BillingAddress().LastName(),e=o.BillingAddress().CompanyName()):(u=o.ShippingAddress().FirstName(),f=o.ShippingAddress().LastName(),e=o.ShippingAddress().CompanyName());h={elqFormName:"guestCheckoutForm",emailAddress:o.Email,firstName:u,lastName:f,company:e,productName:o.BasketLines()[0].ProductInfo().ProductName(),country:o.CountryOfResidenceNotSet()?o.RegisteredUserCountryOfResidence().CountryIso:o.registeredUserCountryCode,consentCheckbox:o.UserConsentAgreement(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:Helpers.CommerceHelper.stripHtml($("label[for='logged-in-user-consent-marketing']").html()),consentMessageId:$("label[for='logged-in-user-consent-marketing']").attr("message-id"),pageName:"Registered User Checkout (Marketing)",pageUrl:location.href};Helpers.CommerceHelper.SendUserConsentToEloqua(h)}if(o.IsGuestOrder()&&o.Password()&&o.ShippingAddress().Email.isValid()&&o.ShippingAddress().verifiedEmail&&o.Password.isValid()){if(o.registrationDataErrors().length>0){o.registrationDataErrors.showAllMessages(!0);return}i=new n.RegisterUserViewModel(null);i.firstName(o.ShippingAddress().FirstName());i.lastName(o.ShippingAddress().LastName());i.email(o.ShippingAddress().Email());i.password(o.Password());i.CountryOfResidence(o.ShippingAddress().CountryOfResidence());o.ShippingAddress().GdprActive()||o.AccountCreateConsentAgreement(!0);o.AccountCreateConsentAgreement()?(s=null,o.ShippingAddress().GdprActive()&&(s={elqFormName:"guestCheckoutForm",emailAddress:o.ShippingAddress().Email(),firstName:o.ShippingAddress().FirstName(),lastName:o.ShippingAddress().LastName(),company:o.ShippingAddress().CompanyName(),country:o.ShippingAddress().CountryOfResidence().CountryIso,consentCheckbox:o.AccountCreateConsentAgreement(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:Helpers.CommerceHelper.stripHtml($("label[for='user-consent-account']").html()),consentMessageId:$("label[for='user-consent-account']").attr("message-id"),pageName:"Guest User Checkout (Account Create)",pageUrl:location.href}),o.sendMarketingConsent(o.ShippingAddress().GdprActive()),i.registering(null,s,r)):(o.sendMarketingConsent(o.ShippingAddress().GdprActive()),r())}else o.IsGuestOrder()&&o.ShippingAddress().Email.isValid()&&o.ShippingAddress().verifiedEmail&&o.ShippingAddress().GdprActive()&&o.sendMarketingConsent(),r()},o.sendMarketingConsent=function(n){n===void 0&&(n=!0);var t={elqFormName:"guestCheckoutForm",emailAddress:o.ShippingAddress().Email(),firstName:o.ShippingAddress().FirstName(),lastName:o.ShippingAddress().LastName(),company:o.ShippingAddress().CompanyName(),productName:o.BasketLines()[0].ProductInfo().ProductName(),country:o.ShippingAddress().CountryOfResidence().CountryIso,consentCheckbox:n?o.UserConsentAgreement():"",dateOfConsent:n?(new Date).toLocaleString("en-US"):"",consentMessage:n?Helpers.CommerceHelper.stripHtml($("label[for='user-consent-marketing']").html()):"",consentMessageId:n?$("label[for='user-consent-marketing']").attr("message-id"):"",pageName:"Guest User Checkout (Marketing)",pageUrl:location.href};Helpers.CommerceHelper.SendUserConsentToEloqua(t)},o.isValidOrderData=function(n){var t,r,i,u;return n===void 0&&(n=!0),t=!0,o.CountryOfResidenceNotSet()&&(o.isValidCountryOfResidence()?o.EUCountryOfResidenceSelected()&&(r=$(".ko-validation-custom-message[for='logged-in-user-consent-account'][rule='required']"),o.AccountUpdateConsentAgreement()?r.hide():(r.show(),t=!1)):t=!1),o.isKliOrder||o.isValidPaymentInfo()||(t=!1),o.PaymentMethod()=="Credit Card"&&o.paymentDataErrors().length>0&&!o.isKliOrder&&(o.paymentDataErrors.showAllMessages(!0),t=!1),o.HasOnlyDigitalOrPracticeToolProducts()?(o.BillingAddress().isValid(n,o.IsGuestOrder())||(t=!1),i=$("div.ko-validation-custom-message[for='address'][rule='shouldBeApplied']"),o.appliedBillingAddress()?i.length&&i.hide():(i.length&&i.show(),t=!1)):(o.ShippingAddress().isValid(n,o.IsGuestOrder())||(t=!1),i=$("div.ko-validation-custom-message[for='address'][rule='shouldBeApplied']"),o.appliedShippingAddress()?i.length&&i.hide():(i.length&&i.show(),t=!1)),o.BillingAddress().isValid(n,!1)||(t=!1),o.IsValidVatNumber()||(t=!1),u=$("div.ko-validation-custom-message[for='placeorder'][rule='acceptAgreement']"),o.AcceptAgreement()?u.hide():(u.show(),t=!1),t},o.saveAppliedAddresses=function(){n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.Addresses().length||(o.ShippingAddress().isValid(!1)&&(o.ShippingAddress().IsBilling(!1),o.ShippingAddress().IsDefaultShipping(!0),o.ShippingAddress().SaveAsDefault=!0,o.ShippingAddress().saveAddress(null,null,null,!1)),o.BillingAddress().isValid(!1)&&(o.BillingAddress().IsBilling(!0),o.BillingAddress().IsDefaultBilling(!0),o.BillingAddress().SaveAsDefault=!0,o.BillingAddress().saveAddress()))},o._updateOrderInfo=function(i,r,u){var f,s,e;r===void 0&&(r=!0);u===void 0&&(u=!1);f=i;s=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(s);o.Promotions.removeAll();e=[];u&&f.Basket_orderLines&&o.setBasketLines(f.Basket_orderLines);f.Promotions&&(f.Promotion=f.Promotions);f.Promotion&&f.Promotion.forEach(function(n){var i=new t(n);e.push(i)});o.Promotions(e);o.PriceInfo(new n.OrderPriceInfoModel(f.PriceInfo));o.checkTaxError();r&&(o.ShippingMethod(f.ShippingMethod),o.getShippingMethods(),o.getPaymentMethods());o.isKliOrder&&o.generatePaymentFrameUrl(o.AppliedBillingAddress,f.PriceInfo)},o.checkTaxError=function(){if(o.PriceInfo()&&o.PriceInfo().TaxCalculationError()){var n=$("div.wkis-place-order-content-left").first();n.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Warning,"",$("ko-error-text[for='taxes'][rule='calculationError']").first().text()))}},o.loadSpreedlyFrame=function(){var t=$("#spreedly-env-key").attr("key"),n,i;if(t){n=".ko-validation-custom-message[for='CardNumber'][rule='required']";i="color: rgb(102, 102, 102); font-size: 16px; font-family: 'Fira Sans', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;";Spreedly.init(t,{numberEl:"spreedly-number",cvvEl:"spreedly-cvv"});Spreedly.on("ready",function(){Spreedly.setPlaceholder("number","XXXX XXXX XXXX XXXX");Spreedly.setFieldType("number","text");Spreedly.setNumberFormat("prettyFormat");Spreedly.setStyle("number",i)});Spreedly.on("paymentMethod",function(t,i){i.card_type!=="discover"?o.submitOrder(t):(o.showSpreedlyValidationError(),$("#spreedly-number").addClass("ko-error"),$(n).show())});Spreedly.on("validation",function(t){t.validNumber?($("#spreedly-number").removeClass("ko-error"),$(n).hide(),o.IsValidCardNumber(!0)):($("#spreedly-number").addClass("ko-error"),$(n).show(),o.IsValidCardNumber(!1))});Spreedly.on("errors",function(t){o.showSpreedlyValidationError();t&&t[0].attribute=="number"?($("#spreedly-number").addClass("ko-error"),$(n).show()):($("#spreedly-number").removeClass("ko-error"),$(n).hide())})}},o.showSpreedlyValidationError=function(){var n=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(n);n.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"",window.payment400Error));Helpers.HtmlHelper.HideGlobalLoaderElement()},o.canSendVatNumber=function(){for(var i,n=0,t=o.PaymentMethods();n<t.length;n++)if(i=t[n],i==="Proforma")return!0;return!1},o.isCreditCardSelected=function(){var n=o.PaymentMethod();return n==="Credit Card"?!0:!1},o.verifyVatNumber=function(n,t){var i=$(t.currentTarget),r=o.VatNumber(),u=function(){$("[for='vatNumber'][rule='valid']",o.$container).hide();i.removeClass("ko-valid");i.parent().removeClass("ko-valid");i.removeClass("ko-error");o.IsValidVatNumber(!0)},f=function(){$("[for='vatNumber'][rule='valid']",o.$container).hide();i.addClass("ko-valid");i.parent().addClass("ko-valid");i.removeClass("ko-error");o.IsValidVatNumber(!0)},e=function(){$("[for='vatNumber'][rule='valid']",o.$container).show();i.removeClass("ko-valid");i.parent().removeClass("ko-valid");i.addClass("ko-error");o.IsValidVatNumber(!1)};if(!r){u();return}$.ajax("/Ecommerce.svc/BasketAdministration_ValidateVatNumber",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidateVatNumber"),VatNumber:r}}),success:function(n){n.value===!0?f():e()},error:function(){u()}})},o.generatePaymentFrameUrl=function(n,t){var r=$("#payment-frame"),u=$("#payment-frame-loading-message"),f=$("#payment-frame-error-message"),i={};i.Name=n.FirstName+" "+n.LastName;i.Email=n.Email;i.Add1=n.AddressLine;i.Add2=n.AddressLine2;i.City=n.City;i.Region=n.Region;i.State=n.StateName;i.Postcode=n.ZipCode;i.Country=n.CountryIso;$.ajax({url:"/api/commerce/payment/getpaymenturl",cache:!1,type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify({session:r.attr("frameid"),isGuestOrder:o.IsGuestOrder(),userEmail:o.Email,billingAddressInfo:i,price:t,protocol:window.location.protocol,hostname:window.location.hostname}),beforeSend:function(){r.height(0);r.width(0);f.hide();u.show();Helpers.HtmlHelper.ShowPaymentFrameLoader(u)},success:function(n){r.height(422);r.width(r.parent().width());r.attr("src",n.toString())},error:function(){f.show()},complete:function(){Helpers.HtmlHelper.HidePaymentFrameLoader();u.hide()}})},o.showPaymentButton=function(){return o.isKliOrder?!0:!1},o.proceedWithPayment=function(){if(o.isValidOrderData()){var n=Services.UserServices.GetUserBasketViewModel(!1,!0);o.generatePaymentFrameUrl(o.AppliedBillingAddress,n.PriceInfo);$("#payment-frame").show();$("#btnPayment").hide()}},o.sortShippingMethods=function(n){return n.sort(function(n,t){return o.iOS?n.DefaultPriority>t.DefaultPriority?1:-1:n.DefaultPriority>t.DefaultPriority?-1:1})},o.prefillAddress=function(){n.AddressViewModel.Countries&&n.AddressViewModel.Countries.length?o.setCountries(n.AddressViewModel.Countries):$.ajax("/Ecommerce.svc/AddressAdministration_GetCountries",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetCountries")}}),success:function(t){n.AddressViewModel.Countries=t.Countries;o.setCountries(t.Countries)}})},o.setCountries=function(n){n&&n.length&&(o.AvailableCountries.removeAll(),o.sortedCountries(n).forEach(function(n){o.AvailableCountries.push(n)}))},o.changeRegisteredUserCountryOfResidenceHandler=function(){var n,t;o.setRegisteredUserCountryOfResidence(o.RegisteredUserCountryOfResidence());n=!1;o.RegisteredUserCountryOfResidence()&&(n=Helpers.CommerceHelper.CheckIfCountryWithinEU(o.RegisteredUserCountryOfResidence().CountryIso));o.GdprRulesApplicable(n);o.EUCountryOfResidenceSelected(n);t=$("select[name=countyOfResidenceSelect]",o.$container);t.removeClass("ko-error");o.isValidCountryOfResidence()},o.isValidCountryOfResidence=function(){if(o.CountryOfResidenceNotSet()){var n=$("div.ko-validation-custom-message[for='RegisteredUserCountryOfResidence'][rule='required']"),t=$("select[name=countyOfResidenceSelect]",o.$container);return o.RegisteredUserCountryOfResidence()?(t.removeClass("ko-error"),n.hide(),!0):(t.addClass("ko-error"),n.show(),o.isKliOrder&&($("#payment-frame").hide(),$("#btnPayment").show()),!1)}},o.updateUserProfile=function(){Services.UserServices.GetUserInfo().done(function(n){var t=n.value[0],u=Helpers.CommerceHelper.addCountryCode(o.RegisteredUserCountryOfResidence().CountryIso,""),i={FirstName:t.FirstName,LastName:t.LastName,PhoneNumber:u,CustomerType:t.CustomerType,ReferralMethod:t.ReferralMethod,CompanyName:null,Id:null,Password:null,Email:null},r;$.extend(i,{"odata.type":Constants.Global.ODataOperation("User")});o.EUCountryOfResidenceSelected()&&(r={elqFormName:"acctInfoForm",emailAddress:t.Email,country:o.RegisteredUserCountryOfResidence().CountryIso,consentCheckbox:o.AccountUpdateConsentAgreement(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:Helpers.CommerceHelper.stripHtml($("label[for='logged-in-user-consent-account']").html()),consentMessageId:$("label[for='logged-in-user-consent-account']").attr("message-id"),pageName:"Registered User Checkout (Account Update)",pageUrl:location.href},Helpers.CommerceHelper.SendUserConsentToEloqua(r));$.ajax("/Ecommerce.svc/Users('0')",{data:JSON.stringify(i),type:"put",contentType:"application/json;odata=minimalmetadata",success:function(){},error:function(){}})})},o.setRegisteredUserCountryOfResidence=function(n){return o.RegisteredUserCountryOfResidence(n),!0},o.sortedCountries=function(n){return n.sort(function(n,t){return Constants.AddressBook.PriorityCountries.indexOf(n.CountryIso)!=-1?-1:Constants.AddressBook.PriorityCountries.indexOf(t.CountryIso)!=-1?1:n.CountryName<t.CountryName?-1:1})},o.iOS=/iP(ad|hone|od).+Version\/[\d\.]+.*Safari/.test(window.navigator.userAgent),o.isKliOrder=window.isKliOrder==="True",o.termsAndConditionsAvailable=window.termsAndConditionsAvailable==="True",o.displayPaymentFrame=!1,o.OrderDate=ko.observable(u.OrderDate),o.ShippingMethod=ko.observable(u.ShippingMethod),o.PaymentMethod=ko.observable(u.PaymentMethod),o.PromoCode=ko.observable(),o.CardNumber=u.PaymentInfo&&u.PaymentInfo.CardNumber?ko.observable(u.PaymentInfo.CardNumber):ko.observable(""),o.CardType=u.PaymentInfo&&u.PaymentInfo.CardType?ko.observable(u.PaymentInfo.CardType.toUpperCase()):ko.observable(""),o.registeredUserCountryCode="",o.bindValidation(),o.formatedCardNumber=ko.computed(function(){return o.CardNumber()?o.CardNumber().replace(/X/g,"*").replace(/-/g," "):""}),o.cartSummary=ko.computed(function(){if(window.paymentItemsInYourCartLabel){var n=o.BasketLines().length;return Helpers.String.Format(window.paymentItemsInYourCartLabel,n,n>1?"s":"")}return""}),o.enableSubmit=ko.computed(function(){return o.AcceptAgreement()&&(o.appliedShippingAddress()||o.HasOnlyDigitalOrPracticeToolProducts())&&o.ShippingMethod()&&o.appliedBillingAddress()&&o.IsValidVatNumber()&&o.isValidPaymentInfo()}),o.IsGuestOrder=ko.computed(function(){return $.cookie(Constants.Global.UserTokenCookieKey)?!1:!0}),o.IsGuestOrder()||Services.UserServices.GetUserInfo().done(function(n){var i=n.value[0],t;o.registeredUserCountryCode=Helpers.CommerceHelper.GetCountryCodefromString(i.PhoneNumber);o.registeredUserCountryCode&&o.registeredUserCountryCode.length>0&&(t=Helpers.CommerceHelper.CheckIfCountryWithinEU(o.registeredUserCountryCode),o.GdprRulesApplicable(t));o.registeredUserCountryCode===""&&(o.prefillAddress(),o.CountryOfResidenceNotSet(!0))}),u.Promotions&&(u.Promotion=u.Promotions),u.Promotion&&(s=[],u.Promotion.forEach(function(n){var i=new t(n);s.push(i)}),o.Promotions=ko.observableArray(s)),o.AddressBook=ko.observable(e),o.SameAddresses=ko.computed(function(){return!(n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.Addresses().length>0)&&!o.HasOnlyDigitalOrPracticeToolProducts()&&(!o.BillingAddress()||o.ShippingAddress()&&o.BillingAddress().FirstName()===o.ShippingAddress().FirstName()&&o.BillingAddress().LastName()===o.ShippingAddress().LastName()&&o.BillingAddress().CountryIso()===o.ShippingAddress().CountryIso()&&o.BillingAddress().CountryName()===o.ShippingAddress().CountryName()&&o.BillingAddress().StateIso()===o.ShippingAddress().StateIso()&&o.BillingAddress().StateName()===o.ShippingAddress().StateName()&&o.BillingAddress().AddressLine()===o.ShippingAddress().AddressLine()&&o.BillingAddress().AddressLine2()===o.ShippingAddress().AddressLine2()&&o.BillingAddress().City()===o.ShippingAddress().City()&&o.BillingAddress().Region()===o.ShippingAddress().Region()&&o.BillingAddress().CompanyName()===o.ShippingAddress().CompanyName()&&o.BillingAddress().ZipCode()===o.ShippingAddress().ZipCode()&&o.BillingAddress().Telephone()===o.ShippingAddress().Telephone())}),o.ShippingAddress(o.initializeShippingAddress(u.ShippingAddress,f)),o.AppliedShippingAddress=ko.mapping.toJS(o.ShippingAddress,Constants.KnockoutMapping.IgnoreJQueryMapping),o.BillingAddress(o.initializeBillingAddress(u.BillingAddress,u.ShippingAddress,f)),o.AppliedBillingAddress=ko.mapping.toJS(o.BillingAddress,Constants.KnockoutMapping.IgnoreJQueryMapping),o.OrderStatus()==="Basket"&&(h=!u.ShippingAddress&&o.ShippingAddress().isValid(!1)?o.ShippingAddress():null,c=!u.BillingAddress&&o.BillingAddress().isValid(!1)?o.BillingAddress():null,h||c?o.updateAddresses(h,c):(o.getPaymentMethods(),o.ShippingMethods().length||o.getShippingMethods()),o.isKliOrder||(o.loadSpreedlyFrame(),o.checkTaxError())),o.IsGuestOrder()||o.AddressBook()&&o.AddressBook().Addresses().length!==0||$.get("/Ecommerce.svc/Users",function(n){if(n&&n.value&&!o.ShippingAddress().FirstName()&&!o.ShippingAddress().LastName()){var t=n.value[0];o.ShippingAddress().FirstName(t.FirstName);o.ShippingAddress().LastName(t.LastName);o.SameAddresses()&&(o.BillingAddress().FirstName(t.FirstName),o.BillingAddress().LastName(t.LastName))}}),$.cookie(Constants.Global.UserTokenCookieKey)&&Services.UserServices.GetUserInfo().done(function(n){var t=n.value[0];t&&t.Email&&(o.Email=t.Email)}),r.Order=o,o}return __extends(r,i),r.prototype.sendOrderSubmitTags=function(n){if(!n){var t="undefined email";this.Email?t=this.Email:n.ShippingAddress&&n.ShippingAddress.Email&&(t=n.ShippingAddress.Email);window.dataLayer&&(window.dataLayer.push({event:"orderSubmit",eventCategory:"Order",order:{id:n.Id,currency:n.PriceInfo.CurrencySymbol,totalPrice:n.PriceInfo.OrderTotal,shippingTotalPrice:n.PriceInfo.Shipping,discount:n.PriceInfo.Discount,taxPrice:n.PriceInfo.Tax,email:t,city:n.BillingAddress.City,state:n.BillingAddress.StateName,country:n.BillingAddress.CountryIso,zipCode:n.BillingAddress.ZipCode,promotionCode:n.Promotion&&n.Promotion.length?n.Promotion[0].PromotionCode:""}}),this.sendSubmittedProducts(ko.mapping.toJS(this.BasketLines),n.Id,t))}},r.prototype.sendSubmittedProducts=function(n,t,i){window.dataLayer&&n&&n.forEach(function(n){window.dataLayer.push({event:"orderLinesSubmit",eventCategory:"Order",orderLine:{id:n.Id,productName:n.ProductInfo.ProductName,price:n.PriceInfo.ActualItemPrice,email:i,quantity:n.Quantity,orderId:t,format:n.ProductInfo.FormatName,orderTotal:n.PriceInfo.ActualTotalPrice}})})},r}(n.BasketViewModel),t;n.OrderViewModel=i;t=function(){function t(t){var r=this;this.PromotionCode=ko.observable();this.PromotionId=ko.observable();this.PromotionTitle=ko.observable();this.PromotionDescription=ko.observable();this.Name=ko.observable();this.TotalDiscount=ko.observable(0);this.IsFreeShipping=ko.observable();this.displayPromoDetails=function(){var t=document.createElement("div"),n;t.innerHTML=r.PromotionDescription();n=$("#promo-description-popup-text")[0];n.innerHTML="";n.appendChild(t);$("#promo-title-popup-text").text(r.PromotionTitle())};t&&(this.PromotionCode=ko.observable(t.PromotionCode),this.PromotionTitle=ko.observable(t.PromotionTitle),this.PromotionDescription=ko.observable(t.PromotionDescription),this.PromotionId=ko.observable(t.PromotionId),this.Name=ko.observable(t.Name),this.IsFreeShipping=ko.observable(t.IsFreeShipping),this.TotalDiscount=ko.observable(t.TotalDiscount),this.formatedTotalDiscount=ko.computed(function(){return i.Order?"-("+i.Order.PriceInfo().CurrencySymbol()+Number(r.TotalDiscount()).toFixed(i.Order.PriceInfo().Precision())+")":n.BasketViewModel.Basket?"-("+n.BasketViewModel.Basket.PriceInfo().CurrencySymbol()+Number(r.TotalDiscount()).toFixed(n.BasketViewModel.Basket.PriceInfo().Precision())+")":void 0}),this.formatedDescription=ko.computed(function(){return r.PromotionCode()?r.PromotionCode()+" - "+r.Name():r.Name()}))}return t}();n.PromotionModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(){var t=this;this.RecommendedProducts=ko.observableArray();this.loadRecommendedProducts=function(i,r){i.length>0?(r||(r=4),$.ajax("/api/commerce/recommendation/getbyoffernumbers/"+i.join(",")+"/"+r,{type:"GET",success:function(i){for(var f=[],e,r=0,u=i;r<u.length;r++)e=u[r],f.push(new n.ProductInfo(e));t.RecommendedProducts(f)}})):t.RecommendedProducts([])};this.viewRecommendedProducts=function(n,i){var r=$(i.target),u=r.closest(".js-wkis-read-more").find(".js-wkis-read-more-content");u.css("height")!=="500px"?t.collapseViewMore():t.expandViewMore()};this.expandViewMore=function(){var t=$("#recommendations-view-more-action-button"),n=t.closest(".js-wkis-read-more").find(".js-wkis-read-more-content"),i;n.attr("data-expanded","true");n.css("height","100%");i=n.height();n.css("height","500px");n.stop().animate({height:i},400);t.text("View Less")};this.collapseViewMore=function(){var n=$("#recommendations-view-more-action-button"),t=n.closest(".js-wkis-read-more").find(".js-wkis-read-more-content");t.attr("data-expanded","false");t.stop().animate({height:"500px"},200);n.text("View More")}}return t}();n.RecommendedProductsViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(t){var i=this;this.viewModelContainer=t;this.CountryOfResidence=ko.observable(new Entities.AddressBookModels.CountryModel);this.AvailableCountries=ko.observableArray();this.GdprActive=ko.observable();this.UserConsentAgreement=ko.observable(!1);this.rememberMe=ko.observable(!0);this.verifiedEmail=!0;this.verifiedPassword=!0;this.inProgress=ko.observable(!1);this.IsEnableCountryOfResidenceValidation=ko.observable(!1);this.register=function(n,t){var r,f,u;if(t.preventDefault(),!i.inProgress()){if(n.errors().length>0||!i.verifiedEmail||!i.verifiedPassword){n.errors.showAllMessages(!0);n.verifiedEmail||n.errors().length>0?$("[for='email'][rule='exist']",n.$container).hide():$("[for='email'][rule='exist']",n.$container).show();return}if(i.GdprActive())if(r=$("div.ko-validation-custom-message[for='UserConsent'][rule='acceptUserConsentAgreement']"),i.UserConsentAgreement())r.hide();else{r.show();return}f=$("#RegisterUserForm").find("[name='formCategory']").val();u=null;i.GdprActive()&&(u={elqFormName:"acctRegForm",emailAddress:i.email(),firstName:i.firstName(),lastName:i.lastName(),country:i.CountryOfResidence().CountryIso,consentCheckbox:i.UserConsentAgreement(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:Helpers.CommerceHelper.stripHtml($("label[for='user-consent']").html()),consentMessageId:$("label[for='user-consent']").attr("message-id"),pageName:"Sign-In/Register",pageUrl:location.href,formCategory:f});i.checkCaptcha(function(){return n.registering(t,u)})}};this.checkCaptcha=function(n){var t=!1,r=$(".register-recaptcha .g-recaptcha-response").val(),u=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidateCaptcha"),Captcha:r}});i.inProgress(!0);$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ValidateCaptcha",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:u,success:function(n){t=n.value},error:function(){t=!1}})).done(function(){t?($("[for='captcha'][rule='required']",i.$container).hide(),$(".register-recaptcha").css({"border-color":"","border-style":"",width:"",height:""}),n()):(i.inProgress(!1),$("[for='captcha'][rule='required']",i.$container).show(),$(".register-recaptcha").css({"border-color":"#f00","border-style":"solid",width:"308px",height:"82px"}))})};this.registerPopup=function(n,t){var u,r;if(t.preventDefault(),!i.inProgress()){if(u=$(t.currentTarget),n.errors().length>0||!n.verifiedEmail||!n.verifiedPassword){n.errors.showAllMessages(!0);n.verifiedEmail||n.errors().length>0?$("[for='email'][rule='exist']",n.$container).hide():$("[for='email'][rule='exist']",n.$container).show();return}if(i.GdprActive())if(r=$("div.ko-validation-custom-message[for='UserConsent'][rule='acceptUserConsentAgreement']"),i.UserConsentAgreement())r.hide();else{r.show();return}var e=function(){Services.UserServices.ShowMyAccHeader();$(".wkis-terms-modal-info-email","[role='dialog'][data-modal='terms-conditions']").text(n.email());u.siblings('a.js-wkis-modal-open[data-modal="terms-conditions"]')[0].click();Helpers.HtmlHelper.HideGlobalLoaderElement()},o=$("#RegisterUserForm").find("[name='formCategory']").val,f=null;i.GdprActive()&&(f={elqFormName:"acctRegForm",emailAddress:i.email(),country:i.CountryOfResidence().CountryIso,consentCheckbox:i.UserConsentAgreement(),dateOfConsent:(new Date).toLocaleString("en-US"),consentMessage:Helpers.CommerceHelper.stripHtml($("label[for='user-consent']").html()),consentMessageId:$("label[for='user-consent']").attr("message-id"),pageName:"Sign-In/Register (PDP)",pageUrl:location.href,formCategory:o});i.checkCaptcha(function(){return n.registering(t,f,e)})}};this.registering=function(n,t,r){var f=Helpers.CommerceHelper.addCountryCode(i.CountryOfResidence().CountryIso,""),e=JSON.stringify({"odata.type":Constants.Global.ODataOperation("User"),FirstName:i.firstName(),LastName:i.lastName(),Email:i.email(),Password:i.password(),PhoneNumber:f}),u;t!=null&&Helpers.CommerceHelper.SendUserConsentToEloqua(t);u=function(t){var f,e,u;t.readyState==4&&(t.status==201?(i.sendRegistrationTag({firstName:i.firstName(),lastName:i.lastName(),email:i.email()}),f=function(t){$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(t),{path:"/"});var i=$.cookie(Constants.Global.BasketCookieKey),u=function(){r?r():location.href=$(n.currentTarget).attr("href")},f=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("AssignBasket"),BasketId:i}});Services.UserServices.AssignBasketToCurrentUser(f,!0).always(u)},e=JSON.stringify({request:{Email:i.email(),Password:i.password(),"odata.type":"ecommerce.Auth"}}),Services.UserServices.Authentication(e,!0).done(f),i.rememberMe()&&(u=new Date,u.setTime(u.getTime()+Constants.Global.RememberMeExpirationDays*864e5),$.cookie(Constants.Global.RememberMeCookieKey,i.email(),{path:"/",expires:u}))):Helpers.HtmlHelper.HideGlobalLoaderElement())};Services.UserServices.Register(e,!0,!0).always(function(n,t,r){if(i.inProgress(!1),t=="error"){$("[for='registerinmup']",n.$container).show();var f=$("#RegisterUserForm  [name='Email']",n.$container),e=$("#RegisterUserForm  [name='Password']",n.$container);f.removeClass("ko-valid");f.parent().removeClass("ko-valid");f.addClass("ko-error");e.removeClass("ko-valid");e.parent().removeClass("ko-valid");e.addClass("ko-error");grecaptcha.reset()}else u(r)})};this.verifyEmail=function(n,t){t.preventDefault();var r=$(t.currentTarget);if(!i.email.isValid()){$("[for='email'][rule='exist']",i.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");return}$("[for='registerinmup']",n.$container).hide();$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{Email:r.val(),"odata.type":Constants.Global.ODataOperation("EmailExists")}}),success:function(n){n.value===!1?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='email'][rule='exist']",i.$container).hide(),i.verifiedEmail=!0):(r.addClass("ko-error"),r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),$("[for='email'][rule='exist']",i.$container).show(),i.verifiedEmail=!1)}})};this.verifyPassword=function(n,t){t.preventDefault();var r=$(t.currentTarget);$("[for='password'][rule='weak']",i.$container).hide();i.password.isValid()?$.ajax("/api/commerce/customer/verifypassword/",{method:"POST",contentType:"application/json; charset=utf-8",data:i.password(),success:function(t){console.log(t);t?(r.removeClass("ko-error"),r.addClass("ko-valid"),r.parent().addClass("ko-valid"),$("[for='registerinmup']",n.$container).hide(),i.verifiedPassword=!0):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),r.addClass("ko-error"),$("[for='password'][rule='weak']",i.$container).show(),i.verifiedPassword=!1)},error:function(){r.removeClass("ko-error");r.addClass("ko-valid");r.parent().addClass("ko-valid");$("[for='registerinmup']",n.$container).hide()}}):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))};this.acceptUserConsent=function(){if(i.UserConsentAgreement(!i.UserConsentAgreement()),i.UserConsentAgreement()){var n=$("div.ko-validation-custom-message[for='UserConsent'][rule='acceptUserConsentAgreement']");n&&n.hide()}};this.prefillAddress=function(){n.AddressViewModel.Countries&&n.AddressViewModel.Countries.length?i.setCountries(n.AddressViewModel.Countries):$.ajax("/Ecommerce.svc/AddressAdministration_GetCountries",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetCountries")}}),success:function(t){n.AddressViewModel.Countries=t.Countries;n.AddressViewModel.DefaultCountryIso=t.DefaultCountryIso;i.setCountries(t.Countries,t.DefaultCountryIso)}})};this.setCountries=function(n,t){n&&n.length&&(i.AvailableCountries.removeAll(),i.sortedCountries(n).forEach(function(n){i.AvailableCountries.push(n);t&&i.AvailableCountries()&&i.AvailableCountries().length>0&&i.AvailableCountries().forEach(function(n){if(n.CountryIso==t){var r=n;i.setCountryOfResidence(r);i.changeCountryOfResidenceHandler();i.IsEnableCountryOfResidenceValidation(!0)}})}));i.CountryOfResidence.clearError()};this.changeCountryOfResidenceHandler=function(){i.setCountryOfResidence(i.CountryOfResidence());var n=!1;i.CountryOfResidence()&&(n=Helpers.CommerceHelper.CheckIfCountryWithinEU(i.CountryOfResidence().CountryIso));i.GdprActive(n)};this.setCountryOfResidence=function(n){return i.CountryOfResidence(n),!0};this.sortedCountries=function(n){return n.sort(function(n,t){return Constants.AddressBook.PriorityCountries.indexOf(n.CountryIso)!=-1?-1:Constants.AddressBook.PriorityCountries.indexOf(t.CountryIso)!=-1?1:n.CountryName<t.CountryName?-1:1})};t&&(this.$container=$(t));this.firstName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("firstName","required",this.$container)}});this.lastName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("lastName","required",this.$container)}});this.email=Helpers.KnockoutHelper.GetObservableByTypeRegistration("email",this.$container);this.password=Helpers.KnockoutHelper.GetObservableByTypeRegistration("password",this.$container);this.CountryOfResidence.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CountryOfResidence","required",this.$container),onlyIf:this.IsEnableCountryOfResidenceValidation}});this.errors=ko.validation.group(this,{deep:!0});$(t).keyup(function(n){n.which==13&&($(n.currentTarget).blur(),$("[type='submit']",t).click())});this.prefillAddress()}return t.prototype.sendRegistrationTag=function(n){window.dataLayer&&window.dataLayer.push({event:"registrationSuccess",eventCategory:"User",userInfo:{email:n.email,firstName:n.firstName,lastName:n.lastName}})},t}();n.RegisterUserViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n,t,i){var r=this;this.orderNumber=n;this.Email=ko.observable();this.isSendingEmail=ko.observable(!1);this.sendEmail=function(){if(r.emailErrors().length>0){r.emailErrors.showAllMessages(!0);return}if(!r.isSendingEmail()){r.isSendingEmail(!0);var n={request:{"odata.type":Constants.Global.ODataOperation("ResendEmailConfirmation"),Email:r.Email(),OrderNumber:r.orderNumber}};Services.OrderServices.ResendConfirmationEmail(n).done(function(){Helpers.HtmlHelper.OpenModalDialog("resend-confirmation-email-success")}).always(function(){r.isSendingEmail(!1)})}};this.emailInputKeyUp=function(n,t){t.keyCode===13&&r.sendEmail()};this.emailErrors=ko.validation.group([this.Email]);this.Email(t);this.Email.extend({email:{message:Helpers.KnockoutHelper.validationMessage("email","email",i)}}).extend({required:{message:Helpers.KnockoutHelper.validationMessage("email","required",i)}})}return n}();n.ResendEmailViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.viewModelContainer=n;this.resetToken=ko.observable();this.isValidToken=ko.observable();this.resetInProgress=ko.observable(!1);this.verifiedPassword=!0;this.showResetPopup=function(){$("#btnResetPassword").click()};this.resetPassword=function(n,i){if(t.resetToken()!==""&&t.resetToken()!==null){if(t.errors().length>0||!t.verifiedPassword){t.errors.showAllMessages(!0);return}var f=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ResetPassword"),Token:t.resetToken(),NewPassword:t.password()}}),r=!1,u="";t.resetInProgress(!0);$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ResetPassword",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){r=n.IsSuccessfullyReset;u=n.Email},error:function(){$("#btnResetPasswordFailed").click()}})).done(function(){r?$.ajax("/Ecommerce.svc/CustomerAdministration_Auth",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("Auth"),Email:u,Password:t.password()}}),success:function(n){$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(n),{path:"/"});var t=$(i.currentTarget).attr("href");location.href=t},error:function(){$("#btnResetPasswordFailed").click()}}):$("#btnResetPasswordFailed").click()})}};this.validateToken=function(){$.ajax("/Ecommerce.svc/CustomerAdministration_ValidatePasswordReset",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidatePasswordReset"),Token:t.resetToken()}}),success:function(n){n.value==!0?t.showResetPopup():t.showInvalidTokenPopup()},error:function(){return!1}})};this.verifyPassword=function(n,i){var r,u;i.preventDefault();r=$(i.currentTarget);t.password.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"));$("[for='password'][rule='weak']",t.$container).hide();$.ajax("/api/commerce/customer/verifypassword/",{method:"POST",contentType:"application/json; charset=utf-8",data:t.password(),success:function(n){console.log(n);n?t.verifiedPassword=!0:(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),r.addClass("ko-error"),$("[for='password'][rule='weak']",t.$container).show(),t.verifiedPassword=!1)}});u=$('input[name="ConfirmPassword"]',t.$container);t.confirmPassword.isValid()?(u.addClass("ko-valid"),u.parent().addClass("ko-valid")):(u.removeClass("ko-valid"),u.parent().removeClass("ko-valid"))};this.verifyConfirmationPassword=function(n,i){i.preventDefault();var r=$(i.currentTarget);t.confirmPassword.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))};this.$container=$(n);this.password=Helpers.KnockoutHelper.GetObservableByTypeRegistration("password",this.$container);this.confirmPassword=Helpers.KnockoutHelper.GetObservableByType("password",this.$container,"confirmPassword").extend({equal:{message:Helpers.KnockoutHelper.validationMessage("confirmPassword","equal",this.$container),params:this.password}});this.isValidToken=ko.observable();this.errors=ko.validation.group(this,{deep:!0})}return n.prototype.showInvalidTokenPopup=function(){$("#btnInvalidtoken").click()},n}();n.ResetPasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function n(n){this.IsChecked=ko.observable(!1);this.Variant=new t.ProductInfo(n)}return n}(),r=function(){function t(){var t=this;this.Variants=ko.observableArray();this.loadSeriesVariants=function(n){$.ajax("/api/commerce/product/getSeriesVariants/"+n,{type:"GET",success:function(n){for(var u=[],e,r=0,f=n;r<f.length;r++)e=f[r],u.push(new i(e));t.Variants(u);u.length<=4?t.expandViewMore():t.collapseViewMore()},error:function(){t.Variants([])}})};this.expandViewMore=function(){var t=$("#volumes-view-more-action-button"),n=t.closest(".js-wkis-read-more").find(".js-wkis-read-more-content"),i;n.attr("data-expanded","true");n.css("height","100%");i=n.height();n.css("height","500px");n.stop().animate({height:i},400);t.text("View Less")};this.collapseViewMore=function(){var n=$("#volumes-view-more-action-button"),t=n.closest(".js-wkis-read-more").find(".js-wkis-read-more-content");t.attr("data-expanded","false");t.stop().animate({height:"500px"},200);n.text("View More")};this.viewMoreClick=function(n,i){var r=$(i.target),u=r.closest(".js-wkis-read-more").find(".js-wkis-read-more-content");u.css("height")!=="500px"?t.collapseViewMore():t.expandViewMore()};this.canAddToCart=function(){for(var r,n=0,i=t.Variants();n<i.length;n++)if(r=i[n],r.IsChecked())return!0;return!1};this.addToCart=function(){for(var i=[],f,o,r=0,u=t.Variants();r<u.length;r++)f=u[r],f.IsChecked()&&i.push(f);if(i.length!==0){var l=$.cookie(Constants.Global.BasketCookieKey),e=0,s=0,h=!1,c=null;Helpers.HtmlHelper.ShowGlobalLoaderElement();o=function(){var t=i[e],r=new Entities.OrderModels.OrderLineModel;r.Id=t.Variant.Id();r.Quantity=1;$.ajax("/api/commerce/basket/"+l+"/orderLine",{type:"POST",data:r,success:function(){t.IsChecked(!1);c=t.Variant.BackofficeProductId();s++},error:function(n){n.status===409&&(h=!0)},complete:function(){e++;e===i.length?(Helpers.HtmlHelper.HideGlobalLoaderElement(),h?Helpers.HtmlHelper.OpenModalDialog("added-cart-conflict"):s===i.length&&($("#volumes-added-cart-popup-button")[0].click(),n.Initializer.CartPageInitializer.CallInitialize($("#added-cart-popup")[0],c))):o()}})};o()}}}return t}();t.SeriesProductVariantsViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){var t=this,i,r,u;this.loadCounter=0;this.IsLoading=ko.observable(!1);this.SearchString=ko.observable();this.CurrentSearchString=ko.observable();this.Rows=ko.observableArray();this.IsGridView=ko.observable(!0);this.IsClearAllFiltersVisible=ko.observable(!1);this.TotalRowsCount=ko.observable(-1);this.ResultsPerPage=ko.observable();this.ResultsPerPageList=ko.observableArray();this.SortBy=ko.observable();this.SortByList=ko.observableArray();this.Page=ko.observable(1);this.PagesCount=ko.observable(0);this.SelectedMarketSegmentFacet=ko.observable();this.FormatFacets=ko.observableArray();this.NoticeBannerIndex=ko.observable(-1);this.performSearch=function(i){var u=++t.loadCounter,r;i==null&&(i=1);r={IndexType:"product,productPlatform",QueryStr:t.SearchString(),PageSize:t.ResultsPerPage().Value,Page:i,SortBy:t.SortBy().Value,Facets:t.getFacets()};r.ReturnFacets=[n.Models.StorePage.FacetNames.MarketSegment,n.Models.StorePage.FacetNames.PracticeArea,n.Models.StorePage.FacetNames.Format,n.Models.StorePage.FacetNames.Industry,n.Models.StorePage.FacetNames.Role];u!==1&&(t.updateUrlQueryString(i),t.IsClearAllFiltersVisible(r.Facets.length>0||r.QueryStr!=null&&r.QueryStr.length>0));t.IsLoading(!0);$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(r),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){if(u===1&&(t.initFormatFacets(n.Facets),t.updateFacetsHitCount(n.Facets,!0)),u===1&&location.search)t.loadFromSearchUrlPart();else{if(u!==t.loadCounter)return;u!==1&&t.updateFacetsHitCount(n.Facets,!1);t.IsLoading(!1);t.CurrentSearchString(r.QueryStr);t.Rows(n.Rows);t.generateRandomNoticeBannerIndex();t.TotalRowsCount(n.TotalRowsCount);t.Page(n.Page);t.PagesCount(n.PagesCount);t.updateStorePageHistory()}t.displayBanners(r)}})};this.updateStorePageHistory=function(){$.cookie(Constants.Global.StorePageCookieKey,location.pathname+location.search,{path:"/"})};this.loadFromSearchUrlPart=function(){var i=t.getQueryParameters(),v=i.query,r,f,d,e,y,o,u,s,h,g,c,p,w,l,nt,a,b,k;if(v&&v.length===1&&t.SearchString(v[0]),r=function(n,r){var f=i[n],e,c,u,o,l,w,a,s,v,y,h,p,b;if(f&&f.length!==0)for(e=0,c=r();e<c.length;e++){for(u=c[e],o=0,l=f;o<l.length;o++)if(w=l[o],u.Value()===w){u.IsChecked(!0);t.updateFacetParentAndChildren(u);break}if(a=!1,!u.IsChecked())for(s=0,v=u.Children();s<v.length;s++)for(y=v[s],h=0,p=f;h<p.length;h++)if(b=p[h],y.Value()===b){y.IsChecked(!0);a=!0;break}a&&$("#"+n+"-filter-accordion-trigger-"+r().indexOf(u)).click()}},f=i[n.Models.StorePage.FacetNames.MarketSegment],f&&f.length>=1)for(d=f[0],e=0,y=t.MarketSegmentFacets();e<y.length;e++)if(o=y[e],o.Value()===d){t.SelectedMarketSegmentFacet(o);r(n.Models.StorePage.FacetNames.PracticeArea,o.Children);break}if(r(n.Models.StorePage.FacetNames.Format,t.FormatFacets),r(n.Models.StorePage.FacetNames.Industry,t.IndustryFacets),r(n.Models.StorePage.FacetNames.Role,t.RoleFacets),u=1,s=i.page,s&&s.length===1&&(u=parseInt(s[0],10),isNaN(u)&&(u=1)),h=i.resultsPerPage,h&&h.length===1)for(g=h[0],c=0,p=t.ResultsPerPageList();c<p.length;c++)if(w=p[c],w.Value.toString()===g){t.ResultsPerPage(w);break}if(l=i.sortBy,l&&l.length===1)for(nt=l[0],a=0,b=t.SortByList();a<b.length;a++)if(k=b[a],k.Value===nt){t.SortBy(k);break}t.performSearch(u)};this.updateUrlQueryString=function(i){var u=t.getQueryParameters(),r=function(n,t){u[n]=t?t:""},e=function(n,t){u[n]=t?t.map(function(n){return n}).join(","):""},f,o,s;r("query",t.SearchString());f=function(n,t){for(var i=[],u,f,s,h,r=0,o=t();r<o.length;r++)for(u=o[r],u.IsChecked()&&i.push(u.Value()),f=0,s=u.Children();f<s.length;f++)h=s[f],h.IsChecked()&&i.push(h.Value());i.length>0?e(n,i):e(n,null)};o=Helpers.UrlHelper.GetUrlParam(window.location.href,"cm_mmc");o!=null?e("cm_mmc",[o]):e("cm_mmc",null);t.SelectedMarketSegmentFacet()?(r(n.Models.StorePage.FacetNames.MarketSegment,t.SelectedMarketSegmentFacet().Value()),f(n.Models.StorePage.FacetNames.PracticeArea,t.SelectedMarketSegmentFacet().Children)):(r(n.Models.StorePage.FacetNames.MarketSegment,null),r(n.Models.StorePage.FacetNames.PracticeArea,null));f(n.Models.StorePage.FacetNames.Format,t.FormatFacets);f(n.Models.StorePage.FacetNames.Industry,t.IndustryFacets);f(n.Models.StorePage.FacetNames.Role,t.RoleFacets);i>1?r("page",i.toString()):r("page","");t.ResultsPerPageList().indexOf(t.ResultsPerPage())>0?r("resultsPerPage",t.ResultsPerPage().Value.toString()):r("resultsPerPage","");t.SortByList().indexOf(t.SortBy())>0?r("sortBy",t.SortBy().Value):r("sortBy","");s=t.getUpdatedQueryString(u);history.replaceState({},null,location.pathname+s+location.hash)};this.getQueryParameters=function(){var n={},t=function(){for(var r=/\+/g,u=/([^&=]+)=?([^&]*)/g,i=function(n){return decodeURIComponent(n.replace(r," "))},t;;){if(t=u.exec(location.search.substring(1)),!t)break;n[i(t[1])]=t[2].split("%2C").map(function(n){return i(n)})}};return t(),n};this.getUpdatedQueryString=function(n){var r=[],t,i;for(t in n)n.hasOwnProperty(t)&&n[t]!==""&&r.push(encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return(i=r.join("&"),i)?"?"+i:""};this.generateRandomNoticeBannerIndex=function(){var n=Math.ceil(t.Rows().length/3),i;if(n<=2){t.NoticeBannerIndex(-1);return}i=Math.floor(Math.random()*(n-2)+2);t.NoticeBannerIndex(i*3)};this.gridViewClick=function(){t.IsGridView(!0)};this.listViewClick=function(){t.IsGridView(!1)};this.searchInputKeyUp=function(n,i){i.keyCode===13&&t.performSearch()};this.performSearchClick=function(){return t.performSearch(),!0};this.incrementPageClick=function(){var n=t.Page()+1;n<=t.PagesCount()&&(t.performSearch(n),t.scrollToTop())};this.decrementPageClick=function(){var n=t.Page()-1;n>0&&(t.performSearch(n),t.scrollToTop())};this.scrollToTop=function(){var n=$(".wkis-store-content").offset();$("html, body").animate({scrollTop:n.top})};this.getFacets=function(){var u=[],i=function(t,i){var r=new n.Models.StorePage.FacetArg,f;r.Name=t;f=function(n){for(var i,t=0,u=n();t<u.length;t++)i=u[t],i.IsChecked()&&r.Labels.push(i.Value()),f(i.Children)};f(i);r.Labels.length>0&&u.push(r)},f=t.SelectedMarketSegmentFacet(),r;return f!=null&&(r=new n.Models.StorePage.FacetArg,r.Name=n.Models.StorePage.FacetNames.MarketSegment,r.Labels.push(f.Value()),u.push(r),i(n.Models.StorePage.FacetNames.PracticeArea,f.Children)),i(n.Models.StorePage.FacetNames.Format,t.FormatFacets),i(n.Models.StorePage.FacetNames.Industry,t.IndustryFacets),i(n.Models.StorePage.FacetNames.Role,t.RoleFacets),u};this.initFormatFacets=function(i){for(var s,h,e,c,r,u,f=0,o=i;f<o.length;f++)if(s=o[f],s.Name===n.Models.StorePage.FacetNames.Format){for(h=[],e=0,c=s.Items;e<c.length;e++)(r=c[e],r.HitCount!==0)&&(u=new n.Models.StorePage.FacetModel,u.Text(r.Label),u.Value(r.Label),u.HitCount(r.HitCount),h.push(u));t.FormatFacets(h);break}};this.updateFacetsHitCount=function(i,r){for(var p=function(n){for(var u={},r,t=0,i=n;t<i.length;t++)r=i[t],u[r.Label]=r.HitCount;return u},f=function(n,t){for(var o=[],i,e,u=0,f=n();u<f.length;u++)i=f[u],e=t[i.Value()],e?(i.HitCount(e),o.push(i)):i.HitCount(0);r&&n(o)},c,u,o,l,a,s,v,y,e=0,h=i;e<h.length;e++){c=h[e];u=p(c.Items);switch(c.Name){case n.Models.StorePage.FacetNames.MarketSegment:f(t.MarketSegmentFacets,u);break;case n.Models.StorePage.FacetNames.PracticeArea:for(o=0,l=t.MarketSegmentFacets();o<l.length;o++)for(a=l[o],f(a.Children,u),s=0,v=a.Children();s<v.length;s++)y=v[s],f(y.Children,u);break;case n.Models.StorePage.FacetNames.Format:f(t.FormatFacets,u);break;case n.Models.StorePage.FacetNames.Industry:f(t.IndustryFacets,u);break;case n.Models.StorePage.FacetNames.Role:f(t.RoleFacets,u)}}};this.withHits=function(n){for(var u=[],t,r,e,o,i=0,f=n;i<f.length;i++)if(t=f[i],t.HitCount())u.push(t);else for(r=0,e=t.Children();r<e.length;r++)if(o=e[r],o.HitCount()){u.push(t);break}return u};this.clearFacets=function(n){for(var r=function(n){var t,i,u;for(n.IsChecked(!1),t=0,i=n.Children();t<i.length;t++)u=i[t],r(u)},u,t=0,i=n();t<i.length;t++)u=i[t],r(u)};this.marketSegmentFacetClick=function(n){t.clearFacets(t.MarketSegmentFacets);t.SelectedMarketSegmentFacet(n);t.performSearch()};this.marketSegmentFacetCloseClick=function(){t.clearFacets(t.MarketSegmentFacets);t.SelectedMarketSegmentFacet(null);t.performSearch()};this.accordionTriggerClick=function(n,t){$(t.target).toggleClass("-open");$(t.target).next(".js-wkis-filter-accordion-content").slideToggle(300).toggleClass("-open")};this.facetClick=function(n){return t.updateFacetParentAndChildren(n),t.performSearch(),!0};this.updateFacetParentAndChildren=function(n){var t=function(n){for(var f=n.IsChecked(),u,i=0,r=n.Children();i<r.length;i++)u=r[i],u.IsChecked(f),t(u)};t(n)};this.clearAllFiltersClick=function(){t.clearFacets(t.MarketSegmentFacets);t.clearFacets(t.FormatFacets);t.clearFacets(t.IndustryFacets);t.clearFacets(t.RoleFacets);t.SelectedMarketSegmentFacet(null);t.SearchString(null);t.performSearch()};this.displayBanners=function(n){var t=$(".wkis-banner-bar-container");t.children().remove();$.ajax({type:"POST",url:"/umbraco/surface/BannerContent/GetContent",contentType:"application/json",dataType:"html",data:JSON.stringify(n),success:function(n){t.append(n)},error:function(){}})};i=function(){t.ResultsPerPageList([{Text:"20",Value:20},{Text:"50",Value:50},{Text:"80",Value:80},{Text:"110",Value:110}]);t.ResultsPerPage(t.ResultsPerPageList()[0])};i();r=function(){t.SortByList([{Text:$("#storeSortByAZDictText").text(),Value:"title-az"},{Text:$("#storeSortByZADictText").text(),Value:"title-za"}])};r();this.SortBy(this.SortByList()[0]);u=function(){var i=function(n){var t,r,u;for(n.IsChecked=ko.observable(!1),n.HitCount=ko.observable(0),t=0,r=n.Children();t<r.length;t++)u=r[t],u.Parent=n,i(u)},e=window.InitialPageJsonModel,r,o,u,s,f,h,n;for(t.MarketSegmentFacets=ko.mapping.fromJS(e.MarketSegmentFacets),r=0,o=t.MarketSegmentFacets();r<o.length;r++)n=o[r],i(n);for(t.IndustryFacets=ko.mapping.fromJS(e.IndustryFacets),u=0,s=t.IndustryFacets();u<s.length;u++)n=s[u],i(n);for(t.RoleFacets=ko.mapping.fromJS(e.RoleFacets),f=0,h=t.RoleFacets();f<h.length;f++)n=h[f],i(n)};u();this.performSearch()}return t}();t.StorePageViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var h=function(){function n(){}return n.Space=" ",n.BasketCookieKey="basketid",n.StorePageCookieKey="storePage",n.RememberMeCookieKey="auth",n.UserTokenCookieKey="userToken",n.AlertMessageClass="js-wkis-alert-message",n.RememberMeExpirationDays=90,n.BasketIdExpirationCookieDays=90,n.UserTokenExpirationMinutes=20,n.ODataElement="odata.type",n.ODataOperation=function(n){return"ecommerce."+n},n}(),t,i,r,u,f,e,o,s;n.Global=h;t=function(){function n(){}return n.OsaContentType="application/json;odata=minimalmetadata",n.CommonContentType="application/x-www-form-urlencoded",n}();n.ContentType=t;i=function(){function n(){}return n.Success="success",n.Failed="failed",n.Info="info",n.Warning="warning",n}();n.AlertMessageTypes=i;r=function(){function n(){}return n.US="US",n.CA="CA",n}();n.CountriesIso=r;u=function(){function t(){}return t.PriorityCountries=[n.CountriesIso.US],t.CitiesWithoutRegionValidation=["london"],t}();n.AddressBook=u;f=function(){function n(){}return n.ApplyingPromoCodeKey="applyingPromoCode",n.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey="checkGeoIpCurrencyDoesntMatchToBillingAddressCurrency",n.POBoxAddressLineRegexp=/(?:P(?:ost(?:al)?)?[\.\-\s]*(?:(?:O(?:ffice)?[\.\-\s]*)?B(?:ox|in|\b|\d)|o(?:ffice|\b)(?:[-\s]*\d)|code)|box[-\s\b]*\d)/i,n.CurrentCurrencyByIpAddress="currentCurrencyByIpAddress",n}();n.Commerce=f;e=function(){function n(){}return n.Sellable=0,n.NonSellable=1,n.Digital=2,n.PracticeTool=3,n}();n.VariantType=e;o=function(){function n(){}return n.HeaderReturnContent={Prefer:"return-content"},n}();n.JQuery=o;s=function(){function n(){}return n.AddressModelOsaMapping={ignore:["$container","AvailableCountries","AvailableStates","State","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","verifiedEmail","SaveAsDefault","CountryOfResidence","GdprActive","CustomerName","IsDefaultBilling","IsDefaultShipping","Selected","AddressId","regionVisibility","IsEnableCountryOfResidenceValidation"]},n.IgnoreJQueryMapping={ignore:["$container","alsoIgnoreThis"]},n}();n.KnockoutMapping=s}(Constants||(Constants={})),function(n){var t;(function(n){var t=function(){function n(){}return n}();n.AccountInfoModel=t})(t=n.AccountInfoModels||(n.AccountInfoModels={}))}(Entities||(Entities={})),function(n){var t;(function(n){var f=function(){function n(){}return n}(),t,i,r,u;n.CustomerAddressBookModel=f;t=function(){function n(){}return n}();n.AddressBookModel=t;i=function(){function n(){}return n}();n.AddressModel=i;r=function(){function n(){}return n}();n.CountryModel=r;u=function(){function n(n,t){this.StateName=n?n:"";this.StateIso=t?t:""}return n}();n.StateModel=u})(t=n.AddressBookModels||(n.AddressBookModels={}))}(Entities||(Entities={})),function(n){var t;(function(n){var t=function(){function n(){}return n}();n.Warning=t})(t=n.Common||(n.Common={}))}(Entities||(Entities={})),function(n){var t;(function(n){var c=function(){function n(){}return n}(),t,i,r,u,f,e,o,s,h;n.OrderModel=c;t=function(){function n(){}return n}();n.OrderLineModel=t;i=function(){function n(){}return n}();n.ShippingLocation=i;r=function(){function n(){}return n}();n.ProductInfo=r;u=function(){function n(){}return n}();n.PriceInfo=u;f=function(){function n(){}return n}();n.ProductProgramModel=f;e=function(){function n(){}return n}();n.OrderPriceInfo=e;o=function(){function n(){}return n}();n.PromotionModel=o;s=function(){function n(){}return n}();n.ShippingMethod=s;h=function(){function n(){}return n}();n.PaymentInfo=h})(t=n.OrderModels||(n.OrderModels={}))}(Entities||(Entities={})),function(n){var t=function(){function n(){}return n}();n.Token=t}(Entities||(Entities={})),function(n){var t=function(){function n(){}return n.CheckIfCountryWithinEU=function(n){for(var i=["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","GB"],t=0;t<i.length;t++)if(i[t]===n)return!0;return!1},n.addCountryCode=function(n,t){return t+"[countryCode-"+n+"]"},n.GetPhoneNumberFromString=function(n){var t=n.indexOf("[countryCode-");return n.substr(t)},n.GetCountryCodefromString=function(n){var i=new RegExp(/\[countryCode\-([A-Z]+)\]/),t=n.match(i);return t?t[1]:""},n.SendUserConsentToEloqua=function(n){return this.submitEloquaForm("https://s1654.t.eloqua.com/e/f2",n,null),!0},n.submitEloquaForm=function(n,t,i){var r,e,f;i=i||"post";$.extend(t,{elqSiteId:"1654"});var u=document.createElement("iframe"),o=Math.random().toString(36).slice(-5),s="Eloqua-iFrame"+o;document.body.appendChild(u);u.style.display="none";u.contentWindow.name=s;r=document.createElement("form");r.target=s;r.setAttribute("id","eloquaDataForm"+o);r.setAttribute("method",i);r.setAttribute("action",n);for(e in t)t.hasOwnProperty(e)&&(f=document.createElement("input"),f.setAttribute("type","hidden"),f.setAttribute("name",e),f.setAttribute("value",t[e]),r.appendChild(f));u.appendChild(r);r.submit();u.removeChild(r)},n.stripHtml=function(n){var t=document.createElement("div");return t.innerHTML=n,t.textContent||t.innerText||""},n.setCountriesList=function(t,i,r){return i&&i.length&&(t.removeAll(),n.sortedCountries(i).forEach(function(n){t.push(n)}),r&&t()&&t().length>0&&t().forEach(function(n){if(n.CountryIso==r)return n})),new Entities.AddressBookModels.CountryModel},n.sortedCountries=function(n){return n.sort(function(n,t){return Constants.AddressBook.PriorityCountries.indexOf(n.CountryIso)!=-1?-1:Constants.AddressBook.PriorityCountries.indexOf(t.CountryIso)!=-1?1:n.CountryName<t.CountryName?-1:1})},n}();n.CommerceHelper=t}(Helpers||(Helpers={})),function(n){var i=function(){function n(){}return n.TrimArray=function(n){for(var t=0;t<n.length;t++)n[t]=n[t].trim()},n.GetUniqueArray=function(n){return n.filter(function(n,t,i){return i.indexOf(n)===t})},n.GetUTCDate=function(n){var t=/\/Date\((\d+)\)\//;return n.search(t)!=-1?parseInt(n.replace(t,"$1")):Date.parse(n)},n}(),t;n.CommonHelper=i;t=function(){function n(){}return n.Format=function(t){for(var u=[],r,i=1;i<arguments.length;i++)u[i-1]=arguments[i];try{return r=u,t.replace(/{(\d+)}/g,function(n,t){return typeof r[t]!="undefined"?r[t]:n})}catch(f){return n.Empty}},n.Empty="",n}();n.String=t}(Helpers||(Helpers={})),function(n){var t=function(){function n(){}return n.GetAlertMessageElement=function(t,i,r,u){var f=document.createElement("div"),e;return f.classList.add(Constants.Global.AlertMessageClass),f.setAttribute("data-type",t),e='<div class="js-wkis-alert-message-content">\n                   <div class="wkis-eyebrow">'+i+'<\/div>\n                   <div class="js-wkis-alert-message-text">'+r+'<\/div>\n                <\/div>\n                <a class="js-wkis-alert-message-close close-alert">Close<\/a>',f.innerHTML=e,$(".close-alert",f).click(function(t){t.preventDefault();$(t.currentTarget).parent("."+Constants.Global.AlertMessageClass).remove();n.CloseGlobalAlertMessage()}),u&&(u.complete||(u.complete=function(){$(f).remove()}),$(f).fadeOut(u.duration,u.complete)),f},n.PreventJumpingOnTargetElement=function(n,t){$("a[href^='#']",n).on("click",function(n){n.preventDefault();var i=$(document).scrollTop();history.pushState({},"",this.href);location.href=this.href;$(document).scrollTop(i);t&&t()})},n.RemoveAlertMessages=function(n,t){var i=t?"."+Constants.Global.AlertMessageClass+"[data-type="+t+"]":"."+Constants.Global.AlertMessageClass;$(i,n).remove()},n.GetLoaderElement=function(n){var t,i,u,r;for(n===void 0&&(n=24),t=document.createElement("div"),t.classList.add("js-wkis-preloader"),t.style.background="none",t.style.opacity="1",t.style.transition="none",t.style["box-shadow"]="none",t.style.visibility="visible",i=document.createElement("div"),i.classList.add(".wkis-preloader-cube"),i.style.width=n+"px",i.style.height=n+"px",u=0;u<9;u++)r=document.createElement("div"),r.classList.add("wkis-preloader-cube-part"),r.setAttribute("data-cube",u.toString()),r.style.width=(n/3).toFixed().toString(),r.style.height=(n/3).toFixed().toString(),i.appendChild(r);return t.appendChild(i),t},n.ShowGlobalLoaderElement=function(){$("html").attr("data-loading","true");$(".js-wkis-preloader").show()},n.HideGlobalLoaderElement=function(){$("html").attr("data-loading","false");$(".js-wkis-preloader").hide()},n.ShowMiniLoaderElement=function(n,t,i){t===void 0&&(t=0);i===void 0&&(i=0);var r=$("#miniLoader");r.insertAfter($(n));r.css("left",t);r.css("top",i);r.show()},n.HideMinilLoaderElement=function(){$("#miniLoader").hide()},n.ShowPaymentFrameLoader=function(n,t,i){t===void 0&&(t=0);i===void 0&&(i=0);var r=$("#payment-frame-loader");r.insertAfter($(n));r.css("left",n.width/2);r.css("top",n.height+25);r.show()},n.HidePaymentFrameLoader=function(){$("#payment-frame-loader").hide()},n.CloseModalDialog=function(){var n=$(".js-wkis-modal-overlay").first();n.length&&n[0].click()},n.OpenModalDialog=function(n){var t=$(".js-wkis-modal-open[data-modal="+n+"]");t.length&&t[0].click()},n.ShowHelpInfo=function(){var n=$(".wkis-account-help");n.length&&n.show()},n.HideHelpInfo=function(){var n=$(".wkis-account-help");n.length&&n.hide()},n.SetGlobalAlertMessage=function(n){var t=$(".js-wkis-dialog-box");t.length&&(t.html(""),t.append(n))},n.ShowGlobalAlertMessage=function(){$("html").addClass("-dialog-open")},n.CloseGlobalAlertMessage=function(){$("html").removeClass("-dialog-open")},n}();n.HtmlHelper=t}(Helpers||(Helpers={})),function(n){var t=function(){function t(){}return t.validationMessage=function(n,t,i){var r=$("ko-error-text[for="+n+"][rule="+t+"]",i).first();return r&&r.text().length?r.text():this.DefaultErrorMessage},t.GetObservableByType=function(t,i,r){var u=r?r:t;switch(t){case"password":return ko.observable().extend({required:{message:n.KnockoutHelper.validationMessage(u,"required",i)}}).extend({minLength:{params:6,message:n.KnockoutHelper.validationMessage(u,"minLength",i)}}).extend({spaceInPassword:{message:n.KnockoutHelper.validationMessage(u,"spaces",i)}});case"email":return ko.observable().extend({required:{message:n.KnockoutHelper.validationMessage(u,"required",i)}}).extend({email:{message:n.KnockoutHelper.validationMessage(u,"email",i)}})}return ko.observable()},t.GetObservableByTypeRegistration=function(t,i,r){var u=r?r:t;switch(t){case"password":return ko.observable().extend({required:{message:n.KnockoutHelper.validationMessage(u,"required",i)}}).extend({minLength:{params:8,message:n.KnockoutHelper.validationMessage(u,"minLength",i)}}).extend({spaceInPassword:{message:n.KnockoutHelper.validationMessage(u,"spaces",i)}});case"email":return ko.observable().extend({required:{message:n.KnockoutHelper.validationMessage(u,"required",i)}}).extend({email:{message:n.KnockoutHelper.validationMessage(u,"email",i)}})}return ko.observable()},t.DefaultErrorMessage="",t}();n.KnockoutHelper=t}(Helpers||(Helpers={})),function(n){var t=function(){function n(){}return n.GetUrlParam=function(n,t){return(RegExp(t+"=(.+?)(&|$)").exec(n)||[,null])[1]},n.SetUrlParam=function(n,t,i){var r,u,f;return n?(r=new RegExp("(.*)"+t+"=[^&]*?&(.*)"),r.test(n))?n.replace(r,"$1"+(t+"="+i+"&")+"$2"):(u=new RegExp("(.*)"+t+"=[^&]*?$"),u.test(n))?n.replace(u,"$1"+(t+"="+i)):n.indexOf("/")>=0?(f=n.indexOf("?"),f<0?n+("?"+t+"="+i):f<=n.length-1?n+("&"+t+"="+i):n+("&"+t+"="+i)):n+("&"+t+"="+i):t+"="+i},n}();n.UrlHelper=t}(Helpers||(Helpers={})),function(n){var t=function(){function n(){}return n.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency=function(n){this.GetCurrentCurrencyByIp().done(function(t){var i=$.cookie(Constants.Commerce.CurrentCurrencyByIpAddress);i&&i===t||$.ajax("/Ecommerce.svc/AddressAdministration_CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency"),BillingCountryName:n}}),success:function(n){$.removeCookie(Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey);n.value===!0&&$("#geo-ip-currency-is-not-billing-message-link")[0].click()}})})},n.AddToCookieModalDialogGeoCurrencyIsNotBillingWasAlreadyShown=function(){this.GetCurrentCurrencyByIp().done(function(n){$.cookie(Constants.Commerce.CurrentCurrencyByIpAddress,n,{path:"/"})})},n.GetCurrentCurrencyByIp=function(){return $.ajax("/api/commerce/address/getCurrencyIsoByCurrentIpAddress",{method:"GET",contentType:Constants.ContentType.OsaContentType})},n}();n.AddressServices=t}(Services||(Services={})),function(n){var t=function(){function t(){}return t.UpdateExpirationBasketIdCookie=function(){var t=$.cookie(Constants.Global.BasketCookieKey),n;t&&(n=new Date,n.setTime(n.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5),$.cookie(Constants.Global.BasketCookieKey,t,{path:"/",expires:n}))},t.GetOrderLine=function(t,i,r,u){return r===void 0&&(r=!0),u===void 0&&(u=!1),$.ajax(n.UrlManager.GetBasketUrl(t)+"/Basket_orderLines('"+i+"')",{type:"GET",async:r,contentType:Constants.ContentType.OsaContentType,beforeSend:function(){u&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t.RemoveOrderLine=function(t,i){return i===void 0&&(i=!1),$.ajax(n.UrlManager.OrderLinesUrl(t),{type:"DELETE",contentType:Constants.ContentType.OsaContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t.UpdateOrderLine=function(t,i,r){return r===void 0&&(r=!1),$.ajax(n.UrlManager.OrderLinesUrl(t),{type:"PUT",data:i,contentType:Constants.ContentType.OsaContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t.ResendConfirmationEmail=function(t,i){return i===void 0&&(i=!1),$.ajax(n.UrlManager.ResendConfirmationEmailUrl,{type:"POST",data:JSON.stringify(t),contentType:Constants.ContentType.OsaContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t}();n.OrderServices=t}(Services||(Services={})),function(n){var t=function(){function n(){}return n.RoutePrefix="/Ecommerce.svc/",n.AddressApi=n.RoutePrefix+"Addresses",n.BasketApi=n.RoutePrefix+"Baskets",n.OrderApi=n.RoutePrefix+"Orders",n.UserApi=n.RoutePrefix+"Users",n.UserManagmentApi="/Ecommerce.svc",n.AuthApi=n.RoutePrefix+"CustomerAdministration_Auth",n.BasketAppendApi=n.RoutePrefix+"BasketAdministration_AppendBasketOrderLines",n.BasketAssignToCurrentUserApi=n.RoutePrefix+"BasketAdministration_AssignBasket",n.OrderResenEmailConfirmationApi=n.RoutePrefix+"OrderAdministration_ResendEmailConfirmation",n.OrderLineApi=function(t){return n.RoutePrefix+"OrderLines('"+t+"')"},n}(),i=function(){function n(){}return n.GetUserInfoUrl=t.UserApi,n.RegisterUserUrl=t.UserApi,n.AuthenticationUrl=t.AuthApi,n.GetCurrentBasketUrl=t.BasketApi+"('_')",n.GetCurrentBasketCommerceUrl="/api/commerce/basket/getcurrent",n.GetBasketUrl=function(n){return t.BasketApi+"('"+n+"')"},n.AppendBasketUrl="/api/commerce/basket/AppendBasketOrderLines",n.AssignBasketToCurrentUserUrl=t.BasketAssignToCurrentUserApi,n.GetOrderUrl=function(n){return t.OrderApi+"('"+n+"')"},n.OrderLinesUrl=function(n){return t.OrderLineApi(n)},n.ResendConfirmationEmailUrl=t.OrderResenEmailConfirmationApi,n}();n.UrlManager=i}(Services||(Services={})),function(n){var t=function(){function t(){}return t.GetUserAddressBook=function(n){n===void 0&&(n=!0);var t=[];return $.ajax("/api/commerce/address",{type:"GET",async:n,success:function(n){$.extend(t,n)}}),t},t.GetUserBasketViewModel=function(n,t){var r=this,e;n===void 0&&(n=!0);t===void 0&&(t=!1);var u=$.cookie(Constants.Global.BasketCookieKey),i=new Entities.OrderModels.OrderModel,f=function(n){var u;window.preInit&&window.preInit.order&&window.preInit.order[n]?(u=window.preInit.order[n],$.extend(i,u)):(u=t?r.GetJsonBasketCommerceApi(n):r.GetJsonBasket(n),$.extend(i,u))};return u?f(u):(e=function(n){if(n.readyState===4&&n.status===201){var t=new Date;t.setTime(t.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5);$.cookie(Constants.Global.BasketCookieKey,n.responseJSON.Id,{path:"/",expires:t});f(n.responseJSON.Id)}},this.CreateBasket(n,e)),i},t.GetSuggestedAddress=function(n,t){t===void 0&&(t=!0);var i={},r=Constants.Global.ODataOperation("SuggestAddress"),u=Constants.Global.ODataOperation("ValidatingAddress"),f=JSON.stringify({request:{"odata.type":r,Address:{"odata.type":u,AddressLine:n.AddressLine,AddressLine2:n.AddressLine2,City:n.City,CountryName:n.CountryName,CountryIso:n.CountryIso,PostalCode:n.PostalCode,StateName:n.StateName,StateIso:n.StateIso}}});return $.ajax("/Ecommerce.svc/AddressAdministration_SuggestAddress",{method:"POST",async:t,data:f,contentType:Constants.ContentType.OsaContentType,success:function(t){if(t.IsValid==!0)i.addressModel=new Entities.AddressBookModels.AddressBookModel,$.extend(i.addressModel,t),n.AddressId&&(i.Id=n.AddressId),i.addressModel.CountryName=n.CountryName,i.addressModel.StateName=n.StateName,i.addressModel.IsBilling=n.IsBilling,i.addressModel.FirstName=n.FirstName,i.addressModel.LastName=n.LastName,i.addressModel.CompanyName=n.CompanyName,i.addressModel.PhoneNumber=n.PhoneNumber,i.addressModel.Email=n.Email,i.addressModel.IsDefaultShipping=n.IsDefaultShipping,i.addressModel.IsDefaultBilling=n.IsDefaultBilling,i.addressModel.IsBilling=n.IsBilling;else{var r=t.ErrorDescription.indexOf("]");t.ErrorDescription&&(i.message=t.ErrorDescriptionstartIndex!=-1&&r!=-1?t.ErrorDescription.substring(r+1):t.ErrorDescription)}}}),i},t.Logout=function(){var n=$(".js-wkis-login-open","header").css("display","inline-block"),t=$(".js-wkis-myaccount-open","header").hide();$.removeCookie(Constants.Global.UserTokenCookieKey,{path:"/"});$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})},t.ShowMyAccHeader=function(){var n=$(".js-wkis-login-open","header").hide(),t=$(".js-wkis-myaccount-open","header").css("display","inline-block")},t.GetJsonBasket=function(t){var r=this,i=new Entities.OrderModels.OrderModel;return $.ajax("/Ecommerce.svc/Baskets('"+t+"')?$expand=Basket_orderLines/Product",{method:"GET",async:!1,success:function(n){$.extend(i,n)},error:function(){var n,t=function(t){if(t.readyState===4&&t.status===201){var i=new Date;i.setTime(i.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5);$.cookie(Constants.Global.BasketCookieKey,t.responseJSON.Id,{path:"/",expires:i});n=t.responseJSON}};r.CreateBasket(!1,t);$.extend(i,n);i.Basket_orderLines=n.BasketLines},complete:function(){n.OrderServices.UpdateExpirationBasketIdCookie()}}),i},t.GetJsonBasketCommerceApi=function(t){var r=this,i=new Entities.OrderModels.OrderModel;return $.ajax("/api/commerce/basket/"+t,{method:"GET",async:!1,success:function(n){$.extend(i,n);i.Basket_orderLines=n.BasketLines},error:function(){var n,t=function(t){if(t.readyState===4&&t.status===201){var i=new Date;i.setTime(i.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5);$.cookie(Constants.Global.BasketCookieKey,t.responseJSON.Id,{path:"/",expires:i});n=t.responseJSON}};r.CreateBasket(!1,t);$.extend(i,n);i.Basket_orderLines=n.BasketLines},complete:function(){n.OrderServices.UpdateExpirationBasketIdCookie()}}),i},t.CreateBasket=function(n,t){var i=Constants.Global.ODataOperation("Basket");$.ajax("/Ecommerce.svc/Baskets",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({"odata.type":i}),async:n,complete:function(n){return t(n)}})},t.GetUserInfo=function(t,i){return t===void 0&&(t=!1),i===void 0&&(i=!1),$.ajax(n.UrlManager.GetUserInfoUrl,{type:"GET",contentType:t?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t.Authentication=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.AuthenticationUrl,{data:t,type:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement();$(".ko-validation-message").hide()},error:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},t.GetCurrentBasket=function(t,i){return t===void 0&&(t=!1),i===void 0&&(i=!1),$.ajax(t?n.UrlManager.GetCurrentBasketUrl:n.UrlManager.GetCurrentBasketCommerceUrl,{type:"GET",contentType:t?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t.AppendBasket=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.AppendBasketUrl,{data:t,type:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t.Register=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.RegisterUserUrl,{data:t,type:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()},error:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},t.AssignBasketToCurrentUser=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.AssignBasketToCurrentUserUrl,{data:t,method:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})},t}();n.UserServices=t}(Services||(Services={})),function(n){var t;(function(n){var t;(function(n){var i=function(){function n(){}return n}(),t;n.FacetModel=i;t=function(){function n(){}return n}();n.FacetArg=t})(t=n.FacetEntities||(n.FacetEntities={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(n){var t;(function(n){var v=function(){function n(){}return n}(),i,r,u,f,e,o,s,h,t,c,l,a;n.SearchResultItemModel=v;i=function(){function n(){}return n}();n.MsFacetModel=i;r=function(){function n(){}return n}();n.PaFacetModel=r;u=function(){function n(){}return n}();n.TgFacetModel=u;f=function(){function n(){}return n}();n.EventFacetModel=f;e=function(){function n(){}return n}();n.SearchResultItemsByDateModel=e;o=function(){function n(){}return n}();n.FacetArg=o;s=function(){function n(){}return n}();n.PressReleaseYearModel=s;h=function(){function n(){}return n}();n.KeyValuePair=h;t=function(){function n(){}return n}();n.ResourceMetaDataItem=t;c=function(){function n(){}return n}();n.SearchParams=c;l=function(){function n(){}return n.MarketSegment="marketSegments",n.PracticeArea="practiceAreas",n.Type="type",n}();n.FacetNames=l;a=function(){function n(){var n=this;this.addResourceMetaDataItem=function(n,t){t.IsSeparator?n.resourceMetaDataItems.length>0&&(n.resourceMetaDataItems[n.resourceMetaDataItems.length-1].IsSeparator||n.resourceMetaDataItems.push(t)):n.resourceMetaDataItems.push(t)};this.addSeparator=function(i){var r=new t;r.IsSeparator=!0;n.addResourceMetaDataItem(i,r)};this.momentMonthDateYearFormat=function(n){return moment(n,"MM-DD-YYYY").format("MMMM DD, YYYY")};this.addDate=function(i){var u,f,r;i.HasMetaDate||i.Timestamp&&(u=new Date(i.Timestamp),f=new Date(0),u>f&&(i.HasMetaDate=!0,i.MetaDate=n.momentMonthDateYearFormat(u)));i.HasMetaDate&&(r=new t,r.IsSeparator=!1,r.Class="wkis-teaser-meta-date",r.Text=i.MetaDate,n.addResourceMetaDataItem(i,r))};this.addTime=function(i){if(i.HasMetaTime){var r=new t;r.IsSeparator=!1;r.Class="wkis-teaser-meta-time";r.Text=i.MetaTime;n.addResourceMetaDataItem(i,r)}};this.addDuration=function(i){if(!i.HasDuration&&(i.DocumentType==="pastWebinar"||i.ContentTypeDisplayName==="Webinar"||i.ContentTypeDisplayName==="Past Webinar"||i.ContentTypeDisplayName==="Webinars"||i.ContentTypeDisplayName==="Past Webinars")&&i.AdditionalText&&(i.HasDuration=!0,i.MetaDuration=i.AdditionalText),i.HasDuration){var r=new t;r.IsSeparator=!1;r.Class="wkis-teaser-meta-duration";r.Text=i.MetaDuration;n.addResourceMetaDataItem(i,r)}};this.addAuthors=function(i){if(i.HasAuthors){var r=new t;r.IsSeparator=!1;r.Class="wkis-teaser-meta-author";r.Text=i.Authors;n.addResourceMetaDataItem(i,r)}else n.addDynamicMetaDataItem(i,"dc:contributor","wkis-teaser-meta-author")};this.addDynamicMetaDataItem=function(i,r,u){var f,e;if(i.dynamicLength>0)for(f=0;f<i.dynamicLength;f++)if(i.dynamicFieldArray[f].key===r){e=new t;e.IsSeparator=!1;e.Class=u;e.Text=i.dynamicFieldArray[f].value;n.addResourceMetaDataItem(i,e);return}};this.createResourceMetaDataItems=function(t){if(t.resourceMetaDataItems=[],t.DynamicFields!=null&&t.DynamicFields.length>0&&t.DynamicFields!=="]"?(t.dynamicFieldArray=JSON.parse(t.DynamicFields),t.dynamicLength=t.dynamicFieldArray.length):(t.dynamicFieldArray=[],t.dynamicLength=0),t.ContentTypeDisplayName)switch(t.ContentTypeDisplayName.toLowerCase()){case"news":case"daily news":n.addAuthors(t);n.addSeparator(t);n.addDate(t);break;case"whitepaper":case"whitepapers":case"white paper":case"white papers":n.addAuthors(t);n.addSeparator(t);n.addDate(t);break;case"past webinar":case"past webinars":case"webinar":case"webinars":case"educational webinar":case"educational webinars":case"educational video":case"educational videos":n.addDuration(t);n.addSeparator(t);n.addAuthors(t);n.addSeparator(t);n.addDate(t);n.addSeparator(t);n.addTime(t);break;case"treatise":case"treatises":case"strategic perspective":case"strategic perspectives":case"journal":case"journals":case"journal article":case"journal articles":case"explanation":case"explanations":n.addAuthors(t);n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-journal-title","wkis-teaser-meta-info");n.addSeparator(t);n.addDate(t);break;case"case":case"cases":case"law":case"laws":n.addDynamicMetaDataItem(t,"data-court-title","wkis-teaser-meta-author");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-court","wkis-teaser-meta-author");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-law-section-heading","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-law-section","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"dcterms:title","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-case-number","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-citation","wkis-teaser-meta-info");n.addSeparator(t);n.addDate(t);break;case"final rule":case"final rules":case"rule":case"rules":case"regulation":case"regulations":case"form":case"forms":case"agency document":case"agency documents":case"administrative decision":case"administrative decisions":n.addDynamicMetaDataItem(t,"data-issuing-body-title","wkis-teaser-meta-author");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-issuing-body","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-citation","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"opt-Decision Number","wkis-teaser-meta-info");n.addSeparator(t);n.addDate(t)}}}return n}();n.ResourceMetaDataMapper=a})(t=n.SearchResultEntities||(n.SearchResultEntities={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.EloquaFormViewModel(t),t)},t}();t.EloquaFormInitializer=i})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"filter"),u=i.GetUrlParam(window.location.href,"query"),f=i.GetUrlParam(window.location.href,"ms"),e=i.GetUrlParam(window.location.href,"pa"),o=i.GetUrlParam(window.location.href,"type");ko.applyBindings(new n.ViewModel.EventsLandingViewModel(t,r,u,f,e,o),t)},t}();t.EventsLandingInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(){}return n.prototype.Initialize=function(n){this.InitializeReadMoreButton(n)},n.prototype.InitializeReadMoreButton=function(n){var t=$(".js-wkis-seo-more-content.wkis-global-type-styles",n),u=$(".js-wkis-seo-more-action",n),i,r,f;if(t.length&&u.length){i=$("p",t).toArray();r=0;for(f in i)r+=$(i[f]).outerHeight(!0);r<parseInt(t.css("height"))&&u.hide()}},n}();n.ExpandedContentInitializer=t})(t=n.Initializer||(n.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"ms"),u=i.GetUrlParam(window.location.href,"pa"),f=i.GetUrlParam(window.location.href,"query"),e=i.GetUrlParam(window.location.href,"resultsPerPage"),o=i.GetUrlParam(window.location.href,"page");ko.applyBindings(new n.ViewModel.ExpertsLandingViewModel(t,f,r,u,e,o),t)},t}();t.ExpertsLandingPageInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"ms"),u=i.GetUrlParam(window.location.href,"pa"),f=i.GetUrlParam(window.location.href,"spa"),e=i.GetUrlParam(window.location.href,"type"),o=i.GetUrlParam(window.location.href,"lastdays"),s=i.GetUrlParam(window.location.href,"query"),h=i.GetUrlParam(window.location.href,"sortBy"),c=i.GetUrlParam(window.location.href,"resultsPerPage"),l=i.GetUrlParam(window.location.href,"page");ko.applyBindings(new n.ViewModel.KlLandingViewModel(t,r,u,f,e,o,s,h,c,l),t)},t}();t.KlLandingInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"resultsPerPage"),u=i.GetUrlParam(window.location.href,"page");ko.applyBindings(new n.ViewModel.PressReleasesLandingViewModel(t,r,u),t)},t}();t.PressReleasesLandingPageInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"filter"),u=i.GetUrlParam(window.location.href,"query"),f=i.GetUrlParam(window.location.href,"sortBy"),e=i.GetUrlParam(window.location.href,"resultsPerPage"),o=i.GetUrlParam(window.location.href,"page"),s=i.GetUrlParam(window.location.href,"expId"),h=i.GetUrlParam(window.location.href,"expName");ko.applyBindings(new n.ViewModel.SearchResultsViewModel(t,r,u,f,e,o,s,h),t)},t}();t.SearchResultsPageInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={}));AccountInfoModel=Entities.AccountInfoModels.AccountInfoModel,function(n){var t;(function(n){var t=function(){function n(t){var i=this;this.UserConsentAgreement=ko.observable(!1);this.processSuccess=function(n,t){i.submitDisabled=ko.observable(!1);i.isModal&&($(".js-wkis-modal").removeClass("-is-open"),$("html").removeClass("-js-modal-open"));i.saveFieldsToSessionStorage(t);i.isContentLocked?i.showLockedContent():i.postToNewWindow||i.showSuccessModal()};this.showIFrameModal=function(n){var t=$(".js-wkis-modal[data-modal='modal-iframe']"),i=t.find("iframe");i.attr("src",n);t.addClass("-is-open");$("html").addClass("-js-modal-open")};this.showSuccessModal=function(){i.successModalUserLoggedIn&&i.successModalUserLoggedIn.length>0&&i.userIsLoggedIn()?i.showModal(i.successModalUserLoggedIn):i.successModal&&i.successModal.length>0?i.showModal(i.successModal):i.showGenericModal("success",i.eloquaFormSuccessMessage,null);$("html, body").animate({scrollTop:0},300)};this.processLockedContentResult=function(n){var t,r;if(n&&n.FullContent&&n.FullContent.length>0){if(t=$("div.wkis-content-locked"),t.remove(),r=$('div[name="gated-content-article-body"]'),r.replaceWith(n.FullContent),i.showSuccessModal(),$("a.metadataLink.osa-doc-metadata-link")&&$("a.metadataLink.osa-doc-metadata-link").length===1&&$("a.metadataLink.osa-doc-metadata-link").children().length===2&&$("div.osa-doc-metadata")&&$("div.osa-doc-metadata").length===1)$("a.metadataLink.osa-doc-metadata-link").on("click",function(){var n=$("div.osa-doc-metadata").is(":visible");n?($("a.metadataLink.osa-doc-metadata-link").children().first().show(),$("a.metadataLink.osa-doc-metadata-link").children().last().hide(),$("div.osa-doc-metadata").hide()):($("a.metadataLink.osa-doc-metadata-link").children().first().hide(),$("a.metadataLink.osa-doc-metadata-link").children().last().show(),$("div.osa-doc-metadata").show())})}else i.showGenericModal("failed","Gated content not available.",null)};this.showLockedContent=function(){var n=$('div[name="gated-content-article-body"]'),t=n.attr("gated-content-id"),r="/Umbraco/Api/GatedContentApi/GetGatedContent?gatedContentId="+t,u=i;$.ajax({type:"GET",url:r,contentType:"application/json",dataType:"json",success:function(n){u.processLockedContentResult(n)},error:function(){this.showGenericModal("failed","Failed to loaded gated content.",null)}})};this.showModal=function(n){$(".js-wkis-modal[data-modal='"+n+"']").addClass("-is-open");$("html").addClass("-js-modal-open")};this.checkRedirectUrlResult=function(n){var r,u,i,t;return n&&n.length>0&&n.indexOf("document.location.href")>0&&(r=n.substr(n.indexOf("document.location.href")),u=r.indexOf("http"),u>0&&((i=r.substr(u),t=i.indexOf("'"),t>0)||(t=i.indexOf('"'),t>0)))?i.substr(0,t):""};this.submitForm=function(){var n=i.usesCaptcha(i.eloquaForm);n?i.verifyCaptcha(function(){return i.dataSubmit()}):i.dataSubmit()};this.dataSubmit=function(){var n=i,t;i.checkFormValid()?(i.gdprActive&&i.isGdprApplied?i.assignValuesToFormFields():i.clearFieldValues(),n.formData=i.eloquaForm.serializeArray(),i.postToNewWindow?(n.processSuccess("",n.formData),i.eloquaForm.submit()):(t=i.eloquaForm.attr("action"),$.ajax({url:t,type:"POST",dataType:"html",cache:!1,data:n.formData,beforeSend:function(){n.submitDisabled=ko.observable(!0)},success:function(t){var i=n.checkRedirectUrlResult(t);n.processSuccess(i,n.formData)},error:function(){n.processSuccess("",n.formData)}}))):i.isInline&&i.displayInlineValidations()};this.getValidator=function(n,t){var r="ko-error-text[for='"+n+"'][rule='"+t+"']";return i.eloquaForm.find(r)};this.validateOnBlur=function(n){i.performedValidationOnce&&i.validateElement(n.target)};this.validateElement=function(n){var u=i.failsRequired(n),t,r;return u?!1:(t=i.failsEmail(n),t)||(r=i.failsMinimumLength(n),r)?!1:!0};this.checkFormValid=function(){var t=i.eloquaForm.find("[hasvalidation]"),n;return i.inlineValidations=[],i.performedValidationOnce||i.isInline||(i.performedValidationOnce=!0,t.blur(i.validateOnBlur)),n=!0,t.each(function(t,r){var u=i.validateElement(r);u||(n=!1)}),n};this.failsRequired=function(n){var t=i.getValidator(n.name,"required"),f,r,u;if(t&&t.length===1){if(f=n.value,n.type==="select-one"&&(n.selectedIndex>0||(f=!1)),n.type==="select-multiple"){for(r=[],u=0;u<n.length;u++)n.options[u].selected&&r.push(u);f=r.length>0&&!(r.length===1&&r[0]===0)}return f?(i.hide(t),!1):(i.isInline?i.pushValidatorText(t):i.show(t),!0)}return!1};this.failsEmail=function(n){var t=i.getValidator(n.name,"email"),r;return t&&t.length===1?(r=n.value,r&&/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(r))?(i.hide(t),!1):(i.isInline?i.pushValidatorText(t):i.show(t),!0):!1};this.failsMinimumLength=function(n){var t=i.getValidator(n.name,"minlength"),r,u;return t&&t.length===1?(r=n.value,u=r.attr("minlength"),r&&r.length>=u)?(i.hide(t),!1):(i.isInline?i.pushValidatorText(t):i.show(t),!0):!1};this.verifyCaptcha=function(n){var t=!1,r=$(".eloquaForm-recaptcha .g-recaptcha-response").val(),u=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidateCaptcha"),Captcha:r}});$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ValidateCaptcha",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:u,success:function(n){t=n.value},error:function(){t=!1}})).done(function(){t?($("[for='captcha'][rule='required']",i.$container).hide(),$(".eloquaForm-recaptcha").css({"border-color":"","border-style":"",width:"",height:""}),n()):($("[for='captcha'][rule='required']",i.$container).show(),$(".eloquaForm-recaptcha").css({"border-color":"#f00","border-style":"solid",width:"308px",height:"82px"}))})};this.usesCaptcha=function(n){var t=n.find(".eloquaForm-recaptcha");return t.length>0?!0:!1};this.showGenericModal=function(n,t,i){var u=$("div.js-wkis-dialog-box.-generic-modal"),f=u.find("div.js-wkis-alert-message"),r,e;f.attr("data-type",n);r=u.find("div.wkis-eyebrow");i!==null?r.text(i):r.text(r.attr(n));e=u.find(".js-wkis-alert-message-text");e.html(t);$("html").toggleClass("-dialog-open");f.css({opacity:1,transition:"opacity 0.3s"}).slideDown(300)};this.hide=function(n){n.css("visibility","hidden");n.css("opacity","0");n.fadeOut("fast")};this.show=function(n){n.css("visibility","visible");n.css("opacity","1");n.fadeIn("fast")};this.pushValidatorText=function(n){var t=n.html();i.inlineValidations.push(t)};this.displayInlineValidations=function(){var n="";i.inlineValidations.forEach(function(t){n+="<p>"+t+"<\/p>"});i.showGenericModal("failed",n,null)};this.saveFieldsToSessionStorage=function(n){var f,r,u,h,c,t;if(window.sessionStorage){for(f=new Date,window.sessionStorage.setItem("LastEloquaSaveTime",f.getMilliseconds().toString()),r=0,u=n;r<u.length;r++){var e=u[r],o=e.name,s=i.eloquaForm.find("input[type='hidden'][name='"+o+"']");s&&s.length!==0||(h=e.value,window.sessionStorage.setItem("EloquaField_"+o,h))}c=i.eloquaForm.find("[user-field-map]");t=new AccountInfoModel;c.each(function(n,i){var r=$(i),u=r.attr("user-field-map");if(u)switch(u){case"Email":t.Email=r.val();break;case"FirstName":t.FirstName=r.val();break;case"LastName":t.LastName=r.val();break;case"PhoneNumber":t.PhoneNumber=r.val()}});window.sessionStorage.setItem("EloquaAccountInfoModel",JSON.stringify(t))}};this.userIsLoggedIn=function(){return!!$.cookie(Constants.Global.UserTokenCookieKey)};this.getUserAccountInfo=function(){var s,t,e,n,c;if(window.sessionStorage){var o=window.sessionStorage.getItem("LastEloquaSaveTime"),u=!1,f=!1;if(f||u||(o&&o.toString().length>0?u=!0:i.userIsLoggedIn()&&(f=!0)),f)Services.UserServices.GetUserInfo().done(function(n){if(n&&n.value){var t=n.value[0];i.mapUserAccountInfo(t)}else i.setDefaultCountry()});else if(u)for(s=i.eloquaForm.serializeArray(),t=0,e=s;t<e.length;t++){var l=e[t],r=l.name,h=i.eloquaForm.find("input[type='hidden'][name='"+r+"']");h&&h.length!==0||(n=window.sessionStorage.getItem("EloquaField_"+r),n&&n.toString().length>0&&(c=i.eloquaForm.find("[name='"+r+"']"),c.val(n.toString()),r==="country"&&(i.countryCode=n.toString(),i.changeEloquaCountry())))}else i.setDefaultCountry()}};this.mapUserAccountInfo=function(n){if(n){var t=i.eloquaForm.find("[user-field-map]");t.each(function(t,i){var r=$(i),u=r.attr("user-field-map");if(u)switch(u){case"Email":r.val(n.Email);r.val()&&r.attr("disabled","disabled");break;case"FirstName":r.val(n.FirstName);break;case"LastName":r.val(n.LastName);break;case"PhoneNumber":r.val(n.PhoneNumber)}})}};this.processAdditionalFields=function(){var f="country",s=i.eloquaForm.attr("id"),t=document.getElementById(s),r,n,u,e,o;if(i.containsInputField(t,f)&&i.isGdprApplied){for(r in i.eloquAdditionalFields)i.eloquAdditionalFields.hasOwnProperty(r)&&(i.containsInputField(t,r)||(n=document.createElement("input"),n.setAttribute("type","hidden"),n.setAttribute("name",r),n.setAttribute("value",""),u=t.querySelectorAll("input[type='hidden']"),e=u[u.length-1],e.insertAdjacentElement("beforebegin",n)));o=t.querySelector("[name="+f+"]");o.setAttribute("data-bind","value: countryCode, event: { change: changeEloquaCountry }");i.setDefaultCountry()}};this.containsInputField=function(n,t){return n.querySelector("[name="+t+"]")!=null?!0:!1};this.assignValuesToFormFields=function(){var t=i.eloquaForm.attr("id"),n=document.getElementById(t);n.querySelector("[name=consentCheckbox]").setAttribute("value",i.UserConsentAgreement().toString());n.querySelector("[name=dateOfConsent]").setAttribute("value",(new Date).toLocaleString("en-US"));n.querySelector("[name=consentMessage]").setAttribute("value",Helpers.CommerceHelper.stripHtml($("label[for='eloqua-user-consent']").html()));n.querySelector("[name=consentMessageId]").setAttribute("value",$("label[for='eloqua-user-consent']").attr("message-id"))};this.clearFieldValues=function(){var u=i.eloquaForm.attr("id"),t=document.getElementById(u),n,r;for(n in i.eloquAdditionalFields)i.eloquAdditionalFields.hasOwnProperty(n)&&i.containsInputField(t,n)&&(r=t.querySelector("[name="+n+"]"),r.setAttribute("value",""))};this.acceptUserConsent=function(){i.UserConsentAgreement(!i.UserConsentAgreement());i.assignValuesToFormFields()};this.changeEloquaCountry=function(){var n;if(i.countryCode&&(i.gdprActive=Helpers.CommerceHelper.CheckIfCountryWithinEU(i.countryCode),i.consentMessageVisible(i.gdprActive)),i.countryCode){var t="stateOrProvince",u=i.eloquaForm.attr("id"),r=document.getElementById(u);i.countryCode=="US"?i.containsInputField(r,t)&&(n=i.eloquaForm.find("[name='"+t+"']"),n.val("")):i.containsInputField(r,t)&&(n=i.eloquaForm.find("[name='"+t+"']"),n.val("Non U.S."))}};this.setDefaultCountry=function(){n.countryCodeStaic?i.countryCode=n.countryCodeStaic:$.ajax("/Ecommerce.svc/AddressAdministration_GetCountries",{type:"POST",async:!1,cache:!0,contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetCountries")}}),success:function(t){n.countryCodeStaic=t.DefaultCountryIso;i.countryCode=n.countryCodeStaic;var r=i.eloquaForm.find("[name='country']");r.val(i.countryCode);i.changeEloquaCountry()}})};this.$container=$(t);this.eloquaForm=this.$container.find("form");this.submitDisabled=ko.observable(!1);this.consentMessageVisible=ko.observable(!1);this.isModal=this.eloquaForm.attr("is-on-modal")==="true";this.isInline=this.eloquaForm.attr("is-inline")==="true";this.isGdprApplied=this.eloquaForm.attr("apply-gdpr-rules")==="true";this.postToNewWindow=this.eloquaForm.attr("target")==="_blank";this.isContentLocked=this.eloquaForm.attr("is-content-locked")==="true";this.successModal=this.eloquaForm.attr("success-modal");this.successModalUserLoggedIn=this.eloquaForm.attr("success-modal-user-logged-in");this.performedValidationOnce=!1;this.eloquaFormSuccessMessage=this.$container.find("div.-eloquaFormSuccessMessage").html();this.eloquaFormFailMessage=this.$container.find("div.-eloquaFormFailMessage").html();this.eloquAdditionalFields={consentCheckbox:"",dateOfConsent:"",consentMessage:"",consentMessageId:""};this.countryCode="";this.getUserAccountInfo();this.gdprActive=!1;this.processAdditionalFields()}return n.countryCodeStaic="",n}();n.EloquaFormViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(t,i,r,u,f,e){var o=this,c,h,a,s,l,v;this.onSearchButtonClick=function(){if(!o.OnInit){o.SeeAllMonthEvents=!1;o.SeeRestOfTheMonthEvents=!1;o.ShowMonthByDaysPagination(!1);o.ShowFullMonthPagination(!1);o.ShowDayPagination(!0);var n=$("#seealllink");n.show();o.performSearch()}};this.getMonthResults=function(){o.SeeAllMonthEvents=!0;o.ShowFullMonthPagination(!0);o.ShowMonthByDaysPagination(!1);o.ShowDayPagination(!1);o.setMonthPagination();var n=$("#seealllink");n.hide();o.performSearch()};this.setMonthPagination=function(){var n=$("#limitmonthbydays"),t,i,r;n&&(t=n.attr("limitbydays"),t==="limitbydays"&&(i=n.attr("noofdays"),r=parseInt(i),o.PageSize=r,o.ShowFullMonthPagination(!1),o.ShowMonthByDaysPagination(!0)))};this.momentDayFormat=function(n){return moment(n,"MM-DD-YYYY").format("dddd")};this.momentMonthDateFormat=function(n){return moment(n,"MM-DD-YYYY").format("MMMM")+" "+moment(n).format("DD")};this.momentSelectedMonth=function(n){return moment(n,"MM-DD-YYYY").format("MMMM")};this.momentSelectedYear=function(n){return moment(n,"MM-DD-YYYY").format("YYYY")};this.moveToNextMonth=function(){o.Subscription.dispose();o.SearchDate(moment(o.SearchDate(),"MM-DD-YYYY").add(1,"months").startOf("month").format("L"));o.getMonthResults();o.Subscription=o.SearchDate.subscribe(function(){o.onSearchButtonClick()})};this.moveToPreviousMonth=function(){o.Subscription.dispose();o.SearchDate(moment(o.SearchDate(),"MM-DD-YYYY").subtract(1,"months").startOf("month").format("L"));o.getMonthResults();o.Subscription=o.SearchDate.subscribe(function(){o.onSearchButtonClick()})};this.marketSegmentSelected=function(n){o.SelectedMarketSegment(n);o.SelectedPracticeArea("");o.performSearch()};this.practiceAreaSelected=function(n){o.SelectedPracticeArea(n);o.performSearch()};this.eventTypeSelected=function(n){return o.SelectedEventType(n),o.performSearch(),!0};this.clearFilters=function(){(o.SelectedEventType()||o.SelectedMarketSegment()||o.SelectedPracticeArea())&&(o.SelectedEventType(""),o.SelectedMarketSegment(""),o.SelectedPracticeArea(""),o.performSearch())};this.movePage=function(n){var r,t,i,u;for(o.RequestedPage=o.CurrentPage()+n,r=o.SearchResultItemsByDatePerPage().length,t=0;t<r;t++)o.SearchResultItemsByDatePerPage.pop();o.PageSize*o.RequestedPage-o.SearchResultItemsByDate().length>0?o.CurrentResultsPerPage(o.PageSize*o.RequestedPage-o.SearchResultItemsByDate().length):o.CurrentResultsPerPage(o.PageSize);i=o.PageSize*(o.RequestedPage-1);u=i+o.CurrentResultsPerPage();ko.utils.arrayForEach(o.SearchResultItemsByDate.slice(i,u),function(n){return o.SearchResultItemsByDatePerPage.push(n)});o.CurrentPage(o.RequestedPage)};this.incrementPage=function(){o.movePage(1)};this.decrementPage=function(){o.movePage(-1)};this.previousDaySelected=function(){o.SearchDate(moment(o.SearchDate(),"MM-DD-YYYY").subtract(1,"days").format("L"));o.SeeAllMonthEvents=!1;o.SeeRestOfTheMonthEvents=!1;o.performSearch()};this.nextDaySelected=function(){o.SearchDate(moment(o.SearchDate(),"MM-DD-YYYY").add(1,"days").format("L"));o.SeeAllMonthEvents=!1;o.SeeRestOfTheMonthEvents=!1;o.performSearch()};this.performSearch=function(){var i,f,e,s,r,u,a,l;o.SearchDateFromForQuery(o.SearchDate());o.SearchDateToForQuery(o.SearchDate());o.SeeAllMonthEvents&&(o.SearchDateFromForQuery(moment(o.SearchDate(),"MM-DD-YYYY").startOf("month").format("L")),o.SearchDateToForQuery(moment(o.SearchDate(),"MM-DD-YYYY").endOf("month").format("L")));o.SeeRestOfTheMonthEvents&&o.SearchDateToForQuery(moment(o.SearchDate(),"MM-DD-YYYY").endOf("month").format("L"));i=[];o.SelectedEventType()&&(f=new n.Entities.SearchResultEntities.FacetArg,f.Name="eventCategories",f.Labels=[o.SelectedEventType()],i.push(f));o.SelectedMarketSegment()&&(e=new n.Entities.SearchResultEntities.FacetArg,e.Name="marketSegments",e.Labels=[o.SelectedMarketSegment()],i.push(e));o.SelectedPracticeArea()&&(s=new n.Entities.SearchResultEntities.FacetArg,s.Name="practiceAreas",s.Labels=[o.SelectedPracticeArea()],i.push(s));var t="",v=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+encodeURIComponent(i)},c=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+i.map(function(n){return encodeURIComponent(n)}).join(",")},h=ko.utils.arrayFirst(i,function(n){return n.Name==="marketSegments"});h&&h.Labels&&h.Labels.length>0&&c("ms",h.Labels);r=ko.utils.arrayFirst(i,function(n){return n.Name==="practiceAreas"});r&&r.Labels&&r.Labels.length>0&&c("pa",r.Labels);u=ko.utils.arrayFirst(i,function(n){return n.Name==="eventCategories"});u&&u.Labels&&u.Labels.length>0&&c("type",u.Labels);history.replaceState({},null,location.pathname+t+location.hash);a={ReturnFacets:["marketSegments","practiceAreas"],IndexType:"event",Facets:i,MetaDateFrom:o.SearchDateFromForQuery(),MetaDateTo:o.SearchDateToForQuery(),PageSize:1e4};l=o;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(a),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){l.processJsonResult(n);l.adjustDropdownLists(n.Facets);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}});console.log(o.ShowFullMonthPagination());console.log(o.ShowMonthByDaysPagination());console.log(o.ShowDayPagination())};this.processJsonResult=function(t){var u,r,i,e,f,s;if(o.SearchResultItemsByDate([]),o.SearchResultItemsByDatePerPage([]),o.CurrentResultsSearchDate(o.SearchDateForQuery),o.TotalRowsCount(t.TotalRowsCount),console.log("Rows count: "+t.TotalRowsCount),t.TotalRowsCount>0){for(o.NoResults(!1),u=0;u<t.TotalRowsCount;u++)for(r=t.Rows[u],i=moment(r.MetaDateFrom);i.diff(r.MetaDateTo,"days")<=0;i.add(1,"days"))i.diff(o.SearchDateFromForQuery(),"days")>=0&&i.diff(o.SearchDateToForQuery(),"days")<=0&&(e=ko.utils.arrayFirst(o.SearchResultItemsByDate(),function(n){return n.Date===i.format("L")}),e?e.ResultItems.push(r):(f=new n.Entities.SearchResultEntities.SearchResultItemsByDateModel,f.Date=i.format("L"),f.ResultItems=[r],o.SearchResultItemsByDate.push(f)));o.SeeAllMonthEvents||o.SeeRestOfTheMonthEvents?(o.SearchResultItemsByDate.sort(function(n,t){return n.Date===t.Date?0:n.Date>t.Date?1:-1}),o.ShowFullMonthPagination()||!o.ShowFullMonthPagination()&&o.SearchResultItemsByDate().length<=o.PageSize?(o.SearchResultItemsByDatePerPage(o.SearchResultItemsByDate()),o.TotalPages(1)):(o.SearchResultItemsByDatePerPage(o.SearchResultItemsByDate.slice(0,o.PageSize)),o.TotalPages(Math.ceil(o.SearchResultItemsByDate().length/o.PageSize)),console.log("this by day"),console.log(o.SearchResultItemsByDate()),console.log(o.PageSize),console.log(o.SearchResultItemsByDatePerPage()))):(s=ko.utils.arrayFirst(o.SearchResultItemsByDate(),function(n){return n.Date===moment(o.SearchDate(),"MM-DD-YYYY").format("L")}),s&&o.SearchResultItemsByDatePerPage.push(s),o.TotalPages(1));o.CurrentPage(1)}else o.TotalPages(0),o.ShowMonthByDaysPagination(!1),o.NoResults(!0),o.CurrentPage(0)};this.adjustDropdownLists=function(n){var i,r,t,u,f;if($("#msOptions option").each(function(){$(this).val()!==""&&$(this).hide()}),$("#paOptions option").each(function(){$(this).val()!==""&&$(this).hide()}),n){for(t=0;t<n.length;t++)n[t].Name==="marketSegments"&&(i=n[t]),n[t].Name==="practiceAreas"&&(r=n[t]);u=[];f=[];i&&i.Items.forEach(function(n){n.HitCount!=0&&u.push(n.Label)});r&&r.Items.forEach(function(n){n.HitCount!=0&&f.push(n.Label)});$("#msOptions option").each(function(){$(this).val()!==""&&u.indexOf($(this).val())>-1&&$(this).show()});$("#paOptions option").each(function(){$(this).val()!==""&&f.indexOf($(this).val())>-1&&$(this).show()})}};this.$container=$(t);this.OnInit=!0;this.RequestedPage=0;this.SearchDateForQuery="";this.CurrentResultsSearchDate=ko.observable("");this.NoResults=ko.observable(!0);this.SearchResultItems=ko.observableArray([]);this.SearchResultItemsByDate=ko.observableArray([]);this.SearchResultItemsByDatePerPage=ko.observableArray([]);this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.SelectedMarketSegment=ko.observable("");this.SelectedPracticeArea=ko.observable("");this.SelectedEventType=ko.observable("");this.SeeAllMonthEvents=!0;this.SeeRestOfTheMonthEvents=!0;this.PreventPASubscription=!1;this.PageSize=1;this.CurrentResultsPerPage=ko.observable(0);this.SearchDateFromForQuery=ko.observable("");this.SearchDateToForQuery=ko.observable("");this.ShowMonthByDaysPagination=ko.observable(!1);this.ShowFullMonthPagination=ko.observable(!0);this.ShowDayPagination=ko.observable(!1);this.SearchDate=ko.observable(moment().format("L"));this.setMonthPagination();u!=null&&u.length>0&&(u=decodeURIComponent(u).replace("#",""),c=u.split(","),c.length>0&&(s=c[0],this.SelectedMarketSegment(s)));f!=null&&f.length>0&&(f=decodeURIComponent(f).replace("#",""),h=f.split(","),h.length>0&&(a=h[0],s=$("#"+h[0]).attr("parent-ms-facet"),s&&this.SelectedMarketSegment(s),this.SelectedPracticeArea(a)));e!=null&&e.length>0&&(e=decodeURIComponent(e).replace("#",""),l=e.split(","),l.length>0&&(v=l[0],this.SelectedEventType(v)));this.OnInit=!1;this.SelectedMarketSegment.subscribe(function(){o.PreventPASubscription=!0;o.SelectedPracticeArea("");o.PreventPASubscription=!1;o.performSearch()});this.SelectedPracticeArea.subscribe(function(){o.PreventPASubscription||o.performSearch()});this.SelectedEventType.subscribe(function(){o.performSearch()});this.Subscription=this.SearchDate.subscribe(function(){o.onSearchButtonClick()});this.performSearch()}return t}();t.EventsLandingViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(t,i,r,u,f,e){var o=this,c,h,l,s;this.enterSearch=function(n,t){return t.keyCode===13&&o.performSearch(),!0};this.movePage=function(n){o.RequestedPage=o.CurrentPage()+n;o.performSearch()};this.incrementPage=function(){o.movePage(1)};this.decrementPage=function(){o.movePage(-1)};this.clickSearchIcon=function(){o.performSearch()};this.performSearch=function(){var s,i,r,u,f,e,l,a;o.SearchTermForQuery=o.SearchTerm();s=o.RequestedPage>0?o.RequestedPage:1;o.RequestedPage=0;i=[];o.MarketSegmentFacet()!=null&&o.MarketSegmentFacet().length>0&&(r=new n.Entities.SearchResultEntities.FacetArg,r.Name="marketSegments",r.Labels=[],r.Labels.push(o.MarketSegmentFacet()),i.push(r),o.PracticeAreaFacet()!=null&&o.PracticeAreaFacet().length>0&&(u=new n.Entities.SearchResultEntities.FacetArg,u.Name="practiceAreas",u.Labels=[],u.Labels.push(o.PracticeAreaFacet()),i.push(u)));var t="",h=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+encodeURIComponent(i)},c=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+i.map(function(n){return encodeURIComponent(n)}).join(",")};o.SearchTerm()&&h("query",o.SearchTerm());o.ResultsPerPage()&&o.ResultsPerPage()!==o.DefaultResultsPerPage&&h("resultsPerPage",o.ResultsPerPage());s>1&&h("page",s.toString());f=ko.utils.arrayFirst(i,function(n){return n.Name==="marketSegments"});f&&f.Labels&&f.Labels.length>0&&c("ms",f.Labels);e=ko.utils.arrayFirst(i,function(n){return n.Name==="practiceAreas"});e&&e.Labels&&e.Labels.length>0&&c("pa",e.Labels);history.replaceState({},null,location.pathname+t+location.hash);l={IndexType:o.SelectedTopFilter(),QueryStr:o.SearchTermForQuery,PageSize:o.ResultsPerPage(),Page:s,SortBy:o.SortBy(),Facets:i};a=o;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(l),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){a.processJsonResult(n);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})};this.processJsonResult=function(n){o.CurrentResultsSearchTerm(o.SearchTermForQuery);o.TotalRowsCount(n.TotalRowsCount);n.TotalRowsCount>0?(o.TotalPages(n.PagesCount),o.ShowPagination(n.PagesCount>1),o.NoResults(!1),o.CurrentPage(n.Page),o.SearchResultItems(n.Rows)):(o.TotalPages(0),o.ShowPagination(!1),o.NoResults(!0),o.CurrentPage(0),o.SearchResultItems([]))};this.resetFilter=function(){o.MarketSegmentFacet("");o.PracticeAreaFacet("");o.SearchTerm("");o.performSearch()};this.$container=$(t);this.OnInit=!0;this.RequestedPage=0;this.NoResults=ko.observable(!0);this.SearchTerm=ko.observable("");this.SearchResultItems=ko.observableArray([]);this.SearchTermForQuery="";this.CurrentResultsSearchTerm=ko.observable("");this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.ShowPagination=ko.observable(!1);this.OnMarketSegmentChange=!1;r!=null&&r.length>0?(this.MarketSegmentFacet=ko.observable(r),this.PracticeAreaFacet=u!=null&&u.length>0?ko.observable(u):ko.observable("")):(this.MarketSegmentFacet=ko.observable(""),this.PracticeAreaFacet=ko.observable(""));this.ValidResultsPerPage=["10","50","100","150","200"];this.DefaultResultsPerPage="10";this.ResultsPerPage=f!=null&&f.length>0&&this.ValidResultsPerPage.indexOf(f)>-1?ko.observable(f):ko.observable(this.DefaultResultsPerPage);this.SortBy=ko.observable("title-az");this.SelectedTopFilter=ko.observable("expert");i!=null&&i.length>0&&(i=decodeURIComponent(i).replace("#",""),this.SearchTerm=ko.observable(i));e!=null&&e.length>0&&(e=decodeURIComponent(e).replace("#",""),this.RequestedPage=parseInt(e));r!=null&&r.length>0&&(r=decodeURIComponent(r).replace("#",""),c=r.split(","),c.length>0&&(s=c[0],this.MarketSegmentFacet(s)));u!=null&&u.length>0&&(u=decodeURIComponent(u).replace("#",""),h=u.split(","),h.length>0&&(l=h[0],s=$("#"+h[0]).attr("parent-ms-facet"),s&&this.MarketSegmentFacet(s),this.PracticeAreaFacet(l)));this.ResultsPerPage.subscribe(function(){o.TotalRowsCount()>0&&o.performSearch()});this.MarketSegmentFacet.subscribe(function(){o.OnMarketSegmentChange=!0;o.PracticeAreaFacet("");o.performSearch();o.OnMarketSegmentChange=!1});this.PracticeAreaFacet.subscribe(function(){o.OnMarketSegmentChange||o.performSearch()});this.ResultsPerPage.extend({rateLimit:50});this.OnInit=!1;this.performSearch()}return t.isNaNModified=function(n){var t=parseFloat(n);return isNaN(t)||t.toString().length!=n.length},t}();t.ExpertsLandingViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=n.Entities.SearchResultEntities.ResourceMetaDataMapper,r=function(){function t(t,r,u,f,e,o,s,h,c,l){var a=this,nt,tt,it,w,b,p,y,k,d,v,g,ut;if(this.urldecode=function(n){return decodeURIComponent((n+"").replace(/\+/g,"%20"))},this.clickedMarketSegmentAnchor=function(t,i,r){var u,f,e,h,c,o,s;if(a.SelectedMarketSegment().Value!==i){if(u=new n.Entities.SearchResultEntities.KeyValuePair,u.Key=t,u.Value=i,a.SelectedMarketSegment(u),a.DisplaySelectedMarketSegment(!0),f=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="practiceAreas"}),f!=null)for(e=0;e<f.Labels.length;e++)h=f.Labels[e],c=$("#"+h),c.prop("checked",!1);a.SelectedFacets.remove(function(n){return n.Name==="practiceAreas"})}return o=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="marketSegments"}),o?(o.Labels.pop(),o.Labels.push(i)):(s=new n.Entities.SearchResultEntities.FacetArg,s.Name="marketSegments",s.Labels=[i],a.SelectedFacets.push(s)),r&&a.performSearch(!1),!0},this.closeSelectedMarketSegment=function(){var t,i,r,u;if(a.SelectedMarketSegment(new n.Entities.SearchResultEntities.KeyValuePair),a.DisplaySelectedMarketSegment(!1),t=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="practiceAreas"}),t!=null)for(i=0;i<t.Labels.length;i++)r=t.Labels[i],u=$("#"+r),u.prop("checked",!1);a.SelectedFacets.remove(function(n){return n.Name==="practiceAreas"});a.SelectedFacets.remove(function(n){return n.Name==="marketSegments"});a.performSearch(!1)},this.paFilterChecked=function(t,i,r){var e=$('input[type="checkbox"].'+t),u=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="practiceAreas"}),f;return i?u?u.Labels.push(t):(f=new n.Entities.SearchResultEntities.FacetArg,f.Name="practiceAreas",f.Labels=[t],a.SelectedFacets.push(f)):u&&a.removeStringFromArray(u.Labels,t),r&&a.performSearch(!1),!0},this.typeFilterChecked=function(t,i,r,u,f){var o=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="type"}),s,e;return u?(o?o.Labels.push(r):(s=new n.Entities.SearchResultEntities.FacetArg,s.Name="type",s.Labels=[r],a.SelectedFacets.push(s)),e=$("#"+t),$("."+t+":checked").length===$("."+t).parent("div:visible").length&&e.prop("checked",!0)):(o&&a.removeStringFromArray(o.Labels,r),e=$("#"+t),e.prop("checked",!1)),f&&a.performSearch(!1),!0},this.typeFilterGroupChecked=function(t,i,r){var f=i.split(","),e,s,u,o;if(f.length>0){if(e=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="type"}),r)if(e){for(u=0;u<f.length;u++)o=$("#"+f[u]),$(o).parent("div").css("display")!=="none"&&(o.prop("checked",!0),a.arrayHasString(e.Labels,f[u])||e.Labels.push(f[u]));e.GroupLabels||(e.GroupLabels=[]);e.GroupLabels.push(t)}else{for(s=new n.Entities.SearchResultEntities.FacetArg,s.Name="type",s.Labels=[],u=0;u<f.length;u++)o=$("#"+f[u]),$(o).parent("div").css("display")!=="none"&&(o.prop("checked",!0),s.Labels.push(f[u]));s.GroupLabels=[];s.GroupLabels.push(t);a.SelectedFacets.push(s)}else if(e){for(u=0;u<f.length;u++)a.removeStringFromArray(e.Labels,f[u]),o=$("#"+f[u]),o.prop("checked",!1);a.removeStringFromArray(e.GroupLabels,t)}return a.performSearch(!1),!0}return!1},this.dateFilterChecked=function(t,i,r,u){var f=ko.utils.arrayFirst(a.SelectedDateFacets(),function(n){return n.Name==="date"}),e;return r?(f?(ko.utils.arrayForEach(f.Labels,function(n){var t=$("#"+n);t.prop("checked",!1);f.Labels.pop()}),f.Labels.push(t)):(e=new n.Entities.SearchResultEntities.FacetArg,e.Name="date",e.Labels=[t],a.SelectedDateFacets.push(e)),i&&a.LastDays(i)):(f&&f.Labels.pop(),a.LastDays("")),u&&a.performSearch(!1),!0},this.showHideClearFilters=function(n){n?$(".wkis-filter-panel-clear").fadeIn(300):$(".wkis-filter-panel-clear").fadeOut(300)},this.clearFilters=function(){var f,i,o,s,e,t,r,u;if(a.SelectedMarketSegment(new n.Entities.SearchResultEntities.KeyValuePair),a.DisplaySelectedMarketSegment(!1),f=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="practiceAreas"}),f!=null)for(t=0;t<f.Labels.length;t++)r=f.Labels[t],u=$("#"+r),u.prop("checked",!1);if(a.SelectedFacets.remove(function(n){return n.Name==="practiceAreas"}),a.SelectedFacets.remove(function(n){return n.Name==="marketSegments"}),i=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="type"}),i!=null&&i.Labels.length>0){for(t=0;t<i.Labels.length;t++)r=i.Labels[t],u=$("#"+r),u.prop("checked",!1);if(i.GroupLabels&&i.GroupLabels.length>0)for(t=0;t<i.GroupLabels.length;t++)o=i.GroupLabels[t],s=$("#"+o),s.prop("checked",!1)}if(a.SelectedFacets.remove(function(n){return n.Name==="type"}),e=ko.utils.arrayFirst(a.SelectedDateFacets(),function(n){return n.Name==="date"}),e!=null)for(t=0;t<e.Labels.length;t++)r=e.Labels[t],u=$("#"+r),u.prop("checked",!1);a.SelectedDateFacets.remove(function(n){return n.Name==="date"});a.LastDays("");a.SearchTerm("");a.performSearch(!1)},this.movePage=function(n){a.RequestedPage=a.CurrentPage()+n;a.performSearch(!1)},this.incrementPage=function(){a.movePage(1)},this.decrementPage=function(){a.movePage(-1)},this.enterSearch=function(n,t){return t.keyCode===13&&a.performSearch(!1),!0},this.momentMonthDateYearFormat=function(n){return moment(n,"MM-DD-YYYY").format("MMMM DD, YYYY")},this.performSearch=function(t){var o,r,u,f,e,c,l;a.SearchTermForQuery=a.SearchTerm();o=a.RequestedPage>0?a.RequestedPage:1;a.RequestedPage=0;(a.SortBy()===null||a.SortBy().length===0)&&a.SortBy("title-az");var i="",s=function(n,t){i+=i?"&":"?";i+=encodeURIComponent(n)+"="+encodeURIComponent(t)},h=function(n,t){i+=i?"&":"?";i+=encodeURIComponent(n)+"="+t.map(function(n){return encodeURIComponent(n)}).join(",")};a.SearchTerm()&&s("query",a.SearchTerm());a.showHideClearFilters(a.SelectedFacets().length>0||a.SelectedDateFacets().length>0||a.SearchTerm()!=null&&a.SearchTerm().length>0);r=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="type"});r&&r.Labels&&r.Labels.length>0&&h("type",r.Labels);u=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="marketSegments"});u&&u.Labels&&u.Labels.length>0&&h("ms",u.Labels);f=ko.utils.arrayFirst(a.SelectedFacets(),function(n){return n.Name==="practiceAreas"});f&&f.Labels&&f.Labels.length>0&&h("pa",f.Labels);e=ko.utils.arrayFirst(a.SelectedDateFacets(),function(n){return n.Name==="date"});e&&e.Labels&&e.Labels.length>0&&h("lastdays",e.Labels);o>1&&s("page",o.toString());a.ResultsPerPage()&&a.ResultsPerPage()!==a.DefaultResultsPerPage&&s("resultsPerPage",a.ResultsPerPage());a.SortBy()&&a.SortBy()!==a.DefaultSortBy&&s("sortBy",a.SortBy());history.replaceState({},null,location.pathname+i+location.hash);c={IndexType:"resource",QueryStr:a.SearchTermForQuery,PageSize:a.ResultsPerPage(),Page:o,SortBy:a.SortBy(),Facets:a.SelectedFacets(),LastDays:a.LastDays()};c.ReturnFacets=[n.Entities.SearchResultEntities.FacetNames.MarketSegment,n.Entities.SearchResultEntities.FacetNames.PracticeArea,n.Entities.SearchResultEntities.FacetNames.Type];l=a;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(c),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){l.processJsonResult(n,t);t||$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})},this.processJsonResult=function(n,t){var f,s,v,e,h,c,u,y,p,l,w,o,r;if(t)for(f=0,s=n.Facets;f<s.length;f++)for(v=s[f],e=0,h=v.Items;e<h.length;e++)c=h[e],c.HitCount>0&&(u=$("#"+c.Label),u&&(u.css("display",""),y=$(u.parent()),y.css("display",""),p=$(u).attr("paortype"),l=$("[paortype='"+p+"']"),l&&l.css("display","")));else if(a.CurrentResultsSearchTerm(a.SearchTermForQuery),a.TotalRowsCount(n.TotalRowsCount),n.TotalRowsCount>0){for(w=new i,o=0;o<n.Rows.length;o++)r=n.Rows[o],r.HasMetaDate=a.dateNotNull(r.MetaDate),r.HasMetaTime=!1,r.HasAuthors=r.Authors&&r.Authors.length>0,r.HasDuration=a.durationNotNull(r.MetaDuration),a.checkOverlayGating(r),w.createResourceMetaDataItems(r),r.Title&&(r.Title=r.Title.replace(/(<p[^>]+?>|<p>|<\/p>)/img,""));a.TotalPages(n.PagesCount);a.ShowPagination(n.PagesCount>1);a.NoResults(!1);a.CurrentPage(n.Page);a.SearchResultItems(n.Rows);a.overlayForm&&a.overlayForm.length>0&&setTimeout(function(){$('a[data-modal="'+a.overlayForm+'"]').addClass("js-wkis-modal-open")},100)}else a.TotalPages(0),a.ShowPagination(!1),a.NoResults(!0),a.CurrentPage(0),a.SearchResultItems([])},this.checkOverlayGating=function(n){var i,t,r;if(n.overlayGated=!1,n.Gated&&n.GatingType&&n.GatingType.toLowerCase()==="overlay"&&a.overlayForm)if(a.jsonMaxGatedDays&&a.jsonMaxGatedDays.length!==0&&a.dateNotNull(n.Timestamp)){for(i=!1,t=0;t<a.jsonMaxGatedDays.length;t++)if(r=a.jsonMaxGatedDays[t][n.ContentTypeDisplayName],r>0){i=!0;n.overlayGated=a.datePlusDaysLessThanToday(new Date(n.Timestamp),r);break}i||(n.overlayGated=!0)}else n.overlayGated=!0;n.overlayGated?(n.Url="#",n.overlayForm=a.overlayForm):n.overlayForm=null},this.datePlusDaysLessThanToday=function(n,t){return new Date(n.getDate()+t)<new Date},this.durationNotNull=function(n){return n&&n.replace(/0/g,"").replace(/:/g,"")!==""},this.dateNotNull=function(n){return n&&n!=="0001-01-01T00:00:00"},this.timeNotNull=function(n){return n&&n.indexOf("T00:00:00")===-1},this.getLinkTarget=function(n){return a.isExternalLink(n)?"_blank":""},this.isExternalLink=function(n){if(a.isPathAbsolute(n)){var r=new URL(n),t=r.hostname,i=window.location.hostname;if(t&&i&&t.toLowerCase()!==i.toLowerCase())return!0}return!1},this.isPathAbsolute=function(n){return n?/(?:^[a - z][a - z0 - 9 +.-]*:|\/\/)/.test(n):!1},this.$container=$(t),this.OnInit=!0,this.RequestedPage=0,this.NoResults=ko.observable(!0),this.SearchTerm=ko.observable(""),this.SearchResultItems=ko.observableArray([]),this.SearchTermForQuery="",this.CurrentResultsSearchTerm=ko.observable(""),this.CurrentPage=ko.observable(0),this.TotalPages=ko.observable(0),this.TotalRowsCount=ko.observable(0),this.ShowPagination=ko.observable(!1),this.SelectedMarketSegment=ko.observable(new n.Entities.SearchResultEntities.KeyValuePair),this.DisplaySelectedMarketSegment=ko.observable(!1),this.DisplayRelatedPracticeAreas=ko.observable(!1),this.SelectedFacets=ko.observableArray([]),this.SelectedDateFacets=ko.observableArray([]),this.LastDays=ko.observable(""),this.DefaultSortBy="",this.DefaultResultsPerPage="",this.jsonMaxGatedDays=JSON.parse($("#jsonMaxGatedDays").attr("data-maxgateddays")),this.overlayForm=$("#jsonMaxGatedDays").attr("data-overlayform"),this.ValidSortBy=["title-az","title-za","author-az","author-za","timestamp-az","timestamp-za","relevance"],nt=$("#resultsSortByList").attr("initvalue"),this.DefaultSortBy=nt?nt:"title-az",this.SortBy=h!=null&&h.length>0&&this.ValidSortBy.indexOf(h.toLowerCase())>-1?ko.observable(h.toLowerCase()):ko.observable(this.DefaultSortBy),this.ValidResultsPerPage=["10","15","50","100","150","200"],tt=$("#resultsPerPageList").attr("initvalue"),this.DefaultResultsPerPage=tt?tt:"15",this.ResultsPerPage=c!=null&&c.length>0&&this.ValidResultsPerPage.indexOf(c)>-1?ko.observable(c):ko.observable(this.DefaultResultsPerPage),this.performSearch(!0),r!=null&&r.length>0&&(r=decodeURIComponent(r).replace("#",""),it=r.split(","),it.length>0&&(p=it[0],y=$(".wkis-market-segment-filter-list").find("#"+p),y!=null&&y.length>0&&this.clickedMarketSegmentAnchor(y[0].innerText,p,!1))),u!=null&&u.length>0&&(u=decodeURIComponent(u).replace("#",""),w=u.split(","),w.length>0))for(v=0;v<w.length;v++)p=$("#"+w[v]).attr("parent-ms-facet"),y=$(".wkis-market-segment-filter-list").find("#"+p),y!=null&&y.length>0&&(this.clickedMarketSegmentAnchor(y[0].innerText,p,!1),k=$("#"+w[v]),k.prop("checked",!0),this.paFilterChecked(w[v],!0,!1));if(f!=null&&f.length>0&&(f=decodeURIComponent(f).replace("#",""),b=f.split(","),b.length>0))for(v=0;v<b.length;v++)p=$("#"+b[v]).attr("parent-ms-facet"),y=$(".wkis-market-segment-filter-list").find("#"+p),y!=null&&y.length>0&&(this.clickedMarketSegmentAnchor(y[0].innerText,p,!1),k=$("#"+b[v]),k.prop("checked",!0),this.paFilterChecked(b[v],!0,!1));if(e!=null&&e.length>0&&(e=decodeURIComponent(e).replace("#",""),d=e.split(","),d.length>0))for(v=0;v<d.length;v++){var rt=$("#"+d[v]),ft=rt.attr("maingroup-title"),et=rt.attr("maingroup-index");ft&&et&&(rt.prop("checked",!0),this.typeFilterChecked(ft,et,d[v],!0,!1))}o!=null&&o.length>0&&(o=decodeURIComponent(o).replace("#",""),g=$(".datefacets").find("#"+o),g!=null&&g.length>0&&(ut=g.attr("date-range"),ut&&(g.prop("checked",!0),this.dateFilterChecked(o,ut,!0,!1))));this.SortBy.subscribe(function(){a.TotalRowsCount()>0&&a.performSearch(!1)});s!=null&&s.length>0&&(s=this.urldecode(s).replace("#",""),this.SearchTerm=ko.observable(s));l!=null&&l.length>0&&(l=decodeURIComponent(l).replace("#",""),this.RequestedPage=parseInt(l));this.ResultsPerPage.subscribe(function(){a.TotalRowsCount()>0&&a.performSearch(!1)});this.SortBy.extend({rateLimit:50});this.ResultsPerPage.extend({rateLimit:50});this.performSearch(!1)}return t.prototype.removeStringFromArray=function(n,t){for(var i=n.length-1;i>=0;i--)if(n[i]===t){n.splice(i,1);break}},t.prototype.arrayHasString=function(n,t){for(var i=n.length-1;i>=0;i--)if(n[i]===t)return!0},t}();t.KlLandingViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=n.Entities.SearchResultEntities.PressReleaseYearModel,r=function(){function n(n,t,r){var u=this,f;this.movePage=function(n){u.RequestedPage=u.CurrentPage()+n;u.performSearch()};this.incrementPage=function(){u.movePage(1)};this.decrementPage=function(){u.movePage(-1)};this.saveToSessionStorage=function(n,t){window.sessionStorage&&window.sessionStorage.setItem(u.sessionStoragePrefix+n,t)};this.retrieveFromSessionStorage=function(n){return window.sessionStorage?window.sessionStorage.getItem(u.sessionStoragePrefix+n):null};this.formatDate=function(n){return moment(n).format("MMMM DD, YYYY ")};this.performSearch=function(){var t=u.RequestedPage>0?u.RequestedPage:1,n,i,r,f;u.RequestedPage=0;n="";i=function(t,i){n+=n?"&":"?";n+=encodeURIComponent(t)+"="+encodeURIComponent(i)};u.ResultsPerPage()&&u.ResultsPerPage()!==u.DefaultResultsPerPage&&i("resultsPerPage",u.ResultsPerPage());t>1&&i("page",t.toString());history.replaceState({},null,location.pathname+n+location.hash);r={IndexType:u.SelectedTopFilter(),PageSize:u.ResultsPerPage(),Page:t,SortBy:u.SortBy()};f=u;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(r),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){f.processJsonResult(n);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})};this.processJsonResult=function(n){var f,s,t;if(u.TotalRowsCount(n.TotalRowsCount),n.TotalRowsCount>0){u.TotalPages(n.PagesCount);u.ShowPagination(n.PagesCount>0);u.CurrentPage(n.Page);u.SearchResultItems(n.Rows);var e=[],o="0",r=new i,h=n.Rows.length,c=ko.mapping.fromJS(u.SearchResultItems);for(f=0;f<h;f++)s=n.Rows[f].Timestamp,t=new Date(s).getFullYear().toString(),t!==o&&(r=new i,r.Year=t,r.PressReleaseItemModels=c.remove(function(n){var i=n.Timestamp(),r=new Date(i).getFullYear().toString();if(r===t)return n}),e.push(r)),o=t;u.SearchResultItems(e)}else u.TotalPages(0),u.ShowPagination(!1),u.CurrentPage(0),u.SearchResultItems([])};this.sessionStoragePrefix="pressReleases_";this.$container=$(n);this.OnInit=!0;this.RequestedPage=0;this.SearchResultItems=ko.observableArray([]);this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.ShowPagination=ko.observable(!1);this.NoResults=ko.observable(!0);this.ValidResultsPerPage=["10","20","50","100","150","200"];this.DefaultResultsPerPage="10";t!=null&&t.length>0&&this.ValidResultsPerPage.indexOf(t)>-1?this.ResultsPerPage=ko.observable(t):(f=this.retrieveFromSessionStorage("ResultsPerPage"),this.ResultsPerPage=f!=null&&f.length>0&&this.ValidResultsPerPage.indexOf(f)>-1?ko.observable(f):ko.observable(this.DefaultResultsPerPage));r!=null&&r.length>0&&(r=decodeURIComponent(r).replace("#",""),this.RequestedPage=parseInt(r));this.SortBy=ko.observable("timestamp-za");this.SelectedTopFilter=ko.observable("pressReleaseDetail");this.ResultsPerPage.subscribe(function(n){u.saveToSessionStorage("ResultsPerPage",n);u.TotalRowsCount()>0&&u.performSearch()});this.ResultsPerPage.extend({rateLimit:50});this.OnInit=!1;this.performSearch()}return n.isNaNModified=function(n){var t=parseFloat(n);return isNaN(t)||t.toString().length!=n.length},n}();t.PressReleasesLandingViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=n.Entities.SearchResultEntities.ResourceMetaDataMapper,r=function(){function n(n,t,r,u,f,e,o,s){var h=this,c,l,a,v;this.urldecode=function(n){return decodeURIComponent((n+"").replace(/\+/g,"%20"))};this.clickedTopFilterAnchor=function(n){h.OnInit||h.SelectedTopFilter()===n||(h.SelectedTopFilter(n),h.performSearch())};this.movePage=function(n){h.RequestedPage=h.CurrentPage()+n;h.performSearch()};this.incrementPage=function(){h.movePage(1)};this.decrementPage=function(){h.movePage(-1)};this.enterSearch=function(n,t){return t.keyCode===13&&h.performSearch(),!0};this.performSearch=function(){var i,u,f,e;h.SearchTermForQuery=h.SearchTerm();i=h.RequestedPage>0?h.RequestedPage:1;h.RequestedPage=0;var t="",n=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+encodeURIComponent(i)},r=h.ExpId.length>0&&h.ExpName.length>0&&h.SearchTerm()&&h.SearchTerm().indexOf(h.ExpName)>-1;r&&(n("expId",h.ExpId),n("expName",h.ExpName));h.SearchTerm()&&(r?(u=h.SearchTerm().replace(h.ExpName,"").trim(),u.length>0&&n("query",u)):n("query",h.SearchTerm()));h.SelectedTopFilter()&&h.SelectedTopFilter()!==h.DefaultFilter&&n("filter",h.SelectedTopFilter());h.ResultsPerPage()&&h.ResultsPerPage()!==h.DefaultResultsPerPage&&n("resultsPerPage",h.ResultsPerPage());h.SortBy()&&h.SortBy()!==h.DefaultSortBy&&n("sortBy",h.SortBy());i>1&&n("page",i.toString());history.replaceState({},null,location.pathname+t+location.hash);f=[];r&&(e={Name:"experts",Labels:[h.ExpId]},f.push(e));var s=h.SelectedTopFilter()==="product"?"product,productPlatform":h.SelectedTopFilter(),o={IndexType:s,QueryStr:r?h.SearchTermForQuery.replace(h.ExpName,"").trim():h.SearchTermForQuery,PageSize:h.ResultsPerPage(),Page:i,SortBy:h.SortBy(),Facets:f},c=h;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(o),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){window.dataLayer&&window.dataLayer.push({event:"searchSuccess",eventCategory:"Search",searchQuery:o.QueryStr,searchResult:n.TotalRowsCount});c.processJsonResult(n);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})};this.processJsonResult=function(n){var u,r,t;if(h.CurrentResultsSearchTerm(h.SearchTermForQuery),h.TotalRowsCount(n.TotalRowsCount),n.TotalRowsCount>0){for(u=new i,r=0;r<n.Rows.length;r++)t=n.Rows[r],t.HasMetaDate=h.dateNotNull(t.MetaDate),t.HasMetaTime=h.timeNotNull(t.MetaDate),t.HasAuthors=t.Authors&&t.Authors.length>0,t.HasDuration=h.durationNotNull(t.MetaDuration),t.HasShowableTimeStamp=!t.HasDuration&&t.ContentStyleType==="news"&&t.Timestamp&&t.Timestamp.length>0,t.Title&&(t.Title=t.Title.replace(/(<p[^>]+?>|<p>|<\/p>)/img,"")),h.checkOverlayGating(t),u.createResourceMetaDataItems(t);h.TotalPages(n.PagesCount);h.ShowPagination(n.PagesCount>1);h.NoResults(!1);h.CurrentPage(n.Page);h.SearchResultItems(n.Rows);h.overlayForm&&h.overlayForm.length>0&&setTimeout(function(){$('a[data-modal="'+h.overlayForm+'"]').addClass("js-wkis-modal-open")},100)}else h.TotalPages(0),h.ShowPagination(!1),h.NoResults(!0),h.CurrentPage(0),h.SearchResultItems([])};this.momentMonthDateYearFormat=function(n){return moment(n,"MM-DD-YYYY").format("MMMM DD, YYYY")};this.checkOverlayGating=function(n){var i,t,r;if(n.overlayGated=!1,n.Gated&&n.GatingType&&n.GatingType.toLowerCase()==="overlay"&&h.overlayForm)if(h.jsonMaxGatedDays&&h.jsonMaxGatedDays.length!==0&&h.dateNotNull(n.Timestamp)){for(i=!1,t=0;t<h.jsonMaxGatedDays.length;t++)if(r=h.jsonMaxGatedDays[t][n.ContentTypeDisplayName],r>0){i=!0;n.overlayGated=h.datePlusDaysLessThanToday(new Date(n.Timestamp),r);break}i||(n.overlayGated=!0)}else n.overlayGated=!0;n.overlayGated?(n.Url="#",n.overlayForm=h.overlayForm):n.overlayForm=null};this.datePlusDaysLessThanToday=function(n,t){return new Date(n.getDate()+t)<new Date};this.durationNotNull=function(n){return n&&n.replace(/0/g,"").replace(/:/g,"")!==""};this.dateNotNull=function(n){return n&&n!=="0001-01-01T00:00:00"};this.timeNotNull=function(n){return n&&n.indexOf("T00:00:00")===-1};this.getLinkTarget=function(n){return h.isExternalLink(n)?"_blank":""};this.isExternalLink=function(n){if(h.isPathAbsolute(n)){var r=new URL(n),t=r.hostname,i=window.location.hostname;if(t&&i&&t.toLowerCase()!==i.toLowerCase())return!0}return!1};this.isPathAbsolute=function(n){return n?/(?:^[a - z][a - z0 - 9 +.-]*:|\/\/)/.test(n):!1};this.$container=$(n);this.OnInit=!0;this.RequestedPage=0;this.NoResults=ko.observable(!0);this.SearchTerm=ko.observable("");this.SearchResultItems=ko.observableArray([]);this.SearchTermForQuery="";this.CurrentResultsSearchTerm=ko.observable("");this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.ShowPagination=ko.observable(!1);this.ExpId="";this.ExpName="";o!=null&&o.length>0&&(this.ExpId=o);s!=null&&s.length>0&&(this.ExpName=this.urldecode(s).replace("#",""));this.jsonMaxGatedDays=JSON.parse($("#jsonMaxGatedDays").attr("data-maxgateddays"));this.overlayForm=$("#jsonMaxGatedDays").attr("data-overlayform");this.ValidSortBy=["relevance","title-az","title-za","author-az","author-za"];c=$("#resultsSortByList").attr("initvalue");this.DefaultSortBy=c?c:"relevance";this.SortBy=u!=null&&u.length>0&&this.ValidSortBy.indexOf(u.toLowerCase())>-1?ko.observable(u.toLowerCase()):ko.observable(this.DefaultSortBy);this.ValidResultsPerPage=["10","50","100","150","200"];l=$("#resultsPerPageList").attr("initvalue");this.DefaultResultsPerPage=l?l:"10";this.ResultsPerPage=f!=null&&f.length>0&&this.ValidResultsPerPage.indexOf(f)>-1?ko.observable(f):ko.observable(this.DefaultResultsPerPage);this.ValidFilters=["all","product","resource","expert","event"];this.DefaultFilter="all";this.SelectedTopFilter=t!=null&&t.length>0&&this.ValidFilters.indexOf(t.toLowerCase().replace("#",""))>-1?ko.observable(t.toLowerCase().replace("#","")):ko.observable(this.DefaultFilter);e!=null&&e.length>0&&(e=decodeURIComponent(e).replace("#",""),this.RequestedPage=parseInt(e));r!=null&&r.length>0?(r=this.urldecode(r).replace("#",""),this.ExpName!=null&&this.ExpName.length>0&&(r+=" "+this.ExpName),this.SearchTerm=ko.observable(r)):this.SearchTerm=ko.observable(this.ExpName);this.SortBy.subscribe(function(){h.TotalRowsCount()>0&&h.performSearch()});this.ResultsPerPage.subscribe(function(){h.TotalRowsCount()>0&&h.performSearch()});this.SelectedTopFilter.subscribe(function(){h.TotalRowsCount()>0&&h.performSearch()});a=$("#pluralResultsLabel")[0];v=$("#resultLabel")[0];this.ResultLabel=ko.computed(function(){return h.TotalRowsCount()>1?a.innerText:v.innerText});this.SortBy.extend({rateLimit:50});this.ResultsPerPage.extend({rateLimit:50});this.SelectedTopFilter.extend({rateLimit:50});this.OnInit=!1;this.performSearch()}return n}();t.SearchResultsViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={}))