var ProductPageScripts,Basket,__extends,TagManager;(function(n){var t=function(){function n(n){this.Config=n;this.IsValid=!0}return n.prototype.BeginRequest=function(){this.RequestIsInProgress=!0;this.IsValid&&this.Config.OnBeginRequest!=null&&this.Config.OnBeginRequest()},n.prototype.EndRequest=function(){this.RequestIsInProgress=!1;this.IsValid?(this.OnSuccessfulRequest(),this.Config.OnEndRequest!=null&&this.Config.OnEndRequest()):this.ShowError()},n.prototype.IsInProgress=function(){return this.RequestIsInProgress},n.prototype.OnSuccessfulRequest=function(){if(this.OnAddToBasketSuccess!=null){var n=this.GetSelectedVariants();this.OnAddToBasketSuccess(n)}PRODUCT_PAGE_CONFIG.VariantsEnabled&&VariantsObject!=undefined&&VariantsObject.ClearSelectedVariants();BASKET_PANEL_CONFIG.ShowBasketPopup||this.ShowInfo()},n.prototype.ShowInfo=function(){$(".add-to-basket__btn-box").hasClass("basket__added-info")||($(".add-to-basket__btn-box").addClass("basket__added-info"),setTimeout(function(){return $(".add-to-basket__btn-box").removeClass("basket__added-info")},4e3))},n.prototype.ShowError=function(){$(".error-message:not(.basket-popup__add-message, .basket-popup__delete-message)").length>0&&$("html, body").animate({scrollTop:0},800)},n.prototype.Validate=function(){this.ValidateAmount($(this.Config.TbAmount));this.IsValid=!PRODUCT_PAGE_CONFIG.VariantsEnabled||VariantsObject!=undefined&&VariantsObject.GetSelectedVariants().length>0},n.prototype.ValidateAmount=function(n){var t,i;n.length>0&&(t=n.val(),$.isNumeric(t)?(i=parseInt(t),(i.toString()!==t||i<1)&&n.val("1")):n.val("1"))},n.prototype.GetSelectedVariants=function(){var t=[],n,i;return PRODUCT_PAGE_CONFIG.VariantsEnabled&&VariantsObject!=undefined?VariantsObject.GetSelectedVariants():($(this.Config.TbAmount).length>0&&(n=$(this.Config.TbAmount).val(),$.isNumeric(n)&&(i=parseInt(n),t.push({Id:null,Name:null,Quantity:i}))),t)},n}();n.AddToBasket=t})(ProductPageScripts||(ProductPageScripts={})),function(n){var t=function(){function n(n,t,i,r,u,f,e){this.name=n;this.id=t;this.price=i;this.brand=r;this.category=u;this.variant=f;this.quantity=e}return n.prototype.GetPropertiesFromProduct=function(n){this.name=n.name;this.id=n.id;this.price=n.price;this.brand=n.brand;this.category=n.category;this.variant=n.variant;this.quantity=n.quantity},n.prototype.AsIProduct=function(){return{name:this.name,id:this.id,price:this.price,brand:this.brand,category:this.category,variant:this.variant,quantity:this.quantity}},n}();n.BasketProduct=t}(Basket||(Basket={})),function(n){var t=function(){function n(n,t){this.DataLayer=n;this.EventName=t;this.EventRaised=!1;this.Validate=null}return n.prototype.PushToDataLayer=function(n,t){if(this.Validate==null||this.Validate()){var r=this.EventName!=null&&this.EventName!==""&&this.EventName!=undefined,i=t!=null&&t!==""&&t!=undefined;r?i?this.CreateEcommerceEventWithCallback(n,t):this.CreateEcommerceEvent(n):i?this.CreateEcommerceObjectWithCallback(n,t):this.CreateEcommerceObject(n)}},n.prototype.CreateEcommerceEvent=function(n){var t={event:this.EventName,ecommerce:n};this.DataLayer.push(t)},n.prototype.CreateEcommerceEventWithCallback=function(n,t){var i={event:this.EventName,ecommerce:n,eventCallback:function(){window.location.href=t}};this.DataLayer.push(i)},n.prototype.CreateEcommerceObject=function(n){var t={ecommerce:n};this.DataLayer.push(t)},n.prototype.CreateEcommerceObjectWithCallback=function(n,t){var i={ecommerce:n,eventCallback:function(){window.location.href=t}};this.DataLayer.push(i)},n}();n.TagManagerBase=t}(TagManager||(TagManager={}));__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)Object.prototype.hasOwnProperty.call(t,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){function t(t){return n.call(this,t,"addToCart")||this}return __extends(t,n),t.prototype.Invoke=function(n,t){this.PushToDataLayer({currencyCode:n,add:{products:t}})},t}(n.TagManagerBase),i;n.AddToCartEventBase=t;i=function(n){function t(t){return n.call(this,t)||this}return __extends(t,n),t.prototype.AddProducts=function(n,t,i){this.Invoke(n,this.GetAddedProducts(t,i))},t.prototype.GetAddedProducts=function(n,t){var i=[],u,r;if(t.length>0)for(u=function(r){var u=n.AsIProduct();u.quantity=t[r].Quantity;u.variant=t[r].Name!=undefined?t[r].Name:null;u.variant!=null&&i.some(function(n){return n.variant!=null&&n.variant!=undefined&&n.variant.toLowerCase()===u.variant.toLowerCase()})||i.push(u)},r=0;r<t.length;r++)u(r);else i.push(n.AsIProduct());return i},t}(t);n.AddToCartEvent=i}(TagManager||(TagManager={}))