ui.shipaid.com 0.3.100 → 0.3.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.es.js CHANGED
@@ -1049,8 +1049,18 @@ const styles$2 = i$2`
1049
1049
  object-fit: contain;
1050
1050
  }
1051
1051
 
1052
- .shipaid-popup .popup-disclaimer-subtitle {
1053
- display: inline-flex;
1052
+
1053
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-enable{
1054
+ display: var(--shipaid-subtitle-enable, inline-flex);
1055
+ }
1056
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-monitor{
1057
+ display: var(--shipaid-subtitle-monitor, inline-flex);
1058
+ }
1059
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-notify{
1060
+ display: var(--shipaid-subtitle-notify, inline-flex);
1061
+ }
1062
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-resolution{
1063
+ display: var(--shipaid-subtitle-resolution, inline-flex);
1054
1064
  }
1055
1065
 
1056
1066
  .shipaid-popup .popup-disclaimer-subtitle p {
@@ -1488,19 +1498,19 @@ const _LearnMorePopup = class _LearnMorePopup extends s$1 {
1488
1498
  </button>
1489
1499
  <div class="popup-logo">${ShipAidLogoPopUp}</div>
1490
1500
  <p class="popup-title">${translate("learn-more-popup.title")}</p>
1491
- <div class="popup-disclaimer-subtitle">
1501
+ <div class="popup-disclaimer-subtitle subtitle-enable">
1492
1502
  <div class="popup-icon">${CheckmarkRibbon}</div>
1493
1503
  <p>${translate("learn-more-popup.disclaimer.subtitle-enable")}</p>
1494
1504
  </div>
1495
- <div class="popup-disclaimer-subtitle">
1505
+ <div class="popup-disclaimer-subtitle subtitle-monitor">
1496
1506
  <div class="popup-icon">${MapIcon}</div>
1497
1507
  <p>${translate("learn-more-popup.disclaimer.subtitle-monitor")}</p>
1498
1508
  </div>
1499
- <div class="popup-disclaimer-subtitle">
1509
+ <div class="popup-disclaimer-subtitle subtitle-notify">
1500
1510
  <div class="popup-icon-b">${BellIcon}</div>
1501
1511
  <p>${translate("learn-more-popup.disclaimer.subtitle-notify")}</p>
1502
1512
  </div>
1503
- <div class="popup-disclaimer-subtitle">
1513
+ <div class="popup-disclaimer-subtitle subtitle-resolution">
1504
1514
  <div class="popup-icon-bell">${BoxIcon}</div>
1505
1515
  <p>
1506
1516
  ${translate("learn-more-popup.disclaimer.subtitle-resolution")}
@@ -3171,7 +3181,6 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3171
3181
  display: flex;
3172
3182
  align-items: center;
3173
3183
  justify-content: space-between;
3174
- font-size: 14px;
3175
3184
  margin-bottom: 1rem;
3176
3185
  }
3177
3186
 
@@ -3180,7 +3189,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3180
3189
  display: flex;
3181
3190
  align-items: center;
3182
3191
  gap: 0.5rem;
3183
- font-size: 1.3rem;
3192
+ font-size: clamp(0.8rem, 1vw + 0.6rem, 1.4rem);
3184
3193
  }
3185
3194
 
3186
3195
  .protection-text p {
@@ -3294,7 +3303,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3294
3303
  }
3295
3304
  }
3296
3305
  promptTemplate() {
3297
- var _a, _b, _c;
3306
+ var _a, _b, _c, _d, _e;
3298
3307
  if (this.useShipAidCheckout && this.dataSelector) {
3299
3308
  return this.checkoutButtonTemplate();
3300
3309
  }
@@ -3319,16 +3328,32 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3319
3328
  )}
3320
3329
  </div>
3321
3330
  <div class="prompt-product-details">
3322
- <p class="prompt-product-details-title">
3323
- <slot name="title">${translate("title")}</slot>
3324
- </p>
3331
+ <div class="heading-container">
3332
+ <p class="prompt-product-details-title">
3333
+ <slot name="title">${translate("title")}</slot>
3334
+ </p>
3335
+ ${n(
3336
+ !((_c = this._store) == null ? void 0 : _c.useCustomApp),
3337
+ () => x`<button
3338
+ class="prompt-information-button"
3339
+ @click=${() => {
3340
+ this._popup = "learn-more";
3341
+ if (this.persistPopup) {
3342
+ this.setPopupKey();
3343
+ }
3344
+ }}
3345
+ >
3346
+ i
3347
+ </button>`
3348
+ )}
3349
+ </div>
3325
3350
  <p class="prompt-product-details-description">
3326
3351
  <slot name="subtitle">${translate("description")}</slot>
3327
3352
  </p>
3328
3353
  </div>
3329
3354
  <div class="prompt-product-actions">
3330
3355
  <p class="prompt-product-actions-price">
3331
- ${((_c = this._protectionVariant) == null ? void 0 : _c.price) && this._currencyFormat(this._protectionVariant.price)}
3356
+ ${((_d = this._protectionVariant) == null ? void 0 : _d.price) && this._currencyFormat(this._protectionVariant.price)}
3332
3357
  </p>
3333
3358
  ${!(useToggle || useCheckbox) && !this.defaultToggleButton ? n(
3334
3359
  !this.disableActions,
@@ -3356,31 +3381,36 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3356
3381
  this._state.error,
3357
3382
  () => x`<p class="error">${this._state.error}</p>`
3358
3383
  )}
3359
- <div class="prompt-footer">
3360
- <a
3361
- class="prompt-footer-badge"
3362
- @click=${() => {
3363
- this._popup = "learn-more";
3364
- if (this.persistPopup) {
3365
- this.setPopupKey();
3366
- }
3367
- }}
3368
- >
3369
- <span>${translate("footer.button")}</span>
3370
- ${ShipAidLogoText}
3371
- <button
3372
- class="prompt-footer-about"
3373
- @click=${() => {
3374
- this._popup = "learn-more";
3375
- if (this.persistPopup) {
3376
- this.setPopupKey();
3377
- }
3378
- }}
3379
- >
3380
- i
3381
- </button>
3382
- </a>
3383
- </div>
3384
+ ${n(
3385
+ (_e = this._store) == null ? void 0 : _e.useCustomApp,
3386
+ () => x`
3387
+ <div class="prompt-footer">
3388
+ <a
3389
+ class="prompt-footer-badge"
3390
+ @click=${() => {
3391
+ this._popup = "learn-more";
3392
+ if (this.persistPopup) {
3393
+ this.setPopupKey();
3394
+ }
3395
+ }}
3396
+ >
3397
+ <span>${translate("footer.button")}</span>
3398
+ ${ShipAidLogoText}
3399
+ <button
3400
+ class="prompt-footer-about"
3401
+ @click=${() => {
3402
+ this._popup = "learn-more";
3403
+ if (this.persistPopup) {
3404
+ this.setPopupKey();
3405
+ }
3406
+ }}
3407
+ >
3408
+ i
3409
+ </button>
3410
+ </a>
3411
+ </div>
3412
+ `
3413
+ )}
3384
3414
  </div>
3385
3415
  `;
