commercelayer
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -1,2 +0,2 @@ | ||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}([function(e,t,n){"use strict";var r=n(7),o=n(17),a=Object.prototype.toString;function i(e){return"[object Array]"===a.call(e)}function s(e){return null!==e&&"object"==typeof e}function u(e){return"[object Function]"===a.call(e)}function c(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===a.call(e)},isBuffer:o,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===a.call(e)},isFile:function(e){return"[object File]"===a.call(e)},isBlob:function(e){return"[object Blob]"===a.call(e)},isFunction:u,isStream:function(e){return s(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:c,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,o=arguments.length;r<o;r++)c(arguments[r],n);return t},extend:function(e,t,n){return c(t,function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t){e.exports={addToBag:document.querySelector(".clayer-add-to-bag"),availableMessage:document.querySelector(".clayer-available-message"),config:document.querySelector("#clayer-config"),main:document.querySelector("#clayer-main"),prices:Array.prototype.slice.call(document.querySelectorAll(".clayer-price"),0),shoppingBagContainer:document.querySelector("#clayer-shopping-bag-container"),shoppingBagItemsContainer:document.querySelector("#clayer-shopping-bag-items-container"),shoppingBagItemTemplate:document.querySelector("#clayer-shopping-bag-item-template"),shoppingBagCheckout:document.querySelector("#clayer-shopping-bag-checkout"),shoppingBagClose:document.querySelector("#clayer-shopping-bag-close"),shoppingBagPreviewCount:document.querySelector("#clayer-shopping-bag-preview-count"),shoppingBagPreviewTotal:document.querySelector("#clayer-shopping-bag-preview-total"),shoppingBagToggle:document.querySelector("#clayer-shopping-bag-toggle"),shoppingBagUnavailableMessage:document.querySelector(".clayer-shopping-bag-unavailable-message"),unavailableMessage:document.querySelector(".clayer-unavailable-message"),variants:Array.prototype.slice.call(document.querySelectorAll(".clayer-variant"),0),variantSelect:document.querySelector(".clayer-variant-select")}},function(e,t,n){const r=n(5);e.exports={setCookie:function(e,t,n){var r=new Date;r.setTime(r.getTime()+1e3*n);var o="expires="+r.toUTCString();document.cookie=e+"="+t+";"+o+";path=/"},getCookie:function(e){for(var t=e+"=",n=decodeURIComponent(document.cookie).split(";"),r=0;r<n.length;r++){for(var o=n[r];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""},deleteCookie:function(e){document.cookie=e+"=; Expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/"},getOrderCookieName:function(){return"order_token_"+r.countryCode()},getOrderToken:function(){return this.getCookie(this.getOrderCookieName())},setOrderToken:function(e){return this.setCookie(this.getOrderCookieName(),e,2592e3)},deleteOrderToken:function(){return this.deleteCookie(this.getOrderCookieName())}}},function(e,t,n){e.exports=n(16)},function(e,t,n){"use strict";(function(t){var r=n(0),o=n(20),a={"Content-Type":"application/x-www-form-urlencoded"};function i(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,u={adapter:("undefined"!=typeof XMLHttpRequest?s=n(8):void 0!==t&&(s=n(8)),s),transformRequest:[function(e,t){return o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(i(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(i(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],function(e){u.headers[e]={}}),r.forEach(["post","put","patch"],function(e){u.headers[e]=r.merge(a)}),e.exports=u}).call(this,n(19))},function(e,t,n){const r=n(1);e.exports={baseUrl:function(){return r.config.dataset.baseUrl},clientId:function(){return r.config.dataset.clientId},marketId:function(){return r.config.dataset.marketId},countryCode:function(){return r.config.dataset.countryCode},languageCode:function(){return r.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return r.config.dataset.cartUrl},returnUrl:function(){return r.config.dataset.returnUrl},privacyUrl:function(){return r.config.dataset.privacyUrl},termsUrl:function(){return r.config.dataset.termsUrl}}},function(e,t,n){const r=n(1),o=n(3),a=(n(12),n(13)),i=n(5),s=n(2),u=n(14);e.exports={getPrices:function(){var e=r.prices;if(e.length>0){var t=[];e.forEach(function(e){t.push(e.dataset.skuCode)});var n="/api/skus?filter[codes]="+t.join(",")+"&include=prices&page[size]=25",i=["id","code","prices.formatted_amount","prices.formatted_compare_at_amount","prices.amount_cents","prices.compare_at_amount_cents"];o.get(n).then(function(e){u.updatePrices(a(e.data).get(i));var t=e.data.meta.page_count;if(t>1)for(var r=2;r<=t;r++){var s=n+"&page[number]="+r;o.get(s).then(function(e){u.updatePrices(a(e.data).get(i))})}})}},getVariants:function(){u.disableElement(r.addToBag);var t=r.variants;if(t.length>0){var n=[];t.forEach(function(e){u.disableElement(e),n.push(e.dataset.skuCode)}),o.get("/api/skus?filter[codes]="+n.join(",")).then(function(t){for(var n=a(t.data).get(["id","code"]),r=0;r<n.length;r++){var o=document.querySelector('.clayer-variant[data-sku-code="'+n[r].code+'"]');o&&(o.value=n[r].id,u.enableElement(o),1==n.length&&e.exports.getInventory(o.value,o.dataset.skuName))}})}},getInventory:function(e,t){o.get("/api/skus/"+e+"?fields[skus]=inventory").then(function(n){var r=n.data.data;r.attributes.inventory.available&&(u.updateAddToBag(e,t),u.updateAvailableMessage(r.attributes.inventory))})},createOrder:function(){return o.post("/api/orders",{data:{type:"orders",attributes:{shipping_country_code_lock:i.countryCode(),language_code:i.languageCode(),cart_url:i.cartUrl(),return_url:i.returnUrl(),privacy_url:i.privacyUrl(),terms_url:i.termsUrl()}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return s.setOrderToken(e.data.data.attributes.token),e.data.data})},refreshOrder:function(){s.getOrderToken()&&this.getOrder().then(function(e){e&&"placed"==e.attributes.status&&(s.deleteOrderToken(),u.clearShoppingBag())})},createLineItem:function(e,t,n,r){return o.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:r,_update_quantity:1},relationships:{order:{data:{type:"orders",id:e}},item:{data:{type:"skus",id:t}}}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},deleteLineItem:function(e){return o.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return o.patch("/api/line_items/"+e,{data:{type:"line_items",id:e,attributes:t}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},updateLineItemQty:function(e,t){api=this,api.updateLineItem(e,{quantity:t}).then(function(e){api.getOrder()}).catch(function(e){if(e.response)switch(e.response.status){case 422:u.displayShoppingBagUnavailableMessage()}})},updateShoppingBagItems:function(e){var t=this,n=r.shoppingBagItemsContainer;if(n){var o=a(e).get(["id","formatted_subtotal_amount","formatted_discount_amount","formatted_shipping_amount","formatted_payment_method_amount","formatted_total_tax_amount","formatted_total_amount_with_taxes","line_items.id","line_items.item_type","line_items.image_url","line_items.name","line_items.quantity","line_items.formatted_unit_amount","line_items.formatted_total_amount"])[0];if(o.line_items){n.innerHTML="";for(var i=0;i<o.line_items.length;i++){var s=o.line_items[i];if("skus"==s.item_type&&($shoppingBagItemTemplate=r.shoppingBagItemTemplate,$shoppingBagItemTemplate)){"TEMPLATE"==$shoppingBagItemTemplate.tagName?$shoppingBagItem=$shoppingBagItemTemplate.content.cloneNode(!0):$shoppingBagItem=$shoppingBagItemTemplate.cloneNode(!0),$shoppingBagItemImage=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-image"),$shoppingBagItemImage.src=s.image_url,$shoppingBagItemName=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-name"),$shoppingBagItemName.innerHTML=s.name,$shoppingBagItemQtyContainer=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-qty-container"),$qtySelect=document.createElement("select"),$qtySelect.dataset.lineItemId=s.id;for(var u=1;u<=10;u++)$option=document.createElement("option"),$option.value=u,$option.text=u,u==s.quantity&&($option.selected=!0),$qtySelect.appendChild($option);$qtySelect.addEventListener("change",function(e){t.updateLineItemQty(this.dataset.lineItemId,this.value)}),$shoppingBagItemQtyContainer.appendChild($qtySelect),$shoppingBagItemUnitAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-unit-amount"),$shoppingBagItemUnitAmount.innerHTML=s.formatted_unit_amount,$shoppingBagItemTotalAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-total-amount"),$shoppingBagItemTotalAmount.innerHTML=s.formatted_total_amount,$shoppingBagItemRemove=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-remove"),$shoppingBagItemRemove.dataset.lineItemId=s.id,$shoppingBagItemRemove.addEventListener("click",function(e){e.preventDefault(),t.deleteLineItem(this.dataset.lineItemId).then(function(e){t.getOrder()})}),n.appendChild($shoppingBagItem)}}}}},getOrder:function(){var e=this;return o.get("/api/orders?include=line_items&filter[token]="+s.getOrderToken()).then(function(t){if(t.data.data.length>0)return e.updateShoppingBagItems(t.data),u.hideShoppingBagUnavailableMessage(),u.updateShoppingBagPreview(t.data.data[0]),u.updateShoppingBagCheckout(t.data),t.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0),o=n(21),a=n(23),i=n(24),s=n(25),u=n(9),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(26);e.exports=function(e){return new Promise(function(t,l){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var f=new XMLHttpRequest,g="onreadystatechange",h=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in f||s(e.url)||(f=new window.XDomainRequest,g="onload",h=!0,f.onprogress=function(){},f.ontimeout=function(){}),e.auth){var m=e.auth.username||"",v=e.auth.password||"";d.Authorization="Basic "+c(m+":"+v)}if(f.open(e.method.toUpperCase(),a(e.url,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,f[g]=function(){if(f&&(4===f.readyState||h)&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in f?i(f.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?f.response:f.responseText,status:1223===f.status?204:f.status,statusText:1223===f.status?"No Content":f.statusText,headers:n,config:e,request:f};o(t,l,r),f=null}},f.onerror=function(){l(u("Network Error",e,null,f)),f=null},f.ontimeout=function(){l(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",f)),f=null},r.isStandardBrowserEnv()){var y=n(27),b=(e.withCredentials||s(e.url))&&e.xsrfCookieName?y.read(e.xsrfCookieName):void 0;b&&(d[e.xsrfHeaderName]=b)}if("setRequestHeader"in f&&r.forEach(d,function(e,t){void 0===p&&"content-type"===t.toLowerCase()?delete d[t]:f.setRequestHeader(t,e)}),e.withCredentials&&(f.withCredentials=!0),e.responseType)try{f.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){f&&(f.abort(),l(e),f=null)}),void 0===p&&(p=null),f.send(p)})}},function(e,t,n){"use strict";var r=n(22);e.exports=function(e,t,n,o,a){var i=new Error(e);return r(i,t,n,o,a)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){const r=n(3),o=n(5),a=n(2);r.defaults.baseURL=o.baseUrl(),r.defaults.headers.common.Accept="application/vnd.api+json",r.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+a.getCookie("access_token_${config.clientId()}_${config.marketId()}"),e},function(e){return Promise.reject(e)}),r.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&"INVALID_TOKEN"==e.response.data.errors[0].code?r.post("/oauth/token",{grant_type:"client_credentials",client_id:o.clientId(),scope:"market:"+o.marketId()}).then(function(e){return a.setCookie("access_token_${config.clientId()}_${config.marketId()}",e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return e.config.headers.Authorization="Bearer "+t,r.request(e.config)}):Promise.reject(e)})},function(e,t,n){var r,o,a;o=[],void 0===(a="function"==typeof(r=function(){function e(r,o){if(!(this instanceof e)){var a=new e(r);return o?a.get(o):a}if("string"==typeof r&&(r=JSON.parse(r)),!r||!r.data)throw new Error("Invalid json api normalizer input");var i,s,u,c;this.dataset=r,this.isCollection=t(r.data),this.haystack=(i=r.included,s=this.isCollection?r.data:[r.data],u=[],n(c=i||[],function(e){u.push(e.type+"@"+e.id)}),n(s,function(e){u.indexOf(e.type+"@"+e.id)<0&&c.push(e)}),c)}function t(e){return e instanceof Array}function n(e,n,r){if(t(e))for(var o=e.length,a=0;a<o;a++)n.call(r,e[a],a);else for(var i in e)e.hasOwnProperty(i)&&n.call(r,i,e[i])}function r(e,t,r){var o=[];return n(e,function(e,n){o.push(t.call(r,e,n))}),o}function o(o,s,u){var c={};return n(o,function(n,o){if(o)c[n]=function(e,n,o,s){var u=o.relationships&&o.relationships[e]&&o.relationships[e].data,c=u&&i(u,s);return t(c)?r(c,function(e){return a(n,e,s)}):c?a(n,c,s):void 0}(n,o,s,u);else{var l=s.relationships&&s.relationships[n]&&s.relationships[n].data;if(l){var p=i(l,u);c[n]=p?new e({data:p,included:u}):void 0}else c[n]=function(e,t){return["id","type"].indexOf(e)>=0?t[e]:t.attributes[e]}(n,s)}}),c}function a(t,n,r){return s.call(new e({data:n,included:r}),t)}function i(e,o){var a=[],i=t(e)?r(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(o,function(e){i.indexOf(e.type+"@"+e.id)>=0&&a.push(e)}),0===a.length?void 0:1!==a.length||t(e)?a:a[0]}function s(e){return this.isCollection?r(this.dataset.data,function(t){return o(e,t,this.haystack)},this):o(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var o,a,i=s.call(this,(o=t(e)?e:[e],a={},n(o,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var r in n)n.hasOwnProperty(r)&&("object"==typeof n[r]&&null!==n[r]?(void 0===t[r]&&(t[r]={}),e(t[r],n[r])):t[r]=n[r]);return t}(a,function(e){for(var t={},n=t,r=e.length,o=0;o<r;o++)n=n[e[o]]=n[e[o]]||(o+1===r?void 0:{});return t}(t)):a[e]=void 0}),a));return this.isCollection?t(e)?i:r(i,function(t){return t[e]}):t(e)?i:i[e]},e})?r.apply(t,o):r)||(e.exports=a)},function(e,t,n){const r=n(1),o=n(13);e.exports={enableElement:function(e){e&&e.removeAttribute("disabled")},disableElement:function(e){e&&e.setAttribute("disabled","disabled")},setElementHTML(e,t){var n=document.querySelector(e);n&&(n.innerHTML=t)},displayElement:function(e){e&&(e.style.display="block")},hideElement:function(e){e&&(e.style.display="none")},updatePrices:function(e){for(var t=0;t<e.length;t++){var n=document.querySelector('[data-sku-code="'+e[t].code+'"] > .amount');n&&(n.innerHTML=e[t].prices[0].formatted_amount);var r=document.querySelector('[data-sku-code="'+e[t].code+'"] > .compare-at-amount');r&&e[t].prices[0].compare_at_amount_cents>e[t].prices[0].amount_cents&&(r.innerHTML=e[t].prices[0].formatted_compare_at_amount)}},updateAddToBag:function(e,t){var n=r.addToBag;n&&(n.dataset.skuId=e,n.dataset.skuName=t,this.enableElement(n))},updateAvailableMessage:function(e){var t=r.availableMessage,n=r.unavailableMessage;if(this.hideElement(n),t){if(first_level=e.levels[0],0==first_level.quantity)for(var o=1;o<e.levels.length;o++)if(level=e.levels[o],level.quantity>0){first_level=level;break}first_level.quantity>0&&(first_delivery_lead_time=first_level.delivery_lead_times[0],this.setElementHTML(".available-message-qty",first_level.quantity),this.setElementHTML(".available-message-min-days",first_delivery_lead_time.min.days),this.setElementHTML(".available-message-max-days",first_delivery_lead_time.max.days),this.setElementHTML(".available-message-shipping-price",first_delivery_lead_time.shipping_method.formatted_price_amount),this.displayElement(t))}},updateShoppingBagPreview:function(e){var t=r.shoppingBagPreviewCount;t&&(t.innerHTML=e.attributes.skus_count);var n=r.shoppingBagPreviewTotal;n&&(n.innerHTML=e.attributes.formatted_total_amount_with_taxes)},updateShoppingBagCheckout:function(e){var t=r.shoppingBagCheckout;if(t){var n=o(e).get(["line_items.id","checkout_url"])[0];n.line_items?(t.removeAttribute("disabled"),t.href=n.checkout_url):t.setAttribute("disabled","")}},displayUnavailableMessage:function(){this.hideElement(r.availableMessage),this.displayElement(r.unavailableMessage)},toggleShoppingBag:function(){$shoppingBagContainer=r.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=r.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=r.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=r.main,$main&&$main.classList.add("open")},closeShoppingBag:function(){$shoppingBagContainer=r.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.remove("open"),$main=r.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){r.shoppingBagItemsContainer.innerHTML=""},displayShoppingBagUnavailableMessage:function(){this.displayElement(r.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(r.shoppingBagUnavailableMessage)},addTableColText:function(e,t,n){var r=document.createElement("td");r.classList.add("shopping-bag-col"),r.classList.add(n);var o=document.createTextNode(t);r.appendChild(o),e.appendChild(r)},addTableColImage:function(e,t,n){var r=document.createElement("td");r.classList.add("shopping-bag-col"),r.classList.add(n);var o=document.createElement("img");o.src=t,r.appendChild(o),e.appendChild(r)},addTableColElement:function(e,t,n){var r=document.createElement("td");r.classList.add("shopping-bag-col"),r.classList.add(n),r.appendChild(t),e.appendChild(r)}}},function(e,t,n){const r=n(6),o=n(35);n(2);t.init=function(){r.getPrices(),r.getVariants(),o.setVariantSelect(),o.setAddToShoppingBag(),o.setShoppingBagToggle(),o.setShoppingBagClose(),r.refreshOrder()}},function(e,t,n){"use strict";var r=n(0),o=n(7),a=n(18),i=n(4);function s(e){var t=new a(e),n=o(a.prototype.request,t);return r.extend(n,a.prototype,t),r.extend(n,t),n}var u=s(i);u.Axios=a,u.create=function(e){return s(r.merge(i,e))},u.Cancel=n(11),u.CancelToken=n(33),u.isCancel=n(10),u.all=function(e){return Promise.all(e)},u.spread=n(34),e.exports=u,e.exports.default=u},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)} | ||
!function(e){var t={};function n(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(a,i,function(t){return e[t]}.bind(null,i));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}([function(e,t,n){"use strict";var a=n(7),i=n(17),o=Object.prototype.toString;function r(e){return"[object Array]"===o.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===o.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,a=e.length;n<a;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:i,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,a){"object"==typeof t[a]&&"object"==typeof n?t[a]=e(t[a],n):t[a]=n}for(var a=0,i=arguments.length;a<i;a++)u(arguments[a],n);return t},extend:function(e,t,n){return u(t,function(t,i){e[i]=n&&"function"==typeof t?a(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){n(5);const a=n(35);e.exports={getOrderCookieName:function(){return"order_token_${config.countryCode()}"},getAccessTokenCookieName:function(){return"access_token_${config.clientId()}_${config.marketId()}"},getAccessTokenRetryLockCookieName:function(){return"${this.getAccessTokenCookieName()}_retry_lock"},getOrderToken:function(){return a.get(this.getOrderCookieName())},setOrderToken:function(e){return a.set(this.getOrderCookieName(),e,{expires:30})},deleteOrderToken:function(){return a.remove(this.getOrderCookieName())},getAccessTokenCookie:function(){return a.get(this.getAccessTokenCookieName())},setAccessTokenCookie:function(e,t){a.set(this.getAccessTokenCookieName(),e,t)},getAccessTokenRetryLockCookie:function(){return a.get(this.getAccessTokenRetryLockCookieName())},setAccessTokenRetryLockCookie:function(){a.set(this.getAccessTokenRetryLockCookieName(),"1",{expires:1/1440})},getElementFromTemplate:function(e){return"TEMPLATE"==e.tagName?e.content.cloneNode(!0):e.cloneNode(!0)},getInventoryFirstAvailableLevel:function(e){if(first_level=e.levels[0],0==first_level.quantity)for(k=1;k<e.levels.length;k++)if(level=e.levels[k],level.quantity>0){first_level=level;break}return first_level}}},function(e,t){e.exports={config:document.querySelector("#clayer-config"),main:document.querySelector("#clayer-main"),prices:Array.prototype.slice.call(document.querySelectorAll(".clayer-price"),0),variants:Array.prototype.slice.call(document.querySelectorAll(".clayer-variant"),0),variantSelect:document.querySelector(".clayer-variant-select"),availabilityMessageContainer:document.querySelector("#clayer-availability-message-container"),availabilityMessageAvailableTemplate:document.querySelector("#clayer-availability-message-available-template"),availabilityMessageUnavailableTemplate:document.querySelector("#clayer-availability-message-unavailable-template"),addToBag:document.querySelector(".clayer-add-to-bag"),shoppingBagContainer:document.querySelector("#clayer-shopping-bag-container"),shoppingBagItemsContainer:document.querySelector("#clayer-shopping-bag-items-container"),shoppingBagItemTemplate:document.querySelector("#clayer-shopping-bag-item-template"),shoppingBagItemsCount:document.querySelector("#clayer-shopping-bag-items-count"),shoppingBagSubtotal:document.querySelector("#clayer-shopping-bag-subtotal"),shoppingBagShipping:document.querySelector("#clayer-shopping-bag-shipping"),shoppingBagPayment:document.querySelector("#clayer-shopping-bag-payment"),shoppingBagTaxes:document.querySelector("#clayer-shopping-bag-taxes"),shoppingBagTotal:document.querySelector("#clayer-shopping-bag-total"),shoppingBagCheckout:document.querySelector("#clayer-shopping-bag-checkout"),shoppingBagClose:document.querySelector("#clayer-shopping-bag-close"),shoppingBagToggle:document.querySelector("#clayer-shopping-bag-toggle"),shoppingBagUnavailableMessage:document.querySelector(".clayer-shopping-bag-unavailable-message")}},function(e,t,n){e.exports=n(16)},function(e,t,n){"use strict";(function(t){var a=n(0),i=n(20),o={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!a.isUndefined(e)&&a.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:("undefined"!=typeof XMLHttpRequest?s=n(8):void 0!==t&&(s=n(8)),s),transformRequest:[function(e,t){return i(t,"Content-Type"),a.isFormData(e)||a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)?e:a.isArrayBufferView(e)?e.buffer:a.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):a.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},a.forEach(["delete","get","head"],function(e){c.headers[e]={}}),a.forEach(["post","put","patch"],function(e){c.headers[e]=a.merge(o)}),e.exports=c}).call(this,n(19))},function(e,t,n){const a=n(2);e.exports={baseUrl:function(){return a.config.dataset.baseUrl},clientId:function(){return a.config.dataset.clientId},marketId:function(){return a.config.dataset.marketId},countryCode:function(){return a.config.dataset.countryCode},languageCode:function(){return a.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return a.config.dataset.cartUrl},returnUrl:function(){return a.config.dataset.returnUrl},privacyUrl:function(){return a.config.dataset.privacyUrl},termsUrl:function(){return a.config.dataset.termsUrl}}},function(e,t,n){const a=n(2),o=n(3),r=(n(12),n(13)),s=n(5),c=n(1),u=n(14);e.exports={getPrices:function(){$prices=a.prices,$prices.length>0&&(skuCodes=[],$prices.forEach(function(e){skuCodes.push(e.dataset.skuCode)}),skus=[],skusEndpoint="/api/skus?filter[codes]="+skuCodes.join(",")+"&include=prices&page[size]=25",skuAttributes=["id","code","prices.formatted_amount","prices.formatted_compare_at_amount","prices.amount_cents","prices.compare_at_amount_cents"],o.get(skusEndpoint).then(function(e){if(u.updatePrices(r(e.data).get(skuAttributes)),pageCount=e.data.meta.page_count,pageCount>1)for(p=2;p<=pageCount;p++)skusEndpointWithPage=skusEndpoint+"&page[number]="+p,o.get(skusEndpointWithPage).then(function(e){u.updatePrices(r(e.data).get(skuAttributes))})}))},getVariants:function(){u.disableElement(a.addToBag),$variants=a.variants,$variants.length>0&&(skuCodes=[],$variants.forEach(function(e){u.disableElement(e),skuCodes.push(e.dataset.skuCode)}),o.get("/api/skus?filter[codes]="+skuCodes.join(",")).then(function(t){for(skus=r(t.data).get(["id","code"]),i=0;i<skus.length;i++)variant=document.querySelector('.clayer-variant[data-sku-code="'+skus[i].code+'"]'),variant&&(variant.value=skus[i].id,u.enableElement(variant),0==i&&e.exports.selectVariant(variant))}))},getInventory:function(e,t){o.get("/api/skus/"+e+"?fields[skus]=inventory").then(function(n){sku=n.data.data,u.updateAvailabilityMessage(sku.attributes.inventory),sku.attributes.inventory.available?(u.updateAddToBagSKU(e,t),u.enableAddToBag()):u.disableAddToBag()})},selectVariant:function(t){switch(t.tagName){case"INPUT":switch(t.type){case"radio":t.click();break;case"hidden":e.exports.getInventory(t.value,t.dataset.skuName)}break;case"OPTION":$select=t.parentNode,$select.value=t.value,$select.dispatchEvent(new Event("change"))}},createOrder:function(){return o.post("/api/orders",{data:{type:"orders",attributes:{shipping_country_code_lock:s.countryCode(),language_code:s.languageCode(),cart_url:s.cartUrl(),return_url:s.returnUrl(),privacy_url:s.privacyUrl(),terms_url:s.termsUrl()}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return c.setOrderToken(e.data.data.attributes.token),e.data.data})},refreshOrder:function(){c.getOrderToken()&&this.getOrder().then(function(e){e&&"placed"==e.attributes.status&&(c.deleteOrderToken(),u.clearShoppingBag())})},createLineItem:function(e,t,n,a){return o.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:a,_update_quantity:1},relationships:{order:{data:{type:"orders",id:e}},item:{data:{type:"skus",id:t}}}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},deleteLineItem:function(e){return o.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return o.patch("/api/line_items/"+e,{data:{type:"line_items",id:e,attributes:t}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},updateLineItemQty:function(e,t){api=this,api.updateLineItem(e,{quantity:t}).then(function(e){api.getOrder()}).catch(function(e){if(e.response)switch(e.response.status){case 422:u.displayShoppingBagUnavailableMessage()}})},updateShoppingBagItems:function(e){if(api=this,$shoppingBagItemsContainer=a.shoppingBagItemsContainer,$shoppingBagItemsContainer&&(normalized_order=r(e).get(["id","formatted_subtotal_amount","formatted_discount_amount","formatted_shipping_amount","formatted_payment_method_amount","formatted_total_tax_amount","formatted_total_amount_with_taxes","line_items.id","line_items.item_type","line_items.image_url","line_items.name","line_items.quantity","line_items.formatted_unit_amount","line_items.formatted_total_amount"])[0],normalized_order.line_items))for($shoppingBagItemsContainer.innerHTML="",i=0;i<normalized_order.line_items.length;i++)if(line_item=normalized_order.line_items[i],"skus"==line_item.item_type&&($shoppingBagItemTemplate=a.shoppingBagItemTemplate,$shoppingBagItemTemplate)){for("TEMPLATE"==$shoppingBagItemTemplate.tagName?$shoppingBagItem=$shoppingBagItemTemplate.content.cloneNode(!0):$shoppingBagItem=$shoppingBagItemTemplate.cloneNode(!0),$shoppingBagItemImage=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-image"),$shoppingBagItemImage.src=line_item.image_url,$shoppingBagItemName=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-name"),$shoppingBagItemName.innerHTML=line_item.name,$shoppingBagItemQtyContainer=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-qty-container"),$qtySelect=document.createElement("select"),$qtySelect.dataset.lineItemId=line_item.id,qty=1;qty<=10;qty++)$option=document.createElement("option"),$option.value=qty,$option.text=qty,qty==line_item.quantity&&($option.selected=!0),$qtySelect.appendChild($option);$qtySelect.addEventListener("change",function(e){api.updateLineItemQty(this.dataset.lineItemId,this.value)}),$shoppingBagItemQtyContainer.appendChild($qtySelect),$shoppingBagItemUnitAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-unit-amount"),$shoppingBagItemUnitAmount.innerHTML=line_item.formatted_unit_amount,$shoppingBagItemTotalAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-total-amount"),$shoppingBagItemTotalAmount.innerHTML=line_item.formatted_total_amount,$shoppingBagItemRemove=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-remove"),$shoppingBagItemRemove.dataset.lineItemId=line_item.id,$shoppingBagItemRemove.addEventListener("click",function(e){e.preventDefault(),zombieItem=this.parentNode,api.deleteLineItem(this.dataset.lineItemId).then(function(e){api.getOrder(),zombieItem.parentNode.removeChild(zombieItem)})}),$shoppingBagItemsContainer.appendChild($shoppingBagItem)}},getOrder:function(){return api=this,o.get("/api/orders?include=line_items&filter[token]="+c.getOrderToken()).then(function(e){if(e.data.data.length>0)return api.updateShoppingBagItems(e.data),u.hideShoppingBagUnavailableMessage(),u.updateShoppingBagSummary(e.data.data[0]),u.updateShoppingBagCheckout(e.data),e.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),a=0;a<n.length;a++)n[a]=arguments[a];return e.apply(t,n)}}},function(e,t,n){"use strict";var a=n(0),i=n(21),o=n(23),r=n(24),s=n(25),c=n(9),u="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(26);e.exports=function(e){return new Promise(function(t,p){var l=e.data,d=e.headers;a.isFormData(l)&&delete d["Content-Type"];var f=new XMLHttpRequest,g="onreadystatechange",h=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in f||s(e.url)||(f=new window.XDomainRequest,g="onload",h=!0,f.onprogress=function(){},f.ontimeout=function(){}),e.auth){var m=e.auth.username||"",y=e.auth.password||"";d.Authorization="Basic "+u(m+":"+y)}if(f.open(e.method.toUpperCase(),o(e.url,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,f[g]=function(){if(f&&(4===f.readyState||h)&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in f?r(f.getAllResponseHeaders()):null,a={data:e.responseType&&"text"!==e.responseType?f.response:f.responseText,status:1223===f.status?204:f.status,statusText:1223===f.status?"No Content":f.statusText,headers:n,config:e,request:f};i(t,p,a),f=null}},f.onerror=function(){p(c("Network Error",e,null,f)),f=null},f.ontimeout=function(){p(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",f)),f=null},a.isStandardBrowserEnv()){var v=n(27),b=(e.withCredentials||s(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;b&&(d[e.xsrfHeaderName]=b)}if("setRequestHeader"in f&&a.forEach(d,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete d[t]:f.setRequestHeader(t,e)}),e.withCredentials&&(f.withCredentials=!0),e.responseType)try{f.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){f&&(f.abort(),p(e),f=null)}),void 0===l&&(l=null),f.send(l)})}},function(e,t,n){"use strict";var a=n(22);e.exports=function(e,t,n,i,o){var r=new Error(e);return a(r,t,n,i,o)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function a(e){this.message=e}a.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},a.prototype.__CANCEL__=!0,e.exports=a},function(e,t,n){const a=n(3),i=n(5),o=n(1);a.defaults.baseURL=i.baseUrl(),a.defaults.headers.common.Accept="application/vnd.api+json",a.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+o.getAccessTokenCookie(),e},function(e){return Promise.reject(e)}),a.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&null==o.getAccessTokenRetryLockCookie()?a.post("/oauth/token",{grant_type:"client_credentials",client_id:i.clientId(),scope:"market:"+i.marketId()}).then(function(e){return o.setAccessTokenCookie(e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return o.setAccessTokenRetryLockCookie(),e.config.headers.Authorization="Bearer "+t,a.request(e.config)}):Promise.reject(e)})},function(e,t,n){var a,i,o;i=[],void 0===(o="function"==typeof(a=function(){function e(a,i){if(!(this instanceof e)){var o=new e(a);return i?o.get(i):o}if("string"==typeof a&&(a=JSON.parse(a)),!a||!a.data)throw new Error("Invalid json api normalizer input");var r,s,c,u;this.dataset=a,this.isCollection=t(a.data),this.haystack=(r=a.included,s=this.isCollection?a.data:[a.data],c=[],n(u=r||[],function(e){c.push(e.type+"@"+e.id)}),n(s,function(e){c.indexOf(e.type+"@"+e.id)<0&&u.push(e)}),u)}function t(e){return e instanceof Array}function n(e,n,a){if(t(e))for(var i=e.length,o=0;o<i;o++)n.call(a,e[o],o);else for(var r in e)e.hasOwnProperty(r)&&n.call(a,r,e[r])}function a(e,t,a){var i=[];return n(e,function(e,n){i.push(t.call(a,e,n))}),i}function i(i,s,c){var u={};return n(i,function(n,i){if(i)u[n]=function(e,n,i,s){var c=i.relationships&&i.relationships[e]&&i.relationships[e].data,u=c&&r(c,s);return t(u)?a(u,function(e){return o(n,e,s)}):u?o(n,u,s):void 0}(n,i,s,c);else{var p=s.relationships&&s.relationships[n]&&s.relationships[n].data;if(p){var l=r(p,c);u[n]=l?new e({data:l,included:c}):void 0}else u[n]=function(e,t){return["id","type"].indexOf(e)>=0?t[e]:t.attributes[e]}(n,s)}}),u}function o(t,n,a){return s.call(new e({data:n,included:a}),t)}function r(e,i){var o=[],r=t(e)?a(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(i,function(e){r.indexOf(e.type+"@"+e.id)>=0&&o.push(e)}),0===o.length?void 0:1!==o.length||t(e)?o:o[0]}function s(e){return this.isCollection?a(this.dataset.data,function(t){return i(e,t,this.haystack)},this):i(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var i,o,r=s.call(this,(i=t(e)?e:[e],o={},n(i,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var a in n)n.hasOwnProperty(a)&&("object"==typeof n[a]&&null!==n[a]?(void 0===t[a]&&(t[a]={}),e(t[a],n[a])):t[a]=n[a]);return t}(o,function(e){for(var t={},n=t,a=e.length,i=0;i<a;i++)n=n[e[i]]=n[e[i]]||(i+1===a?void 0:{});return t}(t)):o[e]=void 0}),o));return this.isCollection?t(e)?r:a(r,function(t){return t[e]}):t(e)?r:r[e]},e})?a.apply(t,i):a)||(e.exports=o)},function(e,t,n){const a=n(2),i=n(1),o=n(13);e.exports={enableElement:function(e){e&&e.classList.remove("disabled")},disableElement:function(e){e&&e.classList.add("disabled")},setElementHTML(e,t){$el=document.querySelector(e),$el&&($el.innerHTML=t)},displayElement:function(e){e&&(e.style.display="block")},hideElement:function(e){e&&(e.style.display="none")},updatePrices:function(e){for(k=0;k<e.length;k++)priceAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .amount'),priceAmount&&(priceAmount.innerHTML=e[k].prices[0].formatted_amount),priceCompareAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .compare-at-amount'),priceCompareAmount&&e[k].prices[0].compare_at_amount_cents>e[k].prices[0].amount_cents&&(priceCompareAmount.innerHTML=e[k].prices[0].formatted_compare_at_amount)},updateAddToBagSKU:function(e,t){$addToBag=a.addToBag,$addToBag&&($addToBag.dataset.skuId=e,$addToBag.dataset.skuName=t)},enableAddToBag:function(){$addToBag=a.addToBag,$addToBag&&this.enableElement($addToBag)},disableAddToBag:function(){$addToBag=a.addToBag,$addToBag&&this.disableElement($addToBag)},updateAvailabilityMessage:function(e){$container=a.availabilityMessageContainer,$container&&(first_level=i.getInventoryFirstAvailableLevel(e),first_level.quantity>0?(dlt=first_level.delivery_lead_times[0],qty=first_level.quantity,minDays=dlt.min.days,maxDays=dlt.max.days,shippingMethodName=dlt.shipping_method.name,shippingMethodPrice=dlt.shipping_method.formatted_price_amount,this.displayAvailableMessage(qty,minDays,maxDays,shippingMethodName,shippingMethodPrice)):this.displayUnavailableMessage())},updateShoppingBagSummary:function(e){$shoppingBagItemsCount=a.shoppingBagItemsCount,$shoppingBagItemsCount&&($shoppingBagItemsCount.innerHTML=e.attributes.skus_count),$shoppingBagTotal=a.shoppingBagTotal,$shoppingBagTotal&&($shoppingBagTotal.innerHTML=e.attributes.formatted_total_amount_with_taxes),$shoppingBagSubtotal=a.shoppingBagSubtotal,$shoppingBagSubtotal&&($shoppingBagSubtotal.innerHTML=e.attributes.formatted_subtotal_amount),$shoppingBagShipping=a.shoppingBagShipping,$shoppingBagShipping&&($shoppingBagShipping.innerHTML=e.attributes.formatted_shipping_amount),$shoppingBagPayment=a.shoppingBagPayment,$shoppingBagPayment&&($shoppingBagPayment.innerHTML=e.attributes.formatted_payment_method_amount),$shoppingBagTaxes=a.shoppingBagTaxes,$shoppingBagTaxes&&($shoppingBagTaxes.innerHTML=e.attributes.formatted_total_tax_amount),$shoppingBagDiscount=a.shoppingBagDiscount,$shoppingBagDiscount&&($shoppingBagDiscount.innerHTML=e.attributes.formatted_discount_amount)},updateShoppingBagCheckout:function(e){$shoppingBagCheckout=a.shoppingBagCheckout,$shoppingBagCheckout&&(normalized_order=o(e).get(["line_items.id","checkout_url"])[0],normalized_order.line_items?(this.enableElement($shoppingBagCheckout),$shoppingBagCheckout.href=normalized_order.checkout_url):($shoppingBagCheckout.href="",this.disableElement($shoppingBagCheckout)))},displayAvailableMessage:function(e,t,n,o,r){$container=a.availabilityMessageContainer,$container&&($tmp=a.availabilityMessageAvailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),$availableMessageQty=$el.querySelector(".clayer-availability-message-available-qty"),$availableMessageQty.innerHTML=e,$availabilityMessageAvailableMinDays=$el.querySelector(".clayer-availability-message-available-min-days"),$availabilityMessageAvailableMinDays.innerHTML=t,$availabilityMessageAvailableMaxDays=$el.querySelector(".clayer-availability-message-available-max-days"),$availabilityMessageAvailableMaxDays.innerHTML=n,$availabilityMessageAvailableShippingMethodName=$el.querySelector(".clayer-availability-message-available-shipping-method-name"),$availabilityMessageAvailableShippingMethodName.innerHTML=o,$availabilityMessageAvailableShippingMethodPrice=$el.querySelector(".clayer-availability-message-available-shipping-method-price"),$availabilityMessageAvailableShippingMethodPrice.innerHTML=r,$container.innerHTML="",$container.appendChild($el)))},displayUnavailableMessage:function(){$container=a.availabilityMessageContainer,$container&&($tmp=a.availabilityMessageUnavailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),$container.innerHTML="",$container.appendChild($el)))},toggleShoppingBag:function(){$shoppingBagContainer=a.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=a.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=a.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=a.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){a.shoppingBagItemsContainer.innerHTML=""},displayShoppingBagUnavailableMessage:function(){this.displayElement(a.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(a.shoppingBagUnavailableMessage)}}},function(e,t,n){const a=n(6),i=n(36);n(1);t.init=function(){a.getPrices(),a.getVariants(),i.setVariantSelect(),i.setAddToShoppingBag(),i.setShoppingBagToggle(),a.refreshOrder()}},function(e,t,n){"use strict";var a=n(0),i=n(7),o=n(18),r=n(4);function s(e){var t=new o(e),n=i(o.prototype.request,t);return a.extend(n,o.prototype,t),a.extend(n,t),n}var c=s(r);c.Axios=o,c.create=function(e){return s(a.merge(r,e))},c.Cancel=n(11),c.CancelToken=n(33),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(34),e.exports=c,e.exports.default=c},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)} | ||
/*! | ||
@@ -8,2 +8,9 @@ * Determine if an object is a Buffer | ||
*/ | ||
e.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var r=n(4),o=n(0),a=n(28),i=n(29);function s(e){this.defaults=e,this.interceptors={request:new a,response:new a}}s.prototype.request=function(e){"string"==typeof e&&(e=o.merge({url:arguments[0]},arguments[1])),(e=o.merge(r,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[i,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},o.forEach(["delete","get","head","options"],function(e){s.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){s.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=s},function(e,t){var n,r,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var u,c=[],l=!1,p=-1;function d(){l&&u&&(l=!1,u.length?c=u.concat(c):p=-1,c.length&&f())}function f(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(u=c,c=[];++p<t;)u&&u[p].run();p=-1,t=c.length}u=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function h(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new g(e,t)),1!==c.length||l||s(f)},g.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=h,o.addListener=h,o.once=h,o.off=h,o.removeListener=h,o.removeAllListeners=h,o.emit=h,o.prependListener=h,o.prependOnceListener=h,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var a;if(n)a=n(t);else if(r.isURLSearchParams(t))a=t.toString();else{var i=[];r.forEach(t,function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),i.push(o(t)+"="+o(e))}))}),a=i.join("&")}return a&&(e+=(-1===e.indexOf("?")?"?":"&")+a),e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,a,i={};return e?(r.forEach(e.split("\n"),function(e){if(a=e.indexOf(":"),t=r.trim(e.substr(0,a)).toLowerCase(),n=r.trim(e.substr(a+1)),t){if(i[t]&&o.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([n]):i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function o(){this.message="String contains an invalid character"}o.prototype=new Error,o.prototype.code=5,o.prototype.name="InvalidCharacterError",e.exports=function(e){for(var t,n,a=String(e),i="",s=0,u=r;a.charAt(0|s)||(u="=",s%1);i+=u.charAt(63&t>>8-s%1*8)){if((n=a.charCodeAt(s+=.75))>255)throw new o;t=t<<8|n}return i}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,a,i){var s=[];s.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(o)&&s.push("path="+o),r.isString(a)&&s.push("domain="+a),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(30),a=n(10),i=n(4),s=n(31),u=n(32);function c(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return c(e),e.baseURL&&!s(e.url)&&(e.url=u(e.baseURL,e.url)),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),r.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||i.adapter)(e).then(function(t){return c(e),t.data=o(t.data,t.headers,e.transformResponse),t},function(t){return a(t)||(c(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(11);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new r(e),t(n.reason))})}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o(function(t){e=t}),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){const r=n(1),o=(n(3),n(12),n(14)),a=n(6),i=n(2);e.exports={setVariantSelect:function(){var e=r.variantSelect;e?e.addEventListener("change",a.getInventory(e.value,e.options[this.selectedIndex].dataset.skuName)):($variants=r.variants,$variants.forEach(function(e){console.log(e),e.addEventListener("click",a.getInventory(e.value,e.dataset.skuName))}))},setAddToShoppingBag:function(){var e=r.addToBag;e&&e.addEventListener("click",function(t){t.preventDefault(),(i.getOrderToken()?a.getOrder():a.createOrder()).then(function(t){a.createLineItem(t.id,e.dataset.skuId,e.dataset.skuName,e.dataset.skuImageUrl).then(function(e){a.getOrder(),o.openShoppingBag()}).catch(function(e){if(e.response)switch(e.response.status){case 422:o.displayUnavailableMessage()}})})})},setShoppingBagToggle:function(){var e=r.shoppingBagToggle;e&&e.addEventListener("click",function(e){e.preventDefault(),o.toggleShoppingBag()})},setShoppingBagClose:function(){var e=r.shoppingBagClose;e&&e.addEventListener("click",function(e){e.preventDefault(),o.closeShoppingBag()})}}}]); | ||
e.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var a=n(4),i=n(0),o=n(28),r=n(29);function s(e){this.defaults=e,this.interceptors={request:new o,response:new o}}s.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),(e=i.merge(a,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[r,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){s.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){s.prototype[e]=function(t,n,a){return this.request(i.merge(a||{},{method:e,url:t,data:n}))}}),e.exports=s},function(e,t){var n,a,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{a="function"==typeof clearTimeout?clearTimeout:r}catch(e){a=r}}();var c,u=[],p=!1,l=-1;function d(){p&&c&&(p=!1,c.length?u=c.concat(u):l=-1,u.length&&f())}function f(){if(!p){var e=s(d);p=!0;for(var t=u.length;t;){for(c=u,u=[];++l<t;)c&&c[l].run();l=-1,t=u.length}c=null,p=!1,function(e){if(a===clearTimeout)return clearTimeout(e);if((a===r||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function h(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new g(e,t)),1!==u.length||p||s(f)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=h,i.addListener=h,i.once=h,i.off=h,i.removeListener=h,i.removeAllListeners=h,i.emit=h,i.prependListener=h,i.prependOnceListener=h,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";var a=n(0);e.exports=function(e,t){a.forEach(e,function(n,a){a!==t&&a.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[a])})}},function(e,t,n){"use strict";var a=n(9);e.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(a("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n,a,i){return e.config=t,n&&(e.code=n),e.request=a,e.response=i,e}},function(e,t,n){"use strict";var a=n(0);function i(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(a.isURLSearchParams(t))o=t.toString();else{var r=[];a.forEach(t,function(e,t){null!=e&&(a.isArray(e)?t+="[]":e=[e],a.forEach(e,function(e){a.isDate(e)?e=e.toISOString():a.isObject(e)&&(e=JSON.stringify(e)),r.push(i(t)+"="+i(e))}))}),o=r.join("&")}return o&&(e+=(-1===e.indexOf("?")?"?":"&")+o),e}},function(e,t,n){"use strict";var a=n(0),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,o,r={};return e?(a.forEach(e.split("\n"),function(e){if(o=e.indexOf(":"),t=a.trim(e.substr(0,o)).toLowerCase(),n=a.trim(e.substr(o+1)),t){if(r[t]&&i.indexOf(t)>=0)return;r[t]="set-cookie"===t?(r[t]?r[t]:[]).concat([n]):r[t]?r[t]+", "+n:n}}),r):r}},function(e,t,n){"use strict";var a=n(0);e.exports=a.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var a=e;return t&&(n.setAttribute("href",a),a=n.href),n.setAttribute("href",a),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=a.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function i(){this.message="String contains an invalid character"}i.prototype=new Error,i.prototype.code=5,i.prototype.name="InvalidCharacterError",e.exports=function(e){for(var t,n,o=String(e),r="",s=0,c=a;o.charAt(0|s)||(c="=",s%1);r+=c.charAt(63&t>>8-s%1*8)){if((n=o.charCodeAt(s+=.75))>255)throw new i;t=t<<8|n}return r}},function(e,t,n){"use strict";var a=n(0);e.exports=a.isStandardBrowserEnv()?{write:function(e,t,n,i,o,r){var s=[];s.push(e+"="+encodeURIComponent(t)),a.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),a.isString(i)&&s.push("path="+i),a.isString(o)&&s.push("domain="+o),!0===r&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var a=n(0);function i(){this.handlers=[]}i.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){a.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=i},function(e,t,n){"use strict";var a=n(0),i=n(30),o=n(10),r=n(4),s=n(31),c=n(32);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!s(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=a.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),a.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||r.adapter)(e).then(function(t){return u(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var a=n(0);e.exports=function(e,t,n){return a.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var a=n(11);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new a(e),t(n.reason))})}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i(function(t){e=t}),cancel:e}},e.exports=i},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){var a,i; | ||
/*! | ||
* JavaScript Cookie v2.2.0 | ||
* https://github.com/js-cookie/js-cookie | ||
* | ||
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack | ||
* Released under the MIT license | ||
*/!function(o){if(void 0===(i="function"==typeof(a=o)?a.call(t,n,t,e):a)||(e.exports=i),!0,e.exports=o(),!!0){var r=window.Cookies,s=window.Cookies=o();s.noConflict=function(){return window.Cookies=r,s}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var a in n)t[a]=n[a]}return t}return function t(n){function a(t,i,o){var r;if("undefined"!=typeof document){if(arguments.length>1){if("number"==typeof(o=e({path:"/"},a.defaults,o)).expires){var s=new Date;s.setMilliseconds(s.getMilliseconds()+864e5*o.expires),o.expires=s}o.expires=o.expires?o.expires.toUTCString():"";try{r=JSON.stringify(i),/^[\{\[]/.test(r)&&(i=r)}catch(e){}i=n.write?n.write(i,t):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=(t=(t=encodeURIComponent(String(t))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var c="";for(var u in o)o[u]&&(c+="; "+u,!0!==o[u]&&(c+="="+o[u]));return document.cookie=t+"="+i+c}t||(r={});for(var p=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d<p.length;d++){var f=p[d].split("="),g=f.slice(1).join("=");this.json||'"'!==g.charAt(0)||(g=g.slice(1,-1));try{var h=f[0].replace(l,decodeURIComponent);if(g=n.read?n.read(g,h):n(g,h)||g.replace(l,decodeURIComponent),this.json)try{g=JSON.parse(g)}catch(e){}if(t===h){r=g;break}t||(r[h]=g)}catch(e){}}return r}}return a.set=a,a.get=function(e){return a.call(a,e)},a.getJSON=function(){return a.apply({json:!0},[].slice.call(arguments))},a.defaults={},a.remove=function(t,n){a(t,"",e(n,{expires:-1}))},a.withConverter=t,a}(function(){})})},function(e,t,n){const a=n(2),i=(n(3),n(12),n(14)),o=n(6),r=n(1);e.exports={setVariantSelect:function(){$variantSelect=a.variantSelect,$variantSelect?$variantSelect.addEventListener("change",function(e){$selectedOption=$variantSelect.options[this.selectedIndex],o.getInventory($selectedOption.value,$selectedOption.dataset.skuName)}):($variants=a.variants,$variants.forEach(function(e){e.addEventListener("click",function(e){o.getInventory(this.value,this.dataset.skuName)})}))},setAddToShoppingBag:function(){$addToBag=a.addToBag,$addToBag&&$addToBag.addEventListener("click",function(e){e.preventDefault(),orderPromise=r.getOrderToken()?o.getOrder():o.createOrder(),orderPromise.then(function(e){o.createLineItem(e.id,$addToBag.dataset.skuId,$addToBag.dataset.skuName,$addToBag.dataset.skuImageUrl).then(function(e){o.getOrder(),i.openShoppingBag()}).catch(function(e){if(e.response)switch(e.response.status){case 422:i.displayUnavailableMessage()}})})})},setShoppingBagToggle:function(){$shoppingBagToggle=a.shoppingBagToggle,$shoppingBagToggle&&$shoppingBagToggle.addEventListener("click",function(e){e.preventDefault(),i.toggleShoppingBag()})}}}]); |
{ | ||
"name": "commercelayer", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "The Official Commerce Layer JS library", | ||
@@ -28,2 +28,3 @@ "main": "./src/main.js", | ||
"axios": "^0.18.0", | ||
"js-cookie": "^2.2.0", | ||
"json-api-normalize": "^1.1.5" | ||
@@ -30,0 +31,0 @@ }, |
@@ -12,7 +12,7 @@ const elements = require('./elements') | ||
var $prices = elements.prices | ||
$prices = elements.prices | ||
if ($prices.length > 0) { | ||
var skuCodes = [] | ||
skuCodes = [] | ||
@@ -23,5 +23,5 @@ $prices.forEach(function ($price) { | ||
var skus = [] | ||
var skusEndpoint = '/api/skus?filter[codes]=' + skuCodes.join(',') +'&include=prices&page[size]=25' | ||
var skuAttributes = [ | ||
skus = [] | ||
skusEndpoint = '/api/skus?filter[codes]=' + skuCodes.join(',') +'&include=prices&page[size]=25' | ||
skuAttributes = [ | ||
'id', | ||
@@ -41,8 +41,8 @@ 'code', | ||
var pageCount = response.data.meta.page_count | ||
pageCount = response.data.meta.page_count | ||
if (pageCount > 1) { | ||
for (var p=2; p<=pageCount; p++ ) { | ||
for (p=2; p<=pageCount; p++ ) { | ||
var skusEndpointWithPage = skusEndpoint + '&page[number]=' + p | ||
skusEndpointWithPage = skusEndpoint + '&page[number]=' + p | ||
@@ -63,7 +63,7 @@ axios | ||
var $variants = elements.variants | ||
$variants = elements.variants | ||
if ($variants.length > 0) { | ||
var skuCodes = [] | ||
skuCodes = [] | ||
@@ -78,3 +78,3 @@ $variants.forEach(function (variant) { | ||
.then(function(response) { | ||
var skus = normalize(response.data).get([ | ||
skus = normalize(response.data).get([ | ||
'id', | ||
@@ -84,10 +84,10 @@ 'code' | ||
for (var i = 0; i < skus.length; i++) { | ||
for (i = 0; i < skus.length; i++) { | ||
var variant = document.querySelector('.clayer-variant[data-sku-code="' + skus[i].code + '"]') | ||
variant = document.querySelector('.clayer-variant[data-sku-code="' + skus[i].code + '"]') | ||
if (variant) { | ||
variant.value = skus[i].id | ||
ui.enableElement(variant) | ||
if (skus.length == 1) { | ||
module.exports.getInventory(variant.value, variant.dataset.skuName) | ||
if (i == 0) { | ||
module.exports.selectVariant(variant) | ||
} | ||
@@ -103,9 +103,31 @@ } | ||
.then(function(response) { | ||
var sku = response.data.data | ||
sku = response.data.data | ||
ui.updateAvailabilityMessage(sku.attributes.inventory) | ||
if (sku.attributes.inventory.available) { | ||
ui.updateAddToBag(skuId, skuName) | ||
ui.updateAvailableMessage(sku.attributes.inventory) | ||
ui.updateAddToBagSKU(skuId, skuName) | ||
ui.enableAddToBag() | ||
} else { | ||
ui.disableAddToBag() | ||
} | ||
}) | ||
}, | ||
selectVariant: function(variant) { | ||
switch(variant.tagName) { | ||
case "INPUT": | ||
switch(variant.type) { | ||
case "radio": | ||
variant.click() | ||
break | ||
case "hidden": | ||
module.exports.getInventory(variant.value, variant.dataset.skuName) | ||
break | ||
} | ||
break | ||
case "OPTION": | ||
$select = variant.parentNode | ||
$select.value = variant.value | ||
$select.dispatchEvent(new Event('change')) | ||
break | ||
} | ||
}, | ||
createOrder: function() { | ||
@@ -223,7 +245,7 @@ return axios | ||
updateShoppingBagItems: function(order) { | ||
var api = this | ||
var $shoppingBagItemsContainer = elements.shoppingBagItemsContainer | ||
api = this | ||
$shoppingBagItemsContainer = elements.shoppingBagItemsContainer | ||
if ($shoppingBagItemsContainer) { | ||
var normalized_order = normalize(order).get([ | ||
normalized_order = normalize(order).get([ | ||
'id', | ||
@@ -249,5 +271,5 @@ 'formatted_subtotal_amount', | ||
for (var i = 0; i < normalized_order.line_items.length; i++) { | ||
for (i = 0; i < normalized_order.line_items.length; i++) { | ||
var line_item = normalized_order.line_items[i] | ||
line_item = normalized_order.line_items[i] | ||
@@ -279,3 +301,3 @@ if (line_item.item_type == "skus") { | ||
for (var qty = 1; qty <= 10; qty++) { | ||
for (qty = 1; qty <= 10; qty++) { | ||
$option = document.createElement("option") | ||
@@ -308,4 +330,6 @@ $option.value = qty | ||
event.preventDefault() | ||
zombieItem = this.parentNode | ||
api.deleteLineItem(this.dataset.lineItemId).then(function(lineItem){ | ||
api.getOrder() | ||
zombieItem.parentNode.removeChild(zombieItem) | ||
}) | ||
@@ -320,3 +344,2 @@ }) | ||
} | ||
} | ||
@@ -326,3 +349,3 @@ }, | ||
var api = this | ||
api = this | ||
@@ -335,3 +358,3 @@ return axios | ||
ui.hideShoppingBagUnavailableMessage() | ||
ui.updateShoppingBagPreview(response.data.data[0]) | ||
ui.updateShoppingBagSummary(response.data.data[0]) | ||
ui.updateShoppingBagCheckout(response.data) | ||
@@ -338,0 +361,0 @@ return response.data.data[0] |
@@ -5,6 +5,2 @@ const axios = require('axios') | ||
function accessTokenCookieName() { | ||
return 'access_token_${config.clientId()}_${config.marketId()}' | ||
} | ||
function getAccessToken() { | ||
@@ -18,3 +14,3 @@ return axios | ||
.then(function (response) { | ||
utils.setCookie(accessTokenCookieName(), response.data.access_token, response.data.expires_in) | ||
utils.setAccessTokenCookie(response.data.access_token, response.data.expires_in) | ||
return response.data.access_token | ||
@@ -30,3 +26,3 @@ }) | ||
axios.interceptors.request.use(function (requestConfig) { | ||
requestConfig.headers.Authorization = 'Bearer ' + utils.getCookie(accessTokenCookieName()) | ||
requestConfig.headers.Authorization = 'Bearer ' + utils.getAccessTokenCookie() | ||
return requestConfig | ||
@@ -41,4 +37,5 @@ }, function (error) { | ||
if (error.response.status === 401) { | ||
if (error.response.data.errors[0].code == "INVALID_TOKEN") { | ||
if (utils.getAccessTokenRetryLockCookie() == undefined) { | ||
return getAccessToken().then(function(accessToken) { | ||
utils.setAccessTokenRetryLockCookie() | ||
error.config.headers.Authorization = 'Bearer ' + accessToken | ||
@@ -45,0 +42,0 @@ return axios.request(error.config) |
module.exports = { | ||
addToBag: document.querySelector(".clayer-add-to-bag"), | ||
availableMessage: document.querySelector('.clayer-available-message'), | ||
config: document.querySelector('#clayer-config'), | ||
main: document.querySelector('#clayer-main'), | ||
prices: Array.prototype.slice.call(document.querySelectorAll('.clayer-price'), 0), | ||
variants: Array.prototype.slice.call(document.querySelectorAll('.clayer-variant'), 0), | ||
variantSelect: document.querySelector('.clayer-variant-select'), | ||
availabilityMessageContainer: document.querySelector('#clayer-availability-message-container'), | ||
availabilityMessageAvailableTemplate: document.querySelector('#clayer-availability-message-available-template'), | ||
availabilityMessageUnavailableTemplate: document.querySelector('#clayer-availability-message-unavailable-template'), | ||
addToBag: document.querySelector(".clayer-add-to-bag"), | ||
shoppingBagContainer: document.querySelector('#clayer-shopping-bag-container'), | ||
shoppingBagItemsContainer: document.querySelector('#clayer-shopping-bag-items-container'), | ||
shoppingBagItemTemplate: document.querySelector('#clayer-shopping-bag-item-template'), | ||
shoppingBagItemsCount: document.querySelector('#clayer-shopping-bag-items-count'), | ||
shoppingBagSubtotal: document.querySelector('#clayer-shopping-bag-subtotal'), | ||
shoppingBagShipping: document.querySelector('#clayer-shopping-bag-shipping'), | ||
shoppingBagPayment: document.querySelector('#clayer-shopping-bag-payment'), | ||
shoppingBagTaxes: document.querySelector('#clayer-shopping-bag-taxes'), | ||
shoppingBagTotal: document.querySelector('#clayer-shopping-bag-total'), | ||
shoppingBagCheckout: document.querySelector('#clayer-shopping-bag-checkout'), | ||
shoppingBagClose: document.querySelector('#clayer-shopping-bag-close'), | ||
shoppingBagPreviewCount: document.querySelector('#clayer-shopping-bag-preview-count'), | ||
shoppingBagPreviewTotal: document.querySelector('#clayer-shopping-bag-preview-total'), | ||
shoppingBagToggle: document.querySelector('#clayer-shopping-bag-toggle'), | ||
shoppingBagUnavailableMessage: document.querySelector('.clayer-shopping-bag-unavailable-message'), | ||
unavailableMessage: document.querySelector('.clayer-unavailable-message'), | ||
variants: Array.prototype.slice.call(document.querySelectorAll('.clayer-variant'), 0), | ||
variantSelect: document.querySelector('.clayer-variant-select') | ||
shoppingBagUnavailableMessage: document.querySelector('.clayer-shopping-bag-unavailable-message') | ||
} |
@@ -11,11 +11,15 @@ const elements = require('./elements') | ||
var $variantSelect = elements.variantSelect | ||
$variantSelect = elements.variantSelect | ||
if ($variantSelect) { | ||
$variantSelect.addEventListener('change', api.getInventory($variantSelect.value, $variantSelect.options[this.selectedIndex].dataset.skuName)) | ||
$variantSelect.addEventListener('change', function(event){ | ||
$selectedOption = $variantSelect.options[this.selectedIndex] | ||
api.getInventory($selectedOption.value, $selectedOption.dataset.skuName) | ||
}) | ||
} else { // radio | ||
$variants = elements.variants | ||
$variants.forEach(function (variant) { | ||
console.log(variant) | ||
variant.addEventListener('click', api.getInventory(variant.value, variant.dataset.skuName)) | ||
variant.addEventListener('click', function(event){ | ||
api.getInventory(this.value, this.dataset.skuName) | ||
}) | ||
}) | ||
@@ -25,3 +29,3 @@ } | ||
setAddToShoppingBag: function() { | ||
var $addToBag = elements.addToBag | ||
$addToBag = elements.addToBag | ||
@@ -32,3 +36,3 @@ if ($addToBag) { | ||
var orderPromise = utils.getOrderToken() ? api.getOrder() : api.createOrder() | ||
orderPromise = utils.getOrderToken() ? api.getOrder() : api.createOrder() | ||
@@ -54,3 +58,3 @@ orderPromise.then(function(order){ | ||
setShoppingBagToggle: function() { | ||
var $shoppingBagToggle = elements.shoppingBagToggle | ||
$shoppingBagToggle = elements.shoppingBagToggle | ||
if ($shoppingBagToggle) { | ||
@@ -62,13 +66,3 @@ $shoppingBagToggle.addEventListener('click', function(event){ | ||
} | ||
}, | ||
setShoppingBagClose: function() { | ||
var $shoppingBagClose = elements.shoppingBagClose | ||
if ($shoppingBagClose) { | ||
$shoppingBagClose.addEventListener('click', function(event){ | ||
event.preventDefault() | ||
ui.closeShoppingBag() | ||
}) | ||
} | ||
} | ||
} |
@@ -11,4 +11,3 @@ const api = require('./api') | ||
listeners.setShoppingBagToggle() | ||
listeners.setShoppingBagClose() | ||
api.refreshOrder() | ||
} |
188
src/ui.js
const elements = require('./elements') | ||
const utils = require('./utils') | ||
const normalize = require('json-api-normalize') | ||
@@ -7,3 +8,3 @@ | ||
if (el) { | ||
el.removeAttribute('disabled') | ||
el.classList.remove("disabled") | ||
} | ||
@@ -13,7 +14,7 @@ }, | ||
if (el) { | ||
el.setAttribute("disabled","disabled") | ||
el.classList.add("disabled") | ||
} | ||
}, | ||
setElementHTML(selector, html) { | ||
var $el = document.querySelector(selector) | ||
$el = document.querySelector(selector) | ||
if ($el) { | ||
@@ -34,8 +35,8 @@ $el.innerHTML = html | ||
updatePrices: function(skus) { | ||
for (var k = 0; k < skus.length; k++) { | ||
var priceAmount = document.querySelector('[data-sku-code="' + skus[k].code + '"] > .amount') | ||
for (k = 0; k < skus.length; k++) { | ||
priceAmount = document.querySelector('[data-sku-code="' + skus[k].code + '"] > .amount') | ||
if (priceAmount) { | ||
priceAmount.innerHTML = skus[k].prices[0].formatted_amount | ||
} | ||
var priceCompareAmount = document.querySelector('[data-sku-code="' + skus[k].code + '"] > .compare-at-amount') | ||
priceCompareAmount = document.querySelector('[data-sku-code="' + skus[k].code + '"] > .compare-at-amount') | ||
if (priceCompareAmount) { | ||
@@ -48,57 +49,78 @@ if (skus[k].prices[0].compare_at_amount_cents > skus[k].prices[0].amount_cents) { | ||
}, | ||
updateAddToBag: function(skuId, skuName) { | ||
var $addToBag = elements.addToBag | ||
updateAddToBagSKU: function(skuId, skuName) { | ||
$addToBag = elements.addToBag | ||
if ($addToBag) { | ||
$addToBag.dataset.skuId = skuId | ||
$addToBag.dataset.skuName = skuName | ||
} | ||
}, | ||
enableAddToBag: function() { | ||
$addToBag = elements.addToBag | ||
if ($addToBag) { | ||
this.enableElement($addToBag) | ||
} | ||
}, | ||
updateAvailableMessage: function(inventory) { | ||
var $availableMessage = elements.availableMessage | ||
var $unavailableMessage = elements.unavailableMessage | ||
disableAddToBag: function() { | ||
$addToBag = elements.addToBag | ||
if ($addToBag) { | ||
this.disableElement($addToBag) | ||
} | ||
}, | ||
updateAvailabilityMessage: function(inventory) { | ||
this.hideElement($unavailableMessage) | ||
$container = elements.availabilityMessageContainer | ||
if ($availableMessage) { | ||
if ($container) { | ||
first_level = inventory.levels[0] | ||
first_level = utils.getInventoryFirstAvailableLevel(inventory) | ||
if (first_level.quantity == 0) { | ||
for(var k=1; k < inventory.levels.length; k++) { | ||
level = inventory.levels[k] | ||
if (level.quantity > 0) { | ||
first_level = level | ||
break | ||
} | ||
} | ||
} | ||
if (first_level.quantity > 0) { | ||
if (first_level.quantity > 0) { | ||
first_delivery_lead_time = first_level.delivery_lead_times[0] | ||
this.setElementHTML('.available-message-qty', first_level.quantity) | ||
this.setElementHTML('.available-message-min-days', first_delivery_lead_time.min.days) | ||
this.setElementHTML('.available-message-max-days', first_delivery_lead_time.max.days) | ||
this.setElementHTML('.available-message-shipping-price', first_delivery_lead_time.shipping_method.formatted_price_amount) | ||
this.displayElement($availableMessage) | ||
dlt = first_level.delivery_lead_times[0] | ||
qty = first_level.quantity | ||
minDays = dlt.min.days | ||
maxDays = dlt.max.days | ||
shippingMethodName = dlt.shipping_method.name | ||
shippingMethodPrice = dlt.shipping_method.formatted_price_amount | ||
this.displayAvailableMessage(qty, minDays, maxDays, shippingMethodName, shippingMethodPrice) | ||
} else { | ||
this.displayUnavailableMessage() | ||
} | ||
} | ||
}, | ||
updateShoppingBagPreview: function(order) { | ||
var $shoppingBagPreviewCount = elements.shoppingBagPreviewCount | ||
if ($shoppingBagPreviewCount) { | ||
$shoppingBagPreviewCount.innerHTML = order.attributes.skus_count | ||
updateShoppingBagSummary: function(order) { | ||
$shoppingBagItemsCount = elements.shoppingBagItemsCount | ||
if ($shoppingBagItemsCount) { | ||
$shoppingBagItemsCount.innerHTML = order.attributes.skus_count | ||
} | ||
var $shoppingBagPreviewTotal = elements.shoppingBagPreviewTotal | ||
if ($shoppingBagPreviewTotal) { | ||
$shoppingBagPreviewTotal.innerHTML = order.attributes.formatted_total_amount_with_taxes | ||
$shoppingBagTotal = elements.shoppingBagTotal | ||
if ($shoppingBagTotal) { | ||
$shoppingBagTotal.innerHTML = order.attributes.formatted_total_amount_with_taxes | ||
} | ||
$shoppingBagSubtotal = elements.shoppingBagSubtotal | ||
if ($shoppingBagSubtotal) { | ||
$shoppingBagSubtotal.innerHTML = order.attributes.formatted_subtotal_amount | ||
} | ||
$shoppingBagShipping = elements.shoppingBagShipping | ||
if ($shoppingBagShipping) { | ||
$shoppingBagShipping.innerHTML = order.attributes.formatted_shipping_amount | ||
} | ||
$shoppingBagPayment = elements.shoppingBagPayment | ||
if ($shoppingBagPayment) { | ||
$shoppingBagPayment.innerHTML = order.attributes.formatted_payment_method_amount | ||
} | ||
$shoppingBagTaxes = elements.shoppingBagTaxes | ||
if ($shoppingBagTaxes) { | ||
$shoppingBagTaxes.innerHTML = order.attributes.formatted_total_tax_amount | ||
} | ||
$shoppingBagDiscount = elements.shoppingBagDiscount | ||
if ($shoppingBagDiscount) { | ||
$shoppingBagDiscount.innerHTML = order.attributes.formatted_discount_amount | ||
} | ||
}, | ||
updateShoppingBagCheckout: function(order) { | ||
var $shoppingBagCheckout = elements.shoppingBagCheckout | ||
$shoppingBagCheckout = elements.shoppingBagCheckout | ||
if ($shoppingBagCheckout) { | ||
var normalized_order = normalize(order).get([ | ||
normalized_order = normalize(order).get([ | ||
'line_items.id', | ||
@@ -109,13 +131,53 @@ 'checkout_url' | ||
if (normalized_order.line_items) { | ||
$shoppingBagCheckout.removeAttribute('disabled') | ||
this.enableElement($shoppingBagCheckout) | ||
$shoppingBagCheckout.href = normalized_order.checkout_url | ||
} else { | ||
$shoppingBagCheckout.setAttribute('disabled', '') | ||
$shoppingBagCheckout.href = '' | ||
this.disableElement($shoppingBagCheckout) | ||
} | ||
} | ||
}, | ||
displayAvailableMessage: function(qty, minDays, maxDays, shippingMethodName, shippingMethodPrice) { | ||
$container = elements.availabilityMessageContainer | ||
if ($container) { | ||
$tmp = elements.availabilityMessageAvailableTemplate | ||
if ($tmp) { | ||
$el = utils.getElementFromTemplate($tmp) | ||
$availableMessageQty = $el.querySelector('.clayer-availability-message-available-qty') | ||
$availableMessageQty.innerHTML = qty | ||
$availabilityMessageAvailableMinDays = $el.querySelector('.clayer-availability-message-available-min-days') | ||
$availabilityMessageAvailableMinDays.innerHTML = minDays | ||
$availabilityMessageAvailableMaxDays = $el.querySelector('.clayer-availability-message-available-max-days') | ||
$availabilityMessageAvailableMaxDays.innerHTML = maxDays | ||
$availabilityMessageAvailableShippingMethodName = $el.querySelector('.clayer-availability-message-available-shipping-method-name') | ||
$availabilityMessageAvailableShippingMethodName.innerHTML = shippingMethodName | ||
$availabilityMessageAvailableShippingMethodPrice = $el.querySelector('.clayer-availability-message-available-shipping-method-price') | ||
$availabilityMessageAvailableShippingMethodPrice.innerHTML = shippingMethodPrice | ||
$container.innerHTML = '' | ||
$container.appendChild($el) | ||
} | ||
} | ||
}, | ||
displayUnavailableMessage: function() { | ||
this.hideElement(elements.availableMessage) | ||
this.displayElement(elements.unavailableMessage) | ||
$container = elements.availabilityMessageContainer | ||
if ($container) { | ||
$tmp = elements.availabilityMessageUnavailableTemplate | ||
if ($tmp) { | ||
$el = utils.getElementFromTemplate($tmp) | ||
$container.innerHTML = '' | ||
$container.appendChild($el) | ||
} | ||
} | ||
}, | ||
@@ -139,12 +201,2 @@ toggleShoppingBag: function() { | ||
if ($main) { | ||
$main.classList.add("open") | ||
} | ||
}, | ||
closeShoppingBag: function() { | ||
$shoppingBagContainer = elements.shoppingBagContainer | ||
if ($shoppingBagContainer) { | ||
$shoppingBagContainer.classList.remove("open") | ||
} | ||
$main = elements.main | ||
if ($main) { | ||
$main.classList.remove("open") | ||
@@ -161,27 +213,3 @@ } | ||
this.hideElement(elements.shoppingBagUnavailableMessage) | ||
}, | ||
addTableColText: function(tableRow, text, className) { | ||
var tableCol = document.createElement('td') | ||
tableCol.classList.add('shopping-bag-col') | ||
tableCol.classList.add(className) | ||
var tableColText = document.createTextNode(text) | ||
tableCol.appendChild(tableColText) | ||
tableRow.appendChild(tableCol) | ||
}, | ||
addTableColImage: function(tableRow, imageUrl, className) { | ||
var tableCol = document.createElement('td') | ||
tableCol.classList.add('shopping-bag-col') | ||
tableCol.classList.add(className) | ||
var tableColImg = document.createElement('img') | ||
tableColImg.src = imageUrl | ||
tableCol.appendChild(tableColImg) | ||
tableRow.appendChild(tableCol) | ||
}, | ||
addTableColElement: function(tableRow, element, className) { | ||
var tableCol = document.createElement('td') | ||
tableCol.classList.add('shopping-bag-col') | ||
tableCol.classList.add(className) | ||
tableCol.appendChild(element) | ||
tableRow.appendChild(tableCol) | ||
} | ||
} |
const config = require('./config') | ||
const cookies = require('js-cookie') | ||
module.exports = { | ||
setCookie: function(cname, cvalue, exsecs) { | ||
var d = new Date() | ||
d.setTime(d.getTime() + (exsecs*1000)) | ||
var expires = "expires="+ d.toUTCString() | ||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/" | ||
getOrderCookieName: function() { | ||
return 'order_token_${config.countryCode()}' | ||
}, | ||
getCookie: function(cname) { | ||
var name = cname + "="; | ||
var decodedCookie = decodeURIComponent(document.cookie) | ||
var ca = decodedCookie.split(';') | ||
for(var i = 0; i <ca.length; i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0) == ' ') { | ||
c = c.substring(1); | ||
} | ||
if (c.indexOf(name) == 0) { | ||
return c.substring(name.length, c.length); | ||
} | ||
} | ||
return "" | ||
getAccessTokenCookieName: function() { | ||
return 'access_token_${config.clientId()}_${config.marketId()}' | ||
}, | ||
deleteCookie: function(cname) { | ||
document.cookie = cname + "=; Expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/"; | ||
getAccessTokenRetryLockCookieName: function() { | ||
return '${this.getAccessTokenCookieName()}_retry_lock' | ||
}, | ||
getOrderCookieName: function() { | ||
return 'order_token_' + config.countryCode() | ||
}, | ||
getOrderToken: function() { | ||
return this.getCookie(this.getOrderCookieName()) | ||
return cookies.get(this.getOrderCookieName()) | ||
}, | ||
setOrderToken: function(token) { | ||
return this.setCookie(this.getOrderCookieName(), token, 30*60*60*24) | ||
return cookies.set(this.getOrderCookieName(), token, { expires: 30 }) | ||
}, | ||
deleteOrderToken: function() { | ||
return this.deleteCookie(this.getOrderCookieName()) | ||
return cookies.remove(this.getOrderCookieName()) | ||
}, | ||
getAccessTokenCookie: function() { | ||
return cookies.get(this.getAccessTokenCookieName()) | ||
}, | ||
setAccessTokenCookie: function(access_token, expires_in) { | ||
cookies.set(this.getAccessTokenCookieName(), access_token, expires_in) | ||
}, | ||
getAccessTokenRetryLockCookie: function() { | ||
return cookies.get(this.getAccessTokenRetryLockCookieName()) | ||
}, | ||
setAccessTokenRetryLockCookie: function() { | ||
cookies.set(this.getAccessTokenRetryLockCookieName(), "1", { expires: 1/1440 }) // 1 minute | ||
}, | ||
getElementFromTemplate: function(template) { | ||
if (template.tagName == "TEMPLATE") { | ||
return template.content.cloneNode(true) | ||
} else { | ||
return template.cloneNode(true) | ||
} | ||
}, | ||
getInventoryFirstAvailableLevel: function(inventory) { | ||
first_level = inventory.levels[0] | ||
if (first_level.quantity == 0) { | ||
for(k=1; k < inventory.levels.length; k++) { | ||
level = inventory.levels[k] | ||
if (level.quantity > 0) { | ||
first_level = level | ||
break | ||
} | ||
} | ||
} | ||
return first_level | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61268
859
3
+ Addedjs-cookie@^2.2.0
+ Addedjs-cookie@2.2.1(transitive)