@odynn/awayz-flights 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,42 @@
1
1
  import { jsx as r, jsxs as e } from "react/jsx-runtime";
2
- import O, { useState as d, useMemo as E } from "react";
3
- import { g as f, E as N, F as I, a as M } from "../../FlightItinerary-DgpK1LYF.js";
4
- import { DEFAULT_AIRLINE_PROGRAM as R, getFlightNumber as T, getLogoPath as B, getAirlineProgram as L } from "../../utils/flightUtils.js";
2
+ import k, { useState as d, useMemo as E } from "react";
3
+ import { g as f, E as N, F as I, a as R } from "../../FlightItinerary-DgpK1LYF.js";
4
+ import { DEFAULT_AIRLINE_PROGRAM as T, getFlightNumber as B, getLogoPath as L, getAirlineProgram as $ } from "../../utils/flightUtils.js";
5
5
  import { h as u } from "../../arrayExtensions-DWKenJCh.js";
6
- import { g as $ } from "../../dateUtils-DeNLG5hw.js";
6
+ import { g as x } from "../../dateUtils-DeNLG5hw.js";
7
7
  import { EPaymentType as v } from "../../enums/EPaymentType.js";
8
+ import { CashValue as M } from "@odynn/awayz-core";
8
9
  import '../../assets/FlightResult.css';function b(i) {
9
10
  if (!i || isNaN(i) || i < 0) return "N/A";
10
11
  let n = i == null ? void 0 : i.toString().split(".")[0];
11
12
  return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
12
13
  }
