@final-commerce/common 2.12.0-staging.5 → 2.12.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.
- package/README.md +20 -0
- package/bin/gate-done.mjs +71 -36
- package/bin/lib/budget.mjs +71 -0
- package/dist/index.d.mts +96 -248
- package/dist/index.d.ts +96 -248
- package/dist/index.js +345 -1025
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +330 -992
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +35 -58
- package/dist/pos-types/index.d.ts +35 -58
- package/dist/pos-types/index.js +2 -7
- package/dist/pos-types/index.js.map +1 -1
- package/dist/pos-types/index.mjs +1 -5
- package/dist/pos-types/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,13 +31,10 @@ __export(index_exports, {
|
|
|
31
31
|
AttributeType: () => AttributeType,
|
|
32
32
|
BNPL_METHOD_STATUS: () => BNPL_METHOD_STATUS,
|
|
33
33
|
BNPL_SKIP_REASON: () => BNPL_SKIP_REASON,
|
|
34
|
-
BookingArriveLeave: () => BookingArriveLeave,
|
|
35
|
-
BookingDurationUnit: () => BookingDurationUnit,
|
|
36
34
|
BookingRatePeriod: () => BookingRatePeriod,
|
|
37
35
|
BookingResourceKind: () => BookingResourceKind,
|
|
38
36
|
BookingResourceStatus: () => BookingResourceStatus,
|
|
39
37
|
BookingRulesError: () => BookingRulesError,
|
|
40
|
-
BookingSessionSale: () => BookingSessionSale,
|
|
41
38
|
BookingType: () => BookingType,
|
|
42
39
|
CANADA_PROVINCES: () => CANADA_PROVINCES,
|
|
43
40
|
CONDITION_OPERATORS: () => CONDITION_OPERATORS,
|
|
@@ -52,6 +49,7 @@ __export(index_exports, {
|
|
|
52
49
|
DEFAULT_DISPLAY_STATE_MAP: () => DEFAULT_DISPLAY_STATE_MAP,
|
|
53
50
|
DEFAULT_HOLD_MINUTES: () => DEFAULT_HOLD_MINUTES,
|
|
54
51
|
DEFAULT_RESOLVED_CONFIG: () => DEFAULT_RESOLVED_CONFIG,
|
|
52
|
+
DEFAULT_SHELL_SETTINGS: () => DEFAULT_SHELL_SETTINGS,
|
|
55
53
|
DEFAULT_UNIT_ID: () => DEFAULT_UNIT_ID,
|
|
56
54
|
DualWriteStrategy: () => DualWriteStrategy,
|
|
57
55
|
EUFixedRates: () => EUFixedRates,
|
|
@@ -107,6 +105,11 @@ __export(index_exports, {
|
|
|
107
105
|
ResidualPaymentMethod: () => ResidualPaymentMethod,
|
|
108
106
|
ResidualStatus: () => ResidualStatus,
|
|
109
107
|
ResourceAvailabilityState: () => ResourceAvailabilityState,
|
|
108
|
+
SHELL_FLOW_SETTINGS_PREFIX: () => SHELL_FLOW_SETTINGS_PREFIX,
|
|
109
|
+
SHELL_FLOW_TIPS_KEY: () => SHELL_FLOW_TIPS_KEY,
|
|
110
|
+
SHELL_TIP_LABEL_MAX_LENGTH: () => SHELL_TIP_LABEL_MAX_LENGTH,
|
|
111
|
+
SHELL_TIP_PERCENT_MAX: () => SHELL_TIP_PERCENT_MAX,
|
|
112
|
+
SHELL_TIP_PERCENT_MIN: () => SHELL_TIP_PERCENT_MIN,
|
|
110
113
|
SHIPPING_COUNTRIES: () => SHIPPING_COUNTRIES,
|
|
111
114
|
STATE_SCHEMA: () => STATE_SCHEMA,
|
|
112
115
|
STRIPE_SUPPORTED_COUNTRIES: () => STRIPE_SUPPORTED_COUNTRIES,
|
|
@@ -127,7 +130,6 @@ __export(index_exports, {
|
|
|
127
130
|
StripeStatus: () => StripeStatus,
|
|
128
131
|
TimePeriod: () => TimePeriod,
|
|
129
132
|
TopMetericsSort: () => TopMetericsSort,
|
|
130
|
-
UNLIMITED_PLACES: () => UNLIMITED_PLACES,
|
|
131
133
|
UserTypes: () => UserTypes,
|
|
132
134
|
addAmounts: () => addAmounts,
|
|
133
135
|
addressPlaceKeys: () => addressPlaceKeys,
|
|
@@ -136,7 +138,6 @@ __export(index_exports, {
|
|
|
136
138
|
adyenStoreRequiresStateOrProvince: () => adyenStoreRequiresStateOrProvince,
|
|
137
139
|
adyenSupportsTaxNumberAbsent: () => adyenSupportsTaxNumberAbsent,
|
|
138
140
|
adyenTaxNumberFormat: () => adyenTaxNumberFormat,
|
|
139
|
-
allowedDurationUnits: () => allowedDurationUnits,
|
|
140
141
|
amountToString: () => amountToString,
|
|
141
142
|
ancestorChain: () => ancestorChain,
|
|
142
143
|
applyAssignment: () => applyAssignment,
|
|
@@ -146,21 +147,15 @@ __export(index_exports, {
|
|
|
146
147
|
baseFulfillmentDefinitions: () => baseFulfillmentDefinitions,
|
|
147
148
|
baseOf: () => baseOf,
|
|
148
149
|
basePaymentDefinitions: () => basePaymentDefinitions,
|
|
149
|
-
bookingMethodOf: () => bookingMethodOf,
|
|
150
|
-
bookingRuleParts: () => bookingRuleParts,
|
|
151
150
|
buildAvailability: () => buildAvailability,
|
|
152
151
|
buildGrid: () => buildGrid,
|
|
153
152
|
buildOrderContext: () => buildOrderContext,
|
|
154
153
|
buildPosPresetConfig: () => buildPosPresetConfig,
|
|
155
154
|
buildResolvedConfig: () => buildResolvedConfig,
|
|
156
155
|
calculatePercentage: () => calculatePercentage,
|
|
157
|
-
calendarDate: () => calendarDate,
|
|
158
156
|
canTransition: () => canTransition,
|
|
159
|
-
capacityOf: () => capacityOf,
|
|
160
157
|
cheapestCompositeItem: () => cheapestCompositeItem,
|
|
161
158
|
cheapestCompositePrice: () => cheapestCompositePrice,
|
|
162
|
-
checkPartySize: () => checkPartySize,
|
|
163
|
-
checkQtyPerBooking: () => checkQtyPerBooking,
|
|
164
159
|
compositeItemCost: () => compositeItemCost,
|
|
165
160
|
compositeItemUnavailable: () => compositeItemUnavailable,
|
|
166
161
|
compositeMakeable: () => compositeMakeable,
|
|
@@ -169,10 +164,6 @@ __export(index_exports, {
|
|
|
169
164
|
compositeVariantInStock: () => compositeVariantInStock,
|
|
170
165
|
conditionSummary: () => conditionSummary,
|
|
171
166
|
convertFixedFeeToLocalCurrency: () => convertFixedFeeToLocalCurrency,
|
|
172
|
-
courseSessions: () => courseSessions,
|
|
173
|
-
courseSpan: () => courseSpan,
|
|
174
|
-
courseStarted: () => courseStarted,
|
|
175
|
-
courseStartedInZone: () => courseStartedInZone,
|
|
176
167
|
createAmount: () => createAmount,
|
|
177
168
|
crossAxisRuleApplies: () => crossAxisRuleApplies,
|
|
178
169
|
currentAssignees: () => currentAssignees,
|
|
@@ -181,13 +172,11 @@ __export(index_exports, {
|
|
|
181
172
|
deriveUnitId: () => deriveUnitId,
|
|
182
173
|
displayRuleMatchesPair: () => displayRuleMatchesPair,
|
|
183
174
|
divideAmount: () => divideAmount,
|
|
184
|
-
durationProblems: () => durationProblems,
|
|
185
|
-
durationText: () => durationText,
|
|
186
175
|
evaluateCondition: () => evaluateCondition,
|
|
187
176
|
evaluateConditionSet: () => evaluateConditionSet,
|
|
188
177
|
extendPrice: () => extendPrice,
|
|
189
178
|
extendPriceFor: () => extendPriceFor,
|
|
190
|
-
|
|
179
|
+
flowSettingsFromShellSettings: () => flowSettingsFromShellSettings,
|
|
191
180
|
formatCurrency: () => formatCurrency,
|
|
192
181
|
formatInUnit: () => formatInUnit,
|
|
193
182
|
formatMinorUnitsToString: () => formatMinorUnitsToString,
|
|
@@ -221,6 +210,7 @@ __export(index_exports, {
|
|
|
221
210
|
isFulfillmentState: () => isFulfillmentState,
|
|
222
211
|
isInCart: () => isInCart,
|
|
223
212
|
isPaymentState: () => isPaymentState,
|
|
213
|
+
isShellTipPercent: () => isShellTipPercent,
|
|
224
214
|
isSupportedCurrency: () => isSupportedCurrency,
|
|
225
215
|
isSystemFamilyCode: () => isSystemFamilyCode,
|
|
226
216
|
isValidQuantity: () => isValidQuantity,
|
|
@@ -229,9 +219,7 @@ __export(index_exports, {
|
|
|
229
219
|
listCountries: () => listCountries,
|
|
230
220
|
listProvinces: () => listProvinces,
|
|
231
221
|
listShippingCountries: () => listShippingCountries,
|
|
232
|
-
longestMinutesOf: () => longestMinutesOf,
|
|
233
222
|
mapToLegacyStatus: () => mapToLegacyStatus,
|
|
234
|
-
maxAdvanceMinutesOf: () => maxAdvanceMinutesOf,
|
|
235
223
|
maxPrecisionFor: () => maxPrecisionFor,
|
|
236
224
|
mergeFragment: () => mergeFragment,
|
|
237
225
|
modifiersSellable: () => modifiersSellable,
|
|
@@ -243,15 +231,11 @@ __export(index_exports, {
|
|
|
243
231
|
normalizePostCode: () => normalizePostCode,
|
|
244
232
|
normalizeProvince: () => normalizeProvince,
|
|
245
233
|
occupancyIn: () => occupancyIn,
|
|
246
|
-
occupiedAtOutlet: () => occupiedAtOutlet,
|
|
247
|
-
oldMaxAdvanceOf: () => oldMaxAdvanceOf,
|
|
248
234
|
orderAssignments: () => orderAssignments,
|
|
249
235
|
parseAmountToMinorUnits: () => parseAmountToMinorUnits,
|
|
250
236
|
parseCurrencyCode: () => parseCurrencyCode,
|
|
251
237
|
parseStripeCurrencyCode: () => parseStripeCurrencyCode,
|
|
252
|
-
pickFreeResource: () => pickFreeResource,
|
|
253
238
|
placeKey: () => placeKey,
|
|
254
|
-
planCourse: () => planCourse,
|
|
255
239
|
planWindow: () => planWindow,
|
|
256
240
|
poolDemand: () => poolDemand,
|
|
257
241
|
poolOf: () => poolOf,
|
|
@@ -261,27 +245,27 @@ __export(index_exports, {
|
|
|
261
245
|
presentAt: () => presentAt,
|
|
262
246
|
priceForTotal: () => priceForTotal,
|
|
263
247
|
provincesForPostCode: () => provincesForPostCode,
|
|
248
|
+
readShellTipSettings: () => readShellTipSettings,
|
|
264
249
|
removeFragment: () => removeFragment,
|
|
265
|
-
rentalEnds: () => rentalEnds,
|
|
266
250
|
resolveFamily: () => resolveFamily,
|
|
267
251
|
resolveModifiersForProduct: () => resolveModifiersForProduct,
|
|
252
|
+
resolveShellSettings: () => resolveShellSettings,
|
|
253
|
+
resolveShellSettingsWithSources: () => resolveShellSettingsWithSources,
|
|
268
254
|
resolveShipping: () => resolveShipping,
|
|
269
255
|
resolveTemplate: () => resolveTemplate,
|
|
270
256
|
resolveUnit: () => resolveUnit,
|
|
271
257
|
roundToPrecision: () => roundToPrecision,
|
|
272
|
-
ruleDurationsOf: () => ruleDurationsOf,
|
|
273
|
-
ruleInNewShape: () => ruleInNewShape,
|
|
274
258
|
sameFamily: () => sameFamily,
|
|
275
|
-
sessionCells: () => sessionCells,
|
|
276
259
|
setOrderState: () => setOrderState,
|
|
260
|
+
shellSettingsFromCompanyTips: () => shellSettingsFromCompanyTips,
|
|
261
|
+
shellSettingsFromFlowSettings: () => shellSettingsFromFlowSettings,
|
|
262
|
+
shellSettingsProblems: () => shellSettingsProblems,
|
|
263
|
+
shellTipSettingsProblems: () => shellTipSettingsProblems,
|
|
277
264
|
shipsToCountry: () => shipsToCountry,
|
|
278
265
|
shopDayKey: () => shopDayKey,
|
|
279
266
|
shopDayRange: () => shopDayRange,
|
|
280
|
-
shortestMinutesOf: () => shortestMinutesOf,
|
|
281
267
|
signReportForDisplay: () => signReportForDisplay,
|
|
282
268
|
slotsForWindow: () => slotsForWindow,
|
|
283
|
-
soldAsCourse: () => soldAsCourse,
|
|
284
|
-
startsPastMaxAdvance: () => startsPastMaxAdvance,
|
|
285
269
|
stringifyMinorUnits: () => stringifyMinorUnits,
|
|
286
270
|
subtractAmounts: () => subtractAmounts,
|
|
287
271
|
toBase: () => toBase,
|
|
@@ -292,8 +276,6 @@ __export(index_exports, {
|
|
|
292
276
|
validateShippingZone: () => validateShippingZone,
|
|
293
277
|
violatesFinancialInvariant: () => violatesFinancialInvariant,
|
|
294
278
|
windowEndsAt: () => windowEndsAt,
|
|
295
|
-
windowEndsAtInZone: () => windowEndsAtInZone,
|
|
296
|
-
windowForPeriods: () => windowForPeriods,
|
|
297
279
|
withinPresence: () => withinPresence
|
|
298
280
|
});
|
|
299
281
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -754,42 +736,21 @@ var PaymentProcessor = /* @__PURE__ */ ((PaymentProcessor2) => {
|
|
|
754
736
|
})(PaymentProcessor || {});
|
|
755
737
|
|
|
756
738
|
// enums/booking.enum.ts
|
|
757
|
-
var BookingType = /* @__PURE__ */ ((
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
return
|
|
739
|
+
var BookingType = /* @__PURE__ */ ((BookingType3) => {
|
|
740
|
+
BookingType3["RENTAL"] = "rental";
|
|
741
|
+
BookingType3["APPOINTMENT"] = "appointment";
|
|
742
|
+
BookingType3["OVERNIGHT"] = "overnight";
|
|
743
|
+
BookingType3["GROUP"] = "group";
|
|
744
|
+
return BookingType3;
|
|
763
745
|
})(BookingType || {});
|
|
764
746
|
var BookingRatePeriod = /* @__PURE__ */ ((BookingRatePeriod2) => {
|
|
765
747
|
BookingRatePeriod2["SLOT"] = "slot";
|
|
766
|
-
BookingRatePeriod2["HOUR"] = "hour";
|
|
767
|
-
BookingRatePeriod2["SESSION"] = "session";
|
|
768
748
|
BookingRatePeriod2["DAY"] = "day";
|
|
769
749
|
BookingRatePeriod2["NIGHT"] = "night";
|
|
770
750
|
BookingRatePeriod2["WEEK"] = "week";
|
|
771
751
|
BookingRatePeriod2["MONTH"] = "month";
|
|
772
752
|
return BookingRatePeriod2;
|
|
773
753
|
})(BookingRatePeriod || {});
|
|
774
|
-
var BookingDurationUnit = /* @__PURE__ */ ((BookingDurationUnit2) => {
|
|
775
|
-
BookingDurationUnit2["MINUTE"] = "minute";
|
|
776
|
-
BookingDurationUnit2["HOUR"] = "hour";
|
|
777
|
-
BookingDurationUnit2["DAY"] = "day";
|
|
778
|
-
BookingDurationUnit2["NIGHT"] = "night";
|
|
779
|
-
BookingDurationUnit2["WEEK"] = "week";
|
|
780
|
-
BookingDurationUnit2["MONTH"] = "month";
|
|
781
|
-
return BookingDurationUnit2;
|
|
782
|
-
})(BookingDurationUnit || {});
|
|
783
|
-
var BookingSessionSale = /* @__PURE__ */ ((BookingSessionSale2) => {
|
|
784
|
-
BookingSessionSale2["SESSION"] = "session";
|
|
785
|
-
BookingSessionSale2["COURSE"] = "course";
|
|
786
|
-
return BookingSessionSale2;
|
|
787
|
-
})(BookingSessionSale || {});
|
|
788
|
-
var BookingArriveLeave = /* @__PURE__ */ ((BookingArriveLeave2) => {
|
|
789
|
-
BookingArriveLeave2["SET_TIMES"] = "set-times";
|
|
790
|
-
BookingArriveLeave2["OPENING_HOURS"] = "opening-hours";
|
|
791
|
-
return BookingArriveLeave2;
|
|
792
|
-
})(BookingArriveLeave || {});
|
|
793
754
|
var BookingResourceKind = /* @__PURE__ */ ((BookingResourceKind2) => {
|
|
794
755
|
BookingResourceKind2["ASSET"] = "asset";
|
|
795
756
|
BookingResourceKind2["ROOM"] = "room";
|
|
@@ -2102,6 +2063,157 @@ function lineStockMoves(item, quantity, reservations = []) {
|
|
|
2102
2063
|
});
|
|
2103
2064
|
}
|
|
2104
2065
|
|
|
2066
|
+
// utils/shell-settings.util.ts
|
|
2067
|
+
var DEFAULT_SHELL_SETTINGS = {
|
|
2068
|
+
pinSwitchUser: false,
|
|
2069
|
+
pinSession: false,
|
|
2070
|
+
stationLock: 0,
|
|
2071
|
+
buildTimeout: 0,
|
|
2072
|
+
lockedAccess: false,
|
|
2073
|
+
cashManagement: true,
|
|
2074
|
+
tips: {
|
|
2075
|
+
enabled: true,
|
|
2076
|
+
tip1: { label: "Good", value: 15 },
|
|
2077
|
+
tip2: { label: "Great", value: 18 },
|
|
2078
|
+
tip3: { label: "Amazing!", value: 25 },
|
|
2079
|
+
customTipLabel: "Custom",
|
|
2080
|
+
noTipLabel: "No tip"
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
var FIELD_ORDER = ["station"];
|
|
2084
|
+
var TIP_ORDER = ["station", "outlet", "flow", "company"];
|
|
2085
|
+
var TOP_FIELDS = [
|
|
2086
|
+
"pinSwitchUser",
|
|
2087
|
+
"pinSession",
|
|
2088
|
+
"stationLock",
|
|
2089
|
+
"buildTimeout",
|
|
2090
|
+
"lockedAccess",
|
|
2091
|
+
"cashManagement"
|
|
2092
|
+
];
|
|
2093
|
+
var TIP_FIELDS = ["enabled", "tip1", "tip2", "tip3", "customTipLabel", "noTipLabel"];
|
|
2094
|
+
function pick(levels, order, read, fallback) {
|
|
2095
|
+
for (const level of order) {
|
|
2096
|
+
const settings = levels[level];
|
|
2097
|
+
if (!settings) continue;
|
|
2098
|
+
const value = read(settings);
|
|
2099
|
+
if (value !== void 0 && value !== null) return { value, source: level };
|
|
2100
|
+
}
|
|
2101
|
+
return { value: fallback, source: "default" };
|
|
2102
|
+
}
|
|
2103
|
+
function resolveShellSettingsWithSources(levels) {
|
|
2104
|
+
const settings = { ...DEFAULT_SHELL_SETTINGS, tips: { ...DEFAULT_SHELL_SETTINGS.tips } };
|
|
2105
|
+
const sources = { fields: {}, tips: {} };
|
|
2106
|
+
for (const field of TOP_FIELDS) {
|
|
2107
|
+
const { value, source } = pick(levels, FIELD_ORDER, (s) => s[field], DEFAULT_SHELL_SETTINGS[field]);
|
|
2108
|
+
settings[field] = value;
|
|
2109
|
+
sources.fields[field] = source;
|
|
2110
|
+
}
|
|
2111
|
+
for (const field of TIP_FIELDS) {
|
|
2112
|
+
const { value, source } = pick(levels, TIP_ORDER, (s) => s.tips?.[field], DEFAULT_SHELL_SETTINGS.tips[field]);
|
|
2113
|
+
settings.tips[field] = value;
|
|
2114
|
+
sources.tips[field] = source;
|
|
2115
|
+
}
|
|
2116
|
+
return { settings, sources };
|
|
2117
|
+
}
|
|
2118
|
+
function resolveShellSettings(levels) {
|
|
2119
|
+
return resolveShellSettingsWithSources(levels).settings;
|
|
2120
|
+
}
|
|
2121
|
+
var SHELL_TIP_PERCENT_MIN = 1;
|
|
2122
|
+
var SHELL_TIP_PERCENT_MAX = 100;
|
|
2123
|
+
var SHELL_TIP_LABEL_MAX_LENGTH = 20;
|
|
2124
|
+
var isLabel = (raw) => typeof raw === "string" && raw.trim().length > 0 && raw.length <= SHELL_TIP_LABEL_MAX_LENGTH;
|
|
2125
|
+
var isShellTipPercent = (raw) => typeof raw === "number" && Number.isInteger(raw) && raw >= SHELL_TIP_PERCENT_MIN && raw <= SHELL_TIP_PERCENT_MAX;
|
|
2126
|
+
function shellTipSettingsProblems(tips) {
|
|
2127
|
+
if (!tips) return [];
|
|
2128
|
+
const problems = [];
|
|
2129
|
+
if (tips.enabled !== void 0 && typeof tips.enabled !== "boolean") {
|
|
2130
|
+
problems.push({ field: "tips.enabled", code: "boolean" });
|
|
2131
|
+
}
|
|
2132
|
+
for (const key of ["tip1", "tip2", "tip3"]) {
|
|
2133
|
+
const option = tips[key];
|
|
2134
|
+
if (option === void 0) continue;
|
|
2135
|
+
if (!option || typeof option !== "object") {
|
|
2136
|
+
problems.push({ field: `tips.${key}`, code: "preset" });
|
|
2137
|
+
continue;
|
|
2138
|
+
}
|
|
2139
|
+
if (!isShellTipPercent(option.value)) problems.push({ field: `tips.${key}`, code: "percent" });
|
|
2140
|
+
if (!isLabel(option.label)) problems.push({ field: `tips.${key}`, code: "label" });
|
|
2141
|
+
}
|
|
2142
|
+
for (const key of ["customTipLabel", "noTipLabel"]) {
|
|
2143
|
+
if (tips[key] !== void 0 && !isLabel(tips[key])) problems.push({ field: `tips.${key}`, code: "label" });
|
|
2144
|
+
}
|
|
2145
|
+
return problems;
|
|
2146
|
+
}
|
|
2147
|
+
function shellSettingsProblems(settings) {
|
|
2148
|
+
if (!settings) return [];
|
|
2149
|
+
const problems = [];
|
|
2150
|
+
for (const field of ["pinSwitchUser", "pinSession", "lockedAccess", "cashManagement"]) {
|
|
2151
|
+
if (settings[field] !== void 0 && typeof settings[field] !== "boolean")
|
|
2152
|
+
problems.push({ field, code: "boolean" });
|
|
2153
|
+
}
|
|
2154
|
+
for (const field of ["stationLock", "buildTimeout"]) {
|
|
2155
|
+
const value = settings[field];
|
|
2156
|
+
if (value !== void 0 && !(typeof value === "number" && Number.isInteger(value) && value >= 0)) {
|
|
2157
|
+
problems.push({ field, code: "timeout" });
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
return [...problems, ...shellTipSettingsProblems(settings.tips)];
|
|
2161
|
+
}
|
|
2162
|
+
var SHELL_FLOW_SETTINGS_PREFIX = "flowSettingsKey";
|
|
2163
|
+
var SHELL_FLOW_TIPS_KEY = `${SHELL_FLOW_SETTINGS_PREFIX}.tips`;
|
|
2164
|
+
var readBoolean = (raw) => {
|
|
2165
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
2166
|
+
const v = raw.trim().toLowerCase();
|
|
2167
|
+
if (v === "true") return true;
|
|
2168
|
+
if (v === "false") return false;
|
|
2169
|
+
return void 0;
|
|
2170
|
+
};
|
|
2171
|
+
function readTipOption(raw) {
|
|
2172
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
2173
|
+
const { label, value } = raw;
|
|
2174
|
+
const n = typeof value === "number" ? value : parseFloat(String(value ?? ""));
|
|
2175
|
+
if (typeof label !== "string" || !Number.isFinite(n) || n < 0) return void 0;
|
|
2176
|
+
return { label, value: n };
|
|
2177
|
+
}
|
|
2178
|
+
function readShellTipSettings(raw) {
|
|
2179
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
2180
|
+
const r = raw;
|
|
2181
|
+
const tips = {};
|
|
2182
|
+
if (typeof r.enabled === "boolean") tips.enabled = r.enabled;
|
|
2183
|
+
const tip1 = readTipOption(r.tip1);
|
|
2184
|
+
const tip2 = readTipOption(r.tip2);
|
|
2185
|
+
const tip3 = readTipOption(r.tip3);
|
|
2186
|
+
if (tip1) tips.tip1 = tip1;
|
|
2187
|
+
if (tip2) tips.tip2 = tip2;
|
|
2188
|
+
if (tip3) tips.tip3 = tip3;
|
|
2189
|
+
if (typeof r.customTipLabel === "string") tips.customTipLabel = r.customTipLabel;
|
|
2190
|
+
if (typeof r.noTipLabel === "string") tips.noTipLabel = r.noTipLabel;
|
|
2191
|
+
return Object.keys(tips).length > 0 ? tips : void 0;
|
|
2192
|
+
}
|
|
2193
|
+
var parseJson = (raw) => {
|
|
2194
|
+
if (!raw) return void 0;
|
|
2195
|
+
try {
|
|
2196
|
+
return JSON.parse(raw);
|
|
2197
|
+
} catch {
|
|
2198
|
+
return void 0;
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
function shellSettingsFromFlowSettings(dict) {
|
|
2202
|
+
const tips = readShellTipSettings(parseJson(dict?.[SHELL_FLOW_TIPS_KEY]));
|
|
2203
|
+
return tips ? { tips } : {};
|
|
2204
|
+
}
|
|
2205
|
+
function flowSettingsFromShellSettings(settings) {
|
|
2206
|
+
return settings.tips && Object.keys(settings.tips).length > 0 ? { [SHELL_FLOW_TIPS_KEY]: JSON.stringify(settings.tips) } : {};
|
|
2207
|
+
}
|
|
2208
|
+
function shellSettingsFromCompanyTips(enabled, options) {
|
|
2209
|
+
const tips = {
|
|
2210
|
+
...readShellTipSettings(typeof options === "string" ? parseJson(options) : options)
|
|
2211
|
+
};
|
|
2212
|
+
const on = typeof enabled === "boolean" ? enabled : readBoolean(typeof enabled === "string" ? enabled : void 0);
|
|
2213
|
+
if (on !== void 0) tips.enabled = on;
|
|
2214
|
+
return Object.keys(tips).length > 0 ? { tips } : {};
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2105
2217
|
// units/family-code.ts
|
|
2106
2218
|
var MAX_SLUG_LENGTH = 32;
|
|
2107
2219
|
var FALLBACK_SLUG = "family";
|
|
@@ -3650,7 +3762,6 @@ var ORDER_STATE_EVENTS = {
|
|
|
3650
3762
|
};
|
|
3651
3763
|
|
|
3652
3764
|
// booking/types.ts
|
|
3653
|
-
var UNLIMITED_PLACES = Number.MAX_SAFE_INTEGER;
|
|
3654
3765
|
var BookingRulesError = class extends Error {
|
|
3655
3766
|
constructor(message) {
|
|
3656
3767
|
super(message);
|
|
@@ -3719,39 +3830,153 @@ function atZonedMinute(dayStart, minutes, timeZone) {
|
|
|
3719
3830
|
const { year, month, day } = zonedParts(dayStart, timeZone);
|
|
3720
3831
|
return instantFromLocal(year, month, day, minutes, timeZone);
|
|
3721
3832
|
}
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3833
|
+
|
|
3834
|
+
// booking/grid.ts
|
|
3835
|
+
var MINUTE2 = 6e4;
|
|
3836
|
+
var MAX_RANGE_DAYS = 366;
|
|
3837
|
+
var asTime = (value, field) => {
|
|
3838
|
+
if (value == null) return void 0;
|
|
3839
|
+
const time = new Date(value).getTime();
|
|
3840
|
+
if (Number.isNaN(time)) throw new BookingRulesError(`Booking rules: ${field} is not a date, got "${String(value)}"`);
|
|
3841
|
+
return time;
|
|
3842
|
+
};
|
|
3843
|
+
function parseHhMm(value, field) {
|
|
3844
|
+
const [hours, minutes] = value.split(":").map(Number);
|
|
3845
|
+
if (!Number.isInteger(hours) || !Number.isInteger(minutes)) {
|
|
3846
|
+
throw new BookingRulesError(`Booking rules: ${field} must be "HH:mm", got "${value}"`);
|
|
3847
|
+
}
|
|
3848
|
+
return hours * 60 + minutes;
|
|
3726
3849
|
}
|
|
3727
|
-
function
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3850
|
+
function windowEndsAt(rule, now) {
|
|
3851
|
+
const { maxAdvanceDays, bookableTo } = rule.window;
|
|
3852
|
+
const ends = Math.min(
|
|
3853
|
+
maxAdvanceDays ? now.getTime() + maxAdvanceDays * 1440 * MINUTE2 : Number.POSITIVE_INFINITY,
|
|
3854
|
+
asTime(bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY
|
|
3732
3855
|
);
|
|
3856
|
+
return Number.isFinite(ends) ? new Date(ends) : null;
|
|
3733
3857
|
}
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3858
|
+
function periodSlot(dayStart, timeZone, rule, openMinute, closeMinute) {
|
|
3859
|
+
const { ratePeriod, slot, checkInTime, checkOutTime } = rule;
|
|
3860
|
+
const at = (minutes) => atZonedMinute(dayStart, minutes, timeZone);
|
|
3861
|
+
if (ratePeriod === "night" /* NIGHT */) {
|
|
3862
|
+
if (!checkInTime || !checkOutTime) {
|
|
3863
|
+
throw new BookingRulesError("Overnight booking rules need both checkInTime and checkOutTime");
|
|
3864
|
+
}
|
|
3865
|
+
const checkIn = parseHhMm(checkInTime, "checkInTime");
|
|
3866
|
+
const checkOut = parseHhMm(checkOutTime, "checkOutTime");
|
|
3867
|
+
return {
|
|
3868
|
+
startAt: at(checkIn),
|
|
3869
|
+
endAt: at(1440 + checkOut),
|
|
3870
|
+
// Housekeeping sits between check-out and the next check-in: it costs no night.
|
|
3871
|
+
bufferEndAt: at(1440 + checkIn),
|
|
3872
|
+
canStart: true
|
|
3873
|
+
};
|
|
3874
|
+
}
|
|
3875
|
+
const from = ratePeriod === "day" /* DAY */ ? openMinute ?? 0 : 0;
|
|
3876
|
+
const to = ratePeriod === "day" /* DAY */ ? closeMinute ?? 1440 : 1440;
|
|
3877
|
+
return {
|
|
3878
|
+
startAt: at(from),
|
|
3879
|
+
endAt: at(to),
|
|
3880
|
+
bufferEndAt: at(to + (slot.bufferMinutes ?? 0)),
|
|
3881
|
+
canStart: true
|
|
3882
|
+
};
|
|
3883
|
+
}
|
|
3884
|
+
function freeGaps(openAt, closeAt, busy) {
|
|
3885
|
+
const inside = busy.map(({ startAt, bufferEndAt }) => ({ from: +startAt, to: +bufferEndAt })).filter(({ from, to }) => to > openAt && from < closeAt).sort((first, second) => first.from - second.from);
|
|
3886
|
+
const gaps = [];
|
|
3887
|
+
let cursor = openAt;
|
|
3888
|
+
for (const { from, to } of inside) {
|
|
3889
|
+
if (from > cursor) gaps.push({ from: cursor, to: from, endsAtBooking: true });
|
|
3890
|
+
cursor = Math.max(cursor, to);
|
|
3891
|
+
if (cursor >= closeAt) break;
|
|
3892
|
+
}
|
|
3893
|
+
if (cursor < closeAt) gaps.push({ from: cursor, to: closeAt, endsAtBooking: false });
|
|
3894
|
+
return gaps;
|
|
3895
|
+
}
|
|
3896
|
+
function buildGrid(rule, timeZone, from, to, now, busy = []) {
|
|
3897
|
+
if (to.getTime() - from.getTime() > MAX_RANGE_DAYS * 1440 * MINUTE2) {
|
|
3898
|
+
throw new BookingRulesError(`A booking range may span at most ${MAX_RANGE_DAYS} days`);
|
|
3899
|
+
}
|
|
3900
|
+
const { availability, slot, window, ratePeriod } = rule;
|
|
3901
|
+
const periodMode = ratePeriod !== "slot" /* SLOT */;
|
|
3902
|
+
const weeklyHours = availability.weeklyHours ?? [];
|
|
3903
|
+
const notBefore = Math.max(
|
|
3904
|
+
now.getTime() + (window.minNoticeMinutes ?? 0) * MINUTE2,
|
|
3905
|
+
asTime(window.bookableFrom, "window.bookableFrom") ?? 0,
|
|
3906
|
+
asTime(availability.availableFrom, "availability.availableFrom") ?? 0
|
|
3907
|
+
);
|
|
3908
|
+
const notAfter = windowEndsAt(rule, now)?.getTime() ?? Number.POSITIVE_INFINITY;
|
|
3909
|
+
const blocked = (availability.offMarket ?? []).map(({ from: blockFrom, to: blockTo }) => ({
|
|
3910
|
+
from: asTime(blockFrom, "availability.offMarket.from"),
|
|
3911
|
+
to: asTime(blockTo, "availability.offMarket.to")
|
|
3912
|
+
}));
|
|
3913
|
+
const arrivalDays = availability.arrivalDays;
|
|
3914
|
+
const step = slot.lengthMinutes + (slot.bufferMinutes ?? 0);
|
|
3915
|
+
const slots = [];
|
|
3916
|
+
const lastDay = startOfZonedDay(to, timeZone).getTime();
|
|
3917
|
+
let dayStart = startOfZonedDay(from, timeZone);
|
|
3918
|
+
while (dayStart.getTime() <= lastDay) {
|
|
3919
|
+
const weekday = zonedParts(dayStart, timeZone).weekday;
|
|
3920
|
+
const rows = weeklyHours.filter((entry) => entry.weekday === weekday);
|
|
3921
|
+
if (periodMode) {
|
|
3922
|
+
const openToday = weeklyHours.length === 0 || rows.length > 0;
|
|
3923
|
+
if (openToday) {
|
|
3924
|
+
const built = periodSlot(dayStart, timeZone, rule, rows[0]?.openMinute, rows[0]?.closeMinute);
|
|
3925
|
+
slots.push({ ...built, canStart: !arrivalDays?.length || arrivalDays.includes(weekday) });
|
|
3926
|
+
}
|
|
3927
|
+
} else {
|
|
3928
|
+
for (const row of rows) {
|
|
3929
|
+
const openAt = +atZonedMinute(dayStart, row.openMinute, timeZone);
|
|
3930
|
+
const closeAt = +atZonedMinute(dayStart, row.closeMinute, timeZone);
|
|
3931
|
+
for (const gap of freeGaps(openAt, closeAt, busy)) {
|
|
3932
|
+
const mustFit = (gap.endsAtBooking ? step : slot.lengthMinutes) * MINUTE2;
|
|
3933
|
+
for (let start = gap.from; start + mustFit <= gap.to; start += step * MINUTE2) {
|
|
3934
|
+
slots.push({
|
|
3935
|
+
startAt: new Date(start),
|
|
3936
|
+
endAt: new Date(start + slot.lengthMinutes * MINUTE2),
|
|
3937
|
+
bufferEndAt: new Date(start + step * MINUTE2),
|
|
3938
|
+
canStart: true
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
dayStart = nextZonedDay(dayStart, timeZone);
|
|
3945
|
+
}
|
|
3946
|
+
const askedFrom = from.getTime();
|
|
3947
|
+
const askedTo = to.getTime();
|
|
3948
|
+
return slots.filter(({ startAt, bufferEndAt }) => {
|
|
3949
|
+
const start = startAt.getTime();
|
|
3950
|
+
if (start < askedFrom || start >= askedTo) return false;
|
|
3951
|
+
if (start < notBefore || start > notAfter) return false;
|
|
3952
|
+
return !blocked.some(
|
|
3953
|
+
({ from: blockFrom, to: blockTo }) => start < blockTo && bufferEndAt.getTime() > blockFrom
|
|
3954
|
+
);
|
|
3955
|
+
}).sort((first, second) => +first.startAt - +second.startAt);
|
|
3956
|
+
}
|
|
3957
|
+
function slotsForWindow(grid, startAt, endAt) {
|
|
3958
|
+
const startIndex = grid.findIndex((entry) => entry.startAt.getTime() === startAt.getTime());
|
|
3959
|
+
if (startIndex < 0) {
|
|
3960
|
+
throw new BookingRulesError(`${startAt.toISOString()} is not a bookable slot start for these rules`);
|
|
3961
|
+
}
|
|
3962
|
+
if (!grid[startIndex].canStart) {
|
|
3963
|
+
throw new BookingRulesError(`${startAt.toISOString()} is not an arrival day for these rules`);
|
|
3964
|
+
}
|
|
3965
|
+
const covered = [];
|
|
3966
|
+
for (let index = startIndex; index < grid.length; index++) {
|
|
3967
|
+
const entry = grid[index];
|
|
3968
|
+
const previous = covered[covered.length - 1];
|
|
3969
|
+
if (previous && entry.startAt.getTime() !== previous.bufferEndAt.getTime()) break;
|
|
3970
|
+
covered.push(entry);
|
|
3971
|
+
if (entry.endAt.getTime() === endAt.getTime()) return covered;
|
|
3972
|
+
if (entry.endAt.getTime() > endAt.getTime()) break;
|
|
3973
|
+
}
|
|
3974
|
+
throw new BookingRulesError(
|
|
3975
|
+
`${startAt.toISOString()} \u2192 ${endAt.toISOString()} does not line up with the bookable grid`
|
|
3976
|
+
);
|
|
3751
3977
|
}
|
|
3752
3978
|
|
|
3753
3979
|
// booking/availability.ts
|
|
3754
|
-
var placesOnTheWire = (entry) => Number.isFinite(entry.capacity) ? entry : { ...entry, capacity: UNLIMITED_PLACES, free: UNLIMITED_PLACES, unlimited: true };
|
|
3755
3980
|
var withinPresence = (slot, timeZone, presence) => {
|
|
3756
3981
|
if (!presence?.length) return true;
|
|
3757
3982
|
const dayStart = startOfZonedDay(slot.startAt, timeZone);
|
|
@@ -3769,11 +3994,6 @@ function occupancyIn(occupied, productId, startAt, bufferEndAt, shared) {
|
|
|
3769
3994
|
foreignProductId: foreign?.productId
|
|
3770
3995
|
};
|
|
3771
3996
|
}
|
|
3772
|
-
var inEveryOutletPool = (entry) => !entry.outletId;
|
|
3773
|
-
function occupiedAtOutlet(occupied, rule, outletId) {
|
|
3774
|
-
if (bookingMethodOf(rule) !== "sessions" || !outletId) return occupied;
|
|
3775
|
-
return occupied.filter((entry) => inEveryOutletPool(entry) || entry.outletId === outletId);
|
|
3776
|
-
}
|
|
3777
3997
|
var stateFor = (hasShift, offerable, free) => {
|
|
3778
3998
|
if (offerable === 0) {
|
|
3779
3999
|
return hasShift() ? "fullyBooked" /* FULLY_BOOKED */ : "noHoursInRange" /* NO_HOURS_IN_RANGE */;
|
|
@@ -3803,36 +4023,26 @@ function shopDayRange(fromDayKey, count, timeZone) {
|
|
|
3803
4023
|
function buildAvailability({
|
|
3804
4024
|
productId,
|
|
3805
4025
|
bookingRulesId,
|
|
4026
|
+
bookingType,
|
|
3806
4027
|
rule,
|
|
3807
4028
|
resources,
|
|
3808
|
-
occupied
|
|
3809
|
-
outletId,
|
|
4029
|
+
occupied,
|
|
3810
4030
|
from,
|
|
3811
4031
|
to,
|
|
3812
|
-
now
|
|
3813
|
-
timeZone
|
|
4032
|
+
now
|
|
3814
4033
|
}) {
|
|
3815
|
-
const occupied = occupiedAtOutlet(everyOutlet, rule, outletId);
|
|
3816
4034
|
const shared = rule.slot.sharedAcrossProducts ?? false;
|
|
3817
|
-
const bookableUntil =
|
|
3818
|
-
const parts = bookingRuleParts(rule);
|
|
4035
|
+
const bookableUntil = windowEndsAt(rule, now);
|
|
3819
4036
|
const header = {
|
|
3820
4037
|
productId,
|
|
3821
4038
|
bookingRulesId,
|
|
4039
|
+
bookingType,
|
|
3822
4040
|
ratePeriod: rule.ratePeriod,
|
|
3823
|
-
// Time slots / sessions / date ranges — so a reader never re-classifies `ratePeriod` itself.
|
|
3824
|
-
bookingMethod: bookingMethodOf(rule),
|
|
3825
4041
|
// Passed through for the UI to label: a group slot under minimumToRun may not run.
|
|
3826
4042
|
minimumToRun: rule.slot.minimumToRun,
|
|
3827
4043
|
minStay: rule.slot.minStay,
|
|
3828
4044
|
maxStay: rule.slot.maxStay,
|
|
3829
|
-
//
|
|
3830
|
-
minStayLength: parts.method === "date-ranges" ? parts.minStay : void 0,
|
|
3831
|
-
maxStayLength: parts.method === "date-ranges" ? parts.maxStay : void 0,
|
|
3832
|
-
// The per-booking limits, so a stepper is bounded by the rules (G7) instead of a number in the flow.
|
|
3833
|
-
maxQtyPerBooking: rule.slot.maxQtyPerBooking,
|
|
3834
|
-
maxPartySize: rule.slot.maxPartySize,
|
|
3835
|
-
// Why a day can come back empty. Past this instant the rule refuses every start, so the UI
|
|
4045
|
+
// Why a day can come back empty. Past this instant the rule refuses everything, so the UI
|
|
3836
4046
|
// can say "beyond the booking window" where it would otherwise claim "nothing free".
|
|
3837
4047
|
bookableUntil,
|
|
3838
4048
|
// The comparison itself, not just the boundary: deciding whether a day lies past the
|
|
@@ -3855,7 +4065,7 @@ function buildAvailability({
|
|
|
3855
4065
|
const byInstant = /* @__PURE__ */ new Map();
|
|
3856
4066
|
const freeSlotsPerResource = /* @__PURE__ */ new Map();
|
|
3857
4067
|
for (const { resource, slots: slots2 } of grids) {
|
|
3858
|
-
const capacity =
|
|
4068
|
+
const capacity = resource.seats ?? 1;
|
|
3859
4069
|
const mine = byResource.get(resource.id) ?? [];
|
|
3860
4070
|
for (const slot of slots2) {
|
|
3861
4071
|
const { taken, foreignProductId } = occupancyIn(mine, productId, slot.startAt, slot.bufferEndAt, shared);
|
|
@@ -3872,9 +4082,7 @@ function buildAvailability({
|
|
|
3872
4082
|
entry.booked += foreignProductId ? capacity : taken;
|
|
3873
4083
|
entry.free += free;
|
|
3874
4084
|
entry.canStart = entry.canStart || slot.canStart;
|
|
3875
|
-
entry.resources.push(
|
|
3876
|
-
placesOnTheWire({ resourceId: resource.id, name: resource.name, capacity, booked: taken, free })
|
|
3877
|
-
);
|
|
4085
|
+
entry.resources.push({ resourceId: resource.id, name: resource.name, capacity, booked: taken, free });
|
|
3878
4086
|
if (free > 0) freeSlotsPerResource.set(resource.id, (freeSlotsPerResource.get(resource.id) ?? 0) + 1);
|
|
3879
4087
|
byInstant.set(+slot.startAt, entry);
|
|
3880
4088
|
}
|
|
@@ -3896,10 +4104,9 @@ function buildAvailability({
|
|
|
3896
4104
|
)
|
|
3897
4105
|
};
|
|
3898
4106
|
});
|
|
3899
|
-
const slots = [...byInstant.values()].
|
|
4107
|
+
const slots = [...byInstant.values()].sort((first, second) => +first.startAt - +second.startAt);
|
|
3900
4108
|
return {
|
|
3901
4109
|
...header,
|
|
3902
|
-
course: soldAsCourse(rule) ? courseAvailability(rule, resources, byResource, productId, shared, now) : void 0,
|
|
3903
4110
|
resources: inWindow,
|
|
3904
4111
|
slots,
|
|
3905
4112
|
/**
|
|
@@ -3911,53 +4118,6 @@ function buildAvailability({
|
|
|
3911
4118
|
days: [...new Set(slots.map((slot) => slot.dayKey))]
|
|
3912
4119
|
};
|
|
3913
4120
|
}
|
|
3914
|
-
function courseAvailability(rule, resources, byResource, productId, shared, now) {
|
|
3915
|
-
if (resources.length === 0) return void 0;
|
|
3916
|
-
const sessions = courseSessions(rule, resources[0].timeZone);
|
|
3917
|
-
const alreadyStarted = courseStartedInZone(rule, sessions, now, resources[0].timeZone);
|
|
3918
|
-
const beyondWindow = startsPastMaxAdvance(rule, sessions[0].startAt, now, resources[0].timeZone);
|
|
3919
|
-
const free = resources.map((resource) => {
|
|
3920
|
-
const mine = byResource.get(resource.id) ?? [];
|
|
3921
|
-
const everySession = sessions.every((session) => withinPresence(session, resource.timeZone, resource.presence));
|
|
3922
|
-
const freePerSession = sessions.map((session) => {
|
|
3923
|
-
const { taken, foreignProductId } = occupancyIn(mine, productId, session.startAt, session.bufferEndAt, shared);
|
|
3924
|
-
return foreignProductId ? 0 : Math.max(capacityOf(rule, resource) - taken, 0);
|
|
3925
|
-
});
|
|
3926
|
-
const fewest = everySession && !alreadyStarted && !beyondWindow ? Math.min(...freePerSession) : 0;
|
|
3927
|
-
return Number.isFinite(fewest) ? { resourceId: resource.id, free: fewest } : { resourceId: resource.id, free: UNLIMITED_PLACES, unlimited: true };
|
|
3928
|
-
});
|
|
3929
|
-
return withMaxQtyNow(
|
|
3930
|
-
{
|
|
3931
|
-
sessions: sessions.length,
|
|
3932
|
-
alreadyStarted,
|
|
3933
|
-
beyondWindow,
|
|
3934
|
-
sessionTimes: sessions.map(({ startAt, endAt }) => ({ startAt, endAt })),
|
|
3935
|
-
startAt: sessions[0].startAt,
|
|
3936
|
-
endAt: sessions[sessions.length - 1].endAt,
|
|
3937
|
-
resources: free
|
|
3938
|
-
},
|
|
3939
|
-
free,
|
|
3940
|
-
rule.slot.maxQtyPerBooking
|
|
3941
|
-
);
|
|
3942
|
-
}
|
|
3943
|
-
function pickFreeResource(slot, qty = 1) {
|
|
3944
|
-
return slot.resources.find((entry) => entry.free >= qty);
|
|
3945
|
-
}
|
|
3946
|
-
function withMaxQtyNow(entry, resources, maxQtyPerBooking) {
|
|
3947
|
-
const largest = resources.some((resource) => resource.unlimited) ? Number.POSITIVE_INFINITY : Math.max(0, ...resources.map((resource) => resource.free));
|
|
3948
|
-
const maxQtyNow = Math.min(largest, maxQtyPerBooking ?? Number.POSITIVE_INFINITY);
|
|
3949
|
-
return Number.isFinite(maxQtyNow) ? { ...entry, maxQtyNow } : entry;
|
|
3950
|
-
}
|
|
3951
|
-
function fewestFreeOver(slots, from, to) {
|
|
3952
|
-
const cells = slots.filter(({ startAt, endAt }) => +startAt >= +from && +endAt <= +to);
|
|
3953
|
-
if (cells.length === 0) return [];
|
|
3954
|
-
return cells[0].resources.map((resource) => ({
|
|
3955
|
-
...resource,
|
|
3956
|
-
free: Math.min(
|
|
3957
|
-
...cells.map((cell) => cell.resources.find(({ resourceId }) => resourceId === resource.resourceId)?.free ?? 0)
|
|
3958
|
-
)
|
|
3959
|
-
}));
|
|
3960
|
-
}
|
|
3961
4121
|
function presentAt(resources, rows, outletId) {
|
|
3962
4122
|
const byResource = /* @__PURE__ */ new Map();
|
|
3963
4123
|
for (const row of rows) {
|
|
@@ -3971,846 +4131,24 @@ function presentAt(resources, rows, outletId) {
|
|
|
3971
4131
|
});
|
|
3972
4132
|
}
|
|
3973
4133
|
|
|
3974
|
-
// booking/durations.ts
|
|
3975
|
-
var { MINUTE: MINUTE2, HOUR, DAY, NIGHT, WEEK, MONTH } = BookingDurationUnit;
|
|
3976
|
-
var NONE = [];
|
|
3977
|
-
var CLOCK = [MINUTE2, HOUR];
|
|
3978
|
-
var everyType = (units) => Object.fromEntries(Object.values(BookingRatePeriod).map((ratePeriod) => [ratePeriod, units]));
|
|
3979
|
-
var STAY = {
|
|
3980
|
-
slot: NONE,
|
|
3981
|
-
session: NONE,
|
|
3982
|
-
hour: [HOUR, DAY, WEEK],
|
|
3983
|
-
night: [NIGHT, WEEK, MONTH],
|
|
3984
|
-
day: [DAY, WEEK, MONTH],
|
|
3985
|
-
week: [WEEK],
|
|
3986
|
-
month: [MONTH]
|
|
3987
|
-
};
|
|
3988
|
-
var ALLOWED_UNITS = {
|
|
3989
|
-
"timeSlots.length": { ...everyType(NONE), slot: CLOCK },
|
|
3990
|
-
"slot.buffer": { ...everyType(CLOCK), night: NONE },
|
|
3991
|
-
"window.hold": everyType(CLOCK),
|
|
3992
|
-
"window.minNotice": everyType([MINUTE2, HOUR, DAY, WEEK]),
|
|
3993
|
-
"window.maxAdvance": everyType([MINUTE2, HOUR, DAY, WEEK, MONTH]),
|
|
3994
|
-
"dateRanges.minStay": STAY,
|
|
3995
|
-
"dateRanges.maxStay": STAY
|
|
3996
|
-
};
|
|
3997
|
-
function allowedDurationUnits(rule, field) {
|
|
3998
|
-
const units = ALLOWED_UNITS[field]?.[rule.ratePeriod];
|
|
3999
|
-
if (!units) throw new BookingRulesError(`Booking rules: no duration "${field}" for rate period "${rule.ratePeriod}"`);
|
|
4000
|
-
return units;
|
|
4001
|
-
}
|
|
4002
|
-
var DURATION_AT = {
|
|
4003
|
-
"timeSlots.length": (rule) => rule.timeSlots?.length,
|
|
4004
|
-
"slot.buffer": (rule) => rule.slot.buffer,
|
|
4005
|
-
"window.hold": (rule) => rule.window.hold,
|
|
4006
|
-
"window.minNotice": (rule) => rule.window.minNotice,
|
|
4007
|
-
"window.maxAdvance": (rule) => rule.window.maxAdvance,
|
|
4008
|
-
"dateRanges.minStay": (rule) => rule.dateRanges?.minStay,
|
|
4009
|
-
"dateRanges.maxStay": (rule) => rule.dateRanges?.maxStay
|
|
4010
|
-
};
|
|
4011
|
-
function durationProblems(rule) {
|
|
4012
|
-
const problems = Object.keys(DURATION_AT).flatMap((field) => {
|
|
4013
|
-
const duration = DURATION_AT[field](rule);
|
|
4014
|
-
const problem = duration && problemOf(field, duration, allowedDurationUnits(rule, field), rule.ratePeriod);
|
|
4015
|
-
return problem ? [problem] : [];
|
|
4016
|
-
});
|
|
4017
|
-
if (problems.length > 0) return problems;
|
|
4018
|
-
return [stayAboveMax(rule.dateRanges?.minStay, rule.dateRanges?.maxStay), noticeAboveAdvance(rule.window)].filter(
|
|
4019
|
-
(problem) => !!problem
|
|
4020
|
-
);
|
|
4021
|
-
}
|
|
4022
|
-
function problemOf(field, duration, allowed, ratePeriod) {
|
|
4023
|
-
if (!Number.isInteger(duration.count) || duration.count < 1) {
|
|
4024
|
-
const message = `${field}: count must be a whole number of at least 1, got ${String(duration.count)}`;
|
|
4025
|
-
return { field, kind: "count", message };
|
|
4026
|
-
}
|
|
4027
|
-
if (allowed.length === 0) {
|
|
4028
|
-
return { field, kind: "not-for-type", message: `${field}: does not apply to ${ratePeriod} rules` };
|
|
4029
|
-
}
|
|
4030
|
-
if (!allowed.includes(duration.unit)) {
|
|
4031
|
-
return { field, kind: "unit", allowed, message: `${field}: takes ${allowed.join(", ")}, got ${duration.unit}` };
|
|
4032
|
-
}
|
|
4033
|
-
return void 0;
|
|
4034
|
-
}
|
|
4035
|
-
var MINUTES_RANGE = {
|
|
4036
|
-
minute: [1, 1],
|
|
4037
|
-
hour: [60, 60],
|
|
4038
|
-
day: [1440, 1440],
|
|
4039
|
-
night: [1440, 1440],
|
|
4040
|
-
week: [7 * 1440, 7 * 1440],
|
|
4041
|
-
month: [28 * 1440, 31 * 1440]
|
|
4042
|
-
};
|
|
4043
|
-
var clockShiftOf = (unit2) => unit2 === MINUTE2 || unit2 === HOUR ? 0 : 60;
|
|
4044
|
-
var shortestMinutesOf = ({ count, unit: unit2 }) => count * MINUTES_RANGE[unit2][0] - clockShiftOf(unit2);
|
|
4045
|
-
var longestMinutesOf = ({ count, unit: unit2 }) => count * MINUTES_RANGE[unit2][1] + clockShiftOf(unit2);
|
|
4046
|
-
var durationText = ({ count, unit: unit2 }) => `${count} ${unit2}${count === 1 ? "" : "s"}`;
|
|
4047
|
-
var DAYS_IN_UNIT = { day: 1, night: 1, week: 7 };
|
|
4048
|
-
var MINUTES_IN_UNIT = { minute: 1, hour: 60 };
|
|
4049
|
-
function exactly(min, max) {
|
|
4050
|
-
if (min.unit === max.unit) return [min.count, max.count];
|
|
4051
|
-
for (const table of [DAYS_IN_UNIT, MINUTES_IN_UNIT]) {
|
|
4052
|
-
const [minSize, maxSize] = [table[min.unit], table[max.unit]];
|
|
4053
|
-
if (minSize && maxSize) return [min.count * minSize, max.count * maxSize];
|
|
4054
|
-
}
|
|
4055
|
-
return void 0;
|
|
4056
|
-
}
|
|
4057
|
-
function minLongerThanMax(min, max) {
|
|
4058
|
-
const exact = exactly(min, max);
|
|
4059
|
-
return exact ? exact[0] > exact[1] : longestMinutesOf(min) > shortestMinutesOf(max);
|
|
4060
|
-
}
|
|
4061
|
-
function stayAboveMax(min, max) {
|
|
4062
|
-
if (!min || !max || !minLongerThanMax(min, max)) return void 0;
|
|
4063
|
-
const message = `dateRanges.maxStay: Max ${durationText(max)} can be shorter than Min ${durationText(min)}`;
|
|
4064
|
-
return { field: "dateRanges.maxStay", kind: "min-above-max", min, max, message };
|
|
4065
|
-
}
|
|
4066
|
-
function noticeAboveAdvance({
|
|
4067
|
-
minNotice,
|
|
4068
|
-
maxAdvance
|
|
4069
|
-
}) {
|
|
4070
|
-
if (!minNotice || !maxAdvance || !minLongerThanMax(minNotice, maxAdvance)) return void 0;
|
|
4071
|
-
const message = `window.maxAdvance: ${durationText(maxAdvance)} ahead can be shorter than the notice of ${durationText(minNotice)}`;
|
|
4072
|
-
return { field: "window.maxAdvance", kind: "min-above-max", min: minNotice, max: maxAdvance, message };
|
|
4073
|
-
}
|
|
4074
|
-
|
|
4075
4134
|
// booking/plan.ts
|
|
4076
4135
|
var DEFAULT_HOLD_MINUTES = 10;
|
|
4077
4136
|
function planWindow({ rule, timeZone, presence, startAt, endAt, now, busy = [] }) {
|
|
4078
|
-
if (!soldAsCourse(rule)) checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
|
|
4079
4137
|
const grid = buildGrid(rule, timeZone, startAt, endAt, now, busy).filter(
|
|
4080
4138
|
(slot) => withinPresence(slot, timeZone, presence)
|
|
4081
4139
|
);
|
|
4082
4140
|
const slots = slotsForWindow(grid, startAt, endAt);
|
|
4083
|
-
const
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
const periods = wholePeriods ? wholePeriodsIn(rule.ratePeriod, timeZone, startAt, last.endAt, slots.length) : slots.length;
|
|
4087
|
-
checkStay(parts, timeZone, startAt, periods);
|
|
4088
|
-
const { buffer } = ruleDurationsOf(rule);
|
|
4089
|
-
const bufferEndAt = rule.ratePeriod === "hour" /* HOUR */ || wholePeriods ? buffer ? addDuration(last.endAt, buffer, timeZone) : new Date(last.endAt.getTime()) : last.bufferEndAt;
|
|
4090
|
-
return { slots, periods, endAt: last.endAt, bufferEndAt };
|
|
4091
|
-
}
|
|
4092
|
-
function checkStartWithinMaxAdvance(rule, timeZone, startAt, now) {
|
|
4093
|
-
if (startsPastMaxAdvance(rule, startAt, now, timeZone)) {
|
|
4094
|
-
throw new BookingRulesError(`${startAt.toISOString()} is past the booking window of these rules`);
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
function checkStay(parts, timeZone, startAt, periods) {
|
|
4098
|
-
if (parts.method !== "date-ranges") return;
|
|
4099
|
-
const stay = { count: periods, unit: periodUnitOf(parts) };
|
|
4100
|
-
const length = (duration) => stayLength(parts.ratePeriod, duration, startAt, timeZone);
|
|
4101
|
-
const { minStay, maxStay } = parts;
|
|
4102
|
-
if (minStay && length(stay) < length(minStay)) {
|
|
4103
|
-
throw new BookingRulesError(
|
|
4104
|
-
`These rules ask for a stay of at least ${durationText(minStay)}, got ${durationText(stay)}`
|
|
4105
|
-
);
|
|
4106
|
-
}
|
|
4107
|
-
if (maxStay && length(stay) > length(maxStay)) {
|
|
4108
|
-
throw new BookingRulesError(
|
|
4109
|
-
`These rules allow a stay of at most ${durationText(maxStay)}, got ${durationText(stay)}`
|
|
4110
|
-
);
|
|
4111
|
-
}
|
|
4112
|
-
}
|
|
4113
|
-
function stayLength(ratePeriod, duration, startAt, timeZone) {
|
|
4114
|
-
if (ratePeriod === "hour" /* HOUR */) return addDuration(startAt, duration, timeZone).getTime();
|
|
4115
|
-
const { count, unit: unit2 } = duration;
|
|
4116
|
-
if (unit2 === "day" /* DAY */ || unit2 === "night" /* NIGHT */) return count;
|
|
4117
|
-
if (unit2 === "week" /* WEEK */) return 7 * count;
|
|
4118
|
-
if (unit2 !== "month" /* MONTH */) {
|
|
4119
|
-
throw new BookingRulesError(`Booking rules: a ${ratePeriod} stay cannot be counted in ${unit2}s`);
|
|
4120
|
-
}
|
|
4121
|
-
const { year, month, day } = zonedParts(startAt, timeZone);
|
|
4122
|
-
const [toYear, toMonth, toDay] = sameDayMonthsLaterDate(year, month, day, count);
|
|
4123
|
-
return (Date.UTC(toYear, toMonth - 1, toDay) - Date.UTC(year, month - 1, day)) / 864e5;
|
|
4124
|
-
}
|
|
4125
|
-
function windowForPeriods({ rule, timeZone, startAt, periods, now }) {
|
|
4126
|
-
if (!Number.isInteger(periods) || periods < 1) {
|
|
4127
|
-
throw new BookingRulesError(`periods must be a whole number of at least 1, got ${String(periods)}`);
|
|
4128
|
-
}
|
|
4129
|
-
checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
|
|
4130
|
-
const parts = bookingRuleParts(rule);
|
|
4131
|
-
checkStay(parts, timeZone, startAt, periods);
|
|
4132
|
-
const wholePeriods = parts.method === "date-ranges" && parts.wholePeriods;
|
|
4133
|
-
const monthsEnd = wholePeriods && rule.ratePeriod === "month" /* MONTH */ ? sameDayMonthsLater(startAt, periods, timeZone) : null;
|
|
4134
|
-
const cells = wholePeriods && rule.ratePeriod === "week" /* WEEK */ ? periods * 7 : periods;
|
|
4135
|
-
const lastDay = monthsEnd ?? new Date(startAt.getTime() + (cells + 2) * 1440 * 6e4);
|
|
4136
|
-
const grid = buildGrid(
|
|
4137
|
-
rule,
|
|
4138
|
-
timeZone,
|
|
4139
|
-
startAt,
|
|
4140
|
-
new Date(Math.min(lastDay.getTime() + 1440 * 6e4, startAt.getTime() + 366 * 1440 * 6e4)),
|
|
4141
|
-
now
|
|
4142
|
-
);
|
|
4143
|
-
const startIndex = grid.findIndex((cell) => cell.startAt.getTime() === startAt.getTime());
|
|
4144
|
-
if (startIndex < 0)
|
|
4145
|
-
throw new BookingRulesError(`${startAt.toISOString()} is not a bookable slot start for these rules`);
|
|
4146
|
-
const endAt = monthsEnd ?? grid[startIndex + cells - 1]?.endAt;
|
|
4147
|
-
if (!endAt)
|
|
4148
|
-
throw new BookingRulesError(`${periods} period(s) from ${startAt.toISOString()} run past the bookable grid`);
|
|
4149
|
-
slotsForWindow(grid, startAt, endAt);
|
|
4150
|
-
return { startAt, endAt };
|
|
4151
|
-
}
|
|
4152
|
-
function rentalEnds(input) {
|
|
4153
|
-
const { rule, timeZone, startAt, now, untilDay } = input;
|
|
4154
|
-
const parts = bookingRuleParts(rule);
|
|
4155
|
-
if (parts.method !== "date-ranges") throw new BookingRulesError("Only date-range rules book a stay");
|
|
4156
|
-
checkStartWithinMaxAdvance(rule, timeZone, startAt, now);
|
|
4157
|
-
const horizon = shopDayRange(untilDay, 1, timeZone).to;
|
|
4158
|
-
if (horizon <= startAt) throw new BookingRulesError(`untilDay ${untilDay} is before the stay starts`);
|
|
4159
|
-
const gridUntil = (end) => buildGrid(rule, timeZone, startAt, new Date(Math.min(end, startAt.getTime() + 366 * 1440 * 6e4)), now);
|
|
4160
|
-
let walk = walkRentalEnds(gridUntil(horizon.getTime() + 1440 * 6e4), input, parts, horizon);
|
|
4161
|
-
if (!walk.ends.length && walk.refusal && walk.ranOut)
|
|
4162
|
-
walk = walkRentalEnds(gridUntil(Infinity), input, parts, horizon);
|
|
4163
|
-
if (walk.ends.length) return walk.ends;
|
|
4164
|
-
throw walk.refusal ?? new BookingRulesError(
|
|
4165
|
-
`No stay from ${startAt.toISOString()} fits these rules: the bookable days run out before the shortest allowed stay`
|
|
4166
|
-
);
|
|
4167
|
-
}
|
|
4168
|
-
function walkRentalEnds(grid, { rule, timeZone, startAt, untilDay }, parts, horizon) {
|
|
4169
|
-
const startIndex = grid.findIndex((cell) => cell.startAt.getTime() === startAt.getTime());
|
|
4170
|
-
if (startIndex < 0) {
|
|
4171
|
-
throw new BookingRulesError(`${startAt.toISOString()} is not a bookable slot start for these rules`);
|
|
4172
|
-
}
|
|
4173
|
-
slotsForWindow(grid, startAt, grid[startIndex].endAt);
|
|
4174
|
-
const ends = [];
|
|
4175
|
-
let refusal;
|
|
4176
|
-
for (const cell of grid.slice(startIndex)) {
|
|
4177
|
-
if (cell.endAt > horizon && (ends.length || !refusal)) {
|
|
4178
|
-
refusal ??= new BookingRulesError(`No stay from ${startAt.toISOString()} ends on or before ${untilDay}`);
|
|
4179
|
-
return { ends, refusal, ranOut: false };
|
|
4180
|
-
}
|
|
4181
|
-
const slots = refusalOr(() => slotsForWindow(grid, startAt, cell.endAt));
|
|
4182
|
-
if (slots instanceof BookingRulesError) return { ends, refusal, ranOut: false };
|
|
4183
|
-
const periods = refusalOr(
|
|
4184
|
-
() => parts.wholePeriods ? wholePeriodsIn(rule.ratePeriod, timeZone, startAt, cell.endAt, slots.length) : slots.length
|
|
4185
|
-
);
|
|
4186
|
-
if (periods instanceof BookingRulesError) continue;
|
|
4187
|
-
const stay = refusalOr(() => checkStay(parts, timeZone, startAt, periods));
|
|
4188
|
-
if (stay instanceof BookingRulesError) {
|
|
4189
|
-
if (ends.length) return { ends, refusal, ranOut: false };
|
|
4190
|
-
refusal = stay;
|
|
4191
|
-
continue;
|
|
4192
|
-
}
|
|
4193
|
-
ends.push(rentalEndOf(slots, periods, timeZone));
|
|
4194
|
-
}
|
|
4195
|
-
return { ends, refusal, ranOut: true };
|
|
4196
|
-
}
|
|
4197
|
-
function rentalEndOf(slots, periods, timeZone) {
|
|
4198
|
-
const endAt = slots[slots.length - 1].endAt;
|
|
4199
|
-
return {
|
|
4200
|
-
periods,
|
|
4201
|
-
endAt: endAt.toISOString(),
|
|
4202
|
-
lastDayKey: shopDayKey(new Date(endAt.getTime() - 1), timeZone),
|
|
4203
|
-
coveredSlots: slots.map((slot) => ({
|
|
4204
|
-
startAt: slot.startAt.toISOString(),
|
|
4205
|
-
dayKey: shopDayKey(slot.startAt, timeZone)
|
|
4206
|
-
}))
|
|
4207
|
-
};
|
|
4208
|
-
}
|
|
4209
|
-
function refusalOr(run) {
|
|
4210
|
-
try {
|
|
4211
|
-
return run();
|
|
4212
|
-
} catch (error) {
|
|
4213
|
-
if (error instanceof BookingRulesError) return error;
|
|
4214
|
-
throw error;
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
function sameDayMonthsLater(startAt, months, timeZone) {
|
|
4218
|
-
const { year, month, day } = zonedParts(startAt, timeZone);
|
|
4219
|
-
return instantFromLocal(...sameDayMonthsLaterDate(year, month, day, months), 0, timeZone);
|
|
4220
|
-
}
|
|
4221
|
-
function wholePeriodsIn(ratePeriod, timeZone, startAt, endAt, days) {
|
|
4222
|
-
if (ratePeriod === "week" /* WEEK */) {
|
|
4223
|
-
if (days % 7 !== 0) throw new BookingRulesError(`Book whole weeks: ${days} day(s) is not a number of weeks`);
|
|
4224
|
-
return days / 7;
|
|
4225
|
-
}
|
|
4226
|
-
if (ratePeriod !== "month" /* MONTH */) {
|
|
4227
|
-
throw new BookingRulesError("Whole periods are for week and month rules only");
|
|
4228
|
-
}
|
|
4229
|
-
const start = zonedParts(startAt, timeZone);
|
|
4230
|
-
const end = zonedParts(endAt, timeZone);
|
|
4231
|
-
const months = (end.year - start.year) * 12 + (end.month - start.month);
|
|
4232
|
-
const lastDayOfEndMonth = new Date(Date.UTC(end.year, end.month, 0)).getUTCDate();
|
|
4233
|
-
if (months < 1 || end.day !== Math.min(start.day, lastDayOfEndMonth)) {
|
|
4234
|
-
throw new BookingRulesError("Book whole months: the stay must end on the same day of a later month");
|
|
4235
|
-
}
|
|
4236
|
-
return months;
|
|
4237
|
-
}
|
|
4238
|
-
function courseSessions(rule, timeZone) {
|
|
4239
|
-
const [from, to] = rule.sessions?.weekly?.length ? weeklyCourseRange(rule) : datesCourseRange(rule.sessions?.dates ?? [], timeZone);
|
|
4240
|
-
const sessions = sessionCells(rule, timeZone, from, to).sort((first, second) => +first.startAt - +second.startAt);
|
|
4241
|
-
if (sessions.length === 0) throw new BookingRulesError("These course dates hold no session");
|
|
4242
|
-
return sessions;
|
|
4243
|
-
}
|
|
4244
|
-
function courseSpan(rule, timeZone) {
|
|
4245
|
-
const sessions = courseSessions(rule, timeZone);
|
|
4246
|
-
return { from: sessions[0].startAt, to: sessions[sessions.length - 1].bufferEndAt };
|
|
4247
|
-
}
|
|
4248
|
-
function weeklyCourseRange(rule) {
|
|
4249
|
-
const { bookableFrom, bookableTo } = rule.window;
|
|
4250
|
-
if (!bookableFrom || !bookableTo) throw new BookingRulesError("A course needs both course dates");
|
|
4251
|
-
return [new Date(bookableFrom), new Date(bookableTo)];
|
|
4252
|
-
}
|
|
4253
|
-
function datesCourseRange(dates, timeZone) {
|
|
4254
|
-
if (dates.length === 0) throw new BookingRulesError("A course needs its sessions");
|
|
4255
|
-
const days = dates.map(({ date }) => date).sort();
|
|
4256
|
-
const [firstYear, firstMonth, firstDay] = calendarDate(days[0]);
|
|
4257
|
-
const [lastYear, lastMonth, lastDay] = calendarDate(days[days.length - 1]);
|
|
4258
|
-
return [
|
|
4259
|
-
instantFromLocal(firstYear, firstMonth, firstDay, 0, timeZone),
|
|
4260
|
-
instantFromLocal(lastYear, lastMonth, lastDay + 1, 0, timeZone)
|
|
4261
|
-
];
|
|
4262
|
-
}
|
|
4263
|
-
var courseStarted = (rule, sessions, now) => sessions[0].startAt.getTime() < now.getTime() + (rule.window.minNoticeMinutes ?? 0) * 6e4;
|
|
4264
|
-
function courseStartedInZone(rule, sessions, now, timeZone) {
|
|
4265
|
-
const { minNotice } = ruleDurationsOf(rule);
|
|
4266
|
-
return sessions[0].startAt.getTime() < (minNotice ? addDuration(now, minNotice, timeZone) : now).getTime();
|
|
4267
|
-
}
|
|
4268
|
-
function planCourse({ rule, timeZone, presence, now }) {
|
|
4269
|
-
const sessions = courseSessions(rule, timeZone);
|
|
4270
|
-
if (!sessions.every((session) => withinPresence(session, timeZone, presence))) {
|
|
4271
|
-
throw new BookingRulesError("This resource is not there for every session of the course");
|
|
4272
|
-
}
|
|
4273
|
-
if (courseStartedInZone(rule, sessions, now, timeZone))
|
|
4274
|
-
throw new BookingRulesError("This course has already started");
|
|
4275
|
-
if (startsPastMaxAdvance(rule, sessions[0].startAt, now, timeZone)) {
|
|
4276
|
-
throw new BookingRulesError("This course starts past the booking window of these rules");
|
|
4277
|
-
}
|
|
4278
|
-
return sessions;
|
|
4279
|
-
}
|
|
4280
|
-
function holdExpiresAt(rule, now) {
|
|
4281
|
-
return addClockDuration(now, holdOf(rule) ?? DEFAULT_HOLD);
|
|
4282
|
-
}
|
|
4283
|
-
var DEFAULT_HOLD = { count: DEFAULT_HOLD_MINUTES, unit: "minute" /* MINUTE */ };
|
|
4284
|
-
function holdOf(rule) {
|
|
4285
|
-
const { hold } = ruleDurationsOf(rule);
|
|
4286
|
-
if (!hold) return void 0;
|
|
4287
|
-
const field = rule.window.hold ? "window.hold" : "window.holdMinutes";
|
|
4288
|
-
if (!Number.isInteger(hold.count)) {
|
|
4289
|
-
throw new BookingRulesError(`${field} must be a whole number of ${hold.unit}s, got ${hold.count}`);
|
|
4290
|
-
}
|
|
4291
|
-
if (hold.count < 1) throw new BookingRulesError(`${field} must be at least 1 ${hold.unit}, got ${hold.count}`);
|
|
4292
|
-
return hold;
|
|
4293
|
-
}
|
|
4294
|
-
function checkQtyPerBooking(rule, qty) {
|
|
4295
|
-
const max = rule.slot.maxQtyPerBooking;
|
|
4296
|
-
if (max !== void 0 && qty > max) {
|
|
4297
|
-
throw new BookingRulesError(`These rules allow at most ${max} per booking, got ${qty}`);
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
function checkPartySize(rule, partySize) {
|
|
4301
|
-
const max = rule.slot.maxPartySize;
|
|
4302
|
-
if (max !== void 0 && partySize > max) {
|
|
4303
|
-
throw new BookingRulesError(`These rules allow at most ${max} people per booking, got ${partySize}`);
|
|
4304
|
-
}
|
|
4305
|
-
}
|
|
4306
|
-
function bookingMethodOf(rule) {
|
|
4307
|
-
if (rule.ratePeriod === "slot" /* SLOT */) return "time-slots";
|
|
4308
|
-
if (rule.ratePeriod === "session" /* SESSION */) return "sessions";
|
|
4309
|
-
return "date-ranges";
|
|
4310
|
-
}
|
|
4311
|
-
var soldAsCourse = (rule) => rule.ratePeriod === "session" /* SESSION */ && rule.sessions?.sold === "course" /* COURSE */;
|
|
4312
|
-
function capacityOf(rule, resource) {
|
|
4313
|
-
if (rule.ratePeriod !== "session" /* SESSION */) return resource.seats ?? 1;
|
|
4314
|
-
if (!rule.sessions) throw new BookingRulesError("Scheduled-session rules need their sessions");
|
|
4315
|
-
return rule.sessions.spots ?? Number.POSITIVE_INFINITY;
|
|
4316
|
-
}
|
|
4317
|
-
function bookingRuleParts(rule) {
|
|
4318
|
-
const method = bookingMethodOf(rule);
|
|
4319
|
-
if (method === "sessions") {
|
|
4320
|
-
if (!rule.sessions) throw new BookingRulesError("Scheduled-session rules need their sessions");
|
|
4321
|
-
return { method, sessions: rule.sessions };
|
|
4322
|
-
}
|
|
4323
|
-
if (method === "time-slots") {
|
|
4324
|
-
const timeSlots = rule.timeSlots ? newTimeSlotsOf(rule.timeSlots) : oldTimeSlotsOf(rule);
|
|
4325
|
-
const { count } = timeSlots.length;
|
|
4326
|
-
if (!Number.isInteger(count) || count < 1) {
|
|
4327
|
-
const field = rule.timeSlots ? "timeSlots.length" : "slot.lengthMinutes";
|
|
4328
|
-
throw new BookingRulesError(`Booking rules: ${field} must be a whole number of at least 1, got ${count}`);
|
|
4329
|
-
}
|
|
4330
|
-
return { method, ...timeSlots };
|
|
4141
|
+
const { minStay, maxStay } = rule.slot;
|
|
4142
|
+
if (minStay && slots.length < minStay) {
|
|
4143
|
+
throw new BookingRulesError(`These rules ask for at least ${minStay} period(s), got ${slots.length}`);
|
|
4331
4144
|
}
|
|
4332
|
-
if (
|
|
4333
|
-
|
|
4334
|
-
return { method, ratePeriod: rule.ratePeriod, wholePeriods, ...rule.dateRanges };
|
|
4335
|
-
}
|
|
4336
|
-
function newTimeSlotsOf({ length, weeklyHours }) {
|
|
4337
|
-
if (!weeklyHours?.length) throw new BookingRulesError("Booking rules: timeSlots.weeklyHours needs at least one day");
|
|
4338
|
-
return { length, weeklyHours };
|
|
4339
|
-
}
|
|
4340
|
-
function oldTimeSlotsOf({ slot, availability }) {
|
|
4341
|
-
if (slot.lengthMinutes == null) throw new BookingRulesError("Time-slot rules need their slot length");
|
|
4342
|
-
return {
|
|
4343
|
-
length: { count: slot.lengthMinutes, unit: "minute" /* MINUTE */ },
|
|
4344
|
-
weeklyHours: availability.weeklyHours ?? []
|
|
4345
|
-
};
|
|
4346
|
-
}
|
|
4347
|
-
function oldDateRangesOf(rule) {
|
|
4348
|
-
const { slot, availability } = rule;
|
|
4349
|
-
const wholePeriods = slot.wholePeriods ?? false;
|
|
4350
|
-
const stay = (count) => count ? { count, unit: periodUnitOf({ ratePeriod: rule.ratePeriod, wholePeriods }) } : void 0;
|
|
4351
|
-
return {
|
|
4352
|
-
// Old `[]` meant "open every day" — the new form says that by having no rows.
|
|
4353
|
-
weeklyHours: availability.weeklyHours?.length ? availability.weeklyHours : void 0,
|
|
4354
|
-
arrivalDays: availability.arrivalDays,
|
|
4355
|
-
checkInTime: rule.checkInTime,
|
|
4356
|
-
checkOutTime: rule.checkOutTime,
|
|
4357
|
-
checkTimesByWeekday: rule.checkTimesByWeekday,
|
|
4358
|
-
minStay: stay(slot.minStay),
|
|
4359
|
-
maxStay: stay(slot.maxStay),
|
|
4360
|
-
wholePeriods
|
|
4361
|
-
};
|
|
4362
|
-
}
|
|
4363
|
-
function periodUnitOf({
|
|
4364
|
-
ratePeriod,
|
|
4365
|
-
wholePeriods
|
|
4366
|
-
}) {
|
|
4367
|
-
const units = {
|
|
4368
|
-
["hour" /* HOUR */]: "hour" /* HOUR */,
|
|
4369
|
-
["night" /* NIGHT */]: "night" /* NIGHT */,
|
|
4370
|
-
["day" /* DAY */]: "day" /* DAY */,
|
|
4371
|
-
["week" /* WEEK */]: wholePeriods ? "week" /* WEEK */ : "day" /* DAY */,
|
|
4372
|
-
["month" /* MONTH */]: wholePeriods ? "month" /* MONTH */ : "day" /* DAY */
|
|
4373
|
-
};
|
|
4374
|
-
const unit2 = units[ratePeriod];
|
|
4375
|
-
if (!unit2) throw new BookingRulesError(`Booking rules: "${ratePeriod}" is not a date-range rate period`);
|
|
4376
|
-
return unit2;
|
|
4377
|
-
}
|
|
4378
|
-
var OLD_BUFFER = {
|
|
4379
|
-
path: "slot.bufferMinutes",
|
|
4380
|
-
home: {
|
|
4381
|
-
"time-slots": "slot.buffer",
|
|
4382
|
-
sessions: "slot.buffer",
|
|
4383
|
-
// The old night grid never read it: housekeeping is the gap between check-out and check-in (O-1).
|
|
4384
|
-
"date-ranges": ({ ratePeriod }) => ratePeriod === "night" /* NIGHT */ ? { unread: "nights clean between check-out and check-in" } : "slot.buffer"
|
|
4385
|
-
}
|
|
4386
|
-
};
|
|
4387
|
-
var OLD_FIELDS = [
|
|
4388
|
-
{
|
|
4389
|
-
path: "slot.lengthMinutes",
|
|
4390
|
-
home: {
|
|
4391
|
-
"time-slots": "timeSlots.length",
|
|
4392
|
-
sessions: { unread: "placeholder" },
|
|
4393
|
-
"date-ranges": { unread: "placeholder" }
|
|
4394
|
-
}
|
|
4395
|
-
},
|
|
4396
|
-
OLD_BUFFER,
|
|
4397
|
-
{
|
|
4398
|
-
path: "slot.minStay",
|
|
4399
|
-
home: {
|
|
4400
|
-
"time-slots": { dropped: "time-slots rules have no stay limits" },
|
|
4401
|
-
sessions: { dropped: "sessions rules have no stay limits" },
|
|
4402
|
-
"date-ranges": "dateRanges.minStay"
|
|
4403
|
-
}
|
|
4404
|
-
},
|
|
4405
|
-
{
|
|
4406
|
-
path: "slot.maxStay",
|
|
4407
|
-
home: {
|
|
4408
|
-
"time-slots": { dropped: "time-slots rules have no stay limits" },
|
|
4409
|
-
sessions: { dropped: "sessions rules have no stay limits" },
|
|
4410
|
-
"date-ranges": "dateRanges.maxStay"
|
|
4411
|
-
}
|
|
4412
|
-
},
|
|
4413
|
-
{
|
|
4414
|
-
path: "window.holdMinutes",
|
|
4415
|
-
home: { "time-slots": "window.hold", sessions: "window.hold", "date-ranges": "window.hold" }
|
|
4416
|
-
},
|
|
4417
|
-
{
|
|
4418
|
-
path: "window.minNoticeMinutes",
|
|
4419
|
-
home: { "time-slots": "window.minNotice", sessions: "window.minNotice", "date-ranges": "window.minNotice" }
|
|
4420
|
-
},
|
|
4421
|
-
// The two old max-advance fields are one fact, as the old readers took it: minutes, else days × 1440.
|
|
4422
|
-
...["window.maxAdvanceMinutes", "window.maxAdvanceDays"].map((path) => ({
|
|
4423
|
-
path,
|
|
4424
|
-
carried: maxAdvanceMinutesOf,
|
|
4425
|
-
home: { "time-slots": "window.maxAdvance", sessions: "window.maxAdvance", "date-ranges": "window.maxAdvance" }
|
|
4426
|
-
})),
|
|
4427
|
-
{
|
|
4428
|
-
path: "availability.weeklyHours",
|
|
4429
|
-
home: {
|
|
4430
|
-
"time-slots": "timeSlots.weeklyHours",
|
|
4431
|
-
sessions: { unread: "sessions read their timetable" },
|
|
4432
|
-
"date-ranges": "dateRanges.weeklyHours"
|
|
4433
|
-
}
|
|
4434
|
-
},
|
|
4435
|
-
{
|
|
4436
|
-
path: "availability.arrivalDays",
|
|
4437
|
-
home: {
|
|
4438
|
-
"time-slots": { unread: "date ranges only" },
|
|
4439
|
-
sessions: { unread: "date ranges only" },
|
|
4440
|
-
"date-ranges": "dateRanges.arrivalDays"
|
|
4441
|
-
}
|
|
4442
|
-
},
|
|
4443
|
-
// An `opening-hours` night has no check times (FC-1503): switching to it drops the old ones, said in a note.
|
|
4444
|
-
...["checkInTime", "checkOutTime", "checkTimesByWeekday"].map((path) => ({
|
|
4445
|
-
path,
|
|
4446
|
-
home: {
|
|
4447
|
-
"time-slots": { unread: "date ranges only" },
|
|
4448
|
-
sessions: { unread: "date ranges only" },
|
|
4449
|
-
"date-ranges": ({ dateRanges }) => dateRanges?.arriveLeave === "opening-hours" /* OPENING_HOURS */ ? { dropped: "opening-hours nights have no check times" } : `dateRanges.${path}`
|
|
4450
|
-
}
|
|
4451
|
-
}))
|
|
4452
|
-
];
|
|
4453
|
-
var homeOf = (field, rule) => {
|
|
4454
|
-
const home = field.home[bookingMethodOf(rule)];
|
|
4455
|
-
return typeof home === "function" ? home(rule) : home;
|
|
4456
|
-
};
|
|
4457
|
-
var carriedValueOf = (rule, field) => field.carried ? field.carried(rule) : valueAt(rule, field.path);
|
|
4458
|
-
var carries = (value) => value != null && value !== 0 && !(Array.isArray(value) && value.length === 0);
|
|
4459
|
-
function ruleInNewShape(rule) {
|
|
4460
|
-
const set = { ...typePartInNewShape(rule), ...durationsInNewShape(rule) };
|
|
4461
|
-
const unset = [...OLD_FIELDS.map(({ path }) => path), "slot.wholePeriods"].filter(
|
|
4462
|
-
(path) => valueAt(rule, path) !== void 0
|
|
4463
|
-
);
|
|
4464
|
-
const written = writtenRule(rule, set, unset);
|
|
4465
|
-
bookingRuleParts(written);
|
|
4466
|
-
refuseLostValues(rule, written);
|
|
4467
|
-
const changesBehaviour = sellsOneDayOfWeekOrMonth(rule) ? "whole-periods" : void 0;
|
|
4468
|
-
const notes = [
|
|
4469
|
-
...droppedFieldNotes(rule, written),
|
|
4470
|
-
...changesBehaviour ? [`${rule.ratePeriod} rule now sells whole ${rule.ratePeriod}s, was one day per booking`] : []
|
|
4471
|
-
];
|
|
4472
|
-
return { set, unset, problems: durationProblems(written), notes, ...changesBehaviour && { changesBehaviour } };
|
|
4473
|
-
}
|
|
4474
|
-
function typePartInNewShape(rule) {
|
|
4475
|
-
const method = bookingMethodOf(rule);
|
|
4476
|
-
if (method === "sessions") return {};
|
|
4477
|
-
if (method === "time-slots") return { timeSlots: newTimeSlotsOf(rule.timeSlots ?? oldTimeSlotsOf(rule)) };
|
|
4478
|
-
if (rule.dateRanges) return { dateRanges: rule.dateRanges };
|
|
4479
|
-
const dateRanges = oldDateRangesOf(rule);
|
|
4480
|
-
delete dateRanges.wholePeriods;
|
|
4481
|
-
return { dateRanges: definedOnly(dateRanges) };
|
|
4482
|
-
}
|
|
4483
|
-
function durationsInNewShape(rule) {
|
|
4484
|
-
const { buffer, minNotice } = ruleDurationsOf(rule);
|
|
4485
|
-
return definedOnly({
|
|
4486
|
-
"slot.buffer": rule.slot.buffer ?? (typeof homeOf(OLD_BUFFER, rule) === "string" ? buffer : void 0),
|
|
4487
|
-
"window.hold": holdOf(rule) ?? DEFAULT_HOLD,
|
|
4488
|
-
"window.minNotice": minNotice,
|
|
4489
|
-
"window.maxAdvance": ruleDurationsOf(rule).maxAdvance
|
|
4490
|
-
});
|
|
4491
|
-
}
|
|
4492
|
-
var sellsOneDayOfWeekOrMonth = ({ ratePeriod, slot, dateRanges }) => !dateRanges && (ratePeriod === "week" /* WEEK */ || ratePeriod === "month" /* MONTH */) && !slot.wholePeriods;
|
|
4493
|
-
function droppedFieldNotes(rule, written) {
|
|
4494
|
-
const weekOrMonth = rule.ratePeriod === "week" /* WEEK */ || rule.ratePeriod === "month" /* MONTH */;
|
|
4495
|
-
return [
|
|
4496
|
-
...OLD_FIELDS.flatMap((field) => {
|
|
4497
|
-
const home = homeOf(field, rule);
|
|
4498
|
-
const dropped = typeof home === "object" && "dropped" in home && carries(carriedValueOf(rule, field));
|
|
4499
|
-
return dropped ? [`${field.path} is dropped: ${home.dropped}`] : [];
|
|
4500
|
-
}),
|
|
4501
|
-
...rule.slot.wholePeriods && !weekOrMonth ? ["slot.wholePeriods is dropped: only week and month rules have it"] : [],
|
|
4502
|
-
...rule.ratePeriod === "hour" /* HOUR */ && !written.dateRanges?.weeklyHours?.length ? ["hour rule has no opening hours: nothing can be booked"] : [],
|
|
4503
|
-
...rule.window.holdMinutes == null && !rule.window.hold ? [`window.hold is set to the default ${DEFAULT_HOLD_MINUTES} minutes`] : []
|
|
4504
|
-
];
|
|
4505
|
-
}
|
|
4506
|
-
function writtenRule(rule, set, unset) {
|
|
4507
|
-
const written = {
|
|
4508
|
-
...rule,
|
|
4509
|
-
slot: { ...rule.slot },
|
|
4510
|
-
window: { ...rule.window },
|
|
4511
|
-
availability: { ...rule.availability }
|
|
4512
|
-
};
|
|
4513
|
-
for (const path of unset) {
|
|
4514
|
-
const [head, leaf] = path.split(".");
|
|
4515
|
-
if (leaf) delete written[head][leaf];
|
|
4516
|
-
else delete written[head];
|
|
4517
|
-
}
|
|
4518
|
-
for (const [path, value] of Object.entries(set)) {
|
|
4519
|
-
const [head, leaf] = path.split(".");
|
|
4520
|
-
if (leaf) written[head][leaf] = value;
|
|
4521
|
-
else written[head] = value;
|
|
4522
|
-
}
|
|
4523
|
-
return written;
|
|
4524
|
-
}
|
|
4525
|
-
function refuseLostValues(rule, written) {
|
|
4526
|
-
for (const field of OLD_FIELDS) {
|
|
4527
|
-
const home = homeOf(field, rule);
|
|
4528
|
-
if (typeof home === "string" && carries(carriedValueOf(rule, field)) && valueAt(written, home) == null) {
|
|
4529
|
-
throw new BookingRulesError(`Booking rules: ${home} is missing \u2014 the rule's old value would be lost`);
|
|
4530
|
-
}
|
|
4531
|
-
}
|
|
4532
|
-
}
|
|
4533
|
-
var definedOnly = (value) => Object.fromEntries(Object.entries(value).filter(([, entry]) => entry != null));
|
|
4534
|
-
var valueAt = (rule, path) => path.split(".").reduce((node, key) => node?.[key], rule);
|
|
4535
|
-
|
|
4536
|
-
// booking/grid.ts
|
|
4537
|
-
var MINUTE3 = 6e4;
|
|
4538
|
-
var HOUR_MINUTES = 60;
|
|
4539
|
-
var MAX_RANGE_DAYS = 366;
|
|
4540
|
-
var asTime = (value, field) => {
|
|
4541
|
-
if (value == null) return void 0;
|
|
4542
|
-
const time = new Date(value).getTime();
|
|
4543
|
-
if (Number.isNaN(time)) throw new BookingRulesError(`Booking rules: ${field} is not a date, got "${String(value)}"`);
|
|
4544
|
-
return time;
|
|
4545
|
-
};
|
|
4546
|
-
function parseHhMm(value, field) {
|
|
4547
|
-
const [hours, minutes] = value.split(":").map(Number);
|
|
4548
|
-
if (!Number.isInteger(hours) || !Number.isInteger(minutes)) {
|
|
4549
|
-
throw new BookingRulesError(`Booking rules: ${field} must be "HH:mm", got "${value}"`);
|
|
4550
|
-
}
|
|
4551
|
-
return hours * 60 + minutes;
|
|
4552
|
-
}
|
|
4553
|
-
function windowEndsAt(rule, now) {
|
|
4554
|
-
const maxAdvanceMinutes = maxAdvanceMinutesOf(rule);
|
|
4555
|
-
const ends = Math.min(
|
|
4556
|
-
maxAdvanceMinutes ? now.getTime() + maxAdvanceMinutes * MINUTE3 : Number.POSITIVE_INFINITY,
|
|
4557
|
-
asTime(rule.window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY
|
|
4558
|
-
);
|
|
4559
|
-
return Number.isFinite(ends) ? new Date(ends) : null;
|
|
4560
|
-
}
|
|
4561
|
-
function windowEndsAtInZone(rule, now, timeZone) {
|
|
4562
|
-
const ends = Math.min(
|
|
4563
|
-
lastStartOf(rule, now, timeZone),
|
|
4564
|
-
asTime(rule.window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY
|
|
4565
|
-
);
|
|
4566
|
-
return Number.isFinite(ends) ? new Date(ends) : null;
|
|
4567
|
-
}
|
|
4568
|
-
function lastStartOf(rule, now, timeZone) {
|
|
4569
|
-
const { maxAdvance } = ruleDurationsOf(rule);
|
|
4570
|
-
if (!maxAdvance) return Number.POSITIVE_INFINITY;
|
|
4571
|
-
const reached = addInZone(now, maxAdvance, timeZone, "window.maxAdvance");
|
|
4572
|
-
if (maxAdvance.unit === "minute" /* MINUTE */ || maxAdvance.unit === "hour" /* HOUR */) {
|
|
4573
|
-
return reached.getTime();
|
|
4574
|
-
}
|
|
4575
|
-
const zone = timeZone;
|
|
4576
|
-
return nextZonedDay(startOfZonedDay(reached, zone), zone).getTime() - 1;
|
|
4577
|
-
}
|
|
4578
|
-
var startsPastMaxAdvance = (rule, startAt, now, timeZone) => startAt.getTime() > lastStartOf(rule, now, timeZone);
|
|
4579
|
-
function addInZone(from, duration, timeZone, field) {
|
|
4580
|
-
if (timeZone) return addDuration(from, duration, timeZone);
|
|
4581
|
-
if (duration.unit === "minute" /* MINUTE */ || duration.unit === "hour" /* HOUR */) {
|
|
4582
|
-
return addClockDuration(from, duration);
|
|
4583
|
-
}
|
|
4584
|
-
throw new BookingRulesError(`Booking rules: ${field} in ${duration.unit}s needs the shop's time zone`);
|
|
4585
|
-
}
|
|
4586
|
-
function maxAdvanceMinutesOf(rule) {
|
|
4587
|
-
const { maxAdvanceMinutes, maxAdvanceDays } = rule.window;
|
|
4588
|
-
return maxAdvanceMinutes ?? (maxAdvanceDays ?? 0) * 1440;
|
|
4589
|
-
}
|
|
4590
|
-
var asMinutes = (minutes) => minutes == null ? void 0 : { count: minutes, unit: "minute" /* MINUTE */ };
|
|
4591
|
-
var inMinutes = (minutes) => minutes === 0 ? void 0 : asMinutes(minutes);
|
|
4592
|
-
function notNegative(duration, field) {
|
|
4593
|
-
if (duration && !(Number.isFinite(duration.count) && duration.count >= 0)) {
|
|
4594
|
-
throw new BookingRulesError(`Booking rules: ${field} must be a number of at least 0, got ${duration.count}`);
|
|
4595
|
-
}
|
|
4596
|
-
return duration;
|
|
4597
|
-
}
|
|
4598
|
-
function ruleDurationsOf(rule) {
|
|
4599
|
-
const { slot, window } = rule;
|
|
4600
|
-
return {
|
|
4601
|
-
buffer: notNegative(
|
|
4602
|
-
slot.buffer ?? inMinutes(slot.bufferMinutes),
|
|
4603
|
-
slot.buffer ? "slot.buffer" : "slot.bufferMinutes"
|
|
4604
|
-
),
|
|
4605
|
-
hold: window.hold ?? asMinutes(window.holdMinutes),
|
|
4606
|
-
minNotice: notNegative(
|
|
4607
|
-
window.minNotice ?? inMinutes(window.minNoticeMinutes),
|
|
4608
|
-
window.minNotice ? "window.minNotice" : "window.minNoticeMinutes"
|
|
4609
|
-
),
|
|
4610
|
-
maxAdvance: window.maxAdvance ?? oldMaxAdvanceOf(window)
|
|
4611
|
-
};
|
|
4612
|
-
}
|
|
4613
|
-
function oldMaxAdvanceOf({
|
|
4614
|
-
maxAdvanceMinutes,
|
|
4615
|
-
maxAdvanceDays
|
|
4616
|
-
}) {
|
|
4617
|
-
const days = maxAdvanceDays ?? 0;
|
|
4618
|
-
if (maxAdvanceMinutes == null || days > 0 && maxAdvanceMinutes === days * 1440) {
|
|
4619
|
-
return days > 0 ? { count: days, unit: "day" /* DAY */ } : void 0;
|
|
4620
|
-
}
|
|
4621
|
-
return maxAdvanceMinutes ? { count: maxAdvanceMinutes, unit: "minute" /* MINUTE */ } : void 0;
|
|
4622
|
-
}
|
|
4623
|
-
function periodSlot(dayStart, timeZone, parts, buffer, openMinute, closeMinute) {
|
|
4624
|
-
const { ratePeriod } = parts;
|
|
4625
|
-
const at = (minutes) => atZonedMinute(dayStart, minutes, timeZone);
|
|
4626
|
-
if (ratePeriod === "night" /* NIGHT */ && parts.arriveLeave !== "opening-hours" /* OPENING_HOURS */) {
|
|
4627
|
-
const arrival = zonedParts(dayStart, timeZone).weekday;
|
|
4628
|
-
const departure = (arrival + 1) % 7;
|
|
4629
|
-
return {
|
|
4630
|
-
startAt: at(checkTimesOf(parts, arrival).checkIn),
|
|
4631
|
-
endAt: at(1440 + checkTimesOf(parts, departure).checkOut),
|
|
4632
|
-
// Housekeeping sits between check-out and the next check-in: it costs no night.
|
|
4633
|
-
bufferEndAt: at(1440 + checkTimesOf(parts, departure).checkIn),
|
|
4634
|
-
canStart: true
|
|
4635
|
-
};
|
|
4636
|
-
}
|
|
4637
|
-
const from = ratePeriod === "day" /* DAY */ ? openMinute ?? 0 : 0;
|
|
4638
|
-
const to = ratePeriod === "day" /* DAY */ ? closeMinute ?? 1440 : 1440;
|
|
4639
|
-
const turnaround = parts.wholePeriods || ratePeriod === "night" /* NIGHT */ ? void 0 : buffer;
|
|
4640
|
-
return {
|
|
4641
|
-
startAt: at(from),
|
|
4642
|
-
endAt: at(to),
|
|
4643
|
-
bufferEndAt: turnaround ? addDuration(at(to), turnaround, timeZone) : at(to),
|
|
4644
|
-
canStart: true
|
|
4645
|
-
};
|
|
4646
|
-
}
|
|
4647
|
-
function checkTimesOf(rule, weekday) {
|
|
4648
|
-
const row = rule.checkTimesByWeekday?.find((entry) => entry.weekday === weekday);
|
|
4649
|
-
const checkInTime = row?.checkInTime ?? rule.checkInTime;
|
|
4650
|
-
const checkOutTime = row?.checkOutTime ?? rule.checkOutTime;
|
|
4651
|
-
if (!checkInTime || !checkOutTime) {
|
|
4652
|
-
throw new BookingRulesError("Overnight booking rules need both checkInTime and checkOutTime");
|
|
4653
|
-
}
|
|
4654
|
-
return { checkIn: parseHhMm(checkInTime, "checkInTime"), checkOut: parseHhMm(checkOutTime, "checkOutTime") };
|
|
4655
|
-
}
|
|
4656
|
-
function freeGaps(openAt, closeAt, busy) {
|
|
4657
|
-
const inside = busy.map(({ startAt, bufferEndAt }) => ({ from: +startAt, to: +bufferEndAt })).filter(({ from, to }) => to > openAt && from < closeAt).sort((first, second) => first.from - second.from);
|
|
4658
|
-
const gaps = [];
|
|
4659
|
-
let cursor = openAt;
|
|
4660
|
-
for (const { from, to } of inside) {
|
|
4661
|
-
if (from > cursor) gaps.push({ from: cursor, to: from, endsAtBooking: true });
|
|
4662
|
-
cursor = Math.max(cursor, to);
|
|
4663
|
-
if (cursor >= closeAt) break;
|
|
4664
|
-
}
|
|
4665
|
-
if (cursor < closeAt) gaps.push({ from: cursor, to: closeAt, endsAtBooking: false });
|
|
4666
|
-
return gaps;
|
|
4667
|
-
}
|
|
4668
|
-
function sessionCells(rule, timeZone, from, to) {
|
|
4669
|
-
if (!rule.sessions) throw new BookingRulesError("Scheduled-session rules need their sessions");
|
|
4670
|
-
const { weekly = [], dates = [] } = rule.sessions;
|
|
4671
|
-
const { buffer } = ruleDurationsOf(rule);
|
|
4672
|
-
const cell = (startAt, endAt) => ({
|
|
4673
|
-
startAt: new Date(startAt),
|
|
4674
|
-
endAt: new Date(endAt),
|
|
4675
|
-
bufferEndAt: buffer ? addDuration(new Date(endAt), buffer, timeZone) : new Date(endAt),
|
|
4676
|
-
canStart: true
|
|
4677
|
-
});
|
|
4678
|
-
const cells = dates.map(({ date, startMinute, endMinute }) => {
|
|
4679
|
-
const [year, month, day] = calendarDate(date);
|
|
4680
|
-
return cell(
|
|
4681
|
-
+instantFromLocal(year, month, day, startMinute, timeZone),
|
|
4682
|
-
+instantFromLocal(year, month, day, endMinute, timeZone)
|
|
4683
|
-
);
|
|
4684
|
-
});
|
|
4685
|
-
const lastDay = startOfZonedDay(to, timeZone).getTime();
|
|
4686
|
-
for (let day = startOfZonedDay(from, timeZone); day.getTime() <= lastDay; day = nextZonedDay(day, timeZone)) {
|
|
4687
|
-
const weekday = zonedParts(day, timeZone).weekday;
|
|
4688
|
-
for (const row of weekly.filter((entry) => entry.weekday === weekday)) {
|
|
4689
|
-
cells.push(cell(+atZonedMinute(day, row.startMinute, timeZone), +atZonedMinute(day, row.endMinute, timeZone)));
|
|
4690
|
-
}
|
|
4691
|
-
}
|
|
4692
|
-
const blocked = offMarketOf(rule);
|
|
4693
|
-
return cells.filter(({ startAt, bufferEndAt }) => {
|
|
4694
|
-
const start = startAt.getTime();
|
|
4695
|
-
return start >= from.getTime() && start <= to.getTime() && !isBlocked(blocked, start, bufferEndAt.getTime());
|
|
4696
|
-
});
|
|
4697
|
-
}
|
|
4698
|
-
function calendarDate(value) {
|
|
4699
|
-
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value ?? "");
|
|
4700
|
-
const [year, month, day] = match ? match.slice(1).map(Number) : [];
|
|
4701
|
-
const real = match && new Date(Date.UTC(year, month - 1, day)).toISOString().slice(0, 10) === value;
|
|
4702
|
-
if (!real) throw new BookingRulesError(`Booking rules: "${value}" is not a date (YYYY-MM-DD)`);
|
|
4703
|
-
return [year, month, day];
|
|
4704
|
-
}
|
|
4705
|
-
var offMarketOf = (rule) => (rule.availability.offMarket ?? []).map(({ from: blockFrom, to: blockTo }) => ({
|
|
4706
|
-
from: asTime(blockFrom, "availability.offMarket.from"),
|
|
4707
|
-
to: asTime(blockTo, "availability.offMarket.to")
|
|
4708
|
-
}));
|
|
4709
|
-
var isBlocked = (blocked, start, bufferEnd) => blocked.some(({ from, to }) => start < to && bufferEnd > from);
|
|
4710
|
-
function hourCells(openAt, closeAt) {
|
|
4711
|
-
const cells = [];
|
|
4712
|
-
for (let start = openAt; start + HOUR_MINUTES * MINUTE3 <= closeAt; start += HOUR_MINUTES * MINUTE3) {
|
|
4713
|
-
const endAt = new Date(start + HOUR_MINUTES * MINUTE3);
|
|
4714
|
-
cells.push({ startAt: new Date(start), endAt, bufferEndAt: endAt, canStart: true });
|
|
4715
|
-
}
|
|
4716
|
-
return cells;
|
|
4717
|
-
}
|
|
4718
|
-
function cellsOf(rule, parts, timeZone, from, to, busy) {
|
|
4719
|
-
if (parts.method === "sessions") return sessionCells(rule, timeZone, from, to);
|
|
4720
|
-
const { buffer } = ruleDurationsOf(rule);
|
|
4721
|
-
const cells = [];
|
|
4722
|
-
const lastDay = startOfZonedDay(to, timeZone).getTime();
|
|
4723
|
-
for (let day = startOfZonedDay(from, timeZone); day.getTime() <= lastDay; day = nextZonedDay(day, timeZone)) {
|
|
4724
|
-
cells.push(
|
|
4725
|
-
...parts.method === "time-slots" ? timeSlotCells(parts, buffer, day, timeZone, busy) : periodCells(parts, buffer, day, timeZone)
|
|
4726
|
-
);
|
|
4727
|
-
}
|
|
4728
|
-
return cells;
|
|
4729
|
-
}
|
|
4730
|
-
function timeSlotCells(parts, buffer, dayStart, timeZone, busy) {
|
|
4731
|
-
const weekday = zonedParts(dayStart, timeZone).weekday;
|
|
4732
|
-
return parts.weeklyHours.filter((entry) => entry.weekday === weekday).flatMap(
|
|
4733
|
-
(row) => freeGaps(
|
|
4734
|
-
+atZonedMinute(dayStart, row.openMinute, timeZone),
|
|
4735
|
-
+atZonedMinute(dayStart, row.closeMinute, timeZone),
|
|
4736
|
-
busy
|
|
4737
|
-
).flatMap((gap) => cellsInGap(gap, parts.length, buffer, timeZone))
|
|
4738
|
-
);
|
|
4739
|
-
}
|
|
4740
|
-
function cellsInGap(gap, length, buffer, timeZone) {
|
|
4741
|
-
const cells = [];
|
|
4742
|
-
for (let start = gap.from; ; ) {
|
|
4743
|
-
const endAt = addDuration(new Date(start), length, timeZone);
|
|
4744
|
-
const bufferEndAt = buffer ? addDuration(endAt, buffer, timeZone) : new Date(endAt.getTime());
|
|
4745
|
-
if ((gap.endsAtBooking ? bufferEndAt : endAt).getTime() > gap.to) return cells;
|
|
4746
|
-
cells.push({ startAt: new Date(start), endAt, bufferEndAt, canStart: true });
|
|
4747
|
-
start = bufferEndAt.getTime();
|
|
4748
|
-
}
|
|
4749
|
-
}
|
|
4750
|
-
function periodCells(parts, buffer, dayStart, timeZone) {
|
|
4751
|
-
const weekday = zonedParts(dayStart, timeZone).weekday;
|
|
4752
|
-
const rows = (parts.weeklyHours ?? []).filter((entry) => entry.weekday === weekday);
|
|
4753
|
-
if (parts.ratePeriod === "hour" /* HOUR */) {
|
|
4754
|
-
return rows.flatMap(
|
|
4755
|
-
(row) => hourCells(
|
|
4756
|
-
+atZonedMinute(dayStart, row.openMinute, timeZone),
|
|
4757
|
-
+atZonedMinute(dayStart, row.closeMinute, timeZone)
|
|
4758
|
-
)
|
|
4759
|
-
);
|
|
4760
|
-
}
|
|
4761
|
-
if (parts.weeklyHours?.length && rows.length === 0) return [];
|
|
4762
|
-
const built = periodSlot(dayStart, timeZone, parts, buffer, rows[0]?.openMinute, rows[0]?.closeMinute);
|
|
4763
|
-
return [{ ...built, canStart: !parts.arrivalDays?.length || parts.arrivalDays.includes(weekday) }];
|
|
4764
|
-
}
|
|
4765
|
-
function buildGrid(rule, timeZone, from, to, now, busy = []) {
|
|
4766
|
-
if (to.getTime() - from.getTime() > MAX_RANGE_DAYS * 1440 * MINUTE3) {
|
|
4767
|
-
throw new BookingRulesError(`A booking range may span at most ${MAX_RANGE_DAYS} days`);
|
|
4768
|
-
}
|
|
4769
|
-
const { availability, window } = rule;
|
|
4770
|
-
const { minNotice } = ruleDurationsOf(rule);
|
|
4771
|
-
const notBefore = Math.max(
|
|
4772
|
-
(minNotice ? addDuration(now, minNotice, timeZone) : now).getTime(),
|
|
4773
|
-
asTime(window.bookableFrom, "window.bookableFrom") ?? 0,
|
|
4774
|
-
asTime(availability.availableFrom, "availability.availableFrom") ?? 0
|
|
4775
|
-
);
|
|
4776
|
-
const notAfter = asTime(window.bookableTo, "window.bookableTo") ?? Number.POSITIVE_INFINITY;
|
|
4777
|
-
const lastStart = lastStartOf(rule, now, timeZone);
|
|
4778
|
-
const blocked = offMarketOf(rule);
|
|
4779
|
-
const slots = cellsOf(rule, bookingRuleParts(rule), timeZone, from, to, busy);
|
|
4780
|
-
const askedFrom = from.getTime();
|
|
4781
|
-
const askedTo = to.getTime();
|
|
4782
|
-
return slots.filter(({ startAt, bufferEndAt }) => {
|
|
4783
|
-
const start = startAt.getTime();
|
|
4784
|
-
if (start < askedFrom || start >= askedTo) return false;
|
|
4785
|
-
if (start < notBefore || start > notAfter) return false;
|
|
4786
|
-
return !isBlocked(blocked, start, bufferEndAt.getTime());
|
|
4787
|
-
}).flatMap((cell) => cell.startAt.getTime() > lastStart ? pastMaxAdvance(cell, rule) : [cell]).sort((first, second) => +first.startAt - +second.startAt);
|
|
4788
|
-
}
|
|
4789
|
-
function pastMaxAdvance(cell, rule) {
|
|
4790
|
-
if (soldAsCourse(rule)) return [cell];
|
|
4791
|
-
return bookingMethodOf(rule) === "date-ranges" ? [{ ...cell, canStart: false }] : [];
|
|
4792
|
-
}
|
|
4793
|
-
function slotsForWindow(grid, startAt, endAt) {
|
|
4794
|
-
const startIndex = grid.findIndex((entry) => entry.startAt.getTime() === startAt.getTime());
|
|
4795
|
-
if (startIndex < 0) {
|
|
4796
|
-
throw new BookingRulesError(`${startAt.toISOString()} is not a bookable slot start for these rules`);
|
|
4797
|
-
}
|
|
4798
|
-
if (!grid[startIndex].canStart) {
|
|
4799
|
-
throw new BookingRulesError(`${startAt.toISOString()} is not an arrival day for these rules`);
|
|
4800
|
-
}
|
|
4801
|
-
const covered = [];
|
|
4802
|
-
for (let index = startIndex; index < grid.length; index++) {
|
|
4803
|
-
const entry = grid[index];
|
|
4804
|
-
const previous = covered[covered.length - 1];
|
|
4805
|
-
if (previous && entry.startAt.getTime() !== previous.bufferEndAt.getTime()) break;
|
|
4806
|
-
covered.push(entry);
|
|
4807
|
-
if (entry.endAt.getTime() === endAt.getTime()) return covered;
|
|
4808
|
-
if (entry.endAt.getTime() > endAt.getTime()) break;
|
|
4145
|
+
if (maxStay && slots.length > maxStay) {
|
|
4146
|
+
throw new BookingRulesError(`These rules allow at most ${maxStay} period(s), got ${slots.length}`);
|
|
4809
4147
|
}
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
);
|
|
4148
|
+
const last = slots[slots.length - 1];
|
|
4149
|
+
return { slots, endAt: last.endAt, bufferEndAt: last.bufferEndAt };
|
|
4813
4150
|
}
|
|
4151
|
+
var holdExpiresAt = (rule, now) => new Date(now.getTime() + (rule.window.holdMinutes ?? DEFAULT_HOLD_MINUTES) * 6e4);
|
|
4814
4152
|
|
|
4815
4153
|
// shipping/fold-text.ts
|
|
4816
4154
|
function foldText(value) {
|
|
@@ -5247,13 +4585,10 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5247
4585
|
AttributeType,
|
|
5248
4586
|
BNPL_METHOD_STATUS,
|
|
5249
4587
|
BNPL_SKIP_REASON,
|
|
5250
|
-
BookingArriveLeave,
|
|
5251
|
-
BookingDurationUnit,
|
|
5252
4588
|
BookingRatePeriod,
|
|
5253
4589
|
BookingResourceKind,
|
|
5254
4590
|
BookingResourceStatus,
|
|
5255
4591
|
BookingRulesError,
|
|
5256
|
-
BookingSessionSale,
|
|
5257
4592
|
BookingType,
|
|
5258
4593
|
CANADA_PROVINCES,
|
|
5259
4594
|
CONDITION_OPERATORS,
|
|
@@ -5268,6 +4603,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5268
4603
|
DEFAULT_DISPLAY_STATE_MAP,
|
|
5269
4604
|
DEFAULT_HOLD_MINUTES,
|
|
5270
4605
|
DEFAULT_RESOLVED_CONFIG,
|
|
4606
|
+
DEFAULT_SHELL_SETTINGS,
|
|
5271
4607
|
DEFAULT_UNIT_ID,
|
|
5272
4608
|
DualWriteStrategy,
|
|
5273
4609
|
EUFixedRates,
|
|
@@ -5323,6 +4659,11 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5323
4659
|
ResidualPaymentMethod,
|
|
5324
4660
|
ResidualStatus,
|
|
5325
4661
|
ResourceAvailabilityState,
|
|
4662
|
+
SHELL_FLOW_SETTINGS_PREFIX,
|
|
4663
|
+
SHELL_FLOW_TIPS_KEY,
|
|
4664
|
+
SHELL_TIP_LABEL_MAX_LENGTH,
|
|
4665
|
+
SHELL_TIP_PERCENT_MAX,
|
|
4666
|
+
SHELL_TIP_PERCENT_MIN,
|
|
5326
4667
|
SHIPPING_COUNTRIES,
|
|
5327
4668
|
STATE_SCHEMA,
|
|
5328
4669
|
STRIPE_SUPPORTED_COUNTRIES,
|
|
@@ -5343,7 +4684,6 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5343
4684
|
StripeStatus,
|
|
5344
4685
|
TimePeriod,
|
|
5345
4686
|
TopMetericsSort,
|
|
5346
|
-
UNLIMITED_PLACES,
|
|
5347
4687
|
UserTypes,
|
|
5348
4688
|
addAmounts,
|
|
5349
4689
|
addressPlaceKeys,
|
|
@@ -5352,7 +4692,6 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5352
4692
|
adyenStoreRequiresStateOrProvince,
|
|
5353
4693
|
adyenSupportsTaxNumberAbsent,
|
|
5354
4694
|
adyenTaxNumberFormat,
|
|
5355
|
-
allowedDurationUnits,
|
|
5356
4695
|
amountToString,
|
|
5357
4696
|
ancestorChain,
|
|
5358
4697
|
applyAssignment,
|
|
@@ -5362,21 +4701,15 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5362
4701
|
baseFulfillmentDefinitions,
|
|
5363
4702
|
baseOf,
|
|
5364
4703
|
basePaymentDefinitions,
|
|
5365
|
-
bookingMethodOf,
|
|
5366
|
-
bookingRuleParts,
|
|
5367
4704
|
buildAvailability,
|
|
5368
4705
|
buildGrid,
|
|
5369
4706
|
buildOrderContext,
|
|
5370
4707
|
buildPosPresetConfig,
|
|
5371
4708
|
buildResolvedConfig,
|
|
5372
4709
|
calculatePercentage,
|
|
5373
|
-
calendarDate,
|
|
5374
4710
|
canTransition,
|
|
5375
|
-
capacityOf,
|
|
5376
4711
|
cheapestCompositeItem,
|
|
5377
4712
|
cheapestCompositePrice,
|
|
5378
|
-
checkPartySize,
|
|
5379
|
-
checkQtyPerBooking,
|
|
5380
4713
|
compositeItemCost,
|
|
5381
4714
|
compositeItemUnavailable,
|
|
5382
4715
|
compositeMakeable,
|
|
@@ -5385,10 +4718,6 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5385
4718
|
compositeVariantInStock,
|
|
5386
4719
|
conditionSummary,
|
|
5387
4720
|
convertFixedFeeToLocalCurrency,
|
|
5388
|
-
courseSessions,
|
|
5389
|
-
courseSpan,
|
|
5390
|
-
courseStarted,
|
|
5391
|
-
courseStartedInZone,
|
|
5392
4721
|
createAmount,
|
|
5393
4722
|
crossAxisRuleApplies,
|
|
5394
4723
|
currentAssignees,
|
|
@@ -5397,13 +4726,11 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5397
4726
|
deriveUnitId,
|
|
5398
4727
|
displayRuleMatchesPair,
|
|
5399
4728
|
divideAmount,
|
|
5400
|
-
durationProblems,
|
|
5401
|
-
durationText,
|
|
5402
4729
|
evaluateCondition,
|
|
5403
4730
|
evaluateConditionSet,
|
|
5404
4731
|
extendPrice,
|
|
5405
4732
|
extendPriceFor,
|
|
5406
|
-
|
|
4733
|
+
flowSettingsFromShellSettings,
|
|
5407
4734
|
formatCurrency,
|
|
5408
4735
|
formatInUnit,
|
|
5409
4736
|
formatMinorUnitsToString,
|
|
@@ -5437,6 +4764,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5437
4764
|
isFulfillmentState,
|
|
5438
4765
|
isInCart,
|
|
5439
4766
|
isPaymentState,
|
|
4767
|
+
isShellTipPercent,
|
|
5440
4768
|
isSupportedCurrency,
|
|
5441
4769
|
isSystemFamilyCode,
|
|
5442
4770
|
isValidQuantity,
|
|
@@ -5445,9 +4773,7 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5445
4773
|
listCountries,
|
|
5446
4774
|
listProvinces,
|
|
5447
4775
|
listShippingCountries,
|
|
5448
|
-
longestMinutesOf,
|
|
5449
4776
|
mapToLegacyStatus,
|
|
5450
|
-
maxAdvanceMinutesOf,
|
|
5451
4777
|
maxPrecisionFor,
|
|
5452
4778
|
mergeFragment,
|
|
5453
4779
|
modifiersSellable,
|
|
@@ -5459,15 +4785,11 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5459
4785
|
normalizePostCode,
|
|
5460
4786
|
normalizeProvince,
|
|
5461
4787
|
occupancyIn,
|
|
5462
|
-
occupiedAtOutlet,
|
|
5463
|
-
oldMaxAdvanceOf,
|
|
5464
4788
|
orderAssignments,
|
|
5465
4789
|
parseAmountToMinorUnits,
|
|
5466
4790
|
parseCurrencyCode,
|
|
5467
4791
|
parseStripeCurrencyCode,
|
|
5468
|
-
pickFreeResource,
|
|
5469
4792
|
placeKey,
|
|
5470
|
-
planCourse,
|
|
5471
4793
|
planWindow,
|
|
5472
4794
|
poolDemand,
|
|
5473
4795
|
poolOf,
|
|
@@ -5477,27 +4799,27 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5477
4799
|
presentAt,
|
|
5478
4800
|
priceForTotal,
|
|
5479
4801
|
provincesForPostCode,
|
|
4802
|
+
readShellTipSettings,
|
|
5480
4803
|
removeFragment,
|
|
5481
|
-
rentalEnds,
|
|
5482
4804
|
resolveFamily,
|
|
5483
4805
|
resolveModifiersForProduct,
|
|
4806
|
+
resolveShellSettings,
|
|
4807
|
+
resolveShellSettingsWithSources,
|
|
5484
4808
|
resolveShipping,
|
|
5485
4809
|
resolveTemplate,
|
|
5486
4810
|
resolveUnit,
|
|
5487
4811
|
roundToPrecision,
|
|
5488
|
-
ruleDurationsOf,
|
|
5489
|
-
ruleInNewShape,
|
|
5490
4812
|
sameFamily,
|
|
5491
|
-
sessionCells,
|
|
5492
4813
|
setOrderState,
|
|
4814
|
+
shellSettingsFromCompanyTips,
|
|
4815
|
+
shellSettingsFromFlowSettings,
|
|
4816
|
+
shellSettingsProblems,
|
|
4817
|
+
shellTipSettingsProblems,
|
|
5493
4818
|
shipsToCountry,
|
|
5494
4819
|
shopDayKey,
|
|
5495
4820
|
shopDayRange,
|
|
5496
|
-
shortestMinutesOf,
|
|
5497
4821
|
signReportForDisplay,
|
|
5498
4822
|
slotsForWindow,
|
|
5499
|
-
soldAsCourse,
|
|
5500
|
-
startsPastMaxAdvance,
|
|
5501
4823
|
stringifyMinorUnits,
|
|
5502
4824
|
subtractAmounts,
|
|
5503
4825
|
toBase,
|
|
@@ -5508,8 +4830,6 @@ var EXPENSE_DEFAULT_CATEGORIES = [
|
|
|
5508
4830
|
validateShippingZone,
|
|
5509
4831
|
violatesFinancialInvariant,
|
|
5510
4832
|
windowEndsAt,
|
|
5511
|
-
windowEndsAtInZone,
|
|
5512
|
-
windowForPeriods,
|
|
5513
4833
|
withinPresence
|
|
5514
4834
|
});
|
|
5515
4835
|
//# sourceMappingURL=index.js.map
|