3386
3416
  }
@@ -3765,6 +3795,17 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3765
3795
  padding: 6px 0;
3766
3796
  text-align: right;
3767
3797
  }
3798
+ .shipaid-prompt .prompt-information-button {
3799
+ color: var(--shipaid-text);
3800
+ cursor: pointer;
3801
+ font-size: var(--shipaid-prompt-prompt-information-button-size, 10px);
3802
+ background-color: transparent;
3803
+ cursor: pointer;
3804
+ border: 1px solid var(--shipaid-text);
3805
+ border-radius: 10px;
3806
+ margin-left: 0.5rem;
3807
+ }
3808
+
3768
3809
  .shipaid-prompt .prompt-footer {
3769
3810
  margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
3770
3811
  margin-left: var(--shipaid-prompt-footer-leftMargin, 0px);
@@ -3803,6 +3844,16 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3803
3844
  height:var(--shipaid-footer-badge-logo-height, 9px);
3804
3845
  }
3805
3846
 
3847
+ .shipaid-prompt .heading-container{
3848
+ display: var(--shipaid-prompt-heading-container-display, flex);
3849
+ justify-content: var(--shipaid-prompt-heading-container-justify-content, start);
3850
+ align-items: var(--shipaid-prompt-heading-container-align-items, center);
3851
+ }
3852
+
3853
+ .shipaid-prompt .heading-container > p{
3854
+ margin: var(--shipaid-prompt-heading-container-gap-margin, 0px 10px 0px 0px);
3855
+ }
3856
+
3806
3857
  .shipaid-checkbox {
3807
3858
  display: inline-block;
3808
3859
  position: relative;
@@ -198,8 +198,18 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
198
198
  object-fit: contain;
199
199
  }
