@wix/bookings 1.0.1773 → 1.0.1775

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.
@@ -20,12 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // context-services.ts
21
21
  var context_services_exports = {};
22
22
  __export(context_services_exports, {
23
- SERVICES_CONTEXT_MISSING_PROVIDER_ERROR: () => zc,
24
- ServicesContextProvider: () => Gc,
25
- default: () => Gc,
26
- injectAccessTokenGetter: () => Kc,
27
- servicesContext: () => Rc,
28
- useServicesContext: () => Bc
23
+ SERVICES_CONTEXT_MISSING_PROVIDER_ERROR: () => Lc,
24
+ ServicesContextProvider: () => Uc,
25
+ default: () => Uc,
26
+ injectAccessTokenGetter: () => Wc,
27
+ servicesContext: () => Ic,
28
+ useServicesContext: () => Rc
29
29
  });
30
30
  module.exports = __toCommonJS(context_services_exports);
31
31
 
@@ -3235,7 +3235,7 @@ function Cc(e5) {
3235
3235
  function wc({ categoryId: e5, locationId: t2, serviceItems: n2, isLoading: r2, hasError: i2, children: a2 }) {
3236
3236
  let o2 = { serviceItems: n2, bookingsSettings: null, hasMore: false, isLoading: r2, hasError: i2, categoryId: e5, locationId: t2, loadMore: async () => {
3237
3237
  } };
3238
- return (0, import_jsx_runtime.jsx)(Rc.Provider, { value: o2, children: a2 });
3238
+ return (0, import_jsx_runtime.jsx)(Ic.Provider, { value: o2, children: a2 });
3239
3239
  }
3240
3240
  function Tc({ categoryId: e5, locationId: t2, children: n2 }) {
3241
3241
  return (0, import_jsx_runtime.jsx)(wc, { categoryId: e5, locationId: t2, serviceItems: [], isLoading: true, hasError: false, children: n2 });
@@ -3250,37 +3250,35 @@ function Dc(e5) {
3250
3250
  function $(e5) {
3251
3251
  return e5 ? e5.split(`,`) : null;
3252
3252
  }
3253
- var Oc = 20;
3254
- var kc = 100;
3255
- var Ac = [];
3256
- var jc = [];
3257
- var Mc = {};
3258
- var Nc = {};
3259
- function Pc(e5, t2) {
3253
+ var Oc = [];
3254
+ var kc = [];
3255
+ var Ac = {};
3256
+ var jc = {};
3257
+ function Mc(e5, t2) {
3260
3258
  return Object.keys(t2).length === 0 ? e5 : { ...e5, ...t2 };
3261
3259
  }
3262
- function Fc(e5, t2, n2, r2, i2) {
3260
+ function Nc(e5, t2, n2, r2, i2) {
3263
3261
  let a2 = [...new Set(e5.filter((e6) => !Yo(e6.type)).map((e6) => e6.schedule?._id).filter((e6) => !!e6))], o2 = e5.filter(Xo).map((e6) => e6._id).filter((e6) => !!e6);
3264
- return Promise.all([a2.length === 0 ? Mc : yc(a2, t2).then(bc).catch(() => Mc), o2.length === 0 ? Nc : Ns({ key: xs(r2, o2, n2), warmupData: i2, fetchData: () => Fs(o2) }).catch((e6) => (H(e6, { feature: V.services, action: `fetch-service-variants`, level: `warning` }), null))]);
3262
+ return Promise.all([a2.length === 0 ? Ac : yc(a2, t2).then(bc).catch(() => Ac), o2.length === 0 ? jc : Ns({ key: xs(r2, o2, n2), warmupData: i2, fetchData: () => Fs(o2) }).catch((e6) => (H(e6, { feature: V.services, action: `fetch-service-variants`, level: `warning` }), null))]);
3265
3263
  }
3266
- var Ic = { services: [], hasMore: false, totalPages: 1, hasError: true };
3267
- function Lc(e5) {
3264
+ var Pc = { services: [], hasMore: false, totalPages: 1, hasError: true };
3265
+ function Fc(e5) {
3268
3266
  let t2 = Math.floor(Number(e5));
3269
3267
  return !e5 || !Number.isSafeInteger(t2) || t2 < 1 ? 1 : t2;
3270
3268
  }
3271
- var Rc = (0, import_react.createContext)(null);
3272
- var zc = `useServicesContext must be used within ServicesContextProvider`;
3273
- function Bc() {
3274
- let e5 = (0, import_react.useContext)(Rc);
3275
- if (!e5) throw Error(zc);
3269
+ var Ic = (0, import_react.createContext)(null);
3270
+ var Lc = `useServicesContext must be used within ServicesContextProvider`;
3271
+ function Rc() {
3272
+ let e5 = (0, import_react.useContext)(Ic);
3273
+ if (!e5) throw Error(Lc);
3276
3274
  return e5;
3277
3275
  }
3278
- function Vc(e5, t2) {
3276
+ function zc(e5, t2) {
3279
3277
  return { firstPage: e5, services: e5.services, hasMore: e5.hasMore, isLoadingMore: false, cursor: { offset: (t2.paginationIndex - 1) * t2.safeLimit + e5.services.length, hasMore: e5.hasMore, pending: null, dropped: false } };
3280
3278
  }
3281
- function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2, locationId: o2, children: d2 }) {
3282
- let { firstPagePromise: f2, safeLimit: p2, serviceIdsKey: h2, categoryIdsKey: g2, refreshSignal: _2, language: v2 } = e5, y2 = mi(f2), b2 = mi(n2), [x2, S2] = (0, import_react.useState)(() => Vc(y2, e5)), [ee2, C2] = (0, import_react.useState)({}), [w2, T2] = (0, import_react.useState)({});
3283
- x2.firstPage !== y2 && (S2(Vc(y2, e5)), C2({}), T2({}));
3279
+ function Bc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2, locationId: o2, children: d2 }) {
3280
+ let { firstPagePromise: f2, safeLimit: p2, serviceIdsKey: h2, categoryIdsKey: g2, refreshSignal: _2, language: v2 } = e5, y2 = mi(f2), b2 = mi(n2), [x2, S2] = (0, import_react.useState)(() => zc(y2, e5)), [ee2, C2] = (0, import_react.useState)({}), [w2, T2] = (0, import_react.useState)({});
3281
+ x2.firstPage !== y2 && (S2(zc(y2, e5)), C2({}), T2({}));
3284
3282
  let { cursor: E2 } = x2;
3285
3283
  (0, import_react.useEffect)(() => (E2.dropped = false, () => {
3286
3284
  E2.dropped = true;
@@ -3290,9 +3288,9 @@ function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2
3290
3288
  ne2.current !== y2 && (ne2.current = y2, O2(Bs({ referralInfo: te2().searchParams.get(es.referral) ?? void 0 })), O2(Ks({ numOfServices: y2.services.length })));
3291
3289
  }, [O2, te2, y2]), (0, import_react.useEffect)(() => {
3292
3290
  let e6 = false;
3293
- return Fc(y2.services, D2, _2, v2, ie2.current).then(([t3, n3]) => {
3291
+ return Nc(y2.services, D2, _2, v2, ie2.current).then(([t3, n3]) => {
3294
3292
  e6 || (0, import_react.startTransition)(() => {
3295
- C2((e7) => Pc(e7, t3)), n3 && T2((e7) => Pc(e7, n3));
3293
+ C2((e7) => Mc(e7, t3)), n3 && T2((e7) => Mc(e7, n3));
3296
3294
  });
3297
3295
  }), () => {
3298
3296
  e6 = true;
@@ -3303,9 +3301,9 @@ function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2
3303
3301
  if (!E2.hasMore) return;
3304
3302
  let t3 = (e6) => S2((t4) => t4.cursor === E2 ? e6(t4) : t4);
3305
3303
  return t3((e6) => ({ ...e6, isLoadingMore: true })), E2.pending = $o({ limit: p2, offset: E2.offset, categoryId: e5.categoryId, locationId: e5.locationId, serviceIds: $(h2), categoryIds: $(g2) }).then((e6) => {
3306
- E2.dropped || (E2.hasMore = e6.hasMore, E2.offset += e6.services.length, t3((t4) => ({ ...t4, services: [...t4.services, ...e6.services], hasMore: e6.hasMore })), Fc(e6.services, D2, _2, v2, ie2.current).then(([e7, t4]) => {
3304
+ E2.dropped || (E2.hasMore = e6.hasMore, E2.offset += e6.services.length, t3((t4) => ({ ...t4, services: [...t4.services, ...e6.services], hasMore: e6.hasMore })), Nc(e6.services, D2, _2, v2, ie2.current).then(([e7, t4]) => {
3307
3305
  E2.dropped || (0, import_react.startTransition)(() => {
3308
- C2((t5) => Pc(t5, e7)), t4 && T2((e8) => Pc(e8, t4));
3306
+ C2((t5) => Mc(t5, e7)), t4 && T2((e8) => Mc(e8, t4));
3309
3307
  });
3310
3308
  }));
3311
3309
  }).catch(() => {
@@ -3314,17 +3312,17 @@ function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2
3314
3312
  }), E2.pending;
3315
3313
  }, [E2, p2, e5.categoryId, e5.locationId, h2, g2, O2, D2, _2, v2]), { resolvePath: oe2, toHref: se2 } = cs(), ce2 = (0, import_react.useMemo)(() => x2.services.map((e6) => {
3316
3314
  let t3 = oe2(`servicePage`, { slug: e6.mainSlug?.name ?? null, serviceId: e6._id ?? null });
3317
- return { serviceId: e6._id ?? null, refreshSignal: _2, service: e6, masterEvents: ee2[e6.schedule?._id ?? ``] ?? Ac, serviceOptionsAndVariants: w2[e6._id ?? ``] ?? null, bookingsSettings: b2, servicePageLink: t3 ? { href: se2(t3), target: `_self` } : null };
3318
- }), [oe2, se2, x2.services, _2, ee2, w2, b2]), le2 = (0, import_react.useMemo)(() => ({ serviceItems: t2 ? jc : ce2, bookingsSettings: b2, hasMore: !t2 && x2.hasMore, isLoading: t2 || x2.isLoadingMore, hasError: !t2 && y2.hasError, categoryId: a2, locationId: o2, loadMore: ae2 }), [t2, ce2, b2, x2.hasMore, x2.isLoadingMore, y2.hasError, a2, o2, ae2]);
3319
- return (0, import_jsx_runtime.jsx)(Rc.Provider, { value: le2, children: d2 });
3315
+ return { serviceId: e6._id ?? null, refreshSignal: _2, service: e6, masterEvents: ee2[e6.schedule?._id ?? ``] ?? Oc, serviceOptionsAndVariants: w2[e6._id ?? ``] ?? null, bookingsSettings: b2, servicePageLink: t3 ? { href: se2(t3), target: `_self` } : null };
3316
+ }), [oe2, se2, x2.services, _2, ee2, w2, b2]), le2 = (0, import_react.useMemo)(() => ({ serviceItems: t2 ? kc : ce2, bookingsSettings: b2, hasMore: !t2 && x2.hasMore, isLoading: t2 || x2.isLoadingMore, hasError: !t2 && y2.hasError, categoryId: a2, locationId: o2, loadMore: ae2 }), [t2, ce2, b2, x2.hasMore, x2.isLoadingMore, y2.hasError, a2, o2, ae2]);
3317
+ return (0, import_jsx_runtime.jsx)(Ic.Provider, { value: le2, children: d2 });
3320
3318
  }
3321
- var Uc = (e5) => ({ ...e5, hasError: false });
3322
- var Wc = () => ({ ...Ic });
3323
- function Gc({ categoryData: e5, limit: n2 = Oc, servicesPicker: r2, categoriesPicker: i2, refreshSignal: a2 = 0, children: s2 }) {
3324
- let l2 = Math.min(n2 ?? Oc, kc), { searchParams: d2 } = Oi(), f2 = e5?.categoryId, p2 = !!f2, g2 = f2 || d2.get(es.category), _2 = d2.get(es.location), v2 = p2 ? 1 : Lc(d2.get(es.page)), y2 = Dc(r2?.serviceId), b2 = Dc(i2?.categoryId), x2 = fs(), S2 = vs(), { isSSR: ee2 } = Ls(), [C2] = (0, import_react.useState)(() => ee2()), w2 = (0, import_react.useMemo)(() => ({ firstPagePromise: _i(Ns({ key: bs(S2, g2, _2, v2, l2, $(y2) ?? [], $(b2) ?? []), refresh: a2 !== 0, warmupData: x2, fetchData: () => fi(`services-context-load`, { feature: V.services }, $o({ limit: l2, offset: (v2 - 1) * l2, categoryId: g2, locationId: _2, serviceIds: $(y2), categoryIds: $(b2) })) }), Uc, Wc), safeLimit: l2, paginationIndex: v2, categoryId: g2, locationId: _2, serviceIdsKey: y2, categoryIdsKey: b2, refreshSignal: a2, language: S2 }), [l2, g2, _2, v2, a2, y2, b2, S2]), [T2] = (0, import_react.useState)(() => Ns({ key: Ss(), warmupData: x2, fetchData: Sc })), E2 = (0, import_react.useDeferredValue)(w2);
3325
- return (0, import_jsx_runtime.jsx)(pi, { fallback: (0, import_jsx_runtime.jsx)(Ec, { categoryId: g2, locationId: _2, children: s2 }), feature: V.services, children: (0, import_jsx_runtime.jsxs)(import_react.Suspense, { fallback: (0, import_jsx_runtime.jsx)(Tc, { categoryId: g2, locationId: _2, children: s2 }), children: [C2 && !p2 && (0, import_jsx_runtime.jsx)(tc, { servicesPromise: w2.firstPagePromise, currentPage: v2, pageQueryParam: es.page }), (0, import_jsx_runtime.jsx)(Hc, { query: E2, isQueryPending: E2 !== w2, settingsPromise: T2, categoryId: g2, locationId: _2, children: s2 })] }) });
3319
+ var Vc = (e5) => ({ ...e5, hasError: false });
3320
+ var Hc = () => ({ ...Pc });
3321
+ function Uc({ categoryData: e5, limit: n2 = 9, servicesPicker: r2, categoriesPicker: i2, refreshSignal: a2 = 0, children: s2 }) {
3322
+ let l2 = Math.min(n2 ?? 9, 100), { searchParams: d2 } = Oi(), f2 = e5?.categoryId, p2 = !!f2, g2 = f2 || d2.get(es.category), _2 = d2.get(es.location), v2 = p2 ? 1 : Fc(d2.get(es.page)), y2 = Dc(r2?.serviceId), b2 = Dc(i2?.categoryId), x2 = fs(), S2 = vs(), { isSSR: ee2 } = Ls(), [C2] = (0, import_react.useState)(() => ee2()), w2 = (0, import_react.useMemo)(() => ({ firstPagePromise: _i(Ns({ key: bs(S2, g2, _2, v2, l2, $(y2) ?? [], $(b2) ?? []), refresh: a2 !== 0, warmupData: x2, fetchData: () => fi(`services-context-load`, { feature: V.services }, $o({ limit: l2, offset: (v2 - 1) * l2, categoryId: g2, locationId: _2, serviceIds: $(y2), categoryIds: $(b2) })) }), Vc, Hc), safeLimit: l2, paginationIndex: v2, categoryId: g2, locationId: _2, serviceIdsKey: y2, categoryIdsKey: b2, refreshSignal: a2, language: S2 }), [l2, g2, _2, v2, a2, y2, b2, S2]), [T2] = (0, import_react.useState)(() => Ns({ key: Ss(), warmupData: x2, fetchData: Sc })), E2 = (0, import_react.useDeferredValue)(w2);
3323
+ return (0, import_jsx_runtime.jsx)(pi, { fallback: (0, import_jsx_runtime.jsx)(Ec, { categoryId: g2, locationId: _2, children: s2 }), feature: V.services, children: (0, import_jsx_runtime.jsxs)(import_react.Suspense, { fallback: (0, import_jsx_runtime.jsx)(Tc, { categoryId: g2, locationId: _2, children: s2 }), children: [C2 && !p2 && (0, import_jsx_runtime.jsx)(tc, { servicesPromise: w2.firstPagePromise, currentPage: v2, pageQueryParam: es.page }), (0, import_jsx_runtime.jsx)(Bc, { query: E2, isQueryPending: E2 !== w2, settingsPromise: T2, categoryId: g2, locationId: _2, children: s2 })] }) });
3326
3324
  }
3327
- var Kc = zn(`117fa14c-cf9c-47f5-b2cb-7797094612ce`);
3325
+ var Wc = zn(`117fa14c-cf9c-47f5-b2cb-7797094612ce`);
3328
3326
  // Annotate the CommonJS export names for ESM import in node:
3329
3327
  0 && (module.exports = {
3330
3328
  SERVICES_CONTEXT_MISSING_PROVIDER_ERROR,