ui.shipaid.com 0.1.5 → 0.1.6

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.
@@ -6,15 +6,15 @@ var xt=Object.defineProperty,Ct=Object.defineProperties;var Pt=Object.getOwnProp
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const Nt=(o,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?A(b({},t),{finisher(e){e.createProperty(t.key,o)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,o)}};function F(o){return(t,e)=>e!==void 0?((i,r,s)=>{r.constructor.createProperty(s,i)})(o,t,e):Nt(o,t)}/**
9
+ */const Nt=(o,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?A(b({},t),{finisher(e){e.createProperty(t.key,o)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,o)}};function j(o){return(t,e)=>e!==void 0?((i,r,s)=>{r.constructor.createProperty(s,i)})(o,t,e):Nt(o,t)}/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */function y(o){return F(A(b({},o),{state:!0}))}/**
13
+ */function y(o){return j(A(b({},o),{state:!0}))}/**
14
14
  * @license
15
15
  * Copyright 2021 Google LLC
16
16
  * SPDX-License-Identifier: BSD-3-Clause
17
- */var j;((j=window.HTMLSlotElement)===null||j===void 0?void 0:j.prototype.assignedElements)!=null;/**
17
+ */var F;((F=window.HTMLSlotElement)===null||F===void 0?void 0:F.prototype.assignedElements)!=null;/**
18
18
  * @license
19
19
  * Copyright 2019 Google LLC
20
20
  * SPDX-License-Identifier: BSD-3-Clause
@@ -26,7 +26,7 @@ var xt=Object.defineProperty,Ct=Object.defineProperties;var Pt=Object.getOwnProp
26
26
  * @license
27
27
  * Copyright 2017 Google LLC
28
28
  * SPDX-License-Identifier: BSD-3-Clause
29
- */var K;const x=globalThis.trustedTypes,lt=x?x.createPolicy("lit-html",{createHTML:o=>o}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,ut="?"+w,Mt=`<${ut}>`,C=document,N=(o="")=>C.createComment(o),I=o=>o===null||typeof o!="object"&&typeof o!="function",ft=Array.isArray,zt=o=>{var t;return ft(o)||typeof((t=o)===null||t===void 0?void 0:t[Symbol.iterator])=="function"},O=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,mt=/-->/g,vt=/>/g,E=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,_t=/'/g,gt=/"/g,yt=/^(?:script|style|textarea|title)$/i,Dt=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),P=Dt(1),T=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),$t=new WeakMap,Rt=(o,t,e)=>{var i,r;const s=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let n=s._$litPart$;if(n===void 0){const c=(r=e==null?void 0:e.renderBefore)!==null&&r!==void 0?r:null;s._$litPart$=n=new z(t.insertBefore(N(),c),c,void 0,e!=null?e:{})}return n._$AI(o),n},U=C.createTreeWalker(C,129,null,!1),Ft=(o,t)=>{const e=o.length-1,i=[];let r,s=t===2?"<svg>":"",n=O;for(let a=0;a<e;a++){const p=o[a];let l,h,d=-1,u=0;for(;u<p.length&&(n.lastIndex=u,h=n.exec(p),h!==null);)u=n.lastIndex,n===O?h[1]==="!--"?n=mt:h[1]!==void 0?n=vt:h[2]!==void 0?(yt.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=E):h[3]!==void 0&&(n=E):n===E?h[0]===">"?(n=r!=null?r:O,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,l=h[1],n=h[3]===void 0?E:h[3]==='"'?gt:_t):n===gt||n===_t?n=E:n===mt||n===vt?n=O:(n=E,r=void 0);const _=n===E&&o[a+1].startsWith("/>")?" ":"";s+=n===O?p+Mt:d>=0?(i.push(l),p.slice(0,d)+"$lit$"+p.slice(d)+w+_):p+w+(d===-2?(i.push(void 0),a):_)}const c=s+(o[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return[lt!==void 0?lt.createHTML(c):c,i]};class M{constructor({strings:t,_$litType$:e},i){let r;this.parts=[];let s=0,n=0;const c=t.length-1,a=this.parts,[p,l]=Ft(t,e);if(this.el=M.createElement(p,i),U.currentNode=this.el.content,e===2){const h=this.el.content,d=h.firstChild;d.remove(),h.append(...d.childNodes)}for(;(r=U.nextNode())!==null&&a.length<c;){if(r.nodeType===1){if(r.hasAttributes()){const h=[];for(const d of r.getAttributeNames())if(d.endsWith("$lit$")||d.startsWith(w)){const u=l[n++];if(h.push(d),u!==void 0){const _=r.getAttribute(u.toLowerCase()+"$lit$").split(w),g=/([.?@])?(.*)/.exec(u);a.push({type:1,index:s,name:g[2],strings:_,ctor:g[1]==="."?Vt:g[1]==="?"?qt:g[1]==="@"?Wt:D})}else a.push({type:6,index:s})}for(const d of h)r.removeAttribute(d)}if(yt.test(r.tagName)){const h=r.textContent.split(w),d=h.length-1;if(d>0){r.textContent=x?x.emptyScript:"";for(let u=0;u<d;u++)r.append(h[u],N()),U.nextNode(),a.push({type:2,index:++s});r.append(h[d],N())}}}else if(r.nodeType===8)if(r.data===ut)a.push({type:2,index:s});else{let h=-1;for(;(h=r.data.indexOf(w,h+1))!==-1;)a.push({type:7,index:s}),h+=w.length-1}s++}}static createElement(t,e){const i=C.createElement("template");return i.innerHTML=t,i}}function k(o,t,e=o,i){var r,s,n,c;if(t===T)return t;let a=i!==void 0?(r=e._$Cl)===null||r===void 0?void 0:r[i]:e._$Cu;const p=I(t)?void 0:t._$litDirective$;return(a==null?void 0:a.constructor)!==p&&((s=a==null?void 0:a._$AO)===null||s===void 0||s.call(a,!1),p===void 0?a=void 0:(a=new p(o),a._$AT(o,e,i)),i!==void 0?((n=(c=e)._$Cl)!==null&&n!==void 0?n:c._$Cl=[])[i]=a:e._$Cu=a),a!==void 0&&(t=k(o,a._$AS(o,t.values),a,i)),t}class jt{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:r}=this._$AD,s=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:C).importNode(i,!0);U.currentNode=s;let n=U.nextNode(),c=0,a=0,p=r[0];for(;p!==void 0;){if(c===p.index){let l;p.type===2?l=new z(n,n.nextSibling,this,t):p.type===1?l=new p.ctor(n,p.name,p.strings,this,t):p.type===6&&(l=new Jt(n,this,t)),this.v.push(l),p=r[++a]}c!==(p==null?void 0:p.index)&&(n=U.nextNode(),c++)}return s}m(t){let e=0;for(const i of this.v)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class z{constructor(t,e,i,r){var s;this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=r,this._$Cg=(s=r==null?void 0:r.isConnected)===null||s===void 0||s}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=k(this,t,e),I(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==T&&this.$(t):t._$litType$!==void 0?this.T(t):t.nodeType!==void 0?this.k(t):zt(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==f&&I(this._$AH)?this._$AA.nextSibling.data=t:this.k(C.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:r}=t,s=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=M.createElement(r.h,this.options)),r);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===s)this._$AH.m(i);else{const n=new jt(s,this),c=n.p(this.options);n.m(i),this.k(c),this._$AH=n}}_$AC(t){let e=$t.get(t.strings);return e===void 0&&$t.set(t.strings,e=new M(t)),e}S(t){ft(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,r=0;for(const s of t)r===e.length?e.push(i=new z(this.A(N()),this.A(N()),this,this.options)):i=e[r],i._$AI(s),r++;r<e.length&&(this._$AR(i&&i._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const r=t.nextSibling;t.remove(),t=r}}setConnected(t){var e;this._$AM===void 0&&(this._$Cg=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class D{constructor(t,e,i,r,s){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=s,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=f}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,r){const s=this.strings;let n=!1;if(s===void 0)t=k(this,t,e,0),n=!I(t)||t!==this._$AH&&t!==T,n&&(this._$AH=t);else{const c=t;let a,p;for(t=s[0],a=0;a<s.length-1;a++)p=k(this,c[i+a],e,a),p===T&&(p=this._$AH[a]),n||(n=!I(p)||p!==this._$AH[a]),p===f?t=f:t!==f&&(t+=(p!=null?p:"")+s[a+1]),this._$AH[a]=p}n&&!r&&this.C(t)}C(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}}class Vt extends D{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===f?void 0:t}}const Bt=x?x.emptyScript:"";class qt extends D{constructor(){super(...arguments),this.type=4}C(t){t&&t!==f?this.element.setAttribute(this.name,Bt):this.element.removeAttribute(this.name)}}class Wt extends D{constructor(t,e,i,r,s){super(t,e,i,r,s),this.type=5}_$AI(t,e=this){var i;if((t=(i=k(this,t,e,0))!==null&&i!==void 0?i:f)===T)return;const r=this._$AH,s=t===f&&r!==f||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==f&&(r===f||s);s&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class Jt{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){k(this,t)}}const wt=window.litHtmlPolyfillSupport;wt==null||wt(M,z),((K=globalThis.litHtmlVersions)!==null&&K!==void 0?K:globalThis.litHtmlVersions=[]).push("2.2.0");/**
29
+ */var K;const x=globalThis.trustedTypes,lt=x?x.createPolicy("lit-html",{createHTML:o=>o}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,ut="?"+w,Mt=`<${ut}>`,C=document,N=(o="")=>C.createComment(o),I=o=>o===null||typeof o!="object"&&typeof o!="function",ft=Array.isArray,zt=o=>{var t;return ft(o)||typeof((t=o)===null||t===void 0?void 0:t[Symbol.iterator])=="function"},O=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,mt=/-->/g,vt=/>/g,E=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,_t=/'/g,gt=/"/g,yt=/^(?:script|style|textarea|title)$/i,Dt=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),P=Dt(1),T=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),$t=new WeakMap,Rt=(o,t,e)=>{var i,r;const s=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let n=s._$litPart$;if(n===void 0){const c=(r=e==null?void 0:e.renderBefore)!==null&&r!==void 0?r:null;s._$litPart$=n=new z(t.insertBefore(N(),c),c,void 0,e!=null?e:{})}return n._$AI(o),n},U=C.createTreeWalker(C,129,null,!1),jt=(o,t)=>{const e=o.length-1,i=[];let r,s=t===2?"<svg>":"",n=O;for(let a=0;a<e;a++){const p=o[a];let l,h,d=-1,u=0;for(;u<p.length&&(n.lastIndex=u,h=n.exec(p),h!==null);)u=n.lastIndex,n===O?h[1]==="!--"?n=mt:h[1]!==void 0?n=vt:h[2]!==void 0?(yt.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=E):h[3]!==void 0&&(n=E):n===E?h[0]===">"?(n=r!=null?r:O,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,l=h[1],n=h[3]===void 0?E:h[3]==='"'?gt:_t):n===gt||n===_t?n=E:n===mt||n===vt?n=O:(n=E,r=void 0);const _=n===E&&o[a+1].startsWith("/>")?" ":"";s+=n===O?p+Mt:d>=0?(i.push(l),p.slice(0,d)+"$lit$"+p.slice(d)+w+_):p+w+(d===-2?(i.push(void 0),a):_)}const c=s+(o[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return[lt!==void 0?lt.createHTML(c):c,i]};class M{constructor({strings:t,_$litType$:e},i){let r;this.parts=[];let s=0,n=0;const c=t.length-1,a=this.parts,[p,l]=jt(t,e);if(this.el=M.createElement(p,i),U.currentNode=this.el.content,e===2){const h=this.el.content,d=h.firstChild;d.remove(),h.append(...d.childNodes)}for(;(r=U.nextNode())!==null&&a.length<c;){if(r.nodeType===1){if(r.hasAttributes()){const h=[];for(const d of r.getAttributeNames())if(d.endsWith("$lit$")||d.startsWith(w)){const u=l[n++];if(h.push(d),u!==void 0){const _=r.getAttribute(u.toLowerCase()+"$lit$").split(w),g=/([.?@])?(.*)/.exec(u);a.push({type:1,index:s,name:g[2],strings:_,ctor:g[1]==="."?Vt:g[1]==="?"?qt:g[1]==="@"?Wt:D})}else a.push({type:6,index:s})}for(const d of h)r.removeAttribute(d)}if(yt.test(r.tagName)){const h=r.textContent.split(w),d=h.length-1;if(d>0){r.textContent=x?x.emptyScript:"";for(let u=0;u<d;u++)r.append(h[u],N()),U.nextNode(),a.push({type:2,index:++s});r.append(h[d],N())}}}else if(r.nodeType===8)if(r.data===ut)a.push({type:2,index:s});else{let h=-1;for(;(h=r.data.indexOf(w,h+1))!==-1;)a.push({type:7,index:s}),h+=w.length-1}s++}}static createElement(t,e){const i=C.createElement("template");return i.innerHTML=t,i}}function k(o,t,e=o,i){var r,s,n,c;if(t===T)return t;let a=i!==void 0?(r=e._$Cl)===null||r===void 0?void 0:r[i]:e._$Cu;const p=I(t)?void 0:t._$litDirective$;return(a==null?void 0:a.constructor)!==p&&((s=a==null?void 0:a._$AO)===null||s===void 0||s.call(a,!1),p===void 0?a=void 0:(a=new p(o),a._$AT(o,e,i)),i!==void 0?((n=(c=e)._$Cl)!==null&&n!==void 0?n:c._$Cl=[])[i]=a:e._$Cu=a),a!==void 0&&(t=k(o,a._$AS(o,t.values),a,i)),t}class Ft{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:r}=this._$AD,s=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:C).importNode(i,!0);U.currentNode=s;let n=U.nextNode(),c=0,a=0,p=r[0];for(;p!==void 0;){if(c===p.index){let l;p.type===2?l=new z(n,n.nextSibling,this,t):p.type===1?l=new p.ctor(n,p.name,p.strings,this,t):p.type===6&&(l=new Jt(n,this,t)),this.v.push(l),p=r[++a]}c!==(p==null?void 0:p.index)&&(n=U.nextNode(),c++)}return s}m(t){let e=0;for(const i of this.v)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class z{constructor(t,e,i,r){var s;this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=r,this._$Cg=(s=r==null?void 0:r.isConnected)===null||s===void 0||s}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=k(this,t,e),I(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==T&&this.$(t):t._$litType$!==void 0?this.T(t):t.nodeType!==void 0?this.k(t):zt(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==f&&I(this._$AH)?this._$AA.nextSibling.data=t:this.k(C.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:r}=t,s=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=M.createElement(r.h,this.options)),r);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===s)this._$AH.m(i);else{const n=new Ft(s,this),c=n.p(this.options);n.m(i),this.k(c),this._$AH=n}}_$AC(t){let e=$t.get(t.strings);return e===void 0&&$t.set(t.strings,e=new M(t)),e}S(t){ft(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,r=0;for(const s of t)r===e.length?e.push(i=new z(this.A(N()),this.A(N()),this,this.options)):i=e[r],i._$AI(s),r++;r<e.length&&(this._$AR(i&&i._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const r=t.nextSibling;t.remove(),t=r}}setConnected(t){var e;this._$AM===void 0&&(this._$Cg=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class D{constructor(t,e,i,r,s){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=s,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=f}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,r){const s=this.strings;let n=!1;if(s===void 0)t=k(this,t,e,0),n=!I(t)||t!==this._$AH&&t!==T,n&&(this._$AH=t);else{const c=t;let a,p;for(t=s[0],a=0;a<s.length-1;a++)p=k(this,c[i+a],e,a),p===T&&(p=this._$AH[a]),n||(n=!I(p)||p!==this._$AH[a]),p===f?t=f:t!==f&&(t+=(p!=null?p:"")+s[a+1]),this._$AH[a]=p}n&&!r&&this.C(t)}C(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}}class Vt extends D{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===f?void 0:t}}const Bt=x?x.emptyScript:"";class qt extends D{constructor(){super(...arguments),this.type=4}C(t){t&&t!==f?this.element.setAttribute(this.name,Bt):this.element.removeAttribute(this.name)}}class Wt extends D{constructor(t,e,i,r,s){super(t,e,i,r,s),this.type=5}_$AI(t,e=this){var i;if((t=(i=k(this,t,e,0))!==null&&i!==void 0?i:f)===T)return;const r=this._$AH,s=t===f&&r!==f||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==f&&(r===f||s);s&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class Jt{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){k(this,t)}}const wt=window.litHtmlPolyfillSupport;wt==null||wt(M,z),((K=globalThis.litHtmlVersions)!==null&&K!==void 0?K:globalThis.litHtmlVersions=[]).push("2.2.0");/**
30
30
  * @license
31
31
  * Copyright 2017 Google LLC
32
32
  * SPDX-License-Identifier: BSD-3-Clause
@@ -272,7 +272,7 @@ var xt=Object.defineProperty,Ct=Object.defineProperties;var Pt=Object.getOwnProp
272
272
  color: var(--shipaid-text-grey);
273
273
  font-weight: var(--shipaid-font-heavy);
274
274
  }
275
- `,L=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(L||{}),Qt=Object.defineProperty,te=Object.getOwnPropertyDescriptor,v=(o,t,e,i)=>{for(var r=i>1?void 0:i?te(t,e):t,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&Qt(t,e,r),r};const Et=async(o,t)=>{try{const e=await fetch(o,t);if(!e.ok)throw new Error(await e.text());return await e.json()}catch(e){throw console.error(e),new Error("Failed to complete fetch request.")}},ee=2500;let m=class extends H{constructor(){super(...arguments);var o;this.disablePolling=!1,this.pollingInterval=ee,this._apiEndpoint="/apps/shipaid",this._storeDomain=(o=window.Shopify)==null?void 0:o.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Et(t),post:(t,e)=>Et(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var e;Gt(this,async()=>{var r,s,n,c;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[a,p]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=a,this._cart=p}catch{this._hasFinishedSetup=!0;return}if(!((s=(r=this._store)==null?void 0:r.plan)!=null&&s.active)){console.warn("No ShipAid plan is active for this store - skipping setup."),this._hasFinishedSetup=!0;return}if(!((c=(n=this._store)==null?void 0:n.protectionSettings)!=null&&c.protectionType)){console.warn("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0;return}this._hasFinishedSetup=!0,this._dispatchEvent(L.LOADED,this._store),setTimeout(async()=>{var a;!this._hasProtectionInCart&&((a=this._store)==null?void 0:a.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()},500),!this.disablePolling&&setInterval(async()=>{const a=this._cartLastUpdated;a&&new Date().getTime()-a.getTime()<this.pollingInterval||await this.updateCart()},this.pollingInterval)}),At(this,async()=>{var h,d,u,_,g;if(this._cartLastUpdated=new Date,!((h=this._cart)!=null&&h.items))return;const i=await this.calculateProtectionTotal(this._cart),r=this._findProtectionVariant(i);if(this._protectionVariant=r,!(r!=null&&r.id))throw new Error("No matching protection variant found.");const s=(u=(d=this._cart.items)==null?void 0:d.findIndex(St=>{var X,Q,tt,et,it;return(it=(et=(tt=(Q=(X=this._store)==null?void 0:X.protectionSettings)==null?void 0:Q.product)==null?void 0:tt.variants)==null?void 0:et.edges)==null?void 0:it.some(({node:R})=>{var ot;return(ot=R==null?void 0:R.id)==null?void 0:ot.includes(St.variant_id.toString())})}))!=null?u:[],n=(_=this._cart)==null?void 0:_.items[s];if(this._hasProtectionInCart=!!n,!n)return;if((g=r.id)!=null&&g.includes(n.id.toString())){this._protectionCartItem=A(b({},n),{index:s,position:s+1});return}const c={id:n.key,quantity:0};await this._fetch.post("/cart/change.js",c);const a={id:r.id.replace("gid://shopify/ProductVariant/",""),quantity:1},p=await this._fetch.post("/cart/add.js",a),l=A(b({},this._cart),{items:[p,...this._cart.items]});this._cart=l,this._dispatchEvent(L.STATUS_UPDATE,{protection:!0,cart:l,lineItem:p}),this.disablePolling||window.location.reload()},[this._store,this._cart]);const o=P`
275
+ `,L=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(L||{}),Qt=Object.defineProperty,te=Object.getOwnPropertyDescriptor,v=(o,t,e,i)=>{for(var r=i>1?void 0:i?te(t,e):t,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&Qt(t,e,r),r};const Et=async(o,t)=>{try{const e=await fetch(o,t);if(!e.ok)throw new Error(await e.text());return await e.json()}catch(e){throw console.error(e),new Error("Failed to complete fetch request.")}},ee=2500;let m=class extends H{constructor(){super(...arguments);var o;this.disablePolling=!1,this.pollingInterval=ee,this._apiEndpoint="/apps/shipaid",this._storeDomain=(o=window.Shopify)==null?void 0:o.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Et(t),post:(t,e)=>Et(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var e;Gt(this,async()=>{var r,s,n,c;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[a,p]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=a,this._cart=p}catch{this._hasFinishedSetup=!0;return}if(!((s=(r=this._store)==null?void 0:r.plan)!=null&&s.active)){console.warn("No ShipAid plan is active for this store - skipping setup.");return}if(!((c=(n=this._store)==null?void 0:n.protectionSettings)!=null&&c.protectionType)){console.warn("No protection settings for this store - skipping setup.");return}this._hasFinishedSetup=!0,this._dispatchEvent(L.LOADED,this._store),setTimeout(async()=>{var a;!this._hasProtectionInCart&&((a=this._store)==null?void 0:a.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()},500),!this.disablePolling&&setInterval(async()=>{const a=this._cartLastUpdated;a&&new Date().getTime()-a.getTime()<this.pollingInterval||await this.updateCart()},this.pollingInterval)}),At(this,async()=>{var h,d,u,_,g;if(this._cartLastUpdated=new Date,!((h=this._cart)!=null&&h.items))return;const i=await this.calculateProtectionTotal(this._cart),r=this._findProtectionVariant(i);if(this._protectionVariant=r,!(r!=null&&r.id))throw this._hasFinishedSetup=!1,new Error("No matching protection variant found.");const s=(u=(d=this._cart.items)==null?void 0:d.findIndex(St=>{var X,Q,tt,et,it;return(it=(et=(tt=(Q=(X=this._store)==null?void 0:X.protectionSettings)==null?void 0:Q.product)==null?void 0:tt.variants)==null?void 0:et.edges)==null?void 0:it.some(({node:R})=>{var ot;return(ot=R==null?void 0:R.id)==null?void 0:ot.includes(St.variant_id.toString())})}))!=null?u:[],n=(_=this._cart)==null?void 0:_.items[s];if(this._hasProtectionInCart=!!n,!n)return;if((g=r.id)!=null&&g.includes(n.id.toString())){this._protectionCartItem=A(b({},n),{index:s,position:s+1});return}const c={id:n.key,quantity:0};await this._fetch.post("/cart/change.js",c);const a={id:r.id.replace("gid://shopify/ProductVariant/",""),quantity:1},p=await this._fetch.post("/cart/add.js",a),l=A(b({},this._cart),{items:[p,...this._cart.items]});this._cart=l,this._dispatchEvent(L.STATUS_UPDATE,{protection:!0,cart:l,lineItem:p}),this.disablePolling||window.location.reload()},[this._store,this._cart]);const o=P`
276
276
  <div class=${`shipaid-popup ${this._popup==="learn-more"&&"active"}`}>
277
277
  <div class="popup">
278
278
  <button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
@@ -327,4 +327,4 @@ var xt=Object.defineProperty,Ct=Object.defineProperties;var Pt=Object.getOwnProp
327
327
  <div class="shipaid">
328
328
  ${G(this._hasFinishedSetup,()=>{var i,r;return G(((r=(i=this._store)==null?void 0:i.plan)==null?void 0:r.active)&&this._store.widgetShowCart,()=>[o,t],()=>P``)},()=>P`<p><slot>Loading ShipAid Widget...</slot></p>`)}
329
329
  </div>
330
- `}_currencyFormat(o){var t,e,i,r,s;return new Intl.NumberFormat((e=(t=window.Shopify)==null?void 0:t.locale)!=null?e:void 0,{currency:((i=this._store)==null?void 0:i.currency)||((s=(r=window.Shopify)==null?void 0:r.currency)==null?void 0:s.active)||"USD",style:"currency"}).format(Number(o))}_dispatchEvent(o,t={}){this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:t}))}async calculateProtectionTotal(o){var s,n,c,a,p;if(o||(o=await this._fetchCart()),!o)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const t=(s=this._store)==null?void 0:s.protectionSettings;if(!t||!t.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const e=((n=this._store)==null?void 0:n.excludedProductSkus)&&o.items?o.items.reduce((l,h)=>h.sku&&this._store.excludedProductSkus.find(d=>d===h.sku)?l-h.final_price:l,o.total_price):o.total_price,i=((a=(c=o.items)==null?void 0:c.filter(l=>{var h,d,u;return(u=(d=(h=t.product)==null?void 0:h.variants)==null?void 0:d.edges)==null?void 0:u.some(({node:_})=>{var g;return(g=_==null?void 0:_.id)==null?void 0:g.includes(l.variant_id.toString())})}))!=null?a:[]).reduce((l,h)=>l+=h.final_line_price,0),r=e-i;if(t.protectionType==="FIXED"){if(!t.defaultFee)throw new Error("Missing default fee amount.");if(!((p=t.rules)!=null&&p.length))return t.defaultFee;const l=r/100,h=t.rules.sort((d,u)=>!d.rangeLower||!u.rangeLower?0:d.rangeLower-u.rangeLower).find(d=>{const u=Boolean(d.rangeLower&&d.rangeLower<l);return d.rangeUpper?u&&d.rangeUpper>=l:u});return typeof(h==null?void 0:h.fee)=="number"?h.fee:t.defaultFee}if(t.protectionType==="PERCENTAGE"){const l=r*t.percentage/100;return l>=t.minimumFee?l:t.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(o){var e,i,r;const t=(e=this._store)==null?void 0:e.protectionSettings;if(!t||!((r=(i=t.product)==null?void 0:i.variants)!=null&&r.edges))throw new Error("Missing product and variants from protection settings.");return t.product.variants.edges.flatMap(({node:s})=>{if(!s||!s.price)return[];const n=Number(s.price);return[A(b({},s),{formattedPrice:n})]}).sort((s,n)=>s.formattedPrice-n.formattedPrice).find(s=>s.formattedPrice>=o)}_setState(o,t){this._state={loading:o==="loading",success:o==="success",error:o==="error"?t||!0:!1}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const o=new URL(window.location.href);o.pathname=this._apiEndpoint;const t=await this._fetch.get(o.toString());if(!t)throw new Error(`Failed to fetch store data for ${o.toString()}`);const[e]=t.stores;if(!e)throw new Error(`Could not find a store for this URL ${o.toString()}.`);return e}catch(o){throw console.error(o),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(o){throw console.error(o),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(o){o||(o=await this._fetchCart()),this._cart=o}async addProtection(){var o,t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!((o=this._cart)!=null&&o.items))throw new Error("Cart has not been loaded.");if(!((t=this._protectionVariant)!=null&&t.id))throw new Error("No protection variant found.");this._setState("loading");const i={id:this._protectionVariant.id.replace("gid://shopify/ProductVariant/",""),quantity:1},r=await this._fetch.post("/cart/add.js",i),s=A(b({},this._cart),{items:[r,...this._cart.items]});this._cart=s,this._setState("success"),this._dispatchEvent(L.STATUS_UPDATE,{protection:!0,cart:s,lineItem:r}),(((e=window.Shopify)==null?void 0:e.Checkout)||!this.disablePolling)&&window.location.reload()}catch(i){console.error(i),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var o;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={id:this._protectionCartItem.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);this._dispatchEvent(L.STATUS_UPDATE,{protection:!1,cart:e,lineItem:this._protectionCartItem}),this._cart=e,this._setState("success"),(((o=window.Shopify)==null?void 0:o.Checkout)||!this.disablePolling)&&window.location.reload()}catch(t){console.error(t),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}};m.styles=Xt,v([F({type:Boolean,attribute:!0})],m.prototype,"disablePolling",2),v([F({type:Number,attribute:!0})],m.prototype,"pollingInterval",2),v([y()],m.prototype,"_storeDomain",2),v([y()],m.prototype,"_store",2),v([y()],m.prototype,"_cart",2),v([y()],m.prototype,"_cartLastUpdated",2),v([y()],m.prototype,"_hasFinishedSetup",2),v([y()],m.prototype,"_hasProtectionInCart",2),v([y()],m.prototype,"_protectionCartItem",2),v([y()],m.prototype,"_protectionVariant",2),v([y()],m.prototype,"_state",2),v([y()],m.prototype,"_popup",2),m=v([kt("shipaid-widget")],m);export{m as ShipAidWidget};
330
+ `}_currencyFormat(o){var t,e,i,r,s;return new Intl.NumberFormat((e=(t=window.Shopify)==null?void 0:t.locale)!=null?e:void 0,{currency:((i=this._store)==null?void 0:i.currency)||((s=(r=window.Shopify)==null?void 0:r.currency)==null?void 0:s.active)||"USD",style:"currency"}).format(Number(o))}_dispatchEvent(o,t={}){this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:t}))}async calculateProtectionTotal(o){var s,n,c,a,p;if(o||(o=await this._fetchCart()),!o)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const t=(s=this._store)==null?void 0:s.protectionSettings;if(!t||!t.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const e=((n=this._store)==null?void 0:n.excludedProductSkus)&&o.items?o.items.reduce((l,h)=>h.sku&&this._store.excludedProductSkus.find(d=>d===h.sku)?l-h.final_price:l,o.total_price):o.total_price,i=((a=(c=o.items)==null?void 0:c.filter(l=>{var h,d,u;return(u=(d=(h=t.product)==null?void 0:h.variants)==null?void 0:d.edges)==null?void 0:u.some(({node:_})=>{var g;return(g=_==null?void 0:_.id)==null?void 0:g.includes(l.variant_id.toString())})}))!=null?a:[]).reduce((l,h)=>l+=h.final_line_price,0),r=e-i;if(t.protectionType==="FIXED"){if(!t.defaultFee)throw new Error("Missing default fee amount.");if(!((p=t.rules)!=null&&p.length))return t.defaultFee;const l=r/100,h=t.rules.sort((d,u)=>!d.rangeLower||!u.rangeLower?0:d.rangeLower-u.rangeLower).find(d=>{const u=Boolean(d.rangeLower&&d.rangeLower<l);return d.rangeUpper?u&&d.rangeUpper>=l:u});return typeof(h==null?void 0:h.fee)=="number"?h.fee:t.defaultFee}if(t.protectionType==="PERCENTAGE"){const l=r*t.percentage/100;return l>=t.minimumFee?l:t.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(o){var e,i,r;const t=(e=this._store)==null?void 0:e.protectionSettings;if(!t||!((r=(i=t.product)==null?void 0:i.variants)!=null&&r.edges))throw new Error("Missing product and variants from protection settings.");return t.product.variants.edges.flatMap(({node:s})=>{if(!s||!s.price)return[];const n=Number(s.price);return[A(b({},s),{formattedPrice:n})]}).sort((s,n)=>s.formattedPrice-n.formattedPrice).find(s=>s.formattedPrice>=o)}_setState(o,t){this._state={loading:o==="loading",success:o==="success",error:o==="error"?t||!0:!1}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const o=new URL(window.location.href);o.pathname=this._apiEndpoint;const t=await this._fetch.get(o.toString());if(!t)throw new Error(`Failed to fetch store data for ${o.toString()}`);const[e]=t.stores;if(!e)throw new Error(`Could not find a store for this URL ${o.toString()}.`);return e}catch(o){throw console.error(o),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(o){throw console.error(o),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(o){o||(o=await this._fetchCart()),this._cart=o}async addProtection(){var o,t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!((o=this._cart)!=null&&o.items))throw new Error("Cart has not been loaded.");if(!((t=this._protectionVariant)!=null&&t.id))throw new Error("No protection variant found.");this._setState("loading");const i={id:this._protectionVariant.id.replace("gid://shopify/ProductVariant/",""),quantity:1},r=await this._fetch.post("/cart/add.js",i),s=A(b({},this._cart),{items:[r,...this._cart.items]});this._cart=s,this._setState("success"),this._dispatchEvent(L.STATUS_UPDATE,{protection:!0,cart:s,lineItem:r}),(((e=window.Shopify)==null?void 0:e.Checkout)||!this.disablePolling)&&window.location.reload()}catch(i){console.error(i),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var o;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={id:this._protectionCartItem.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);this._dispatchEvent(L.STATUS_UPDATE,{protection:!1,cart:e,lineItem:this._protectionCartItem}),this._cart=e,this._setState("success"),(((o=window.Shopify)==null?void 0:o.Checkout)||!this.disablePolling)&&window.location.reload()}catch(t){console.error(t),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}};m.styles=Xt,v([j({type:Boolean,attribute:!0})],m.prototype,"disablePolling",2),v([j({type:Number,attribute:!0})],m.prototype,"pollingInterval",2),v([y()],m.prototype,"_storeDomain",2),v([y()],m.prototype,"_store",2),v([y()],m.prototype,"_cart",2),v([y()],m.prototype,"_cartLastUpdated",2),v([y()],m.prototype,"_hasFinishedSetup",2),v([y()],m.prototype,"_hasProtectionInCart",2),v([y()],m.prototype,"_protectionCartItem",2),v([y()],m.prototype,"_protectionVariant",2),v([y()],m.prototype,"_state",2),v([y()],m.prototype,"_popup",2),m=v([kt("shipaid-widget")],m);export{m as ShipAidWidget};
@@ -285,7 +285,7 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
285
285
  color: var(--shipaid-text-grey);
286
286
  font-weight: var(--shipaid-font-heavy);
287
287
  }
288
- `,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(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&&gt(e,i,s),s};const wt=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.")}};return t.ShipAidWidget=class extends lt{constructor(){var t;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this._apiEndpoint="/apps/shipaid",this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>wt(t),post:(t,e)=>wt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t;((t,e)=>{ut(t,e,[])})(this,(async()=>{var t,e,i,o;const r=document.createElement("link");r.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),r.setAttribute("rel","stylesheet"),document.head.appendChild(r);try{const[t,e]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=t,this._cart=e}catch{return void(this._hasFinishedSetup=!0)}return null!=(e=null==(t=this._store)?void 0:t.plan)&&e.active?null!=(o=null==(i=this._store)?void 0:i.protectionSettings)&&o.protectionType?(this._hasFinishedSetup=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&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))):(console.warn("No protection settings for this store - skipping setup."),void(this._hasFinishedSetup=!0)):(console.warn("No ShipAid plan is active for this store - skipping setup."),void(this._hasFinishedSetup=!0))})),ut(this,(async()=>{var t,e,i,o,r;if(this._cartLastUpdated=new Date,null==(t=this._cart)||!t.items)return;const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,null==n||!n.id)throw new Error("No matching protection variant found.");const a=null!=(i=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i,o,r,s;return null==(s=null==(r=null==(o=null==(i=null==(e=this._store)?void 0:e.protectionSettings)?void 0:i.product)?void 0:o.variants)?void 0:r.edges)?void 0:s.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?i:[],d=null==(o=this._cart)?void 0:o.items[a];if(this._hasProtectionInCart=!!d,!d)return;if(null!=(r=n.id)&&r.includes(d.id.toString()))return void(this._protectionCartItem=l(p({},d),{index:a,position:a+1}));const h={id:d.key,quantity:0};await this._fetch.post("/cart/change.js",h);const c={id:n.id.replace("gid://shopify/ProductVariant/",""),quantity:1},u=await this._fetch.post("/cart/add.js",c),f=l(p({},this._cart),{items:[u,...this._cart.items]});this._cart=f,this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:f,lineItem:u}),this.disablePolling||window.location.reload()}),[this._store,this._cart]);const e=B`
288
+ `,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(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&&gt(e,i,s),s};const wt=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.")}};return t.ShipAidWidget=class extends lt{constructor(){var t;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this._apiEndpoint="/apps/shipaid",this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>wt(t),post:(t,e)=>wt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t;((t,e)=>{ut(t,e,[])})(this,(async()=>{var t,e,i,o;const r=document.createElement("link");r.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),r.setAttribute("rel","stylesheet"),document.head.appendChild(r);try{const[t,e]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=t,this._cart=e}catch{return void(this._hasFinishedSetup=!0)}null!=(e=null==(t=this._store)?void 0:t.plan)&&e.active?null!=(o=null==(i=this._store)?void 0:i.protectionSettings)&&o.protectionType?(this._hasFinishedSetup=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()}),500),!this.disablePolling&&setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval)):console.warn("No protection settings for this store - skipping setup."):console.warn("No ShipAid plan is active for this store - skipping setup.")})),ut(this,(async()=>{var t,e,i,o,r;if(this._cartLastUpdated=new Date,null==(t=this._cart)||!t.items)return;const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,null==n||!n.id)throw this._hasFinishedSetup=!1,new Error("No matching protection variant found.");const a=null!=(i=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i,o,r,s;return null==(s=null==(r=null==(o=null==(i=null==(e=this._store)?void 0:e.protectionSettings)?void 0:i.product)?void 0:o.variants)?void 0:r.edges)?void 0:s.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?i:[],d=null==(o=this._cart)?void 0:o.items[a];if(this._hasProtectionInCart=!!d,!d)return;if(null!=(r=n.id)&&r.includes(d.id.toString()))return void(this._protectionCartItem=l(p({},d),{index:a,position:a+1}));const h={id:d.key,quantity:0};await this._fetch.post("/cart/change.js",h);const c={id:n.id.replace("gid://shopify/ProductVariant/",""),quantity:1},u=await this._fetch.post("/cart/add.js",c),f=l(p({},this._cart),{items:[u,...this._cart.items]});this._cart=f,this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:f,lineItem:u}),this.disablePolling||window.location.reload()}),[this._store,this._cart]);const e=B`
289
289
  <div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
290
290
  <div class="popup">
291
291
  <button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
@@ -285,7 +285,7 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
285
285
  color: var(--shipaid-text-grey);
286
286
  font-weight: var(--shipaid-font-heavy);
287
287
  }
288
- `,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(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&&gt(e,i,s),s};const wt=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.")}};t.ShipAidWidget=class extends lt{constructor(){var t;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this._apiEndpoint="/apps/shipaid",this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>wt(t),post:(t,e)=>wt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t;((t,e)=>{ut(t,e,[])})(this,(async()=>{var t,e,i,o;const r=document.createElement("link");r.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),r.setAttribute("rel","stylesheet"),document.head.appendChild(r);try{const[t,e]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=t,this._cart=e}catch{return void(this._hasFinishedSetup=!0)}return null!=(e=null==(t=this._store)?void 0:t.plan)&&e.active?null!=(o=null==(i=this._store)?void 0:i.protectionSettings)&&o.protectionType?(this._hasFinishedSetup=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&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))):(console.warn("No protection settings for this store - skipping setup."),void(this._hasFinishedSetup=!0)):(console.warn("No ShipAid plan is active for this store - skipping setup."),void(this._hasFinishedSetup=!0))})),ut(this,(async()=>{var t,e,i,o,r;if(this._cartLastUpdated=new Date,null==(t=this._cart)||!t.items)return;const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,null==n||!n.id)throw new Error("No matching protection variant found.");const a=null!=(i=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i,o,r,s;return null==(s=null==(r=null==(o=null==(i=null==(e=this._store)?void 0:e.protectionSettings)?void 0:i.product)?void 0:o.variants)?void 0:r.edges)?void 0:s.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?i:[],d=null==(o=this._cart)?void 0:o.items[a];if(this._hasProtectionInCart=!!d,!d)return;if(null!=(r=n.id)&&r.includes(d.id.toString()))return void(this._protectionCartItem=l(p({},d),{index:a,position:a+1}));const h={id:d.key,quantity:0};await this._fetch.post("/cart/change.js",h);const c={id:n.id.replace("gid://shopify/ProductVariant/",""),quantity:1},u=await this._fetch.post("/cart/add.js",c),f=l(p({},this._cart),{items:[u,...this._cart.items]});this._cart=f,this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:f,lineItem:u}),this.disablePolling||window.location.reload()}),[this._store,this._cart]);const e=B`
288
+ `,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(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&&gt(e,i,s),s};const wt=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.")}};t.ShipAidWidget=class extends lt{constructor(){var t;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this._apiEndpoint="/apps/shipaid",this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>wt(t),post:(t,e)=>wt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t;((t,e)=>{ut(t,e,[])})(this,(async()=>{var t,e,i,o;const r=document.createElement("link");r.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),r.setAttribute("rel","stylesheet"),document.head.appendChild(r);try{const[t,e]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=t,this._cart=e}catch{return void(this._hasFinishedSetup=!0)}null!=(e=null==(t=this._store)?void 0:t.plan)&&e.active?null!=(o=null==(i=this._store)?void 0:i.protectionSettings)&&o.protectionType?(this._hasFinishedSetup=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()}),500),!this.disablePolling&&setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval)):console.warn("No protection settings for this store - skipping setup."):console.warn("No ShipAid plan is active for this store - skipping setup.")})),ut(this,(async()=>{var t,e,i,o,r;if(this._cartLastUpdated=new Date,null==(t=this._cart)||!t.items)return;const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,null==n||!n.id)throw this._hasFinishedSetup=!1,new Error("No matching protection variant found.");const a=null!=(i=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i,o,r,s;return null==(s=null==(r=null==(o=null==(i=null==(e=this._store)?void 0:e.protectionSettings)?void 0:i.product)?void 0:o.variants)?void 0:r.edges)?void 0:s.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?i:[],d=null==(o=this._cart)?void 0:o.items[a];if(this._hasProtectionInCart=!!d,!d)return;if(null!=(r=n.id)&&r.includes(d.id.toString()))return void(this._protectionCartItem=l(p({},d),{index:a,position:a+1}));const h={id:d.key,quantity:0};await this._fetch.post("/cart/change.js",h);const c={id:n.id.replace("gid://shopify/ProductVariant/",""),quantity:1},u=await this._fetch.post("/cart/add.js",c),f=l(p({},this._cart),{items:[u,...this._cart.items]});this._cart=f,this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:f,lineItem:u}),this.disablePolling||window.location.reload()}),[this._store,this._cart]);const e=B`
289
289
  <div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
290
290
  <div class="popup">
291
291
  <button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui.shipaid.com",
3
3
  "private": false,
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "main": "dist/ui.shipaid.com.umd.js",
6
6
  "unpkg": "dist/ui.shipaid.com.iife.js",
7
7
  "module": "dist/ui.shipaid.com.es.js",