var Quickbeam=function(){function t(t){function e(){var e;"function"==typeof t.variantSelector?(e=t.variantSelector.call(),typeof e!==string&&(console.error("variantSelector not returning a string."),e="")):[].forEach.call(document.querySelectorAll(".quickbeam-variant"),function(t){t.checked&&(y=parseInt(t.getAttribute("quickbeam-value")),e=t.getAttribute("value"))}),"undefined"==typeof e&&(console.error("Not able to select variant"),e="");var r=document.querySelector("#quick-cart-product-"+y)||!1;if(k&&T&&0==r){var i=n({id:y,price:S,image:v,size:e,color:I});k.insertBefore(i,k.firstChild),a(i,1e3)}}function n(t){var e='
'+t.price.trim()+''+t.size.trim()+'
0',n=document.createElement("div");return n.classList.add("quick-cart-product"),n.classList.add("quick-cart-product-static"),n.setAttribute("id","quick-cart-product-"+t.id),n.style.opacity=0,n.innerHTML=e,n}function a(t,e){e="undefined"!=typeof e?e:0,window.setTimeout(function(){t.style.opacity=1},e)}function r(t){var e=t.time,n=+new Date+e,a=function(){var r=+new Date,i=n-r;if(60>i)return void t.run(1);var o=1-i/e;t.run(o),requestAnimationFrame(a)};a()}function i(){var e=s(),n=u(e);"gsap"===t.animationLib?o(e,n):c(e,n)}function o(t,e){t.style.position="absolute",t.classList.add("run");var n=document.getElementById("quick-cart-product-count-"+y);n&&(n.classList.remove("fadeUp"),n.classList.add("fadeDown")),TweenMax.to(t,1,{bezier:{type:"soft",values:e.through},ease:Power1.easeInOut}),setTimeout(function(){t.style.opacity=0,document.body.removeChild(t),setTimeout(function(){d()},100)},1e3)}function c(t,e){var n=function(t,e){if(!t)var t=0;if(!e)var e=0;return{x:t,y:e}},a=function(t,e,n,a,r){var i=3*(n.x-e.x),o=3*(a.x-n.x)-i,c=r.x-e.x-i-o,s=3*(n.y-e.y),u=3*(a.y-n.y)-s,d=r.y-e.y-s-u,l=c*Math.pow(t,3)+o*Math.pow(t,2)+i*t+e.x,p=d*Math.pow(t,3)+u*Math.pow(t,2)+s*t+e.y;return{x:l,y:p}},i=n(e.start.x,e.start.y),o=n(e.start.x-300,e["final"].y),c=n(e.start.x+500,e.start.y+500),s=n(e["final"].x,e["final"].y);t.style.position="absolute",t.classList.add("run"),r({time:1e3,run:function(e){1==e&&setTimeout(function(){t.style.opacity=0,document.body.removeChild(t),setTimeout(function(){d()},1e3)},500);var n=a(e,i,o,c,s),r="translate("+Math.round(n.x)+"px,"+Math.round(n.y)+"px)";t.style.webkitTransform=r,t.style.transform=r}})}function s(e){var n=T.offsetWidth-2,a=Math.round(1.33*parseInt(T.offsetWidth-2)),r=T.getBoundingClientRect(),i='
',o=document.createElement("div");if(o.classList.add("quick-cart-product"),o.classList.add("quick-cart-product"),o.classList.add("animated"),o.setAttribute("id","quick-cart-product-animated"),"gsap"===t.animationLib){var c="translate("+r.left+"px,"+r.top+"px)";o.style.webkitTransform=c,o.style.transform=c}return o.innerHTML=i,document.body.appendChild(o),o}function u(t){var e=t.querySelector("div"),n=T.getBoundingClientRect(),a=document.querySelector("#quick-cart-product-"+y).getBoundingClientRect(),r=a.top,i=document.documentElement,o=((window.pageXOffset||i.scrollLeft)-(i.clientLeft||0),(window.pageYOffset||i.scrollTop)-(i.clientTop||0)),c=parseInt(n.left)-1.4*parseInt(e.style.width),s=r+o-parseInt(e.style.height)/3;return{start:{x:n.left,y:n.top},through:[{x:c,y:s},{x:a.left,y:r+o}],"final":{x:a.left,y:r+o}}}function d(){var t=document.getElementById("quick-cart-product-"+y),e=document.getElementById("quick-cart-product-count-"+y),n=parseInt(e.innerText),a=document.getElementById("quick-cart-pay-total-count"),r=parseInt(a.innerText);n+=h,e.innerText=n,n>1&&e.classList.remove("hide"),r+=h,a.innerText=r;var i=document.getElementById("quick-cart-product-count-"+y);i.classList.remove("fadeDown"),i.classList.add("fadeUp"),0>h&&(h=1),t&&(t.classList.remove("show-remove-all"),g=0);var o=new XMLHttpRequest;o.onreadystatechange=function(){4==o.readyState&&200==o.status&&p()},o.open("POST","/cart/add.js",!0),o.setRequestHeader("Content-Type","application/json;charset=UTF-8"),o.send(JSON.stringify({quantity:h,id:y}))}function l(t){var e=new XMLHttpRequest;e.onreadystatechange=function(){4==e.readyState&&200==e.status&&p()},e.open("POST","/cart/change.js",!0),e.setRequestHeader("Content-Type","application/json;charset=UTF-8"),e.send(JSON.stringify(t))}function p(){var t=new XMLHttpRequest;t.onreadystatechange=function(){if(4==t.readyState&&200==t.status){var e=JSON.parse(t.responseText);b.innerText=Shopify.formatMoney(e.total_price),e.total_price<=0&&L.classList.remove("open")}},t.open("GET","/cart.js",!0),t.setRequestHeader("Content-Type","application/json;charset=UTF-8"),t.send()}function f(t){k.removeChild(t)}function m(){if(L){var t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;t>600?(L.setAttribute("href","/checkout"),L.classList.remove("cart-ico")):(L.setAttribute("href","/cart"),L.classList.add("cart-ico"))}}var y,v,h,q,g,w={},k=document.querySelector("#quick-cart"),L=document.querySelector("#quick-cart-pay"),b=document.querySelector("#quick-cart-price"),x=document.querySelector('[quickbeam="add-to-cart"]'),T=document.querySelector('[quickbeam="image"]'),S=document.querySelector('[quickbeam="price"]'),I="#000";return function(){function n(t){t.preventDefault(),this.blur(),L.classList.contains("open")||L.classList.add("open"),h=parseInt(document.querySelector(".quantity-selector").value),e(),i(),T&&(T.classList.add("animate"),window.setTimeout(function(){T.classList.remove("animate")},400))}if(window.onresize=function(t){m()},m(),L.length>0)return!1;if("gsap"===t.animationLib&&"function"!=typeof TweenMax)throw"GSAP is not loaded.";if(S&&(S=S.innerHTML),T&&(v=T.getAttribute("src"),!v)){var a=/url\(\s*(['"]?)(.*?)\1\s*\)/i;v=T.getAttribute("style").match(a)[2]}[].forEach.call(document.querySelectorAll(".quickbeam-variant"),function(t){t.checked&&(y=parseInt(t.getAttribute("quickbeam-value")))});var r={".quick-cart-product-remove":function(t){var e=t.getAttribute("data-id"),n=t.parentNode,a=n.querySelector(".count"),r=parseInt(a.innerText),i=n.querySelector("div");if(!n||!k)return!1;if(r--,0>=r)n.classList.add("remove-product"),window.setTimeout(function(){n.classList.remove("remove-product"),f(n)},1e3);else{a.innerText=r;var o=i.cloneNode(!0);o.classList.add("animateOut"),i.parentNode.appendChild(o),window.setTimeout(function(){o.parentNode.removeChild(o)},1e3),1>=r&&a.classList.add("hide")}q==e?g++:(q=e,g=1),3==g&&r>1&&n.classList.add("show-remove-all"),l({quantity:r,id:e})},".quick-cart-product-removeall":function(t){var e=t.getAttribute("data-id"),n=t.parentNode;return n&&k?(n.classList.add("remove-product"),window.setTimeout(function(){f(product_box)},200),void l({quantity:0,id:e})):!1}};return k.addEventListener("click",function(t){for(var e in r)r.hasOwnProperty(e)&&t.target&&t.target.matches(e)&&r[e].apply(null,[t.target])}),x&&x.addEventListener("click",n,!1),!1}(),w}var e;return{init:function(n){return e||(e=t(n)),e}}}();