@getspot/spot-widget 1.2.0 → 1.3.0

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @getspot/spot-widget@1.2.0 build /builds/getspot/spot-widget/packages/core
2
+ > @getspot/spot-widget@1.3.0 build /builds/getspot/spot-widget/packages/core
3
3
  > vite build
4
4
 
5
5
  The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
@@ -8,6 +8,6 @@ transforming...
8
8
  ✓ 5 modules transformed.
9
9
  rendering chunks...
10
10
  computing gzip size...
11
- dist/index.umd.js 31.12 kB │ gzip: 8.74 kB
12
- dist/index.es.js 35.34 kB │ gzip: 9.23 kB
13
- ✓ built in 185ms
11
+ dist/index.umd.js 31.95 kB │ gzip: 8.86 kB
12
+ dist/index.es.js 36.58 kB │ gzip: 9.39 kB
13
+ ✓ built in 248ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @getspot/spot-widget
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5373fa2: Fix not setting productPrice correctly for batchQuoteDetails
8
+
3
9
  ## 1.2.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- async function I(p, e, o) {
1
+ async function I(c, e, o) {
2
2
  try {
3
- const n = await fetch(p, {
3
+ const n = await fetch(c, {
4
4
  method: "POST",
5
5
  headers: {
6
6
  "Content-Type": "application/json",
@@ -17,9 +17,9 @@ async function I(p, e, o) {
17
17
  throw n instanceof Error ? n : new Error("Unknown error occurred while fetching quote");
18
18
  }
19
19
  }
20
- async function x(p, e, o) {
20
+ async function x(c, e, o) {
21
21
  try {
22
- const n = p.replace("/quote", "/quote/batch"), t = await fetch(n, {
22
+ const n = c.replace("/quote", "/quote/batch"), t = await fetch(n, {
23
23
  method: "POST",
24
24
  headers: {
25
25
  "Content-Type": "application/json",
@@ -28,59 +28,59 @@ async function x(p, e, o) {
28
28
  body: JSON.stringify(o)
29
29
  }), r = await t.json();
30
30
  if (!t.ok) {
31
- const c = new Error((r == null ? void 0 : r.message) || "Failed to fetch batch quote");
32
- throw c.status = t.status, c.responseBody = r, c;
31
+ const p = new Error((r == null ? void 0 : r.message) || "Failed to fetch batch quote");
32
+ throw p.status = t.status, p.responseBody = r, p;
33
33
  }
34
34
  return r;
35
35
  } catch (n) {
36
36
  throw n instanceof Error ? n : new Error("Unknown error occurred while fetching batch quote");
37
37
  }
38
38
  }
39
- async function k(p, e, o) {
39
+ async function D(c, e, o) {
40
40
  try {
41
41
  const n = {
42
42
  cartId: o.cartInfo.cartId,
43
43
  cartName: o.cartInfo.cartName,
44
44
  currencyCode: o.cartInfo.currencyCode,
45
- items: o.items.map((a, u) => ({
46
- cartItemId: a.cartItemId || `item-${u + 1}`,
47
- productPrice: a.productPrice,
48
- productType: a.productType,
49
- productDuration: a.productDuration,
50
- productId: a.productId,
51
- productName: a.productName,
52
- participantDescription: a.participantDescription,
53
- eventType: a.eventType,
54
- startDate: a.startDate,
55
- endDate: a.endDate
45
+ items: o.items.map((i, u) => ({
46
+ cartItemId: i.cartItemId || `item-${u + 1}`,
47
+ productPrice: i.productPrice,
48
+ productType: i.productType,
49
+ productDuration: i.productDuration,
50
+ productId: i.productId,
51
+ productName: i.productName,
52
+ participantDescription: i.participantDescription,
53
+ eventType: i.eventType,
54
+ startDate: i.startDate,
55
+ endDate: i.endDate
56
56
  }))
57
- }, t = await x(p, e, n);
57
+ }, t = await x(c, e, n);
58
58
  if (t.status !== "QUOTES_AVAILABLE" && t.status !== "QUOTE_AVAILABLE")
59
59
  return { status: "NO_MATCHING_QUOTE" };
60
- const r = t.quotes.map((a) => {
60
+ const r = t.quotes.map((i) => {
61
61
  const u = o.items.find(
62
- (h) => (h.cartItemId || `item-${o.items.indexOf(h) + 1}`) === a.cartItemId
62
+ (g) => (g.cartItemId || `item-${o.items.indexOf(g) + 1}`) === i.cartItemId
63
63
  );
64
- return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${a.cartItemId}`;
65
- }), c = Math.round((t.totalSpotPrice || t.spotPrice || 0) * 100) / 100;
64
+ return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${i.cartItemId}`;
65
+ }), p = Math.round((t.totalSpotPrice || t.spotPrice || 0) * 100) / 100;
66
66
  return {
67
67
  status: "QUOTE_AVAILABLE",
68
68
  data: {
69
- id: t.quotes ? t.quotes.map((a) => a.id).join(",") : t.id,
70
- spotPrice: c,
69
+ id: t.quotes ? t.quotes.map((i) => i.id).join(",") : t.id,
70
+ spotPrice: p,
71
71
  currencyCode: t.currencyCode,
72
72
  communication: {
73
73
  ...t.communication,
74
- yesOptionText: t.communication.yesOptionText.replace(t.totalSpotPrice, c)
74
+ yesOptionText: t.communication.yesOptionText.replace(t.totalSpotPrice, p)
75
75
  },
76
- payoutSchedule: t.payoutSchedule.map((a) => ({
77
- ...a,
78
- amount: a.amount !== void 0 ? a.amount : 0
76
+ payoutSchedule: t.payoutSchedule.map((i) => ({
77
+ ...i,
78
+ amount: i.amount !== void 0 ? i.amount : 0
79
79
  })),
80
80
  coveredItems: r,
81
81
  originalQuotes: t.quotes || [t]
82
82
  },
83
- spotPrice: c,
83
+ spotPrice: p,
84
84
  coveredItems: r
85
85
  };
86
86
  } catch (n) {
@@ -92,25 +92,25 @@ const N = {
92
92
  production: "https://api.getspot.com/v1/quote",
93
93
  local: "http://localhost:3999/api/v1/quote"
94
94
  };
95
- function D(p) {
95
+ function k(c) {
96
96
  const {
97
97
  apiConfig: e = {},
98
98
  quoteRequestData: o,
99
99
  callbacks: n = {},
100
100
  location: t,
101
101
  theme: r
102
- } = p, {
103
- environment: c = "sandbox",
104
- partnerId: a,
102
+ } = c, {
103
+ environment: p = "sandbox",
104
+ partnerId: i,
105
105
  endpoint: u
106
106
  } = e;
107
- if (!a || typeof a != "string")
107
+ if (!i || typeof i != "string")
108
108
  throw new Error("Invalid or missing partnerId in apiConfig");
109
- if (!(u || N[c]))
110
- throw new Error(`Invalid environment in apiConfig: ${c}`);
109
+ if (!(u || N[p]))
110
+ throw new Error(`Invalid environment in apiConfig: ${p}`);
111
111
  if (!o || typeof o != "object" && !Array.isArray(o))
112
112
  throw new Error("quoteRequestData must be a non-null object or array");
113
- const m = [
113
+ const h = [
114
114
  "startDate",
115
115
  "endDate",
116
116
  "currencyCode",
@@ -122,16 +122,16 @@ function D(p) {
122
122
  "cartId",
123
123
  "productName"
124
124
  ];
125
- function d(s, y = null) {
126
- const f = y !== null ? `quoteRequestData[${y}]` : "quoteRequestData";
127
- m.forEach((b) => {
128
- if (!Object.prototype.hasOwnProperty.call(s, b) || s[b] === void 0 || s[b] === null)
129
- throw new Error(`Missing required ${f} field: '${b}'`);
125
+ function d(s, l = null) {
126
+ const f = l !== null ? `quoteRequestData[${l}]` : "quoteRequestData";
127
+ h.forEach((v) => {
128
+ if (!Object.prototype.hasOwnProperty.call(s, v) || s[v] === void 0 || s[v] === null)
129
+ throw new Error(`Missing required ${f} field: '${v}'`);
130
130
  });
131
- const v = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
132
- if (!v.test(s.startDate))
131
+ const w = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
132
+ if (!w.test(s.startDate))
133
133
  throw new Error(`${f}.startDate must be a valid ISO8601 string`);
134
- if (!v.test(s.endDate))
134
+ if (!w.test(s.endDate))
135
135
  throw new Error(`${f}.endDate must be a valid ISO8601 string`);
136
136
  if (typeof s.currencyCode != "string")
137
137
  throw new Error(`${f}.currencyCode must be a string`);
@@ -141,17 +141,17 @@ function D(p) {
141
141
  throw new Error(`${f}.eventType must be a string`);
142
142
  if (typeof s.productType != "string")
143
143
  throw new Error(`${f}.productType must be a string`);
144
- const w = ["Pass", "Trip", "Registration"];
145
- if (!w.includes(s.productType))
144
+ const _ = ["Pass", "Trip", "Registration"];
145
+ if (!_.includes(s.productType))
146
146
  throw new Error(
147
- `${f}.productType must be one of ${w.join(", ")}`
147
+ `${f}.productType must be one of ${_.join(", ")}`
148
148
  );
149
149
  if (typeof s.productDuration != "string")
150
150
  throw new Error(`${f}.productDuration must be a string`);
151
- const g = ["Daily", "Seasonal", "Trip", "Event"];
152
- if (!g.includes(s.productDuration))
151
+ const y = ["Daily", "Seasonal", "Trip", "Event"];
152
+ if (!y.includes(s.productDuration))
153
153
  throw new Error(
154
- `${f}.productDuration must be one of ${g.join(", ")}`
154
+ `${f}.productDuration must be one of ${y.join(", ")}`
155
155
  );
156
156
  if (typeof s.productPrice != "number" || isNaN(s.productPrice))
157
157
  throw new Error(`${f}.productPrice must be a valid number`);
@@ -163,7 +163,7 @@ function D(p) {
163
163
  throw new Error(`${f}.productName must be a string`);
164
164
  }
165
165
  if (o.cartInfo && o.items) {
166
- const { cartInfo: s, items: y } = o;
166
+ const { cartInfo: s, items: l } = o;
167
167
  if (!s || typeof s != "object")
168
168
  throw new Error("quoteRequestData.cartInfo must be a non-null object");
169
169
  if (!s.cartId || typeof s.cartId != "string")
@@ -174,48 +174,48 @@ function D(p) {
174
174
  throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");
175
175
  if (!["USD", "CAD", "AUD"].includes(s.currencyCode))
176
176
  throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${s.currencyCode}`);
177
- if (!Array.isArray(y) || y.length === 0)
177
+ if (!Array.isArray(l) || l.length === 0)
178
178
  throw new Error("quoteRequestData.items must be a non-empty array");
179
- const v = m.filter((l) => l !== "cartId" && l !== "currencyCode");
180
- y.forEach((l, w) => {
181
- if (!l || typeof l != "object")
182
- throw new Error(`quoteRequestData.items[${w}] must be a non-null object`);
183
- const g = `quoteRequestData.items[${w}]`;
184
- v.forEach((_) => {
185
- if (!Object.prototype.hasOwnProperty.call(l, _) || l[_] === void 0 || l[_] === null)
186
- throw new Error(`Missing required ${g} field: '${_}'`);
179
+ const w = h.filter((m) => m !== "cartId" && m !== "currencyCode");
180
+ l.forEach((m, _) => {
181
+ if (!m || typeof m != "object")
182
+ throw new Error(`quoteRequestData.items[${_}] must be a non-null object`);
183
+ const y = `quoteRequestData.items[${_}]`;
184
+ w.forEach((C) => {
185
+ if (!Object.prototype.hasOwnProperty.call(m, C) || m[C] === void 0 || m[C] === null)
186
+ throw new Error(`Missing required ${y} field: '${C}'`);
187
187
  });
188
- const b = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
189
- if (!b.test(l.startDate))
190
- throw new Error(`${g}.startDate must be a valid ISO8601 string`);
191
- if (!b.test(l.endDate))
192
- throw new Error(`${g}.endDate must be a valid ISO8601 string`);
193
- if (typeof l.eventType != "string")
194
- throw new Error(`${g}.eventType must be a string`);
195
- if (typeof l.productType != "string")
196
- throw new Error(`${g}.productType must be a string`);
188
+ const v = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
189
+ if (!v.test(m.startDate))
190
+ throw new Error(`${y}.startDate must be a valid ISO8601 string`);
191
+ if (!v.test(m.endDate))
192
+ throw new Error(`${y}.endDate must be a valid ISO8601 string`);
193
+ if (typeof m.eventType != "string")
194
+ throw new Error(`${y}.eventType must be a string`);
195
+ if (typeof m.productType != "string")
196
+ throw new Error(`${y}.productType must be a string`);
197
197
  const E = ["Pass", "Trip", "Registration"];
198
- if (!E.includes(l.productType))
199
- throw new Error(`${g}.productType must be one of ${E.join(", ")}`);
200
- if (typeof l.productDuration != "string")
201
- throw new Error(`${g}.productDuration must be a string`);
198
+ if (!E.includes(m.productType))
199
+ throw new Error(`${y}.productType must be one of ${E.join(", ")}`);
200
+ if (typeof m.productDuration != "string")
201
+ throw new Error(`${y}.productDuration must be a string`);
202
202
  const q = ["Daily", "Seasonal", "Trip", "Event"];
203
- if (!q.includes(l.productDuration))
204
- throw new Error(`${g}.productDuration must be one of ${q.join(", ")}`);
205
- if (typeof l.productPrice != "number" || isNaN(l.productPrice))
206
- throw new Error(`${g}.productPrice must be a valid number`);
207
- if (typeof l.productId != "string")
208
- throw new Error(`${g}.productId must be a string`);
209
- if (typeof l.productName != "string")
210
- throw new Error(`${g}.productName must be a string`);
203
+ if (!q.includes(m.productDuration))
204
+ throw new Error(`${y}.productDuration must be one of ${q.join(", ")}`);
205
+ if (typeof m.productPrice != "number" || isNaN(m.productPrice))
206
+ throw new Error(`${y}.productPrice must be a valid number`);
207
+ if (typeof m.productId != "string")
208
+ throw new Error(`${y}.productId must be a string`);
209
+ if (typeof m.productName != "string")
210
+ throw new Error(`${y}.productName must be a string`);
211
211
  });
212
212
  } else if (Array.isArray(o)) {
213
213
  if (o.length === 0)
214
214
  throw new Error("quoteRequestData array cannot be empty");
215
- o.forEach((s, y) => {
215
+ o.forEach((s, l) => {
216
216
  if (!s || typeof s != "object")
217
- throw new Error(`quoteRequestData[${y}] must be a non-null object`);
218
- d(s, y);
217
+ throw new Error(`quoteRequestData[${l}] must be a non-null object`);
218
+ d(s, l);
219
219
  });
220
220
  } else
221
221
  d(o);
@@ -226,8 +226,8 @@ function D(p) {
226
226
  "onError",
227
227
  "noMatchingQuote"
228
228
  ].forEach((s) => {
229
- const y = n[s];
230
- if (y && typeof y != "function")
229
+ const l = n[s];
230
+ if (l && typeof l != "function")
231
231
  throw new Error(`Callback '${s}' must be a function.`);
232
232
  }), typeof t == "string" && !document.querySelector(t))
233
233
  throw new Error(`Invalid location selector: '${t}'`);
@@ -236,128 +236,128 @@ function D(p) {
236
236
  "Theme must be an object with CSS variables, do not include the '--' prefix"
237
237
  );
238
238
  }
239
- function i(p, { text: e, className: o, parent: n, innerHTML: t } = {}) {
240
- const r = document.createElement(p);
239
+ function a(c, { text: e, className: o, parent: n, innerHTML: t } = {}) {
240
+ const r = document.createElement(c);
241
241
  return o && (r.className = o), e != null && (r.textContent = e), t != null && (r.innerHTML = t), n && n.appendChild(r), r;
242
242
  }
243
- function O(p, { name: e, description: o }) {
244
- i("div", {
243
+ function O(c, { name: e, description: o }) {
244
+ a("div", {
245
245
  className: "spot-header__title",
246
246
  text: e,
247
- parent: p
248
- }), i("div", {
247
+ parent: c
248
+ }), a("div", {
249
249
  className: "spot-header__description",
250
250
  text: o,
251
- parent: p
251
+ parent: c
252
252
  });
253
253
  }
254
- function P(p, e = []) {
255
- const o = i("ul", {
254
+ function P(c, e = []) {
255
+ const o = a("ul", {
256
256
  className: "spot-benefits__list",
257
- parent: p
257
+ parent: c
258
258
  });
259
259
  e.forEach((n) => {
260
- const t = i("li", { parent: o });
260
+ const t = a("li", { parent: o });
261
261
  t.innerHTML = `
262
262
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
263
263
  <path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
264
264
  stroke="#2E2E2E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
265
- </svg>`, i("span", { text: n, parent: t });
265
+ </svg>`, a("span", { text: n, parent: t });
266
266
  });
267
267
  }
268
- function $(p, e = []) {
268
+ function $(c, e = []) {
269
269
  if (e.length === 0) return;
270
- const o = i("div", {
270
+ const o = a("div", {
271
271
  className: "spot-covered-items__container",
272
- parent: p
272
+ parent: c
273
273
  });
274
- i("div", {
274
+ a("div", {
275
275
  className: "spot-covered-items__title",
276
276
  text: "Items covered in your cart:",
277
277
  parent: o
278
278
  });
279
- const n = i("ul", {
279
+ const n = a("ul", {
280
280
  className: "spot-covered-items__list",
281
281
  parent: o
282
282
  });
283
283
  e.forEach((t) => {
284
- const r = i("li", { parent: n });
285
- i("span", { text: t, parent: r });
284
+ const r = a("li", { parent: n });
285
+ a("span", { text: t, parent: r });
286
286
  });
287
287
  }
288
- function Q(p, e = []) {
289
- const o = i("div", {
288
+ function R(c, e = []) {
289
+ const o = a("div", {
290
290
  className: "spot-table__container",
291
- parent: p
292
- }), n = i("table", {
291
+ parent: c
292
+ }), n = a("table", {
293
293
  className: "spot-refund__table spot-table--dynamic",
294
294
  parent: o
295
- }), t = i("thead", { parent: n }), r = i("tr", { parent: t });
296
- i("th", { text: "When you cancel", parent: r }), i("th", { text: "You will receive", parent: r });
297
- const c = i("tbody", { parent: n });
298
- e.forEach(({ text: a, percent: u, amount: h }) => {
299
- const m = i("tr", { parent: c });
300
- i("td", { text: a, parent: m });
301
- const d = u === "Not eligible for refund" ? "Not eligible for a refund" : `$${h} refund`;
302
- i("td", { text: d, parent: m });
295
+ }), t = a("thead", { parent: n }), r = a("tr", { parent: t });
296
+ a("th", { text: "When you cancel", parent: r }), a("th", { text: "You will receive", parent: r });
297
+ const p = a("tbody", { parent: n });
298
+ e.forEach(({ text: i, percent: u, amount: g }) => {
299
+ const h = a("tr", { parent: p });
300
+ a("td", { text: i, parent: h });
301
+ const d = u === "Not eligible for refund" ? "Not eligible for a refund" : `$${g} refund`;
302
+ a("td", { text: d, parent: h });
303
303
  });
304
304
  }
305
- function H(p, e, o) {
306
- const n = i("div", {
305
+ function Q(c, e, o) {
306
+ const n = a("div", {
307
307
  className: "spot-selection__options",
308
- parent: p
309
- }), t = i("label", {
308
+ parent: c
309
+ }), t = a("label", {
310
310
  className: `spot-selection__option ${e ? "selected" : ""}`,
311
311
  parent: n
312
- }), r = i("input", { parent: t });
313
- r.type = "radio", r.name = "selection", r.value = "yes", e && (r.checked = !0), i("strong", {
312
+ }), r = a("input", { parent: t });
313
+ r.type = "radio", r.name = "selection", r.value = "yes", e && (r.checked = !0), a("strong", {
314
314
  text: o.yesOptionText,
315
315
  parent: t
316
- }), i("span", {
316
+ }), a("span", {
317
317
  className: "spot-selection__recommended-tag",
318
318
  text: "Recommended",
319
319
  parent: t
320
320
  });
321
- const c = i("label", {
321
+ const p = a("label", {
322
322
  className: "spot-selection__option",
323
323
  parent: n
324
- }), a = i("input", { parent: c });
325
- return a.type = "radio", a.name = "selection", a.value = "no", i("span", { text: o.noOptionText, parent: c }), n;
324
+ }), i = a("input", { parent: p });
325
+ return i.type = "radio", i.name = "selection", i.value = "no", a("span", { text: o.noOptionText, parent: p }), n;
326
326
  }
327
- function S(p, e) {
327
+ function H(c, e) {
328
328
  var t;
329
- const o = (t = e.communication) == null ? void 0 : t.paymentTerms, n = i("div", {
329
+ const o = (t = e.communication) == null ? void 0 : t.paymentTerms, n = a("div", {
330
330
  className: "spot-payment-terms",
331
- parent: p
331
+ parent: c
332
332
  });
333
- return i("div", {
333
+ return a("div", {
334
334
  className: "spot-payment-terms__header",
335
335
  text: "PAYMENT TERMS",
336
336
  parent: n
337
- }), i("div", {
337
+ }), a("div", {
338
338
  className: "spot-payment-terms__body",
339
339
  text: o,
340
340
  parent: n
341
341
  }), n;
342
342
  }
343
- function z(p, e) {
344
- const o = i("div", {
343
+ function S(c, e) {
344
+ const o = a("div", {
345
345
  className: "spot-footer__container",
346
- parent: p
347
- }), n = i("div", {
346
+ parent: c
347
+ }), n = a("div", {
348
348
  className: "spot-footer__terms",
349
349
  parent: o
350
350
  });
351
- i("span", {
351
+ a("span", {
352
352
  innerHTML: e.communication.legalDisclaimer,
353
353
  parent: n
354
- }), i("br", { parent: n }), i("a", {
354
+ }), a("br", { parent: n }), a("a", {
355
355
  href: e.communication.termsAndConditionsUrl,
356
356
  className: "spot-footer__terms-link",
357
357
  text: "Refund Guarantee Terms and Conditions",
358
358
  parent: n
359
359
  });
360
- const t = i("p", {
360
+ const t = a("p", {
361
361
  className: "spot-footer__powered-by",
362
362
  parent: o
363
363
  });
@@ -378,12 +378,12 @@ function z(p, e) {
378
378
  </defs>
379
379
  </svg>`, o;
380
380
  }
381
- const M = ":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--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-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-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-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:51rem;margin:1rem}.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}@media (min-width: 48rem){.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr 20.3125rem;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list{grid-row:1}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1}.desktop-layout .spot-selection__options{grid-row:3}.desktop-layout .spot-table__container{grid-row:1 / span 3}}@media (max-width: 52.438rem){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 47.938rem){.spot-selection__recommended-tag{margin-top:0rem}}@media (max-width: 32.125rem){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 47.9375rem){.spot-table__container{display:flex;justify-content:center}.spot-selection__recommended-tag{display:inline-block;margin-left:0}.spot-footer__container{flex-direction:column;margin-top:.5rem}.spot-refund__table{width:100%;table-layout:auto}.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:.5rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-covered-items__container{margin-top:0;margin-bottom:1rem}.spot-covered-items__title{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: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-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:1.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;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}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:block;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;gap:.5rem;flex:1 0 0;align-self:stretch}.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:1.5rem;white-space:nowrap}.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)}.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;justify-content:space-between;align-items:center}.spot-footer__powered-by{margin-top:1.5rem}";
382
- function R(p) {
381
+ const z = ":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--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-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-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-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:51rem;margin:1rem}.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}@media (min-width: 48rem){.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr 20.3125rem;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list{grid-row:1}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1}.desktop-layout .spot-selection__options{grid-row:3}.desktop-layout .spot-table__container{grid-row:1 / span 3}}@media (max-width: 52.438rem){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 47.938rem){.spot-selection__recommended-tag{margin-top:0rem}}@media (max-width: 32.125rem){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 47.9375rem){.spot-table__container{display:flex;justify-content:center}.spot-selection__recommended-tag{display:inline-block;margin-left:0}.spot-footer__container{flex-direction:column;margin-top:.5rem}.spot-refund__table{width:100%;table-layout:auto}.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:.5rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-covered-items__container{margin-top:0;margin-bottom:1rem}.spot-covered-items__title{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: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-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:1.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;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}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:block;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;gap:.5rem;flex:1 0 0;align-self:stretch}.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:1.5rem;white-space:nowrap}.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)}.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;justify-content:space-between;align-items:center}.spot-footer__powered-by{margin-top:1.5rem}";
382
+ function M(c) {
383
383
  const e = document.createElement("style");
384
- e.textContent = p, document.head.appendChild(e);
384
+ e.textContent = c, document.head.appendChild(e);
385
385
  }
386
- R(M);
386
+ M(z);
387
387
  const T = {
388
388
  sandbox: "https://api.sandbox.getspot.com/api/v1/quote",
389
389
  production: "https://api.getspot.com/api/v1/quote",
@@ -404,8 +404,8 @@ class L {
404
404
  async _init() {
405
405
  var e, o, n, t, r;
406
406
  try {
407
- D(this.options);
408
- const { environment: c, partnerId: a } = this.options.apiConfig, h = this.options.apiConfig.customEndpoint || T[c], d = this.options.quoteRequestData.cartInfo && this.options.quoteRequestData.items ? await k(h, a, this.options.quoteRequestData) : await I(h, a, this.options.quoteRequestData);
407
+ k(this.options);
408
+ const { environment: p, partnerId: i } = this.options.apiConfig, g = this.options.apiConfig.customEndpoint || T[p], d = this.options.quoteRequestData.cartInfo && this.options.quoteRequestData.items ? await D(g, i, this.options.quoteRequestData) : await I(g, i, this.options.quoteRequestData);
409
409
  if (d.status !== "QUOTE_AVAILABLE") {
410
410
  d.status === "NO_MATCHING_QUOTE" && ((e = this.options.callbacks) != null && e.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
411
411
  status: "NO_MATCHING_QUOTE",
@@ -414,23 +414,29 @@ class L {
414
414
  return;
415
415
  }
416
416
  if (this.quote = d.data, this._renderWidget(), this.options.optInSelected && ((o = this.options.callbacks) != null && o.onOptIn)) {
417
- const C = {
417
+ const b = {
418
418
  status: "QUOTE_ACCEPTED",
419
419
  spotPrice: this.quote.spotPrice,
420
420
  quoteId: this.quote.id
421
421
  };
422
- this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (C.batchQuoteDetails = this.quote.originalQuotes.map((s) => ({
423
- quoteId: s.id,
424
- productPrice: s.spotPrice,
425
- cartItemId: s.cartItemId
426
- }))), this.options.callbacks.onOptIn(C);
422
+ this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (b.batchQuoteDetails = this.quote.originalQuotes.map((s) => {
423
+ var f;
424
+ const l = (f = this.options.quoteRequestData.items) == null ? void 0 : f.find(
425
+ (w) => (w.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(w) + 1}`) === s.cartItemId
426
+ );
427
+ return {
428
+ quoteId: s.id,
429
+ productPrice: (l == null ? void 0 : l.productPrice) || s.spotPrice,
430
+ cartItemId: s.cartItemId
431
+ };
432
+ })), this.options.callbacks.onOptIn(b);
427
433
  }
428
434
  (n = this.options.callbacks) != null && n.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote);
429
- } catch (c) {
435
+ } catch (p) {
430
436
  (t = this.options.callbacks) != null && t.onError && ((r = this.options.callbacks) == null || r.onError({
431
- message: c.message,
432
- status: c.status,
433
- responseBody: c.responseBody
437
+ message: p.message,
438
+ status: p.status,
439
+ responseBody: p.responseBody
434
440
  }));
435
441
  }
436
442
  }
@@ -440,16 +446,16 @@ class L {
440
446
  this.container.style.setProperty(r, t);
441
447
  }), O(this.container, this.quote.communication);
442
448
  const e = document.createElement("div");
443
- e.className = "spot-content__wrapper", this.container.appendChild(e), P(e, this.quote.communication.bulletPoints), this.quote.coveredItems && $(e, this.quote.coveredItems), this.options.showTable && Q(e, this.quote.payoutSchedule);
444
- const o = H(
449
+ e.className = "spot-content__wrapper", this.container.appendChild(e), P(e, this.quote.communication.bulletPoints), this.quote.coveredItems && $(e, this.quote.coveredItems), this.options.showTable && R(e, this.quote.payoutSchedule);
450
+ const o = Q(
445
451
  e,
446
452
  this.options.optInSelected,
447
453
  this.quote.communication
448
454
  );
449
- e.appendChild(o), this.paymentTermsEl = i("div", {
455
+ e.appendChild(o), this.paymentTermsEl = a("div", {
450
456
  className: "spot-payment-terms__wrapper",
451
457
  parent: e
452
- }), z(this.container, this.quote), window.addEventListener("resize", this._onResize), this._updateLayout(), this._setupOptionListeners(o);
458
+ }), S(this.container, this.quote), window.addEventListener("resize", this._onResize), this._updateLayout(), this._setupOptionListeners(o);
453
459
  }
454
460
  _updateLayout() {
455
461
  const e = window.matchMedia("(min-width: 768px)").matches;
@@ -459,30 +465,42 @@ class L {
459
465
  const o = e.querySelectorAll('input[type="radio"]'), n = e.querySelectorAll(".spot-selection__option");
460
466
  o.forEach((t) => {
461
467
  t.addEventListener("change", (r) => {
462
- var a, u, h;
463
- const c = r.target.value;
464
- if (this.hideSelectionError(), this.currentSelection = c, n.forEach((m) => m.classList.remove("selected")), (a = r.target.closest(".spot-selection__option")) == null || a.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), c === "yes" && (this.options.quoteRequestData.isPartialPayment && S(this.paymentTermsEl, this.quote), (u = this.options.callbacks) != null && u.onOptIn)) {
465
- const m = {
468
+ var i, u, g;
469
+ const p = r.target.value;
470
+ if (this.hideSelectionError(), this.currentSelection = p, n.forEach((h) => h.classList.remove("selected")), (i = r.target.closest(".spot-selection__option")) == null || i.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), p === "yes" && (this.options.quoteRequestData.isPartialPayment && H(this.paymentTermsEl, this.quote), (u = this.options.callbacks) != null && u.onOptIn)) {
471
+ const h = {
466
472
  status: "QUOTE_ACCEPTED",
467
473
  spotPrice: this.quote.spotPrice,
468
474
  quoteId: this.quote.id
469
475
  };
470
- this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (m.batchQuoteDetails = this.quote.originalQuotes.map((d) => ({
471
- quoteId: d.id,
472
- productPrice: d.spotPrice,
473
- cartItemId: d.cartItemId
474
- }))), this.options.callbacks.onOptIn(m);
476
+ this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (h.batchQuoteDetails = this.quote.originalQuotes.map((d) => {
477
+ var s;
478
+ const b = (s = this.options.quoteRequestData.items) == null ? void 0 : s.find(
479
+ (l) => (l.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(l) + 1}`) === d.cartItemId
480
+ );
481
+ return {
482
+ quoteId: d.id,
483
+ productPrice: (b == null ? void 0 : b.productPrice) || d.spotPrice,
484
+ cartItemId: d.cartItemId
485
+ };
486
+ })), this.options.callbacks.onOptIn(h);
475
487
  }
476
- if (c === "no" && ((h = this.options.callbacks) != null && h.onOptOut)) {
477
- const m = {
488
+ if (p === "no" && ((g = this.options.callbacks) != null && g.onOptOut)) {
489
+ const h = {
478
490
  status: "QUOTE_DECLINED",
479
491
  quoteId: this.quote.id
480
492
  };
481
- this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (m.batchQuoteDetails = this.quote.originalQuotes.map((d) => ({
482
- quoteId: d.id,
483
- productPrice: d.spotPrice,
484
- cartItemId: d.cartItemId
485
- }))), this.options.callbacks.onOptOut(m);
493
+ this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (h.batchQuoteDetails = this.quote.originalQuotes.map((d) => {
494
+ var s;
495
+ const b = (s = this.options.quoteRequestData.items) == null ? void 0 : s.find(
496
+ (l) => (l.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(l) + 1}`) === d.cartItemId
497
+ );
498
+ return {
499
+ quoteId: d.id,
500
+ productPrice: (b == null ? void 0 : b.productPrice) || d.spotPrice,
501
+ cartItemId: d.cartItemId
502
+ };
503
+ })), this.options.callbacks.onOptOut(h);
486
504
  }
487
505
  });
488
506
  });
@@ -515,12 +533,12 @@ class L {
515
533
  ...this.options,
516
534
  quoteRequestData: e
517
535
  };
518
- D(r);
536
+ k(r);
519
537
  const {
520
- environment: c,
521
- partnerId: a,
538
+ environment: p,
539
+ partnerId: i,
522
540
  endpoint: u
523
- } = this.options.apiConfig, h = u || T[c], d = r.quoteRequestData.cartInfo && r.quoteRequestData.items ? await k(h, a, r.quoteRequestData) : await I(h, a, r.quoteRequestData);
541
+ } = this.options.apiConfig, g = u || T[p], d = r.quoteRequestData.cartInfo && r.quoteRequestData.items ? await D(g, i, r.quoteRequestData) : await I(g, i, r.quoteRequestData);
524
542
  return d.status !== "QUOTE_AVAILABLE" ? (d.status === "NO_MATCHING_QUOTE" && ((o = this.options.callbacks) != null && o.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
525
543
  status: "NO_MATCHING_QUOTE",
526
544
  data: r.quoteRequestData
@@ -542,11 +560,17 @@ class L {
542
560
  spotPrice: (n = this.quote) == null ? void 0 : n.spotPrice,
543
561
  status: this.currentSelection === "yes" ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED"
544
562
  };
545
- return (t = this.quote) != null && t.originalQuotes && this.quote.originalQuotes.length > 0 && (e.batchQuoteDetails = this.quote.originalQuotes.map((r) => ({
546
- quoteId: r.id,
547
- productPrice: r.spotPrice,
548
- cartItemId: r.cartItemId
549
- }))), e;
563
+ return (t = this.quote) != null && t.originalQuotes && this.quote.originalQuotes.length > 0 && (e.batchQuoteDetails = this.quote.originalQuotes.map((r) => {
564
+ var i;
565
+ const p = (i = this.options.quoteRequestData.items) == null ? void 0 : i.find(
566
+ (u) => (u.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(u) + 1}`) === r.cartItemId
567
+ );
568
+ return {
569
+ quoteId: r.id,
570
+ productPrice: (p == null ? void 0 : p.productPrice) || r.spotPrice,
571
+ cartItemId: r.cartItemId
572
+ };
573
+ })), e;
550
574
  }
551
575
  destroy() {
552
576
  window.removeEventListener("resize", this._onResize), this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container);
package/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
- (function(w,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(w=typeof globalThis<"u"?globalThis:w||self,w.SpotWidget=v())})(this,function(){"use strict";async function w(p,e,o){try{const n=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":e},body:JSON.stringify(o)}),t=await n.json();if(!n.ok){const r=new Error((t==null?void 0:t.message)||"Failed to fetch quote");throw r.status=n.status,r.responseBody=t,r}return t}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching quote")}}async function v(p,e,o){try{const n=p.replace("/quote","/quote/batch"),t=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":e},body:JSON.stringify(o)}),r=await t.json();if(!t.ok){const c=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw c.status=t.status,c.responseBody=r,c}return r}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching batch quote")}}async function I(p,e,o){try{const n={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((a,u)=>({cartItemId:a.cartItemId||`item-${u+1}`,productPrice:a.productPrice,productType:a.productType,productDuration:a.productDuration,productId:a.productId,productName:a.productName,participantDescription:a.participantDescription,eventType:a.eventType,startDate:a.startDate,endDate:a.endDate}))},t=await v(p,e,n);if(t.status!=="QUOTES_AVAILABLE"&&t.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const r=t.quotes.map(a=>{const u=o.items.find(h=>(h.cartItemId||`item-${o.items.indexOf(h)+1}`)===a.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${a.cartItemId}`}),c=Math.round((t.totalSpotPrice||t.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:t.quotes?t.quotes.map(a=>a.id).join(","):t.id,spotPrice:c,currencyCode:t.currencyCode,communication:{...t.communication,yesOptionText:t.communication.yesOptionText.replace(t.totalSpotPrice,c)},payoutSchedule:t.payoutSchedule.map(a=>({...a,amount:a.amount!==void 0?a.amount:0})),coveredItems:r,originalQuotes:t.quotes||[t]},spotPrice:c,coveredItems:r}}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching multiple quotes")}}const N={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function k(p){const{apiConfig:e={},quoteRequestData:o,callbacks:n={},location:t,theme:r}=p,{environment:c="sandbox",partnerId:a,endpoint:u}=e;if(!a||typeof a!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(u||N[c]))throw new Error(`Invalid environment in apiConfig: ${c}`);if(!o||typeof o!="object"&&!Array.isArray(o))throw new Error("quoteRequestData must be a non-null object or array");const m=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function d(s,y=null){const f=y!==null?`quoteRequestData[${y}]`:"quoteRequestData";m.forEach(b=>{if(!Object.prototype.hasOwnProperty.call(s,b)||s[b]===void 0||s[b]===null)throw new Error(`Missing required ${f} field: '${b}'`)});const C=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!C.test(s.startDate))throw new Error(`${f}.startDate must be a valid ISO8601 string`);if(!C.test(s.endDate))throw new Error(`${f}.endDate must be a valid ISO8601 string`);if(typeof s.currencyCode!="string")throw new Error(`${f}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(s.currencyCode))throw new Error(`Invalid ${f}.currencyCode: ${s.currencyCode}`);if(typeof s.eventType!="string")throw new Error(`${f}.eventType must be a string`);if(typeof s.productType!="string")throw new Error(`${f}.productType must be a string`);const _=["Pass","Trip","Registration"];if(!_.includes(s.productType))throw new Error(`${f}.productType must be one of ${_.join(", ")}`);if(typeof s.productDuration!="string")throw new Error(`${f}.productDuration must be a string`);const g=["Daily","Seasonal","Trip","Event"];if(!g.includes(s.productDuration))throw new Error(`${f}.productDuration must be one of ${g.join(", ")}`);if(typeof s.productPrice!="number"||isNaN(s.productPrice))throw new Error(`${f}.productPrice must be a valid number`);if(typeof s.productId!="string")throw new Error(`${f}.productId must be a string`);if(typeof s.cartId!="string")throw new Error(`${f}.cartId must be a string`);if(typeof s.productName!="string")throw new Error(`${f}.productName must be a string`)}if(o.cartInfo&&o.items){const{cartInfo:s,items:y}=o;if(!s||typeof s!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!s.cartId||typeof s.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!s.cartName||typeof s.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!s.currencyCode||typeof s.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(s.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${s.currencyCode}`);if(!Array.isArray(y)||y.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const C=m.filter(l=>l!=="cartId"&&l!=="currencyCode");y.forEach((l,_)=>{if(!l||typeof l!="object")throw new Error(`quoteRequestData.items[${_}] must be a non-null object`);const g=`quoteRequestData.items[${_}]`;C.forEach(E=>{if(!Object.prototype.hasOwnProperty.call(l,E)||l[E]===void 0||l[E]===null)throw new Error(`Missing required ${g} field: '${E}'`)});const b=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!b.test(l.startDate))throw new Error(`${g}.startDate must be a valid ISO8601 string`);if(!b.test(l.endDate))throw new Error(`${g}.endDate must be a valid ISO8601 string`);if(typeof l.eventType!="string")throw new Error(`${g}.eventType must be a string`);if(typeof l.productType!="string")throw new Error(`${g}.productType must be a string`);const T=["Pass","Trip","Registration"];if(!T.includes(l.productType))throw new Error(`${g}.productType must be one of ${T.join(", ")}`);if(typeof l.productDuration!="string")throw new Error(`${g}.productDuration must be a string`);const x=["Daily","Seasonal","Trip","Event"];if(!x.includes(l.productDuration))throw new Error(`${g}.productDuration must be one of ${x.join(", ")}`);if(typeof l.productPrice!="number"||isNaN(l.productPrice))throw new Error(`${g}.productPrice must be a valid number`);if(typeof l.productId!="string")throw new Error(`${g}.productId must be a string`);if(typeof l.productName!="string")throw new Error(`${g}.productName must be a string`)})}else if(Array.isArray(o)){if(o.length===0)throw new Error("quoteRequestData array cannot be empty");o.forEach((s,y)=>{if(!s||typeof s!="object")throw new Error(`quoteRequestData[${y}] must be a non-null object`);d(s,y)})}else d(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(s=>{const y=n[s];if(y&&typeof y!="function")throw new Error(`Callback '${s}' must be a function.`)}),typeof t=="string"&&!document.querySelector(t))throw new Error(`Invalid location selector: '${t}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function i(p,{text:e,className:o,parent:n,innerHTML:t}={}){const r=document.createElement(p);return o&&(r.className=o),e!=null&&(r.textContent=e),t!=null&&(r.innerHTML=t),n&&n.appendChild(r),r}function O(p,{name:e,description:o}){i("div",{className:"spot-header__title",text:e,parent:p}),i("div",{className:"spot-header__description",text:o,parent:p})}function P(p,e=[]){const o=i("ul",{className:"spot-benefits__list",parent:p});e.forEach(n=>{const t=i("li",{parent:o});t.innerHTML=`
1
+ (function(_,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(_=typeof globalThis<"u"?globalThis:_||self,_.SpotWidget=C())})(this,function(){"use strict";async function _(c,e,o){try{const n=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":e},body:JSON.stringify(o)}),t=await n.json();if(!n.ok){const r=new Error((t==null?void 0:t.message)||"Failed to fetch quote");throw r.status=n.status,r.responseBody=t,r}return t}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching quote")}}async function C(c,e,o){try{const n=c.replace("/quote","/quote/batch"),t=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":e},body:JSON.stringify(o)}),r=await t.json();if(!t.ok){const p=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw p.status=t.status,p.responseBody=r,p}return r}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching batch quote")}}async function I(c,e,o){try{const n={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((i,u)=>({cartItemId:i.cartItemId||`item-${u+1}`,productPrice:i.productPrice,productType:i.productType,productDuration:i.productDuration,productId:i.productId,productName:i.productName,participantDescription:i.participantDescription,eventType:i.eventType,startDate:i.startDate,endDate:i.endDate}))},t=await C(c,e,n);if(t.status!=="QUOTES_AVAILABLE"&&t.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const r=t.quotes.map(i=>{const u=o.items.find(g=>(g.cartItemId||`item-${o.items.indexOf(g)+1}`)===i.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${i.cartItemId}`}),p=Math.round((t.totalSpotPrice||t.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:t.quotes?t.quotes.map(i=>i.id).join(","):t.id,spotPrice:p,currencyCode:t.currencyCode,communication:{...t.communication,yesOptionText:t.communication.yesOptionText.replace(t.totalSpotPrice,p)},payoutSchedule:t.payoutSchedule.map(i=>({...i,amount:i.amount!==void 0?i.amount:0})),coveredItems:r,originalQuotes:t.quotes||[t]},spotPrice:p,coveredItems:r}}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching multiple quotes")}}const N={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function D(c){const{apiConfig:e={},quoteRequestData:o,callbacks:n={},location:t,theme:r}=c,{environment:p="sandbox",partnerId:i,endpoint:u}=e;if(!i||typeof i!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(u||N[p]))throw new Error(`Invalid environment in apiConfig: ${p}`);if(!o||typeof o!="object"&&!Array.isArray(o))throw new Error("quoteRequestData must be a non-null object or array");const h=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function d(s,l=null){const f=l!==null?`quoteRequestData[${l}]`:"quoteRequestData";h.forEach(v=>{if(!Object.prototype.hasOwnProperty.call(s,v)||s[v]===void 0||s[v]===null)throw new Error(`Missing required ${f} field: '${v}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(s.startDate))throw new Error(`${f}.startDate must be a valid ISO8601 string`);if(!w.test(s.endDate))throw new Error(`${f}.endDate must be a valid ISO8601 string`);if(typeof s.currencyCode!="string")throw new Error(`${f}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(s.currencyCode))throw new Error(`Invalid ${f}.currencyCode: ${s.currencyCode}`);if(typeof s.eventType!="string")throw new Error(`${f}.eventType must be a string`);if(typeof s.productType!="string")throw new Error(`${f}.productType must be a string`);const E=["Pass","Trip","Registration"];if(!E.includes(s.productType))throw new Error(`${f}.productType must be one of ${E.join(", ")}`);if(typeof s.productDuration!="string")throw new Error(`${f}.productDuration must be a string`);const y=["Daily","Seasonal","Trip","Event"];if(!y.includes(s.productDuration))throw new Error(`${f}.productDuration must be one of ${y.join(", ")}`);if(typeof s.productPrice!="number"||isNaN(s.productPrice))throw new Error(`${f}.productPrice must be a valid number`);if(typeof s.productId!="string")throw new Error(`${f}.productId must be a string`);if(typeof s.cartId!="string")throw new Error(`${f}.cartId must be a string`);if(typeof s.productName!="string")throw new Error(`${f}.productName must be a string`)}if(o.cartInfo&&o.items){const{cartInfo:s,items:l}=o;if(!s||typeof s!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!s.cartId||typeof s.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!s.cartName||typeof s.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!s.currencyCode||typeof s.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(s.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${s.currencyCode}`);if(!Array.isArray(l)||l.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const w=h.filter(m=>m!=="cartId"&&m!=="currencyCode");l.forEach((m,E)=>{if(!m||typeof m!="object")throw new Error(`quoteRequestData.items[${E}] must be a non-null object`);const y=`quoteRequestData.items[${E}]`;w.forEach(q=>{if(!Object.prototype.hasOwnProperty.call(m,q)||m[q]===void 0||m[q]===null)throw new Error(`Missing required ${y} field: '${q}'`)});const v=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!v.test(m.startDate))throw new Error(`${y}.startDate must be a valid ISO8601 string`);if(!v.test(m.endDate))throw new Error(`${y}.endDate must be a valid ISO8601 string`);if(typeof m.eventType!="string")throw new Error(`${y}.eventType must be a string`);if(typeof m.productType!="string")throw new Error(`${y}.productType must be a string`);const T=["Pass","Trip","Registration"];if(!T.includes(m.productType))throw new Error(`${y}.productType must be one of ${T.join(", ")}`);if(typeof m.productDuration!="string")throw new Error(`${y}.productDuration must be a string`);const x=["Daily","Seasonal","Trip","Event"];if(!x.includes(m.productDuration))throw new Error(`${y}.productDuration must be one of ${x.join(", ")}`);if(typeof m.productPrice!="number"||isNaN(m.productPrice))throw new Error(`${y}.productPrice must be a valid number`);if(typeof m.productId!="string")throw new Error(`${y}.productId must be a string`);if(typeof m.productName!="string")throw new Error(`${y}.productName must be a string`)})}else if(Array.isArray(o)){if(o.length===0)throw new Error("quoteRequestData array cannot be empty");o.forEach((s,l)=>{if(!s||typeof s!="object")throw new Error(`quoteRequestData[${l}] must be a non-null object`);d(s,l)})}else d(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(s=>{const l=n[s];if(l&&typeof l!="function")throw new Error(`Callback '${s}' must be a function.`)}),typeof t=="string"&&!document.querySelector(t))throw new Error(`Invalid location selector: '${t}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function a(c,{text:e,className:o,parent:n,innerHTML:t}={}){const r=document.createElement(c);return o&&(r.className=o),e!=null&&(r.textContent=e),t!=null&&(r.innerHTML=t),n&&n.appendChild(r),r}function O(c,{name:e,description:o}){a("div",{className:"spot-header__title",text:e,parent:c}),a("div",{className:"spot-header__description",text:o,parent:c})}function P(c,e=[]){const o=a("ul",{className:"spot-benefits__list",parent:c});e.forEach(n=>{const t=a("li",{parent:o});t.innerHTML=`
2
2
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
3
3
  <path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
4
4
  stroke="#2E2E2E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
5
- </svg>`,i("span",{text:n,parent:t})})}function $(p,e=[]){if(e.length===0)return;const o=i("div",{className:"spot-covered-items__container",parent:p});i("div",{className:"spot-covered-items__title",text:"Items covered in your cart:",parent:o});const n=i("ul",{className:"spot-covered-items__list",parent:o});e.forEach(t=>{const r=i("li",{parent:n});i("span",{text:t,parent:r})})}function Q(p,e=[]){const o=i("div",{className:"spot-table__container",parent:p}),n=i("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),t=i("thead",{parent:n}),r=i("tr",{parent:t});i("th",{text:"When you cancel",parent:r}),i("th",{text:"You will receive",parent:r});const c=i("tbody",{parent:n});e.forEach(({text:a,percent:u,amount:h})=>{const m=i("tr",{parent:c});i("td",{text:a,parent:m});const d=u==="Not eligible for refund"?"Not eligible for a refund":`$${h} refund`;i("td",{text:d,parent:m})})}function S(p,e,o){const n=i("div",{className:"spot-selection__options",parent:p}),t=i("label",{className:`spot-selection__option ${e?"selected":""}`,parent:n}),r=i("input",{parent:t});r.type="radio",r.name="selection",r.value="yes",e&&(r.checked=!0),i("strong",{text:o.yesOptionText,parent:t}),i("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:t});const c=i("label",{className:"spot-selection__option",parent:n}),a=i("input",{parent:c});return a.type="radio",a.name="selection",a.value="no",i("span",{text:o.noOptionText,parent:c}),n}function H(p,e){var t;const o=(t=e.communication)==null?void 0:t.paymentTerms,n=i("div",{className:"spot-payment-terms",parent:p});return i("div",{className:"spot-payment-terms__header",text:"PAYMENT TERMS",parent:n}),i("div",{className:"spot-payment-terms__body",text:o,parent:n}),n}function z(p,e){const o=i("div",{className:"spot-footer__container",parent:p}),n=i("div",{className:"spot-footer__terms",parent:o});i("span",{innerHTML:e.communication.legalDisclaimer,parent:n}),i("br",{parent:n}),i("a",{href:e.communication.termsAndConditionsUrl,className:"spot-footer__terms-link",text:"Refund Guarantee Terms and Conditions",parent:n});const t=i("p",{className:"spot-footer__powered-by",parent:o});return t.innerHTML=`
5
+ </svg>`,a("span",{text:n,parent:t})})}function $(c,e=[]){if(e.length===0)return;const o=a("div",{className:"spot-covered-items__container",parent:c});a("div",{className:"spot-covered-items__title",text:"Items covered in your cart:",parent:o});const n=a("ul",{className:"spot-covered-items__list",parent:o});e.forEach(t=>{const r=a("li",{parent:n});a("span",{text:t,parent:r})})}function R(c,e=[]){const o=a("div",{className:"spot-table__container",parent:c}),n=a("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),t=a("thead",{parent:n}),r=a("tr",{parent:t});a("th",{text:"When you cancel",parent:r}),a("th",{text:"You will receive",parent:r});const p=a("tbody",{parent:n});e.forEach(({text:i,percent:u,amount:g})=>{const h=a("tr",{parent:p});a("td",{text:i,parent:h});const d=u==="Not eligible for refund"?"Not eligible for a refund":`$${g} refund`;a("td",{text:d,parent:h})})}function Q(c,e,o){const n=a("div",{className:"spot-selection__options",parent:c}),t=a("label",{className:`spot-selection__option ${e?"selected":""}`,parent:n}),r=a("input",{parent:t});r.type="radio",r.name="selection",r.value="yes",e&&(r.checked=!0),a("strong",{text:o.yesOptionText,parent:t}),a("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:t});const p=a("label",{className:"spot-selection__option",parent:n}),i=a("input",{parent:p});return i.type="radio",i.name="selection",i.value="no",a("span",{text:o.noOptionText,parent:p}),n}function S(c,e){var t;const o=(t=e.communication)==null?void 0:t.paymentTerms,n=a("div",{className:"spot-payment-terms",parent:c});return a("div",{className:"spot-payment-terms__header",text:"PAYMENT TERMS",parent:n}),a("div",{className:"spot-payment-terms__body",text:o,parent:n}),n}function H(c,e){const o=a("div",{className:"spot-footer__container",parent:c}),n=a("div",{className:"spot-footer__terms",parent:o});a("span",{innerHTML:e.communication.legalDisclaimer,parent:n}),a("br",{parent:n}),a("a",{href:e.communication.termsAndConditionsUrl,className:"spot-footer__terms-link",text:"Refund Guarantee Terms and Conditions",parent:n});const t=a("p",{className:"spot-footer__powered-by",parent:o});return t.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,4 +17,4 @@
17
17
  <rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
18
18
  </clipPath>
19
19
  </defs>
20
- </svg>`,o}const M=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--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-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-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-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:51rem;margin:1rem}.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}@media (min-width: 48rem){.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr 20.3125rem;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list{grid-row:1}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1}.desktop-layout .spot-selection__options{grid-row:3}.desktop-layout .spot-table__container{grid-row:1 / span 3}}@media (max-width: 52.438rem){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 47.938rem){.spot-selection__recommended-tag{margin-top:0rem}}@media (max-width: 32.125rem){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 47.9375rem){.spot-table__container{display:flex;justify-content:center}.spot-selection__recommended-tag{display:inline-block;margin-left:0}.spot-footer__container{flex-direction:column;margin-top:.5rem}.spot-refund__table{width:100%;table-layout:auto}.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:.5rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-covered-items__container{margin-top:0;margin-bottom:1rem}.spot-covered-items__title{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: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-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:1.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;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}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:block;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;gap:.5rem;flex:1 0 0;align-self:stretch}.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:1.5rem;white-space:nowrap}.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)}.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;justify-content:space-between;align-items:center}.spot-footer__powered-by{margin-top:1.5rem}";function R(p){const e=document.createElement("style");e.textContent=p,document.head.appendChild(e)}R(M);const D={sandbox:"https://api.sandbox.getspot.com/api/v1/quote",production:"https://api.getspot.com/api/v1/quote",local:"http://localhost:3999/api/v1/quote"};class L{constructor(e={}){this.options={location:"body",showTable:!0,optInSelected:!1,apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},...e},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 e,o,n,t,r;try{k(this.options);const{environment:c,partnerId:a}=this.options.apiConfig,h=this.options.apiConfig.customEndpoint||D[c],d=this.options.quoteRequestData.cartInfo&&this.options.quoteRequestData.items?await I(h,a,this.options.quoteRequestData):await w(h,a,this.options.quoteRequestData);if(d.status!=="QUOTE_AVAILABLE"){d.status==="NO_MATCHING_QUOTE"&&((e=this.options.callbacks)!=null&&e.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=d.data,this._renderWidget(),this.options.optInSelected&&((o=this.options.callbacks)!=null&&o.onOptIn)){const q={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};this.quote.originalQuotes&&this.quote.originalQuotes.length>0&&(q.batchQuoteDetails=this.quote.originalQuotes.map(s=>({quoteId:s.id,productPrice:s.spotPrice,cartItemId:s.cartItemId}))),this.options.callbacks.onOptIn(q)}(n=this.options.callbacks)!=null&&n.onQuoteRetrieved&&this.options.callbacks.onQuoteRetrieved(this.quote)}catch(c){(t=this.options.callbacks)!=null&&t.onError&&((r=this.options.callbacks)==null||r.onError({message:c.message,status:c.status,responseBody:c.responseBody}))}}_renderWidget(){this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([n,t])=>{const r=`--${n}`;this.container.style.setProperty(r,t)}),O(this.container,this.quote.communication);const e=document.createElement("div");e.className="spot-content__wrapper",this.container.appendChild(e),P(e,this.quote.communication.bulletPoints),this.quote.coveredItems&&$(e,this.quote.coveredItems),this.options.showTable&&Q(e,this.quote.payoutSchedule);const o=S(e,this.options.optInSelected,this.quote.communication);e.appendChild(o),this.paymentTermsEl=i("div",{className:"spot-payment-terms__wrapper",parent:e}),z(this.container,this.quote),window.addEventListener("resize",this._onResize),this._updateLayout(),this._setupOptionListeners(o)}_updateLayout(){const e=window.matchMedia("(min-width: 768px)").matches;this.container.querySelector(".spot-content__wrapper").classList.toggle("desktop-layout",e&&this.options.showTable)}_setupOptionListeners(e){const o=e.querySelectorAll('input[type="radio"]'),n=e.querySelectorAll(".spot-selection__option");o.forEach(t=>{t.addEventListener("change",r=>{var a,u,h;const c=r.target.value;if(this.hideSelectionError(),this.currentSelection=c,n.forEach(m=>m.classList.remove("selected")),(a=r.target.closest(".spot-selection__option"))==null||a.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),c==="yes"&&(this.options.quoteRequestData.isPartialPayment&&H(this.paymentTermsEl,this.quote),(u=this.options.callbacks)!=null&&u.onOptIn)){const m={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};this.quote.originalQuotes&&this.quote.originalQuotes.length>0&&(m.batchQuoteDetails=this.quote.originalQuotes.map(d=>({quoteId:d.id,productPrice:d.spotPrice,cartItemId:d.cartItemId}))),this.options.callbacks.onOptIn(m)}if(c==="no"&&((h=this.options.callbacks)!=null&&h.onOptOut)){const m={status:"QUOTE_DECLINED",quoteId:this.quote.id};this.quote.originalQuotes&&this.quote.originalQuotes.length>0&&(m.batchQuoteDetails=this.quote.originalQuotes.map(d=>({quoteId:d.id,productPrice:d.spotPrice,cartItemId:d.cartItemId}))),this.options.callbacks.onOptOut(m)}})})}showSelectionError(){var e;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const o=(e=this.container)==null?void 0:e.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 e=!!this.container.querySelector('input[name="selection"]:checked');return e?this.hideSelectionError():this.showSelectionError(),e}async updateQuote(e){var o,n,t;try{const r={...this.options,quoteRequestData:e};k(r);const{environment:c,partnerId:a,endpoint:u}=this.options.apiConfig,h=u||D[c],d=r.quoteRequestData.cartInfo&&r.quoteRequestData.items?await I(h,a,r.quoteRequestData):await w(h,a,r.quoteRequestData);return d.status!=="QUOTE_AVAILABLE"?(d.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:r.quoteRequestData}),!1):(this.options.quoteRequestData=r.quoteRequestData,this.quote=d.data,this.currentSelection=null,this.destroy(),this._renderWidget(),(n=this.options.callbacks)!=null&&n.onQuoteRetrieved&&this.options.callbacks.onQuoteRetrieved(this.quote),!0)}catch(r){return(t=this.options.callbacks)==null||t.onError({message:r.message,status:r.status,responseBody:r.responseBody}),!1}}getSelection(){var o,n,t;if(this.currentSelection==null)return null;const e={selection:this.currentSelection,quoteId:(o=this.quote)==null?void 0:o.id,spotPrice:(n=this.quote)==null?void 0:n.spotPrice,status:this.currentSelection==="yes"?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};return(t=this.quote)!=null&&t.originalQuotes&&this.quote.originalQuotes.length>0&&(e.batchQuoteDetails=this.quote.originalQuotes.map(r=>({quoteId:r.id,productPrice:r.spotPrice,cartItemId:r.cartItemId}))),e}destroy(){window.removeEventListener("resize",this._onResize),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}return L});
20
+ </svg>`,o}const z=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--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-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-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-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:51rem;margin:1rem}.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}@media (min-width: 48rem){.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr 20.3125rem;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list{grid-row:1}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1}.desktop-layout .spot-selection__options{grid-row:3}.desktop-layout .spot-table__container{grid-row:1 / span 3}}@media (max-width: 52.438rem){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 47.938rem){.spot-selection__recommended-tag{margin-top:0rem}}@media (max-width: 32.125rem){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 47.9375rem){.spot-table__container{display:flex;justify-content:center}.spot-selection__recommended-tag{display:inline-block;margin-left:0}.spot-footer__container{flex-direction:column;margin-top:.5rem}.spot-refund__table{width:100%;table-layout:auto}.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:.5rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-covered-items__container{margin-top:0;margin-bottom:1rem}.spot-covered-items__title{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: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-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:1.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;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}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:block;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;gap:.5rem;flex:1 0 0;align-self:stretch}.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:1.5rem;white-space:nowrap}.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)}.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;justify-content:space-between;align-items:center}.spot-footer__powered-by{margin-top:1.5rem}";function M(c){const e=document.createElement("style");e.textContent=c,document.head.appendChild(e)}M(z);const k={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 L{constructor(e={}){this.options={location:"body",showTable:!0,optInSelected:!1,apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},...e},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 e,o,n,t,r;try{D(this.options);const{environment:p,partnerId:i}=this.options.apiConfig,g=this.options.apiConfig.customEndpoint||k[p],d=this.options.quoteRequestData.cartInfo&&this.options.quoteRequestData.items?await I(g,i,this.options.quoteRequestData):await _(g,i,this.options.quoteRequestData);if(d.status!=="QUOTE_AVAILABLE"){d.status==="NO_MATCHING_QUOTE"&&((e=this.options.callbacks)!=null&&e.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=d.data,this._renderWidget(),this.options.optInSelected&&((o=this.options.callbacks)!=null&&o.onOptIn)){const b={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};this.quote.originalQuotes&&this.quote.originalQuotes.length>0&&(b.batchQuoteDetails=this.quote.originalQuotes.map(s=>{var f;const l=(f=this.options.quoteRequestData.items)==null?void 0:f.find(w=>(w.cartItemId||`item-${this.options.quoteRequestData.items.indexOf(w)+1}`)===s.cartItemId);return{quoteId:s.id,productPrice:(l==null?void 0:l.productPrice)||s.spotPrice,cartItemId:s.cartItemId}})),this.options.callbacks.onOptIn(b)}(n=this.options.callbacks)!=null&&n.onQuoteRetrieved&&this.options.callbacks.onQuoteRetrieved(this.quote)}catch(p){(t=this.options.callbacks)!=null&&t.onError&&((r=this.options.callbacks)==null||r.onError({message:p.message,status:p.status,responseBody:p.responseBody}))}}_renderWidget(){this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([n,t])=>{const r=`--${n}`;this.container.style.setProperty(r,t)}),O(this.container,this.quote.communication);const e=document.createElement("div");e.className="spot-content__wrapper",this.container.appendChild(e),P(e,this.quote.communication.bulletPoints),this.quote.coveredItems&&$(e,this.quote.coveredItems),this.options.showTable&&R(e,this.quote.payoutSchedule);const o=Q(e,this.options.optInSelected,this.quote.communication);e.appendChild(o),this.paymentTermsEl=a("div",{className:"spot-payment-terms__wrapper",parent:e}),H(this.container,this.quote),window.addEventListener("resize",this._onResize),this._updateLayout(),this._setupOptionListeners(o)}_updateLayout(){const e=window.matchMedia("(min-width: 768px)").matches;this.container.querySelector(".spot-content__wrapper").classList.toggle("desktop-layout",e&&this.options.showTable)}_setupOptionListeners(e){const o=e.querySelectorAll('input[type="radio"]'),n=e.querySelectorAll(".spot-selection__option");o.forEach(t=>{t.addEventListener("change",r=>{var i,u,g;const p=r.target.value;if(this.hideSelectionError(),this.currentSelection=p,n.forEach(h=>h.classList.remove("selected")),(i=r.target.closest(".spot-selection__option"))==null||i.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),p==="yes"&&(this.options.quoteRequestData.isPartialPayment&&S(this.paymentTermsEl,this.quote),(u=this.options.callbacks)!=null&&u.onOptIn)){const h={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};this.quote.originalQuotes&&this.quote.originalQuotes.length>0&&(h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var s;const b=(s=this.options.quoteRequestData.items)==null?void 0:s.find(l=>(l.cartItemId||`item-${this.options.quoteRequestData.items.indexOf(l)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(b==null?void 0:b.productPrice)||d.spotPrice,cartItemId:d.cartItemId}})),this.options.callbacks.onOptIn(h)}if(p==="no"&&((g=this.options.callbacks)!=null&&g.onOptOut)){const h={status:"QUOTE_DECLINED",quoteId:this.quote.id};this.quote.originalQuotes&&this.quote.originalQuotes.length>0&&(h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var s;const b=(s=this.options.quoteRequestData.items)==null?void 0:s.find(l=>(l.cartItemId||`item-${this.options.quoteRequestData.items.indexOf(l)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(b==null?void 0:b.productPrice)||d.spotPrice,cartItemId:d.cartItemId}})),this.options.callbacks.onOptOut(h)}})})}showSelectionError(){var e;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const o=(e=this.container)==null?void 0:e.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 e=!!this.container.querySelector('input[name="selection"]:checked');return e?this.hideSelectionError():this.showSelectionError(),e}async updateQuote(e){var o,n,t;try{const r={...this.options,quoteRequestData:e};D(r);const{environment:p,partnerId:i,endpoint:u}=this.options.apiConfig,g=u||k[p],d=r.quoteRequestData.cartInfo&&r.quoteRequestData.items?await I(g,i,r.quoteRequestData):await _(g,i,r.quoteRequestData);return d.status!=="QUOTE_AVAILABLE"?(d.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:r.quoteRequestData}),!1):(this.options.quoteRequestData=r.quoteRequestData,this.quote=d.data,this.currentSelection=null,this.destroy(),this._renderWidget(),(n=this.options.callbacks)!=null&&n.onQuoteRetrieved&&this.options.callbacks.onQuoteRetrieved(this.quote),!0)}catch(r){return(t=this.options.callbacks)==null||t.onError({message:r.message,status:r.status,responseBody:r.responseBody}),!1}}getSelection(){var o,n,t;if(this.currentSelection==null)return null;const e={selection:this.currentSelection,quoteId:(o=this.quote)==null?void 0:o.id,spotPrice:(n=this.quote)==null?void 0:n.spotPrice,status:this.currentSelection==="yes"?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};return(t=this.quote)!=null&&t.originalQuotes&&this.quote.originalQuotes.length>0&&(e.batchQuoteDetails=this.quote.originalQuotes.map(r=>{var i;const p=(i=this.options.quoteRequestData.items)==null?void 0:i.find(u=>(u.cartItemId||`item-${this.options.quoteRequestData.items.indexOf(u)+1}`)===r.cartItemId);return{quoteId:r.id,productPrice:(p==null?void 0:p.productPrice)||r.spotPrice,cartItemId:r.cartItemId}})),e}destroy(){window.removeEventListener("resize",this._onResize),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}return L});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getspot/spot-widget",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/index.js CHANGED
@@ -88,11 +88,16 @@ class SpotWidget {
88
88
 
89
89
  // For batch quotes, include detailed quote information
90
90
  if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
91
- optInData.batchQuoteDetails = this.quote.originalQuotes.map(q => ({
92
- quoteId: q.id,
93
- productPrice: q.spotPrice,
94
- cartItemId: q.cartItemId
95
- }));
91
+ optInData.batchQuoteDetails = this.quote.originalQuotes.map(q => {
92
+ const originalItem = this.options.quoteRequestData.items?.find(item =>
93
+ (item.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(item) + 1}`) === q.cartItemId
94
+ );
95
+ return {
96
+ quoteId: q.id,
97
+ productPrice: originalItem?.productPrice || q.spotPrice,
98
+ cartItemId: q.cartItemId
99
+ };
100
+ });
96
101
  }
97
102
 
98
103
  this.options.callbacks.onOptIn(optInData);
@@ -185,11 +190,16 @@ class SpotWidget {
185
190
 
186
191
  // For batch quotes, include detailed quote information
187
192
  if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
188
- optInData.batchQuoteDetails = this.quote.originalQuotes.map(q => ({
189
- quoteId: q.id,
190
- productPrice: q.spotPrice,
191
- cartItemId: q.cartItemId
192
- }));
193
+ optInData.batchQuoteDetails = this.quote.originalQuotes.map(q => {
194
+ const originalItem = this.options.quoteRequestData.items?.find(item =>
195
+ (item.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(item) + 1}`) === q.cartItemId
196
+ );
197
+ return {
198
+ quoteId: q.id,
199
+ productPrice: originalItem?.productPrice || q.spotPrice,
200
+ cartItemId: q.cartItemId
201
+ };
202
+ });
193
203
  }
194
204
 
195
205
  this.options.callbacks.onOptIn(optInData);
@@ -203,11 +213,16 @@ class SpotWidget {
203
213
 
204
214
  // For batch quotes, include detailed quote information
205
215
  if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
206
- optOutData.batchQuoteDetails = this.quote.originalQuotes.map(q => ({
207
- quoteId: q.id,
208
- productPrice: q.spotPrice,
209
- cartItemId: q.cartItemId
210
- }));
216
+ optOutData.batchQuoteDetails = this.quote.originalQuotes.map(q => {
217
+ const originalItem = this.options.quoteRequestData.items?.find(item =>
218
+ (item.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(item) + 1}`) === q.cartItemId
219
+ );
220
+ return {
221
+ quoteId: q.id,
222
+ productPrice: originalItem?.productPrice || q.spotPrice,
223
+ cartItemId: q.cartItemId
224
+ };
225
+ });
211
226
  }
212
227
 
213
228
  this.options.callbacks.onOptOut(optOutData);
@@ -325,11 +340,16 @@ class SpotWidget {
325
340
 
326
341
  // For batch quotes, include detailed quote information
327
342
  if (this.quote?.originalQuotes && this.quote.originalQuotes.length > 0) {
328
- selectionData.batchQuoteDetails = this.quote.originalQuotes.map(q => ({
329
- quoteId: q.id,
330
- productPrice: q.spotPrice,
331
- cartItemId: q.cartItemId
332
- }));
343
+ selectionData.batchQuoteDetails = this.quote.originalQuotes.map(q => {
344
+ const originalItem = this.options.quoteRequestData.items?.find(item =>
345
+ (item.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(item) + 1}`) === q.cartItemId
346
+ );
347
+ return {
348
+ quoteId: q.id,
349
+ productPrice: originalItem?.productPrice || q.spotPrice,
350
+ cartItemId: q.cartItemId
351
+ };
352
+ });
333
353
  }
334
354
 
335
355
  return selectionData;