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