@loczer/storefront-sdk 0.151.0 → 0.152.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.
@@ -97,6 +97,10 @@ export declare const loader: ({ ctx, params }: LoaderArgs) => Promise<{
97
97
  end: string;
98
98
  }[];
99
99
  }[] | undefined;
100
+ extraTimeSlots?: {
101
+ minutesAfterClose: number;
102
+ extraAmount: number;
103
+ }[] | undefined;
100
104
  };
101
105
  currency: "EUR" | "USD" | "GBP" | "CHF";
102
106
  checkout: {
@@ -339,6 +343,10 @@ declare const storefrontConfigurationSchema: z.ZodObject<{
339
343
  end: string;
340
344
  }[];
341
345
  }[] | undefined;
346
+ extraTimeSlots?: {
347
+ minutesAfterClose: number;
348
+ extraAmount: number;
349
+ }[] | undefined;
342
350
  };
343
351
  currency: "EUR" | "USD" | "GBP" | "CHF";
344
352
  checkout: {
@@ -403,6 +411,10 @@ declare const storefrontConfigurationSchema: z.ZodObject<{
403
411
  end: string;
404
412
  }[];
405
413
  }[] | undefined;
414
+ extraTimeSlots?: {
415
+ minutesAfterClose: number;
416
+ extraAmount: number;
417
+ }[] | undefined;
406
418
  };
407
419
  currency: "EUR" | "USD" | "GBP" | "CHF";
408
420
  checkout: {
@@ -768,6 +780,10 @@ export declare function useStorefrontConfig(): {
768
780
  end: string;
769
781
  }[];
770
782
  }[] | undefined;
783
+ extraTimeSlots?: {
784
+ minutesAfterClose: number;
785
+ extraAmount: number;
786
+ }[] | undefined;
771
787
  };
772
788
  currency: "EUR" | "USD" | "GBP" | "CHF";
773
789
  checkout: {
@@ -980,6 +996,10 @@ export declare function useStorefrontConfig(): {
980
996
  end: string;
981
997
  }[];
982
998
  }[] | undefined;
999
+ extraTimeSlots?: {
1000
+ minutesAfterClose: number;
1001
+ extraAmount: number;
1002
+ }[] | undefined;
983
1003
  };
984
1004
  currency: "EUR" | "USD" | "GBP" | "CHF";
