@odynn/awayz-flights 0.1.2 → 0.1.4

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.
@@ -0,0 +1,376 @@
1
+ import { jsxs as a, jsx as c, Fragment as B } from "react/jsx-runtime";
2
+ import d, { useMemo as k } from "react";
3
+ import { l as G, h as y } from "./arrayExtensions-DWKenJCh.js";
4
+ import { ECabinClass as I } from "./types/enums.js";
5
+ import { a as E, b as V, d as P } from "./dateUtils-DeNLG5hw.js";
6
+ import { DUFFEL_ASSET_PATH as K } from "./constants/constants.js";
7
+ import './assets/FlightItinerary.css';const x = (e) => {
8
+ var t;
9
+ if (!e) return "";
10
+ try {
11
+ return (t = G.byIso(e)) == null ? void 0 : t.country;
12
+ } catch (r) {
13
+ return console.error(r), "";
14
+ }
15
+ };
16
+ var D = /* @__PURE__ */ ((e) => (e.USStringDateFormat = "MMM DD, YYYY", e.USStringDateTimeFormat = "MMM DD, YYYY, h:mm A (z)", e.FlightShortDate = "MMM DD - h:mm A", e.FlightTime = "h:mm A", e.DateFormat = "MM/DD", e.StringDateFormat = "MMM DD", e.FullDateFormat = "MM/DD/YYYY", e.ServerDate = "YYYY-MM-DD", e.GoogleDateFormat = "YYYYMMDDTHHmmssZ", e.AppleDateFormat = "YYYYMMDDTHHmmss", e.USStringDateWithTimeFormat = "MMM DD, YYYY, h:mm A", e))(D || {}), U = {
17
+ color: void 0,
18
+ size: void 0,
19
+ className: void 0,
20
+ style: void 0,
21
+ attr: void 0
22
+ }, z = d.createContext && /* @__PURE__ */ d.createContext(U), q = ["attr", "size", "title"];
23
+ function J(e, t) {
24
+ if (e == null) return {};
25
+ var r = Q(e, t), i, o;
26
+ if (Object.getOwnPropertySymbols) {
27
+ var m = Object.getOwnPropertySymbols(e);
28
+ for (o = 0; o < m.length; o++)
29
+ i = m[o], !(t.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(e, i) && (r[i] = e[i]);
30
+ }
31
+ return r;
32
+ }
33
+ function Q(e, t) {
34
+ if (e == null) return {};
35
+ var r = {};
36
+ for (var i in e)
37
+ if (Object.prototype.hasOwnProperty.call(e, i)) {
38
+ if (t.indexOf(i) >= 0) continue;
39
+ r[i] = e[i];
40
+ }
41
+ return r;
42
+ }
43
+ function A() {
44
+ return A = Object.assign ? Object.assign.bind() : function(e) {
45
+ for (var t = 1; t < arguments.length; t++) {
46
+ var r = arguments[t];
47
+ for (var i in r)
48
+ Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
49
+ }
50
+ return e;
51
+ }, A.apply(this, arguments);
52
+ }
53
+ function _(e, t) {
54
+ var r = Object.keys(e);
55
+ if (Object.getOwnPropertySymbols) {
56
+ var i = Object.getOwnPropertySymbols(e);
57
+ t && (i = i.filter(function(o) {
58
+ return Object.getOwnPropertyDescriptor(e, o).enumerable;
59
+ })), r.push.apply(r, i);
60
+ }
61
+ return r;
62
+ }
63
+ function S(e) {
64
+ for (var t = 1; t < arguments.length; t++) {
65
+ var r = arguments[t] != null ? arguments[t] : {};
66
+ t % 2 ? _(Object(r), !0).forEach(function(i) {
67
+ X(e, i, r[i]);
68
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : _(Object(r)).forEach(function(i) {
69
+ Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i));
70
+ });
71
+ }
72
+ return e;
73
+ }
74
+ function X(e, t, r) {
75
+ return t = R(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
76
+ }
77
+ function R(e) {
78
+ var t = ee(e, "string");
79
+ return typeof t == "symbol" ? t : t + "";
80
+ }
81
+ function ee(e, t) {
82
+ if (typeof e != "object" || !e) return e;
83
+ var r = e[Symbol.toPrimitive];
84
+ if (r !== void 0) {
85
+ var i = r.call(e, t || "default");
86
+ if (typeof i != "object") return i;
87
+ throw new TypeError("@@toPrimitive must return a primitive value.");
88
+ }
89
+ return (t === "string" ? String : Number)(e);
90
+ }
91
+ function W(e) {
92
+ return e && e.map((t, r) => /* @__PURE__ */ d.createElement(t.tag, S({
93
+ key: r
94
+ }, t.attr), W(t.child)));
95
+ }
96
+ function Z(e) {
97
+ return (t) => /* @__PURE__ */ d.createElement(te, A({
98
+ attr: S({}, e.attr)
99
+ }, t), W(e.child));
100
+ }
101
+ function te(e) {
102
+ var t = (r) => {
103
+ var {
104
+ attr: i,
105
+ size: o,
106
+ title: m
107
+ } = e, p = J(e, q), u = o || r.size || "1em", l;
108
+ return r.className && (l = r.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */ d.createElement("svg", A({
109
+ stroke: "currentColor",
110
+ fill: "currentColor",
111
+ strokeWidth: "0"
112
+ }, r.attr, i, p, {
113
+ className: l,
114
+ style: S(S({
115
+ color: e.color || r.color
116
+ }, r.style), e.style),
117
+ height: u,
118
+ width: u,
119
+ xmlns: "http://www.w3.org/2000/svg"
120
+ }), m && /* @__PURE__ */ d.createElement("title", null, m), e.children);
121
+ };
122
+ return z !== void 0 ? /* @__PURE__ */ d.createElement(z.Consumer, null, (r) => t(r)) : t(U);
123
+ }
124
+ function $(e) {
125
+ return Z({ tag: "svg", attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" }, child: [] }] })(e);
126
+ }
127
+ function me(e) {
128
+ return Z({ tag: "svg", attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z" }, child: [] }] })(e);
129
+ }
130
+ function re(e) {
131
+ return Z({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z" }, child: [] }] })(e);
132
+ }
133
+ const se = ({
134
+ itinerary: e,
135
+ origin: t,
136
+ destination: r,
137
+ onDisableRenderItinerary: i,
138
+ isMultiDayFlight: o
139
+ }) => {
140
+ var u, l, v, N, j, w;
141
+ const m = () => I.ECONOMY, p = k(() => {
142
+ var h, b, O, C, T, M, Y;
143
+ const n = [];
144
+ for (let f = 0; f < e.length; f++) {
145
+ const g = e[f], s = e[f + 1];
146
+ if (!s)
147
+ break;
148
+ const F = {
149
+ arrival: {
150
+ airport: (h = g.destination) == null ? void 0 : h.name,
151
+ city: (O = (b = g.destination) == null ? void 0 : b.city) == null ? void 0 : O.name,
152
+ country: "France",
153
+ //getCountryNameByCode(segment.destination?.iata_country_code),
154
+ time: g.arrivingAt,
155
+ // ?? segment.arrival_datetime,
156
+ arrivalTimeZone: g.destination.timeZone
157
+ },
158
+ departure: {
159
+ airport: (C = s.origin) == null ? void 0 : C.name,
160
+ city: (M = (T = s.origin) == null ? void 0 : T.city) == null ? void 0 : M.name,
161
+ country: "France",
162
+ //getCountryNameByCode(segment.destination?.iata_country_code),
163
+ time: s.departingAt,
164
+ // ?? segment.departure_datetime,
165
+ airline: s.operatingCarrier.name,
166
+ airlineCode: s.operatingCarrier.iataCode,
167
+ aircraft: (Y = s.aircraft) == null ? void 0 : Y.name,
168
+ flightNumber: s.operatingCarrierFlightNumber,
169
+ cabin: s.passengers[0].cabinClassMarketingName ?? m(),
170
+ departureTimeZone: s.origin.timeZone
171
+ },
172
+ layoverTime: E({
173
+ // we need to swap around the departure and arrival times
174
+ departureAt: g.arrivingAt,
175
+ departureTimeZone: g.destination.timeZone,
176
+ arrivalAt: s.departingAt,
177
+ arrivalTimeZone: s.origin.timeZone
178
+ })
179
+ };
180
+ F.layoverTime <= 0 && (i == null || i()), n.push(F);
181
+ }
182
+ return n;
183
+ }, [e]);
184
+ return /* @__PURE__ */ a("div", { className: "flight-itinerary", children: [
185
+ /* @__PURE__ */ c(
186
+ H,
187
+ {
188
+ airport: e[0].origin.name,
189
+ city: t.city,
190
+ country: x(t.country),
191
+ departureAt: e[0].departingAt,
192
+ departureTimeZone: e[0].origin.timeZone,
193
+ arrivalAt: e[0].arrivingAt,
194
+ arrivalTimeZone: e[0].destination.timeZone,
195
+ airline: e[0].operatingCarrier.name,
196
+ airlineCode: e[0].operatingCarrier.iataCode,
197
+ aircraft: (u = e[0].aircraft) == null ? void 0 : u.name,
198
+ flightNumber: e[0].operatingCarrierFlightNumber,
199
+ cabin: e[0].passengers[0].cabinClassMarketingName ?? m(),
200
+ isMultiDayFlight: o
201
+ }
202
+ ),
203
+ p.map((n, h) => {
204
+ var b, O, C, T, M, Y, f, g;
205
+ return /* @__PURE__ */ a(d.Fragment, { children: [
206
+ /* @__PURE__ */ c(
207
+ L,
208
+ {
209
+ airport: n.arrival.airport,
210
+ city: n.arrival.city,
211
+ country: n.arrival.country,
212
+ time: n.arrival.time,
213
+ isLayover: !0,
214
+ layoverTime: V(n.layoverTime),
215
+ arrivalTimeZone: P(
216
+ n.arrival.arrivalTimeZone,
217
+ n.arrival.time
218
+ )
219
+ }
220
+ ),
221
+ /* @__PURE__ */ c(
222
+ H,
223
+ {
224
+ airport: (b = n.departure) == null ? void 0 : b.airport,
225
+ city: (O = n.departure) == null ? void 0 : O.city,
226
+ country: (C = n.departure) == null ? void 0 : C.country,
227
+ departureAt: n.departure.time,
228
+ departureTimeZone: n.departure.departureTimeZone,
229
+ arrivalAt: e[h + 1].arrivingAt,
230
+ arrivalTimeZone: e[h + 1].destination.timeZone,
231
+ airline: (T = n.departure) == null ? void 0 : T.airline,
232
+ airlineCode: (M = n.departure) == null ? void 0 : M.airlineCode,
233
+ aircraft: (Y = n.departure) == null ? void 0 : Y.aircraft,
234
+ flightNumber: (f = n.departure) == null ? void 0 : f.flightNumber,
235
+ cabin: (g = n.departure) == null ? void 0 : g.cabin
236
+ }
237
+ )
238
+ ] }, n.departure.flightNumber || h);
239
+ }),
240
+ /* @__PURE__ */ c(
241
+ L,
242
+ {
243
+ airport: (v = (l = e.getLast()) == null ? void 0 : l.destination) == null ? void 0 : v.name,
244
+ city: r.city,
245
+ country: x(r.country),
246
+ time: (N = e.getLast()) == null ? void 0 : N.arrivingAt,
247
+ arrivalTimeZone: P(
248
+ (j = e.getLast()) == null ? void 0 : j.destination.timeZone,
249
+ (w = e.getLast()) == null ? void 0 : w.arrivingAt
250
+ // ?? itinerary.getLast()?.arrival_datetime
251
+ ),
252
+ isMultiDayFlight: o
253
+ }
254
+ )
255
+ ] });
256
+ }, H = ({
257
+ airport: e,
258
+ city: t,
259
+ country: r,
260
+ airline: i,
261
+ airlineCode: o,
262
+ flightNumber: m,
263
+ aircraft: p,
264
+ cabin: u,
265
+ departureAt: l,
266
+ departureTimeZone: v,
267
+ arrivalAt: N,
268
+ arrivalTimeZone: j,
269
+ isMultiDayFlight: w
270
+ }) => {
271
+ const n = E({
272
+ departureAt: l,
273
+ departureTimeZone: v,
274
+ arrivalAt: N,
275
+ arrivalTimeZone: j
276
+ });
277
+ return /* @__PURE__ */ a("div", { className: "departure", children: [
278
+ /* @__PURE__ */ a("p", { children: [
279
+ y(l).format(D.FlightTime),
280
+ " ",
281
+ /* @__PURE__ */ a("span", { className: "time-zone", children: [
282
+ "(",
283
+ P(v, l),
284
+ ")"
285
+ ] }),
286
+ /* @__PURE__ */ c("br", {}),
287
+ w ? /* @__PURE__ */ a("div", { className: "travel-time", children: [
288
+ /* @__PURE__ */ c($, {}),
289
+ /* @__PURE__ */ a("span", { children: [
290
+ " ",
291
+ "Departure:",
292
+ " ",
293
+ y(l).format(D.StringDateFormat)
294
+ ] })
295
+ ] }) : /* @__PURE__ */ c(B, {}),
296
+ /* @__PURE__ */ a("div", { className: "travel-time", children: [
297
+ /* @__PURE__ */ c(re, {}),
298
+ /* @__PURE__ */ a("span", { children: [
299
+ "Travel Time: ",
300
+ V(n)
301
+ ] })
302
+ ] })
303
+ ] }),
304
+ /* @__PURE__ */ a("div", { children: [
305
+ /* @__PURE__ */ a("span", { children: [
306
+ e,
307
+ ", ",
308
+ t,
309
+ ", ",
310
+ r
311
+ ] }),
312
+ /* @__PURE__ */ c("img", { src: `${K}${o}.svg`, alt: i }),
313
+ /* @__PURE__ */ a("p", { children: [
314
+ /* @__PURE__ */ c("strong", { children: "Aircraft:" }),
315
+ " ",
316
+ p
317
+ ] }),
318
+ /* @__PURE__ */ a("p", { children: [
319
+ /* @__PURE__ */ c("strong", { children: "Flight:" }),
320
+ " ",
321
+ o,
322
+ " ",
323
+ m
324
+ ] }),
325
+ /* @__PURE__ */ a("p", { children: [
326
+ /* @__PURE__ */ c("strong", { children: "Cabin:" }),
327
+ " ",
328
+ u
329
+ ] })
330
+ ] })
331
+ ] });
332
+ }, L = ({
333
+ airport: e,
334
+ city: t,
335
+ country: r,
336
+ time: i,
337
+ isLayover: o,
338
+ layoverTime: m,
339
+ arrivalTimeZone: p,
340
+ isMultiDayFlight: u
341
+ }) => /* @__PURE__ */ a("div", { className: `arrival ${o ? "layover" : ""}`, children: [
342
+ /* @__PURE__ */ a("p", { children: [
343
+ y(i).format(D.FlightTime),
344
+ " ",
345
+ /* @__PURE__ */ a("span", { className: "time-zone", children: [
346
+ "(",
347
+ p,
348
+ ")"
349
+ ] }),
350
+ u && !o ? /* @__PURE__ */ a("div", { className: "travel-time", children: [
351
+ /* @__PURE__ */ c($, {}),
352
+ /* @__PURE__ */ a("span", { children: [
353
+ "Arrival: ",
354
+ y(i).format(D.StringDateFormat)
355
+ ] })
356
+ ] }) : /* @__PURE__ */ c(B, {})
357
+ ] }),
358
+ /* @__PURE__ */ a("div", { children: [
359
+ /* @__PURE__ */ a("p", { children: [
360
+ o ? "Layover in" : "",
361
+ " ",
362
+ e,
363
+ ", ",
364
+ t,
365
+ ", ",
366
+ r
367
+ ] }),
368
+ /* @__PURE__ */ c("i", { children: o ? m : "" })
369
+ ] })
370
+ ] });
371
+ export {
372
+ D as E,
373
+ me as F,
374
+ se as a,
375
+ x as g
376
+ };
@@ -0,0 +1,99 @@
1
+ var p = Object.defineProperty;
2
+ var d = (t, a, s) => a in t ? p(t, a, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[a] = s;
3
+ var u = (t, a, s) => d(t, typeof a != "symbol" ? a + "" : a, s);
4
+ import "./arrayExtensions-DWKenJCh.js";
5
+ import { EFlightEndpoint as r } from "./constants/endpoints.js";
6
+ import { clientInstance as m } from "@odynn/awayz-auth";
7
+ function g(t) {
8
+ return t = t.replace(/^_+/, ""), t.replace(/_([a-z])/g, (a, s) => s.toUpperCase());
9
+ }
10
+ const o = (t) => Array.isArray(t) ? t.map((a) => o(a)) : typeof t == "object" && t !== null ? Object.keys(t).reduce((a, s) => {
11
+ const n = g(s);
12
+ return a[n] = o(t[s]), a;
13
+ }, {}) : t;
14
+ class l {
15
+ constructor() {
16
+ u(this, "getAirports", async (a) => {
17
+ try {
18
+ const { data: s } = await m.get(
19
+ `${r.GET_AIRPORTS}?search_term=${a}`
20
+ );
21
+ return {
22
+ success: !0,
23
+ data: s.data
24
+ };
25
+ } catch (s) {
26
+ return {
27
+ success: !1,
28
+ data: [],
29
+ message: s == null ? void 0 : s.message
30
+ };
31
+ }
32
+ });
33
+ u(this, "cashOnlySearch", async (a) => {
34
+ var s, n, e, i;
35
+ try {
36
+ const { data: c } = await m.post(
37
+ r.CASH_FLIGHT_SEARCH,
38
+ a
39
+ );
40
+ return c.success ? {
41
+ success: !0,
42
+ data: o(
43
+ c.data.offers
44
+ )
45
+ } : {
46
+ success: !1,
47
+ message: c.message
48
+ };
49
+ } catch (c) {
50
+ return console.error(JSON.stringify(c)), c.message === "canceled" ? {
51
+ success: !1,
52
+ message: ((n = (s = c == null ? void 0 : c.response) == null ? void 0 : s.data) == null ? void 0 : n.message) || (c == null ? void 0 : c.message)
53
+ } : {
54
+ success: !1,
55
+ message: ((i = (e = c == null ? void 0 : c.response) == null ? void 0 : e.data) == null ? void 0 : i.message) || (c == null ? void 0 : c.message)
56
+ };
57
+ }
58
+ });
59
+ u(this, "roundTripOutboundSearch", async (a) => {
60
+ var s, n;
61
+ try {
62
+ const { data: e } = await m.post(
63
+ r.CASH_OUTBOUND_SEARCH,
64
+ { ...a, to: "2025-06-07", from: a.departure_date }
65
+ );
66
+ if (!e.success) throw e;
67
+ return e;
68
+ } catch (e) {
69
+ return {
70
+ success: !1,
71
+ message: ((n = (s = e == null ? void 0 : e.response) == null ? void 0 : s.data) == null ? void 0 : n.message) || (e == null ? void 0 : e.message)
72
+ };
73
+ }
74
+ });
75
+ u(this, "roundTripInboundSearch", async (a) => {
76
+ var s, n;
77
+ try {
78
+ const { data: e } = await m.get(
79
+ r.CASH_INBOUND_SEARCH,
80
+ {
81
+ params: a
82
+ }
83
+ );
84
+ if (!e.success) throw e;
85
+ return e;
86
+ } catch (e) {
87
+ return {
88
+ success: !1,
89
+ message: ((n = (s = e == null ? void 0 : e.response) == null ? void 0 : s.data) == null ? void 0 : n.message) || (e == null ? void 0 : e.message)
90
+ };
91
+ }
92
+ });
93
+ }
94
+ }
95
+ const C = new l();
96
+ export {
97
+ C as F,
98
+ o as c
99
+ };