@odynn/awayz-hotels 0.13.4 → 0.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useHotelDetails/useHotelDetails.js +79 -79
- package/dist/lib/components/HotelResult/HotelResult.types.d.ts +1 -1
- package/dist/lib/services/hotel/HotelService.mappers.d.ts +6 -0
- package/dist/services/hotel/HotelService.mappers.js +66 -61
- package/dist/utilities/hotelUtils/hotelUtils.js +77 -78
- package/package.json +1 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import { b as
|
|
3
|
-
import { g as
|
|
4
|
-
import { E as
|
|
2
|
+
import { b as ae } from "../../index-CJj9N0Xq.js";
|
|
3
|
+
import { g as ce } from "../../dateUtils-C1hKW8MF.js";
|
|
4
|
+
import { E as K } from "../../DateFormats-DZD30Nea.js";
|
|
5
5
|
import "../../arrayExtensions-CFEBYUok.js";
|
|
6
|
-
import { useState as
|
|
7
|
-
import
|
|
8
|
-
import { isPartialHotelDetails as
|
|
9
|
-
import { useAwayzContext as
|
|
6
|
+
import { useState as se, useMemo as D } from "react";
|
|
7
|
+
import ie from "../../stores/useHotelsStore.js";
|
|
8
|
+
import { isPartialHotelDetails as re, fetchTransferPartners as ne, fetchPointsCheck as le, fetchAvailableRooms as he, combineUpdatedHotelData as I, fallbackBestCheckout as ue, fetchBestCheckout as De } from "./useHotelDetails.api.js";
|
|
9
|
+
import { useAwayzContext as me, useWallet as fe, EAmountsDisplayFeature as ke } from "@odynn/awayz-core";
|
|
10
10
|
import { useQuery as r } from "@tanstack/react-query";
|
|
11
11
|
import { h as n } from "../../moment-BGjjqtLQ.js";
|
|
12
|
-
import { livePointsCheckTimeout as
|
|
13
|
-
import { HotelChains as
|
|
14
|
-
import { IhgFreeNightCards as
|
|
15
|
-
import { HotelService as
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
const
|
|
19
|
-
var
|
|
12
|
+
import { livePointsCheckTimeout as de } from "../../configs/defaults.js";
|
|
13
|
+
import { HotelChains as pe } from "../../definitions/HotelChains.js";
|
|
14
|
+
import { IhgFreeNightCards as ye } from "../../definitions/IhgFreeNightCards.js";
|
|
15
|
+
import { HotelService as ge } from "../../services/hotel/HotelService.js";
|
|
16
|
+
import { isDuffelHotelId as Ce } from "../../utilities/hotelUtils/hotelUtils.js";
|
|
17
|
+
import { calculatePointsAsCash as Fe } from "../../utilities/pointsAsCashUtils.js";
|
|
18
|
+
const Ie = (a) => {
|
|
19
|
+
var R, A, O, q, S, _, G, B, E, N, P, w, T;
|
|
20
20
|
if (!a)
|
|
21
21
|
throw new Error(
|
|
22
22
|
"Hotel is required in order to initiate the hotel details flow"
|
|
23
23
|
);
|
|
24
|
-
const { user:
|
|
24
|
+
const { user: m, config: f, featureFlags: k } = me(), { updateHotel: g, searchParams: o } = ie(), s = re(a), [e, L] = se({
|
|
25
25
|
checkinDate: s ? n(a.checkinDate) : o == null ? void 0 : o.checkinDate,
|
|
26
26
|
checkoutDate: s ? n(a.checkoutDate) : o == null ? void 0 : o.checkoutDate
|
|
27
27
|
}), {
|
|
28
28
|
data: i,
|
|
29
|
-
isFetching:
|
|
30
|
-
isFetched:
|
|
29
|
+
isFetching: U,
|
|
30
|
+
isFetched: d
|
|
31
31
|
} = r({
|
|
32
32
|
queryKey: [
|
|
33
33
|
"hotelDetails",
|
|
34
34
|
a.hotelId,
|
|
35
35
|
a.hotelGroup,
|
|
36
|
-
(
|
|
37
|
-
(
|
|
36
|
+
(R = e == null ? void 0 : e.checkinDate) == null ? void 0 : R.valueOf(),
|
|
37
|
+
(A = e == null ? void 0 : e.checkoutDate) == null ? void 0 : A.valueOf()
|
|
38
38
|
],
|
|
39
39
|
queryFn: () => {
|
|
40
40
|
var c;
|
|
41
|
-
return
|
|
41
|
+
return ge.searchByHotelId({
|
|
42
42
|
hotel_group: a.hotelGroup,
|
|
43
43
|
hotel_id: a.hotelId,
|
|
44
44
|
check_in_date: n(e.checkinDate).format(
|
|
45
|
-
|
|
45
|
+
K.ServerDate
|
|
46
46
|
),
|
|
47
47
|
check_out_date: n(e.checkoutDate).format(
|
|
48
|
-
|
|
48
|
+
K.ServerDate
|
|
49
49
|
),
|
|
50
50
|
guests: a.guests,
|
|
51
51
|
rooms: a.rooms,
|
|
52
|
-
currency: ((c =
|
|
52
|
+
currency: ((c = m == null ? void 0 : m.userRegion) == null ? void 0 : c.currency) || ae,
|
|
53
53
|
cash_or_points: ["cash", "points"],
|
|
54
|
-
use_duffel:
|
|
54
|
+
use_duffel: f == null ? void 0 : f.supportsDuffel
|
|
55
55
|
});
|
|
56
56
|
},
|
|
57
57
|
enabled: s && !!e.checkinDate && !!e.checkoutDate,
|
|
@@ -59,22 +59,22 @@ const Ne = (a) => {
|
|
|
59
59
|
}), t = D(() => {
|
|
60
60
|
var c;
|
|
61
61
|
return s ? i != null && i.success && ((c = i.data) != null && c[0]) ? i.data[0] : {} : a;
|
|
62
|
-
}, [s, i, a]), h = D(() =>
|
|
63
|
-
|
|
62
|
+
}, [s, i, a]), h = D(() => ce(e.checkinDate, e.checkoutDate), [e]), x = (c, l) => {
|
|
63
|
+
L({
|
|
64
64
|
checkinDate: n(c),
|
|
65
65
|
checkoutDate: n(l)
|
|
66
66
|
});
|
|
67
|
-
}, { userCards: u } = fe(),
|
|
67
|
+
}, { userCards: u } = fe(), C = D(() => (t == null ? void 0 : t.hotelGroup) === pe.IHG ? ye.some(
|
|
68
68
|
(c) => u == null ? void 0 : u.some((l) => l.name === c)
|
|
69
|
-
) : !0, [u]), { data:
|
|
69
|
+
) : !0, [u]), { data: W, isFetching: z } = r({
|
|
70
70
|
queryKey: ["transferPartners", t.hotelGroup],
|
|
71
|
-
queryFn: () =>
|
|
71
|
+
queryFn: () => ne(t.hotelGroup),
|
|
72
72
|
enabled: !!t.hotelGroup,
|
|
73
73
|
placeholderData: []
|
|
74
74
|
}), {
|
|
75
|
-
data:
|
|
76
|
-
isFetching:
|
|
77
|
-
isFetched:
|
|
75
|
+
data: M,
|
|
76
|
+
isFetching: F,
|
|
77
|
+
isFetched: Q
|
|
78
78
|
} = r({
|
|
79
79
|
queryKey: [
|
|
80
80
|
"hotelPointsCheck",
|
|
@@ -84,16 +84,16 @@ const Ne = (a) => {
|
|
|
84
84
|
(q = e == null ? void 0 : e.checkoutDate) == null ? void 0 : q.valueOf()
|
|
85
85
|
],
|
|
86
86
|
queryFn: ({ signal: c }) => {
|
|
87
|
-
const l = AbortSignal.timeout(
|
|
88
|
-
return
|
|
87
|
+
const l = AbortSignal.timeout(de), oe = AbortSignal.any([c, l]);
|
|
88
|
+
return le({
|
|
89
89
|
hotel: t,
|
|
90
90
|
checkinDate: e.checkinDate,
|
|
91
91
|
checkoutDate: e.checkoutDate,
|
|
92
92
|
updateHotel: g,
|
|
93
|
-
signal:
|
|
93
|
+
signal: oe
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (!s ||
|
|
96
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!t.liveScrapingCheckNeeded && (k == null ? void 0 : k.amountsDisplayFeature) === ke.CASH_AND_TRAVEL_PARTNER_POINTS && (!s || d),
|
|
97
97
|
// We don't throw an error on fail so we can gracefully handle fallback
|
|
98
98
|
retry: !1,
|
|
99
99
|
refetchOnWindowFocus: !1,
|
|
@@ -102,23 +102,23 @@ const Ne = (a) => {
|
|
|
102
102
|
pointsHotelDetails: t,
|
|
103
103
|
pointsRooms: t.rooms ?? []
|
|
104
104
|
}
|
|
105
|
-
}), { pointsRooms:
|
|
105
|
+
}), { pointsRooms: V, pointsHotelDetails: p } = M || {
|
|
106
106
|
pointsHotelDetails: t,
|
|
107
107
|
pointsRooms: []
|
|
108
108
|
}, {
|
|
109
109
|
data: Y,
|
|
110
|
-
isFetching:
|
|
110
|
+
isFetching: v,
|
|
111
111
|
isFetched: j
|
|
112
112
|
} = r({
|
|
113
113
|
queryKey: [
|
|
114
114
|
"fetchAvailableRooms",
|
|
115
|
-
(
|
|
116
|
-
(
|
|
115
|
+
(S = t.cashBookingOffers) == null ? void 0 : S.accommodationId,
|
|
116
|
+
(_ = e == null ? void 0 : e.checkinDate) == null ? void 0 : _.valueOf(),
|
|
117
117
|
(G = e == null ? void 0 : e.checkoutDate) == null ? void 0 : G.valueOf(),
|
|
118
118
|
o == null ? void 0 : o.guests,
|
|
119
119
|
o == null ? void 0 : o.rooms
|
|
120
120
|
],
|
|
121
|
-
queryFn: () =>
|
|
121
|
+
queryFn: () => he({
|
|
122
122
|
hotel: t,
|
|
123
123
|
checkinDate: e.checkinDate,
|
|
124
124
|
checkoutDate: e.checkoutDate,
|
|
@@ -127,82 +127,82 @@ const Ne = (a) => {
|
|
|
127
127
|
updateHotel: g,
|
|
128
128
|
numberOfNights: h
|
|
129
129
|
}),
|
|
130
|
-
enabled: !!e.checkinDate && !!e.checkoutDate && !!((
|
|
130
|
+
enabled: !!e.checkinDate && !!e.checkoutDate && !!((B = t.cashBookingOffers) != null && B.accommodationId) && (!s || d),
|
|
131
131
|
retry: !1,
|
|
132
132
|
placeholderData: {
|
|
133
133
|
cashHotelDetails: t,
|
|
134
134
|
cashRooms: []
|
|
135
135
|
}
|
|
136
|
-
}), { cashRooms: J, cashHotelDetails:
|
|
136
|
+
}), { cashRooms: J, cashHotelDetails: y } = Y || {
|
|
137
137
|
cashHotelDetails: t,
|
|
138
138
|
cashRooms: []
|
|
139
|
-
},
|
|
140
|
-
() =>
|
|
141
|
-
[t,
|
|
139
|
+
}, X = D(
|
|
140
|
+
() => I(t, p, y),
|
|
141
|
+
[t, p, y]
|
|
142
142
|
), {
|
|
143
|
-
data:
|
|
144
|
-
isFetching:
|
|
145
|
-
isFetched:
|
|
143
|
+
data: Z,
|
|
144
|
+
isFetching: $,
|
|
145
|
+
isFetched: ee
|
|
146
146
|
} = r({
|
|
147
147
|
queryKey: [
|
|
148
148
|
"bestCheckout",
|
|
149
149
|
t.hotelId,
|
|
150
150
|
t.hotelGroup,
|
|
151
|
-
(
|
|
152
|
-
(
|
|
153
|
-
|
|
151
|
+
(E = e == null ? void 0 : e.checkinDate) == null ? void 0 : E.valueOf(),
|
|
152
|
+
(N = e == null ? void 0 : e.checkoutDate) == null ? void 0 : N.valueOf(),
|
|
153
|
+
C
|
|
154
154
|
],
|
|
155
|
-
queryFn: () =>
|
|
156
|
-
|
|
155
|
+
queryFn: () => De(
|
|
156
|
+
X,
|
|
157
157
|
h,
|
|
158
|
-
|
|
158
|
+
C
|
|
159
159
|
),
|
|
160
|
-
enabled: !
|
|
160
|
+
enabled: !Ce(t.hotelId) && !F && (t.liveScrapingCheckNeeded ? Q : !0) && !v && ((P = t.cashBookingOffers) != null && P.accommodationId ? j : !0) && h > 0 && t.points >= 0 && (!s || d),
|
|
161
161
|
retry: !1,
|
|
162
162
|
placeholderData: {
|
|
163
|
-
bestCheckout:
|
|
163
|
+
bestCheckout: ue(t, h),
|
|
164
164
|
isAvailable: !1
|
|
165
165
|
}
|
|
166
|
-
}), { bestCheckout:
|
|
166
|
+
}), { bestCheckout: b, isAvailable: H } = Z || {
|
|
167
167
|
isAvailable: !1
|
|
168
|
-
}, { data:
|
|
168
|
+
}, { data: te } = r({
|
|
169
169
|
queryKey: [
|
|
170
170
|
"pointsAsCash",
|
|
171
171
|
t.hotelId,
|
|
172
172
|
t.hotelGroup,
|
|
173
|
-
(
|
|
174
|
-
(
|
|
173
|
+
(w = e == null ? void 0 : e.checkinDate) == null ? void 0 : w.valueOf(),
|
|
174
|
+
(T = e == null ? void 0 : e.checkoutDate) == null ? void 0 : T.valueOf()
|
|
175
175
|
],
|
|
176
|
-
queryFn: () =>
|
|
177
|
-
enabled:
|
|
176
|
+
queryFn: () => Fe(b.totalCashCost),
|
|
177
|
+
enabled: ee && H,
|
|
178
178
|
retry: !1
|
|
179
179
|
});
|
|
180
180
|
return {
|
|
181
|
-
transferPartners:
|
|
182
|
-
loadingTransferPartners:
|
|
181
|
+
transferPartners: W || [],
|
|
182
|
+
loadingTransferPartners: z,
|
|
183
183
|
// Hotel Details
|
|
184
|
-
loadingHotelDetails:
|
|
184
|
+
loadingHotelDetails: U,
|
|
185
185
|
// Points Check
|
|
186
|
-
pointsRooms:
|
|
187
|
-
loadingLivePointsCheck:
|
|
186
|
+
pointsRooms: V || [],
|
|
187
|
+
loadingLivePointsCheck: F,
|
|
188
188
|
// Cash Rooms
|
|
189
189
|
cashRooms: J || [],
|
|
190
|
-
loadingCashRooms:
|
|
190
|
+
loadingCashRooms: v,
|
|
191
191
|
// Best Checkout
|
|
192
|
-
bestCheckout:
|
|
193
|
-
loadingBestCheckout:
|
|
192
|
+
bestCheckout: b,
|
|
193
|
+
loadingBestCheckout: $,
|
|
194
194
|
// Combined availability
|
|
195
|
-
isAvailable:
|
|
195
|
+
isAvailable: H,
|
|
196
196
|
// Points as Cash
|
|
197
|
-
pointsAsCash:
|
|
198
|
-
hotelDetails:
|
|
197
|
+
pointsAsCash: te,
|
|
198
|
+
hotelDetails: I(
|
|
199
199
|
t,
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
p,
|
|
201
|
+
y
|
|
202
202
|
),
|
|
203
|
-
updateDates:
|
|
203
|
+
updateDates: x
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
export {
|
|
207
|
-
|
|
207
|
+
Ie as useHotelDetails
|
|
208
208
|
};
|
|
@@ -12,7 +12,6 @@ export interface IHotelDetails {
|
|
|
12
12
|
amount: number;
|
|
13
13
|
};
|
|
14
14
|
cashBookingOffers?: ICashBookingOffers;
|
|
15
|
-
chainRating: number;
|
|
16
15
|
city: string;
|
|
17
16
|
cityCode: string;
|
|
18
17
|
coordinates: ICoordinates;
|
|
@@ -61,6 +60,7 @@ export interface IHotelDetails {
|
|
|
61
60
|
checkInInformation?: ICheckInInformation;
|
|
62
61
|
checkinDate?: string;
|
|
63
62
|
checkoutDate?: string;
|
|
63
|
+
starRating: number;
|
|
64
64
|
}
|
|
65
65
|
export interface IHotelPartner {
|
|
66
66
|
bonus: number;
|
|
@@ -2,6 +2,12 @@ import { ITransferPartner } from '@type-op/shared';
|
|
|
2
2
|
import { ICashBookingOffers, IHotelDetails, ILiveHotelCheck } from '../../components/HotelResult/HotelResult.types';
|
|
3
3
|
import { IAmenity, IRate, IRoom } from '../booking/BookingService.types';
|
|
4
4
|
import { ICashBookingOffersResponse, IHotelResultResponse, ILiveHotelCheckResponse, IRateResponse, IRoomResponse, ITransferPartnerResponse } from './HotelService.types';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves hotel star rating.
|
|
7
|
+
* Prioritizes Duffel (cash booking offers) ratings,
|
|
8
|
+
* then falls back to scraped chain rating.
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveHotelStarRating: (hotel: IHotelResultResponse) => number;
|
|
5
11
|
/**
|
|
6
12
|
* Map API rate response to IRate.
|
|
7
13
|
*/
|
|
@@ -1,66 +1,70 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = (e) => {
|
|
2
2
|
if (e == null) return 0;
|
|
3
3
|
if (typeof e == "number") return e;
|
|
4
4
|
if (typeof e == "string") {
|
|
5
|
-
const
|
|
6
|
-
return isNaN(
|
|
5
|
+
const n = parseFloat(e);
|
|
6
|
+
return isNaN(n) ? 0 : n;
|
|
7
7
|
}
|
|
8
8
|
return 0;
|
|
9
9
|
}, d = (e) => {
|
|
10
10
|
if (e != null) {
|
|
11
11
|
if (typeof e == "number") return e;
|
|
12
12
|
if (typeof e == "string") {
|
|
13
|
-
const
|
|
14
|
-
return isNaN(
|
|
13
|
+
const n = parseFloat(e);
|
|
14
|
+
return isNaN(n) ? void 0 : n;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}, w = (e) => {
|
|
18
|
-
var
|
|
18
|
+
var i;
|
|
19
|
+
const n = e.cash_booking_offers, t = (i = n == null ? void 0 : n.ratings) != null && i.length ? Math.max(...n.ratings.map((s) => s.value)) : void 0;
|
|
20
|
+
return (n == null ? void 0 : n.rating) ?? t ?? e.chain_rating ?? 0;
|
|
21
|
+
}, R = (e) => {
|
|
22
|
+
var n;
|
|
19
23
|
return {
|
|
20
24
|
publicCurrency: e.public_currency,
|
|
21
25
|
dueAtAccommodationCurrency: e.due_at_accommodation_currency,
|
|
22
26
|
dueAtAccommodationAmount: d(
|
|
23
27
|
e.due_at_accommodation_amount
|
|
24
28
|
),
|
|
25
|
-
quantityAvailable:
|
|
29
|
+
quantityAvailable: a(e.quantity_available),
|
|
26
30
|
publicAmount: d(e.public_amount),
|
|
27
31
|
dealTypes: e.deal_types ?? void 0,
|
|
28
|
-
cancellationTimeline: ((
|
|
32
|
+
cancellationTimeline: ((n = e.cancellation_timeline) == null ? void 0 : n.map((t) => ({
|
|
29
33
|
before: t.before,
|
|
30
34
|
currency: t.currency,
|
|
31
|
-
refundAmount:
|
|
35
|
+
refundAmount: a(t.refund_amount)
|
|
32
36
|
}))) ?? [],
|
|
33
37
|
boardType: e.board_type,
|
|
34
38
|
supportedLoyaltyProgramme: e.supported_loyalty_programme ?? void 0,
|
|
35
39
|
availablePaymentMethods: e.available_payment_methods ?? [],
|
|
36
|
-
feeAmount:
|
|
40
|
+
feeAmount: a(e.fee_amount),
|
|
37
41
|
taxCurrency: e.tax_currency,
|
|
38
42
|
baseCurrency: e.base_currency,
|
|
39
|
-
baseAmount:
|
|
40
|
-
taxAmount:
|
|
43
|
+
baseAmount: a(e.base_amount),
|
|
44
|
+
taxAmount: a(e.tax_amount),
|
|
41
45
|
feeCurrency: e.fee_currency,
|
|
42
46
|
totalCurrency: e.total_currency,
|
|
43
47
|
paymentType: e.payment_type,
|
|
44
|
-
totalAmount:
|
|
48
|
+
totalAmount: a(e.total_amount),
|
|
45
49
|
conditions: e.conditions ?? [],
|
|
46
50
|
source: e.source,
|
|
47
51
|
id: e.id
|
|
48
52
|
};
|
|
49
53
|
}, p = (e) => {
|
|
50
|
-
var
|
|
54
|
+
var n, t, i, s;
|
|
51
55
|
return {
|
|
52
56
|
roomId: e.room_id,
|
|
53
|
-
rates: ((
|
|
57
|
+
rates: ((n = e.rates) == null ? void 0 : n.map(R)) ?? [],
|
|
54
58
|
roomTitle: e.room_title,
|
|
55
59
|
roomType: e.room_type,
|
|
56
60
|
roomCategory: e.room_category,
|
|
57
61
|
roomDescription: e.room_description,
|
|
58
62
|
roomImage: e.room_image,
|
|
59
|
-
lowestPointsRate:
|
|
60
|
-
lowestAwardPointsRate:
|
|
63
|
+
lowestPointsRate: a(e.lowest_points_rate),
|
|
64
|
+
lowestAwardPointsRate: a(e.lowest_award_points_rate),
|
|
61
65
|
lowestCashRate: {
|
|
62
66
|
currency: ((t = e.lowest_cash_rate) == null ? void 0 : t.currency) ?? "",
|
|
63
|
-
cashAmount:
|
|
67
|
+
cashAmount: a((i = e.lowest_cash_rate) == null ? void 0 : i.cash_amount)
|
|
64
68
|
},
|
|
65
69
|
roomRatePlans: ((s = e.room_rate_plans) == null ? void 0 : s.map((o) => {
|
|
66
70
|
var _, m;
|
|
@@ -69,9 +73,9 @@ const n = (e) => {
|
|
|
69
73
|
ratePlanName: o.rate_plan_name,
|
|
70
74
|
ratePlanType: o.rate_plan_type,
|
|
71
75
|
ratePlanCategory: o.rate_plan_category,
|
|
72
|
-
ratePlanPoints:
|
|
76
|
+
ratePlanPoints: a(o.rate_plan_points),
|
|
73
77
|
ratePlanCash: {
|
|
74
|
-
cashAmount:
|
|
78
|
+
cashAmount: a((_ = o.rate_plan_cash) == null ? void 0 : _.cash_amount),
|
|
75
79
|
currency: ((m = o.rate_plan_cash) == null ? void 0 : m.currency) ?? ""
|
|
76
80
|
}
|
|
77
81
|
};
|
|
@@ -81,24 +85,24 @@ const n = (e) => {
|
|
|
81
85
|
beds: e.beds
|
|
82
86
|
};
|
|
83
87
|
}, T = (e) => {
|
|
84
|
-
var
|
|
88
|
+
var n, t, i, s, o, _, m, c, u, r, l, y, g, f, h, v, C, k, b, P;
|
|
85
89
|
if (e)
|
|
86
90
|
return {
|
|
87
91
|
searchRoomRateId: e.search_room_rate_id,
|
|
88
92
|
accommodationId: e.accommodation_id,
|
|
89
93
|
matchedType: e.matched_type,
|
|
90
|
-
rooms: ((
|
|
94
|
+
rooms: ((n = e.rooms) == null ? void 0 : n.map(p)) ?? [],
|
|
91
95
|
ratings: e.ratings ?? [],
|
|
92
|
-
rating:
|
|
93
|
-
reviewScore:
|
|
96
|
+
rating: a(e.rating),
|
|
97
|
+
reviewScore: a(e.review_score),
|
|
94
98
|
reviewCount: d(e.review_count),
|
|
95
99
|
photos: e.photos ?? [],
|
|
96
100
|
phoneNumber: e.phone_number ?? "",
|
|
97
101
|
name: e.name ?? "",
|
|
98
102
|
location: {
|
|
99
103
|
geographicCoordinates: {
|
|
100
|
-
latitude:
|
|
101
|
-
longitude:
|
|
104
|
+
latitude: a((i = (t = e.location) == null ? void 0 : t.geographic_coordinates) == null ? void 0 : i.latitude),
|
|
105
|
+
longitude: a((o = (s = e.location) == null ? void 0 : s.geographic_coordinates) == null ? void 0 : o.longitude)
|
|
102
106
|
},
|
|
103
107
|
address: {
|
|
104
108
|
region: ((m = (_ = e.location) == null ? void 0 : _.address) == null ? void 0 : m.region) ?? null,
|
|
@@ -112,15 +116,15 @@ const n = (e) => {
|
|
|
112
116
|
email: e.email,
|
|
113
117
|
description: e.description ?? "",
|
|
114
118
|
checkInInformation: {
|
|
115
|
-
checkInAfterTime: ((
|
|
116
|
-
checkOutBeforeTime: ((
|
|
117
|
-
checkInBeforeTime: ((
|
|
119
|
+
checkInAfterTime: ((v = e.check_in_information) == null ? void 0 : v.check_in_after_time) ?? "",
|
|
120
|
+
checkOutBeforeTime: ((C = e.check_in_information) == null ? void 0 : C.check_out_before_time) ?? "",
|
|
121
|
+
checkInBeforeTime: ((k = e.check_in_information) == null ? void 0 : k.check_in_before_time) ?? ""
|
|
118
122
|
},
|
|
119
|
-
matchedScore:
|
|
123
|
+
matchedScore: a(e.matched_score),
|
|
120
124
|
keyCollection: e.key_collection,
|
|
121
|
-
cheapestRateTotalAmount:
|
|
125
|
+
cheapestRateTotalAmount: a(e.cheapest_rate_total_amount),
|
|
122
126
|
cheapestRateCurrency: e.cheapest_rate_currency ?? "",
|
|
123
|
-
chain: { name: ((
|
|
127
|
+
chain: { name: ((b = e.chain) == null ? void 0 : b.name) ?? "" },
|
|
124
128
|
brand: { name: ((P = e.brand) == null ? void 0 : P.name) ?? "" },
|
|
125
129
|
supportedLoyaltyProgramme: e.supported_loyalty_programme,
|
|
126
130
|
amenities: e.amenities ?? []
|
|
@@ -128,7 +132,7 @@ const n = (e) => {
|
|
|
128
132
|
}, A = (e) => ({
|
|
129
133
|
bonus: (e == null ? void 0 : e.bonus) ?? 0,
|
|
130
134
|
stepThreshold: (e == null ? void 0 : e.step_threshold) ?? 0
|
|
131
|
-
}),
|
|
135
|
+
}), N = (e) => ({
|
|
132
136
|
program: e.program,
|
|
133
137
|
ratio: e.ratio,
|
|
134
138
|
bonus: e.bonus,
|
|
@@ -136,7 +140,7 @@ const n = (e) => {
|
|
|
136
140
|
minimumTransfer: e.minimum_transfer,
|
|
137
141
|
transferDenominator: e.transfer_denominator,
|
|
138
142
|
stepBonus: A(e.step_bonus)
|
|
139
|
-
}),
|
|
143
|
+
}), I = (e) => {
|
|
140
144
|
if (e)
|
|
141
145
|
return {
|
|
142
146
|
program: e.program,
|
|
@@ -149,7 +153,7 @@ const n = (e) => {
|
|
|
149
153
|
valueCent: e.value_cent,
|
|
150
154
|
logo: e.logo
|
|
151
155
|
};
|
|
152
|
-
},
|
|
156
|
+
}, L = (e) => {
|
|
153
157
|
if (e)
|
|
154
158
|
return {
|
|
155
159
|
pointsAsCashRequired: e.points_as_cash_required,
|
|
@@ -157,9 +161,9 @@ const n = (e) => {
|
|
|
157
161
|
totalPointsUsed: e.total_points_used,
|
|
158
162
|
awardProgram: e.award_program
|
|
159
163
|
};
|
|
160
|
-
},
|
|
164
|
+
}, x = (e, n) => {
|
|
161
165
|
var i, s, o, _, m, c, u;
|
|
162
|
-
const t =
|
|
166
|
+
const t = n ?? ((r) => ({
|
|
163
167
|
description: r,
|
|
164
168
|
type: r.toLowerCase().replace(/\s/g, "_")
|
|
165
169
|
}));
|
|
@@ -174,14 +178,13 @@ const n = (e) => {
|
|
|
174
178
|
bookingLinkPoints: e.booking_link_points,
|
|
175
179
|
cashValue: {
|
|
176
180
|
currency: ((s = e.cash_value) == null ? void 0 : s.currency) ?? "",
|
|
177
|
-
amount:
|
|
181
|
+
amount: a((o = e.cash_value) == null ? void 0 : o.amount)
|
|
178
182
|
},
|
|
179
|
-
chainRating: e.chain_rating,
|
|
180
183
|
city: e.city,
|
|
181
184
|
cityCode: e.city_code,
|
|
182
185
|
coordinates: {
|
|
183
|
-
latitude:
|
|
184
|
-
longitude:
|
|
186
|
+
latitude: a((_ = e.coordinates) == null ? void 0 : _.latitude),
|
|
187
|
+
longitude: a((m = e.coordinates) == null ? void 0 : m.longitude)
|
|
185
188
|
},
|
|
186
189
|
country: e.country,
|
|
187
190
|
countryCode: e.country_code,
|
|
@@ -211,19 +214,20 @@ const n = (e) => {
|
|
|
211
214
|
premiumPointsAvailable: e.premium_points_available,
|
|
212
215
|
standardPointsAvailable: e.standard_points_available,
|
|
213
216
|
liveScrapingCheckNeeded: e.live_scraping_check_needed,
|
|
214
|
-
partners: ((u = e.partners) == null ? void 0 : u.map(
|
|
215
|
-
hotelProgram:
|
|
217
|
+
partners: ((u = e.partners) == null ? void 0 : u.map(N)) ?? [],
|
|
218
|
+
hotelProgram: I(e.hotel_program),
|
|
216
219
|
pointsProgramDisplay: e.points_program_display,
|
|
217
220
|
bestValue: e.best_value,
|
|
218
|
-
pointsAsCash:
|
|
221
|
+
pointsAsCash: L(e.points_as_cash),
|
|
219
222
|
cashBookingOffers: T(e.cash_booking_offers),
|
|
220
223
|
distance: 0,
|
|
221
224
|
// Calculated separately
|
|
222
|
-
pointsCalculated: 0
|
|
225
|
+
pointsCalculated: 0,
|
|
223
226
|
// Calculated separately
|
|
227
|
+
starRating: w(e)
|
|
224
228
|
};
|
|
225
|
-
},
|
|
226
|
-
var
|
|
229
|
+
}, S = (e) => {
|
|
230
|
+
var n, t, i, s, o;
|
|
227
231
|
return {
|
|
228
232
|
hotelName: e.hotel_name,
|
|
229
233
|
hotelNameKey: e.hotel_name_key,
|
|
@@ -232,24 +236,24 @@ const n = (e) => {
|
|
|
232
236
|
state: e.state,
|
|
233
237
|
hotelId: e.hotel_id,
|
|
234
238
|
points: {
|
|
235
|
-
pointsType: ((
|
|
236
|
-
pointsValue:
|
|
237
|
-
awardPointsValue:
|
|
239
|
+
pointsType: ((n = e.points) == null ? void 0 : n.points_type) ?? "",
|
|
240
|
+
pointsValue: a((t = e.points) == null ? void 0 : t.points_value),
|
|
241
|
+
awardPointsValue: a((i = e.points) == null ? void 0 : i.award_points_value),
|
|
238
242
|
availability: ((s = e.points) == null ? void 0 : s.availability) ?? !1
|
|
239
243
|
},
|
|
240
244
|
rooms: ((o = e.rooms) == null ? void 0 : o.map(p)) ?? []
|
|
241
245
|
};
|
|
242
246
|
}, D = (e) => {
|
|
243
|
-
var
|
|
247
|
+
var n, t;
|
|
244
248
|
return {
|
|
245
249
|
partnerProgram: e.partner_program,
|
|
246
|
-
ratio:
|
|
247
|
-
bonus:
|
|
248
|
-
transferMinutes:
|
|
249
|
-
minimumTransfer:
|
|
250
|
-
transferDenominator:
|
|
250
|
+
ratio: a(e.ratio),
|
|
251
|
+
bonus: a(e.bonus),
|
|
252
|
+
transferMinutes: a(e.transfer_minutes),
|
|
253
|
+
minimumTransfer: a(e.minimum_transfer),
|
|
254
|
+
transferDenominator: a(e.transfer_denominator),
|
|
251
255
|
stepBonus: {
|
|
252
|
-
bonus: ((
|
|
256
|
+
bonus: ((n = e.step_bonus) == null ? void 0 : n.bonus) ?? 0,
|
|
253
257
|
stepThreshold: ((t = e.step_bonus) == null ? void 0 : t.step_threshold) ?? 0
|
|
254
258
|
},
|
|
255
259
|
steps: e.steps ?? [],
|
|
@@ -263,9 +267,10 @@ const n = (e) => {
|
|
|
263
267
|
};
|
|
264
268
|
export {
|
|
265
269
|
T as mapCashBookingOffersResponse,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
x as mapHotelResponse,
|
|
271
|
+
S as mapLiveHotelCheckResponse,
|
|
272
|
+
R as mapRateResponse,
|
|
269
273
|
p as mapRoomResponse,
|
|
270
|
-
D as mapTransferPartnerResponse
|
|
274
|
+
D as mapTransferPartnerResponse,
|
|
275
|
+
w as resolveHotelStarRating
|
|
271
276
|
};
|
|
@@ -1,128 +1,127 @@
|
|
|
1
|
-
import { HotelChains as
|
|
2
|
-
var
|
|
3
|
-
static initParams(
|
|
4
|
-
return [
|
|
1
|
+
import { HotelChains as m } from "../../definitions/HotelChains.js";
|
|
2
|
+
var f = class l {
|
|
3
|
+
static initParams(e, n) {
|
|
4
|
+
return [e.replace(/\s+/g, "").toLowerCase(), n.replace(/\s+/g, "").toLowerCase()];
|
|
5
5
|
}
|
|
6
|
-
static checkThanosType(
|
|
7
|
-
if (typeof
|
|
6
|
+
static checkThanosType(e) {
|
|
7
|
+
if (typeof e != "string") throw new Error("first argument should be a string");
|
|
8
8
|
}
|
|
9
|
-
static checkRivalType(
|
|
10
|
-
if (typeof
|
|
9
|
+
static checkRivalType(e) {
|
|
10
|
+
if (typeof e != "string") throw new Error("second argument should be a string");
|
|
11
11
|
}
|
|
12
|
-
static checkAvengersType(
|
|
13
|
-
if (!Array.isArray(
|
|
14
|
-
if (
|
|
12
|
+
static checkAvengersType(e) {
|
|
13
|
+
if (!Array.isArray(e)) throw new Error("second argument should be an array of strings");
|
|
14
|
+
if (e.find((n) => typeof n != "string")) throw new Error("second argument should be an array of strings");
|
|
15
15
|
}
|
|
16
|
-
sortMatch(
|
|
17
|
-
return
|
|
16
|
+
sortMatch(e, n) {
|
|
17
|
+
return l.checkThanosType(e), l.checkAvengersType(n), n.map((s, o) => ({ member: s, index: o, rating: this.similarity(e, s) })).sort((s, o) => s.rating - o.rating);
|
|
18
18
|
}
|
|
19
|
-
}, g = class extends
|
|
20
|
-
similarity(
|
|
21
|
-
|
|
22
|
-
let [n,
|
|
23
|
-
if (!n.length && !
|
|
24
|
-
if (
|
|
19
|
+
}, g = class extends f {
|
|
20
|
+
similarity(t, e) {
|
|
21
|
+
f.checkThanosType(t), f.checkRivalType(e);
|
|
22
|
+
let [n, s] = f.initParams(t, e), [o, a] = [n.length, s.length];
|
|
23
|
+
if (!n.length && !s.length || n === s) return 1;
|
|
24
|
+
if (o < 2 || a < 2) return 0;
|
|
25
25
|
let c = /* @__PURE__ */ new Map();
|
|
26
|
-
for (let r = 0; r <
|
|
26
|
+
for (let r = 0; r < o - 1; r++) {
|
|
27
27
|
let i = n.slice(r, r + 2), h = c.has(i) ? c.get(i) + 1 : 1;
|
|
28
28
|
c.set(i, h);
|
|
29
29
|
}
|
|
30
30
|
let u = 0;
|
|
31
31
|
for (let r = 0; r < a - 1; r++) {
|
|
32
|
-
let i =
|
|
32
|
+
let i = s.slice(r, r + 2), h = c.has(i) ? c.get(i) : 0;
|
|
33
33
|
h > 0 && (c.set(i, h - 1), ++u);
|
|
34
34
|
}
|
|
35
|
-
return 2 * u / (
|
|
35
|
+
return 2 * u / (o + a - 2);
|
|
36
36
|
}
|
|
37
|
-
distance(
|
|
38
|
-
return 1 - this.similarity(
|
|
37
|
+
distance(t, e) {
|
|
38
|
+
return 1 - this.similarity(t, e);
|
|
39
39
|
}
|
|
40
|
-
}, y = new g(), w = { diceCoefficient: y },
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
}, y = new g(), w = { diceCoefficient: y }, b = w;
|
|
41
|
+
const v = (t, e, n, s) => {
|
|
42
|
+
const o = (p) => p * Math.PI / 180, c = o(Number(t)), u = o(Number(n)), r = o(Number(n) - Number(t)), i = o(Number(s) - Number(e)), h = Math.sin(r / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin(i / 2) ** 2;
|
|
43
43
|
return 6371 * 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));
|
|
44
|
-
}, T = (
|
|
45
|
-
|
|
46
|
-
const t = e.cashBookingOffers, n = (o = t == null ? void 0 : t.ratings) != null && o.length ? Math.max(...t.ratings.map((s) => s.value)) : void 0;
|
|
44
|
+
}, T = (t) => {
|
|
45
|
+
const e = t.cashBookingOffers;
|
|
47
46
|
return {
|
|
48
|
-
starRating:
|
|
49
|
-
userRating: (
|
|
50
|
-
reviewCount: (
|
|
47
|
+
starRating: t.starRating,
|
|
48
|
+
userRating: (e == null ? void 0 : e.reviewScore) ?? (t.reviewRating ? Number(t.reviewRating) * 2 : ""),
|
|
49
|
+
reviewCount: (e == null ? void 0 : e.reviewCount) ?? t.reviewCount
|
|
51
50
|
};
|
|
52
|
-
}, k = (
|
|
53
|
-
const
|
|
54
|
-
if (isNaN(
|
|
55
|
-
const n =
|
|
56
|
-
return n.endsWith(".0") ? String(Math.trunc(
|
|
57
|
-
}, M = (
|
|
58
|
-
if (!
|
|
59
|
-
const
|
|
60
|
-
if (isNaN(
|
|
61
|
-
if (
|
|
62
|
-
const n =
|
|
63
|
-
return `${
|
|
51
|
+
}, k = (t) => {
|
|
52
|
+
const e = typeof t == "number" ? t : Number(t);
|
|
53
|
+
if (isNaN(e)) return String(t);
|
|
54
|
+
const n = e.toFixed(1);
|
|
55
|
+
return n.endsWith(".0") ? String(Math.trunc(e)) : n;
|
|
56
|
+
}, M = (t) => {
|
|
57
|
+
if (!t) return null;
|
|
58
|
+
const e = typeof t == "number" ? t : Number(t);
|
|
59
|
+
if (isNaN(e)) return String(t);
|
|
60
|
+
if (e >= 1e3) {
|
|
61
|
+
const n = e / 1e3, s = n.toFixed(1);
|
|
62
|
+
return `${s.endsWith(".0") ? n.toFixed(0) : s}k`;
|
|
64
63
|
}
|
|
65
|
-
return String(
|
|
66
|
-
},
|
|
64
|
+
return String(e);
|
|
65
|
+
}, C = (t) => {
|
|
67
66
|
var h;
|
|
68
|
-
const
|
|
67
|
+
const e = t.freeNight || t.nthNightFree !== 0 ? t.awardPoints : t.points, n = {
|
|
69
68
|
type: "",
|
|
70
69
|
value: -1
|
|
71
|
-
},
|
|
72
|
-
return
|
|
73
|
-
transferPartners: ((h =
|
|
70
|
+
}, s = typeof t.cashValue.amount == "number" ? t.cashValue.amount : parseFloat(t.cashValue.amount), o = { ...n }, { cashBookingOffers: a } = t, c = (a == null ? void 0 : a.cheapestRateCurrency) || t.cashValue.currency, u = a == null ? void 0 : a.cheapestRateTotalAmount, r = u && u > 0 ? u : s, i = m.isHotelChain(t.hotelGroup);
|
|
71
|
+
return t.bestValue === "cash" ? (n.type = "cash", n.value = r, o.type = "points", o.value = e || -1) : t.bestValue === "points" && (n.type = "points", n.value = e || -1, o.type = "cash", o.value = r), {
|
|
72
|
+
transferPartners: ((h = t.partners) == null ? void 0 : h.map((p) => ({
|
|
74
73
|
...p,
|
|
75
|
-
value:
|
|
74
|
+
value: e ? Math.ceil(e * p.ratio) : -1
|
|
76
75
|
}))) || [],
|
|
77
76
|
bestBookingOption: n,
|
|
78
|
-
alternateBookingOption:
|
|
79
|
-
points:
|
|
80
|
-
hasPoints: typeof
|
|
77
|
+
alternateBookingOption: o,
|
|
78
|
+
points: e || -1,
|
|
79
|
+
hasPoints: typeof e == "number" && e > 0,
|
|
81
80
|
cashAmount: r,
|
|
82
81
|
cashCurrency: c,
|
|
83
82
|
duffelCashBookingOffers: a,
|
|
84
83
|
isHotelChain: i
|
|
85
84
|
};
|
|
86
|
-
},
|
|
87
|
-
function
|
|
88
|
-
return !
|
|
85
|
+
}, L = (t) => (t == null ? void 0 : t.hotelGroup) === m.IHG ? t.freeNight || t.nthNightFree ? t.awardPoints : t.points : t.awardPoints;
|
|
86
|
+
function x(t) {
|
|
87
|
+
return !t || !Array.isArray(t) || t.length === 0 ? [] : t.map((e) => typeof e == "string" ? e : e && typeof e == "object" && "url" in e ? e.url : "").filter((e) => e !== "");
|
|
89
88
|
}
|
|
90
|
-
const
|
|
91
|
-
const
|
|
89
|
+
const A = async (t, e, n) => {
|
|
90
|
+
const s = (o) => new Promise((a, c) => {
|
|
92
91
|
const u = new Image();
|
|
93
|
-
u.src =
|
|
92
|
+
u.src = o, u.onload = () => a(o), u.onerror = () => c();
|
|
94
93
|
});
|
|
95
|
-
return
|
|
96
|
-
},
|
|
97
|
-
const n =
|
|
98
|
-
return
|
|
99
|
-
},
|
|
100
|
-
const
|
|
94
|
+
return t && await s(t).catch(() => !1) ? t : e && await s(e).catch(() => !1) ? e : n;
|
|
95
|
+
}, d = (t, e) => {
|
|
96
|
+
const n = t.toLowerCase().trim(), s = e.toLowerCase().trim();
|
|
97
|
+
return b.diceCoefficient.similarity(n, s) * 100;
|
|
98
|
+
}, P = (t) => (t == null ? void 0 : t.startsWith("duff_")) ?? !1, R = (t, e, n, s) => {
|
|
99
|
+
const o = t.toLowerCase().trim(), a = s.map((r) => {
|
|
101
100
|
const i = r.description.toLowerCase().trim();
|
|
102
101
|
return {
|
|
103
102
|
...r,
|
|
104
|
-
score:
|
|
103
|
+
score: d(t, r.description),
|
|
105
104
|
startsWithText: i
|
|
106
105
|
};
|
|
107
106
|
}), c = a.filter(
|
|
108
|
-
(r) => r.startsWithText.startsWith(
|
|
107
|
+
(r) => r.startsWithText.startsWith(o) && r.score >= e
|
|
109
108
|
), u = a.filter(
|
|
110
|
-
(r) => r.score <
|
|
109
|
+
(r) => r.score < e
|
|
111
110
|
);
|
|
112
111
|
return c.sort((r, i) => i.score - r.score), u.sort(
|
|
113
112
|
(r, i) => n[r.searchType] - n[i.searchType]
|
|
114
113
|
), [...c, ...u];
|
|
115
114
|
};
|
|
116
115
|
export {
|
|
117
|
-
|
|
116
|
+
d as calculateStringSimilarity,
|
|
118
117
|
k as formatRating,
|
|
119
118
|
M as formatReviewCount,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
C as getBookingOptions,
|
|
120
|
+
v as getHaversineDistanceKm,
|
|
121
|
+
x as getHotelImageUrls,
|
|
123
122
|
T as getHotelRatingInfo,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
L as getPointsValue,
|
|
124
|
+
P as isDuffelHotelId,
|
|
125
|
+
A as loadImageWithFallback,
|
|
126
|
+
R as sortLocationResults
|
|
128
127
|
};
|