@getspot/spot-widget 3.2.3 → 3.2.5
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 +14 -0
- package/README.md +1 -0
- package/dist/index.es.js +103 -103
- package/dist/index.umd.js +4 -4
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [3.2.5](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.2.4...@getspot/spot-widget@3.2.5) (2025-12-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **core:** stop event propogation on covered items toggle ([357cd77](https://gitlab.com/getspot/spot-widget/commit/357cd77c01d9245b1ac852270b6494911307abf1))
|
|
7
|
+
|
|
8
|
+
## [3.2.4](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.2.3...@getspot/spot-widget@3.2.4) (2025-12-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **core:** map cartItemId to original quote logic update ([13bfa13](https://gitlab.com/getspot/spot-widget/commit/13bfa13c1ad2507f7ce5b58c3b2bdda7a576c0fb))
|
|
14
|
+
|
|
1
15
|
## [3.2.3](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.2.2...@getspot/spot-widget@3.2.3) (2025-12-10)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -61,7 +61,7 @@ async function I(m, t, o) {
|
|
|
61
61
|
return { status: "NO_MATCHING_QUOTE" };
|
|
62
62
|
const i = r.quotes.map((n) => {
|
|
63
63
|
const u = o.items.find(
|
|
64
|
-
(
|
|
64
|
+
(f, h) => (f.cartItemId || `item-${h + 1}`) === n.cartItemId
|
|
65
65
|
);
|
|
66
66
|
return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${n.id}`;
|
|
67
67
|
}), e = Math.round((r.totalSpotPrice || r.spotPrice || 0) * 100) / 100;
|
|
@@ -115,7 +115,7 @@ function D(m) {
|
|
|
115
115
|
throw new Error(`Invalid environment in apiConfig: ${i}`);
|
|
116
116
|
if (!o || typeof o != "object" && !Array.isArray(o))
|
|
117
117
|
throw new Error("quoteRequestData must be a non-null object or array");
|
|
118
|
-
const
|
|
118
|
+
const f = [
|
|
119
119
|
"startDate",
|
|
120
120
|
"endDate",
|
|
121
121
|
"currencyCode",
|
|
@@ -127,58 +127,58 @@ function D(m) {
|
|
|
127
127
|
"cartId",
|
|
128
128
|
"productName"
|
|
129
129
|
];
|
|
130
|
-
function
|
|
131
|
-
const l =
|
|
132
|
-
|
|
133
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
130
|
+
function h(d, p = null) {
|
|
131
|
+
const l = p !== null ? `quoteRequestData[${p}]` : "quoteRequestData";
|
|
132
|
+
f.forEach((v) => {
|
|
133
|
+
if (!Object.prototype.hasOwnProperty.call(d, v) || d[v] === void 0 || d[v] === null)
|
|
134
134
|
throw new Error(`Missing required ${l} field: '${v}'`);
|
|
135
135
|
});
|
|
136
136
|
const w = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
|
|
137
|
-
if (!w.test(
|
|
137
|
+
if (!w.test(d.startDate))
|
|
138
138
|
throw new Error(`${l}.startDate must be a valid ISO8601 string`);
|
|
139
|
-
if (!w.test(
|
|
139
|
+
if (!w.test(d.endDate))
|
|
140
140
|
throw new Error(`${l}.endDate must be a valid ISO8601 string`);
|
|
141
|
-
if (typeof
|
|
141
|
+
if (typeof d.currencyCode != "string")
|
|
142
142
|
throw new Error(`${l}.currencyCode must be a string`);
|
|
143
|
-
if (!["USD", "CAD", "AUD"].includes(
|
|
144
|
-
throw new Error(`Invalid ${l}.currencyCode: ${
|
|
145
|
-
if (typeof
|
|
143
|
+
if (!["USD", "CAD", "AUD"].includes(d.currencyCode))
|
|
144
|
+
throw new Error(`Invalid ${l}.currencyCode: ${d.currencyCode}`);
|
|
145
|
+
if (typeof d.eventType != "string")
|
|
146
146
|
throw new Error(`${l}.eventType must be a string`);
|
|
147
|
-
if (typeof
|
|
147
|
+
if (typeof d.productType != "string")
|
|
148
148
|
throw new Error(`${l}.productType must be a string`);
|
|
149
149
|
const g = ["Pass", "Trip", "Registration"];
|
|
150
|
-
if (!g.includes(
|
|
150
|
+
if (!g.includes(d.productType))
|
|
151
151
|
throw new Error(
|
|
152
152
|
`${l}.productType must be one of ${g.join(", ")}`
|
|
153
153
|
);
|
|
154
|
-
if (typeof
|
|
154
|
+
if (typeof d.productDuration != "string")
|
|
155
155
|
throw new Error(`${l}.productDuration must be a string`);
|
|
156
156
|
const b = ["Daily", "Seasonal", "Trip", "Event"];
|
|
157
|
-
if (!b.includes(
|
|
157
|
+
if (!b.includes(d.productDuration))
|
|
158
158
|
throw new Error(
|
|
159
159
|
`${l}.productDuration must be one of ${b.join(", ")}`
|
|
160
160
|
);
|
|
161
|
-
if (typeof
|
|
161
|
+
if (typeof d.productPrice != "number" || isNaN(d.productPrice))
|
|
162
162
|
throw new Error(`${l}.productPrice must be a valid number`);
|
|
163
|
-
if (typeof
|
|
163
|
+
if (typeof d.productId != "string")
|
|
164
164
|
throw new Error(`${l}.productId must be a string`);
|
|
165
|
-
if (typeof
|
|
165
|
+
if (typeof d.cartId != "string")
|
|
166
166
|
throw new Error(`${l}.cartId must be a string`);
|
|
167
|
-
if (typeof
|
|
167
|
+
if (typeof d.productName != "string")
|
|
168
168
|
throw new Error(`${l}.productName must be a string`);
|
|
169
169
|
}
|
|
170
170
|
if ("cartInfo" in o && "items" in o) {
|
|
171
|
-
const
|
|
172
|
-
if (!
|
|
171
|
+
const d = o, { cartInfo: p, items: l } = d;
|
|
172
|
+
if (!p || typeof p != "object")
|
|
173
173
|
throw new Error("quoteRequestData.cartInfo must be a non-null object");
|
|
174
|
-
if (!
|
|
174
|
+
if (!p.cartId || typeof p.cartId != "string")
|
|
175
175
|
throw new Error("quoteRequestData.cartInfo.cartId must be a string");
|
|
176
|
-
if (!
|
|
176
|
+
if (!p.cartName || typeof p.cartName != "string")
|
|
177
177
|
throw new Error("quoteRequestData.cartInfo.cartName must be a string");
|
|
178
|
-
if (!
|
|
178
|
+
if (!p.currencyCode || typeof p.currencyCode != "string")
|
|
179
179
|
throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");
|
|
180
|
-
if (!["USD", "CAD", "AUD"].includes(
|
|
181
|
-
throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${
|
|
180
|
+
if (!["USD", "CAD", "AUD"].includes(p.currencyCode))
|
|
181
|
+
throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${p.currencyCode}`);
|
|
182
182
|
if (!Array.isArray(l) || l.length === 0)
|
|
183
183
|
throw new Error("quoteRequestData.items must be a non-empty array");
|
|
184
184
|
const _ = [
|
|
@@ -226,23 +226,23 @@ function D(m) {
|
|
|
226
226
|
} else if (Array.isArray(o)) {
|
|
227
227
|
if (o.length === 0)
|
|
228
228
|
throw new Error("quoteRequestData array cannot be empty");
|
|
229
|
-
o.forEach((
|
|
230
|
-
if (!
|
|
231
|
-
throw new Error(`quoteRequestData[${
|
|
232
|
-
|
|
229
|
+
o.forEach((d, p) => {
|
|
230
|
+
if (!d || typeof d != "object")
|
|
231
|
+
throw new Error(`quoteRequestData[${p}] must be a non-null object`);
|
|
232
|
+
h(d, p);
|
|
233
233
|
});
|
|
234
234
|
} else
|
|
235
|
-
|
|
235
|
+
h(o);
|
|
236
236
|
if ([
|
|
237
237
|
"onOptIn",
|
|
238
238
|
"onOptOut",
|
|
239
239
|
"onQuoteRetrieved",
|
|
240
240
|
"onError",
|
|
241
241
|
"noMatchingQuote"
|
|
242
|
-
].forEach((
|
|
243
|
-
const
|
|
244
|
-
if (
|
|
245
|
-
throw new Error(`Callback '${
|
|
242
|
+
].forEach((d) => {
|
|
243
|
+
const p = s[d];
|
|
244
|
+
if (p && typeof p != "function")
|
|
245
|
+
throw new Error(`Callback '${d}' must be a function.`);
|
|
246
246
|
}), typeof a == "string" && !document.querySelector(a))
|
|
247
247
|
throw new Error(`Invalid location selector: '${a}'`);
|
|
248
248
|
if (r && typeof r != "object")
|
|
@@ -310,23 +310,23 @@ function L(m, t = []) {
|
|
|
310
310
|
i = "./assets/";
|
|
311
311
|
}
|
|
312
312
|
s.forEach((e) => {
|
|
313
|
-
var
|
|
313
|
+
var h, y, d;
|
|
314
314
|
const n = c("div", {
|
|
315
315
|
className: "spot-qualifying-reasons__item",
|
|
316
316
|
parent: a
|
|
317
317
|
}), u = c("div", {
|
|
318
318
|
className: "spot-qualifying-reasons__icon-wrapper",
|
|
319
319
|
parent: n
|
|
320
|
-
}),
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
320
|
+
}), f = r[((h = e.benefitType) == null ? void 0 : h.name) || ""] || r[e.name || ""];
|
|
321
|
+
if (f) {
|
|
322
|
+
const p = c("img", {
|
|
323
323
|
parent: u
|
|
324
324
|
});
|
|
325
|
-
|
|
325
|
+
p.src = i + f, p.alt = ((y = e.benefitType) == null ? void 0 : y.name) || e.name || "", p.className = "spot-qualifying-reasons__icon";
|
|
326
326
|
}
|
|
327
327
|
c("span", {
|
|
328
328
|
className: "spot-qualifying-reasons__label",
|
|
329
|
-
text: ((
|
|
329
|
+
text: ((d = e.benefitType) == null ? void 0 : d.name) || e.name || "",
|
|
330
330
|
parent: n
|
|
331
331
|
});
|
|
332
332
|
});
|
|
@@ -335,18 +335,18 @@ function O(m, t = [], o) {
|
|
|
335
335
|
if (t.length === 0 || !o || o <= 1)
|
|
336
336
|
return;
|
|
337
337
|
const s = /* @__PURE__ */ new Map();
|
|
338
|
-
t.forEach((
|
|
339
|
-
s.set(
|
|
338
|
+
t.forEach((p) => {
|
|
339
|
+
s.set(p, (s.get(p) || 0) + 1);
|
|
340
340
|
});
|
|
341
341
|
const r = Array.from(s.entries()).map(
|
|
342
|
-
([
|
|
343
|
-
item:
|
|
342
|
+
([p, l]) => ({
|
|
343
|
+
item: p,
|
|
344
344
|
count: l,
|
|
345
|
-
displayText: l > 1 ? `${l} x ${
|
|
345
|
+
displayText: l > 1 ? `${l} x ${p}` : p
|
|
346
346
|
})
|
|
347
|
-
).sort((
|
|
348
|
-
const w =
|
|
349
|
-
return !g && b ? -1 : g && !b ? 1 :
|
|
347
|
+
).sort((p, l) => {
|
|
348
|
+
const w = p.item.charAt(0), _ = l.item.charAt(0), g = /[a-zA-Z]/.test(w), b = /[a-zA-Z]/.test(_);
|
|
349
|
+
return !g && b ? -1 : g && !b ? 1 : p.item.localeCompare(l.item, void 0, { sensitivity: "base" });
|
|
350
350
|
}), i = c("div", {
|
|
351
351
|
className: "spot-covered-items__container",
|
|
352
352
|
parent: m
|
|
@@ -371,27 +371,27 @@ function O(m, t = [], o) {
|
|
|
371
371
|
text: "View All",
|
|
372
372
|
parent: u
|
|
373
373
|
});
|
|
374
|
-
const
|
|
374
|
+
const f = c("span", {
|
|
375
375
|
className: "spot-covered-items__arrow",
|
|
376
376
|
innerHTML: "▼",
|
|
377
377
|
parent: u
|
|
378
|
-
}),
|
|
378
|
+
}), h = c("div", {
|
|
379
379
|
className: "spot-covered-items__content",
|
|
380
380
|
parent: i
|
|
381
381
|
}), y = c("ul", {
|
|
382
382
|
className: "spot-covered-items__list",
|
|
383
|
-
parent:
|
|
383
|
+
parent: h
|
|
384
384
|
});
|
|
385
|
-
r.forEach(({ displayText:
|
|
385
|
+
r.forEach(({ displayText: p }) => {
|
|
386
386
|
const l = c("li", { parent: y });
|
|
387
|
-
c("span", { text:
|
|
387
|
+
c("span", { text: p, parent: l });
|
|
388
388
|
});
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
p = !
|
|
392
|
-
}), n.setAttribute("aria-expanded", "false"), n.setAttribute("aria-controls", "covered-items-list"),
|
|
389
|
+
let d = !1;
|
|
390
|
+
h.style.display = "none", n.addEventListener("click", (p) => {
|
|
391
|
+
p.stopPropagation(), d = !d, h.style.display = d ? "block" : "none", f.innerHTML = d ? "▲" : "▼", n.setAttribute("aria-expanded", d.toString());
|
|
392
|
+
}), n.setAttribute("aria-expanded", "false"), n.setAttribute("aria-controls", "covered-items-list"), h.setAttribute("id", "covered-items-list");
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function P(m, t = []) {
|
|
395
395
|
const o = c("div", {
|
|
396
396
|
className: "spot-table__container",
|
|
397
397
|
parent: m
|
|
@@ -402,13 +402,13 @@ function $(m, t = []) {
|
|
|
402
402
|
c("th", { text: "When you cancel", parent: r }), c("th", { text: "You will receive", parent: r });
|
|
403
403
|
const i = c("tbody", { parent: s });
|
|
404
404
|
t.forEach(({ text: e, percent: n, amount: u }) => {
|
|
405
|
-
const
|
|
406
|
-
c("td", { text: e, parent:
|
|
407
|
-
const
|
|
408
|
-
c("td", { text:
|
|
405
|
+
const f = c("tr", { parent: i });
|
|
406
|
+
c("td", { text: e, parent: f });
|
|
407
|
+
const h = n === "Not eligible for refund" ? "Not eligible for a refund" : `$${u} refund`;
|
|
408
|
+
c("td", { text: h, parent: f });
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function $(m, t, o) {
|
|
412
412
|
const s = c("div", {
|
|
413
413
|
className: "spot-selection__options",
|
|
414
414
|
parent: m
|
|
@@ -539,13 +539,13 @@ class A {
|
|
|
539
539
|
if (this.options.useMockData && this.options.mockData)
|
|
540
540
|
i = this.options.mockData;
|
|
541
541
|
else {
|
|
542
|
-
const { environment: e, partnerId: n } = this.options.apiConfig,
|
|
542
|
+
const { environment: e, partnerId: n } = this.options.apiConfig, f = this.options.apiConfig.customEndpoint || T[e];
|
|
543
543
|
i = "cartInfo" in this.options.quoteRequestData && "items" in this.options.quoteRequestData ? await I(
|
|
544
|
-
|
|
544
|
+
f,
|
|
545
545
|
n,
|
|
546
546
|
this.options.quoteRequestData
|
|
547
547
|
) : await x(
|
|
548
|
-
|
|
548
|
+
f,
|
|
549
549
|
n,
|
|
550
550
|
this.options.quoteRequestData
|
|
551
551
|
);
|
|
@@ -568,14 +568,14 @@ class A {
|
|
|
568
568
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
569
569
|
const n = this.options.quoteRequestData;
|
|
570
570
|
e.batchQuoteDetails = this.quote.originalQuotes.map((u) => {
|
|
571
|
-
var
|
|
572
|
-
const
|
|
573
|
-
(y) => (y.cartItemId || `item-${n.items.indexOf(y) + 1}`) === u.
|
|
571
|
+
var h;
|
|
572
|
+
const f = (h = n.items) == null ? void 0 : h.find(
|
|
573
|
+
(y) => (y.cartItemId || `item-${n.items.indexOf(y) + 1}`) === u.cartItemId
|
|
574
574
|
);
|
|
575
575
|
return {
|
|
576
576
|
quoteId: u.id,
|
|
577
|
-
productPrice: (
|
|
578
|
-
cartItemId:
|
|
577
|
+
productPrice: (f == null ? void 0 : f.productPrice) || u.spotPrice,
|
|
578
|
+
cartItemId: (f == null ? void 0 : f.cartItemId) || ""
|
|
579
579
|
};
|
|
580
580
|
});
|
|
581
581
|
}
|
|
@@ -607,8 +607,8 @@ class A {
|
|
|
607
607
|
const s = this._getTotalItemsInRequest();
|
|
608
608
|
O(t, this.quote.coveredItems, s);
|
|
609
609
|
}
|
|
610
|
-
this.options.showTable && !this.quote.qualifyingReasons &&
|
|
611
|
-
const o =
|
|
610
|
+
this.options.showTable && !this.quote.qualifyingReasons && P(t, this.quote.payoutSchedule);
|
|
611
|
+
const o = $(
|
|
612
612
|
t,
|
|
613
613
|
this.options.optInSelected,
|
|
614
614
|
this.quote.communication
|
|
@@ -669,54 +669,54 @@ class A {
|
|
|
669
669
|
), s = t.querySelectorAll(".spot-selection__option");
|
|
670
670
|
o.forEach((a) => {
|
|
671
671
|
a.addEventListener("change", (r) => {
|
|
672
|
-
var n, u,
|
|
672
|
+
var n, u, f;
|
|
673
673
|
const i = r.target, e = i.value;
|
|
674
|
-
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((
|
|
675
|
-
const
|
|
674
|
+
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((h) => h.classList.remove("selected")), (n = i.closest(".spot-selection__option")) == null || n.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e === "yes" && (this.options.quoteRequestData.isPartialPayment && R(this.paymentTermsEl, this.quote), (u = this.options.callbacks) != null && u.onOptIn)) {
|
|
675
|
+
const h = {
|
|
676
676
|
status: "QUOTE_ACCEPTED",
|
|
677
677
|
spotPrice: this.quote.spotPrice,
|
|
678
678
|
quoteId: this.quote.id
|
|
679
679
|
};
|
|
680
680
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
681
681
|
const y = this.options.quoteRequestData;
|
|
682
|
-
|
|
683
|
-
(
|
|
682
|
+
h.batchQuoteDetails = this.quote.originalQuotes.map(
|
|
683
|
+
(d) => {
|
|
684
684
|
var l;
|
|
685
|
-
const
|
|
686
|
-
(w) => (w.cartItemId || `item-${y.items.indexOf(w) + 1}`) ===
|
|
685
|
+
const p = (l = y.items) == null ? void 0 : l.find(
|
|
686
|
+
(w) => (w.cartItemId || `item-${y.items.indexOf(w) + 1}`) === d.cartItemId
|
|
687
687
|
);
|
|
688
688
|
return {
|
|
689
|
-
quoteId:
|
|
690
|
-
productPrice: (
|
|
691
|
-
cartItemId: p.
|
|
689
|
+
quoteId: d.id,
|
|
690
|
+
productPrice: (p == null ? void 0 : p.productPrice) || d.spotPrice,
|
|
691
|
+
cartItemId: (p == null ? void 0 : p.cartItemId) || ""
|
|
692
692
|
};
|
|
693
693
|
}
|
|
694
694
|
);
|
|
695
695
|
}
|
|
696
|
-
this.options.callbacks.onOptIn(
|
|
696
|
+
this.options.callbacks.onOptIn(h);
|
|
697
697
|
}
|
|
698
|
-
if (e === "no" && ((
|
|
699
|
-
const
|
|
698
|
+
if (e === "no" && ((f = this.options.callbacks) != null && f.onOptOut)) {
|
|
699
|
+
const h = {
|
|
700
700
|
status: "QUOTE_DECLINED",
|
|
701
701
|
quoteId: this.quote.id
|
|
702
702
|
};
|
|
703
703
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
704
704
|
const y = this.options.quoteRequestData;
|
|
705
|
-
|
|
706
|
-
(
|
|
705
|
+
h.batchQuoteDetails = this.quote.originalQuotes.map(
|
|
706
|
+
(d) => {
|
|
707
707
|
var l;
|
|
708
|
-
const
|
|
709
|
-
(w) => (w.cartItemId || `item-${y.items.indexOf(w) + 1}`) ===
|
|
708
|
+
const p = (l = y.items) == null ? void 0 : l.find(
|
|
709
|
+
(w) => (w.cartItemId || `item-${y.items.indexOf(w) + 1}`) === d.cartItemId
|
|
710
710
|
);
|
|
711
711
|
return {
|
|
712
|
-
quoteId:
|
|
713
|
-
productPrice: (
|
|
714
|
-
cartItemId: p.
|
|
712
|
+
quoteId: d.id,
|
|
713
|
+
productPrice: (p == null ? void 0 : p.productPrice) || d.spotPrice,
|
|
714
|
+
cartItemId: (p == null ? void 0 : p.cartItemId) || ""
|
|
715
715
|
};
|
|
716
716
|
}
|
|
717
717
|
);
|
|
718
718
|
}
|
|
719
|
-
this.options.callbacks.onOptOut(
|
|
719
|
+
this.options.callbacks.onOptOut(h);
|
|
720
720
|
}
|
|
721
721
|
});
|
|
722
722
|
});
|
|
@@ -750,12 +750,12 @@ class A {
|
|
|
750
750
|
quoteRequestData: t
|
|
751
751
|
};
|
|
752
752
|
D(i);
|
|
753
|
-
const { environment: e, partnerId: n, customEndpoint: u } = this.options.apiConfig,
|
|
754
|
-
|
|
753
|
+
const { environment: e, partnerId: n, customEndpoint: u } = this.options.apiConfig, f = u || T[e], y = "cartInfo" in i.quoteRequestData && "items" in i.quoteRequestData ? await I(
|
|
754
|
+
f,
|
|
755
755
|
n,
|
|
756
756
|
i.quoteRequestData
|
|
757
757
|
) : await x(
|
|
758
|
-
|
|
758
|
+
f,
|
|
759
759
|
n,
|
|
760
760
|
i.quoteRequestData
|
|
761
761
|
);
|
|
@@ -765,8 +765,8 @@ class A {
|
|
|
765
765
|
data: i.quoteRequestData
|
|
766
766
|
}), !1;
|
|
767
767
|
if (this.options.quoteRequestData = i.quoteRequestData, this.quote = y.data, this.currentSelection = null, this.destroy(), this._renderWidget(), (s = this.options.callbacks) != null && s.onQuoteRetrieved) {
|
|
768
|
-
const
|
|
769
|
-
|
|
768
|
+
const d = this.options.callbacks.onQuoteRetrieved(this.quote);
|
|
769
|
+
d && this._applyQuoteUpdates(d);
|
|
770
770
|
}
|
|
771
771
|
return !0;
|
|
772
772
|
} catch (i) {
|
|
@@ -792,12 +792,12 @@ class A {
|
|
|
792
792
|
t.batchQuoteDetails = this.quote.originalQuotes.map((i) => {
|
|
793
793
|
var n;
|
|
794
794
|
const e = (n = r.items) == null ? void 0 : n.find(
|
|
795
|
-
(u) => (u.cartItemId || `item-${r.items.indexOf(u) + 1}`) === i.
|
|
795
|
+
(u) => (u.cartItemId || `item-${r.items.indexOf(u) + 1}`) === i.cartItemId
|
|
796
796
|
);
|
|
797
797
|
return {
|
|
798
798
|
quoteId: i.id,
|
|
799
799
|
productPrice: (e == null ? void 0 : e.productPrice) || i.spotPrice,
|
|
800
|
-
cartItemId:
|
|
800
|
+
cartItemId: (e == null ? void 0 : e.cartItemId) || ""
|
|
801
801
|
};
|
|
802
802
|
});
|
|
803
803
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(_,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(_=typeof globalThis<"u"?globalThis:_||self,_.SpotWidget=C())})(this,function(){"use strict";async function _(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)}),a=await s.json();if(!s.ok){const r=new Error((a==null?void 0:a.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=a,r}return a}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function C(m,t,o){try{const s=m.replace("/quote","/quote/batch"),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await a.json();if(!a.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=a.status,i.responseBody=r,i}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function x(m,t,o){var s;try{const a={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((n,u)=>({cartItemId:n.cartItemId||`item-${u+1}`,productPrice:n.productPrice,productType:n.productType,productDuration:n.productDuration,productId:n.productId,productName:n.productName,participantDescription:n.participantDescription,eventType:n.eventType,eventId:n.eventId,startDate:n.startDate,endDate:n.endDate}))},r=await C(m,t,a);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=r.quotes.map(n=>{const u=o.items.find((h
|
|
1
|
+
(function(_,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(_=typeof globalThis<"u"?globalThis:_||self,_.SpotWidget=C())})(this,function(){"use strict";async function _(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)}),a=await s.json();if(!s.ok){const r=new Error((a==null?void 0:a.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=a,r}return a}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function C(m,t,o){try{const s=m.replace("/quote","/quote/batch"),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await a.json();if(!a.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=a.status,i.responseBody=r,i}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function x(m,t,o){var s;try{const a={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((n,u)=>({cartItemId:n.cartItemId||`item-${u+1}`,productPrice:n.productPrice,productType:n.productType,productDuration:n.productDuration,productId:n.productId,productName:n.productName,participantDescription:n.participantDescription,eventType:n.eventType,eventId:n.eventId,startDate:n.startDate,endDate:n.endDate}))},r=await C(m,t,a);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=r.quotes.map(n=>{const u=o.items.find((f,h)=>(f.cartItemId||`item-${h+1}`)===n.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${n.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(n=>n.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(n=>({...n,amount:n.amount!==void 0?n.amount:0})),coveredItems:i,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:i}}catch(a){throw a instanceof Error?a:new Error("Unknown error occurred while fetching multiple quotes")}}const z={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function E(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:a,theme:r}=m,{environment:i="sandbox",partnerId:e,customEndpoint:n}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(n||z[i]))throw new Error(`Invalid environment in apiConfig: ${i}`);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(d,p=null){const l=p!==null?`quoteRequestData[${p}]`:"quoteRequestData";f.forEach(v=>{if(!Object.prototype.hasOwnProperty.call(d,v)||d[v]===void 0||d[v]===null)throw new Error(`Missing required ${l} field: '${v}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(d.startDate))throw new Error(`${l}.startDate must be a valid ISO8601 string`);if(!w.test(d.endDate))throw new Error(`${l}.endDate must be a valid ISO8601 string`);if(typeof d.currencyCode!="string")throw new Error(`${l}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(d.currencyCode))throw new Error(`Invalid ${l}.currencyCode: ${d.currencyCode}`);if(typeof d.eventType!="string")throw new Error(`${l}.eventType must be a string`);if(typeof d.productType!="string")throw new Error(`${l}.productType must be a string`);const g=["Pass","Trip","Registration"];if(!g.includes(d.productType))throw new Error(`${l}.productType must be one of ${g.join(", ")}`);if(typeof d.productDuration!="string")throw new Error(`${l}.productDuration must be a string`);const b=["Daily","Seasonal","Trip","Event"];if(!b.includes(d.productDuration))throw new Error(`${l}.productDuration must be one of ${b.join(", ")}`);if(typeof d.productPrice!="number"||isNaN(d.productPrice))throw new Error(`${l}.productPrice must be a valid number`);if(typeof d.productId!="string")throw new Error(`${l}.productId must be a string`);if(typeof d.cartId!="string")throw new Error(`${l}.cartId must be a string`);if(typeof d.productName!="string")throw new Error(`${l}.productName must be a string`)}if("cartInfo"in o&&"items"in o){const d=o,{cartInfo:p,items:l}=d;if(!p||typeof p!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!p.cartId||typeof p.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!p.cartName||typeof p.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!p.currencyCode||typeof p.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(p.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${p.currencyCode}`);if(!Array.isArray(l)||l.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const q=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];l.forEach((g,b)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${b}] must be a non-null object`);const v=`quoteRequestData.items[${b}]`;q.forEach(k=>{if(!Object.prototype.hasOwnProperty.call(g,k)||g[k]===void 0||g[k]===null)throw new Error(`Missing required ${v} field: '${k}'`)});const D=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!D.test(g.startDate))throw new Error(`${v}.startDate must be a valid ISO8601 string`);if(!D.test(g.endDate))throw new Error(`${v}.endDate must be a valid ISO8601 string`);if(typeof g.eventType!="string")throw new Error(`${v}.eventType must be a string`);if(typeof g.productType!="string")throw new Error(`${v}.productType must be a string`);const T=["Pass","Trip","Registration"];if(!T.includes(g.productType))throw new Error(`${v}.productType must be one of ${T.join(", ")}`);if(typeof g.productDuration!="string")throw new Error(`${v}.productDuration must be a string`);const H=["Daily","Seasonal","Trip","Event"];if(!H.includes(g.productDuration))throw new Error(`${v}.productDuration must be one of ${H.join(", ")}`);if(typeof g.productPrice!="number"||isNaN(g.productPrice))throw new Error(`${v}.productPrice must be a valid number`);if(typeof g.productId!="string")throw new Error(`${v}.productId must be a string`);if(typeof g.productName!="string")throw new Error(`${v}.productName must be a string`)})}else if(Array.isArray(o)){if(o.length===0)throw new Error("quoteRequestData array cannot be empty");o.forEach((d,p)=>{if(!d||typeof d!="object")throw new Error(`quoteRequestData[${p}] must be a non-null object`);h(d,p)})}else h(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(d=>{const p=s[d];if(p&&typeof p!="function")throw new Error(`Callback '${d}' must be a function.`)}),typeof a=="string"&&!document.querySelector(a))throw new Error(`Invalid location selector: '${a}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function c(m,{text:t,className:o,parent:s,innerHTML:a,href:r,target:i}={}){const e=document.createElement(m);return o&&(e.className=o),t!=null&&(e.textContent=t),a!=null&&(e.innerHTML=a),r&&"href"in e&&(e.href=r),i&&"target"in e&&(e.target=i),s&&s.appendChild(e),e}function N(m,{name:t,description:o}){c("div",{className:"spot-header__title",text:t,parent:m}),c("div",{className:"spot-header__description",text:o,parent:m})}function M(m,t=[]){const o=c("ul",{className:"spot-benefits__list",parent:m});t.forEach(s=>{const a=c("li",{parent:o});a.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>`,
|
|
5
|
+
</svg>`,c("span",{text:s,parent:a})})}function L(m,t=[]){if(!t||t.length===0)return;const o=c("div",{className:"spot-qualifying-reasons__container",parent:m}),s=[...t].sort((e,n)=>e.rank-n.rank),a=c("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 i;try{const e=document.currentScript;if(e!=null&&e.src){const n=new URL(e.src);i=n.origin+n.pathname.replace(/\/[^/]*$/,"/")}else i=window.location.origin+window.location.pathname.replace(/\/[^/]*$/,"/");i+="assets/"}catch{i="./assets/"}s.forEach(e=>{var h,y,d;const n=c("div",{className:"spot-qualifying-reasons__item",parent:a}),u=c("div",{className:"spot-qualifying-reasons__icon-wrapper",parent:n}),f=r[((h=e.benefitType)==null?void 0:h.name)||""]||r[e.name||""];if(f){const p=c("img",{parent:u});p.src=i+f,p.alt=((y=e.benefitType)==null?void 0:y.name)||e.name||"",p.className="spot-qualifying-reasons__icon"}c("span",{className:"spot-qualifying-reasons__label",text:((d=e.benefitType)==null?void 0:d.name)||e.name||"",parent:n})})}function O(m,t=[],o){if(t.length===0||!o||o<=1)return;const s=new Map;t.forEach(p=>{s.set(p,(s.get(p)||0)+1)});const r=Array.from(s.entries()).map(([p,l])=>({item:p,count:l,displayText:l>1?`${l} x ${p}`:p})).sort((p,l)=>{const w=p.item.charAt(0),q=l.item.charAt(0),g=/[a-zA-Z]/.test(w),b=/[a-zA-Z]/.test(q);return!g&&b?-1:g&&!b?1:p.item.localeCompare(l.item,void 0,{sensitivity:"base"})}),i=c("div",{className:"spot-covered-items__container",parent:m}),e=c("div",{className:"spot-covered-items__header",parent:i}),n=c("button",{className:"spot-covered-items__toggle",parent:e});c("span",{className:"spot-covered-items__title",text:`Items Covered in Your Cart (${t.length})`,parent:n});const u=c("div",{className:"spot-covered-items__right-section",parent:n});c("span",{className:"spot-covered-items__view-all",text:"View All",parent:u});const f=c("span",{className:"spot-covered-items__arrow",innerHTML:"▼",parent:u}),h=c("div",{className:"spot-covered-items__content",parent:i}),y=c("ul",{className:"spot-covered-items__list",parent:h});r.forEach(({displayText:p})=>{const l=c("li",{parent:y});c("span",{text:p,parent:l})});let d=!1;h.style.display="none",n.addEventListener("click",p=>{p.stopPropagation(),d=!d,h.style.display=d?"block":"none",f.innerHTML=d?"▲":"▼",n.setAttribute("aria-expanded",d.toString())}),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-controls","covered-items-list"),h.setAttribute("id","covered-items-list")}function P(m,t=[]){const o=c("div",{className:"spot-table__container",parent:m}),s=c("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),a=c("thead",{parent:s}),r=c("tr",{parent:a});c("th",{text:"When you cancel",parent:r}),c("th",{text:"You will receive",parent:r});const i=c("tbody",{parent:s});t.forEach(({text:e,percent:n,amount:u})=>{const f=c("tr",{parent:i});c("td",{text:e,parent:f});const h=n==="Not eligible for refund"?"Not eligible for a refund":`$${u} refund`;c("td",{text:h,parent:f})})}function $(m,t,o){const s=c("div",{className:"spot-selection__options",parent:m}),a=c("label",{className:`spot-selection__option ${t?"selected":""}`,parent:s}),r=c("input",{parent:a});r.type="radio",r.name="selection",r.value="yes",t&&(r.checked=!0),c("strong",{text:o.yesOptionText,parent:a}),c("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:a});const i=c("label",{className:"spot-selection__option",parent:s}),e=c("input",{parent:i});return e.type="radio",e.name="selection",e.value="no",c("span",{text:o.noOptionText,parent:i}),s}function R(m,t){var a;const o=(a=t.communication)==null?void 0:a.paymentTerms,s=c("div",{className:"spot-payment-terms",parent:m});return c("div",{className:"spot-payment-terms__header",text:"PAYMENT TERMS",parent:s}),c("div",{className:"spot-payment-terms__body",text:o||"",parent:s}),s}function V(m,t,o="bottom-right"){if(o==="top-right"){const e=c("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"/>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
|
|
18
18
|
</clipPath>
|
|
19
19
|
</defs>
|
|
20
|
-
</svg>`}const s=
|
|
20
|
+
</svg>`}const s=c("div",{className:"spot-footer__container",parent:m}),a=c("div",{className:"spot-footer__terms",parent:s}),r=`<a href="${t.communication.termsAndConditionsUrl}" target="_blank" class="spot-footer__terms-link">Terms & Conditions</a>`,i=t.communication.legalDisclaimer.replace(/terms (and|&) conditions/gi,r);if(c("span",{innerHTML:i,parent:a}),o==="bottom-right"){const e=c("p",{className:"spot-footer__powered-by",parent:s});e.innerHTML=`
|
|
21
21
|
<svg width="145" height="28" viewBox="0 0 145 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
22
22
|
<rect width="145" height="28"/>
|
|
23
23
|
<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 S=":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 Q(m){const t=document.createElement("style");t.textContent=m,document.head.appendChild(t)}Q(S);const I={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 A{constructor(t={}){this.options={location:"body",showTable:!0,optInSelected:!1,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t},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.optInSelected?"yes":null,this._init()}async _init(){var t,o,s,a,r;try{E(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:n}=this.options.apiConfig,h=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await x(h,n,this.options.quoteRequestData):await _(h,n,this.options.quoteRequestData)}if(i.status!=="QUOTE_AVAILABLE"){i.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=i.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.optInSelected&&((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 n=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var f;const h=(f=n.items)==null?void 0:f.find(y=>(y.cartItemId||`item-${n.items.indexOf(y)+1}`)===u.id);return{quoteId:u.id,productPrice:(h==null?void 0:h.productPrice)||u.spotPrice,cartItemId:u.id}})}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(i){if((a=this.options.callbacks)!=null&&a.onError){const e=i;(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,a])=>{const r=`--${s}`;this.container.style.setProperty(r,a)}),N(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?L(t,this.quote.qualifyingReasons):M(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const s=this._getTotalItemsInRequest();O(t,this.quote.coveredItems,s)}this.options.showTable&&!this.quote.qualifyingReasons&&$(t,this.quote.payoutSchedule);const o=P(t,this.options.optInSelected,this.quote.communication);t.appendChild(o),this.paymentTermsEl=p("div",{className:"spot-payment-terms__wrapper",parent:t}),V(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,a=16;if(o>=900)return!0;if(o>=650){const r=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const i=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!i)return r&&t.classList.add("desktop-layout"),r;const n=Math.min(i.scrollWidth,400)+s+a;return r&&t.classList.add("desktop-layout"),o>=n}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"cartInfo"in this.options.quoteRequestData&&"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(a=>{a.addEventListener("change",r=>{var n,u,h;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(f=>f.classList.remove("selected")),(n=i.closest(".spot-selection__option"))==null||n.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),e==="yes"&&(this.options.quoteRequestData.isPartialPayment&&R(this.paymentTermsEl,this.quote),(u=this.options.callbacks)!=null&&u.onOptIn)){const f={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;f.batchQuoteDetails=this.quote.originalQuotes.map(c=>{var l;const d=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===c.id);return{quoteId:c.id,productPrice:(d==null?void 0:d.productPrice)||c.spotPrice,cartItemId:c.id}})}this.options.callbacks.onOptIn(f)}if(e==="no"&&((h=this.options.callbacks)!=null&&h.onOptOut)){const f={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;f.batchQuoteDetails=this.quote.originalQuotes.map(c=>{var l;const d=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===c.id);return{quoteId:c.id,productPrice:(d==null?void 0:d.productPrice)||c.spotPrice,cartItemId:c.id}})}this.options.callbacks.onOptOut(f)}})})}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,a,r;try{const i={...this.options,quoteRequestData:t};E(i);const{environment:e,partnerId:n,customEndpoint:u}=this.options.apiConfig,h=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await x(h,n,i.quoteRequestData):await _(h,n,i.quoteRequestData);if(y.status!=="QUOTE_AVAILABLE")return y.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:i.quoteRequestData}),!1;if(this.options.quoteRequestData=i.quoteRequestData,this.quote=y.data,this.currentSelection=null,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(i){const e=i;return(r=(a=this.options.callbacks)==null?void 0:a.onError)==null||r.call(a,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,a;if(this.currentSelection==null)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==="yes"?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};if((a=this.quote)!=null&&a.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var n;const e=(n=r.items)==null?void 0:n.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===i.id);return{quoteId:i.id,productPrice:(e==null?void 0:e.productPrice)||i.spotPrice,cartItemId:i.id}})}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)}}return A});
|
|
35
|
+
</svg>`}return s}const S=":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 Q(m){const t=document.createElement("style");t.textContent=m,document.head.appendChild(t)}Q(S);const I={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 A{constructor(t={}){this.options={location:"body",showTable:!0,optInSelected:!1,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t},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.optInSelected?"yes":null,this._init()}async _init(){var t,o,s,a,r;try{E(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:n}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await x(f,n,this.options.quoteRequestData):await _(f,n,this.options.quoteRequestData)}if(i.status!=="QUOTE_AVAILABLE"){i.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=i.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.optInSelected&&((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 n=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=n.items)==null?void 0:h.find(y=>(y.cartItemId||`item-${n.items.indexOf(y)+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(i){if((a=this.options.callbacks)!=null&&a.onError){const e=i;(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,a])=>{const r=`--${s}`;this.container.style.setProperty(r,a)}),N(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?L(t,this.quote.qualifyingReasons):M(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const s=this._getTotalItemsInRequest();O(t,this.quote.coveredItems,s)}this.options.showTable&&!this.quote.qualifyingReasons&&P(t,this.quote.payoutSchedule);const o=$(t,this.options.optInSelected,this.quote.communication);t.appendChild(o),this.paymentTermsEl=c("div",{className:"spot-payment-terms__wrapper",parent:t}),V(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,a=16;if(o>=900)return!0;if(o>=650){const r=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const i=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!i)return r&&t.classList.add("desktop-layout"),r;const n=Math.min(i.scrollWidth,400)+s+a;return r&&t.classList.add("desktop-layout"),o>=n}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"cartInfo"in this.options.quoteRequestData&&"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(a=>{a.addEventListener("change",r=>{var n,u,f;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(h=>h.classList.remove("selected")),(n=i.closest(".spot-selection__option"))==null||n.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),e==="yes"&&(this.options.quoteRequestData.isPartialPayment&&R(this.paymentTermsEl,this.quote),(u=this.options.callbacks)!=null&&u.onOptIn)){const h={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var l;const p=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(p==null?void 0:p.productPrice)||d.spotPrice,cartItemId:(p==null?void 0:p.cartItemId)||""}})}this.options.callbacks.onOptIn(h)}if(e==="no"&&((f=this.options.callbacks)!=null&&f.onOptOut)){const h={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var l;const p=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(p==null?void 0:p.productPrice)||d.spotPrice,cartItemId:(p==null?void 0:p.cartItemId)||""}})}this.options.callbacks.onOptOut(h)}})})}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,a,r;try{const i={...this.options,quoteRequestData:t};E(i);const{environment:e,partnerId:n,customEndpoint:u}=this.options.apiConfig,f=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await x(f,n,i.quoteRequestData):await _(f,n,i.quoteRequestData);if(y.status!=="QUOTE_AVAILABLE")return y.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:i.quoteRequestData}),!1;if(this.options.quoteRequestData=i.quoteRequestData,this.quote=y.data,this.currentSelection=null,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const d=this.options.callbacks.onQuoteRetrieved(this.quote);d&&this._applyQuoteUpdates(d)}return!0}catch(i){const e=i;return(r=(a=this.options.callbacks)==null?void 0:a.onError)==null||r.call(a,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,a;if(this.currentSelection==null)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==="yes"?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};if((a=this.quote)!=null&&a.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var n;const e=(n=r.items)==null?void 0:n.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===i.cartItemId);return{quoteId:i.id,productPrice:(e==null?void 0:e.productPrice)||i.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)}}return A});
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface QuoteItem {
|
|
|
22
22
|
productDuration: "Daily" | "Seasonal" | "Trip" | "Event";
|
|
23
23
|
productId: string;
|
|
24
24
|
cartId: string;
|
|
25
|
+
cartItemId?: string;
|
|
25
26
|
cartName: string;
|
|
26
27
|
productName: string;
|
|
27
28
|
participantDescription?: string;
|
|
@@ -38,7 +39,7 @@ export interface QuoteItem {
|
|
|
38
39
|
destinations?: string[];
|
|
39
40
|
dob?: string;
|
|
40
41
|
}
|
|
41
|
-
type BatchItem = Omit<QuoteItem, "cartName" | "cartId" | "currencyCode" | "isPartialPayment" | "metadata">;
|
|
42
|
+
type BatchItem = Omit<QuoteItem, "cartName" | "cartItemId" | "cartId" | "currencyCode" | "isPartialPayment" | "metadata">;
|
|
42
43
|
export interface BatchQuoteItem extends BatchItem {
|
|
43
44
|
cartItemId: string;
|
|
44
45
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,SAAS,GAAG,YAAY,GAAG,OAAO,CAAC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IACpC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;I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