@getspot/spot-widget 3.3.1 → 3.3.2
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/dist/index.es.js +163 -163
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.3.2](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.3.1...@getspot/spot-widget@3.3.2) (2026-01-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **core:** render payment terms if quote contains paymentTerms ([852af4e](https://gitlab.com/getspot/spot-widget/commit/852af4e7fe9838aac0409e26713614e20d523a9b))
|
|
7
|
+
|
|
1
8
|
## [3.3.1](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.3.0...@getspot/spot-widget@3.3.1) (2026-01-07)
|
|
2
9
|
|
|
3
10
|
|
package/dist/index.es.js
CHANGED
|
@@ -45,23 +45,23 @@ async function I(m, t, o) {
|
|
|
45
45
|
currencyCode: o.cartInfo.currencyCode,
|
|
46
46
|
isPartialPayment: o.cartInfo.isPartialPayment || !1,
|
|
47
47
|
roundTo: o.cartInfo.roundTo || void 0,
|
|
48
|
-
items: o.items.map((
|
|
49
|
-
...
|
|
50
|
-
cartItemId:
|
|
48
|
+
items: o.items.map((p, u) => ({
|
|
49
|
+
...p,
|
|
50
|
+
cartItemId: p.cartItemId || `item-${u + 1}`
|
|
51
51
|
}))
|
|
52
52
|
}, r = await H(m, t, n);
|
|
53
53
|
if (r.status !== "QUOTES_AVAILABLE" && r.status !== "QUOTE_AVAILABLE")
|
|
54
54
|
return { status: "NO_MATCHING_QUOTE" };
|
|
55
|
-
const i = r.quotes.map((
|
|
55
|
+
const i = r.quotes.map((p) => {
|
|
56
56
|
const u = o.items.find(
|
|
57
|
-
(f, h) => (f.cartItemId || `item-${h + 1}`) ===
|
|
57
|
+
(f, h) => (f.cartItemId || `item-${h + 1}`) === p.cartItemId
|
|
58
58
|
);
|
|
59
|
-
return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${
|
|
59
|
+
return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${p.id}`;
|
|
60
60
|
}), e = Math.round((r.totalSpotPrice || r.spotPrice || 0) * 100) / 100;
|
|
61
61
|
return {
|
|
62
62
|
status: "QUOTE_AVAILABLE",
|
|
63
63
|
data: {
|
|
64
|
-
id: r.quotes ? r.quotes.map((
|
|
64
|
+
id: r.quotes ? r.quotes.map((p) => p.id).join(",") : ((s = r.data) == null ? void 0 : s.id) || "",
|
|
65
65
|
spotPrice: e,
|
|
66
66
|
currencyCode: r.currencyCode || "",
|
|
67
67
|
communication: {
|
|
@@ -71,9 +71,9 @@ async function I(m, t, o) {
|
|
|
71
71
|
String(e)
|
|
72
72
|
)
|
|
73
73
|
},
|
|
74
|
-
payoutSchedule: r.payoutSchedule.map((
|
|
75
|
-
...
|
|
76
|
-
amount:
|
|
74
|
+
payoutSchedule: r.payoutSchedule.map((p) => ({
|
|
75
|
+
...p,
|
|
76
|
+
amount: p.amount !== void 0 ? p.amount : 0
|
|
77
77
|
})),
|
|
78
78
|
coveredItems: i,
|
|
79
79
|
originalQuotes: r.quotes || (r.data ? [r.data] : [])
|
|
@@ -90,7 +90,7 @@ const z = {
|
|
|
90
90
|
production: "https://api.getspot.com/v1/quote",
|
|
91
91
|
local: "http://localhost:3999/api/v1/quote"
|
|
92
92
|
};
|
|
93
|
-
function
|
|
93
|
+
function T(m) {
|
|
94
94
|
const {
|
|
95
95
|
apiConfig: t = {},
|
|
96
96
|
quoteRequestData: o,
|
|
@@ -100,11 +100,11 @@ function D(m) {
|
|
|
100
100
|
} = m, {
|
|
101
101
|
environment: i = "sandbox",
|
|
102
102
|
partnerId: e,
|
|
103
|
-
customEndpoint:
|
|
103
|
+
customEndpoint: p
|
|
104
104
|
} = t;
|
|
105
105
|
if (!e || typeof e != "string")
|
|
106
106
|
throw new Error("Invalid or missing partnerId in apiConfig");
|
|
107
|
-
if (!(
|
|
107
|
+
if (!(p || z[i]))
|
|
108
108
|
throw new Error(`Invalid environment in apiConfig: ${i}`);
|
|
109
109
|
if (!o || typeof o != "object" && !Array.isArray(o))
|
|
110
110
|
throw new Error("quoteRequestData must be a non-null object or array");
|
|
@@ -120,61 +120,61 @@ function D(m) {
|
|
|
120
120
|
"cartId",
|
|
121
121
|
"productName"
|
|
122
122
|
];
|
|
123
|
-
function h(
|
|
124
|
-
const l =
|
|
123
|
+
function h(c, d = null) {
|
|
124
|
+
const l = d !== null ? `quoteRequestData[${d}]` : "quoteRequestData";
|
|
125
125
|
f.forEach((v) => {
|
|
126
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
126
|
+
if (!Object.prototype.hasOwnProperty.call(c, v) || c[v] === void 0 || c[v] === null)
|
|
127
127
|
throw new Error(`Missing required ${l} field: '${v}'`);
|
|
128
128
|
});
|
|
129
129
|
const w = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
|
|
130
|
-
if (!w.test(
|
|
130
|
+
if (!w.test(c.startDate))
|
|
131
131
|
throw new Error(`${l}.startDate must be a valid ISO8601 string`);
|
|
132
|
-
if (!w.test(
|
|
132
|
+
if (!w.test(c.endDate))
|
|
133
133
|
throw new Error(`${l}.endDate must be a valid ISO8601 string`);
|
|
134
|
-
if (typeof
|
|
134
|
+
if (typeof c.currencyCode != "string")
|
|
135
135
|
throw new Error(`${l}.currencyCode must be a string`);
|
|
136
|
-
if (!["USD", "CAD", "AUD"].includes(
|
|
137
|
-
throw new Error(`Invalid ${l}.currencyCode: ${
|
|
138
|
-
if (typeof
|
|
136
|
+
if (!["USD", "CAD", "AUD"].includes(c.currencyCode))
|
|
137
|
+
throw new Error(`Invalid ${l}.currencyCode: ${c.currencyCode}`);
|
|
138
|
+
if (typeof c.eventType != "string")
|
|
139
139
|
throw new Error(`${l}.eventType must be a string`);
|
|
140
|
-
if (typeof
|
|
140
|
+
if (typeof c.productType != "string")
|
|
141
141
|
throw new Error(`${l}.productType must be a string`);
|
|
142
142
|
const g = ["Pass", "Trip", "Registration"];
|
|
143
|
-
if (!g.includes(
|
|
143
|
+
if (!g.includes(c.productType))
|
|
144
144
|
throw new Error(
|
|
145
145
|
`${l}.productType must be one of ${g.join(", ")}`
|
|
146
146
|
);
|
|
147
|
-
if (typeof
|
|
147
|
+
if (typeof c.productDuration != "string")
|
|
148
148
|
throw new Error(`${l}.productDuration must be a string`);
|
|
149
|
-
const
|
|
150
|
-
if (!
|
|
149
|
+
const _ = ["Daily", "Seasonal", "Trip", "Event"];
|
|
150
|
+
if (!_.includes(c.productDuration))
|
|
151
151
|
throw new Error(
|
|
152
|
-
`${l}.productDuration must be one of ${
|
|
152
|
+
`${l}.productDuration must be one of ${_.join(", ")}`
|
|
153
153
|
);
|
|
154
|
-
if (typeof
|
|
154
|
+
if (typeof c.productPrice != "number" || isNaN(c.productPrice))
|
|
155
155
|
throw new Error(`${l}.productPrice must be a valid number`);
|
|
156
|
-
if (typeof
|
|
156
|
+
if (typeof c.productId != "string")
|
|
157
157
|
throw new Error(`${l}.productId must be a string`);
|
|
158
|
-
if (typeof
|
|
158
|
+
if (typeof c.cartId != "string")
|
|
159
159
|
throw new Error(`${l}.cartId must be a string`);
|
|
160
|
-
if (typeof
|
|
160
|
+
if (typeof c.productName != "string")
|
|
161
161
|
throw new Error(`${l}.productName must be a string`);
|
|
162
162
|
}
|
|
163
163
|
if ("cartInfo" in o && "items" in o) {
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
164
|
+
const c = o, { cartInfo: d, items: l } = c;
|
|
165
|
+
if (!d || typeof d != "object")
|
|
166
166
|
throw new Error("quoteRequestData.cartInfo must be a non-null object");
|
|
167
|
-
if (!
|
|
167
|
+
if (!d.cartId || typeof d.cartId != "string")
|
|
168
168
|
throw new Error("quoteRequestData.cartInfo.cartId must be a string");
|
|
169
|
-
if (!
|
|
169
|
+
if (!d.cartName || typeof d.cartName != "string")
|
|
170
170
|
throw new Error("quoteRequestData.cartInfo.cartName must be a string");
|
|
171
|
-
if (!
|
|
171
|
+
if (!d.currencyCode || typeof d.currencyCode != "string")
|
|
172
172
|
throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");
|
|
173
|
-
if (!["USD", "CAD", "AUD"].includes(
|
|
174
|
-
throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${
|
|
173
|
+
if (!["USD", "CAD", "AUD"].includes(d.currencyCode))
|
|
174
|
+
throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${d.currencyCode}`);
|
|
175
175
|
if (!Array.isArray(l) || l.length === 0)
|
|
176
176
|
throw new Error("quoteRequestData.items must be a non-empty array");
|
|
177
|
-
const
|
|
177
|
+
const b = [
|
|
178
178
|
"startDate",
|
|
179
179
|
"endDate",
|
|
180
180
|
"eventType",
|
|
@@ -184,11 +184,11 @@ function D(m) {
|
|
|
184
184
|
"productId",
|
|
185
185
|
"productName"
|
|
186
186
|
];
|
|
187
|
-
l.forEach((g,
|
|
187
|
+
l.forEach((g, _) => {
|
|
188
188
|
if (!g || typeof g != "object")
|
|
189
|
-
throw new Error(`quoteRequestData.items[${
|
|
190
|
-
const v = `quoteRequestData.items[${
|
|
191
|
-
|
|
189
|
+
throw new Error(`quoteRequestData.items[${_}] must be a non-null object`);
|
|
190
|
+
const v = `quoteRequestData.items[${_}]`;
|
|
191
|
+
b.forEach((C) => {
|
|
192
192
|
if (!Object.prototype.hasOwnProperty.call(g, C) || g[C] === void 0 || g[C] === null)
|
|
193
193
|
throw new Error(`Missing required ${v} field: '${C}'`);
|
|
194
194
|
});
|
|
@@ -219,10 +219,10 @@ function D(m) {
|
|
|
219
219
|
} else if (Array.isArray(o)) {
|
|
220
220
|
if (o.length === 0)
|
|
221
221
|
throw new Error("quoteRequestData array cannot be empty");
|
|
222
|
-
o.forEach((
|
|
223
|
-
if (!
|
|
224
|
-
throw new Error(`quoteRequestData[${
|
|
225
|
-
h(
|
|
222
|
+
o.forEach((c, d) => {
|
|
223
|
+
if (!c || typeof c != "object")
|
|
224
|
+
throw new Error(`quoteRequestData[${d}] must be a non-null object`);
|
|
225
|
+
h(c, d);
|
|
226
226
|
});
|
|
227
227
|
} else
|
|
228
228
|
h(o);
|
|
@@ -232,10 +232,10 @@ function D(m) {
|
|
|
232
232
|
"onQuoteRetrieved",
|
|
233
233
|
"onError",
|
|
234
234
|
"noMatchingQuote"
|
|
235
|
-
].forEach((
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
throw new Error(`Callback '${
|
|
235
|
+
].forEach((c) => {
|
|
236
|
+
const d = s[c];
|
|
237
|
+
if (d && typeof d != "function")
|
|
238
|
+
throw new Error(`Callback '${c}' must be a function.`);
|
|
239
239
|
}), typeof n == "string" && !document.querySelector(n))
|
|
240
240
|
throw new Error(`Invalid location selector: '${n}'`);
|
|
241
241
|
if (r && typeof r != "object")
|
|
@@ -243,41 +243,41 @@ function D(m) {
|
|
|
243
243
|
"Theme must be an object with CSS variables, do not include the '--' prefix"
|
|
244
244
|
);
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function a(m, { text: t, className: o, parent: s, innerHTML: n, href: r, target: i } = {}) {
|
|
247
247
|
const e = document.createElement(m);
|
|
248
248
|
return o && (e.className = o), t != null && (e.textContent = t), n != null && (e.innerHTML = n), r && "href" in e && (e.href = r), i && "target" in e && (e.target = i), s && s.appendChild(e), e;
|
|
249
249
|
}
|
|
250
250
|
function M(m, { name: t, description: o }) {
|
|
251
|
-
|
|
251
|
+
a("div", {
|
|
252
252
|
className: "spot-header__title",
|
|
253
253
|
text: t,
|
|
254
254
|
parent: m
|
|
255
|
-
}),
|
|
255
|
+
}), a("div", {
|
|
256
256
|
className: "spot-header__description",
|
|
257
257
|
text: o,
|
|
258
258
|
parent: m
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
261
|
function N(m, t = []) {
|
|
262
|
-
const o =
|
|
262
|
+
const o = a("ul", {
|
|
263
263
|
className: "spot-benefits__list",
|
|
264
264
|
parent: m
|
|
265
265
|
});
|
|
266
266
|
t.forEach((s) => {
|
|
267
|
-
const n =
|
|
267
|
+
const n = a("li", { parent: o });
|
|
268
268
|
n.innerHTML = `
|
|
269
269
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="spot-bullets__checkmark">
|
|
270
270
|
<path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
|
|
271
271
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
272
|
-
</svg>`,
|
|
272
|
+
</svg>`, a("span", { text: s, parent: n });
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
275
|
function L(m, t = []) {
|
|
276
276
|
if (!t || t.length === 0) return;
|
|
277
|
-
const o =
|
|
277
|
+
const o = a("div", {
|
|
278
278
|
className: "spot-qualifying-reasons__container",
|
|
279
279
|
parent: m
|
|
280
|
-
}), s = [...t].sort((e,
|
|
280
|
+
}), s = [...t].sort((e, p) => e.rank - p.rank), n = a("div", {
|
|
281
281
|
className: "spot-qualifying-reasons__grid",
|
|
282
282
|
parent: o
|
|
283
283
|
}), r = {
|
|
@@ -294,8 +294,8 @@ function L(m, t = []) {
|
|
|
294
294
|
try {
|
|
295
295
|
const e = document.currentScript;
|
|
296
296
|
if (e != null && e.src) {
|
|
297
|
-
const
|
|
298
|
-
i =
|
|
297
|
+
const p = new URL(e.src);
|
|
298
|
+
i = p.origin + p.pathname.replace(/\/[^/]*$/, "/");
|
|
299
299
|
} else
|
|
300
300
|
i = window.location.origin + window.location.pathname.replace(/\/[^/]*$/, "/");
|
|
301
301
|
i += "assets/";
|
|
@@ -303,24 +303,24 @@ function L(m, t = []) {
|
|
|
303
303
|
i = "./assets/";
|
|
304
304
|
}
|
|
305
305
|
s.forEach((e) => {
|
|
306
|
-
var h, y,
|
|
307
|
-
const
|
|
306
|
+
var h, y, c;
|
|
307
|
+
const p = a("div", {
|
|
308
308
|
className: "spot-qualifying-reasons__item",
|
|
309
309
|
parent: n
|
|
310
|
-
}), u =
|
|
310
|
+
}), u = a("div", {
|
|
311
311
|
className: "spot-qualifying-reasons__icon-wrapper",
|
|
312
|
-
parent:
|
|
312
|
+
parent: p
|
|
313
313
|
}), f = r[((h = e.benefitType) == null ? void 0 : h.name) || ""] || r[e.name || ""];
|
|
314
314
|
if (f) {
|
|
315
|
-
const
|
|
315
|
+
const d = a("img", {
|
|
316
316
|
parent: u
|
|
317
317
|
});
|
|
318
|
-
|
|
318
|
+
d.src = i + f, d.alt = ((y = e.benefitType) == null ? void 0 : y.name) || e.name || "", d.className = "spot-qualifying-reasons__icon";
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
a("span", {
|
|
321
321
|
className: "spot-qualifying-reasons__label",
|
|
322
|
-
text: ((
|
|
323
|
-
parent:
|
|
322
|
+
text: ((c = e.benefitType) == null ? void 0 : c.name) || e.name || "",
|
|
323
|
+
parent: p
|
|
324
324
|
});
|
|
325
325
|
});
|
|
326
326
|
}
|
|
@@ -328,112 +328,112 @@ function O(m, t = [], o) {
|
|
|
328
328
|
if (t.length === 0 || !o || o <= 1)
|
|
329
329
|
return;
|
|
330
330
|
const s = /* @__PURE__ */ new Map();
|
|
331
|
-
t.forEach((
|
|
332
|
-
s.set(
|
|
331
|
+
t.forEach((d) => {
|
|
332
|
+
s.set(d, (s.get(d) || 0) + 1);
|
|
333
333
|
});
|
|
334
334
|
const r = Array.from(s.entries()).map(
|
|
335
|
-
([
|
|
336
|
-
item:
|
|
335
|
+
([d, l]) => ({
|
|
336
|
+
item: d,
|
|
337
337
|
count: l,
|
|
338
|
-
displayText: l > 1 ? `${l} x ${
|
|
338
|
+
displayText: l > 1 ? `${l} x ${d}` : d
|
|
339
339
|
})
|
|
340
|
-
).sort((
|
|
341
|
-
const w =
|
|
342
|
-
return !g &&
|
|
343
|
-
}), i =
|
|
340
|
+
).sort((d, l) => {
|
|
341
|
+
const w = d.item.charAt(0), b = l.item.charAt(0), g = /[a-zA-Z]/.test(w), _ = /[a-zA-Z]/.test(b);
|
|
342
|
+
return !g && _ ? -1 : g && !_ ? 1 : d.item.localeCompare(l.item, void 0, { sensitivity: "base" });
|
|
343
|
+
}), i = a("div", {
|
|
344
344
|
className: "spot-covered-items__container",
|
|
345
345
|
parent: m
|
|
346
|
-
}), e =
|
|
346
|
+
}), e = a("div", {
|
|
347
347
|
className: "spot-covered-items__header",
|
|
348
348
|
parent: i
|
|
349
|
-
}),
|
|
349
|
+
}), p = a("button", {
|
|
350
350
|
className: "spot-covered-items__toggle",
|
|
351
351
|
parent: e
|
|
352
352
|
});
|
|
353
|
-
|
|
353
|
+
a("span", {
|
|
354
354
|
className: "spot-covered-items__title",
|
|
355
355
|
text: `Items Covered in Your Cart (${t.length})`,
|
|
356
|
-
parent:
|
|
356
|
+
parent: p
|
|
357
357
|
});
|
|
358
|
-
const u =
|
|
358
|
+
const u = a("div", {
|
|
359
359
|
className: "spot-covered-items__right-section",
|
|
360
|
-
parent:
|
|
360
|
+
parent: p
|
|
361
361
|
});
|
|
362
|
-
|
|
362
|
+
a("span", {
|
|
363
363
|
className: "spot-covered-items__view-all",
|
|
364
364
|
text: "View All",
|
|
365
365
|
parent: u
|
|
366
366
|
});
|
|
367
|
-
const f =
|
|
367
|
+
const f = a("span", {
|
|
368
368
|
className: "spot-covered-items__arrow",
|
|
369
369
|
innerHTML: "▼",
|
|
370
370
|
parent: u
|
|
371
|
-
}), h =
|
|
371
|
+
}), h = a("div", {
|
|
372
372
|
className: "spot-covered-items__content",
|
|
373
373
|
parent: i
|
|
374
|
-
}), y =
|
|
374
|
+
}), y = a("ul", {
|
|
375
375
|
className: "spot-covered-items__list",
|
|
376
376
|
parent: h
|
|
377
377
|
});
|
|
378
|
-
r.forEach(({ displayText:
|
|
379
|
-
const l =
|
|
380
|
-
|
|
378
|
+
r.forEach(({ displayText: d }) => {
|
|
379
|
+
const l = a("li", { parent: y });
|
|
380
|
+
a("span", { text: d, parent: l });
|
|
381
381
|
});
|
|
382
|
-
let
|
|
383
|
-
h.style.display = "none",
|
|
384
|
-
|
|
385
|
-
}),
|
|
382
|
+
let c = !1;
|
|
383
|
+
h.style.display = "none", p.addEventListener("click", (d) => {
|
|
384
|
+
d.stopPropagation(), c = !c, h.style.display = c ? "block" : "none", f.innerHTML = c ? "▲" : "▼", p.setAttribute("aria-expanded", c.toString());
|
|
385
|
+
}), p.setAttribute("aria-expanded", "false"), p.setAttribute("aria-controls", "covered-items-list"), h.setAttribute("id", "covered-items-list");
|
|
386
386
|
}
|
|
387
387
|
function P(m, t = []) {
|
|
388
|
-
const o =
|
|
388
|
+
const o = a("div", {
|
|
389
389
|
className: "spot-table__container",
|
|
390
390
|
parent: m
|
|
391
|
-
}), s =
|
|
391
|
+
}), s = a("table", {
|
|
392
392
|
className: "spot-refund__table spot-table--dynamic",
|
|
393
393
|
parent: o
|
|
394
|
-
}), n =
|
|
395
|
-
|
|
396
|
-
const i =
|
|
397
|
-
t.forEach(({ text: e, percent:
|
|
398
|
-
const f =
|
|
399
|
-
|
|
400
|
-
const h =
|
|
401
|
-
|
|
394
|
+
}), n = a("thead", { parent: s }), r = a("tr", { parent: n });
|
|
395
|
+
a("th", { text: "When you cancel", parent: r }), a("th", { text: "You will receive", parent: r });
|
|
396
|
+
const i = a("tbody", { parent: s });
|
|
397
|
+
t.forEach(({ text: e, percent: p, amount: u }) => {
|
|
398
|
+
const f = a("tr", { parent: i });
|
|
399
|
+
a("td", { text: e, parent: f });
|
|
400
|
+
const h = p === "Not eligible for refund" ? "Not eligible for a refund" : `$${u} refund`;
|
|
401
|
+
a("td", { text: h, parent: f });
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
function $(m, t, o) {
|
|
405
|
-
const s =
|
|
405
|
+
const s = a("div", {
|
|
406
406
|
className: "spot-selection__options",
|
|
407
407
|
parent: m
|
|
408
|
-
}), n =
|
|
408
|
+
}), n = a("label", {
|
|
409
409
|
className: `spot-selection__option ${t ? "selected" : ""}`,
|
|
410
410
|
parent: s
|
|
411
|
-
}), r =
|
|
412
|
-
r.type = "radio", r.name = "selection", r.value = "yes", t && (r.checked = !0),
|
|
411
|
+
}), r = a("input", { parent: n });
|
|
412
|
+
r.type = "radio", r.name = "selection", r.value = "yes", t && (r.checked = !0), a("strong", {
|
|
413
413
|
text: o.yesOptionText,
|
|
414
414
|
parent: n
|
|
415
|
-
}),
|
|
415
|
+
}), a("span", {
|
|
416
416
|
className: "spot-selection__recommended-tag",
|
|
417
417
|
text: "Recommended",
|
|
418
418
|
parent: n
|
|
419
419
|
});
|
|
420
|
-
const i =
|
|
420
|
+
const i = a("label", {
|
|
421
421
|
className: "spot-selection__option",
|
|
422
422
|
parent: s
|
|
423
|
-
}), e =
|
|
424
|
-
return e.type = "radio", e.name = "selection", e.value = "no",
|
|
423
|
+
}), e = a("input", { parent: i });
|
|
424
|
+
return e.type = "radio", e.name = "selection", e.value = "no", a("span", { text: o.noOptionText, parent: i }), s;
|
|
425
425
|
}
|
|
426
426
|
function R(m, t) {
|
|
427
427
|
var n;
|
|
428
|
-
const o = (n = t.communication) == null ? void 0 : n.paymentTerms, s =
|
|
428
|
+
const o = (n = t.communication) == null ? void 0 : n.paymentTerms, s = a("div", {
|
|
429
429
|
className: "spot-payment-terms",
|
|
430
430
|
parent: m
|
|
431
431
|
});
|
|
432
|
-
return
|
|
432
|
+
return a("div", {
|
|
433
433
|
className: "spot-payment-terms__header",
|
|
434
434
|
text: "PAYMENT TERMS",
|
|
435
435
|
parent: s
|
|
436
|
-
}),
|
|
436
|
+
}), a("div", {
|
|
437
437
|
className: "spot-payment-terms__body",
|
|
438
438
|
text: o || "",
|
|
439
439
|
parent: s
|
|
@@ -441,7 +441,7 @@ function R(m, t) {
|
|
|
441
441
|
}
|
|
442
442
|
function V(m, t, o = "bottom-right") {
|
|
443
443
|
if (o === "top-right") {
|
|
444
|
-
const e =
|
|
444
|
+
const e = a("div", {
|
|
445
445
|
className: "spot-logo__top-right",
|
|
446
446
|
parent: m
|
|
447
447
|
});
|
|
@@ -462,21 +462,21 @@ function V(m, t, o = "bottom-right") {
|
|
|
462
462
|
</defs>
|
|
463
463
|
</svg>`;
|
|
464
464
|
}
|
|
465
|
-
const s =
|
|
465
|
+
const s = a("div", {
|
|
466
466
|
className: "spot-footer__container",
|
|
467
467
|
parent: m
|
|
468
|
-
}), n =
|
|
468
|
+
}), n = a("div", {
|
|
469
469
|
className: "spot-footer__terms",
|
|
470
470
|
parent: s
|
|
471
471
|
}), r = `<a href="${t.communication.termsAndConditionsUrl}" target="_blank" class="spot-footer__terms-link">Terms & Conditions</a>`, i = t.communication.legalDisclaimer.replace(
|
|
472
472
|
/terms (and|&) conditions/gi,
|
|
473
473
|
r
|
|
474
474
|
);
|
|
475
|
-
if (
|
|
475
|
+
if (a("span", {
|
|
476
476
|
innerHTML: i,
|
|
477
477
|
parent: n
|
|
478
478
|
}), o === "bottom-right") {
|
|
479
|
-
const e =
|
|
479
|
+
const e = a("p", {
|
|
480
480
|
className: "spot-footer__powered-by",
|
|
481
481
|
parent: s
|
|
482
482
|
});
|
|
@@ -505,7 +505,7 @@ function S(m) {
|
|
|
505
505
|
t.textContent = m, document.head.appendChild(t);
|
|
506
506
|
}
|
|
507
507
|
S(Q);
|
|
508
|
-
const
|
|
508
|
+
const D = {
|
|
509
509
|
sandbox: "https://api.sandbox.getspot.com/api/v1/quote",
|
|
510
510
|
production: "https://api.getspot.com/api/v1/quote",
|
|
511
511
|
local: "http://localhost:3999/api/v1/quote"
|
|
@@ -527,19 +527,19 @@ class A {
|
|
|
527
527
|
async _init() {
|
|
528
528
|
var t, o, s, n, r;
|
|
529
529
|
try {
|
|
530
|
-
|
|
530
|
+
T(this.options);
|
|
531
531
|
let i;
|
|
532
532
|
if (this.options.useMockData && this.options.mockData)
|
|
533
533
|
i = this.options.mockData;
|
|
534
534
|
else {
|
|
535
|
-
const { environment: e, partnerId:
|
|
535
|
+
const { environment: e, partnerId: p } = this.options.apiConfig, f = this.options.apiConfig.customEndpoint || D[e];
|
|
536
536
|
i = "cartInfo" in this.options.quoteRequestData && "items" in this.options.quoteRequestData ? await I(
|
|
537
537
|
f,
|
|
538
|
-
|
|
538
|
+
p,
|
|
539
539
|
this.options.quoteRequestData
|
|
540
540
|
) : await x(
|
|
541
541
|
f,
|
|
542
|
-
|
|
542
|
+
p,
|
|
543
543
|
this.options.quoteRequestData
|
|
544
544
|
);
|
|
545
545
|
}
|
|
@@ -559,11 +559,11 @@ class A {
|
|
|
559
559
|
quoteId: this.quote.id
|
|
560
560
|
};
|
|
561
561
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
562
|
-
const
|
|
562
|
+
const p = this.options.quoteRequestData;
|
|
563
563
|
e.batchQuoteDetails = this.quote.originalQuotes.map((u) => {
|
|
564
564
|
var h;
|
|
565
|
-
const f = (h =
|
|
566
|
-
(y) => (y.cartItemId || `item-${
|
|
565
|
+
const f = (h = p.items) == null ? void 0 : h.find(
|
|
566
|
+
(y) => (y.cartItemId || `item-${p.items.indexOf(y) + 1}`) === u.cartItemId
|
|
567
567
|
);
|
|
568
568
|
return {
|
|
569
569
|
quoteId: u.id,
|
|
@@ -606,7 +606,7 @@ class A {
|
|
|
606
606
|
this.options.optInSelected,
|
|
607
607
|
this.quote.communication
|
|
608
608
|
);
|
|
609
|
-
t.appendChild(o), this.paymentTermsEl =
|
|
609
|
+
t.appendChild(o), this.paymentTermsEl = a("div", {
|
|
610
610
|
className: "spot-payment-terms__wrapper",
|
|
611
611
|
parent: t
|
|
612
612
|
}), V(this.container, this.quote, this.options.logoPosition), window.addEventListener("resize", this._onResize), this._setupResizeObserver(), this._updateLayout(), this._setupOptionListeners(o);
|
|
@@ -635,8 +635,8 @@ class A {
|
|
|
635
635
|
);
|
|
636
636
|
if (!i)
|
|
637
637
|
return r && t.classList.add("desktop-layout"), r;
|
|
638
|
-
const
|
|
639
|
-
return r && t.classList.add("desktop-layout"), o >=
|
|
638
|
+
const p = Math.min(i.scrollWidth, 400) + s + n;
|
|
639
|
+
return r && t.classList.add("desktop-layout"), o >= p;
|
|
640
640
|
}
|
|
641
641
|
return !1;
|
|
642
642
|
}
|
|
@@ -662,54 +662,54 @@ class A {
|
|
|
662
662
|
), s = t.querySelectorAll(".spot-selection__option");
|
|
663
663
|
o.forEach((n) => {
|
|
664
664
|
n.addEventListener("change", (r) => {
|
|
665
|
-
var
|
|
665
|
+
var p, u, f, h;
|
|
666
666
|
const i = r.target, e = i.value;
|
|
667
|
-
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((
|
|
668
|
-
const
|
|
667
|
+
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((y) => y.classList.remove("selected")), (p = i.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e === "yes" && ((u = this.quote) != null && u.communication.paymentTerms && R(this.paymentTermsEl, this.quote), (f = this.options.callbacks) != null && f.onOptIn)) {
|
|
668
|
+
const y = {
|
|
669
669
|
status: "QUOTE_ACCEPTED",
|
|
670
670
|
spotPrice: this.quote.spotPrice,
|
|
671
671
|
quoteId: this.quote.id
|
|
672
672
|
};
|
|
673
673
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
674
|
-
const
|
|
675
|
-
|
|
674
|
+
const c = this.options.quoteRequestData;
|
|
675
|
+
y.batchQuoteDetails = this.quote.originalQuotes.map(
|
|
676
676
|
(d) => {
|
|
677
|
-
var
|
|
678
|
-
const
|
|
679
|
-
(
|
|
677
|
+
var w;
|
|
678
|
+
const l = (w = c.items) == null ? void 0 : w.find(
|
|
679
|
+
(b) => (b.cartItemId || `item-${c.items.indexOf(b) + 1}`) === d.cartItemId
|
|
680
680
|
);
|
|
681
681
|
return {
|
|
682
682
|
quoteId: d.id,
|
|
683
|
-
productPrice: (
|
|
684
|
-
cartItemId: (
|
|
683
|
+
productPrice: (l == null ? void 0 : l.productPrice) || d.spotPrice,
|
|
684
|
+
cartItemId: (l == null ? void 0 : l.cartItemId) || ""
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
687
|
);
|
|
688
688
|
}
|
|
689
|
-
this.options.callbacks.onOptIn(
|
|
689
|
+
this.options.callbacks.onOptIn(y);
|
|
690
690
|
}
|
|
691
|
-
if (e === "no" && ((
|
|
692
|
-
const
|
|
691
|
+
if (e === "no" && ((h = this.options.callbacks) != null && h.onOptOut)) {
|
|
692
|
+
const y = {
|
|
693
693
|
status: "QUOTE_DECLINED",
|
|
694
694
|
quoteId: this.quote.id
|
|
695
695
|
};
|
|
696
696
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
697
|
-
const
|
|
698
|
-
|
|
697
|
+
const c = this.options.quoteRequestData;
|
|
698
|
+
y.batchQuoteDetails = this.quote.originalQuotes.map(
|
|
699
699
|
(d) => {
|
|
700
|
-
var
|
|
701
|
-
const
|
|
702
|
-
(
|
|
700
|
+
var w;
|
|
701
|
+
const l = (w = c.items) == null ? void 0 : w.find(
|
|
702
|
+
(b) => (b.cartItemId || `item-${c.items.indexOf(b) + 1}`) === d.cartItemId
|
|
703
703
|
);
|
|
704
704
|
return {
|
|
705
705
|
quoteId: d.id,
|
|
706
|
-
productPrice: (
|
|
707
|
-
cartItemId: (
|
|
706
|
+
productPrice: (l == null ? void 0 : l.productPrice) || d.spotPrice,
|
|
707
|
+
cartItemId: (l == null ? void 0 : l.cartItemId) || ""
|
|
708
708
|
};
|
|
709
709
|
}
|
|
710
710
|
);
|
|
711
711
|
}
|
|
712
|
-
this.options.callbacks.onOptOut(
|
|
712
|
+
this.options.callbacks.onOptOut(y);
|
|
713
713
|
}
|
|
714
714
|
});
|
|
715
715
|
});
|
|
@@ -742,14 +742,14 @@ class A {
|
|
|
742
742
|
...this.options,
|
|
743
743
|
quoteRequestData: t
|
|
744
744
|
};
|
|
745
|
-
|
|
746
|
-
const { environment: e, partnerId:
|
|
745
|
+
T(i);
|
|
746
|
+
const { environment: e, partnerId: p, customEndpoint: u } = this.options.apiConfig, f = u || D[e], y = "cartInfo" in i.quoteRequestData && "items" in i.quoteRequestData ? await I(
|
|
747
747
|
f,
|
|
748
|
-
|
|
748
|
+
p,
|
|
749
749
|
i.quoteRequestData
|
|
750
750
|
) : await x(
|
|
751
751
|
f,
|
|
752
|
-
|
|
752
|
+
p,
|
|
753
753
|
i.quoteRequestData
|
|
754
754
|
);
|
|
755
755
|
if (y.status !== "QUOTE_AVAILABLE")
|
|
@@ -758,8 +758,8 @@ class A {
|
|
|
758
758
|
data: i.quoteRequestData
|
|
759
759
|
}), !1;
|
|
760
760
|
if (this.options.quoteRequestData = i.quoteRequestData, this.quote = y.data, this.currentSelection = null, this.destroy(), this._renderWidget(), (s = this.options.callbacks) != null && s.onQuoteRetrieved) {
|
|
761
|
-
const
|
|
762
|
-
|
|
761
|
+
const c = this.options.callbacks.onQuoteRetrieved(this.quote);
|
|
762
|
+
c && this._applyQuoteUpdates(c);
|
|
763
763
|
}
|
|
764
764
|
return !0;
|
|
765
765
|
} catch (i) {
|
|
@@ -783,8 +783,8 @@ class A {
|
|
|
783
783
|
if ((n = this.quote) != null && n.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
784
784
|
const r = this.options.quoteRequestData;
|
|
785
785
|
t.batchQuoteDetails = this.quote.originalQuotes.map((i) => {
|
|
786
|
-
var
|
|
787
|
-
const e = (
|
|
786
|
+
var p;
|
|
787
|
+
const e = (p = r.items) == null ? void 0 : p.find(
|
|
788
788
|
(u) => (u.cartItemId || `item-${r.items.indexOf(u) + 1}`) === i.cartItemId
|
|
789
789
|
);
|
|
790
790
|
return {
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(C,q){typeof exports=="object"&&typeof module<"u"?module.exports=q():typeof define=="function"&&define.amd?define(q):(C=typeof globalThis<"u"?globalThis:C||self,C.SpotWidget=q())})(this,function(){"use strict";async function C(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)}),n=await s.json();if(!s.ok){const r=new Error((n==null?void 0:n.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=n,r}return n}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function q(m,t,o){try{const s=m.replace("/quote","/quote/batch"),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await n.json();if(!n.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=n.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 n={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,isPartialPayment:o.cartInfo.isPartialPayment||!1,roundTo:o.cartInfo.roundTo||void 0,items:o.items.map((p,u)=>({...p,cartItemId:p.cartItemId||`item-${u+1}`}))},r=await q(m,t,n);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=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:i,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:i}}catch(n){throw n instanceof Error?n: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:n,theme:r}=m,{environment:i="sandbox",partnerId:e,customEndpoint:p}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(p||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(c,d=null){const l=d!==null?`quoteRequestData[${d}]`:"quoteRequestData";f.forEach(v=>{if(!Object.prototype.hasOwnProperty.call(c,v)||c[v]===void 0||c[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(c.startDate))throw new Error(`${l}.startDate must be a valid ISO8601 string`);if(!w.test(c.endDate))throw new Error(`${l}.endDate must be a valid ISO8601 string`);if(typeof c.currencyCode!="string")throw new Error(`${l}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(c.currencyCode))throw new Error(`Invalid ${l}.currencyCode: ${c.currencyCode}`);if(typeof c.eventType!="string")throw new Error(`${l}.eventType must be a string`);if(typeof c.productType!="string")throw new Error(`${l}.productType must be a string`);const g=["Pass","Trip","Registration"];if(!g.includes(c.productType))throw new Error(`${l}.productType must be one of ${g.join(", ")}`);if(typeof c.productDuration!="string")throw new Error(`${l}.productDuration must be a string`);const _=["Daily","Seasonal","Trip","Event"];if(!_.includes(c.productDuration))throw new Error(`${l}.productDuration must be one of ${_.join(", ")}`);if(typeof c.productPrice!="number"||isNaN(c.productPrice))throw new Error(`${l}.productPrice must be a valid number`);if(typeof c.productId!="string")throw new Error(`${l}.productId must be a string`);if(typeof c.cartId!="string")throw new Error(`${l}.cartId must be a string`);if(typeof c.productName!="string")throw new Error(`${l}.productName must be a string`)}if("cartInfo"in o&&"items"in o){const c=o,{cartInfo:d,items:l}=c;if(!d||typeof d!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!d.cartId||typeof d.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!d.cartName||typeof d.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!d.currencyCode||typeof d.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(d.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${d.currencyCode}`);if(!Array.isArray(l)||l.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const b=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];l.forEach((g,_)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${_}] must be a non-null object`);const v=`quoteRequestData.items[${_}]`;b.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 T=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!T.test(g.startDate))throw new Error(`${v}.startDate must be a valid ISO8601 string`);if(!T.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 D=["Pass","Trip","Registration"];if(!D.includes(g.productType))throw new Error(`${v}.productType must be one of ${D.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((c,d)=>{if(!c||typeof c!="object")throw new Error(`quoteRequestData[${d}] must be a non-null object`);h(c,d)})}else h(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(c=>{const d=s[c];if(d&&typeof d!="function")throw new Error(`Callback '${c}' must be a function.`)}),typeof n=="string"&&!document.querySelector(n))throw new Error(`Invalid location selector: '${n}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function a(m,{text:t,className:o,parent:s,innerHTML:n,href:r,target:i}={}){const e=document.createElement(m);return o&&(e.className=o),t!=null&&(e.textContent=t),n!=null&&(e.innerHTML=n),r&&"href"in e&&(e.href=r),i&&"target"in e&&(e.target=i),s&&s.appendChild(e),e}function M(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 N(m,t=[]){const o=a("ul",{className:"spot-benefits__list",parent:m});t.forEach(s=>{const n=a("li",{parent:o});n.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>`,a("span",{text:s,parent:n})})}function L(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),n=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 i;try{const e=document.currentScript;if(e!=null&&e.src){const p=new URL(e.src);i=p.origin+p.pathname.replace(/\/[^/]*$/,"/")}else i=window.location.origin+window.location.pathname.replace(/\/[^/]*$/,"/");i+="assets/"}catch{i="./assets/"}s.forEach(e=>{var h,y,c;const p=a("div",{className:"spot-qualifying-reasons__item",parent:n}),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 d=a("img",{parent:u});d.src=i+f,d.alt=((y=e.benefitType)==null?void 0:y.name)||e.name||"",d.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 O(m,t=[],o){if(t.length===0||!o||o<=1)return;const s=new Map;t.forEach(d=>{s.set(d,(s.get(d)||0)+1)});const r=Array.from(s.entries()).map(([d,l])=>({item:d,count:l,displayText:l>1?`${l} x ${d}`:d})).sort((d,l)=>{const w=d.item.charAt(0),b=l.item.charAt(0),g=/[a-zA-Z]/.test(w),_=/[a-zA-Z]/.test(b);return!g&&_?-1:g&&!_?1:d.item.localeCompare(l.item,void 0,{sensitivity:"base"})}),i=a("div",{className:"spot-covered-items__container",parent:m}),e=a("div",{className:"spot-covered-items__header",parent:i}),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:i}),y=a("ul",{className:"spot-covered-items__list",parent:h});r.forEach(({displayText:d})=>{const l=a("li",{parent:y});a("span",{text:d,parent:l})});let c=!1;h.style.display="none",p.addEventListener("click",d=>{d.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 P(m,t=[]){const o=a("div",{className:"spot-table__container",parent:m}),s=a("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),n=a("thead",{parent:s}),r=a("tr",{parent:n});a("th",{text:"When you cancel",parent:r}),a("th",{text:"You will receive",parent:r});const i=a("tbody",{parent:s});t.forEach(({text:e,percent:p,amount:u})=>{const f=a("tr",{parent:i});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 $(m,t,o){const s=a("div",{className:"spot-selection__options",parent:m}),n=a("label",{className:`spot-selection__option ${t?"selected":""}`,parent:s}),r=a("input",{parent:n});r.type="radio",r.name="selection",r.value="yes",t&&(r.checked=!0),a("strong",{text:o.yesOptionText,parent:n}),a("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:n});const i=a("label",{className:"spot-selection__option",parent:s}),e=a("input",{parent:i});return e.type="radio",e.name="selection",e.value="no",a("span",{text:o.noOptionText,parent:i}),s}function R(m,t){var n;const o=(n=t.communication)==null?void 0:n.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 V(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"/>
|
|
@@ -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=a("div",{className:"spot-footer__container",parent:m}),n=a("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(a("span",{innerHTML:i,parent:n}),o==="bottom-right"){const e=a("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,n,r;try{E(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:c}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await x(f,c,this.options.quoteRequestData):await _(f,c,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 c=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=c.items)==null?void 0:h.find(y=>(y.cartItemId||`item-${c.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((n=this.options.callbacks)!=null&&n.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,n])=>{const r=`--${s}`;this.container.style.setProperty(r,n)}),M(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):N(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=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,n=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 c=Math.min(i.scrollWidth,400)+s+n;return r&&t.classList.add("desktop-layout"),o>=c}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(n=>{n.addEventListener("change",r=>{var c,u,f;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(h=>h.classList.remove("selected")),(c=i.closest(".spot-selection__option"))==null||c.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 a=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(a==null?void 0:a.productPrice)||d.spotPrice,cartItemId:(a==null?void 0:a.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 a=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(a==null?void 0:a.productPrice)||d.spotPrice,cartItemId:(a==null?void 0:a.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,n,r;try{const i={...this.options,quoteRequestData:t};E(i);const{environment:e,partnerId:c,customEndpoint:u}=this.options.apiConfig,f=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await x(f,c,i.quoteRequestData):await _(f,c,i.quoteRequestData);if(y.status!=="QUOTE_AVAILABLE")return this.destroy(),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=(n=this.options.callbacks)==null?void 0:n.onError)==null||r.call(n,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,n;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((n=this.quote)!=null&&n.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var c;const e=(c=r.items)==null?void 0:c.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});
|
|
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,n,r;try{E(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:p}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await x(f,p,this.options.quoteRequestData):await C(f,p,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 p=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=p.items)==null?void 0:h.find(y=>(y.cartItemId||`item-${p.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((n=this.options.callbacks)!=null&&n.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,n])=>{const r=`--${s}`;this.container.style.setProperty(r,n)}),M(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):N(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=a("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,n=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 p=Math.min(i.scrollWidth,400)+s+n;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"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(n=>{n.addEventListener("change",r=>{var p,u,f,h;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(y=>y.classList.remove("selected")),(p=i.closest(".spot-selection__option"))==null||p.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),e==="yes"&&((u=this.quote)!=null&&u.communication.paymentTerms&&R(this.paymentTermsEl,this.quote),(f=this.options.callbacks)!=null&&f.onOptIn)){const y={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;y.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var w;const l=(w=c.items)==null?void 0:w.find(b=>(b.cartItemId||`item-${c.items.indexOf(b)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(l==null?void 0:l.productPrice)||d.spotPrice,cartItemId:(l==null?void 0:l.cartItemId)||""}})}this.options.callbacks.onOptIn(y)}if(e==="no"&&((h=this.options.callbacks)!=null&&h.onOptOut)){const y={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const c=this.options.quoteRequestData;y.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var w;const l=(w=c.items)==null?void 0:w.find(b=>(b.cartItemId||`item-${c.items.indexOf(b)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(l==null?void 0:l.productPrice)||d.spotPrice,cartItemId:(l==null?void 0:l.cartItemId)||""}})}this.options.callbacks.onOptOut(y)}})})}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,n,r;try{const i={...this.options,quoteRequestData:t};E(i);const{environment:e,partnerId:p,customEndpoint:u}=this.options.apiConfig,f=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await x(f,p,i.quoteRequestData):await C(f,p,i.quoteRequestData);if(y.status!=="QUOTE_AVAILABLE")return this.destroy(),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=(n=this.options.callbacks)==null?void 0:n.onError)==null||r.call(n,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,n;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((n=this.quote)!=null&&n.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var p;const e=(p=r.items)==null?void 0:p.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});
|