@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.
@@ -3204,7 +3204,7 @@ function Cc(e5) {
3204
3204
  function wc({ categoryId: e5, locationId: t2, serviceItems: n2, isLoading: r2, hasError: i2, children: a2 }) {
3205
3205
  let o2 = { serviceItems: n2, bookingsSettings: null, hasMore: false, isLoading: r2, hasError: i2, categoryId: e5, locationId: t2, loadMore: async () => {
3206
3206
  } };
3207
- return m(Rc.Provider, { value: o2, children: a2 });
3207
+ return m(Ic.Provider, { value: o2, children: a2 });
3208
3208
  }
3209
3209
  function Tc({ categoryId: e5, locationId: t2, children: n2 }) {
3210
3210
  return m(wc, { categoryId: e5, locationId: t2, serviceItems: [], isLoading: true, hasError: false, children: n2 });
@@ -3219,37 +3219,35 @@ function Dc(e5) {
3219
3219
  function $(e5) {
3220
3220
  return e5 ? e5.split(`,`) : null;
3221
3221
  }
3222
- var Oc = 20;
3223
- var kc = 100;
3224
- var Ac = [];
3225
- var jc = [];
3226
- var Mc = {};
3227
- var Nc = {};
3228
- function Pc(e5, t2) {
3222
+ var Oc = [];
3223
+ var kc = [];
3224
+ var Ac = {};
3225
+ var jc = {};
3226
+ function Mc(e5, t2) {
3229
3227
  return Object.keys(t2).length === 0 ? e5 : { ...e5, ...t2 };
3230
3228
  }
3231
- function Fc(e5, t2, n2, r2, i2) {
3229
+ function Nc(e5, t2, n2, r2, i2) {
3232
3230
  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);
3233
- 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))]);
3231
+ 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))]);
3234
3232
  }
3235
- var Ic = { services: [], hasMore: false, totalPages: 1, hasError: true };
3236
- function Lc(e5) {
3233
+ var Pc = { services: [], hasMore: false, totalPages: 1, hasError: true };
3234
+ function Fc(e5) {
3237
3235
  let t2 = Math.floor(Number(e5));
3238
3236
  return !e5 || !Number.isSafeInteger(t2) || t2 < 1 ? 1 : t2;
3239
3237
  }
3240
- var Rc = n(null);
3241
- var zc = `useServicesContext must be used within ServicesContextProvider`;
3242
- function Bc() {
3243
- let e5 = a(Rc);
3244
- if (!e5) throw Error(zc);
3238
+ var Ic = n(null);
3239
+ var Lc = `useServicesContext must be used within ServicesContextProvider`;
3240
+ function Rc() {
3241
+ let e5 = a(Ic);
3242
+ if (!e5) throw Error(Lc);
3245
3243
  return e5;
3246
3244
  }
3247
- function Vc(e5, t2) {
3245
+ function zc(e5, t2) {
3248
3246
  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 } };
3249
3247
  }
3250
- function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2, locationId: o2, children: d2 }) {
3251
- let { firstPagePromise: f2, safeLimit: p2, serviceIdsKey: h2, categoryIdsKey: g2, refreshSignal: _2, language: v2 } = e5, y2 = mi(f2), b2 = mi(n2), [x2, S2] = u(() => Vc(y2, e5)), [ee2, C2] = u({}), [w2, T2] = u({});
3252
- x2.firstPage !== y2 && (S2(Vc(y2, e5)), C2({}), T2({}));
3248
+ function Bc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2, locationId: o2, children: d2 }) {
3249
+ let { firstPagePromise: f2, safeLimit: p2, serviceIdsKey: h2, categoryIdsKey: g2, refreshSignal: _2, language: v2 } = e5, y2 = mi(f2), b2 = mi(n2), [x2, S2] = u(() => zc(y2, e5)), [ee2, C2] = u({}), [w2, T2] = u({});
3250
+ x2.firstPage !== y2 && (S2(zc(y2, e5)), C2({}), T2({}));
3253
3251
  let { cursor: E2 } = x2;
3254
3252
  s(() => (E2.dropped = false, () => {
3255
3253
  E2.dropped = true;
@@ -3259,9 +3257,9 @@ function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2
3259
3257
  ne2.current !== y2 && (ne2.current = y2, O2(Bs({ referralInfo: te2().searchParams.get(es.referral) ?? void 0 })), O2(Ks({ numOfServices: y2.services.length })));
3260
3258
  }, [O2, te2, y2]), s(() => {
3261
3259
  let e6 = false;
3262
- return Fc(y2.services, D2, _2, v2, ie2.current).then(([t3, n3]) => {
3260
+ return Nc(y2.services, D2, _2, v2, ie2.current).then(([t3, n3]) => {
3263
3261
  e6 || r(() => {
3264
- C2((e7) => Pc(e7, t3)), n3 && T2((e7) => Pc(e7, n3));
3262
+ C2((e7) => Mc(e7, t3)), n3 && T2((e7) => Mc(e7, n3));
3265
3263
  });
3266
3264
  }), () => {
3267
3265
  e6 = true;
@@ -3272,9 +3270,9 @@ function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2
3272
3270
  if (!E2.hasMore) return;
3273
3271
  let t3 = (e6) => S2((t4) => t4.cursor === E2 ? e6(t4) : t4);
3274
3272
  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) => {
3275
- 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]) => {
3273
+ 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]) => {
3276
3274
  E2.dropped || r(() => {
3277
- C2((t5) => Pc(t5, e7)), t4 && T2((e8) => Pc(e8, t4));
3275
+ C2((t5) => Mc(t5, e7)), t4 && T2((e8) => Mc(e8, t4));
3278
3276
  });
3279
3277
  }));
3280
3278
  }).catch(() => {
@@ -3283,23 +3281,23 @@ function Hc({ query: e5, isQueryPending: t2, settingsPromise: n2, categoryId: a2
3283
3281
  }), E2.pending;
3284
3282
  }, [E2, p2, e5.categoryId, e5.locationId, h2, g2, O2, D2, _2, v2]), { resolvePath: oe2, toHref: se2 } = cs(), ce2 = c(() => x2.services.map((e6) => {
3285
3283
  let t3 = oe2(`servicePage`, { slug: e6.mainSlug?.name ?? null, serviceId: e6._id ?? null });
3286
- 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 };
3287
- }), [oe2, se2, x2.services, _2, ee2, w2, b2]), le2 = c(() => ({ 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]);
3288
- return m(Rc.Provider, { value: le2, children: d2 });
3284
+ 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 };
3285
+ }), [oe2, se2, x2.services, _2, ee2, w2, b2]), le2 = c(() => ({ 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]);
3286
+ return m(Ic.Provider, { value: le2, children: d2 });
3289
3287
  }
