$(document).ready(function(){var $productGrid=document.querySelector("#ProductGridContainer")||null;window.initPartnerSlider=function(){$(".partner_slider_new").each(function(key,val){var id1="",sliderId_1="",id1=$(this).attr("id"),sliderId_1="#"+id1;$(sliderId_1).hasClass("slick-initialized")||($(sliderId_1).slick({slidesToShow:4,slidesToScroll:3,infinite:!1,prevArrow:$("#l_"+id1),nextArrow:$("#r_"+id1),variableWidth:!0,speed:1e3,responsive:[{breakpoint:1200,settings:{slidesToShow:3,slidesToScroll:2,infinite:!1,variableWidth:!0,speed:1e3}},{breakpoint:1024,settings:{slidesToShow:2,slidesToScroll:2,infinite:!1,variableWidth:!0,speed:1e3}},{breakpoint:768,settings:{slidesToShow:1,slidesToScroll:1,infinite:!0,variableWidth:!0,speed:500}},{breakpoint:480,settings:{slidesToShow:1,slidesToScroll:1,infinite:!0,variableWidth:!0,speed:500}}]}),setTimeout(()=>{const slickSlides=$(sliderId_1).find(".slick-list .slick-slide");adaFormatSlickSlides(slickSlides)},250)),$("#l_"+id1).hide(),$(sliderId_1).on("afterChange",function(event,slick,currentSlide){currentSlide===0?$("#l_"+id1).hide():$("#l_"+id1).show()})})},window.initPartnerSlider(),window.initProductSlider=function(){$(".product-list-contain").each(function(key,val){var id=$(this).attr("id"),sliderId="#"+id;$(sliderId).not(".slick-initialized").slick({variableWidth:!0,dots:!0,infinite:!0,speed:300,slidesToShow:3,slidesToScroll:1,prevArrow:$(this).parent().find(".prev"),nextArrow:$(this).parent().find(".next"),responsive:[{breakpoint:1200,settings:{slidesToShow:2,slidesToScroll:1,infinite:!0,dots:!0}},{breakpoint:768,settings:{slidesToShow:1,slidesToScroll:1,arrows:!1}}]}),setTimeout(()=>{const slickSlides=$(sliderId).find(".slick-list .slick-slide");adaFormatSlickSlides(slickSlides)},250)})},window.initProductSlider(),$(document).on("click",".freq-select-products",function(){if($(".button-cart-frequent").attr("product-list")=="Cart Page")var productList="ATTACH :: Cart Page";else var mpn_handle=$("#mpn_handle").val(),productList="Shopify Rec :: "+mpn_handle;localStorage.setItem("product-click",productList)}),$(document).on("change",".frequent-products-checkbox",function(){var checkLength=$("input[name='frequent-products-pdp']:checked").length;$("#checked-products").text(checkLength),checkLength==0?$("#card-button").prop("disabled",!0):$("#card-button").prop("disabled",!1);var product_id=$(this).val(),prodtitle=$("#title_"+product_id).val(),prodMPN=$("#product_mpn_handle_"+product_id).val(),prodType=$(".card_product_category_"+product_id).val(),prodCurrency=$(".card_product_currency_"+product_id).attr("value"),prodPrice=$(".card_product_price_"+product_id).attr("value"),compareprice=$(".card_product_compare_"+product_id).attr("value"),prodSku=$(".card_product_sku_"+product_id).attr("value");prodPrice=Number(prodPrice.replace(/[^0-9.-]+/g,"")),prodPrice=parseFloat(prodPrice);var prodSku=$(".card_product_sku_"+product_id).attr("value");if($(".button-cart-frequent").attr("product-list")=="Cart Page")var productList="ATTACH :: Cart Page";else var mpn_handle=$("#mpn_handle").val(),productList="Shopify Rec :: "+mpn_handle;localStorage.setItem("product-click",productList),dataLayer.push({ecommerce:null}),dataLayer.push({event:"select_item",ecommerce:{item_list_name:productList,items:[{item_id:prodSku,item_name:prodtitle,item_category:prodType,price:prodPrice,quantity:1}]}})}),$(document).on("click","#card-button",function(event){event.preventDefault(),$(".button-cart-frequent").attr("aria-disabled",!0),$(".button-cart-frequent").addClass("loading"),$(".loading-overlay__spinner-frequent").removeClass("hidden");var frequentProducts=[],frequentProducts_ga=[],tax_total_quantity=0,quncheck=[],prodTitle=[],value_price=0,prodCurrency=$("#prod_currency").val();if($.each($("input[name='frequent-products-pdp']:checked"),function(){var prodId=$("#product_id_"+$(this).val()).val(),prodQuant=1,prodMaxqut=$("#product_max_quantity_"+$(this).val()).val(),prodtitle=$("#title_"+$(this).val()).val(),prodMPN=$("#product_mpn_handle_"+$(this).val()).val(),prod_handle=$("#card_product_handle_"+$(this).val()).val(),prodPreorder=$("#card_product_preorder_"+$(this).val()).val(),prodPreorderMessage=$("#card_product_preorder_message_"+$(this).val()).val(),prodTradeIn=$("#card_product_tradein_"+$(this).val()).val();if(prodMaxqut!=""){var maxQuant=checkMaxquantity(prodId);if(maxQuant!="")var max_total_quantity=parseInt(prodQuant)+parseInt(maxQuant);else var max_total_quantity=parseInt(prodQuant);max_total_quantity>prodMaxqut&&(quncheck.push(1),prodTitle.push(prodtitle))}var taxtags_fb=$("#tags_"+$(this).val()).val(),addtaxfree=taxtags_fb.indexOf("taxfree")!=-1;addtaxfree==!0&&tax_total_quantity++,item={},item.quantity="quantity:1",item.id=$(this).val(),item.properties={_uuid:prod_handle,...prodPreorder==="true"&&{_preOrder:"true"},...prodPreorderMessage&&{_preOrderMessage:prodPreorderMessage},...prodTradeIn==="true"&&{_tradeInEligible:"true"}},frequentProducts.push(item);var prodType=$(".card_product_category_"+$(this).val()).val(),prodPrice=$(".card_product_price_"+$(this).val()).attr("value"),prodSku=$(".card_product_sku_"+$(this).val()).attr("value"),compareprice=$(".card_product_compare_"+$(this).val()).attr("value"),productList=$(".button-cart-frequent").attr("product-list"),mpn_handle=$("#mpn_handle").val(),shopify_rec="Shopify Rec :: "+mpn_handle;prodPrice=Number(prodPrice.replace(/[^0-9.-]+/g,"")),value_price+=parseFloat(prodPrice),value_price=parseFloat(value_price);var productPrice1=parseFloat(prodPrice);item_ga={},item_ga.item_id=prodSku,item_ga.item_name=prodtitle,item_ga.item_category=prodType,item_ga.item_list_name=shopify_rec,item_ga.price=parseFloat(productPrice1),item_ga.quantity=1,frequentProducts_ga.push(item_ga)}),jQuery.inArray(1,quncheck)!==-1){var prod_title=prodTitle.join();return alert(quantity_limit_error_message+" "+prod_title),$(".button-cart-frequent").attr("aria-disabled",!1),$(".button-cart-frequent").removeClass("loading"),$(".loading-overlay__spinner-frequent").addClass("hidden"),!1}if(vat_free_day==!0){if(getCookie("total_quantity")=="")var tax_total_quantity=parseInt(tax_total_quantity);else var tax_total_quantity=parseInt(tax_total_quantity)+parseInt(getCookie("total_quantity"));if(tax_total_quantity>vat_free_quantity)return alert(vat_free_message),$(".button-cart-frequent").attr("aria-disabled",!1),$(".button-cart-frequent").removeClass("loading"),$(".loading-overlay__spinner-frequent").addClass("hidden"),!1}const adobeItems=frequentProducts.map(item2=>({...item2,quantity:item2.quantity?.replace("quantity:","")||1}));return fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:frequentProducts})}).then(response=>{response.json().then(d=>{var mpn_handle=$("#mpn_handle").val(),shopify_rec="Shopify Rec :: "+mpn_handle,exphone_fa=[];JSON.parse(localStorage.getItem("cart"))!=null&&(exphone_fa=JSON.parse(localStorage.getItem("cart")));for(var i=0;i0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")}),dataLayer.push({ecommerce:null}),dataLayer.push({event:"add_to_cart",ecommerce:{value:value_price,currency:prodCurrency,items:frequentProducts_ga}}),$(".button-cart-frequent").attr("aria-disabled",!1),$(".button-cart-frequent").removeClass("loading"),$(".loading-overlay__spinner-frequent").addClass("hidden"),window.location.href.indexOf("/cart")>-1&&window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)),!1});function quickAddEvents(){$(".slider-form").click(function(evt){evt.preventDefault();var mpn_handle=$("#mpn_handle").val(),pageName=window.location.href,prodId=$(this).attr("data-productid"),prodQuant=1,prodMaxqut=$(this).attr("data-productmaxquantity"),cartpage=$(this).attr("data-cartpage");if(cartpage=="Cart Page")var attach="ATTACH :: Cart Page";else var attach="ATTACH :: ";if(prodMaxqut!=""){var maxQuant=checkMaxquantity(prodId);if(maxQuant!="")var max_total_quantity=parseInt(prodQuant)+parseInt(maxQuant);else var max_total_quantity=parseInt(prodQuant);if(max_total_quantity>prodMaxqut)return alert(quantity_limit_error_message),!1}var slider_variantid=$(this).attr("data-variantid"),slider_tag=$(this).attr("data-tag"),collection_name=$(this).attr("data-collection"),main_product_sku=$(this).attr("data-productsku");if(pageName.includes("products"))var mpn_handle=$("#mpn_handle").val(),productList=mpn_handle;else if(pageName.includes("search"))var productList="Search Results";else var productList=formatString($(this).attr("data-productlist"));var productCategory=$(this).attr("data-producttype"),productPrice=$(this).attr("data-productprice"),productcomPrice=$(this).attr("data-productcompprice"),productCurrency=$(this).attr("data-productcurrency"),productTitle=$(this).attr("data-producttitle"),productMPN=$(this).attr("data-productMPN"),productHandle=$(this).attr("data-producthandle"),productPreOrder=$(this).attr("data-productpreorder"),productPreOrderMessage=$(this).attr("data-productpreordermessage"),productTradeIn=$(this).attr("data-producttradein");if(vat_free_day==!0){var addtaxfree=slider_tag.indexOf("taxfree")!=-1;if(addtaxfree==!0&&getCookie("total_quantity")>=vat_free_quantity)return alert(vat_free_message),!1}$("#slider-form-"+slider_variantid).attr("aria-disabled",!0),$("#slider-form-"+slider_variantid).addClass("loading"),$(".loading-overlay__spinner-frequent").removeClass("hidden");var uid=productHandle;const props={_uuid:uid,...productPreOrder==="true"&&{_preOrder:"true"},...productPreOrderMessage&&{_preOrderMessage:productPreOrderMessage},...productTradeIn==="true"&&{_tradeInEligible:"true"}};var items=[{id:slider_variantid,quantity:1,properties:props}];const adobeItems=[];return items.forEach(item2=>{adobeItems.push({id:item2.id,quantity:item2.quantity})}),fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:slider_variantid,quantity:1,properties:{_uuid:productHandle,...productPreOrder==="true"&&{_preOrder:"true"},...productPreOrderMessage&&{_preOrderMessage:productPreOrderMessage},...productTradeIn==="true"&&{_tradeInEligible:"true"}}}]})}).then(response=>{if(response.json().then(d=>{cartCookie(productMPN,d.items[0].key,prod_list)}),cartpage=="Cart Page")var prod_list=attach;else if(pageName.includes("search"))var prod_list=productList;else var prod_list=attach+productList;if(triggerGAAddToCart(productcomPrice,main_product_sku,productTitle,productCategory,prod_list,productCurrency,productPrice,prodQuant,main_product_sku,slider_variantid),adobeTrackAddToCart({items:adobeItems,context:"Quick Add",$trigger:this}),cartpage=="Cart Page")return window.onCartUpdate({scrollToTop:!0}),!1;$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")}),$("#slider-form-"+slider_variantid).attr("aria-disabled",!1),$("#slider-form-"+slider_variantid).removeClass("loading"),$(".loading-overlay__spinner-frequent").addClass("hidden")}).catch(error=>(console.error("Error:",error),!1)),!1})}quickAddEvents(),window.quickAddEvents=quickAddEvents,$(document).on("click",".add-cart-apple-care",function(e){e.preventDefault(),$(this).prop("disabled",!0);var add_button=$(this),product_id=add_button.data("variantid"),main_product_index=add_button.data("forproduct"),wp_idx=add_button.data("forwproduct"),wp_key=add_button.data("forwkey"),previous_uid=add_button.data("uuid"),main_product_parent=$("#CartItem-"+main_product_index),has_applcr_sku=main_product_parent.data("applecare_sku").trim(),has_applcr_handle=main_product_parent.data("applecare_handle"),has_sw_sku=main_product_parent.data("secwarranty_sku").trim(),has_sw_handle=main_product_parent.data("secwarranty_handle"),main_product_quantity=main_product_parent.find(".quantity__input").val(),main_product_sku=add_button.data("skuparent"),main_product_handle=add_button.data("handleparent"),main_product_preorder=add_button.data("preorderparent"),main_product_preorder_message=add_button.data("preordermessageparent"),main_product_trade_in=add_button.data("tradeinparent"),main_product_key=add_button.data("keyparent"),aplCr_sku=add_button.data("skuaplcr"),applecarempn=add_button.data("mpnaplcr"),aplCr_handle=add_button.data("handleaplcr"),main_mpn_value=add_button.data("mpnparent"),additional_flag=add_button.data("reference"),main_product_tags=main_product_parent.find(".cart_tax_tags").val();const tradeInValue=$(main_product_parent).data("tradeInValue"),tradeInDevice=$(main_product_parent).data("tradeInDevice");var preorder="";main_product_preorder&&(preorder='", "_preOrder": "true');var preordermessage="";main_product_preorder_message&&(preordermessage='", "_preOrderMessage": "'+main_product_preorder_message);var trade_in="";main_product_trade_in&&(trade_in='", "_tradeInEligible": "true');let trade_in_value="";tradeInValue&&(trade_in_value=`", "_tradeIn_value": "${tradeInValue.toString().replace(".","")}`);let trade_in_device="";if(tradeInDevice&&(trade_in_device=`", "_tradeIn_device": "${tradeInDevice}`),additional_flag=="secwr")if(has_applcr_sku){var uid=main_product_handle+"-"+has_applcr_handle+"-"+aplCr_handle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");var data='{ "line":"'+main_product_index+'", "quantity": '+main_product_quantity+', "properties":{ "_uuid": "'+uid+preorder+preordermessage+trade_in+trade_in_value+trade_in_device+'", "_applecare_sku": "'+has_applcr_sku+'", "_applecare_handle": "'+has_applcr_handle+'", "_secWarranty_sku": "'+aplCr_sku+'", "_secWarranty_handle": "'+aplCr_handle+'" } }'}else{var uid=main_product_handle+"-"+aplCr_handle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");var data='{ "line":"'+main_product_index+'", "quantity": '+main_product_quantity+', "properties":{ "_uuid": "'+uid+preorder+preordermessage+trade_in+trade_in_value+trade_in_device+'", "_secWarranty_sku": "'+aplCr_sku+'", "_secWarranty_handle": "'+aplCr_handle+'" } }'}else if(has_sw_sku){var uid=main_product_handle+"-"+aplCr_handle+"-"+has_sw_handle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");var data='{ "line":"'+main_product_index+'", "quantity": '+main_product_quantity+', "properties":{ "_uuid": "'+uid+preorder+preordermessage+trade_in+trade_in_value+trade_in_device+'", "_secWarranty_sku": "'+has_sw_sku+'", "_secWarranty_handle": "'+has_sw_handle+'", "_applecare_sku": "'+aplCr_sku+'", "_applecare_handle": "'+aplCr_handle+'" } }'}else{var uid=main_product_handle+"-"+aplCr_handle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");var data='{ "line":"'+main_product_index+'", "quantity": '+main_product_quantity+', "properties":{ "_uuid": "'+uid+preorder+preordermessage+trade_in+trade_in_value+trade_in_device+'", "_applecare_sku": "'+aplCr_sku+'", "_applecare_handle": "'+aplCr_handle+'" } }'}if(!has_applcr_sku&&!has_sw_sku)var wp_idx=0;$.ajax({url:`${window.Shopify.routes.root}cart/change.js`,type:"POST",data,contentType:"application/json",dataType:"json",success:function(data2){if(wp_idx>=1){if(has_applcr_sku)var newWpKey=data2.items.find(item2=>item2.properties?._aplcr_main_product_sku===main_product_sku&&item2.properties?._uuid===previous_uid)?.key||wp_key,data22='{ "id":"'+newWpKey+'", "quantity": '+main_product_quantity+', "properties": { "_aplcr_main_product_sku": "'+main_product_sku+'", "_aplcr_main_product_handle": "'+main_product_handle+'", "_uuid": "'+uid+trade_in_value+trade_in_device+'" } }';else var newWpKey=data2.items.find(item2=>item2.properties?._sw_main_product_sku===main_product_sku&&item2.properties?._uuid===previous_uid)?.key||wp_key,data22='{ "id":"'+newWpKey+'", "quantity": '+main_product_quantity+', "properties": { "_sw_main_product_sku": "'+main_product_sku+'", "_sw_main_product_handle": "'+main_product_handle+'", "_uuid": "'+uid+trade_in_value+trade_in_device+'" } }';$.ajax({url:`${window.Shopify.routes.root}cart/change.js`,type:"POST",data:data22,contentType:"application/json",dataType:"json",success:function(data3){additional_flag=="secwr"?has_applcr_sku?fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_sw_main_product_sku:main_product_sku,_sw_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)):fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_sw_main_product_sku:main_product_sku,_sw_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)):has_sw_sku?fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_aplcr_main_product_sku:main_product_sku,_aplcr_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)):fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_aplcr_main_product_sku:main_product_sku,_aplcr_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1))}})}else additional_flag=="secwr"?has_applcr_sku?fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_sw_main_product_sku:main_product_sku,_sw_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)):fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_sw_main_product_sku:main_product_sku,_sw_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)):has_sw_sku?fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_aplcr_main_product_sku:main_product_sku,_aplcr_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1)):fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:product_id,quantity:main_product_quantity,properties:{_aplcr_main_product_sku:main_product_sku,_aplcr_main_product_handle:main_product_handle,_uuid:uid}}]})}).then(response=>{console.log(response.json()),window.onCartUpdate()}).catch(error=>(console.error("Error:",error),!1))}})}),$(document).on("click",".add-cart-trade-in",function(e){e.preventDefault(),$(this).prop("disabled",!0);const add_button=$(this),tradeInValue=add_button.data("tradeInValue"),tradeInDevice=add_button.data("tradeInDevice"),main_product_id=add_button.data("parentId"),main_product_index=add_button.data("forproduct"),main_product_parent=$(`#${main_product_id}`),main_product_quantity=main_product_parent.find(".quantity__input").val(),main_product_sku=add_button.data("skuparent"),main_product_handle=add_button.data("handleparent"),main_product_preorder=add_button.data("preorderparent"),main_product_preorder_message=add_button.data("preordermessageparent"),main_product_trade_in=add_button.data("tradeinparent"),main_product_key=add_button.data("keyparent"),main_mpn_value=add_button.data("mpnparent"),additional_flag=add_button.data("reference"),main_product_tags=main_product_parent.find(".cart_tax_tags").val();let properties=$(this).data("itemProperties");main_product_preorder&&(properties._preOrder="true"),main_product_preorder_message&&(properties._preOrderMessage=main_product_preorder_message),tradeInDevice&&(properties._tradeInEligible="true"),tradeInValue&&(properties._tradeIn_value=tradeInValue.toString().replace(".","")),tradeInDevice&&(properties._tradeIn_device=tradeInDevice),tradeInDevice&&properties._uuid&&!properties._uuid.includes("tradein")&&(properties._uuid=properties._uuid+"-tradein");const data_tradeIn=`{ "line": ${main_product_index}, "quantity": ${main_product_quantity}, "properties": ${JSON.stringify(properties)} }`;$.ajax({url:`${window.Shopify.routes.root}cart/change.js`,type:"POST",data:data_tradeIn,contentType:"application/json",dataType:"json",success:function(data){const oldUuid=properties?._uuid.split("-tradein")[0],newUuid=properties?._uuid;if(!oldUuid||!newUuid||oldUuid===newUuid)return;const appleCareProductsThatNeedUpdating=data.items.find(item2=>item2.properties?._aplcr_main_product_sku&&item2.properties?._uuid===oldUuid),secWarrantyProductsThatNeedUpdating=data.items.find(item2=>item2.properties?._sw_main_product_sku&&item2.properties?._uuid===oldUuid);async function updateAcSecProducts(){if(appleCareProductsThatNeedUpdating){const newProperties={...appleCareProductsThatNeedUpdating.properties,_uuid:newUuid},newData={id:appleCareProductsThatNeedUpdating.key,quantity:appleCareProductsThatNeedUpdating.quantity,properties:newProperties};await fetch(`${window.Shopify.routes.root}cart/change.js`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(newData)})}if(secWarrantyProductsThatNeedUpdating){const newProperties={...secWarrantyProductsThatNeedUpdating.properties,_uuid:newUuid},newData={id:secWarrantyProductsThatNeedUpdating.key,quantity:secWarrantyProductsThatNeedUpdating.quantity,properties:newProperties};await fetch(`${window.Shopify.routes.root}cart/change.js`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(newData)})}location.reload()}updateAcSecProducts()},error:function(xhr,status,error){console.log(`Error: ${xhr.responseText}`)}})}),$(document).on("click","#footer-atc",function(evt){evt.preventDefault();var prodVariantID=$("#main-product-variant").val(),prodQuant=$("#prodQuantity").val(),total_qty=$("#total_qty_"+prodVariantID).val();if(!checkQty())return!1;if(vat_free_day==!0){var taxtags=$("#tax_tags").val(),prodQuant=$("#prodQuantity").val(),addtaxfree=taxtags.indexOf("taxfree")!=-1;if(getCookie("total_quantity")=="")var tax_total_quantity=parseInt(prodQuant);else var tax_total_quantity=parseInt(prodQuant)+parseInt(getCookie("total_quantity"));if(addtaxfree==!0){if(tax_total_quantity>vat_free_quantity)return alert(vat_free_message),!1;addToCart("cart")}else addToCart("cart")}else addToCart("cart");return!1}),$(document).on("click",".js-checkout-button,.js-checkout-link",function(evt){evt.preventDefault();var prodVariantID=$("#main-product-variant").val(),mpn_handle=$("#mpn_handle_"+prodVariantID).val();if(!checkQty())return!1;if(vat_free_day==!0){var taxtags=$("#tax_tags").val(),prodQuant=$("#prodQuantity").val(),addtaxfree=taxtags.indexOf("taxfree")!=-1;if(getCookie("total_quantity")=="")var tax_total_quantity=parseInt(prodQuant);else var tax_total_quantity=parseInt(prodQuant)+parseInt(getCookie("total_quantity"));if(addtaxfree==!0&&tax_total_quantity>vat_free_quantity)return alert(vat_free_message),!1}if($(".pdp_product_list").attr("value").indexOf("PLP ::")>=0)var proliststring=$(".pdp_product_list").attr("value");else var proliststring=formatString($(".pdp_product_list").attr("value"));var productList=proliststring;$(".js-checkout-button,.js-checkout-link").attr("disabled",!0),addToCart("buy")});function addToCart(check_buy){var $cartDrawer=document.querySelector("cart-drawer")||null,taxtags=$("#tax_tags").val(),btn=$(this).find(".BUY_NOW_CLICKED"),buy_now_checker=btn.data("submit"),isChecked=$("#add-apple-care").is(":checked"),isChecked2=$("#add-secWarranty").is(":checked"),hasTradeIn=$("#selected-trade-in-value").val()!==void 0&&$("#selected-trade-in-value").val()!=="0"&&$("#selected-trade-in-device").val()!=="";const tradeInValue=$("#selected-trade-in-value").val()||"",parsedTradeInValue=hasTradeIn?parseInt(tradeInValue).toFixed(2).replace(".",""):null,tradeInDevice=$("#selected-trade-in-device").val()||"";var prodVariantID=$("#main-product-variant").val(),mpn_handle=$("#mpn_handle_"+prodVariantID).val(),productcomPrice=$("#compr_price_"+prodVariantID).val(),uuid=Math.random().toString(36).slice(2);const disablePdpButton=disable=>{check_buy==="cart"&&$("#footer-atc").attr("disabled",disable)},adobeTrack=items=>{adobeTrackAddToCart({items,context:check_buy==="cart"?"PDP Add to Cart":"Check out with Apple Pay",$trigger:check_buy==="cart"?$("#footer-atc")[0]:null,triggerText:check_buy!=="cart"?"Check out with Apple Pay":null,triggerUrl:check_buy!=="cart"?`${window.location.origin}${window.Shopify.routes.root}checkout`:null})};if(disablePdpButton(!0),isChecked==!0||isChecked2==!0||hasTradeIn===!0){if(isChecked==!0&&isChecked2==!0){var prodMaxqut=$("#product_max_quantity").val(),applecareID=$("#apple-care-varid").val(),applecaresku=$("#applecare-product-sku").val(),applecarempn=$("#applecare-product-mpn").val(),applecarehandle=$("#applecare-product-handle").val(),secWarrantyID=$("#secWarranty-varid").val(),secWarrantysku=$("#secWarranty-product-sku").val(),secWarrantympn=$("#secWarranty-product-mpn").val(),secWarrantyhandle=$("#secWarranty-product-handle").val(),main_product_sku=$("#main-pro-sku").val(),main_product_handle=$("#main-pro-handle").val(),main_product_preorder=$("#main-pro-preorder").val(),main_product_preorder_message=$("#main-pro-preorder-message").val(),main_product_trade_in=$("#main-pro-trade-in").val(),prodVariantID=$("#main-product-variant").val(),prodQuant=$("#prodQuantity").val(),taxtags=$("#tax_tags").val(),uid=main_product_handle+"-"+applecarehandle+"-"+secWarrantyhandle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");const props={_applecare_sku:applecaresku,_applecare_handle:applecarehandle,_secWarranty_sku:secWarrantysku,_secWarranty_handle:secWarrantyhandle,_uuid:uid,...main_product_preorder==="true"&&{_preOrder:"true"},...main_product_preorder_message&&{_preOrderMessage:main_product_preorder_message},...main_product_trade_in==="true"&&{_tradeInEligible:"true"}};hasTradeIn===!0&&(props._tradeIn_value=parsedTradeInValue,props._tradeIn_device=tradeInDevice,props._tradeInEligible="true");const adobeItems=[{id:secWarrantyID,quantity:prodQuant},{id:applecareID,quantity:prodQuant},{id:prodVariantID,quantity:prodQuant}];fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:secWarrantyID,quantity:prodQuant,properties:{_sw_main_product_sku:main_product_sku,_sw_main_product_handle:main_product_handle,_uuid:uid}},{id:applecareID,quantity:prodQuant,properties:{_aplcr_main_product_sku:main_product_sku,_aplcr_main_product_handle:main_product_handle,_uuid:uid}},{id:prodVariantID,quantity:prodQuant,properties:props}]})}).then(response=>{if(response.json().then(d=>{if($(".pdp_product_list").attr("value").indexOf("PLP ::")>=0)var proliststring=$(".pdp_product_list").attr("value");else var proliststring=formatString($(".pdp_product_list").attr("value"));var productList=proliststring;cartCookie(mpn_handle,d.items[2].key,productList),triggerGAAddToCart(productcomPrice,mpn_handle,productTitle,productCategory,productList,productCurrency,productPrice,prodQuant2,main_product_sku2,prodVariantID),$cartDrawer&&$cartDrawer.updateItems(),adobeTrack(adobeItems)}),check_buy=="buy")$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active"),$("#cart-notification").css("visibility","hidden"),$(".cart-count-bubble").css("visibility","hidden"),window.location.href=`${window.Shopify.routes.root}checkout`});else{$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")});var main_product_sku2=$("#main-pro-sku").val(),productCategory=$(".pdp_product_category").attr("value"),productCurrency=$(".pdp_product_currency").attr("value"),productPrice1=$(".pdp_product_price").attr("value"),productPrice=$("#prod_price_"+prodVariantID).val(),productTitle=$(".pdp_product_title").attr("value"),prodQuant2=$("#prodQuantity").val()}}).catch(error=>(console.error("Error:",error),!1)).finally(()=>{disablePdpButton(!1)})}else if(isChecked==!1&&isChecked2==!0){var secWarrantyID=$("#secWarranty-varid").val(),secWarrantysku=$("#secWarranty-product-sku").val(),secWarrantympn=$("#secWarranty-product-mpn").val(),secWarrantyhandle=$("#secWarranty-product-handle").val(),main_product_sku=$("#main-pro-sku").val(),main_product_handle=$("#main-pro-handle").val(),main_product_preorder=$("#main-pro-preorder").val(),main_product_preorder_message=$("#main-pro-preorder-message").val(),main_product_trade_in=$("#main-pro-trade-in").val(),prodVariantID=$("#main-product-variant").val(),prodQuant=$("#prodQuantity").val(),taxtags=$("#tax_tags").val(),uid=main_product_handle+"-"+secWarrantyhandle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");const props={_secWarranty_sku:secWarrantysku,_secWarranty_handle:secWarrantyhandle,_uuid:uid,...main_product_preorder==="true"&&{_preOrder:"true"},...main_product_preorder_message&&{_preOrderMessage:main_product_preorder_message},...main_product_trade_in==="true"&&{_tradeInEligible:"true"}};hasTradeIn===!0&&(props._tradeIn_value=parsedTradeInValue,props._tradeIn_device=tradeInDevice,props._tradeInEligible="true");const adobeItems=[{id:secWarrantyID,quantity:prodQuant},{id:prodVariantID,quantity:prodQuant}];fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:secWarrantyID,quantity:prodQuant,properties:{_sw_main_product_sku:main_product_sku,_sw_main_product_handle:main_product_handle,_uuid:uid}},{id:prodVariantID,quantity:prodQuant,properties:props}]})}).then(response=>{if(response.json().then(d=>{if($(".pdp_product_list").attr("value").indexOf("PLP ::")>=0)var proliststring=$(".pdp_product_list").attr("value");else var proliststring=formatString($(".pdp_product_list").attr("value"));var productList=proliststring;cartCookie(mpn_handle,d.items[1].key,productList),triggerGAAddToCart(productcomPrice,mpn_handle,productTitle,productCategory,productList,productCurrency,productPrice,prodQuant2,main_product_sku2,prodVariantID),$cartDrawer&&$cartDrawer.updateItems(),adobeTrack(adobeItems)}),check_buy=="buy")$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active"),$("#cart-notification").css("visibility","hidden"),$(".cart-count-bubble").css("visibility","hidden"),window.location.href=`${window.Shopify.routes.root}checkout`});else{$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")});var main_product_sku2=$("#main-pro-sku").val(),productCategory=$(".pdp_product_category").attr("value"),productCurrency=$(".pdp_product_currency").attr("value"),productPrice1=$(".pdp_product_price").attr("value"),productPrice=$("#prod_price_"+prodVariantID).val(),productTitle=$(".pdp_product_title").attr("value"),prodQuant2=$("#prodQuantity").val()}}).catch(error=>(console.error("Error:",error),!1)).finally(()=>{disablePdpButton(!1)})}else if(isChecked==!0&&isChecked2==!1){var prodMaxqut=$("#product_max_quantity").val(),applecareID=$("#apple-care-varid").val(),applecaresku=$("#applecare-product-sku").val(),applecarempn=$("#applecare-product-mpn").val(),applecarehandle=$("#applecare-product-handle").val(),main_product_sku=$("#main-pro-sku").val(),main_product_handle=$("#main-pro-handle").val(),main_product_preorder=$("#main-pro-preorder").val(),main_product_preorder_message=$("#main-pro-preorder-message").val(),main_product_trade_in=$("#main-pro-trade-in").val(),prodVariantID=$("#main-product-variant").val(),prodQuant=$("#prodQuantity").val(),taxtags=$("#tax_tags").val(),uid=main_product_handle+"-"+applecarehandle;tradeInDevice&&!uid.includes("tradein")&&(uid=uid+"-tradein");const props={_applecare_sku:applecaresku,_applecare_handle:applecarehandle,_uuid:uid,...main_product_preorder==="true"&&{_preOrder:"true"},...main_product_preorder_message&&{_preOrderMessage:main_product_preorder_message},...main_product_trade_in==="true"&&{_tradeInEligible:"true"}};hasTradeIn===!0&&(props._tradeIn_value=parsedTradeInValue,props._tradeIn_device=tradeInDevice,props._tradeInEligible="true");const adobeItems=[{id:applecareID,quantity:prodQuant},{id:prodVariantID,quantity:prodQuant}];fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:applecareID,quantity:prodQuant,properties:{_aplcr_main_product_sku:main_product_sku,_aplcr_main_product_handle:main_product_handle,_uuid:uid}},{id:prodVariantID,quantity:prodQuant,properties:props}]})}).then(response=>{if(response.json().then(d=>{if($(".pdp_product_list").attr("value").indexOf("PLP ::")>=0)var proliststring=$(".pdp_product_list").attr("value");else var proliststring=formatString($(".pdp_product_list").attr("value"));var productList=proliststring;cartCookie(mpn_handle,d.items[1].key,productList),triggerGAAddToCart(productcomPrice,mpn_handle,productTitle,productCategory,productList,productCurrency,productPrice,prodQuant2,main_product_sku2,prodVariantID),$cartDrawer&&$cartDrawer.updateItems(),adobeTrack(adobeItems)}),check_buy=="buy")$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active"),$("#cart-notification").css("visibility","hidden"),$(".cart-count-bubble").css("visibility","hidden"),window.location.href=`${window.Shopify.routes.root}checkout`});else{$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")});var main_product_sku2=$("#main-pro-sku").val(),productCategory=$(".pdp_product_category").attr("value"),productCurrency=$(".pdp_product_currency").attr("value"),productPrice1=$(".pdp_product_price").attr("value"),productPrice=$("#prod_price_"+prodVariantID).val(),productTitle=$(".pdp_product_title").attr("value"),prodQuant2=$("#prodQuantity").val()}}).catch(error=>(console.error("Error:",error),!1)).finally(()=>{disablePdpButton(!1)})}else if(hasTradeIn===!0){const prodMaxqut2=$("#product_max_quantity").val(),main_product_sku2=$("#main-pro-sku").val(),main_product_handle2=$("#main-pro-handle").val(),main_product_preorder2=$("#main-pro-preorder").val(),main_product_preorder_message2=$("#main-pro-preorder-message").val();var main_product_trade_in=$("#main-pro-trade-in").val();const prodVariantID2=$("#main-product-variant").val(),prodQuant2=$("#prodQuantity").val(),taxtags2=$("#tax_tags").val(),adobeItems=[{id:prodVariantID2,quantity:prodQuant2}];fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:prodVariantID2,quantity:prodQuant2,properties:{_tradeIn_value:parsedTradeInValue,_tradeIn_device:tradeInDevice,_tradeInEligible:"true",_uuid:main_product_handle2,...main_product_preorder2==="true"&&{_preOrder:"true"},...main_product_preorder_message2&&{_preOrderMessage:main_product_preorder_message2},...main_product_trade_in==="true"&&{_tradeInEligible:"true"}}}]})}).then(response=>{if(response.json().then(d=>{if($(".pdp_product_list").attr("value").indexOf("PLP ::")>=0)var proliststring=$(".pdp_product_list").attr("value");else var proliststring=formatString($(".pdp_product_list").attr("value"));var productList=proliststring;cartCookie(mpn_handle,d.items[0].key,productList),triggerGAAddToCart(productcomPrice,mpn_handle,productTitle,productCategory,productList,productCurrency,productPrice,prodQuant3,main_product_sku3,prodVariantID2),$cartDrawer&&$cartDrawer.updateItems(),adobeTrack(adobeItems)}),check_buy=="buy")$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active"),$("#cart-notification").css("visibility","hidden"),$(".cart-count-bubble").css("visibility","hidden"),window.location.href=`${window.Shopify.routes.root}checkout`});else{$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")});var main_product_sku3=$("#main-pro-sku").val(),productCategory=$(".pdp_product_category").attr("value"),productCurrency=$(".pdp_product_currency").attr("value"),productPrice1=$(".pdp_product_price").attr("value"),productPrice=$("#prod_price_"+prodVariantID2).val(),productTitle=$(".pdp_product_title").attr("value"),prodQuant3=$("#prodQuantity").val()}}).catch(error=>(console.error("Error:",error),!1)).finally(()=>{disablePdpButton(!1)})}}else{var main_product_handle=$("#main-pro-handle").val(),main_product_preorder=$("#main-pro-preorder").val(),main_product_preorder_message=$("#main-pro-preorder-message").val(),main_product_trade_in=$("#main-pro-trade-in").val(),main_product_sku=$("#main-pro-sku").val(),prodQuant=$("#prodQuantity").val(),prodVariantID=$("#main-product-variant").val();const adobeItems=[{id:prodVariantID,quantity:prodQuant}];fetch(`${window.Shopify.routes.root}cart/add.js`,{method:"post",headers:{"content-type":"application/json"},body:JSON.stringify({items:[{id:prodVariantID,quantity:prodQuant,properties:{_uuid:main_product_handle,...main_product_preorder==="true"&&{_preOrder:"true"},...main_product_preorder_message&&{_preOrderMessage:main_product_preorder_message},...main_product_trade_in==="true"&&{_tradeInEligible:"true"}}}]})}).then(response=>{if(response.json().then(d=>{if($(".pdp_product_list").attr("value").indexOf("PLP ::")>=0)var proliststring=$(".pdp_product_list").attr("value");else var proliststring=formatString($(".pdp_product_list").attr("value"));var productList=proliststring;cartCookie(mpn_handle,d.items[0].key,productList),triggerGAAddToCart(productcomPrice,mpn_handle,productTitle,productCategory,productList,productCurrency,productPrice,prodQuant2,main_product_sku2,prodVariantID),$cartDrawer&&$cartDrawer.updateItems(),adobeTrack(adobeItems)}),check_buy=="buy")$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active"),$("#cart-notification").css("visibility","hidden"),$(".cart-count-bubble").css("visibility","hidden"),window.location.href=`${window.Shopify.routes.root}checkout`});else{$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){var item_count=jQuery(itemData).find("#cart-notification-button .count").text();$(".cart-count-bubble").length>0||$("#cart-icon-bubble").append('
'),$(".cart-count-bubble span").text(item_count),$("#cart-notification").text("");var textreplace="
";$("#cart-notification").append(textreplace),$("#cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active")});var main_product_sku2=$("#main-pro-sku").val(),productCategory=$(".pdp_product_category").attr("value"),productCurrency=$(".pdp_product_currency").attr("value"),productPrice1=$(".pdp_product_price").attr("value"),productPrice=$("#prod_price_"+prodVariantID).val(),productTitle=$(".pdp_product_title").attr("value"),prodQuant2=$("#prodQuantity").val()}}).catch(e=>{console.error(e)}).finally(()=>{disablePdpButton(!1)})}}function cartCookie(mpn_handle,prodVariantID,productList){var prevPage=document.referrer,search_value="",first_search="";if(prevPage.includes("search")&&(first_search=localStorage.getItem("search_value"),search_value=localStorage.getItem("search_value_term"),first_search==null)){localStorage.setItem("search_value",search_value);var first_search_str=localStorage.getItem("search_value");first_search=formatString(first_search_str)}var exphone=[],item_cart={};item_cart.cart_item_id=prodVariantID,item_cart.cart_item_list_name=productList,item_cart.cart_item_mpn=mpn_handle,item_cart.cart_search_term=first_search,JSON.parse(localStorage.getItem("cart"))!=null&&(exphone=JSON.parse(localStorage.getItem("cart"))),exphone.push(item_cart),localStorage.setItem("cart",JSON.stringify(exphone))}function triggerGAAddToCart(productcomPrice,mpn,productTitle,productCategory,productList,productCurrency,productPrice,prodQuant,main_product_sku,prod_variantID){var prevPage=document.referrer,search_value="";if(prevPage.includes("search")){var first_search=localStorage.getItem("search_value");if(search_value=localStorage.getItem("search_value_term"),first_search==null){localStorage.setItem("search_value",search_value);var first_search_str=localStorage.getItem("search_value");first_search=formatString(first_search_str)}}dataLayer.push({ecommerce:null}),productPrice=Number(productPrice?.replace(/[^0-9.-]+/g,""));var value_price=productPrice*parseInt(prodQuant),discount=0,value_price1=parseFloat(value_price),productPrice1=parseFloat(productPrice);dataLayer.push({event:"add_to_cart",search_term:search_value,currency:productCurrency,value:value_price1,ecommerce:{items:[{item_id:mpn,item_name:productTitle,item_category:productCategory,item_list_name:productList,price:productPrice1,quantity:parseInt(prodQuant)}]}})}function formatString(str){return str.replace(/(\B)[^ ]*/g,match=>match.toLowerCase()).replace(/^[^ ]/g,match=>match.toUpperCase())}function miniCart(){$.get(`${window.Shopify.routes.root}cart?view=minicart`,function(itemData){$("cart-notification").replaceWith(itemData),$("#cart-notification").addClass("minicart-active"),$.ajax({type:"GET",dataType:"json",url:`${window.Shopify.routes.root}cart.js`,success:function(cart){let total=cart.item_count;$(".cart-count-bubble").text(total)}})})}$productGrid&&new MutationObserver(mutations=>{mutations.forEach(mutation=>{mutation?.type==="childList"&&quickAddEvents()})}).observe($productGrid,{childList:!0}),$("#prodQuantity").on("change",function(){debounce(checkQty,500)()});function checkQty(){var productId=$("#product_id").val(),productQty=$("#prodQuantity").val(),prodMaxQty=$("#product_max_quantity").val(),prodInventoryQuantity=$("#productInventoryQuantity").val(),$errorMessage=document.querySelector(".js-qty-error")||null,$qtyInput=document.querySelector(".js-qty-input")||null,$pickUpAvailability=document.querySelectorAll("pickup-availability")||null,$storeLocator=document.querySelector("my-store-locator")||null;$storeLocator&&$pickUpAvailability?.length>0&&productQty&&[...$pickUpAvailability].forEach(el=>{var locationId=$storeLocator.preferredStoreId||null;if(el.dataset.itemQuantity=productQty?parseInt(productQty):null,locationId){var location2=$storeLocator?.allLocationsData?.find(loc=>loc.id===locationId)||null;location2&&el.renderPreview(location2)}});var maxQty=checkMaxquantity(productId);if(maxQty!="")var maxQtyAllowed=parseInt(productQty)+parseInt(maxQty);else var maxQtyAllowed=parseInt(productQty);if(maxQtyAllowed>prodMaxQty){if($errorMessage){const text=$errorMessage.innerHTML;text&&(text.includes("{limit}")&&($errorMessage.innerHTML=text.replace("{limit}",`(${prodMaxQty})`)),$errorMessage.classList.remove("hidden"))}return $qtyInput&&$qtyInput.classList.add("quantity--error"),!1}else if(maxQtyAllowed>parseInt(prodInventoryQuantity)){if($errorMessage){const maxLevel=parseInt(prodInventoryQuantity),text=$errorMessage.innerHTML;text&&(text.includes("{limit}")&&($errorMessage.innerHTML=text.replace("{limit}",`(${maxLevel})`)),$errorMessage.classList.remove("hidden"))}return $qtyInput&&$qtyInput.classList.add("quantity--error"),!1}else return resetErrors(),!0}function resetErrors(){var $errorMessage=document?.querySelector(".js-qty-error")||null,$qtyInput=document?.querySelector(".js-qty-input")||null;$errorMessage&&$errorMessage.classList.add("hidden"),$qtyInput&&$qtyInput.classList.remove("quantity--error")}});function checkMaxquantity(product_id){var total_max_quantity=0,product_id=product_id;return $.ajax({type:"GET",dataType:"json",async:!1,url:`${window.Shopify.routes.root}cart.js`,success:function(cart){for(var i=0;i