const csp={pc:!1,sd:!0,bre:[],apiDomain:"api.corso.com",arc:!1};csp.scriptUrl=new URL(document.currentScript.src),csp.sfd=csp.scriptUrl.searchParams.get("sfid");const open=window.XMLHttpRequest.prototype.open;function orp(){return this.addEventListener("load",(function(){this._url&&(filteredUrl=["/cart/add","/cart/update","/cart/change","/cart/clear"].filter((s=>this._url.includes(s))),filteredUrl.length>0&&csp.pc&&csp.rc(this.response))})),open.apply(this,arguments)}window.XMLHttpRequest.prototype.open=orp,function(s,n){"function"==typeof n&&(s.fetch=function(){const s=n.apply(this,arguments);return s.then((async s=>{clonedResponse=s.clone(),filteredUrl=["/cart/add","/cart/update","/cart/change","/cart/clear"].filter((n=>s.url.includes(n))),filteredUrl.length>0&&csp.pc&&csp.rc(),filteredUrl=["/cart/update","/cart/change"].filter((s=>clonedResponse.url.includes(s))),filteredUrl.length>0&&csp.pc&&csp.uncheckOnRemoval(await clonedResponse.json())})),s})}(window,window.fetch),csp.uncheckOnRemoval=async function(s){let n=[];s.items_removed&&s.items_removed.length>0&&(n=s.items_removed.filter((s=>s.variant_id=sessionStorage.getItem("cv")))),n.length>0&&csp.dqs("#corso-protection-placeholder")&&csp.dqs("#corso-protection-placeholder").hasAttribute("at")&&(csp.dqs("#cn").checked=!1,sessionStorage.setItem("isGspChecked","no"))},csp.rc=async function(){if(Shopify?.currency?.active&&"undefined"!=Shopify?.currency?.active?csp.customerCurrency=Shopify?.currency?.active:Shopify?.Checkout?.currency&&"undefined"!=Shopify?.Checkout?.currency?csp.customerCurrency=Shopify?.Checkout?.currency:csp.customerCurrency="USD",Shopify?.locale&&Shopify?.country&&"undefined"!=Shopify?.locale&&"undefined"!=Shopify?.country?csp.customerLocale=Shopify?.locale+"-"+Shopify?.country:Shopify?.Checkout?.locale&&"undefined"!=Shopify?.Checkout?.locale?csp.customerLocale=Shopify?.Checkout?.locale:csp.customerLocale=navigator.language,5==csp.customerLocale.length&&csp.customerLocale.includes("-")||(csp.customerLocale=navigator.language),csp.dqs("#corso-protection-placeholder")&&csp.dqs("#corso-protection-placeholder").hasAttribute("noex"))return;let s=await fetch("/cart.js",{method:"GET"});s=csp.pa=await s.json();const n=s.items;if(csp.cc=s.item_count,csp.totalCartPrice=s.total_price,csp.ci=s.items.filter((s=>s.handle.startsWith("green-shipping-protection")||s.handle.startsWith("sustainability-coverage")||s.handle.startsWith(csp.ph))),csp.nc=s.items.filter((s=>0==s.handle.startsWith("green-shipping-protection")&&0==s.handle.startsWith("sustainability-coverage")&&0==s.handle.startsWith(csp.ph))),csp.sd&&csp.ce?.length>0&&csp.dcf(),csp.ci.length>=csp.cc&&await csp.ri(),csp.dqs("#corso-protection-placeholder")&&csp.dqs("#corso-protection-placeholder").hasAttribute("rmc")&&(csp.arc=!0),1==csp.arc&&csp.ci.length>0&&(await csp.ri(),window.location.reload()),csp.ci.length>0&&!1===csp.dqs("#cn")?.checked)return void await csp.ri();csp.si=[];for(const s of csp.nc)s.selling_plan_allocation&&csp.si.push(s.selling_plan_allocation.selling_plan.name);if(csp.si=[...new Set(csp.si)],csp.ra=[],"undefined"!=typeof ReCharge){for(const s of n)s.properties&&s.properties.ii&&csp.ra.push({ii:s.properties.ii,it:s.properties.it});ra=[],csp.ra.forEach((s=>{ra.push(JSON.stringify(s))})),ra=[...new Set(ra)],csp.ra=[],ra.forEach((s=>{csp.ra.push(JSON.parse(s))}))}const t=s.items.filter((s=>0!=s.requires_shipping||!s.handle.startsWith(csp.ph))).reduce(((s,n)=>s+n.line_price),0);let e;csp.rs=s.items.filter((s=>s.requires_shipping)).length,csp.rs<1&&csp.dqs("#gsp-widget")&&(csp.dqs("#cn").checked=!1),e!=s.item_count-csp.ci.length&&0==csp.arc&&(e=s.item_count-csp.ci.length,csp.tc=.01*t,await csp.rp(),csp.brf()),csp.dqs("#cn")&&1==csp.dqs("#cn").checked&&csp.ci.length<1&&0==csp.arc&&(e=s.item_count-csp.ci.length,csp.tc=csp.tc=.01*t,await csp.rp(),csp.brf())},csp.rp=async function(){let s=await fetch(`https://${csp.apiDomain}/v1/shop/gsp/${csp.sfd}/quote/?cartValue=${csp.tc.toFixed(0)}¤cyCode=${csp.customerCurrency}`);const n=await s.json();if(Number(n?.cost)>0){csp.pp=n.cost,csp.pv=n.variant;const s=await fetch(`/products/${csp.ph}.js`);try{csp.gps=await s.json();const n=csp.gps.variants.filter((s=>s.id.toString()==csp.pv.toString()));csp.pp=.01*n[0].price}catch{}}else if(csp.dqs("#gsp-widget"))return csp.dqs("#gsp-widget").style.display="none",csp.pp=null,void csp.ri();csp.uw(),csp.dqs("#cn")&&1==csp.dqs("#cn").checked&&(Number(sessionStorage.getItem("corsoCartPrice",csp.totalCartPrice))!=csp.totalCartPrice||csp.ci.length<1)&&await csp.rb()},csp.uw=function(){null!=csp.pp&&!0===csp.mi&&csp.rs>0&&csp.dqs("#gsp-widget")?(csp.dqs("#gsp-widget").style.display="block",csp.dqs("#cw").innerHTML=new Intl.NumberFormat(csp.customerLocale,{style:"currency",currency:csp.customerCurrency}).format(csp.pp),csp.dc(),csp.sv()):csp.dqs("#gsp-widget")&&(csp.dqs("#cn").checked=!1)},csp.rb=async function(){if(!1===csp.pc)return;csp.pc=!1,"undefined"!=typeof Rebuy&&void 0!==Rebuy.SmartCart&&(Rebuy.SmartCart.skip_open=!0),!0===window.upcartOpenOnAddToCartOverride&&(window.upcartOpenOnAddToCartOverride=!1,csp.sct=!0),void 0===window.upcartOpenOnAddToCartOverride&&(window.upcartOpenOnAddToCartOverride=!1,csp.scu=!0);let pi=[],no;if(csp.dqs("#corso-protection-placeholder")&&csp.dqs("#corso-protection-placeholder").hasAttribute("rbc")&&csp.nc.length>0){for(const s of csp.nc)cartItem={id:s.id,properties:s.properties,quantity:s.quantity},s.selling_plan_allocation&&(cartItem.selling_plan=s.selling_plan_allocation.selling_plan.id),pi.push(cartItem);pi.reverse(),await fetch("/cart/clear.js")}else await csp.ri();if(csp.si.length<1&&csp.ra.length<1&&csp.dqs("#cn").checked&&(no=[{id:csp.pv}].concat(pi)),csp.si.length>0&&csp.dqs("#cn").checked){const s=csp.gps.variants.find((s=>s.id.toString()===csp.pv));let n=[];for(item of csp.si)csp.gps.selling_plan_groups.filter((s=>{const t=s.selling_plans.filter((s=>s.name.toLowerCase()===item.toLowerCase()));n.push(t)}));n=n.flat(),sellingPlansToProtect=[],n.forEach((n=>{const t=s.selling_plan_allocations.filter((s=>s.selling_plan_id===n.id));sellingPlansToProtect.push(t)})),sellingPlansToProtect=[...new Set(sellingPlansToProtect.flat())];let t=[];sellingPlansToProtect.forEach((s=>{t.push({quantity:1,id:csp.pv,selling_plan:s.selling_plan_id})})),no=t.concat(pi),t.length<1&&(no=[{id:csp.pv}].concat(pi))}if(csp.ra.length>0&&!0===csp.dqs("#cn").checked){let ia=[];const response=await fetch(`/products/${csp.ph}`);let data=await response.text();data.split(/\r?/).forEach((e=>{if(e=e.trim(),e.startsWith("variant_to_duplicate")){e=e.replace("variant_to_duplicate: ",""),e=e.substring(0,e.length-1);const vp=eval("("+e+")");for(item of csp.ra)ia.push({quantity:1,id:vp[csp.pv],properties:item});no=ia.concat(pi)}})),ia.length<1&&(no=[{id:csp.pv}].concat(pi))}no&&(await csp.ri(),await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:no})}),sessionStorage.setItem("cv",csp.pv),csp.dqs("#gsp-widget").dispatchEvent(new Event("corsoGspAdded"))),csp.dqs("#corso-protection-placeholder")&&csp.dqs("#corso-protection-placeholder").hasAttribute("rbc")&&(csp.pa.note||csp.pa.attributes)&&(await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({note:csp.pa.note,attributes:csp.pa.attributes})}),csp.dqs("#gsp-widget").dispatchEvent(new Event("corsoGspAdded"))),csp.ci.length<1&&await csp.rc(),!0===csp.sd&&csp.ce?.length>0&&csp.dcf(),csp.pc=!0,"undefined"!=typeof Rebuy&&void 0!==Rebuy.SmartCart&&setTimeout((()=>{Rebuy.SmartCart.skip_open=!1}),500),sessionStorage.setItem("corsoCartPrice",csp.totalCartPrice),!0===csp.scu&&(window.upcartOpenOnAddToCartOverride=void 0),!0===csp.sct&&(window.upcartOpenOnAddToCartOverride=!0)},csp.ri=async function(){let s={};csp.ci.forEach((n=>{s[n.key]=0})),Object.keys(s).length>0&&await fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:s})})},csp.og=function(){csp.dqs("#gspi-modal").style.display="block"},csp.closeGspInfoModal=function(){csp.dqs("#gspi-modal").style.display="none"},csp.kt=function(){csp.dqs("#cn").checked=!1},csp.dc=function(){const s=sessionStorage.getItem("isGspChecked"),n=csp.dqs("#cn");"yes"==s&&n?n.checked=!0:"no"==s&&n?n.checked=!1:csp.isDefaulted&&n?(n.checked=!0,sessionStorage.setItem("isGspChecked","yes")):n&&(n.checked=!1)},csp.sv=function(){av=[csp.wc].filter(Boolean).join(" "),csp.dqs("#gsp-vars")&&(csp.dqs("#gsp-vars").style.cssText+=av),csp.dqs("#gspi-vars")&&(csp.dqs("#gspi-vars").style.cssText+=av)},csp.checkForClickedUpdateCartLink=function(s){if("A"!=s.target.tagName)return;const n=s.target.getAttribute("href"),t=[["/cart/change",csp.pv,"&quantity=0"],["/cart/update",csp.pv,"&quantity=0"]];urlRemovesGsp=!1,t.forEach((s=>{s.every((s=>n.includes(s)))&&(urlRemovesGsp=!0)})),urlRemovesGsp&&csp.dqs("#corso-protection-placeholder")&&csp.dqs("#corso-protection-placeholder").hasAttribute("at")&&sessionStorage.setItem("isGspChecked","no")},csp.dcf=async function(){csp.sd=!1;const s=csp.nc.reduce(((s,n)=>s+n.quantity),0);csp.ce.forEach((n=>{csp.dqs(n)&&(counter=csp.dqs(n),counter.innerHTML=s)})),await setTimeout((async()=>{}),500),csp.sd=!0},csp.brf=function(){if((csp.dqs("div[data-step='contact_information']")||csp.dqs("div[data-step='payment_method']")||csp.dqs("div[data-step='shipping_method']")&&!csp.bre.includes(".order-summary__section--product-list",".total-line-table__tbody",".total-line-table__footer",".order-summary-toggle__total-recap"))&&csp.bre.push(".order-summary__section--product-list",".total-line-table__tbody",".total-line-table__footer",".order-summary-toggle__total-recap"),csp.bre.length<1)return;let s=!1;csp.dqs("#gsp-checkout-script")&&(s=!0),fetch(s?location.origin+"/checkout":location).then((function(s){return s.text()})).then((function(s){var n=(new DOMParser).parseFromString(s,"text/html");const t=new Event("elementReplacedByCorso");csp.bre.forEach((s=>{n.querySelector(s)&&(ne=n.querySelector(s),oe=csp.dqs(s),oe.parentNode.replaceChild(ne,oe)),document.dispatchEvent(t)}))}))},csp.fwt=function(){let s=null,n=null,t=null,e=null;s??=csp.dqs("#corso-protection-placeholder-pr"),s??=csp.dqs("#shopify-section-header-classic + #theme-ajax-cart #corso-protection-placeholder"),s??=csp.dqs(".corso-pr #corso-protection-placeholder"),s??=csp.dqs("#corso-protection-placeholder"),e??=csp.dqs(".total-line-table__tbody"),t??=csp.dqs(".sidebar .sidebar__content"),s??=csp.dqs("div[data-step='shipping_method'] .step__footer"),s??=csp.dqs("div[data-step='contact_information'] .step__footer"),n??=csp.dqs("div[data-step='payment_method'] .step__footer"),s??=csp.dqs(".rebuy-cart__flyout-actions"),s??=csp.dqs(".upcart-checkout-button"),s??=csp.dqs("#slidecart-checkout-form"),s??=csp.dqs(".qsc2-checkout-button"),s??=csp.dqs(".slider-cart-action-cta-buttons"),s??=csp.dqs(".boost-sd__cart .boost-sd__cart-btn-group"),s??=csp.dqs(".boost-cart__checkout-cta"),s??=csp.dqs(".icartCheckoutBtnGroup"),s??=csp.dqs(".ajaxcart__note"),s??=csp.dqs(".cart__ctas"),s??=csp.dqs(".cart__buttons-container"),s??=csp.dqs(".grid__item.text-right a[href='/collections/all']"),s??=csp.dqs(".cart__actions"),s??=csp.dqs(".drawer-page-content .grid__item.text-center button[name='checkout']"),s??=csp.dqs(".ajaxcart .ajaxcart__row"),s??=csp.dqs('input[name="update"]'),s??=csp.dqs('button[name="update"]'),s??=csp.dqs('button[name="checkout"]'),s??=csp.dqs("button.cart__submit"),s??=csp.dqs(".cart-notification__links");var a=document.documentElement.clientWidth||window.innerWidth;e&&(csp.dqs("div[data-step='shipping_method']")||csp.dqs("div[data-step='contact_information']")||csp.dqs("div[data-step='payment_method']"))&&!csp.dqs("#gsp-widget")&&"sidebar"===csp.dqs("#gsp-checkout-script")?.getAttribute("widget-location")&&"shipping"===csp.dqs("#gsp-checkout-script")?.getAttribute("sidebar-location")&&a>=985&&e.insertAdjacentHTML("afterend",`
${csp.widgetHtml}
`),t&&(csp.dqs("div[data-step='shipping_method']")||csp.dqs("div[data-step='contact_information']"))&&!csp.dqs("#gsp-widget")&&"sidebar"===csp.dqs("#gsp-checkout-script")?.getAttribute("widget-location")&&t.insertAdjacentHTML("beforeend",csp.widgetHtml),s&&!csp.dqs("#gsp-widget")&&s.insertAdjacentHTML("beforebegin",csp.widgetHtml),n&&csp.dqs("div[data-step='payment_method']")&&!csp.dqs("#gsp-widget")&&"payment"===csp.dqs("#gsp-checkout-script")?.getAttribute("widget-location")&&n.insertAdjacentHTML("beforebegin",csp.widgetHtml),(s||t||e||n)&&!csp.dqs("#gspi-modal")&&document.body.insertAdjacentHTML("beforeend",infoModalHtml),csp.dqs("#gsp-widget")&&document.querySelector("#cn").addEventListener("change",(function(){1==this.checked&&(sessionStorage.setItem("isGspChecked","yes"),csp.pc&&1==csp.dqs("#cn").checked&&csp.rb()),0==this.checked&&(sessionStorage.setItem("isGspChecked","no"),csp.ri())})),csp.dc(),csp.uw()},csp.dqs=function(s){return document.querySelector(s)},csp.widgetHtml='';const infoModalHtml='';csp.setupWidgetInterval=setInterval((()=>{csp.dqs("#gsp-widget")?clearInterval(csp.svi):csp.fwt()}),100),csp.svi=setInterval((async()=>{if(window?.Shopify?.shop&&"undefined"!=window.Shopify.shop?csp.sn=window.Shopify.shop:window?.Shopify?.Checkout?.apiHost&&"undefined"!=window.Shopify.Checkout.apiHost&&(csp.sn=window.Shopify.Checkout.apiHost),csp.sn){clearInterval(csp.svi);let s=JSON.parse(sessionStorage.getItem("corsoShop"));if(!s||Date.now()-sessionStorage.getItem("corsoShopTime")>36e5){const n=await fetch(`https://${csp.apiDomain}/v1/shop/gsp/${csp.sfd}/`);s=await n.json(),sessionStorage.setItem("corsoShop",JSON.stringify(s)),sessionStorage.setItem("corsoShopTime",Date.now())}csp.mi=s.isActive,csp.wc=s.styles,csp.ph=s.productHandle,csp.isDefaulted=s.isDefaulted,s.config?.bgres&&(csp.bre=s.config.bgres),s.config?.cces&&(csp.ce=s.config.cces),csp.dc(),csp.sv(),csp.ce?.length>0&&csp.ce.forEach((s=>{let n;csp.dqs(s)&&(n=csp.dqs(s));new MutationObserver((function(){!0===csp.sd&&csp.dcf()})).observe(n,{childList:!0})})),document.addEventListener("click",csp.checkForClickedUpdateCartLink),csp.pc=!0,csp.rc()}}),100); //202406101713+0000