200
200
 
201
- .shipaid-popup .popup-disclaimer-subtitle {
202
- display: inline-flex;
201
+
202
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-enable{
203
+ display: var(--shipaid-subtitle-enable, inline-flex);
204
+ }
205
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-monitor{
206
+ display: var(--shipaid-subtitle-monitor, inline-flex);
207
+ }
208
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-notify{
209
+ display: var(--shipaid-subtitle-notify, inline-flex);
210
+ }
211
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-resolution{
212
+ display: var(--shipaid-subtitle-resolution, inline-flex);
203
213
  }
204
214
 
205
215
  .shipaid-popup .popup-disclaimer-subtitle p {
@@ -608,19 +618,19 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
608
618
  </button>
609
619
  <div class="popup-logo">${Rt}</div>
610
620
  <p class="popup-title">${Lt("learn-more-popup.title")}</p>
611
- <div class="popup-disclaimer-subtitle">
621
+ <div class="popup-disclaimer-subtitle subtitle-enable">
612
622
  <div class="popup-icon">${Bt}</div>
613
623
  <p>${Lt("learn-more-popup.disclaimer.subtitle-enable")}</p>
614
624
  </div>
615
- <div class="popup-disclaimer-subtitle">
625
+ <div class="popup-disclaimer-subtitle subtitle-monitor">
616
626
  <div class="popup-icon">${Ut}</div>
617
627
  <p>${Lt("learn-more-popup.disclaimer.subtitle-monitor")}</p>
618
628
  </div>
619
- <div class="popup-disclaimer-subtitle">
629
+ <div class="popup-disclaimer-subtitle subtitle-notify">
620
630
  <div class="popup-icon-b">${Ft}</div>
621
631
  <p>${Lt("learn-more-popup.disclaimer.subtitle-notify")}</p>
622
632
  </div>
623
- <div class="popup-disclaimer-subtitle">
633
+ <div class="popup-disclaimer-subtitle subtitle-resolution">
624
634
  <div class="popup-icon-bell">${Dt}</div>
625
635
  <p>
626
636
  ${Lt("learn-more-popup.disclaimer.subtitle-resolution")}
@@ -1309,7 +1319,6 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1309
1319
  display: flex;
1310
1320
  align-items: center;
1311
1321
  justify-content: space-between;
1312
- font-size: 14px;
1313
1322
  margin-bottom: 1rem;
1314
1323
  }
1315
1324
 
@@ -1318,7 +1327,7 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1318
1327
  display: flex;
1319
1328
  align-items: center;
1320
1329
  gap: 0.5rem;
1321
- font-size: 1.3rem;
1330
+ font-size: clamp(0.8rem, 1vw + 0.6rem, 1.4rem);
1322
1331
  }
1323
1332
 
1324
1333
  .protection-text p {
@@ -1403,10 +1412,10 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1403
1412
  <slot name="link-continue">${Lt("checkout-plus.continue")}</slot>
1404
1413
  </a>
1405
1414
  </div>
1406
- `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:o,useCheckbox:r,leftCheckbox:n}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1415
+ `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i,o,r;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:n,useCheckbox:a,leftCheckbox:s}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1407
1416
  <div class="shipaid-prompt">
1408
1417
  <div class="prompt-product">
