@odynn/awayz-flights 0.7.14 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,354 @@
1
+ import { jsx as i, jsxs as n, Fragment as I } from "react/jsx-runtime";
2
+ import { useAwayzContext as ce, useFeatureFlags as le, RewardsService as z, EAmountsDisplayFeature as v, CashValue as q, EToolTipPosition as H, ClientPointsValue as me, EInvalidAmountDisplayOption as pe, awayzClient as G, CurrencyService as he } from "@odynn/awayz-core";
3
+ import { useQuery as ge } from "@tanstack/react-query";
4
+ import { g as ue } from "./index-7zRjF0bU.js";
5
+ import { G as fe, g as w, a as F, E as T, F as ye, b as de } from "./FlightItinerary-Dy-2zMYt.js";
6
+ import { E as x } from "./enums-Bmg_7eKJ.js";
7
+ import "./arrayExtensions-DFLvtO8l.js";
8
+ import Ne, { useState as E, useMemo as S, useEffect as R } from "react";
9
+ import { h as p } from "./moment-BGjjqtLQ.js";
10
+ import { useTranslation as Pe } from "react-i18next";
11
+ import { EPaymentType as A } from "./enums/EPaymentType.js";
12
+ import { isSameDayFlight as ve } from "./utils/flightDateUtils.js";
13
+ import { DEFAULT_AIRLINE_PROGRAM as K, getFlightNumber as Fe, getLogoPath as Te, getAirlineProgram as Ee } from "./utils/flightUtils.js";
14
+ import './assets/FlightResult.css';const Ae = (e, s, c = s + "s") => e === 1 ? s : c;
15
+ function Ce(e) {
16
+ if (!e || isNaN(e) || e < 0) return "N/A";
17
+ let s = e == null ? void 0 : e.toString().split(".")[0];
18
+ return s == null ? void 0 : s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19
+ }
20
+ function b(e) {
21
+ return fe({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }, child: [] }] })(e);
22
+ }
23
+ async function Q(e, s, c) {
24
+ if (!e || s === c) return e;
25
+ const a = await G.ensureQueryData({
26
+ queryKey: [x.CONVERT_CURRENCY, s, c],
27
+ staleTime: 1e3 * 60 * 60,
28
+ // 1 hour
29
+ queryFn: () => he.convertCurrency({
30
+ baseCurrency: s,
31
+ targetCurrency: c
32
+ })
33
+ });
34
+ return e * a;
35
+ }
36
+ const ze = ({
37
+ details: e,
38
+ onClick: s,
39
+ showBestValue: c = !1,
40
+ onShowBestValueCalculation: a,
41
+ customStyling: Y = !1,
42
+ customCashComponent: j,
43
+ customPointsComponent: J
44
+ }) => {
45
+ const { t: g } = Pe(), [k, W] = E(!1), [u, X] = E(
46
+ "none"
47
+ /* NONE */
48
+ ), [Z, V] = E(!1), { config: C } = ce(), f = e.origin, y = e.destination, L = e.flightDetails, d = e.paymentOptions || [], { featureFlags: N } = le(), B = d.filter((r) => r.points === -1).length === 1, ee = d.filter((r) => r.points > -1).length === 1, [re, M] = E(K), m = S(() => {
49
+ var r = d.filter((t) => t.points > -1).sort((t, o) => t.points - o.points);
50
+ return r.find(
51
+ (t) => t.program === e.airlineProgram
52
+ ) || r[0];
53
+ }, [d, e.airlineProgram]), ie = async () => {
54
+ if (!m) {
55
+ M(K);
56
+ return;
57
+ }
58
+ const r = await Ee(m.program);
59
+ M(r);
60
+ };
61
+ R(() => {
62
+ ie();
63
+ }, [m]);
64
+ const { flightNumbers: D, airlines: ne } = S(() => {
65
+ const r = [], t = [];
66
+ return e.flightDetails.slices.forEach((o) => {
67
+ o.segments.forEach((l) => {
68
+ const h = Fe(l);
69
+ r.includes(h) || r.push(h);
70
+ const P = l.operatingCarrier;
71
+ t.some((O) => O.airline === P.name) || t.push({
72
+ logo: Te(P.iataCode),
73
+ airline: P.name
74
+ });
75
+ });
76
+ }), { flightNumbers: r, airlines: t };
77
+ }, [e.flightDetails.slices]), te = () => {
78
+ e.cash > 0 ? s(e, A.CASH) : s(e, A.POINTS);
79
+ }, se = !ve(
80
+ e.departureTime,
81
+ e.arrivalTime
82
+ ), _ = e == null ? void 0 : e.airlineProgram, { data: U } = ge({
83
+ queryKey: [x.VALUE_CENTS, _, "test"],
84
+ queryFn: () => z.getCentPerPoint(_),
85
+ staleTime: 1 / 0,
86
+ enabled: !!_ && c
87
+ }), $ = S(() => {
88
+ var r, t;
89
+ return (t = (r = e.paymentOptions) == null ? void 0 : r.find(
90
+ (o) => {
91
+ var l;
92
+ return o.program === e.airlineProgram && ((l = o.cashFee) == null ? void 0 : l.amount) !== 0;
93
+ }
94
+ )) == null ? void 0 : t.cashFee;
95
+ }, [e.paymentOptions, e.airlineProgram]), ae = async () => {
96
+ if (!e || !U || !e.points || !e.cash)
97
+ return;
98
+ const r = e.currency;
99
+ let t = {
100
+ valueCents: 1,
101
+ currency: r
102
+ };
103
+ try {
104
+ t = await G.ensureQueryData({
105
+ queryKey: [x.VALUE_CENTS, e.airlineProgram],
106
+ staleTime: 1e3 * 60 * 60,
107
+ // 1 hour
108
+ queryFn: () => z.getCentPerPoint(e.airlineProgram)
109
+ });
110
+ } catch (oe) {
111
+ console.warn(
112
+ "Failed to fetch value cents for airline program:",
113
+ e.airlineProgram,
114
+ oe
115
+ );
116
+ }
117
+ const o = $ ?? {
118
+ amount: 0,
119
+ currency: r
120
+ }, [l, h] = await Promise.all([
121
+ Q(
122
+ o.amount,
123
+ o.currency,
124
+ r
125
+ ),
126
+ Q(
127
+ t.valueCents,
128
+ t.currency,
129
+ r
130
+ )
131
+ ]), O = h * e.points / 100 + l < e.cash;
132
+ X(
133
+ O ? "points" : "cash"
134
+ /* CASH */
135
+ );
136
+ };
137
+ return R(() => {
138
+ ae();
139
+ }, [e, U, $]), R(() => {
140
+ const r = p(e.expiresAt), t = p();
141
+ if (!(r.year() === p(0).year()) && r.isAfter(t)) {
142
+ const l = r.diff(t), h = setTimeout(() => {
143
+ V(!0);
144
+ }, l);
145
+ return () => {
146
+ clearTimeout(h);
147
+ };
148
+ }
149
+ }, [e.expiresAt]), /* @__PURE__ */ i(
150
+ "div",
151
+ {
152
+ className: `${Y ? "" : "awayz-"}flight-result`,
153
+ onClick: te,
154
+ children: /* @__PURE__ */ n("div", { className: "content", children: [
155
+ /* @__PURE__ */ i("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
156
+ /* @__PURE__ */ i("div", { className: "airlines", children: ne.map((r, t) => /* @__PURE__ */ i(Ne.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
157
+ /* @__PURE__ */ i(
158
+ "img",
159
+ {
160
+ src: r.logo,
161
+ alt: r.airline,
162
+ onError: (o) => o.currentTarget.src = (C == null ? void 0 : C.logoFallbackImageUrl) ?? ""
163
+ }
164
+ ),
165
+ /* @__PURE__ */ i("span", { className: "right", children: r.airline })
166
+ ] }, t) }, t)) }),
167
+ /* @__PURE__ */ n("div", { className: "flight-location", children: [
168
+ /* @__PURE__ */ n("p", { className: "show-desktop", children: [
169
+ f.city,
170
+ ",",
171
+ w(f.country)
172
+ ] }),
173
+ /* @__PURE__ */ i("p", { className: "show-desktop", children: p(e.departureTime).format(
174
+ g(F.DATE_TIME_MEDIUM, T.FlightShortDate)
175
+ ) }),
176
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: f.airportCode }),
177
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: p(e.departureTime).format(
178
+ g(F.TIME_ONLY, T.FlightTime)
179
+ ) })
180
+ ] }),
181
+ /* @__PURE__ */ n("div", { className: "flight-duration", children: [
182
+ /* @__PURE__ */ i("span", { className: "line" }),
183
+ /* @__PURE__ */ n("p", { children: [
184
+ ue(L.slices[0].duration),
185
+ " ",
186
+ " - ",
187
+ e.numberOfStops > 0 ? `${e.numberOfStops} ${Ae(
188
+ e.numberOfStops,
189
+ "Stop"
190
+ )}` : "Direct"
191
+ ] }),
192
+ /* @__PURE__ */ i("span", { className: "line" })
193
+ ] }),
194
+ /* @__PURE__ */ n("div", { children: [
195
+ /* @__PURE__ */ n("p", { className: "show-desktop", children: [
196
+ y.city,
197
+ ", ",
198
+ w(y.country)
199
+ ] }),
200
+ /* @__PURE__ */ n("p", { className: "show-desktop", children: [
201
+ p(e.arrivalTime).format(
202
+ g(F.DATE_TIME_MEDIUM, T.FlightShortDate)
203
+ ),
204
+ " "
205
+ ] }),
206
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: y.airportCode }),
207
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: p(e.arrivalTime).format(
208
+ g(F.TIME_ONLY, T.FlightTime)
209
+ ) })
210
+ ] })
211
+ ] }) }),
212
+ /* @__PURE__ */ n("div", { className: "flight-footer", children: [
213
+ /* @__PURE__ */ i("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
214
+ "div",
215
+ {
216
+ className: "flight-detail",
217
+ onClick: (r) => {
218
+ r.stopPropagation(), W(!k);
219
+ },
220
+ children: [
221
+ /* @__PURE__ */ i("p", { children: "Aircraft" }),
222
+ /* @__PURE__ */ n("p", { className: "chevron-text", children: [
223
+ /* @__PURE__ */ i(ye, {}),
224
+ /* @__PURE__ */ n("span", { children: [
225
+ D[0],
226
+ D.length > 1 && /* @__PURE__ */ n("sup", { children: [
227
+ "+",
228
+ D.length - 1
229
+ ] })
230
+ ] })
231
+ ] })
232
+ ]
233
+ }
234
+ ) }),
235
+ /* @__PURE__ */ i("div", { className: "booking-options ", children: Z ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
236
+ /* @__PURE__ */ i("span", { children: /* @__PURE__ */ i(b, {}) }),
237
+ /* @__PURE__ */ i("p", { className: "expired-tip", children: "Offer Expired" })
238
+ ] }) : /* @__PURE__ */ n(I, { children: [
239
+ j || e.cash > 0 && /* @__PURE__ */ n(
240
+ "div",
241
+ {
242
+ className: `amount-value ${u === "cash" && c ? "show-best-value-flag" : ""}`,
243
+ onClick: (r) => {
244
+ r.stopPropagation(), s(e, A.CASH);
245
+ },
246
+ children: [
247
+ N.amountsDisplayFeature === v.CASH_AND_TRAVEL_PARTNER_POINTS && /* @__PURE__ */ i("b", { children: "Cash" }),
248
+ /* @__PURE__ */ n("div", { children: [
249
+ /* @__PURE__ */ i("label", { children: B ? "Book For" : "From" }),
250
+ /* @__PURE__ */ n("span", { children: [
251
+ /* @__PURE__ */ i(
252
+ q,
253
+ {
254
+ amount: e.cash,
255
+ currency: e.currency,
256
+ position: H.LEFT
257
+ }
258
+ ),
259
+ N.amountsDisplayFeature === v.CASH_AND_CLIENT_POINTS && /* @__PURE__ */ n(I, { children: [
260
+ "/",
261
+ " ",
262
+ /* @__PURE__ */ i(
263
+ me,
264
+ {
265
+ currency: e.currency,
266
+ cashAmount: e.cash
267
+ }
268
+ )
269
+ ] })
270
+ ] })
271
+ ] }),
272
+ u === "cash" && N.amountsDisplayFeature === v.CASH_AND_TRAVEL_PARTNER_POINTS && c && /* @__PURE__ */ n(
273
+ "div",
274
+ {
275
+ className: "best-value-flag tip",
276
+ onClick: (r) => {
277
+ r.stopPropagation(), a == null || a(e);
278
+ },
279
+ children: [
280
+ a && /* @__PURE__ */ i(b, {}),
281
+ /* @__PURE__ */ i("p", { children: "Best Value" }),
282
+ a && /* @__PURE__ */ i("span", { children: "Click to learn more" })
283
+ ]
284
+ }
285
+ )
286
+ ]
287
+ }
288
+ ),
289
+ J || e.points > 0 && N.amountsDisplayFeature === v.CASH_AND_TRAVEL_PARTNER_POINTS && /* @__PURE__ */ n(
290
+ "div",
291
+ {
292
+ className: `amount-value ${u === "points" && c ? "show-best-value-flag" : ""}`,
293
+ onClick: (r) => {
294
+ r.stopPropagation(), s(e, A.POINTS);
295
+ },
296
+ children: [
297
+ u === "points" && c && /* @__PURE__ */ n(
298
+ "div",
299
+ {
300
+ className: "best-value-flag tip",
301
+ onClick: (r) => {
302
+ r.stopPropagation(), a == null || a(e);
303
+ },
304
+ children: [
305
+ a && /* @__PURE__ */ i(b, {}),
306
+ /* @__PURE__ */ i("p", { children: "Best Value" }),
307
+ a && /* @__PURE__ */ i("span", { children: "Click to learn more" })
308
+ ]
309
+ }
310
+ ),
311
+ /* @__PURE__ */ i("div", { className: "amount-airline-logo", children: /* @__PURE__ */ i("img", { src: re.programLogo }) }),
312
+ /* @__PURE__ */ n("div", { children: [
313
+ /* @__PURE__ */ i("label", { children: ee ? "Book For" : "From" }),
314
+ /* @__PURE__ */ n("p", { children: [
315
+ `${Ce(
316
+ m.points
317
+ )} ${g("miles")}`,
318
+ !!m.cashFee && /* @__PURE__ */ n(I, { children: [
319
+ " + ",
320
+ /* @__PURE__ */ i(
321
+ q,
322
+ {
323
+ amount: m.cashFee.amount,
324
+ currency: m.cashFee.currency,
325
+ customDisplay: "No fee",
326
+ zeroDisplayOption: pe.CUSTOM,
327
+ position: H.LEFT
328
+ }
329
+ )
330
+ ] })
331
+ ] })
332
+ ] })
333
+ ]
334
+ }
335
+ )
336
+ ] }) })
337
+ ] }),
338
+ /* @__PURE__ */ i("div", { className: `flight-details ${k ? "is-open" : ""}`, children: /* @__PURE__ */ i("div", { className: "inner", children: /* @__PURE__ */ i(
339
+ de,
340
+ {
341
+ itinerary: L.slices[0].segments,
342
+ origin: f,
343
+ destination: y,
344
+ isMultiDayFlight: se
345
+ }
346
+ ) }) })
347
+ ] })
348
+ }
349
+ );
350
+ };
351
+ export {
352
+ ze as F,
353
+ Ce as c
354
+ };
@@ -1 +1 @@
1
- @import"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap";*{font-family:Inter,sans-serif!important;margin:0;padding:0;box-sizing:border-box}:root{font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.tip{position:relative}.tip>span{background-color:var(--dark, #14181f);color:#fff;padding:.5rem;border-radius:.5rem;position:absolute;bottom:110%;left:50%;transform:translate(-50%);display:none;transition:all .2s ease-in-out;z-index:100;width:max-content;font-size:.6rem;font-weight:600;text-transform:uppercase;line-height:.8rem;text-align:center;box-sizing:border-box;pointer-events:none}@media screen and (max-width: 480px){.tip>span{width:fit-content}}.tip>span.left{right:100%;top:50%;bottom:auto;left:auto;transform:translateY(-50%)}.tip>span.left:before{left:auto;right:-7.5px;top:50%;transform:translateY(-50%) rotate(-90deg)}.tip>span.right{left:100%;top:50%;bottom:auto;right:auto;transform:translateY(-50%)}.tip>span.right:before{left:-7.5px;right:auto;top:50%;transform:translateY(-50%) rotate(90deg)}.tip>span.bottom{top:100%;left:50%;right:auto;bottom:auto;transform:translate(-50%)}.tip>span.bottom:before{left:50%;right:auto;top:-5px;transform:translate(-50%) rotate(180deg)}.tip>span:before{content:"";position:absolute;bottom:-5px;left:50%;transform:translate(-50%);width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid var(--dark, #14181f)}.tip:hover>span,.tip:focus>span{display:flex;animation:tip-fade-up .2s ease-in-out}.tip:hover>span.right,.tip:focus>span.right{animation:tip-fade-right .2s ease-in-out}.tip:hover>span.left,.tip:focus>span.left{animation:tip-fade-left .2s ease-in-out}.tip:hover>span.bottom,.tip:focus>span.bottom{animation:tip-fade-down .2s ease-in-out}@keyframes slide-in-right{0%{opacity:0;transform:translate(0)}50%{transform:translate(-100vw);opacity:0}50.001%{opacity:0;transform:translate(105vw)}50.002%{opacity:1;transform:translate(100vw)}to{transform:translate(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(0)}50%{transform:translate(100vw);opacity:0}50.001%{opacity:0;transform:translate(-100vw)}50.002%{opacity:1;transform:translate(-100vw)}to{transform:translate(0)}}@keyframes slide-out-right{0%{transform:translate(0)}to{transform:translate(100vw);opacity:1}}@keyframes slide-out-left{0%{transform:translate(0)}to{transform:translate(-100vw);opacity:1}}@keyframes slide-up{0%{transform:translateY(100%)}to{transform:translate(0);opacity:1}}@keyframes fade-out{0%{opacity:1}to{opacity:0}}@keyframes fade-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}@keyframes scale-out{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes scale-in{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes no-no{0%{transform:translate(0)}20%{transform:translate(-20px)}40%{transform:translate(15px)}60%{transform:translate(-10px)}80%{transform:translate(5px)}to{transform:translate(0)}}@keyframes loading-track{0%{transform:translate(-100%);opacity:0}25%{opacity:1}75%{opacity:1}to{opacity:0;transform:translate(100%)}}@keyframes loading-in{0%{height:0}to{height:5px}}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes shine{0%{background-position:right}}@keyframes text-pulse{0%{opacity:.75}35%{opacity:1}65%{opacity:1}to{opacity:.75}}@keyframes pulse{0%{opacity:.85}35%{opacity:1}65%{opacity:1}to{opacity:.85}}@keyframes shimmer{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}@keyframes fade-up{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes fade-down{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes fade-right{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@keyframes spring-in{0%{opacity:0;transform:scale(.8)}70%{opacity:1;transform:scale(1.05)}to{opacity:1;transform:scale(1)}}@keyframes ripple{0%{transform:scale(1)}to{transform:scale(1.1,1.4)}}@keyframes tip-fade-right{0%{opacity:0;transform:translate(-20px,-50%)}to{opacity:1;transform:translateY(-50%)}}@keyframes tip-fade-left{0%{opacity:0;transform:translate(20px,-50%)}to{opacity:1;transform:translateY(-50%)}}@keyframes tip-fade-down{0%{opacity:0;transform:translate(-50%,-20px)}to{opacity:1;transform:translate(-50%)}}@keyframes tip-fade-up{0%{opacity:0;transform:translate(-50%,5px)}to{opacity:1;transform:translate(-50%)}}@keyframes slide-in{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes slide-out{0%{transform:translate(0);opacity:1}to{transform:translate(100%);opacity:0}}@keyframes scale-fade-in{0%{transform:scale(.9);opacity:0}to{transform:scale(1);opacity:1}}@keyframes scroll-horizontally{0%{transform:translate(0)}to{transform:translate(-50%)}}.awayz-flight-result{background-color:var(--foreground, #fff);border-radius:1rem;border:1px solid var(--border, #e7eef3);overflow:hidden;width:100%;margin:0 auto;position:relative;height:fit-content;padding:1px;transition:all .2s ease-in-out;z-index:10;animation:fade-up .2s ease-in-out both;backface-visibility:hidden}.awayz-flight-result .content{overflow:hidden;border-radius:.8rem;width:100%;margin:0 auto;position:relative;height:fit-content;z-index:1;display:flex;flex-direction:column}.awayz-flight-result .content>div{z-index:2}.awayz-flight-result .content>div.flight-info{flex:4;display:flex;flex-direction:column;min-height:60%;gap:.5rem;padding:1rem}.awayz-flight-result .content>div.flight-info .airlines{position:relative;width:50px;max-width:50px;height:30px}.awayz-flight-result .content>div.flight-info .airlines>div{position:absolute;display:flex;align-items:center;gap:.5rem;border:1px solid var(--border, #e7eef3);border-radius:50%;height:30px;width:30px;justify-content:center;background-color:var(--light, #f9fdff)}.awayz-flight-result .content>div.flight-info .airlines>div img{width:70%}.awayz-flight-result .content>div.flight-info .airlines>div:nth-child(2){top:10px;left:15px}.awayz-flight-result .content>div.flight-info .airlines>div:nth-child(3){top:-10px;left:20px}.awayz-flight-result .content>div.flight-info .airlines>div span{font-size:.7rem}.awayz-flight-result .content>div.flight-info .airlines p{font-weight:600}.awayz-flight-result .content>div.flight-info .flight-locations{align-items:center;gap:1rem;display:flex}.awayz-flight-result .content>div.flight-info .flight-locations .show-desktop{display:none}@media screen and (min-width: 768px){.awayz-flight-result .content>div.flight-info .flight-locations .show-desktop{display:flex}}.awayz-flight-result .content>div.flight-info .flight-locations .show-mobile{display:none}@media screen and (max-width: 768px){.awayz-flight-result .content>div.flight-info .flight-locations .show-mobile{display:flex}}.awayz-flight-result .content>div.flight-info .flight-locations:last-child div p:first-child{font-weight:600}.awayz-flight-result .content>div.flight-info .flight-locations>div{flex:1;font-size:.8rem}.awayz-flight-result .content>div.flight-info .flight-locations>div:first-child{text-align:left}.awayz-flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right}.awayz-flight-result .content>div.flight-info .flight-locations .flight-duration{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:1rem;font-weight:600;font-size:.7rem}.awayz-flight-result .content>div.flight-info .flight-locations .line{height:2px;flex:1;background:repeating-linear-gradient(90deg,var(--border, #e7eef3) 0 20px,rgba(0,0,0,0) 0 30px);z-index:1}.awayz-flight-result .content>div.flight-info .flight-locations>div{display:flex;flex-direction:column;text-align:center;flex:1;width:100%}.awayz-flight-result .content>div.flight-info .flight-locations>div.duration{flex-direction:row;align-items:center;justify-content:center;gap:.5rem}.awayz-flight-result .content>div.flight-info .flight-locations>div.duration p{opacity:.4}.awayz-flight-result .content>div.flight-info .flight-locations>div.flight-location{text-align:left;align-items:flex-start;max-width:fit-content}.awayz-flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right;align-items:flex-end;max-width:fit-content}.awayz-flight-result .content>div.flight-footer{flex:2;display:flex;justify-content:space-between;align-items:center;padding:1rem;gap:1rem;background-color:var(--background, #f9fdff);border-top:1px solid var(--border, #e7eef3)}@media screen and (max-width: 1024px){.awayz-flight-result .content>div.flight-footer{flex-direction:column}}.awayz-flight-result .content>div.flight-footer .view-details{display:flex;align-items:center;gap:1rem;cursor:pointer;-webkit-user-select:none;user-select:none}.awayz-flight-result .content>div.flight-footer .booking-options{display:flex;justify-content:flex-end;gap:1rem;font-size:.8rem;flex:3}@media screen and (max-width: 1024px){.awayz-flight-result .content>div.flight-footer .booking-options{width:100%;flex-direction:column}}.awayz-flight-result .content>div.flight-footer .booking-options .offer-expiry{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--border, #e7eef3);border-radius:50rem;padding:1rem;gap:1rem;transition:all .2s ease-in-out;background-color:var(--foreground, #fff);font-weight:600}.awayz-flight-result .content>div.flight-footer .booking-options .offer-expiry span{display:flex;align-items:center;justify-content:center;font-size:1rem;color:var(--warning, #ff7f2f)}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--border, #e7eef3);border-radius:4rem;padding:.5rem 1rem;gap:2rem;cursor:pointer;transition:all .2s ease-in-out;background-color:var(--foreground, #fff)}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value .amount-airline-logo{display:flex;align-items:center;background-color:var(--light, #f9fdff);border-radius:4rem;padding:.25rem .5rem;margin-left:-.5rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value img{height:30px;max-width:100px}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value>div{display:flex;flex-direction:column}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value label{font-size:.7rem;font-weight:600}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value{position:relative}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value .currency-conversion{display:flex}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value .best-value-flag{display:flex;align-items:center;justify-content:center;flex-direction:row;gap:.25rem;position:absolute;right:-1px;padding:.25rem .5rem;top:-1rem;color:var(--foreground, #fff);border-radius:50rem;font-weight:600;background-color:var(--primary, #1495f2);border-bottom-right-radius:0;font-size:.7rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value .best-value-flag p{color:var(--foreground, #fff)}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value.show-best-value-flag{border-color:var(--primary, #1495f2);border-top-right-radius:0}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value p{display:flex;gap:.25rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value:first-of-type{grid-area:price}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value:last-of-type{grid-area:points}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value:hover{background-color:var(--background, #f9fdff)}@media screen and (max-width: 1024px){.awayz-flight-result .content>div.flight-footer .booking-options .amount-value{flex-direction:row;justify-content:space-between;align-items:center}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value{text-align:center}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value img{height:30px;max-width:80px}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value p:last-child{font-weight:600;font-size:1rem}}.awayz-flight-result .content .flight-detail-container{display:flex;gap:1rem;justify-content:space-between}@media screen and (max-width: 1024px){.awayz-flight-result .content .flight-detail-container{width:100%}}.awayz-flight-result .content .flight-detail:not(:first-of-type){border-left:1px solid var(--border, #e7eef3);padding:0 2rem}@media screen and (max-width: 1024px){.awayz-flight-result .content .flight-detail:not(:first-of-type){padding:0 .5rem}}.awayz-flight-result .content .flight-detail p{font-size:.8rem}.awayz-flight-result .content .flight-detail p:first-of-type{font-size:.7rem;color:var(--text-light, rgba(37, 46, 52, .2509803922))}.awayz-flight-result .content .flight-detail p:last-of-type{font-weight:600}.awayz-flight-result .content .flight-detail p.chevron-text{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.awayz-flight-result .flight-details{display:grid;grid-template-rows:0fr;transition:all .2s ease-in-out;background-color:var(--foreground, #fff);border-top:1px solid var(--border, #e7eef3);border-width:0}.awayz-flight-result .flight-details.is-open{grid-template-rows:1fr;padding:1rem;border-top:1px solid var(--border, #e7eef3)}.awayz-flight-result .flight-details.is-open .inner{padding:1rem 0;scale:1;opacity:1}.awayz-flight-result .flight-details .inner{overflow:hidden;transition:all .2s ease-in-out;scale:.9;opacity:0;transform-origin:top center}.awayz-flight-result:hover{cursor:pointer}
1
+ @import"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap";*{font-family:Inter,sans-serif!important;margin:0;padding:0;box-sizing:border-box}:root{font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.tip{position:relative}.tip>span{background-color:var(--dark, #14181f);color:#fff;padding:.5rem;border-radius:.5rem;position:absolute;bottom:110%;left:50%;transform:translate(-50%);display:none;transition:all .2s ease-in-out;z-index:100;width:max-content;font-size:.6rem;font-weight:600;text-transform:uppercase;line-height:.8rem;text-align:center;box-sizing:border-box;pointer-events:none}@media screen and (max-width: 480px){.tip>span{width:fit-content}}.tip>span.left{right:100%;top:50%;bottom:auto;left:auto;transform:translateY(-50%)}.tip>span.left:before{left:auto;right:-7.5px;top:50%;transform:translateY(-50%) rotate(-90deg)}.tip>span.right{left:100%;top:50%;bottom:auto;right:auto;transform:translateY(-50%)}.tip>span.right:before{left:-7.5px;right:auto;top:50%;transform:translateY(-50%) rotate(90deg)}.tip>span.bottom{top:100%;left:50%;right:auto;bottom:auto;transform:translate(-50%)}.tip>span.bottom:before{left:50%;right:auto;top:-5px;transform:translate(-50%) rotate(180deg)}.tip>span:before{content:"";position:absolute;bottom:-5px;left:50%;transform:translate(-50%);width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid var(--dark, #14181f)}.tip:hover>span,.tip:focus>span{display:flex;animation:tip-fade-up .2s ease-in-out}.tip:hover>span.right,.tip:focus>span.right{animation:tip-fade-right .2s ease-in-out}.tip:hover>span.left,.tip:focus>span.left{animation:tip-fade-left .2s ease-in-out}.tip:hover>span.bottom,.tip:focus>span.bottom{animation:tip-fade-down .2s ease-in-out}@keyframes slide-in-right{0%{opacity:0;transform:translate(0)}50%{transform:translate(-100vw);opacity:0}50.001%{opacity:0;transform:translate(105vw)}50.002%{opacity:1;transform:translate(100vw)}to{transform:translate(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(0)}50%{transform:translate(100vw);opacity:0}50.001%{opacity:0;transform:translate(-100vw)}50.002%{opacity:1;transform:translate(-100vw)}to{transform:translate(0)}}@keyframes slide-out-right{0%{transform:translate(0)}to{transform:translate(100vw);opacity:1}}@keyframes slide-out-left{0%{transform:translate(0)}to{transform:translate(-100vw);opacity:1}}@keyframes slide-up{0%{transform:translateY(100%)}to{transform:translate(0);opacity:1}}@keyframes fade-out{0%{opacity:1}to{opacity:0}}@keyframes fade-in{0%{opacity:0;scale:.9}to{opacity:1;scale:1}}@keyframes scale-out{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes scale-in{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes no-no{0%{transform:translate(0)}20%{transform:translate(-20px)}40%{transform:translate(15px)}60%{transform:translate(-10px)}80%{transform:translate(5px)}to{transform:translate(0)}}@keyframes loading-track{0%{transform:translate(-100%);opacity:0}25%{opacity:1}75%{opacity:1}to{opacity:0;transform:translate(100%)}}@keyframes loading-in{0%{height:0}to{height:5px}}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes shine{0%{background-position:right}}@keyframes text-pulse{0%{opacity:.75}35%{opacity:1}65%{opacity:1}to{opacity:.75}}@keyframes pulse{0%{opacity:.85}35%{opacity:1}65%{opacity:1}to{opacity:.85}}@keyframes shimmer{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}@keyframes fade-up{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes fade-down{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes fade-right{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@keyframes spring-in{0%{opacity:0;transform:scale(.8)}70%{opacity:1;transform:scale(1.05)}to{opacity:1;transform:scale(1)}}@keyframes ripple{0%{transform:scale(1)}to{transform:scale(1.1,1.4)}}@keyframes tip-fade-right{0%{opacity:0;transform:translate(-20px,-50%)}to{opacity:1;transform:translateY(-50%)}}@keyframes tip-fade-left{0%{opacity:0;transform:translate(20px,-50%)}to{opacity:1;transform:translateY(-50%)}}@keyframes tip-fade-down{0%{opacity:0;transform:translate(-50%,-20px)}to{opacity:1;transform:translate(-50%)}}@keyframes tip-fade-up{0%{opacity:0;transform:translate(-50%,5px)}to{opacity:1;transform:translate(-50%)}}@keyframes slide-in{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes slide-out{0%{transform:translate(0);opacity:1}to{transform:translate(100%);opacity:0}}@keyframes scale-fade-in{0%{transform:scale(.9);opacity:0}to{transform:scale(1);opacity:1}}@keyframes scroll-horizontally{0%{transform:translate(0)}to{transform:translate(-50%)}}.awayz-flight-result{background-color:var(--foreground, #fff);border-radius:1rem;border:1px solid var(--border, #e7eef3);overflow:hidden;width:100%;margin:0 auto;position:relative;height:fit-content;padding:1px;transition:all .2s ease-in-out;z-index:10;animation:fade-up .2s ease-in-out both;backface-visibility:hidden}.awayz-flight-result .content{overflow:hidden;border-radius:.8rem;width:100%;margin:0 auto;position:relative;height:fit-content;z-index:1;display:flex;flex-direction:column}.awayz-flight-result .content>div{z-index:2}.awayz-flight-result .content>div.flight-info{flex:4;display:flex;flex-direction:column;min-height:60%;gap:.5rem;padding:1rem}.awayz-flight-result .content>div.flight-info .airlines{position:relative;width:50px;max-width:50px;height:30px}.awayz-flight-result .content>div.flight-info .airlines>div{position:absolute;display:flex;align-items:center;gap:.5rem;border:1px solid var(--border, #e7eef3);border-radius:50%;height:30px;width:30px;justify-content:center;background-color:var(--light, #f9fdff)}.awayz-flight-result .content>div.flight-info .airlines>div img{width:70%}.awayz-flight-result .content>div.flight-info .airlines>div:nth-child(2){top:10px;left:15px}.awayz-flight-result .content>div.flight-info .airlines>div:nth-child(3){top:-10px;left:20px}.awayz-flight-result .content>div.flight-info .airlines>div span{font-size:.7rem}.awayz-flight-result .content>div.flight-info .airlines p{font-weight:600}.awayz-flight-result .content>div.flight-info .flight-locations{align-items:center;gap:1rem;display:flex}.awayz-flight-result .content>div.flight-info .flight-locations .show-desktop{display:none}@media screen and (min-width: 768px){.awayz-flight-result .content>div.flight-info .flight-locations .show-desktop{display:flex}}.awayz-flight-result .content>div.flight-info .flight-locations .show-mobile{display:none}@media screen and (max-width: 768px){.awayz-flight-result .content>div.flight-info .flight-locations .show-mobile{display:flex}}.awayz-flight-result .content>div.flight-info .flight-locations:last-child div p:first-child{font-weight:600}.awayz-flight-result .content>div.flight-info .flight-locations>div{flex:1;font-size:.8rem}.awayz-flight-result .content>div.flight-info .flight-locations>div:first-child{text-align:left}.awayz-flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right}.awayz-flight-result .content>div.flight-info .flight-locations .flight-duration{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:1rem;font-weight:600;font-size:.7rem}.awayz-flight-result .content>div.flight-info .flight-locations .line{height:2px;flex:1;background:repeating-linear-gradient(90deg,var(--border, #e7eef3) 0 20px,rgba(0,0,0,0) 0 30px);z-index:1}.awayz-flight-result .content>div.flight-info .flight-locations>div{display:flex;flex-direction:column;text-align:center;flex:1;width:100%}.awayz-flight-result .content>div.flight-info .flight-locations>div.duration{flex-direction:row;align-items:center;justify-content:center;gap:.5rem}.awayz-flight-result .content>div.flight-info .flight-locations>div.duration p{opacity:.4}.awayz-flight-result .content>div.flight-info .flight-locations>div.flight-location{text-align:left;align-items:flex-start;max-width:fit-content}.awayz-flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right;align-items:flex-end;max-width:fit-content}.awayz-flight-result .content>div.flight-footer{flex:2;display:flex;justify-content:space-between;align-items:center;padding:1rem;gap:1rem;background-color:var(--background, #f9fdff);border-top:1px solid var(--border, #e7eef3)}@media screen and (max-width: 1024px){.awayz-flight-result .content>div.flight-footer{flex-direction:column}}.awayz-flight-result .content>div.flight-footer .view-details{display:flex;align-items:center;gap:1rem;cursor:pointer;-webkit-user-select:none;user-select:none}.awayz-flight-result .content>div.flight-footer .booking-options{display:flex;justify-content:flex-end;gap:1rem;font-size:.8rem;flex:3}@media screen and (max-width: 1024px){.awayz-flight-result .content>div.flight-footer .booking-options{width:100%;flex-direction:column}}.awayz-flight-result .content>div.flight-footer .booking-options .offer-expiry{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--border, #e7eef3);border-radius:50rem;padding:1rem;gap:1rem;transition:all .2s ease-in-out;background-color:var(--foreground, #fff);font-weight:600}.awayz-flight-result .content>div.flight-footer .booking-options .offer-expiry span{display:flex;align-items:center;justify-content:center;font-size:1rem;color:var(--warning, #ff7f2f)}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--border, #e7eef3);border-radius:4rem;padding:.5rem 1rem;gap:2rem;cursor:pointer;transition:all .2s ease-in-out;background-color:var(--foreground, #fff)}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value .amount-airline-logo{display:flex;align-items:center;background-color:var(--light, #f9fdff);border-radius:4rem;padding:.25rem .5rem;margin-left:-.5rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value img{height:30px;max-width:100px}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value>div{display:flex;flex-direction:column}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value label{font-size:.7rem;font-weight:600}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value span{display:flex;gap:.25rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value{position:relative}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value .currency-conversion{display:flex}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value .best-value-flag{display:flex;align-items:center;justify-content:center;flex-direction:row;gap:.25rem;position:absolute;right:-1px;padding:.25rem .5rem;top:-1rem;color:var(--foreground, #fff);border-radius:50rem;font-weight:600;background-color:var(--primary, #1495f2);border-bottom-right-radius:0;font-size:.7rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value .best-value-flag p{color:var(--foreground, #fff)}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value.show-best-value-flag{border-color:var(--primary, #1495f2);border-top-right-radius:0}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value p{display:flex;gap:.25rem}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value:first-of-type{grid-area:price}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value:last-of-type{grid-area:points}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value:hover{background-color:var(--background, #f9fdff)}@media screen and (max-width: 1024px){.awayz-flight-result .content>div.flight-footer .booking-options .amount-value{flex-direction:row;justify-content:space-between;align-items:center}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value{text-align:center}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value.amount-value img{height:30px;max-width:80px}.awayz-flight-result .content>div.flight-footer .booking-options .amount-value p:last-child{font-weight:600;font-size:1rem}}.awayz-flight-result .content .flight-detail-container{display:flex;gap:1rem;justify-content:space-between}@media screen and (max-width: 1024px){.awayz-flight-result .content .flight-detail-container{width:100%}}.awayz-flight-result .content .flight-detail:not(:first-of-type){border-left:1px solid var(--border, #e7eef3);padding:0 2rem}@media screen and (max-width: 1024px){.awayz-flight-result .content .flight-detail:not(:first-of-type){padding:0 .5rem}}.awayz-flight-result .content .flight-detail p{font-size:.8rem}.awayz-flight-result .content .flight-detail p:first-of-type{font-size:.7rem;color:var(--text-light, rgba(37, 46, 52, .2509803922))}.awayz-flight-result .content .flight-detail p:last-of-type{font-weight:600}.awayz-flight-result .content .flight-detail p.chevron-text{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.awayz-flight-result .flight-details{display:grid;grid-template-rows:0fr;transition:all .2s ease-in-out;background-color:var(--foreground, #fff);border-top:1px solid var(--border, #e7eef3);border-width:0}.awayz-flight-result .flight-details.is-open{grid-template-rows:1fr;padding:1rem;border-top:1px solid var(--border, #e7eef3)}.awayz-flight-result .flight-details.is-open .inner{padding:1rem 0;scale:1;opacity:1}.awayz-flight-result .flight-details .inner{overflow:hidden;transition:all .2s ease-in-out;scale:.9;opacity:0;transform-origin:top center}.awayz-flight-result:hover{cursor:pointer}
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "@odynn/awayz-core";
3
3
  import "@tanstack/react-query";
4
- import { F as x } from "../../FlightResult-gPF9SQ7r.js";
4
+ import { F as x } from "../../FlightResult-D6dFGMxN.js";
5
5
  import "../../index-7zRjF0bU.js";
6
6
  import "../../FlightItinerary-Dy-2zMYt.js";
7
7
  import "../../enums-Bmg_7eKJ.js";
@@ -1,4 +1,4 @@
1
- import { F as l } from "../FlightResult-gPF9SQ7r.js";
1
+ import { F as l } from "../FlightResult-D6dFGMxN.js";
2
2
  export {
3
3
  l as FlightResult
4
4
  };
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useFlightSearch as o } from "./hooks/useFlightSearch/useFlightSearch.js";
2
2
  import { useAirportSearch as g } from "./hooks/useAirportSearch/useAirportSearch.js";
3
3
  import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
- import { F as f, c as l } from "./FlightResult-gPF9SQ7r.js";
4
+ import { F as f, c as l } from "./FlightResult-D6dFGMxN.js";
5
5
  import { EPaymentType as x } from "./enums/EPaymentType.js";
6
6
  import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
7
7
  import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.7.14",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,341 +0,0 @@
1
- import { jsx as i, jsxs as n, Fragment as L } from "react/jsx-runtime";
2
- import { useAwayzContext as ar, RewardsService as R, CashValue as $, EToolTipPosition as z, EInvalidAmountDisplayOption as or, awayzClient as Q, CurrencyService as cr } from "@odynn/awayz-core";
3
- import { useQuery as lr } from "@tanstack/react-query";
4
- import { g as mr } from "./index-7zRjF0bU.js";
5
- import { G as pr, g as q, a as v, E as P, F as hr, b as gr } from "./FlightItinerary-Dy-2zMYt.js";
6
- import { E as x } from "./enums-Bmg_7eKJ.js";
7
- import "./arrayExtensions-DFLvtO8l.js";
8
- import fr, { useState as F, useMemo as O, useEffect as I } from "react";
9
- import { h as p } from "./moment-BGjjqtLQ.js";
10
- import { useTranslation as ur } from "react-i18next";
11
- import { EPaymentType as E } from "./enums/EPaymentType.js";
12
- import { isSameDayFlight as dr } from "./utils/flightDateUtils.js";
13
- import { DEFAULT_AIRLINE_PROGRAM as w, getFlightNumber as yr, getLogoPath as Nr, getAirlineProgram as vr } from "./utils/flightUtils.js";
14
- import './assets/FlightResult.css';const Pr = (r, s, c = s + "s") => r === 1 ? s : c;
15
- function Fr(r) {
16
- if (!r || isNaN(r) || r < 0) return "N/A";
17
- let s = r == null ? void 0 : r.toString().split(".")[0];
18
- return s == null ? void 0 : s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19
- }
20
- function b(r) {
21
- return pr({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }, child: [] }] })(r);
22
- }
23
- async function K(r, s, c) {
24
- if (!r || s === c) return r;
25
- const a = await Q.ensureQueryData({
26
- queryKey: [x.CONVERT_CURRENCY, s, c],
27
- staleTime: 1e3 * 60 * 60,
28
- // 1 hour
29
- queryFn: () => cr.convertCurrency({
30
- baseCurrency: s,
31
- targetCurrency: c
32
- })
33
- });
34
- return r * a;
35
- }
36
- const _r = ({
37
- details: r,
38
- onClick: s,
39
- showBestValue: c = !1,
40
- onShowBestValueCalculation: a,
41
- customStyling: G = !1,
42
- customCashComponent: Y,
43
- customPointsComponent: j
44
- }) => {
45
- const { t: g } = ur(), [k, H] = F(!1), [f, J] = F(
46
- "none"
47
- /* NONE */
48
- ), [W, X] = F(!1), { config: T } = ar(), u = r.origin, d = r.destination, M = r.flightDetails, y = r.paymentOptions || [], Z = y.filter((e) => e.points === -1).length === 1, V = y.filter((e) => e.points > -1).length === 1, [B, S] = F(w), m = O(() => {
49
- var e = y.filter((t) => t.points > -1).sort((t, o) => t.points - o.points);
50
- return e.find(
51
- (t) => t.program === r.airlineProgram
52
- ) || e[0];
53
- }, [y, r.airlineProgram]), rr = async () => {
54
- if (!m) {
55
- S(w);
56
- return;
57
- }
58
- const e = await vr(m.program);
59
- S(e);
60
- };
61
- I(() => {
62
- rr();
63
- }, [m]);
64
- const { flightNumbers: C, airlines: er } = O(() => {
65
- const e = [], t = [];
66
- return r.flightDetails.slices.forEach((o) => {
67
- o.segments.forEach((l) => {
68
- const h = yr(l);
69
- e.includes(h) || e.push(h);
70
- const N = l.operatingCarrier;
71
- t.some((A) => A.airline === N.name) || t.push({
72
- logo: Nr(N.iataCode),
73
- airline: N.name
74
- });
75
- });
76
- }), { flightNumbers: e, airlines: t };
77
- }, [r.flightDetails.slices]), ir = () => {
78
- r.cash > 0 ? s(r, E.CASH) : s(r, E.POINTS);
79
- }, nr = !dr(
80
- r.departureTime,
81
- r.arrivalTime
82
- ), D = r == null ? void 0 : r.airlineProgram, { data: U } = lr({
83
- queryKey: [x.VALUE_CENTS, D, "test"],
84
- queryFn: () => R.getCentPerPoint(D),
85
- staleTime: 1 / 0,
86
- enabled: !!D && c
87
- }), _ = O(() => {
88
- var e, t;
89
- return (t = (e = r.paymentOptions) == null ? void 0 : e.find(
90
- (o) => {
91
- var l;
92
- return o.program === r.airlineProgram && ((l = o.cashFee) == null ? void 0 : l.amount) !== 0;
93
- }
94
- )) == null ? void 0 : t.cashFee;
95
- }, [r.paymentOptions, r.airlineProgram]), tr = async () => {
96
- if (!r || !U || !r.points || !r.cash)
97
- return;
98
- const e = r.currency;
99
- let t = {
100
- valueCents: 1,
101
- currency: e
102
- };
103
- try {
104
- t = await Q.ensureQueryData({
105
- queryKey: [x.VALUE_CENTS, r.airlineProgram],
106
- staleTime: 1e3 * 60 * 60,
107
- // 1 hour
108
- queryFn: () => R.getCentPerPoint(r.airlineProgram)
109
- });
110
- } catch (sr) {
111
- console.warn(
112
- "Failed to fetch value cents for airline program:",
113
- r.airlineProgram,
114
- sr
115
- );
116
- }
117
- const o = _ ?? {
118
- amount: 0,
119
- currency: e
120
- }, [l, h] = await Promise.all([
121
- K(
122
- o.amount,
123
- o.currency,
124
- e
125
- ),
126
- K(
127
- t.valueCents,
128
- t.currency,
129
- e
130
- )
131
- ]), A = h * r.points / 100 + l < r.cash;
132
- J(
133
- A ? "points" : "cash"
134
- /* CASH */
135
- );
136
- };
137
- return I(() => {
138
- tr();
139
- }, [r, U, _]), I(() => {
140
- const e = p(r.expiresAt), t = p();
141
- if (!(e.year() === p(0).year()) && e.isAfter(t)) {
142
- const l = e.diff(t), h = setTimeout(() => {
143
- X(!0);
144
- }, l);
145
- return () => {
146
- clearTimeout(h);
147
- };
148
- }
149
- }, [r.expiresAt]), /* @__PURE__ */ i(
150
- "div",
151
- {
152
- className: `${G ? "" : "awayz-"}flight-result`,
153
- onClick: ir,
154
- children: /* @__PURE__ */ n("div", { className: "content", children: [
155
- /* @__PURE__ */ i("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
156
- /* @__PURE__ */ i("div", { className: "airlines", children: er.map((e, t) => /* @__PURE__ */ i(fr.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
157
- /* @__PURE__ */ i(
158
- "img",
159
- {
160
- src: e.logo,
161
- alt: e.airline,
162
- onError: (o) => o.currentTarget.src = (T == null ? void 0 : T.logoFallbackImageUrl) ?? ""
163
- }
164
- ),
165
- /* @__PURE__ */ i("span", { className: "right", children: e.airline })
166
- ] }, t) }, t)) }),
167
- /* @__PURE__ */ n("div", { className: "flight-location", children: [
168
- /* @__PURE__ */ n("p", { className: "show-desktop", children: [
169
- u.city,
170
- ",",
171
- q(u.country)
172
- ] }),
173
- /* @__PURE__ */ i("p", { className: "show-desktop", children: p(r.departureTime).format(
174
- g(v.DATE_TIME_MEDIUM, P.FlightShortDate)
175
- ) }),
176
- /* @__PURE__ */ i("p", { className: "show-mobile", children: u.airportCode }),
177
- /* @__PURE__ */ i("p", { className: "show-mobile", children: p(r.departureTime).format(
178
- g(v.TIME_ONLY, P.FlightTime)
179
- ) })
180
- ] }),
181
- /* @__PURE__ */ n("div", { className: "flight-duration", children: [
182
- /* @__PURE__ */ i("span", { className: "line" }),
183
- /* @__PURE__ */ n("p", { children: [
184
- mr(M.slices[0].duration),
185
- " ",
186
- " - ",
187
- r.numberOfStops > 0 ? `${r.numberOfStops} ${Pr(
188
- r.numberOfStops,
189
- "Stop"
190
- )}` : "Direct"
191
- ] }),
192
- /* @__PURE__ */ i("span", { className: "line" })
193
- ] }),
194
- /* @__PURE__ */ n("div", { children: [
195
- /* @__PURE__ */ n("p", { className: "show-desktop", children: [
196
- d.city,
197
- ", ",
198
- q(d.country)
199
- ] }),
200
- /* @__PURE__ */ n("p", { className: "show-desktop", children: [
201
- p(r.arrivalTime).format(
202
- g(v.DATE_TIME_MEDIUM, P.FlightShortDate)
203
- ),
204
- " "
205
- ] }),
206
- /* @__PURE__ */ i("p", { className: "show-mobile", children: d.airportCode }),
207
- /* @__PURE__ */ i("p", { className: "show-mobile", children: p(r.arrivalTime).format(
208
- g(v.TIME_ONLY, P.FlightTime)
209
- ) })
210
- ] })
211
- ] }) }),
212
- /* @__PURE__ */ n("div", { className: "flight-footer", children: [
213
- /* @__PURE__ */ i("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
214
- "div",
215
- {
216
- className: "flight-detail",
217
- onClick: (e) => {
218
- e.stopPropagation(), H(!k);
219
- },
220
- children: [
221
- /* @__PURE__ */ i("p", { children: "Aircraft" }),
222
- /* @__PURE__ */ n("p", { className: "chevron-text", children: [
223
- /* @__PURE__ */ i(hr, {}),
224
- /* @__PURE__ */ n("span", { children: [
225
- C[0],
226
- C.length > 1 && /* @__PURE__ */ n("sup", { children: [
227
- "+",
228
- C.length - 1
229
- ] })
230
- ] })
231
- ] })
232
- ]
233
- }
234
- ) }),
235
- /* @__PURE__ */ i("div", { className: "booking-options ", children: W ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
236
- /* @__PURE__ */ i("span", { children: /* @__PURE__ */ i(b, {}) }),
237
- /* @__PURE__ */ i("p", { className: "expired-tip", children: "Offer Expired" })
238
- ] }) : /* @__PURE__ */ n(L, { children: [
239
- Y || r.cash > 0 && /* @__PURE__ */ n(
240
- "div",
241
- {
242
- className: `amount-value ${f === "cash" && c ? "show-best-value-flag" : ""}`,
243
- onClick: (e) => {
244
- e.stopPropagation(), s(r, E.CASH);
245
- },
246
- children: [
247
- /* @__PURE__ */ i("b", { children: "Cash" }),
248
- /* @__PURE__ */ n("div", { children: [
249
- /* @__PURE__ */ i("label", { children: Z ? "Book For" : "From" }),
250
- /* @__PURE__ */ i(
251
- $,
252
- {
253
- amount: r.cash,
254
- currency: r.currency,
255
- position: z.LEFT
256
- }
257
- )
258
- ] }),
259
- f === "cash" && c && /* @__PURE__ */ n(
260
- "div",
261
- {
262
- className: "best-value-flag tip",
263
- onClick: (e) => {
264
- e.stopPropagation(), a == null || a(r);
265
- },
266
- children: [
267
- a && /* @__PURE__ */ i(b, {}),
268
- /* @__PURE__ */ i("p", { children: "Best Value" }),
269
- a && /* @__PURE__ */ i("span", { children: "Click to learn more" })
270
- ]
271
- }
272
- )
273
- ]
274
- }
275
- ),
276
- j || r.points > 0 && /* @__PURE__ */ n(
277
- "div",
278
- {
279
- className: `amount-value ${f === "points" && c ? "show-best-value-flag" : ""}`,
280
- onClick: (e) => {
281
- e.stopPropagation(), s(r, E.POINTS);
282
- },
283
- children: [
284
- f === "points" && c && /* @__PURE__ */ n(
285
- "div",
286
- {
287
- className: "best-value-flag tip",
288
- onClick: (e) => {
289
- e.stopPropagation(), a == null || a(r);
290
- },
291
- children: [
292
- a && /* @__PURE__ */ i(b, {}),
293
- /* @__PURE__ */ i("p", { children: "Best Value" }),
294
- a && /* @__PURE__ */ i("span", { children: "Click to learn more" })
295
- ]
296
- }
297
- ),
298
- /* @__PURE__ */ i("div", { className: "amount-airline-logo", children: /* @__PURE__ */ i("img", { src: B.programLogo }) }),
299
- /* @__PURE__ */ n("div", { children: [
300
- /* @__PURE__ */ i("label", { children: V ? "Book For" : "From" }),
301
- /* @__PURE__ */ n("p", { children: [
302
- `${Fr(
303
- m.points
304
- )} ${g("miles")}`,
305
- !!m.cashFee && /* @__PURE__ */ n(L, { children: [
306
- " + ",
307
- /* @__PURE__ */ i(
308
- $,
309
- {
310
- amount: m.cashFee.amount,
311
- currency: m.cashFee.currency,
312
- customDisplay: "No fee",
313
- zeroDisplayOption: or.CUSTOM,
314
- position: z.LEFT
315
- }
316
- )
317
- ] })
318
- ] })
319
- ] })
320
- ]
321
- }
322
- )
323
- ] }) })
324
- ] }),
325
- /* @__PURE__ */ i("div", { className: `flight-details ${k ? "is-open" : ""}`, children: /* @__PURE__ */ i("div", { className: "inner", children: /* @__PURE__ */ i(
326
- gr,
327
- {
328
- itinerary: M.slices[0].segments,
329
- origin: u,
330
- destination: d,
331
- isMultiDayFlight: nr
332
- }
333
- ) }) })
334
- ] })
335
- }
336
- );
337
- };
338
- export {
339
- _r as F,
340
- Fr as c
341
- };