@wix/bookings 1.0.1745 → 1.0.1746
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/_sdk-exports/context-service-context/runtime.d.ts +2 -0
- package/_sdk-exports/context-service-context/runtime.js +1 -1
- package/build/cjs/context-service-context.d.ts +2 -0
- package/build/cjs/context-service-context.js +100 -95
- package/build/cjs/context-service-context.js.map +1 -1
- package/build/es/context-service-context.d.mts +2 -0
- package/build/es/context-service-context.mjs +100 -95
- package/build/es/context-service-context.mjs.map +1 -1
- package/build/internal/cjs/context-service-context.d.ts +2 -0
- package/build/internal/es/context-service-context.d.mts +2 -0
- package/package.json +2 -2
|
@@ -3514,6 +3514,8 @@ interface RescheduledBooking {
|
|
|
3514
3514
|
revision: string | null;
|
|
3515
3515
|
serviceId: string | null;
|
|
3516
3516
|
kind: 'appointment' | 'class' | 'other';
|
|
3517
|
+
/** When the booking starts now (before the move), as an ISO instant. */
|
|
3518
|
+
startDate: string | null;
|
|
3517
3519
|
participants: number;
|
|
3518
3520
|
addOnIds: string[];
|
|
3519
3521
|
locationId: string | null;
|
|
@@ -20,13 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// context-service-context.ts
|
|
21
21
|
var context_service_context_exports = {};
|
|
22
22
|
__export(context_service_context_exports, {
|
|
23
|
-
SERVICE_CONTEXT_MISSING_PROVIDER_ERROR: () =>
|
|
24
|
-
ServiceContextProvider: () =>
|
|
25
|
-
default: () =>
|
|
26
|
-
injectAccessTokenGetter: () =>
|
|
27
|
-
resolveServiceTarget: () =>
|
|
28
|
-
serviceContext: () =>
|
|
29
|
-
useServiceContext: () =>
|
|
23
|
+
SERVICE_CONTEXT_MISSING_PROVIDER_ERROR: () => Zy,
|
|
24
|
+
ServiceContextProvider: () => Sb,
|
|
25
|
+
default: () => Sb,
|
|
26
|
+
injectAccessTokenGetter: () => Cb,
|
|
27
|
+
resolveServiceTarget: () => $y,
|
|
28
|
+
serviceContext: () => Xy,
|
|
29
|
+
useServiceContext: () => Qy
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(context_service_context_exports);
|
|
32
32
|
|
|
@@ -4936,7 +4936,7 @@ function vy({ isLoading: e2, hasError: t2, bookingsSettingsLoading: n2, reschedu
|
|
|
4936
4936
|
}, navigateToMultiServiceForm: () => {
|
|
4937
4937
|
}, resolveNextPageHref: () => null, isNavigating: false, openPreferences: () => Promise.resolve(), multiServiceAppointmentsEnabled: false, isMultiServiceAppointment: false, multiServiceAppointmentServices: [], multiServiceAppointmentOptionsAndVariants: {}, multiServiceAppointmentVariantsStatus: `ready`, bookingsSettingsLoading: n2, reschedule: a2, rescheduleBooking: async () => ({ outcome: `failed` }), goHomeAfterReschedule: () => {
|
|
4938
4938
|
}, canRescheduleToPick: false };
|
|
4939
|
-
return (0, import_jsx_runtime.jsx)(
|
|
4939
|
+
return (0, import_jsx_runtime.jsx)(Xy.Provider, { value: o2, children: i2 });
|
|
4940
4940
|
}
|
|
4941
4941
|
function yy({ rescheduleRequest: e2, children: t2 }) {
|
|
4942
4942
|
return (0, import_jsx_runtime.jsx)(py, { children: (0, import_jsx_runtime.jsx)(vy, { isLoading: true, hasError: false, bookingsSettingsLoading: true, rescheduleRequest: e2, children: t2 }) });
|
|
@@ -4980,11 +4980,16 @@ function Ay(e2) {
|
|
|
4980
4980
|
function jy({ totalParticipants: e2, participantsChoices: t2 }) {
|
|
4981
4981
|
return e2 || (t2?.serviceChoices ?? []).reduce((e3, t3) => e3 + (t3.numberOfParticipants ?? 1), 0) || 1;
|
|
4982
4982
|
}
|
|
4983
|
-
function My(e2
|
|
4983
|
+
function My(e2) {
|
|
4984
|
+
if (!e2) return null;
|
|
4985
|
+
let t2 = new Date(e2);
|
|
4986
|
+
return Number.isNaN(t2.getTime()) ? null : t2.toISOString();
|
|
4987
|
+
}
|
|
4988
|
+
function Ny(e2, t2) {
|
|
4984
4989
|
let { slot: n2, schedule: r2, tags: i2 } = e2.bookedEntity ?? {}, a2 = n2?.location;
|
|
4985
|
-
return { bookingId: t2, revision: e2.revision ?? null, serviceId: n2?.serviceId ?? r2?.serviceId ?? null, kind: Ay(i2), participants: jy(e2), addOnIds: (e2.bookedAddOns ?? []).flatMap((e3) => e3._id ?? []), locationId: a2?._id ?? null, customAddress: a2?.locationType === `CUSTOM` ? a2.formattedAddress ?? `` : null };
|
|
4990
|
+
return { bookingId: t2, revision: e2.revision ?? null, serviceId: n2?.serviceId ?? r2?.serviceId ?? null, kind: Ay(i2), startDate: My(e2.startDate), participants: jy(e2), addOnIds: (e2.bookedAddOns ?? []).flatMap((e3) => e3._id ?? []), locationId: a2?._id ?? null, customAddress: a2?.locationType === `CUSTOM` ? a2.formattedAddress ?? `` : null };
|
|
4986
4991
|
}
|
|
4987
|
-
async function
|
|
4992
|
+
async function Py({ bookingId: e2, token: t2 }) {
|
|
4988
4993
|
let n2;
|
|
4989
4994
|
try {
|
|
4990
4995
|
t2 ? n2 = (await ad(t2)).booking : e2 && (n2 = (await Io({ filter: { _id: e2 }, cursorPaging: { limit: 1 } }, {})).extendedBookings?.[0]?.booking);
|
|
@@ -4994,17 +4999,17 @@ async function Ny({ bookingId: e2, token: t2 }) {
|
|
|
4994
4999
|
}
|
|
4995
5000
|
let r2 = n2?._id;
|
|
4996
5001
|
if (!n2 || !r2) throw new Oy(`notFound`);
|
|
4997
|
-
let i2 =
|
|
5002
|
+
let i2 = Ny(n2, r2);
|
|
4998
5003
|
return t2 ? { ...i2, customAddress: null } : i2;
|
|
4999
5004
|
}
|
|
5000
|
-
function
|
|
5005
|
+
function Fy(e2) {
|
|
5001
5006
|
let t2 = e2?.bookedEntity?.slot;
|
|
5002
5007
|
return { staffName: t2?.resource?.name || null, locationName: t2?.location?.name || t2?.location?.formattedAddress || null };
|
|
5003
5008
|
}
|
|
5004
|
-
async function
|
|
5005
|
-
return
|
|
5009
|
+
async function Iy({ booking: e2, slot: t2, token: n2 }) {
|
|
5010
|
+
return Fy(n2 ? (await id(n2, t2, { revision: e2.revision || `1` })).booking : (await od(e2.bookingId, t2, { revision: e2.revision ?? `` })).booking);
|
|
5006
5011
|
}
|
|
5007
|
-
async function
|
|
5012
|
+
async function Ly(e2) {
|
|
5008
5013
|
try {
|
|
5009
5014
|
let t2 = (await Io({ filter: { _id: e2 }, cursorPaging: { limit: 1 } }, { withEcomTransactions: true })).extendedBookings?.[0]?.transactions?.chargedMembershipPaymentDetails?.expirationDate;
|
|
5010
5015
|
return t2 ? new Date(t2).toISOString() : null;
|
|
@@ -5012,7 +5017,7 @@ async function Iy(e2) {
|
|
|
5012
5017
|
return ma(e3, { feature: fa.reschedule, action: `fetch-plan-valid-until`, level: `warning` }), null;
|
|
5013
5018
|
}
|
|
5014
5019
|
}
|
|
5015
|
-
function
|
|
5020
|
+
function Ry() {
|
|
5016
5021
|
let e2 = pm();
|
|
5017
5022
|
return (0, import_react.useCallback)(() => {
|
|
5018
5023
|
if (!e2) return null;
|
|
@@ -5023,25 +5028,25 @@ function Ly() {
|
|
|
5023
5028
|
}
|
|
5024
5029
|
}, [e2]);
|
|
5025
5030
|
}
|
|
5026
|
-
var
|
|
5027
|
-
function
|
|
5031
|
+
var zy = Kd(`@wix/viewer-service-site-members`);
|
|
5032
|
+
function By() {
|
|
5028
5033
|
try {
|
|
5029
5034
|
return (0, import_services_manager_react.useGetService)();
|
|
5030
5035
|
} catch {
|
|
5031
5036
|
return null;
|
|
5032
5037
|
}
|
|
5033
5038
|
}
|
|
5034
|
-
function
|
|
5039
|
+
function Vy(e2) {
|
|
5035
5040
|
try {
|
|
5036
|
-
return e2 ? e2(
|
|
5041
|
+
return e2 ? e2(zy) : null;
|
|
5037
5042
|
} catch {
|
|
5038
5043
|
return null;
|
|
5039
5044
|
}
|
|
5040
5045
|
}
|
|
5041
|
-
function
|
|
5042
|
-
return By(
|
|
5046
|
+
function Hy() {
|
|
5047
|
+
return Vy(By());
|
|
5043
5048
|
}
|
|
5044
|
-
function
|
|
5049
|
+
function Uy(e2) {
|
|
5045
5050
|
if (!e2) return null;
|
|
5046
5051
|
try {
|
|
5047
5052
|
let t2 = new URL(e2);
|
|
@@ -5050,93 +5055,93 @@ function Hy(e2) {
|
|
|
5050
5055
|
return null;
|
|
5051
5056
|
}
|
|
5052
5057
|
}
|
|
5053
|
-
function
|
|
5058
|
+
function Wy(e2, { bookable: t2, staffChoiceRequired: n2, timezone: r2, validUntil: i2 }) {
|
|
5054
5059
|
if (!$g(e2) || !t2) return false;
|
|
5055
5060
|
let a2 = Rg(e2);
|
|
5056
5061
|
if (n2 && (!a2 || a2.anyResource)) return false;
|
|
5057
5062
|
let o2 = e2.slotStart ? hf(e2.slotStart, r2) : null;
|
|
5058
5063
|
return !i2 || !o2 || o2.getTime() <= Date.parse(i2);
|
|
5059
5064
|
}
|
|
5060
|
-
var
|
|
5061
|
-
async function
|
|
5065
|
+
var Gy = { status: `loading`, booking: null, validUntil: null };
|
|
5066
|
+
async function Ky(e2) {
|
|
5062
5067
|
return e2.getMemberDetails ? !!await e2.getMemberDetails().catch(() => null) : !!e2.isInitiallyLoggedIn;
|
|
5063
5068
|
}
|
|
5064
|
-
async function
|
|
5069
|
+
async function qy(e2, t2) {
|
|
5065
5070
|
let { bookingId: n2, token: r2 } = e2;
|
|
5066
|
-
if (!r2 && !(t2 && await
|
|
5071
|
+
if (!r2 && !(t2 && await Ky(t2)) && !(t2 && await t2.promptLogin({ mode: `login` }).then(() => true, () => false))) return { status: `loginRequired`, booking: null, validUntil: null };
|
|
5067
5072
|
try {
|
|
5068
|
-
let [t3, i2] = await Promise.all([
|
|
5073
|
+
let [t3, i2] = await Promise.all([Py(e2), n2 && !r2 ? Ly(n2) : null]);
|
|
5069
5074
|
return { status: `ready`, booking: t3, validUntil: i2 };
|
|
5070
5075
|
} catch (e3) {
|
|
5071
5076
|
return ma(e3, { feature: fa.reschedule, action: `fetch-booking` }), { status: e3 instanceof Oy ? e3.reason : `failed`, booking: null, validUntil: null };
|
|
5072
5077
|
}
|
|
5073
5078
|
}
|
|
5074
|
-
var
|
|
5075
|
-
function
|
|
5076
|
-
let r2 = `${e2.bookingId ?? ``}|${e2.token ?? ``}`, i2 =
|
|
5077
|
-
return i2.users += 1,
|
|
5078
|
-
--i2.users, i2.users === 0 &&
|
|
5079
|
+
var Jy = /* @__PURE__ */ new Map();
|
|
5080
|
+
function Yy(e2, t2, n2) {
|
|
5081
|
+
let r2 = `${e2.bookingId ?? ``}|${e2.token ?? ``}`, i2 = Jy.get(r2) ?? { load: qy(e2, t2), users: 0 };
|
|
5082
|
+
return i2.users += 1, Jy.set(r2, i2), i2.load.then(n2), () => {
|
|
5083
|
+
--i2.users, i2.users === 0 && Jy.get(r2) === i2 && Jy.delete(r2);
|
|
5079
5084
|
};
|
|
5080
5085
|
}
|
|
5081
|
-
var
|
|
5082
|
-
var
|
|
5083
|
-
function
|
|
5084
|
-
let t2 = (0, import_react.useContext)(
|
|
5085
|
-
if (!t2 && !e2) throw Error(
|
|
5086
|
+
var Xy = (0, import_react.createContext)(null);
|
|
5087
|
+
var Zy = `useServiceContext must be used within ServiceContextProvider`;
|
|
5088
|
+
function Qy(e2 = false) {
|
|
5089
|
+
let t2 = (0, import_react.useContext)(Xy);
|
|
5090
|
+
if (!t2 && !e2) throw Error(Zy);
|
|
5086
5091
|
return t2;
|
|
5087
5092
|
}
|
|
5088
|
-
function
|
|
5093
|
+
function $y(e2, t2, n2) {
|
|
5089
5094
|
if (e2) return { by: `slug`, value: e2 };
|
|
5090
5095
|
let r2 = t2?.services ?? [];
|
|
5091
5096
|
return wg(t2) ? { by: `multi`, serviceIds: r2.map(({ serviceId: e3 }) => e3) } : r2.length === 1 ? { by: `id`, value: r2[0].serviceId } : n2 ? { by: `id`, value: n2 } : { by: `none` };
|
|
5092
5097
|
}
|
|
5093
|
-
var
|
|
5094
|
-
var
|
|
5095
|
-
var
|
|
5096
|
-
let n2 =
|
|
5098
|
+
var eb = (e2) => void 0;
|
|
5099
|
+
var tb = (e2, t2) => Cg(t2.get(Y.blob))?.services.find((t3) => t3.serviceId === e2);
|
|
5100
|
+
var nb = (e2, t2) => {
|
|
5101
|
+
let n2 = tb(e2, t2) ?? Og(e2), r2 = eb(e2);
|
|
5097
5102
|
return r2 === void 0 ? n2 : zg(n2, r2);
|
|
5098
5103
|
};
|
|
5099
|
-
var
|
|
5100
|
-
let n2 =
|
|
5104
|
+
var rb = (e2, t2) => {
|
|
5105
|
+
let n2 = nb(e2, t2), r2 = t2.get(Y.resource), i2 = eb(e2) !== void 0 || !!tb(e2, t2);
|
|
5101
5106
|
return r2 && !i2 ? zg(n2, r2) : n2;
|
|
5102
5107
|
};
|
|
5103
|
-
function
|
|
5108
|
+
function ib(e2, t2) {
|
|
5104
5109
|
return !e2 || !t2 || !e2.services.every($g) ? null : Mg(t2, e2);
|
|
5105
5110
|
}
|
|
5106
|
-
var
|
|
5107
|
-
function
|
|
5111
|
+
var ab = [];
|
|
5112
|
+
function ob(e2) {
|
|
5108
5113
|
return { min: 1, max: e2?.bookingPolicy?.participantsPolicy?.maxParticipantsPerBooking || 1 };
|
|
5109
5114
|
}
|
|
5110
|
-
function
|
|
5115
|
+
function sb(e2, { previous: t2, others: n2 }, { min: r2, max: i2 }) {
|
|
5111
5116
|
let a2 = Math.max(0, Math.floor(e2)), o2 = Math.max(t2, i2 - n2), s2 = Math.min(a2, o2);
|
|
5112
5117
|
return s2 > 0 && n2 + s2 < r2 ? Math.min(r2 - n2, o2) : s2;
|
|
5113
5118
|
}
|
|
5114
|
-
function
|
|
5119
|
+
function cb({ serviceCtaState: e2, courseAvailability: t2, serviceBookability: n2 }) {
|
|
5115
5120
|
return `${e2}|${t2?.totalCapacity ?? `-`}|${t2?.remainingCapacity ?? `-`}|${t2 === null}|${n2.state}|${n2.isAvailableForBooking}`;
|
|
5116
5121
|
}
|
|
5117
|
-
var
|
|
5118
|
-
var
|
|
5119
|
-
var
|
|
5120
|
-
var
|
|
5121
|
-
var
|
|
5122
|
-
var
|
|
5123
|
-
var
|
|
5124
|
-
function
|
|
5125
|
-
return (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: (0, import_jsx_runtime.jsx)(yy, { rescheduleRequest: i2, children: o2 }), children: (0, import_jsx_runtime.jsx)(_y, { bookingsSettings: a2, children: (0, import_jsx_runtime.jsx)(ga, { fallback: (0, import_jsx_runtime.jsx)(by, { rescheduleRequest: i2, children: o2 }), feature: fa.service, children: (0, import_jsx_runtime.jsx)(
|
|
5126
|
-
}
|
|
5127
|
-
var
|
|
5128
|
-
var
|
|
5129
|
-
function
|
|
5122
|
+
var lb = (e2) => ({ service: e2, hasError: false });
|
|
5123
|
+
var ub = () => ({ service: null, hasError: true });
|
|
5124
|
+
var db = { service: null, hasError: false };
|
|
5125
|
+
var fb = (e2) => ({ ...db, isMultiServiceAppointment: true, multiServiceAppointmentServices: e2 });
|
|
5126
|
+
var pb = () => ({ ...ub(), isMultiServiceAppointment: true });
|
|
5127
|
+
var mb = [];
|
|
5128
|
+
var hb = {};
|
|
5129
|
+
function gb({ servicePromise: e2, refreshSignal: n2, injected: r2, rescheduleRequest: i2 = null, bookingsSettings: a2, children: o2 }) {
|
|
5130
|
+
return (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: (0, import_jsx_runtime.jsx)(yy, { rescheduleRequest: i2, children: o2 }), children: (0, import_jsx_runtime.jsx)(_y, { bookingsSettings: a2, children: (0, import_jsx_runtime.jsx)(ga, { fallback: (0, import_jsx_runtime.jsx)(by, { rescheduleRequest: i2, children: o2 }), feature: fa.service, children: (0, import_jsx_runtime.jsx)(bb, { servicePromise: e2, refreshSignal: n2, injected: r2, rescheduleRequest: i2, children: o2 }) }) }) });
|
|
5131
|
+
}
|
|
5132
|
+
var _b = (e2) => e2 ?? void 0;
|
|
5133
|
+
var vb = () => void 0;
|
|
5134
|
+
function yb(e2, t2) {
|
|
5130
5135
|
ma(e2, { feature: fa.service, action: `fetch-service-variants`, level: `warning`, contexts: { service: { serviceId: t2 } } });
|
|
5131
5136
|
}
|
|
5132
|
-
function
|
|
5133
|
-
let d2 = n2 ? null : e2 ? ka(e2) : null, f2 = n2?.service ?? d2?.service ?? null, m2 = d2?.hasError ?? false, h2 = d2?.isMultiServiceAppointment ?? false, g2 = d2?.multiServiceAppointmentServices ??
|
|
5137
|
+
function bb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, rescheduleRequest: a2 = null, children: u2 }) {
|
|
5138
|
+
let d2 = n2 ? null : e2 ? ka(e2) : null, f2 = n2?.service ?? d2?.service ?? null, m2 = d2?.hasError ?? false, h2 = d2?.isMultiServiceAppointment ?? false, g2 = d2?.multiServiceAppointmentServices ?? mb, _2 = p_(), { navigate: v2, navigateToHref: ee2, resolvePath: y2, toHref: b2, getBookingFormPath: te2 } = ry(), ne2 = Ry(), x2 = lf($d.SERVICE), { getParsedUrl: S2, pushUrl: C2, searchParams: re2 } = Oa(), w2 = (0, import_react.useRef)(S2);
|
|
5134
5139
|
w2.current = S2;
|
|
5135
5140
|
let ie2 = (0, import_react.useRef)(C2);
|
|
5136
5141
|
ie2.current = C2;
|
|
5137
5142
|
let ae2 = v_(), oe2 = (0, import_react.useRef)(ae2);
|
|
5138
5143
|
oe2.current = ae2;
|
|
5139
|
-
let [T2, E2] = (0, import_react.useState)(
|
|
5144
|
+
let [T2, E2] = (0, import_react.useState)(Gy), se2 = Hy(), D2 = (e3, t3) => a2 ? Og(e3) : nb(e3, t3), ce2 = (0, import_react.useRef)(D2);
|
|
5140
5145
|
ce2.current = D2;
|
|
5141
5146
|
let [le2, ue2] = (0, import_react.useState)(() => D2(f2?._id ?? ``, S2().searchParams)), O2 = (0, import_react.useRef)(le2), de2 = (0, import_react.useRef)(void 0), k2 = (0, import_react.useRef)(true), fe2 = (0, import_react.useRef)(false), pe2 = (0, import_react.useRef)(null), [me2, he2] = (0, import_react.useState)(null), ge2 = (0, import_react.useRef)(me2), [_e2, ve2] = (0, import_react.useState)(0), A2 = f2?._id ?? null, ye2 = (0, import_react.useMemo)(() => {
|
|
5142
5147
|
if (!a2) return null;
|
|
@@ -5148,25 +5153,25 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5148
5153
|
if (!f2) return null;
|
|
5149
5154
|
let e3 = y2(`servicePage`, { slug: f2.mainSlug?.name ?? null, serviceId: f2._id ?? null });
|
|
5150
5155
|
return e3 ? { href: b2(e3), target: `_self` } : null;
|
|
5151
|
-
}, [f2, y2, b2]), [Ce2, we2] = (0, import_react.useState)(
|
|
5156
|
+
}, [f2, y2, b2]), [Ce2, we2] = (0, import_react.useState)(ab), Te2 = n2 ? n2.masterEvents : Ce2, Ee2 = hy(), De2 = dy(), Oe2 = De2.isLoading, ke2 = !De2.isLoading && De2.multiServiceAppointmentsEnabled;
|
|
5152
5157
|
(0, import_react.useEffect)(() => {
|
|
5153
5158
|
if (!a2 || Oe2) return;
|
|
5154
|
-
let e3 = false, t3 =
|
|
5159
|
+
let e3 = false, t3 = Yy(a2, se2, (t4) => {
|
|
5155
5160
|
e3 || E2(t4);
|
|
5156
5161
|
});
|
|
5157
5162
|
return () => {
|
|
5158
5163
|
e3 = true, t3();
|
|
5159
5164
|
};
|
|
5160
5165
|
}, [a2, Oe2, se2]);
|
|
5161
|
-
let Ae2 = !n2 && !!f2 && Od(f2), je2 = Ae2 && A2 ? C_(A2, t2) : null, Me2 = (typeof window > `u` && je2 && A2 && ae2.scope && !Oe2 ? ka(Ma(I_({ key: je2, warmupData: ae2, fetchData: () => Pf(A2).catch((e3) => (
|
|
5166
|
+
let Ae2 = !n2 && !!f2 && Od(f2), je2 = Ae2 && A2 ? C_(A2, t2) : null, Me2 = (typeof window > `u` && je2 && A2 && ae2.scope && !Oe2 ? ka(Ma(I_({ key: je2, warmupData: ae2, fetchData: () => Pf(A2).catch((e3) => (yb(e3, A2), null)) }), _b, vb)) : void 0) ?? (je2 ? A_(je2) : void 0), [Ne2, Pe2] = (0, import_react.useState)(() => Me2 ?? null), [Fe2, Ie2] = (0, import_react.useState)(() => Me2 ? je2 : null), Le2 = je2 !== null && Fe2 !== je2, Re2 = n2 ? n2.serviceOptionsAndVariants : Ae2 ? Ne2 : null;
|
|
5162
5167
|
(0, import_react.useEffect)(() => {
|
|
5163
5168
|
if (n2) return;
|
|
5164
5169
|
let e3 = be2 && !Td(xe2) ? be2 : null;
|
|
5165
|
-
if ((!e3 || Oe2) && we2((e4) => e4.length === 0 ? e4 :
|
|
5170
|
+
if ((!e3 || Oe2) && we2((e4) => e4.length === 0 ? e4 : ab), Oe2) return;
|
|
5166
5171
|
let i2 = Ae2 ? A2 : null;
|
|
5167
5172
|
if (!e3 && !i2) return;
|
|
5168
|
-
let a3 = false, o2 = e3 ? Mf([e3], Ee2).catch(() =>
|
|
5169
|
-
|
|
5173
|
+
let a3 = false, o2 = e3 ? Mf([e3], Ee2).catch(() => ab) : Promise.resolve(ab), s2 = i2 ? I_({ key: C_(i2, t2), warmupData: oe2.current, fetchData: () => Pf(i2) }).catch((e4) => {
|
|
5174
|
+
yb(e4, i2);
|
|
5170
5175
|
}) : Promise.resolve(void 0);
|
|
5171
5176
|
return Promise.all([o2, s2]).then(([e4, t3]) => {
|
|
5172
5177
|
a3 || (0, import_react.startTransition)(() => {
|
|
@@ -5179,7 +5184,7 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5179
5184
|
let ze2 = a2 ? null : re2.get(Y.blob), Be2 = (0, import_react.useMemo)(() => JSON.stringify([...new Set((Cg(ze2)?.services ?? []).filter((e3) => Hg(e3).length > 0).map(({ serviceId: e3 }) => e3))].sort()), [ze2]), Ve2 = (0, import_react.useMemo)(() => {
|
|
5180
5185
|
let e3 = new Set(JSON.parse(Be2));
|
|
5181
5186
|
return [...new Set(g2.filter(Od).flatMap(({ _id: t3 }) => t3 && e3.has(t3) ? [t3] : []))];
|
|
5182
|
-
}, [g2, Be2]), He2 = (0, import_react.useMemo)(() => ({ serviceIds: Ve2, refreshSignal: t2 }), [Ve2, t2]), [Ue2, We2] = (0, import_react.useState)(null), Ge2 = Ue2?.request === He2 ? Ue2 : null, Ke2 = Ge2?.data ??
|
|
5187
|
+
}, [g2, Be2]), He2 = (0, import_react.useMemo)(() => ({ serviceIds: Ve2, refreshSignal: t2 }), [Ve2, t2]), [Ue2, We2] = (0, import_react.useState)(null), Ge2 = Ue2?.request === He2 ? Ue2 : null, Ke2 = Ge2?.data ?? hb, j2 = Ve2.length === 0 ? `ready` : Oe2 || !Ge2 ? `loading` : Ge2.data && Ve2.every((e3) => Ge2.data?.[e3]) ? `ready` : `error`;
|
|
5183
5188
|
(0, import_react.useEffect)(() => {
|
|
5184
5189
|
let { serviceIds: e3, refreshSignal: t3 } = He2;
|
|
5185
5190
|
if (Oe2 || e3.length === 0) return;
|
|
@@ -5190,7 +5195,7 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5190
5195
|
n3 = true;
|
|
5191
5196
|
};
|
|
5192
5197
|
}, [Oe2, He2]);
|
|
5193
|
-
let M2 = rm({ service: f2, masterEvents: Te2, locale: _2, timeZone: Ee2, now: y_() }), N2 =
|
|
5198
|
+
let M2 = rm({ service: f2, masterEvents: Te2, locale: _2, timeZone: Ee2, now: y_() }), N2 = cb(M2), qe2 = (0, import_react.useMemo)(() => M2, [f2, Te2, _2, Ee2, N2]), Je2 = (0, import_react.useRef)(null);
|
|
5194
5199
|
(0, import_react.useEffect)(() => {
|
|
5195
5200
|
if (Je2.current !== null) {
|
|
5196
5201
|
let e3 = ce2.current(f2?._id ?? ``, w2.current().searchParams);
|
|
@@ -5212,20 +5217,20 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5212
5217
|
O2.current = t3, ue2(t3);
|
|
5213
5218
|
}, []), $e2 = (0, import_react.useCallback)((e3) => {
|
|
5214
5219
|
Qe2(e3);
|
|
5215
|
-
let t3 = w2.current(), n3 = e3(
|
|
5220
|
+
let t3 = w2.current(), n3 = e3(nb(A2 ?? ``, t3.searchParams)), r2 = Eg(`${t3.pathname}${t3.search}${t3.hash}`, { currentUrl: t3, entries: [Lg(n3, Xe2.current)], policy: `inPlace` }), i2 = new URL(r2, t3);
|
|
5216
5221
|
Ye2.current = i2.searchParams.get(Y.blob), ie2.current(i2, { disableScrollToTop: true, skipHistory: true });
|
|
5217
5222
|
}, [Qe2, A2]), et2 = Cg(ze2)?.wantsPromoCode === true, tt2 = (0, import_react.useCallback)((e3) => {
|
|
5218
5223
|
let t3 = w2.current(), n3 = Cg(t3.searchParams.get(Y.blob));
|
|
5219
5224
|
if (!n3) return;
|
|
5220
5225
|
let r2 = new URL(Mg(`${t3.pathname}${t3.search}${t3.hash}`, Fg(n3, e3)), t3);
|
|
5221
5226
|
Ye2.current = r2.searchParams.get(Y.blob), ie2.current(r2, { disableScrollToTop: true, skipHistory: true });
|
|
5222
|
-
}, []), nt2 = Uf(Re2), P2 = (0, import_react.useCallback)((e3, t3) => nt2 ? Ug(e3, t3 ? [t3] : []) : e3, [nt2]), F2 = (0, import_react.useCallback)((e3) => Qe2((t3) => P2(zg(t3, e3), e3)), [Qe2, P2]), rt2 = (0, import_react.useCallback)(() => Qe2((e3) => P2(Vg(e3), null)), [Qe2, P2]), I2 = (0, import_react.useCallback)((e3) => Qe2((t3) => P2(Bg(t3, e3), null)), [Qe2, P2]), it2 = (0, import_react.useCallback)((e3) => $e2((t3) => Ug(t3, e3)), [$e2]), at2 = (0, import_react.useMemo)(() =>
|
|
5227
|
+
}, []), nt2 = Uf(Re2), P2 = (0, import_react.useCallback)((e3, t3) => nt2 ? Ug(e3, t3 ? [t3] : []) : e3, [nt2]), F2 = (0, import_react.useCallback)((e3) => Qe2((t3) => P2(zg(t3, e3), e3)), [Qe2, P2]), rt2 = (0, import_react.useCallback)(() => Qe2((e3) => P2(Vg(e3), null)), [Qe2, P2]), I2 = (0, import_react.useCallback)((e3) => Qe2((t3) => P2(Bg(t3, e3), null)), [Qe2, P2]), it2 = (0, import_react.useCallback)((e3) => $e2((t3) => Ug(t3, e3)), [$e2]), at2 = (0, import_react.useMemo)(() => ob(f2), [f2]), ot2 = (0, import_react.useMemo)(() => Wf(Re2, { locale: _2, staffMembers: f2 ? Gf(f2) : [], businessLocations: Cd(f2) }), [Re2, _2, f2]), st2 = (0, import_react.useMemo)(() => new Set(Wf(Re2, { locale: _2 })?.choices.flatMap((e3) => e3.choiceId ? [e3.choiceId] : []) ?? []), [Re2, _2]), ct2 = (0, import_react.useCallback)((e3) => {
|
|
5223
5228
|
let t3 = Object.entries(e3).filter(([e4, t4]) => st2.has(e4) && Number.isFinite(t4));
|
|
5224
5229
|
if (!t3.length) return;
|
|
5225
5230
|
let n3 = (e4) => {
|
|
5226
5231
|
let n4 = qg(e4, st2), r2 = ([e5, t4]) => t4 <= Wg(n4, e5), i2 = [...t3.filter(r2), ...t3.filter((e5) => !r2(e5))];
|
|
5227
5232
|
for (let [e5, t4] of i2) {
|
|
5228
|
-
let r3 = Wg(n4, e5), i3 =
|
|
5233
|
+
let r3 = Wg(n4, e5), i3 = sb(t4, { previous: r3, others: Gg(n4) - r3 }, at2);
|
|
5229
5234
|
i3 !== r3 && (n4 = Kg(n4, e5, i3));
|
|
5230
5235
|
}
|
|
5231
5236
|
return n4;
|
|
@@ -5243,7 +5248,7 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5243
5248
|
return n3 ? (ge2.current = n3, he2(n3), true) : false;
|
|
5244
5249
|
}, []), mt2 = (0, import_react.useCallback)((e3, t3) => pt2((n3) => n_(n3, e3, t3, Wd())), [pt2]), ht2 = (0, import_react.useCallback)(() => {
|
|
5245
5250
|
pt2(i_);
|
|
5246
|
-
}, [pt2]), gt2 = qe2.serviceCtaState, _t2 = (0, import_react.useMemo)(() => h2 ?
|
|
5251
|
+
}, [pt2]), gt2 = qe2.serviceCtaState, _t2 = (0, import_react.useMemo)(() => h2 ? ib(me2 ?? Cg(ze2), te2()) : null, [h2, me2, ze2, te2]), vt2 = (0, import_react.useCallback)((e3) => {
|
|
5247
5252
|
if (h2) return _t2 ? b2(_t2) : null;
|
|
5248
5253
|
let t3 = Yv({ actionState: gt2, serviceType: f2?.type ?? null, config: e3 ?? Jv });
|
|
5249
5254
|
if (Xv(t3, f2?.type ?? null, le2)) return null;
|
|
@@ -5261,9 +5266,9 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5261
5266
|
}, (e4) => {
|
|
5262
5267
|
ma(e4, { feature: fa.serviceCta, action: `navigateToNextPage` }), Ct2();
|
|
5263
5268
|
});
|
|
5264
|
-
}, [v2, Ct2, b2]), Tt2 = (0, import_react.useCallback)(() => yt2.open(mm(s_({ service: f2, pricingOption: ot2 ?? void 0, selection:
|
|
5269
|
+
}, [v2, Ct2, b2]), Tt2 = (0, import_react.useCallback)(() => yt2.open(mm(s_({ service: f2, pricingOption: ot2 ?? void 0, selection: rb(A2 ?? ``, w2.current().searchParams), multiServiceAppointmentsEnabled: ke2 }))), [yt2, f2, ot2, A2, ke2]), Et2 = (0, import_react.useCallback)((e3) => {
|
|
5265
5270
|
if (St2.current) return;
|
|
5266
|
-
let t3 = ge2.current ?? Cg(w2.current().searchParams.get(Y.blob)), n3 =
|
|
5271
|
+
let t3 = ge2.current ?? Cg(w2.current().searchParams.get(Y.blob)), n3 = ib(t3, te2());
|
|
5267
5272
|
if (n3) {
|
|
5268
5273
|
for (let n4 of t3?.services ?? []) e3(gf({ serviceId: n4.serviceId, serviceType: n4.serviceType ?? g2.find(({ _id: e4 }) => e4 === n4.serviceId)?.type ?? void 0, start: n4.slotStart, end: n4.slotEnd, timeZone: t3?.timezone ?? void 0, isEligibleForFlowCompletion: true }));
|
|
5269
5274
|
wt2(n3);
|
|
@@ -5289,42 +5294,42 @@ function yb({ servicePromise: e2, refreshSignal: t2 = 0, injected: n2, reschedul
|
|
|
5289
5294
|
kt2.current = Ot2;
|
|
5290
5295
|
let At2 = (0, import_react.useCallback)(async () => {
|
|
5291
5296
|
let e3 = ye2?.status === `ready` ? ye2.booking : null;
|
|
5292
|
-
if (!ye2 || !a2 || !e3 || !
|
|
5297
|
+
if (!ye2 || !a2 || !e3 || !Wy(O2.current, kt2.current())) return { outcome: `failed` };
|
|
5293
5298
|
x2(pf({ component: of.RESCHEDULE_DIALOG, element: sf.CONFIRM_BUTTON })), x2(Qd({ action: af, pageName: sf.CONFIRM_BUTTON, referralInfo: w2.current().searchParams.get(Y.referral) ?? void 0 }));
|
|
5294
5299
|
let t3 = Lg(O2.current, Xe2.current), n3;
|
|
5295
5300
|
try {
|
|
5296
|
-
n3 = await
|
|
5301
|
+
n3 = await Iy({ booking: e3, slot: Dy(t3, de2.current ?? null, e3, pe2.current), token: a2.token });
|
|
5297
5302
|
} catch (e4) {
|
|
5298
5303
|
return ma(e4, { feature: fa.reschedule, action: `reschedule-booking` }), { outcome: `failed` };
|
|
5299
5304
|
}
|
|
5300
5305
|
x2(ff({ bookingId: e3.bookingId }));
|
|
5301
5306
|
let r2 = { outcome: `succeeded`, ...n3 };
|
|
5302
5307
|
if (a2.fromManageBookingPage) return r2;
|
|
5303
|
-
let i2 =
|
|
5308
|
+
let i2 = Uy(a2.redirectUrl), o2 = i2 ? null : ne2();
|
|
5304
5309
|
if (!i2 && !o2) return r2;
|
|
5305
5310
|
try {
|
|
5306
5311
|
return i2 ? await ee2({ href: i2 }) : o2 && await v2(o2), { outcome: `navigated` };
|
|
5307
5312
|
} catch (e4) {
|
|
5308
5313
|
return ma(e4, { feature: fa.reschedule, action: `return-after-reschedule` }), r2;
|
|
5309
5314
|
}
|
|
5310
|
-
}, [ye2, a2, ne2, v2, ee2, x2]), jt2 =
|
|
5315
|
+
}, [ye2, a2, ne2, v2, ee2, x2]), jt2 = Wy(le2, Ot2()), Mt2 = (0, import_react.useCallback)(() => {
|
|
5311
5316
|
x2(Qd({ component: sf.GO_TO_HOMEPAGE_BUTTON, action: af, pageName: cf })), v2(`/`).catch((e3) => ma(e3, { feature: fa.reschedule, action: `go-home` }));
|
|
5312
5317
|
}, [v2, x2]), { serviceBookability: Nt2, policyDescription: Pt2, coverImage: Ft2 } = qe2, It2 = (0, import_react.useCallback)(() => Nt2.isAvailableForBooking, [Nt2]), Lt2 = (0, import_react.useCallback)(() => !!Pt2, [Pt2]), Rt2 = (0, import_react.useCallback)(() => !!Ft2, [Ft2]), zt2 = (0, import_react.useCallback)(() => Dp(f2), [f2]), Bt2 = (0, import_react.useCallback)(() => !!f2 && om(f2), [f2]), Vt2 = (0, import_react.useMemo)(() => ({ ...qe2, service: f2, servicePageLink: Se2, serviceOptionsAndVariants: Re2, pricingOption: ot2, isLoadingServiceOptionsAndVariants: Le2, isAvailableForBooking: It2, hasPolicyDescription: Lt2, hasCoverImage: Rt2, hasGalleryImages: zt2, isVariantDuration: Bt2, isLoading: false, hasError: m2, locale: _2, selectStaffMember: F2, clearSelection: I2, clearStaffMember: rt2, selection: le2, selectionTimezone: de2.current ?? Ee2, setVariant: it2, setVariantCounts: ct2, maxParticipantsPerBooking: at2.max, toggleAddOn: lt2, setAddOnQuantity: ut2, setSlot: dt2, clearSlot: ft2, setMultiServiceSlot: mt2, clearMultiServiceSlot: ht2, draftRevision: _e2, wantsPromoCode: et2, setWantsPromoCode: tt2, withSelectionParam: Ze2, navigateToNextPage: Dt2, navigateToMultiServiceForm: Et2, resolveNextPageHref: vt2, isNavigating: bt2, openPreferences: Tt2, multiServiceAppointmentsEnabled: ke2, isMultiServiceAppointment: h2, multiServiceAppointmentServices: g2, multiServiceAppointmentOptionsAndVariants: Ke2, multiServiceAppointmentVariantsStatus: j2, bookingsSettingsLoading: Oe2, reschedule: ye2, rescheduleBooking: At2, goHomeAfterReschedule: Mt2, canRescheduleToPick: jt2 }), [qe2, f2, Se2, Re2, ot2, Le2, It2, Lt2, Rt2, zt2, Bt2, m2, _2, F2, I2, rt2, le2, Ee2, it2, ct2, at2.max, lt2, ut2, dt2, ft2, mt2, ht2, _e2, et2, tt2, Ze2, Dt2, Et2, vt2, bt2, Tt2, ke2, h2, g2, Ke2, j2, Oe2, ye2, At2, Mt2, jt2]);
|
|
5313
|
-
return (0, import_jsx_runtime.jsx)(
|
|
5318
|
+
return (0, import_jsx_runtime.jsx)(Xy.Provider, { value: Vt2, children: u2 });
|
|
5314
5319
|
}
|
|
5315
|
-
function
|
|
5320
|
+
function xb({ pathname: e2, initialServiceId: t2, refreshSignal: n2, editingSurface: r2, children: i2 }) {
|
|
5316
5321
|
uf($d.SERVICE);
|
|
5317
5322
|
let a2 = v_(), { getParsedUrl: o2 } = Oa(), [s2] = (0, import_react.useState)(() => r2 ? null : Ey(o2().searchParams)), [c2] = (0, import_react.useState)(() => {
|
|
5318
|
-
let r3 =
|
|
5319
|
-
return r3.by === `none` ? Aa(
|
|
5323
|
+
let r3 = $y(Md(e2), s2 ? null : ay(o2().searchParams), t2);
|
|
5324
|
+
return r3.by === `none` ? Aa(db) : r3.by === `multi` ? Ma(I_({ key: S_(r3.serviceIds), refresh: n2 !== 0, warmupData: a2, fetchData: () => ha(`service-context-load-multi-service`, { feature: fa.service }, Ld(r3.serviceIds)) }), fb, pb) : Ma(I_({ key: x_(r3.by, r3.value), refresh: n2 !== 0, warmupData: a2, fetchData: () => ha(`service-context-load`, { feature: fa.service }, r3.by === `slug` ? Fd(r3.value) : Id(r3.value)) }), lb, ub);
|
|
5320
5325
|
});
|
|
5321
|
-
return (0, import_jsx_runtime.jsx)(
|
|
5326
|
+
return (0, import_jsx_runtime.jsx)(gb, { servicePromise: c2, refreshSignal: n2, rescheduleRequest: s2, children: i2 });
|
|
5322
5327
|
}
|
|
5323
|
-
function
|
|
5324
|
-
let { pathname: a2 } = Oa(), o2 = t2?.serviceId?.$eq, c2 = e2?.service ?? null, l2 = (0, import_react.useMemo)(() => c2 ? { service: c2, masterEvents: e2?.masterEvents ??
|
|
5325
|
-
return l2 ? (0, import_jsx_runtime.jsx)(
|
|
5328
|
+
function Sb({ serviceData: e2, servicePicker: t2, refreshSignal: n2 = 0, editingSurface: r2 = false, children: i2 }) {
|
|
5329
|
+
let { pathname: a2 } = Oa(), o2 = t2?.serviceId?.$eq, c2 = e2?.service ?? null, l2 = (0, import_react.useMemo)(() => c2 ? { service: c2, masterEvents: e2?.masterEvents ?? ab, serviceOptionsAndVariants: e2?.serviceOptionsAndVariants ?? null, bookingsSettings: e2?.bookingsSettings } : null, [c2, e2?.masterEvents, e2?.serviceOptionsAndVariants, e2?.bookingsSettings]);
|
|
5330
|
+
return l2 ? (0, import_jsx_runtime.jsx)(gb, { injected: l2, bookingsSettings: l2.bookingsSettings, children: i2 }, `injected:${n2}`) : e2 ? (0, import_jsx_runtime.jsx)(gb, { bookingsSettings: e2.bookingsSettings, children: i2 }) : (0, import_jsx_runtime.jsx)(xb, { pathname: a2, initialServiceId: o2, refreshSignal: n2, editingSurface: r2, children: i2 }, `fetch:${a2}:${o2 ?? ``}:${n2}:${r2}`);
|
|
5326
5331
|
}
|
|
5327
|
-
var
|
|
5332
|
+
var Cb = ea;
|
|
5328
5333
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5329
5334
|
0 && (module.exports = {
|
|
5330
5335
|
SERVICE_CONTEXT_MISSING_PROVIDER_ERROR,
|