ui.shipaid.com 0.0.1 → 0.0.4
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/ui.shipaid.com.es.js +140 -227
- package/dist/ui.shipaid.com.iife.js +79 -0
- package/dist/ui.shipaid.com.umd.js +79 -0
- package/package.json +4 -3
|
@@ -1,107 +1,138 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1
|
+
var vt=Object.defineProperty,ft=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var K=(s,t,e)=>t in s?vt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,C=(s,t)=>{for(var e in t||(t={}))_t.call(t,e)&&K(s,e,t[e]);if(J)for(var e of J(t))$t.call(t,e)&&K(s,e,t[e]);return s},P=(s,t)=>ft(s,mt(t));/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/const gt=s=>t=>typeof t=="function"?((e,i)=>(window.customElements.define(e,i),i))(s,t):((e,i)=>{const{kind:o,elements:r}=i;return{kind:o,elements:r,finisher(n){window.customElements.define(e,n)}}})(s,t);/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2017 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
+
*/const yt=(s,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?P(C({},t),{finisher(e){e.createProperty(t.key,s)}}):{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,s)}};function At(s){return(t,e)=>e!==void 0?((i,o,r)=>{o.constructor.createProperty(r,i)})(s,t,e):yt(s,t)}/**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright 2017 Google LLC
|
|
12
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
+
*/function g(s){return At(P(C({},s),{state:!0}))}/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2021 Google LLC
|
|
16
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
+
*/var R;((R=window.HTMLSlotElement)===null||R===void 0?void 0:R.prototype.assignedElements)!=null;/**
|
|
18
|
+
* @license
|
|
19
|
+
* Copyright 2019 Google LLC
|
|
20
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
+
*/const z=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Z=Symbol(),G=new Map;class wt{constructor(t,e){if(this._$cssResult$=!0,e!==Z)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=G.get(this.cssText);return z&&t===void 0&&(G.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const Et=s=>new wt(typeof s=="string"?s:s+"",Z),bt=(s,t)=>{z?s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const i=document.createElement("style"),o=window.litNonce;o!==void 0&&i.setAttribute("nonce",o),i.textContent=e.cssText,s.appendChild(i)})},Q=z?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Et(e)})(s):s;/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2017 Google LLC
|
|
24
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
+
*/var L;const X=window.trustedTypes,St=X?X.emptyScript:"",Y=window.reactiveElementPolyfillSupport,j={toAttribute(s,t){switch(t){case Boolean:s=s?St:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},tt=(s,t)=>t!==s&&(t==t||s==s),V={attribute:!0,type:String,converter:j,reflect:!1,hasChanged:tt};class A extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;(e=this.l)!==null&&e!==void 0||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((e,i)=>{const o=this._$Eh(i,e);o!==void 0&&(this._$Eu.set(o,i),t.push(o))}),t}static createProperty(t,e=V){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i=typeof t=="symbol"?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);o!==void 0&&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)||V}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._$Eu=new Map,this.hasOwnProperty("properties")){const e=this.properties,i=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const o of i)this.createProperty(o,e[o])}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 o of i)e.unshift(Q(o))}else t!==void 0&&e.push(Q(t));return e}static _$Eh(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Em(),this.requestUpdate(),(t=this.constructor.l)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,i;((e=this._$Eg)!==null&&e!==void 0?e:this._$Eg=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((i=t.hostConnected)===null||i===void 0||i.call(t))}removeController(t){var e;(e=this._$Eg)===null||e===void 0||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;const e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return bt(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$Eg)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostConnected)===null||i===void 0?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$Eg)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostDisconnected)===null||i===void 0?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ES(t,e,i=V){var o,r;const n=this.constructor._$Eh(t,i);if(n!==void 0&&i.reflect===!0){const d=((r=(o=i.converter)===null||o===void 0?void 0:o.toAttribute)!==null&&r!==void 0?r:j.toAttribute)(e,i.type);this._$Ei=t,d==null?this.removeAttribute(n):this.setAttribute(n,d),this._$Ei=null}}_$AK(t,e){var i,o,r;const n=this.constructor,d=n._$Eu.get(t);if(d!==void 0&&this._$Ei!==d){const a=n.getPropertyOptions(d),h=a.converter,u=(r=(o=(i=h)===null||i===void 0?void 0:i.fromAttribute)!==null&&o!==void 0?o:typeof h=="function"?h:null)!==null&&r!==void 0?r:j.fromAttribute;this._$Ei=d,this[d]=u(e,a.type),this._$Ei=null}}requestUpdate(t,e,i){let o=!0;t!==void 0&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||tt)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Ei!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach((o,r)=>this[r]=o),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),(t=this._$Eg)===null||t===void 0||t.forEach(o=>{var r;return(r=o.hostUpdate)===null||r===void 0?void 0:r.call(o)}),this.update(i)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;(e=this._$Eg)===null||e===void 0||e.forEach(i=>{var o;return(o=i.hostUpdated)===null||o===void 0?void 0:o.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,i)=>this._$ES(i,this[i],e)),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}A.finalized=!0,A.elementProperties=new Map,A.elementStyles=[],A.shadowRootOptions={mode:"open"},Y==null||Y({ReactiveElement:A}),((L=globalThis.reactiveElementVersions)!==null&&L!==void 0?L:globalThis.reactiveElementVersions=[]).push("1.3.0");/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2017 Google LLC
|
|
28
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
29
|
+
*/var B;const w=globalThis.trustedTypes,et=w?w.createPolicy("lit-html",{createHTML:s=>s}):void 0,_=`lit$${(Math.random()+"").slice(9)}$`,it="?"+_,xt=`<${it}>`,E=document,U=(s="")=>E.createComment(s),T=s=>s===null||typeof s!="object"&&typeof s!="function",st=Array.isArray,Ct=s=>{var t;return st(s)||typeof((t=s)===null||t===void 0?void 0:t[Symbol.iterator])=="function"},N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ot=/-->/g,rt=/>/g,y=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,nt=/'/g,at=/"/g,ht=/^(?:script|style|textarea|title)$/i,Pt=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),q=Pt(1),b=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),dt=new WeakMap,Ut=(s,t,e)=>{var i,o;const r=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let n=r._$litPart$;if(n===void 0){const d=(o=e==null?void 0:e.renderBefore)!==null&&o!==void 0?o:null;r._$litPart$=n=new O(t.insertBefore(U(),d),d,void 0,e!=null?e:{})}return n._$AI(s),n},S=E.createTreeWalker(E,129,null,!1),Tt=(s,t)=>{const e=s.length-1,i=[];let o,r=t===2?"<svg>":"",n=N;for(let a=0;a<e;a++){const h=s[a];let u,l,c=-1,v=0;for(;v<h.length&&(n.lastIndex=v,l=n.exec(h),l!==null);)v=n.lastIndex,n===N?l[1]==="!--"?n=ot:l[1]!==void 0?n=rt:l[2]!==void 0?(ht.test(l[2])&&(o=RegExp("</"+l[2],"g")),n=y):l[3]!==void 0&&(n=y):n===y?l[0]===">"?(n=o!=null?o:N,c=-1):l[1]===void 0?c=-2:(c=n.lastIndex-l[2].length,u=l[1],n=l[3]===void 0?y:l[3]==='"'?at:nt):n===at||n===nt?n=y:n===ot||n===rt?n=N:(n=y,o=void 0);const k=n===y&&s[a+1].startsWith("/>")?" ":"";r+=n===N?h+xt:c>=0?(i.push(u),h.slice(0,c)+"$lit$"+h.slice(c)+_+k):h+_+(c===-2?(i.push(void 0),a):k)}const d=r+(s[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return[et!==void 0?et.createHTML(d):d,i]};class I{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,n=0;const d=t.length-1,a=this.parts,[h,u]=Tt(t,e);if(this.el=I.createElement(h,i),S.currentNode=this.el.content,e===2){const l=this.el.content,c=l.firstChild;c.remove(),l.append(...c.childNodes)}for(;(o=S.nextNode())!==null&&a.length<d;){if(o.nodeType===1){if(o.hasAttributes()){const l=[];for(const c of o.getAttributeNames())if(c.endsWith("$lit$")||c.startsWith(_)){const v=u[n++];if(l.push(c),v!==void 0){const k=o.getAttribute(v.toLowerCase()+"$lit$").split(_),M=/([.?@])?(.*)/.exec(v);a.push({type:1,index:r,name:M[2],strings:k,ctor:M[1]==="."?Ht:M[1]==="?"?Ot:M[1]==="@"?kt:D})}else a.push({type:6,index:r})}for(const c of l)o.removeAttribute(c)}if(ht.test(o.tagName)){const l=o.textContent.split(_),c=l.length-1;if(c>0){o.textContent=w?w.emptyScript:"";for(let v=0;v<c;v++)o.append(l[v],U()),S.nextNode(),a.push({type:2,index:++r});o.append(l[c],U())}}}else if(o.nodeType===8)if(o.data===it)a.push({type:2,index:r});else{let l=-1;for(;(l=o.data.indexOf(_,l+1))!==-1;)a.push({type:7,index:r}),l+=_.length-1}r++}}static createElement(t,e){const i=E.createElement("template");return i.innerHTML=t,i}}function x(s,t,e=s,i){var o,r,n,d;if(t===b)return t;let a=i!==void 0?(o=e._$Cl)===null||o===void 0?void 0:o[i]:e._$Cu;const h=T(t)?void 0:t._$litDirective$;return(a==null?void 0:a.constructor)!==h&&((r=a==null?void 0:a._$AO)===null||r===void 0||r.call(a,!1),h===void 0?a=void 0:(a=new h(s),a._$AT(s,e,i)),i!==void 0?((n=(d=e)._$Cl)!==null&&n!==void 0?n:d._$Cl=[])[i]=a:e._$Cu=a),a!==void 0&&(t=x(s,a._$AS(s,t.values),a,i)),t}class Nt{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:o}=this._$AD,r=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:E).importNode(i,!0);S.currentNode=r;let n=S.nextNode(),d=0,a=0,h=o[0];for(;h!==void 0;){if(d===h.index){let u;h.type===2?u=new O(n,n.nextSibling,this,t):h.type===1?u=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(u=new Mt(n,this,t)),this.v.push(u),h=o[++a]}d!==(h==null?void 0:h.index)&&(n=S.nextNode(),d++)}return r}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 O{constructor(t,e,i,o){var r;this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cg=(r=o==null?void 0:o.isConnected)===null||r===void 0||r}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=x(this,t,e),T(t)?t===p||t==null||t===""?(this._$AH!==p&&this._$AR(),this._$AH=p):t!==this._$AH&&t!==b&&this.$(t):t._$litType$!==void 0?this.T(t):t.nodeType!==void 0?this.k(t):Ct(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!==p&&T(this._$AH)?this._$AA.nextSibling.data=t:this.k(E.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:o}=t,r=typeof o=="number"?this._$AC(t):(o.el===void 0&&(o.el=I.createElement(o.h,this.options)),o);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===r)this._$AH.m(i);else{const n=new Nt(r,this),d=n.p(this.options);n.m(i),this.k(d),this._$AH=n}}_$AC(t){let e=dt.get(t.strings);return e===void 0&&dt.set(t.strings,e=new I(t)),e}S(t){st(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 O(this.A(U()),this.A(U()),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((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const o=t.nextSibling;t.remove(),t=o}}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,o,r){this.type=1,this._$AH=p,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=p}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let n=!1;if(r===void 0)t=x(this,t,e,0),n=!T(t)||t!==this._$AH&&t!==b,n&&(this._$AH=t);else{const d=t;let a,h;for(t=r[0],a=0;a<r.length-1;a++)h=x(this,d[i+a],e,a),h===b&&(h=this._$AH[a]),n||(n=!T(h)||h!==this._$AH[a]),h===p?t=p:t!==p&&(t+=(h!=null?h:"")+r[a+1]),this._$AH[a]=h}n&&!o&&this.C(t)}C(t){t===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}}class Ht extends D{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===p?void 0:t}}const It=w?w.emptyScript:"";class Ot extends D{constructor(){super(...arguments),this.type=4}C(t){t&&t!==p?this.element.setAttribute(this.name,It):this.element.removeAttribute(this.name)}}class kt extends D{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=(i=x(this,t,e,0))!==null&&i!==void 0?i:p)===b)return;const o=this._$AH,r=t===p&&o!==p||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,n=t!==p&&(o===p||r);r&&this.element.removeEventListener(this.name,this,o),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 Mt{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){x(this,t)}}const lt=window.litHtmlPolyfillSupport;lt==null||lt(I,O),((B=globalThis.litHtmlVersions)!==null&&B!==void 0?B:globalThis.litHtmlVersions=[]).push("2.2.0");/**
|
|
30
|
+
* @license
|
|
31
|
+
* Copyright 2017 Google LLC
|
|
32
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
+
*/var F,W;class H extends A{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=Ut(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Dt)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Dt)===null||t===void 0||t.setConnected(!1)}render(){return b}}H.finalized=!0,H._$litElement$=!0,(F=globalThis.litElementHydrateSupport)===null||F===void 0||F.call(globalThis,{LitElement:H});const ct=globalThis.litElementPolyfillSupport;ct==null||ct({LitElement:H}),((W=globalThis.litElementVersions)!==null&&W!==void 0?W:globalThis.litElementVersions=[]).push("3.2.0");function Dt(s){if(!s.dispatchEvent||!s.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return s}const m="__registered_effects";function Rt(s){const t=s;if(t[m])return t;const e=Dt(s),i=e.updated;return t[m]={index:0,count:0,effects:[]},e.updated=o=>(t[m].index=0,i(o)),t}function zt(s,t){const e=Rt(s),{index:i,count:o}=e[m];return i===o?(e[m].index++,e[m].count++,e[m].effects.push(t),t):(e[m].index++,e[m].effects[i])}function pt(s,t,e){const i=zt(s,{on:t,observe:["__initial__dirty"]});i.observe.some((o,r)=>e[r]!==o)&&i.on(),i.observe=e}const Lt=(s,t)=>pt(s,t,[]);/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2021 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
|
+
*/function jt(s,t,e){return s?t():e==null?void 0:e()}var Vt=`.shipaid-prompt {
|
|
38
|
+
--shipaid-primary: #002bd6;
|
|
39
|
+
--shipaid-secondary: #0076ff;
|
|
40
|
+
--shipaid-text: #000000;
|
|
41
|
+
--shipaid-text-muted: #cccccc;
|
|
42
|
+
--shipaid-text-grey: #aaaaaa;
|
|
43
|
+
--shipaid-light-grey: #ebecf0;
|
|
44
|
+
--shipaid-font: "Lato", sans-serif;
|
|
45
|
+
--shipaid-font-sm: 14px;
|
|
46
|
+
--shipaid-font-base: 16px;
|
|
47
|
+
--shipaid-font-lg: 18px;
|
|
48
|
+
--shipaid-font-regular: 400;
|
|
49
|
+
--shipaid-font-heavy: 700;
|
|
50
|
+
width: 400px;
|
|
51
|
+
font-family: var(--shipaid-font);
|
|
52
|
+
font-size: var(--shipaid-font-base);
|
|
53
|
+
color: var(--shipaid-text);
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
gap: 1rem;
|
|
57
|
+
margin: 2rem 0 2rem auto;
|
|
58
|
+
}
|
|
59
|
+
.shipaid-prompt p, .shipaid-prompt a {
|
|
60
|
+
margin: 0;
|
|
61
|
+
line-height: 1;
|
|
62
|
+
}
|
|
63
|
+
.shipaid-prompt .prompt-title {
|
|
64
|
+
text-align: center;
|
|
65
|
+
font-size: var(--shipaid-font-lg);
|
|
66
|
+
font-weight: var(--shipaid-font-heavy);
|
|
67
|
+
}
|
|
68
|
+
.shipaid-prompt .prompt-product {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: row;
|
|
71
|
+
gap: 2rem;
|
|
72
|
+
height: 55px;
|
|
73
|
+
margin-top: 1rem;
|
|
74
|
+
}
|
|
75
|
+
.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-title {
|
|
76
|
+
font-size: var(--shipaid-font-base);
|
|
77
|
+
font-weight: var(--shipaid-font-heavy);
|
|
78
|
+
}
|
|
79
|
+
.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-description {
|
|
80
|
+
font-size: var(--shipaid-font-sm);
|
|
81
|
+
margin-top: 1rem;
|
|
82
|
+
}
|
|
83
|
+
.shipaid-prompt .prompt-product .prompt-product-actions {
|
|
84
|
+
margin-left: auto;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
justify-content: space-between;
|
|
88
|
+
text-align: right;
|
|
89
|
+
}
|
|
90
|
+
.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-price {
|
|
91
|
+
color: var(--shipaid-text-muted);
|
|
92
|
+
font-size: var(--shipaid-font-base);
|
|
93
|
+
}
|
|
94
|
+
.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-button {
|
|
95
|
+
background-color: transparent;
|
|
96
|
+
border: none;
|
|
97
|
+
color: var(--shipaid-primary);
|
|
98
|
+
text-transform: uppercase;
|
|
99
|
+
font-weight: var(--shipaid-font-heavy);
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
}
|
|
102
|
+
.shipaid-prompt .prompt-footer {
|
|
103
|
+
display: flex;
|
|
104
|
+
flex-direction: row;
|
|
105
|
+
justify-content: space-between;
|
|
106
|
+
align-items: center;
|
|
107
|
+
margin-top: 1rem;
|
|
108
|
+
}
|
|
109
|
+
.shipaid-prompt .prompt-footer .prompt-footer-about {
|
|
110
|
+
color: var(--shipaid-text-grey);
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
text-decoration: underline;
|
|
113
|
+
font-size: var(--shipaid-font-sm);
|
|
114
|
+
}
|
|
115
|
+
.shipaid-prompt .prompt-footer .prompt-footer-badge {
|
|
116
|
+
background-color: var(--shipaid-light-grey);
|
|
117
|
+
color: var(--shipaid-text);
|
|
118
|
+
padding: 0.5rem 1.5rem;
|
|
119
|
+
border-radius: 30px;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
text-decoration: none;
|
|
122
|
+
font-size: var(--shipaid-font-sm);
|
|
123
|
+
}
|
|
124
|
+
.shipaid-prompt .prompt-footer .prompt-footer-badge .ship {
|
|
125
|
+
text-transform: uppercase;
|
|
126
|
+
color: var(--shipaid-secondary);
|
|
127
|
+
font-weight: var(--shipaid-font-heavy);
|
|
128
|
+
}
|
|
129
|
+
.shipaid-prompt .prompt-footer .prompt-footer-badge .aid {
|
|
130
|
+
text-transform: uppercase;
|
|
131
|
+
color: var(--shipaid-text-grey);
|
|
132
|
+
font-weight: var(--shipaid-font-heavy);
|
|
133
|
+
}`,Bt=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,$=(s,t,e,i)=>{for(var o=i>1?void 0:i?qt(t,e):t,r=s.length-1,n;r>=0;r--)(n=s[r])&&(o=(i?n(t,e,o):n(o))||o);return i&&o&&Bt(t,e,o),o},Ft=(s=>(s.LOADED="shipaid-loaded",s.STATUS_UPDATE="shipaid-protection-status",s))(Ft||{});const Wt=s=>{var t,e,i,o,r;return new Intl.NumberFormat((e=(t=window.Shopify)==null?void 0:t.locale)!=null?e:void 0,{currency:(r=(o=(i=window.Shopify)==null?void 0:i.currency)==null?void 0:o.active)!=null?r:"USD",style:"currency"}).format(s)},ut=async(s,t)=>{try{const e=await fetch(s,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.")}};let f=class extends H{constructor(){super(...arguments);var s;this._storeDomain=(s=window.Shopify)==null?void 0:s.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._fetch={get:t=>ut(t),post:(t,e)=>ut(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t,e;Lt(this,async()=>{var n,d;const[i,o]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=i,this._cart=o;const r=(d=(n=o.items)==null?void 0:n.some(a=>a.variant_id===i.productVariantNumericId))!=null?d:!1;this._hasProtectionInCart=r,this._hasFinishedSetup=!0,this._dispatchEvent("shipaid-loaded",i)}),pt(this,()=>{var r,n,d,a;if(!((r=this._cart)!=null&&r.items))return;const i=(d=(n=this._cart)==null?void 0:n.items)==null?void 0:d.findIndex(h=>{var u;return h.variant_id===((u=this._store)==null?void 0:u.productVariantNumericId)}),o=(a=this._cart)==null?void 0:a.items[i];this._hasProtectionInCart=!!o,o&&(this._protectionProduct=P(C({},o),{index:i,position:i+1}))},[this._store,this._cart]);const s=q`
|
|
103
134
|
<div class="shipaid-prompt">
|
|
104
|
-
<p class="prompt-title">${this._hasProtectionInCart
|
|
135
|
+
<p class="prompt-title">${this._hasProtectionInCart?"Active":"Inactive"}</p>
|
|
105
136
|
<div class="prompt-product">
|
|
106
137
|
<!-- <div class="prompt-product-image">
|
|
107
138
|
<img src="" alt="ShipAid logo" />
|
|
@@ -111,9 +142,9 @@ let ShipAidWidget = class extends LitElement {
|
|
|
111
142
|
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
112
143
|
</div>
|
|
113
144
|
<div class="prompt-product-actions">
|
|
114
|
-
<p class="prompt-product-actions-price">${
|
|
145
|
+
<p class="prompt-product-actions-price">${Wt((e=(t=this._store)==null?void 0:t.productPrice)!=null?e:0)}</p>
|
|
115
146
|
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
116
|
-
${this._state.loading
|
|
147
|
+
${this._state.loading?"Loading...":this._hasProtectionInCart?"Remove":"+ Add"}
|
|
117
148
|
</button>
|
|
118
149
|
</div>
|
|
119
150
|
</div>
|
|
@@ -126,30 +157,9 @@ let ShipAidWidget = class extends LitElement {
|
|
|
126
157
|
</a>
|
|
127
158
|
</div>
|
|
128
159
|
</div>
|
|
129
|
-
`;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
`;
|
|
133
|
-
}
|
|
134
|
-
_dispatchEvent(event, detail = {}) {
|
|
135
|
-
this.dispatchEvent(new CustomEvent(event, { bubbles: true, composed: true, detail }));
|
|
136
|
-
}
|
|
137
|
-
_setState(state2, message) {
|
|
138
|
-
this._state = {
|
|
139
|
-
loading: state2 === "loading",
|
|
140
|
-
success: state2 === "success",
|
|
141
|
-
error: state2 === "error" ? message || true : false
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
async _updateProtection() {
|
|
145
|
-
return this._hasProtectionInCart ? this.removeProtection() : this.addProtection();
|
|
146
|
-
}
|
|
147
|
-
async _fetchShipAidData() {
|
|
148
|
-
try {
|
|
149
|
-
if (!this._storeDomain)
|
|
150
|
-
throw new Error("Missing store domain - cannot continue.");
|
|
151
|
-
const variables = { store: this._storeDomain };
|
|
152
|
-
const query = `query StoreByDomain($store: String!) {
|
|
160
|
+
`;return q`
|
|
161
|
+
${jt(this._hasFinishedSetup&&this._store,()=>s,()=>q`<p>Loading...</p>`)}
|
|
162
|
+
`}_dispatchEvent(s,t={}){this.dispatchEvent(new CustomEvent(s,{bubbles:!0,composed:!0,detail:t}))}_setState(s,t){this._state={loading:s==="loading",success:s==="success",error:s==="error"?t||!0:!1}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{if(!this._storeDomain)throw new Error("Missing store domain - cannot continue.");const s={store:this._storeDomain},t=`query StoreByDomain($store: String!) {
|
|
153
163
|
store(store: $store) {
|
|
154
164
|
store
|
|
155
165
|
productId
|
|
@@ -157,101 +167,4 @@ let ShipAidWidget = class extends LitElement {
|
|
|
157
167
|
productVariantNumericId
|
|
158
168
|
productPrice
|
|
159
169
|
}
|
|
160
|
-
}
|
|
161
|
-
const { data } = await this._fetch.post("http://localhost:1337/v1/graphql", { query, variables });
|
|
162
|
-
if (!data.store)
|
|
163
|
-
throw new Error(`Could not find a store for ${this._storeDomain}`);
|
|
164
|
-
if (!data.store.productVariantNumericId)
|
|
165
|
-
throw new Error("Missing variant ID for ShipAid product.");
|
|
166
|
-
return data.store;
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.error(error);
|
|
169
|
-
throw new Error(`Could not find a store for ${this._storeDomain}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
async _fetchCart() {
|
|
173
|
-
try {
|
|
174
|
-
const cart = await this._fetch.get("/cart.js");
|
|
175
|
-
return cart;
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.error(error);
|
|
178
|
-
throw new Error("Could not fetch cart for current domain.");
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
hasProtection() {
|
|
182
|
-
return this._hasProtectionInCart;
|
|
183
|
-
}
|
|
184
|
-
async addProtection() {
|
|
185
|
-
var _a, _b;
|
|
186
|
-
try {
|
|
187
|
-
if (!((_a = this._store) == null ? void 0 : _a.productVariantNumericId))
|
|
188
|
-
throw new Error("Store has not been loaded.");
|
|
189
|
-
if (!((_b = this._cart) == null ? void 0 : _b.items))
|
|
190
|
-
throw new Error("Cart has not been loaded.");
|
|
191
|
-
this._setState("loading");
|
|
192
|
-
const payload = {
|
|
193
|
-
id: this._store.productVariantNumericId,
|
|
194
|
-
quantity: 1
|
|
195
|
-
};
|
|
196
|
-
const cartItem = await this._fetch.post("/cart/add.js", payload);
|
|
197
|
-
const updatedCart = __spreadProps(__spreadValues({}, this._cart), {
|
|
198
|
-
items: [cartItem, ...this._cart.items]
|
|
199
|
-
});
|
|
200
|
-
this._cart = updatedCart;
|
|
201
|
-
this._setState("success");
|
|
202
|
-
this._dispatchEvent("shipaid-protection-status", { protection: true, cart: updatedCart, lineItem: cartItem });
|
|
203
|
-
} catch (err) {
|
|
204
|
-
const error = err;
|
|
205
|
-
console.error(error);
|
|
206
|
-
this._setState("error", "Failed to add protection to cart - please try again, or contact us for help.");
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
async removeProtection() {
|
|
210
|
-
var _a;
|
|
211
|
-
try {
|
|
212
|
-
if (!((_a = this._store) == null ? void 0 : _a.productVariantNumericId))
|
|
213
|
-
throw new Error("Store has not been loaded.");
|
|
214
|
-
if (!this._protectionProduct)
|
|
215
|
-
throw new Error("Protection product not found.");
|
|
216
|
-
this._setState("loading");
|
|
217
|
-
const payload = {
|
|
218
|
-
id: this._protectionProduct.key,
|
|
219
|
-
quantity: 0
|
|
220
|
-
};
|
|
221
|
-
const cart = await this._fetch.post("/cart/change.js", payload);
|
|
222
|
-
this._dispatchEvent("shipaid-protection-status", { protection: false, cart, lineItem: this._protectionProduct });
|
|
223
|
-
this._cart = cart;
|
|
224
|
-
this._setState("success");
|
|
225
|
-
} catch (err) {
|
|
226
|
-
const error = err;
|
|
227
|
-
console.error(error);
|
|
228
|
-
this._setState("error", "Failed to add protection to cart - please try again, or contact us for help.");
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
ShipAidWidget.styles = styles;
|
|
233
|
-
__decorateClass([
|
|
234
|
-
state()
|
|
235
|
-
], ShipAidWidget.prototype, "_storeDomain", 2);
|
|
236
|
-
__decorateClass([
|
|
237
|
-
state()
|
|
238
|
-
], ShipAidWidget.prototype, "_store", 2);
|
|
239
|
-
__decorateClass([
|
|
240
|
-
state()
|
|
241
|
-
], ShipAidWidget.prototype, "_cart", 2);
|
|
242
|
-
__decorateClass([
|
|
243
|
-
state()
|
|
244
|
-
], ShipAidWidget.prototype, "_hasFinishedSetup", 2);
|
|
245
|
-
__decorateClass([
|
|
246
|
-
state()
|
|
247
|
-
], ShipAidWidget.prototype, "_hasProtectionInCart", 2);
|
|
248
|
-
__decorateClass([
|
|
249
|
-
state()
|
|
250
|
-
], ShipAidWidget.prototype, "_protectionProduct", 2);
|
|
251
|
-
__decorateClass([
|
|
252
|
-
state()
|
|
253
|
-
], ShipAidWidget.prototype, "_state", 2);
|
|
254
|
-
ShipAidWidget = __decorateClass([
|
|
255
|
-
customElement("shipaid-widget")
|
|
256
|
-
], ShipAidWidget);
|
|
257
|
-
export { ShipAidWidget };
|
|
170
|
+
}`,{data:e}=await this._fetch.post("http://localhost:1337/v1/graphql",{query:t,variables:s});if(!e.store)throw new Error(`Could not find a store for ${this._storeDomain}`);if(!e.store.productVariantNumericId)throw new Error("Missing variant ID for ShipAid product.");return e.store}catch(s){throw console.error(s),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(s){throw console.error(s),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async addProtection(){var s,t;try{if(!((s=this._store)!=null&&s.productVariantNumericId))throw new Error("Store has not been loaded.");if(!((t=this._cart)!=null&&t.items))throw new Error("Cart has not been loaded.");this._setState("loading");const e={id:this._store.productVariantNumericId,quantity:1},i=await this._fetch.post("/cart/add.js",e),o=P(C({},this._cart),{items:[i,...this._cart.items]});this._cart=o,this._setState("success"),this._dispatchEvent("shipaid-protection-status",{protection:!0,cart:o,lineItem:i})}catch(e){console.error(e),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var s;try{if(!((s=this._store)!=null&&s.productVariantNumericId))throw new Error("Store has not been loaded.");if(!this._protectionProduct)throw new Error("Protection product not found.");this._setState("loading");const t={id:this._protectionProduct.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);this._dispatchEvent("shipaid-protection-status",{protection:!1,cart:e,lineItem:this._protectionProduct}),this._cart=e,this._setState("success")}catch(t){console.error(t),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}};f.styles=Vt,$([g()],f.prototype,"_storeDomain",2),$([g()],f.prototype,"_store",2),$([g()],f.prototype,"_cart",2),$([g()],f.prototype,"_hasFinishedSetup",2),$([g()],f.prototype,"_hasProtectionInCart",2),$([g()],f.prototype,"_protectionProduct",2),$([g()],f.prototype,"_state",2),f=$([gt("shipaid-widget")],f);export{f as ShipAidWidget};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var Wt=Object.defineProperty,Vt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,ft=(t,e,i)=>e in t?Wt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,M=(t,e)=>{for(var i in e||(e={}))qt.call(e,i)&&ft(t,i,e[i]);if(vt)for(var i of vt(e))Ft.call(e,i)&&ft(t,i,e[i]);return t},k=(t,e)=>Vt(t,Bt(e)),ShipAidWidget=function(t){"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2017 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/const e=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?k(M({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
function i(t){return function(t){return(i,s)=>{return void 0!==s?(r=t,o=s,void i.constructor.createProperty(o,r)):e(t,i);var r,o}}(k(M({},t),{state:!0}))}
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2021 Google LLC
|
|
21
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
+
*/var s;null===(s=window.HTMLSlotElement)||void 0===s||s.prototype.assignedElements;
|
|
23
|
+
/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright 2019 Google LLC
|
|
26
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
+
*/
|
|
28
|
+
const r=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o=Symbol(),n=new Map;class a{constructor(t,e){if(this._$cssResult$=!0,e!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=n.get(this.cssText);return r&&void 0===t&&(n.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const h=r?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",o))(e)})(t):t
|
|
29
|
+
/**
|
|
30
|
+
* @license
|
|
31
|
+
* Copyright 2017 Google LLC
|
|
32
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
+
*/;var l;const d=window.trustedTypes,p=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,u={toAttribute(t,e){switch(e){case Boolean:t=t?p: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{i=null}}return i}},v=(t,e)=>e!==t&&(e==e||t==t),f={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:v};class _ extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Eh(i,e);void 0!==s&&(this._$Eu.set(s,i),t.push(s))})),t}static createProperty(t,e=f){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,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const r=this[t];this[e]=s,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||f}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._$Eu=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(h(t))}else void 0!==t&&e.push(h(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Eg)&&void 0!==e?e:this._$Eg=[]).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._$Eg)||void 0===e||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.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)=>{r?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),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._$Eg)||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._$Eg)||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)}_$ES(t,e,i=f){var s,r;const o=this.constructor._$Eh(t,i);if(void 0!==o&&!0===i.reflect){const n=(null!==(r=null===(s=i.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==r?r:u.toAttribute)(e,i.type);this._$Ei=t,null==n?this.removeAttribute(o):this.setAttribute(o,n),this._$Ei=null}}_$AK(t,e){var i,s,r;const o=this.constructor,n=o._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=o.getPropertyOptions(n),a=t.converter,h=null!==(r=null!==(s=null===(i=a)||void 0===i?void 0:i.fromAttribute)&&void 0!==s?s:"function"==typeof a?a:null)&&void 0!==r?r:u.fromAttribute;this._$Ei=n,this[n]=h(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||v)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}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._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Eg)||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._$EU()}catch(s){throw e=!1,this._$EU(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Eg)||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)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$ES(e,this[e],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2017 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
+
*/
|
|
39
|
+
var m;_.finalized=!0,_.elementProperties=new Map,_.elementStyles=[],_.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:_}),(null!==(l=globalThis.reactiveElementVersions)&&void 0!==l?l:globalThis.reactiveElementVersions=[]).push("1.3.0");const g=globalThis.trustedTypes,$=g?g.createPolicy("lit-html",{createHTML:t=>t}):void 0,y=`lit$${(Math.random()+"").slice(9)}$`,A="?"+y,b=`<${A}>`,w=document,S=(t="")=>w.createComment(t),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,x=Array.isArray,P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,C=/-->/g,U=/>/g,O=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,T=/'/g,N=/"/g,H=/^(?:script|style|textarea|title)$/i,I=(L=1,(t,...e)=>({_$litType$:L,strings:t,values:e})),D=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),j=new WeakMap,z=w.createTreeWalker(w,129,null,!1);var L;class W{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const n=t.length-1,a=this.parts,[h,l]=((t,e)=>{const i=t.length-1,s=[];let r,o=2===e?"<svg>":"",n=P;for(let h=0;h<i;h++){const e=t[h];let i,a,l=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===P?"!--"===a[1]?n=C:void 0!==a[1]?n=U:void 0!==a[2]?(H.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=O):void 0!==a[3]&&(n=O):n===O?">"===a[0]?(n=null!=r?r:P,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?O:'"'===a[3]?N:T):n===N||n===T?n=O:n===C||n===U?n=P:(n=O,r=void 0);const p=n===O&&t[h+1].startsWith("/>")?" ":"";o+=n===P?e+b:l>=0?(s.push(i),e.slice(0,l)+"$lit$"+e.slice(l)+y+p):e+y+(-2===l?(s.push(void 0),h):p)}const a=o+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==$?$.createHTML(a):a,s]})(t,e);if(this.el=W.createElement(h,i),z.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=z.nextNode())&&a.length<n;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const e of s.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(y)){const i=l[o++];if(t.push(e),void 0!==i){const t=s.getAttribute(i.toLowerCase()+"$lit$").split(y),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?J:"?"===e[1]?Z:"@"===e[1]?G:F})}else a.push({type:6,index:r})}for(const e of t)s.removeAttribute(e)}if(H.test(s.tagName)){const t=s.textContent.split(y),e=t.length-1;if(e>0){s.textContent=g?g.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],S()),z.nextNode(),a.push({type:2,index:++r});s.append(t[e],S())}}}else if(8===s.nodeType)if(s.data===A)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=s.data.indexOf(y,t+1));)a.push({type:7,index:r}),t+=y.length-1}r++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function B(t,e,i=t,s){var r,o,n,a;if(e===D)return e;let h=void 0!==s?null===(r=i._$Cl)||void 0===r?void 0:r[s]:i._$Cu;const l=E(e)?void 0:e._$litDirective$;return(null==h?void 0:h.constructor)!==l&&(null===(o=null==h?void 0:h._$AO)||void 0===o||o.call(h,!1),void 0===l?h=void 0:(h=new l(t),h._$AT(t,i,s)),void 0!==s?(null!==(n=(a=i)._$Cl)&&void 0!==n?n:a._$Cl=[])[s]=h:i._$Cu=h),void 0!==h&&(e=B(t,h._$AS(t,e.values),h,s)),e}class V{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:s}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:w).importNode(i,!0);z.currentNode=r;let o=z.nextNode(),n=0,a=0,h=s[0];for(;void 0!==h;){if(n===h.index){let e;2===h.type?e=new q(o,o.nextSibling,this,t):1===h.type?e=new h.ctor(o,h.name,h.strings,this,t):6===h.type&&(e=new Q(o,this,t)),this.v.push(e),h=s[++a]}n!==(null==h?void 0:h.index)&&(o=z.nextNode(),n++)}return r}m(t){let e=0;for(const i of this.v)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class q{constructor(t,e,i,s){var r;this.type=2,this._$AH=R,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cg=null===(r=null==s?void 0:s.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._$Cg}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=B(this,t,e),E(t)?t===R||null==t||""===t?(this._$AH!==R&&this._$AR(),this._$AH=R):t!==this._$AH&&t!==D&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var e;return x(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(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!==R&&E(this._$AH)?this._$AA.nextSibling.data=t:this.k(w.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=W.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.m(i);else{const t=new V(r,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=j.get(t.strings);return void 0===e&&j.set(t.strings,e=new W(t)),e}S(t){x(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new q(this.A(S()),this.A(S()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$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._$Cg=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class F{constructor(t,e,i,s,r){this.type=1,this._$AH=R,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=R}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(void 0===r)t=B(this,t,e,0),o=!E(t)||t!==this._$AH&&t!==D,o&&(this._$AH=t);else{const s=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=B(this,s[i+n],e,n),a===D&&(a=this._$AH[n]),o||(o=!E(a)||a!==this._$AH[n]),a===R?t=R:t!==R&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}o&&!s&&this.C(t)}C(t){t===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class J extends F{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===R?void 0:t}}const K=g?g.emptyScript:"";class Z extends F{constructor(){super(...arguments),this.type=4}C(t){t&&t!==R?this.element.setAttribute(this.name,K):this.element.removeAttribute(this.name)}}class G extends F{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=B(this,t,e,0))&&void 0!==i?i:R)===D)return;const s=this._$AH,r=t===R&&s!==R||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==R&&(s===R||r);r&&this.element.removeEventListener(this.name,this,s),o&&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 Q{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){B(this,t)}}const X=window.litHtmlPolyfillSupport;
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2017 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
+
*/
|
|
45
|
+
var Y,tt;null==X||X(W,q),(null!==(m=globalThis.litHtmlVersions)&&void 0!==m?m:globalThis.litHtmlVersions=[]).push("2.2.0");class et extends _{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,e,i)=>{var s,r;const o=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let n=o._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;o._$litPart$=n=new q(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return D}}et.finalized=!0,et._$litElement$=!0,null===(Y=globalThis.litElementHydrateSupport)||void 0===Y||Y.call(globalThis,{LitElement:et});const it=globalThis.litElementPolyfillSupport;null==it||it({LitElement:et}),(null!==(tt=globalThis.litElementVersions)&&void 0!==tt?tt:globalThis.litElementVersions=[]).push("3.2.0");const st="__registered_effects";function rt(t){const e=t;if(e[st])return e;const i=function(t){if(!t.dispatchEvent||!t.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return t}(t),s=i.updated;return e[st]={index:0,count:0,effects:[]},i.updated=t=>(e[st].index=0,s(t)),e}function ot(t,e,i){const s=function(t,e){const i=rt(t),{index:s,count:r}=i[st];return s===r?(i[st].index++,i[st].count++,i[st].effects.push(e),e):(i[st].index++,i[st].effects[s])}(t,{on:e,observe:["__initial__dirty"]});s.observe.some(((t,e)=>i[e]!==t))&&s.on(),s.observe=i}var nt=Object.defineProperty,at=Object.getOwnPropertyDescriptor,ht=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?at(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&nt(e,i,o),o},lt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(lt||{});const dt=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 et{constructor(){var t;super(...arguments),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._fetch={get:t=>dt(t),post:(t,e)=>dt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t,e;((t,e)=>{ot(t,e,[]);
|
|
46
|
+
/**
|
|
47
|
+
* @license
|
|
48
|
+
* Copyright 2021 Google LLC
|
|
49
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
+
*/})(this,(async()=>{var t,e;const[i,s]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=i,this._cart=s;const r=null!=(e=null==(t=s.items)?void 0:t.some((t=>t.variant_id===i.productVariantNumericId)))&&e;this._hasProtectionInCart=r,this._hasFinishedSetup=!0,this._dispatchEvent("shipaid-loaded",i)})),ot(this,(()=>{var t,e,i,s;if(null==(t=this._cart)||!t.items)return;const r=null==(i=null==(e=this._cart)?void 0:e.items)?void 0:i.findIndex((t=>{var e;return t.variant_id===(null==(e=this._store)?void 0:e.productVariantNumericId)})),o=null==(s=this._cart)?void 0:s.items[r];this._hasProtectionInCart=!!o,o&&(this._protectionProduct=k(M({},o),{index:r,position:r+1}))}),[this._store,this._cart]);const i=I`
|
|
51
|
+
<div class="shipaid-prompt">
|
|
52
|
+
<p class="prompt-title">${this._hasProtectionInCart?"Active":"Inactive"}</p>
|
|
53
|
+
<div class="prompt-product">
|
|
54
|
+
<!-- <div class="prompt-product-image">
|
|
55
|
+
<img src="" alt="ShipAid logo" />
|
|
56
|
+
</div> -->
|
|
57
|
+
<div class="prompt-product-details">
|
|
58
|
+
<p class="prompt-product-details-title">Instant Package Protection</p>
|
|
59
|
+
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="prompt-product-actions">
|
|
62
|
+
<p class="prompt-product-actions-price">${(t=>{var e,i,s,r,o;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:null!=(o=null==(r=null==(s=window.Shopify)?void 0:s.currency)?void 0:r.active)?o:"USD",style:"currency"}).format(t)})(null!=(e=null==(t=this._store)?void 0:t.productPrice)?e:0)}</p>
|
|
63
|
+
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
64
|
+
${this._state.loading?"Loading...":this._hasProtectionInCart?"Remove":"+ Add"}
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="prompt-footer">
|
|
69
|
+
<b class="prompt-footer-about" href="/">Learn More</b>
|
|
70
|
+
<a class="prompt-footer-badge" href="/">
|
|
71
|
+
<span>Powered by</span>
|
|
72
|
+
<span class="ship">Ship</span>
|
|
73
|
+
<span class="aid">Aid</span>
|
|
74
|
+
</a>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`;return I`
|
|
78
|
+
${function(t,e,i){return t?e():null==i?void 0:i()}(this._hasFinishedSetup&&this._store,(()=>i),(()=>I`<p>Loading...</p>`))}
|
|
79
|
+
`}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_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(){try{if(!this._storeDomain)throw new Error("Missing store domain - cannot continue.");const t={store:this._storeDomain},e="query StoreByDomain($store: String!) {\n store(store: $store) {\n store\n productId\n productVariantId\n productVariantNumericId\n productPrice\n }\n }",{data:i}=await this._fetch.post("http://localhost:1337/v1/graphql",{query:e,variables:t});if(!i.store)throw new Error(`Could not find a store for ${this._storeDomain}`);if(!i.store.productVariantNumericId)throw new Error("Missing variant ID for ShipAid product.");return i.store}catch(L){throw console.error(L),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(L){throw console.error(L),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async addProtection(){var t,e;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(null==(e=this._cart)||!e.items)throw new Error("Cart has not been loaded.");this._setState("loading");const i={id:this._store.productVariantNumericId,quantity:1},s=await this._fetch.post("/cart/add.js",i),r=k(M({},this._cart),{items:[s,...this._cart.items]});this._cart=r,this._setState("success"),this._dispatchEvent("shipaid-protection-status",{protection:!0,cart:r,lineItem:s})}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 t;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(!this._protectionProduct)throw new Error("Protection product not found.");this._setState("loading");const e={id:this._protectionProduct.key,quantity:0},i=await this._fetch.post("/cart/change.js",e);this._dispatchEvent("shipaid-protection-status",{protection:!1,cart:i,lineItem:this._protectionProduct}),this._cart=i,this._setState("success")}catch(e){console.error(e),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}},t.ShipAidWidget.styles='.shipaid-prompt {\n --shipaid-primary: #002bd6;\n --shipaid-secondary: #0076ff;\n --shipaid-text: #000000;\n --shipaid-text-muted: #cccccc;\n --shipaid-text-grey: #aaaaaa;\n --shipaid-light-grey: #ebecf0;\n --shipaid-font: "Lato", sans-serif;\n --shipaid-font-sm: 14px;\n --shipaid-font-base: 16px;\n --shipaid-font-lg: 18px;\n --shipaid-font-regular: 400;\n --shipaid-font-heavy: 700;\n width: 400px;\n font-family: var(--shipaid-font);\n font-size: var(--shipaid-font-base);\n color: var(--shipaid-text);\n display: flex;\n flex-direction: column;\n gap: 1rem;\n margin: 2rem 0 2rem auto;\n}\n.shipaid-prompt p, .shipaid-prompt a {\n margin: 0;\n line-height: 1;\n}\n.shipaid-prompt .prompt-title {\n text-align: center;\n font-size: var(--shipaid-font-lg);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-product {\n display: flex;\n flex-direction: row;\n gap: 2rem;\n height: 55px;\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-title {\n font-size: var(--shipaid-font-base);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-description {\n font-size: var(--shipaid-font-sm);\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-product .prompt-product-actions {\n margin-left: auto;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n text-align: right;\n}\n.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-price {\n color: var(--shipaid-text-muted);\n font-size: var(--shipaid-font-base);\n}\n.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-button {\n background-color: transparent;\n border: none;\n color: var(--shipaid-primary);\n text-transform: uppercase;\n font-weight: var(--shipaid-font-heavy);\n cursor: pointer;\n}\n.shipaid-prompt .prompt-footer {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-footer .prompt-footer-about {\n color: var(--shipaid-text-grey);\n cursor: pointer;\n text-decoration: underline;\n font-size: var(--shipaid-font-sm);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge {\n background-color: var(--shipaid-light-grey);\n color: var(--shipaid-text);\n padding: 0.5rem 1.5rem;\n border-radius: 30px;\n cursor: pointer;\n text-decoration: none;\n font-size: var(--shipaid-font-sm);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge .ship {\n text-transform: uppercase;\n color: var(--shipaid-secondary);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge .aid {\n text-transform: uppercase;\n color: var(--shipaid-text-grey);\n font-weight: var(--shipaid-font-heavy);\n}',ht([i()],t.ShipAidWidget.prototype,"_storeDomain",2),ht([i()],t.ShipAidWidget.prototype,"_store",2),ht([i()],t.ShipAidWidget.prototype,"_cart",2),ht([i()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),ht([i()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),ht([i()],t.ShipAidWidget.prototype,"_protectionProduct",2),ht([i()],t.ShipAidWidget.prototype,"_state",2),t.ShipAidWidget=ht([(t=>e=>{return"function"==typeof e?(i=t,s=e,window.customElements.define(i,s),s):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})(t,e);var i,s})("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var Wt=Object.defineProperty,Vt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,vt=(t,e,i)=>e in t?Wt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,M=(t,e)=>{for(var i in e||(e={}))qt.call(e,i)&&vt(t,i,e[i]);if(ft)for(var i of ft(e))Ft.call(e,i)&&vt(t,i,e[i]);return t},k=(t,e)=>Vt(t,Bt(e));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShipAidWidget={})}(this,(function(t){"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2017 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/const e=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?k(M({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2017 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
function i(t){return function(t){return(i,s)=>{return void 0!==s?(o=t,r=s,void i.constructor.createProperty(r,o)):e(t,i);var o,r}}(k(M({},t),{state:!0}))}
|
|
18
|
+
/**
|
|
19
|
+
* @license
|
|
20
|
+
* Copyright 2021 Google LLC
|
|
21
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
+
*/var s;null===(s=window.HTMLSlotElement)||void 0===s||s.prototype.assignedElements;
|
|
23
|
+
/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright 2019 Google LLC
|
|
26
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
+
*/
|
|
28
|
+
const o=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),n=new Map;class a{constructor(t,e){if(this._$cssResult$=!0,e!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=n.get(this.cssText);return o&&void 0===t&&(n.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const l=o?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",r))(e)})(t):t
|
|
29
|
+
/**
|
|
30
|
+
* @license
|
|
31
|
+
* Copyright 2017 Google LLC
|
|
32
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
+
*/;var h;const d=window.trustedTypes,p=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,u={toAttribute(t,e){switch(e){case Boolean:t=t?p: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{i=null}}return i}},v=(t,e)=>e!==t&&(e==e||t==t),f={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:v};class m extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Eh(i,e);void 0!==s&&(this._$Eu.set(s,i),t.push(s))})),t}static createProperty(t,e=f){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,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||f}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._$Eu=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(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Eg)&&void 0!==e?e:this._$Eg=[]).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._$Eg)||void 0===e||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.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)=>{o?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),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._$Eg)||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._$Eg)||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)}_$ES(t,e,i=f){var s,o;const r=this.constructor._$Eh(t,i);if(void 0!==r&&!0===i.reflect){const n=(null!==(o=null===(s=i.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:u.toAttribute)(e,i.type);this._$Ei=t,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$Ei=null}}_$AK(t,e){var i,s,o;const r=this.constructor,n=r._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=r.getPropertyOptions(n),a=t.converter,l=null!==(o=null!==(s=null===(i=a)||void 0===i?void 0:i.fromAttribute)&&void 0!==s?s:"function"==typeof a?a:null)&&void 0!==o?o:u.fromAttribute;this._$Ei=n,this[n]=l(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||v)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}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._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Eg)||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._$EU()}catch(s){throw e=!1,this._$EU(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Eg)||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)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$ES(e,this[e],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2017 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
|
+
*/
|
|
39
|
+
var _;m.finalized=!0,m.elementProperties=new Map,m.elementStyles=[],m.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:m}),(null!==(h=globalThis.reactiveElementVersions)&&void 0!==h?h:globalThis.reactiveElementVersions=[]).push("1.3.0");const g=globalThis.trustedTypes,y=g?g.createPolicy("lit-html",{createHTML:t=>t}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,A="?"+$,b=`<${A}>`,w=document,S=(t="")=>w.createComment(t),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,x=Array.isArray,P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,C=/-->/g,U=/>/g,T=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,O=/'/g,N=/"/g,H=/^(?:script|style|textarea|title)$/i,I=(L=1,(t,...e)=>({_$litType$:L,strings:t,values:e})),D=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),j=new WeakMap,z=w.createTreeWalker(w,129,null,!1);var L;class W{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,r=0;const n=t.length-1,a=this.parts,[l,h]=((t,e)=>{const i=t.length-1,s=[];let o,r=2===e?"<svg>":"",n=P;for(let l=0;l<i;l++){const e=t[l];let i,a,h=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===P?"!--"===a[1]?n=C:void 0!==a[1]?n=U:void 0!==a[2]?(H.test(a[2])&&(o=RegExp("</"+a[2],"g")),n=T):void 0!==a[3]&&(n=T):n===T?">"===a[0]?(n=null!=o?o:P,h=-1):void 0===a[1]?h=-2:(h=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?T:'"'===a[3]?N:O):n===N||n===O?n=T:n===C||n===U?n=P:(n=T,o=void 0);const p=n===T&&t[l+1].startsWith("/>")?" ":"";r+=n===P?e+b:h>=0?(s.push(i),e.slice(0,h)+"$lit$"+e.slice(h)+$+p):e+$+(-2===h?(s.push(void 0),l):p)}const a=r+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==y?y.createHTML(a):a,s]})(t,e);if(this.el=W.createElement(l,i),z.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=z.nextNode())&&a.length<n;){if(1===s.nodeType){if(s.hasAttributes()){const t=[];for(const e of s.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith($)){const i=h[r++];if(t.push(e),void 0!==i){const t=s.getAttribute(i.toLowerCase()+"$lit$").split($),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:o,name:e[2],strings:t,ctor:"."===e[1]?J:"?"===e[1]?Z:"@"===e[1]?G:F})}else a.push({type:6,index:o})}for(const e of t)s.removeAttribute(e)}if(H.test(s.tagName)){const t=s.textContent.split($),e=t.length-1;if(e>0){s.textContent=g?g.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],S()),z.nextNode(),a.push({type:2,index:++o});s.append(t[e],S())}}}else if(8===s.nodeType)if(s.data===A)a.push({type:2,index:o});else{let t=-1;for(;-1!==(t=s.data.indexOf($,t+1));)a.push({type:7,index:o}),t+=$.length-1}o++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function B(t,e,i=t,s){var o,r,n,a;if(e===D)return e;let l=void 0!==s?null===(o=i._$Cl)||void 0===o?void 0:o[s]:i._$Cu;const h=E(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==h&&(null===(r=null==l?void 0:l._$AO)||void 0===r||r.call(l,!1),void 0===h?l=void 0:(l=new h(t),l._$AT(t,i,s)),void 0!==s?(null!==(n=(a=i)._$Cl)&&void 0!==n?n:a._$Cl=[])[s]=l:i._$Cu=l),void 0!==l&&(e=B(t,l._$AS(t,e.values),l,s)),e}class V{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:s}=this._$AD,o=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:w).importNode(i,!0);z.currentNode=o;let r=z.nextNode(),n=0,a=0,l=s[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new q(r,r.nextSibling,this,t):1===l.type?e=new l.ctor(r,l.name,l.strings,this,t):6===l.type&&(e=new Q(r,this,t)),this.v.push(e),l=s[++a]}n!==(null==l?void 0:l.index)&&(r=z.nextNode(),n++)}return o}m(t){let e=0;for(const i of this.v)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class q{constructor(t,e,i,s){var o;this.type=2,this._$AH=R,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cg=null===(o=null==s?void 0:s.isConnected)||void 0===o||o}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cg}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=B(this,t,e),E(t)?t===R||null==t||""===t?(this._$AH!==R&&this._$AR(),this._$AH=R):t!==this._$AH&&t!==D&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var e;return x(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(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!==R&&E(this._$AH)?this._$AA.nextSibling.data=t:this.k(w.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=W.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.m(i);else{const t=new V(o,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=j.get(t.strings);return void 0===e&&j.set(t.strings,e=new W(t)),e}S(t){x(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new q(this.A(S()),this.A(S()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$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._$Cg=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class F{constructor(t,e,i,s,o){this.type=1,this._$AH=R,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=R}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let r=!1;if(void 0===o)t=B(this,t,e,0),r=!E(t)||t!==this._$AH&&t!==D,r&&(this._$AH=t);else{const s=t;let n,a;for(t=o[0],n=0;n<o.length-1;n++)a=B(this,s[i+n],e,n),a===D&&(a=this._$AH[n]),r||(r=!E(a)||a!==this._$AH[n]),a===R?t=R:t!==R&&(t+=(null!=a?a:"")+o[n+1]),this._$AH[n]=a}r&&!s&&this.C(t)}C(t){t===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class J extends F{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===R?void 0:t}}const K=g?g.emptyScript:"";class Z extends F{constructor(){super(...arguments),this.type=4}C(t){t&&t!==R?this.element.setAttribute(this.name,K):this.element.removeAttribute(this.name)}}class G extends F{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=B(this,t,e,0))&&void 0!==i?i:R)===D)return;const s=this._$AH,o=t===R&&s!==R||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==R&&(s===R||o);o&&this.element.removeEventListener(this.name,this,s),r&&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 Q{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){B(this,t)}}const X=window.litHtmlPolyfillSupport;
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2017 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
+
*/
|
|
45
|
+
var Y,tt;null==X||X(W,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:globalThis.litHtmlVersions=[]).push("2.2.0");class et extends m{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,e,i)=>{var s,o;const r=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let n=r._$litPart$;if(void 0===n){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;r._$litPart$=n=new q(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return D}}et.finalized=!0,et._$litElement$=!0,null===(Y=globalThis.litElementHydrateSupport)||void 0===Y||Y.call(globalThis,{LitElement:et});const it=globalThis.litElementPolyfillSupport;null==it||it({LitElement:et}),(null!==(tt=globalThis.litElementVersions)&&void 0!==tt?tt:globalThis.litElementVersions=[]).push("3.2.0");const st="__registered_effects";function ot(t){const e=t;if(e[st])return e;const i=function(t){if(!t.dispatchEvent||!t.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return t}(t),s=i.updated;return e[st]={index:0,count:0,effects:[]},i.updated=t=>(e[st].index=0,s(t)),e}function rt(t,e,i){const s=function(t,e){const i=ot(t),{index:s,count:o}=i[st];return s===o?(i[st].index++,i[st].count++,i[st].effects.push(e),e):(i[st].index++,i[st].effects[s])}(t,{on:e,observe:["__initial__dirty"]});s.observe.some(((t,e)=>i[e]!==t))&&s.on(),s.observe=i}var nt=Object.defineProperty,at=Object.getOwnPropertyDescriptor,lt=(t,e,i,s)=>{for(var o,r=s>1?void 0:s?at(e,i):e,n=t.length-1;n>=0;n--)(o=t[n])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&nt(e,i,r),r},ht=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(ht||{});const dt=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 et{constructor(){var t;super(...arguments),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._fetch={get:t=>dt(t),post:(t,e)=>dt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t,e;((t,e)=>{rt(t,e,[]);
|
|
46
|
+
/**
|
|
47
|
+
* @license
|
|
48
|
+
* Copyright 2021 Google LLC
|
|
49
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
+
*/})(this,(async()=>{var t,e;const[i,s]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=i,this._cart=s;const o=null!=(e=null==(t=s.items)?void 0:t.some((t=>t.variant_id===i.productVariantNumericId)))&&e;this._hasProtectionInCart=o,this._hasFinishedSetup=!0,this._dispatchEvent("shipaid-loaded",i)})),rt(this,(()=>{var t,e,i,s;if(null==(t=this._cart)||!t.items)return;const o=null==(i=null==(e=this._cart)?void 0:e.items)?void 0:i.findIndex((t=>{var e;return t.variant_id===(null==(e=this._store)?void 0:e.productVariantNumericId)})),r=null==(s=this._cart)?void 0:s.items[o];this._hasProtectionInCart=!!r,r&&(this._protectionProduct=k(M({},r),{index:o,position:o+1}))}),[this._store,this._cart]);const i=I`
|
|
51
|
+
<div class="shipaid-prompt">
|
|
52
|
+
<p class="prompt-title">${this._hasProtectionInCart?"Active":"Inactive"}</p>
|
|
53
|
+
<div class="prompt-product">
|
|
54
|
+
<!-- <div class="prompt-product-image">
|
|
55
|
+
<img src="" alt="ShipAid logo" />
|
|
56
|
+
</div> -->
|
|
57
|
+
<div class="prompt-product-details">
|
|
58
|
+
<p class="prompt-product-details-title">Instant Package Protection</p>
|
|
59
|
+
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="prompt-product-actions">
|
|
62
|
+
<p class="prompt-product-actions-price">${(t=>{var e,i,s,o,r;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:null!=(r=null==(o=null==(s=window.Shopify)?void 0:s.currency)?void 0:o.active)?r:"USD",style:"currency"}).format(t)})(null!=(e=null==(t=this._store)?void 0:t.productPrice)?e:0)}</p>
|
|
63
|
+
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
64
|
+
${this._state.loading?"Loading...":this._hasProtectionInCart?"Remove":"+ Add"}
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="prompt-footer">
|
|
69
|
+
<b class="prompt-footer-about" href="/">Learn More</b>
|
|
70
|
+
<a class="prompt-footer-badge" href="/">
|
|
71
|
+
<span>Powered by</span>
|
|
72
|
+
<span class="ship">Ship</span>
|
|
73
|
+
<span class="aid">Aid</span>
|
|
74
|
+
</a>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`;return I`
|
|
78
|
+
${function(t,e,i){return t?e():null==i?void 0:i()}(this._hasFinishedSetup&&this._store,(()=>i),(()=>I`<p>Loading...</p>`))}
|
|
79
|
+
`}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_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(){try{if(!this._storeDomain)throw new Error("Missing store domain - cannot continue.");const t={store:this._storeDomain},e="query StoreByDomain($store: String!) {\n store(store: $store) {\n store\n productId\n productVariantId\n productVariantNumericId\n productPrice\n }\n }",{data:i}=await this._fetch.post("http://localhost:1337/v1/graphql",{query:e,variables:t});if(!i.store)throw new Error(`Could not find a store for ${this._storeDomain}`);if(!i.store.productVariantNumericId)throw new Error("Missing variant ID for ShipAid product.");return i.store}catch(L){throw console.error(L),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(L){throw console.error(L),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async addProtection(){var t,e;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(null==(e=this._cart)||!e.items)throw new Error("Cart has not been loaded.");this._setState("loading");const i={id:this._store.productVariantNumericId,quantity:1},s=await this._fetch.post("/cart/add.js",i),o=k(M({},this._cart),{items:[s,...this._cart.items]});this._cart=o,this._setState("success"),this._dispatchEvent("shipaid-protection-status",{protection:!0,cart:o,lineItem:s})}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 t;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(!this._protectionProduct)throw new Error("Protection product not found.");this._setState("loading");const e={id:this._protectionProduct.key,quantity:0},i=await this._fetch.post("/cart/change.js",e);this._dispatchEvent("shipaid-protection-status",{protection:!1,cart:i,lineItem:this._protectionProduct}),this._cart=i,this._setState("success")}catch(e){console.error(e),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}},t.ShipAidWidget.styles='.shipaid-prompt {\n --shipaid-primary: #002bd6;\n --shipaid-secondary: #0076ff;\n --shipaid-text: #000000;\n --shipaid-text-muted: #cccccc;\n --shipaid-text-grey: #aaaaaa;\n --shipaid-light-grey: #ebecf0;\n --shipaid-font: "Lato", sans-serif;\n --shipaid-font-sm: 14px;\n --shipaid-font-base: 16px;\n --shipaid-font-lg: 18px;\n --shipaid-font-regular: 400;\n --shipaid-font-heavy: 700;\n width: 400px;\n font-family: var(--shipaid-font);\n font-size: var(--shipaid-font-base);\n color: var(--shipaid-text);\n display: flex;\n flex-direction: column;\n gap: 1rem;\n margin: 2rem 0 2rem auto;\n}\n.shipaid-prompt p, .shipaid-prompt a {\n margin: 0;\n line-height: 1;\n}\n.shipaid-prompt .prompt-title {\n text-align: center;\n font-size: var(--shipaid-font-lg);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-product {\n display: flex;\n flex-direction: row;\n gap: 2rem;\n height: 55px;\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-title {\n font-size: var(--shipaid-font-base);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-product .prompt-product-details .prompt-product-details-description {\n font-size: var(--shipaid-font-sm);\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-product .prompt-product-actions {\n margin-left: auto;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n text-align: right;\n}\n.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-price {\n color: var(--shipaid-text-muted);\n font-size: var(--shipaid-font-base);\n}\n.shipaid-prompt .prompt-product .prompt-product-actions .prompt-product-actions-button {\n background-color: transparent;\n border: none;\n color: var(--shipaid-primary);\n text-transform: uppercase;\n font-weight: var(--shipaid-font-heavy);\n cursor: pointer;\n}\n.shipaid-prompt .prompt-footer {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n margin-top: 1rem;\n}\n.shipaid-prompt .prompt-footer .prompt-footer-about {\n color: var(--shipaid-text-grey);\n cursor: pointer;\n text-decoration: underline;\n font-size: var(--shipaid-font-sm);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge {\n background-color: var(--shipaid-light-grey);\n color: var(--shipaid-text);\n padding: 0.5rem 1.5rem;\n border-radius: 30px;\n cursor: pointer;\n text-decoration: none;\n font-size: var(--shipaid-font-sm);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge .ship {\n text-transform: uppercase;\n color: var(--shipaid-secondary);\n font-weight: var(--shipaid-font-heavy);\n}\n.shipaid-prompt .prompt-footer .prompt-footer-badge .aid {\n text-transform: uppercase;\n color: var(--shipaid-text-grey);\n font-weight: var(--shipaid-font-heavy);\n}',lt([i()],t.ShipAidWidget.prototype,"_storeDomain",2),lt([i()],t.ShipAidWidget.prototype,"_store",2),lt([i()],t.ShipAidWidget.prototype,"_cart",2),lt([i()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),lt([i()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),lt([i()],t.ShipAidWidget.prototype,"_protectionProduct",2),lt([i()],t.ShipAidWidget.prototype,"_state",2),t.ShipAidWidget=lt([(t=>e=>{return"function"==typeof e?(i=t,s=e,window.customElements.define(i,s),s):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})(t,e);var i,s})("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui.shipaid.com",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"main": "dist/ui.shipaid.com.
|
|
6
|
-
"unpkg": "dist/ui.shipaid.com.
|
|
4
|
+
"version": "0.0.4",
|
|
5
|
+
"main": "dist/ui.shipaid.com.umd.js",
|
|
6
|
+
"unpkg": "dist/ui.shipaid.com.iife.js",
|
|
7
7
|
"module": "dist/ui.shipaid.com.es.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./dist/ui.shipaid.com.es.js"
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"eslint-plugin-lit-a11y": "^2.2.0",
|
|
35
35
|
"eslint-plugin-node": "^11.1.0",
|
|
36
36
|
"eslint-plugin-promise": "^5.2.0",
|
|
37
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
37
38
|
"rollup-plugin-postcss-lit": "^2.0.0",
|
|
38
39
|
"sass": "^1.49.9",
|
|
39
40
|
"typescript": "^4.6.2",
|