1409
- ${Tt(!this.disableActions&&n,(()=>F`
1418
+ ${Tt(!this.disableActions&&s,(()=>F`
1410
1419
  <label class="shipaid-checkbox">
1411
1420
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1412
1421
  <span class="shipaid-checkMark left"></span>
@@ -1416,21 +1425,29 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1416
1425
  ${Tt(this._hasProtectionInCart,(()=>Nt),(()=>jt))}
1417
1426
  </div>
1418
1427
  <div class="prompt-product-details">
1419
- <p class="prompt-product-details-title">
1420
- <slot name="title">${Lt("title")}</slot>
1421
- </p>
1428
+ <div class="heading-container">
1429
+ <p class="prompt-product-details-title">
1430
+ <slot name="title">${Lt("title")}</slot>
1431
+ </p>
1432
+ ${Tt(!(null==(i=this._store)?void 0:i.useCustomApp),(()=>F`<button
1433
+ class="prompt-information-button"
1434
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1435
+ >
1436
+ i
1437
+ </button>`))}
1438
+ </div>
1422
1439
  <p class="prompt-product-details-description">
1423
1440
  <slot name="subtitle">${Lt("description")}</slot>
1424
1441
  </p>
1425
1442
  </div>
1426
1443
  <div class="prompt-product-actions">
1427
1444
  <p class="prompt-product-actions-price">
1428
- ${(null==(i=this._protectionVariant)?void 0:i.price)&&this._currencyFormat(this._protectionVariant.price)}
1445
+ ${(null==(o=this._protectionVariant)?void 0:o.price)&&this._currencyFormat(this._protectionVariant.price)}
1429
1446
  </p>
1430
- ${o||r||this.defaultToggleButton?Tt(!this.disableActions&&!n,(()=>F`
1431
- <label class="shipaid-${o?"toggle":r?"checkbox":""}">
1447
+ ${n||a||this.defaultToggleButton?Tt(!this.disableActions&&!s,(()=>F`
1448
+ <label class="shipaid-${n?"toggle":a?"checkbox":""}">
1432
1449
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1433
- <span class="shipaid-${o?"slider":r?"checkMark":""}"></span>
1450
+ <span class="shipaid-${n?"slider":a?"checkMark":""}"></span>
1434
1451
  </label>
1435
1452
  `)):Tt(!this.disableActions,(()=>F`
1436
1453
  <button
@@ -1444,21 +1461,23 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1444
1461
  </div>
1445
1462
  </div>
1446
1463
  ${Tt(this._state.error,(()=>F`<p class="error">${this._state.error}</p>`))}
1447
- <div class="prompt-footer">
1448
- <a
1449
- class="prompt-footer-badge"
1450
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1451
- >
1452
- <span>${Lt("footer.button")}</span>
1453
- ${Vt}
1454
- <button
1455
- class="prompt-footer-about"
1456
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1457
- >
1458
- i
1459
- </button>
1460
- </a>
1461
- </div>
1464
+ ${Tt(null==(r=this._store)?void 0:r.useCustomApp,(()=>F`
1465
+ <div class="prompt-footer">
1466
+ <a
1467
+ class="prompt-footer-badge"
1468
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1469
+ >
1470
+ <span>${Lt("footer.button")}</span>
1471
+ ${Vt}
1472
+ <button
1473
+ class="prompt-footer-about"
1474
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1475
+ >
1476
+ i
1477
+ </button>
1478
+ </a>
1479
+ </div>
1480
+ `))}
1462
1481
  </div>
1463
1482
  `}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(_e),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(_e)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(_e,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`
1464
1483
  <style>
@@ -1589,6 +1608,17 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1589
1608
  padding: 6px 0;
1590
1609
  text-align: right;
1591
1610
  }
1611
+ .shipaid-prompt .prompt-information-button {
1612
+ color: var(--shipaid-text);
1613
+ cursor: pointer;
1614
+ font-size: var(--shipaid-prompt-prompt-information-button-size, 10px);
1615
+ background-color: transparent;
1616
+ cursor: pointer;
1617
+ border: 1px solid var(--shipaid-text);
1618
+ border-radius: 10px;
1619
+ margin-left: 0.5rem;
1620
+ }
1621
+
1592
1622
  .shipaid-prompt .prompt-footer {
1593
1623
  margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
1594
1624
  margin-left: var(--shipaid-prompt-footer-leftMargin, 0px);
@@ -1627,6 +1657,16 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1627
1657
  height:var(--shipaid-footer-badge-logo-height, 9px);
1628
1658
  }
1629
1659
 
1660
+ .shipaid-prompt .heading-container{
1661
+ display: var(--shipaid-prompt-heading-container-display, flex);
1662
+ justify-content: var(--shipaid-prompt-heading-container-justify-content, start);
1663
+ align-items: var(--shipaid-prompt-heading-container-align-items, center);
1664
+ }
1665
+
1666
+ .shipaid-prompt .heading-container > p{
1667
+ margin: var(--shipaid-prompt-heading-container-gap-margin, 0px 10px 0px 0px);
1668
+ }
1669
+
1630
1670
  .shipaid-checkbox {
1631
1671
  display: inline-block;
1632
1672
  position: relative;
@@ -198,8 +198,18 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
198
198
  object-fit: contain;
199
199
  }
200
200
 
201
- .shipaid-popup .popup-disclaimer-subtitle {
202
- display: inline-flex;
201
+
202
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-enable{
203
+ display: var(--shipaid-subtitle-enable, inline-flex);
204
+ }
205
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-monitor{
206
+ display: var(--shipaid-subtitle-monitor, inline-flex);
207
+ }
208
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-notify{
209
+ display: var(--shipaid-subtitle-notify, inline-flex);
210
+ }
211
+ .shipaid-popup .popup-disclaimer-subtitle.subtitle-resolution{
212
+ display: var(--shipaid-subtitle-resolution, inline-flex);
203
213
  }
204
214
 
205
215
  .shipaid-popup .popup-disclaimer-subtitle p {
@@ -608,19 +618,19 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
608
618
  </button>
609
619
  <div class="popup-logo">${Rt}</div>
610
620
  <p class="popup-title">${Lt("learn-more-popup.title")}</p>
611
- <div class="popup-disclaimer-subtitle">
621
+ <div class="popup-disclaimer-subtitle subtitle-enable">
612
622
  <div class="popup-icon">${Bt}</div>
613
623
  <p>${Lt("learn-more-popup.disclaimer.subtitle-enable")}</p>
614
624
  </div>
615
- <div class="popup-disclaimer-subtitle">
625
+ <div class="popup-disclaimer-subtitle subtitle-monitor">
616
626
  <div class="popup-icon">${Ut}</div>
617
627
  <p>${Lt("learn-more-popup.disclaimer.subtitle-monitor")}</p>
618
628
  </div>
619
- <div class="popup-disclaimer-subtitle">
629
+ <div class="popup-disclaimer-subtitle subtitle-notify">
620
630
  <div class="popup-icon-b">${Ft}</div>
621
631
  <p>${Lt("learn-more-popup.disclaimer.subtitle-notify")}</p>
622
632
  </div>
623
- <div class="popup-disclaimer-subtitle">
633
+ <div class="popup-disclaimer-subtitle subtitle-resolution">
624
634
  <div class="popup-icon-bell">${Dt}</div>
625
635
  <p>
626
636
  ${Lt("learn-more-popup.disclaimer.subtitle-resolution")}
@@ -1309,7 +1319,6 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1309
1319
  display: flex;
1310
1320
  align-items: center;
1311
1321
  justify-content: space-between;
1312
- font-size: 14px;
1313
1322
  margin-bottom: 1rem;
1314
1323
  }
1315
1324
 
@@ -1318,7 +1327,7 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1318
1327
  display: flex;
1319
1328
  align-items: center;
1320
1329
  gap: 0.5rem;
1321
- font-size: 1.3rem;
1330
+ font-size: clamp(0.8rem, 1vw + 0.6rem, 1.4rem);
1322
1331
  }
1323
1332
 
1324
1333
  .protection-text p {
@@ -1403,10 +1412,10 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1403
1412
  <slot name="link-continue">${Lt("checkout-plus.continue")}</slot>
1404
1413
  </a>
1405
1414
  </div>
1406
- `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:o,useCheckbox:r,leftCheckbox:n}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1415
+ `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i,o,r;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:n,useCheckbox:a,leftCheckbox:s}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1407
1416
  <div class="shipaid-prompt">
1408
1417
  <div class="prompt-product">
1409
- ${Tt(!this.disableActions&&n,(()=>F`
1418
+ ${Tt(!this.disableActions&&s,(()=>F`
1410
1419
  <label class="shipaid-checkbox">
1411
1420
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1412
1421
  <span class="shipaid-checkMark left"></span>
@@ -1416,21 +1425,29 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1416
1425
  ${Tt(this._hasProtectionInCart,(()=>Nt),(()=>jt))}
1417
1426
  </div>
1418
1427
  <div class="prompt-product-details">
1419
- <p class="prompt-product-details-title">
1420
- <slot name="title">${Lt("title")}</slot>
1421
- </p>
1428
+ <div class="heading-container">
1429
+ <p class="prompt-product-details-title">
1430
+ <slot name="title">${Lt("title")}</slot>
1431
+ </p>
1432
+ ${Tt(!(null==(i=this._store)?void 0:i.useCustomApp),(()=>F`<button
1433
+ class="prompt-information-button"
1434
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1435
+ >
1436
+ i
1437
+ </button>`))}
1438
+ </div>
1422
1439
  <p class="prompt-product-details-description">
1423
1440
  <slot name="subtitle">${Lt("description")}</slot>
1424
1441
  </p>
1425
1442
  </div>
1426
1443
  <div class="prompt-product-actions">
1427
1444
  <p class="prompt-product-actions-price">
1428
- ${(null==(i=this._protectionVariant)?void 0:i.price)&&this._currencyFormat(this._protectionVariant.price)}
1445
+ ${(null==(o=this._protectionVariant)?void 0:o.price)&&this._currencyFormat(this._protectionVariant.price)}
1429
1446
  </p>
1430
- ${o||r||this.defaultToggleButton?Tt(!this.disableActions&&!n,(()=>F`
1431
- <label class="shipaid-${o?"toggle":r?"checkbox":""}">
1447
+ ${n||a||this.defaultToggleButton?Tt(!this.disableActions&&!s,(()=>F`
1448
+ <label class="shipaid-${n?"toggle":a?"checkbox":""}">
1432
1449
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1433
- <span class="shipaid-${o?"slider":r?"checkMark":""}"></span>
1450
+ <span class="shipaid-${n?"slider":a?"checkMark":""}"></span>
1434
1451
  </label>
1435
1452
  `)):Tt(!this.disableActions,(()=>F`
1436
1453
  <button
@@ -1444,21 +1461,23 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1444
1461
  </div>
1445
1462
  </div>
1446
1463
  ${Tt(this._state.error,(()=>F`<p class="error">${this._state.error}</p>`))}
1447
- <div class="prompt-footer">
1448
- <a
1449
- class="prompt-footer-badge"
1450
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1451
- >
1452
- <span>${Lt("footer.button")}</span>
1453
- ${Vt}
1454
- <button
1455
- class="prompt-footer-about"
1456
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1457
- >
1458
- i
1459
- </button>
1460
- </a>
1461
- </div>
1464
+ ${Tt(null==(r=this._store)?void 0:r.useCustomApp,(()=>F`
1465
+ <div class="prompt-footer">
1466
+ <a
1467
+ class="prompt-footer-badge"
1468
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1469
+ >
1470
+ <span>${Lt("footer.button")}</span>
1471
+ ${Vt}
1472
+ <button
1473
+ class="prompt-footer-about"
1474
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1475
+ >
1476
+ i
1477
+ </button>
1478
+ </a>
1479
+ </div>
1480
+ `))}
1462
1481
  </div>
1463
1482
  `}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(_e),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(_e)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(_e,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`
1464
1483
  <style>
@@ -1589,6 +1608,17 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1589
1608
  padding: 6px 0;
1590
1609
  text-align: right;
1591
1610
  }
1611
+ .shipaid-prompt .prompt-information-button {
1612
+ color: var(--shipaid-text);
1613
+ cursor: pointer;
1614
+ font-size: var(--shipaid-prompt-prompt-information-button-size, 10px);
1615
+ background-color: transparent;
1616
+ cursor: pointer;
1617
+ border: 1px solid var(--shipaid-text);
1618
+ border-radius: 10px;
1619
+ margin-left: 0.5rem;
1620
+ }
1621
+
1592
1622
  .shipaid-prompt .prompt-footer {
1593
1623
  margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
1594
1624
  margin-left: var(--shipaid-prompt-footer-leftMargin, 0px);
@@ -1627,6 +1657,16 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1627
1657
  height:var(--shipaid-footer-badge-logo-height, 9px);
1628
1658
  }
1629
1659
 
1660
+ .shipaid-prompt .heading-container{
1661
+ display: var(--shipaid-prompt-heading-container-display, flex);
1662
+ justify-content: var(--shipaid-prompt-heading-container-justify-content, start);
1663
+ align-items: var(--shipaid-prompt-heading-container-align-items, center);
1664
+ }
1665
+
1666
+ .shipaid-prompt .heading-container > p{
1667
+ margin: var(--shipaid-prompt-heading-container-gap-margin, 0px 10px 0px 0px);
1668
+ }
1669
+
1630
1670
  .shipaid-checkbox {
1631
1671
  display: inline-block;
1632
1672
  position: relative;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui.shipaid.com",
3
3
  "private": false,
4
- "version": "0.3.100",
4
+ "version": "0.3.102",
5
5
  "type": "module",
6
6
  "main": "dist/widget.umd.js",
7
7
  "unpkg": "dist/widget.iife.js",