@pisell/private-materials 6.11.661 → 6.11.662

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.
Files changed (33) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.js +18 -18
  6. package/build/lowcode/view.js +18 -18
  7. package/es/components/booking/utils.js +1 -1
  8. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.js +5 -1
  9. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.js +9 -1
  10. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.js +3 -1
  11. package/es/components/eventBooking/components/bookingAvailabilityCalendar/index.d.ts +5 -0
  12. package/es/components/eventBooking/components/bookingAvailabilityCalendar/index.js +2 -1
  13. package/es/plus/salesSdk/normalProductDetail/NormalProductDetailHostRenderer.js +103 -43
  14. package/es/plus/salesSdk/normalProductDetail/availabilityContextRouting.js +29 -0
  15. package/es/pro/skuDetailModal/flow/modules/date/availabilityWindow.js +71 -0
  16. package/es/pro/skuDetailModal/flow/modules/date/index.js +24 -9
  17. package/es/pro/skuDetailModal/flow/modules/time/index.js +28 -13
  18. package/es/pro/skuDetailModal/flow/modules/time/posCustomTime.js +7 -1
  19. package/es/pro/skuDetailModal/flow/types.d.ts +8 -0
  20. package/lib/components/booking/utils.js +1 -1
  21. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.js +5 -1
  22. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.js +9 -1
  23. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.js +3 -1
  24. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/index.d.ts +5 -0
  25. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/index.js +2 -1
  26. package/lib/plus/salesSdk/normalProductDetail/NormalProductDetailHostRenderer.js +103 -43
  27. package/lib/plus/salesSdk/normalProductDetail/availabilityContextRouting.js +32 -0
  28. package/lib/pro/skuDetailModal/flow/modules/date/availabilityWindow.js +74 -0
  29. package/lib/pro/skuDetailModal/flow/modules/date/index.js +24 -9
  30. package/lib/pro/skuDetailModal/flow/modules/time/index.js +27 -12
  31. package/lib/pro/skuDetailModal/flow/modules/time/posCustomTime.js +8 -0
  32. package/lib/pro/skuDetailModal/flow/types.d.ts +8 -0
  33. package/package.json +4 -4
@@ -554,7 +554,7 @@ const getProductTotalPrice = (item, options) => {
554
554
  return accumulator.add(currentPrice.mul(currentNum));
555
555
  }, price);
556
556
  if (other === null || other === void 0 ? void 0 : other.option) price = other === null || other === void 0 ? void 0 : other.option.reduce((accumulator, currentValue) => {
557
- const currentPrice = new Decimal(currentValue.price || 0);
557
+ const currentPrice = new Decimal(currentValue.price || currentValue.add_price || 0);
558
558
  const currentNum = new Decimal(currentValue.num || 0);
559
559
  return accumulator.add(currentPrice.mul(currentNum));
560
560
  }, price);
@@ -11,7 +11,7 @@ import classNames from "classnames";
11
11
  import "./index.less";
12
12
  //#region src/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.tsx