3290
- var Uc = (e5) => ({ ...e5, hasError: false });
3291
- var Wc = () => ({ ...Ic });
3292
- function Gc({ categoryData: e5, limit: n2 = Oc, servicesPicker: r2, categoriesPicker: i2, refreshSignal: a2 = 0, children: s2 }) {
3293
- 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] = u(() => ee2()), w2 = c(() => ({ 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] = u(() => Ns({ key: Ss(), warmupData: x2, fetchData: Sc })), E2 = o(w2);
3294
- return m(pi, { fallback: m(Ec, { categoryId: g2, locationId: _2, children: s2 }), feature: V.services, children: h(t, { fallback: m(Tc, { categoryId: g2, locationId: _2, children: s2 }), children: [C2 && !p2 && m(tc, { servicesPromise: w2.firstPagePromise, currentPage: v2, pageQueryParam: es.page }), m(Hc, { query: E2, isQueryPending: E2 !== w2, settingsPromise: T2, categoryId: g2, locationId: _2, children: s2 })] }) });
3288
+ var Vc = (e5) => ({ ...e5, hasError: false });
3289
+ var Hc = () => ({ ...Pc });
3290
+ function Uc({ categoryData: e5, limit: n2 = 9, servicesPicker: r2, categoriesPicker: i2, refreshSignal: a2 = 0, children: s2 }) {
3291
+ 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] = u(() => ee2()), w2 = c(() => ({ 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] = u(() => Ns({ key: Ss(), warmupData: x2, fetchData: Sc })), E2 = o(w2);
3292
+ return m(pi, { fallback: m(Ec, { categoryId: g2, locationId: _2, children: s2 }), feature: V.services, children: h(t, { fallback: m(Tc, { categoryId: g2, locationId: _2, children: s2 }), children: [C2 && !p2 && m(tc, { servicesPromise: w2.firstPagePromise, currentPage: v2, pageQueryParam: es.page }), m(Bc, { query: E2, isQueryPending: E2 !== w2, settingsPromise: T2, categoryId: g2, locationId: _2, children: s2 })] }) });
3295
3293
  }
3296
- var Kc = zn(`117fa14c-cf9c-47f5-b2cb-7797094612ce`);
3294
+ var Wc = zn(`117fa14c-cf9c-47f5-b2cb-7797094612ce`);
3297
3295
  export {
3298
- zc as SERVICES_CONTEXT_MISSING_PROVIDER_ERROR,
3299
- Gc as ServicesContextProvider,
3300
- Gc as default,
3301
- Kc as injectAccessTokenGetter,
3302
- Rc as servicesContext,
3303
- Bc as useServicesContext
3296
+ Lc as SERVICES_CONTEXT_MISSING_PROVIDER_ERROR,
3297
+ Uc as ServicesContextProvider,
3298
+ Uc as default,
3299
+ Wc as injectAccessTokenGetter,
3300
+ Ic as servicesContext,
3301
+ Rc as useServicesContext
3304
3302
  };
3305
3303
  //# sourceMappingURL=context-services.mjs.map