985
1005
  checkout: {
@@ -16,6 +16,7 @@ declare namespace bookingPeriod {
16
16
  NormalizedOpeningHours,
17
17
  NormalizeOpeningHoursOptions,
18
18
  normalizeOpeningHours,
19
+ BookingPeriodExtraTimeSlotRule,
19
20
  BookingPeriodConfig_2 as BookingPeriodConfig,
20
21
  BookingPeriodConstants,
21
22
  createBookingPeriodConstants,
@@ -59,10 +60,16 @@ declare type BookingPeriodConfig_2 = {
59
60
  openingHours: StoreOpeningHours;
60
61
  openingHoursOverrides: StoreOpeningOverride[];
61
62
  timeZone: string;
63
+ extraTimeSlots?: BookingPeriodExtraTimeSlotRule[];
62
64
  };
63
65
 
64
66
  declare type BookingPeriodConstants = ReturnType<typeof createBookingPeriodConstants>;
65
67
 
68
+ declare type BookingPeriodExtraTimeSlotRule = {
69
+ minutesAfterClose: number;
70
+ extraAmount: number;
71
+ };
72
+
66
73
  declare interface BookingPeriodInput {
67
74
  startDate?: Date | string | null;
68
75
  startTime?: string | null;
@@ -141,35 +148,6 @@ declare interface DefaultBookingPeriodOptions {
141
148
  config: BookingPeriodConfig_2;
142
149
  }
143
150
 
144
- export declare interface DisabledTimeSlotRule {
145
- startMinutes?: number;
146
- endMinutes?: number;
147
- values?: string[];
148
- reason?: string;
149
- dates?: string[];
150
- weekdays?: number[];
151
- }
152
-
153
- export declare interface DisabledTimeSlotRuleContext {
154
- date?: string;
155
- slotInterval: number;
156
- }
157
-
158
- export declare interface ExtraTimeSlotRule {
159
- startMinutes: number;
160
- endMinutes?: number;
161
- extraAmount: number;
162
- dates?: string[];
163
- weekdays?: number[];
164
- journeyTypes?: JourneyType[];
165
- }
166
-
167
- export declare interface ExtraTimeSlotRuleContext {
168
- date?: string;
169
- slotInterval: number;
170
- journeyType?: JourneyType;
171
- }
172
-
173
151
  export declare const getBookingPeriodTimeSlots: (bookingPeriodConfig: BookingPeriodConfig, { date, }?: {
174
152
  date?: string;
175
153
  }) => Promise<{
@@ -186,14 +164,6 @@ export declare const getBookingPeriodTimeSlotsSync: (bookingPeriodConfig: Bookin
186
164
 
187
165
  declare const getDefaultBookingPeriod: (options: DefaultBookingPeriodOptions) => DefaultBookingPeriod;
188
166
 
189
- export declare const getDisabledTimeSlotRules: (context: DisabledTimeSlotRuleContext) => Promise<DisabledTimeSlotRule[]>;
190
-
191
- export declare const getDisabledTimeSlotRulesSync: (_context: DisabledTimeSlotRuleContext) => DisabledTimeSlotRule[];
192
-
193
- export declare const getExtraTimeSlotRules: (context: ExtraTimeSlotRuleContext) => Promise<ExtraTimeSlotRule[]>;
194
-
195
- export declare const getExtraTimeSlotRulesSync: (_context: ExtraTimeSlotRuleContext) => ExtraTimeSlotRule[];
196
-
197
167
  declare const getWeekdayFromDateString: (dateString: string) => Weekday;
198
168
 
199
169
  declare const instantToBusinessDateString: (date: Date, timeZone: string) => string | undefined;
@@ -249,10 +219,6 @@ declare type NormalizeOpeningHoursOptions = {
249
219
 
250
220
  declare const parseTimeToMinutes: (time?: string | null) => number | null;
251
221
 
252
- export declare const staticDisabledTimeSlotRules: DisabledTimeSlotRule[];
253
-
254
- export declare const staticExtraTimeSlotRules: ExtraTimeSlotRule[];
255
-
256
222
  declare type StoreOpeningDay = {
257
223
  day: Weekday;
258
224
  openingSlots: StoreOpeningSlot[];
@@ -21,10 +21,16 @@ export declare type BookingPeriodConfig = {
21
21
  openingHours: StoreOpeningHours;
22
22
  openingHoursOverrides: StoreOpeningOverride[];
23
23
  timeZone: string;
24
+ extraTimeSlots?: BookingPeriodExtraTimeSlotRule[];
24
25
  };
25
26
 
26
27
  export declare type BookingPeriodConstants = ReturnType<typeof createBookingPeriodConstants>;
27
28
 
29
+ export declare type BookingPeriodExtraTimeSlotRule = {
30
+ minutesAfterClose: number;
31
+ extraAmount: number;
32
+ };
33
+
28
34
  export declare interface BookingPeriodInput {
29
35
  startDate?: Date | string | null;
30
36
  startTime?: string | null;
package/dist/booking.d.ts CHANGED
@@ -11,6 +11,12 @@ declare type BookingPeriodConfig = {
11
11
  openingHours: StoreOpeningHours;
12
12
  openingHoursOverrides: StoreOpeningOverride[];
13
13
  timeZone: string;
14
+ extraTimeSlots?: BookingPeriodExtraTimeSlotRule[];
15
+ };
16
+
17
+ declare type BookingPeriodExtraTimeSlotRule = {
18
+ minutesAfterClose: number;
19
+ extraAmount: number;
14
20
  };
15
21
 
16
22
  declare type BookingSearchStorage = Pick<Storage, "getItem" | "removeItem" | "setItem"> | null | undefined;
@@ -22,6 +28,10 @@ declare type BookingTimingConfig = {
22
28
  minBufferMinutes: number;
23
29
  };
24
30
 
31
+ export declare const createBookingPeriodConfigFromBookingEngineConfiguration: (bookingEngine: StorefrontConfiguration["bookingEngine"], options?: {
32
+ sameDayCutoff?: string;
33
+ }) => BookingPeriodConfig;
34
+
25
35
  export declare const createBookingPeriodConfigFromStorefrontConfiguration: (storefrontConfiguration: StorefrontConfiguration) => BookingPeriodConfig;
26
36
 
27
37
  export declare const getBookingDurationLabel: (booking: StorefrontBookingParams) => {
@@ -173,6 +183,10 @@ declare const storefrontConfigurationSchema: z.ZodObject<{
173
183
  end: string;
174
184
  }[];
175
185
  }[] | undefined;
186
+ extraTimeSlots?: {
187
+ minutesAfterClose: number;
188
+ extraAmount: number;
189
+ }[] | undefined;
176
190
  };
177
191
  currency: "EUR" | "USD" | "GBP" | "CHF";
178
192
  checkout: {
@@ -237,6 +251,10 @@ declare const storefrontConfigurationSchema: z.ZodObject<{
237
251
  end: string;
238
252
  }[];
239
253
  }[] | undefined;
254
+ extraTimeSlots?: {
255
+ minutesAfterClose: number;
256
+ extraAmount: number;
257
+ }[] | undefined;
240
258
  };
241
259
  currency: "EUR" | "USD" | "GBP" | "CHF";
242
260
  checkout: {
@@ -1,9 +1,9 @@
1
1
  import { z as e } from "zod";
2
2
  import { localizedStringSchema as s } from "../models/LocalizedString--6q77SPQ.js";
3
- import { priceUnitSchema as a } from "../models/Price-BlFRDHXV.js";
3
+ import { priceUnitSchema as i } from "../models/Price-BlFRDHXV.js";
4
4
  import { currencyCodeSchema as m } from "./money-Dy4b9loa.js";
5
- import { shopConfigurationSchema as r } from "./shop-opening-hours-B47MMaoD.js";
6
- import { isoDateSchema as H, shopOpeningDaySchema as x, shopOpeningHoursOverrideSchema as z, shopOpeningHoursPeriodSchema as E, shopOpeningSlotSchema as I, timeOfDaySchema as L } from "./shop-opening-hours-B47MMaoD.js";
5
+ import { shopConfigurationSchema as r } from "./shop-opening-hours-DqNWstqT.js";
6
+ import { isoDateSchema as x, shopExtraTimeSlotRuleSchema as E, shopOpeningDaySchema as H, shopOpeningHoursOverrideSchema as z, shopOpeningHoursPeriodSchema as I, shopOpeningSlotSchema as L, timeOfDaySchema as $ } from "./shop-opening-hours-DqNWstqT.js";
7
7
  const l = [
8
8
  "soldOutOnly",
9
9
  "soldOutAndFewRemaining",
@@ -16,30 +16,30 @@ const l = [
16
16
  "soldOutAndFewRemaining",
17
17
  "fewRemaining",
18
18
  "fewRemainingCounts"
19
- ]), p = (i) => c.has(i), d = {
19
+ ]), p = (a) => c.has(a), h = {
20
20
  message: "A defaultFewRemainingThreshold is required for display modes that highlight 'few remaining' states"
21
- }, h = e.object({
21
+ }, d = e.object({
22
22
  defaultMode: u,
23
23
  defaultFewRemainingThreshold: e.number().int().min(1).optional()
24
24
  }).refine(
25
- (i) => !p(i.defaultMode) || i.defaultFewRemainingThreshold !== void 0,
26
- d
25
+ (a) => !p(a.defaultMode) || a.defaultFewRemainingThreshold !== void 0,
26
+ h
27
27
  ), g = e.object({
28
28
  enabled: e.boolean(),
29
29
  defaultTtlMinutes: e.number().int().min(1)
30
30
  }), b = e.object({
31
- unit: a,
31
+ unit: i,
32
32
  label: s.optional(),
33
33
  durationHours: e.number().positive()
34
34
  }), f = e.object({
35
35
  enabled: e.boolean(),
36
36
  boundaryHour: e.number().int().min(0).max(23)
37
37
  }), S = e.object({
38
- baseUnit: a,
38
+ baseUnit: i,
39
39
  rentalUnits: e.array(b).min(1),
40
40
  halfDay: f.optional()
41
41
  }).refine(
42
- (i) => i.rentalUnits.some((t) => t.unit === i.baseUnit),
42
+ (a) => a.rentalUnits.some((t) => t.unit === a.baseUnit),
43
43
  { message: "Rental units must include the configured base unit" }
44
44
  ), y = e.number().min(0, { message: "Percentage must be greater than or equal to 0" }).max(1, { message: "Percentage must be less than or equal to 1" }), o = e.object({
45
45
  enabled: e.boolean(),
@@ -68,8 +68,8 @@ const l = [
68
68
  }).catchall(e.unknown()), R = e.object({
69
69
  mode: O,
70
70
  dynamicOptions: C.optional()
71
- }), k = m, T = e.object({
72
- availabilityDisplay: h,
71
+ }), k = m, M = e.object({
72
+ availabilityDisplay: d,
73
73
  holdSettings: g,
74
74
  pricing: S,
75
75
  bookingDeposit: o,
@@ -80,25 +80,26 @@ const l = [
80
80
  });
81
81
  export {
82
82
  F as DEFAULT_PAYMENT_POLICIES,
83
- h as availabilityDisplayConfigurationSchema,
83
+ d as availabilityDisplayConfigurationSchema,
84
84
  u as availabilityDisplayModeSchema,
85
85
  o as bookingDepositPolicySchema,
86
- T as bookingEngineConfigurationSchema,
86
+ M as bookingEngineConfigurationSchema,
87
87
  R as checkoutConfigurationSchema,
88
88
  C as checkoutDynamicOptionsSchema,
89
89
  O as checkoutModeSchema,
90
90
  k as currencySchema,
91
91
  g as holdSettingsSchema,
92
- H as isoDateSchema,
92
+ x as isoDateSchema,
93
93
  q as paymentPoliciesSchema,
94
94
  S as pricingConfigurationSchema,
95
95
  f as pricingHalfDaySchema,
96
96
  b as pricingUnitOptionSchema,
97
97
  n as securityDepositPolicySchema,
98
98
  r as shopConfigurationSchema,
99
- x as shopOpeningDaySchema,
99
+ E as shopExtraTimeSlotRuleSchema,
100
+ H as shopOpeningDaySchema,
100
101
  z as shopOpeningHoursOverrideSchema,
101
- E as shopOpeningHoursPeriodSchema,
102
- I as shopOpeningSlotSchema,
103
- L as timeOfDaySchema
102
+ I as shopOpeningHoursPeriodSchema,
103
+ L as shopOpeningSlotSchema,
104
+ $ as timeOfDaySchema
104
105
  };
@@ -1,9 +1,9 @@
1
1
  import { z as e } from "zod";
2
2
  import { identifierSchema as i } from "../models/types-DLcvzW5b.js";
3
3
  import { moneyMinorSchema as a } from "./money-Dy4b9loa.js";
4
- import { fulfillmentModeSchema as s } from "./public-booking-engine-configuration-C9VB-WhU.js";
4
+ import { fulfillmentModeSchema as s } from "./public-booking-engine-configuration-DKoak4s5.js";
5
5
  import { richTextSchema as m } from "./rich-text-CqXhNDN3.js";
6
- import { timeOfDaySchema as r, isoDateSchema as n } from "./shop-opening-hours-B47MMaoD.js";
6
+ import { timeOfDaySchema as r, isoDateSchema as n } from "./shop-opening-hours-DqNWstqT.js";
7
7
  const p = e.object({
8
8
  startDate: n,
9
9
  endDate: n,
@@ -1,6 +1,6 @@
1
1
  import { z as o } from "zod";
2
- import { checkoutConfigurationSchema as i, bookingEngineConfigurationSchema as a } from "./booking-engine-configuration-CnBdp3jk.js";
3
- import { timeOfDaySchema as e } from "./shop-opening-hours-B47MMaoD.js";
2
+ import { checkoutConfigurationSchema as i, bookingEngineConfigurationSchema as a } from "./booking-engine-configuration-BKlzwJJX.js";
3
+ import { timeOfDaySchema as e } from "./shop-opening-hours-DqNWstqT.js";
4
4
  const n = o.enum(["pickup", "delivery"]), t = o.object({
5
5
  fulfillmentModes: o.array(n).min(1).optional(),
6
6
  sameDayCutoff: e.optional()
@@ -0,0 +1,51 @@
1
+ import { z as e } from "zod";
2
+ const o = /^([01]\d|2[0-3]):[0-5]\d$/, i = /^\d{4}-\d{2}-\d{2}$/, r = e.string().regex(o, {
3
+ message: "Time value must use 24-hour HH:MM format"
4
+ }), a = e.string().regex(i, {
5
+ message: "Date must use YYYY-MM-DD format"
6
+ }), s = e.object({
7
+ start: r,
8
+ end: r
9
+ }).refine((t) => t.start < t.end, {
10
+ message: "End must be after start",
11
+ path: ["end"]
12
+ }), n = e.union([
13
+ e.literal(0),
14
+ e.literal(1),
15
+ e.literal(2),
16
+ e.literal(3),
17
+ e.literal(4),
18
+ e.literal(5),
19
+ e.literal(6)
20
+ ]), m = e.object({
21
+ day: n,
22
+ openingSlots: e.array(s)
23
+ }), l = e.object({
24
+ name: e.string().min(1),
25
+ startDate: a,
26
+ endDate: a,
27
+ openingHours: e.array(m).min(1)
28
+ }), p = e.object({
29
+ date: a,
30
+ openingSlots: e.array(s)
31
+ }), g = e.object({
32
+ minutesAfterClose: e.number().int().positive().max(240),
33
+ // Surcharge for returning in this tier, in currency minor units.
34
+ extraAmount: e.number().int().positive()
35
+ }), u = e.object({
36
+ timeZone: e.string().min(1),
37
+ openingHours: e.array(l).min(1),
38
+ openingHoursOverrides: e.array(p).optional(),
39
+ extraTimeSlots: e.array(g).optional()
40
+ });
41
+ export {
42
+ a as isoDateSchema,
43
+ u as shopConfigurationSchema,
44
+ g as shopExtraTimeSlotRuleSchema,
45
+ n as shopOpeningDayIndexSchema,
46
+ m as shopOpeningDaySchema,
47
+ p as shopOpeningHoursOverrideSchema,
48
+ l as shopOpeningHoursPeriodSchema,
49
+ s as shopOpeningSlotSchema,
50
+ r as timeOfDaySchema
51
+ };
@@ -1,18 +1,18 @@
1
1
  import { useMemo as l, useState as O, useRef as q, useCallback as d, useEffect as P } from "react";
2
- import { differenceInCalendarDays as ee } from "date-fns";
3
- import { fr as Fe, de as He, es as Re, it as Ue, enUS as Ae } from "date-fns/locale";
4
- import { useMediaQuery as Le } from "@rpcbase/client";
5
- import { parseTimeToMinutes as M, dateToBusinessDateString as We } from "../../lib/booking-period.js";
6
- import { getBookingPeriodTimeSlotsSync as qe } from "../../lib/booking-period-time-slots.js";
7
- const Ne = ({
2
+ import { differenceInCalendarDays as _ } from "date-fns";
3
+ import { fr as ke, de as Fe, es as xe, it as He, enUS as Re } from "date-fns/locale";
4
+ import { useMediaQuery as Ue } from "@rpcbase/client";
5
+ import { parseTimeToMinutes as M, dateToBusinessDateString as Ae } from "../../lib/booking-period.js";
6
+ import { getBookingPeriodTimeSlotsSync as Le } from "../../lib/booking-period-time-slots.js";
7
+ const We = ({
8
8
  locale: u,
9
9
  localeCode: n
10
10
  }) => {
11
11
  if (u)
12
12
  return u;
13
13
  const s = n?.toLowerCase() ?? "";
14
- return s.startsWith("fr") ? Fe : s.startsWith("de") ? He : s.startsWith("es") ? Re : s.startsWith("it") ? Ue : Ae;
15
- }, ze = (u) => {
14
+ return s.startsWith("fr") ? ke : s.startsWith("de") ? Fe : s.startsWith("es") ? xe : s.startsWith("it") ? He : Re;
15
+ }, qe = (u) => {
16
16
  if (!u?.length)
17
17
  return null;
18
18
  const n = u.map((t) => M(t.value)).filter((t) => typeof t == "number").sort((t, C) => t - C);
@@ -20,16 +20,16 @@ const Ne = ({
20
20
  return null;
21
21
  const s = n[1] - n[0];
22
22
  return !Number.isFinite(s) || s <= 0 ? null : s;
23
- }, $e = (u) => {
23
+ }, Ne = (u) => {
24
24
  if (typeof u != "string")
25
25
  return null;
26
26
  const n = u.match(/(\d{1,2}:\d{2})\s*-\s*(\d{1,2}:\d{2})/);
27
27
  return n ? M(n[2]) : null;
28
- }, ue = (u, n) => u.map((s) => {
28
+ }, ae = (u, n) => u.map((s) => {
29
29
  const t = M(s.value);
30
30
  if (t == null)
31
31
  return null;
32
- const C = $e(s.label) ?? t + n, o = typeof s.label == "string" ? s.label : s.value;
32
+ const C = Ne(s.label) ?? t + n, o = typeof s.label == "string" ? s.label : s.value;
33
33
  return {
34
34
  value: s.value,
35
35
  label: o,
@@ -38,65 +38,61 @@ const Ne = ({
38
38
  isExtra: !1,
39
39
  isDisabled: !!s.disabled
40
40
  };
41
- }).filter((s) => !!s), Ke = (u) => {
41
+ }).filter((s) => !!s), Je = (u) => {
42
42
  const {
43
43
  startDate: n,
44
44
  onStartDateChange: s,
45
45
  startTime: t,
46
46
  onStartTimeChange: C,
47
47
  endDate: o,
48
- onEndDateChange: x,
48
+ onEndDateChange: F,
49
49
  endTime: f,
50
50
  onEndTimeChange: c,
51
- onEndTimeCommit: F,
52
- errors: oe = {},
53
- labels: fe,
54
- labelClassName: ce,
55
- inputClassName: de,
51
+ onEndTimeCommit: x,
52
+ errors: le = {},
53
+ labels: ue,
54
+ labelClassName: oe,
55
+ inputClassName: fe,
56
56
  bookingPeriodConfig: a,
57
- currencyCode: me = "EUR",
58
- showEndExtraSlots: te = !0,
57
+ currencyCode: ce = "EUR",
59
58
  disableAutomaticTimeCorrection: w = !1,
60
- openDatePickerOnFocus: Se = !0,
59
+ openDatePickerOnFocus: de = !0,
61
60
  startTimeOptions: y = [],
62
- endTimeOptions: ne,
63
- locale: re,
61
+ endTimeOptions: ee,
62
+ locale: te,
64
63
  localeCode: N
65
- } = u, De = Le("(max-width: 767px)"), pe = l(() => Ne({ locale: re, localeCode: N }), [re, N]), ve = N ?? "en-US", b = l(() => a?.timing.slotIntervalMinutes ? a.timing.slotIntervalMinutes : ze(y) ?? 30, [a?.timing.slotIntervalMinutes, y]), [z, H] = O(!1), [$, Q] = O(!1), [V, R] = O(!1), [Z, j] = O(!1), [Te, G] = O(void 0), [Me, be] = O(!1), [se, ge] = O(!1), I = q(null), J = q(0), K = q(0), X = q(0), he = d(() => {
64
+ } = u, me = Ue("(max-width: 767px)"), Se = l(() => We({ locale: te, localeCode: N }), [te, N]), De = N ?? "en-US", b = l(() => a?.timing.slotIntervalMinutes ? a.timing.slotIntervalMinutes : qe(y) ?? 30, [a?.timing.slotIntervalMinutes, y]), [z, H] = O(!1), [$, Q] = O(!1), [V, R] = O(!1), [Z, j] = O(!1), [pe, G] = O(void 0), [ve, Te] = O(!1), [ne, Me] = O(!1), I = q(null), J = q(0), K = q(0), X = q(0), be = d(() => {
66
65
  G(void 0);
67
- }, []), U = l(() => !n || !o ? !1 : ee(o, n) === 0, [n, o]), Ee = l(() => M(t), [t]), D = l(
68
- () => !!n && ee(n, /* @__PURE__ */ new Date()) === 0,
66
+ }, []), U = l(() => !n || !o ? !1 : _(o, n) === 0, [n, o]), ge = l(() => M(t), [t]), D = l(
67
+ () => !!n && _(n, /* @__PURE__ */ new Date()) === 0,
69
68
  [n]
70
69
  ), B = l(
71
- () => !!o && ee(o, /* @__PURE__ */ new Date()) === 0,
70
+ () => !!o && _(o, /* @__PURE__ */ new Date()) === 0,
72
71
  [o]
73
- ), ie = l(() => {
72
+ ), re = l(() => {
74
73
  if (!D && !B) return null;
75
74
  const e = /* @__PURE__ */ new Date(), i = a?.timing.minBufferMinutes ?? 10;
76
75
  return e.setMinutes(e.getMinutes() + i), `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}`;
77
- }, [a?.timing.minBufferMinutes, B, D]), p = l(() => M(ie), [ie]), Y = l(() => D ? p : null, [p, D]), ae = l(() => {
76
+ }, [a?.timing.minBufferMinutes, B, D]), p = l(() => M(re), [re]), Y = l(() => D ? p : null, [p, D]), se = l(() => {
78
77
  if (!a)
79
78
  return;
80
79
  const i = (n instanceof Date ? n : n ? new Date(n) : void 0) ?? /* @__PURE__ */ new Date();
81
- return We(i, a.timeZone) ?? void 0;
82
- }, [a, n]), A = l(() => a ? qe(a, {
83
- date: ae
84
- }) : null, [a, ae]), S = l(() => a ? A?.startTimeSlots ?? [] : ue(y, b), [a, A?.startTimeSlots, b, y]), _ = l(() => a ? A?.endTimeSlots ?? [] : ue(ne ?? y, b), [a, A?.endTimeSlots, ne, b, y]), g = l(
85
- () => te ? _ : _.filter((e) => !e.isExtra),
86
- [_, te]
87
- ), m = d(
80
+ return Ae(i, a.timeZone) ?? void 0;
81
+ }, [a, n]), A = l(() => a ? Le(a, {
82
+ date: se
83
+ }) : null, [a, se]), S = l(() => a ? A?.startTimeSlots ?? [] : ae(y, b), [a, A?.startTimeSlots, b, y]), g = l(() => a ? A?.endTimeSlots ?? [] : ae(ee ?? y, b), [a, A?.endTimeSlots, ee, b, y]), m = d(
88
84
  (e, i) => {
89
- ge(i === "user"), C(e);
85
+ Me(i === "user"), C(e);
90
86
  },
91
87
  [C]
92
88
  ), L = l(() => S.length ? S.find((e) => !(e.isDisabled || Y != null && e.startMinutes < Y)) ?? null : null, [Y, S]);
93
89
  P(() => {
94
- w || se || L && t !== L.value && m(L.value, "auto");
95
- }, [w, L, se, t, m]), P(() => {
90
+ w || ne || L && t !== L.value && m(L.value, "auto");
91
+ }, [w, L, ne, t, m]), P(() => {
96
92
  if (w || !S.length)
97
93
  return;
98
94
  const e = t ? S.find((r) => r.value === t) : void 0, i = p ?? void 0, k = D ? i : null, h = (r) => {
99
- const E = typeof r == "number" ? r : null, W = S.find((le) => !(le.isDisabled || E != null && le.startMinutes < E));
95
+ const E = typeof r == "number" ? r : null, W = S.find((ie) => !(ie.isDisabled || E != null && ie.startMinutes < E));
100
96
  W && W.value !== t ? m(W.value, "auto") : !W && t && m("", "auto");
101
97
  };
102
98
  if (t && !e) {
@@ -145,97 +141,97 @@ const Ne = ({
145
141
  c,
146
142
  b,
147
143
  t
148
- ]), P(() => (be(!0), () => {
144
+ ]), P(() => (Te(!0), () => {
149
145
  I.current != null && clearTimeout(I.current);
150
146
  }), []), P(() => {
151
147
  $ && z && H(!1);
152
148
  }, [z, $]), P(() => {
153
149
  Z && V && R(!1);
154
150
  }, [V, Z]);
155
- const Oe = d((e) => {
151
+ const he = d((e) => {
156
152
  e && J.current && Date.now() < J.current || H(e);
157
- }, []), Ce = d((e) => {
153
+ }, []), Ee = d((e) => {
158
154
  e && K.current && Date.now() < K.current || R(e);
159
- }, []), we = d((e) => {
155
+ }, []), Oe = d((e) => {
160
156
  e && X.current && Date.now() < X.current || j(e);
161
- }, []), ye = d(
157
+ }, []), Ce = d(
162
158
  (e, { openTimePicker: i = !0 } = {}) => {
163
159
  if (!e) {
164
160
  H(!1);
165
161
  return;
166
162
  }
167
- s(e), J.current = Date.now() + 250, H(!1), o && e > o && x(e), i && Q(!0);
163
+ s(e), J.current = Date.now() + 250, H(!1), o && e > o && F(e), i && Q(!0);
168
164
  },
169
- [s, o, x]
170
- ), Ie = d(
165
+ [s, o, F]
166
+ ), we = d(
171
167
  (e) => {
172
168
  m(e, "user"), Q(!1), I.current != null && clearTimeout(I.current), e && n ? I.current = setTimeout(() => {
173
169
  R(!0);
174
170
  }, 100) : I.current = null;
175
171
  },
176
172
  [n, m]
177
- ), Pe = d(
173
+ ), ye = d(
178
174
  (e) => {
179
175
  e && e !== t && m(e, "user");
180
176
  },
181
177
  [t, m]
182
- ), Be = d(
178
+ ), Ie = d(
183
179
  (e, { openTimePicker: i = !0 } = {}) => {
184
- x(e), G(void 0), K.current = Date.now() + 250, R(!1), e && i && j(!0);
180
+ F(e), G(void 0), K.current = Date.now() + 250, R(!1), e && i && j(!0);
185
181
  },
186
- [x]
187
- ), ke = d((e) => {
182
+ [F]
183
+ ), Pe = d((e) => {
188
184
  c(e);
189
- }, [c]), xe = d(
185
+ }, [c]), Be = d(
190
186
  (e) => {
191
- c(e), X.current = Date.now() + 250, j(!1), F && (typeof window > "u" ? F() : requestAnimationFrame(() => {
192
- requestAnimationFrame(F);
187
+ c(e), X.current = Date.now() + 250, j(!1), x && (typeof window > "u" ? x() : requestAnimationFrame(() => {
188
+ requestAnimationFrame(x);
193
189
  }));
194
190
  },
195
- [c, F]
191
+ [c, x]
196
192
  );
197
193
  return {
198
194
  startDate: n,
199
195
  startTime: t,
200
196
  endDate: o,
201
197
  endTime: f,
202
- errors: oe,
203
- labels: fe,
204
- labelClassName: ce,
205
- inputClassName: de,
206
- currencyCode: me,
207
- localeCode: ve,
198
+ errors: le,
199
+ labels: ue,
200
+ labelClassName: oe,
201
+ inputClassName: fe,
202
+ currencyCode: ce,
203
+ localeCode: De,
208
204
  slotIntervalMinutes: b,
209
- dateLocale: pe,
210
- numberOfMonths: De ? 1 : 2,
211
- isHydrated: Me,
212
- openDatePickerOnFocus: Se,
205
+ dateLocale: Se,
206
+ numberOfMonths: me ? 1 : 2,
207
+ isHydrated: ve,
208
+ openDatePickerOnFocus: de,
213
209
  isStartDatePopoverOpen: z,
214
- setIsStartDatePopoverOpen: Oe,
210
+ setIsStartDatePopoverOpen: he,
215
211
  isStartTimeSelectOpen: $,
216
212
  setIsStartTimeSelectOpen: Q,
217
213
  isEndDatePopoverOpen: V,
218
- setIsEndDatePopoverOpen: Ce,
214
+ setIsEndDatePopoverOpen: Ee,
219
215
  isEndTimeSelectOpen: Z,
220
- setIsEndTimeSelectOpen: we,
221
- hoveredEndDate: Te,
216
+ setIsEndTimeSelectOpen: Oe,
217
+ hoveredEndDate: pe,
222
218
  setHoveredEndDate: G,
223
- resetHoveredEndDate: he,
219
+ resetHoveredEndDate: be,
224
220
  startTimeSlots: S,
225
221
  availableEndTimeSlots: g,
226
222
  isStartToday: D,
227
223
  isEndToday: B,
228
224
  earliestMinutesForToday: p,
229
- startMinutesValue: Ee,
225
+ startMinutesValue: ge,
230
226
  isSameDaySelection: U,
231
- updateStartTime: Pe,
232
- selectStartDate: ye,
233
- selectStartTime: Ie,
234
- selectEndDate: Be,
235
- updateEndTime: ke,
236
- selectEndTime: xe
227
+ updateStartTime: ye,
228
+ selectStartDate: Ce,
229
+ selectStartTime: we,
230
+ selectEndDate: Ie,
231
+ updateEndTime: Pe,
232
+ selectEndTime: Be
237
233
  };
238
234
  };
239
235
  export {
240
- Ke as useBookingPeriodController
236
+ Je as useBookingPeriodController
241
237
  };