13
13
  const CalenDateWeek = (props) => {
14
- const { currentDate, dateChange, productId, timeList, dateLimitData, getLimitData, cutTime, showStatusBar = true, showDisabledStatus = true, ignoreAvailabilityDisabled = false, minSelectableDate, minViewDate, enableRangeSelection = false, selectedRangeStartDate, selectedRangeEndDate, showMonthHeader = false, enableSwipeNavigation = false, disableCallToBook = false, navigationVariant = "default" } = props;
14
+ const { currentDate, dateChange, productId, timeList, dateLimitData, getLimitData, cutTime, showStatusBar = true, showDisabledStatus = true, ignoreAvailabilityDisabled = false, minSelectableDate, minViewDate, enableRangeSelection = false, selectedRangeStartDate, selectedRangeEndDate, showMonthHeader = false, enableSwipeNavigation = false, disableCallToBook = false, navigationVariant = "default", onVisibleDateRangeChange } = props;
15
15
  const [weekList, setWeekList] = useState([]);
16
16
  const [weekAnchorDate, setWeekAnchorDate] = useState(currentDate);
17
17
  const [pendingWeekList, setPendingWeekList] = useState(null);
@@ -163,6 +163,10 @@ const CalenDateWeek = (props) => {
163
163
  if (pendingWeekAnchorDate && pendingWeekList) {
164
164
  setWeekAnchorDate(pendingWeekAnchorDate);
165
165
  setWeekList(pendingWeekList);
166
+ onVisibleDateRangeChange === null || onVisibleDateRangeChange === void 0 || onVisibleDateRangeChange({
167
+ startDate: pendingWeekList[0],
168
+ endDate: pendingWeekList[pendingWeekList.length - 1]
169
+ });
166
170
  }
167
171
  setPendingWeekAnchorDate(null);
168
172
  setPendingWeekList(null);
@@ -11,7 +11,7 @@ import "./index.less";
11
11
  //#region src/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.tsx
12
12
  dayjs.extend(isSameOrBefore);
13
13
  const CalendarDate = (props, ref) => {
14
- const { cutTime, getLimitData, dateLimitData, loading, disableCallToBook = false, enforceAvailabilitySelection = false, ignoreAvailabilityDisabled = false, availabilityRange, minSelectableDate, title = locales.getText("pisell2.event.calendar.select.date"), closeOnSelect = false } = props;
14
+ const { cutTime, getLimitData, dateLimitData, loading, disableCallToBook = false, enforceAvailabilitySelection = false, ignoreAvailabilityDisabled = false, availabilityRange, minSelectableDate, title = locales.getText("pisell2.event.calendar.select.date"), closeOnSelect = false, onVisibleDateRangeChange } = props;
15
15
  const [productId, setProductId] = useState("");
16
16
  const [currentDate, setCurrentDate] = useState("");
17
17
  const [dateMonthList, setDateMonthList] = useState([]);
@@ -75,6 +75,10 @@ const CalendarDate = (props, ref) => {
75
75
  let newLastMonth = dayjs(currentMonth.format("YYYY-MM")).subtract(1, "month");
76
76
  setCurrentMonth(newLastMonth);
77
77
  setDateMonthList(getMonthData(newLastMonth.format("YYYY-MM")));
78
+ onVisibleDateRangeChange === null || onVisibleDateRangeChange === void 0 || onVisibleDateRangeChange({
79
+ startDate: newLastMonth.startOf("month").format("YYYY-MM-DD"),
80
+ endDate: newLastMonth.endOf("month").format("YYYY-MM-DD")
81
+ });
78
82
  };
79
83
  /**
80
84
  * @title: 切换下个月
@@ -88,6 +92,10 @@ const CalendarDate = (props, ref) => {
88
92
  let newNextMonth = dayjs(currentMonth.format("YYYY-MM")).add(1, "month");
89
93
  setCurrentMonth(newNextMonth);
90
94
  setDateMonthList(getMonthData(newNextMonth.format("YYYY-MM")));
95
+ onVisibleDateRangeChange === null || onVisibleDateRangeChange === void 0 || onVisibleDateRangeChange({
96
+ startDate: newNextMonth.startOf("month").format("YYYY-MM-DD"),
97
+ endDate: newNextMonth.endOf("month").format("YYYY-MM-DD")
98
+ });
91
99
  };
92
100
  /**
93
101
  * @title: 根据当前选择的月份剩余量
@@ -12,7 +12,7 @@ import { Iconfont } from "@pisell/materials";
12
12
  import classNames from "classnames";
13
13
  import "./index.less";
14
14
  //#region src/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.tsx
15
- const SelectDate = ({ currentDate, detail, currentDateChange, setSurplusDisabledChange, cutTime, setCutTime, showCalendarPopup, showStatusLegend = true, showDateStatusBar = true, title = locales.getText("pisell2.event.calendar.select.date"), showHeader = true, showDisabledStatus = true, ignoreAvailabilityDisabled = false, minSelectableDate, minViewDate, enableRangeSelection = false, selectedRangeStartDate, selectedRangeEndDate, showMonthHeader = false, enableWeekSwipe = false, weekNavigationVariant = "default", closeCalendarOnSelect = false, availabilityDates }, ref) => {
15
+ const SelectDate = ({ currentDate, detail, currentDateChange, onVisibleDateRangeChange, setSurplusDisabledChange, cutTime, setCutTime, showCalendarPopup, showStatusLegend = true, showDateStatusBar = true, title = locales.getText("pisell2.event.calendar.select.date"), showHeader = true, showDisabledStatus = true, ignoreAvailabilityDisabled = false, minSelectableDate, minViewDate, enableRangeSelection = false, selectedRangeStartDate, selectedRangeEndDate, showMonthHeader = false, enableWeekSwipe = false, weekNavigationVariant = "default", closeCalendarOnSelect = false, availabilityDates }, ref) => {
16
16
  const [dateLimitData, setDateLimitData] = useState(mock.availability_calendar.limitData);
17
17
  /**
18
18
  * UBS 日期结果只负责状态展示,不伪造旧事件预约的 times/库存结构。
@@ -76,6 +76,7 @@ const SelectDate = ({ currentDate, detail, currentDateChange, setSurplusDisabled
76
76
  productId: detail === null || detail === void 0 ? void 0 : detail.id,
77
77
  cutTime,
78
78
  dateLimitData: resolvedDateLimitData,
79
+ onVisibleDateRangeChange,
79
80
  showStatusBar: showDateStatusBar,
80
81
  showDisabledStatus,
81
82
  ignoreAvailabilityDisabled,
@@ -96,6 +97,7 @@ const SelectDate = ({ currentDate, detail, currentDateChange, setSurplusDisabled
96
97
  },
97
98
  cutTime,
98
99
  dateLimitData: resolvedDateLimitData,
100
+ onVisibleDateRangeChange,
99
101
  disableCallToBook: usesExternalAvailability,
100
102
  enforceAvailabilitySelection: usesExternalAvailability,
101
103
  ignoreAvailabilityDisabled,
@@ -25,6 +25,11 @@ interface BookingAvailabilityCalendarProps {
25
25
  currentDate?: string;
26
26
  cutTime?: any;
27
27
  onCurrentDateChange?: (date: string) => void;
28
+ /** 周历或月历切换后,通知外层当前可视日期范围。 */
29
+ onVisibleDateRangeChange?: (range: {
30
+ startDate: string;
31
+ endDate: string;
32
+ }) => void;
28
33
  onCutTimeChange?: (date: string) => void;
29
34
  onSurplusDisabledChange?: (date: boolean) => void;
30
35
  showStatusLegend?: boolean;
@@ -18,7 +18,7 @@ const BookingAvailabilityCalendar = forwardRef((props, ref) => {
18
18
  * 日历挂载后日期图例、Add Note、Cancel 等文案又闪回英文。
19
19
  */
20
20
  locales.init(locales_default, locales.getLocale() || "en");
21
- const { showCalendarPopup, onDateChange, detail = (_mock$availability_ca = mock.availability_calendar) === null || _mock$availability_ca === void 0 ? void 0 : _mock$availability_ca.detail, currentDate = (_mock$availability_ca2 = mock.availability_calendar) === null || _mock$availability_ca2 === void 0 ? void 0 : _mock$availability_ca2.currentDate, cutTime = (_mock$availability_ca3 = mock.availability_calendar) === null || _mock$availability_ca3 === void 0 ? void 0 : _mock$availability_ca3.cutTime, onCurrentDateChange, onCutTimeChange, onSurplusDisabledChange, showStatusLegend = true, showDateStatusBar = true, theme = "light", className, title, showHeader, showDisabledStatus, ignoreAvailabilityDisabled, minSelectableDate, minViewDate, enableRangeSelection, selectedRangeStartDate, selectedRangeEndDate, showMonthHeader, enableWeekSwipe, weekNavigationVariant, closeCalendarOnSelect, availabilityDates } = props;
21
+ const { showCalendarPopup, onDateChange, detail = (_mock$availability_ca = mock.availability_calendar) === null || _mock$availability_ca === void 0 ? void 0 : _mock$availability_ca.detail, currentDate = (_mock$availability_ca2 = mock.availability_calendar) === null || _mock$availability_ca2 === void 0 ? void 0 : _mock$availability_ca2.currentDate, cutTime = (_mock$availability_ca3 = mock.availability_calendar) === null || _mock$availability_ca3 === void 0 ? void 0 : _mock$availability_ca3.cutTime, onCurrentDateChange, onVisibleDateRangeChange, onCutTimeChange, onSurplusDisabledChange, showStatusLegend = true, showDateStatusBar = true, theme = "light", className, title, showHeader, showDisabledStatus, ignoreAvailabilityDisabled, minSelectableDate, minViewDate, enableRangeSelection, selectedRangeStartDate, selectedRangeEndDate, showMonthHeader, enableWeekSwipe, weekNavigationVariant, closeCalendarOnSelect, availabilityDates } = props;
22
22
  const selectDateRef = useRef(null);
23
23
  useImperativeHandle(ref, () => ({ openCalendarPopup: () => {
24
24
  var _selectDateRef$curren;
@@ -34,6 +34,7 @@ const BookingAvailabilityCalendar = forwardRef((props, ref) => {
34
34
  onCurrentDateChange(date);
35
35
  if (currentDate !== date) onDateChange(date);
36
36
  },
37
+ onVisibleDateRangeChange,
37
38
  setSurplusDisabledChange: onSurplusDisabledChange,
38
39
  cutTime,
39
40
  setCutTime: onCutTimeChange,
@@ -20,6 +20,7 @@ import { prepareNormalProductEditCacheItem, transformNormalProductCreateConfirm
20
20
  import { assertBookingEditQuantityUnchanged, buildAvailabilityCommitParams, normalizeAvailabilityOrderProductForCommit, resolveBookingCommitCount, resolveBookingEditRepriceFlags } from "./resolveBookingCommitCount.js";
21
21
  import { buildInitialBookingSelectionPriceSnapshot, buildInitialBookingSelectionProductData, createBookingSelectionPriceService, resolveConfiguredBookingSelectionPricingDuration } from "./bookingSelectionPrice.js";
22
22
  import { buildBookingSelectionCacheItem } from "./buildBookingSelectionCacheItem.js";
23
+ import { availabilityDateRangeContains, resolveAvailabilityRequestContextId } from "./availabilityContextRouting.js";
23
24
  import dayjs from "dayjs";
24
25
  import React, { useEffect, useMemo, useRef, useState } from "react";
25
26
  import { locales } from "@pisell/utils";
@@ -115,11 +116,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
115
116
  tempOrderRef.current = tempOrder;
116
117
  const handledDismissRevisionRef = useRef(dismissRevision);
117
118
  const availabilityContextIdRef = useRef(null);
119
+ const availabilityContextsRef = useRef(/* @__PURE__ */ new Map());
118
120
  const releaseAvailabilityContext = useMemoizedFn(() => {
119
- const contextId = availabilityContextIdRef.current;
120
- if (!contextId) return;
121
+ const contextIds = Array.from(availabilityContextsRef.current.keys());
121
122
  availabilityContextIdRef.current = null;
122
- salesModule.releaseAvailabilityContext(contextId);
123
+ availabilityContextsRef.current.clear();
124
+ contextIds.forEach((contextId) => {
125
+ salesModule.releaseAvailabilityContext(contextId);
126
+ });
123
127
  });
124
128
  const commitAvailabilitySelection = useMemoizedFn(function() {
125
129
  var _ref2 = _asyncToGenerator(function* (orderProduct, selection, commit) {
@@ -214,7 +218,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
214
218
  activePendingRef.current = null;
215
219
  };
216
220
  (function() {
217
- var _ref17 = _asyncToGenerator(function* () {
221
+ var _ref19 = _asyncToGenerator(function* () {
218
222
  var _bookingTicket$getBoo3, _bookingTicket$getBoo4;
219
223
  const payload = capturedPending.payload;
220
224
  let openArgs;
@@ -249,12 +253,25 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
249
253
  const prepareAvailability = (productId, date, editingProductLineUids) => {
250
254
  const numericProductId = Number(productId);
251
255
  if (!Number.isFinite(numericProductId)) throw new Error("预约商品缺少有效 product id。");
256
+ const initialScheduleDate = dayjs(date).format("YYYY-MM-DD");
257
+ const initialDateRange = {
258
+ startDate: initialScheduleDate,
259
+ endDate: dayjs(initialScheduleDate).add(31, "day").format("YYYY-MM-DD")
260
+ };
252
261
  let availabilityReady;
253
- const getAvailabilityReady = () => {
254
- if (availabilityReady) return availabilityReady;
255
- availabilityReady = _asyncToGenerator(function* () {
262
+ let dateAvailabilityContextId = null;
263
+ let latestDateRangeRequestId = 0;
264
+ const dateRangePrepareTasks = /* @__PURE__ */ new Map();
265
+ const getRegisteredContexts = () => Array.from(availabilityContextsRef.current.values());
266
+ const prepareDateRange = (dateRange) => {
267
+ const coveringContext = [...getRegisteredContexts()].reverse().find((item) => availabilityDateRangeContains(item.dateRange, dateRange));
268
+ if (coveringContext) return Promise.resolve(coveringContext.contextId);
269
+ const rangeKey = `${dateRange.startDate}:${dateRange.endDate}`;
270
+ const pendingRange = dateRangePrepareTasks.get(rangeKey);
271
+ if (pendingRange) return pendingRange;
272
+ const task = _asyncToGenerator(function* () {
256
273
  var _getProductCatalog;
257
- const scheduleDate = dayjs(date).format("YYYY-MM-DD");
274
+ const scheduleDate = dateRange.startDate;
258
275
  const availabilityProduct = yield salesModule.queryProductDetail({
259
276
  product_id: numericProductId,
260
277
  schedule_date: scheduleDate,
@@ -268,35 +285,78 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
268
285
  catalogWithAvailabilityProduct.push(availabilityProduct);
269
286
  const prepared = yield salesModule.prepareAvailabilityProjection(_objectSpread2({
270
287
  productIds: [numericProductId],
288
+ dateRange,
271
289
  rawProducts: catalogWithAvailabilityProduct
272
290
  }, (editingProductLineUids === null || editingProductLineUids === void 0 ? void 0 : editingProductLineUids.length) ? { editingProductLineUids } : {}));
273
291
  if (!isCurrentPending()) {
274
292
  salesModule.releaseAvailabilityContext(prepared.contextId);
275
293
  throw new Error("预约商品选择已取消。");
276
294
  }
277
- availabilityContextIdRef.current = prepared.contextId;
295
+ availabilityContextsRef.current.set(prepared.contextId, {
296
+ contextId: prepared.contextId,
297
+ dateRange
298
+ });
278
299
  return prepared.contextId;
279
300
  })();
301
+ dateRangePrepareTasks.set(rangeKey, task);
302
+ task.finally(() => {
303
+ if (dateRangePrepareTasks.get(rangeKey) === task) dateRangePrepareTasks.delete(rangeKey);
304
+ }).catch(() => void 0);
305
+ return task;
306
+ };
307
+ const getAvailabilityReady = () => {
308
+ if (availabilityReady) return availabilityReady;
309
+ availabilityReady = prepareDateRange(initialDateRange).then((contextId) => {
310
+ dateAvailabilityContextId = contextId;
311
+ availabilityContextIdRef.current = contextId;
312
+ return contextId;
313
+ });
280
314
  availabilityReady.catch((error) => {
281
315
  if (isCurrentPending()) console.warn("[SalesSdk] Availability context 初始化失败", error);
282
316
  });
283
317
  return availabilityReady;
284
318
  };
319
+ const ensureDateRange = function() {
320
+ var _ref4 = _asyncToGenerator(function* (dateRange) {
321
+ yield getAvailabilityReady();
322
+ const requestId = ++latestDateRangeRequestId;
323
+ const contextId = yield prepareDateRange(dateRange);
324
+ if (!isCurrentPending()) throw new Error("预约商品选择已取消。");
325
+ if (requestId === latestDateRangeRequestId) dateAvailabilityContextId = contextId;
326
+ });
327
+ return function ensureDateRange(_x6) {
328
+ return _ref4.apply(this, arguments);
329
+ };
330
+ }();
331
+ const resolveContextId = function() {
332
+ var _ref5 = _asyncToGenerator(function* (request, target) {
333
+ const initialContextId = yield getAvailabilityReady();
334
+ if (target === "date") return dateAvailabilityContextId || initialContextId;
335
+ const contextId = resolveAvailabilityRequestContextId(getRegisteredContexts(), request, dateAvailabilityContextId || initialContextId) || initialContextId;
336
+ availabilityContextIdRef.current = contextId;
337
+ return contextId;
338
+ });
339
+ return function resolveContextId(_x7, _x8) {
340
+ return _ref5.apply(this, arguments);
341
+ };
342
+ }();
285
343
  let availabilityQuerySequence = 0;
286
344
  selectionFlowServices = _objectSpread2(_objectSpread2({}, selectionFlowServices), {}, { availability: {
287
345
  contextId: `pending:${numericProductId}`,
288
346
  productId,
289
347
  partySize: 1,
348
+ ensureDateRange,
290
349
  getProductTimeRanges: function() {
291
- var _ref4 = _asyncToGenerator(function* (_contextId, request) {
292
- return salesModule.getProductTimeRanges(yield getAvailabilityReady(), request);
350
+ var _ref6 = _asyncToGenerator(function* (_contextId, request) {
351
+ const contextId = yield resolveContextId(request);
352
+ return salesModule.getProductTimeRanges(contextId, request);
293
353
  });
294
- return function getProductTimeRanges(_x6, _x7) {
295
- return _ref4.apply(this, arguments);
354
+ return function getProductTimeRanges(_x9, _x10) {
355
+ return _ref6.apply(this, arguments);
296
356
  };
297
357
  }(),
298
358
  queryBookingAvailability: function() {
299
- var _ref5 = _asyncToGenerator(function* (_contextId, request) {
359
+ var _ref7 = _asyncToGenerator(function* (_contextId, request) {
300
360
  availabilityQuerySequence += 1;
301
361
  const callId = `${numericProductId}-${availabilityQuerySequence}`;
302
362
  console.info("[SelectionFlowAvailability][queryBookingAvailability][input]", {
@@ -305,7 +365,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
305
365
  request
306
366
  });
307
367
  try {
308
- const contextId = yield getAvailabilityReady();
368
+ const contextId = yield resolveContextId(request, request.target);
309
369
  const result = yield salesModule.queryBookingAvailability(contextId, request);
310
370
  console.info("[SelectionFlowAvailability][queryBookingAvailability][output]", {
311
371
  callId,
@@ -324,14 +384,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
324
384
  throw error;
325
385
  }
326
386
  });
327
- return function queryBookingAvailability(_x8, _x9) {
328
- return _ref5.apply(this, arguments);
387
+ return function queryBookingAvailability(_x11, _x12) {
388
+ return _ref7.apply(this, arguments);
329
389
  };
330
390
  }()
331
391
  } });
332
392
  };
333
393
  const refreshHolderContextFromHydratedProduct = function() {
334
- var _ref6 = _asyncToGenerator(function* ({ productData }) {
394
+ var _ref8 = _asyncToGenerator(function* ({ productData }) {
335
395
  holderSource = productData;
336
396
  try {
337
397
  holderOptions = yield ensureHolderOptionsForSource(productData);
@@ -360,14 +420,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
360
420
  holderSource: productData
361
421
  });
362
422
  });
363
- return function refreshHolderContextFromHydratedProduct(_x10) {
364
- return _ref6.apply(this, arguments);
423
+ return function refreshHolderContextFromHydratedProduct(_x13) {
424
+ return _ref8.apply(this, arguments);
365
425
  };
366
426
  }();
367
427
  if (payload.mode === "create") {
368
- var _ref7, _detailPayload$produc;
428
+ var _ref9, _detailPayload$produc;
369
429
  const detailPayload = payload.requiresDetailPayload;
370
- const item = normalizeCatalogProduct((_ref7 = (_detailPayload$produc = detailPayload.productData) !== null && _detailPayload$produc !== void 0 ? _detailPayload$produc : detailPayload.item) !== null && _ref7 !== void 0 ? _ref7 : {});
430
+ const item = normalizeCatalogProduct((_ref9 = (_detailPayload$produc = detailPayload.productData) !== null && _detailPayload$produc !== void 0 ? _detailPayload$produc : detailPayload.item) !== null && _ref9 !== void 0 ? _ref9 : {});
371
431
  const detailProductData = _objectSpread2(_objectSpread2({}, item), {}, { is_eject: detailPayload.isEject });
372
432
  const productId = resolveCatalogProductId(item);
373
433
  const rawDate = detailPayload.date;
@@ -379,26 +439,26 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
379
439
  const liveTempOrder = (_bookingTicket$getTem = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getTem2 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem2 === void 0 ? void 0 : _bookingTicket$getTem2.call(bookingTicket)) !== null && _bookingTicket$getTem !== void 0 ? _bookingTicket$getTem : tempOrderRef.current;
380
440
  if (usesUnifiedBookingSales) {
381
441
  if (!bookingConfig && typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.initBookingContext) === "function") {
382
- var _ref8, _result$bookingConfig, _bookingTicket$getBoo5;
442
+ var _ref10, _result$bookingConfig, _bookingTicket$getBoo5;
383
443
  const bookingIds = collectBookingIdsFromTempOrder(liveTempOrder);
384
444
  const result = yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
385
445
  date: dayjs(date),
386
446
  bookingIds: bookingIds.length ? bookingIds : void 0,
387
447
  loadResources: initializeFullBookingContext
388
448
  }));
389
- bookingConfig = (_ref8 = (_result$bookingConfig = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig !== void 0 ? _result$bookingConfig : (_bookingTicket$getBoo5 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo5 === void 0 ? void 0 : _bookingTicket$getBoo5.call(bookingTicket)) !== null && _ref8 !== void 0 ? _ref8 : null;
449
+ bookingConfig = (_ref10 = (_result$bookingConfig = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig !== void 0 ? _result$bookingConfig : (_bookingTicket$getBoo5 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo5 === void 0 ? void 0 : _bookingTicket$getBoo5.call(bookingTicket)) !== null && _ref10 !== void 0 ? _ref10 : null;
390
450
  }
391
451
  } else if (typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.initBookingContext) !== "function") {
392
452
  if (!bookingConfig) throw new Error("当前 SalesSdk 运行时不支持初始化 BookingContext。");
393
453
  } else {
394
- var _ref9, _result$bookingConfig2, _bookingTicket$getBoo6;
454
+ var _ref11, _result$bookingConfig2, _bookingTicket$getBoo6;
395
455
  const bookingIds = collectBookingIdsFromTempOrder(liveTempOrder);
396
456
  const result = yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
397
457
  date: dayjs(date),
398
458
  bookingIds: bookingIds.length ? bookingIds : void 0,
399
459
  loadResources: true
400
460
  }));
401
- bookingConfig = (_ref9 = (_result$bookingConfig2 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig2 !== void 0 ? _result$bookingConfig2 : (_bookingTicket$getBoo6 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo6 === void 0 ? void 0 : _bookingTicket$getBoo6.call(bookingTicket)) !== null && _ref9 !== void 0 ? _ref9 : null;
461
+ bookingConfig = (_ref11 = (_result$bookingConfig2 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig2 !== void 0 ? _result$bookingConfig2 : (_bookingTicket$getBoo6 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo6 === void 0 ? void 0 : _bookingTicket$getBoo6.call(bookingTicket)) !== null && _ref11 !== void 0 ? _ref11 : null;
402
462
  }
403
463
  if (!usesUnifiedBookingSales && !bookingConfig) throw new Error("BookingContext 初始化完成后仍缺少 bookingConfig。");
404
464
  const customerId = resolveBookingEditCustomerId(liveTempOrder, detailPayload.customerId, bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getOrd2 = bookingTicket.getOrderCustomerSnapshot) === null || _bookingTicket$getOrd2 === void 0 || (_bookingTicket$getOrd2 = _bookingTicket$getOrd2.call(bookingTicket)) === null || _bookingTicket$getOrd2 === void 0 ? void 0 : _bookingTicket$getOrd2.id);
@@ -450,14 +510,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
450
510
  return true;
451
511
  } } : {}), {}, { skuDetailConfig });
452
512
  } else if (payload.mode === "booking-create" || payload.mode === "booking-edit") {
453
- var _ref10, _ref11, _ref12, _ref13, _bookingPayload$date, _bookingPayload$cache, _bookingTicket$getTem3, _bookingTicket$getTem4, _bookingTicket$getOrd3, _ref15, _bookingTicket$getRes3, _bookingTicket$getRes4, _initialCacheItem$_da, _ref16, _bookingPayload$catal, _initialCacheItem$_ex, _bookingTicket$getOth3, _initialCacheItem$_ex2;
513
+ var _ref12, _ref13, _ref14, _ref15, _bookingPayload$date, _bookingPayload$cache, _bookingTicket$getTem3, _bookingTicket$getTem4, _bookingTicket$getOrd3, _ref17, _bookingTicket$getRes3, _bookingTicket$getRes4, _initialCacheItem$_da, _ref18, _bookingPayload$catal, _initialCacheItem$_ex, _bookingTicket$getOth3, _initialCacheItem$_ex2;
454
514
  const isBookingEdit = payload.mode === "booking-edit";
455
515
  const bookingPayload = isBookingEdit ? payload.bookingEditPayload : payload.requiresBookingEditPayload;
456
516
  selectionFlowServices = _objectSpread2(_objectSpread2({}, selectionFlowServices), {}, {
457
517
  selectionFlowMode: isBookingEdit ? "edit" : "create",
458
518
  deferAvailabilityCommit: Boolean(isBookingEdit && bookingPayload.deferCommit)
459
519
  });
460
- const item = normalizeCatalogProduct((_ref10 = (_ref11 = (_ref12 = (_ref13 = isBookingEdit ? bookingPayload.catalogProduct : null) !== null && _ref13 !== void 0 ? _ref13 : bookingPayload.catalogProduct) !== null && _ref12 !== void 0 ? _ref12 : bookingPayload.sourceProduct) !== null && _ref11 !== void 0 ? _ref11 : bookingPayload.cacheItem) !== null && _ref10 !== void 0 ? _ref10 : {});
520
+ const item = normalizeCatalogProduct((_ref12 = (_ref13 = (_ref14 = (_ref15 = isBookingEdit ? bookingPayload.catalogProduct : null) !== null && _ref15 !== void 0 ? _ref15 : bookingPayload.catalogProduct) !== null && _ref14 !== void 0 ? _ref14 : bookingPayload.sourceProduct) !== null && _ref13 !== void 0 ? _ref13 : bookingPayload.cacheItem) !== null && _ref12 !== void 0 ? _ref12 : {});
461
521
  const skuDetailConfig = mergeSkuDetailConfig(item === null || item === void 0 ? void 0 : item.skuDetailConfig, defaultSkuDetailConfig);
462
522
  if (!(Array.isArray(skuDetailConfig.steps) || typeof skuDetailConfig.resolveSteps === "function") || getUnsupportedBookingFlowReason(item) && !isMultiDayProduct(item) || !bookingTicket) {
463
523
  completeCaptured({ mode: "booking-fallback" });
@@ -473,13 +533,13 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
473
533
  const liveTempOrder = (_bookingTicket$getTem3 = (_bookingTicket$getTem4 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem4 === void 0 ? void 0 : _bookingTicket$getTem4.call(bookingTicket)) !== null && _bookingTicket$getTem3 !== void 0 ? _bookingTicket$getTem3 : tempOrderRef.current;
474
534
  const bookingIds = collectBookingIdsFromTempOrder(liveTempOrder);
475
535
  if (typeof bookingTicket.initBookingContext === "function") {
476
- var _ref14, _result$bookingConfig3, _bookingTicket$getBoo7;
536
+ var _ref16, _result$bookingConfig3, _bookingTicket$getBoo7;
477
537
  const result = yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
478
538
  date: dayjs(date),
479
539
  bookingIds: bookingIds.length ? bookingIds : void 0,
480
540
  loadResources: !usesUnifiedBookingSales || initializeFullBookingContext
481
541
  }));
482
- bookingConfig = (_ref14 = (_result$bookingConfig3 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig3 !== void 0 ? _result$bookingConfig3 : (_bookingTicket$getBoo7 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo7 === void 0 ? void 0 : _bookingTicket$getBoo7.call(bookingTicket)) !== null && _ref14 !== void 0 ? _ref14 : null;
542
+ bookingConfig = (_ref16 = (_result$bookingConfig3 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig3 !== void 0 ? _result$bookingConfig3 : (_bookingTicket$getBoo7 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo7 === void 0 ? void 0 : _bookingTicket$getBoo7.call(bookingTicket)) !== null && _ref16 !== void 0 ? _ref16 : null;
483
543
  }
484
544
  if (!usesUnifiedBookingSales && !bookingConfig) throw new Error("预约 Selection Flow 初始化后仍缺少 bookingConfig。");
485
545
  let initialCacheItem = bookingPayload.cacheItem;
@@ -491,10 +551,10 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
491
551
  initialCacheItem = prepareCacheItemForBookingEdit(initialCacheItem);
492
552
  if (isBookingEdit && bookingPayload.orderProduct) initialCacheItem = _objectSpread2(_objectSpread2({}, initialCacheItem), {}, { discount_list: Array.isArray(bookingPayload.orderProduct.discount_list) ? [...bookingPayload.orderProduct.discount_list] : [] });
493
553
  const customerId = resolveBookingEditCustomerId(liveTempOrder, bookingPayload.customerId, (_bookingTicket$getOrd3 = bookingTicket.getOrderCustomerSnapshot) === null || _bookingTicket$getOrd3 === void 0 || (_bookingTicket$getOrd3 = _bookingTicket$getOrd3.call(bookingTicket)) === null || _bookingTicket$getOrd3 === void 0 ? void 0 : _bookingTicket$getOrd3.id);
494
- const resourcesOrigin = (_ref15 = (_bookingTicket$getRes3 = (_bookingTicket$getRes4 = bookingTicket.getResourcesOrigin) === null || _bookingTicket$getRes4 === void 0 ? void 0 : _bookingTicket$getRes4.call(bookingTicket)) !== null && _bookingTicket$getRes3 !== void 0 ? _bookingTicket$getRes3 : initialCacheItem === null || initialCacheItem === void 0 || (_initialCacheItem$_da = initialCacheItem._data) === null || _initialCacheItem$_da === void 0 ? void 0 : _initialCacheItem$_da.resourcesOrigin) !== null && _ref15 !== void 0 ? _ref15 : [];
554
+ const resourcesOrigin = (_ref17 = (_bookingTicket$getRes3 = (_bookingTicket$getRes4 = bookingTicket.getResourcesOrigin) === null || _bookingTicket$getRes4 === void 0 ? void 0 : _bookingTicket$getRes4.call(bookingTicket)) !== null && _bookingTicket$getRes3 !== void 0 ? _bookingTicket$getRes3 : initialCacheItem === null || initialCacheItem === void 0 || (_initialCacheItem$_da = initialCacheItem._data) === null || _initialCacheItem$_da === void 0 ? void 0 : _initialCacheItem$_da.resourcesOrigin) !== null && _ref17 !== void 0 ? _ref17 : [];
495
555
  initialCacheItem = _objectSpread2(_objectSpread2({}, initialCacheItem), {}, { _data: _objectSpread2(_objectSpread2({}, (initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem._data) || {}), {}, { resourcesOrigin }) });
496
556
  bookingInitialCacheItem = initialCacheItem;
497
- holderSource = (_ref16 = (_bookingPayload$catal = bookingPayload.catalogProduct) !== null && _bookingPayload$catal !== void 0 ? _bookingPayload$catal : bookingPayload.sourceProduct) !== null && _ref16 !== void 0 ? _ref16 : initialCacheItem;
557
+ holderSource = (_ref18 = (_bookingPayload$catal = bookingPayload.catalogProduct) !== null && _bookingPayload$catal !== void 0 ? _bookingPayload$catal : bookingPayload.sourceProduct) !== null && _ref18 !== void 0 ? _ref18 : initialCacheItem;
498
558
  if (usesUnifiedBookingSales) holderOptions = getHolderOptionsForSource(holderSource);
499
559
  else try {
500
560
  holderOptions = yield ensureHolderOptionsForSource(holderSource);
@@ -579,7 +639,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
579
639
  });
580
640
  });
581
641
  return function prepareOpen() {
582
- return _ref17.apply(this, arguments);
642
+ return _ref19.apply(this, arguments);
583
643
  };
584
644
  })()().catch((error) => {
585
645
  if (!isCurrentPending()) return;
@@ -629,7 +689,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
629
689
  showHostError
630
690
  ]);
631
691
  const handleConfirm = useMemoizedFn(function() {
632
- var _ref27 = _asyncToGenerator(function* (data) {
692
+ var _ref29 = _asyncToGenerator(function* (data) {
633
693
  const activePending = activePendingRef.current;
634
694
  if (!activePending || bridge.getSnapshot() !== activePending) return false;
635
695
  const completeActive = (result) => {
@@ -640,9 +700,9 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
640
700
  return true;
641
701
  };
642
702
  if (activePending.payload.mode === "create") {
643
- var _ref18, _detailPayload$produc2;
703
+ var _ref20, _detailPayload$produc2;
644
704
  const detailPayload = activePending.payload.requiresDetailPayload;
645
- const item = normalizeCatalogProduct((_ref18 = (_detailPayload$produc2 = detailPayload.productData) !== null && _detailPayload$produc2 !== void 0 ? _detailPayload$produc2 : detailPayload.item) !== null && _ref18 !== void 0 ? _ref18 : {});
705
+ const item = normalizeCatalogProduct((_ref20 = (_detailPayload$produc2 = detailPayload.productData) !== null && _detailPayload$produc2 !== void 0 ? _detailPayload$produc2 : detailPayload.item) !== null && _ref20 !== void 0 ? _ref20 : {});
646
706
  const productId = resolveCatalogProductId(item);
647
707
  if (!productId) {
648
708
  console.warn("[SalesSdk] openNormalProductDetail: 商品缺少有效 id/product_id");
@@ -656,13 +716,13 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
656
716
  let detailResult = transformNormalProductCreateConfirm(productId, data);
657
717
  const holderIds = (_detailResult$detail = detailResult.detail) === null || _detailResult$detail === void 0 || (_detailResult$detail = _detailResult$detail._extend) === null || _detailResult$detail === void 0 ? void 0 : _detailResult$detail.holder_id;
658
718
  if (Array.isArray(holderIds) && holderIds.length > 0 && activeBookingState) {
659
- var _activeBookingState$b, _activeBookingState$c, _ref19, _ref20, _ref21;
719
+ var _activeBookingState$b, _activeBookingState$c, _ref21, _ref22, _ref23;
660
720
  detailResult = _objectSpread2(_objectSpread2({}, detailResult), {}, { detail: applyHolderToCacheItem(detailResult.detail, holderIds, {
661
721
  bookingConfig: (_activeBookingState$b = activeBookingState.bookingConfig) !== null && _activeBookingState$b !== void 0 ? _activeBookingState$b : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingConfig,
662
722
  customerId: (_activeBookingState$c = activeBookingState.client) === null || _activeBookingState$c === void 0 || (_activeBookingState$c = _activeBookingState$c.value) === null || _activeBookingState$c === void 0 ? void 0 : _activeBookingState$c.id,
663
723
  isFranchisee: activeBookingState.isFranchisee,
664
724
  holderOptions: activeHolderOptions,
665
- productSource: (_ref19 = (_ref20 = (_ref21 = data !== null && data !== void 0 ? data : detailResult.detail) !== null && _ref21 !== void 0 ? _ref21 : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref20 !== void 0 ? _ref20 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref19 !== void 0 ? _ref19 : item
725
+ productSource: (_ref21 = (_ref22 = (_ref23 = data !== null && data !== void 0 ? data : detailResult.detail) !== null && _ref23 !== void 0 ? _ref23 : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref22 !== void 0 ? _ref22 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref21 !== void 0 ? _ref21 : item
666
726
  }) });
667
727
  }
668
728
  const availabilitySelection = (_detailResult$detail2 = detailResult.detail) === null || _detailResult$detail2 === void 0 || (_detailResult$detail2 = _detailResult$detail2._extend) === null || _detailResult$detail2 === void 0 ? void 0 : _detailResult$detail2.availabilitySelection;
@@ -687,11 +747,11 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
687
747
  const isBookingEdit = activePending.payload.mode === "booking-edit";
688
748
  const bookingPayload = isBookingEdit ? activePending.payload.bookingEditPayload : activePending.payload.requiresBookingEditPayload;
689
749
  try {
690
- var _hydratedContext$book2, _ref22, _hydratedContext$hold2, _bookingState$booking, _bookingState$client, _ref23, _ref24, _ref25, _ref26, _cacheItem$_extend3;
750
+ var _hydratedContext$book2, _ref24, _hydratedContext$hold2, _bookingState$booking, _bookingState$client, _ref25, _ref26, _ref27, _ref28, _cacheItem$_extend3;
691
751
  if (isBookingEdit && !bookingPayload.deferCommit) assertBookingEditQuantityUnchanged(data);
692
752
  const hydratedContext = (hydratedHolderContext === null || hydratedHolderContext === void 0 ? void 0 : hydratedHolderContext.pending) === activePending ? hydratedHolderContext : null;
693
753
  const bookingState = (_hydratedContext$book2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.bookingState) !== null && _hydratedContext$book2 !== void 0 ? _hydratedContext$book2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingState;
694
- const holderOptions = (_ref22 = (_hydratedContext$hold2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderOptions) !== null && _hydratedContext$hold2 !== void 0 ? _hydratedContext$hold2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderOptions) !== null && _ref22 !== void 0 ? _ref22 : [];
754
+ const holderOptions = (_ref24 = (_hydratedContext$hold2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderOptions) !== null && _hydratedContext$hold2 !== void 0 ? _hydratedContext$hold2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderOptions) !== null && _ref24 !== void 0 ? _ref24 : [];
695
755
  const cacheItem = buildBookingSelectionCacheItem(data, {
696
756
  bookingConfig: (_bookingState$booking = bookingState === null || bookingState === void 0 ? void 0 : bookingState.bookingConfig) !== null && _bookingState$booking !== void 0 ? _bookingState$booking : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingConfig,
697
757
  customerId: bookingState === null || bookingState === void 0 || (_bookingState$client = bookingState.client) === null || _bookingState$client === void 0 || (_bookingState$client = _bookingState$client.value) === null || _bookingState$client === void 0 ? void 0 : _bookingState$client.id,
@@ -699,7 +759,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
699
759
  isPriceIncludeTax: data === null || data === void 0 ? void 0 : data.is_price_include_tax,
700
760
  holderOptions,
701
761
  initialCacheItem: preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.initialCacheItem,
702
- productSource: (_ref23 = (_ref24 = (_ref25 = (_ref26 = data !== null && data !== void 0 ? data : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref26 !== void 0 ? _ref26 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref25 !== void 0 ? _ref25 : bookingPayload.catalogProduct) !== null && _ref24 !== void 0 ? _ref24 : bookingPayload.sourceProduct) !== null && _ref23 !== void 0 ? _ref23 : bookingPayload.cacheItem
762
+ productSource: (_ref25 = (_ref26 = (_ref27 = (_ref28 = data !== null && data !== void 0 ? data : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref28 !== void 0 ? _ref28 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref27 !== void 0 ? _ref27 : bookingPayload.catalogProduct) !== null && _ref26 !== void 0 ? _ref26 : bookingPayload.sourceProduct) !== null && _ref25 !== void 0 ? _ref25 : bookingPayload.cacheItem
703
763
  });
704
764
  cacheItem._holderOptionsSnapshot = holderOptions;
705
765
  const selection = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.availabilitySelection;
@@ -750,8 +810,8 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
750
810
  return false;
751
811
  }
752
812
  });
753
- return function(_x11) {
754
- return _ref27.apply(this, arguments);
813
+ return function(_x14) {
814
+ return _ref29.apply(this, arguments);
755
815
  };
756
816
  }());
757
817
  const handleClose = useMemoizedFn(() => {
@@ -0,0 +1,29 @@
1
+ import dayjs from "dayjs";
2
+ //#region src/plus/salesSdk/normalProductDetail/availabilityContextRouting.ts
3
+ const normalizeDate = (value) => {
4
+ if (value == null || value === "") return void 0;
5
+ const parsed = dayjs(value);
6
+ return parsed.isValid() ? parsed.format("YYYY-MM-DD") : void 0;
7
+ };
8
+ const availabilityDateRangeContains = (coverage, requested) => !dayjs(requested.startDate).isBefore(dayjs(coverage.startDate), "day") && !dayjs(requested.endDate).isAfter(dayjs(coverage.endDate), "day");
9
+ const resolveAvailabilityRequestContextId = (contexts, request, preferredContextId) => {
10
+ var _rangeCandidates$find, _rawDateRange$endDate, _contexts;
11
+ const candidateContextId = (_rangeCandidates$find = [...Array.isArray(request.candidates) ? request.candidates : [], ...Array.isArray(request.selectedRanges) ? request.selectedRanges : []].find((item) => typeof (item === null || item === void 0 ? void 0 : item.availabilityContextId) === "string")) === null || _rangeCandidates$find === void 0 ? void 0 : _rangeCandidates$find.availabilityContextId;
12
+ if (candidateContextId && contexts.some((item) => item.contextId === candidateContextId)) return candidateContextId;
13
+ const rawDateRange = request.dateRange;
14
+ const startDate = normalizeDate(rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.startDate);
15
+ const endDate = normalizeDate((_rawDateRange$endDate = rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.endDate) !== null && _rawDateRange$endDate !== void 0 ? _rawDateRange$endDate : rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.startDate);
16
+ if (startDate && endDate) {
17
+ var _reverse$find;
18
+ const requestedRange = {
19
+ startDate,
20
+ endDate
21
+ };
22
+ const preferred = contexts.find((item) => item.contextId === preferredContextId && availabilityDateRangeContains(item.dateRange, requestedRange));
23
+ if (preferred) return preferred.contextId;
24
+ return (_reverse$find = [...contexts].reverse().find((item) => availabilityDateRangeContains(item.dateRange, requestedRange))) === null || _reverse$find === void 0 ? void 0 : _reverse$find.contextId;
25
+ }
26
+ return contexts.some((item) => item.contextId === preferredContextId) ? preferredContextId || void 0 : (_contexts = contexts[contexts.length - 1]) === null || _contexts === void 0 ? void 0 : _contexts.contextId;
27
+ };
28
+ //#endregion
29
+ export { availabilityDateRangeContains, resolveAvailabilityRequestContextId };
@@ -0,0 +1,71 @@
1
+ import dayjs from "dayjs";
2
+ //#region src/pro/skuDetailModal/flow/modules/date/availabilityWindow.ts
3
+ const AVAILABILITY_RANGE_EDGE_DAYS = 7;
4
+ const AVAILABILITY_RANGE_PRELOAD_DAYS = 28;
5
+ const MAX_AVAILABILITY_RANGE_DAYS = 90;
6
+ const normalizeRange = (range) => {
7
+ const start = dayjs(range.startDate);
8
+ const end = dayjs(range.endDate);
9
+ if (!start.isValid() || !end.isValid()) return null;
10
+ return start.isAfter(end, "day") ? {
11
+ startDate: end.format("YYYY-MM-DD"),
12
+ endDate: start.format("YYYY-MM-DD")
13
+ } : {
14
+ startDate: start.format("YYYY-MM-DD"),
15
+ endDate: end.format("YYYY-MM-DD")
16
+ };
17
+ };
18
+ const resolveAvailabilityDatesCoverage = (dates) => {
19
+ const normalizedDates = (dates || []).map((item) => dayjs(item === null || item === void 0 ? void 0 : item.date)).filter((date) => date.isValid()).sort((left, right) => left.valueOf() - right.valueOf());
20
+ if (normalizedDates.length === 0) return null;
21
+ return {
22
+ startDate: normalizedDates[0].format("YYYY-MM-DD"),
23
+ endDate: normalizedDates[normalizedDates.length - 1].format("YYYY-MM-DD")
24
+ };
25
+ };
26
+ const inclusiveDays = (range) => dayjs(range.endDate).diff(dayjs(range.startDate), "day") + 1;
27
+ /**
28
+ * 日历只在接近当前缓存边缘时向外扩展。能与现有覆盖合并且不超过 UBS
29
+ * 90 天上限时优先扩展;跨度更大时围绕用户正在查看的范围移动窗口。
30
+ */
31
+ const resolveSlidingAvailabilityDateRange = (params) => {
32
+ const visibleRange = normalizeRange(params.visibleRange);
33
+ const coverage = resolveAvailabilityDatesCoverage(params.availabilityDates);
34
+ if (!visibleRange || !coverage) return null;
35
+ const visibleStart = dayjs(visibleRange.startDate);
36
+ const visibleEnd = dayjs(visibleRange.endDate);
37
+ const coverageStart = dayjs(coverage.startDate);
38
+ const coverageEnd = dayjs(coverage.endDate);
39
+ const beforeStart = visibleStart.isBefore(coverageStart, "day");
40
+ const nearEnd = visibleEnd.isAfter(coverageEnd.subtract(AVAILABILITY_RANGE_EDGE_DAYS, "day"), "day");
41
+ if (!beforeStart && !nearEnd) return null;
42
+ const browsingForward = !beforeStart;
43
+ const requestedStart = browsingForward ? coverageStart : visibleStart.subtract(AVAILABILITY_RANGE_PRELOAD_DAYS, "day");
44
+ const requestedEnd = browsingForward ? visibleEnd.add(AVAILABILITY_RANGE_PRELOAD_DAYS, "day") : coverageEnd;
45
+ const mergedRange = normalizeRange({
46
+ startDate: requestedStart.format("YYYY-MM-DD"),
47
+ endDate: requestedEnd.format("YYYY-MM-DD")
48
+ });
49
+ if (inclusiveDays(mergedRange) <= MAX_AVAILABILITY_RANGE_DAYS) return mergedRange;
50
+ if (browsingForward) {
51
+ const endDate = requestedEnd;
52
+ return {
53
+ startDate: endDate.subtract(MAX_AVAILABILITY_RANGE_DAYS - 1, "day").format("YYYY-MM-DD"),
54
+ endDate: endDate.format("YYYY-MM-DD")
55
+ };
56
+ }
57
+ const startDate = requestedStart;
58
+ return {
59
+ startDate: startDate.format("YYYY-MM-DD"),
60
+ endDate: startDate.add(MAX_AVAILABILITY_RANGE_DAYS - 1, "day").format("YYYY-MM-DD")
61
+ };
62
+ };
63
+ const mergeAvailabilityDates = (previousDates, nextDates) => {
64
+ const byDate = /* @__PURE__ */ new Map();
65
+ [...previousDates || [], ...nextDates].forEach((item) => {
66
+ if (typeof (item === null || item === void 0 ? void 0 : item.date) === "string" && dayjs(item.date).isValid()) byDate.set(item.date, item);
67
+ });
68
+ return Array.from(byDate.values()).sort((left, right) => dayjs(left.date).valueOf() - dayjs(right.date).valueOf());
69
+ };
70
+ //#endregion
71
+ export { mergeAvailabilityDates, resolveSlidingAvailabilityDateRange };