"use strict";function _classCallCheck(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function");}function updateSizes(n,t,i){var f=n.find(".sizes-selector"),u,r,e;if(f.length!==0){for(f.empty(),u=[],r=0;r<i.length;r++)i[r].Color===t&&$.inArray(i[r].Size,u)<0&&u.push(i[r].Size);var o=n.find(".selected-size"),h=o.val(),s=!1;for(r=0;r<u.length;r++)e="",u[r]===h&&(e="selected",s=!0),f.append("<option value ='"+u[r]+"' "+e+">"+u[r]+" <\/option>");s||o.val(u[0])}}function updateNames(n,t,i){var f=n.find(".names-selector"),u,r,e;if(f.length!==0){for(f.empty(),u=[],r=0;r<i.length;r++)i[r].Color===t&&$.inArray(i[r].SkuName,u)<0&&u.push(i[r].SkuName);var o=n.find(".selected-name"),h=o.val(),s=!1;for(r=0;r<u.length;r++)e="",u[r]===h&&(e="selected",s=!0),f.append("<option value ='"+u[r]+"' "+e+">"+u[r]+" <\/option>");s||o.val(u[0])}}function _classCallCheck(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function");}function _classCallCheck(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function");}var _createClass=function(){function n(n,t){for(var i,r=0;r<t.length;r++)i=t[r],i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}return function(t,i,r){return i&&n(t.prototype,i),r&&n(t,r),t}}(),GiftOptions=function(){function n(t){_classCallCheck(this,n);this.init=this.init.bind(this);this.changeColor=this.changeColor.bind(this);this.changeSize=this.changeSize.bind(this);this.changeName=this.changeName.bind(this);this.getStockHtml=this.getStockHtml.bind(this);this.changeGiftOption=this.changeGiftOption.bind(this);this.getSelectedVariant=this.getSelectedVariant.bind(this);this.addFreeGift=this.addFreeGift.bind(this);this.callbackFunc=t}return _createClass(n,[{key:"init",value:function(){if($("#choose-gift-section").length!==0){$(".js-gift-option-table tr").each(function(){var n=$(this),u=n.find(".js-serialized-product").val(),f=JSON.parse(u),t=f.VariantOptions,i=t[0],r=i.Color,e=i.Size,o=i.SkuName;updateSizes(n,r,t);updateNames(n,r,t)});$(".colors-selector img").on("click",this.changeColor);$(".sizes-selector").on("change",this.changeSize);$(".names-selector").on("change",this.changeName);$(".add-free-gift").on("click",this.addFreeGift)}}},{key:"addFreeGift",value:function(n){var t=$(n.target),i=t.closest("tr"),r=t.closest("table"),u=i.find(".js-serialized-product").val(),f=JSON.parse(u),e=this.getSelectedVariant(i,f),o=r.data("promoId"),s={promoId:o,variantCode:e.VariationCode},h=this;$.ajax(app.WEB.postOptions(window.location.pathname,"chooseGift",s)).then(function(n){h.callbackFunc(n)}).fail(function(n){console.log(n);alert("An error occured while performing this action.")})}},{key:"changeColor",value:function(n){var r=$(n.target),t=r.closest("tr"),e=t.find(".js-serialized-product").val(),u=JSON.parse(e),f=u.VariantOptions,i=r.data("color");updateSizes(t,i,f);updateNames(t,i,f);t.find(".selected-color").val(i);this.changeGiftOption(t,u)}},{key:"changeSize",value:function(n){var i=$(n.target),t=i.closest("tr"),r=t.find(".js-serialized-product").val(),u=JSON.parse(r);t.find(".selected-size").val(i.val());this.changeGiftOption(t,u)}},{key:"changeName",value:function(n){var i=$(n.target),t=i.closest("tr"),r=t.find(".js-serialized-product").val(),u=JSON.parse(r);t.find(".selected-name").val(i.val());this.changeGiftOption(t,u)}},{key:"changeGiftOption",value:function(n,t){var i=this.getSelectedVariant(n,t);n.find(".main-image").attr("src",i.ImageUrl);n.find(".status").html(this.getStockHtml(i));n.find(".cart-item-itemPrice .strikethrough").html(i.Price)}},{key:"getSelectedVariant",value:function(n,t){for(var u,f=n.find(".selected-color").val(),e=n.find(".selected-size").val(),o=n.find(".selected-name").val(),h=n.find(".names-selector").length!=0,r=t.VariantOptions,i=0;i<r.length;i++){var c=f===""||r[i].Color===f,l=e===""||r[i].Size===e,s=o===""||r[i].SkuName===o;h==!1&&(s=!0);l&&c&&s&&(u=r[i],i=r.length)}return u}},{key:"getStockHtml",value:function(n){switch(n.StockStatusDto.Status){case 0:return'<span class="in-stock">'+n.StockStatusDto.Display+"<\/span>";case 1:return'<span class="out-of-stock">'+n.StockStatusDto.Display+"<\/span>";case 2:return'<span class="out-of-stock">'+n.StockStatusDto.Display+"<\/span>";case 3:return'<span class="limited-stock">'+n.StockStatusDto.Display+"<\/span>";default:return'<span class="out-of-stock">'+n.StockStatusDto.Display+"<\/span>"}}}]),n}(),CartPage,ExtendHelper;_createClass=function(){function n(n,t){for(var i,r=0;r<t.length;r++)i=t[r],i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}return function(t,i,r){return i&&n(t.prototype,i),r&&n(t,r),t}}();CartPage=function(){function n(){_classCallCheck(this,n);this.cartContainer=$("#shopping-cart-container");this.changeItemQuantity=this.changeItemQuantity.bind(this);this.saveForLaterItem=this.saveForLaterItem.bind(this);this.removeItem=this.removeItem.bind(this);this.saveBikeForLater=this.saveBikeForLater.bind(this);this.removeCustomBike=this.removeCustomBike.bind(this);this.removeSuspensionServiceItem=this.removeSuspensionServiceItem.bind(this);this.saveForLaterSuspensionServiceItem=this.saveForLaterSuspensionServiceItem.bind(this);this.removeSkuExtend=this.removeSkuExtend.bind(this);this.updateSkuExtend=this.updateSkuExtend.bind(this);this.displayExtendModal=this.displayExtendModal.bind(this);this.emptyCart=this.emptyCart.bind(this);this.updateCartAjaxCall=this.updateCartAjaxCall.bind(this);this.applyCouponCode=this.applyCouponCode.bind(this);this.removeCouponCode=this.removeCouponCode.bind(this);this.couponErrorContainer=$("#coupon-apply-error-message");this.updateShoppingCartHtml=this.updateShoppingCartHtml.bind(this);this.countryChange=this.countryChange.bind(this);this.changeSaveForLaterItemQuantity=this.changeSaveForLaterItemQuantity.bind(this);this.moveItemToCart=this.moveItemToCart.bind(this);this.handleEmployeeDiscount=this.handleEmployeeDiscount.bind(this);this.removeItemFromSaved=this.removeItemFromSaved.bind(this);this.applyShippingMethod=this.applyShippingMethod.bind(this);this.applyShippingAddress=this.applyShippingAddress.bind(this);this.renderPayPalButton=this.renderPayPalButton.bind(this);this.handleError=this.handleError.bind(this);this.trackCartUpdate=this.trackCartUpdate.bind(this);this.giftOptions=new GiftOptions(this.updateShoppingCartHtml);this.extendHelper=new ExtendHelper;this.exponeaTrackingHelper=new ExponeaTrackingHelper;this.isFirstLoad=!0;this.model=serverSideViewModel;this.giftOptions.init();this.model.lineItems.forEach(function(n){Extend.trackOfferViewed({productId:n.variationCode,offerType:{area:"cart_page",component:"buttons"}})})}return _createClass(n,[{key:"init",value:function(){$(document).on("click","[data-change-quantity]",this.changeItemQuantity);$(document).on("click","[data-remove-item]",this.removeItem);$(document).on("click","[data-save-for-later-bike]",this.saveBikeForLater);$(document).on("click","[data-remove-custom-bike]",this.removeCustomBike);$(document).on("click","[data-save-for-later-item]",this.saveForLaterItem);$(document).on("click","[data-remove-suspension-service-item]",this.removeSuspensionServiceItem);$(document).on("click","[data-save-for-later-suspension-service-item]",this.saveForLaterSuspensionServiceItem);$(document).on("click","[data-transition-bike-to-cart]",this.transitionBike);$(document).on("click","[data-coupon-code]",this.removeCouponCode);$(document).one("click","#apply-coupon-code",this.applyCouponCode);$(document).on("click","#emptry-cart",this.emptyCart);$(document).on("change","#countryDdl",this.countryChange);$(document).on("click","[data-change-save-for-later-quantity]",this.changeSaveForLaterItemQuantity);$(document).on("click","[data-move-item-to-cart]",this.moveItemToCart);$(document).on("click","[data-remove-item-from-saved]",this.removeItemFromSaved);$(document).on("click","[data-extend-plan]",this.displayExtendModal);this.applyCouponCodeOnEnterKey();this.applyZipCodeOnEnterKey();this.handleEmployeeDiscount();$(document).on("change",".custom-radio-btn",this.applyShippingMethod);$(document).on("click","#get-shipping-methods",this.applyShippingAddress);$(document).on("change","#regionDdl",this.applyShippingAddress);$(".modal-backdrop").length>0&&$(".modal-backdrop").remove();$(window).width()>768&&$("table.cart-item-list tr[data-line-item-id]:not(.visible-xs):even").css("background","#fff");var t=window.location.search,n=new URLSearchParams(t).get("emppurch");n!==null&&this.verifyEmployeeTokenAndSaveToCookie(n,this.applyEmployeeDiscount);this.renderPayPalButton()}},{key:"trackCartUpdate",value:function(n,t,i){var u=[],f=[],e=[],o=[],s=0,r,h;n!=="empty_cart"&&this.model.lineItems.forEach(function(t){n==="remove_item"&&t.lineItemId===i||(o.push(t.productCode),e.push({product_id:t.productCode,quantity:t.quantity}),f.push(t.variationCode),u.push({product_id:t.variantCode,quantity:t.quantity}),s+=t.quantity)});r=i!=""?this.model.lineItems.find(function(n){return n.lineItemId===i}):{};h={action:n,button_type:t.type,button_copy:t.text,page_type:"Shopping Cart Page",product_id:r.productCode,variant_id:r.variationCode,title:r.name,tags:r.hasExtendPlan?["has-extend-plan"]:[],category_name:r.categoryName,price:r.placedPrice!=undefined?r.placedPrice.amount:0,discount_value:r.placedPrice!=undefined?r.discountAmount.amount:0,local_currency:$("#currencySelector").html().substr($("#currencySelector").html().indexOf("(")+1,$("#currencySelector").html().indexOf(")")-$("#currencySelector").html().indexOf("(")-1),product_list:e,product_ids:o,variant_list:u,variant_ids:f,total_quantity:s,total_price:n==="empty_cart"?0:this.model.total.amount,total_price_local_currency:n==="empty_cart"?0:this.model.totalLocalCurrency.amount,total_price_without_tax:n==="empty_cart"?0:this.model.total.amount-this.model.tax.amount};this.exponeaTrackingHelper.trackCartUpdate(h)}},{key:"displayExtendModal",value:function(n){var i=n.currentTarget.dataset.variantId,t=this,r;t.lineItemId=n.currentTarget.dataset.lineItemId;r=n.currentTarget.parentElement.parentElement.parentElement.parentElement.querySelector(".quantity-td").children[0].querySelector(".quantityBox").value;$.get("/api/product/GetExtendOffers?productId="+i,null,function(n){var o,u,f,e;n!==null&&n.marketing!==null&&($("#offerList").html(""),o=t.extendHelper.getExtendHtml(n),$("#offerList").append(o.modalHtml),t.extendHelper.registerNewOfferSelectedClickHandler(),u=$("a[data-variant-id='"+i+"'][data-line-item-id='"+t.lineItemId+"']")[0],u!=null&&u.dataset.extendPlan!=""&&$("#protection-no-thanks").attr("data-line-id",t.lineItemId),f=null,$("#offerList div.offer").each(function(){u!=null&&$(this)[0].dataset.offerUrl==u.dataset.extendPlan?($(this).addClass("selected-offer"),f=$(this)[0].parentElement.id):$(this).removeClass("selected-offer")}),e=$("tr[data-variation-code='"+i+"']").find("div.imgBound").find("img"),$("#productName").html(e.prop("alt")),$("#productView img").attr("src",e.prop("src")),t.isFirstLoad?t.extendHelper.initializeFancyBox(t):$(".fancybox-container").show(),$("#add-product-protection").unbind(),$("#add-product-protection").click(function(){var n=$("div.offer.selected-offer"),u=t.lineItemId;if($(".fancybox-container").hide(),$("#protection-no-thanks").attr("data-line-id",u),n!=null&&n.length!==0){var e=$(n).parent()[0].id,o=$(n).find(".offerPlanPrice").html(),s=n[0].dataset.offerUrl;t.updateSkuExtend(u,i,r,e,f,s,o)}}),$("#protection-no-thanks").click(function(){var n=$("div.offer.selected-offer"),r=$(n).parent()[0].id;Extend.trackOfferRemovedFromCart({productId:i,planId:r});$(".fancybox-container").hide();t.removeSkuExtend(t.lineItemId);t.isFirstLoad=!1}),Extend.trackOfferViewed({productId:i,offerType:{area:"cart_page",component:"modal"}}))},"json")}},{key:"removeSkuExtend",value:function(n){var i={lineId:n},t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"removeExtend",i)).then(function(n){t.updateShoppingCartHtml(n);t.isFirstLoad=!1}).fail(function(n){t.updateShoppingCartHtml(n);t.isFirstLoad=!1})}},{key:"updateSkuExtend",value:function(n,t,i,r,u,f,e){var s={lineId:n,extendPlanId:r,extendPlanUrl:f,extendPlanPrice:e},o=this;$.ajax(app.WEB.postOptions(window.location.pathname,"updateExtendPlan",s)).then(function(n){o.updateShoppingCartHtml(n);o.isFirstLoad=!1;u!=null&&Extend.trackOfferRemovedFromCart({productId:t,planId:u});Extend.trackOfferAddedToCart({productId:t,productQuantity:Number(i),warrantyQuantity:Number(i),planId:r,offerType:{area:"cart_page",component:"modal"}})}).fail(function(n){o.updateShoppingCartHtml(n);o.isFirstLoad=!1})}},{key:"saveBikeForLater",value:function(n){var i={customBikeId:$(n.target)[0].attributes["bike-id"].value,emailAddress:window.BuilderEmail},t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"saveCustomBikeForLater",i)).then(function(n){t.updateShoppingCartHtml(n);alert("Bike saved for later. You can find your bike builds in your MyAccount portal")}).fail(function(n){t.updateShoppingCartHtml(n)})}},{key:"transitionBike",value:function(){$(".transition-build").html("Please wait, transitioning bike to cart");$.post("/api/Cart/transitionBikeBuildToCart",{CartId:window.cartId,AccessToken:window.at},function(){location.reload()},"json")}},{key:"removeCustomBike",value:function(){var n=this;$.ajax(app.WEB.postOptions(window.location.pathname,"removeCustomBikeBuild",{cartId:window.cartId,accessToken:window.at})).then(function(t){n.updateShoppingCartHtml(t)}).fail(function(t){n.updateShoppingCartHtml(t)})}},{key:"removeSuspensionServiceItem",value:function(n){var t=this,i=$(n.target)[0].attributes["data-service-item-id"].value;$.ajax(app.WEB.postOptions(window.location.pathname,"removeSuspensionServiceItem",{cartId:window.cartId,accessToken:window.at,suspensionServiceItemId:i})).then(function(n){t.updateShoppingCartHtml(n)}).fail(function(n){t.updateShoppingCartHtml(n)})}},{key:"saveForLaterSuspensionServiceItem",value:function(n){$(n.target).removeAttr("data-save-for-later-suspension-service-item");$(n.target).html("Loading");var i=$(n.target).closest("[data-service-item-id]").data("service-item-id"),r={lineItemId:i},t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"saveForLater",r)).then(function(n){n.url!=""&&n.url!=undefined?window.location.href=n.url:t.updateShoppingCartHtml(n)}).fail(function(n){t.handleError(n)})}},{key:"applyCouponCodeOnEnterKey",value:function(){$("#coupon-code").on("keypress",function(n){n.which===13&&($(this).attr("disabled","disabled"),$("#apply-coupon-code").trigger("click"),$(this).removeAttr("disabled"))})}},{key:"applyZipCodeOnEnterKey",value:function(){$("#postalCode").on("keypress",function(n){n.which===13&&($(this).attr("disabled","disabled"),$("#get-shipping-methods").trigger("click"),$(this).removeAttr("disabled"))})}},{key:"countryChange",value:function(n){var t=$(n.target).val();t==="USA"?($("#zipcode-form").show(),$("#regions-form").hide()):($("#zipcode-form").hide(),$("#regionDdl").empty(),$("#postalCode").val(""),$.ajax({url:"/API/CheckoutApi/LoadStatesForCountry?countryCode="+t,method:"POST",success:function(n){n.length==0?$("#regions-form").hide():($("#regions-form").show(),$.each(n,function(){$("#regionDdl").append($("<option>",{value:this.name,text:this.name}))}))}}))}},{key:"applyShippingMethod",value:function(n){var i={shippingMethodId:$(n.target).val()},t=this;$(".cart-info-loading").show();$.ajax(app.WEB.postOptions(window.location.pathname,"applyShippingMethod",i)).then(function(n){t.updateShoppingCartHtml(n);$("html, body").animate({scrollTop:$("#shopping-cart-container").offset().top},500);$(".cart-info-loading").hide()}).fail(function(n){t.handleError(n)})}},{key:"applyShippingAddress",value:function(n){var t={countryCode:$("#countryDdl").val(),region:$("#countryDdl").val()==="USA"?"":$("#regionDdl").val(),postalCode:$("#postalCode").val()},i=this;$("#get-shipping-methods").html("loading");$(n.target).removeAttr("id");$.ajax(app.WEB.postOptions(window.location.pathname,"applyShippingAddress",t)).then(function(){window.location.reload(!0)}).fail(function(n){i.handleError(n)})}},{key:"moveItemToCart",value:function(n){$(n.target).removeAttr("data-move-item-to-cart");$(n.target).html("Loading");var i={lineItemId:$(n.target).data("line-item-id"),variationCode:$(n.target).data("variation-code"),quantity:$(n.target).data("quantity")},t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"moveItemToCart",i)).then(function(n){t.updateShoppingCartHtml(n)}).fail(function(n){t.handleError(n)})}},{key:"changeSaveForLaterItemQuantity",value:function(n){$(n.target).removeAttr("data-change-save-for-later-quantity");$(n.target).html("Loading");var i=$(n.target).data("line-item-id"),r=$(n.target).data("cart-id"),u=$(n.target).data("variation-code"),f=$(n.target).siblings(".quantityBox")[0].value,t=this,e={savedForLaterCartId:r,lineItemId:i,variationCode:u,quantity:f};$.ajax(app.WEB.postOptions(window.location.pathname,"changeSaveForLaterItemQuantity",e)).then(function(n){t.updateShoppingCartHtml(n)}).fail(function(n){t.handleError(n)})}},{key:"removeItemFromSaved",value:function(n){$(n.target).removeAttr("data-change-save-for-later-quantity");$(n.target).html("Loading");var i={lineItemId:$(n.target).data("line-item-id"),quantity:0},t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"removeItemFromSavedForLater",i)).then(function(n){t.updateShoppingCartHtml(n)}).fail(function(n){t.handleError(n)})}},{key:"changeItemQuantity",value:function(n){var u=$(n.target).html(),f=$(n.target).parents("[data-line-item-id]")[0].dataset.lineItemId;$(n.target).removeAttr("data-change-quantity");$(n.target).html("Loading");var t=$(n.target).closest("[data-line-item-id]"),e=t.data("line-item-id"),i=t.data("variation-code"),r=$(n.target).closest("[data-line-item-id]").find(".quantityBox")[0].value,o={lineItemId:e,variationCode:i,quantity:r,email:window.BuilderEmail};this.updateCartAjaxCall(o);this.trackCartUpdate("change_quantity",{type:"Change Item Quantity",text:u},f);Extend.trackProductUpdated({productId:i,updates:{productQuantity:Number(r)}})}},{key:"removeItem",value:function(n){var u=$(n.target).html(),f=$(n.target).parents("[data-line-item-id]")[0].dataset.lineItemId,t=$(n.target).parents("[data-line-item-id]")[0].dataset.variationCode;$(n.target).removeAttr("data-remove-item");$(n.target).html("Loading");var i=$(n.target).closest("[data-line-item-id]").data("line-item-id"),e={lineItemId:i,quantity:0},r=$("a[data-variant-id='"+t+"'][data-line-item-id='"+i+"']")[0];(r==null||r.dataset.extendPlan=="")&&Extend.trackProductRemovedFromCart({productId:t});this.updateCartAjaxCall(e);this.trackCartUpdate("remove_item",{type:"Remove Item",text:u},f)}},{key:"emptyCart",value:function(n){var i=$(n.target).html(),t;$(n.target).html("Loading");t=this;$("#clear-cart").modal("hide");$.ajax(app.WEB.postOptions(window.location.pathname,"emptyCart")).then(function(n){t.trackCartUpdate("empty_cart",{type:"Empty Cart",text:i},"");t.updateShoppingCartHtml(n);$(".modal-backdrop").length>0&&$(".modal-backdrop").remove()}).fail(function(n){t.handleError(n)})}},{key:"saveForLaterItem",value:function(n){$(n.target).removeAttr("data-save-for-later-item");$(n.target).html("Loading");var i=$(n.target).closest("[data-line-item-id]").data("line-item-id"),r={lineItemId:i},t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"saveForLater",r)).then(function(n){n.url!=""&&n.url!=undefined?window.location.href=n.url:t.updateShoppingCartHtml(n)}).fail(function(n){t.handleError(n)})}},{key:"applyCouponCode",value:function(){var t=this,i=$("#coupon-code").val(),r={couponCode:i,userEmail:window.BuilderEmail},n=this;$("#apply-coupon-code").html("loading");n.couponErrorContainer.hide();$.ajax(app.WEB.postOptions(window.location.pathname,"applyCouponCode",r)).then(function(i){if(i.url!=""&&i.url!=undefined)window.location.href=i.url;else{n.updateShoppingCartHtml(i);$(document).one("click","#apply-coupon-code",t.applyCouponCode)}n.trackCartUpdate("coupon_code_applied",{type:"Coupon Code",text:"Add Code"},"")}).fail(function(i){n.handleError(i);$(document).one("click","#apply-coupon-code",t.applyCouponCode)})}},{key:"removeCouponCode",value:function(n){$(n.target).html("Loading");var i=$(n.target).closest("[data-coupon-code]").data("coupon-code"),r={couponCode:i},t=this;t.couponErrorContainer.hide();$.ajax(app.WEB.postOptions(window.location.pathname,"removeCouponCode",r)).then(function(n){t.updateShoppingCartHtml(n);t.trackCartUpdate("coupon_code_removed",{type:"Coupon Code",text:"Remove Code"},"")}).fail(function(n){t.handleError(n)})}},{key:"updateCartAjaxCall",value:function(n){var t=this;$.ajax(app.WEB.postOptions(window.location.pathname,"updateItemQuantity",n)).then(function(n){t.updateShoppingCartHtml(n);t.model=serverSideViewModel}).fail(function(n){t.handleError(n)})}},{key:"updateShoppingCartHtml",value:function(n){if(n.hasOwnProperty("errorMessage")&&n.errorMessage!=undefined){alert(n.errorMessage);return}this.cartContainer.html(n);this.renderPayPalButton();var t=this;$.ajax({url:"/Navigation/MiniCart",method:"GET",success:function(n){$("#shopping-cart").replaceWith(n);t.applyCouponCodeOnEnterKey();t.applyZipCodeOnEnterKey()}});this.giftOptions.init()}},{key:"renderPayPalButton",value:function(){var n=$("#paypal-button-container1"),t,i;n.length!=0&&(t=$(n).data("checkout-url"),i=$(n).data("environment"),["#paypal-button-container1","#paypal-button-container2","#paypal-button-container3"].forEach(function(n){paypal.Button.render({env:i=="live"?"production":"sandbox",commit:!1,payment:function(){return paypal.request.post("/api/checkoutApi/CreatePayPalAuthorizationPayment?isCheckoutCart=false").then(function(n){return n.paymentID})},onAuthorize:function(n){window.location=t+"?paymentId="+n.paymentID+"&payerId="+n.payerID}},n)}))}},{key:"handleEmployeeDiscount",value:function(){var u=window.location.search,i=new URLSearchParams(u).get("emppurch"),n;if(i!==null)this.verifyEmployeeTokenAndSaveToCookie(i,this.applyEmployeeDiscount);else if(n=document.cookie.split("; ").find(function(n){return n.startsWith("EmployeePurchaseToken")}),n!==null&&n!=undefined){var f=n.substring(22,n.length),r=window.BuilderEmail,e=r.substring(r.length-14,19)=="@jensonusa.com"?!0:!1,t=this;f==""&&e&&$.ajax(app.WEB.postOptions(window.location.pathname,"RemoveEmployeeDiscount")).then(function(n){t.updateShoppingCartHtml(n);t.trackCartUpdate("employee_coupon_code_added",{type:"",text:""},"")}).fail(function(n){t.handleError(n)})}}},{key:"verifyEmployeeTokenAndSaveToCookie",value:function(n,t){var i={token:n,userEmail:window.BuilderEmail,completePurchase:!1};$.get(window.location.pathname+"VerifyEmployeeToken",i,function(n){n.url!==""&&n.url!==undefined?window.location.href=n.url:n.tokenValidAndActive&&$.post(window.location.pathname+"AddTokenToCookie",{token:n.token},function(n){n=="True"&&t()})},"json")}},{key:"applyEmployeeDiscount",value:function(){var n={email:window.BuilderEmail};window.BuilderEmail!==""&&$.get(window.location.pathname+"ApplyJensonEmployeeDiscount",n,function(n){n.success&&window.location.replace(window.location.origin+"/cart")},"json")}},{key:"handleError",value:function(n){app.API.handleEmptyCartIdError(n)||(console.log(n),alert("An error occured while performing this action."))}}]),n}();$(function(){var n=new CartPage;n.init()});_createClass=function(){function n(n,t){for(var i,r=0;r<t.length;r++)i=t[r],i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}return function(t,i,r){return i&&n(t.prototype,i),r&&n(t,r),t}}();ExtendHelper=function(){function n(){_classCallCheck(this,n);this.getExtendHtml=this.getExtendHtml.bind(this)}return _createClass(n,[{key:"getExtendHtml",value:function(n){var i=0,e=null,o="",f="",s="",t,r,u;for(t in n.plans.adh)s+="<div class=' offers' id='"+n.plans.adh[t].id+"'><div data-offer-url='"+n.plans.adh[t].url+"' class='pdp-offer'> <span class='pdp-offer-length'>"+parseInt(n.plans.adh[t].contract.termLength/12)+"<\/span> Year - $<span class='pdp-offer-price'>"+parseFloat(n.plans.adh[t].price*.01).toFixed(2)+"<\/span> <\/div><\/div>",i==0&&(o=n.plans.adh[t].url),r="",u="<div data-offer-url='"+n.plans.adh[t].url+"' class='offer'> ",i==1&&(r=" <div class='ribbon'> <div class='txt' >Top Seller<\/div> <\/div>"),i==2&&(u="<div data-offer-url='"+n.plans.adh[t].url+"' class='offer'> ",r=" <div class='ribbon'> <div class='txt' > Best Value<\/div> <\/div>"),i==1?e="<li id='"+n.plans.adh[t].id+"'> "+u+r+"<span class='offerLength'> "+parseInt(n.plans.adh[t].contract.termLength/12)+" Year <\/span> <span class='offerPlanDesc'> Protection Plan <\/span> <span class='offerPlanPrice'> "+parseFloat(n.plans.adh[t].price*.01).toFixed(2)+"<\/span> ea.<\/div> <\/li>":f+="<li id='"+n.plans.adh[t].id+"'> "+u+r+"<span class='offerLength'> "+parseInt(n.plans.adh[t].contract.termLength/12)+" Year <\/span> <span class='offerPlanDesc'> Protection Plan <\/span> <span class='offerPlanPrice'> "+parseFloat(n.plans.adh[t].price*.01).toFixed(2)+"<\/span> ea.<\/div> <\/li>",i++;return f+=e,{modalHtml:f,firstOfferUrl:o,pdpExtendButtonsHtml:s}}},{key:"initializeButtonsText",value:function(n){n!=null&&n.dataset.extendPlan!=""?($("#protection-no-thanks").html("Remove protection"),$("#add-product-protection").val("Edit Protection")):($("#add-product-protection").val("Add Protection"),$("#protection-no-thanks").html("No thanks"))}},{key:"registerNewOfferSelectedClickHandler",value:function(){$(function(){$(".offer").on("click tap touchstart",function(){var n=this;$(".offer").each(function(){$(this).removeClass("selected-offer")});$(n).addClass("selected-offer")})})}},{key:"initializeFancyBox",value:function(){var n=arguments.length<=0||arguments[0]===undefined?null:arguments[0];$("#productProtection").fancybox({type:"inline",autoSize:!1,width:520,height:700,scrolling:"yes",touch:{vertical:!1,momentum:!1},afterClose:function(){n!=null&&(n.isFirstLoad&&(n.isFirstLoad=!0),n.triggerAddToCartFromExtendModal&&(Cookies.set(n.showExtendCookieName,"false"),n.triggerAddToCartFromExtendModal=!1,n.addToCart()))}}).trigger("click");$("#productProtection").css("width","520px");$("#productProtection").css("height","700px")}}]),n}()