13
- const x = (i, n) => {
14
- if (i <= 0) return "N/A";
15
- var l = new Intl.NumberFormat("en-US", {
16
- style: "currency",
17
- currency: n
18
- });
19
- return i ? l.format(Math.round(i)).toString().split(".")[0] : l.format(0);
20
- }, z = ({ details: i, onClick: n }) => {
21
- const [l, D] = d(!1), o = i.origin, c = i.destination, g = i.flightDetails, S = i.paymentOptions.length === 1, [y, F] = d(R), C = async () => {
22
- const t = await L(i.airlineProgram);
23
- F(t);
24
- }, { flightNumbers: h, airlines: P } = E(() => {
25
- const t = [], a = [];
14
+ const z = ({ details: i, onClick: n }) => {
15
+ const [m, y] = d(!1), l = i.origin, o = i.destination, g = i.flightDetails, C = !i.paymentOptions || i.paymentOptions.length === 1, [D, F] = d(T), S = async () => {
16
+ const a = await $(i.airlineProgram);
17
+ F(a);
18
+ }, { flightNumbers: c, airlines: P } = E(() => {
19
+ const a = [], t = [];
26
20
  return i.flightDetails.slices.forEach((A) => {
27
21
  A.segments.forEach((s) => {
28
- const p = T(s);
29
- t.includes(p) || t.push(p);
30
- const m = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier;
31
- a.some((k) => k.airline === m.name) || a.push({
32
- logo: B(m.iataCode),
33
- airline: m.name
22
+ const p = B(s);
23
+ a.includes(p) || a.push(p);
24
+ const h = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier;
25
+ t.some((O) => O.airline === h.name) || t.push({
26
+ logo: L(h.iataCode),
27
+ airline: h.name
34
28
  });
35
29
  });
36
- }), C(), { flightNumbers: t, airlines: a };
30
+ }), S(), { flightNumbers: a, airlines: t };
37
31
  }, [i.flightDetails.slices]);
38
32
  return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () => n(i), children: /* @__PURE__ */ e("div", { className: "content", children: [
39
33
  /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
40
- /* @__PURE__ */ r("div", { className: "airlines", children: P.map((t, a) => /* @__PURE__ */ r(O.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: t.logo, alt: t.airline }) }, a) }, a)) }),
34
+ /* @__PURE__ */ r("div", { className: "airlines", children: P.map((a, t) => /* @__PURE__ */ r(k.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: a.logo, alt: a.airline }) }, t) }, t)) }),
41
35
  /* @__PURE__ */ e("div", { className: "flight-location", children: [
42
36
  /* @__PURE__ */ e("p", { children: [
43
- o.city,
37
+ l.city,
44
38
  ",",
45
- f(o.country)
39
+ f(l.country)
46
40
  ] }),
47
41
  /* @__PURE__ */ r("p", { children: u(i.departureTime).format(
48
42
  // isMobile
@@ -54,7 +48,7 @@ const x = (i, n) => {
54
48
  /* @__PURE__ */ e("div", { className: "flight-duration", children: [
55
49
  /* @__PURE__ */ r("span", { className: "line" }),
56
50
  /* @__PURE__ */ e("p", { children: [
57
- $(g.slices[0].duration),
51
+ x(g.slices[0].duration),
58
52
  " ",
59
53
  " - ",
60
54
  i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
@@ -63,9 +57,9 @@ const x = (i, n) => {
63
57
  ] }),
64
58
  /* @__PURE__ */ e("div", { children: [
65
59
  /* @__PURE__ */ e("p", { children: [
66
- c.city,
60
+ o.city,
67
61
  ", ",
68
- f(c.country)
62
+ f(o.country)
69
63
  ] }),
70
64
  /* @__PURE__ */ e("p", { children: [
71
65
  u(i.arrivalTime).format(
@@ -84,18 +78,18 @@ const x = (i, n) => {
84
78
  "div",
85
79
  {
86
80
  className: "flight-detail",
87
- onClick: (t) => {
88
- t.stopPropagation(), D(!l);
81
+ onClick: (a) => {
82
+ a.stopPropagation(), y(!m);
89
83
  },
90
84
  children: [
91
85
  /* @__PURE__ */ r("p", { children: "Aircraft" }),
92
86
  /* @__PURE__ */ e("p", { className: "chevron-text", children: [
93
87
  /* @__PURE__ */ r(I, {}),
94
88
  /* @__PURE__ */ e("span", { children: [
95
- h[0],
96
- h.length > 1 && /* @__PURE__ */ e("sup", { children: [
89
+ c[0],
90
+ c.length > 1 && /* @__PURE__ */ e("sup", { children: [
97
91
  "+",
98
- h.length - 1
92
+ c.length - 1
99
93
  ] })
100
94
  ] })
101
95
  ] })
@@ -117,12 +111,18 @@ const x = (i, n) => {
117
111
  "div",
118
112
  {
119
113
  className: "cash-value",
120
- onClick: (t) => {
121
- t.stopPropagation(), n(i, v.CASH);
114
+ onClick: (a) => {
115
+ a.stopPropagation(), n(i, v.CASH);
122
116
  },
123
117
  children: [
124
- /* @__PURE__ */ r("p", { children: S ? "Book For" : "From" }),
125
- /* @__PURE__ */ r("p", { children: x(i.cash, "USD") })
118
+ /* @__PURE__ */ r("p", { children: C ? "Book For" : "From" }),
119
+ /* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
120
+ M,
121
+ {
122
+ amount: i.cash,
123
+ currency: i.currency
124
+ }
125
+ ) })
126
126
  ]
127
127
  }
128
128
  ),
@@ -130,23 +130,23 @@ const x = (i, n) => {
130
130
  "div",
131
131
  {
132
132
  className: "points-value",
133
- onClick: (t) => {
134
- t.stopPropagation(), n(i, v.POINTS);
133
+ onClick: (a) => {
134
+ a.stopPropagation(), n(i, v.POINTS);
135
135
  },
136
136
  children: [
137
- /* @__PURE__ */ r("img", { src: y.programLogo }),
137
+ /* @__PURE__ */ r("img", { src: D.programLogo }),
138
138
  /* @__PURE__ */ r("p", { children: `${b(i.points)} miles` })
139
139
  ]
140
140
  }
141
141
  )
142
142
  ] })
143
143
  ] }),
144
- /* @__PURE__ */ r("div", { className: `flight-details ${l ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
145
- M,
144
+ /* @__PURE__ */ r("div", { className: `flight-details ${m ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
145
+ R,
146
146
  {
147
147
  itinerary: g.slices[0].segments,
148
- origin: o,
149
- destination: c
148
+ origin: l,
149
+ destination: o
150
150
  }
151
151
  ) }) })
152
152
  ] }) });
@@ -1,85 +1,77 @@
1
- import { useContext as B, useState as N, useRef as J } from "react";
1
+ import { useState as N, useRef as K } from "react";
2
2
  import { useMutation as L } from "@tanstack/react-query";
3
- import { ECabinClass as K, EFlightType as $, EFlightPaymentType as k } from "../../types/enums.js";
3
+ import { ECabinClass as Q, EFlightType as J, EFlightPaymentType as k } from "../../types/enums.js";
4
4
  import { FlightService as D } from "../../services/flights/FlightsService.js";
5
- import { parseFlightDetails as Q, groupFlightResults as G, buildFlightSearchQuery as X } from "../../utils/flightUtils.js";
5
+ import { parseFlightDetails as V, groupFlightResults as G, buildFlightSearchQuery as X } from "../../utils/flightUtils.js";
6
6
  import "../../arrayExtensions-DWKenJCh.js";
7
- import { t as Z, c as H, n as ee } from "../../AccountService-BjwUydb_-DRFWL3cC.js";
8
- import te from "../../stores/useFlightStore.js";
9
- import "react/jsx-runtime";
10
- const ne = () => {
11
- const n = B(Z);
12
- if (!n)
13
- throw new Error(
14
- "Awayz Components must be wrapped in an AwayzProvider. Visit https://docs.awayz.com/providers/awayzprovider for more information."
15
- );
16
- return n;
17
- };
18
- async function re(n, t) {
19
- const o = n.getReader();
20
- let r;
21
- for (; !(r = await o.read()).done; )
22
- t(r.value);
7
+ import { c as W } from "../../objectUtils-CyIaVmog.js";
8
+ import Z from "../../stores/useFlightStore.js";
9
+ import { useAwayzContext as ee, getBaseUrl as te } from "@odynn/awayz-core";
10
+ async function ne(o, t) {
11
+ const r = o.getReader();
12
+ let n;
13
+ for (; !(n = await r.read()).done; )
14
+ t(n.value);
23
15
  }
24
- function oe(n) {
25
- let t, o, r, s = !1;
16
+ function re(o) {
17
+ let t, r, n, s = !1;
26
18
  return function(c) {
27
- t === void 0 ? (t = c, o = 0, r = -1) : t = ae(t, c);
19
+ t === void 0 ? (t = c, r = 0, n = -1) : t = se(t, c);
28
20
  const u = t.length;
29
21
  let a = 0;
30
- for (; o < u; ) {
31
- s && (t[o] === 10 && (a = ++o), s = !1);
22
+ for (; r < u; ) {
23
+ s && (t[r] === 10 && (a = ++r), s = !1);
32
24
  let d = -1;
33
- for (; o < u && d === -1; ++o)
34
- switch (t[o]) {
25
+ for (; r < u && d === -1; ++r)
26
+ switch (t[r]) {
35
27
  case 58:
36
- r === -1 && (r = o - a);
28
+ n === -1 && (n = r - a);
37
29
  break;
38
30
  case 13:
39
31
  s = !0;
40
32
  case 10:
41
- d = o;
33
+ d = r;
42
34
  break;
43
35
  }
44
36
  if (d === -1)
45
37
  break;
46
- n(t.subarray(a, d), r), a = o, r = -1;
38
+ o(t.subarray(a, d), n), a = r, n = -1;
47
39
  }
48
- a === u ? t = void 0 : a !== 0 && (t = t.subarray(a), o -= a);
40
+ a === u ? t = void 0 : a !== 0 && (t = t.subarray(a), r -= a);
49
41
  };
50
42
  }
51
- function se(n, t, o) {
52
- let r = M();
43
+ function oe(o, t, r) {
44
+ let n = U();
53
45
  const s = new TextDecoder();
54
46
  return function(c, u) {
55
47
  if (c.length === 0)
56
- o == null || o(r), r = M();
48
+ r == null || r(n), n = U();
57
49
  else if (u > 0) {
58
- const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), b = s.decode(c.subarray(d));
50
+ const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), g = s.decode(c.subarray(d));
59
51
  switch (a) {
60
52
  case "data":
61
- r.data = r.data ? r.data + `
62
- ` + b : b;
53
+ n.data = n.data ? n.data + `
54
+ ` + g : g;
63
55
  break;
64
56
  case "event":
65
- r.event = b;
57
+ n.event = g;
66
58
  break;
67
59
  case "id":
68
- n(r.id = b);
60
+ o(n.id = g);
69
61
  break;
70
62
  case "retry":
71
- const g = parseInt(b, 10);
72
- isNaN(g) || t(r.retry = g);
63
+ const b = parseInt(g, 10);
64
+ isNaN(b) || t(n.retry = b);
73
65
  break;
74
66
  }
75
67
  }
76
68
  };
77
69
  }
78
- function ae(n, t) {
79
- const o = new Uint8Array(n.length + t.length);
80
- return o.set(n), o.set(t, n.length), o;
70
+ function se(o, t) {
71
+ const r = new Uint8Array(o.length + t.length);
72
+ return r.set(o), r.set(t, o.length), r;
81
73
  }
82
- function M() {
74
+ function U() {
83
75
  return {
84
76
  data: "",
85
77
  event: "",
@@ -87,100 +79,102 @@ function M() {
87
79
  retry: void 0
88
80
  };
89
81
  }
90
- var ie = function(n, t) {
91
- var o = {};
92
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (o[r] = n[r]);
93
- if (n != null && typeof Object.getOwnPropertySymbols == "function")
94
- for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
95
- t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (o[r[s]] = n[r[s]]);
96
- return o;
82
+ var ae = function(o, t) {
83
+ var r = {};
84
+ for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && t.indexOf(n) < 0 && (r[n] = o[n]);
85
+ if (o != null && typeof Object.getOwnPropertySymbols == "function")
86
+ for (var s = 0, n = Object.getOwnPropertySymbols(o); s < n.length; s++)
87
+ t.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(o, n[s]) && (r[n[s]] = o[n[s]]);
88
+ return r;
97
89
  };
98
- const j = "text/event-stream", ue = 1e3, z = "last-event-id";
99
- function ce(n, t) {
100
- var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = t, b = ie(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
101
- return new Promise((g, P) => {
102
- const p = Object.assign({}, r);
103
- p.accept || (p.accept = j);
90
+ const x = "text/event-stream", ie = 1e3, z = "last-event-id";
91
+ function ue(o, t) {
92
+ var { signal: r, headers: n, onopen: s, onmessage: v, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = t, g = ae(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
93
+ return new Promise((b, _) => {
94
+ const p = Object.assign({}, n);
95
+ p.accept || (p.accept = x);
104
96
  let m;
105
97
  function w() {
106
- m.abort(), document.hidden || C();
98
+ m.abort(), document.hidden || T();
107
99
  }
108
100
  a || document.addEventListener("visibilitychange", w);
109
- let F = ue, S = 0;
110
- function R() {
111
- document.removeEventListener("visibilitychange", w), window.clearTimeout(S), m.abort();
101
+ let F = ie, E = 0;
102
+ function S() {
103
+ document.removeEventListener("visibilitychange", w), window.clearTimeout(E), m.abort();
112
104
  }
113
- o == null || o.addEventListener("abort", () => {
114
- R(), g();
105
+ r == null || r.addEventListener("abort", () => {
106
+ S(), b();
115
107
  });
116
- const _ = d ?? window.fetch, q = s ?? de;
117
- async function C() {
118
- var T;
108
+ const q = d ?? window.fetch, P = s ?? ce;
109
+ async function T() {
110
+ var C;
119
111
  m = new AbortController();
120
112
  try {
121
- const O = await _(n, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
122
- await q(O), await re(O.body, oe(se((h) => {
113
+ const O = await q(o, Object.assign(Object.assign({}, g), { headers: p, signal: m.signal }));
114
+ await P(O), await ne(O.body, re(oe((h) => {
123
115
  h ? p[z] = h : delete p[z];
124
116
  }, (h) => {
125
117
  F = h;
126
- }, E))), c == null || c(), R(), g();
118
+ }, v))), c == null || c(), S(), b();
127
119
  } catch (O) {
128
120
  if (!m.signal.aborted)
129
121
  try {
130
- const h = (T = u == null ? void 0 : u(O)) !== null && T !== void 0 ? T : F;
131
- window.clearTimeout(S), S = window.setTimeout(C, h);
122
+ const h = (C = u == null ? void 0 : u(O)) !== null && C !== void 0 ? C : F;
123
+ window.clearTimeout(E), E = window.setTimeout(T, h);
132
124
  } catch (h) {
133
- R(), P(h);
125
+ S(), _(h);
134
126
  }
135
127
  }
136
128
  }
137
- C();
129
+ T();
138
130
  });
139
131
  }
140
- function de(n) {
141
- const t = n.headers.get("content-type");
142
- if (!(t != null && t.startsWith(j)))
143
- throw new Error(`Expected content-type to be ${j}, Actual: ${t}`);
132
+ function ce(o) {
133
+ const t = o.headers.get("content-type");
134
+ if (!(t != null && t.startsWith(x)))
135
+ throw new Error(`Expected content-type to be ${x}, Actual: ${t}`);
144
136
  }
145
- const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n) => {
146
- if (!n.origin || !n.destination)
137
+ const B = 1, Y = Q.ECONOMY;
138
+ let j = new AbortController();
139
+ const de = 3 * 60 * 1e3, $ = (o) => {
140
+ if (!o.origin || !o.destination)
147
141
  throw new Error("Origin and destination are required.");
148
- if (!n.departureDate)
142
+ if (!o.departureDate)
149
143
  throw new Error("Departure date is required.");
150
- if (n.flightType === $.ROUND_TRIP && !n.returnDate)
144
+ if (o.flightType === J.ROUND_TRIP && !o.returnDate)
151
145
  throw new Error("Return date is required for round-trip flights.");
152
- }, Se = () => {
153
- const { token: n, config: t } = ne(), [o, r] = N(""), [s, E] = N([]), [c, u] = N(!1), a = J(null), {
146
+ }, Ee = () => {
147
+ const { token: o, config: t } = ee(), [r, n] = N(""), [s, v] = N([]), [c, u] = N(!1), a = K(null), {
154
148
  inboundResults: d,
155
- outboundResults: b,
156
- setInboundResults: g,
157
- setOutboundResults: P,
149
+ outboundResults: g,
150
+ setInboundResults: b,
151
+ setOutboundResults: _,
158
152
  partialOfferRequestId: p,
159
153
  setPartialOfferRequestId: m
160
- } = te(), w = ({
154
+ } = Z(), w = ({
161
155
  data: e,
162
156
  previousResults: l,
163
157
  inbound: f
164
158
  }) => {
165
- const i = Q(e, l);
166
- return (f ? g : P)(G(i)), i;
159
+ const i = V(e, l);
160
+ return (f ? b : _)(G(i)), i;
167
161
  }, {
168
162
  mutate: F,
169
- status: S,
170
- error: R
163
+ status: E,
164
+ error: S
171
165
  } = L({
172
166
  mutationFn: async (e) => {
173
- Y(e);
167
+ $(e);
174
168
  const f = {
175
169
  passengers: Array.from(
176
- { length: e.passengers ?? W },
170
+ { length: e.passengers ?? B },
177
171
  () => ({ type: "adult" })
178
172
  ),
179
173
  origin: e.origin || "",
180
174
  destination: e.destination || "",
181
- cabin_class: e.cabinClass || U
175
+ cabin_class: e.cabinClass || Y
182
176
  };
183
- if (e.flightType === $.ONE_WAY) {
177
+ if (e.flightType === J.ONE_WAY) {
184
178
  const i = await D.cashOnlySearch({
185
179
  ...f,
186
180
  departure_date: e.departureDate
@@ -215,14 +209,14 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
215
209
  console.error("Error in outbound flight search:", e);
216
210
  }
217
211
  }), {
218
- mutate: _,
219
- status: q,
220
- error: C
212
+ mutate: q,
213
+ status: P,
214
+ error: T
221
215
  } = L({
222
216
  mutationFn: async (e) => {
223
217
  if (!p)
224
218
  throw new Error("No partialOfferRequestId found for inbound search.");
225
- return r(e), await D.roundTripInboundSearch({
219
+ return n(e), await D.roundTripInboundSearch({
226
220
  outboundOfferId: e,
227
221
  outboundOfferRequestId: p
228
222
  });
@@ -238,7 +232,7 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
238
232
  console.error("Error in inbound flight search:", e);
239
233
  }
240
234
  }), {
241
- mutate: T,
235
+ mutate: C,
242
236
  status: O,
243
237
  error: h
244
238
  } = L({
@@ -246,7 +240,7 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
246
240
  if (!p)
247
241
  throw new Error("No partialOfferRequestId found for round-trip fares.");
248
242
  return await D.getRoundTripFares({
249
- outboundOfferId: o,
243
+ outboundOfferId: r,
250
244
  outboundOfferRequestId: p,
251
245
  inboundOfferId: e
252
246
  });
@@ -255,61 +249,60 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
255
249
  const { success: l, data: f } = e;
256
250
  if (!l) return;
257
251
  const i = f.offers;
258
- E(H(i));
252
+ v(W(i));
259
253
  },
260
254
  onError: (e) => {
261
255
  console.error("Error in round-trip fare search:", e);
262
256
  }
263
- }), x = async (e) => {
257
+ }), H = async (e) => {
258
+ var M;
264
259
  u(!0);
265
260
  const l = e.paymentType === k.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], f = X({
266
261
  originCode: e.origin,
267
262
  destinationCode: e.destination,
268
263
  departureDate: e.departureDate,
269
- cabinClass: e.cabinClass || U,
270
- passengerCount: e.passengers || W,
264
+ cabinClass: e.cabinClass || Y,
265
+ passengerCount: e.passengers || B,
271
266
  paymentType: l
272
267
  });
273
268
  let i = [], I = 0;
274
- a.current = setTimeout(() => {
275
- v();
276
- }, le), await ce(ee() + f, {
269
+ j = new AbortController(), a.current = setTimeout(() => {
270
+ R();
271
+ }, (((M = t == null ? void 0 : t.flightsConfig) == null ? void 0 : M.streamTimeoutTotalSeconds) || de) * 1e3), ue(te() + f, {
277
272
  headers: {
278
273
  "Content-Type": "application/json",
279
- Authorization: n || "",
274
+ Authorization: o || "",
280
275
  "client-id": (t == null ? void 0 : t.clientId) || ""
281
276
  },
282
277
  openWhenHidden: !0,
283
- signal: V.signal,
278
+ signal: j.signal,
284
279
  onmessage(A) {
285
280
  try {
286
- const y = H(JSON.parse(A.data));
287
- if (y.success === !1) {
288
- v();
281
+ const y = W(JSON.parse(A.data));
282
+ if (y.success === !1)
289
283
  return;
290
- }
291
284
  if (y.close === !0) {
292
- v();
285
+ R();
293
286
  return;
294
287
  }
295
288
  y.flights && (I = 0, i = w({
296
289
  data: y.flights,
297
290
  previousResults: i
298
- })), y.ping && (I++, I >= t.flightsConfig.streamTimeoutPingCount && v());
291
+ })), y.ping && (I++, I >= t.flightsConfig.streamTimeoutPingCount && R());
299
292
  } catch (y) {
300
- console.error("Error parsing message:", y), v();
293
+ console.error("Error parsing message:", y), R();
301
294
  }
302
295
  },
303
296
  onerror(A) {
304
- throw console.error("EventSource error:", A), v(), A;
297
+ throw console.error("EventSource error:", A), R(), A;
305
298
  },
306
299
  onclose() {
307
300
  u(!1);
308
301
  },
309
302
  keepalive: !1
310
303
  });
311
- }, v = () => {
312
- c && (V.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1));
304
+ }, R = () => {
305
+ j.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1);
313
306
  };
314
307
  return {
315
308
  /**
@@ -317,18 +310,18 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
317
310
  * @type {boolean}
318
311
  * @default false
319
312
  */
320
- loading: S === "pending" || q === "pending" || c,
313
+ loading: E === "pending" || P === "pending" || c,
321
314
  /**
322
315
  * Loading status for fares
323
316
  * @type {boolean}
324
317
  * @default false
325
318
  */
326
319
  loadingFares: O === "pending",
327
- outboundError: R,
328
- inboundError: C,
320
+ outboundError: S,
321
+ inboundError: T,
329
322
  roundTripFaresError: h,
330
323
  // Results
331
- outboundResults: b,
324
+ outboundResults: g,
332
325
  inboundResults: d,
333
326
  roundTripFares: s,
334
327
  // Mutation triggers
@@ -339,16 +332,16 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
339
332
  * @param {ISearchFlightArgs} args - The search arguments
340
333
  */
341
334
  searchOutboundFlights: async (e) => {
342
- switch (Y(e), e.paymentType) {
335
+ switch ($(e), e.paymentType) {
343
336
  default:
344
337
  case k.CASH_AND_MILES:
345
- x(e);
338
+ H(e);
346
339
  break;
347
340
  case k.CASH:
348
341
  F(e);
349
342
  break;
350
343
  case k.MILES:
351
- x(e);
344
+ H(e);
352
345
  break;
353
346
  }
354
347
  },
@@ -358,16 +351,16 @@ const W = 1, U = K.ECONOMY, V = new AbortController(), le = 3 * 60 * 1e3, Y = (n
358
351
  *
359
352
  * @param {string} outboundOfferId - The ID of the outbound offer
360
353
  */
361
- searchInboundFlights: _,
354
+ searchInboundFlights: q,
362
355
  /**
363
356
  * Used to get round-trip fares after selecting both outbound and inbound flights
364
357
  * @type {function}
365
358
  *
366
359
  * @param {string} inboundOfferId - The ID of the inbound offer
367
360
  */
368
- getRoundTripFares: T
361
+ getRoundTripFares: C
369
362
  };
370
363
  };
371
364
  export {
372
- Se as useFlightSearch
365
+ Ee as useFlightSearch
373
366
  };
@@ -79,6 +79,7 @@ export interface IFlightPaymentOption {
79
79
  cashFeeAmount: number;
80
80
  baseCurrency: string;
81
81
  fareBrandName: string;
82
+ program: string;
82
83
  baggages?: {
83
84
  type: EBaggage | null;
84
85
  quantity: number;
@@ -110,6 +111,7 @@ export interface IFlightResult {
110
111
  durationMinutes: number;
111
112
  flightDetails: IFlightOffer;
112
113
  paymentOptions: IFlightPaymentOption[];
114
+ currency: string;
113
115
  }
114
116
  export interface IAirportLocation {
115
117
  city: string;
@@ -0,0 +1,10 @@
1
+ function c(e) {
2
+ return e = e.replace(/^_+/, ""), e.replace(/_([a-z])/g, (r, a) => a.toUpperCase());
3
+ }
4
+ const t = (e) => Array.isArray(e) ? e.map((r) => t(r)) : typeof e == "object" && e !== null ? Object.keys(e).reduce((r, a) => {
5
+ const n = c(a);
6
+ return r[n] = t(e[a]), r;
7
+ }, {}) : e;
8
+ export {
9
+ t as c
10
+ };