ui.shipaid.com 0.1.8 → 0.1.9

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.
@@ -271,7 +271,7 @@ var St=Object.defineProperty,Et=Object.defineProperties;var xt=Object.getOwnProp
271
271
  color: var(--shipaid-text-grey);
272
272
  font-weight: var(--shipaid-font-heavy);
273
273
  }
274
- `,z=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(z||{}),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 bt=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 I{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._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>bt(t),post:(t,e)=>bt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var e;Gt(this,async()=>{var r,s,n,d;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,this._shouldShowWidget=!1;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,this._shouldShowWidget=!1;return}if(!((d=(n=this._store)==null?void 0:n.protectionSettings)!=null&&d.protectionType)){console.warn("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,this._shouldShowWidget=!1;return}this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(z.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 l,h,u,g,y;if(this._cartLastUpdated=new Date,!((l=this._cart)!=null&&l.items))return;const i=await this.calculateProtectionTotal(this._cart),r=this._findProtectionVariant(i);if(this._protectionVariant=r,!(r!=null&&r.id)){this._shouldShowWidget=!1,console.error("No matching protection variant found.");return}const s=(u=(h=this._cart.items)==null?void 0:h.findIndex(Lt=>{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:F})=>{var ot;return(ot=F==null?void 0:F.id)==null?void 0:ot.includes(Lt.variant_id.toString())})}))!=null?u:[],n=(g=this._cart)==null?void 0:g.items[s];if(this._hasProtectionInCart=!!n,!n)return;if((y=r.id)!=null&&y.includes(n.id.toString())){this._protectionCartItem=b(A({},n),{index:s,position:s+1});return}const d={id:n.key,quantity:0};await this._fetch.post("/cart/change.js",d);const a={id:r.id.replace("gid://shopify/ProductVariant/",""),quantity:1},p=await this._fetch.post("/cart/add.js",a),c=b(A({},this._cart),{items:[p,...this._cart.items]});this._cart=c,this._dispatchEvent(z.STATUS_UPDATE,{protection:!0,cart:c,lineItem:p}),this.disablePolling||window.location.reload()},[this._store,this._cart]);const o=w`
274
+ `,z=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(z||{}),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 bt=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 I{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._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>bt(t),post:(t,e)=>bt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var e;Gt(this,async()=>{var r,s,n,d;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,this._shouldShowWidget=!1;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,this._shouldShowWidget=!1;return}if(!((d=(n=this._store)==null?void 0:n.protectionSettings)!=null&&d.protectionType)){console.warn("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,this._shouldShowWidget=!1;return}this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(z.LOADED,this._store),setTimeout(async()=>{var a;!this._hasProtectionInCart&&((a=this._store)==null?void 0:a.widgetAutoOptIn)&&this._store.widgetShowCart},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 l,h,u,g,y;if(this._cartLastUpdated=new Date,!((l=this._cart)!=null&&l.items))return;const i=await this.calculateProtectionTotal(this._cart),r=this._findProtectionVariant(i);if(this._protectionVariant=r,!(r!=null&&r.id)){this._shouldShowWidget=!1,console.error("No matching protection variant found.");return}const s=(u=(h=this._cart.items)==null?void 0:h.findIndex(Lt=>{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:F})=>{var ot;return(ot=F==null?void 0:F.id)==null?void 0:ot.includes(Lt.variant_id.toString())})}))!=null?u:[],n=(g=this._cart)==null?void 0:g.items[s];if(this._hasProtectionInCart=!!n,!n)return;if((y=r.id)!=null&&y.includes(n.id.toString())){this._protectionCartItem=b(A({},n),{index:s,position:s+1});return}const d={id:n.key,quantity:0};await this._fetch.post("/cart/change.js",d);const a={id:r.id.replace("gid://shopify/ProductVariant/",""),quantity:1},p=await this._fetch.post("/cart/add.js",a),c=b(A({},this._cart),{items:[p,...this._cart.items]});this._cart=c,this._dispatchEvent(z.STATUS_UPDATE,{protection:!0,cart:c,lineItem:p}),this.disablePolling||window.location.reload()},[this._store,this._cart]);const o=w`
275
275
  <div class=${`shipaid-popup ${this._popup==="learn-more"&&"active"}`}>
276
276
  <div class="popup">
277
277
  <button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
@@ -284,7 +284,7 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
284
284
  color: var(--shipaid-text-grey);
285
285
  font-weight: var(--shipaid-font-heavy);
286
286
  }
287
- `,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 Ct=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._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Ct(t),post:(t,e)=>Ct(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 this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}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._shouldShowWidget=!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."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(console.warn("No ShipAid plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))})),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)return this._shouldShowWidget=!1,void console.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`
287
+ `,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 Ct=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._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Ct(t),post:(t,e)=>Ct(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 this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}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._shouldShowWidget=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&this._store.widgetShowCart}),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."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(console.warn("No ShipAid plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))})),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)return this._shouldShowWidget=!1,void console.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
288
  <div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
289
289
  <div class="popup">
290
290
  <button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
@@ -284,7 +284,7 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
284
284
  color: var(--shipaid-text-grey);
285
285
  font-weight: var(--shipaid-font-heavy);
286
286
  }
287
- `,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 Ct=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._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Ct(t),post:(t,e)=>Ct(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 this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}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._shouldShowWidget=!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."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(console.warn("No ShipAid plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))})),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)return this._shouldShowWidget=!1,void console.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`
287
+ `,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 Ct=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._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Ct(t),post:(t,e)=>Ct(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 this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}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._shouldShowWidget=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&this._store.widgetShowCart}),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."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(console.warn("No ShipAid plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))})),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)return this._shouldShowWidget=!1,void console.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
288
  <div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
289
289
  <div class="popup">
290
290
  <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.8",
4
+ "version": "0.1.9",
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",