@getspot/spot-widget 4.3.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.3.1](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@4.3.0...@getspot/spot-widget@4.3.1) (2026-06-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **core:** preserve user selection across updateQuote re-renders ([a232974](https://gitlab.com/getspot/spot-widget/commit/a23297487d0a42eb9505d256809bde1943a91001))
7
+
1
8
  # [4.3.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@4.2.0...@getspot/spot-widget@4.3.0) (2026-06-22)
2
9
 
3
10
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAkBpB,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,SAAS,CAAC,CAAc;IAChC,OAAO,CAAC,cAAc,CAAC,CAAc;IACrC,OAAO,CAAC,OAAO,CAAC,CAAc;IAC9B,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,cAAc,CAAC,CAAoB;IAC3C,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,eAAe,CAAC,CAAiB;gBAE7B,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM;YAuBtC,KAAK;IAoGnB,OAAO,CAAC,aAAa;IAwErB,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,uBAAuB;IAqC/B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,cAAc,CAAC,CAAS;IAEhC,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,2BAA2B;IAUnC,OAAO,CAAC,qBAAqB;IA6F7B,kBAAkB,IAAI,IAAI;IAgB1B,kBAAkB,IAAI,IAAI;IAM1B,iBAAiB,IAAI,OAAO;IAgBtB,WAAW,CACf,mBAAmB,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,GACzD,OAAO,CAAC,OAAO,CAAC;IAuEnB,YAAY,IAAI,aAAa,GAAG,IAAI;IAgCpC,OAAO,IAAI,IAAI;CAahB;AAED,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,KAAK,GACN,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EAKnB,MAAM,YAAY,CAAC;AAkBpB,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,SAAS,CAAC,CAAc;IAChC,OAAO,CAAC,cAAc,CAAC,CAAc;IACrC,OAAO,CAAC,OAAO,CAAC,CAAc;IAC9B,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,cAAc,CAAC,CAAoB;IAC3C,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,eAAe,CAAC,CAAiB;gBAE7B,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM;YAuBtC,KAAK;IAoGnB,OAAO,CAAC,aAAa;IAwErB,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,uBAAuB;IAqC/B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,cAAc,CAAC,CAAS;IAEhC,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,2BAA2B;IAUnC,OAAO,CAAC,qBAAqB;IA6F7B,kBAAkB,IAAI,IAAI;IAgB1B,kBAAkB,IAAI,IAAI;IAM1B,iBAAiB,IAAI,OAAO;IAgBtB,WAAW,CACf,mBAAmB,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,GACzD,OAAO,CAAC,OAAO,CAAC;IAsEnB,YAAY,IAAI,aAAa,GAAG,IAAI;IAgCpC,OAAO,IAAI,IAAI;CAahB;AAED,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,KAAK,GACN,MAAM,YAAY,CAAC"}
package/dist/index.es.js CHANGED
@@ -84,7 +84,7 @@ async function S(c, t, r, s) {
84
84
  throw a instanceof Error ? a : new Error("Unknown error occurred while fetching multiple quotes");
85
85
  }
86
86
  }
87
- const q = "non-us-resident", A = [
87
+ const E = "non-us-resident", L = [
88
88
  { value: "AL", label: "Alabama" },
89
89
  { value: "AK", label: "Alaska" },
90
90
  { value: "AS", label: "American Samoa" },
@@ -141,7 +141,7 @@ const q = "non-us-resident", A = [
141
141
  { value: "WV", label: "West Virginia" },
142
142
  { value: "WI", label: "Wisconsin" },
143
143
  { value: "WY", label: "Wyoming" }
144
- ], O = new Set(A.map((c) => c.value)), I = [
144
+ ], O = new Set(L.map((c) => c.value)), I = [
145
145
  "USD",
146
146
  "CAD",
147
147
  "AUD",
@@ -206,10 +206,10 @@ function M(c) {
206
206
  if (!Object.prototype.hasOwnProperty.call(p, g) || p[g] === void 0 || p[g] === null)
207
207
  throw new Error(`Missing required ${d} field: '${g}'`);
208
208
  });
209
- const w = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
210
- if (!w.test(p.startDate))
209
+ const b = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
210
+ if (!b.test(p.startDate))
211
211
  throw new Error(`${d}.startDate must be a valid ISO8601 string`);
212
- if (!w.test(p.endDate))
212
+ if (!b.test(p.endDate))
213
213
  throw new Error(`${d}.endDate must be a valid ISO8601 string`);
214
214
  if (typeof p.currencyCode != "string")
215
215
  throw new Error(`${d}.currencyCode must be a string`);
@@ -241,15 +241,15 @@ function M(c) {
241
241
  throw new Error(`${d}.productName must be a string`);
242
242
  }
243
243
  if ("items" in r) {
244
- const p = r, { cartId: u, cartName: d, currencyCode: w, items: y } = p;
244
+ const p = r, { cartId: u, cartName: d, currencyCode: b, items: y } = p;
245
245
  if (!u || typeof u != "string")
246
246
  throw new Error("quoteRequestData.cartId must be a string");
247
247
  if (!d || typeof d != "string")
248
248
  throw new Error("quoteRequestData.cartName must be a string");
249
- if (!w || typeof w != "string")
249
+ if (!b || typeof b != "string")
250
250
  throw new Error("quoteRequestData.currencyCode must be a string");
251
- if (!I.includes(w))
252
- throw new Error(`Invalid quoteRequestData.currencyCode: ${w}`);
251
+ if (!I.includes(b))
252
+ throw new Error(`Invalid quoteRequestData.currencyCode: ${b}`);
253
253
  if (!Array.isArray(y) || y.length === 0)
254
254
  throw new Error("quoteRequestData.items must be a non-empty array");
255
255
  const C = [
@@ -266,9 +266,9 @@ function M(c) {
266
266
  if (!g || typeof g != "object")
267
267
  throw new Error(`quoteRequestData.items[${k}] must be a non-null object`);
268
268
  const _ = `quoteRequestData.items[${k}]`;
269
- C.forEach((E) => {
270
- if (!Object.prototype.hasOwnProperty.call(g, E) || g[E] === void 0 || g[E] === null)
271
- throw new Error(`Missing required ${_} field: '${E}'`);
269
+ C.forEach((q) => {
270
+ if (!Object.prototype.hasOwnProperty.call(g, q) || g[q] === void 0 || g[q] === null)
271
+ throw new Error(`Missing required ${_} field: '${q}'`);
272
272
  });
273
273
  const x = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
274
274
  if (!x.test(g.startDate))
@@ -323,7 +323,7 @@ function M(c) {
323
323
  if (c.state && !O.has(c.state))
324
324
  throw new Error(`Invalid state: '${c.state}'. Must be a 2-character US state or territory code.`);
325
325
  }
326
- var b = /* @__PURE__ */ ((c) => (c.YES = "yes", c.NO = "no", c.UNSELECTED = "unselected", c))(b || {});
326
+ var w = /* @__PURE__ */ ((c) => (c.YES = "yes", c.NO = "no", c.UNSELECTED = "unselected", c))(w || {});
327
327
  function n(c, { text: t, className: r, parent: s, innerHTML: i, href: a, target: e } = {}) {
328
328
  const o = document.createElement(c);
329
329
  return r && (o.className = r), t != null && (o.textContent = t), i != null && (o.innerHTML = i), a && "href" in o && (o.href = a), e && "target" in o && (o.target = e), s && s.appendChild(o), o;
@@ -419,7 +419,7 @@ function Q(c, t = [], r) {
419
419
  displayText: d > 1 ? `${d} x ${u}` : u
420
420
  })
421
421
  ).sort((u, d) => {
422
- const w = u.item.charAt(0), y = d.item.charAt(0), C = /[a-zA-Z]/.test(w), g = /[a-zA-Z]/.test(y);
422
+ const b = u.item.charAt(0), y = d.item.charAt(0), C = /[a-zA-Z]/.test(b), g = /[a-zA-Z]/.test(y);
423
423
  return !C && g ? -1 : C && !g ? 1 : u.item.localeCompare(d.item, void 0, { sensitivity: "base" });
424
424
  }), e = n("div", {
425
425
  className: "spot-covered-items__container",
@@ -526,7 +526,7 @@ function B(c, t) {
526
526
  text: "Select a state...",
527
527
  parent: s
528
528
  });
529
- i.value = "", i.selected = !t, A.forEach(({ value: e, label: o }) => {
529
+ i.value = "", i.selected = !t, L.forEach(({ value: e, label: o }) => {
530
530
  const l = n("option", { text: o, parent: s });
531
531
  l.value = e, e === t && (l.selected = !0);
532
532
  });
@@ -534,17 +534,17 @@ function B(c, t) {
534
534
  text: "Not a US Resident",
535
535
  parent: s
536
536
  });
537
- return a.value = q, t === q && (a.selected = !0), s;
537
+ return a.value = E, t === E && (a.selected = !0), s;
538
538
  }
539
539
  function j(c, t, r, s = !1) {
540
540
  const i = n("div", {
541
541
  className: `spot-selection__options${s ? " spot-selection__options--disabled" : ""}`,
542
542
  parent: c
543
543
  }), a = n("label", {
544
- className: `spot-selection__option ${t === b.YES ? "selected" : ""}`,
544
+ className: `spot-selection__option ${t === w.YES ? "selected" : ""}`,
545
545
  parent: i
546
546
  }), e = n("input", { parent: a });
547
- e.type = "radio", e.name = "selection", e.value = b.YES, t === b.YES && (e.checked = !0), s && (e.disabled = !0), n("strong", {
547
+ e.type = "radio", e.name = "selection", e.value = w.YES, t === w.YES && (e.checked = !0), s && (e.disabled = !0), n("strong", {
548
548
  text: r.yesOptionText,
549
549
  parent: a
550
550
  }), n("span", {
@@ -553,10 +553,10 @@ function j(c, t, r, s = !1) {
553
553
  parent: a
554
554
  });
555
555
  const o = n("label", {
556
- className: `spot-selection__option ${t === b.NO ? "selected" : ""}`,
556
+ className: `spot-selection__option ${t === w.NO ? "selected" : ""}`,
557
557
  parent: i
558
558
  }), l = n("input", { parent: o });
559
- return l.type = "radio", l.name = "selection", l.value = b.NO, t === b.NO && (l.checked = !0), s && (l.disabled = !0), n("span", { text: r.noOptionText, parent: o }), i;
559
+ return l.type = "radio", l.name = "selection", l.value = w.NO, t === w.NO && (l.checked = !0), s && (l.disabled = !0), n("span", { text: r.noOptionText, parent: o }), i;
560
560
  }
561
561
  function H(c, t) {
562
562
  var s;
@@ -643,7 +643,7 @@ function Y(c) {
643
643
  t.textContent = c, document.head.appendChild(t);
644
644
  }
645
645
  Y(W);
646
- const L = {
646
+ const A = {
647
647
  sandbox: "https://api.sandbox.getspot.com/api/v1/quote",
648
648
  production: "https://api.getspot.com/api/v1/quote",
649
649
  local: "http://localhost:3999/api/v1/quote"
@@ -659,7 +659,7 @@ class G {
659
659
  callbacks: {},
660
660
  useMockData: !1,
661
661
  ...t,
662
- selection: t.selection ?? b.UNSELECTED
662
+ selection: t.selection ?? w.UNSELECTED
663
663
  }, this._onResize = this._updateLayout.bind(this), this.root = typeof this.options.location == "string" ? document.querySelector(this.options.location) : this.options.location, this.currentSelection = this.options.selection, this._init();
664
664
  }
665
665
  async _init() {
@@ -670,7 +670,7 @@ class G {
670
670
  if (this.options.useMockData && this.options.mockData)
671
671
  e = this.options.mockData;
672
672
  else {
673
- const { environment: o, partnerId: l } = this.options.apiConfig, f = this.options.apiConfig.customEndpoint || L[o];
673
+ const { environment: o, partnerId: l } = this.options.apiConfig, f = this.options.apiConfig.customEndpoint || A[o];
674
674
  e = "items" in this.options.quoteRequestData ? await S(
675
675
  f,
676
676
  l,
@@ -692,7 +692,7 @@ class G {
692
692
  }
693
693
  if (this.quote = e.data, !this.quote)
694
694
  throw new Error("No quote data in response");
695
- if (this._renderWidget(), this.options.selection === b.YES && ((r = this.options.callbacks) != null && r.onOptIn)) {
695
+ if (this._renderWidget(), this.options.selection === w.YES && ((r = this.options.callbacks) != null && r.onOptIn)) {
696
696
  const o = {
697
697
  status: "QUOTE_ACCEPTED",
698
698
  spotPrice: this.quote.spotPrice,
@@ -749,14 +749,14 @@ class G {
749
749
  this._isPassOrTrip() && !this.options.state && (this._stateSelectEl = B(r, this.currentState));
750
750
  const i = !this._isQuotingAvailable(), a = j(
751
751
  r,
752
- this.options.selection,
752
+ this.currentSelection,
753
753
  this.quote.communication,
754
754
  i
755
755
  );
756
756
  this.paymentTermsEl = n("div", {
757
757
  className: "spot-payment-terms__wrapper",
758
758
  parent: t
759
- }), this.currentSelection === b.YES && H(this.paymentTermsEl, this.quote), F(this.container, this.quote, this.options.logoPosition), window.addEventListener("resize", this._onResize), this._setupResizeObserver(), this._updateLayout(), this._setupOptionListeners(a), this._setupStateDropdownListener();
759
+ }), this.currentSelection === w.YES && H(this.paymentTermsEl, this.quote), F(this.container, this.quote, this.options.logoPosition), window.addEventListener("resize", this._onResize), this._setupResizeObserver(), this._updateLayout(), this._setupOptionListeners(a), this._setupStateDropdownListener();
760
760
  }
761
761
  _updateLayout() {
762
762
  if (!this.container || !this.quote) return;
@@ -815,11 +815,11 @@ class G {
815
815
  return r.productType === "Pass" || r.productType === "Trip";
816
816
  }
817
817
  _validState() {
818
- if (this._isPassOrTrip() && !(!this.currentState || this.currentState === q))
818
+ if (this._isPassOrTrip() && !(!this.currentState || this.currentState === E))
819
819
  return this.currentState;
820
820
  }
821
821
  _isQuotingAvailable() {
822
- return !this._isPassOrTrip() || this.options.state ? !0 : !!this.currentState && this.currentState !== q;
822
+ return !this._isPassOrTrip() || this.options.state ? !0 : !!this.currentState && this.currentState !== E;
823
823
  }
824
824
  _setRadiosDisabled(t) {
825
825
  var i, a, e;
@@ -830,7 +830,7 @@ class G {
830
830
  o.checked = !1;
831
831
  }), (e = this.container) == null || e.querySelectorAll(".spot-selection__option").forEach((o) => {
832
832
  o.classList.remove("selected");
833
- }), this.currentSelection = b.UNSELECTED, this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""));
833
+ }), this.currentSelection = w.UNSELECTED, this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""));
834
834
  }
835
835
  _setupStateDropdownListener() {
836
836
  this._stateSelectEl && this._stateSelectEl.addEventListener("change", () => {
@@ -845,7 +845,7 @@ class G {
845
845
  i.addEventListener("change", (a) => {
846
846
  var l, m, f, v;
847
847
  const e = a.target, o = e.value;
848
- if (this.hideSelectionError(), this.currentSelection = o, s.forEach((h) => h.classList.remove("selected")), (l = e.closest(".spot-selection__option")) == null || l.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), o === b.YES && ((m = this.quote) != null && m.communication.paymentTerms && H(this.paymentTermsEl, this.quote), (f = this.options.callbacks) != null && f.onOptIn)) {
848
+ if (this.hideSelectionError(), this.currentSelection = o, s.forEach((h) => h.classList.remove("selected")), (l = e.closest(".spot-selection__option")) == null || l.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), o === w.YES && ((m = this.quote) != null && m.communication.paymentTerms && H(this.paymentTermsEl, this.quote), (f = this.options.callbacks) != null && f.onOptIn)) {
849
849
  const h = {
850
850
  status: "QUOTE_ACCEPTED",
851
851
  spotPrice: this.quote.spotPrice,
@@ -856,8 +856,8 @@ class G {
856
856
  const p = this.options.quoteRequestData;
857
857
  h.batchQuoteDetails = this.quote.originalQuotes.map(
858
858
  (u) => {
859
- var w;
860
- const d = (w = p.items) == null ? void 0 : w.find(
859
+ var b;
860
+ const d = (b = p.items) == null ? void 0 : b.find(
861
861
  (y) => (y.cartItemId || `item-${p.items.indexOf(y) + 1}`) === u.cartItemId
862
862
  );
863
863
  return {
@@ -870,7 +870,7 @@ class G {
870
870
  }
871
871
  this.options.callbacks.onOptIn(h);
872
872
  }
873
- if (o === b.NO && ((v = this.options.callbacks) != null && v.onOptOut)) {
873
+ if (o === w.NO && ((v = this.options.callbacks) != null && v.onOptOut)) {
874
874
  const h = {
875
875
  status: "QUOTE_DECLINED",
876
876
  quoteId: this.quote.id,
@@ -880,8 +880,8 @@ class G {
880
880
  const p = this.options.quoteRequestData;
881
881
  h.batchQuoteDetails = this.quote.originalQuotes.map(
882
882
  (u) => {
883
- var w;
884
- const d = (w = p.items) == null ? void 0 : w.find(
883
+ var b;
884
+ const d = (b = p.items) == null ? void 0 : b.find(
885
885
  (y) => (y.cartItemId || `item-${p.items.indexOf(y) + 1}`) === u.cartItemId
886
886
  );
887
887
  return {
@@ -926,7 +926,7 @@ class G {
926
926
  quoteRequestData: t
927
927
  };
928
928
  M(e);
929
- const { environment: o, partnerId: l, customEndpoint: m } = this.options.apiConfig, f = m || L[o], h = "items" in e.quoteRequestData ? await S(
929
+ const { environment: o, partnerId: l, customEndpoint: m } = this.options.apiConfig, f = m || A[o], h = "items" in e.quoteRequestData ? await S(
930
930
  f,
931
931
  l,
932
932
  e.quoteRequestData,
@@ -942,7 +942,7 @@ class G {
942
942
  status: "NO_MATCHING_QUOTE",
943
943
  data: e.quoteRequestData
944
944
  }), !1;
945
- if (this.options.quoteRequestData = e.quoteRequestData, this.quote = h.data, this.currentSelection = b.UNSELECTED, this.destroy(), this._renderWidget(), (s = this.options.callbacks) != null && s.onQuoteRetrieved) {
945
+ if (this.options.quoteRequestData = e.quoteRequestData, this.quote = h.data, this.destroy(), this._renderWidget(), (s = this.options.callbacks) != null && s.onQuoteRetrieved) {
946
946
  const p = this.options.callbacks.onQuoteRetrieved(this.quote);
947
947
  p && this._applyQuoteUpdates(p);
948
948
  }
@@ -958,12 +958,12 @@ class G {
958
958
  }
959
959
  getSelection() {
960
960
  var r, s, i;
961
- if (this.currentSelection == null || this.currentSelection == b.UNSELECTED) return null;
961
+ if (this.currentSelection == null || this.currentSelection == w.UNSELECTED) return null;
962
962
  const t = {
963
963
  selection: this.currentSelection,
964
964
  quoteId: (r = this.quote) == null ? void 0 : r.id,
965
965
  spotPrice: (s = this.quote) == null ? void 0 : s.spotPrice,
966
- status: this.currentSelection === b.YES ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED",
966
+ status: this.currentSelection === w.YES ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED",
967
967
  state: this.currentState
968
968
  };
969
969
  if ((i = this.quote) != null && i.originalQuotes && this.quote.originalQuotes.length > 0) {
@@ -987,7 +987,7 @@ class G {
987
987
  }
988
988
  }
989
989
  export {
990
- q as NON_US_RESIDENT_VALUE,
991
- b as SelectionEnum,
990
+ E as NON_US_RESIDENT_VALUE,
991
+ w as SelectionEnum,
992
992
  G as default
993
993
  };
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(C,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(C=typeof globalThis<"u"?globalThis:C||self,q(C.SpotWidget={}))})(this,function(C){"use strict";async function q(c,t,r,s){try{const i=s?{...r,state:s}:r,a=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(i)}),e=await a.json();if(!a.ok){const o=new Error((e==null?void 0:e.message)||"Failed to fetch quote");throw o.status=a.status,o.responseBody=e,o}return e}catch(i){throw i instanceof Error?i:new Error("Unknown error occurred while fetching quote")}}async function R(c,t,r){try{const s=c.replace("/quote","/quote/batch"),i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(r)}),a=await i.json();if(!i.ok){const e=new Error((a==null?void 0:a.message)||"Failed to fetch batch quote");throw e.status=i.status,e.responseBody=a,e}return a}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function D(c,t,r,s){var i;try{const a={...r,...s?{state:s}:{},isPartialPayment:r.isPartialPayment||!1,roundTo:r.roundTo||void 0,items:r.items.map((m,f)=>({...m,cartItemId:m.cartItemId||`item-${f+1}`}))},e=await R(c,t,a);if(e.status!=="QUOTES_AVAILABLE"&&e.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const o=e.quotes.map(m=>{const f=r.items.find((v,h)=>(v.cartItemId||`item-${h+1}`)===m.cartItemId);return f?f.participantDescription?`${f.productName} - ${f.participantDescription}`:f.productName:`Item ${m.id}`}),l=Math.round((e.totalSpotPrice||e.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:e.quotes?e.quotes.map(m=>m.id).join(","):((i=e.data)==null?void 0:i.id)||"",spotPrice:l,currencyCode:e.currencyCode||"",communication:{...e.communication,yesOptionText:e.communication.yesOptionText.replace(String(e.totalSpotPrice),String(l))},payoutSchedule:e.payoutSchedule.map(m=>({...m,amount:m.amount!==void 0?m.amount:0})),coveredItems:o,originalQuotes:e.quotes||(e.data?[e.data]:[])},spotPrice:l,coveredItems:o}}catch(a){throw a instanceof Error?a:new Error("Unknown error occurred while fetching multiple quotes")}}const k="non-us-resident",T=[{value:"AL",label:"Alabama"},{value:"AK",label:"Alaska"},{value:"AS",label:"American Samoa"},{value:"AZ",label:"Arizona"},{value:"AR",label:"Arkansas"},{value:"CA",label:"California"},{value:"CO",label:"Colorado"},{value:"CT",label:"Connecticut"},{value:"DE",label:"Delaware"},{value:"DC",label:"District of Columbia"},{value:"FL",label:"Florida"},{value:"GA",label:"Georgia"},{value:"GU",label:"Guam"},{value:"HI",label:"Hawaii"},{value:"ID",label:"Idaho"},{value:"IL",label:"Illinois"},{value:"IN",label:"Indiana"},{value:"IA",label:"Iowa"},{value:"KS",label:"Kansas"},{value:"KY",label:"Kentucky"},{value:"LA",label:"Louisiana"},{value:"ME",label:"Maine"},{value:"MD",label:"Maryland"},{value:"MA",label:"Massachusetts"},{value:"MI",label:"Michigan"},{value:"MN",label:"Minnesota"},{value:"MS",label:"Mississippi"},{value:"MO",label:"Missouri"},{value:"MT",label:"Montana"},{value:"NE",label:"Nebraska"},{value:"NV",label:"Nevada"},{value:"NH",label:"New Hampshire"},{value:"NJ",label:"New Jersey"},{value:"NM",label:"New Mexico"},{value:"NY",label:"New York"},{value:"NC",label:"North Carolina"},{value:"ND",label:"North Dakota"},{value:"MP",label:"Northern Mariana Islands"},{value:"OH",label:"Ohio"},{value:"OK",label:"Oklahoma"},{value:"OR",label:"Oregon"},{value:"PA",label:"Pennsylvania"},{value:"PR",label:"Puerto Rico"},{value:"RI",label:"Rhode Island"},{value:"SC",label:"South Carolina"},{value:"SD",label:"South Dakota"},{value:"TN",label:"Tennessee"},{value:"TX",label:"Texas"},{value:"VI",label:"U.S. Virgin Islands"},{value:"UT",label:"Utah"},{value:"VT",label:"Vermont"},{value:"VA",label:"Virginia"},{value:"WA",label:"Washington"},{value:"WV",label:"West Virginia"},{value:"WI",label:"Wisconsin"},{value:"WY",label:"Wyoming"}],z=new Set(T.map(c=>c.value)),S=["USD","CAD","AUD","NZD","EUR","MXN","AED","GBP","MAD","SAR","BGN","BRL","CHF","DKK","INR","JPY","MYR","NOK","PLN","SEK","SGD","THB","ZAR"],P={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function N(c){const{apiConfig:t={},quoteRequestData:r,callbacks:s={},location:i,theme:a}=c,{environment:e="sandbox",partnerId:o,customEndpoint:l}=t;if(!o||typeof o!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(l||P[e]))throw new Error(`Invalid environment in apiConfig: ${e}`);if(!r||typeof r!="object"&&!Array.isArray(r))throw new Error("quoteRequestData must be a non-null object or array");const f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function v(p,u=null){const d=u!==null?`quoteRequestData[${u}]`:"quoteRequestData";f.forEach(g=>{if(!Object.prototype.hasOwnProperty.call(p,g)||p[g]===void 0||p[g]===null)throw new Error(`Missing required ${d} field: '${g}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(p.startDate))throw new Error(`${d}.startDate must be a valid ISO8601 string`);if(!w.test(p.endDate))throw new Error(`${d}.endDate must be a valid ISO8601 string`);if(typeof p.currencyCode!="string")throw new Error(`${d}.currencyCode must be a string`);if(!S.includes(p.currencyCode))throw new Error(`Invalid ${d}.currencyCode: ${p.currencyCode}`);if(typeof p.eventType!="string")throw new Error(`${d}.eventType must be a string`);if(typeof p.productType!="string")throw new Error(`${d}.productType must be a string`);const y=["Pass","Trip","Registration"];if(!y.includes(p.productType))throw new Error(`${d}.productType must be one of ${y.join(", ")}`);if(typeof p.productDuration!="string")throw new Error(`${d}.productDuration must be a string`);const E=["Daily","Seasonal","Trip","Event"];if(!E.includes(p.productDuration))throw new Error(`${d}.productDuration must be one of ${E.join(", ")}`);if(typeof p.productPrice!="number"||isNaN(p.productPrice))throw new Error(`${d}.productPrice must be a valid number`);if(typeof p.productId!="string")throw new Error(`${d}.productId must be a string`);if(typeof p.cartId!="string")throw new Error(`${d}.cartId must be a string`);if(typeof p.productName!="string")throw new Error(`${d}.productName must be a string`)}if("items"in r){const p=r,{cartId:u,cartName:d,currencyCode:w,items:y}=p;if(!u||typeof u!="string")throw new Error("quoteRequestData.cartId must be a string");if(!d||typeof d!="string")throw new Error("quoteRequestData.cartName must be a string");if(!w||typeof w!="string")throw new Error("quoteRequestData.currencyCode must be a string");if(!S.includes(w))throw new Error(`Invalid quoteRequestData.currencyCode: ${w}`);if(!Array.isArray(y)||y.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const E=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];y.forEach((g,H)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${H}] must be a non-null object`);const _=`quoteRequestData.items[${H}]`;E.forEach(x=>{if(!Object.prototype.hasOwnProperty.call(g,x)||g[x]===void 0||g[x]===null)throw new Error(`Missing required ${_} field: '${x}'`)});const L=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!L.test(g.startDate))throw new Error(`${_}.startDate must be a valid ISO8601 string`);if(!L.test(g.endDate))throw new Error(`${_}.endDate must be a valid ISO8601 string`);if(typeof g.eventType!="string")throw new Error(`${_}.eventType must be a string`);if(typeof g.productType!="string")throw new Error(`${_}.productType must be a string`);const A=["Pass","Trip","Registration"];if(!A.includes(g.productType))throw new Error(`${_}.productType must be one of ${A.join(", ")}`);if(typeof g.productDuration!="string")throw new Error(`${_}.productDuration must be a string`);const O=["Daily","Seasonal","Trip","Event"];if(!O.includes(g.productDuration))throw new Error(`${_}.productDuration must be one of ${O.join(", ")}`);if(typeof g.productPrice!="number"||isNaN(g.productPrice))throw new Error(`${_}.productPrice must be a valid number`);if(typeof g.productId!="string")throw new Error(`${_}.productId must be a string`);if(typeof g.productName!="string")throw new Error(`${_}.productName must be a string`)})}else if(Array.isArray(r)){if(r.length===0)throw new Error("quoteRequestData array cannot be empty");r.forEach((p,u)=>{if(!p||typeof p!="object")throw new Error(`quoteRequestData[${u}] must be a non-null object`);v(p,u)})}else v(r);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(p=>{const u=s[p];if(u&&typeof u!="function")throw new Error(`Callback '${p}' must be a function.`)}),typeof i=="string"&&!document.querySelector(i))throw new Error(`Invalid location selector: '${i}'`);if(a&&typeof a!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix");if(c.state&&!z.has(c.state))throw new Error(`Invalid state: '${c.state}'. Must be a 2-character US state or territory code.`)}var b=(c=>(c.YES="yes",c.NO="no",c.UNSELECTED="unselected",c))(b||{});function n(c,{text:t,className:r,parent:s,innerHTML:i,href:a,target:e}={}){const o=document.createElement(c);return r&&(o.className=r),t!=null&&(o.textContent=t),i!=null&&(o.innerHTML=i),a&&"href"in o&&(o.href=a),e&&"target"in o&&(o.target=e),s&&s.appendChild(o),o}function $(c,{name:t,description:r}){n("div",{className:"spot-header__title",text:t,parent:c}),n("div",{className:"spot-header__description",text:r,parent:c})}function V(c,t=[]){const r=n("ul",{className:"spot-benefits__list",parent:c});t.forEach(s=>{const i=n("li",{parent:r});i.innerHTML=`
1
+ (function(C,q){typeof exports=="object"&&typeof module<"u"?q(exports):typeof define=="function"&&define.amd?define(["exports"],q):(C=typeof globalThis<"u"?globalThis:C||self,q(C.SpotWidget={}))})(this,function(C){"use strict";async function q(c,t,r,s){try{const i=s?{...r,state:s}:r,a=await fetch(c,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(i)}),e=await a.json();if(!a.ok){const o=new Error((e==null?void 0:e.message)||"Failed to fetch quote");throw o.status=a.status,o.responseBody=e,o}return e}catch(i){throw i instanceof Error?i:new Error("Unknown error occurred while fetching quote")}}async function R(c,t,r){try{const s=c.replace("/quote","/quote/batch"),i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(r)}),a=await i.json();if(!i.ok){const e=new Error((a==null?void 0:a.message)||"Failed to fetch batch quote");throw e.status=i.status,e.responseBody=a,e}return a}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function D(c,t,r,s){var i;try{const a={...r,...s?{state:s}:{},isPartialPayment:r.isPartialPayment||!1,roundTo:r.roundTo||void 0,items:r.items.map((m,f)=>({...m,cartItemId:m.cartItemId||`item-${f+1}`}))},e=await R(c,t,a);if(e.status!=="QUOTES_AVAILABLE"&&e.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const o=e.quotes.map(m=>{const f=r.items.find((v,h)=>(v.cartItemId||`item-${h+1}`)===m.cartItemId);return f?f.participantDescription?`${f.productName} - ${f.participantDescription}`:f.productName:`Item ${m.id}`}),l=Math.round((e.totalSpotPrice||e.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:e.quotes?e.quotes.map(m=>m.id).join(","):((i=e.data)==null?void 0:i.id)||"",spotPrice:l,currencyCode:e.currencyCode||"",communication:{...e.communication,yesOptionText:e.communication.yesOptionText.replace(String(e.totalSpotPrice),String(l))},payoutSchedule:e.payoutSchedule.map(m=>({...m,amount:m.amount!==void 0?m.amount:0})),coveredItems:o,originalQuotes:e.quotes||(e.data?[e.data]:[])},spotPrice:l,coveredItems:o}}catch(a){throw a instanceof Error?a:new Error("Unknown error occurred while fetching multiple quotes")}}const k="non-us-resident",T=[{value:"AL",label:"Alabama"},{value:"AK",label:"Alaska"},{value:"AS",label:"American Samoa"},{value:"AZ",label:"Arizona"},{value:"AR",label:"Arkansas"},{value:"CA",label:"California"},{value:"CO",label:"Colorado"},{value:"CT",label:"Connecticut"},{value:"DE",label:"Delaware"},{value:"DC",label:"District of Columbia"},{value:"FL",label:"Florida"},{value:"GA",label:"Georgia"},{value:"GU",label:"Guam"},{value:"HI",label:"Hawaii"},{value:"ID",label:"Idaho"},{value:"IL",label:"Illinois"},{value:"IN",label:"Indiana"},{value:"IA",label:"Iowa"},{value:"KS",label:"Kansas"},{value:"KY",label:"Kentucky"},{value:"LA",label:"Louisiana"},{value:"ME",label:"Maine"},{value:"MD",label:"Maryland"},{value:"MA",label:"Massachusetts"},{value:"MI",label:"Michigan"},{value:"MN",label:"Minnesota"},{value:"MS",label:"Mississippi"},{value:"MO",label:"Missouri"},{value:"MT",label:"Montana"},{value:"NE",label:"Nebraska"},{value:"NV",label:"Nevada"},{value:"NH",label:"New Hampshire"},{value:"NJ",label:"New Jersey"},{value:"NM",label:"New Mexico"},{value:"NY",label:"New York"},{value:"NC",label:"North Carolina"},{value:"ND",label:"North Dakota"},{value:"MP",label:"Northern Mariana Islands"},{value:"OH",label:"Ohio"},{value:"OK",label:"Oklahoma"},{value:"OR",label:"Oregon"},{value:"PA",label:"Pennsylvania"},{value:"PR",label:"Puerto Rico"},{value:"RI",label:"Rhode Island"},{value:"SC",label:"South Carolina"},{value:"SD",label:"South Dakota"},{value:"TN",label:"Tennessee"},{value:"TX",label:"Texas"},{value:"VI",label:"U.S. Virgin Islands"},{value:"UT",label:"Utah"},{value:"VT",label:"Vermont"},{value:"VA",label:"Virginia"},{value:"WA",label:"Washington"},{value:"WV",label:"West Virginia"},{value:"WI",label:"Wisconsin"},{value:"WY",label:"Wyoming"}],z=new Set(T.map(c=>c.value)),S=["USD","CAD","AUD","NZD","EUR","MXN","AED","GBP","MAD","SAR","BGN","BRL","CHF","DKK","INR","JPY","MYR","NOK","PLN","SEK","SGD","THB","ZAR"],P={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function N(c){const{apiConfig:t={},quoteRequestData:r,callbacks:s={},location:i,theme:a}=c,{environment:e="sandbox",partnerId:o,customEndpoint:l}=t;if(!o||typeof o!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(l||P[e]))throw new Error(`Invalid environment in apiConfig: ${e}`);if(!r||typeof r!="object"&&!Array.isArray(r))throw new Error("quoteRequestData must be a non-null object or array");const f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function v(p,u=null){const d=u!==null?`quoteRequestData[${u}]`:"quoteRequestData";f.forEach(g=>{if(!Object.prototype.hasOwnProperty.call(p,g)||p[g]===void 0||p[g]===null)throw new Error(`Missing required ${d} field: '${g}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(p.startDate))throw new Error(`${d}.startDate must be a valid ISO8601 string`);if(!w.test(p.endDate))throw new Error(`${d}.endDate must be a valid ISO8601 string`);if(typeof p.currencyCode!="string")throw new Error(`${d}.currencyCode must be a string`);if(!S.includes(p.currencyCode))throw new Error(`Invalid ${d}.currencyCode: ${p.currencyCode}`);if(typeof p.eventType!="string")throw new Error(`${d}.eventType must be a string`);if(typeof p.productType!="string")throw new Error(`${d}.productType must be a string`);const y=["Pass","Trip","Registration"];if(!y.includes(p.productType))throw new Error(`${d}.productType must be one of ${y.join(", ")}`);if(typeof p.productDuration!="string")throw new Error(`${d}.productDuration must be a string`);const E=["Daily","Seasonal","Trip","Event"];if(!E.includes(p.productDuration))throw new Error(`${d}.productDuration must be one of ${E.join(", ")}`);if(typeof p.productPrice!="number"||isNaN(p.productPrice))throw new Error(`${d}.productPrice must be a valid number`);if(typeof p.productId!="string")throw new Error(`${d}.productId must be a string`);if(typeof p.cartId!="string")throw new Error(`${d}.cartId must be a string`);if(typeof p.productName!="string")throw new Error(`${d}.productName must be a string`)}if("items"in r){const p=r,{cartId:u,cartName:d,currencyCode:w,items:y}=p;if(!u||typeof u!="string")throw new Error("quoteRequestData.cartId must be a string");if(!d||typeof d!="string")throw new Error("quoteRequestData.cartName must be a string");if(!w||typeof w!="string")throw new Error("quoteRequestData.currencyCode must be a string");if(!S.includes(w))throw new Error(`Invalid quoteRequestData.currencyCode: ${w}`);if(!Array.isArray(y)||y.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const E=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];y.forEach((g,H)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${H}] must be a non-null object`);const _=`quoteRequestData.items[${H}]`;E.forEach(x=>{if(!Object.prototype.hasOwnProperty.call(g,x)||g[x]===void 0||g[x]===null)throw new Error(`Missing required ${_} field: '${x}'`)});const A=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!A.test(g.startDate))throw new Error(`${_}.startDate must be a valid ISO8601 string`);if(!A.test(g.endDate))throw new Error(`${_}.endDate must be a valid ISO8601 string`);if(typeof g.eventType!="string")throw new Error(`${_}.eventType must be a string`);if(typeof g.productType!="string")throw new Error(`${_}.productType must be a string`);const L=["Pass","Trip","Registration"];if(!L.includes(g.productType))throw new Error(`${_}.productType must be one of ${L.join(", ")}`);if(typeof g.productDuration!="string")throw new Error(`${_}.productDuration must be a string`);const O=["Daily","Seasonal","Trip","Event"];if(!O.includes(g.productDuration))throw new Error(`${_}.productDuration must be one of ${O.join(", ")}`);if(typeof g.productPrice!="number"||isNaN(g.productPrice))throw new Error(`${_}.productPrice must be a valid number`);if(typeof g.productId!="string")throw new Error(`${_}.productId must be a string`);if(typeof g.productName!="string")throw new Error(`${_}.productName must be a string`)})}else if(Array.isArray(r)){if(r.length===0)throw new Error("quoteRequestData array cannot be empty");r.forEach((p,u)=>{if(!p||typeof p!="object")throw new Error(`quoteRequestData[${u}] must be a non-null object`);v(p,u)})}else v(r);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(p=>{const u=s[p];if(u&&typeof u!="function")throw new Error(`Callback '${p}' must be a function.`)}),typeof i=="string"&&!document.querySelector(i))throw new Error(`Invalid location selector: '${i}'`);if(a&&typeof a!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix");if(c.state&&!z.has(c.state))throw new Error(`Invalid state: '${c.state}'. Must be a 2-character US state or territory code.`)}var b=(c=>(c.YES="yes",c.NO="no",c.UNSELECTED="unselected",c))(b||{});function n(c,{text:t,className:r,parent:s,innerHTML:i,href:a,target:e}={}){const o=document.createElement(c);return r&&(o.className=r),t!=null&&(o.textContent=t),i!=null&&(o.innerHTML=i),a&&"href"in o&&(o.href=a),e&&"target"in o&&(o.target=e),s&&s.appendChild(o),o}function $(c,{name:t,description:r}){n("div",{className:"spot-header__title",text:t,parent:c}),n("div",{className:"spot-header__description",text:r,parent:c})}function V(c,t=[]){const r=n("ul",{className:"spot-benefits__list",parent:c});t.forEach(s=>{const i=n("li",{parent:r});i.innerHTML=`
2
2
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="spot-bullets__checkmark">
3
3
  <path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
4
4
  stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
@@ -32,4 +32,4 @@
32
32
  <rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
33
33
  </clipPath>
34
34
  </defs>
35
- </svg>`}return s}const Y=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--spot-border-line-width: .0625rem;--spot-border-color: #e0e0e0;--spot-max-width: 51rem;--spot-margin: 1rem;--spot-title-font-size: 1.25rem;--spot-title-font-weight: 700;--spot-title-padding: 0 0 1.25rem 0;--spot-description-font-size: .875rem;--spot-description-font-weight: 400;--spot-description-padding: 0 0 .5rem 0;--spot-bullets-font-size: .875rem;--spot-bullets-font-weight: 400;--spot-bullets-padding: .3125rem;--spot-bullets-checkmark-color: #2e2e2e;--spot-table-border-radius: .625rem;--spot-table-header-font-size: .875rem;--spot-table-header-font-weight: 700;--spot-table-header-padding: 0 .5rem .625rem;--spot-table-cell-font-size: .815rem;--spot-table-cell-font-weight: 400;--spot-table-cell-padding: 0 .625rem;--spot-radio-border: #000000;--spot-radio-border-radius: .625rem;--spot-radio-checked-background: #000000;--spot-radio-text-font-size: .875rem;--spot-radio-text-font-weight: 400;--spot-radio-text-padding: .625rem;--spot-radio-selection-background: #f4f4f4;--spot-radio-selection-border-radius: .625rem;--spot-radio-selection-padding: .625rem;--spot-recommended-tag-background: #000000;--spot-recommended-tag-font-color: #ffffff;--spot-recommended-tag-font-size: .875rem;--spot-recommended-tag-font-weight: 700;--spot-recommended-tag-padding: .25rem .5rem;--spot-recommended-tag-border-radius: .5rem;--spot-state-dropdown-label-font-size: .875rem;--spot-state-dropdown-label-font-weight: 600;--spot-state-dropdown-label-margin-bottom: .25rem;--spot-state-dropdown-select-border: .0625rem solid #e0e0e0;--spot-state-dropdown-select-border-radius: .375rem;--spot-state-dropdown-select-padding: .5rem .75rem;--spot-state-dropdown-select-font-size: .875rem;--spot-state-dropdown-select-background: #ffffff;--spot-state-dropdown-wrapper-margin-bottom: .75rem;--spot-selection-error-font-color: #ff0000;--spot-selection-error-font-size: .875rem;--spot-qualifying-reasons-margin: .75rem 0;--spot-qualifying-reasons-padding: 0 .3125rem;--spot-qualifying-reasons-column-gap: 3rem;--spot-qualifying-reasons-row-gap: .25rem;--spot-qualifying-reasons-grid-padding-left: 1rem;--spot-qualifying-reasons-icon-wrapper-size: 1.125rem;--spot-qualifying-reasons-icon-size: .75rem;--spot-qualifying-reasons-icon-border-color: #2e2e2e;--spot-qualifying-reasons-icon-border-width: 1px;--spot-qualifying-reasons-icon-background: #ffffff;--spot-qualifying-reasons-item-gap: .625rem;--spot-qualifying-reasons-label-font-size: .8rem;--spot-qualifying-reasons-label-font-weight: 400;--spot-qualifying-reasons-label-font-color: #000000;--spot-qualifying-reasons-label-font-family: Arial;--spot-selection-error-padding: .5rem;--spot-payment-terms-background: #f4f4f4;--spot-payment-terms-border-radius: .625rem;--spot-payment-terms-padding: 1rem;--spot-payment-terms-font-color: #636569;--spot-payment-terms-font-size: .75rem;--spot-payment-terms-header-font-weight: 700;--spot-payment-terms-header-font-size: .875rem;--spot-payment-terms-header-margin-bottom: .5rem;--spot-payment-terms-header-border-color: #c2c2c2;--spot-payment-terms-header-padding: 0 0 .5rem 0;--spot-terms-font-size: .75rem;--spot-terms-font-weight: 400;--spot-terms-font-color: #636569;--spot-terms-padding: 0;--spot-terms-link-text-decoration: underline;--spot-terms-link-font-size: .75rem;--spot-terms-link-font-weight: 400;--spot-terms-link-font-color: #636569;--spot-terms-link-padding: 0;--spot-covered-items-background: #f1f3f5;--spot-covered-items-hover-background: #e9ecef;--spot-covered-items-border-radius: .5rem;--spot-covered-items-padding: .75rem 1rem;--spot-covered-items-font-size: .875rem;--spot-covered-items-font-weight: 400;--spot-covered-items-font-color: #000000;--spot-covered-items-font-family: Arial;--spot-covered-items-arrow-font-size: .6rem;--spot-covered-items-arrow-color: #636569;--spot-covered-items-view-all-color: #636569;--spot-covered-items-view-all-font-size: .875rem;--spot-covered-items-view-all-font-weight: 400;--spot-covered-items-content-background: #f8f9fa;--spot-covered-items-content-border: 1px solid #e0e0e0;--spot-covered-items-content-border-radius: .5rem;--spot-covered-items-content-padding: .75rem 1rem;--spot-desktop-radio-margin-top: -1.5rem;--spot-benefits-margin-bottom: 0rem;--spot-covered-items-margin-bottom: 1.5rem;--spot-footer-gap: 1rem;--spot-footer-terms-margin-right: 7rem;--spot-payment-terms-margin-top: .5rem;--spot-logo-top-right-margin: 1rem}.spot-refund-guarantee{font-family:var(--spot-font-family);padding:var(--spot-padding);background-color:var(--spot-background-color);color:var(--spot-font-color);border:var(--spot-border-line-width) solid var(--spot-border-color);border-radius:var(--spot-border-radius);max-width:var(--spot-max-width);margin:var(--spot-margin);container-type:inline-size;position:relative;word-wrap:normal;overflow-wrap:normal;-webkit-hyphens:none;hyphens:none}.spot-refund-guarantee *{color:inherit}.spot-header__title{font-size:var(--spot-title-font-size);font-weight:var(--spot-title-font-weight);padding:var(--spot-title-padding);color:var(--spot-title-font-color);font-family:var(--spot-title-font-family);line-height:120%;letter-spacing:-.03125rem}.spot-header__description{font-size:var(--spot-description-font-size);font-weight:var(--spot-description-font-weight);color:var(--spot-description-font-color);font-family:var(--spot-description-font-family);padding:var(--spot-description-padding);line-height:125%;letter-spacing:-.025rem}.spot-content__wrapper{display:flex;flex-direction:column}.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr auto;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container,.desktop-layout .spot-covered-items__container,.desktop-layout .spot-selection__wrapper{min-width:0;word-wrap:normal}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container{grid-row:1;margin-bottom:var(--spot-benefits-margin-bottom)}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1;margin-bottom:var(--spot-covered-items-margin-bottom)}.desktop-layout .spot-selection__wrapper{grid-row:3;grid-column:1;margin-top:var(--spot-desktop-radio-margin-top)}.desktop-layout .spot-payment-terms__wrapper{grid-row:4;grid-column:1;margin-top:var(--spot-payment-terms-margin-top)}.desktop-layout .spot-table__container{grid-row:1 / span 4;grid-column:2;width:auto;min-width:20.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-table__container{display:flex;justify-content:flex-start;margin-top:1rem;margin-bottom:1rem;box-sizing:border-box;padding:0 .3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-refund__table{width:100%;max-width:22rem;table-layout:auto}@media (max-width: 850px){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 500px){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 600px){.spot-refund__table th{padding:0rem}}.spot-benefits__list{list-style-type:none;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-benefits__list li{margin-bottom:.375rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-bullets__checkmark path{stroke:var(--spot-bullets-checkmark-color)}.spot-qualifying-reasons__container{margin:var(--spot-qualifying-reasons-margin);padding:var(--spot-qualifying-reasons-padding)}.spot-qualifying-reasons__grid{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));column-gap:var(--spot-qualifying-reasons-column-gap);row-gap:var(--spot-qualifying-reasons-row-gap);max-width:100%;padding-left:var(--spot-qualifying-reasons-grid-padding-left)}.spot-qualifying-reasons__item{display:flex;align-items:center;gap:var(--spot-qualifying-reasons-item-gap)}.spot-qualifying-reasons__icon-wrapper{width:var(--spot-qualifying-reasons-icon-wrapper-size);height:var(--spot-qualifying-reasons-icon-wrapper-size);border-radius:50%;border:var(--spot-qualifying-reasons-icon-border-width) solid var(--spot-qualifying-reasons-icon-border-color);background-color:var(--spot-qualifying-reasons-icon-background);display:flex;align-items:center;justify-content:center;flex-shrink:0}.spot-qualifying-reasons__icon{width:var(--spot-qualifying-reasons-icon-size);height:var(--spot-qualifying-reasons-icon-size)}.spot-qualifying-reasons__label{font-size:var(--spot-qualifying-reasons-label-font-size);font-weight:var(--spot-qualifying-reasons-label-font-weight);color:var(--spot-qualifying-reasons-label-font-color);font-family:var(--spot-qualifying-reasons-label-font-family);line-height:1.2}@media (max-width: 480px){.spot-qualifying-reasons__grid{grid-template-columns:1fr}}.spot-covered-items__container{margin-top:.85rem;margin-bottom:.5rem;max-width:26rem}.spot-content__wrapper.desktop-layout:has(.spot-table__container) .spot-covered-items__container{margin-top:0rem;margin-bottom:1rem}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);padding:0 .3125rem .25rem;line-height:125%;margin:0}.spot-covered-items__list{list-style-type:disc;list-style-position:inside;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-covered-items__list li{margin-bottom:.3rem;text-align:left}.spot-covered-items__list li:last-child{margin-bottom:0}.spot-covered-items__header{margin-bottom:.5rem}.spot-covered-items__toggle{background:var(--spot-covered-items-background);border:none;border-radius:var(--spot-covered-items-border-radius);padding:var(--spot-covered-items-padding);cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;transition:all .2s ease}.spot-covered-items__toggle:hover{background-color:var(--spot-covered-items-hover-background)}.spot-covered-items__toggle:focus{outline:none;box-shadow:0 0 0 2px #0000001a}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;margin:0;padding:0}.spot-covered-items__right-section{display:flex;align-items:center;gap:.5rem;margin-left:auto}.spot-covered-items__view-all{font-size:var(--spot-covered-items-view-all-font-size);font-weight:var(--spot-covered-items-view-all-font-weight);color:var(--spot-covered-items-view-all-color);font-family:var(--spot-covered-items-font-family);line-height:125%}.spot-covered-items__arrow{font-size:var(--spot-covered-items-arrow-font-size);transition:transform .2s ease;color:var(--spot-covered-items-arrow-color);flex-shrink:0;transform:scaleX(1.5)}.spot-covered-items__content{margin-top:.5rem;transition:all .2s ease;overflow:hidden}.spot-covered-items__list{background-color:var(--spot-covered-items-content-background);border:var(--spot-covered-items-content-border);border-radius:var(--spot-covered-items-content-border-radius);margin:0;padding:var(--spot-covered-items-content-padding)}.spot-table__container{width:100%}.spot-refund__table{max-width:22rem;border-radius:var(--spot-table-border-radius);overflow:hidden;border:.09375rem solid #636569;table-layout:fixed;margin-bottom:.5rem;margin-top:.25rem;padding:.625rem}.spot-refund__table--dynamic{height:auto!important;min-height:7.5rem}.spot-refund__table td,.spot-refund__table th{padding:.375rem .625rem;text-align:left}.spot-refund__table th{text-align:left;font-size:var(--spot-table-header-font-size);font-weight:var(--spot-table-header-font-weight);color:var(--spot-table-header-font-color);font-family:var(--spot-table-header-font-family);padding:var(--spot-table-header-padding)}.spot-refund__table td{text-align:left;font-size:var(--spot-table-cell-font-size);font-weight:var(--spot-table-cell-font-weight);color:var(--spot-table-cell-font-color);font-family:var(--spot-table-cell-font-family);padding:var(--spot-table-cell-padding)}.spot-state-dropdown__wrapper{display:flex;flex-direction:column;margin-bottom:var(--spot-state-dropdown-wrapper-margin-bottom)}.spot-state-dropdown__label{font-size:var(--spot-state-dropdown-label-font-size);font-weight:var(--spot-state-dropdown-label-font-weight);font-family:var(--spot-font-family);color:var(--spot-font-color);margin-bottom:var(--spot-state-dropdown-label-margin-bottom)}.spot-state-dropdown__select{width:100%;box-sizing:border-box;border:var(--spot-state-dropdown-select-border);border-radius:var(--spot-state-dropdown-select-border-radius);padding:var(--spot-state-dropdown-select-padding);font-size:var(--spot-state-dropdown-select-font-size);font-family:var(--spot-font-family);color:var(--spot-font-color);background-color:var(--spot-state-dropdown-select-background);cursor:pointer;-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.spot-state-dropdown__select:focus{outline:none;box-shadow:0 0 0 2px #00000026}input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:.75rem;height:.75rem;min-width:.75rem;border:.0625rem solid var(--spot-radio-border);border-radius:var(--spot-radio-border-radius);margin-right:.5rem;position:relative;vertical-align:middle;top:-.0625rem;cursor:pointer;flex-shrink:0}input[type=radio]:checked{background:var(--spot-radio-checked-background);box-shadow:inset 0 0 0 .0625rem #fff}.spot-selection__options{display:flex;flex-direction:column;gap:.5rem}.spot-selection__option{display:flex;align-items:center;flex-wrap:nowrap;position:relative;transition:background .2s;cursor:pointer;font-size:var(--spot-radio-text-font-size);font-weight:var(--spot-radio-text-font-weight);color:var(--spot-radio-text-font-color);font-family:var(--spot-radio-text-font-family);padding:var(--spot-radio-text-padding);margin-right:.5rem}.spot-selection__option.selected{background:var(--spot-radio-selection-background);border-radius:var(--spot-radio-selection-border-radius);padding:var(--spot-radio-selection-padding)}.spot-selection__recommended-tag{background:var(--spot-recommended-tag-background);color:var(--spot-recommended-tag-font-color);font-size:var(--spot-recommended-tag-font-size);font-weight:var(--spot-recommended-tag-font-weight);padding:var(--spot-recommended-tag-padding);border-radius:var(--spot-recommended-tag-border-radius);margin-left:.75rem;white-space:nowrap;flex-shrink:0}@media (max-width: 850px){.spot-selection__recommended-tag{margin-left:.5rem}}@media (max-width: 600px){.spot-selection__recommended-tag{margin-left:.5rem;font-size:.75rem;padding:.1875rem .4375rem}}.spot-selection__error{color:var(--spot-selection-error-font-color);font-size:var(--spot-selection-error-font-size);padding:var(--spot-selection-error-padding);display:none}.spot-selection__options--disabled .spot-selection__option{opacity:.4;cursor:not-allowed;pointer-events:none}.spot-selection__options--disabled input[type=radio]{cursor:not-allowed}.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);color:var(--spot-payment-terms-font-color);font-size:var(--spot-payment-terms-font-size)}.spot-footer__terms{margin-top:.625rem;margin-right:.25rem;font-size:var(--spot-terms-font-size);font-weight:var(--spot-terms-font-weight);color:var(--spot-terms-font-color);font-family:var(--spot-terms-font-family);padding:var(--spot-terms-padding);line-height:1.4;word-wrap:normal;-webkit-hyphens:none;hyphens:none;flex:1;min-width:0;overflow-wrap:normal}.spot-footer__terms-link{text-decoration:var(--spot-terms-link-text-decoration);font-size:var(--spot-terms-link-font-size);font-weight:var(--spot-terms-link-font-weight);color:var(--spot-terms-link-font-color);font-family:var(--spot-terms-link-font-family);padding:var(--spot-terms-link-padding)}.spot-footer__container{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;flex-wrap:nowrap;gap:var(--spot-footer-gap)}@container (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}@media (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}.spot-footer__powered-by{margin-top:0;flex-shrink:0}.spot-logo__top-right{position:absolute;top:-14px;right:40px;z-index:10;background:linear-gradient(to bottom,transparent 50%,inherit 50%);padding:0 .25rem}.spot-logo__top-right svg{border-radius:1.25rem;border:var(--spot-border-line-width) solid var(--spot-border-color);display:block;background:var(--spot-background-color)}@container (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}@media (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}";function G(c){const t=document.createElement("style");t.textContent=c,document.head.appendChild(t)}G(Y);const M={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 K{constructor(t={}){this.options={location:"body",showTable:!0,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t,selection:t.selection??b.UNSELECTED},this._onResize=this._updateLayout.bind(this),this.root=typeof this.options.location=="string"?document.querySelector(this.options.location):this.options.location,this.currentSelection=this.options.selection,this._init()}async _init(){var t,r,s,i,a;try{N(this.options),this.currentState=this.options.state;let e;if(this.options.useMockData&&this.options.mockData)e=this.options.mockData;else{const{environment:o,partnerId:l}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||M[o];e="items"in this.options.quoteRequestData?await D(f,l,this.options.quoteRequestData,this._validState()):await q(f,l,this.options.quoteRequestData,this._validState())}if(e.status!=="QUOTE_AVAILABLE"){e.status==="NO_MATCHING_QUOTE"&&((t=this.options.callbacks)!=null&&t.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=e.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.selection===b.YES&&((r=this.options.callbacks)!=null&&r.onOptIn)){const o={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id,state:this._validState()};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const l=this.options.quoteRequestData;o.batchQuoteDetails=this.quote.originalQuotes.map(m=>{var v;const f=(v=l.items)==null?void 0:v.find(h=>(h.cartItemId||`item-${l.items.indexOf(h)+1}`)===m.cartItemId);return{quoteId:m.id,productPrice:(f==null?void 0:f.productPrice)||m.spotPrice,cartItemId:(f==null?void 0:f.cartItemId)||""}})}this.options.callbacks.onOptIn(o)}if((s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const o=this.options.callbacks.onQuoteRetrieved(this.quote);o&&this._applyQuoteUpdates(o)}}catch(e){if((i=this.options.callbacks)!=null&&i.onError){const o=e;(a=this.options.callbacks)==null||a.onError({message:o.message,status:o.status,responseBody:o.responseBody})}}}_renderWidget(){if(!this.quote)return;this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([e,o])=>{const l=`--${e}`;this.container.style.setProperty(l,o)}),$(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?Q(t,this.quote.qualifyingReasons):V(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const e=this._getTotalItemsInRequest();U(t,this.quote.coveredItems,e)}this.options.showTable&&!this.quote.qualifyingReasons&&B(t,this.quote.payoutSchedule,this.quote.currencyCode);const r=n("div",{className:"spot-selection__wrapper",parent:t});this._isPassOrTrip()&&!this.options.state&&(this._stateSelectEl=j(r,this.currentState));const i=!this._isQuotingAvailable(),a=F(r,this.options.selection,this.quote.communication,i);this.paymentTermsEl=n("div",{className:"spot-payment-terms__wrapper",parent:t}),this.currentSelection===b.YES&&I(this.paymentTermsEl,this.quote),W(this.container,this.quote,this.options.logoPosition),window.addEventListener("resize",this._onResize),this._setupResizeObserver(),this._updateLayout(),this._setupOptionListeners(a),this._setupStateDropdownListener()}_updateLayout(){if(!this.container||!this.quote)return;const t=this.container.querySelector(".spot-content__wrapper"),r=this.options.showTable&&!this.quote.qualifyingReasons;if(!t||!r){t==null||t.classList.remove("desktop-layout");return}const s=this._shouldUseDesktopLayout(t);t.classList.toggle("desktop-layout",s)}_shouldUseDesktopLayout(t){const r=this.container.offsetWidth-40,s=325,i=16;if(r>=900)return!0;if(r>=650){const a=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const e=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!e)return a&&t.classList.add("desktop-layout"),a;const l=Math.min(e.scrollWidth,400)+s+i;return a&&t.classList.add("desktop-layout"),r>=l}return!1}_setupResizeObserver(){!this.container||!window.ResizeObserver||(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=window.setTimeout(()=>{this._updateLayout()},100)}),this._resizeObserver.observe(this.container))}_getTotalItemsInRequest(){return"items"in this.options.quoteRequestData?this.options.quoteRequestData.items.length:1}_applyQuoteUpdates(t){!this.quote||!this.container||(t.spotPriceWithFees!==void 0&&(this.quote.communication.yesOptionText=this.quote.communication.yesOptionText.replace(`$${this.quote.spotPrice.toFixed(2)}`,`$${t.spotPriceWithFees.toFixed(2)}`)),this.destroy(),this._renderWidget())}_isPassOrTrip(){const t=this.options.quoteRequestData;if(Array.isArray(t))return t.some(s=>s.productType==="Pass"||s.productType==="Trip");if("items"in t)return t.items.some(s=>s.productType==="Pass"||s.productType==="Trip");const r=t;return r.productType==="Pass"||r.productType==="Trip"}_validState(){if(this._isPassOrTrip()&&!(!this.currentState||this.currentState===k))return this.currentState}_isQuotingAvailable(){return!this._isPassOrTrip()||this.options.state?!0:!!this.currentState&&this.currentState!==k}_setRadiosDisabled(t){var i,a,e;const r=(i=this.container)==null?void 0:i.querySelectorAll('input[name="selection"]'),s=(a=this.container)==null?void 0:a.querySelector(".spot-selection__options");r==null||r.forEach(o=>{o.disabled=t}),s==null||s.classList.toggle("spot-selection__options--disabled",t),t&&(r==null||r.forEach(o=>{o.checked=!1}),(e=this.container)==null||e.querySelectorAll(".spot-selection__option").forEach(o=>{o.classList.remove("selected")}),this.currentSelection=b.UNSELECTED,this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""))}_setupStateDropdownListener(){this._stateSelectEl&&this._stateSelectEl.addEventListener("change",()=>{this.currentState=this._stateSelectEl.value,this._setRadiosDisabled(!this._isQuotingAvailable())})}_setupOptionListeners(t){const r=t.querySelectorAll('input[type="radio"]'),s=t.querySelectorAll(".spot-selection__option");r.forEach(i=>{i.addEventListener("change",a=>{var l,m,f,v;const e=a.target,o=e.value;if(this.hideSelectionError(),this.currentSelection=o,s.forEach(h=>h.classList.remove("selected")),(l=e.closest(".spot-selection__option"))==null||l.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),o===b.YES&&((m=this.quote)!=null&&m.communication.paymentTerms&&I(this.paymentTermsEl,this.quote),(f=this.options.callbacks)!=null&&f.onOptIn)){const h={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id,state:this._validState()};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const p=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var w;const d=(w=p.items)==null?void 0:w.find(y=>(y.cartItemId||`item-${p.items.indexOf(y)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(d==null?void 0:d.productPrice)||u.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptIn(h)}if(o===b.NO&&((v=this.options.callbacks)!=null&&v.onOptOut)){const h={status:"QUOTE_DECLINED",quoteId:this.quote.id,state:this._validState()};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const p=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var w;const d=(w=p.items)==null?void 0:w.find(y=>(y.cartItemId||`item-${p.items.indexOf(y)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(d==null?void 0:d.productPrice)||u.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptOut(h)}})})}showSelectionError(){var t;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const r=(t=this.container)==null?void 0:t.querySelector(".spot-selection__options");r&&r.insertAdjacentElement("afterend",this.errorEl)}this.errorEl.style.display="block"}hideSelectionError(){this.errorEl&&(this.errorEl.style.display="none")}validateSelection(){if(!this.container)return!1;const t=!!this.container.querySelector('input[name="selection"]:checked');return t?this.hideSelectionError():this.showSelectionError(),t}async updateQuote(t){var r,s,i,a;try{const e={...this.options,quoteRequestData:t};N(e);const{environment:o,partnerId:l,customEndpoint:m}=this.options.apiConfig,f=m||M[o],h="items"in e.quoteRequestData?await D(f,l,e.quoteRequestData,this._validState()):await q(f,l,e.quoteRequestData,this._validState());if(h.status!=="QUOTE_AVAILABLE")return this.destroy(),h.status==="NO_MATCHING_QUOTE"&&((r=this.options.callbacks)!=null&&r.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:e.quoteRequestData}),!1;if(this.options.quoteRequestData=e.quoteRequestData,this.quote=h.data,this.currentSelection=b.UNSELECTED,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const p=this.options.callbacks.onQuoteRetrieved(this.quote);p&&this._applyQuoteUpdates(p)}return!0}catch(e){const o=e;return(a=(i=this.options.callbacks)==null?void 0:i.onError)==null||a.call(i,{message:o.message,status:o.status,responseBody:o.responseBody}),!1}}getSelection(){var r,s,i;if(this.currentSelection==null||this.currentSelection==b.UNSELECTED)return null;const t={selection:this.currentSelection,quoteId:(r=this.quote)==null?void 0:r.id,spotPrice:(s=this.quote)==null?void 0:s.spotPrice,status:this.currentSelection===b.YES?"QUOTE_ACCEPTED":"QUOTE_DECLINED",state:this.currentState};if((i=this.quote)!=null&&i.originalQuotes&&this.quote.originalQuotes.length>0){const a=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(e=>{var l;const o=(l=a.items)==null?void 0:l.find(m=>(m.cartItemId||`item-${a.items.indexOf(m)+1}`)===e.cartItemId);return{quoteId:e.id,productPrice:(o==null?void 0:o.productPrice)||e.spotPrice,cartItemId:(o==null?void 0:o.cartItemId)||""}})}return t}destroy(){window.removeEventListener("resize",this._onResize),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeTimeout&&window.clearTimeout(this._resizeTimeout),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}C.NON_US_RESIDENT_VALUE=k,C.SelectionEnum=b,C.default=K,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
35
+ </svg>`}return s}const Y=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--spot-border-line-width: .0625rem;--spot-border-color: #e0e0e0;--spot-max-width: 51rem;--spot-margin: 1rem;--spot-title-font-size: 1.25rem;--spot-title-font-weight: 700;--spot-title-padding: 0 0 1.25rem 0;--spot-description-font-size: .875rem;--spot-description-font-weight: 400;--spot-description-padding: 0 0 .5rem 0;--spot-bullets-font-size: .875rem;--spot-bullets-font-weight: 400;--spot-bullets-padding: .3125rem;--spot-bullets-checkmark-color: #2e2e2e;--spot-table-border-radius: .625rem;--spot-table-header-font-size: .875rem;--spot-table-header-font-weight: 700;--spot-table-header-padding: 0 .5rem .625rem;--spot-table-cell-font-size: .815rem;--spot-table-cell-font-weight: 400;--spot-table-cell-padding: 0 .625rem;--spot-radio-border: #000000;--spot-radio-border-radius: .625rem;--spot-radio-checked-background: #000000;--spot-radio-text-font-size: .875rem;--spot-radio-text-font-weight: 400;--spot-radio-text-padding: .625rem;--spot-radio-selection-background: #f4f4f4;--spot-radio-selection-border-radius: .625rem;--spot-radio-selection-padding: .625rem;--spot-recommended-tag-background: #000000;--spot-recommended-tag-font-color: #ffffff;--spot-recommended-tag-font-size: .875rem;--spot-recommended-tag-font-weight: 700;--spot-recommended-tag-padding: .25rem .5rem;--spot-recommended-tag-border-radius: .5rem;--spot-state-dropdown-label-font-size: .875rem;--spot-state-dropdown-label-font-weight: 600;--spot-state-dropdown-label-margin-bottom: .25rem;--spot-state-dropdown-select-border: .0625rem solid #e0e0e0;--spot-state-dropdown-select-border-radius: .375rem;--spot-state-dropdown-select-padding: .5rem .75rem;--spot-state-dropdown-select-font-size: .875rem;--spot-state-dropdown-select-background: #ffffff;--spot-state-dropdown-wrapper-margin-bottom: .75rem;--spot-selection-error-font-color: #ff0000;--spot-selection-error-font-size: .875rem;--spot-qualifying-reasons-margin: .75rem 0;--spot-qualifying-reasons-padding: 0 .3125rem;--spot-qualifying-reasons-column-gap: 3rem;--spot-qualifying-reasons-row-gap: .25rem;--spot-qualifying-reasons-grid-padding-left: 1rem;--spot-qualifying-reasons-icon-wrapper-size: 1.125rem;--spot-qualifying-reasons-icon-size: .75rem;--spot-qualifying-reasons-icon-border-color: #2e2e2e;--spot-qualifying-reasons-icon-border-width: 1px;--spot-qualifying-reasons-icon-background: #ffffff;--spot-qualifying-reasons-item-gap: .625rem;--spot-qualifying-reasons-label-font-size: .8rem;--spot-qualifying-reasons-label-font-weight: 400;--spot-qualifying-reasons-label-font-color: #000000;--spot-qualifying-reasons-label-font-family: Arial;--spot-selection-error-padding: .5rem;--spot-payment-terms-background: #f4f4f4;--spot-payment-terms-border-radius: .625rem;--spot-payment-terms-padding: 1rem;--spot-payment-terms-font-color: #636569;--spot-payment-terms-font-size: .75rem;--spot-payment-terms-header-font-weight: 700;--spot-payment-terms-header-font-size: .875rem;--spot-payment-terms-header-margin-bottom: .5rem;--spot-payment-terms-header-border-color: #c2c2c2;--spot-payment-terms-header-padding: 0 0 .5rem 0;--spot-terms-font-size: .75rem;--spot-terms-font-weight: 400;--spot-terms-font-color: #636569;--spot-terms-padding: 0;--spot-terms-link-text-decoration: underline;--spot-terms-link-font-size: .75rem;--spot-terms-link-font-weight: 400;--spot-terms-link-font-color: #636569;--spot-terms-link-padding: 0;--spot-covered-items-background: #f1f3f5;--spot-covered-items-hover-background: #e9ecef;--spot-covered-items-border-radius: .5rem;--spot-covered-items-padding: .75rem 1rem;--spot-covered-items-font-size: .875rem;--spot-covered-items-font-weight: 400;--spot-covered-items-font-color: #000000;--spot-covered-items-font-family: Arial;--spot-covered-items-arrow-font-size: .6rem;--spot-covered-items-arrow-color: #636569;--spot-covered-items-view-all-color: #636569;--spot-covered-items-view-all-font-size: .875rem;--spot-covered-items-view-all-font-weight: 400;--spot-covered-items-content-background: #f8f9fa;--spot-covered-items-content-border: 1px solid #e0e0e0;--spot-covered-items-content-border-radius: .5rem;--spot-covered-items-content-padding: .75rem 1rem;--spot-desktop-radio-margin-top: -1.5rem;--spot-benefits-margin-bottom: 0rem;--spot-covered-items-margin-bottom: 1.5rem;--spot-footer-gap: 1rem;--spot-footer-terms-margin-right: 7rem;--spot-payment-terms-margin-top: .5rem;--spot-logo-top-right-margin: 1rem}.spot-refund-guarantee{font-family:var(--spot-font-family);padding:var(--spot-padding);background-color:var(--spot-background-color);color:var(--spot-font-color);border:var(--spot-border-line-width) solid var(--spot-border-color);border-radius:var(--spot-border-radius);max-width:var(--spot-max-width);margin:var(--spot-margin);container-type:inline-size;position:relative;word-wrap:normal;overflow-wrap:normal;-webkit-hyphens:none;hyphens:none}.spot-refund-guarantee *{color:inherit}.spot-header__title{font-size:var(--spot-title-font-size);font-weight:var(--spot-title-font-weight);padding:var(--spot-title-padding);color:var(--spot-title-font-color);font-family:var(--spot-title-font-family);line-height:120%;letter-spacing:-.03125rem}.spot-header__description{font-size:var(--spot-description-font-size);font-weight:var(--spot-description-font-weight);color:var(--spot-description-font-color);font-family:var(--spot-description-font-family);padding:var(--spot-description-padding);line-height:125%;letter-spacing:-.025rem}.spot-content__wrapper{display:flex;flex-direction:column}.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr auto;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container,.desktop-layout .spot-covered-items__container,.desktop-layout .spot-selection__wrapper{min-width:0;word-wrap:normal}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container{grid-row:1;margin-bottom:var(--spot-benefits-margin-bottom)}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1;margin-bottom:var(--spot-covered-items-margin-bottom)}.desktop-layout .spot-selection__wrapper{grid-row:3;grid-column:1;margin-top:var(--spot-desktop-radio-margin-top)}.desktop-layout .spot-payment-terms__wrapper{grid-row:4;grid-column:1;margin-top:var(--spot-payment-terms-margin-top)}.desktop-layout .spot-table__container{grid-row:1 / span 4;grid-column:2;width:auto;min-width:20.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-table__container{display:flex;justify-content:flex-start;margin-top:1rem;margin-bottom:1rem;box-sizing:border-box;padding:0 .3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-refund__table{width:100%;max-width:22rem;table-layout:auto}@media (max-width: 850px){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 500px){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 600px){.spot-refund__table th{padding:0rem}}.spot-benefits__list{list-style-type:none;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-benefits__list li{margin-bottom:.375rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-bullets__checkmark path{stroke:var(--spot-bullets-checkmark-color)}.spot-qualifying-reasons__container{margin:var(--spot-qualifying-reasons-margin);padding:var(--spot-qualifying-reasons-padding)}.spot-qualifying-reasons__grid{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));column-gap:var(--spot-qualifying-reasons-column-gap);row-gap:var(--spot-qualifying-reasons-row-gap);max-width:100%;padding-left:var(--spot-qualifying-reasons-grid-padding-left)}.spot-qualifying-reasons__item{display:flex;align-items:center;gap:var(--spot-qualifying-reasons-item-gap)}.spot-qualifying-reasons__icon-wrapper{width:var(--spot-qualifying-reasons-icon-wrapper-size);height:var(--spot-qualifying-reasons-icon-wrapper-size);border-radius:50%;border:var(--spot-qualifying-reasons-icon-border-width) solid var(--spot-qualifying-reasons-icon-border-color);background-color:var(--spot-qualifying-reasons-icon-background);display:flex;align-items:center;justify-content:center;flex-shrink:0}.spot-qualifying-reasons__icon{width:var(--spot-qualifying-reasons-icon-size);height:var(--spot-qualifying-reasons-icon-size)}.spot-qualifying-reasons__label{font-size:var(--spot-qualifying-reasons-label-font-size);font-weight:var(--spot-qualifying-reasons-label-font-weight);color:var(--spot-qualifying-reasons-label-font-color);font-family:var(--spot-qualifying-reasons-label-font-family);line-height:1.2}@media (max-width: 480px){.spot-qualifying-reasons__grid{grid-template-columns:1fr}}.spot-covered-items__container{margin-top:.85rem;margin-bottom:.5rem;max-width:26rem}.spot-content__wrapper.desktop-layout:has(.spot-table__container) .spot-covered-items__container{margin-top:0rem;margin-bottom:1rem}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);padding:0 .3125rem .25rem;line-height:125%;margin:0}.spot-covered-items__list{list-style-type:disc;list-style-position:inside;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-covered-items__list li{margin-bottom:.3rem;text-align:left}.spot-covered-items__list li:last-child{margin-bottom:0}.spot-covered-items__header{margin-bottom:.5rem}.spot-covered-items__toggle{background:var(--spot-covered-items-background);border:none;border-radius:var(--spot-covered-items-border-radius);padding:var(--spot-covered-items-padding);cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;transition:all .2s ease}.spot-covered-items__toggle:hover{background-color:var(--spot-covered-items-hover-background)}.spot-covered-items__toggle:focus{outline:none;box-shadow:0 0 0 2px #0000001a}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;margin:0;padding:0}.spot-covered-items__right-section{display:flex;align-items:center;gap:.5rem;margin-left:auto}.spot-covered-items__view-all{font-size:var(--spot-covered-items-view-all-font-size);font-weight:var(--spot-covered-items-view-all-font-weight);color:var(--spot-covered-items-view-all-color);font-family:var(--spot-covered-items-font-family);line-height:125%}.spot-covered-items__arrow{font-size:var(--spot-covered-items-arrow-font-size);transition:transform .2s ease;color:var(--spot-covered-items-arrow-color);flex-shrink:0;transform:scaleX(1.5)}.spot-covered-items__content{margin-top:.5rem;transition:all .2s ease;overflow:hidden}.spot-covered-items__list{background-color:var(--spot-covered-items-content-background);border:var(--spot-covered-items-content-border);border-radius:var(--spot-covered-items-content-border-radius);margin:0;padding:var(--spot-covered-items-content-padding)}.spot-table__container{width:100%}.spot-refund__table{max-width:22rem;border-radius:var(--spot-table-border-radius);overflow:hidden;border:.09375rem solid #636569;table-layout:fixed;margin-bottom:.5rem;margin-top:.25rem;padding:.625rem}.spot-refund__table--dynamic{height:auto!important;min-height:7.5rem}.spot-refund__table td,.spot-refund__table th{padding:.375rem .625rem;text-align:left}.spot-refund__table th{text-align:left;font-size:var(--spot-table-header-font-size);font-weight:var(--spot-table-header-font-weight);color:var(--spot-table-header-font-color);font-family:var(--spot-table-header-font-family);padding:var(--spot-table-header-padding)}.spot-refund__table td{text-align:left;font-size:var(--spot-table-cell-font-size);font-weight:var(--spot-table-cell-font-weight);color:var(--spot-table-cell-font-color);font-family:var(--spot-table-cell-font-family);padding:var(--spot-table-cell-padding)}.spot-state-dropdown__wrapper{display:flex;flex-direction:column;margin-bottom:var(--spot-state-dropdown-wrapper-margin-bottom)}.spot-state-dropdown__label{font-size:var(--spot-state-dropdown-label-font-size);font-weight:var(--spot-state-dropdown-label-font-weight);font-family:var(--spot-font-family);color:var(--spot-font-color);margin-bottom:var(--spot-state-dropdown-label-margin-bottom)}.spot-state-dropdown__select{width:100%;box-sizing:border-box;border:var(--spot-state-dropdown-select-border);border-radius:var(--spot-state-dropdown-select-border-radius);padding:var(--spot-state-dropdown-select-padding);font-size:var(--spot-state-dropdown-select-font-size);font-family:var(--spot-font-family);color:var(--spot-font-color);background-color:var(--spot-state-dropdown-select-background);cursor:pointer;-webkit-appearance:auto;-moz-appearance:auto;appearance:auto}.spot-state-dropdown__select:focus{outline:none;box-shadow:0 0 0 2px #00000026}input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:.75rem;height:.75rem;min-width:.75rem;border:.0625rem solid var(--spot-radio-border);border-radius:var(--spot-radio-border-radius);margin-right:.5rem;position:relative;vertical-align:middle;top:-.0625rem;cursor:pointer;flex-shrink:0}input[type=radio]:checked{background:var(--spot-radio-checked-background);box-shadow:inset 0 0 0 .0625rem #fff}.spot-selection__options{display:flex;flex-direction:column;gap:.5rem}.spot-selection__option{display:flex;align-items:center;flex-wrap:nowrap;position:relative;transition:background .2s;cursor:pointer;font-size:var(--spot-radio-text-font-size);font-weight:var(--spot-radio-text-font-weight);color:var(--spot-radio-text-font-color);font-family:var(--spot-radio-text-font-family);padding:var(--spot-radio-text-padding);margin-right:.5rem}.spot-selection__option.selected{background:var(--spot-radio-selection-background);border-radius:var(--spot-radio-selection-border-radius);padding:var(--spot-radio-selection-padding)}.spot-selection__recommended-tag{background:var(--spot-recommended-tag-background);color:var(--spot-recommended-tag-font-color);font-size:var(--spot-recommended-tag-font-size);font-weight:var(--spot-recommended-tag-font-weight);padding:var(--spot-recommended-tag-padding);border-radius:var(--spot-recommended-tag-border-radius);margin-left:.75rem;white-space:nowrap;flex-shrink:0}@media (max-width: 850px){.spot-selection__recommended-tag{margin-left:.5rem}}@media (max-width: 600px){.spot-selection__recommended-tag{margin-left:.5rem;font-size:.75rem;padding:.1875rem .4375rem}}.spot-selection__error{color:var(--spot-selection-error-font-color);font-size:var(--spot-selection-error-font-size);padding:var(--spot-selection-error-padding);display:none}.spot-selection__options--disabled .spot-selection__option{opacity:.4;cursor:not-allowed;pointer-events:none}.spot-selection__options--disabled input[type=radio]{cursor:not-allowed}.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);color:var(--spot-payment-terms-font-color);font-size:var(--spot-payment-terms-font-size)}.spot-footer__terms{margin-top:.625rem;margin-right:.25rem;font-size:var(--spot-terms-font-size);font-weight:var(--spot-terms-font-weight);color:var(--spot-terms-font-color);font-family:var(--spot-terms-font-family);padding:var(--spot-terms-padding);line-height:1.4;word-wrap:normal;-webkit-hyphens:none;hyphens:none;flex:1;min-width:0;overflow-wrap:normal}.spot-footer__terms-link{text-decoration:var(--spot-terms-link-text-decoration);font-size:var(--spot-terms-link-font-size);font-weight:var(--spot-terms-link-font-weight);color:var(--spot-terms-link-font-color);font-family:var(--spot-terms-link-font-family);padding:var(--spot-terms-link-padding)}.spot-footer__container{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;flex-wrap:nowrap;gap:var(--spot-footer-gap)}@container (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}@media (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}.spot-footer__powered-by{margin-top:0;flex-shrink:0}.spot-logo__top-right{position:absolute;top:-14px;right:40px;z-index:10;background:linear-gradient(to bottom,transparent 50%,inherit 50%);padding:0 .25rem}.spot-logo__top-right svg{border-radius:1.25rem;border:var(--spot-border-line-width) solid var(--spot-border-color);display:block;background:var(--spot-background-color)}@container (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}@media (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}";function G(c){const t=document.createElement("style");t.textContent=c,document.head.appendChild(t)}G(Y);const M={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 K{constructor(t={}){this.options={location:"body",showTable:!0,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t,selection:t.selection??b.UNSELECTED},this._onResize=this._updateLayout.bind(this),this.root=typeof this.options.location=="string"?document.querySelector(this.options.location):this.options.location,this.currentSelection=this.options.selection,this._init()}async _init(){var t,r,s,i,a;try{N(this.options),this.currentState=this.options.state;let e;if(this.options.useMockData&&this.options.mockData)e=this.options.mockData;else{const{environment:o,partnerId:l}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||M[o];e="items"in this.options.quoteRequestData?await D(f,l,this.options.quoteRequestData,this._validState()):await q(f,l,this.options.quoteRequestData,this._validState())}if(e.status!=="QUOTE_AVAILABLE"){e.status==="NO_MATCHING_QUOTE"&&((t=this.options.callbacks)!=null&&t.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=e.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.selection===b.YES&&((r=this.options.callbacks)!=null&&r.onOptIn)){const o={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id,state:this._validState()};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const l=this.options.quoteRequestData;o.batchQuoteDetails=this.quote.originalQuotes.map(m=>{var v;const f=(v=l.items)==null?void 0:v.find(h=>(h.cartItemId||`item-${l.items.indexOf(h)+1}`)===m.cartItemId);return{quoteId:m.id,productPrice:(f==null?void 0:f.productPrice)||m.spotPrice,cartItemId:(f==null?void 0:f.cartItemId)||""}})}this.options.callbacks.onOptIn(o)}if((s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const o=this.options.callbacks.onQuoteRetrieved(this.quote);o&&this._applyQuoteUpdates(o)}}catch(e){if((i=this.options.callbacks)!=null&&i.onError){const o=e;(a=this.options.callbacks)==null||a.onError({message:o.message,status:o.status,responseBody:o.responseBody})}}}_renderWidget(){if(!this.quote)return;this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([e,o])=>{const l=`--${e}`;this.container.style.setProperty(l,o)}),$(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?Q(t,this.quote.qualifyingReasons):V(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const e=this._getTotalItemsInRequest();U(t,this.quote.coveredItems,e)}this.options.showTable&&!this.quote.qualifyingReasons&&B(t,this.quote.payoutSchedule,this.quote.currencyCode);const r=n("div",{className:"spot-selection__wrapper",parent:t});this._isPassOrTrip()&&!this.options.state&&(this._stateSelectEl=j(r,this.currentState));const i=!this._isQuotingAvailable(),a=F(r,this.currentSelection,this.quote.communication,i);this.paymentTermsEl=n("div",{className:"spot-payment-terms__wrapper",parent:t}),this.currentSelection===b.YES&&I(this.paymentTermsEl,this.quote),W(this.container,this.quote,this.options.logoPosition),window.addEventListener("resize",this._onResize),this._setupResizeObserver(),this._updateLayout(),this._setupOptionListeners(a),this._setupStateDropdownListener()}_updateLayout(){if(!this.container||!this.quote)return;const t=this.container.querySelector(".spot-content__wrapper"),r=this.options.showTable&&!this.quote.qualifyingReasons;if(!t||!r){t==null||t.classList.remove("desktop-layout");return}const s=this._shouldUseDesktopLayout(t);t.classList.toggle("desktop-layout",s)}_shouldUseDesktopLayout(t){const r=this.container.offsetWidth-40,s=325,i=16;if(r>=900)return!0;if(r>=650){const a=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const e=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!e)return a&&t.classList.add("desktop-layout"),a;const l=Math.min(e.scrollWidth,400)+s+i;return a&&t.classList.add("desktop-layout"),r>=l}return!1}_setupResizeObserver(){!this.container||!window.ResizeObserver||(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=window.setTimeout(()=>{this._updateLayout()},100)}),this._resizeObserver.observe(this.container))}_getTotalItemsInRequest(){return"items"in this.options.quoteRequestData?this.options.quoteRequestData.items.length:1}_applyQuoteUpdates(t){!this.quote||!this.container||(t.spotPriceWithFees!==void 0&&(this.quote.communication.yesOptionText=this.quote.communication.yesOptionText.replace(`$${this.quote.spotPrice.toFixed(2)}`,`$${t.spotPriceWithFees.toFixed(2)}`)),this.destroy(),this._renderWidget())}_isPassOrTrip(){const t=this.options.quoteRequestData;if(Array.isArray(t))return t.some(s=>s.productType==="Pass"||s.productType==="Trip");if("items"in t)return t.items.some(s=>s.productType==="Pass"||s.productType==="Trip");const r=t;return r.productType==="Pass"||r.productType==="Trip"}_validState(){if(this._isPassOrTrip()&&!(!this.currentState||this.currentState===k))return this.currentState}_isQuotingAvailable(){return!this._isPassOrTrip()||this.options.state?!0:!!this.currentState&&this.currentState!==k}_setRadiosDisabled(t){var i,a,e;const r=(i=this.container)==null?void 0:i.querySelectorAll('input[name="selection"]'),s=(a=this.container)==null?void 0:a.querySelector(".spot-selection__options");r==null||r.forEach(o=>{o.disabled=t}),s==null||s.classList.toggle("spot-selection__options--disabled",t),t&&(r==null||r.forEach(o=>{o.checked=!1}),(e=this.container)==null||e.querySelectorAll(".spot-selection__option").forEach(o=>{o.classList.remove("selected")}),this.currentSelection=b.UNSELECTED,this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""))}_setupStateDropdownListener(){this._stateSelectEl&&this._stateSelectEl.addEventListener("change",()=>{this.currentState=this._stateSelectEl.value,this._setRadiosDisabled(!this._isQuotingAvailable())})}_setupOptionListeners(t){const r=t.querySelectorAll('input[type="radio"]'),s=t.querySelectorAll(".spot-selection__option");r.forEach(i=>{i.addEventListener("change",a=>{var l,m,f,v;const e=a.target,o=e.value;if(this.hideSelectionError(),this.currentSelection=o,s.forEach(h=>h.classList.remove("selected")),(l=e.closest(".spot-selection__option"))==null||l.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),o===b.YES&&((m=this.quote)!=null&&m.communication.paymentTerms&&I(this.paymentTermsEl,this.quote),(f=this.options.callbacks)!=null&&f.onOptIn)){const h={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id,state:this._validState()};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const p=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var w;const d=(w=p.items)==null?void 0:w.find(y=>(y.cartItemId||`item-${p.items.indexOf(y)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(d==null?void 0:d.productPrice)||u.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptIn(h)}if(o===b.NO&&((v=this.options.callbacks)!=null&&v.onOptOut)){const h={status:"QUOTE_DECLINED",quoteId:this.quote.id,state:this._validState()};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const p=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var w;const d=(w=p.items)==null?void 0:w.find(y=>(y.cartItemId||`item-${p.items.indexOf(y)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(d==null?void 0:d.productPrice)||u.spotPrice,cartItemId:(d==null?void 0:d.cartItemId)||""}})}this.options.callbacks.onOptOut(h)}})})}showSelectionError(){var t;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const r=(t=this.container)==null?void 0:t.querySelector(".spot-selection__options");r&&r.insertAdjacentElement("afterend",this.errorEl)}this.errorEl.style.display="block"}hideSelectionError(){this.errorEl&&(this.errorEl.style.display="none")}validateSelection(){if(!this.container)return!1;const t=!!this.container.querySelector('input[name="selection"]:checked');return t?this.hideSelectionError():this.showSelectionError(),t}async updateQuote(t){var r,s,i,a;try{const e={...this.options,quoteRequestData:t};N(e);const{environment:o,partnerId:l,customEndpoint:m}=this.options.apiConfig,f=m||M[o],h="items"in e.quoteRequestData?await D(f,l,e.quoteRequestData,this._validState()):await q(f,l,e.quoteRequestData,this._validState());if(h.status!=="QUOTE_AVAILABLE")return this.destroy(),h.status==="NO_MATCHING_QUOTE"&&((r=this.options.callbacks)!=null&&r.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:e.quoteRequestData}),!1;if(this.options.quoteRequestData=e.quoteRequestData,this.quote=h.data,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const p=this.options.callbacks.onQuoteRetrieved(this.quote);p&&this._applyQuoteUpdates(p)}return!0}catch(e){const o=e;return(a=(i=this.options.callbacks)==null?void 0:i.onError)==null||a.call(i,{message:o.message,status:o.status,responseBody:o.responseBody}),!1}}getSelection(){var r,s,i;if(this.currentSelection==null||this.currentSelection==b.UNSELECTED)return null;const t={selection:this.currentSelection,quoteId:(r=this.quote)==null?void 0:r.id,spotPrice:(s=this.quote)==null?void 0:s.spotPrice,status:this.currentSelection===b.YES?"QUOTE_ACCEPTED":"QUOTE_DECLINED",state:this.currentState};if((i=this.quote)!=null&&i.originalQuotes&&this.quote.originalQuotes.length>0){const a=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(e=>{var l;const o=(l=a.items)==null?void 0:l.find(m=>(m.cartItemId||`item-${a.items.indexOf(m)+1}`)===e.cartItemId);return{quoteId:e.id,productPrice:(o==null?void 0:o.productPrice)||e.spotPrice,cartItemId:(o==null?void 0:o.cartItemId)||""}})}return t}destroy(){window.removeEventListener("resize",this._onResize),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeTimeout&&window.clearTimeout(this._resizeTimeout),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}C.NON_US_RESIDENT_VALUE=k,C.SelectionEnum=b,C.default=K,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getspot/spot-widget",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },