1(function(){if(window.SPKit)return;var root=window.Shopify&&Shopify.routes&&Shopify.routes.root?Shopify.routes.root:"/",KEY="spkit_opt",cfg=null,busy=!1,pending=!1,waiters=[],CART_RE=/\/cart\/(add|change|update|clear)(\.js)?(\?|$)/;function widgets(){return Array.prototype.slice.call(document.querySelectorAll("[data-sp-kit]"))}function readCfg(){var el=document.querySelector("[data-sp-kit]");if(!el)return null;try{cfg=JSON.parse(el.getAttribute("data-sp-config"))}catch(e){cfg=null}return cfg}function optedIn(){var v=null;try{v=localStorage.getItem(KEY)}catch(e){}return v==="on"?!0:v==="off"?!1:!!(cfg&&cfg.default==="on")}function setOpt(on){try{localStorage.setItem(KEY,on?"on":"off")}catch(e){}document.querySelectorAll("[data-sp-toggle]").forEach(function(t){t.checked=on})}function rate(){var r=window.Shopify&&Shopify.currency&&parseFloat(Shopify.currency.rate);return r&&r>0?r:1}function tierFor(usd){if(!cfg||!usd||usd<=0)return null;if(cfg.mode==="pct"){var fee=Math.round(usd*cfg.rate);fee<cfg.min&&(fee=cfg.min),fee>cfg.max&&(fee=cfg.max);var ext=extId(fee);if(ext)return{id:ext,label:extLabel(fee),cents:fee*100,fee:fee};for(;fee>0&&!cfg.map[String(fee)];)fee--;var m=cfg.map[String(fee)];return m?{id:m[0],label:m[1],cents:fee*100,fee:fee}:null}for(var t=cfg.tiers,best=null,i=0;i<t.length;i++){if(usd>=t[i].min-.005&&usd<=t[i].max+.005)return t[i];(!best||t[i].max>best.max)&&(best=t[i])}return usd>best.max?best:null}var extCache=null;function extIds(){if(extCache)return extCache;var e=cfg&&cfg.ext;if(!e||!e.ids||!e.ids.length)return extCache=[];for(var out=[e.ids[0]],i=1;i<e.ids.length;i++)out.push(out[i-1]+e.ids[i]);return extCache=out}function extId(fee){var e=cfg&&cfg.ext;if(!e||fee<e.from)return null;var ids=extIds();return ids[fee-e.from]||null}function extLabel(fee){for(var ks=Object.keys(cfg.map||{}),top=null,i=0;i<ks.length;i++)(!top||+ks[i]>+top)&&(top=ks[i]);var sample=top?cfg.map[top][1]:"$250",txt=fee.toLocaleString("en-US");return sample.replace(/[\d][\d,.]*/,function(m){return/[.,]\d\d$/.test(m)?txt+m.slice(-3):txt})}function isProtId(vid){if(cfg.mode==="pct"){for(var k in cfg.map)if(cfg.map[k][0]===vid)return!0;return extIds().indexOf(vid)>=0}return cfg.tiers.some(function(t){return t.id===vid})}function isProt(item){return item.product_type===cfg.type||cfg.handle&&item.handle===cfg.handle||isProtId(item.variant_id)}function req(url,body){return fetch(root+url,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Accept:"application/json","X-SPKit":"1"},body:JSON.stringify(body)}).then(function(r){return r.json()})}function getCart(){return fetch(root+"cart.js?t="+Date.now(),{credentials:"same-origin",headers:{"X-SPKit":"1"}}).then(function(r){return r.json()})}var LINE_SEL=".cart-item, .cart__item, .cart-drawer__item, .line-item, .cart__row, .cart-line-item, .mini-cart__line-item, [data-cart-item], [data-line-item], .quick-cart__item, .ajaxcart__product, .cart-list__item, li, tr",HIDE_HANDLES=["shipping-protection","shipping-protection-legacy","shipping-protection-1","shipping-protection-2","shipping-insurance","order-armor"],CARD_SEL=".product-card, .card-wrapper, .card, .grid__item, .product-item, .product-grid-item, .predictive-search__item, .predictive-search__list-item, .search-result, .product, [data-product-card], [data-product-item], [data-product-id], article";function hideLines(){var handles=cfg&&HIDE_HANDLES.indexOf(cfg.handle)<0?HIDE_HANDLES.concat([cfg.handle]):HIDE_HANDLES;handles.forEach(function(h){document.querySelectorAll('a[href*="/products/'+h+'"]').forEach(function(a){if(!a.closest("[data-sp-kit]")){var hp=a.getAttribute("href")||"",m=hp.match(/\/products\/([^/?#]+)/);if(!(m&&m[1]!==h)){var line=a.closest(LINE_SEL)||a.closest(CARD_SEL)||a;line&&!line.classList.contains("sp-hidden-line")&&line.classList.add("sp-hidden-line")}}})})}function sectionsFor(mode){if(mode!=="dawn")return null;var ids=[];document.querySelector("cart-drawer")&&ids.push("cart-drawer","cart-icon-bubble","cart-price");var mi=document.getElementById("main-cart-items"),mf=document.getElementById("main-cart-footer");return mi&&ids.push(mi.dataset.id||"main-cart-items","cart-icon-bubble","cart-live-region-text","cart-price"),mf&&ids.push(mf.dataset.id||"main-cart-footer"),ids=ids.filter(function(v,i,a){return v&&a.indexOf(v)===i}),ids.length?ids:null}function swapSection(el){var sid=el.getAttribute("data-sp-section"),sel=el.getAttribute("data-sp-swap");return sid?fetch(root+"?sections="+encodeURIComponent(sid)+"&t="+D
1ate.now(),{credentials:"same-origin",headers:{"X-SPKit":"1"}}).then(function(r){return r.json()}).then(function(j){var html=j[sid];if(html){var doc=new DOMParser().parseFromString(html,"text/html"),target=sel?el.closest(sel)||document.querySelector(sel):el.closest("form");if(target){var fresh=sel?doc.querySelector(sel):doc.querySelector("form");fresh&&(target.innerHTML=fresh.innerHTML)}}}).catch(function(){}):Promise.resolve()}function rerender(cart){var modes={};widgets().forEach(function(el){modes[el.getAttribute("data-sp-refresh")||"none"]=el});var p=Promise.resolve();if(modes.impulse&&document.dispatchEvent(new CustomEvent("cart:build")),modes.focal&&document.documentElement.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:{cart:cart}})),modes.dawn&&cart&&cart.sections){var cd=document.querySelector("cart-drawer"),ci=document.querySelector("cart-items");try{cd&&cd.renderContents&&cd.renderContents(cart)}catch(e){}try{ci&&ci.renderContents&&ci.renderContents(cart)}catch(e){}!(cd&&cd.renderContents)&&!(ci&&ci.renderContents)&&Object.keys(cart.sections).forEach(function(id){var host=document.getElementById("shopify-section-"+id);if(host){var doc=new DOMParser().parseFromString(cart.sections[id],"text/html"),inner=doc.getElementById("shopify-section-"+id);host.innerHTML=inner?inner.innerHTML:doc.body.innerHTML}})}return modes.fn&&widgets().forEach(function(el){var x=el.getAttribute("data-sp-fn");if(x)try{new Function(x)()}catch(e){}}),modes.section&&widgets().forEach(function(el){el.getAttribute("data-sp-refresh")==="section"&&(p=p.then(function(){return swapSection(el)}))}),modes.reload&&/\/cart\/?(\?|$)/.test(location.pathname+location.search)&&setTimeout(function(){location.reload()},150),p.then(function(){document.dispatchEvent(new CustomEvent("spkit:synced"))})}function paint(cart,tier){var lines=cart&&cart.items?cart.items.filter(isProt):[];widgets().forEach(function(el){var price=el.querySelector("[data-sp-price]"),note=el.querySelector("[data-sp-note]");price&&tier&&(price.textContent=tier.label),note&&(note.hidden=!(lines.length&&optedIn())),el.classList.toggle("is-off",!optedIn()),el.querySelectorAll("[data-sp-toggle]").forEach(function(t){t.checked=optedIn()})}),hideLines()}function sync(){if(!cfg&&!readCfg())return Promise.resolve(null);if(busy)return pending=!0,new Promise(function(res){waiters.push(res)});busy=!0,widgets().forEach(function(el){el.classList.add("is-busy")});var changed=!1,last=null,dawnSections=sectionsFor(widgets().some(function(el){return el.getAttribute("data-sp-refresh")==="dawn"})?"dawn":""),extra=dawnSections?{sections:dawnSections.join(","),sections_url:location.pathname}:{};return getCart().then(function(cart){var lines=cart.items.filter(isProt),protCents=lines.reduce(function(s,i){return s+i.final_line_price},0),goodsUsd=(cart.total_price-protCents)/100/rate(),want=optedIn()?tierFor(goodsUsd):null,keep=null,ops=Promise.resolve();return lines.forEach(function(l){if(want&&l.variant_id===want.id&&l.quantity===1&&!keep){keep=l;return}changed=!0,ops=ops.then(function(){return req("cart/%63hange.js",Object.assign({id:l.key,quantity:0},extra)).then(function(r){last=r})})}),want&&!keep&&(changed=!0,ops=ops.then(function(){return req("cart/add.js",Object.assign({items:[{id:want.id,quantity:1,properties:{_protection:"sp-kit"}}]},extra))}).then(function(){return getCart()}).then(function(c){if(last=c,dawnSections)return fetch(root+"?sections="+dawnSections.join(",")+"&t="+Date.now(),{credentials:"same-origin",headers:{"X-SPKit":"1"}}).then(function(r){return r.json()}).then(function(s){last.sections=s})})),ops.then(function(){return last&&last.items?last:getCart()}).then(function(c){return paint(c,want),c})}).then(function(c){busy=!1,widgets().forEach(function(el){el.classList.remove("is-busy")});var done=changed?rerender(c):Promise.resolve();return done.then(function(){if(paint(c,optedIn()?tierFor((c.total_price-c.items.filter(isProt).reduce(function(s,i){return s+i.final_line_price},0))/100/rate()):null),pending)return pending=!1,sync();var w=waiters;
1return waiters=[],w.forEach(function(res){res(c)}),c})}).catch(function(e){busy=!1,pending=!1,widgets().forEach(function(el){el.classList.remove("is-busy")});var w=waiters;return waiters=[],w.forEach(function(res){res(null)}),window.console&&console.warn("sp-kit",e),null})}var debounced=(function(){var t;return function(){clearTimeout(t),t=setTimeout(sync,350)}})();document.addEventListener("change",function(e){!e.target.matches||!e.target.matches("[data-sp-toggle]")||(setOpt(e.target.checked),sync())}),["cart:updated","ajaxProduct:added","cart:open","cart:refresh","cart-drawer:open","cart:item-added","quick-cart:open","cart:change","cart-notification:show"].forEach(function(ev){document.addEventListener(ev,debounced),document.documentElement.addEventListener(ev,debounced)});var ofetch=window.fetch;window.fetch=function(input,init){var url=typeof input=="string"?input:input&&input.url||"",h=init&&init.headers,mine=h&&(h["X-SPKit"]||h.get&&h.get("X-SPKit")),p=ofetch.apply(this,arguments);return!mine&&CART_RE.test(url)&&p.then(debounced,function(){}),p};var oopen=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(m,url){return CART_RE.test(url||"")&&this.addEventListener("loadend",debounced),oopen.apply(this,arguments)};var mo=new MutationObserver((function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){if(!cfg&&readCfg()){sync();return}hideLines(),widgets().forEach(function(el){el.querySelectorAll("[data-sp-toggle]").forEach(function(x){x.checked=optedIn()})})},60)}})());mo.observe(document.documentElement,{childList:!0,subtree:!0}),document.addEventListener("submit",function(e){var f=e.target;if(!(!f||!/\/cart\/?$/.test((f.getAttribute("action")||"").replace(/\?.*$/,"")))&&!(!busy&&!pending)){e.preventDefault();var tries=0,wait=setInterval(function(){if(!busy&&!pending||++tries>40){clearInterval(wait);var b=f.querySelector('[name="checkout"]');b?b.click():f.submit()}},100)}},!0),document.addEventListener("click",function(e){var a=e.target.closest&&e.target.closest('a[href$="/checkout"], a[href*="/checkout?"]');!a||!busy&&!pending||(e.preventDefault(),sync().then(function(){location.href=a.href}))},!0),document.addEventListener("click",function(e){var a=e.target.closest&&e.target.closest(".cart__remove a");if(a){var m=(a.getAttribute("href")||"").match(/[?&]id=([^&]+)/);if(m){e.preventDefault();var item=a.closest(".cart__item");item&&(item.style.opacity=".4"),req("cart/change.js",{id:decodeURIComponent(m[1]),quantity:0}).then(function(){document.dispatchEvent(new CustomEvent("cart:build")),sync()},function(){window.location.href=a.href})}}}),window.SPKit={sync:sync,optedIn:optedIn,setOpt:setOpt,tierFor:tierFor,hideLines:hideLines},document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){readCfg(),hideLines(),sync()}):(readCfg(),hideLines(),sync())})(); 2//# sourceMappingURL=/cdn/shop/t/55/assets/sp-kit.js.map?v=7957108729870893711790302794
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.