@getspot/spot-widget 4.0.0 → 4.0.1
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/CHANGELOG.md +7 -0
- package/README.md +3 -5
- package/dist/api.d.ts +1 -1
- package/dist/index.es.js +22 -22
- package/dist/index.umd.js +3 -3
- package/dist/ui.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.0.1](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@4.0.0...@getspot/spot-widget@4.0.1) (2026-01-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* when the selection is no we need to check the NO option ([628f5f4](https://gitlab.com/getspot/spot-widget/commit/628f5f453d95bf4956ed4328b8c1fceeb633edd2))
|
|
7
|
+
|
|
1
8
|
# [4.0.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.3.2...@getspot/spot-widget@4.0.0) (2026-01-12)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -113,11 +113,9 @@ const widget = new SpotWidget(options);
|
|
|
113
113
|
|
|
114
114
|
```typescript
|
|
115
115
|
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
currencyCode: 'USD' | 'CAD' | 'AUD';
|
|
120
|
-
};
|
|
116
|
+
cartId: string;
|
|
117
|
+
cartName: string;
|
|
118
|
+
currencyCode: 'USD' | 'CAD' | 'AUD';
|
|
121
119
|
items: Array<{
|
|
122
120
|
// All single product fields except cartId and currencyCode
|
|
123
121
|
cartItemId?: string; // Optional item identifier
|
package/dist/api.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function fetchBatchQuote(endpoint: string, partnerId: string, bat
|
|
|
19
19
|
* Retrieve multiple quotes in parallel from Spot API
|
|
20
20
|
* @param endpoint – Spot API URL
|
|
21
21
|
* @param partnerId – partner UUID
|
|
22
|
-
* @param batchData – batch quote data with
|
|
22
|
+
* @param batchData – batch quote data with cart metadata and items
|
|
23
23
|
* @returns Promise resolving to formatted API response
|
|
24
24
|
*/
|
|
25
25
|
export declare function fetchMultipleQuotes(endpoint: string, partnerId: string, batchData: BatchQuoteRequest): Promise<ApiResponse>;
|
package/dist/index.es.js
CHANGED
|
@@ -161,7 +161,7 @@ function z(m) {
|
|
|
161
161
|
throw new Error(`${d}.productName must be a string`);
|
|
162
162
|
}
|
|
163
163
|
if ("items" in o) {
|
|
164
|
-
const c = o, { cartId: l, cartName: d, currencyCode: y, items:
|
|
164
|
+
const c = o, { cartId: l, cartName: d, currencyCode: y, items: b } = c;
|
|
165
165
|
if (!l || typeof l != "string")
|
|
166
166
|
throw new Error("quoteRequestData.cartId must be a string");
|
|
167
167
|
if (!d || typeof d != "string")
|
|
@@ -170,7 +170,7 @@ function z(m) {
|
|
|
170
170
|
throw new Error("quoteRequestData.currencyCode must be a string");
|
|
171
171
|
if (!["USD", "CAD", "AUD"].includes(y))
|
|
172
172
|
throw new Error(`Invalid quoteRequestData.currencyCode: ${y}`);
|
|
173
|
-
if (!Array.isArray(
|
|
173
|
+
if (!Array.isArray(b) || b.length === 0)
|
|
174
174
|
throw new Error("quoteRequestData.items must be a non-empty array");
|
|
175
175
|
const C = [
|
|
176
176
|
"startDate",
|
|
@@ -182,7 +182,7 @@ function z(m) {
|
|
|
182
182
|
"productId",
|
|
183
183
|
"productName"
|
|
184
184
|
];
|
|
185
|
-
|
|
185
|
+
b.forEach((g, k) => {
|
|
186
186
|
if (!g || typeof g != "object")
|
|
187
187
|
throw new Error(`quoteRequestData.items[${k}] must be a non-null object`);
|
|
188
188
|
const _ = `quoteRequestData.items[${k}]`;
|
|
@@ -241,7 +241,7 @@ function z(m) {
|
|
|
241
241
|
"Theme must be an object with CSS variables, do not include the '--' prefix"
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
|
-
var
|
|
244
|
+
var w = /* @__PURE__ */ ((m) => (m.YES = "yes", m.NO = "no", m.UNSELECTED = "unselected", m))(w || {});
|
|
245
245
|
function a(m, { text: t, className: o, parent: s, innerHTML: i, href: r, target: n } = {}) {
|
|
246
246
|
const e = document.createElement(m);
|
|
247
247
|
return o && (e.className = o), t != null && (e.textContent = t), i != null && (e.innerHTML = i), r && "href" in e && (e.href = r), n && "target" in e && (e.target = n), s && s.appendChild(e), e;
|
|
@@ -257,7 +257,7 @@ function O(m, { name: t, description: o }) {
|
|
|
257
257
|
parent: m
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function $(m, t = []) {
|
|
261
261
|
const o = a("ul", {
|
|
262
262
|
className: "spot-benefits__list",
|
|
263
263
|
parent: m
|
|
@@ -271,7 +271,7 @@ function P(m, t = []) {
|
|
|
271
271
|
</svg>`, a("span", { text: s, parent: i });
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function P(m, t = []) {
|
|
275
275
|
if (!t || t.length === 0) return;
|
|
276
276
|
const o = a("div", {
|
|
277
277
|
className: "spot-qualifying-reasons__container",
|
|
@@ -337,7 +337,7 @@ function S(m, t = [], o) {
|
|
|
337
337
|
displayText: d > 1 ? `${d} x ${l}` : l
|
|
338
338
|
})
|
|
339
339
|
).sort((l, d) => {
|
|
340
|
-
const y = l.item.charAt(0),
|
|
340
|
+
const y = l.item.charAt(0), b = d.item.charAt(0), q = /[a-zA-Z]/.test(y), C = /[a-zA-Z]/.test(b);
|
|
341
341
|
return !q && C ? -1 : q && !C ? 1 : l.item.localeCompare(d.item, void 0, { sensitivity: "base" });
|
|
342
342
|
}), n = a("div", {
|
|
343
343
|
className: "spot-covered-items__container",
|
|
@@ -405,10 +405,10 @@ function Q(m, t, o) {
|
|
|
405
405
|
className: "spot-selection__options",
|
|
406
406
|
parent: m
|
|
407
407
|
}), i = a("label", {
|
|
408
|
-
className: `spot-selection__option ${t ===
|
|
408
|
+
className: `spot-selection__option ${t === w.YES ? "selected" : ""}`,
|
|
409
409
|
parent: s
|
|
410
410
|
}), r = a("input", { parent: i });
|
|
411
|
-
r.type = "radio", r.name = "selection", r.value =
|
|
411
|
+
r.type = "radio", r.name = "selection", r.value = w.YES, t === w.YES && (r.checked = !0), a("strong", {
|
|
412
412
|
text: o.yesOptionText,
|
|
413
413
|
parent: i
|
|
414
414
|
}), a("span", {
|
|
@@ -417,10 +417,10 @@ function Q(m, t, o) {
|
|
|
417
417
|
parent: i
|
|
418
418
|
});
|
|
419
419
|
const n = a("label", {
|
|
420
|
-
className:
|
|
420
|
+
className: `spot-selection__option ${t === w.NO ? "selected" : ""}`,
|
|
421
421
|
parent: s
|
|
422
422
|
}), e = a("input", { parent: n });
|
|
423
|
-
return e.type = "radio", e.name = "selection", e.value =
|
|
423
|
+
return e.type = "radio", e.name = "selection", e.value = w.NO, t === w.NO && (e.checked = !0), a("span", { text: o.noOptionText, parent: n }), s;
|
|
424
424
|
}
|
|
425
425
|
function R(m, t) {
|
|
426
426
|
var i;
|
|
@@ -520,7 +520,7 @@ class j {
|
|
|
520
520
|
callbacks: {},
|
|
521
521
|
useMockData: !1,
|
|
522
522
|
...t,
|
|
523
|
-
selection: t.selection ??
|
|
523
|
+
selection: t.selection ?? w.UNSELECTED
|
|
524
524
|
}, this._onResize = this._updateLayout.bind(this), this.root = typeof this.options.location == "string" ? document.querySelector(this.options.location) : this.options.location, this.currentSelection = this.options.selection, this._init();
|
|
525
525
|
}
|
|
526
526
|
async _init() {
|
|
@@ -551,7 +551,7 @@ class j {
|
|
|
551
551
|
}
|
|
552
552
|
if (this.quote = n.data, !this.quote)
|
|
553
553
|
throw new Error("No quote data in response");
|
|
554
|
-
if (this._renderWidget(), this.options.selection ===
|
|
554
|
+
if (this._renderWidget(), this.options.selection === w.YES && ((o = this.options.callbacks) != null && o.onOptIn)) {
|
|
555
555
|
const e = {
|
|
556
556
|
status: "QUOTE_ACCEPTED",
|
|
557
557
|
spotPrice: this.quote.spotPrice,
|
|
@@ -595,7 +595,7 @@ class j {
|
|
|
595
595
|
this.container.style.setProperty(r, i);
|
|
596
596
|
}), O(this.container, this.quote.communication);
|
|
597
597
|
const t = document.createElement("div");
|
|
598
|
-
if (t.className = "spot-content__wrapper", this.container.appendChild(t), this.quote.qualifyingReasons ?
|
|
598
|
+
if (t.className = "spot-content__wrapper", this.container.appendChild(t), this.quote.qualifyingReasons ? P(t, this.quote.qualifyingReasons) : $(t, this.quote.communication.bulletPoints), this.quote.coveredItems) {
|
|
599
599
|
const s = this._getTotalItemsInRequest();
|
|
600
600
|
S(t, this.quote.coveredItems, s);
|
|
601
601
|
}
|
|
@@ -663,7 +663,7 @@ class j {
|
|
|
663
663
|
i.addEventListener("change", (r) => {
|
|
664
664
|
var p, u, f, h;
|
|
665
665
|
const n = r.target, e = n.value;
|
|
666
|
-
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((v) => v.classList.remove("selected")), (p = n.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e ===
|
|
666
|
+
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((v) => v.classList.remove("selected")), (p = n.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e === w.YES && ((u = this.quote) != null && u.communication.paymentTerms && R(this.paymentTermsEl, this.quote), (f = this.options.callbacks) != null && f.onOptIn)) {
|
|
667
667
|
const v = {
|
|
668
668
|
status: "QUOTE_ACCEPTED",
|
|
669
669
|
spotPrice: this.quote.spotPrice,
|
|
@@ -675,7 +675,7 @@ class j {
|
|
|
675
675
|
(l) => {
|
|
676
676
|
var y;
|
|
677
677
|
const d = (y = c.items) == null ? void 0 : y.find(
|
|
678
|
-
(
|
|
678
|
+
(b) => (b.cartItemId || `item-${c.items.indexOf(b) + 1}`) === l.cartItemId
|
|
679
679
|
);
|
|
680
680
|
return {
|
|
681
681
|
quoteId: l.id,
|
|
@@ -687,7 +687,7 @@ class j {
|
|
|
687
687
|
}
|
|
688
688
|
this.options.callbacks.onOptIn(v);
|
|
689
689
|
}
|
|
690
|
-
if (e ===
|
|
690
|
+
if (e === w.NO && ((h = this.options.callbacks) != null && h.onOptOut)) {
|
|
691
691
|
const v = {
|
|
692
692
|
status: "QUOTE_DECLINED",
|
|
693
693
|
quoteId: this.quote.id
|
|
@@ -698,7 +698,7 @@ class j {
|
|
|
698
698
|
(l) => {
|
|
699
699
|
var y;
|
|
700
700
|
const d = (y = c.items) == null ? void 0 : y.find(
|
|
701
|
-
(
|
|
701
|
+
(b) => (b.cartItemId || `item-${c.items.indexOf(b) + 1}`) === l.cartItemId
|
|
702
702
|
);
|
|
703
703
|
return {
|
|
704
704
|
quoteId: l.id,
|
|
@@ -756,7 +756,7 @@ class j {
|
|
|
756
756
|
status: "NO_MATCHING_QUOTE",
|
|
757
757
|
data: n.quoteRequestData
|
|
758
758
|
}), !1;
|
|
759
|
-
if (this.options.quoteRequestData = n.quoteRequestData, this.quote = v.data, this.currentSelection =
|
|
759
|
+
if (this.options.quoteRequestData = n.quoteRequestData, this.quote = v.data, this.currentSelection = w.UNSELECTED, this.destroy(), this._renderWidget(), (s = this.options.callbacks) != null && s.onQuoteRetrieved) {
|
|
760
760
|
const c = this.options.callbacks.onQuoteRetrieved(this.quote);
|
|
761
761
|
c && this._applyQuoteUpdates(c);
|
|
762
762
|
}
|
|
@@ -772,12 +772,12 @@ class j {
|
|
|
772
772
|
}
|
|
773
773
|
getSelection() {
|
|
774
774
|
var o, s, i;
|
|
775
|
-
if (this.currentSelection == null || this.currentSelection ==
|
|
775
|
+
if (this.currentSelection == null || this.currentSelection == w.UNSELECTED) return null;
|
|
776
776
|
const t = {
|
|
777
777
|
selection: this.currentSelection,
|
|
778
778
|
quoteId: (o = this.quote) == null ? void 0 : o.id,
|
|
779
779
|
spotPrice: (s = this.quote) == null ? void 0 : s.spotPrice,
|
|
780
|
-
status: this.currentSelection ===
|
|
780
|
+
status: this.currentSelection === w.YES ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED"
|
|
781
781
|
};
|
|
782
782
|
if ((i = this.quote) != null && i.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
783
783
|
const r = this.options.quoteRequestData;
|
|
@@ -800,6 +800,6 @@ class j {
|
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
802
|
export {
|
|
803
|
-
|
|
803
|
+
w as SelectionEnum,
|
|
804
804
|
j as default
|
|
805
805
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(C,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(C=typeof globalThis<"u"?globalThis:C||self,E(C.SpotWidget={}))})(this,function(C){"use strict";async function E(m,t,o){try{const s=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),i=await s.json();if(!s.ok){const r=new Error((i==null?void 0:i.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=i,r}return i}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function L(m,t,o){try{const s=m.replace("/quote","/quote/batch"),i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await i.json();if(!i.ok){const n=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw n.status=i.status,n.responseBody=r,n}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function T(m,t,o){var s;try{const i={cartId:o.cartId,cartName:o.cartName,currencyCode:o.currencyCode,isPartialPayment:o.isPartialPayment||!1,roundTo:o.roundTo||void 0,items:o.items.map((p,u)=>({...p,cartItemId:p.cartItemId||`item-${u+1}`}))},r=await L(m,t,i);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const n=r.quotes.map(p=>{const u=o.items.find((f,h)=>(f.cartItemId||`item-${h+1}`)===p.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${p.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(p=>p.id).join(","):((s=r.data)==null?void 0:s.id)||"",spotPrice:e,currencyCode:r.currencyCode||"",communication:{...r.communication,yesOptionText:r.communication.yesOptionText.replace(String(r.totalSpotPrice),String(e))},payoutSchedule:r.payoutSchedule.map(p=>({...p,amount:p.amount!==void 0?p.amount:0})),coveredItems:n,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:n}}catch(i){throw i instanceof Error?i:new Error("Unknown error occurred while fetching multiple quotes")}}const O={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function I(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:i,theme:r}=m,{environment:n="sandbox",partnerId:e,customEndpoint:p}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(p||O[n]))throw new Error(`Invalid environment in apiConfig: ${n}`);if(!o||typeof o!="object"&&!Array.isArray(o))throw new Error("quoteRequestData must be a non-null object or array");const f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function h(c,l=null){const d=l!==null?`quoteRequestData[${l}]`:"quoteRequestData";f.forEach(g=>{if(!Object.prototype.hasOwnProperty.call(c,g)||c[g]===void 0||c[g]===null)throw new Error(`Missing required ${d} field: '${g}'`)});const
|
|
1
|
+
(function(C,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(C=typeof globalThis<"u"?globalThis:C||self,E(C.SpotWidget={}))})(this,function(C){"use strict";async function E(m,t,o){try{const s=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),i=await s.json();if(!s.ok){const r=new Error((i==null?void 0:i.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=i,r}return i}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function L(m,t,o){try{const s=m.replace("/quote","/quote/batch"),i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await i.json();if(!i.ok){const n=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw n.status=i.status,n.responseBody=r,n}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function T(m,t,o){var s;try{const i={cartId:o.cartId,cartName:o.cartName,currencyCode:o.currencyCode,isPartialPayment:o.isPartialPayment||!1,roundTo:o.roundTo||void 0,items:o.items.map((p,u)=>({...p,cartItemId:p.cartItemId||`item-${u+1}`}))},r=await L(m,t,i);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const n=r.quotes.map(p=>{const u=o.items.find((f,h)=>(f.cartItemId||`item-${h+1}`)===p.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${p.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(p=>p.id).join(","):((s=r.data)==null?void 0:s.id)||"",spotPrice:e,currencyCode:r.currencyCode||"",communication:{...r.communication,yesOptionText:r.communication.yesOptionText.replace(String(r.totalSpotPrice),String(e))},payoutSchedule:r.payoutSchedule.map(p=>({...p,amount:p.amount!==void 0?p.amount:0})),coveredItems:n,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:n}}catch(i){throw i instanceof Error?i:new Error("Unknown error occurred while fetching multiple quotes")}}const O={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function I(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:i,theme:r}=m,{environment:n="sandbox",partnerId:e,customEndpoint:p}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(p||O[n]))throw new Error(`Invalid environment in apiConfig: ${n}`);if(!o||typeof o!="object"&&!Array.isArray(o))throw new Error("quoteRequestData must be a non-null object or array");const f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function h(c,l=null){const d=l!==null?`quoteRequestData[${l}]`:"quoteRequestData";f.forEach(g=>{if(!Object.prototype.hasOwnProperty.call(c,g)||c[g]===void 0||c[g]===null)throw new Error(`Missing required ${d} field: '${g}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(c.startDate))throw new Error(`${d}.startDate must be a valid ISO8601 string`);if(!w.test(c.endDate))throw new Error(`${d}.endDate must be a valid ISO8601 string`);if(typeof c.currencyCode!="string")throw new Error(`${d}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(c.currencyCode))throw new Error(`Invalid ${d}.currencyCode: ${c.currencyCode}`);if(typeof c.eventType!="string")throw new Error(`${d}.eventType must be a string`);if(typeof c.productType!="string")throw new Error(`${d}.productType must be a string`);const k=["Pass","Trip","Registration"];if(!k.includes(c.productType))throw new Error(`${d}.productType must be one of ${k.join(", ")}`);if(typeof c.productDuration!="string")throw new Error(`${d}.productDuration must be a string`);const q=["Daily","Seasonal","Trip","Event"];if(!q.includes(c.productDuration))throw new Error(`${d}.productDuration must be one of ${q.join(", ")}`);if(typeof c.productPrice!="number"||isNaN(c.productPrice))throw new Error(`${d}.productPrice must be a valid number`);if(typeof c.productId!="string")throw new Error(`${d}.productId must be a string`);if(typeof c.cartId!="string")throw new Error(`${d}.cartId must be a string`);if(typeof c.productName!="string")throw new Error(`${d}.productName must be a string`)}if("items"in o){const c=o,{cartId:l,cartName:d,currencyCode:w,items:b}=c;if(!l||typeof l!="string")throw new Error("quoteRequestData.cartId must be a string");if(!d||typeof d!="string")throw new Error("quoteRequestData.cartName must be a string");if(!w||typeof w!="string")throw new Error("quoteRequestData.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(w))throw new Error(`Invalid quoteRequestData.currencyCode: ${w}`);if(!Array.isArray(b)||b.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const q=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];b.forEach((g,H)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${H}] must be a non-null object`);const _=`quoteRequestData.items[${H}]`;q.forEach(x=>{if(!Object.prototype.hasOwnProperty.call(g,x)||g[x]===void 0||g[x]===null)throw new Error(`Missing required ${_} field: '${x}'`)});const z=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!z.test(g.startDate))throw new Error(`${_}.startDate must be a valid ISO8601 string`);if(!z.test(g.endDate))throw new Error(`${_}.endDate must be a valid ISO8601 string`);if(typeof g.eventType!="string")throw new Error(`${_}.eventType must be a string`);if(typeof g.productType!="string")throw new Error(`${_}.productType must be a string`);const N=["Pass","Trip","Registration"];if(!N.includes(g.productType))throw new Error(`${_}.productType must be one of ${N.join(", ")}`);if(typeof g.productDuration!="string")throw new Error(`${_}.productDuration must be a string`);const M=["Daily","Seasonal","Trip","Event"];if(!M.includes(g.productDuration))throw new Error(`${_}.productDuration must be one of ${M.join(", ")}`);if(typeof g.productPrice!="number"||isNaN(g.productPrice))throw new Error(`${_}.productPrice must be a valid number`);if(typeof g.productId!="string")throw new Error(`${_}.productId must be a string`);if(typeof g.productName!="string")throw new Error(`${_}.productName must be a string`)})}else if(Array.isArray(o)){if(o.length===0)throw new Error("quoteRequestData array cannot be empty");o.forEach((c,l)=>{if(!c||typeof c!="object")throw new Error(`quoteRequestData[${l}] must be a non-null object`);h(c,l)})}else h(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(c=>{const l=s[c];if(l&&typeof l!="function")throw new Error(`Callback '${c}' must be a function.`)}),typeof i=="string"&&!document.querySelector(i))throw new Error(`Invalid location selector: '${i}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}var y=(m=>(m.YES="yes",m.NO="no",m.UNSELECTED="unselected",m))(y||{});function a(m,{text:t,className:o,parent:s,innerHTML:i,href:r,target:n}={}){const e=document.createElement(m);return o&&(e.className=o),t!=null&&(e.textContent=t),i!=null&&(e.innerHTML=i),r&&"href"in e&&(e.href=r),n&&"target"in e&&(e.target=n),s&&s.appendChild(e),e}function S(m,{name:t,description:o}){a("div",{className:"spot-header__title",text:t,parent:m}),a("div",{className:"spot-header__description",text:o,parent:m})}function P(m,t=[]){const o=a("ul",{className:"spot-benefits__list",parent:m});t.forEach(s=>{const i=a("li",{parent:o});i.innerHTML=`
|
|
2
2
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="spot-bullets__checkmark">
|
|
3
3
|
<path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
|
|
4
4
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
-
</svg>`,a("span",{text:s,parent:i})})}function $(m,t=[]){if(!t||t.length===0)return;const o=a("div",{className:"spot-qualifying-reasons__container",parent:m}),s=[...t].sort((e,p)=>e.rank-p.rank),i=a("div",{className:"spot-qualifying-reasons__grid",parent:o}),r={"Accident & Illness":"cross.svg","Family Emergencies":"users.svg",Layoffs:"building.svg","Jury Duty":"scale.svg","Work Travel Conflict":"briefcase.svg","Severe Weather":"umbrella.svg","Travel Interruption":"plane.svg","Military Duty":"medal.svg"};let n;try{const e=document.currentScript;if(e!=null&&e.src){const p=new URL(e.src);n=p.origin+p.pathname.replace(/\/[^/]*$/,"/")}else n=window.location.origin+window.location.pathname.replace(/\/[^/]*$/,"/");n+="assets/"}catch{n="./assets/"}s.forEach(e=>{var h,v,c;const p=a("div",{className:"spot-qualifying-reasons__item",parent:i}),u=a("div",{className:"spot-qualifying-reasons__icon-wrapper",parent:p}),f=r[((h=e.benefitType)==null?void 0:h.name)||""]||r[e.name||""];if(f){const l=a("img",{parent:u});l.src=n+f,l.alt=((v=e.benefitType)==null?void 0:v.name)||e.name||"",l.className="spot-qualifying-reasons__icon"}a("span",{className:"spot-qualifying-reasons__label",text:((c=e.benefitType)==null?void 0:c.name)||e.name||"",parent:p})})}function V(m,t=[],o){if(t.length===0||!o||o<=1)return;const s=new Map;t.forEach(l=>{s.set(l,(s.get(l)||0)+1)});const r=Array.from(s.entries()).map(([l,d])=>({item:l,count:d,displayText:d>1?`${d} x ${l}`:l})).sort((l,d)=>{const
|
|
5
|
+
</svg>`,a("span",{text:s,parent:i})})}function $(m,t=[]){if(!t||t.length===0)return;const o=a("div",{className:"spot-qualifying-reasons__container",parent:m}),s=[...t].sort((e,p)=>e.rank-p.rank),i=a("div",{className:"spot-qualifying-reasons__grid",parent:o}),r={"Accident & Illness":"cross.svg","Family Emergencies":"users.svg",Layoffs:"building.svg","Jury Duty":"scale.svg","Work Travel Conflict":"briefcase.svg","Severe Weather":"umbrella.svg","Travel Interruption":"plane.svg","Military Duty":"medal.svg"};let n;try{const e=document.currentScript;if(e!=null&&e.src){const p=new URL(e.src);n=p.origin+p.pathname.replace(/\/[^/]*$/,"/")}else n=window.location.origin+window.location.pathname.replace(/\/[^/]*$/,"/");n+="assets/"}catch{n="./assets/"}s.forEach(e=>{var h,v,c;const p=a("div",{className:"spot-qualifying-reasons__item",parent:i}),u=a("div",{className:"spot-qualifying-reasons__icon-wrapper",parent:p}),f=r[((h=e.benefitType)==null?void 0:h.name)||""]||r[e.name||""];if(f){const l=a("img",{parent:u});l.src=n+f,l.alt=((v=e.benefitType)==null?void 0:v.name)||e.name||"",l.className="spot-qualifying-reasons__icon"}a("span",{className:"spot-qualifying-reasons__label",text:((c=e.benefitType)==null?void 0:c.name)||e.name||"",parent:p})})}function V(m,t=[],o){if(t.length===0||!o||o<=1)return;const s=new Map;t.forEach(l=>{s.set(l,(s.get(l)||0)+1)});const r=Array.from(s.entries()).map(([l,d])=>({item:l,count:d,displayText:d>1?`${d} x ${l}`:l})).sort((l,d)=>{const w=l.item.charAt(0),b=d.item.charAt(0),k=/[a-zA-Z]/.test(w),q=/[a-zA-Z]/.test(b);return!k&&q?-1:k&&!q?1:l.item.localeCompare(d.item,void 0,{sensitivity:"base"})}),n=a("div",{className:"spot-covered-items__container",parent:m}),e=a("div",{className:"spot-covered-items__header",parent:n}),p=a("button",{className:"spot-covered-items__toggle",parent:e});a("span",{className:"spot-covered-items__title",text:`Items Covered in Your Cart (${t.length})`,parent:p});const u=a("div",{className:"spot-covered-items__right-section",parent:p});a("span",{className:"spot-covered-items__view-all",text:"View All",parent:u});const f=a("span",{className:"spot-covered-items__arrow",innerHTML:"▼",parent:u}),h=a("div",{className:"spot-covered-items__content",parent:n}),v=a("ul",{className:"spot-covered-items__list",parent:h});r.forEach(({displayText:l})=>{const d=a("li",{parent:v});a("span",{text:l,parent:d})});let c=!1;h.style.display="none",p.addEventListener("click",l=>{l.stopPropagation(),c=!c,h.style.display=c?"block":"none",f.innerHTML=c?"▲":"▼",p.setAttribute("aria-expanded",c.toString())}),p.setAttribute("aria-expanded","false"),p.setAttribute("aria-controls","covered-items-list"),h.setAttribute("id","covered-items-list")}function Q(m,t=[]){const o=a("div",{className:"spot-table__container",parent:m}),s=a("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),i=a("thead",{parent:s}),r=a("tr",{parent:i});a("th",{text:"When you cancel",parent:r}),a("th",{text:"You will receive",parent:r});const n=a("tbody",{parent:s});t.forEach(({text:e,percent:p,amount:u})=>{const f=a("tr",{parent:n});a("td",{text:e,parent:f});const h=p==="Not eligible for refund"?"Not eligible for a refund":`$${u} refund`;a("td",{text:h,parent:f})})}function R(m,t,o){const s=a("div",{className:"spot-selection__options",parent:m}),i=a("label",{className:`spot-selection__option ${t===y.YES?"selected":""}`,parent:s}),r=a("input",{parent:i});r.type="radio",r.name="selection",r.value=y.YES,t===y.YES&&(r.checked=!0),a("strong",{text:o.yesOptionText,parent:i}),a("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:i});const n=a("label",{className:`spot-selection__option ${t===y.NO?"selected":""}`,parent:s}),e=a("input",{parent:n});return e.type="radio",e.name="selection",e.value=y.NO,t===y.NO&&(e.checked=!0),a("span",{text:o.noOptionText,parent:n}),s}function A(m,t){var i;const o=(i=t.communication)==null?void 0:i.paymentTerms,s=a("div",{className:"spot-payment-terms",parent:m});return a("div",{className:"spot-payment-terms__header",text:"PAYMENT TERMS",parent:s}),a("div",{className:"spot-payment-terms__body",text:o||"",parent:s}),s}function Z(m,t,o="bottom-right"){if(o==="top-right"){const e=a("div",{className:"spot-logo__top-right",parent:m});e.innerHTML=`
|
|
6
6
|
<svg width="145" height="28" viewBox="0 0 145 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7
7
|
<rect width="145" height="28"/>
|
|
8
8
|
<rect x="-655" y="-270" width="819" height="325" rx="10"/>
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
<rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
|
|
33
33
|
</clipPath>
|
|
34
34
|
</defs>
|
|
35
|
-
</svg>`}return s}const U=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--spot-max-width: 51rem;--spot-margin: 1rem;--spot-title-font-size: 1.25rem;--spot-title-font-weight: 700;--spot-title-padding: 0 0 1.25rem 0;--spot-description-font-size: .875rem;--spot-description-font-weight: 400;--spot-description-padding: 0 0 .5rem 0;--spot-bullets-font-size: .875rem;--spot-bullets-font-weight: 400;--spot-bullets-padding: .3125rem;--spot-bullets-checkmark-color: #2e2e2e;--spot-table-border-radius: .625rem;--spot-table-header-font-size: .875rem;--spot-table-header-font-weight: 700;--spot-table-header-padding: 0 .5rem .625rem;--spot-table-cell-font-size: .815rem;--spot-table-cell-font-weight: 400;--spot-table-cell-padding: 0 .625rem;--spot-radio-border: #000000;--spot-radio-border-radius: .625rem;--spot-radio-checked-background: #000000;--spot-radio-text-font-size: .875rem;--spot-radio-text-font-weight: 400;--spot-radio-text-padding: .625rem;--spot-radio-selection-background: #f4f4f4;--spot-radio-selection-border-radius: .625rem;--spot-radio-selection-padding: .625rem;--spot-recommended-tag-background: #000000;--spot-recommended-tag-font-color: #ffffff;--spot-recommended-tag-font-size: .875rem;--spot-recommended-tag-font-weight: 700;--spot-recommended-tag-padding: .25rem .5rem;--spot-recommended-tag-border-radius: .5rem;--spot-selection-error-font-color: #ff0000;--spot-selection-error-font-size: .875rem;--spot-qualifying-reasons-margin: .75rem 0;--spot-qualifying-reasons-padding: 0 .3125rem;--spot-qualifying-reasons-column-gap: 3rem;--spot-qualifying-reasons-row-gap: .25rem;--spot-qualifying-reasons-grid-padding-left: 1rem;--spot-qualifying-reasons-icon-wrapper-size: 1.125rem;--spot-qualifying-reasons-icon-size: .75rem;--spot-qualifying-reasons-icon-border-color: #2e2e2e;--spot-qualifying-reasons-icon-border-width: 1px;--spot-qualifying-reasons-icon-background: #ffffff;--spot-qualifying-reasons-item-gap: .625rem;--spot-qualifying-reasons-label-font-size: .8rem;--spot-qualifying-reasons-label-font-weight: 400;--spot-qualifying-reasons-label-font-color: #000000;--spot-qualifying-reasons-label-font-family: Arial;--spot-selection-error-padding: .5rem;--spot-payment-terms-background: #f4f4f4;--spot-payment-terms-border-radius: .625rem;--spot-payment-terms-padding: 1rem;--spot-payment-terms-font-color: #636569;--spot-payment-terms-font-size: .75rem;--spot-payment-terms-header-font-weight: 700;--spot-payment-terms-header-font-size: .875rem;--spot-payment-terms-header-margin-bottom: .5rem;--spot-payment-terms-header-border-color: #c2c2c2;--spot-payment-terms-header-padding: 0 0 .5rem 0;--spot-terms-font-size: .75rem;--spot-terms-font-weight: 400;--spot-terms-font-color: #636569;--spot-terms-padding: 0;--spot-terms-link-text-decoration: underline;--spot-terms-link-font-size: .75rem;--spot-terms-link-font-weight: 400;--spot-terms-link-font-color: #636569;--spot-terms-link-padding: 0;--spot-covered-items-background: #f1f3f5;--spot-covered-items-hover-background: #e9ecef;--spot-covered-items-border-radius: .5rem;--spot-covered-items-padding: .75rem 1rem;--spot-covered-items-font-size: .875rem;--spot-covered-items-font-weight: 400;--spot-covered-items-font-color: #000000;--spot-covered-items-font-family: Arial;--spot-covered-items-arrow-font-size: .6rem;--spot-covered-items-arrow-color: #636569;--spot-covered-items-view-all-color: #636569;--spot-covered-items-view-all-font-size: .875rem;--spot-covered-items-view-all-font-weight: 400;--spot-covered-items-content-background: #f8f9fa;--spot-covered-items-content-border: 1px solid #e0e0e0;--spot-covered-items-content-border-radius: .5rem;--spot-covered-items-content-padding: .75rem 1rem;--spot-desktop-radio-margin-top: -1.5rem;--spot-benefits-margin-bottom: 0rem;--spot-covered-items-margin-bottom: 1.5rem;--spot-footer-gap: 1rem;--spot-footer-terms-margin-right: 7rem;--spot-payment-terms-margin-top: .5rem;--spot-logo-top-right-margin: 1rem}.spot-refund-guarantee{font-family:var(--spot-font-family);padding:var(--spot-padding);background-color:var(--spot-background-color);color:var(--spot-font-color);border:.0625rem solid #e0e0e0;border-radius:var(--spot-border-radius);max-width:var(--spot-max-width);margin:var(--spot-margin);container-type:inline-size;position:relative;word-wrap:normal;overflow-wrap:normal;-webkit-hyphens:none;hyphens:none}.spot-refund-guarantee *{color:inherit}.spot-header__title{font-size:var(--spot-title-font-size);font-weight:var(--spot-title-font-weight);padding:var(--spot-title-padding);color:var(--spot-title-font-color);font-family:var(--spot-title-font-family);line-height:120%;letter-spacing:-.03125rem}.spot-header__description{font-size:var(--spot-description-font-size);font-weight:var(--spot-description-font-weight);color:var(--spot-description-font-color);font-family:var(--spot-description-font-family);padding:var(--spot-description-padding);line-height:125%;letter-spacing:-.025rem}.spot-content__wrapper{display:flex;flex-direction:column}.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr auto;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container,.desktop-layout .spot-covered-items__container,.desktop-layout .spot-selection__options{min-width:0;word-wrap:normal}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container{grid-row:1;margin-bottom:var(--spot-benefits-margin-bottom)}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1;margin-bottom:var(--spot-covered-items-margin-bottom)}.desktop-layout .spot-selection__options{grid-row:3;margin-top:var(--spot-desktop-radio-margin-top)}.desktop-layout .spot-payment-terms__wrapper{grid-row:4;grid-column:1;margin-top:var(--spot-payment-terms-margin-top)}.desktop-layout .spot-table__container{grid-row:1 / span 4;grid-column:2;width:auto;min-width:20.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-table__container{display:flex;justify-content:flex-start;margin-top:1rem;margin-bottom:1rem;padding-left:.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-refund__table{width:100%;max-width:22rem;table-layout:auto}@media (max-width: 850px){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 500px){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 600px){.spot-refund__table th{padding:0rem}}.spot-benefits__list{list-style-type:none;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-benefits__list li{margin-bottom:.375rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-bullets__checkmark path{stroke:var(--spot-bullets-checkmark-color)}.spot-qualifying-reasons__container{margin:var(--spot-qualifying-reasons-margin);padding:var(--spot-qualifying-reasons-padding)}.spot-qualifying-reasons__grid{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));column-gap:var(--spot-qualifying-reasons-column-gap);row-gap:var(--spot-qualifying-reasons-row-gap);max-width:100%;padding-left:var(--spot-qualifying-reasons-grid-padding-left)}.spot-qualifying-reasons__item{display:flex;align-items:center;gap:var(--spot-qualifying-reasons-item-gap)}.spot-qualifying-reasons__icon-wrapper{width:var(--spot-qualifying-reasons-icon-wrapper-size);height:var(--spot-qualifying-reasons-icon-wrapper-size);border-radius:50%;border:var(--spot-qualifying-reasons-icon-border-width) solid var(--spot-qualifying-reasons-icon-border-color);background-color:var(--spot-qualifying-reasons-icon-background);display:flex;align-items:center;justify-content:center;flex-shrink:0}.spot-qualifying-reasons__icon{width:var(--spot-qualifying-reasons-icon-size);height:var(--spot-qualifying-reasons-icon-size)}.spot-qualifying-reasons__label{font-size:var(--spot-qualifying-reasons-label-font-size);font-weight:var(--spot-qualifying-reasons-label-font-weight);color:var(--spot-qualifying-reasons-label-font-color);font-family:var(--spot-qualifying-reasons-label-font-family);line-height:1.2}@media (max-width: 480px){.spot-qualifying-reasons__grid{grid-template-columns:1fr}}.spot-covered-items__container{margin-top:.85rem;margin-bottom:.5rem;max-width:26rem}.spot-content__wrapper.desktop-layout:has(.spot-table__container) .spot-covered-items__container{margin-top:0rem;margin-bottom:1rem}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);padding:0 .3125rem .25rem;line-height:125%;margin:0}.spot-covered-items__list{list-style-type:disc;list-style-position:inside;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-covered-items__list li{margin-bottom:.3rem;text-align:left}.spot-covered-items__list li:last-child{margin-bottom:0}.spot-covered-items__header{margin-bottom:.5rem}.spot-covered-items__toggle{background:var(--spot-covered-items-background);border:none;border-radius:var(--spot-covered-items-border-radius);padding:var(--spot-covered-items-padding);cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;transition:all .2s ease}.spot-covered-items__toggle:hover{background-color:var(--spot-covered-items-hover-background)}.spot-covered-items__toggle:focus{outline:none;box-shadow:0 0 0 2px #0000001a}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;margin:0;padding:0}.spot-covered-items__right-section{display:flex;align-items:center;gap:.5rem;margin-left:auto}.spot-covered-items__view-all{font-size:var(--spot-covered-items-view-all-font-size);font-weight:var(--spot-covered-items-view-all-font-weight);color:var(--spot-covered-items-view-all-color);font-family:var(--spot-covered-items-font-family);line-height:125%}.spot-covered-items__arrow{font-size:var(--spot-covered-items-arrow-font-size);transition:transform .2s ease;color:var(--spot-covered-items-arrow-color);flex-shrink:0;transform:scaleX(1.5)}.spot-covered-items__content{margin-top:.5rem;transition:all .2s ease;overflow:hidden}.spot-covered-items__list{background-color:var(--spot-covered-items-content-background);border:var(--spot-covered-items-content-border);border-radius:var(--spot-covered-items-content-border-radius);margin:0;padding:var(--spot-covered-items-content-padding)}.spot-table__container{width:100%}.spot-refund__table{max-width:22rem;border-radius:var(--spot-table-border-radius);overflow:hidden;border:.09375rem solid #636569;table-layout:fixed;margin-bottom:.5rem;margin-top:.25rem;padding:.625rem}.spot-refund__table--dynamic{height:auto!important;min-height:7.5rem}.spot-refund__table td,.spot-refund__table th{padding:.375rem .625rem;text-align:left}.spot-refund__table th{text-align:left;font-size:var(--spot-table-header-font-size);font-weight:var(--spot-table-header-font-weight);color:var(--spot-table-header-font-color);font-family:var(--spot-table-header-font-family);padding:var(--spot-table-header-padding)}.spot-refund__table td{text-align:left;font-size:var(--spot-table-cell-font-size);font-weight:var(--spot-table-cell-font-weight);color:var(--spot-table-cell-font-color);font-family:var(--spot-table-cell-font-family);padding:var(--spot-table-cell-padding)}input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:.75rem;height:.75rem;min-width:.75rem;border:.0625rem solid var(--spot-radio-border);border-radius:var(--spot-radio-border-radius);margin-right:.5rem;position:relative;vertical-align:middle;top:-.0625rem;cursor:pointer;flex-shrink:0}input[type=radio]:checked{background:var(--spot-radio-checked-background);box-shadow:inset 0 0 0 .0625rem #fff}.spot-selection__options{display:flex;flex-direction:column;gap:.5rem}.spot-selection__option{display:flex;align-items:center;flex-wrap:nowrap;position:relative;transition:background .2s;cursor:pointer;font-size:var(--spot-radio-text-font-size);font-weight:var(--spot-radio-text-font-weight);color:var(--spot-radio-text-font-color);font-family:var(--spot-radio-text-font-family);padding:var(--spot-radio-text-padding);margin-right:.5rem}.spot-selection__option.selected{background:var(--spot-radio-selection-background);border-radius:var(--spot-radio-selection-border-radius);padding:var(--spot-radio-selection-padding)}.spot-selection__recommended-tag{background:var(--spot-recommended-tag-background);color:var(--spot-recommended-tag-font-color);font-size:var(--spot-recommended-tag-font-size);font-weight:var(--spot-recommended-tag-font-weight);padding:var(--spot-recommended-tag-padding);border-radius:var(--spot-recommended-tag-border-radius);margin-left:.75rem;white-space:nowrap;flex-shrink:0}@media (max-width: 850px){.spot-selection__recommended-tag{margin-left:.5rem}}@media (max-width: 600px){.spot-selection__recommended-tag{margin-left:.5rem;font-size:.75rem;padding:.1875rem .4375rem}}.spot-selection__error{color:var(--spot-selection-error-font-color);font-size:var(--spot-selection-error-font-size);padding:var(--spot-selection-error-padding);display:none}.spot-payment-terms__wrapper{margin-top:1rem}.spot-payment-terms__header{font-weight:var(--spot-payment-terms-header-font-weight);margin-bottom:.5rem;padding:var(--spot-payment-terms-header-padding);font-size:var(--spot-payment-terms-header-font-size);border-bottom:1px solid var(--spot-payment-terms-header-border-color)}.spot-payment-terms{background-color:var(--spot-payment-terms-background);border-radius:var(--spot-payment-terms-border-radius);padding:var(--spot-payment-terms-padding);margin-right:.5rem;color:var(--spot-payment-terms-font-color);font-size:var(--spot-payment-terms-font-size)}.spot-footer__terms{margin-top:.625rem;margin-right:.25rem;font-size:var(--spot-terms-font-size);font-weight:var(--spot-terms-font-weight);color:var(--spot-terms-font-color);font-family:var(--spot-terms-font-family);padding:var(--spot-terms-padding);line-height:1.4;word-wrap:normal;-webkit-hyphens:none;hyphens:none;flex:1;min-width:0;overflow-wrap:normal}.spot-footer__terms-link{text-decoration:var(--spot-terms-link-text-decoration);font-size:var(--spot-terms-link-font-size);font-weight:var(--spot-terms-link-font-weight);color:var(--spot-terms-link-font-color);font-family:var(--spot-terms-link-font-family);padding:var(--spot-terms-link-padding)}.spot-footer__container{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;flex-wrap:nowrap;gap:var(--spot-footer-gap)}@container (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}@media (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}.spot-footer__powered-by{margin-top:0;flex-shrink:0}.spot-logo__top-right{position:absolute;top:-14px;right:40px;z-index:10;background:#fff;padding:0 8px}@container (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}@media (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}";function j(m){const t=document.createElement("style");t.textContent=m,document.head.appendChild(t)}j(U);const D={sandbox:"https://api.sandbox.getspot.com/api/v1/quote",production:"https://api.getspot.com/api/v1/quote",local:"http://localhost:3999/api/v1/quote"};class B{constructor(t={}){this.options={location:"body",showTable:!0,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t,selection:t.selection??w.UNSELECTED},this._onResize=this._updateLayout.bind(this),this.root=typeof this.options.location=="string"?document.querySelector(this.options.location):this.options.location,this.currentSelection=this.options.selection,this._init()}async _init(){var t,o,s,i,r;try{I(this.options);let n;if(this.options.useMockData&&this.options.mockData)n=this.options.mockData;else{const{environment:e,partnerId:p}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||D[e];n="items"in this.options.quoteRequestData?await T(f,p,this.options.quoteRequestData):await E(f,p,this.options.quoteRequestData)}if(n.status!=="QUOTE_AVAILABLE"){n.status==="NO_MATCHING_QUOTE"&&((t=this.options.callbacks)!=null&&t.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=n.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.selection===w.YES&&((o=this.options.callbacks)!=null&&o.onOptIn)){const e={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const p=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=p.items)==null?void 0:h.find(v=>(v.cartItemId||`item-${p.items.indexOf(v)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(f==null?void 0:f.productPrice)||u.spotPrice,cartItemId:(f==null?void 0:f.cartItemId)||""}})}this.options.callbacks.onOptIn(e)}if((s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const e=this.options.callbacks.onQuoteRetrieved(this.quote);e&&this._applyQuoteUpdates(e)}}catch(n){if((i=this.options.callbacks)!=null&&i.onError){const e=n;(r=this.options.callbacks)==null||r.onError({message:e.message,status:e.status,responseBody:e.responseBody})}}}_renderWidget(){if(!this.quote)return;this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([s,i])=>{const r=`--${s}`;this.container.style.setProperty(r,i)}),S(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?$(t,this.quote.qualifyingReasons):P(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const s=this._getTotalItemsInRequest();V(t,this.quote.coveredItems,s)}this.options.showTable&&!this.quote.qualifyingReasons&&Q(t,this.quote.payoutSchedule);const o=R(t,this.options.selection,this.quote.communication);t.appendChild(o),this.paymentTermsEl=a("div",{className:"spot-payment-terms__wrapper",parent:t}),Z(this.container,this.quote,this.options.logoPosition),window.addEventListener("resize",this._onResize),this._setupResizeObserver(),this._updateLayout(),this._setupOptionListeners(o)}_updateLayout(){if(!this.container||!this.quote)return;const t=this.container.querySelector(".spot-content__wrapper"),o=this.options.showTable&&!this.quote.qualifyingReasons;if(!t||!o){t==null||t.classList.remove("desktop-layout");return}const s=this._shouldUseDesktopLayout(t);t.classList.toggle("desktop-layout",s)}_shouldUseDesktopLayout(t){const o=this.container.offsetWidth-40,s=325,i=16;if(o>=900)return!0;if(o>=650){const r=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const n=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!n)return r&&t.classList.add("desktop-layout"),r;const p=Math.min(n.scrollWidth,400)+s+i;return r&&t.classList.add("desktop-layout"),o>=p}return!1}_setupResizeObserver(){!this.container||!window.ResizeObserver||(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=window.setTimeout(()=>{this._updateLayout()},100)}),this._resizeObserver.observe(this.container))}_getTotalItemsInRequest(){return"items"in this.options.quoteRequestData?this.options.quoteRequestData.items.length:1}_applyQuoteUpdates(t){!this.quote||!this.container||(t.spotPriceWithFees!==void 0&&(this.quote.communication.yesOptionText=this.quote.communication.yesOptionText.replace(`$${this.quote.spotPrice.toFixed(2)}`,`$${t.spotPriceWithFees.toFixed(2)}`)),this.destroy(),this._renderWidget())}_setupOptionListeners(t){const o=t.querySelectorAll('input[type="radio"]'),s=t.querySelectorAll(".spot-selection__option");o.forEach(i=>{i.addEventListener("change",r=>{var p,u,f,h;const n=r.target,e=n.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(v=>v.classList.remove("selected")),(p=n.closest(".spot-selection__option"))==null||p.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),e===w.YES&&((u=this.quote)!=null&&u.communication.paymentTerms&&A(this.paymentTermsEl,this.quote),(f=this.options.callbacks)!=null&&f.onOptIn)){const v={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const c=this.options.quoteRequestData;v.batchQuoteDetails=this.quote.originalQuotes.map(l=>{var y;const d=(y=c.items)==null?void 0:y.find(b=>(b.cartItemId||`item-${c.items.indexOf(b)+1}`)===l.cartItemId);return{quoteId:l.id,productPrice:(d==null?void 0:d.productPrice)||l.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptIn(v)}if(e===w.NO&&((h=this.options.callbacks)!=null&&h.onOptOut)){const v={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const c=this.options.quoteRequestData;v.batchQuoteDetails=this.quote.originalQuotes.map(l=>{var y;const d=(y=c.items)==null?void 0:y.find(b=>(b.cartItemId||`item-${c.items.indexOf(b)+1}`)===l.cartItemId);return{quoteId:l.id,productPrice:(d==null?void 0:d.productPrice)||l.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptOut(v)}})})}showSelectionError(){var t;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const o=(t=this.container)==null?void 0:t.querySelector(".spot-selection__options");o&&o.insertAdjacentElement("afterend",this.errorEl)}this.errorEl.style.display="block"}hideSelectionError(){this.errorEl&&(this.errorEl.style.display="none")}validateSelection(){if(!this.container)return!1;const t=!!this.container.querySelector('input[name="selection"]:checked');return t?this.hideSelectionError():this.showSelectionError(),t}async updateQuote(t){var o,s,i,r;try{const n={...this.options,quoteRequestData:t};I(n);const{environment:e,partnerId:p,customEndpoint:u}=this.options.apiConfig,f=u||D[e],v="items"in n.quoteRequestData?await T(f,p,n.quoteRequestData):await E(f,p,n.quoteRequestData);if(v.status!=="QUOTE_AVAILABLE")return this.destroy(),v.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:n.quoteRequestData}),!1;if(this.options.quoteRequestData=n.quoteRequestData,this.quote=v.data,this.currentSelection=w.UNSELECTED,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const c=this.options.callbacks.onQuoteRetrieved(this.quote);c&&this._applyQuoteUpdates(c)}return!0}catch(n){const e=n;return(r=(i=this.options.callbacks)==null?void 0:i.onError)==null||r.call(i,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,i;if(this.currentSelection==null||this.currentSelection==w.UNSELECTED)return null;const t={selection:this.currentSelection,quoteId:(o=this.quote)==null?void 0:o.id,spotPrice:(s=this.quote)==null?void 0:s.spotPrice,status:this.currentSelection===w.YES?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};if((i=this.quote)!=null&&i.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(n=>{var p;const e=(p=r.items)==null?void 0:p.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===n.cartItemId);return{quoteId:n.id,productPrice:(e==null?void 0:e.productPrice)||n.spotPrice,cartItemId:(e==null?void 0:e.cartItemId)||""}})}return t}destroy(){window.removeEventListener("resize",this._onResize),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeTimeout&&window.clearTimeout(this._resizeTimeout),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}C.SelectionEnum=w,C.default=B,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
35
|
+
</svg>`}return s}const U=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--spot-max-width: 51rem;--spot-margin: 1rem;--spot-title-font-size: 1.25rem;--spot-title-font-weight: 700;--spot-title-padding: 0 0 1.25rem 0;--spot-description-font-size: .875rem;--spot-description-font-weight: 400;--spot-description-padding: 0 0 .5rem 0;--spot-bullets-font-size: .875rem;--spot-bullets-font-weight: 400;--spot-bullets-padding: .3125rem;--spot-bullets-checkmark-color: #2e2e2e;--spot-table-border-radius: .625rem;--spot-table-header-font-size: .875rem;--spot-table-header-font-weight: 700;--spot-table-header-padding: 0 .5rem .625rem;--spot-table-cell-font-size: .815rem;--spot-table-cell-font-weight: 400;--spot-table-cell-padding: 0 .625rem;--spot-radio-border: #000000;--spot-radio-border-radius: .625rem;--spot-radio-checked-background: #000000;--spot-radio-text-font-size: .875rem;--spot-radio-text-font-weight: 400;--spot-radio-text-padding: .625rem;--spot-radio-selection-background: #f4f4f4;--spot-radio-selection-border-radius: .625rem;--spot-radio-selection-padding: .625rem;--spot-recommended-tag-background: #000000;--spot-recommended-tag-font-color: #ffffff;--spot-recommended-tag-font-size: .875rem;--spot-recommended-tag-font-weight: 700;--spot-recommended-tag-padding: .25rem .5rem;--spot-recommended-tag-border-radius: .5rem;--spot-selection-error-font-color: #ff0000;--spot-selection-error-font-size: .875rem;--spot-qualifying-reasons-margin: .75rem 0;--spot-qualifying-reasons-padding: 0 .3125rem;--spot-qualifying-reasons-column-gap: 3rem;--spot-qualifying-reasons-row-gap: .25rem;--spot-qualifying-reasons-grid-padding-left: 1rem;--spot-qualifying-reasons-icon-wrapper-size: 1.125rem;--spot-qualifying-reasons-icon-size: .75rem;--spot-qualifying-reasons-icon-border-color: #2e2e2e;--spot-qualifying-reasons-icon-border-width: 1px;--spot-qualifying-reasons-icon-background: #ffffff;--spot-qualifying-reasons-item-gap: .625rem;--spot-qualifying-reasons-label-font-size: .8rem;--spot-qualifying-reasons-label-font-weight: 400;--spot-qualifying-reasons-label-font-color: #000000;--spot-qualifying-reasons-label-font-family: Arial;--spot-selection-error-padding: .5rem;--spot-payment-terms-background: #f4f4f4;--spot-payment-terms-border-radius: .625rem;--spot-payment-terms-padding: 1rem;--spot-payment-terms-font-color: #636569;--spot-payment-terms-font-size: .75rem;--spot-payment-terms-header-font-weight: 700;--spot-payment-terms-header-font-size: .875rem;--spot-payment-terms-header-margin-bottom: .5rem;--spot-payment-terms-header-border-color: #c2c2c2;--spot-payment-terms-header-padding: 0 0 .5rem 0;--spot-terms-font-size: .75rem;--spot-terms-font-weight: 400;--spot-terms-font-color: #636569;--spot-terms-padding: 0;--spot-terms-link-text-decoration: underline;--spot-terms-link-font-size: .75rem;--spot-terms-link-font-weight: 400;--spot-terms-link-font-color: #636569;--spot-terms-link-padding: 0;--spot-covered-items-background: #f1f3f5;--spot-covered-items-hover-background: #e9ecef;--spot-covered-items-border-radius: .5rem;--spot-covered-items-padding: .75rem 1rem;--spot-covered-items-font-size: .875rem;--spot-covered-items-font-weight: 400;--spot-covered-items-font-color: #000000;--spot-covered-items-font-family: Arial;--spot-covered-items-arrow-font-size: .6rem;--spot-covered-items-arrow-color: #636569;--spot-covered-items-view-all-color: #636569;--spot-covered-items-view-all-font-size: .875rem;--spot-covered-items-view-all-font-weight: 400;--spot-covered-items-content-background: #f8f9fa;--spot-covered-items-content-border: 1px solid #e0e0e0;--spot-covered-items-content-border-radius: .5rem;--spot-covered-items-content-padding: .75rem 1rem;--spot-desktop-radio-margin-top: -1.5rem;--spot-benefits-margin-bottom: 0rem;--spot-covered-items-margin-bottom: 1.5rem;--spot-footer-gap: 1rem;--spot-footer-terms-margin-right: 7rem;--spot-payment-terms-margin-top: .5rem;--spot-logo-top-right-margin: 1rem}.spot-refund-guarantee{font-family:var(--spot-font-family);padding:var(--spot-padding);background-color:var(--spot-background-color);color:var(--spot-font-color);border:.0625rem solid #e0e0e0;border-radius:var(--spot-border-radius);max-width:var(--spot-max-width);margin:var(--spot-margin);container-type:inline-size;position:relative;word-wrap:normal;overflow-wrap:normal;-webkit-hyphens:none;hyphens:none}.spot-refund-guarantee *{color:inherit}.spot-header__title{font-size:var(--spot-title-font-size);font-weight:var(--spot-title-font-weight);padding:var(--spot-title-padding);color:var(--spot-title-font-color);font-family:var(--spot-title-font-family);line-height:120%;letter-spacing:-.03125rem}.spot-header__description{font-size:var(--spot-description-font-size);font-weight:var(--spot-description-font-weight);color:var(--spot-description-font-color);font-family:var(--spot-description-font-family);padding:var(--spot-description-padding);line-height:125%;letter-spacing:-.025rem}.spot-content__wrapper{display:flex;flex-direction:column}.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr auto;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container,.desktop-layout .spot-covered-items__container,.desktop-layout .spot-selection__options{min-width:0;word-wrap:normal}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container{grid-row:1;margin-bottom:var(--spot-benefits-margin-bottom)}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1;margin-bottom:var(--spot-covered-items-margin-bottom)}.desktop-layout .spot-selection__options{grid-row:3;margin-top:var(--spot-desktop-radio-margin-top)}.desktop-layout .spot-payment-terms__wrapper{grid-row:4;grid-column:1;margin-top:var(--spot-payment-terms-margin-top)}.desktop-layout .spot-table__container{grid-row:1 / span 4;grid-column:2;width:auto;min-width:20.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-table__container{display:flex;justify-content:flex-start;margin-top:1rem;margin-bottom:1rem;padding-left:.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-refund__table{width:100%;max-width:22rem;table-layout:auto}@media (max-width: 850px){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 500px){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 600px){.spot-refund__table th{padding:0rem}}.spot-benefits__list{list-style-type:none;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-benefits__list li{margin-bottom:.375rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-bullets__checkmark path{stroke:var(--spot-bullets-checkmark-color)}.spot-qualifying-reasons__container{margin:var(--spot-qualifying-reasons-margin);padding:var(--spot-qualifying-reasons-padding)}.spot-qualifying-reasons__grid{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));column-gap:var(--spot-qualifying-reasons-column-gap);row-gap:var(--spot-qualifying-reasons-row-gap);max-width:100%;padding-left:var(--spot-qualifying-reasons-grid-padding-left)}.spot-qualifying-reasons__item{display:flex;align-items:center;gap:var(--spot-qualifying-reasons-item-gap)}.spot-qualifying-reasons__icon-wrapper{width:var(--spot-qualifying-reasons-icon-wrapper-size);height:var(--spot-qualifying-reasons-icon-wrapper-size);border-radius:50%;border:var(--spot-qualifying-reasons-icon-border-width) solid var(--spot-qualifying-reasons-icon-border-color);background-color:var(--spot-qualifying-reasons-icon-background);display:flex;align-items:center;justify-content:center;flex-shrink:0}.spot-qualifying-reasons__icon{width:var(--spot-qualifying-reasons-icon-size);height:var(--spot-qualifying-reasons-icon-size)}.spot-qualifying-reasons__label{font-size:var(--spot-qualifying-reasons-label-font-size);font-weight:var(--spot-qualifying-reasons-label-font-weight);color:var(--spot-qualifying-reasons-label-font-color);font-family:var(--spot-qualifying-reasons-label-font-family);line-height:1.2}@media (max-width: 480px){.spot-qualifying-reasons__grid{grid-template-columns:1fr}}.spot-covered-items__container{margin-top:.85rem;margin-bottom:.5rem;max-width:26rem}.spot-content__wrapper.desktop-layout:has(.spot-table__container) .spot-covered-items__container{margin-top:0rem;margin-bottom:1rem}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);padding:0 .3125rem .25rem;line-height:125%;margin:0}.spot-covered-items__list{list-style-type:disc;list-style-position:inside;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-covered-items__list li{margin-bottom:.3rem;text-align:left}.spot-covered-items__list li:last-child{margin-bottom:0}.spot-covered-items__header{margin-bottom:.5rem}.spot-covered-items__toggle{background:var(--spot-covered-items-background);border:none;border-radius:var(--spot-covered-items-border-radius);padding:var(--spot-covered-items-padding);cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;transition:all .2s ease}.spot-covered-items__toggle:hover{background-color:var(--spot-covered-items-hover-background)}.spot-covered-items__toggle:focus{outline:none;box-shadow:0 0 0 2px #0000001a}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;margin:0;padding:0}.spot-covered-items__right-section{display:flex;align-items:center;gap:.5rem;margin-left:auto}.spot-covered-items__view-all{font-size:var(--spot-covered-items-view-all-font-size);font-weight:var(--spot-covered-items-view-all-font-weight);color:var(--spot-covered-items-view-all-color);font-family:var(--spot-covered-items-font-family);line-height:125%}.spot-covered-items__arrow{font-size:var(--spot-covered-items-arrow-font-size);transition:transform .2s ease;color:var(--spot-covered-items-arrow-color);flex-shrink:0;transform:scaleX(1.5)}.spot-covered-items__content{margin-top:.5rem;transition:all .2s ease;overflow:hidden}.spot-covered-items__list{background-color:var(--spot-covered-items-content-background);border:var(--spot-covered-items-content-border);border-radius:var(--spot-covered-items-content-border-radius);margin:0;padding:var(--spot-covered-items-content-padding)}.spot-table__container{width:100%}.spot-refund__table{max-width:22rem;border-radius:var(--spot-table-border-radius);overflow:hidden;border:.09375rem solid #636569;table-layout:fixed;margin-bottom:.5rem;margin-top:.25rem;padding:.625rem}.spot-refund__table--dynamic{height:auto!important;min-height:7.5rem}.spot-refund__table td,.spot-refund__table th{padding:.375rem .625rem;text-align:left}.spot-refund__table th{text-align:left;font-size:var(--spot-table-header-font-size);font-weight:var(--spot-table-header-font-weight);color:var(--spot-table-header-font-color);font-family:var(--spot-table-header-font-family);padding:var(--spot-table-header-padding)}.spot-refund__table td{text-align:left;font-size:var(--spot-table-cell-font-size);font-weight:var(--spot-table-cell-font-weight);color:var(--spot-table-cell-font-color);font-family:var(--spot-table-cell-font-family);padding:var(--spot-table-cell-padding)}input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:.75rem;height:.75rem;min-width:.75rem;border:.0625rem solid var(--spot-radio-border);border-radius:var(--spot-radio-border-radius);margin-right:.5rem;position:relative;vertical-align:middle;top:-.0625rem;cursor:pointer;flex-shrink:0}input[type=radio]:checked{background:var(--spot-radio-checked-background);box-shadow:inset 0 0 0 .0625rem #fff}.spot-selection__options{display:flex;flex-direction:column;gap:.5rem}.spot-selection__option{display:flex;align-items:center;flex-wrap:nowrap;position:relative;transition:background .2s;cursor:pointer;font-size:var(--spot-radio-text-font-size);font-weight:var(--spot-radio-text-font-weight);color:var(--spot-radio-text-font-color);font-family:var(--spot-radio-text-font-family);padding:var(--spot-radio-text-padding);margin-right:.5rem}.spot-selection__option.selected{background:var(--spot-radio-selection-background);border-radius:var(--spot-radio-selection-border-radius);padding:var(--spot-radio-selection-padding)}.spot-selection__recommended-tag{background:var(--spot-recommended-tag-background);color:var(--spot-recommended-tag-font-color);font-size:var(--spot-recommended-tag-font-size);font-weight:var(--spot-recommended-tag-font-weight);padding:var(--spot-recommended-tag-padding);border-radius:var(--spot-recommended-tag-border-radius);margin-left:.75rem;white-space:nowrap;flex-shrink:0}@media (max-width: 850px){.spot-selection__recommended-tag{margin-left:.5rem}}@media (max-width: 600px){.spot-selection__recommended-tag{margin-left:.5rem;font-size:.75rem;padding:.1875rem .4375rem}}.spot-selection__error{color:var(--spot-selection-error-font-color);font-size:var(--spot-selection-error-font-size);padding:var(--spot-selection-error-padding);display:none}.spot-payment-terms__wrapper{margin-top:1rem}.spot-payment-terms__header{font-weight:var(--spot-payment-terms-header-font-weight);margin-bottom:.5rem;padding:var(--spot-payment-terms-header-padding);font-size:var(--spot-payment-terms-header-font-size);border-bottom:1px solid var(--spot-payment-terms-header-border-color)}.spot-payment-terms{background-color:var(--spot-payment-terms-background);border-radius:var(--spot-payment-terms-border-radius);padding:var(--spot-payment-terms-padding);margin-right:.5rem;color:var(--spot-payment-terms-font-color);font-size:var(--spot-payment-terms-font-size)}.spot-footer__terms{margin-top:.625rem;margin-right:.25rem;font-size:var(--spot-terms-font-size);font-weight:var(--spot-terms-font-weight);color:var(--spot-terms-font-color);font-family:var(--spot-terms-font-family);padding:var(--spot-terms-padding);line-height:1.4;word-wrap:normal;-webkit-hyphens:none;hyphens:none;flex:1;min-width:0;overflow-wrap:normal}.spot-footer__terms-link{text-decoration:var(--spot-terms-link-text-decoration);font-size:var(--spot-terms-link-font-size);font-weight:var(--spot-terms-link-font-weight);color:var(--spot-terms-link-font-color);font-family:var(--spot-terms-link-font-family);padding:var(--spot-terms-link-padding)}.spot-footer__container{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;flex-wrap:nowrap;gap:var(--spot-footer-gap)}@container (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}@media (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}.spot-footer__powered-by{margin-top:0;flex-shrink:0}.spot-logo__top-right{position:absolute;top:-14px;right:40px;z-index:10;background:#fff;padding:0 8px}@container (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}@media (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}";function j(m){const t=document.createElement("style");t.textContent=m,document.head.appendChild(t)}j(U);const D={sandbox:"https://api.sandbox.getspot.com/api/v1/quote",production:"https://api.getspot.com/api/v1/quote",local:"http://localhost:3999/api/v1/quote"};class B{constructor(t={}){this.options={location:"body",showTable:!0,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t,selection:t.selection??y.UNSELECTED},this._onResize=this._updateLayout.bind(this),this.root=typeof this.options.location=="string"?document.querySelector(this.options.location):this.options.location,this.currentSelection=this.options.selection,this._init()}async _init(){var t,o,s,i,r;try{I(this.options);let n;if(this.options.useMockData&&this.options.mockData)n=this.options.mockData;else{const{environment:e,partnerId:p}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||D[e];n="items"in this.options.quoteRequestData?await T(f,p,this.options.quoteRequestData):await E(f,p,this.options.quoteRequestData)}if(n.status!=="QUOTE_AVAILABLE"){n.status==="NO_MATCHING_QUOTE"&&((t=this.options.callbacks)!=null&&t.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=n.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.selection===y.YES&&((o=this.options.callbacks)!=null&&o.onOptIn)){const e={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const p=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=p.items)==null?void 0:h.find(v=>(v.cartItemId||`item-${p.items.indexOf(v)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(f==null?void 0:f.productPrice)||u.spotPrice,cartItemId:(f==null?void 0:f.cartItemId)||""}})}this.options.callbacks.onOptIn(e)}if((s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const e=this.options.callbacks.onQuoteRetrieved(this.quote);e&&this._applyQuoteUpdates(e)}}catch(n){if((i=this.options.callbacks)!=null&&i.onError){const e=n;(r=this.options.callbacks)==null||r.onError({message:e.message,status:e.status,responseBody:e.responseBody})}}}_renderWidget(){if(!this.quote)return;this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([s,i])=>{const r=`--${s}`;this.container.style.setProperty(r,i)}),S(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?$(t,this.quote.qualifyingReasons):P(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const s=this._getTotalItemsInRequest();V(t,this.quote.coveredItems,s)}this.options.showTable&&!this.quote.qualifyingReasons&&Q(t,this.quote.payoutSchedule);const o=R(t,this.options.selection,this.quote.communication);t.appendChild(o),this.paymentTermsEl=a("div",{className:"spot-payment-terms__wrapper",parent:t}),Z(this.container,this.quote,this.options.logoPosition),window.addEventListener("resize",this._onResize),this._setupResizeObserver(),this._updateLayout(),this._setupOptionListeners(o)}_updateLayout(){if(!this.container||!this.quote)return;const t=this.container.querySelector(".spot-content__wrapper"),o=this.options.showTable&&!this.quote.qualifyingReasons;if(!t||!o){t==null||t.classList.remove("desktop-layout");return}const s=this._shouldUseDesktopLayout(t);t.classList.toggle("desktop-layout",s)}_shouldUseDesktopLayout(t){const o=this.container.offsetWidth-40,s=325,i=16;if(o>=900)return!0;if(o>=650){const r=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const n=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!n)return r&&t.classList.add("desktop-layout"),r;const p=Math.min(n.scrollWidth,400)+s+i;return r&&t.classList.add("desktop-layout"),o>=p}return!1}_setupResizeObserver(){!this.container||!window.ResizeObserver||(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=window.setTimeout(()=>{this._updateLayout()},100)}),this._resizeObserver.observe(this.container))}_getTotalItemsInRequest(){return"items"in this.options.quoteRequestData?this.options.quoteRequestData.items.length:1}_applyQuoteUpdates(t){!this.quote||!this.container||(t.spotPriceWithFees!==void 0&&(this.quote.communication.yesOptionText=this.quote.communication.yesOptionText.replace(`$${this.quote.spotPrice.toFixed(2)}`,`$${t.spotPriceWithFees.toFixed(2)}`)),this.destroy(),this._renderWidget())}_setupOptionListeners(t){const o=t.querySelectorAll('input[type="radio"]'),s=t.querySelectorAll(".spot-selection__option");o.forEach(i=>{i.addEventListener("change",r=>{var p,u,f,h;const n=r.target,e=n.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(v=>v.classList.remove("selected")),(p=n.closest(".spot-selection__option"))==null||p.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),e===y.YES&&((u=this.quote)!=null&&u.communication.paymentTerms&&A(this.paymentTermsEl,this.quote),(f=this.options.callbacks)!=null&&f.onOptIn)){const v={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const c=this.options.quoteRequestData;v.batchQuoteDetails=this.quote.originalQuotes.map(l=>{var w;const d=(w=c.items)==null?void 0:w.find(b=>(b.cartItemId||`item-${c.items.indexOf(b)+1}`)===l.cartItemId);return{quoteId:l.id,productPrice:(d==null?void 0:d.productPrice)||l.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptIn(v)}if(e===y.NO&&((h=this.options.callbacks)!=null&&h.onOptOut)){const v={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const c=this.options.quoteRequestData;v.batchQuoteDetails=this.quote.originalQuotes.map(l=>{var w;const d=(w=c.items)==null?void 0:w.find(b=>(b.cartItemId||`item-${c.items.indexOf(b)+1}`)===l.cartItemId);return{quoteId:l.id,productPrice:(d==null?void 0:d.productPrice)||l.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptOut(v)}})})}showSelectionError(){var t;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const o=(t=this.container)==null?void 0:t.querySelector(".spot-selection__options");o&&o.insertAdjacentElement("afterend",this.errorEl)}this.errorEl.style.display="block"}hideSelectionError(){this.errorEl&&(this.errorEl.style.display="none")}validateSelection(){if(!this.container)return!1;const t=!!this.container.querySelector('input[name="selection"]:checked');return t?this.hideSelectionError():this.showSelectionError(),t}async updateQuote(t){var o,s,i,r;try{const n={...this.options,quoteRequestData:t};I(n);const{environment:e,partnerId:p,customEndpoint:u}=this.options.apiConfig,f=u||D[e],v="items"in n.quoteRequestData?await T(f,p,n.quoteRequestData):await E(f,p,n.quoteRequestData);if(v.status!=="QUOTE_AVAILABLE")return this.destroy(),v.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:n.quoteRequestData}),!1;if(this.options.quoteRequestData=n.quoteRequestData,this.quote=v.data,this.currentSelection=y.UNSELECTED,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const c=this.options.callbacks.onQuoteRetrieved(this.quote);c&&this._applyQuoteUpdates(c)}return!0}catch(n){const e=n;return(r=(i=this.options.callbacks)==null?void 0:i.onError)==null||r.call(i,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,i;if(this.currentSelection==null||this.currentSelection==y.UNSELECTED)return null;const t={selection:this.currentSelection,quoteId:(o=this.quote)==null?void 0:o.id,spotPrice:(s=this.quote)==null?void 0:s.spotPrice,status:this.currentSelection===y.YES?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};if((i=this.quote)!=null&&i.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(n=>{var p;const e=(p=r.items)==null?void 0:p.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===n.cartItemId);return{quoteId:n.id,productPrice:(e==null?void 0:e.productPrice)||n.spotPrice,cartItemId:(e==null?void 0:e.cartItemId)||""}})}return t}destroy(){window.removeEventListener("resize",this._onResize),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeTimeout&&window.clearTimeout(this._resizeTimeout),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}C.SelectionEnum=y,C.default=B,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAC1D,GAAG,EAAE,CAAC,EACN,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB,GACxE,qBAAqB,CAAC,CAAC,CAAC,CAS1B;AAGD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,WAAW,EACtB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAAC,GACjE,IAAI,CAWN;AAGD,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,MAAM,EAAO,GACrB,IAAI,CAcN;AAGD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,EACtB,iBAAiB,GAAE,gBAAgB,EAAO,GACzC,IAAI,CA0EN;AAGD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,YAAY,GAAE,MAAM,EAAO,EAC3B,mBAAmB,CAAC,EAAE,MAAM,GAC3B,IAAI,CAiHN;AAGD,wBAAgB,WAAW,CACzB,SAAS,EAAE,WAAW,EACtB,QAAQ,GAAE,kBAAkB,EAAO,GAClC,IAAI,CAyBN;AAGD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,aAAa,EACxB,aAAa,EAAE,aAAa,GAC3B,WAAW,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAC1D,GAAG,EAAE,CAAC,EACN,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB,GACxE,qBAAqB,CAAC,CAAC,CAAC,CAS1B;AAGD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,WAAW,EACtB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAAC,GACjE,IAAI,CAWN;AAGD,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,MAAM,EAAO,GACrB,IAAI,CAcN;AAGD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,EACtB,iBAAiB,GAAE,gBAAgB,EAAO,GACzC,IAAI,CA0EN;AAGD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,YAAY,GAAE,MAAM,EAAO,EAC3B,mBAAmB,CAAC,EAAE,MAAM,GAC3B,IAAI,CAiHN;AAGD,wBAAgB,WAAW,CACzB,SAAS,EAAE,WAAW,EACtB,QAAQ,GAAE,kBAAkB,EAAO,GAClC,IAAI,CAyBN;AAGD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,aAAa,EACxB,aAAa,EAAE,aAAa,GAC3B,WAAW,CA0Cb;AAGD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,GACX,WAAW,CAqBb;AAGD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,EACZ,YAAY,GAAE,cAAc,GAAG,WAA4B,GAC1D,WAAW,CAwEb"}
|