ui.shipaid.com 0.3.97 → 0.3.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/widget.es.js +1 -1
- package/dist/widget.iife.js +1 -1
- package/dist/widget.umd.js +1 -1
- package/package.json +1 -1
package/dist/widget.es.js
CHANGED
|
@@ -3591,7 +3591,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3591
3591
|
);
|
|
3592
3592
|
}
|
|
3593
3593
|
}, 500);
|
|
3594
|
-
if (this.disablePolling) return;
|
|
3594
|
+
if (this.disablePolling || this.useShipAidCheckout) return;
|
|
3595
3595
|
setInterval(async () => {
|
|
3596
3596
|
const lastUpdated = this._cartLastUpdated;
|
|
3597
3597
|
if (lastUpdated) {
|
package/dist/widget.iife.js
CHANGED
|
@@ -1455,7 +1455,7 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
|
|
|
1455
1455
|
</a>
|
|
1456
1456
|
</div>
|
|
1457
1457
|
</div>
|
|
1458
|
-
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=vt){const i=await e.loader(t,e);e.translationCache={},bt(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const n=e(o,r);if(i)try{await t([o,r],n)}catch(a){console.warn(a)}return await n};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,n;if(null==(o=null==(i=t[1])?void 0:i.headers)?void 0:o["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const a=(null==(n=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:n.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',s=document.querySelector(a);if(console.log("q",s),s){s.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{s.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){var t,e,i,o;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const r=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),n=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t=await this.updateCartProtectionVariant(0,n);return sessionStorage.removeItem(we),await this._handleRefresh(t)}const s=this._findProtectionVariant(a);if(a?(this._protectionVariant=s,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==s?void 0:s.id))return this._shouldShowWidget=!1,void ye("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(this.useShipAidCheckout&&this.supportSubscriptions&&(this._sellingPlanId=await this.getSubscription(this._cart)),!n)return;if(this.supportSubscriptions&&!this.useShipAidCheckout){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let e=!0;if(!t&&(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=null:t&&!(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=await this.getSubscription(this._cart):e=!1,e){const t=await this.updateCartProtectionVariant(1,n);await this._handleRefresh(t)}}if(s.id===n.variant_id){if(this._protectionCartItem={...n,index:r,position:r+1},1===n.quantity)return;const t=await this.updateCartProtectionVariant(1,n);return this._handleRefreshCart(),await this._handleRefresh(t)}const d={updates:{[n.variant_id]:0,[s.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}render(){return Mt(this,(async()=>{var t,e,i,o,r,n;const a=document.createElement("link");a.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),a.setAttribute("rel","stylesheet"),document.head.appendChild(a);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(s){return ye(s.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._dispatchEvent(ue.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(we)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(we,JSON.stringify({loaded:!0}))))}),500),void(this.disablePolling||(setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(n=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:n.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(be("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Mt(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),Mt(this,(async()=>{dt(this.renderPopups(),document.body)}),[this._popup]),F`
|
|
1458
|
+
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=vt){const i=await e.loader(t,e);e.translationCache={},bt(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const n=e(o,r);if(i)try{await t([o,r],n)}catch(a){console.warn(a)}return await n};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,n;if(null==(o=null==(i=t[1])?void 0:i.headers)?void 0:o["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const a=(null==(n=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:n.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',s=document.querySelector(a);if(console.log("q",s),s){s.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{s.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){var t,e,i,o;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const r=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),n=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t=await this.updateCartProtectionVariant(0,n);return sessionStorage.removeItem(we),await this._handleRefresh(t)}const s=this._findProtectionVariant(a);if(a?(this._protectionVariant=s,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==s?void 0:s.id))return this._shouldShowWidget=!1,void ye("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(this.useShipAidCheckout&&this.supportSubscriptions&&(this._sellingPlanId=await this.getSubscription(this._cart)),!n)return;if(this.supportSubscriptions&&!this.useShipAidCheckout){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let e=!0;if(!t&&(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=null:t&&!(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=await this.getSubscription(this._cart):e=!1,e){const t=await this.updateCartProtectionVariant(1,n);await this._handleRefresh(t)}}if(s.id===n.variant_id){if(this._protectionCartItem={...n,index:r,position:r+1},1===n.quantity)return;const t=await this.updateCartProtectionVariant(1,n);return this._handleRefreshCart(),await this._handleRefresh(t)}const d={updates:{[n.variant_id]:0,[s.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}render(){return Mt(this,(async()=>{var t,e,i,o,r,n;const a=document.createElement("link");a.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),a.setAttribute("rel","stylesheet"),document.head.appendChild(a);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(s){return ye(s.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._dispatchEvent(ue.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(we)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(we,JSON.stringify({loaded:!0}))))}),500),void(this.disablePolling||this.useShipAidCheckout||(setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(n=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:n.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(be("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Mt(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),Mt(this,(async()=>{dt(this.renderPopups(),document.body)}),[this._popup]),F`
|
|
1459
1459
|
<style>
|
|
1460
1460
|
:host {
|
|
1461
1461
|
--shipaid-primary: #002bd6;
|
package/dist/widget.umd.js
CHANGED
|
@@ -1455,7 +1455,7 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
|
|
|
1455
1455
|
</a>
|
|
1456
1456
|
</div>
|
|
1457
1457
|
</div>
|
|
1458
|
-
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=vt){const i=await e.loader(t,e);e.translationCache={},bt(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const n=e(o,r);if(i)try{await t([o,r],n)}catch(a){console.warn(a)}return await n};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,n;if(null==(o=null==(i=t[1])?void 0:i.headers)?void 0:o["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const a=(null==(n=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:n.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',s=document.querySelector(a);if(console.log("q",s),s){s.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{s.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){var t,e,i,o;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const r=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),n=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t=await this.updateCartProtectionVariant(0,n);return sessionStorage.removeItem(we),await this._handleRefresh(t)}const s=this._findProtectionVariant(a);if(a?(this._protectionVariant=s,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==s?void 0:s.id))return this._shouldShowWidget=!1,void ye("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(this.useShipAidCheckout&&this.supportSubscriptions&&(this._sellingPlanId=await this.getSubscription(this._cart)),!n)return;if(this.supportSubscriptions&&!this.useShipAidCheckout){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let e=!0;if(!t&&(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=null:t&&!(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=await this.getSubscription(this._cart):e=!1,e){const t=await this.updateCartProtectionVariant(1,n);await this._handleRefresh(t)}}if(s.id===n.variant_id){if(this._protectionCartItem={...n,index:r,position:r+1},1===n.quantity)return;const t=await this.updateCartProtectionVariant(1,n);return this._handleRefreshCart(),await this._handleRefresh(t)}const d={updates:{[n.variant_id]:0,[s.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}render(){return Mt(this,(async()=>{var t,e,i,o,r,n;const a=document.createElement("link");a.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),a.setAttribute("rel","stylesheet"),document.head.appendChild(a);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(s){return ye(s.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._dispatchEvent(ue.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(we)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(we,JSON.stringify({loaded:!0}))))}),500),void(this.disablePolling||(setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(n=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:n.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(be("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Mt(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),Mt(this,(async()=>{dt(this.renderPopups(),document.body)}),[this._popup]),F`
|
|
1458
|
+
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=vt){const i=await e.loader(t,e);e.translationCache={},bt(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const n=e(o,r);if(i)try{await t([o,r],n)}catch(a){console.warn(a)}return await n};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,n;if(null==(o=null==(i=t[1])?void 0:i.headers)?void 0:o["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const a=(null==(n=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:n.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',s=document.querySelector(a);if(console.log("q",s),s){s.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{s.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){var t,e,i,o;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const r=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),n=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t=await this.updateCartProtectionVariant(0,n);return sessionStorage.removeItem(we),await this._handleRefresh(t)}const s=this._findProtectionVariant(a);if(a?(this._protectionVariant=s,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==s?void 0:s.id))return this._shouldShowWidget=!1,void ye("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(this.useShipAidCheckout&&this.supportSubscriptions&&(this._sellingPlanId=await this.getSubscription(this._cart)),!n)return;if(this.supportSubscriptions&&!this.useShipAidCheckout){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let e=!0;if(!t&&(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=null:t&&!(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=await this.getSubscription(this._cart):e=!1,e){const t=await this.updateCartProtectionVariant(1,n);await this._handleRefresh(t)}}if(s.id===n.variant_id){if(this._protectionCartItem={...n,index:r,position:r+1},1===n.quantity)return;const t=await this.updateCartProtectionVariant(1,n);return this._handleRefreshCart(),await this._handleRefresh(t)}const d={updates:{[n.variant_id]:0,[s.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}render(){return Mt(this,(async()=>{var t,e,i,o,r,n;const a=document.createElement("link");a.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),a.setAttribute("rel","stylesheet"),document.head.appendChild(a);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(s){return ye(s.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._dispatchEvent(ue.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(we)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(we,JSON.stringify({loaded:!0}))))}),500),void(this.disablePolling||this.useShipAidCheckout||(setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(n=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:n.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(be("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Mt(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),Mt(this,(async()=>{dt(this.renderPopups(),document.body)}),[this._popup]),F`
|
|
1459
1459
|
<style>
|
|
1460
1460
|
:host {
|
|
1461
1461
|
--shipaid-primary: #002bd6;
|