@getspot/spot-widget 1.1.0 → 1.2.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.
package/dist/index.es.js CHANGED
@@ -1,45 +1,116 @@
1
- async function b(i, e, t) {
1
+ async function I(p, e, o) {
2
2
  try {
3
- const o = await fetch(i, {
3
+ const n = await fetch(p, {
4
4
  method: "POST",
5
5
  headers: {
6
6
  "Content-Type": "application/json",
7
7
  "X-Spot-Partner-Id": e
8
8
  },
9
- body: JSON.stringify(t)
10
- }), n = await o.json();
11
- if (!o.ok) {
12
- const r = new Error((n == null ? void 0 : n.message) || "Failed to fetch quote");
13
- throw r.status = o.status, r.responseBody = n, r;
9
+ body: JSON.stringify(o)
10
+ }), t = await n.json();
11
+ if (!n.ok) {
12
+ const r = new Error((t == null ? void 0 : t.message) || "Failed to fetch quote");
13
+ throw r.status = n.status, r.responseBody = t, r;
14
14
  }
15
- return n;
16
- } catch (o) {
17
- throw o instanceof Error ? o : new Error("Unknown error occurred while fetching quote");
15
+ return t;
16
+ } catch (n) {
17
+ throw n instanceof Error ? n : new Error("Unknown error occurred while fetching quote");
18
18
  }
19
19
  }
20
- const v = {
20
+ async function x(p, e, o) {
21
+ try {
22
+ const n = p.replace("/quote", "/quote/batch"), t = await fetch(n, {
23
+ method: "POST",
24
+ headers: {
25
+ "Content-Type": "application/json",
26
+ "X-Spot-Partner-Id": e
27
+ },
28
+ body: JSON.stringify(o)
29
+ }), r = await t.json();
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;
33
+ }
34
+ return r;
35
+ } catch (n) {
36
+ throw n instanceof Error ? n : new Error("Unknown error occurred while fetching batch quote");
37
+ }
38
+ }
39
+ async function k(p, e, o) {
40
+ try {
41
+ const n = {
42
+ cartId: o.cartInfo.cartId,
43
+ cartName: o.cartInfo.cartName,
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
56
+ }))
57
+ }, t = await x(p, e, n);
58
+ if (t.status !== "QUOTES_AVAILABLE" && t.status !== "QUOTE_AVAILABLE")
59
+ return { status: "NO_MATCHING_QUOTE" };
60
+ const r = t.quotes.map((a) => {
61
+ const u = o.items.find(
62
+ (h) => (h.cartItemId || `item-${o.items.indexOf(h) + 1}`) === a.cartItemId
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;
66
+ return {
67
+ status: "QUOTE_AVAILABLE",
68
+ data: {
69
+ id: t.quotes ? t.quotes.map((a) => a.id).join(",") : t.id,
70
+ spotPrice: c,
71
+ currencyCode: t.currencyCode,
72
+ communication: {
73
+ ...t.communication,
74
+ yesOptionText: t.communication.yesOptionText.replace(t.totalSpotPrice, c)
75
+ },
76
+ payoutSchedule: t.payoutSchedule.map((a) => ({
77
+ ...a,
78
+ amount: a.amount !== void 0 ? a.amount : 0
79
+ })),
80
+ coveredItems: r,
81
+ originalQuotes: t.quotes || [t]
82
+ },
83
+ spotPrice: c,
84
+ coveredItems: r
85
+ };
86
+ } catch (n) {
87
+ throw n instanceof Error ? n : new Error("Unknown error occurred while fetching multiple quotes");
88
+ }
89
+ }
90
+ const N = {
21
91
  sandbox: "https://api.sandbox.getspot.com/v1/quote",
22
- production: "https://api.getspot.com/v1/quote"
92
+ production: "https://api.getspot.com/v1/quote",
93
+ local: "http://localhost:3999/api/v1/quote"
23
94
  };
24
- function y(i) {
95
+ function D(p) {
25
96
  const {
26
97
  apiConfig: e = {},
27
- quoteRequestData: t,
28
- callbacks: o = {},
29
- location: n,
98
+ quoteRequestData: o,
99
+ callbacks: n = {},
100
+ location: t,
30
101
  theme: r
31
- } = i, {
32
- environment: a = "sandbox",
33
- partnerId: p,
34
- endpoint: c
102
+ } = p, {
103
+ environment: c = "sandbox",
104
+ partnerId: a,
105
+ endpoint: u
35
106
  } = e;
36
- if (!p || typeof p != "string")
107
+ if (!a || typeof a != "string")
37
108
  throw new Error("Invalid or missing partnerId in apiConfig");
38
- if (!(c || v[a]))
39
- throw new Error(`Invalid environment in apiConfig: ${a}`);
40
- if (!t || typeof t != "object")
41
- throw new Error("quoteRequestData must be a non-null object");
42
- [
109
+ if (!(u || N[c]))
110
+ throw new Error(`Invalid environment in apiConfig: ${c}`);
111
+ if (!o || typeof o != "object" && !Array.isArray(o))
112
+ throw new Error("quoteRequestData must be a non-null object or array");
113
+ const m = [
43
114
  "startDate",
44
115
  "endDate",
45
116
  "currencyCode",
@@ -50,166 +121,247 @@ function y(i) {
50
121
  "productId",
51
122
  "cartId",
52
123
  "productName"
53
- ].forEach((m) => {
54
- if (!Object.prototype.hasOwnProperty.call(t, m) || t[m] === void 0 || t[m] === null)
55
- throw new Error(`Missing required quoteRequestData field: '${m}'`);
56
- });
57
- const u = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
58
- if (!u.test(t.startDate))
59
- throw new Error("startDate must be a valid ISO8601 string");
60
- if (!u.test(t.endDate))
61
- throw new Error("endDate must be a valid ISO8601 string");
62
- if (typeof t.currencyCode != "string")
63
- throw new Error("currencyCode must be a string");
64
- if (!["USD", "CAD", "AUD"].includes(t.currencyCode))
65
- throw new Error(`Invalid currency code: ${t.currencyCode}`);
66
- if (typeof t.eventType != "string")
67
- throw new Error("eventType must be a string");
68
- if (typeof t.productType != "string")
69
- throw new Error("productType must be a string");
70
- const f = ["Pass", "Trip", "Registration"];
71
- if (!f.includes(t.productType))
72
- throw new Error(
73
- `productType must be one of ${f.join(", ")}`
74
- );
75
- if (typeof t.productDuration != "string")
76
- throw new Error("productDuration must be a string");
77
- const h = ["Daily", "Seasonal", "Trip", "Event"];
78
- if (!h.includes(t.productDuration))
79
- throw new Error(
80
- `productDuration must be one of ${h.join(", ")}`
81
- );
82
- if (typeof t.productPrice != "number" || isNaN(t.productPrice))
83
- throw new Error("productPrice must be a valid number");
84
- if (typeof t.productId != "string")
85
- throw new Error("productId must be a string");
86
- if (typeof t.cartId != "string")
87
- throw new Error("cartId must be a string");
88
- if (typeof t.productName != "string")
89
- throw new Error("productName must be a string");
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}'`);
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))
133
+ throw new Error(`${f}.startDate must be a valid ISO8601 string`);
134
+ if (!v.test(s.endDate))
135
+ throw new Error(`${f}.endDate must be a valid ISO8601 string`);
136
+ if (typeof s.currencyCode != "string")
137
+ throw new Error(`${f}.currencyCode must be a string`);
138
+ if (!["USD", "CAD", "AUD"].includes(s.currencyCode))
139
+ throw new Error(`Invalid ${f}.currencyCode: ${s.currencyCode}`);
140
+ if (typeof s.eventType != "string")
141
+ throw new Error(`${f}.eventType must be a string`);
142
+ if (typeof s.productType != "string")
143
+ throw new Error(`${f}.productType must be a string`);
144
+ const w = ["Pass", "Trip", "Registration"];
145
+ if (!w.includes(s.productType))
146
+ throw new Error(
147
+ `${f}.productType must be one of ${w.join(", ")}`
148
+ );
149
+ if (typeof s.productDuration != "string")
150
+ throw new Error(`${f}.productDuration must be a string`);
151
+ const g = ["Daily", "Seasonal", "Trip", "Event"];
152
+ if (!g.includes(s.productDuration))
153
+ throw new Error(
154
+ `${f}.productDuration must be one of ${g.join(", ")}`
155
+ );
156
+ if (typeof s.productPrice != "number" || isNaN(s.productPrice))
157
+ throw new Error(`${f}.productPrice must be a valid number`);
158
+ if (typeof s.productId != "string")
159
+ throw new Error(`${f}.productId must be a string`);
160
+ if (typeof s.cartId != "string")
161
+ throw new Error(`${f}.cartId must be a string`);
162
+ if (typeof s.productName != "string")
163
+ throw new Error(`${f}.productName must be a string`);
164
+ }
165
+ if (o.cartInfo && o.items) {
166
+ const { cartInfo: s, items: y } = o;
167
+ if (!s || typeof s != "object")
168
+ throw new Error("quoteRequestData.cartInfo must be a non-null object");
169
+ if (!s.cartId || typeof s.cartId != "string")
170
+ throw new Error("quoteRequestData.cartInfo.cartId must be a string");
171
+ if (!s.cartName || typeof s.cartName != "string")
172
+ throw new Error("quoteRequestData.cartInfo.cartName must be a string");
173
+ if (!s.currencyCode || typeof s.currencyCode != "string")
174
+ throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");
175
+ if (!["USD", "CAD", "AUD"].includes(s.currencyCode))
176
+ throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${s.currencyCode}`);
177
+ if (!Array.isArray(y) || y.length === 0)
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: '${_}'`);
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`);
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`);
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`);
211
+ });
212
+ } else if (Array.isArray(o)) {
213
+ if (o.length === 0)
214
+ throw new Error("quoteRequestData array cannot be empty");
215
+ o.forEach((s, y) => {
216
+ if (!s || typeof s != "object")
217
+ throw new Error(`quoteRequestData[${y}] must be a non-null object`);
218
+ d(s, y);
219
+ });
220
+ } else
221
+ d(o);
90
222
  if ([
91
223
  "onOptIn",
92
224
  "onOptOut",
93
225
  "onQuoteRetrieved",
94
226
  "onError",
95
227
  "noMatchingQuote"
96
- ].forEach((m) => {
97
- const g = o[m];
98
- if (g && typeof g != "function")
99
- throw new Error(`Callback '${m}' must be a function.`);
100
- }), typeof n == "string" && !document.querySelector(n))
101
- throw new Error(`Invalid location selector: '${n}'`);
228
+ ].forEach((s) => {
229
+ const y = n[s];
230
+ if (y && typeof y != "function")
231
+ throw new Error(`Callback '${s}' must be a function.`);
232
+ }), typeof t == "string" && !document.querySelector(t))
233
+ throw new Error(`Invalid location selector: '${t}'`);
102
234
  if (r && typeof r != "object")
103
235
  throw new Error(
104
236
  "Theme must be an object with CSS variables, do not include the '--' prefix"
105
237
  );
106
238
  }
107
- function s(i, { text: e, className: t, parent: o, innerHTML: n } = {}) {
108
- const r = document.createElement(i);
109
- return t && (r.className = t), e != null && (r.textContent = e), n != null && (r.innerHTML = n), o && o.appendChild(r), r;
239
+ function i(p, { text: e, className: o, parent: n, innerHTML: t } = {}) {
240
+ const r = document.createElement(p);
241
+ return o && (r.className = o), e != null && (r.textContent = e), t != null && (r.innerHTML = t), n && n.appendChild(r), r;
110
242
  }
111
- function w(i, { name: e, description: t }) {
112
- s("div", {
243
+ function O(p, { name: e, description: o }) {
244
+ i("div", {
113
245
  className: "spot-header__title",
114
246
  text: e,
115
- parent: i
116
- }), s("div", {
247
+ parent: p
248
+ }), i("div", {
117
249
  className: "spot-header__description",
118
- text: t,
119
- parent: i
250
+ text: o,
251
+ parent: p
120
252
  });
121
253
  }
122
- function C(i, e = []) {
123
- const t = s("ul", {
254
+ function P(p, e = []) {
255
+ const o = i("ul", {
124
256
  className: "spot-benefits__list",
125
- parent: i
257
+ parent: p
126
258
  });
127
- e.forEach((o) => {
128
- const n = s("li", { parent: t });
129
- n.innerHTML = `
259
+ e.forEach((n) => {
260
+ const t = i("li", { parent: o });
261
+ t.innerHTML = `
130
262
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
131
263
  <path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
132
264
  stroke="#2E2E2E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
133
- </svg>`, s("span", { text: o, parent: n });
265
+ </svg>`, i("span", { text: n, parent: t });
266
+ });
267
+ }
268
+ function $(p, e = []) {
269
+ if (e.length === 0) return;
270
+ const o = i("div", {
271
+ className: "spot-covered-items__container",
272
+ parent: p
273
+ });
274
+ i("div", {
275
+ className: "spot-covered-items__title",
276
+ text: "Items covered in your cart:",
277
+ parent: o
278
+ });
279
+ const n = i("ul", {
280
+ className: "spot-covered-items__list",
281
+ parent: o
282
+ });
283
+ e.forEach((t) => {
284
+ const r = i("li", { parent: n });
285
+ i("span", { text: t, parent: r });
134
286
  });
135
287
  }
136
- function E(i, e = []) {
137
- const t = s("div", {
288
+ function Q(p, e = []) {
289
+ const o = i("div", {
138
290
  className: "spot-table__container",
139
- parent: i
140
- }), o = s("table", {
291
+ parent: p
292
+ }), n = i("table", {
141
293
  className: "spot-refund__table spot-table--dynamic",
142
- parent: t
143
- }), n = s("thead", { parent: o }), r = s("tr", { parent: n });
144
- s("th", { text: "When you cancel", parent: r }), s("th", { text: "You will receive", parent: r });
145
- const a = s("tbody", { parent: o });
146
- e.forEach(({ text: p, percent: c, amount: l }) => {
147
- const d = s("tr", { parent: a });
148
- s("td", { text: p, parent: d });
149
- const u = c === "Not eligible for refund" ? "Not eligible for a refund" : `$${l} refund`;
150
- s("td", { text: u, parent: d });
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 });
151
303
  });
152
304
  }
153
- function k(i, e, t) {
154
- const o = s("div", {
305
+ function H(p, e, o) {
306
+ const n = i("div", {
155
307
  className: "spot-selection__options",
156
- parent: i
157
- }), n = s("label", {
158
- className: `spot-selection__option ${t ? "selected" : ""}`,
159
- parent: o
160
- }), r = s("input", { parent: n });
161
- r.type = "radio", r.name = "selection", r.value = "yes", t && (r.checked = !0), s("strong", {
162
- text: `Yes, protect my booking for $${e}`,
308
+ parent: p
309
+ }), t = i("label", {
310
+ className: `spot-selection__option ${e ? "selected" : ""}`,
163
311
  parent: n
164
- }), s("span", {
312
+ }), r = i("input", { parent: t });
313
+ r.type = "radio", r.name = "selection", r.value = "yes", e && (r.checked = !0), i("strong", {
314
+ text: o.yesOptionText,
315
+ parent: t
316
+ }), i("span", {
165
317
  className: "spot-selection__recommended-tag",
166
318
  text: "Recommended",
167
- parent: n
319
+ parent: t
168
320
  });
169
- const a = s("label", {
321
+ const c = i("label", {
170
322
  className: "spot-selection__option",
171
- parent: o
172
- }), p = s("input", { parent: a });
173
- return p.type = "radio", p.name = "selection", p.value = "no", s("span", { text: "No, do not protect my booking", parent: a }), o;
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;
174
326
  }
175
- function q(i, e) {
176
- var n;
177
- const t = (n = e.communication) == null ? void 0 : n.paymentTerms, o = s("div", {
327
+ function S(p, e) {
328
+ var t;
329
+ const o = (t = e.communication) == null ? void 0 : t.paymentTerms, n = i("div", {
178
330
  className: "spot-payment-terms",
179
- parent: i
331
+ parent: p
180
332
  });
181
- return s("div", {
333
+ return i("div", {
182
334
  className: "spot-payment-terms__header",
183
335
  text: "PAYMENT TERMS",
184
- parent: o
185
- }), s("div", {
336
+ parent: n
337
+ }), i("div", {
186
338
  className: "spot-payment-terms__body",
187
- text: t,
188
- parent: o
189
- }), o;
339
+ text: o,
340
+ parent: n
341
+ }), n;
190
342
  }
191
- function x(i, e) {
192
- const t = s("div", {
343
+ function z(p, e) {
344
+ const o = i("div", {
193
345
  className: "spot-footer__container",
194
- parent: i
195
- }), o = s("div", {
346
+ parent: p
347
+ }), n = i("div", {
196
348
  className: "spot-footer__terms",
197
- parent: t
349
+ parent: o
198
350
  });
199
- s("span", {
351
+ i("span", {
200
352
  innerHTML: e.communication.legalDisclaimer,
201
- parent: o
202
- }), s("br", { parent: o }), s("a", {
353
+ parent: n
354
+ }), i("br", { parent: n }), i("a", {
203
355
  href: e.communication.termsAndConditionsUrl,
204
356
  className: "spot-footer__terms-link",
205
357
  text: "Refund Guarantee Terms and Conditions",
206
- parent: o
358
+ parent: n
207
359
  });
208
- const n = s("p", {
360
+ const t = i("p", {
209
361
  className: "spot-footer__powered-by",
210
- parent: t
362
+ parent: o
211
363
  });
212
- return n.innerHTML = `
364
+ return t.innerHTML = `
213
365
  <svg width="145" height="28" viewBox="0 0 145 28" fill="none" xmlns="http://www.w3.org/2000/svg">
214
366
  <rect width="145" height="28"/>
215
367
  <rect x="-655" y="-270" width="819" height="325" rx="10"/>
@@ -224,19 +376,20 @@ function x(i, e) {
224
376
  <rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
225
377
  </clipPath>
226
378
  </defs>
227
- </svg>`, t;
379
+ </svg>`, o;
228
380
  }
229
- const T = ":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-selection__options{grid-row:2}.desktop-layout .spot-table__container{grid-row:1 / span 2}}@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-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}";
230
- function H(i) {
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) {
231
383
  const e = document.createElement("style");
232
- e.textContent = i, document.head.appendChild(e);
384
+ e.textContent = p, document.head.appendChild(e);
233
385
  }
234
- H(T);
235
- const _ = {
386
+ R(M);
387
+ const T = {
236
388
  sandbox: "https://api.sandbox.getspot.com/api/v1/quote",
237
- production: "https://api.getspot.com/api/v1/quote"
389
+ production: "https://api.getspot.com/api/v1/quote",
390
+ local: "http://localhost:3999/api/v1/quote"
238
391
  };
239
- class M {
392
+ class L {
240
393
  constructor(e = {}) {
241
394
  this.options = {
242
395
  location: "body",
@@ -249,14 +402,10 @@ class M {
249
402
  }, 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();
250
403
  }
251
404
  async _init() {
252
- var e, t, o, n, r;
405
+ var e, o, n, t, r;
253
406
  try {
254
- y(this.options);
255
- const { environment: a, partnerId: p } = this.options.apiConfig, l = this.options.apiConfig.customEndpoint || _[a], d = await b(
256
- l,
257
- p,
258
- this.options.quoteRequestData
259
- );
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);
260
409
  if (d.status !== "QUOTE_AVAILABLE") {
261
410
  d.status === "NO_MATCHING_QUOTE" && ((e = this.options.callbacks) != null && e.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
262
411
  status: "NO_MATCHING_QUOTE",
@@ -264,54 +413,77 @@ class M {
264
413
  });
265
414
  return;
266
415
  }
267
- this.quote = d.data, this._renderWidget(), this.options.optInSelected && ((t = this.options.callbacks) != null && t.onOptIn) && this.options.callbacks.onOptIn({
268
- status: "QUOTE_ACCEPTED",
269
- spotPrice: this.quote.spotPrice,
270
- quoteId: this.quote.id
271
- }), (o = this.options.callbacks) != null && o.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote);
272
- } catch (a) {
273
- (n = this.options.callbacks) != null && n.onError && ((r = this.options.callbacks) == null || r.onError({
274
- message: a.message,
275
- status: a.status,
276
- responseBody: a.responseBody
416
+ if (this.quote = d.data, this._renderWidget(), this.options.optInSelected && ((o = this.options.callbacks) != null && o.onOptIn)) {
417
+ const C = {
418
+ status: "QUOTE_ACCEPTED",
419
+ spotPrice: this.quote.spotPrice,
420
+ quoteId: this.quote.id
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);
427
+ }
428
+ (n = this.options.callbacks) != null && n.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote);
429
+ } catch (c) {
430
+ (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
277
434
  }));
278
435
  }
279
436
  }
280
437
  _renderWidget() {
281
- this.container = document.createElement("div"), this.container.className = "spot-refund-guarantee", this.root.appendChild(this.container), Object.entries(this.options.theme || {}).forEach(([o, n]) => {
282
- const r = `--${o}`;
283
- this.container.style.setProperty(r, n);
284
- }), w(this.container, this.quote.communication);
438
+ this.container = document.createElement("div"), this.container.className = "spot-refund-guarantee", this.root.appendChild(this.container), Object.entries(this.options.theme || {}).forEach(([n, t]) => {
439
+ const r = `--${n}`;
440
+ this.container.style.setProperty(r, t);
441
+ }), O(this.container, this.quote.communication);
285
442
  const e = document.createElement("div");
286
- e.className = "spot-content__wrapper", this.container.appendChild(e), C(e, this.quote.communication.bulletPoints), this.options.showTable && E(e, this.quote.payoutSchedule);
287
- const t = k(
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(
288
445
  e,
289
- this.quote.spotPrice,
290
- this.options.optInSelected
446
+ this.options.optInSelected,
447
+ this.quote.communication
291
448
  );
292
- e.appendChild(t), this.paymentTermsEl = s("div", {
449
+ e.appendChild(o), this.paymentTermsEl = i("div", {
293
450
  className: "spot-payment-terms__wrapper",
294
451
  parent: e
295
- }), x(this.container, this.quote), window.addEventListener("resize", this._onResize), this._updateLayout(), this._setupOptionListeners(t);
452
+ }), z(this.container, this.quote), window.addEventListener("resize", this._onResize), this._updateLayout(), this._setupOptionListeners(o);
296
453
  }
297
454
  _updateLayout() {
298
455
  const e = window.matchMedia("(min-width: 768px)").matches;
299
456
  this.container.querySelector(".spot-content__wrapper").classList.toggle("desktop-layout", e && this.options.showTable);
300
457
  }
301
458
  _setupOptionListeners(e) {
302
- const t = e.querySelectorAll('input[type="radio"]'), o = e.querySelectorAll(".spot-selection__option");
303
- t.forEach((n) => {
304
- n.addEventListener("change", (r) => {
305
- var p, c, l;
306
- const a = r.target.value;
307
- this.hideSelectionError(), this.currentSelection = a, o.forEach((d) => d.classList.remove("selected")), (p = r.target.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), a === "yes" && (this.options.quoteRequestData.isPartialPayment && q(this.paymentTermsEl, this.quote), (c = this.options.callbacks) != null && c.onOptIn && this.options.callbacks.onOptIn({
308
- status: "QUOTE_ACCEPTED",
309
- spotPrice: this.quote.spotPrice,
310
- quoteId: this.quote.id
311
- })), a === "no" && ((l = this.options.callbacks) != null && l.onOptOut) && this.options.callbacks.onOptOut({
312
- status: "QUOTE_DECLINED",
313
- quoteId: this.quote.id
314
- });
459
+ const o = e.querySelectorAll('input[type="radio"]'), n = e.querySelectorAll(".spot-selection__option");
460
+ o.forEach((t) => {
461
+ 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 = {
466
+ status: "QUOTE_ACCEPTED",
467
+ spotPrice: this.quote.spotPrice,
468
+ quoteId: this.quote.id
469
+ };
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);
475
+ }
476
+ if (c === "no" && ((h = this.options.callbacks) != null && h.onOptOut)) {
477
+ const m = {
478
+ status: "QUOTE_DECLINED",
479
+ quoteId: this.quote.id
480
+ };
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);
486
+ }
315
487
  });
316
488
  });
317
489
  }
@@ -319,10 +491,10 @@ class M {
319
491
  var e;
320
492
  if (!this.errorEl) {
321
493
  this.errorEl = document.createElement("div"), this.errorEl.className = "spot-selection__error", this.errorEl.textContent = "Please make a selection";
322
- const t = (e = this.container) == null ? void 0 : e.querySelector(
494
+ const o = (e = this.container) == null ? void 0 : e.querySelector(
323
495
  ".spot-selection__options"
324
496
  );
325
- t && t.insertAdjacentElement("afterend", this.errorEl);
497
+ o && o.insertAdjacentElement("afterend", this.errorEl);
326
498
  }
327
499
  this.errorEl.style.display = "block";
328
500
  }
@@ -337,31 +509,24 @@ class M {
337
509
  return e ? this.hideSelectionError() : this.showSelectionError(), e;
338
510
  }
339
511
  async updateQuote(e) {
340
- var t, o, n;
512
+ var o, n, t;
341
513
  try {
342
514
  const r = {
343
515
  ...this.options,
344
- quoteRequestData: {
345
- ...this.options.quoteRequestData,
346
- ...e
347
- }
516
+ quoteRequestData: e
348
517
  };
349
- y(r);
518
+ D(r);
350
519
  const {
351
- environment: a,
352
- partnerId: p,
353
- endpoint: c
354
- } = this.options.apiConfig, l = c || _[a], d = await b(
355
- l,
356
- p,
357
- r.quoteRequestData
358
- );
359
- return d.status !== "QUOTE_AVAILABLE" ? (d.status === "NO_MATCHING_QUOTE" && ((t = this.options.callbacks) != null && t.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
520
+ environment: c,
521
+ partnerId: a,
522
+ 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);
524
+ return d.status !== "QUOTE_AVAILABLE" ? (d.status === "NO_MATCHING_QUOTE" && ((o = this.options.callbacks) != null && o.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
360
525
  status: "NO_MATCHING_QUOTE",
361
526
  data: r.quoteRequestData
362
- }), !1) : (this.options.quoteRequestData = r.quoteRequestData, this.quote = d.data, this.currentSelection = null, this.destroy(), this._renderWidget(), (o = this.options.callbacks) != null && o.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote), !0);
527
+ }), !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);
363
528
  } catch (r) {
364
- return (n = this.options.callbacks) == null || n.onError({
529
+ return (t = this.options.callbacks) == null || t.onError({
365
530
  message: r.message,
366
531
  status: r.status,
367
532
  responseBody: r.responseBody
@@ -369,18 +534,24 @@ class M {
369
534
  }
370
535
  }
371
536
  getSelection() {
372
- var e, t;
373
- return this.currentSelection == null ? null : {
537
+ var o, n, t;
538
+ if (this.currentSelection == null) return null;
539
+ const e = {
374
540
  selection: this.currentSelection,
375
- quoteId: (e = this.quote) == null ? void 0 : e.id,
376
- spotPrice: (t = this.quote) == null ? void 0 : t.spotPrice,
541
+ quoteId: (o = this.quote) == null ? void 0 : o.id,
542
+ spotPrice: (n = this.quote) == null ? void 0 : n.spotPrice,
377
543
  status: this.currentSelection === "yes" ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED"
378
544
  };
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;
379
550
  }
380
551
  destroy() {
381
552
  window.removeEventListener("resize", this._onResize), this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container);
382
553
  }
383
554
  }
384
555
  export {
385
- M as default
556
+ L as default
386
557
  };