commercelayer
Advanced tools
Comparing version 1.3.8 to 1.3.9
@@ -1,2 +0,2 @@ | ||
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},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 o=n(7),a=n(17),i=Object.prototype.toString;function r(e){return"[object Array]"===i.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.call(null,e[a],a,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:a,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]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.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,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]=n}for(var o=0,a=arguments.length;o<a;o++)u(arguments[o],n);return t},extend:function(e,t,n){return u(t,function(t,a){e[a]=n&&"function"==typeof t?o(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){const o=n(5),a=n(35);e.exports={getOrderCookieName:function(){return`order_token_${o.clientId()}_${o.marketId()}_${o.countryCode()}`},getAccessTokenCookieName:function(){return`access_token_${o.clientId()}_${o.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"),shoppingBagDiscount:document.querySelector("#clayer-shopping-bag-discount"),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 o=n(0),a=n(20),i={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!o.isUndefined(e)&&o.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 a(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.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, */*"}},o.forEach(["delete","get","head"],function(e){c.headers[e]={}}),o.forEach(["post","put","patch"],function(e){c.headers[e]=o.merge(i)}),e.exports=c}).call(this,n(19))},function(e,t,n){const o=n(2);e.exports={baseUrl:function(){return o.config.dataset.baseUrl},clientId:function(){return o.config.dataset.clientId},marketId:function(){return o.config.dataset.marketId},countryCode:function(){return o.config.dataset.countryCode},languageCode:function(){return o.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return o.config.dataset.cartUrl},returnUrl:function(){return o.config.dataset.returnUrl},privacyUrl:function(){return o.config.dataset.privacyUrl},termsUrl:function(){return o.config.dataset.termsUrl}}},function(e,t,n){const o=n(2),a=n(3),r=(n(12),n(13)),s=n(5),c=n(1),u=n(14);e.exports={getPrices:function(){$prices=o.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"],a.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,a.get(skusEndpointWithPage).then(function(e){u.updatePrices(r(e.data).get(skuAttributes))})}))},getVariants:function(){u.disableElement(o.addToBag),$variants=o.variants,$variants.length>0&&(skuCodes=[],$variants.forEach(function(e){u.disableElement(e),skuCodes.push(e.dataset.skuCode)}),a.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){a.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 a.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,o){return a.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:o,_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 a.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return a.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=o.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=o.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(),api.deleteLineItem(this.dataset.lineItemId).then(function(e){api.getOrder()})}),$shoppingBagItemsContainer.appendChild($shoppingBagItem)}},getOrder:function(){return api=this,a.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),0==e.data.data[0].attributes.skus_count&&u.clearShoppingBag(),e.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}}},function(e,t,n){"use strict";var o=n(0),a=n(21),i=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;o.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(),i(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,o={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};a(t,p,o),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},o.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&&o.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 o=n(22);e.exports=function(e,t,n,a,i){var r=new Error(e);return o(r,t,n,a,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,n){const o=n(3),a=n(5),i=n(1);o.defaults.baseURL=a.baseUrl(),o.defaults.headers.common.Accept="application/vnd.api+json",o.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+i.getAccessTokenCookie(),e},function(e){return Promise.reject(e)}),o.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&function(){if(navigator.cookieEnabled)return!0;document.cookie="cookietest=1";var e=-1!=document.cookie.indexOf("cookietest=");return document.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}()&&null==i.getAccessTokenRetryLockCookie()?(i.setAccessTokenRetryLockCookie(),o.post("/oauth/token",{grant_type:"client_credentials",client_id:a.clientId(),scope:"market:"+a.marketId()}).then(function(e){return i.setAccessTokenCookie(e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return e.config.headers.Authorization="Bearer "+t,o.request(e.config)})):Promise.reject(e)})},function(e,t,n){var o,a,i;a=[],void 0===(i="function"==typeof(o=function(){function e(o,a){if(!(this instanceof e)){var i=new e(o);return a?i.get(a):i}if("string"==typeof o&&(o=JSON.parse(o)),!o||!o.data)throw new Error("Invalid json api normalizer input");var r,s,c,u;this.dataset=o,this.isCollection=t(o.data),this.haystack=(r=o.included,s=this.isCollection?o.data:[o.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,o){if(t(e))for(var a=e.length,i=0;i<a;i++)n.call(o,e[i],i);else for(var r in e)e.hasOwnProperty(r)&&n.call(o,r,e[r])}function o(e,t,o){var a=[];return n(e,function(e,n){a.push(t.call(o,e,n))}),a}function a(a,s,c){var u={};return n(a,function(n,a){if(a)u[n]=function(e,n,a,s){var c=a.relationships&&a.relationships[e]&&a.relationships[e].data,u=c&&r(c,s);return t(u)?o(u,function(e){return i(n,e,s)}):u?i(n,u,s):void 0}(n,a,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 i(t,n,o){return s.call(new e({data:n,included:o}),t)}function r(e,a){var i=[],r=t(e)?o(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(a,function(e){r.indexOf(e.type+"@"+e.id)>=0&&i.push(e)}),0===i.length?void 0:1!==i.length||t(e)?i:i[0]}function s(e){return this.isCollection?o(this.dataset.data,function(t){return a(e,t,this.haystack)},this):a(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var a,i,r=s.call(this,(a=t(e)?e:[e],i={},n(a,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var o in n)n.hasOwnProperty(o)&&("object"==typeof n[o]&&null!==n[o]?(void 0===t[o]&&(t[o]={}),e(t[o],n[o])):t[o]=n[o]);return t}(i,function(e){for(var t={},n=t,o=e.length,a=0;a<o;a++)n=n[e[a]]=n[e[a]]||(a+1===o?void 0:{});return t}(t)):i[e]=void 0}),i));return this.isCollection?t(e)?r:o(r,function(t){return t[e]}):t(e)?r:r[e]},e})?o.apply(t,a):o)||(e.exports=i)},function(e,t,n){const o=n(2),a=n(1),i=n(13);e.exports={enableElement:function(e){e&&e.classList.remove("disabled")},disableElement:function(e){e&&e.classList.add("disabled")},setElementHTML(e,t,n){el=e.querySelector(t),el&&(el.innerHTML=n)},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=o.addToBag,$addToBag&&($addToBag.dataset.skuId=e,$addToBag.dataset.skuName=t)},enableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.enableElement($addToBag)},disableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.disableElement($addToBag)},updateAvailabilityMessage:function(e){$container=o.availabilityMessageContainer,$container&&(first_level=a.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=o.shoppingBagItemsCount,$shoppingBagItemsCount&&($shoppingBagItemsCount.innerHTML=e.attributes.skus_count),$shoppingBagTotal=o.shoppingBagTotal,$shoppingBagTotal&&($shoppingBagTotal.innerHTML=e.attributes.formatted_total_amount_with_taxes),$shoppingBagSubtotal=o.shoppingBagSubtotal,$shoppingBagSubtotal&&($shoppingBagSubtotal.innerHTML=e.attributes.formatted_subtotal_amount),$shoppingBagShipping=o.shoppingBagShipping,$shoppingBagShipping&&($shoppingBagShipping.innerHTML=e.attributes.formatted_shipping_amount),$shoppingBagPayment=o.shoppingBagPayment,$shoppingBagPayment&&($shoppingBagPayment.innerHTML=e.attributes.formatted_payment_method_amount),$shoppingBagTaxes=o.shoppingBagTaxes,$shoppingBagTaxes&&($shoppingBagTaxes.innerHTML=e.attributes.formatted_total_tax_amount),$shoppingBagDiscount=o.shoppingBagDiscount,$shoppingBagDiscount&&($shoppingBagDiscount.innerHTML=e.attributes.formatted_discount_amount)},updateShoppingBagCheckout:function(e){$shoppingBagCheckout=o.shoppingBagCheckout,$shoppingBagCheckout&&(normalized_order=i(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,i,r){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageAvailableTemplate,$tmp&&($el=a.getElementFromTemplate($tmp),this.setElementHTML($el,".clayer-availability-message-available-qty",e),this.setElementHTML($el,".clayer-availability-message-available-min-days",t),this.setElementHTML($el,".clayer-availability-message-available-max-days",n),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-name",i),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-price",r),$container.innerHTML="",$container.appendChild($el)))},displayUnavailableMessage:function(){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageUnavailableTemplate,$tmp&&($el=a.getElementFromTemplate($tmp),$container.innerHTML="",$container.appendChild($el)))},toggleShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=o.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=o.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){o.shoppingBagItemsContainer&&(o.shoppingBagItemsContainer.innerHTML="")},displayShoppingBagUnavailableMessage:function(){this.displayElement(o.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(o.shoppingBagUnavailableMessage)}}},function(e,t,n){const o=n(6),a=n(36);n(1);t.init=function(){o.getPrices(),o.getVariants(),a.setVariantSelect(),a.setAddToShoppingBag(),a.setShoppingBagToggle(),o.refreshOrder()},document.commercelayer=e.exports,document.addEventListener("readystatechange",function(){"interactive"==document.readyState&&document.commercelayer.init()})},function(e,t,n){"use strict";var o=n(0),a=n(7),i=n(18),r=n(4);function s(e){var t=new i(e),n=a(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var c=s(r);c.Axios=i,c.create=function(e){return s(o.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)} | ||
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},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 o=n(7),a=n(17),i=Object.prototype.toString;function r(e){return"[object Array]"===i.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.call(null,e[a],a,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:a,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]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.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,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]=n}for(var o=0,a=arguments.length;o<a;o++)u(arguments[o],n);return t},extend:function(e,t,n){return u(t,function(t,a){e[a]=n&&"function"==typeof t?o(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){const o=n(5),a=n(35);e.exports={getOrderCookieName:function(){return`order_token_${o.clientId()}_${o.marketId()}_${o.countryCode()}`},getAccessTokenCookieName:function(){return`access_token_${o.clientId()}_${o.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"),shoppingBagDiscount:document.querySelector("#clayer-shopping-bag-discount"),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 o=n(0),a=n(20),i={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!o.isUndefined(e)&&o.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 a(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.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, */*"}},o.forEach(["delete","get","head"],function(e){c.headers[e]={}}),o.forEach(["post","put","patch"],function(e){c.headers[e]=o.merge(i)}),e.exports=c}).call(this,n(19))},function(e,t,n){const o=n(2);e.exports={baseUrl:function(){return o.config.dataset.baseUrl},clientId:function(){return o.config.dataset.clientId},marketId:function(){return o.config.dataset.marketId},countryCode:function(){return o.config.dataset.countryCode},languageCode:function(){return o.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return o.config.dataset.cartUrl},returnUrl:function(){return o.config.dataset.returnUrl},privacyUrl:function(){return o.config.dataset.privacyUrl},termsUrl:function(){return o.config.dataset.termsUrl}}},function(e,t,n){const o=n(2),a=n(3),r=(n(12),n(13)),s=n(5),c=n(1),u=n(14);e.exports={getPrices:function(){$prices=o.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"],a.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,a.get(skusEndpointWithPage).then(function(e){u.updatePrices(r(e.data).get(skuAttributes))})}))},getVariants:function(){u.disableElement(o.addToBag),$variants=o.variants,$variants.length>0&&(skuCodes=[],$variants.forEach(function(e){u.disableElement(e),skuCodes.push(e.dataset.skuCode)}),a.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){a.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 a.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,o){return a.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:o,_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 a.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return a.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=o.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=o.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(),api.deleteLineItem(this.dataset.lineItemId).then(function(e){api.getOrder()})}),$shoppingBagItemsContainer.appendChild($shoppingBagItem)}},getOrder:function(){return api=this,a.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),0==e.data.data[0].attributes.skus_count&&u.clearShoppingBag(),e.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}}},function(e,t,n){"use strict";var o=n(0),a=n(21),i=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;o.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(),i(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,o={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};a(t,p,o),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},o.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&&o.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 o=n(22);e.exports=function(e,t,n,a,i){var r=new Error(e);return o(r,t,n,a,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,n){const o=n(3),a=n(5),i=n(1);o.defaults.baseURL=a.baseUrl(),o.defaults.headers.common.Accept="application/vnd.api+json",o.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+i.getAccessTokenCookie(),e},function(e){return Promise.reject(e)}),o.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&function(){if(navigator.cookieEnabled)return!0;document.cookie="cookietest=1";var e=-1!=document.cookie.indexOf("cookietest=");return document.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}()&&null==i.getAccessTokenRetryLockCookie()?(i.setAccessTokenRetryLockCookie(),o.post("/oauth/token",{grant_type:"client_credentials",client_id:a.clientId(),scope:"market:"+a.marketId()}).then(function(e){return i.setAccessTokenCookie(e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return e.config.headers.Authorization="Bearer "+t,o.request(e.config)})):Promise.reject(e)})},function(e,t,n){var o,a,i;a=[],void 0===(i="function"==typeof(o=function(){function e(o,a){if(!(this instanceof e)){var i=new e(o);return a?i.get(a):i}if("string"==typeof o&&(o=JSON.parse(o)),!o||!o.data)throw new Error("Invalid json api normalizer input");var r,s,c,u;this.dataset=o,this.isCollection=t(o.data),this.haystack=(r=o.included,s=this.isCollection?o.data:[o.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,o){if(t(e))for(var a=e.length,i=0;i<a;i++)n.call(o,e[i],i);else for(var r in e)e.hasOwnProperty(r)&&n.call(o,r,e[r])}function o(e,t,o){var a=[];return n(e,function(e,n){a.push(t.call(o,e,n))}),a}function a(a,s,c){var u={};return n(a,function(n,a){if(a)u[n]=function(e,n,a,s){var c=a.relationships&&a.relationships[e]&&a.relationships[e].data,u=c&&r(c,s);return t(u)?o(u,function(e){return i(n,e,s)}):u?i(n,u,s):void 0}(n,a,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 i(t,n,o){return s.call(new e({data:n,included:o}),t)}function r(e,a){var i=[],r=t(e)?o(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(a,function(e){r.indexOf(e.type+"@"+e.id)>=0&&i.push(e)}),0===i.length?void 0:1!==i.length||t(e)?i:i[0]}function s(e){return this.isCollection?o(this.dataset.data,function(t){return a(e,t,this.haystack)},this):a(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var a,i,r=s.call(this,(a=t(e)?e:[e],i={},n(a,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var o in n)n.hasOwnProperty(o)&&("object"==typeof n[o]&&null!==n[o]?(void 0===t[o]&&(t[o]={}),e(t[o],n[o])):t[o]=n[o]);return t}(i,function(e){for(var t={},n=t,o=e.length,a=0;a<o;a++)n=n[e[a]]=n[e[a]]||(a+1===o?void 0:{});return t}(t)):i[e]=void 0}),i));return this.isCollection?t(e)?r:o(r,function(t){return t[e]}):t(e)?r:r[e]},e})?o.apply(t,a):o)||(e.exports=i)},function(e,t,n){const o=n(2),a=n(1),i=n(13);e.exports={enableElement:function(e){e&&e.classList.remove("disabled")},disableElement:function(e){e&&e.classList.add("disabled")},setElementHTML(e,t,n){el=e.querySelector(t),el&&(el.innerHTML=n)},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=o.addToBag,$addToBag&&($addToBag.dataset.skuId=e,$addToBag.dataset.skuName=t)},enableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.enableElement($addToBag)},disableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.disableElement($addToBag)},updateAvailabilityMessage:function(e){$container=o.availabilityMessageContainer,$container&&(first_level=a.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=o.shoppingBagItemsCount,$shoppingBagItemsCount&&($shoppingBagItemsCount.innerHTML=e.attributes.skus_count),$shoppingBagTotal=o.shoppingBagTotal,$shoppingBagTotal&&($shoppingBagTotal.innerHTML=e.attributes.formatted_total_amount_with_taxes),$shoppingBagSubtotal=o.shoppingBagSubtotal,$shoppingBagSubtotal&&($shoppingBagSubtotal.innerHTML=e.attributes.formatted_subtotal_amount),$shoppingBagShipping=o.shoppingBagShipping,$shoppingBagShipping&&($shoppingBagShipping.innerHTML=e.attributes.formatted_shipping_amount),$shoppingBagPayment=o.shoppingBagPayment,$shoppingBagPayment&&($shoppingBagPayment.innerHTML=e.attributes.formatted_payment_method_amount),$shoppingBagTaxes=o.shoppingBagTaxes,$shoppingBagTaxes&&($shoppingBagTaxes.innerHTML=e.attributes.formatted_total_tax_amount),$shoppingBagDiscount=o.shoppingBagDiscount,$shoppingBagDiscount&&($shoppingBagDiscount.innerHTML=e.attributes.formatted_discount_amount)},updateShoppingBagCheckout:function(e){$shoppingBagCheckout=o.shoppingBagCheckout,$shoppingBagCheckout&&(normalized_order=i(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,i,r){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageAvailableTemplate,$tmp&&($el=a.getElementFromTemplate($tmp),this.setElementHTML($el,".clayer-availability-message-available-qty",e),this.setElementHTML($el,".clayer-availability-message-available-min-days",t),this.setElementHTML($el,".clayer-availability-message-available-max-days",n),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-name",i),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-price",r),$container.innerHTML="",$container.appendChild($el)))},displayUnavailableMessage:function(){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageUnavailableTemplate,$tmp&&($el=a.getElementFromTemplate($tmp),$container.innerHTML="",$container.appendChild($el)))},toggleShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=o.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=o.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){o.shoppingBagItemsContainer&&(o.shoppingBagItemsContainer.innerHTML="")},displayShoppingBagUnavailableMessage:function(){this.displayElement(o.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(o.shoppingBagUnavailableMessage)}}},function(e,t,n){document.addEventListener("readystatechange",function(){if("interactive"==document.readyState){const o=n(6),a=n(36);n(1);t.init=function(){o.getPrices(),o.getVariants(),a.setVariantSelect(),a.setAddToShoppingBag(),a.setShoppingBagToggle(),o.refreshOrder()},document.commercelayer=e.exports,document.commercelayer.init()}})},function(e,t,n){"use strict";var o=n(0),a=n(7),i=n(18),r=n(4);function s(e){var t=new i(e),n=a(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var c=s(r);c.Axios=i,c.create=function(e){return s(o.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)} | ||
/*! | ||
@@ -3,0 +3,0 @@ * Determine if an object is a Buffer |
{ | ||
"name": "commercelayer", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"description": "The Official Commerce Layer JS library", | ||
@@ -5,0 +5,0 @@ "main": "./src/main.js", |
@@ -1,20 +0,19 @@ | ||
const api = require('./api') | ||
const listeners = require('./listeners') | ||
const utils = require('./utils') | ||
document.addEventListener('readystatechange', function() { | ||
if (document.readyState == 'interactive') { | ||
const api = require('./api') | ||
const listeners = require('./listeners') | ||
const utils = require('./utils') | ||
exports.init = function() { | ||
api.getPrices() | ||
api.getVariants() | ||
listeners.setVariantSelect() | ||
listeners.setAddToShoppingBag() | ||
listeners.setShoppingBagToggle() | ||
api.refreshOrder() | ||
} | ||
exports.init = function() { | ||
api.getPrices() | ||
api.getVariants() | ||
listeners.setVariantSelect() | ||
listeners.setAddToShoppingBag() | ||
listeners.setShoppingBagToggle() | ||
api.refreshOrder() | ||
} | ||
document.commercelayer = module.exports | ||
document.addEventListener('readystatechange', function() { | ||
if (document.readyState == 'interactive') { | ||
document.commercelayer = module.exports | ||
document.commercelayer.init() | ||
} | ||
}) |
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
61809