ui.shipaid.com 0.2.20 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.es.js CHANGED
@@ -841,7 +841,7 @@ let LearnMorePopup = class extends s {
841
841
  loss, damage, or liability arising from a contingent or unknown event,
842
842
  but rather, through ShipAid brands provide a delivery guarantee whereby
843
843
  if the product you ordered is not delivered in satisfactory condition,
844
- the brand from which you ordered the product will replace the product
844
+ the brand from which you ordered the product may replace the product
845
845
  free of charge. ShipAid does not provide any products or services directly
846
846
  to consumers, but instead provides a service that allow brands to facilitate
847
847
  product replacement to their customers. Purchasing this guarantee does not
@@ -1278,7 +1278,7 @@ let ShipAidWidget = class extends s {
1278
1278
  });
1279
1279
  }
1280
1280
  async calculateProtectionTotal(cart) {
1281
- var _a, _b, _c, _d, _e;
1281
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1282
1282
  if (!cart)
1283
1283
  cart = await this._fetchCart();
1284
1284
  if (!cart)
@@ -1289,25 +1289,23 @@ let ShipAidWidget = class extends s {
1289
1289
  if (!settings || !this._protectionProduct) {
1290
1290
  throw new Error("Tried to find protection variant, but protection settings for this store are missing.");
1291
1291
  }
1292
- const itemTotal = ((_b = this._store) == null ? void 0 : _b.excludedProductSkus) && cart.items ? cart.items.reduce((total, item) => {
1292
+ const excludedProductSkus = Array.isArray((_b = this._store) == null ? void 0 : _b.excludedProductSkus) ? (_c = this._store) == null ? void 0 : _c.excludedProductSkus.map((sku) => sku.trim()) : [];
1293
+ const itemTotal = (_e = (_d = cart.items) == null ? void 0 : _d.reduce((total, item) => {
1293
1294
  if (!item.sku)
1294
1295
  return total;
1295
- const itemIsExcluded = this._store.excludedProductSkus.find((sku) => sku === item.sku);
1296
- return itemIsExcluded ? total - item.final_price : total;
1297
- }, cart.total_price) : cart.total_price;
1298
- const protectionVariantsInCart = (_d = (_c = cart.items) == null ? void 0 : _c.filter((item) => {
1296
+ const itemIsExcluded = excludedProductSkus.some((sku) => sku === item.sku.trim());
1297
+ return itemIsExcluded ? total - item.final_line_price : total;
1298
+ }, cart.total_price)) != null ? _e : cart.total_price;
1299
+ const protectionVariantsInCart = (_g = (_f = cart.items) == null ? void 0 : _f.filter((item) => {
1299
1300
  var _a2, _b2;
1300
1301
  return (_b2 = (_a2 = this._protectionProduct) == null ? void 0 : _a2.variants) == null ? void 0 : _b2.some((variant) => variant.id === item.variant_id);
1301
- })) != null ? _d : [];
1302
- const protectionVariantsInCartTotal = protectionVariantsInCart.reduce((total, item) => {
1303
- const updatedTotal = total += item.final_line_price;
1304
- return updatedTotal;
1305
- }, 0);
1302
+ })) != null ? _g : [];
1303
+ const protectionVariantsInCartTotal = protectionVariantsInCart.reduce((total, item) => total + item.final_line_price, 0);
1306
1304
  const cartTotal = itemTotal - protectionVariantsInCartTotal;
1307
1305
  if (settings.protectionType === "FIXED") {
1308
1306
  if (typeof settings.defaultFee !== "number")
1309
1307
  throw new Error("Missing default fee amount.");
1310
- if (!((_e = settings.rules) == null ? void 0 : _e.length))
1308
+ if (!((_h = settings.rules) == null ? void 0 : _h.length))
1311
1309
  return settings.defaultFee;
1312
1310
  const formattedCartTotal = cartTotal / 100;
1313
1311
  const sortedRules = settings.rules.sort((a2, b2) => {
@@ -1316,9 +1314,7 @@ let ShipAidWidget = class extends s {
1316
1314
  return a2.rangeLower - b2.rangeLower;
1317
1315
  });
1318
1316
  const rule = sortedRules.find((rule2) => {
1319
- const lower = Boolean(
1320
- rule2.rangeLower && rule2.rangeLower < formattedCartTotal
1321
- );
1317
+ const lower = Boolean(rule2.rangeLower && rule2.rangeLower < formattedCartTotal);
1322
1318
  if (!rule2.rangeUpper)
1323
1319
  return lower;
1324
1320
  return lower && rule2.rangeUpper >= formattedCartTotal;
@@ -1639,6 +1635,7 @@ let ShipAidWidget = class extends s {
1639
1635
  return await this._handleRefresh(cart2);
1640
1636
  }
1641
1637
  const protectionFee = await this.calculateProtectionTotal(this._cart);
1638
+ console.log({ protectionFee });
1642
1639
  const protectionVariant = this._findProtectionVariant(protectionFee);
1643
1640
  this._protectionVariant = protectionVariant;
1644
1641
  if (!(protectionVariant == null ? void 0 : protectionVariant.id)) {
@@ -29,13 +29,13 @@ const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"
29
29
  * @license
30
30
  * Copyright 2017 Google LLC
31
31
  * SPDX-License-Identifier: BSD-3-Clause
32
- */;var u;const f=window,v=f.trustedTypes,g=v?v.emptyScript:"",m=f.reactiveElementPolyfillSupport,_={toAttribute(t,e){switch(e){case Boolean:t=t?g:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(o){i=null}}return i}},C=(t,e)=>e!==t&&(e==e||t==t),y={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:C};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Ep(i,e);void 0!==o&&(this._$Ev.set(o,i),t.push(o))})),t}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||y}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{a?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=n.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=y){var o;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(o=i.converter)||void 0===o?void 0:o.toAttribute)?i.converter:_).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const o=this.constructor,r=o._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=o.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:_;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||C)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(o){throw e=!1,this._$Ek(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
32
+ */;var u;const f=window,v=f.trustedTypes,m=v?v.emptyScript:"",g=f.reactiveElementPolyfillSupport,_={toAttribute(t,e){switch(e){case Boolean:t=t?m:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(o){i=null}}return i}},C=(t,e)=>e!==t&&(e==e||t==t),y={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:C};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Ep(i,e);void 0!==o&&(this._$Ev.set(o,i),t.push(o))})),t}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||y}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{a?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=n.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=y){var o;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(o=i.converter)||void 0===o?void 0:o.toAttribute)?i.converter:_).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const o=this.constructor,r=o._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=o.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:_;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||C)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(o){throw e=!1,this._$Ek(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
33
33
  /**
34
34
  * @license
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
37
  */
38
- var $;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==m||m({ReactiveElement:w}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.4.1");const b=window,L=b.trustedTypes,A=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,k=(t="")=>P.createComment(t),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,z=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),R=/'/g,I=/"/g,W=/^(?:script|style|textarea|title)$/i,H=(Z=1,(t,...e)=>({_$litType$:Z,strings:t,values:e})),j=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),B=new WeakMap,F=P.createTreeWalker(P,129,null,!1);var Z;class q{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[p,l]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=U;for(let p=0;p<i;p++){const e=t[p];let i,a,l=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===U?"!--"===a[1]?n=O:void 0!==a[1]?n=z:void 0!==a[2]?(W.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=N):void 0!==a[3]&&(n=N):n===N?">"===a[0]?(n=null!=r?r:U,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?N:'"'===a[3]?I:R):n===I||n===R?n=N:n===O||n===z?n=U:(n=N,r=void 0);const h=n===N&&t[p+1].startsWith("/>")?" ":"";s+=n===U?e+E:l>=0?(o.push(i),e.slice(0,l)+"$lit$"+e.slice(l)+S+h):e+S+(-2===l?(o.push(void 0),p):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==A?A.createHTML(a):a,o]})(t,e);if(this.el=q.createElement(p,i),F.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=F.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=l[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Y:"?"===e[1]?Q:"@"===e[1]?tt:K})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(W.test(o.tagName)){const t=o.textContent.split(S),e=t.length-1;if(e>0){o.textContent=L?L.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],k()),F.nextNode(),a.push({type:2,index:++r});o.append(t[e],k())}}}else if(8===o.nodeType)if(o.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(S,t+1));)a.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function V(t,e,i=t,o){var r,s,n,a;if(e===j)return e;let p=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const l=M(e)?void 0:e._$litDirective$;return(null==p?void 0:p.constructor)!==l&&(null===(s=null==p?void 0:p._$AO)||void 0===s||s.call(p,!1),void 0===l?p=void 0:(p=new l(t),p._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=p:i._$Cl=p),void 0!==p&&(e=V(t,p._$AS(t,e.values),p,o)),e}class J{constructor(t,e){this.u=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:P).importNode(i,!0);F.currentNode=r;let s=F.nextNode(),n=0,a=0,p=o[0];for(;void 0!==p;){if(n===p.index){let e;2===p.type?e=new G(s,s.nextSibling,this,t):1===p.type?e=new p.ctor(s,p.name,p.strings,this,t):6===p.type&&(e=new et(s,this,t)),this.u.push(e),p=o[++a]}n!==(null==p?void 0:p.index)&&(s=F.nextNode(),n++)}return r}p(t){let e=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class G{constructor(t,e,i,o){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cm=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cm}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),M(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==j&&this.g(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==D&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=q.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new J(r,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=B.get(t.strings);return void 0===e&&B.set(t.strings,e=new q(t)),e}k(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new G(this.O(k()),this.O(k()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cm=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class K{constructor(t,e,i,o,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=V(this,t,e,0),s=!M(t)||t!==this._$AH&&t!==j,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=V(this,o[i+n],e,n),a===j&&(a=this._$AH[n]),s||(s=!M(a)||a!==this._$AH[n]),a===D?t=D:t!==D&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Y extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const X=L?L.emptyScript:"";class Q extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,X):this.element.removeAttribute(this.name)}}class tt extends K{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=V(this,t,e,0))&&void 0!==i?i:D)===j)return;const o=this._$AH,r=t===D&&o!==D||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==D&&(o===D||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class et{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const it=b.litHtmlPolyfillSupport;null==it||it(q,G),(null!==($=b.litHtmlVersions)&&void 0!==$?$:b.litHtmlVersions=[]).push("2.4.0");const ot=(t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new G(e.insertBefore(k(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
38
+ var $;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==g||g({ReactiveElement:w}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.4.1");const b=window,L=b.trustedTypes,A=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,k=(t="")=>P.createComment(t),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,z=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),R=/'/g,I=/"/g,W=/^(?:script|style|textarea|title)$/i,H=(Z=1,(t,...e)=>({_$litType$:Z,strings:t,values:e})),j=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),B=new WeakMap,F=P.createTreeWalker(P,129,null,!1);var Z;class q{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[p,l]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=U;for(let p=0;p<i;p++){const e=t[p];let i,a,l=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===U?"!--"===a[1]?n=O:void 0!==a[1]?n=z:void 0!==a[2]?(W.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=N):void 0!==a[3]&&(n=N):n===N?">"===a[0]?(n=null!=r?r:U,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?N:'"'===a[3]?I:R):n===I||n===R?n=N:n===O||n===z?n=U:(n=N,r=void 0);const h=n===N&&t[p+1].startsWith("/>")?" ":"";s+=n===U?e+E:l>=0?(o.push(i),e.slice(0,l)+"$lit$"+e.slice(l)+S+h):e+S+(-2===l?(o.push(void 0),p):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==A?A.createHTML(a):a,o]})(t,e);if(this.el=q.createElement(p,i),F.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=F.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=l[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Y:"?"===e[1]?Q:"@"===e[1]?tt:K})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(W.test(o.tagName)){const t=o.textContent.split(S),e=t.length-1;if(e>0){o.textContent=L?L.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],k()),F.nextNode(),a.push({type:2,index:++r});o.append(t[e],k())}}}else if(8===o.nodeType)if(o.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(S,t+1));)a.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function V(t,e,i=t,o){var r,s,n,a;if(e===j)return e;let p=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const l=M(e)?void 0:e._$litDirective$;return(null==p?void 0:p.constructor)!==l&&(null===(s=null==p?void 0:p._$AO)||void 0===s||s.call(p,!1),void 0===l?p=void 0:(p=new l(t),p._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=p:i._$Cl=p),void 0!==p&&(e=V(t,p._$AS(t,e.values),p,o)),e}class J{constructor(t,e){this.u=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:P).importNode(i,!0);F.currentNode=r;let s=F.nextNode(),n=0,a=0,p=o[0];for(;void 0!==p;){if(n===p.index){let e;2===p.type?e=new G(s,s.nextSibling,this,t):1===p.type?e=new p.ctor(s,p.name,p.strings,this,t):6===p.type&&(e=new et(s,this,t)),this.u.push(e),p=o[++a]}n!==(null==p?void 0:p.index)&&(s=F.nextNode(),n++)}return r}p(t){let e=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class G{constructor(t,e,i,o){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cm=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cm}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),M(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==j&&this.g(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==D&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=q.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new J(r,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=B.get(t.strings);return void 0===e&&B.set(t.strings,e=new q(t)),e}k(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new G(this.O(k()),this.O(k()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cm=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class K{constructor(t,e,i,o,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=V(this,t,e,0),s=!M(t)||t!==this._$AH&&t!==j,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=V(this,o[i+n],e,n),a===j&&(a=this._$AH[n]),s||(s=!M(a)||a!==this._$AH[n]),a===D?t=D:t!==D&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Y extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const X=L?L.emptyScript:"";class Q extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,X):this.element.removeAttribute(this.name)}}class tt extends K{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=V(this,t,e,0))&&void 0!==i?i:D)===j)return;const o=this._$AH,r=t===D&&o!==D||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==D&&(o===D||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class et{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const it=b.litHtmlPolyfillSupport;null==it||it(q,G),(null!==($=b.litHtmlVersions)&&void 0!==$?$:b.litHtmlVersions=[]).push("2.4.0");const ot=(t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new G(e.insertBefore(k(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
39
39
  /**
40
40
  * @license
41
41
  * Copyright 2017 Google LLC
@@ -178,7 +178,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
178
178
  font-size: var(--shipaid-font-sm);
179
179
  color: var(--shipaid-text);
180
180
  }
181
- `;var ut=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,vt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?ft(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&ut(e,i,s),s};let gt=class extends nt{constructor(){super(...arguments),this.active=!1}handleClosePopup(){const t=new Event("close");this.dispatchEvent(t)}render(){return H`
181
+ `;var ut=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,vt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?ft(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&ut(e,i,s),s};let mt=class extends nt{constructor(){super(...arguments),this.active=!1}handleClosePopup(){const t=new Event("close");this.dispatchEvent(t)}render(){return H`
182
182
  <div class=${`shipaid-popup ${this.active&&"active"}`}>
183
183
  <button
184
184
  type="button"
@@ -211,7 +211,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
211
211
  loss, damage, or liability arising from a contingent or unknown event,
212
212
  but rather, through ShipAid brands provide a delivery guarantee whereby
213
213
  if the product you ordered is not delivered in satisfactory condition,
214
- the brand from which you ordered the product will replace the product
214
+ the brand from which you ordered the product may replace the product
215
215
  free of charge. ShipAid does not provide any products or services directly
216
216
  to consumers, but instead provides a service that allow brands to facilitate
217
217
  product replacement to their customers. Purchasing this guarantee does not
@@ -242,7 +242,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
242
242
  </div>
243
243
  </div>
244
244
  </div>
245
- `}};gt.styles=ct,vt([o({type:Boolean,attribute:!0})],gt.prototype,"active",2),gt=vt([e("shipaid-popup-learn-more")],gt);const mt=h`
245
+ `}};mt.styles=ct,vt([o({type:Boolean,attribute:!0})],mt.prototype,"active",2),mt=vt([e("shipaid-popup-learn-more")],mt);const gt=h`
246
246
  :host {
247
247
  --shipaid-primary: #002bd6;
248
248
  --shipaid-secondary: #0076ff;
@@ -519,7 +519,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
519
519
  />
520
520
  </g>
521
521
  </svg>
522
- `;var wt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(wt||{}),$t=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Lt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?bt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&$t(e,i,s),s};const At=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),new Error("Failed to complete fetch request.")}},St=t=>console.warn(`[ShipAid] ${t}`),xt=t=>console.error(`[ShipAid] ${t}`),Et="shipaid-protection";return t.ShipAidWidget=class extends nt{constructor(){var t,e,i,o;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this.disableRefresh=!1,this._apiEndpoint="/apps/shipaid",this._storeDomain=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>At(t),post:(t,e)=>At(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(St("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(wt.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){var e,i,o,r,s;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const n=null==(e=this._store)?void 0:e.protectionSettings;if(!n||!this._protectionProduct)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=((null==(i=this._store)?void 0:i.excludedProductSkus)&&t.items?t.items.reduce(((t,e)=>{if(!e.sku)return t;return this._store.excludedProductSkus.find((t=>t===e.sku))?t-e.final_price:t}),t.total_price):t.total_price)-(null!=(r=null==(o=t.items)?void 0:o.filter((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))?r:[]).reduce(((t,e)=>t+=e.final_line_price),0);if("FIXED"===n.protectionType){if("number"!=typeof n.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(s=n.rules)?void 0:s.length))return n.defaultFee;const t=a/100,e=n.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:n.defaultFee}if("PERCENTAGE"===n.protectionType){const t=a*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o,r;if(!(null==(e=this._store)?void 0:e.protectionSettings)||!(null==(o=null==(i=this._protectionProduct)?void 0:i.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const s=null==(r=this._protectionProduct)?void 0:r.variants.flatMap((t=>{if(!t||!t.price)return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=s.find((e=>e.formattedPrice>=t));return n||s[s.length-1]}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){var t,e,i,o,r,s;const n=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost;if(!n)throw new Error("No shop found in Shopify object.");try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e={query:"query StoreByDomain ($store: String!) {\n store: storeByDomain (input: {store: $store}) {\n currency\n planActive\n store\n widgetAutoOptIn\n widgetShowCart\n excludedProductSkus\n protectionSettings\n }\n}",variables:{store:n}},i=await this._fetch.post(t.toString(),e);if(!i)throw new Error("Missing response for store query.");if(null==(r=i.errors)?void 0:r.length)throw new Error(i.errors[0].message);if(!(null==(s=i.data)?void 0:s.store))throw new Error("Missing store from store query response.");return i.data.store}catch(a){throw console.error(a),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw xt(t.message),new Error("Could not fetch cart for current domain.")}}async _fetchProduct(){try{const{product:t}=await this._fetch.get("/products/shipaid-protection.json");return t}catch(t){throw xt(t.message),new Error("Could not fetch protection product for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!(null==(t=this._cart)?void 0:t.items))throw new Error("Cart has not been loaded.");if(!(null==(e=this._protectionVariant)?void 0:e.id))throw new Error("No protection variant found.");this._setState("loading");const i={quantity:1,id:this._protectionVariant.id},o=await this._fetch.post("/cart/add.js",i);await this._handleRefresh(o),this._setState("success")}catch(i){xt(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){xt(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}learnMorePopupTemplate(){return H`
522
+ `;var wt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(wt||{}),$t=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Lt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?bt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&$t(e,i,s),s};const At=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),new Error("Failed to complete fetch request.")}},St=t=>console.warn(`[ShipAid] ${t}`),xt=t=>console.error(`[ShipAid] ${t}`),Et="shipaid-protection";return t.ShipAidWidget=class extends nt{constructor(){var t,e,i,o;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this.disableRefresh=!1,this._apiEndpoint="/apps/shipaid",this._storeDomain=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>At(t),post:(t,e)=>At(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(St("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(wt.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){var e,i,o,r,s,n,a,p;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const l=null==(e=this._store)?void 0:e.protectionSettings;if(!l||!this._protectionProduct)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const d=Array.isArray(null==(i=this._store)?void 0:i.excludedProductSkus)?null==(o=this._store)?void 0:o.excludedProductSkus.map((t=>t.trim())):[],h=(null!=(s=null==(r=t.items)?void 0:r.reduce(((t,e)=>{if(!e.sku)return t;return d.some((t=>t===e.sku.trim()))?t-e.final_line_price:t}),t.total_price))?s:t.total_price)-(null!=(a=null==(n=t.items)?void 0:n.filter((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))?a:[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===l.protectionType){if("number"!=typeof l.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(p=l.rules)?void 0:p.length))return l.defaultFee;const t=h/100,e=l.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:l.defaultFee}if("PERCENTAGE"===l.protectionType){const t=h*l.percentage/100;return t>=l.minimumFee?t:l.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o,r;if(!(null==(e=this._store)?void 0:e.protectionSettings)||!(null==(o=null==(i=this._protectionProduct)?void 0:i.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const s=null==(r=this._protectionProduct)?void 0:r.variants.flatMap((t=>{if(!t||!t.price)return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=s.find((e=>e.formattedPrice>=t));return n||s[s.length-1]}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){var t,e,i,o,r,s;const n=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost;if(!n)throw new Error("No shop found in Shopify object.");try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e={query:"query StoreByDomain ($store: String!) {\n store: storeByDomain (input: {store: $store}) {\n currency\n planActive\n store\n widgetAutoOptIn\n widgetShowCart\n excludedProductSkus\n protectionSettings\n }\n}",variables:{store:n}},i=await this._fetch.post(t.toString(),e);if(!i)throw new Error("Missing response for store query.");if(null==(r=i.errors)?void 0:r.length)throw new Error(i.errors[0].message);if(!(null==(s=i.data)?void 0:s.store))throw new Error("Missing store from store query response.");return i.data.store}catch(a){throw console.error(a),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw xt(t.message),new Error("Could not fetch cart for current domain.")}}async _fetchProduct(){try{const{product:t}=await this._fetch.get("/products/shipaid-protection.json");return t}catch(t){throw xt(t.message),new Error("Could not fetch protection product for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!(null==(t=this._cart)?void 0:t.items))throw new Error("Cart has not been loaded.");if(!(null==(e=this._protectionVariant)?void 0:e.id))throw new Error("No protection variant found.");this._setState("loading");const i={quantity:1,id:this._protectionVariant.id},o=await this._fetch.post("/cart/add.js",i);await this._handleRefresh(o),this._setState("success")}catch(i){xt(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){xt(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}learnMorePopupTemplate(){return H`
523
523
  <shipaid-popup-learn-more ?active=${"learn-more"===this._popup} @close=${()=>{this._popup=null}}></shipaid-popup-learn-more>
524
524
  `}promptTemplate(){var t;return H`
525
525
  <div class="shipaid-prompt">
@@ -565,8 +565,8 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
565
565
  </button>
566
566
  </div>
567
567
  </div>
568
- `}render(){return dt(this,(async()=>{var t,e;const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(o){return xt(o.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(wt.LOADED,this._store),setTimeout((async()=>{var t,e,i;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(sessionStorage.getItem(Et)||(sessionStorage.setItem(Et,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(i=this._cart)?void 0:i.item_count)&&this._store.widgetShowCart&&await this.addProtection()))}),500),void(this.disablePolling||setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval))):(St("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),dt(this,(async()=>{var t,e,i;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const o=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),r=null==(i=this._cart)?void 0:i.items[o];if(this._hasProtectionInCart=!!r,1===this._cart.item_count&&r){const t={id:r.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,!(null==n?void 0:n.id))return this._shouldShowWidget=!1,void xt("No matching protection variant found.");if(!r)return;if(n.id===r.id){if(this._protectionCartItem={...r,index:o,position:o+1},1===r.quantity)return;const t={id:r.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},p=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(p)}),[this._store,this._cart]),ot(this.learnMorePopupTemplate(),document.body),H`
568
+ `}render(){return dt(this,(async()=>{var t,e;const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(o){return xt(o.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(wt.LOADED,this._store),setTimeout((async()=>{var t,e,i;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(sessionStorage.getItem(Et)||(sessionStorage.setItem(Et,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(i=this._cart)?void 0:i.item_count)&&this._store.widgetShowCart&&await this.addProtection()))}),500),void(this.disablePolling||setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval))):(St("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),dt(this,(async()=>{var t,e,i;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const o=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),r=null==(i=this._cart)?void 0:i.items[o];if(this._hasProtectionInCart=!!r,1===this._cart.item_count&&r){const t={id:r.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const s=await this.calculateProtectionTotal(this._cart);console.log({protectionFee:s});const n=this._findProtectionVariant(s);if(this._protectionVariant=n,!(null==n?void 0:n.id))return this._shouldShowWidget=!1,void xt("No matching protection variant found.");if(!r)return;if(n.id===r.id){if(this._protectionCartItem={...r,index:o,position:o+1},1===r.quantity)return;const t={id:r.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},p=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(p)}),[this._store,this._cart]),ot(this.learnMorePopupTemplate(),document.body),H`
569
569
  <div class="shipaid">
570
570
  ${ht(this._hasFinishedSetup,(()=>{var t;return ht(this._shouldShowWidget&&this.planActive&&(null==(t=this._store)?void 0:t.widgetShowCart),(()=>this.promptTemplate()),(()=>D))}),(()=>H`<p><slot name="loading" default>Loading ShipAid Widget...</slot></p>`))}
571
571
  </div>
572
- `}},t.ShipAidWidget.styles=mt,Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),Lt([o({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),Lt([r()],t.ShipAidWidget.prototype,"_storeDomain",2),Lt([r()],t.ShipAidWidget.prototype,"_store",2),Lt([r()],t.ShipAidWidget.prototype,"_cart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionProduct",2),Lt([r()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),Lt([r()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),Lt([r()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),Lt([r()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionCartItem",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionVariant",2),Lt([r()],t.ShipAidWidget.prototype,"_state",2),Lt([r()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=Lt([e("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({});
572
+ `}},t.ShipAidWidget.styles=gt,Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),Lt([o({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),Lt([r()],t.ShipAidWidget.prototype,"_storeDomain",2),Lt([r()],t.ShipAidWidget.prototype,"_store",2),Lt([r()],t.ShipAidWidget.prototype,"_cart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionProduct",2),Lt([r()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),Lt([r()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),Lt([r()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),Lt([r()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionCartItem",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionVariant",2),Lt([r()],t.ShipAidWidget.prototype,"_state",2),Lt([r()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=Lt([e("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({});
@@ -29,13 +29,13 @@ const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"
29
29
  * @license
30
30
  * Copyright 2017 Google LLC
31
31
  * SPDX-License-Identifier: BSD-3-Clause
32
- */;var u;const f=window,v=f.trustedTypes,g=v?v.emptyScript:"",m=f.reactiveElementPolyfillSupport,_={toAttribute(t,e){switch(e){case Boolean:t=t?g:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(o){i=null}}return i}},C=(t,e)=>e!==t&&(e==e||t==t),y={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:C};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Ep(i,e);void 0!==o&&(this._$Ev.set(o,i),t.push(o))})),t}static createProperty(t,e=y){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||y}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{a?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=n.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=y){var o;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(o=i.converter)||void 0===o?void 0:o.toAttribute)?i.converter:_).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const o=this.constructor,r=o._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=o.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:_;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||C)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(o){throw e=!1,this._$Ek(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
32
+ */;var u;const f=window,v=f.trustedTypes,m=v?v.emptyScript:"",g=f.reactiveElementPolyfillSupport,_={toAttribute(t,e){switch(e){case Boolean:t=t?m:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(o){i=null}}return i}},y=(t,e)=>e!==t&&(e==e||t==t),C={attribute:!0,type:String,converter:_,reflect:!1,hasChanged:y};class w extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;null!==(e=this.h)&&void 0!==e||(this.h=[]),this.h.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Ep(i,e);void 0!==o&&(this._$Ev.set(o,i),t.push(o))})),t}static createProperty(t,e=C){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||C}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{a?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=n.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=C){var o;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(o=i.converter)||void 0===o?void 0:o.toAttribute)?i.converter:_).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const o=this.constructor,r=o._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=o.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:_;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||y)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(o){throw e=!1,this._$Ek(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
33
33
  /**
34
34
  * @license
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
37
  */
38
- var $;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==m||m({ReactiveElement:w}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.4.1");const b=window,L=b.trustedTypes,A=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,k=(t="")=>P.createComment(t),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,z=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),R=/'/g,I=/"/g,W=/^(?:script|style|textarea|title)$/i,H=(Z=1,(t,...e)=>({_$litType$:Z,strings:t,values:e})),j=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),B=new WeakMap,F=P.createTreeWalker(P,129,null,!1);var Z;class q{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[p,l]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=U;for(let p=0;p<i;p++){const e=t[p];let i,a,l=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===U?"!--"===a[1]?n=O:void 0!==a[1]?n=z:void 0!==a[2]?(W.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=N):void 0!==a[3]&&(n=N):n===N?">"===a[0]?(n=null!=r?r:U,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?N:'"'===a[3]?I:R):n===I||n===R?n=N:n===O||n===z?n=U:(n=N,r=void 0);const h=n===N&&t[p+1].startsWith("/>")?" ":"";s+=n===U?e+E:l>=0?(o.push(i),e.slice(0,l)+"$lit$"+e.slice(l)+S+h):e+S+(-2===l?(o.push(void 0),p):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==A?A.createHTML(a):a,o]})(t,e);if(this.el=q.createElement(p,i),F.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=F.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=l[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Y:"?"===e[1]?Q:"@"===e[1]?tt:K})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(W.test(o.tagName)){const t=o.textContent.split(S),e=t.length-1;if(e>0){o.textContent=L?L.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],k()),F.nextNode(),a.push({type:2,index:++r});o.append(t[e],k())}}}else if(8===o.nodeType)if(o.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(S,t+1));)a.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function V(t,e,i=t,o){var r,s,n,a;if(e===j)return e;let p=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const l=M(e)?void 0:e._$litDirective$;return(null==p?void 0:p.constructor)!==l&&(null===(s=null==p?void 0:p._$AO)||void 0===s||s.call(p,!1),void 0===l?p=void 0:(p=new l(t),p._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=p:i._$Cl=p),void 0!==p&&(e=V(t,p._$AS(t,e.values),p,o)),e}class J{constructor(t,e){this.u=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:P).importNode(i,!0);F.currentNode=r;let s=F.nextNode(),n=0,a=0,p=o[0];for(;void 0!==p;){if(n===p.index){let e;2===p.type?e=new G(s,s.nextSibling,this,t):1===p.type?e=new p.ctor(s,p.name,p.strings,this,t):6===p.type&&(e=new et(s,this,t)),this.u.push(e),p=o[++a]}n!==(null==p?void 0:p.index)&&(s=F.nextNode(),n++)}return r}p(t){let e=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class G{constructor(t,e,i,o){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cm=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cm}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),M(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==j&&this.g(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==D&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=q.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new J(r,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=B.get(t.strings);return void 0===e&&B.set(t.strings,e=new q(t)),e}k(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new G(this.O(k()),this.O(k()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cm=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class K{constructor(t,e,i,o,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=V(this,t,e,0),s=!M(t)||t!==this._$AH&&t!==j,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=V(this,o[i+n],e,n),a===j&&(a=this._$AH[n]),s||(s=!M(a)||a!==this._$AH[n]),a===D?t=D:t!==D&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Y extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const X=L?L.emptyScript:"";class Q extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,X):this.element.removeAttribute(this.name)}}class tt extends K{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=V(this,t,e,0))&&void 0!==i?i:D)===j)return;const o=this._$AH,r=t===D&&o!==D||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==D&&(o===D||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class et{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const it=b.litHtmlPolyfillSupport;null==it||it(q,G),(null!==($=b.litHtmlVersions)&&void 0!==$?$:b.litHtmlVersions=[]).push("2.4.0");const ot=(t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new G(e.insertBefore(k(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
38
+ var $;w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},null==g||g({ReactiveElement:w}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.4.1");const b=window,L=b.trustedTypes,A=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,k=(t="")=>P.createComment(t),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,z=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),R=/'/g,I=/"/g,W=/^(?:script|style|textarea|title)$/i,H=(Z=1,(t,...e)=>({_$litType$:Z,strings:t,values:e})),j=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),B=new WeakMap,F=P.createTreeWalker(P,129,null,!1);var Z;class q{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[p,l]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=U;for(let p=0;p<i;p++){const e=t[p];let i,a,l=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===U?"!--"===a[1]?n=O:void 0!==a[1]?n=z:void 0!==a[2]?(W.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=N):void 0!==a[3]&&(n=N):n===N?">"===a[0]?(n=null!=r?r:U,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?N:'"'===a[3]?I:R):n===I||n===R?n=N:n===O||n===z?n=U:(n=N,r=void 0);const h=n===N&&t[p+1].startsWith("/>")?" ":"";s+=n===U?e+E:l>=0?(o.push(i),e.slice(0,l)+"$lit$"+e.slice(l)+S+h):e+S+(-2===l?(o.push(void 0),p):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==A?A.createHTML(a):a,o]})(t,e);if(this.el=q.createElement(p,i),F.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=F.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=l[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Y:"?"===e[1]?Q:"@"===e[1]?tt:K})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(W.test(o.tagName)){const t=o.textContent.split(S),e=t.length-1;if(e>0){o.textContent=L?L.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],k()),F.nextNode(),a.push({type:2,index:++r});o.append(t[e],k())}}}else if(8===o.nodeType)if(o.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(S,t+1));)a.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function V(t,e,i=t,o){var r,s,n,a;if(e===j)return e;let p=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const l=M(e)?void 0:e._$litDirective$;return(null==p?void 0:p.constructor)!==l&&(null===(s=null==p?void 0:p._$AO)||void 0===s||s.call(p,!1),void 0===l?p=void 0:(p=new l(t),p._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=p:i._$Cl=p),void 0!==p&&(e=V(t,p._$AS(t,e.values),p,o)),e}class J{constructor(t,e){this.u=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:P).importNode(i,!0);F.currentNode=r;let s=F.nextNode(),n=0,a=0,p=o[0];for(;void 0!==p;){if(n===p.index){let e;2===p.type?e=new G(s,s.nextSibling,this,t):1===p.type?e=new p.ctor(s,p.name,p.strings,this,t):6===p.type&&(e=new et(s,this,t)),this.u.push(e),p=o[++a]}n!==(null==p?void 0:p.index)&&(s=F.nextNode(),n++)}return r}p(t){let e=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class G{constructor(t,e,i,o){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cm=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cm}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),M(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==j&&this.g(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==D&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=q.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new J(r,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=B.get(t.strings);return void 0===e&&B.set(t.strings,e=new q(t)),e}k(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new G(this.O(k()),this.O(k()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cm=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class K{constructor(t,e,i,o,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=V(this,t,e,0),s=!M(t)||t!==this._$AH&&t!==j,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=V(this,o[i+n],e,n),a===j&&(a=this._$AH[n]),s||(s=!M(a)||a!==this._$AH[n]),a===D?t=D:t!==D&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Y extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const X=L?L.emptyScript:"";class Q extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,X):this.element.removeAttribute(this.name)}}class tt extends K{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=V(this,t,e,0))&&void 0!==i?i:D)===j)return;const o=this._$AH,r=t===D&&o!==D||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==D&&(o===D||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class et{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const it=b.litHtmlPolyfillSupport;null==it||it(q,G),(null!==($=b.litHtmlVersions)&&void 0!==$?$:b.litHtmlVersions=[]).push("2.4.0");const ot=(t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new G(e.insertBefore(k(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
39
39
  /**
40
40
  * @license
41
41
  * Copyright 2017 Google LLC
@@ -178,7 +178,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
178
178
  font-size: var(--shipaid-font-sm);
179
179
  color: var(--shipaid-text);
180
180
  }
181
- `;var ut=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,vt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?ft(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&ut(e,i,s),s};let gt=class extends nt{constructor(){super(...arguments),this.active=!1}handleClosePopup(){const t=new Event("close");this.dispatchEvent(t)}render(){return H`
181
+ `;var ut=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,vt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?ft(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&ut(e,i,s),s};let mt=class extends nt{constructor(){super(...arguments),this.active=!1}handleClosePopup(){const t=new Event("close");this.dispatchEvent(t)}render(){return H`
182
182
  <div class=${`shipaid-popup ${this.active&&"active"}`}>
183
183
  <button
184
184
  type="button"
@@ -211,7 +211,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
211
211
  loss, damage, or liability arising from a contingent or unknown event,
212
212
  but rather, through ShipAid brands provide a delivery guarantee whereby
213
213
  if the product you ordered is not delivered in satisfactory condition,
214
- the brand from which you ordered the product will replace the product
214
+ the brand from which you ordered the product may replace the product
215
215
  free of charge. ShipAid does not provide any products or services directly
216
216
  to consumers, but instead provides a service that allow brands to facilitate
217
217
  product replacement to their customers. Purchasing this guarantee does not
@@ -242,7 +242,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
242
242
  </div>
243
243
  </div>
244
244
  </div>
245
- `}};gt.styles=ct,vt([o({type:Boolean,attribute:!0})],gt.prototype,"active",2),gt=vt([e("shipaid-popup-learn-more")],gt);const mt=h`
245
+ `}};mt.styles=ct,vt([o({type:Boolean,attribute:!0})],mt.prototype,"active",2),mt=vt([e("shipaid-popup-learn-more")],mt);const gt=h`
246
246
  :host {
247
247
  --shipaid-primary: #002bd6;
248
248
  --shipaid-secondary: #0076ff;
@@ -395,7 +395,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
395
395
  <path d="M256.01,120.969C286.193,120.969 314.057,130.87 336.536,147.604L309.406,174.656C294.073,164.573 275.729,158.708 256.01,158.708C229.141,158.708 204.823,169.604 187.214,187.198C169.615,204.797 158.719,229.125 158.719,255.995C158.719,282.865 169.615,307.182 187.214,324.792C204.813,342.406 229.141,353.286 256.01,353.286C282.88,353.286 307.208,342.406 324.807,324.792C342.406,307.193 353.297,282.865 353.297,255.995C353.297,251.818 353.036,247.719 352.526,243.688L383.859,212.458C388.51,226.115 391.036,240.766 391.036,255.995C391.036,293.286 375.927,327.047 351.49,351.479C327.057,375.911 293.302,391.021 256.01,391.021C218.729,391.021 184.964,375.911 160.526,351.479C136.094,327.047 120.984,293.286 120.984,255.995C120.984,218.719 136.094,184.948 160.526,160.516C184.964,136.083 218.719,120.969 256.01,120.969ZM218.141,220.906L253.615,259.729L354.844,158.813L381.375,185.484L252.396,314.068L190.422,246.255L218.13,220.906L218.141,220.906Z" style="fill:white;fill-rule:nonzero;"/>
396
396
  </g>
397
397
  </svg>
398
- `,Ct=H`
398
+ `,yt=H`
399
399
  <svg
400
400
  viewBox="0 0 384 383.999986"
401
401
  preserveAspectRatio="xMidYMid meet"
@@ -437,7 +437,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
437
437
  />
438
438
  </g>
439
439
  </svg>
440
- `,yt=H`
440
+ `,Ct=H`
441
441
  <svg
442
442
  viewBox="0 0 423 62"
443
443
  version="1.1"
@@ -519,13 +519,13 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
519
519
  />
520
520
  </g>
521
521
  </svg>
522
- `;var wt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(wt||{}),$t=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Lt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?bt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&$t(e,i,s),s};const At=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),new Error("Failed to complete fetch request.")}},St=t=>console.warn(`[ShipAid] ${t}`),xt=t=>console.error(`[ShipAid] ${t}`),Et="shipaid-protection";t.ShipAidWidget=class extends nt{constructor(){var t,e,i,o;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this.disableRefresh=!1,this._apiEndpoint="/apps/shipaid",this._storeDomain=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>At(t),post:(t,e)=>At(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(St("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(wt.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){var e,i,o,r,s;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const n=null==(e=this._store)?void 0:e.protectionSettings;if(!n||!this._protectionProduct)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=((null==(i=this._store)?void 0:i.excludedProductSkus)&&t.items?t.items.reduce(((t,e)=>{if(!e.sku)return t;return this._store.excludedProductSkus.find((t=>t===e.sku))?t-e.final_price:t}),t.total_price):t.total_price)-(null!=(r=null==(o=t.items)?void 0:o.filter((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))?r:[]).reduce(((t,e)=>t+=e.final_line_price),0);if("FIXED"===n.protectionType){if("number"!=typeof n.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(s=n.rules)?void 0:s.length))return n.defaultFee;const t=a/100,e=n.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:n.defaultFee}if("PERCENTAGE"===n.protectionType){const t=a*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o,r;if(!(null==(e=this._store)?void 0:e.protectionSettings)||!(null==(o=null==(i=this._protectionProduct)?void 0:i.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const s=null==(r=this._protectionProduct)?void 0:r.variants.flatMap((t=>{if(!t||!t.price)return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=s.find((e=>e.formattedPrice>=t));return n||s[s.length-1]}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){var t,e,i,o,r,s;const n=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost;if(!n)throw new Error("No shop found in Shopify object.");try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e={query:"query StoreByDomain ($store: String!) {\n store: storeByDomain (input: {store: $store}) {\n currency\n planActive\n store\n widgetAutoOptIn\n widgetShowCart\n excludedProductSkus\n protectionSettings\n }\n}",variables:{store:n}},i=await this._fetch.post(t.toString(),e);if(!i)throw new Error("Missing response for store query.");if(null==(r=i.errors)?void 0:r.length)throw new Error(i.errors[0].message);if(!(null==(s=i.data)?void 0:s.store))throw new Error("Missing store from store query response.");return i.data.store}catch(a){throw console.error(a),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw xt(t.message),new Error("Could not fetch cart for current domain.")}}async _fetchProduct(){try{const{product:t}=await this._fetch.get("/products/shipaid-protection.json");return t}catch(t){throw xt(t.message),new Error("Could not fetch protection product for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!(null==(t=this._cart)?void 0:t.items))throw new Error("Cart has not been loaded.");if(!(null==(e=this._protectionVariant)?void 0:e.id))throw new Error("No protection variant found.");this._setState("loading");const i={quantity:1,id:this._protectionVariant.id},o=await this._fetch.post("/cart/add.js",i);await this._handleRefresh(o),this._setState("success")}catch(i){xt(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){xt(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}learnMorePopupTemplate(){return H`
522
+ `;var wt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(wt||{}),$t=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Lt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?bt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&$t(e,i,s),s};const At=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),new Error("Failed to complete fetch request.")}},St=t=>console.warn(`[ShipAid] ${t}`),xt=t=>console.error(`[ShipAid] ${t}`),Et="shipaid-protection";t.ShipAidWidget=class extends nt{constructor(){var t,e,i,o;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this.disableRefresh=!1,this._apiEndpoint="/apps/shipaid",this._storeDomain=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>At(t),post:(t,e)=>At(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(St("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(wt.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){var e,i,o,r,s,n,a,p;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const l=null==(e=this._store)?void 0:e.protectionSettings;if(!l||!this._protectionProduct)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const d=Array.isArray(null==(i=this._store)?void 0:i.excludedProductSkus)?null==(o=this._store)?void 0:o.excludedProductSkus.map((t=>t.trim())):[],h=(null!=(s=null==(r=t.items)?void 0:r.reduce(((t,e)=>{if(!e.sku)return t;return d.some((t=>t===e.sku.trim()))?t-e.final_line_price:t}),t.total_price))?s:t.total_price)-(null!=(a=null==(n=t.items)?void 0:n.filter((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))?a:[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===l.protectionType){if("number"!=typeof l.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(p=l.rules)?void 0:p.length))return l.defaultFee;const t=h/100,e=l.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:l.defaultFee}if("PERCENTAGE"===l.protectionType){const t=h*l.percentage/100;return t>=l.minimumFee?t:l.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o,r;if(!(null==(e=this._store)?void 0:e.protectionSettings)||!(null==(o=null==(i=this._protectionProduct)?void 0:i.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const s=null==(r=this._protectionProduct)?void 0:r.variants.flatMap((t=>{if(!t||!t.price)return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=s.find((e=>e.formattedPrice>=t));return n||s[s.length-1]}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){var t,e,i,o,r,s;const n=null!=(o=null==(t=window.Shopify)?void 0:t.shop)?o:null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost;if(!n)throw new Error("No shop found in Shopify object.");try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e={query:"query StoreByDomain ($store: String!) {\n store: storeByDomain (input: {store: $store}) {\n currency\n planActive\n store\n widgetAutoOptIn\n widgetShowCart\n excludedProductSkus\n protectionSettings\n }\n}",variables:{store:n}},i=await this._fetch.post(t.toString(),e);if(!i)throw new Error("Missing response for store query.");if(null==(r=i.errors)?void 0:r.length)throw new Error(i.errors[0].message);if(!(null==(s=i.data)?void 0:s.store))throw new Error("Missing store from store query response.");return i.data.store}catch(a){throw console.error(a),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw xt(t.message),new Error("Could not fetch cart for current domain.")}}async _fetchProduct(){try{const{product:t}=await this._fetch.get("/products/shipaid-protection.json");return t}catch(t){throw xt(t.message),new Error("Could not fetch protection product for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!(null==(t=this._cart)?void 0:t.items))throw new Error("Cart has not been loaded.");if(!(null==(e=this._protectionVariant)?void 0:e.id))throw new Error("No protection variant found.");this._setState("loading");const i={quantity:1,id:this._protectionVariant.id},o=await this._fetch.post("/cart/add.js",i);await this._handleRefresh(o),this._setState("success")}catch(i){xt(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){xt(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}learnMorePopupTemplate(){return H`
523
523
  <shipaid-popup-learn-more ?active=${"learn-more"===this._popup} @close=${()=>{this._popup=null}}></shipaid-popup-learn-more>
524
524
  `}promptTemplate(){var t;return H`
525
525
  <div class="shipaid-prompt">
526
526
  <div class="prompt-product">
527
527
  <div class="prompt-product-image">
528
- ${ht(this._hasProtectionInCart,(()=>_t),(()=>Ct))}
528
+ ${ht(this._hasProtectionInCart,(()=>_t),(()=>yt))}
529
529
  </div>
530
530
  <div class="prompt-product-details">
531
531
  <p class="prompt-product-details-title">
@@ -555,7 +555,7 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
555
555
  @click=${()=>{this._popup="learn-more"}}
556
556
  >
557
557
  <span>Powered by</span>
558
- ${yt}
558
+ ${Ct}
559
559
  </a>
560
560
  <button
561
561
  class="prompt-footer-about"
@@ -565,8 +565,8 @@ function ht(t,e,i){return t?e():null==i?void 0:i()}const ct=h`
565
565
  </button>
566
566
  </div>
567
567
  </div>
568
- `}render(){return dt(this,(async()=>{var t,e;const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(o){return xt(o.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(wt.LOADED,this._store),setTimeout((async()=>{var t,e,i;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(sessionStorage.getItem(Et)||(sessionStorage.setItem(Et,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(i=this._cart)?void 0:i.item_count)&&this._store.widgetShowCart&&await this.addProtection()))}),500),void(this.disablePolling||setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval))):(St("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),dt(this,(async()=>{var t,e,i;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const o=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),r=null==(i=this._cart)?void 0:i.items[o];if(this._hasProtectionInCart=!!r,1===this._cart.item_count&&r){const t={id:r.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,!(null==n?void 0:n.id))return this._shouldShowWidget=!1,void xt("No matching protection variant found.");if(!r)return;if(n.id===r.id){if(this._protectionCartItem={...r,index:o,position:o+1},1===r.quantity)return;const t={id:r.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},p=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(p)}),[this._store,this._cart]),ot(this.learnMorePopupTemplate(),document.body),H`
568
+ `}render(){return dt(this,(async()=>{var t,e;const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(o){return xt(o.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(wt.LOADED,this._store),setTimeout((async()=>{var t,e,i;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(sessionStorage.getItem(Et)||(sessionStorage.setItem(Et,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(i=this._cart)?void 0:i.item_count)&&this._store.widgetShowCart&&await this.addProtection()))}),500),void(this.disablePolling||setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval))):(St("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(St("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),dt(this,(async()=>{var t,e,i;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const o=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),r=null==(i=this._cart)?void 0:i.items[o];if(this._hasProtectionInCart=!!r,1===this._cart.item_count&&r){const t={id:r.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const s=await this.calculateProtectionTotal(this._cart);console.log({protectionFee:s});const n=this._findProtectionVariant(s);if(this._protectionVariant=n,!(null==n?void 0:n.id))return this._shouldShowWidget=!1,void xt("No matching protection variant found.");if(!r)return;if(n.id===r.id){if(this._protectionCartItem={...r,index:o,position:o+1},1===r.quantity)return;const t={id:r.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},p=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(p)}),[this._store,this._cart]),ot(this.learnMorePopupTemplate(),document.body),H`
569
569
  <div class="shipaid">
570
570
  ${ht(this._hasFinishedSetup,(()=>{var t;return ht(this._shouldShowWidget&&this.planActive&&(null==(t=this._store)?void 0:t.widgetShowCart),(()=>this.promptTemplate()),(()=>D))}),(()=>H`<p><slot name="loading" default>Loading ShipAid Widget...</slot></p>`))}
571
571
  </div>
572
- `}},t.ShipAidWidget.styles=mt,Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),Lt([o({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),Lt([r()],t.ShipAidWidget.prototype,"_storeDomain",2),Lt([r()],t.ShipAidWidget.prototype,"_store",2),Lt([r()],t.ShipAidWidget.prototype,"_cart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionProduct",2),Lt([r()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),Lt([r()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),Lt([r()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),Lt([r()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionCartItem",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionVariant",2),Lt([r()],t.ShipAidWidget.prototype,"_state",2),Lt([r()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=Lt([e("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
572
+ `}},t.ShipAidWidget.styles=gt,Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),Lt([o({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),Lt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),Lt([r()],t.ShipAidWidget.prototype,"_storeDomain",2),Lt([r()],t.ShipAidWidget.prototype,"_store",2),Lt([r()],t.ShipAidWidget.prototype,"_cart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionProduct",2),Lt([r()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),Lt([r()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),Lt([r()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),Lt([r()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionCartItem",2),Lt([r()],t.ShipAidWidget.prototype,"_protectionVariant",2),Lt([r()],t.ShipAidWidget.prototype,"_state",2),Lt([r()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=Lt([e("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui.shipaid.com",
3
3
  "private": false,
4
- "version": "0.2.20",
4
+ "version": "0.2.22",
5
5
  "type": "module",
6
6
  "main": "dist/widget.umd.js",
7
7
  "unpkg": "dist/widget.iife.js",
@@ -14,11 +14,6 @@
14
14
  "dist-types",
15
15
  "dist"
16
16
  ],
17
- "scripts": {
18
- "develop": "vite",
19
- "build": "tsc && node build",
20
- "lint": "eslint . --ext=ts --fix"
21
- },
22
17
  "dependencies": {
23
18
  "@lit-labs/task": "^1.1.3",
24
19
  "lit": "^2.4.0",
@@ -38,5 +33,10 @@
38
33
  "terser": "^5.15.1",
39
34
  "typescript": "^4.8.4",
40
35
  "vite": "^3.1.8"
36
+ },
37
+ "scripts": {
38
+ "develop": "vite",
39
+ "build": "tsc && node build",
40
+ "lint": "eslint . --ext=ts --fix"
41
41
  }
42
- }
42
+ }
@@ -1,2 +0,0 @@
1
- declare const styles: import('lit').CSSResult
2
- export default styles