@odynn/awayz-flights 0.3.9 → 0.3.11

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,7 +1,7 @@
1
1
  import { jsxs as a, jsx as c, Fragment as E } from "react/jsx-runtime";
2
2
  import h, { useMemo as q } from "react";
3
3
  import { h as P } from "./moment-BGjjqtLQ.js";
4
- import { a as $, b as z, d as k, D as J } from "./index-D0Heof44.js";
4
+ import { c as $, a as z, b as k, D as J } from "./index-7zRjF0bU.js";
5
5
  import { l as Q } from "./arrayExtensions-DFLvtO8l.js";
6
6
  import './assets/FlightItinerary.css';const X = (e) => e ? e.charAt(0).toUpperCase() + e.slice(1).toLowerCase() : "", S = (e) => {
7
7
  var t;
@@ -0,0 +1,191 @@
1
+ import { jsx as e, jsxs as a, Fragment as _ } from "react/jsx-runtime";
2
+ import z, { useState as b, useMemo as G } from "react";
3
+ import { g as w, E as m, F as V, a as q } from "./FlightItinerary-VggJiPkC.js";
4
+ import { DEFAULT_AIRLINE_PROGRAM as J, getFlightNumber as K, getLogoPath as E, getAirlineProgram as Q } from "./utils/flightUtils.js";
5
+ import { h } from "./moment-BGjjqtLQ.js";
6
+ import { g as W } from "./index-7zRjF0bU.js";
7
+ import "./arrayExtensions-DFLvtO8l.js";
8
+ import { EPaymentType as p } from "./enums/EPaymentType.js";
9
+ import { CashValue as I, EInvalidAmountDisplayOption as X } from "@odynn/awayz-core";
10
+ import { isSameDayFlight as Y } from "./utils/flightDateUtils.js";
11
+ import './assets/FlightResult.css';function Z(i) {
12
+ if (!i || isNaN(i) || i < 0) return "N/A";
13
+ let n = i == null ? void 0 : i.toString().split(".")[0];
14
+ return n == null ? void 0 : n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
15
+ }
16
+ const mi = ({ details: i, onClick: n }) => {
17
+ var y, C, D, S, O, P, T, k;
18
+ const [N, L] = b(!1), t = i.origin, l = i.destination, u = i.flightDetails, v = i.paymentOptions || [], R = v.filter((r) => r.points === -1).length === 1, B = v.filter((r) => r.points > -1).length === 1, [M, $] = b(J), F = async () => {
19
+ const r = await Q(i.airlineProgram);
20
+ $(r);
21
+ }, { flightNumbers: g, airlines: x } = G(() => {
22
+ const r = [], o = [];
23
+ return i.flightDetails.slices.forEach((U) => {
24
+ U.segments.forEach((d) => {
25
+ const A = K(d);
26
+ r.includes(A) || r.push(A);
27
+ const s = d.marketingCarrier, c = d.operatingCarrier;
28
+ o.some((f) => f.airline === c.name) || o.push({
29
+ logo: E(c.iataCode),
30
+ airline: c.name
31
+ }), s && c.name !== s.name && !o.some((f) => f.airline === s.name) && o.push({
32
+ logo: E(s.iataCode),
33
+ airline: s.name
34
+ });
35
+ });
36
+ }), F(), { flightNumbers: r, airlines: o };
37
+ }, [i.flightDetails.slices, F]), j = () => {
38
+ i.cash > 0 ? n(i, p.CASH) : n(i, p.POINTS);
39
+ }, H = !Y(
40
+ i.departureTime,
41
+ i.arrivalTime
42
+ );
43
+ return /* @__PURE__ */ e("div", { className: "flight-result", onClick: j, children: /* @__PURE__ */ a("div", { className: "content", children: [
44
+ /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ a("div", { className: "flight-locations", children: [
45
+ /* @__PURE__ */ e("div", { className: "airlines", children: x.map((r, o) => /* @__PURE__ */ e(z.Fragment, { children: /* @__PURE__ */ a("div", { className: "tip", children: [
46
+ /* @__PURE__ */ e("img", { src: r.logo, alt: r.airline }),
47
+ /* @__PURE__ */ e("span", { className: "right", children: r.airline })
48
+ ] }, o) }, o)) }),
49
+ /* @__PURE__ */ a("div", { className: "flight-location", children: [
50
+ /* @__PURE__ */ a("p", { className: "show-desktop", children: [
51
+ t.city,
52
+ ",",
53
+ w(t.country)
54
+ ] }),
55
+ /* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
56
+ m.FlightShortDate
57
+ ) }),
58
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: t.airportCode }),
59
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.departureTime).format(m.FlightTime) })
60
+ ] }),
61
+ /* @__PURE__ */ a("div", { className: "flight-duration", children: [
62
+ /* @__PURE__ */ e("span", { className: "line" }),
63
+ /* @__PURE__ */ a("p", { children: [
64
+ W(u.slices[0].duration),
65
+ " ",
66
+ " - ",
67
+ i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
68
+ ] }),
69
+ /* @__PURE__ */ e("span", { className: "line" })
70
+ ] }),
71
+ /* @__PURE__ */ a("div", { children: [
72
+ /* @__PURE__ */ a("p", { className: "show-desktop", children: [
73
+ l.city,
74
+ ", ",
75
+ w(l.country)
76
+ ] }),
77
+ /* @__PURE__ */ a("p", { className: "show-desktop", children: [
78
+ h(i.arrivalTime).format(
79
+ m.FlightShortDate
80
+ ),
81
+ " "
82
+ ] }),
83
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: l.airportCode }),
84
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.arrivalTime).format(m.FlightTime) })
85
+ ] })
86
+ ] }) }),
87
+ /* @__PURE__ */ a("div", { className: "flight-footer", children: [
88
+ /* @__PURE__ */ a("div", { className: "flight-detail-container", children: [
89
+ /* @__PURE__ */ a(
90
+ "div",
91
+ {
92
+ className: "flight-detail",
93
+ onClick: (r) => {
94
+ r.stopPropagation(), L(!N);
95
+ },
96
+ children: [
97
+ /* @__PURE__ */ e("p", { children: "Aircraft" }),
98
+ /* @__PURE__ */ a("p", { className: "chevron-text", children: [
99
+ /* @__PURE__ */ e(V, {}),
100
+ /* @__PURE__ */ a("span", { children: [
101
+ g[0],
102
+ g.length > 1 && /* @__PURE__ */ a("sup", { children: [
103
+ "+",
104
+ g.length - 1
105
+ ] })
106
+ ] })
107
+ ] })
108
+ ]
109
+ }
110
+ ),
111
+ i.cabinClass && /* @__PURE__ */ a("div", { className: "flight-detail", children: [
112
+ /* @__PURE__ */ e("p", { children: "Class" }),
113
+ /* @__PURE__ */ e("p", { children: i.cabinClass })
114
+ ] })
115
+ ] }),
116
+ /* @__PURE__ */ a("div", { className: "booking-options", children: [
117
+ i.cash > 0 && /* @__PURE__ */ a(
118
+ "div",
119
+ {
120
+ className: "cash-value",
121
+ onClick: (r) => {
122
+ r.stopPropagation(), n(i, p.CASH);
123
+ },
124
+ children: [
125
+ /* @__PURE__ */ e("img", { src: i.airlineLogo }),
126
+ /* @__PURE__ */ a("div", { children: [
127
+ /* @__PURE__ */ e("label", { children: R ? "Book For" : "From" }),
128
+ /* @__PURE__ */ e(
129
+ I,
130
+ {
131
+ amount: i.cash,
132
+ currency: i.currency
133
+ }
134
+ )
135
+ ] })
136
+ ]
137
+ }
138
+ ),
139
+ i.points > 0 && /* @__PURE__ */ a(
140
+ "div",
141
+ {
142
+ className: "points-value",
143
+ onClick: (r) => {
144
+ r.stopPropagation(), n(i, p.POINTS);
145
+ },
146
+ children: [
147
+ /* @__PURE__ */ e("img", { src: M.programLogo }),
148
+ /* @__PURE__ */ a("div", { children: [
149
+ /* @__PURE__ */ e("label", { children: B ? "Book For" : "From" }),
150
+ /* @__PURE__ */ a("p", { children: [
151
+ `${Z(i.points)} miles`,
152
+ ((y = i.cashFee) == null ? void 0 : y.amount) > 0 || (((S = (D = (C = i.paymentOptions) == null ? void 0 : C.find(
153
+ (r) => r.points > -1
154
+ )) == null ? void 0 : D.cashFee) == null ? void 0 : S.amount) ?? 0) > 0 && /* @__PURE__ */ a(_, { children: [
155
+ " + ",
156
+ /* @__PURE__ */ e(
157
+ I,
158
+ {
159
+ amount: ((P = (O = i.paymentOptions.find(
160
+ (r) => r.points > -1
161
+ )) == null ? void 0 : O.cashFee) == null ? void 0 : P.amount) ?? 0,
162
+ currency: ((k = (T = i.paymentOptions.find(
163
+ (r) => r.points > -1
164
+ )) == null ? void 0 : T.cashFee) == null ? void 0 : k.currency) ?? "",
165
+ customDisplay: "No fee",
166
+ zeroDisplayOption: X.CUSTOM
167
+ }
168
+ )
169
+ ] })
170
+ ] })
171
+ ] })
172
+ ]
173
+ }
174
+ )
175
+ ] })
176
+ ] }),
177
+ /* @__PURE__ */ e("div", { className: `flight-details ${N ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
178
+ q,
179
+ {
180
+ itinerary: u.slices[0].segments,
181
+ origin: t,
182
+ destination: l,
183
+ isMultiDayFlight: H
184
+ }
185
+ ) }) })
186
+ ] }) });
187
+ };
188
+ export {
189
+ mi as F,
190
+ Z as c
191
+ };
@@ -1,8 +1,8 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../moment-BGjjqtLQ.js";
4
- import { a as e } from "../../FlightItinerary-B_uX-d7I.js";
5
- import "../../index-D0Heof44.js";
4
+ import { a as e } from "../../FlightItinerary-VggJiPkC.js";
5
+ import "../../index-7zRjF0bU.js";
6
6
  import "../../arrayExtensions-DFLvtO8l.js";
7
7
  export {
8
8
  e as default
@@ -1,187 +1,14 @@
1
- import { jsx as e, jsxs as a, Fragment as H } from "react/jsx-runtime";
2
- import U, { useState as T, useMemo as _ } from "react";
3
- import { g as k, E as c, F as z, a as G } from "../../FlightItinerary-B_uX-d7I.js";
4
- import { DEFAULT_AIRLINE_PROGRAM as V, getFlightNumber as q, getLogoPath as J, getAirlineProgram as K } from "../../utils/flightUtils.js";
5
- import { h } from "../../moment-BGjjqtLQ.js";
6
- import { g as Q } from "../../index-D0Heof44.js";
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import { F as g } from "../../FlightResult-BOleEzLV.js";
4
+ import "../../FlightItinerary-VggJiPkC.js";
5
+ import "../../utils/flightUtils.js";
6
+ import "../../moment-BGjjqtLQ.js";
7
+ import "../../index-7zRjF0bU.js";
7
8
  import "../../arrayExtensions-DFLvtO8l.js";
8
- import { EPaymentType as m } from "../../enums/EPaymentType.js";
9
- import { CashValue as A, EInvalidAmountDisplayOption as W } from "@odynn/awayz-core";
10
- import { isSameDayFlight as X } from "../../utils/flightDateUtils.js";
11
- import '../../assets/FlightResult.css';function Y(i) {
12
- if (!i || isNaN(i) || i < 0) return "N/A";
13
- let o = i == null ? void 0 : i.toString().split(".")[0];
14
- return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
15
- }
16
- const ci = ({ details: i, onClick: o }) => {
17
- var u, v, F, y, C, D, S, O;
18
- const [d, b] = T(!1), s = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], w = N.filter((r) => r.points === -1).length === 1, E = N.filter((r) => r.points > -1).length === 1, [I, L] = T(V), R = async () => {
19
- const r = await K(i.airlineProgram);
20
- L(r);
21
- }, { flightNumbers: p, airlines: B } = _(() => {
22
- const r = [], n = [];
23
- return i.flightDetails.slices.forEach((x) => {
24
- x.segments.forEach((l) => {
25
- const P = q(l);
26
- r.includes(P) || r.push(P);
27
- const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
28
- n.some((j) => j.airline === g.name) || n.push({
29
- logo: J(g.iataCode),
30
- airline: g.name
31
- });
32
- });
33
- }), R(), { flightNumbers: r, airlines: n };
34
- }, [i.flightDetails.slices]), M = () => {
35
- i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
36
- }, $ = !X(
37
- i.departureTime,
38
- i.arrivalTime
39
- );
40
- return /* @__PURE__ */ e("div", { className: "flight-result", onClick: M, children: /* @__PURE__ */ a("div", { className: "content", children: [
41
- /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ a("div", { className: "flight-locations", children: [
42
- /* @__PURE__ */ e("div", { className: "airlines", children: B.map((r, n) => /* @__PURE__ */ e(U.Fragment, { children: /* @__PURE__ */ a("div", { className: "tip", children: [
43
- /* @__PURE__ */ e("img", { src: r.logo, alt: r.airline }),
44
- /* @__PURE__ */ e("span", { className: "right", children: r.airline })
45
- ] }, n) }, n)) }),
46
- /* @__PURE__ */ a("div", { className: "flight-location", children: [
47
- /* @__PURE__ */ a("p", { className: "show-desktop", children: [
48
- s.city,
49
- ",",
50
- k(s.country)
51
- ] }),
52
- /* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
53
- c.FlightShortDate
54
- ) }),
55
- /* @__PURE__ */ e("p", { className: "show-mobile", children: s.airportCode }),
56
- /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.departureTime).format(c.FlightTime) })
57
- ] }),
58
- /* @__PURE__ */ a("div", { className: "flight-duration", children: [
59
- /* @__PURE__ */ e("span", { className: "line" }),
60
- /* @__PURE__ */ a("p", { children: [
61
- Q(f.slices[0].duration),
62
- " ",
63
- " - ",
64
- i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
65
- ] }),
66
- /* @__PURE__ */ e("span", { className: "line" })
67
- ] }),
68
- /* @__PURE__ */ a("div", { children: [
69
- /* @__PURE__ */ a("p", { className: "show-desktop", children: [
70
- t.city,
71
- ", ",
72
- k(t.country)
73
- ] }),
74
- /* @__PURE__ */ a("p", { className: "show-desktop", children: [
75
- h(i.arrivalTime).format(
76
- c.FlightShortDate
77
- ),
78
- " "
79
- ] }),
80
- /* @__PURE__ */ e("p", { className: "show-mobile", children: t.airportCode }),
81
- /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.arrivalTime).format(c.FlightTime) })
82
- ] })
83
- ] }) }),
84
- /* @__PURE__ */ a("div", { className: "flight-footer", children: [
85
- /* @__PURE__ */ a("div", { className: "flight-detail-container", children: [
86
- /* @__PURE__ */ a(
87
- "div",
88
- {
89
- className: "flight-detail",
90
- onClick: (r) => {
91
- r.stopPropagation(), b(!d);
92
- },
93
- children: [
94
- /* @__PURE__ */ e("p", { children: "Aircraft" }),
95
- /* @__PURE__ */ a("p", { className: "chevron-text", children: [
96
- /* @__PURE__ */ e(z, {}),
97
- /* @__PURE__ */ a("span", { children: [
98
- p[0],
99
- p.length > 1 && /* @__PURE__ */ a("sup", { children: [
100
- "+",
101
- p.length - 1
102
- ] })
103
- ] })
104
- ] })
105
- ]
106
- }
107
- ),
108
- i.cabinClass && /* @__PURE__ */ a("div", { className: "flight-detail", children: [
109
- /* @__PURE__ */ e("p", { children: "Class" }),
110
- /* @__PURE__ */ e("p", { children: i.cabinClass })
111
- ] })
112
- ] }),
113
- /* @__PURE__ */ a("div", { className: "booking-options", children: [
114
- i.cash > 0 && /* @__PURE__ */ a(
115
- "div",
116
- {
117
- className: "cash-value",
118
- onClick: (r) => {
119
- r.stopPropagation(), o(i, m.CASH);
120
- },
121
- children: [
122
- /* @__PURE__ */ e("img", { src: i.airlineLogo }),
123
- /* @__PURE__ */ a("div", { children: [
124
- /* @__PURE__ */ e("label", { children: w ? "Book For" : "From" }),
125
- /* @__PURE__ */ e(
126
- A,
127
- {
128
- amount: i.cash,
129
- currency: i.currency
130
- }
131
- )
132
- ] })
133
- ]
134
- }
135
- ),
136
- i.points > 0 && /* @__PURE__ */ a(
137
- "div",
138
- {
139
- className: "points-value",
140
- onClick: (r) => {
141
- r.stopPropagation(), o(i, m.POINTS);
142
- },
143
- children: [
144
- /* @__PURE__ */ e("img", { src: I.programLogo }),
145
- /* @__PURE__ */ a("div", { children: [
146
- /* @__PURE__ */ e("label", { children: E ? "Book For" : "From" }),
147
- /* @__PURE__ */ a("p", { children: [
148
- `${Y(i.points)} miles`,
149
- ((u = i.cashFee) == null ? void 0 : u.amount) > 0 || (((y = (F = (v = i.paymentOptions) == null ? void 0 : v.find(
150
- (r) => r.points > -1
151
- )) == null ? void 0 : F.cashFee) == null ? void 0 : y.amount) ?? 0) > 0 && /* @__PURE__ */ a(H, { children: [
152
- " + ",
153
- /* @__PURE__ */ e(
154
- A,
155
- {
156
- amount: ((D = (C = i.paymentOptions.find(
157
- (r) => r.points > -1
158
- )) == null ? void 0 : C.cashFee) == null ? void 0 : D.amount) ?? 0,
159
- currency: ((O = (S = i.paymentOptions.find(
160
- (r) => r.points > -1
161
- )) == null ? void 0 : S.cashFee) == null ? void 0 : O.currency) ?? "",
162
- customDisplay: "No fee",
163
- zeroDisplayOption: W.CUSTOM
164
- }
165
- )
166
- ] })
167
- ] })
168
- ] })
169
- ]
170
- }
171
- )
172
- ] })
173
- ] }),
174
- /* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
175
- G,
176
- {
177
- itinerary: f.slices[0].segments,
178
- origin: s,
179
- destination: t,
180
- isMultiDayFlight: $
181
- }
182
- ) }) })
183
- ] }) });
184
- };
9
+ import "../../enums/EPaymentType.js";
10
+ import "@odynn/awayz-core";
11
+ import "../../utils/flightDateUtils.js";
185
12
  export {
186
- ci as FlightResult
13
+ g as FlightResult
187
14
  };
@@ -1,4 +1,4 @@
1
- import { FlightResult as l } from "./FlightResult/FlightResult.js";
1
+ import { F as l } from "../FlightResult-BOleEzLV.js";
2
2
  export {
3
3
  l as FlightResult
4
4
  };
@@ -1,6 +1,8 @@
1
1
  import { useFlightSearch as o } from "./useFlightSearch/useFlightSearch.js";
2
- import { useAirportSearch as h } from "./useAirportSearch/useAirportSearch.js";
2
+ import { useAirportSearch as a } from "./useAirportSearch/useAirportSearch.js";
3
+ import { EBaggage as p } from "./useFlightSearch/useFlightSearch.types.js";
3
4
  export {
4
- h as useAirportSearch,
5
+ p as EBaggage,
6
+ a as useAirportSearch,
5
7
  o as useFlightSearch
6
8
  };
@@ -1,5 +1,5 @@
1
- import { useState as H, useRef as J } from "react";
2
- import { useMutation as k } from "@tanstack/react-query";
1
+ import { useState as U, useRef as J } from "react";
2
+ import { useMutation as H } from "@tanstack/react-query";
3
3
  import { EFlightType as $, EFlightPaymentType as F } from "../../types/enums.js";
4
4
  import { FlightService as D } from "../../services/flights/FlightsService.js";
5
5
  import { mapDataToFlightDetails as X, groupFlightResults as Z, buildFlightSearchQuery as Q } from "../../utils/flightUtils.js";
@@ -7,9 +7,9 @@ import "../../moment-BGjjqtLQ.js";
7
7
  import "../../arrayExtensions-DFLvtO8l.js";
8
8
  import { c as B } from "../../objectUtils-CyIaVmog.js";
9
9
  import ee from "../../stores/useFlightStore.js";
10
- import { useAwayzContext as te, awayzClient as L, getBaseUrl as ne } from "@odynn/awayz-core";
10
+ import { useAwayzContext as te, awayzClient as P, getBaseUrl as ne } from "@odynn/awayz-core";
11
11
  import { ECabinClass as re } from "../../types/ECabinClass.js";
12
- var y = /* @__PURE__ */ ((e) => (e.LOCATIONS = "LOCATIONS", e.CHECK_USER = "CHECK_USER", e.USER_REGIONS = "USER_REGIONS", e.CONVERT_CURRENCY = "CONVERT_CURRENCY", e.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", e.SEARCH_LIMIT = "SEARCH_LIMIT", e.PROGRAMS = "PROGRAMS", e.BANKS = "BANKS", e.CARDS = "CARDS", e.USER_CARDS = "USER_CARDS", e.TRIPS = "TRIPS", e.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", e.BOOKING = "BOOKING", e))(y || {});
12
+ var y = /* @__PURE__ */ ((e) => (e.LOCATIONS = "LOCATIONS", e.CHECK_USER = "CHECK_USER", e.USER_REGIONS = "USER_REGIONS", e.CONVERT_CURRENCY = "CONVERT_CURRENCY", e.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", e.SEARCH_LIMIT = "SEARCH_LIMIT", e.PROGRAMS = "PROGRAMS", e.USER_PROGRAMS = "USER_PROGRAMS", e.BANKS = "BANKS", e.CARDS = "CARDS", e.USER_CARDS = "USER_CARDS", e.TRIPS = "TRIPS", e.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", e.BOOKING = "BOOKING", e))(y || {});
13
13
  async function oe(e, n) {
14
14
  const o = e.getReader();
15
15
  let r;
@@ -50,21 +50,21 @@ function ae(e, n, o) {
50
50
  if (c.length === 0)
51
51
  o == null || o(r), r = Y();
52
52
  else if (u > 0) {
53
- const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), g = s.decode(c.subarray(d));
53
+ const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), S = s.decode(c.subarray(d));
54
54
  switch (a) {
55
55
  case "data":
56
56
  r.data = r.data ? r.data + `
57
- ` + g : g;
57
+ ` + S : S;
58
58
  break;
59
59
  case "event":
60
- r.event = g;
60
+ r.event = S;
61
61
  break;
62
62
  case "id":
63
- e(r.id = g);
63
+ e(r.id = S);
64
64
  break;
65
65
  case "retry":
66
- const b = parseInt(g, 10);
67
- isNaN(b) || n(r.retry = b);
66
+ const m = parseInt(S, 10);
67
+ isNaN(m) || n(r.retry = m);
68
68
  break;
69
69
  }
70
70
  }
@@ -92,35 +92,35 @@ var ue = function(e, n) {
92
92
  };
93
93
  const G = "text/event-stream", ce = 1e3, W = "last-event-id";
94
94
  function le(e, n) {
95
- var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n, g = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
96
- return new Promise((b, _) => {
95
+ var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n, S = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
96
+ return new Promise((m, _) => {
97
97
  const p = Object.assign({}, r);
98
98
  p.accept || (p.accept = G);
99
- let S;
99
+ let b;
100
100
  function R() {
101
- S.abort(), document.hidden || v();
101
+ b.abort(), document.hidden || v();
102
102
  }
103
103
  a || document.addEventListener("visibilitychange", R);
104
104
  let A = ce, I = 0;
105
105
  function T() {
106
- document.removeEventListener("visibilitychange", R), window.clearTimeout(I), S.abort();
106
+ document.removeEventListener("visibilitychange", R), window.clearTimeout(I), b.abort();
107
107
  }
108
108
  o == null || o.addEventListener("abort", () => {
109
- T(), b();
109
+ T(), m();
110
110
  });
111
- const P = d ?? window.fetch, q = s ?? de;
111
+ const L = d ?? window.fetch, M = s ?? de;
112
112
  async function v() {
113
113
  var w;
114
- S = new AbortController();
114
+ b = new AbortController();
115
115
  try {
116
- const C = await P(e, Object.assign(Object.assign({}, g), { headers: p, signal: S.signal }));
117
- await q(C), await oe(C.body, se(ae((h) => {
116
+ const C = await L(e, Object.assign(Object.assign({}, S), { headers: p, signal: b.signal }));
117
+ await M(C), await oe(C.body, se(ae((h) => {
118
118
  h ? p[W] = h : delete p[W];
119
119
  }, (h) => {
120
120
  A = h;
121
- }, E))), c == null || c(), T(), b();
121
+ }, E))), c == null || c(), T(), m();
122
122
  } catch (C) {
123
- if (!S.signal.aborted)
123
+ if (!b.signal.aborted)
124
124
  try {
125
125
  const h = (w = u == null ? void 0 : u(C)) !== null && w !== void 0 ? w : A;
126
126
  window.clearTimeout(I), I = window.setTimeout(v, h);
@@ -137,9 +137,9 @@ function de(e) {
137
137
  if (!(n != null && n.startsWith(G)))
138
138
  throw new Error(`Expected content-type to be ${G}, Actual: ${n}`);
139
139
  }
140
- const z = 1, K = re.ECONOMY;
141
- let U = new AbortController();
142
- const fe = 3 * 60 * 1e3, V = (e) => {
140
+ const z = 1, V = re.ECONOMY;
141
+ let k = new AbortController();
142
+ const fe = 3 * 60 * 1e3, K = (e) => {
143
143
  if (!e.origin || !e.destination)
144
144
  throw new Error("Origin and destination are required.");
145
145
  if (!e.departureDate)
@@ -147,26 +147,26 @@ const fe = 3 * 60 * 1e3, V = (e) => {
147
147
  if (e.flightType === $.ROUND_TRIP && !e.returnDate)
148
148
  throw new Error("Return date is required for round-trip flights.");
149
149
  }, we = () => {
150
- const { token: e, config: n } = te(), [o, r] = H(""), [s, E] = H([]), [c, u] = H(!1), a = J(null), {
150
+ const { token: e, config: n } = te(), [o, r] = U(""), [s, E] = U([]), [c, u] = U(!1), a = J(null), {
151
151
  inboundResults: d,
152
- outboundResults: g,
153
- setInboundResults: b,
152
+ outboundResults: S,
153
+ setInboundResults: m,
154
154
  setOutboundResults: _,
155
155
  partialOfferRequestId: p,
156
- setPartialOfferRequestId: S
156
+ setPartialOfferRequestId: b
157
157
  } = ee(), R = ({
158
158
  data: t,
159
159
  inbound: f
160
160
  }) => {
161
161
  const l = X(t);
162
- return (f ? b : _)(Z(l)), l;
162
+ return (f ? m : _)(Z(l)), l;
163
163
  }, {
164
164
  mutate: A,
165
165
  status: I,
166
166
  error: T
167
- } = k({
167
+ } = H({
168
168
  mutationFn: async (t) => {
169
- V(t);
169
+ K(t);
170
170
  const l = {
171
171
  passengers: Array.from(
172
172
  { length: t.passengers ?? z },
@@ -174,7 +174,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
174
174
  ),
175
175
  origin: t.origin || "",
176
176
  destination: t.destination || "",
177
- cabin_class: t.cabinClass ?? K
177
+ cabin_class: t.cabinClass ?? V
178
178
  };
179
179
  if (t.flightType === $.ONE_WAY) {
180
180
  const i = await D.cashOnlySearch({
@@ -204,19 +204,19 @@ const fe = 3 * 60 * 1e3, V = (e) => {
204
204
  console.log("oh lol, it didn't work");
205
205
  return;
206
206
  }
207
- R({ data: l }), i && S(i);
207
+ R({ data: l }), i && b(i);
208
208
  },
209
209
  onError: (t) => {
210
210
  console.error("Error in outbound flight search:", t);
211
211
  },
212
212
  onSettled: () => {
213
- L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
213
+ P.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
214
214
  }
215
215
  }), {
216
- mutate: P,
217
- status: q,
216
+ mutate: L,
217
+ status: M,
218
218
  error: v
219
- } = k({
219
+ } = H({
220
220
  mutationFn: async (t) => {
221
221
  if (!p)
222
222
  throw new Error("No partialOfferRequestId found for inbound search.");
@@ -236,13 +236,13 @@ const fe = 3 * 60 * 1e3, V = (e) => {
236
236
  console.error("Error in inbound flight search:", t);
237
237
  },
238
238
  onSettled: () => {
239
- L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
239
+ P.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
240
240
  }
241
241
  }), {
242
242
  mutate: w,
243
243
  status: C,
244
244
  error: h
245
- } = k({
245
+ } = H({
246
246
  mutationFn: async (t) => {
247
247
  if (!p)
248
248
  throw new Error("No partialOfferRequestId found for round-trip fares.");
@@ -262,7 +262,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
262
262
  console.error("Error in round-trip fare search:", t);
263
263
  },
264
264
  onSettled: () => {
265
- L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
265
+ P.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
266
266
  }
267
267
  }), j = async (t) => {
268
268
  var x;
@@ -271,12 +271,12 @@ const fe = 3 * 60 * 1e3, V = (e) => {
271
271
  originCode: t.origin,
272
272
  destinationCode: t.destination,
273
273
  departureDate: t.departureDate,
274
- cabinClass: t.cabinClass ?? K,
274
+ cabinClass: t.cabinClass ?? V,
275
275
  passengerCount: t.passengers ?? z,
276
276
  paymentType: f
277
277
  });
278
- let i = [], M = 0;
279
- U = new AbortController(), a.current = setTimeout(() => {
278
+ let i = [], q = 0;
279
+ k = new AbortController(), a.current = setTimeout(() => {
280
280
  O();
281
281
  }, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) ?? fe) * 1e3), le(ne() + l, {
282
282
  headers: {
@@ -285,19 +285,19 @@ const fe = 3 * 60 * 1e3, V = (e) => {
285
285
  "client-id": (n == null ? void 0 : n.clientId) ?? ""
286
286
  },
287
287
  openWhenHidden: !0,
288
- signal: U.signal,
288
+ signal: k.signal,
289
289
  onmessage(N) {
290
290
  try {
291
- const m = B(JSON.parse(N.data));
292
- if (m.success === !1)
291
+ const g = B(JSON.parse(N.data));
292
+ if (g.success === !1)
293
293
  return;
294
- if (m.close === !0) {
294
+ if (g.close === !0) {
295
295
  O();
296
296
  return;
297
297
  }
298
- m.status === 200 && m.flights && m.flights.length > 0 && (M = 0, i = [...i, ...m.flights], R({ data: i })), m.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && O());
299
- } catch (m) {
300
- console.error("Error parsing message:", m), O();
298
+ g.status === 200 && g.flights && g.flights.length > 0 && (q = 0, i = [...i, ...g.flights], R({ data: i })), g.ping && (q++, q >= n.flightsConfig.streamTimeoutPingCount && O());
299
+ } catch (g) {
300
+ console.error("Error parsing message:", g), O();
301
301
  }
302
302
  },
303
303
  onerror(N) {
@@ -309,7 +309,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
309
309
  keepalive: !1
310
310
  });
311
311
  }, O = () => {
312
- U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
312
+ k.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), P.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
313
313
  };
314
314
  return {
315
315
  /**
@@ -317,7 +317,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
317
317
  * @type {boolean}
318
318
  * @default false
319
319
  */
320
- loading: I === "pending" || q === "pending" || c,
320
+ loading: I === "pending" || M === "pending" || c,
321
321
  /**
322
322
  * Loading status for fares
323
323
  * @type {boolean}
@@ -328,7 +328,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
328
328
  inboundError: v,
329
329
  roundTripFaresError: h,
330
330
  // Results
331
- outboundResults: g,
331
+ outboundResults: S,
332
332
  inboundResults: d,
333
333
  roundTripFares: s,
334
334
  // Mutation triggers
@@ -339,7 +339,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
339
339
  * @param {ISearchFlightArgs} args - The search arguments
340
340
  */
341
341
  searchOutboundFlights: async (t) => {
342
- switch (V(t), _([]), O(), t.paymentType) {
342
+ switch (K(t), _([]), O(), t.paymentType) {
343
343
  case F.CASH_AND_MILES:
344
344
  j(t);
345
345
  break;
@@ -357,7 +357,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
357
357
  *
358
358
  * @param {string} outboundOfferId - The ID of the outbound offer
359
359
  */
360
- searchInboundFlights: P,
360
+ searchInboundFlights: L,
361
361
  /**
362
362
  * Used to get round-trip fares after selecting both outbound and inbound flights
363
363
  * @type {function}
@@ -50,9 +50,9 @@ const $ = (n, s) => {
50
50
  }, D = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
51
51
  export {
52
52
  D,
53
- T as a,
54
- $ as b,
55
- p as c,
56
- M as d,
53
+ $ as a,
54
+ M as b,
55
+ T as c,
56
+ p as d,
57
57
  g
58
58
  };
@@ -1,3 +1,4 @@
1
1
  export * from './useFlightSearch/useFlightSearch';
2
2
  export * from './useAirportSearch/useAirportSearch';
3
- export type { IFlightResult, IFlightOffer, IFlightDetails, EBaggage, IAirportLocation } from './useFlightSearch/useFlightSearch.types';
3
+ export type { IFlightResult, IFlightOffer, IFlightDetails, IAirportLocation } from './useFlightSearch/useFlightSearch.types';
4
+ export { EBaggage } from './useFlightSearch/useFlightSearch.types';
@@ -1,4 +1,4 @@
1
- import { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats } from '@type-op/shared';
1
+ import { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats, DUFFEL_ASSET_PATH } from '@type-op/shared';
2
2
  export * from './hooks';
3
3
  export * from './components';
4
4
  export * from './enums';
@@ -7,4 +7,5 @@ export { getLogoPath, getFlightNumber } from './utils/flightUtils';
7
7
  export { isSameDayFlight } from './utils/flightDateUtils';
8
8
  export { EFlightPaymentType, EFlightType } from './types/enums';
9
9
  export { ECabinClass, getCabinClassLabel, getCabinClassList } from './types/ECabinClass';
10
- export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats };
10
+ export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, DUFFEL_ASSET_PATH };
11
+ export { commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats };
package/dist/main.js CHANGED
@@ -1,24 +1,37 @@
1
- import { useFlightSearch as r } from "./hooks/useFlightSearch/useFlightSearch.js";
2
- import { useAirportSearch as a } from "./hooks/useAirportSearch/useAirportSearch.js";
3
- import { FlightResult as g } from "./components/FlightResult/FlightResult.js";
4
- import { EPaymentType as l } from "./enums/EPaymentType.js";
5
- import { DEFAULT_AIRLINE_PROGRAM as s, getAirlineProgram as h, getFlightNumber as f, getLogoPath as x } from "./utils/flightUtils.js";
6
- import { isSameDayFlight as n } from "./utils/flightDateUtils.js";
7
- import { EFlightPaymentType as C, EFlightType as E } from "./types/enums.js";
8
- import { ECabinClass as A, getCabinClassLabel as L, getCabinClassList as P } from "./types/ECabinClass.js";
1
+ import { useFlightSearch as o } from "./hooks/useFlightSearch/useFlightSearch.js";
2
+ import { useAirportSearch as g } from "./hooks/useAirportSearch/useAirportSearch.js";
3
+ import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
+ import { F as f, c as l } from "./FlightResult-BOleEzLV.js";
5
+ import { EPaymentType as x } from "./enums/EPaymentType.js";
6
+ import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
7
+ import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
8
+ import { EFlightPaymentType as T, EFlightType as A } from "./types/enums.js";
9
+ import { ECabinClass as L, getCabinClassLabel as P, getCabinClassList as S } from "./types/ECabinClass.js";
10
+ import { c as R, g as d, b as O, a as B } from "./index-7zRjF0bU.js";
11
+ import { E as _, g as z } from "./FlightItinerary-VggJiPkC.js";
12
+ import "./arrayExtensions-DFLvtO8l.js";
13
+ import "react";
9
14
  export {
10
- s as DEFAULT_AIRLINE_PROGRAM,
11
- A as ECabinClass,
12
- C as EFlightPaymentType,
13
- E as EFlightType,
14
- l as EPaymentType,
15
- g as FlightResult,
16
- h as getAirlineProgram,
17
- L as getCabinClassLabel,
18
- P as getCabinClassList,
19
- f as getFlightNumber,
20
- x as getLogoPath,
21
- n as isSameDayFlight,
22
- a as useAirportSearch,
23
- r as useFlightSearch
15
+ C as DEFAULT_AIRLINE_PROGRAM,
16
+ s as EBaggage,
17
+ L as ECabinClass,
18
+ _ as EDateFormats,
19
+ T as EFlightPaymentType,
20
+ A as EFlightType,
21
+ x as EPaymentType,
22
+ f as FlightResult,
23
+ R as calculateTimeDifference,
24
+ l as commaSeparatedNumber,
25
+ E as getAirlineProgram,
26
+ P as getCabinClassLabel,
27
+ S as getCabinClassList,
28
+ z as getCountryNameByCode,
29
+ d as getDuration,
30
+ F as getFlightNumber,
31
+ c as getLogoPath,
32
+ O as getTimeString,
33
+ B as getTimezoneOffsetOrCode,
34
+ y as isSameDayFlight,
35
+ g as useAirportSearch,
36
+ o as useFlightSearch
24
37
  };
@@ -1,6 +1,6 @@
1
1
  import { mapBaggageType as Q } from "../hooks/useFlightSearch/useFlightSearch.types.js";
2
2
  import { h as g } from "../moment-BGjjqtLQ.js";
3
- import { c as K, D as V } from "../index-D0Heof44.js";
3
+ import { d as K, D as V } from "../index-7zRjF0bU.js";
4
4
  import "../arrayExtensions-DFLvtO8l.js";
5
5
  import "react";
6
6
  import { awayzClient as Y } from "@odynn/awayz-core";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"